]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
5cb5f4d0 | 25 | #include "lib_errors.h" |
ec0ab544 | 26 | #include "lib/zclient.h" |
718e3744 | 27 | #include "prefix.h" |
28 | #include "plist.h" | |
29 | #include "buffer.h" | |
30 | #include "linklist.h" | |
31 | #include "stream.h" | |
32 | #include "thread.h" | |
33 | #include "log.h" | |
3b8b1855 | 34 | #include "memory.h" |
1c0d8808 | 35 | #include "lib_vty.h" |
4bf6a362 | 36 | #include "hash.h" |
3f9c7369 | 37 | #include "queue.h" |
039f3a34 | 38 | #include "filter.h" |
5d5ba018 | 39 | #include "frrstr.h" |
718e3744 | 40 | |
41 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 42 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 43 | #include "bgpd/bgp_advertise.h" |
718e3744 | 44 | #include "bgpd/bgp_attr.h" |
45 | #include "bgpd/bgp_aspath.h" | |
46 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 47 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 48 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 49 | #include "bgpd/bgp_damp.h" |
718e3744 | 50 | #include "bgpd/bgp_debug.h" |
14454c9f | 51 | #include "bgpd/bgp_errors.h" |
e0701b79 | 52 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 53 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 54 | #include "bgpd/bgp_open.h" |
4bf6a362 | 55 | #include "bgpd/bgp_regex.h" |
718e3744 | 56 | #include "bgpd/bgp_route.h" |
c016b6c7 | 57 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 58 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 59 | #include "bgpd/bgp_table.h" |
94f2b392 | 60 | #include "bgpd/bgp_vty.h" |
165b5fff | 61 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 62 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 63 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 64 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 65 | #include "bgpd/bgp_io.h" |
94c2f693 | 66 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 67 | #include "bgpd/bgp_evpn_vty.h" |
b5e140c8 | 68 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 69 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 70 | #include "bgpd/bgp_mac.h" |
dd65f45e | 71 | #include "bgpd/bgp_flowspec.h" |
49e5a4a0 | 72 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
73 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
74 | #endif | |
75 | ||
ff8a8a7a CS |
76 | #include "northbound.h" |
77 | #include "northbound_cli.h" | |
78 | #include "bgpd/bgp_nb.h" | |
79 | ||
80 | ||
5d5393b9 | 81 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
82 | { |
83 | .val_bool = false, | |
84 | .match_profile = "traditional", | |
85 | .match_version = "< 7.4", | |
86 | }, | |
87 | { .val_bool = true }, | |
5d5393b9 DL |
88 | ) |
89 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
4c1458b5 DL |
90 | { .val_bool = true, .match_profile = "datacenter", }, |
91 | { .val_bool = false }, | |
5d5393b9 | 92 | ) |
aef999a2 DA |
93 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
94 | { .val_bool = true, .match_profile = "datacenter", }, | |
95 | { .val_bool = false }, | |
96 | ) | |
5d5393b9 | 97 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
98 | { .val_bool = true, .match_profile = "datacenter", }, |
99 | { .val_bool = false }, | |
5d5393b9 DL |
100 | ) |
101 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
4c1458b5 DL |
102 | { .val_bool = true, .match_profile = "datacenter", }, |
103 | { .val_bool = false }, | |
5d5393b9 DL |
104 | ) |
105 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
106 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
107 | { .val_ulong = 120 }, | |
108 | ) | |
109 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
110 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
111 | { .val_ulong = 180 }, | |
112 | ) | |
113 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
114 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
115 | { .val_ulong = 60 }, | |
116 | ) | |
1d3fdccf DA |
117 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
118 | { .val_bool = false, .match_profile = "datacenter", }, | |
119 | { .val_bool = false, .match_version = "< 7.4", }, | |
120 | { .val_bool = true }, | |
121 | ) | |
5d5393b9 | 122 | |
dd65f45e DL |
123 | DEFINE_HOOK(bgp_inst_config_write, |
124 | (struct bgp *bgp, struct vty *vty), | |
125 | (bgp, vty)) | |
718e3744 | 126 | |
36235319 QY |
127 | #define GR_NO_OPER \ |
128 | "The Graceful Restart No Operation was executed as cmd same as previous one." | |
129 | #define GR_INVALID \ | |
130 | "The Graceful Restart command used is not valid at this moment." | |
d62a17ae | 131 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
132 | struct prefix *range, int exact); | |
133 | ||
055679e9 | 134 | /* Show BGP peer's information. */ |
135 | enum show_type { | |
136 | show_all, | |
137 | show_peer, | |
138 | show_ipv4_all, | |
139 | show_ipv6_all, | |
140 | show_ipv4_peer, | |
141 | show_ipv6_peer | |
142 | }; | |
143 | ||
36235319 QY |
144 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
145 | struct prefix *range, int exact); | |
2986cac2 | 146 | |
36235319 QY |
147 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
148 | struct bgp *bgp, | |
149 | bool use_json, | |
150 | json_object *json); | |
2986cac2 | 151 | |
36235319 QY |
152 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
153 | enum show_type type, | |
154 | const char *ip_str, | |
155 | afi_t afi, bool use_json); | |
2986cac2 | 156 | |
d62a17ae | 157 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
158 | { | |
159 | switch (afi) { | |
160 | case AFI_IP: | |
161 | switch (safi) { | |
162 | case SAFI_UNICAST: | |
163 | return BGP_IPV4_NODE; | |
d62a17ae | 164 | case SAFI_MULTICAST: |
165 | return BGP_IPV4M_NODE; | |
d62a17ae | 166 | case SAFI_LABELED_UNICAST: |
167 | return BGP_IPV4L_NODE; | |
d62a17ae | 168 | case SAFI_MPLS_VPN: |
169 | return BGP_VPNV4_NODE; | |
7c40bf39 | 170 | case SAFI_FLOWSPEC: |
171 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
172 | default: |
173 | /* not expected */ | |
174 | return BGP_IPV4_NODE; | |
d62a17ae | 175 | } |
176 | break; | |
177 | case AFI_IP6: | |
178 | switch (safi) { | |
179 | case SAFI_UNICAST: | |
180 | return BGP_IPV6_NODE; | |
d62a17ae | 181 | case SAFI_MULTICAST: |
182 | return BGP_IPV6M_NODE; | |
d62a17ae | 183 | case SAFI_LABELED_UNICAST: |
184 | return BGP_IPV6L_NODE; | |
d62a17ae | 185 | case SAFI_MPLS_VPN: |
186 | return BGP_VPNV6_NODE; | |
7c40bf39 | 187 | case SAFI_FLOWSPEC: |
188 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
189 | default: |
190 | /* not expected */ | |
191 | return BGP_IPV4_NODE; | |
d62a17ae | 192 | } |
193 | break; | |
194 | case AFI_L2VPN: | |
195 | return BGP_EVPN_NODE; | |
b26f891d | 196 | case AFI_UNSPEC: |
d62a17ae | 197 | case AFI_MAX: |
198 | // We should never be here but to clarify the switch statement.. | |
199 | return BGP_IPV4_NODE; | |
d62a17ae | 200 | } |
201 | ||
202 | // Impossible to happen | |
203 | return BGP_IPV4_NODE; | |
f51bae9c | 204 | } |
20eb8864 | 205 | |
5cb5f4d0 DD |
206 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
207 | { | |
208 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
209 | return "IPv4 Unicast"; | |
210 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
211 | return "IPv4 Multicast"; | |
212 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
213 | return "IPv4 Labeled Unicast"; | |
214 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
215 | return "IPv4 VPN"; | |
216 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
217 | return "IPv4 Encap"; | |
218 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
219 | return "IPv4 Flowspec"; | |
220 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
221 | return "IPv6 Unicast"; | |
222 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
223 | return "IPv6 Multicast"; | |
224 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
225 | return "IPv6 Labeled Unicast"; | |
226 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
227 | return "IPv6 VPN"; | |
228 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
229 | return "IPv6 Encap"; | |
230 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
231 | return "IPv6 Flowspec"; | |
232 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
233 | return "L2VPN EVPN"; | |
8e5509b0 | 234 | else |
5cb5f4d0 | 235 | return "Unknown"; |
5cb5f4d0 DD |
236 | } |
237 | ||
238 | /* | |
239 | * Please note that we have intentionally camelCased | |
240 | * the return strings here. So if you want | |
241 | * to use this function, please ensure you | |
242 | * are doing this within json output | |
243 | */ | |
244 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
245 | { | |
246 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
247 | return "ipv4Unicast"; | |
248 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
249 | return "ipv4Multicast"; | |
250 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
251 | return "ipv4LabeledUnicast"; | |
252 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
253 | return "ipv4Vpn"; | |
254 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
255 | return "ipv4Encap"; | |
256 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
257 | return "ipv4Flowspec"; | |
258 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
259 | return "ipv6Unicast"; | |
260 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
261 | return "ipv6Multicast"; | |
262 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
263 | return "ipv6LabeledUnicast"; | |
264 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
265 | return "ipv6Vpn"; | |
266 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
267 | return "ipv6Encap"; | |
268 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
269 | return "ipv6Flowspec"; | |
270 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
271 | return "l2VpnEvpn"; | |
8e5509b0 | 272 | else |
5cb5f4d0 | 273 | return "Unknown"; |
5cb5f4d0 DD |
274 | } |
275 | ||
718e3744 | 276 | /* Utility function to get address family from current node. */ |
d62a17ae | 277 | afi_t bgp_node_afi(struct vty *vty) |
278 | { | |
279 | afi_t afi; | |
280 | switch (vty->node) { | |
281 | case BGP_IPV6_NODE: | |
282 | case BGP_IPV6M_NODE: | |
283 | case BGP_IPV6L_NODE: | |
284 | case BGP_VPNV6_NODE: | |
7c40bf39 | 285 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 286 | afi = AFI_IP6; |
287 | break; | |
288 | case BGP_EVPN_NODE: | |
289 | afi = AFI_L2VPN; | |
290 | break; | |
291 | default: | |
292 | afi = AFI_IP; | |
293 | break; | |
294 | } | |
295 | return afi; | |
718e3744 | 296 | } |
297 | ||
298 | /* Utility function to get subsequent address family from current | |
299 | node. */ | |
d62a17ae | 300 | safi_t bgp_node_safi(struct vty *vty) |
301 | { | |
302 | safi_t safi; | |
303 | switch (vty->node) { | |
304 | case BGP_VPNV4_NODE: | |
305 | case BGP_VPNV6_NODE: | |
306 | safi = SAFI_MPLS_VPN; | |
307 | break; | |
308 | case BGP_IPV4M_NODE: | |
309 | case BGP_IPV6M_NODE: | |
310 | safi = SAFI_MULTICAST; | |
311 | break; | |
312 | case BGP_EVPN_NODE: | |
313 | safi = SAFI_EVPN; | |
314 | break; | |
315 | case BGP_IPV4L_NODE: | |
316 | case BGP_IPV6L_NODE: | |
317 | safi = SAFI_LABELED_UNICAST; | |
318 | break; | |
7c40bf39 | 319 | case BGP_FLOWSPECV4_NODE: |
320 | case BGP_FLOWSPECV6_NODE: | |
321 | safi = SAFI_FLOWSPEC; | |
322 | break; | |
d62a17ae | 323 | default: |
324 | safi = SAFI_UNICAST; | |
325 | break; | |
326 | } | |
327 | return safi; | |
718e3744 | 328 | } |
329 | ||
55f91488 QY |
330 | /** |
331 | * Converts an AFI in string form to afi_t | |
332 | * | |
333 | * @param afi string, one of | |
334 | * - "ipv4" | |
335 | * - "ipv6" | |
81cf0de5 | 336 | * - "l2vpn" |
55f91488 QY |
337 | * @return the corresponding afi_t |
338 | */ | |
d62a17ae | 339 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
340 | { | |
341 | afi_t afi = AFI_MAX; /* unknown */ | |
342 | if (strmatch(afi_str, "ipv4")) | |
343 | afi = AFI_IP; | |
344 | else if (strmatch(afi_str, "ipv6")) | |
345 | afi = AFI_IP6; | |
81cf0de5 CS |
346 | else if (strmatch(afi_str, "l2vpn")) |
347 | afi = AFI_L2VPN; | |
d62a17ae | 348 | return afi; |
349 | } | |
350 | ||
351 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
352 | afi_t *afi) | |
353 | { | |
354 | int ret = 0; | |
355 | if (argv_find(argv, argc, "ipv4", index)) { | |
356 | ret = 1; | |
357 | if (afi) | |
358 | *afi = AFI_IP; | |
359 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
360 | ret = 1; | |
361 | if (afi) | |
362 | *afi = AFI_IP6; | |
8688b3e7 DS |
363 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
364 | ret = 1; | |
365 | if (afi) | |
366 | *afi = AFI_L2VPN; | |
d62a17ae | 367 | } |
368 | return ret; | |
46f296b4 LB |
369 | } |
370 | ||
375a2e67 | 371 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 372 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
373 | { | |
374 | safi_t safi = SAFI_MAX; /* unknown */ | |
375 | if (strmatch(safi_str, "multicast")) | |
376 | safi = SAFI_MULTICAST; | |
377 | else if (strmatch(safi_str, "unicast")) | |
378 | safi = SAFI_UNICAST; | |
379 | else if (strmatch(safi_str, "vpn")) | |
380 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
381 | else if (strmatch(safi_str, "evpn")) |
382 | safi = SAFI_EVPN; | |
d62a17ae | 383 | else if (strmatch(safi_str, "labeled-unicast")) |
384 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 385 | else if (strmatch(safi_str, "flowspec")) |
386 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 387 | return safi; |
388 | } | |
389 | ||
390 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
391 | safi_t *safi) | |
392 | { | |
393 | int ret = 0; | |
394 | if (argv_find(argv, argc, "unicast", index)) { | |
395 | ret = 1; | |
396 | if (safi) | |
397 | *safi = SAFI_UNICAST; | |
398 | } else if (argv_find(argv, argc, "multicast", index)) { | |
399 | ret = 1; | |
400 | if (safi) | |
401 | *safi = SAFI_MULTICAST; | |
402 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
403 | ret = 1; | |
404 | if (safi) | |
405 | *safi = SAFI_LABELED_UNICAST; | |
406 | } else if (argv_find(argv, argc, "vpn", index)) { | |
407 | ret = 1; | |
408 | if (safi) | |
409 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
410 | } else if (argv_find(argv, argc, "evpn", index)) { |
411 | ret = 1; | |
412 | if (safi) | |
413 | *safi = SAFI_EVPN; | |
7c40bf39 | 414 | } else if (argv_find(argv, argc, "flowspec", index)) { |
415 | ret = 1; | |
416 | if (safi) | |
417 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 418 | } |
419 | return ret; | |
46f296b4 LB |
420 | } |
421 | ||
5d5393b9 DL |
422 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
423 | enum bgp_instance_type inst_type) | |
424 | { | |
425 | int ret = bgp_get(bgp, as, name, inst_type); | |
426 | ||
427 | if (ret == BGP_CREATED) { | |
428 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
429 | DFLT_BGP_CONNECT_RETRY); | |
430 | ||
431 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 432 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 433 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 434 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
435 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
436 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 437 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 438 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 439 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 440 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
441 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
442 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
5d5393b9 DL |
443 | |
444 | ret = BGP_SUCCESS; | |
445 | } | |
446 | return ret; | |
447 | } | |
448 | ||
7eeee51e | 449 | /* |
f212a857 | 450 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 451 | * |
f212a857 DS |
452 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
453 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
454 | * to appropriate values for the calling function. This is to allow the |
455 | * calling function to make decisions appropriate for the show command | |
456 | * that is being parsed. | |
457 | * | |
458 | * The show commands are generally of the form: | |
d62a17ae | 459 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
460 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
461 | * |
462 | * Since we use argv_find if the show command in particular doesn't have: | |
463 | * [ip] | |
18c57037 | 464 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 465 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
466 | * The command parsing should still be ok. |
467 | * | |
468 | * vty -> The vty for the command so we can output some useful data in | |
469 | * the event of a parse error in the vrf. | |
470 | * argv -> The command tokens | |
471 | * argc -> How many command tokens we have | |
d62a17ae | 472 | * idx -> The current place in the command, generally should be 0 for this |
473 | * function | |
7eeee51e DS |
474 | * afi -> The parsed afi if it was included in the show command, returned here |
475 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 476 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 477 | * use_json -> json is configured or not |
7eeee51e DS |
478 | * |
479 | * The function returns the correct location in the parse tree for the | |
480 | * last token found. | |
0e37c258 DS |
481 | * |
482 | * Returns 0 for failure to parse correctly, else the idx position of where | |
483 | * it found the last token. | |
7eeee51e | 484 | */ |
d62a17ae | 485 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
486 | struct cmd_token **argv, int argc, | |
487 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 488 | struct bgp **bgp, bool use_json) |
d62a17ae | 489 | { |
490 | char *vrf_name = NULL; | |
491 | ||
492 | assert(afi); | |
493 | assert(safi); | |
494 | assert(bgp); | |
495 | ||
496 | if (argv_find(argv, argc, "ip", idx)) | |
497 | *afi = AFI_IP; | |
498 | ||
9a8bdf1c | 499 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 500 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
501 | else if (argv_find(argv, argc, "vrf", idx)) { |
502 | vrf_name = argv[*idx + 1]->arg; | |
503 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
504 | vrf_name = NULL; | |
505 | } | |
506 | if (vrf_name) { | |
d62a17ae | 507 | if (strmatch(vrf_name, "all")) |
508 | *bgp = NULL; | |
509 | else { | |
510 | *bgp = bgp_lookup_by_name(vrf_name); | |
511 | if (!*bgp) { | |
52e5b8c4 SP |
512 | if (use_json) { |
513 | json_object *json = NULL; | |
514 | json = json_object_new_object(); | |
515 | json_object_string_add( | |
516 | json, "warning", | |
517 | "View/Vrf is unknown"); | |
518 | vty_out(vty, "%s\n", | |
519 | json_object_to_json_string_ext(json, | |
520 | JSON_C_TO_STRING_PRETTY)); | |
521 | json_object_free(json); | |
522 | } | |
ca61fd25 DS |
523 | else |
524 | vty_out(vty, "View/Vrf %s is unknown\n", | |
525 | vrf_name); | |
d62a17ae | 526 | *idx = 0; |
527 | return 0; | |
528 | } | |
529 | } | |
530 | } else { | |
531 | *bgp = bgp_get_default(); | |
532 | if (!*bgp) { | |
52e5b8c4 SP |
533 | if (use_json) { |
534 | json_object *json = NULL; | |
535 | json = json_object_new_object(); | |
536 | json_object_string_add( | |
537 | json, "warning", | |
538 | "Default BGP instance not found"); | |
539 | vty_out(vty, "%s\n", | |
540 | json_object_to_json_string_ext(json, | |
541 | JSON_C_TO_STRING_PRETTY)); | |
542 | json_object_free(json); | |
543 | } | |
ca61fd25 DS |
544 | else |
545 | vty_out(vty, | |
546 | "Default BGP instance not found\n"); | |
d62a17ae | 547 | *idx = 0; |
548 | return 0; | |
549 | } | |
550 | } | |
551 | ||
552 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
553 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
554 | ||
555 | *idx += 1; | |
556 | return *idx; | |
557 | } | |
558 | ||
3dc339cd | 559 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 560 | { |
561 | struct interface *ifp = NULL; | |
562 | ||
563 | if (su->sa.sa_family == AF_INET) | |
564 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
565 | else if (su->sa.sa_family == AF_INET6) | |
566 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
567 | su->sin6.sin6_scope_id, | |
568 | bgp->vrf_id); | |
569 | ||
570 | if (ifp) | |
3dc339cd | 571 | return true; |
d62a17ae | 572 | |
3dc339cd | 573 | return false; |
718e3744 | 574 | } |
575 | ||
576 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
577 | /* This is used only for configuration, so disallow if attempted on |
578 | * a dynamic neighbor. | |
579 | */ | |
d62a17ae | 580 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
581 | { | |
582 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
583 | int ret; | |
584 | union sockunion su; | |
585 | struct peer *peer; | |
586 | ||
587 | if (!bgp) { | |
588 | return NULL; | |
589 | } | |
590 | ||
591 | ret = str2sockunion(ip_str, &su); | |
592 | if (ret < 0) { | |
593 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
594 | if (!peer) { | |
595 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
596 | == NULL) { | |
597 | vty_out(vty, | |
598 | "%% Malformed address or name: %s\n", | |
599 | ip_str); | |
600 | return NULL; | |
601 | } | |
602 | } | |
603 | } else { | |
604 | peer = peer_lookup(bgp, &su); | |
605 | if (!peer) { | |
606 | vty_out(vty, | |
607 | "%% Specify remote-as or peer-group commands first\n"); | |
608 | return NULL; | |
609 | } | |
610 | if (peer_dynamic_neighbor(peer)) { | |
611 | vty_out(vty, | |
612 | "%% Operation not allowed on a dynamic neighbor\n"); | |
613 | return NULL; | |
614 | } | |
615 | } | |
616 | return peer; | |
718e3744 | 617 | } |
618 | ||
619 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
620 | /* This is used only for configuration, so disallow if attempted on |
621 | * a dynamic neighbor. | |
622 | */ | |
d62a17ae | 623 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
624 | { | |
625 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
626 | int ret; | |
627 | union sockunion su; | |
628 | struct peer *peer = NULL; | |
629 | struct peer_group *group = NULL; | |
630 | ||
631 | if (!bgp) { | |
632 | return NULL; | |
633 | } | |
634 | ||
635 | ret = str2sockunion(peer_str, &su); | |
636 | if (ret == 0) { | |
637 | /* IP address, locate peer. */ | |
638 | peer = peer_lookup(bgp, &su); | |
639 | } else { | |
640 | /* Not IP, could match either peer configured on interface or a | |
641 | * group. */ | |
642 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
643 | if (!peer) | |
644 | group = peer_group_lookup(bgp, peer_str); | |
645 | } | |
646 | ||
647 | if (peer) { | |
648 | if (peer_dynamic_neighbor(peer)) { | |
649 | vty_out(vty, | |
650 | "%% Operation not allowed on a dynamic neighbor\n"); | |
651 | return NULL; | |
652 | } | |
653 | ||
654 | return peer; | |
655 | } | |
656 | ||
657 | if (group) | |
658 | return group->conf; | |
659 | ||
660 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
661 | ||
662 | return NULL; | |
663 | } | |
664 | ||
665 | int bgp_vty_return(struct vty *vty, int ret) | |
666 | { | |
667 | const char *str = NULL; | |
668 | ||
669 | switch (ret) { | |
670 | case BGP_ERR_INVALID_VALUE: | |
671 | str = "Invalid value"; | |
672 | break; | |
673 | case BGP_ERR_INVALID_FLAG: | |
674 | str = "Invalid flag"; | |
675 | break; | |
676 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
677 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
678 | break; | |
679 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
680 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
681 | break; | |
682 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
683 | str = "Specify remote-as or peer-group remote AS first"; | |
684 | break; | |
685 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
686 | str = "Cannot change the peer-group. Deconfigure first"; | |
687 | break; | |
688 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
689 | str = "Peer is not a member of this peer-group"; | |
690 | break; | |
691 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
692 | str = "Prefix/distribute list can not co-exist"; | |
693 | break; | |
694 | case BGP_ERR_NOT_INTERNAL_PEER: | |
695 | str = "Invalid command. Not an internal neighbor"; | |
696 | break; | |
697 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
698 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
699 | break; | |
700 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
701 | str = "Local-AS allowed only for EBGP peers"; | |
702 | break; | |
703 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
704 | str = "Cannot have local-as same as BGP AS number"; | |
705 | break; | |
706 | case BGP_ERR_TCPSIG_FAILED: | |
707 | str = "Error while applying TCP-Sig to session(s)"; | |
708 | break; | |
709 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
710 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
711 | break; | |
712 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
713 | str = "ttl-security only allowed for EBGP peers"; | |
714 | break; | |
715 | case BGP_ERR_AS_OVERRIDE: | |
716 | str = "as-override cannot be configured for IBGP peers"; | |
717 | break; | |
718 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
719 | str = "Invalid limit for number of dynamic neighbors"; | |
720 | break; | |
721 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
722 | str = "Dynamic neighbor listen range already exists"; | |
723 | break; | |
724 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
725 | str = "Operation not allowed on a dynamic neighbor"; | |
726 | break; | |
727 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
728 | str = "Operation not allowed on a directly connected neighbor"; | |
729 | break; | |
730 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 731 | str = GR_INVALID; |
732 | break; | |
733 | case BGP_ERR_GR_INVALID_CMD: | |
734 | str = "The Graceful Restart command used is not valid at this moment."; | |
735 | break; | |
736 | case BGP_ERR_GR_OPERATION_FAILED: | |
737 | str = "The Graceful Restart Operation failed due to an err."; | |
738 | break; | |
739 | case BGP_GR_NO_OPERATION: | |
740 | str = GR_NO_OPER; | |
d62a17ae | 741 | break; |
742 | } | |
743 | if (str) { | |
744 | vty_out(vty, "%% %s\n", str); | |
745 | return CMD_WARNING_CONFIG_FAILED; | |
746 | } | |
747 | return CMD_SUCCESS; | |
718e3744 | 748 | } |
749 | ||
7aafcaca | 750 | /* BGP clear sort. */ |
d62a17ae | 751 | enum clear_sort { |
752 | clear_all, | |
753 | clear_peer, | |
754 | clear_group, | |
755 | clear_external, | |
756 | clear_as | |
7aafcaca DS |
757 | }; |
758 | ||
ff8a8a7a CS |
759 | static void bgp_clear_vty_error(struct peer *peer, afi_t afi, safi_t safi, |
760 | int error, char *errmsg, size_t errmsg_len) | |
d62a17ae | 761 | { |
762 | switch (error) { | |
763 | case BGP_ERR_AF_UNCONFIGURED: | |
ff8a8a7a CS |
764 | snprintf(errmsg, errmsg_len, |
765 | "%%BGP: Enable %s address family for the neighbor %s", | |
766 | get_afi_safi_str(afi, safi, false), peer->host); | |
d62a17ae | 767 | break; |
768 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
ff8a8a7a CS |
769 | snprintf( |
770 | errmsg, errmsg_len, | |
771 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig", | |
d62a17ae | 772 | peer->host); |
773 | break; | |
774 | default: | |
775 | break; | |
776 | } | |
7aafcaca DS |
777 | } |
778 | ||
dc912615 | 779 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 780 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
781 | { |
782 | int ret = 0; | |
783 | ||
784 | /* if afi/.safi not specified, spin thru all of them */ | |
785 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
786 | afi_t tmp_afi; | |
787 | safi_t tmp_safi; | |
788 | ||
789 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
790 | if (!peer->afc[tmp_afi][tmp_safi]) | |
791 | continue; | |
792 | ||
793 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 794 | ret = peer_clear(peer, nnode); |
dc912615 DS |
795 | else |
796 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
797 | stype); | |
798 | } | |
799 | /* if afi specified and safi not, spin thru safis on this afi */ | |
800 | } else if (safi == SAFI_UNSPEC) { | |
801 | safi_t tmp_safi; | |
802 | ||
803 | for (tmp_safi = SAFI_UNICAST; | |
804 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
805 | if (!peer->afc[afi][tmp_safi]) | |
806 | continue; | |
807 | ||
808 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 809 | ret = peer_clear(peer, nnode); |
dc912615 DS |
810 | else |
811 | ret = peer_clear_soft(peer, afi, | |
812 | tmp_safi, stype); | |
813 | } | |
814 | /* both afi/safi specified, let the caller know if not defined */ | |
815 | } else { | |
816 | if (!peer->afc[afi][safi]) | |
817 | return 1; | |
818 | ||
819 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 820 | ret = peer_clear(peer, nnode); |
dc912615 DS |
821 | else |
822 | ret = peer_clear_soft(peer, afi, safi, stype); | |
823 | } | |
824 | ||
825 | return ret; | |
826 | } | |
827 | ||
7aafcaca | 828 | /* `clear ip bgp' functions. */ |
ff8a8a7a | 829 | static int bgp_clear(struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 830 | enum clear_sort sort, enum bgp_clear_type stype, |
ff8a8a7a | 831 | const char *arg, char *errmsg, size_t errmsg_len) |
d62a17ae | 832 | { |
dc912615 | 833 | int ret = 0; |
3ae8bfa5 | 834 | bool found = false; |
d62a17ae | 835 | struct peer *peer; |
dc95985f | 836 | |
837 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 838 | |
839 | /* Clear all neighbors. */ | |
840 | /* | |
841 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
842 | * nodes on the BGP instance as that may get freed if it is a |
843 | * doppelganger | |
d62a17ae | 844 | */ |
845 | if (sort == clear_all) { | |
846 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 847 | |
848 | bgp_peer_gr_flags_update(peer); | |
849 | ||
36235319 | 850 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 851 | gr_router_detected = true; |
852 | ||
c368171c | 853 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 854 | stype); |
d62a17ae | 855 | |
856 | if (ret < 0) | |
ff8a8a7a CS |
857 | bgp_clear_vty_error(peer, afi, safi, ret, |
858 | errmsg, errmsg_len); | |
dc95985f | 859 | } |
860 | ||
36235319 QY |
861 | if (gr_router_detected |
862 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 863 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
864 | } else if (!gr_router_detected |
865 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 866 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 867 | } |
d62a17ae | 868 | |
869 | /* This is to apply read-only mode on this clear. */ | |
870 | if (stype == BGP_CLEAR_SOFT_NONE) | |
871 | bgp->update_delay_over = 0; | |
872 | ||
873 | return CMD_SUCCESS; | |
7aafcaca DS |
874 | } |
875 | ||
3ae8bfa5 | 876 | /* Clear specified neighbor. */ |
d62a17ae | 877 | if (sort == clear_peer) { |
878 | union sockunion su; | |
d62a17ae | 879 | |
880 | /* Make sockunion for lookup. */ | |
881 | ret = str2sockunion(arg, &su); | |
882 | if (ret < 0) { | |
883 | peer = peer_lookup_by_conf_if(bgp, arg); | |
884 | if (!peer) { | |
885 | peer = peer_lookup_by_hostname(bgp, arg); | |
886 | if (!peer) { | |
ff8a8a7a CS |
887 | snprintf( |
888 | errmsg, errmsg_len, | |
889 | "Malformed address or name: %s", | |
d62a17ae | 890 | arg); |
891 | return CMD_WARNING; | |
892 | } | |
893 | } | |
894 | } else { | |
895 | peer = peer_lookup(bgp, &su); | |
896 | if (!peer) { | |
ff8a8a7a CS |
897 | snprintf(errmsg, errmsg_len, |
898 | "%%BGP: Unknown neighbor - \"%s\"", | |
899 | arg); | |
d62a17ae | 900 | return CMD_WARNING; |
901 | } | |
902 | } | |
7aafcaca | 903 | |
dc95985f | 904 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
905 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
906 | ||
dc912615 DS |
907 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
908 | ||
909 | /* if afi/safi not defined for this peer, let caller know */ | |
910 | if (ret == 1) | |
3ae8bfa5 | 911 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 912 | |
d62a17ae | 913 | if (ret < 0) |
ff8a8a7a CS |
914 | bgp_clear_vty_error(peer, afi, safi, ret, errmsg, |
915 | errmsg_len); | |
7aafcaca | 916 | |
d62a17ae | 917 | return CMD_SUCCESS; |
7aafcaca | 918 | } |
7aafcaca | 919 | |
3ae8bfa5 | 920 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 921 | if (sort == clear_group) { |
922 | struct peer_group *group; | |
7aafcaca | 923 | |
d62a17ae | 924 | group = peer_group_lookup(bgp, arg); |
925 | if (!group) { | |
ff8a8a7a CS |
926 | snprintf(errmsg, errmsg_len, |
927 | "%%BGP: No such peer-group %s", arg); | |
d62a17ae | 928 | return CMD_WARNING; |
929 | } | |
930 | ||
931 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 932 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 933 | |
d62a17ae | 934 | if (ret < 0) |
ff8a8a7a CS |
935 | bgp_clear_vty_error(peer, afi, safi, ret, |
936 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
937 | else |
938 | found = true; | |
d62a17ae | 939 | } |
3ae8bfa5 PM |
940 | |
941 | if (!found) | |
ff8a8a7a CS |
942 | snprintf( |
943 | errmsg, errmsg_len, | |
944 | "%%BGP: No %s peer belonging to peer-group %s is configured", | |
5cb5f4d0 | 945 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 946 | |
d62a17ae | 947 | return CMD_SUCCESS; |
7aafcaca | 948 | } |
7aafcaca | 949 | |
3ae8bfa5 | 950 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 951 | if (sort == clear_external) { |
952 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
953 | if (peer->sort == BGP_PEER_IBGP) | |
954 | continue; | |
7aafcaca | 955 | |
dc95985f | 956 | bgp_peer_gr_flags_update(peer); |
957 | ||
36235319 | 958 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 959 | gr_router_detected = true; |
dc95985f | 960 | |
c368171c | 961 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 962 | |
d62a17ae | 963 | if (ret < 0) |
ff8a8a7a CS |
964 | bgp_clear_vty_error(peer, afi, safi, ret, |
965 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
966 | else |
967 | found = true; | |
d62a17ae | 968 | } |
3ae8bfa5 | 969 | |
36235319 QY |
970 | if (gr_router_detected |
971 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 972 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
973 | } else if (!gr_router_detected |
974 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 975 | bgp_zebra_send_capabilities(bgp, true); |
976 | } | |
977 | ||
3ae8bfa5 | 978 | if (!found) |
ff8a8a7a CS |
979 | snprintf(errmsg, errmsg_len, |
980 | "%%BGP: No external %s peer is configured", | |
981 | get_afi_safi_str(afi, safi, false)); | |
3ae8bfa5 | 982 | |
d62a17ae | 983 | return CMD_SUCCESS; |
984 | } | |
985 | ||
3ae8bfa5 | 986 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 987 | if (sort == clear_as) { |
3ae8bfa5 | 988 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 989 | |
990 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
991 | if (peer->as != as) | |
992 | continue; | |
993 | ||
dc95985f | 994 | bgp_peer_gr_flags_update(peer); |
995 | ||
36235319 | 996 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 997 | gr_router_detected = true; |
dc95985f | 998 | |
c368171c | 999 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1000 | |
1001 | if (ret < 0) | |
ff8a8a7a CS |
1002 | bgp_clear_vty_error(peer, afi, safi, ret, |
1003 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1004 | else |
1005 | found = true; | |
d62a17ae | 1006 | } |
3ae8bfa5 | 1007 | |
36235319 QY |
1008 | if (gr_router_detected |
1009 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1010 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1011 | } else if (!gr_router_detected |
1012 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1013 | bgp_zebra_send_capabilities(bgp, true); |
1014 | } | |
1015 | ||
3ae8bfa5 | 1016 | if (!found) |
ff8a8a7a CS |
1017 | snprintf(errmsg, errmsg_len, |
1018 | "%%BGP: No %s peer is configured with AS %s", | |
1019 | get_afi_safi_str(afi, safi, false), arg); | |
3ae8bfa5 | 1020 | |
d62a17ae | 1021 | return CMD_SUCCESS; |
1022 | } | |
1023 | ||
1024 | return CMD_SUCCESS; | |
1025 | } | |
1026 | ||
ff8a8a7a CS |
1027 | static int bgp_clear_vty(const char *name, afi_t afi, safi_t safi, |
1028 | enum clear_sort sort, enum bgp_clear_type stype, | |
1029 | const char *arg, char *errmsg, size_t errmsg_len) | |
d62a17ae | 1030 | { |
1031 | struct bgp *bgp; | |
1032 | ||
1033 | /* BGP structure lookup. */ | |
1034 | if (name) { | |
1035 | bgp = bgp_lookup_by_name(name); | |
1036 | if (bgp == NULL) { | |
ff8a8a7a CS |
1037 | snprintf(errmsg, errmsg_len, |
1038 | "Can't find BGP instance %s", name); | |
d62a17ae | 1039 | return CMD_WARNING; |
1040 | } | |
1041 | } else { | |
1042 | bgp = bgp_get_default(); | |
1043 | if (bgp == NULL) { | |
ff8a8a7a CS |
1044 | snprintf(errmsg, errmsg_len, |
1045 | "No BGP process is configured"); | |
d62a17ae | 1046 | return CMD_WARNING; |
1047 | } | |
1048 | } | |
1049 | ||
ff8a8a7a | 1050 | return bgp_clear(bgp, afi, safi, sort, stype, arg, errmsg, errmsg_len); |
7aafcaca DS |
1051 | } |
1052 | ||
1053 | /* clear soft inbound */ | |
ff8a8a7a | 1054 | int bgp_clear_star_soft_in(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1055 | { |
99b3ebd3 NS |
1056 | afi_t afi; |
1057 | safi_t safi; | |
ff8a8a7a CS |
1058 | int ret; |
1059 | ||
1060 | FOREACH_AFI_SAFI (afi, safi) { | |
1061 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1062 | BGP_CLEAR_SOFT_IN, NULL, errmsg, | |
1063 | errmsg_len); | |
1064 | if (ret != CMD_SUCCESS) | |
1065 | return -1; | |
1066 | } | |
99b3ebd3 | 1067 | |
ff8a8a7a | 1068 | return 0; |
7aafcaca DS |
1069 | } |
1070 | ||
1071 | /* clear soft outbound */ | |
ff8a8a7a | 1072 | int bgp_clear_star_soft_out(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1073 | { |
99b3ebd3 NS |
1074 | afi_t afi; |
1075 | safi_t safi; | |
ff8a8a7a | 1076 | int ret; |
99b3ebd3 | 1077 | |
ff8a8a7a CS |
1078 | FOREACH_AFI_SAFI (afi, safi) { |
1079 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1080 | BGP_CLEAR_SOFT_OUT, NULL, errmsg, | |
1081 | errmsg_len); | |
1082 | if (ret != CMD_SUCCESS) | |
1083 | return -1; | |
1084 | } | |
1085 | ||
1086 | return 0; | |
7aafcaca DS |
1087 | } |
1088 | ||
1089 | ||
f787d7a0 | 1090 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1091 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1092 | #endif |
1093 | ||
8029b216 AK |
1094 | DEFUN_HIDDEN (bgp_local_mac, |
1095 | bgp_local_mac_cmd, | |
093e3f23 | 1096 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1097 | BGP_STR |
1098 | "Local MAC config\n" | |
1099 | "VxLAN Network Identifier\n" | |
1100 | "VNI number\n" | |
1101 | "local mac\n" | |
1102 | "mac address\n" | |
1103 | "mac-mobility sequence\n" | |
1104 | "seq number\n") | |
1105 | { | |
1106 | int rv; | |
1107 | vni_t vni; | |
1108 | struct ethaddr mac; | |
1109 | struct ipaddr ip; | |
1110 | uint32_t seq; | |
1111 | struct bgp *bgp; | |
1112 | ||
1113 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1114 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1115 | vty_out(vty, "%% Malformed MAC address\n"); | |
1116 | return CMD_WARNING; | |
1117 | } | |
1118 | memset(&ip, 0, sizeof(ip)); | |
1119 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1120 | ||
1121 | bgp = bgp_get_default(); | |
1122 | if (!bgp) { | |
1123 | vty_out(vty, "Default BGP instance is not there\n"); | |
1124 | return CMD_WARNING; | |
1125 | } | |
1126 | ||
b5e140c8 AK |
1127 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1128 | zero_esi); | |
8029b216 AK |
1129 | if (rv < 0) { |
1130 | vty_out(vty, "Internal error\n"); | |
1131 | return CMD_WARNING; | |
1132 | } | |
1133 | ||
1134 | return CMD_SUCCESS; | |
1135 | } | |
1136 | ||
1137 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1138 | no_bgp_local_mac_cmd, | |
093e3f23 | 1139 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1140 | NO_STR |
1141 | BGP_STR | |
1142 | "Local MAC config\n" | |
1143 | "VxLAN Network Identifier\n" | |
1144 | "VNI number\n" | |
1145 | "local mac\n" | |
1146 | "mac address\n") | |
1147 | { | |
1148 | int rv; | |
1149 | vni_t vni; | |
1150 | struct ethaddr mac; | |
1151 | struct ipaddr ip; | |
1152 | struct bgp *bgp; | |
1153 | ||
1154 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1155 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1156 | vty_out(vty, "%% Malformed MAC address\n"); | |
1157 | return CMD_WARNING; | |
1158 | } | |
1159 | memset(&ip, 0, sizeof(ip)); | |
1160 | ||
1161 | bgp = bgp_get_default(); | |
1162 | if (!bgp) { | |
1163 | vty_out(vty, "Default BGP instance is not there\n"); | |
1164 | return CMD_WARNING; | |
1165 | } | |
1166 | ||
ec0ab544 | 1167 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1168 | if (rv < 0) { |
1169 | vty_out(vty, "Internal error\n"); | |
1170 | return CMD_WARNING; | |
1171 | } | |
1172 | ||
1173 | return CMD_SUCCESS; | |
1174 | } | |
1175 | ||
718e3744 | 1176 | DEFUN (no_synchronization, |
1177 | no_synchronization_cmd, | |
1178 | "no synchronization", | |
1179 | NO_STR | |
1180 | "Perform IGP synchronization\n") | |
1181 | { | |
d62a17ae | 1182 | return CMD_SUCCESS; |
718e3744 | 1183 | } |
1184 | ||
1185 | DEFUN (no_auto_summary, | |
1186 | no_auto_summary_cmd, | |
1187 | "no auto-summary", | |
1188 | NO_STR | |
1189 | "Enable automatic network number summarization\n") | |
1190 | { | |
d62a17ae | 1191 | return CMD_SUCCESS; |
718e3744 | 1192 | } |
3d515fd9 | 1193 | |
718e3744 | 1194 | /* "router bgp" commands. */ |
ff8a8a7a CS |
1195 | DEFUN_YANG_NOSH(router_bgp, |
1196 | router_bgp_cmd, | |
1197 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1198 | ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1199 | { |
d62a17ae | 1200 | int idx_asn = 2; |
1201 | int idx_view_vrf = 3; | |
1202 | int idx_vrf = 4; | |
ff8a8a7a | 1203 | int ret = CMD_SUCCESS; |
d62a17ae | 1204 | as_t as; |
1205 | struct bgp *bgp; | |
1206 | const char *name = NULL; | |
ff8a8a7a | 1207 | char as_str[12] = {'\0'}; |
d62a17ae | 1208 | enum bgp_instance_type inst_type; |
ff8a8a7a | 1209 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 1210 | |
1211 | // "router bgp" without an ASN | |
1212 | if (argc == 2) { | |
1213 | // Pending: Make VRF option available for ASN less config | |
1214 | bgp = bgp_get_default(); | |
1215 | ||
1216 | if (bgp == NULL) { | |
1217 | vty_out(vty, "%% No BGP process is configured\n"); | |
1218 | return CMD_WARNING_CONFIG_FAILED; | |
1219 | } | |
1220 | ||
1221 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1222 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1223 | return CMD_WARNING_CONFIG_FAILED; |
1224 | } | |
ff8a8a7a CS |
1225 | |
1226 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, | |
5ce106b7 | 1227 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); |
ff8a8a7a CS |
1228 | |
1229 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
1230 | snprintf(as_str, 12, "%d", bgp->as); | |
87ce2564 CS |
1231 | nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY, |
1232 | as_str); | |
ff8a8a7a | 1233 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) { |
87ce2564 CS |
1234 | nb_cli_enqueue_change(vty, |
1235 | "./global/instance-type-view", | |
ff8a8a7a CS |
1236 | NB_OP_MODIFY, "true"); |
1237 | } | |
1238 | ||
a5ab756f | 1239 | nb_cli_pending_commit_check(vty); |
ff8a8a7a CS |
1240 | ret = nb_cli_apply_changes(vty, base_xpath); |
1241 | if (ret == CMD_SUCCESS) { | |
1242 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); | |
1243 | ||
1244 | /* | |
1245 | * For backward compatibility with old commands we still | |
1246 | * need to use the qobj infrastructure. | |
1247 | */ | |
1248 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1249 | } | |
1250 | return ret; | |
d62a17ae | 1251 | } |
1252 | ||
1253 | // "router bgp X" | |
1254 | else { | |
d62a17ae | 1255 | |
ff8a8a7a | 1256 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
d62a17ae | 1257 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1258 | if (argc > 3) { | |
1259 | name = argv[idx_vrf]->arg; | |
1260 | ||
9a8bdf1c PG |
1261 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1262 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1263 | name = NULL; | |
1264 | else | |
1265 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
ff8a8a7a | 1266 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) { |
d62a17ae | 1267 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
ff8a8a7a | 1268 | } |
d62a17ae | 1269 | } |
ff8a8a7a CS |
1270 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1271 | "frr-bgp:bgp", "bgp", name ? name : VRF_DEFAULT_NAME); | |
1272 | ||
1273 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
87ce2564 | 1274 | nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY, |
ff8a8a7a CS |
1275 | argv[idx_asn]->arg); |
1276 | if (inst_type == BGP_INSTANCE_TYPE_VIEW) { | |
87ce2564 CS |
1277 | nb_cli_enqueue_change(vty, |
1278 | "./global/instance-type-view", | |
ff8a8a7a | 1279 | NB_OP_MODIFY, "true"); |
d62a17ae | 1280 | } |
1281 | ||
ff8a8a7a CS |
1282 | nb_cli_pending_commit_check(vty); |
1283 | ret = nb_cli_apply_changes(vty, base_xpath); | |
1284 | if (ret == CMD_SUCCESS) { | |
1285 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); | |
3bd70bf8 | 1286 | |
ff8a8a7a CS |
1287 | /* |
1288 | * For backward compatibility with old commands we still | |
1289 | * need to use the qobj infrastructure. | |
1290 | */ | |
1291 | bgp = bgp_lookup(as, name); | |
1292 | if (bgp) | |
1293 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1294 | } | |
d62a17ae | 1295 | } |
1296 | ||
ff8a8a7a | 1297 | return ret; |
718e3744 | 1298 | } |
1299 | ||
718e3744 | 1300 | /* "no router bgp" commands. */ |
ff8a8a7a CS |
1301 | DEFUN_YANG(no_router_bgp, |
1302 | no_router_bgp_cmd, | |
1303 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1304 | NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1305 | { |
d62a17ae | 1306 | int idx_asn = 3; |
1307 | int idx_vrf = 5; | |
ff8a8a7a | 1308 | as_t as = 0; |
d62a17ae | 1309 | struct bgp *bgp; |
1310 | const char *name = NULL; | |
ff8a8a7a | 1311 | char base_xpath[XPATH_MAXLEN]; |
4b63e358 | 1312 | const struct lyd_node *bgp_glb_dnode; |
718e3744 | 1313 | |
d62a17ae | 1314 | // "no router bgp" without an ASN |
1315 | if (argc == 3) { | |
1316 | // Pending: Make VRF option available for ASN less config | |
4b63e358 CS |
1317 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1318 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); | |
718e3744 | 1319 | |
4b63e358 CS |
1320 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, |
1321 | base_xpath); | |
1322 | if (!bgp_glb_dnode) { | |
d62a17ae | 1323 | vty_out(vty, "%% No BGP process is configured\n"); |
1324 | return CMD_WARNING_CONFIG_FAILED; | |
1325 | } | |
7fb21a9f | 1326 | |
d62a17ae | 1327 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1328 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1329 | return CMD_WARNING_CONFIG_FAILED; |
1330 | } | |
0b5131c9 | 1331 | |
4b63e358 CS |
1332 | /* tcli mode bgp would not be set until apply stage. */ |
1333 | bgp = nb_running_get_entry(bgp_glb_dnode, NULL, false); | |
1334 | if (!bgp) | |
1335 | return CMD_SUCCESS; | |
1336 | ||
0b5131c9 MK |
1337 | if (bgp->l3vni) { |
1338 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1339 | bgp->l3vni); | |
1340 | return CMD_WARNING_CONFIG_FAILED; | |
1341 | } | |
d62a17ae | 1342 | } else { |
1343 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1344 | |
d62a17ae | 1345 | if (argc > 4) |
1346 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1347 | |
d62a17ae | 1348 | /* Lookup bgp structure. */ |
1349 | bgp = bgp_lookup(as, name); | |
1350 | if (!bgp) { | |
1351 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1352 | return CMD_WARNING_CONFIG_FAILED; | |
1353 | } | |
0b5131c9 MK |
1354 | |
1355 | if (bgp->l3vni) { | |
dd5868c2 | 1356 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1357 | bgp->l3vni); |
1358 | return CMD_WARNING_CONFIG_FAILED; | |
1359 | } | |
dd5868c2 DS |
1360 | |
1361 | /* Cannot delete default instance if vrf instances exist */ | |
1362 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1363 | struct listnode *node; | |
1364 | struct bgp *tmp_bgp; | |
1365 | ||
1366 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1367 | if (tmp_bgp->inst_type | |
1368 | == BGP_INSTANCE_TYPE_VRF) { | |
1369 | vty_out(vty, | |
1370 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1371 | return CMD_WARNING_CONFIG_FAILED; | |
1372 | } | |
1373 | } | |
1374 | } | |
d62a17ae | 1375 | } |
ff8a8a7a CS |
1376 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1377 | "frr-bgp:bgp", "bgp", | |
1378 | bgp->name ? bgp->name : VRF_DEFAULT_NAME); | |
718e3744 | 1379 | |
ff8a8a7a | 1380 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); |
718e3744 | 1381 | |
ff8a8a7a | 1382 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 1383 | } |
1384 | ||
ff8a8a7a CS |
1385 | void cli_show_router_bgp(struct vty *vty, struct lyd_node *dnode, |
1386 | bool show_defaults) | |
1387 | { | |
1388 | const struct lyd_node *vrf_dnode; | |
1389 | const char *vrf_name; | |
1390 | as_t as; | |
6b0655a2 | 1391 | |
ff8a8a7a CS |
1392 | vrf_dnode = yang_dnode_get_parent(dnode, "control-plane-protocol"); |
1393 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
5e42cb2f | 1394 | as = yang_dnode_get_uint32(dnode, "./global/local-as"); |
718e3744 | 1395 | |
ff8a8a7a CS |
1396 | vty_out(vty, "!\n"); |
1397 | vty_out(vty, "router bgp %u", as); | |
1398 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
1399 | vty_out(vty, " vrf %s", vrf_name); | |
1400 | vty_out(vty, "\n"); | |
718e3744 | 1401 | } |
1402 | ||
ff8a8a7a CS |
1403 | /* BGP router-id. */ |
1404 | ||
1405 | DEFPY_YANG(bgp_router_id, bgp_router_id_cmd, "bgp router-id A.B.C.D", | |
1406 | BGP_STR | |
1407 | "Override configured router identifier\n" | |
1408 | "Manually configured router identifier\n") | |
718e3744 | 1409 | { |
87ce2564 CS |
1410 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_MODIFY, |
1411 | router_id_str); | |
718e3744 | 1412 | |
ff8a8a7a CS |
1413 | return nb_cli_apply_changes(vty, NULL); |
1414 | } | |
718e3744 | 1415 | |
ff8a8a7a CS |
1416 | DEFPY_YANG(no_bgp_router_id, no_bgp_router_id_cmd, "no bgp router-id [A.B.C.D]", |
1417 | NO_STR BGP_STR | |
1418 | "Override configured router identifier\n" | |
1419 | "Manually configured router identifier\n") | |
1420 | { | |
87ce2564 | 1421 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_DESTROY, |
ff8a8a7a | 1422 | router_id_str ? router_id_str : NULL); |
718e3744 | 1423 | |
ff8a8a7a | 1424 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1425 | } |
1426 | ||
ff8a8a7a CS |
1427 | void cli_show_router_bgp_router_id(struct vty *vty, struct lyd_node *dnode, |
1428 | bool show_defaults) | |
1429 | { | |
1430 | vty_out(vty, " bgp router-id %s\n", yang_dnode_get_string(dnode, NULL)); | |
1431 | } | |
6b0655a2 | 1432 | |
718e3744 | 1433 | /* BGP Cluster ID. */ |
ff8a8a7a CS |
1434 | DEFUN_YANG(bgp_cluster_id, |
1435 | bgp_cluster_id_cmd, | |
1436 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1437 | BGP_STR | |
1438 | "Configure Route-Reflector Cluster-id\n" | |
1439 | "Route-Reflector Cluster-id in IP address format\n" | |
1440 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1441 | { |
d62a17ae | 1442 | int idx_ipv4 = 2; |
718e3744 | 1443 | |
87ce2564 CS |
1444 | nb_cli_enqueue_change( |
1445 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1446 | NB_OP_MODIFY, argv[idx_ipv4]->arg); | |
718e3744 | 1447 | |
ff8a8a7a | 1448 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1449 | } |
1450 | ||
ff8a8a7a CS |
1451 | DEFUN_YANG(no_bgp_cluster_id, |
1452 | no_bgp_cluster_id_cmd, | |
1453 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1454 | NO_STR BGP_STR | |
1455 | "Configure Route-Reflector Cluster-id\n" | |
1456 | "Route-Reflector Cluster-id in IP address format\n" | |
1457 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1458 | { |
87ce2564 CS |
1459 | nb_cli_enqueue_change( |
1460 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1461 | NB_OP_DESTROY, NULL); | |
718e3744 | 1462 | |
ff8a8a7a | 1463 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1464 | } |
1465 | ||
c163f297 DS |
1466 | DEFPY (bgp_norib, |
1467 | bgp_norib_cmd, | |
1468 | "bgp no-rib", | |
1469 | BGP_STR | |
1470 | "Disable BGP route installation to RIB (Zebra)\n") | |
1471 | { | |
1472 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1473 | vty_out(vty, | |
1474 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1475 | return CMD_SUCCESS; | |
1476 | } | |
1477 | ||
1478 | bgp_option_norib_set_runtime(); | |
1479 | ||
1480 | return CMD_SUCCESS; | |
1481 | } | |
1482 | ||
1483 | DEFPY (no_bgp_norib, | |
1484 | no_bgp_norib_cmd, | |
1485 | "no bgp no-rib", | |
1486 | NO_STR | |
1487 | BGP_STR | |
1488 | "Disable BGP route installation to RIB (Zebra)\n") | |
1489 | { | |
1490 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1491 | vty_out(vty, | |
1492 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1493 | return CMD_SUCCESS; | |
1494 | } | |
1495 | ||
1496 | bgp_option_norib_unset_runtime(); | |
1497 | ||
1498 | return CMD_SUCCESS; | |
1499 | } | |
1500 | ||
ff8a8a7a CS |
1501 | DEFUN_YANG(bgp_confederation_identifier, |
1502 | bgp_confederation_identifier_cmd, | |
1503 | "bgp confederation identifier (1-4294967295)", | |
1504 | "BGP specific commands\n" | |
1505 | "AS confederation parameters\n" | |
1506 | "AS number\n" | |
1507 | "Set routing domain confederation AS\n") | |
718e3744 | 1508 | { |
d62a17ae | 1509 | int idx_number = 3; |
718e3744 | 1510 | |
87ce2564 CS |
1511 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1512 | NB_OP_MODIFY, argv[idx_number]->arg); | |
718e3744 | 1513 | |
ff8a8a7a | 1514 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1515 | } |
1516 | ||
ff8a8a7a CS |
1517 | DEFUN_YANG(no_bgp_confederation_identifier, |
1518 | no_bgp_confederation_identifier_cmd, | |
1519 | "no bgp confederation identifier [(1-4294967295)]", | |
1520 | NO_STR | |
1521 | "BGP specific commands\n" | |
1522 | "AS confederation parameters\n" | |
1523 | "AS number\n" | |
1524 | "Set routing domain confederation AS\n") | |
718e3744 | 1525 | { |
87ce2564 CS |
1526 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1527 | NB_OP_DESTROY, NULL); | |
718e3744 | 1528 | |
ff8a8a7a | 1529 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1530 | } |
1531 | ||
ff8a8a7a CS |
1532 | void cli_show_router_bgp_confederation_identifier(struct vty *vty, |
1533 | struct lyd_node *dnode, | |
1534 | bool show_defaults) | |
1535 | { | |
1536 | vty_out(vty, " bgp confederation identifier %u\n", | |
1537 | yang_dnode_get_uint32(dnode, NULL)); | |
1538 | } | |
1539 | ||
1540 | DEFUN_YANG(bgp_confederation_peers, | |
1541 | bgp_confederation_peers_cmd, | |
1542 | "bgp confederation peers (1-4294967295)...", | |
1543 | "BGP specific commands\n" | |
1544 | "AS confederation parameters\n" | |
1545 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1546 | { |
d62a17ae | 1547 | int idx_asn = 3; |
d62a17ae | 1548 | int i; |
718e3744 | 1549 | |
ff8a8a7a | 1550 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1551 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1552 | NB_OP_CREATE, argv[i]->arg); |
718e3744 | 1553 | |
ff8a8a7a | 1554 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1555 | } |
1556 | ||
ff8a8a7a CS |
1557 | DEFUN_YANG(no_bgp_confederation_peers, |
1558 | no_bgp_confederation_peers_cmd, | |
1559 | "no bgp confederation peers (1-4294967295)...", | |
1560 | NO_STR | |
1561 | "BGP specific commands\n" | |
1562 | "AS confederation parameters\n" | |
1563 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1564 | { |
d62a17ae | 1565 | int idx_asn = 4; |
d62a17ae | 1566 | int i; |
718e3744 | 1567 | |
ff8a8a7a | 1568 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1569 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1570 | NB_OP_DESTROY, argv[i]->arg); |
0b2aa3a0 | 1571 | |
ff8a8a7a CS |
1572 | return nb_cli_apply_changes(vty, NULL); |
1573 | } | |
1574 | ||
1575 | void cli_show_router_bgp_confederation_member_as(struct vty *vty, | |
1576 | struct lyd_node *dnode, | |
1577 | bool show_defaults) | |
1578 | { | |
1579 | vty_out(vty, " bgp confederation peers %u \n", | |
1580 | yang_dnode_get_uint32(dnode, NULL)); | |
718e3744 | 1581 | } |
6b0655a2 | 1582 | |
5e242b0d DS |
1583 | /** |
1584 | * Central routine for maximum-paths configuration. | |
1585 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1586 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1587 | */ | |
d62a17ae | 1588 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1589 | const char *mpaths, uint16_t options, |
d62a17ae | 1590 | int set) |
1591 | { | |
1592 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1593 | uint16_t maxpaths = 0; |
d62a17ae | 1594 | int ret; |
1595 | afi_t afi; | |
1596 | safi_t safi; | |
1597 | ||
1598 | afi = bgp_node_afi(vty); | |
1599 | safi = bgp_node_safi(vty); | |
1600 | ||
1601 | if (set) { | |
1602 | maxpaths = strtol(mpaths, NULL, 10); | |
1603 | if (maxpaths > multipath_num) { | |
1604 | vty_out(vty, | |
1605 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1606 | maxpaths, multipath_num); | |
1607 | return CMD_WARNING_CONFIG_FAILED; | |
1608 | } | |
1609 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1610 | options); | |
1611 | } else | |
1612 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1613 | ||
1614 | if (ret < 0) { | |
1615 | vty_out(vty, | |
1616 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1617 | (set == 1) ? "" : "un", | |
1618 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1619 | maxpaths, afi, safi); | |
1620 | return CMD_WARNING_CONFIG_FAILED; | |
1621 | } | |
1622 | ||
1623 | bgp_recalculate_all_bestpaths(bgp); | |
1624 | ||
1625 | return CMD_SUCCESS; | |
165b5fff JB |
1626 | } |
1627 | ||
ff8a8a7a CS |
1628 | void cli_show_router_bgp_med_config(struct vty *vty, struct lyd_node *dnode, |
1629 | bool show_defaults) | |
abc920f8 | 1630 | { |
ff8a8a7a CS |
1631 | if (yang_dnode_get_bool(dnode, "./enable-med-admin")) { |
1632 | uint32_t med_admin_val; | |
abc920f8 | 1633 | |
ff8a8a7a CS |
1634 | vty_out(vty, " bgp max-med administrative"); |
1635 | if ((med_admin_val = | |
1636 | yang_dnode_get_uint32(dnode, "./max-med-admin")) | |
1637 | != BGP_MAXMED_VALUE_DEFAULT) | |
1638 | vty_out(vty, " %u", med_admin_val); | |
1639 | vty_out(vty, "\n"); | |
1640 | } | |
abc920f8 | 1641 | |
ff8a8a7a CS |
1642 | if (yang_dnode_exists(dnode, "./max-med-onstart-up-time")) { |
1643 | uint32_t onstartup_val; | |
abc920f8 | 1644 | |
ff8a8a7a CS |
1645 | vty_out(vty, " bgp max-med on-startup %u", |
1646 | yang_dnode_get_uint32(dnode, | |
1647 | "./max-med-onstart-up-time")); | |
1648 | onstartup_val = yang_dnode_get_uint32( | |
1649 | dnode, "./max-med-onstart-up-value"); | |
1650 | if (onstartup_val != BGP_MAXMED_VALUE_DEFAULT) | |
1651 | vty_out(vty, " %u", onstartup_val); | |
1652 | ||
1653 | vty_out(vty, "\n"); | |
1654 | } | |
abc920f8 DS |
1655 | } |
1656 | ||
ff8a8a7a CS |
1657 | DEFUN_YANG(bgp_maxmed_admin, |
1658 | bgp_maxmed_admin_cmd, | |
1659 | "bgp max-med administrative ", | |
1660 | BGP_STR | |
1661 | "Advertise routes with max-med\n" | |
1662 | "Administratively applied, for an indefinite period\n") | |
1663 | { | |
87ce2564 | 1664 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a CS |
1665 | NB_OP_MODIFY, "true"); |
1666 | ||
1667 | return nb_cli_apply_changes(vty, NULL); | |
1668 | } | |
1669 | ||
1670 | DEFUN_YANG(bgp_maxmed_admin_medv, | |
1671 | bgp_maxmed_admin_medv_cmd, | |
1672 | "bgp max-med administrative (0-4294967295)", | |
1673 | BGP_STR | |
1674 | "Advertise routes with max-med\n" | |
1675 | "Administratively applied, for an indefinite period\n" | |
1676 | "Max MED value to be used\n") | |
abc920f8 | 1677 | { |
d62a17ae | 1678 | int idx_number = 3; |
abc920f8 | 1679 | |
87ce2564 | 1680 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1681 | NB_OP_MODIFY, "true"); |
abc920f8 | 1682 | |
87ce2564 CS |
1683 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1684 | NB_OP_MODIFY, argv[idx_number]->arg); | |
abc920f8 | 1685 | |
ff8a8a7a | 1686 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1687 | } |
1688 | ||
ff8a8a7a CS |
1689 | DEFUN_YANG(no_bgp_maxmed_admin, |
1690 | no_bgp_maxmed_admin_cmd, | |
1691 | "no bgp max-med administrative [(0-4294967295)]", | |
1692 | NO_STR BGP_STR | |
1693 | "Advertise routes with max-med\n" | |
1694 | "Administratively applied, for an indefinite period\n" | |
1695 | "Max MED value to be used\n") | |
abc920f8 | 1696 | { |
87ce2564 | 1697 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1698 | NB_OP_MODIFY, "false"); |
abc920f8 | 1699 | |
87ce2564 CS |
1700 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1701 | NB_OP_MODIFY, NULL); | |
ff8a8a7a CS |
1702 | |
1703 | return nb_cli_apply_changes(vty, NULL); | |
abc920f8 DS |
1704 | } |
1705 | ||
ff8a8a7a CS |
1706 | DEFUN_YANG(bgp_maxmed_onstartup, |
1707 | bgp_maxmed_onstartup_cmd, | |
1708 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
1709 | BGP_STR | |
1710 | "Advertise routes with max-med\n" | |
1711 | "Effective on a startup\n" | |
1712 | "Time (seconds) period for max-med\n" | |
1713 | "Max MED value to be used\n") | |
abc920f8 | 1714 | { |
d62a17ae | 1715 | int idx = 0; |
4668a151 | 1716 | |
d62a17ae | 1717 | argv_find(argv, argc, "(5-86400)", &idx); |
87ce2564 CS |
1718 | nb_cli_enqueue_change(vty, |
1719 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a CS |
1720 | NB_OP_MODIFY, argv[idx]->arg); |
1721 | ||
d62a17ae | 1722 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
87ce2564 CS |
1723 | nb_cli_enqueue_change( |
1724 | vty, "./global/med-config/max-med-onstart-up-value", | |
1725 | NB_OP_MODIFY, argv[idx]->arg); | |
d62a17ae | 1726 | else |
87ce2564 CS |
1727 | nb_cli_enqueue_change( |
1728 | vty, "./global/med-config/max-med-onstart-up-value", | |
1729 | NB_OP_MODIFY, NULL); | |
abc920f8 | 1730 | |
ff8a8a7a | 1731 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1732 | } |
1733 | ||
ff8a8a7a CS |
1734 | DEFUN_YANG(no_bgp_maxmed_onstartup, |
1735 | no_bgp_maxmed_onstartup_cmd, | |
1736 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
1737 | NO_STR BGP_STR | |
1738 | "Advertise routes with max-med\n" | |
1739 | "Effective on a startup\n" | |
1740 | "Time (seconds) period for max-med\n" | |
1741 | "Max MED value to be used\n") | |
abc920f8 | 1742 | { |
87ce2564 CS |
1743 | nb_cli_enqueue_change(vty, |
1744 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a | 1745 | NB_OP_DESTROY, NULL); |
abc920f8 | 1746 | |
87ce2564 CS |
1747 | nb_cli_enqueue_change(vty, |
1748 | "./global/med-config/max-med-onstart-up-value", | |
ff8a8a7a | 1749 | NB_OP_MODIFY, NULL); |
abc920f8 | 1750 | |
ff8a8a7a | 1751 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1752 | } |
1753 | ||
d70583f7 D |
1754 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
1755 | uint16_t update_delay, | |
1756 | uint16_t establish_wait) | |
1757 | { | |
1758 | struct listnode *node, *nnode; | |
1759 | struct bgp *bgp; | |
1760 | bool vrf_cfg = false; | |
1761 | ||
1762 | /* | |
1763 | * See if update-delay is set per-vrf and warn user to delete it | |
1764 | * Note that we only need to check this if this is the first time | |
1765 | * setting the global config. | |
1766 | */ | |
1767 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
1768 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1769 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
1770 | vty_out(vty, | |
1771 | "%% update-delay configuration found in vrf %s\n", | |
1772 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
1773 | ? VRF_DEFAULT_NAME | |
1774 | : bgp->name); | |
1775 | vrf_cfg = true; | |
1776 | } | |
1777 | } | |
1778 | } | |
1779 | ||
1780 | if (vrf_cfg) { | |
1781 | vty_out(vty, | |
1782 | "%%Failed: global update-delay config not permitted\n"); | |
1783 | return CMD_WARNING; | |
1784 | } | |
1785 | ||
1786 | if (!establish_wait) { /* update-delay <delay> */ | |
1787 | bm->v_update_delay = update_delay; | |
1788 | bm->v_establish_wait = bm->v_update_delay; | |
1789 | } else { | |
1790 | /* update-delay <delay> <establish-wait> */ | |
1791 | if (update_delay < establish_wait) { | |
1792 | vty_out(vty, | |
1793 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1794 | return CMD_WARNING_CONFIG_FAILED; | |
1795 | } | |
1796 | ||
1797 | bm->v_update_delay = update_delay; | |
1798 | bm->v_establish_wait = establish_wait; | |
1799 | } | |
1800 | ||
1801 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1802 | bgp->v_update_delay = bm->v_update_delay; | |
1803 | bgp->v_establish_wait = bm->v_establish_wait; | |
1804 | } | |
1805 | ||
1806 | return CMD_SUCCESS; | |
1807 | } | |
1808 | ||
1809 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
1810 | { | |
1811 | struct listnode *node, *nnode; | |
1812 | struct bgp *bgp; | |
1813 | ||
1814 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1815 | bm->v_establish_wait = bm->v_update_delay; | |
1816 | ||
1817 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1818 | bgp->v_update_delay = bm->v_update_delay; | |
1819 | bgp->v_establish_wait = bm->v_establish_wait; | |
1820 | } | |
1821 | ||
1822 | return CMD_SUCCESS; | |
1823 | } | |
1824 | ||
1825 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
1826 | uint16_t establish_wait) | |
f188f2c4 | 1827 | { |
d62a17ae | 1828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1829 | |
d70583f7 D |
1830 | /* if configured globally, per-instance config is not allowed */ |
1831 | if (bm->v_update_delay) { | |
1832 | vty_out(vty, | |
1833 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
1834 | return CMD_WARNING_CONFIG_FAILED; | |
1835 | } | |
1836 | ||
f188f2c4 | 1837 | |
d70583f7 | 1838 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 1839 | { |
1840 | bgp->v_update_delay = update_delay; | |
1841 | bgp->v_establish_wait = bgp->v_update_delay; | |
1842 | return CMD_SUCCESS; | |
1843 | } | |
f188f2c4 | 1844 | |
d62a17ae | 1845 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 1846 | if (update_delay < establish_wait) { |
1847 | vty_out(vty, | |
1848 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1849 | return CMD_WARNING_CONFIG_FAILED; | |
1850 | } | |
f188f2c4 | 1851 | |
d62a17ae | 1852 | bgp->v_update_delay = update_delay; |
1853 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1854 | |
d62a17ae | 1855 | return CMD_SUCCESS; |
f188f2c4 DS |
1856 | } |
1857 | ||
d62a17ae | 1858 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1859 | { |
d62a17ae | 1860 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1861 | |
d70583f7 D |
1862 | /* If configured globally, cannot remove from one bgp instance */ |
1863 | if (bm->v_update_delay) { | |
1864 | vty_out(vty, | |
1865 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
1866 | return CMD_WARNING_CONFIG_FAILED; | |
1867 | } | |
d62a17ae | 1868 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1869 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1870 | |
d62a17ae | 1871 | return CMD_SUCCESS; |
f188f2c4 DS |
1872 | } |
1873 | ||
2b791107 | 1874 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1875 | { |
d70583f7 D |
1876 | /* If configured globally, no need to display per-instance value */ |
1877 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 1878 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
1879 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1880 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1881 | vty_out(vty, "\n"); | |
1882 | } | |
f188f2c4 DS |
1883 | } |
1884 | ||
d70583f7 D |
1885 | /* Global update-delay configuration */ |
1886 | DEFPY (bgp_global_update_delay, | |
1887 | bgp_global_update_delay_cmd, | |
1888 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
1889 | BGP_STR | |
1890 | "Force initial delay for best-path and updates for all bgp instances\n" | |
1891 | "Max delay in seconds\n" | |
1892 | "Establish wait in seconds\n") | |
1893 | { | |
1894 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
1895 | } | |
f188f2c4 | 1896 | |
d70583f7 D |
1897 | /* Global update-delay deconfiguration */ |
1898 | DEFPY (no_bgp_global_update_delay, | |
1899 | no_bgp_global_update_delay_cmd, | |
1900 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
1901 | NO_STR | |
1902 | BGP_STR | |
f188f2c4 | 1903 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
1904 | "Max delay in seconds\n" |
1905 | "Establish wait in seconds\n") | |
f188f2c4 | 1906 | { |
d70583f7 | 1907 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1908 | } |
1909 | ||
d70583f7 D |
1910 | /* Update-delay configuration */ |
1911 | ||
1912 | DEFPY (bgp_update_delay, | |
1913 | bgp_update_delay_cmd, | |
1914 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 1915 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
1916 | "Max delay in seconds\n" |
1917 | "Establish wait in seconds\n") | |
f188f2c4 | 1918 | { |
d70583f7 | 1919 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
1920 | } |
1921 | ||
1922 | /* Update-delay deconfiguration */ | |
d70583f7 | 1923 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 1924 | no_bgp_update_delay_cmd, |
838758ac DW |
1925 | "no update-delay [(0-3600) [(1-3600)]]", |
1926 | NO_STR | |
f188f2c4 | 1927 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
1928 | "Max delay in seconds\n" |
1929 | "Establish wait in seconds\n") | |
f188f2c4 | 1930 | { |
d62a17ae | 1931 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1932 | } |
1933 | ||
5e242b0d | 1934 | |
ff8a8a7a | 1935 | int bgp_wpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
cb1faec9 | 1936 | { |
8fa7732f QY |
1937 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1938 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1939 | |
1940 | return CMD_SUCCESS; | |
1941 | } | |
1942 | ||
ff8a8a7a | 1943 | int bgp_rpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
555e09d4 | 1944 | { |
8fa7732f QY |
1945 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1946 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1947 | |
d62a17ae | 1948 | return CMD_SUCCESS; |
cb1faec9 DS |
1949 | } |
1950 | ||
2b791107 | 1951 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1952 | { |
555e09d4 QY |
1953 | uint32_t quanta = |
1954 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1955 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1956 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1957 | } |
1958 | ||
555e09d4 QY |
1959 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1960 | { | |
1961 | uint32_t quanta = | |
1962 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1963 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1964 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1965 | } |
cb1faec9 | 1966 | |
8fa7732f QY |
1967 | /* Packet quanta configuration |
1968 | * | |
1969 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1970 | * thread. When changing these limits be careful to prevent stack overflow. | |
1971 | * | |
1972 | * Furthermore, the maximums used here should correspond to | |
1973 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1974 | */ | |
ff8a8a7a CS |
1975 | DEFPY_YANG(bgp_wpkt_quanta, |
1976 | bgp_wpkt_quanta_cmd, | |
1977 | "[no] write-quanta (1-64)$quanta", | |
1978 | NO_STR | |
1979 | "How many packets to write to peer socket per run\n" | |
1980 | "Number of packets\n") | |
1981 | { | |
1982 | if (!no) | |
1983 | nb_cli_enqueue_change( | |
1984 | vty, | |
87ce2564 | 1985 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
1986 | NB_OP_MODIFY, quanta_str); |
1987 | else | |
1988 | nb_cli_enqueue_change( | |
1989 | vty, | |
87ce2564 | 1990 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
1991 | NB_OP_MODIFY, NULL); |
1992 | ||
1993 | return nb_cli_apply_changes(vty, NULL); | |
1994 | } | |
1995 | ||
1996 | DEFPY_YANG(bgp_rpkt_quanta, | |
1997 | bgp_rpkt_quanta_cmd, | |
1998 | "[no] read-quanta (1-10)$quanta", | |
1999 | NO_STR | |
2000 | "How many packets to read from peer socket per I/O cycle\n" | |
2001 | "Number of packets\n") | |
2002 | { | |
2003 | if (!no) | |
2004 | nb_cli_enqueue_change( | |
2005 | vty, | |
87ce2564 | 2006 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a CS |
2007 | NB_OP_MODIFY, quanta_str); |
2008 | else | |
2009 | nb_cli_enqueue_change( | |
2010 | vty, | |
87ce2564 | 2011 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a | 2012 | NB_OP_MODIFY, NULL); |
cb1faec9 | 2013 | |
ff8a8a7a | 2014 | return nb_cli_apply_changes(vty, NULL); |
555e09d4 QY |
2015 | } |
2016 | ||
2b791107 | 2017 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2018 | { |
37a333fe | 2019 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2020 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2021 | } |
2022 | ||
ff8a8a7a CS |
2023 | void cli_show_router_global_update_group_config_coalesce_time( |
2024 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3f9c7369 | 2025 | { |
ff8a8a7a CS |
2026 | vty_out(vty, " coalesce-time %u\n", yang_dnode_get_uint32(dnode, NULL)); |
2027 | } | |
2028 | ||
4668a151 | 2029 | |
ff8a8a7a CS |
2030 | DEFUN_YANG(bgp_coalesce_time, |
2031 | bgp_coalesce_time_cmd, | |
2032 | "coalesce-time (0-4294967295)", | |
2033 | "Subgroup coalesce timer\n" | |
2034 | "Subgroup coalesce timer value (in ms)\n") | |
2035 | { | |
d62a17ae | 2036 | int idx = 0; |
ff8a8a7a | 2037 | |
d62a17ae | 2038 | argv_find(argv, argc, "(0-4294967295)", &idx); |
87ce2564 CS |
2039 | nb_cli_enqueue_change( |
2040 | vty, "./global/global-update-group-config/coalesce-time", | |
2041 | NB_OP_MODIFY, argv[idx]->arg); | |
ff8a8a7a CS |
2042 | |
2043 | return nb_cli_apply_changes(vty, NULL); | |
3f9c7369 DS |
2044 | } |
2045 | ||
ff8a8a7a CS |
2046 | DEFUN_YANG(no_bgp_coalesce_time, |
2047 | no_bgp_coalesce_time_cmd, | |
2048 | "no coalesce-time (0-4294967295)", | |
2049 | NO_STR | |
2050 | "Subgroup coalesce timer\n" | |
2051 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2052 | { |
87ce2564 CS |
2053 | nb_cli_enqueue_change( |
2054 | vty, "./global/global-update-group-config/coalesce-time", | |
2055 | NB_OP_MODIFY, NULL); | |
4668a151 | 2056 | |
ff8a8a7a | 2057 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
2058 | } |
2059 | ||
5e242b0d DS |
2060 | /* Maximum-paths configuration */ |
2061 | DEFUN (bgp_maxpaths, | |
2062 | bgp_maxpaths_cmd, | |
6319fd63 | 2063 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
2064 | "Forward packets over multiple paths\n" |
2065 | "Number of paths\n") | |
2066 | { | |
d62a17ae | 2067 | int idx_number = 1; |
2068 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
2069 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
2070 | } |
2071 | ||
d62a17ae | 2072 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2073 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2074 | "Forward packets over multiple paths\n" | |
2075 | "Number of paths\n") | |
596c17ba | 2076 | |
165b5fff JB |
2077 | DEFUN (bgp_maxpaths_ibgp, |
2078 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 2079 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
2080 | "Forward packets over multiple paths\n" |
2081 | "iBGP-multipath\n" | |
2082 | "Number of paths\n") | |
2083 | { | |
d62a17ae | 2084 | int idx_number = 2; |
2085 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
2086 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 2087 | } |
165b5fff | 2088 | |
d62a17ae | 2089 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2090 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2091 | "Forward packets over multiple paths\n" | |
2092 | "iBGP-multipath\n" | |
2093 | "Number of paths\n") | |
596c17ba | 2094 | |
5e242b0d DS |
2095 | DEFUN (bgp_maxpaths_ibgp_cluster, |
2096 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 2097 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
2098 | "Forward packets over multiple paths\n" |
2099 | "iBGP-multipath\n" | |
2100 | "Number of paths\n" | |
2101 | "Match the cluster length\n") | |
2102 | { | |
d62a17ae | 2103 | int idx_number = 2; |
2104 | return bgp_maxpaths_config_vty( | |
2105 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
2106 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
2107 | } |
2108 | ||
d62a17ae | 2109 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2110 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2111 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2112 | "Forward packets over multiple paths\n" | |
2113 | "iBGP-multipath\n" | |
2114 | "Number of paths\n" | |
2115 | "Match the cluster length\n") | |
596c17ba | 2116 | |
165b5fff JB |
2117 | DEFUN (no_bgp_maxpaths, |
2118 | no_bgp_maxpaths_cmd, | |
6319fd63 | 2119 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
2120 | NO_STR |
2121 | "Forward packets over multiple paths\n" | |
2122 | "Number of paths\n") | |
2123 | { | |
d62a17ae | 2124 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
2125 | } |
2126 | ||
d62a17ae | 2127 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2128 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2129 | "Forward packets over multiple paths\n" |
2130 | "Number of paths\n") | |
596c17ba | 2131 | |
165b5fff JB |
2132 | DEFUN (no_bgp_maxpaths_ibgp, |
2133 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 2134 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
2135 | NO_STR |
2136 | "Forward packets over multiple paths\n" | |
2137 | "iBGP-multipath\n" | |
838758ac DW |
2138 | "Number of paths\n" |
2139 | "Match the cluster length\n") | |
165b5fff | 2140 | { |
d62a17ae | 2141 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
2142 | } |
2143 | ||
d62a17ae | 2144 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2145 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2146 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2147 | NO_STR | |
2148 | "Forward packets over multiple paths\n" | |
2149 | "iBGP-multipath\n" | |
2150 | "Number of paths\n" | |
2151 | "Match the cluster length\n") | |
596c17ba | 2152 | |
dd65f45e DL |
2153 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2154 | afi_t afi, safi_t safi) | |
165b5fff | 2155 | { |
d62a17ae | 2156 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 2157 | vty_out(vty, " maximum-paths %d\n", |
2158 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2159 | } | |
165b5fff | 2160 | |
d62a17ae | 2161 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 2162 | vty_out(vty, " maximum-paths ibgp %d", |
2163 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
2164 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
2165 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
2166 | vty_out(vty, " equal-cluster-length"); | |
2167 | vty_out(vty, "\n"); | |
2168 | } | |
165b5fff | 2169 | } |
6b0655a2 | 2170 | |
718e3744 | 2171 | /* BGP timers. */ |
2172 | ||
ff8a8a7a CS |
2173 | DEFUN_YANG(bgp_timers, |
2174 | bgp_timers_cmd, | |
2175 | "timers bgp (0-65535) (0-65535)", | |
2176 | "Adjust routing timers\n" | |
2177 | "BGP timers\n" | |
2178 | "Keepalive interval\n" | |
2179 | "Holdtime\n") | |
718e3744 | 2180 | { |
d62a17ae | 2181 | int idx_number = 2; |
2182 | int idx_number_2 = 3; | |
718e3744 | 2183 | |
87ce2564 | 2184 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2185 | NB_OP_MODIFY, argv[idx_number]->arg); |
87ce2564 | 2186 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2187 | NB_OP_MODIFY, argv[idx_number_2]->arg); |
718e3744 | 2188 | |
ff8a8a7a CS |
2189 | return nb_cli_apply_changes(vty, NULL); |
2190 | } | |
718e3744 | 2191 | |
ff8a8a7a CS |
2192 | DEFUN_YANG(no_bgp_timers, |
2193 | no_bgp_timers_cmd, | |
2194 | "no timers bgp [(0-65535) (0-65535)]", | |
2195 | NO_STR | |
2196 | "Adjust routing timers\n" | |
2197 | "BGP timers\n" | |
2198 | "Keepalive interval\n" | |
2199 | "Holdtime\n") | |
2200 | { | |
87ce2564 | 2201 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2202 | NB_OP_DESTROY, NULL); |
87ce2564 | 2203 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2204 | NB_OP_DESTROY, NULL); |
718e3744 | 2205 | |
ff8a8a7a | 2206 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2207 | } |
2208 | ||
ff8a8a7a CS |
2209 | void cli_show_router_bgp_route_reflector(struct vty *vty, |
2210 | struct lyd_node *dnode, | |
2211 | bool show_defaults) | |
718e3744 | 2212 | { |
ff8a8a7a CS |
2213 | if (yang_dnode_get_bool(dnode, "./no-client-reflect")) |
2214 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
718e3744 | 2215 | |
ff8a8a7a CS |
2216 | if (yang_dnode_get_bool(dnode, "./allow-outbound-policy")) |
2217 | vty_out(vty, " bgp route-reflector allow-outbound-policy\n"); | |
2218 | ||
2219 | if (yang_dnode_exists(dnode, "./route-reflector-cluster-id")) | |
2220 | vty_out(vty, " bgp cluster-id %s\n", | |
2221 | yang_dnode_get_string(dnode, | |
2222 | "./route-reflector-cluster-id")); | |
718e3744 | 2223 | } |
2224 | ||
ff8a8a7a CS |
2225 | DEFUN_YANG(bgp_client_to_client_reflection, |
2226 | bgp_client_to_client_reflection_cmd, | |
2227 | "bgp client-to-client reflection", | |
2228 | "BGP specific commands\n" | |
2229 | "Configure client to client route reflection\n" | |
2230 | "reflection of routes allowed\n") | |
2231 | { | |
87ce2564 | 2232 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2233 | NB_OP_MODIFY, "false"); |
6b0655a2 | 2234 | |
ff8a8a7a CS |
2235 | return nb_cli_apply_changes(vty, NULL); |
2236 | } | |
2237 | ||
2238 | DEFUN_YANG(no_bgp_client_to_client_reflection, | |
2239 | no_bgp_client_to_client_reflection_cmd, | |
2240 | "no bgp client-to-client reflection", | |
2241 | NO_STR | |
2242 | "BGP specific commands\n" | |
2243 | "Configure client to client route reflection\n" | |
2244 | "reflection of routes allowed\n") | |
718e3744 | 2245 | { |
87ce2564 | 2246 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2247 | NB_OP_MODIFY, "true"); |
7aafcaca | 2248 | |
ff8a8a7a | 2249 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2250 | } |
2251 | ||
ff8a8a7a CS |
2252 | void cli_show_router_bgp_route_selection(struct vty *vty, |
2253 | struct lyd_node *dnode, | |
2254 | bool show_defaults) | |
718e3744 | 2255 | { |
7aafcaca | 2256 | |
ff8a8a7a CS |
2257 | if (yang_dnode_get_bool(dnode, "./always-compare-med")) |
2258 | vty_out(vty, " bgp always-compare-med\n"); | |
2259 | ||
2260 | if (yang_dnode_get_bool(dnode, "./ignore-as-path-length")) | |
2261 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
2262 | ||
2263 | if (yang_dnode_get_bool(dnode, "./aspath-confed")) | |
2264 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
2265 | ||
2266 | if (yang_dnode_get_bool(dnode, "./external-compare-router-id")) | |
2267 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
2268 | ||
2269 | if (yang_dnode_get_bool(dnode, "./allow-multiple-as")) { | |
2270 | if (yang_dnode_get_bool(dnode, "./multi-path-as-set")) | |
2271 | vty_out(vty, | |
2272 | " bgp bestpath as-path multipath-relax as-set\n"); | |
2273 | else | |
2274 | vty_out(vty, " bgp bestpath as-path multipath-relax\n"); | |
2275 | } | |
2276 | ||
2277 | if (yang_dnode_get_bool(dnode, "./deterministic-med")) | |
2278 | vty_out(vty, " bgp deterministic-med\n"); | |
2279 | ||
2280 | if (yang_dnode_get_bool(dnode, "./confed-med") | |
2281 | || yang_dnode_get_bool(dnode, "./missing-as-worst-med")) { | |
2282 | vty_out(vty, " bgp bestpath med"); | |
2283 | if (yang_dnode_get_bool(dnode, "./confed-med")) | |
2284 | vty_out(vty, " confed"); | |
2285 | if (yang_dnode_get_bool(dnode, "./missing-as-worst-med")) | |
2286 | vty_out(vty, " missing-as-worst"); | |
2287 | vty_out(vty, "\n"); | |
2288 | } | |
718e3744 | 2289 | } |
2290 | ||
2291 | /* "bgp always-compare-med" configuration. */ | |
ff8a8a7a CS |
2292 | DEFUN_YANG(bgp_always_compare_med, |
2293 | bgp_always_compare_med_cmd, | |
2294 | "bgp always-compare-med", | |
2295 | "BGP specific commands\n" | |
2296 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2297 | { |
87ce2564 CS |
2298 | nb_cli_enqueue_change( |
2299 | vty, "./global/route-selection-options/always-compare-med", | |
2300 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2301 | |
ff8a8a7a | 2302 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2303 | } |
2304 | ||
ff8a8a7a CS |
2305 | DEFUN_YANG(no_bgp_always_compare_med, |
2306 | no_bgp_always_compare_med_cmd, | |
2307 | "no bgp always-compare-med", | |
2308 | NO_STR | |
2309 | "BGP specific commands\n" | |
2310 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2311 | { |
87ce2564 CS |
2312 | nb_cli_enqueue_change( |
2313 | vty, "./global/route-selection-options/always-compare-med", | |
2314 | NB_OP_MODIFY, "false"); | |
7aafcaca | 2315 | |
ff8a8a7a | 2316 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2317 | } |
6b0655a2 | 2318 | |
ff8a8a7a CS |
2319 | DEFUN_YANG(bgp_ebgp_requires_policy, |
2320 | bgp_ebgp_requires_policy_cmd, | |
2321 | "bgp ebgp-requires-policy", | |
2322 | "BGP specific commands\n" | |
2323 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2324 | { | |
87ce2564 CS |
2325 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2326 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
2327 | return nb_cli_apply_changes(vty, NULL); |
2328 | } | |
9dac9fc8 | 2329 | |
ff8a8a7a CS |
2330 | DEFUN_YANG(no_bgp_ebgp_requires_policy, |
2331 | no_bgp_ebgp_requires_policy_cmd, | |
2332 | "no bgp ebgp-requires-policy", | |
2333 | NO_STR | |
2334 | "BGP specific commands\n" | |
2335 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
9dac9fc8 | 2336 | { |
87ce2564 CS |
2337 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2338 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 2339 | return nb_cli_apply_changes(vty, NULL); |
9dac9fc8 DA |
2340 | } |
2341 | ||
ff8a8a7a CS |
2342 | void cli_show_router_bgp_ebgp_requires_policy(struct vty *vty, |
2343 | struct lyd_node *dnode, | |
2344 | bool show_defaults) | |
9dac9fc8 | 2345 | { |
ff8a8a7a CS |
2346 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_EBGP_REQUIRES_POLICY) |
2347 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
9dac9fc8 DA |
2348 | } |
2349 | ||
fb29348a DA |
2350 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2351 | "bgp reject-as-sets", | |
2352 | "BGP specific commands\n" | |
2353 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2354 | { | |
2355 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2356 | struct listnode *node, *nnode; | |
2357 | struct peer *peer; | |
2358 | ||
7f972cd8 | 2359 | bgp->reject_as_sets = true; |
fb29348a DA |
2360 | |
2361 | /* Reset existing BGP sessions to reject routes | |
2362 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2363 | */ | |
2364 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2365 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2366 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2367 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2368 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2369 | } | |
2370 | } | |
2371 | ||
2372 | return CMD_SUCCESS; | |
2373 | } | |
2374 | ||
2375 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2376 | "no bgp reject-as-sets", | |
2377 | NO_STR | |
2378 | "BGP specific commands\n" | |
2379 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2380 | { | |
2381 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2382 | struct listnode *node, *nnode; | |
2383 | struct peer *peer; | |
2384 | ||
7f972cd8 | 2385 | bgp->reject_as_sets = false; |
fb29348a DA |
2386 | |
2387 | /* Reset existing BGP sessions to reject routes | |
2388 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2389 | */ | |
2390 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2391 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2392 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2393 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2394 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2395 | } | |
2396 | } | |
2397 | ||
2398 | return CMD_SUCCESS; | |
2399 | } | |
9dac9fc8 | 2400 | |
718e3744 | 2401 | /* "bgp deterministic-med" configuration. */ |
ff8a8a7a | 2402 | DEFUN_YANG (bgp_deterministic_med, |
718e3744 | 2403 | bgp_deterministic_med_cmd, |
2404 | "bgp deterministic-med", | |
2405 | "BGP specific commands\n" | |
2406 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2407 | { | |
87ce2564 CS |
2408 | nb_cli_enqueue_change( |
2409 | vty, "./global/route-selection-options/deterministic-med", | |
2410 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2411 | |
ff8a8a7a | 2412 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2413 | } |
2414 | ||
ff8a8a7a | 2415 | DEFUN_YANG (no_bgp_deterministic_med, |
718e3744 | 2416 | no_bgp_deterministic_med_cmd, |
2417 | "no bgp deterministic-med", | |
2418 | NO_STR | |
2419 | "BGP specific commands\n" | |
2420 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2421 | { | |
87ce2564 CS |
2422 | nb_cli_enqueue_change( |
2423 | vty, "./global/route-selection-options/deterministic-med", | |
2424 | NB_OP_MODIFY, "false"); | |
d62a17ae | 2425 | |
ff8a8a7a | 2426 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2427 | } |
538621f2 | 2428 | |
055679e9 | 2429 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2430 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2431 | bgp_graceful_restart_cmd, |
2432 | "bgp graceful-restart", | |
2433 | "BGP specific commands\n" | |
2434 | GR_CMD | |
055679e9 | 2435 | ) |
538621f2 | 2436 | { |
055679e9 | 2437 | int ret = BGP_GR_FAILURE; |
2438 | ||
2439 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2440 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2441 | |
d62a17ae | 2442 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2443 | |
2444 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2445 | ||
36235319 QY |
2446 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2447 | ret); | |
5cce3f05 | 2448 | |
055679e9 | 2449 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2450 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2451 | vty_out(vty, |
2452 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2453 | return bgp_vty_return(vty, ret); |
538621f2 | 2454 | } |
2455 | ||
2456 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2457 | no_bgp_graceful_restart_cmd, |
2458 | "no bgp graceful-restart", | |
2459 | NO_STR | |
2460 | "BGP specific commands\n" | |
2461 | NO_GR_CMD | |
055679e9 | 2462 | ) |
538621f2 | 2463 | { |
d62a17ae | 2464 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2465 | |
2466 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2467 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2468 | |
2469 | int ret = BGP_GR_FAILURE; | |
2470 | ||
2471 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2472 | ||
36235319 QY |
2473 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2474 | ret); | |
5cce3f05 | 2475 | |
055679e9 | 2476 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2477 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2478 | vty_out(vty, |
2479 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2480 | |
2481 | return bgp_vty_return(vty, ret); | |
538621f2 | 2482 | } |
2483 | ||
93406d87 | 2484 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2485 | bgp_graceful_restart_stalepath_time_cmd, |
2486 | "bgp graceful-restart stalepath-time (1-4095)", | |
2487 | "BGP specific commands\n" | |
2488 | "Graceful restart capability parameters\n" | |
2489 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2490 | "Delay value (seconds)\n") | |
93406d87 | 2491 | { |
d62a17ae | 2492 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2493 | int idx_number = 3; | |
d7c0a89a | 2494 | uint32_t stalepath; |
93406d87 | 2495 | |
d62a17ae | 2496 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2497 | bgp->stalepath_time = stalepath; | |
2498 | return CMD_SUCCESS; | |
93406d87 | 2499 | } |
2500 | ||
eb6f1b41 | 2501 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2502 | bgp_graceful_restart_restart_time_cmd, |
2503 | "bgp graceful-restart restart-time (1-4095)", | |
2504 | "BGP specific commands\n" | |
2505 | "Graceful restart capability parameters\n" | |
2506 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2507 | "Delay value (seconds)\n") | |
eb6f1b41 | 2508 | { |
d62a17ae | 2509 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2510 | int idx_number = 3; | |
d7c0a89a | 2511 | uint32_t restart; |
eb6f1b41 | 2512 | |
d62a17ae | 2513 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2514 | bgp->restart_time = restart; | |
2515 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2516 | } |
2517 | ||
cfd47646 | 2518 | DEFUN (bgp_graceful_restart_select_defer_time, |
2519 | bgp_graceful_restart_select_defer_time_cmd, | |
2520 | "bgp graceful-restart select-defer-time (0-3600)", | |
2521 | "BGP specific commands\n" | |
2522 | "Graceful restart capability parameters\n" | |
2523 | "Set the time to defer the BGP route selection after restart\n" | |
2524 | "Delay value (seconds, 0 - disable)\n") | |
2525 | { | |
2526 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2527 | int idx_number = 3; | |
2528 | uint32_t defer_time; | |
2529 | ||
2530 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2531 | bgp->select_defer_time = defer_time; | |
2532 | if (defer_time == 0) | |
892fedb6 | 2533 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2534 | else |
892fedb6 | 2535 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2536 | |
2537 | return CMD_SUCCESS; | |
2538 | } | |
2539 | ||
93406d87 | 2540 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2541 | no_bgp_graceful_restart_stalepath_time_cmd, |
2542 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2543 | NO_STR | |
2544 | "BGP specific commands\n" | |
2545 | "Graceful restart capability parameters\n" | |
2546 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2547 | "Delay value (seconds)\n") | |
93406d87 | 2548 | { |
d62a17ae | 2549 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2550 | |
d62a17ae | 2551 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2552 | return CMD_SUCCESS; | |
93406d87 | 2553 | } |
2554 | ||
eb6f1b41 | 2555 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2556 | no_bgp_graceful_restart_restart_time_cmd, |
2557 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2558 | NO_STR | |
2559 | "BGP specific commands\n" | |
2560 | "Graceful restart capability parameters\n" | |
2561 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2562 | "Delay value (seconds)\n") | |
eb6f1b41 | 2563 | { |
d62a17ae | 2564 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2565 | |
d62a17ae | 2566 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2567 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2568 | } |
2569 | ||
cfd47646 | 2570 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2571 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2572 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2573 | NO_STR | |
2574 | "BGP specific commands\n" | |
2575 | "Graceful restart capability parameters\n" | |
2576 | "Set the time to defer the BGP route selection after restart\n" | |
2577 | "Delay value (seconds)\n") | |
2578 | { | |
2579 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2580 | ||
2581 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2582 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2583 | |
2584 | return CMD_SUCCESS; | |
2585 | } | |
2586 | ||
43fc21b3 | 2587 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2588 | bgp_graceful_restart_preserve_fw_cmd, |
2589 | "bgp graceful-restart preserve-fw-state", | |
2590 | "BGP specific commands\n" | |
2591 | "Graceful restart capability parameters\n" | |
2592 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2593 | { |
d62a17ae | 2594 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2595 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2596 | return CMD_SUCCESS; |
43fc21b3 JC |
2597 | } |
2598 | ||
2599 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2600 | no_bgp_graceful_restart_preserve_fw_cmd, |
2601 | "no bgp graceful-restart preserve-fw-state", | |
2602 | NO_STR | |
2603 | "BGP specific commands\n" | |
2604 | "Graceful restart capability parameters\n" | |
2605 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2606 | { |
d62a17ae | 2607 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2608 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2609 | return CMD_SUCCESS; |
43fc21b3 JC |
2610 | } |
2611 | ||
055679e9 | 2612 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2613 | bgp_graceful_restart_disable_cmd, |
2614 | "bgp graceful-restart-disable", | |
2615 | "BGP specific commands\n" | |
2616 | GR_DISABLE) | |
055679e9 | 2617 | { |
2618 | int ret = BGP_GR_FAILURE; | |
2619 | ||
2620 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2621 | zlog_debug( | |
2ba1fe69 | 2622 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2623 | |
055679e9 | 2624 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2625 | ||
2626 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2627 | ||
dc95985f | 2628 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2629 | bgp->peer, ret); | |
5cce3f05 | 2630 | |
055679e9 | 2631 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2632 | zlog_debug( | |
2ba1fe69 | 2633 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2634 | vty_out(vty, |
2635 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2636 | ||
055679e9 | 2637 | return bgp_vty_return(vty, ret); |
2638 | } | |
2639 | ||
2640 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2641 | no_bgp_graceful_restart_disable_cmd, |
2642 | "no bgp graceful-restart-disable", | |
2643 | NO_STR | |
2644 | "BGP specific commands\n" | |
2645 | NO_GR_DISABLE | |
055679e9 | 2646 | ) |
2647 | { | |
2648 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2649 | ||
2650 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2651 | zlog_debug( | |
2ba1fe69 | 2652 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2653 | |
2654 | int ret = BGP_GR_FAILURE; | |
2655 | ||
2656 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2657 | ||
36235319 QY |
2658 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2659 | ret); | |
5cce3f05 | 2660 | |
055679e9 | 2661 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2662 | zlog_debug( | |
2ba1fe69 | 2663 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2664 | vty_out(vty, |
2665 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2666 | |
2667 | return bgp_vty_return(vty, ret); | |
2668 | } | |
2669 | ||
2670 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2671 | bgp_neighbor_graceful_restart_set_cmd, |
2672 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2673 | NEIGHBOR_STR | |
2674 | NEIGHBOR_ADDR_STR2 | |
2675 | GR_NEIGHBOR_CMD | |
055679e9 | 2676 | ) |
2677 | { | |
2678 | int idx_peer = 1; | |
2679 | struct peer *peer; | |
2680 | int ret = BGP_GR_FAILURE; | |
2681 | ||
dc95985f | 2682 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2683 | ||
055679e9 | 2684 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2685 | zlog_debug( | |
2ba1fe69 | 2686 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2687 | |
055679e9 | 2688 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2689 | if (!peer) | |
2690 | return CMD_WARNING_CONFIG_FAILED; | |
2691 | ||
2692 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2693 | ||
dc95985f | 2694 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2695 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2696 | |
2697 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2698 | zlog_debug( | |
2ba1fe69 | 2699 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2700 | vty_out(vty, |
2701 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2702 | |
2703 | return bgp_vty_return(vty, ret); | |
2704 | } | |
2705 | ||
2706 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2707 | no_bgp_neighbor_graceful_restart_set_cmd, |
2708 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2709 | NO_STR | |
2710 | NEIGHBOR_STR | |
2711 | NEIGHBOR_ADDR_STR2 | |
2712 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2713 | ) |
2714 | { | |
2715 | int idx_peer = 2; | |
2716 | int ret = BGP_GR_FAILURE; | |
2717 | struct peer *peer; | |
2718 | ||
dc95985f | 2719 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2720 | ||
055679e9 | 2721 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2722 | if (!peer) | |
2723 | return CMD_WARNING_CONFIG_FAILED; | |
2724 | ||
2725 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2726 | zlog_debug( | |
2ba1fe69 | 2727 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2728 | |
2729 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2730 | ||
dc95985f | 2731 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2732 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2733 | |
2734 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2735 | zlog_debug( | |
2ba1fe69 | 2736 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2737 | vty_out(vty, |
2738 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2739 | |
2740 | return bgp_vty_return(vty, ret); | |
2741 | } | |
2742 | ||
2743 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2744 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2745 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2746 | NEIGHBOR_STR | |
2747 | NEIGHBOR_ADDR_STR2 | |
2748 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2749 | ) |
2750 | { | |
2751 | int idx_peer = 1; | |
2752 | struct peer *peer; | |
2753 | int ret = BGP_GR_FAILURE; | |
2754 | ||
dc95985f | 2755 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2756 | ||
055679e9 | 2757 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2758 | zlog_debug( | |
2ba1fe69 | 2759 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2760 | |
055679e9 | 2761 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2762 | ||
055679e9 | 2763 | if (!peer) |
2764 | return CMD_WARNING_CONFIG_FAILED; | |
2765 | ||
2766 | ||
2767 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2768 | |
dc95985f | 2769 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2770 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2771 | |
055679e9 | 2772 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2773 | zlog_debug( | |
2ba1fe69 | 2774 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2775 | vty_out(vty, |
2776 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2777 | |
2778 | return bgp_vty_return(vty, ret); | |
2779 | } | |
2780 | ||
2781 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2782 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2783 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2784 | NO_STR | |
2785 | NEIGHBOR_STR | |
2786 | NEIGHBOR_ADDR_STR2 | |
2787 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2788 | ) |
2789 | { | |
2790 | int idx_peer = 2; | |
2791 | int ret = BGP_GR_FAILURE; | |
2792 | struct peer *peer; | |
2793 | ||
dc95985f | 2794 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2795 | ||
055679e9 | 2796 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2797 | if (!peer) | |
2798 | return CMD_WARNING_CONFIG_FAILED; | |
2799 | ||
2800 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2801 | zlog_debug( | |
2ba1fe69 | 2802 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2803 | |
36235319 | 2804 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 2805 | |
dc95985f | 2806 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2807 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2808 | |
2809 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2810 | zlog_debug( | |
2ba1fe69 | 2811 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2812 | vty_out(vty, |
2813 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2814 | |
2815 | return bgp_vty_return(vty, ret); | |
2816 | } | |
2817 | ||
2818 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 2819 | bgp_neighbor_graceful_restart_disable_set_cmd, |
2820 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2821 | NEIGHBOR_STR | |
2822 | NEIGHBOR_ADDR_STR2 | |
2823 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2824 | ) |
2825 | { | |
2826 | int idx_peer = 1; | |
2827 | struct peer *peer; | |
2828 | int ret = BGP_GR_FAILURE; | |
2829 | ||
dc95985f | 2830 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2831 | ||
055679e9 | 2832 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2833 | zlog_debug( | |
2ba1fe69 | 2834 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2835 | |
2836 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2837 | if (!peer) | |
2838 | return CMD_WARNING_CONFIG_FAILED; | |
2839 | ||
36235319 | 2840 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 2841 | |
2842 | if (peer->bgp->t_startup) | |
2843 | bgp_peer_gr_flags_update(peer); | |
2844 | ||
dc95985f | 2845 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2846 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2847 | ||
055679e9 | 2848 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2849 | zlog_debug( | |
2ba1fe69 | 2850 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2851 | vty_out(vty, |
2852 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2853 | |
2854 | return bgp_vty_return(vty, ret); | |
2855 | } | |
2856 | ||
2857 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 2858 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
2859 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2860 | NO_STR | |
2861 | NEIGHBOR_STR | |
2862 | NEIGHBOR_ADDR_STR2 | |
2863 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2864 | ) |
2865 | { | |
2866 | int idx_peer = 2; | |
2867 | int ret = BGP_GR_FAILURE; | |
2868 | struct peer *peer; | |
2869 | ||
dc95985f | 2870 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2871 | ||
055679e9 | 2872 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2873 | if (!peer) | |
2874 | return CMD_WARNING_CONFIG_FAILED; | |
2875 | ||
2876 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2877 | zlog_debug( | |
2ba1fe69 | 2878 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2879 | |
2880 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
2881 | ||
dc95985f | 2882 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2883 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2884 | |
2885 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2886 | zlog_debug( | |
2ba1fe69 | 2887 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2888 | vty_out(vty, |
2889 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2890 | |
2891 | return bgp_vty_return(vty, ret); | |
2892 | } | |
2893 | ||
d6e3c15b | 2894 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
2895 | bgp_graceful_restart_disable_eor_cmd, | |
2896 | "bgp graceful-restart disable-eor", | |
2897 | "BGP specific commands\n" | |
2898 | "Graceful restart configuration parameters\n" | |
2899 | "Disable EOR Check\n") | |
2900 | { | |
2901 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2902 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2903 | |
d6e3c15b | 2904 | return CMD_SUCCESS; |
2905 | } | |
2906 | ||
2907 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
2908 | no_bgp_graceful_restart_disable_eor_cmd, | |
2909 | "no bgp graceful-restart disable-eor", | |
2910 | NO_STR | |
2911 | "BGP specific commands\n" | |
2912 | "Graceful restart configuration parameters\n" | |
2913 | "Disable EOR Check\n") | |
2914 | { | |
2915 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2916 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2917 | |
2918 | return CMD_SUCCESS; | |
2919 | } | |
2920 | ||
2921 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
2922 | bgp_graceful_restart_rib_stale_time_cmd, | |
2923 | "bgp graceful-restart rib-stale-time (1-3600)", | |
2924 | "BGP specific commands\n" | |
2925 | "Graceful restart configuration parameters\n" | |
2926 | "Specify the stale route removal timer in rib\n" | |
2927 | "Delay value (seconds)\n") | |
2928 | { | |
2929 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2930 | int idx_number = 3; | |
2931 | uint32_t stale_time; | |
2932 | ||
2933 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2934 | bgp->rib_stale_time = stale_time; | |
2935 | /* Send the stale timer update message to RIB */ | |
2936 | if (bgp_zebra_stale_timer_update(bgp)) | |
2937 | return CMD_WARNING; | |
2938 | ||
2939 | return CMD_SUCCESS; | |
2940 | } | |
2941 | ||
2942 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
2943 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
2944 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
2945 | NO_STR | |
2946 | "BGP specific commands\n" | |
2947 | "Graceful restart configuration parameters\n" | |
2948 | "Specify the stale route removal timer in rib\n" | |
2949 | "Delay value (seconds)\n") | |
2950 | { | |
2951 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2952 | ||
2953 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
2954 | /* Send the stale timer update message to RIB */ | |
2955 | if (bgp_zebra_stale_timer_update(bgp)) | |
2956 | return CMD_WARNING; | |
2957 | ||
d6e3c15b | 2958 | return CMD_SUCCESS; |
2959 | } | |
2960 | ||
ff8a8a7a CS |
2961 | static inline int bgp_initiate_graceful_shut_unshut(struct bgp *bgp, |
2962 | char *errmsg, | |
2963 | size_t errmsg_len) | |
05bd726c | 2964 | { |
2965 | bgp_static_redo_import_check(bgp); | |
2966 | bgp_redistribute_redo(bgp); | |
ff8a8a7a CS |
2967 | if (bgp_clear_star_soft_out(bgp->name, errmsg, errmsg_len) < 0) |
2968 | return -1; | |
2969 | if (bgp_clear_star_soft_in(bgp->name, errmsg, errmsg_len) < 0) | |
2970 | return -1; | |
2971 | ||
2972 | return 0; | |
05bd726c | 2973 | } |
2974 | ||
2975 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
2976 | { | |
2977 | struct listnode *node, *nnode; | |
2978 | struct bgp *bgp; | |
2979 | bool vrf_cfg = false; | |
ff8a8a7a | 2980 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 2981 | |
2982 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
2983 | return CMD_SUCCESS; | |
2984 | ||
2985 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
2986 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2987 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2988 | vty_out(vty, | |
2989 | "%% graceful-shutdown configuration found in vrf %s\n", | |
2990 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
2991 | VRF_DEFAULT_NAME : bgp->name); | |
2992 | vrf_cfg = true; | |
2993 | } | |
2994 | } | |
2995 | ||
2996 | if (vrf_cfg) { | |
2997 | vty_out(vty, | |
2998 | "%%Failed: global graceful-shutdown not permitted\n"); | |
2999 | return CMD_WARNING; | |
3000 | } | |
3001 | ||
3002 | /* Set flag globally */ | |
3003 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3004 | ||
3005 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3006 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3007 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3008 | sizeof(errmsg)) | |
3009 | < 0) | |
3010 | if (strlen(errmsg)) | |
3011 | vty_out(vty, "%s\n", errmsg); | |
3012 | } | |
05bd726c | 3013 | |
3014 | return CMD_SUCCESS; | |
3015 | } | |
3016 | ||
3017 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3018 | { | |
3019 | struct listnode *node, *nnode; | |
3020 | struct bgp *bgp; | |
ff8a8a7a | 3021 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 3022 | |
3023 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3024 | return CMD_SUCCESS; | |
3025 | ||
3026 | /* Unset flag globally */ | |
3027 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3028 | ||
3029 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3030 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3031 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3032 | sizeof(errmsg)) | |
3033 | < 0) | |
3034 | if (strlen(errmsg)) | |
3035 | vty_out(vty, "%s\n", errmsg); | |
3036 | } | |
05bd726c | 3037 | |
3038 | return CMD_SUCCESS; | |
3039 | } | |
3040 | ||
7f323236 DW |
3041 | /* "bgp graceful-shutdown" configuration */ |
3042 | DEFUN (bgp_graceful_shutdown, | |
3043 | bgp_graceful_shutdown_cmd, | |
3044 | "bgp graceful-shutdown", | |
3045 | BGP_STR | |
3046 | "Graceful shutdown parameters\n") | |
3047 | { | |
05bd726c | 3048 | if (vty->node == CONFIG_NODE) |
3049 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3050 | ||
87ce2564 CS |
3051 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3052 | NB_OP_MODIFY, "true"); | |
7f323236 | 3053 | |
ff8a8a7a | 3054 | return nb_cli_apply_changes(vty, NULL); |
7f323236 DW |
3055 | } |
3056 | ||
ff8a8a7a | 3057 | DEFUN_YANG (no_bgp_graceful_shutdown, |
7f323236 DW |
3058 | no_bgp_graceful_shutdown_cmd, |
3059 | "no bgp graceful-shutdown", | |
3060 | NO_STR | |
3061 | BGP_STR | |
3062 | "Graceful shutdown parameters\n") | |
3063 | { | |
05bd726c | 3064 | if (vty->node == CONFIG_NODE) |
3065 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3066 | ||
87ce2564 CS |
3067 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3068 | NB_OP_MODIFY, "false"); | |
05bd726c | 3069 | |
ff8a8a7a CS |
3070 | return nb_cli_apply_changes(vty, NULL); |
3071 | } | |
7f323236 | 3072 | |
ff8a8a7a CS |
3073 | void cli_show_router_bgp_graceful_shutdown(struct vty *vty, |
3074 | struct lyd_node *dnode, | |
3075 | bool show_defaults) | |
3076 | { | |
3077 | if (yang_dnode_get_bool(dnode, NULL)) | |
3078 | vty_out(vty, " bgp graceful-shutdown\n"); | |
7f323236 DW |
3079 | } |
3080 | ||
718e3744 | 3081 | /* "bgp fast-external-failover" configuration. */ |
ff8a8a7a | 3082 | DEFUN_YANG (bgp_fast_external_failover, |
718e3744 | 3083 | bgp_fast_external_failover_cmd, |
3084 | "bgp fast-external-failover", | |
3085 | BGP_STR | |
3086 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3087 | { | |
87ce2564 CS |
3088 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3089 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3090 | |
3091 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 3092 | } |
3093 | ||
ff8a8a7a | 3094 | DEFUN_YANG (no_bgp_fast_external_failover, |
718e3744 | 3095 | no_bgp_fast_external_failover_cmd, |
3096 | "no bgp fast-external-failover", | |
3097 | NO_STR | |
3098 | BGP_STR | |
3099 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3100 | { | |
87ce2564 CS |
3101 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3102 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3103 | |
3104 | return nb_cli_apply_changes(vty, NULL); | |
3105 | } | |
3106 | ||
3107 | void cli_show_router_bgp_fast_external_failover(struct vty *vty, | |
3108 | struct lyd_node *dnode, | |
3109 | bool show_defaults) | |
3110 | { | |
3111 | if (!yang_dnode_get_bool(dnode, NULL)) | |
3112 | vty_out(vty, " no bgp fast-external-failover\n"); | |
718e3744 | 3113 | } |
6b0655a2 | 3114 | |
718e3744 | 3115 | /* "bgp bestpath compare-routerid" configuration. */ |
ff8a8a7a CS |
3116 | DEFUN_YANG(bgp_bestpath_compare_router_id, |
3117 | bgp_bestpath_compare_router_id_cmd, | |
3118 | "bgp bestpath compare-routerid", | |
3119 | "BGP specific commands\n" | |
3120 | "Change the default bestpath selection\n" | |
3121 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3122 | { |
ff8a8a7a | 3123 | nb_cli_enqueue_change( |
87ce2564 CS |
3124 | vty, |
3125 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3126 | NB_OP_MODIFY, "true"); |
7aafcaca | 3127 | |
ff8a8a7a | 3128 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3129 | } |
3130 | ||
ff8a8a7a CS |
3131 | DEFUN_YANG(no_bgp_bestpath_compare_router_id, |
3132 | no_bgp_bestpath_compare_router_id_cmd, | |
3133 | "no bgp bestpath compare-routerid", | |
3134 | NO_STR | |
3135 | "BGP specific commands\n" | |
3136 | "Change the default bestpath selection\n" | |
3137 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3138 | { |
ff8a8a7a | 3139 | nb_cli_enqueue_change( |
87ce2564 CS |
3140 | vty, |
3141 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3142 | NB_OP_MODIFY, "false"); |
7aafcaca | 3143 | |
ff8a8a7a | 3144 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3145 | } |
6b0655a2 | 3146 | |
718e3744 | 3147 | /* "bgp bestpath as-path ignore" configuration. */ |
ff8a8a7a CS |
3148 | DEFUN_YANG(bgp_bestpath_aspath_ignore, |
3149 | bgp_bestpath_aspath_ignore_cmd, | |
3150 | "bgp bestpath as-path ignore", | |
3151 | "BGP specific commands\n" | |
3152 | "Change the default bestpath selection\n" | |
3153 | "AS-path attribute\n" | |
3154 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3155 | { |
87ce2564 CS |
3156 | nb_cli_enqueue_change( |
3157 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3158 | NB_OP_MODIFY, "true"); | |
7aafcaca | 3159 | |
ff8a8a7a | 3160 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3161 | } |
3162 | ||
ff8a8a7a CS |
3163 | DEFUN_YANG(no_bgp_bestpath_aspath_ignore, |
3164 | no_bgp_bestpath_aspath_ignore_cmd, | |
3165 | "no bgp bestpath as-path ignore", | |
3166 | NO_STR | |
3167 | "BGP specific commands\n" | |
3168 | "Change the default bestpath selection\n" | |
3169 | "AS-path attribute\n" | |
3170 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3171 | { |
87ce2564 CS |
3172 | nb_cli_enqueue_change( |
3173 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3174 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3175 | |
ff8a8a7a | 3176 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3177 | } |
6b0655a2 | 3178 | |
6811845b | 3179 | /* "bgp bestpath as-path confed" configuration. */ |
ff8a8a7a | 3180 | DEFUN_YANG (bgp_bestpath_aspath_confed, |
6811845b | 3181 | bgp_bestpath_aspath_confed_cmd, |
3182 | "bgp bestpath as-path confed", | |
3183 | "BGP specific commands\n" | |
3184 | "Change the default bestpath selection\n" | |
3185 | "AS-path attribute\n" | |
3186 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3187 | { | |
87ce2564 CS |
3188 | nb_cli_enqueue_change(vty, |
3189 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3190 | NB_OP_MODIFY, "true"); |
7aafcaca | 3191 | |
ff8a8a7a | 3192 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3193 | } |
3194 | ||
ff8a8a7a | 3195 | DEFUN_YANG (no_bgp_bestpath_aspath_confed, |
6811845b | 3196 | no_bgp_bestpath_aspath_confed_cmd, |
3197 | "no bgp bestpath as-path confed", | |
3198 | NO_STR | |
3199 | "BGP specific commands\n" | |
3200 | "Change the default bestpath selection\n" | |
3201 | "AS-path attribute\n" | |
3202 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3203 | { | |
87ce2564 CS |
3204 | nb_cli_enqueue_change(vty, |
3205 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3206 | NB_OP_MODIFY, "false"); |
7aafcaca | 3207 | |
ff8a8a7a | 3208 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3209 | } |
6b0655a2 | 3210 | |
2fdd455c | 3211 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
ff8a8a7a | 3212 | DEFUN_YANG (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3213 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3214 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3215 | "BGP specific commands\n" |
3216 | "Change the default bestpath selection\n" | |
3217 | "AS-path attribute\n" | |
3218 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3219 | "Generate an AS_SET\n" |
16fc1eec DS |
3220 | "Do not generate an AS_SET\n") |
3221 | { | |
d62a17ae | 3222 | int idx = 0; |
219178b6 | 3223 | |
87ce2564 CS |
3224 | nb_cli_enqueue_change( |
3225 | vty, "./global/route-selection-options/allow-multiple-as", | |
3226 | NB_OP_MODIFY, "true"); | |
d62a17ae | 3227 | if (argv_find(argv, argc, "as-set", &idx)) |
ff8a8a7a | 3228 | nb_cli_enqueue_change( |
87ce2564 CS |
3229 | vty, |
3230 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3231 | NB_OP_MODIFY, "true"); |
d62a17ae | 3232 | else |
ff8a8a7a | 3233 | nb_cli_enqueue_change( |
87ce2564 CS |
3234 | vty, |
3235 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3236 | NB_OP_MODIFY, "false"); |
7aafcaca | 3237 | |
ff8a8a7a | 3238 | return nb_cli_apply_changes(vty, NULL); |
16fc1eec DS |
3239 | } |
3240 | ||
ff8a8a7a | 3241 | DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3242 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3243 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3244 | NO_STR |
3245 | "BGP specific commands\n" | |
3246 | "Change the default bestpath selection\n" | |
3247 | "AS-path attribute\n" | |
3248 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3249 | "Generate an AS_SET\n" |
16fc1eec DS |
3250 | "Do not generate an AS_SET\n") |
3251 | { | |
87ce2564 CS |
3252 | nb_cli_enqueue_change( |
3253 | vty, "./global/route-selection-options/allow-multiple-as", | |
3254 | NB_OP_MODIFY, "false"); | |
3255 | nb_cli_enqueue_change( | |
3256 | vty, "./global/route-selection-options/multi-path-as-set", | |
3257 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3258 | |
ff8a8a7a | 3259 | return nb_cli_apply_changes(vty, NULL); |
2fdd455c | 3260 | } |
6b0655a2 | 3261 | |
848973c7 | 3262 | /* "bgp log-neighbor-changes" configuration. */ |
ff8a8a7a CS |
3263 | DEFUN_YANG(bgp_log_neighbor_changes, |
3264 | bgp_log_neighbor_changes_cmd, | |
3265 | "bgp log-neighbor-changes", | |
3266 | "BGP specific commands\n" | |
3267 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3268 | { |
87ce2564 CS |
3269 | nb_cli_enqueue_change( |
3270 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3271 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3272 | |
3273 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3274 | } |
3275 | ||
ff8a8a7a CS |
3276 | DEFUN_YANG(no_bgp_log_neighbor_changes, |
3277 | no_bgp_log_neighbor_changes_cmd, | |
3278 | "no bgp log-neighbor-changes", | |
3279 | NO_STR | |
3280 | "BGP specific commands\n" | |
3281 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3282 | { |
87ce2564 CS |
3283 | nb_cli_enqueue_change( |
3284 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3285 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3286 | |
3287 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3288 | } |
6b0655a2 | 3289 | |
718e3744 | 3290 | /* "bgp bestpath med" configuration. */ |
ff8a8a7a | 3291 | DEFUN_YANG (bgp_bestpath_med, |
718e3744 | 3292 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3293 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3294 | "BGP specific commands\n" |
3295 | "Change the default bestpath selection\n" | |
3296 | "MED attribute\n" | |
3297 | "Compare MED among confederation paths\n" | |
838758ac DW |
3298 | "Treat missing MED as the least preferred one\n" |
3299 | "Treat missing MED as the least preferred one\n" | |
3300 | "Compare MED among confederation paths\n") | |
718e3744 | 3301 | { |
d62a17ae | 3302 | int idx = 0; |
ff8a8a7a CS |
3303 | bool confed = false; |
3304 | bool worst_med = false; | |
3305 | ||
3306 | ||
d62a17ae | 3307 | if (argv_find(argv, argc, "confed", &idx)) |
ff8a8a7a CS |
3308 | confed = true; |
3309 | ||
87ce2564 CS |
3310 | nb_cli_enqueue_change(vty, |
3311 | "./global/route-selection-options/confed-med", | |
ff8a8a7a CS |
3312 | NB_OP_MODIFY, confed ? "true" : "false"); |
3313 | ||
d62a17ae | 3314 | idx = 0; |
3315 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3316 | worst_med = true; |
e52702f2 | 3317 | |
87ce2564 CS |
3318 | nb_cli_enqueue_change( |
3319 | vty, "./global/route-selection-options/missing-as-worst-med", | |
3320 | NB_OP_MODIFY, worst_med ? "true" : "false"); | |
7aafcaca | 3321 | |
ff8a8a7a | 3322 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3323 | } |
3324 | ||
ff8a8a7a | 3325 | DEFUN_YANG (no_bgp_bestpath_med, |
718e3744 | 3326 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3327 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3328 | NO_STR |
3329 | "BGP specific commands\n" | |
3330 | "Change the default bestpath selection\n" | |
3331 | "MED attribute\n" | |
3332 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3333 | "Treat missing MED as the least preferred one\n" |
3334 | "Treat missing MED as the least preferred one\n" | |
3335 | "Compare MED among confederation paths\n") | |
718e3744 | 3336 | { |
d62a17ae | 3337 | int idx = 0; |
ff8a8a7a | 3338 | |
d62a17ae | 3339 | if (argv_find(argv, argc, "confed", &idx)) |
87ce2564 CS |
3340 | nb_cli_enqueue_change( |
3341 | vty, "./global/route-selection-options/confed-med", | |
3342 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 3343 | |
d62a17ae | 3344 | idx = 0; |
3345 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3346 | nb_cli_enqueue_change( |
87ce2564 CS |
3347 | vty, |
3348 | "./global/route-selection-options/missing-as-worst-med", | |
ff8a8a7a | 3349 | NB_OP_MODIFY, "false"); |
718e3744 | 3350 | |
ff8a8a7a | 3351 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3352 | } |
3353 | ||
f7e1c681 | 3354 | /* "bgp bestpath bandwidth" configuration. */ |
3355 | DEFPY (bgp_bestpath_bw, | |
3356 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3357 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
f7e1c681 | 3358 | "BGP specific commands\n" |
3359 | "Change the default bestpath selection\n" | |
3360 | "Link Bandwidth attribute\n" | |
3361 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3362 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3363 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3364 | { | |
3365 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3366 | afi_t afi; | |
3367 | safi_t safi; | |
3368 | ||
ad36d216 DS |
3369 | if (!bw_cfg) { |
3370 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3371 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3372 | } |
ad36d216 DS |
3373 | if (!strcmp(bw_cfg, "ignore")) |
3374 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3375 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3376 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3377 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3378 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3379 | else | |
3380 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3381 | |
3382 | /* This config is used in route install, so redo that. */ | |
3383 | FOREACH_AFI_SAFI (afi, safi) { | |
3384 | if (!bgp_fibupd_safi(safi)) | |
3385 | continue; | |
3386 | bgp_zebra_announce_table(bgp, afi, safi); | |
3387 | } | |
3388 | ||
3389 | return CMD_SUCCESS; | |
3390 | } | |
3391 | ||
ad36d216 DS |
3392 | DEFPY (no_bgp_bestpath_bw, |
3393 | no_bgp_bestpath_bw_cmd, | |
3394 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3395 | NO_STR | |
3396 | "BGP specific commands\n" | |
3397 | "Change the default bestpath selection\n" | |
3398 | "Link Bandwidth attribute\n" | |
3399 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3400 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3401 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3402 | { | |
3403 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3404 | afi_t afi; | |
3405 | safi_t safi; | |
3406 | ||
3407 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3408 | ||
3409 | /* This config is used in route install, so redo that. */ | |
3410 | FOREACH_AFI_SAFI (afi, safi) { | |
3411 | if (!bgp_fibupd_safi(safi)) | |
3412 | continue; | |
3413 | bgp_zebra_announce_table(bgp, afi, safi); | |
3414 | } | |
3415 | return CMD_SUCCESS; | |
3416 | } | |
3417 | ||
718e3744 | 3418 | /* "no bgp default ipv4-unicast". */ |
3419 | DEFUN (no_bgp_default_ipv4_unicast, | |
3420 | no_bgp_default_ipv4_unicast_cmd, | |
3421 | "no bgp default ipv4-unicast", | |
3422 | NO_STR | |
3423 | "BGP specific commands\n" | |
3424 | "Configure BGP defaults\n" | |
3425 | "Activate ipv4-unicast for a peer by default\n") | |
3426 | { | |
d62a17ae | 3427 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3428 | SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3429 | return CMD_SUCCESS; |
718e3744 | 3430 | } |
3431 | ||
3432 | DEFUN (bgp_default_ipv4_unicast, | |
3433 | bgp_default_ipv4_unicast_cmd, | |
3434 | "bgp default ipv4-unicast", | |
3435 | "BGP specific commands\n" | |
3436 | "Configure BGP defaults\n" | |
3437 | "Activate ipv4-unicast for a peer by default\n") | |
3438 | { | |
d62a17ae | 3439 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3440 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3441 | return CMD_SUCCESS; |
718e3744 | 3442 | } |
6b0655a2 | 3443 | |
04b6bdc0 | 3444 | /* Display hostname in certain command outputs */ |
ff8a8a7a | 3445 | DEFUN_YANG (bgp_default_show_hostname, |
04b6bdc0 DW |
3446 | bgp_default_show_hostname_cmd, |
3447 | "bgp default show-hostname", | |
3448 | "BGP specific commands\n" | |
3449 | "Configure BGP defaults\n" | |
0437e105 | 3450 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3451 | { |
87ce2564 CS |
3452 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3453 | "true"); | |
ff8a8a7a CS |
3454 | |
3455 | return nb_cli_apply_changes(vty, NULL); | |
04b6bdc0 DW |
3456 | } |
3457 | ||
ff8a8a7a CS |
3458 | DEFUN_YANG(no_bgp_default_show_hostname, |
3459 | no_bgp_default_show_hostname_cmd, | |
3460 | "no bgp default show-hostname", | |
3461 | NO_STR | |
3462 | "BGP specific commands\n" | |
3463 | "Configure BGP defaults\n" | |
3464 | "Show hostname in certain command outputs\n") | |
04b6bdc0 | 3465 | { |
87ce2564 CS |
3466 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3467 | "false"); | |
ff8a8a7a CS |
3468 | |
3469 | return nb_cli_apply_changes(vty, NULL); | |
3470 | } | |
3471 | ||
3472 | void cli_show_router_bgp_show_hostname(struct vty *vty, struct lyd_node *dnode, | |
3473 | bool show_defaults) | |
3474 | { | |
3475 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3476 | vty_out(vty, " bgp default show-hostname\n"); | |
04b6bdc0 DW |
3477 | } |
3478 | ||
aef999a2 DA |
3479 | /* Display hostname in certain command outputs */ |
3480 | DEFUN (bgp_default_show_nexthop_hostname, | |
3481 | bgp_default_show_nexthop_hostname_cmd, | |
3482 | "bgp default show-nexthop-hostname", | |
3483 | "BGP specific commands\n" | |
3484 | "Configure BGP defaults\n" | |
3485 | "Show hostname for nexthop in certain command outputs\n") | |
3486 | { | |
87ce2564 CS |
3487 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3488 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3489 | |
3490 | return nb_cli_apply_changes(vty, NULL); | |
aef999a2 DA |
3491 | } |
3492 | ||
3493 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3494 | no_bgp_default_show_nexthop_hostname_cmd, | |
3495 | "no bgp default show-nexthop-hostname", | |
3496 | NO_STR | |
3497 | "BGP specific commands\n" | |
3498 | "Configure BGP defaults\n" | |
3499 | "Show hostname for nexthop in certain command outputs\n") | |
3500 | { | |
87ce2564 CS |
3501 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3502 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3503 | |
3504 | return nb_cli_apply_changes(vty, NULL); | |
3505 | } | |
3506 | ||
3507 | void cli_show_router_bgp_show_nexthop_hostname(struct vty *vty, | |
3508 | struct lyd_node *dnode, | |
3509 | bool show_defaults) | |
3510 | { | |
3511 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3512 | vty_out(vty, " bgp default show-nexthop-hostname\n"); | |
aef999a2 DA |
3513 | } |
3514 | ||
8233ef81 | 3515 | /* "bgp network import-check" configuration. */ |
ff8a8a7a CS |
3516 | DEFUN_YANG(bgp_network_import_check, |
3517 | bgp_network_import_check_cmd, | |
3518 | "bgp network import-check", | |
3519 | "BGP specific commands\n" | |
3520 | "BGP network command\n" | |
3521 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3522 | { |
87ce2564 CS |
3523 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3524 | "true"); | |
078430f6 | 3525 | |
ff8a8a7a | 3526 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3527 | } |
3528 | ||
d62a17ae | 3529 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3530 | "bgp network import-check exact", | |
3531 | "BGP specific commands\n" | |
3532 | "BGP network command\n" | |
3533 | "Check BGP network route exists in IGP\n" | |
3534 | "Match route precisely\n") | |
8233ef81 | 3535 | |
ff8a8a7a CS |
3536 | DEFUN_YANG(no_bgp_network_import_check, |
3537 | no_bgp_network_import_check_cmd, | |
3538 | "no bgp network import-check", | |
3539 | NO_STR | |
3540 | "BGP specific commands\n" | |
3541 | "BGP network command\n" | |
3542 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3543 | { |
87ce2564 CS |
3544 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3545 | "false"); | |
5623e905 | 3546 | |
ff8a8a7a | 3547 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3548 | } |
6b0655a2 | 3549 | |
ff8a8a7a CS |
3550 | void cli_show_router_bgp_import_check(struct vty *vty, struct lyd_node *dnode, |
3551 | bool show_defaults) | |
718e3744 | 3552 | { |
ff8a8a7a CS |
3553 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_IMPORT_CHECK) |
3554 | vty_out(vty, " bgp network import-check\n"); | |
3555 | } | |
718e3744 | 3556 | |
ff8a8a7a CS |
3557 | DEFUN_YANG(bgp_default_local_preference, |
3558 | bgp_default_local_preference_cmd, | |
3559 | "bgp default local-preference (0-4294967295)", | |
3560 | "BGP specific commands\n" | |
3561 | "Configure BGP defaults\n" | |
3562 | "local preference (higher=more preferred)\n" | |
3563 | "Configure default local preference value\n") | |
3564 | { | |
3565 | int idx_number = 3; | |
718e3744 | 3566 | |
87ce2564 | 3567 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, |
ff8a8a7a | 3568 | argv[idx_number]->arg); |
718e3744 | 3569 | |
ff8a8a7a | 3570 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3571 | } |
3572 | ||
ff8a8a7a CS |
3573 | DEFUN_YANG(no_bgp_default_local_preference, |
3574 | no_bgp_default_local_preference_cmd, | |
3575 | "no bgp default local-preference [(0-4294967295)]", | |
3576 | NO_STR | |
3577 | "BGP specific commands\n" | |
3578 | "Configure BGP defaults\n" | |
3579 | "local preference (higher=more preferred)\n" | |
3580 | "Configure default local preference value\n") | |
718e3744 | 3581 | { |
87ce2564 | 3582 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, NULL); |
7aafcaca | 3583 | |
ff8a8a7a | 3584 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3585 | } |
3586 | ||
ff8a8a7a CS |
3587 | void cli_show_router_bgp_local_pref(struct vty *vty, struct lyd_node *dnode, |
3588 | bool show_defaults) | |
3589 | { | |
3590 | vty_out(vty, " bgp default local-preference %u\n", | |
3591 | yang_dnode_get_uint32(dnode, NULL)); | |
3592 | } | |
6b0655a2 | 3593 | |
ff8a8a7a CS |
3594 | |
3595 | DEFUN_YANG(bgp_default_subgroup_pkt_queue_max, | |
3596 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3597 | "bgp default subgroup-pkt-queue-max (20-100)", | |
3598 | "BGP specific commands\n" | |
3599 | "Configure BGP defaults\n" | |
3600 | "subgroup-pkt-queue-max\n" | |
3601 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3602 | { |
d62a17ae | 3603 | int idx_number = 3; |
3f9c7369 | 3604 | |
ff8a8a7a | 3605 | nb_cli_enqueue_change( |
87ce2564 CS |
3606 | vty, |
3607 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a | 3608 | NB_OP_MODIFY, argv[idx_number]->arg); |
3f9c7369 | 3609 | |
ff8a8a7a | 3610 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
3611 | } |
3612 | ||
ff8a8a7a CS |
3613 | DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max, |
3614 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
3615 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
3616 | NO_STR | |
3617 | "BGP specific commands\n" | |
3618 | "Configure BGP defaults\n" | |
3619 | "subgroup-pkt-queue-max\n" | |
3620 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3621 | { |
ff8a8a7a | 3622 | nb_cli_enqueue_change( |
87ce2564 CS |
3623 | vty, |
3624 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a CS |
3625 | NB_OP_MODIFY, NULL); |
3626 | ||
3627 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
3628 | } |
3629 | ||
ff8a8a7a CS |
3630 | void cli_show_router_global_update_group_config_subgroup_pkt_queue_size( |
3631 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3632 | { | |
3633 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
3634 | yang_dnode_get_uint32(dnode, NULL)); | |
3635 | } | |
813d4307 | 3636 | |
ff8a8a7a CS |
3637 | DEFUN_YANG(bgp_rr_allow_outbound_policy, |
3638 | bgp_rr_allow_outbound_policy_cmd, | |
3639 | "bgp route-reflector allow-outbound-policy", | |
3640 | "BGP specific commands\n" | |
3641 | "Allow modifications made by out route-map\n" | |
3642 | "on ibgp neighbors\n") | |
8bd9d948 | 3643 | { |
87ce2564 CS |
3644 | nb_cli_enqueue_change(vty, |
3645 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a | 3646 | NB_OP_MODIFY, "true"); |
8bd9d948 | 3647 | |
ff8a8a7a CS |
3648 | return nb_cli_apply_changes(vty, NULL); |
3649 | } | |
8bd9d948 | 3650 | |
ff8a8a7a CS |
3651 | DEFUN_YANG(no_bgp_rr_allow_outbound_policy, |
3652 | no_bgp_rr_allow_outbound_policy_cmd, | |
3653 | "no bgp route-reflector allow-outbound-policy", | |
3654 | NO_STR | |
3655 | "BGP specific commands\n" | |
3656 | "Allow modifications made by out route-map\n" | |
3657 | "on ibgp neighbors\n") | |
3658 | { | |
87ce2564 CS |
3659 | nb_cli_enqueue_change(vty, |
3660 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a CS |
3661 | NB_OP_MODIFY, "false"); |
3662 | ||
3663 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
3664 | } |
3665 | ||
ff8a8a7a CS |
3666 | |
3667 | void cli_show_router_global_neighbor_config(struct vty *vty, | |
3668 | struct lyd_node *dnode, | |
3669 | bool show_defaults) | |
8bd9d948 | 3670 | { |
ff8a8a7a CS |
3671 | uint32_t write_quanta, read_quanta; |
3672 | ||
3673 | if (yang_dnode_get_bool(dnode, "./log-neighbor-changes")) | |
3674 | vty_out(vty, " bgp log-neighbor-changes\n"); | |
8bd9d948 | 3675 | |
ff8a8a7a CS |
3676 | if (yang_dnode_exists(dnode, "./dynamic-neighbors-limit")) { |
3677 | uint32_t listen_limit = yang_dnode_get_uint32( | |
3678 | dnode, "./dynamic-neighbors-limit"); | |
3679 | vty_out(vty, " bgp listen limit %u\n", listen_limit); | |
d62a17ae | 3680 | } |
8bd9d948 | 3681 | |
ff8a8a7a CS |
3682 | write_quanta = yang_dnode_get_uint32( |
3683 | dnode, "./packet-quanta-config/wpkt-quanta"); | |
3684 | if (write_quanta != BGP_WRITE_PACKET_MAX) | |
3685 | vty_out(vty, " write-quanta %d\n", write_quanta); | |
3686 | ||
3687 | read_quanta = yang_dnode_get_uint32( | |
3688 | dnode, "./packet-quanta-config/rpkt-quanta"); | |
3689 | ||
3690 | if (read_quanta != BGP_READ_PACKET_MAX) | |
3691 | vty_out(vty, " read-quanta %d\n", read_quanta); | |
8bd9d948 DS |
3692 | } |
3693 | ||
ff8a8a7a CS |
3694 | DEFUN_YANG(bgp_listen_limit, |
3695 | bgp_listen_limit_cmd, | |
3696 | "bgp listen limit (1-5000)", | |
3697 | "BGP specific commands\n" | |
3698 | "BGP Dynamic Neighbors listen commands\n" | |
3699 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3700 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3701 | { |
d62a17ae | 3702 | int idx_number = 3; |
f14e6fdb | 3703 | |
ff8a8a7a | 3704 | nb_cli_enqueue_change( |
87ce2564 | 3705 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a | 3706 | NB_OP_MODIFY, argv[idx_number]->arg); |
f14e6fdb | 3707 | |
ff8a8a7a | 3708 | return nb_cli_apply_changes(vty, NULL); |
f14e6fdb DS |
3709 | } |
3710 | ||
ff8a8a7a CS |
3711 | DEFUN_YANG(no_bgp_listen_limit, |
3712 | no_bgp_listen_limit_cmd, | |
3713 | "no bgp listen limit [(1-5000)]", | |
3714 | NO_STR | |
3715 | "BGP specific commands\n" | |
3716 | "BGP Dynamic Neighbors listen commands\n" | |
3717 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3718 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3719 | { |
ff8a8a7a | 3720 | nb_cli_enqueue_change( |
87ce2564 | 3721 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a CS |
3722 | NB_OP_DESTROY, NULL); |
3723 | ||
3724 | return nb_cli_apply_changes(vty, NULL); | |
f14e6fdb DS |
3725 | } |
3726 | ||
3727 | ||
20eb8864 | 3728 | /* |
3729 | * Check if this listen range is already configured. Check for exact | |
3730 | * match or overlap based on input. | |
3731 | */ | |
d62a17ae | 3732 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3733 | struct prefix *range, int exact) | |
3734 | { | |
3735 | struct listnode *node, *nnode; | |
3736 | struct listnode *node1, *nnode1; | |
3737 | struct peer_group *group; | |
3738 | struct prefix *lr; | |
3739 | afi_t afi; | |
3740 | int match; | |
3741 | ||
3742 | afi = family2afi(range->family); | |
3743 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3744 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3745 | lr)) { | |
3746 | if (exact) | |
3747 | match = prefix_same(range, lr); | |
3748 | else | |
3749 | match = (prefix_match(range, lr) | |
3750 | || prefix_match(lr, range)); | |
3751 | if (match) | |
3752 | return group; | |
3753 | } | |
3754 | } | |
3755 | ||
3756 | return NULL; | |
20eb8864 | 3757 | } |
3758 | ||
f14e6fdb DS |
3759 | DEFUN (bgp_listen_range, |
3760 | bgp_listen_range_cmd, | |
d7b9898c | 3761 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3762 | "BGP specific commands\n" |
d7fa34c1 QY |
3763 | "Configure BGP dynamic neighbors listen range\n" |
3764 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3765 | NEIGHBOR_ADDR_STR |
3766 | "Member of the peer-group\n" | |
3767 | "Peer-group name\n") | |
f14e6fdb | 3768 | { |
d62a17ae | 3769 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3770 | struct prefix range; | |
3771 | struct peer_group *group, *existing_group; | |
3772 | afi_t afi; | |
3773 | int ret; | |
3774 | int idx = 0; | |
3775 | ||
3776 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3777 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3778 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3779 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3780 | char *peergroup = argv[idx]->arg; |
3781 | ||
3782 | /* Convert IP prefix string to struct prefix. */ | |
3783 | ret = str2prefix(prefix, &range); | |
3784 | if (!ret) { | |
3785 | vty_out(vty, "%% Malformed listen range\n"); | |
3786 | return CMD_WARNING_CONFIG_FAILED; | |
3787 | } | |
3788 | ||
3789 | afi = family2afi(range.family); | |
3790 | ||
3791 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3792 | vty_out(vty, | |
3793 | "%% Malformed listen range (link-local address)\n"); | |
3794 | return CMD_WARNING_CONFIG_FAILED; | |
3795 | } | |
3796 | ||
3797 | apply_mask(&range); | |
3798 | ||
3799 | /* Check if same listen range is already configured. */ | |
3800 | existing_group = listen_range_exists(bgp, &range, 1); | |
3801 | if (existing_group) { | |
3802 | if (strcmp(existing_group->name, peergroup) == 0) | |
3803 | return CMD_SUCCESS; | |
3804 | else { | |
3805 | vty_out(vty, | |
3806 | "%% Same listen range is attached to peer-group %s\n", | |
3807 | existing_group->name); | |
3808 | return CMD_WARNING_CONFIG_FAILED; | |
3809 | } | |
3810 | } | |
3811 | ||
3812 | /* Check if an overlapping listen range exists. */ | |
3813 | if (listen_range_exists(bgp, &range, 0)) { | |
3814 | vty_out(vty, | |
3815 | "%% Listen range overlaps with existing listen range\n"); | |
3816 | return CMD_WARNING_CONFIG_FAILED; | |
3817 | } | |
3818 | ||
3819 | group = peer_group_lookup(bgp, peergroup); | |
3820 | if (!group) { | |
3821 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3822 | return CMD_WARNING_CONFIG_FAILED; | |
3823 | } | |
3824 | ||
3825 | ret = peer_group_listen_range_add(group, &range); | |
3826 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3827 | } |
3828 | ||
3829 | DEFUN (no_bgp_listen_range, | |
3830 | no_bgp_listen_range_cmd, | |
d7b9898c | 3831 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3832 | NO_STR |
f14e6fdb | 3833 | "BGP specific commands\n" |
d7fa34c1 QY |
3834 | "Unconfigure BGP dynamic neighbors listen range\n" |
3835 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3836 | NEIGHBOR_ADDR_STR | |
3837 | "Member of the peer-group\n" | |
3838 | "Peer-group name\n") | |
f14e6fdb | 3839 | { |
d62a17ae | 3840 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3841 | struct prefix range; | |
3842 | struct peer_group *group; | |
3843 | afi_t afi; | |
3844 | int ret; | |
3845 | int idx = 0; | |
3846 | ||
3847 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3848 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3849 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3850 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3851 | char *peergroup = argv[idx]->arg; |
3852 | ||
3853 | /* Convert IP prefix string to struct prefix. */ | |
3854 | ret = str2prefix(prefix, &range); | |
3855 | if (!ret) { | |
3856 | vty_out(vty, "%% Malformed listen range\n"); | |
3857 | return CMD_WARNING_CONFIG_FAILED; | |
3858 | } | |
3859 | ||
3860 | afi = family2afi(range.family); | |
3861 | ||
3862 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3863 | vty_out(vty, | |
3864 | "%% Malformed listen range (link-local address)\n"); | |
3865 | return CMD_WARNING_CONFIG_FAILED; | |
3866 | } | |
3867 | ||
3868 | apply_mask(&range); | |
3869 | ||
3870 | group = peer_group_lookup(bgp, peergroup); | |
3871 | if (!group) { | |
3872 | vty_out(vty, "%% Peer-group does not exist\n"); | |
3873 | return CMD_WARNING_CONFIG_FAILED; | |
3874 | } | |
3875 | ||
3876 | ret = peer_group_listen_range_del(group, &range); | |
3877 | return bgp_vty_return(vty, ret); | |
3878 | } | |
3879 | ||
2b791107 | 3880 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 3881 | { |
3882 | struct peer_group *group; | |
3883 | struct listnode *node, *nnode, *rnode, *nrnode; | |
3884 | struct prefix *range; | |
3885 | afi_t afi; | |
d62a17ae | 3886 | |
3887 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
3888 | vty_out(vty, " bgp listen limit %d\n", | |
3889 | bgp->dynamic_neighbors_limit); | |
3890 | ||
3891 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3892 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
3893 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
3894 | nrnode, range)) { | |
d62a17ae | 3895 | vty_out(vty, |
2dbe669b DA |
3896 | " bgp listen range %pFX peer-group %s\n", |
3897 | range, group->name); | |
d62a17ae | 3898 | } |
3899 | } | |
3900 | } | |
f14e6fdb DS |
3901 | } |
3902 | ||
3903 | ||
ff8a8a7a CS |
3904 | DEFUN_YANG(bgp_disable_connected_route_check, |
3905 | bgp_disable_connected_route_check_cmd, | |
3906 | "bgp disable-ebgp-connected-route-check", | |
3907 | "BGP specific commands\n" | |
3908 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 3909 | { |
87ce2564 CS |
3910 | nb_cli_enqueue_change(vty, |
3911 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 3912 | NB_OP_MODIFY, "true"); |
7aafcaca | 3913 | |
ff8a8a7a | 3914 | return nb_cli_apply_changes(vty, NULL); |
907f92c8 DS |
3915 | } |
3916 | ||
ff8a8a7a CS |
3917 | DEFUN_YANG(no_bgp_disable_connected_route_check, |
3918 | no_bgp_disable_connected_route_check_cmd, | |
3919 | "no bgp disable-ebgp-connected-route-check", | |
3920 | NO_STR | |
3921 | "BGP specific commands\n" | |
3922 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 3923 | { |
87ce2564 CS |
3924 | nb_cli_enqueue_change(vty, |
3925 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 3926 | NB_OP_MODIFY, "false"); |
d62a17ae | 3927 | |
ff8a8a7a | 3928 | return nb_cli_apply_changes(vty, NULL); |
d62a17ae | 3929 | } |
3930 | ||
ff8a8a7a CS |
3931 | void cli_show_router_global_ebgp_multihop_connected_route_check( |
3932 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3933 | { | |
3934 | if (yang_dnode_get_bool(dnode, NULL)) | |
3935 | vty_out(vty, " bgp disable-ebgp-connected-route-check\n"); | |
3936 | } | |
d62a17ae | 3937 | |
3938 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
3939 | const char *as_str, afi_t afi, safi_t safi) | |
3940 | { | |
3941 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3942 | int ret; | |
3943 | as_t as; | |
3944 | int as_type = AS_SPECIFIED; | |
3945 | union sockunion su; | |
3946 | ||
3947 | if (as_str[0] == 'i') { | |
3948 | as = 0; | |
3949 | as_type = AS_INTERNAL; | |
3950 | } else if (as_str[0] == 'e') { | |
3951 | as = 0; | |
3952 | as_type = AS_EXTERNAL; | |
3953 | } else { | |
3954 | /* Get AS number. */ | |
3955 | as = strtoul(as_str, NULL, 10); | |
3956 | } | |
3957 | ||
390485fd | 3958 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 3959 | ret = str2sockunion(peer_str, &su); |
3960 | if (ret < 0) { | |
390485fd DS |
3961 | struct peer *peer; |
3962 | ||
3963 | /* Check if existing interface peer */ | |
3964 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
3965 | ||
d62a17ae | 3966 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
3967 | safi); | |
390485fd DS |
3968 | |
3969 | /* if not interface peer, check peer-group settings */ | |
3970 | if (ret < 0 && !peer) { | |
d62a17ae | 3971 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
3972 | if (ret < 0) { | |
3973 | vty_out(vty, | |
390485fd | 3974 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 3975 | return CMD_WARNING_CONFIG_FAILED; |
3976 | } | |
3977 | return CMD_SUCCESS; | |
3978 | } | |
3979 | } else { | |
3980 | if (peer_address_self_check(bgp, &su)) { | |
3981 | vty_out(vty, | |
3982 | "%% Can not configure the local system as neighbor\n"); | |
3983 | return CMD_WARNING_CONFIG_FAILED; | |
3984 | } | |
3985 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
3986 | } | |
3987 | ||
3988 | /* This peer belongs to peer group. */ | |
3989 | switch (ret) { | |
3990 | case BGP_ERR_PEER_GROUP_MEMBER: | |
3991 | vty_out(vty, | |
faa16034 | 3992 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 3993 | return CMD_WARNING_CONFIG_FAILED; |
3994 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
3995 | vty_out(vty, | |
faa16034 | 3996 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 3997 | return CMD_WARNING_CONFIG_FAILED; |
3998 | } | |
3999 | return bgp_vty_return(vty, ret); | |
718e3744 | 4000 | } |
4001 | ||
ff8a8a7a CS |
4002 | DEFUN_YANG(bgp_default_shutdown, |
4003 | bgp_default_shutdown_cmd, | |
4004 | "[no] bgp default shutdown", | |
4005 | NO_STR BGP_STR | |
4006 | "Configure BGP defaults\n" | |
4007 | "Apply administrative shutdown to newly configured peers\n") | |
f26845f9 | 4008 | { |
87ce2564 | 4009 | nb_cli_enqueue_change(vty, "./global/default-shutdown", NB_OP_MODIFY, |
ff8a8a7a CS |
4010 | strmatch(argv[0]->text, "no") ? "false" : "true"); |
4011 | ||
4012 | return nb_cli_apply_changes(vty, NULL); | |
4013 | } | |
4014 | ||
4015 | void cli_show_router_bgp_default_shutdown(struct vty *vty, | |
4016 | struct lyd_node *dnode, | |
4017 | bool show_defaults) | |
4018 | { | |
4019 | if (yang_dnode_get_bool(dnode, NULL)) | |
4020 | vty_out(vty, " bgp default shutdown\n"); | |
f26845f9 QY |
4021 | } |
4022 | ||
736b68f3 DS |
4023 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4024 | BGP_STR | |
9ddf4b81 | 4025 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4026 | "Add a shutdown message (RFC 8203)\n" |
4027 | "Shutdown message\n") | |
9cf59432 | 4028 | { |
736b68f3 | 4029 | char *msgstr = NULL; |
8389c83a | 4030 | |
9cf59432 DS |
4031 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4032 | ||
8389c83a | 4033 | if (argc > 3) |
f80e35b6 | 4034 | msgstr = argv_concat(argv, argc, 3); |
8389c83a DS |
4035 | |
4036 | bgp_shutdown_enable(bgp, msgstr); | |
4037 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4038 | |
4039 | return CMD_SUCCESS; | |
4040 | } | |
4041 | ||
736b68f3 | 4042 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4043 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4044 | { |
4045 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4046 | ||
4047 | bgp_shutdown_enable(bgp, NULL); | |
4048 | ||
4049 | return CMD_SUCCESS; | |
4050 | } | |
8389c83a | 4051 | |
736b68f3 | 4052 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4053 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4054 | { |
4055 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4056 | ||
4057 | bgp_shutdown_disable(bgp); | |
4058 | ||
4059 | return CMD_SUCCESS; | |
4060 | } | |
4061 | ||
9ddf4b81 | 4062 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4063 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4064 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4065 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4066 | |
718e3744 | 4067 | DEFUN (neighbor_remote_as, |
4068 | neighbor_remote_as_cmd, | |
3a2d747c | 4069 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 4070 | NEIGHBOR_STR |
4071 | NEIGHBOR_ADDR_STR2 | |
4072 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 4073 | AS_STR |
3a2d747c QY |
4074 | "Internal BGP peer\n" |
4075 | "External BGP peer\n") | |
718e3744 | 4076 | { |
d62a17ae | 4077 | int idx_peer = 1; |
4078 | int idx_remote_as = 3; | |
4079 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
4080 | argv[idx_remote_as]->arg, AFI_IP, | |
4081 | SAFI_UNICAST); | |
4082 | } | |
4083 | ||
4084 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
4085 | afi_t afi, safi_t safi, int v6only, | |
4086 | const char *peer_group_name, | |
4087 | const char *as_str) | |
4088 | { | |
4089 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4090 | as_t as = 0; | |
4091 | int as_type = AS_UNSPECIFIED; | |
4092 | struct peer *peer; | |
4093 | struct peer_group *group; | |
4094 | int ret = 0; | |
4095 | union sockunion su; | |
4096 | ||
4097 | group = peer_group_lookup(bgp, conf_if); | |
4098 | ||
4099 | if (group) { | |
4100 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
4101 | return CMD_WARNING_CONFIG_FAILED; | |
4102 | } | |
4103 | ||
4104 | if (as_str) { | |
4105 | if (as_str[0] == 'i') { | |
4106 | as_type = AS_INTERNAL; | |
4107 | } else if (as_str[0] == 'e') { | |
4108 | as_type = AS_EXTERNAL; | |
4109 | } else { | |
4110 | /* Get AS number. */ | |
4111 | as = strtoul(as_str, NULL, 10); | |
4112 | as_type = AS_SPECIFIED; | |
4113 | } | |
4114 | } | |
4115 | ||
4116 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4117 | if (peer) { | |
4118 | if (as_str) | |
cc4d4ce8 | 4119 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 4120 | afi, safi); |
4121 | } else { | |
892fedb6 | 4122 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4) |
d62a17ae | 4123 | && afi == AFI_IP && safi == SAFI_UNICAST) |
4124 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
4125 | as_type, 0, 0, NULL); | |
4126 | else | |
4127 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
4128 | as_type, afi, safi, NULL); | |
4129 | ||
4130 | if (!peer) { | |
4131 | vty_out(vty, "%% BGP failed to create peer\n"); | |
4132 | return CMD_WARNING_CONFIG_FAILED; | |
4133 | } | |
4134 | ||
4135 | if (v6only) | |
527de3dc | 4136 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4137 | |
4138 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4139 | * this | |
4140 | * any unnumbered peer in order to not worry about run-time | |
4141 | * transitions | |
4142 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4143 | * address | |
4144 | * gets deleted later etc.) | |
4145 | */ | |
4146 | if (peer->ifp) | |
4147 | bgp_zebra_initiate_radv(bgp, peer); | |
4148 | } | |
4149 | ||
4150 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4151 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4152 | if (v6only) | |
527de3dc | 4153 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4154 | else |
527de3dc | 4155 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4156 | |
4157 | /* v6only flag changed. Reset bgp seesion */ | |
4158 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4159 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4160 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4161 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4162 | } else | |
4163 | bgp_session_reset(peer); | |
4164 | } | |
4165 | ||
9fb964de PM |
4166 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4167 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4168 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4169 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4170 | } |
d62a17ae | 4171 | |
4172 | if (peer_group_name) { | |
4173 | group = peer_group_lookup(bgp, peer_group_name); | |
4174 | if (!group) { | |
4175 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4176 | return CMD_WARNING_CONFIG_FAILED; | |
4177 | } | |
4178 | ||
4179 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4180 | } | |
4181 | ||
4182 | return bgp_vty_return(vty, ret); | |
a80beece DS |
4183 | } |
4184 | ||
4c48cf63 DW |
4185 | DEFUN (neighbor_interface_config, |
4186 | neighbor_interface_config_cmd, | |
d7b9898c | 4187 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
4188 | NEIGHBOR_STR |
4189 | "Interface name or neighbor tag\n" | |
31500417 DW |
4190 | "Enable BGP on interface\n" |
4191 | "Member of the peer-group\n" | |
16cedbb0 | 4192 | "Peer-group name\n") |
4c48cf63 | 4193 | { |
d62a17ae | 4194 | int idx_word = 1; |
4195 | int idx_peer_group_word = 4; | |
31500417 | 4196 | |
d62a17ae | 4197 | if (argc > idx_peer_group_word) |
4198 | return peer_conf_interface_get( | |
4199 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
4200 | argv[idx_peer_group_word]->arg, NULL); | |
4201 | else | |
4202 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
4203 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
4204 | } |
4205 | ||
4c48cf63 DW |
4206 | DEFUN (neighbor_interface_config_v6only, |
4207 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 4208 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
4209 | NEIGHBOR_STR |
4210 | "Interface name or neighbor tag\n" | |
4211 | "Enable BGP on interface\n" | |
31500417 DW |
4212 | "Enable BGP with v6 link-local only\n" |
4213 | "Member of the peer-group\n" | |
16cedbb0 | 4214 | "Peer-group name\n") |
4c48cf63 | 4215 | { |
d62a17ae | 4216 | int idx_word = 1; |
4217 | int idx_peer_group_word = 5; | |
31500417 | 4218 | |
d62a17ae | 4219 | if (argc > idx_peer_group_word) |
4220 | return peer_conf_interface_get( | |
4221 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
4222 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4223 | |
d62a17ae | 4224 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
4225 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
4226 | } |
4227 | ||
a80beece | 4228 | |
b3a39dc5 DD |
4229 | DEFUN (neighbor_interface_config_remote_as, |
4230 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 4231 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
4232 | NEIGHBOR_STR |
4233 | "Interface name or neighbor tag\n" | |
4234 | "Enable BGP on interface\n" | |
3a2d747c | 4235 | "Specify a BGP neighbor\n" |
d7fa34c1 | 4236 | AS_STR |
3a2d747c QY |
4237 | "Internal BGP peer\n" |
4238 | "External BGP peer\n") | |
b3a39dc5 | 4239 | { |
d62a17ae | 4240 | int idx_word = 1; |
4241 | int idx_remote_as = 4; | |
4242 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
4243 | SAFI_UNICAST, 0, NULL, | |
4244 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4245 | } |
4246 | ||
4247 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
4248 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 4249 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
4250 | NEIGHBOR_STR |
4251 | "Interface name or neighbor tag\n" | |
3a2d747c | 4252 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 4253 | "Enable BGP on interface\n" |
3a2d747c | 4254 | "Specify a BGP neighbor\n" |
d7fa34c1 | 4255 | AS_STR |
3a2d747c QY |
4256 | "Internal BGP peer\n" |
4257 | "External BGP peer\n") | |
b3a39dc5 | 4258 | { |
d62a17ae | 4259 | int idx_word = 1; |
4260 | int idx_remote_as = 5; | |
4261 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
4262 | SAFI_UNICAST, 1, NULL, | |
4263 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4264 | } |
4265 | ||
718e3744 | 4266 | DEFUN (neighbor_peer_group, |
4267 | neighbor_peer_group_cmd, | |
4268 | "neighbor WORD peer-group", | |
4269 | NEIGHBOR_STR | |
a80beece | 4270 | "Interface name or neighbor tag\n" |
718e3744 | 4271 | "Configure peer-group\n") |
4272 | { | |
d62a17ae | 4273 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4274 | int idx_word = 1; | |
4275 | struct peer *peer; | |
4276 | struct peer_group *group; | |
718e3744 | 4277 | |
d62a17ae | 4278 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4279 | if (peer) { | |
4280 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4281 | return CMD_WARNING_CONFIG_FAILED; | |
4282 | } | |
718e3744 | 4283 | |
d62a17ae | 4284 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4285 | if (!group) { | |
4286 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4287 | return CMD_WARNING_CONFIG_FAILED; | |
4288 | } | |
718e3744 | 4289 | |
d62a17ae | 4290 | return CMD_SUCCESS; |
718e3744 | 4291 | } |
4292 | ||
4293 | DEFUN (no_neighbor, | |
4294 | no_neighbor_cmd, | |
dab8cd00 | 4295 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 4296 | NO_STR |
4297 | NEIGHBOR_STR | |
3a2d747c QY |
4298 | NEIGHBOR_ADDR_STR2 |
4299 | "Specify a BGP neighbor\n" | |
4300 | AS_STR | |
4301 | "Internal BGP peer\n" | |
4302 | "External BGP peer\n") | |
718e3744 | 4303 | { |
d62a17ae | 4304 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4305 | int idx_peer = 2; | |
4306 | int ret; | |
4307 | union sockunion su; | |
4308 | struct peer_group *group; | |
4309 | struct peer *peer; | |
4310 | struct peer *other; | |
4311 | ||
4312 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
4313 | if (ret < 0) { | |
4314 | /* look up for neighbor by interface name config. */ | |
4315 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4316 | if (peer) { | |
4317 | /* Request zebra to terminate IPv6 RAs on this | |
4318 | * interface. */ | |
4319 | if (peer->ifp) | |
4320 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 4321 | peer_notify_unconfig(peer); |
d62a17ae | 4322 | peer_delete(peer); |
4323 | return CMD_SUCCESS; | |
4324 | } | |
f14e6fdb | 4325 | |
d62a17ae | 4326 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
4327 | if (group) { |
4328 | peer_group_notify_unconfig(group); | |
d62a17ae | 4329 | peer_group_delete(group); |
4e2786df | 4330 | } else { |
d62a17ae | 4331 | vty_out(vty, "%% Create the peer-group first\n"); |
4332 | return CMD_WARNING_CONFIG_FAILED; | |
4333 | } | |
4334 | } else { | |
4335 | peer = peer_lookup(bgp, &su); | |
4336 | if (peer) { | |
4337 | if (peer_dynamic_neighbor(peer)) { | |
4338 | vty_out(vty, | |
4339 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4340 | return CMD_WARNING_CONFIG_FAILED; | |
4341 | } | |
4342 | ||
4343 | other = peer->doppelganger; | |
b3a3290e DS |
4344 | |
4345 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
4346 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4347 | ||
4e2786df | 4348 | peer_notify_unconfig(peer); |
d62a17ae | 4349 | peer_delete(peer); |
4e2786df DA |
4350 | if (other && other->status != Deleted) { |
4351 | peer_notify_unconfig(other); | |
d62a17ae | 4352 | peer_delete(other); |
4e2786df | 4353 | } |
d62a17ae | 4354 | } |
1ff9a340 | 4355 | } |
718e3744 | 4356 | |
d62a17ae | 4357 | return CMD_SUCCESS; |
718e3744 | 4358 | } |
4359 | ||
a80beece DS |
4360 | DEFUN (no_neighbor_interface_config, |
4361 | no_neighbor_interface_config_cmd, | |
d7b9898c | 4362 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
4363 | NO_STR |
4364 | NEIGHBOR_STR | |
4365 | "Interface name\n" | |
31500417 DW |
4366 | "Configure BGP on interface\n" |
4367 | "Enable BGP with v6 link-local only\n" | |
4368 | "Member of the peer-group\n" | |
16cedbb0 | 4369 | "Peer-group name\n" |
3a2d747c QY |
4370 | "Specify a BGP neighbor\n" |
4371 | AS_STR | |
4372 | "Internal BGP peer\n" | |
4373 | "External BGP peer\n") | |
a80beece | 4374 | { |
d62a17ae | 4375 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4376 | int idx_word = 2; | |
4377 | struct peer *peer; | |
4378 | ||
4379 | /* look up for neighbor by interface name config. */ | |
4380 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4381 | if (peer) { | |
4382 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4383 | if (peer->ifp) | |
4384 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 4385 | peer_notify_unconfig(peer); |
d62a17ae | 4386 | peer_delete(peer); |
4387 | } else { | |
4388 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4389 | return CMD_WARNING_CONFIG_FAILED; | |
4390 | } | |
4391 | return CMD_SUCCESS; | |
a80beece DS |
4392 | } |
4393 | ||
718e3744 | 4394 | DEFUN (no_neighbor_peer_group, |
4395 | no_neighbor_peer_group_cmd, | |
4396 | "no neighbor WORD peer-group", | |
4397 | NO_STR | |
4398 | NEIGHBOR_STR | |
4399 | "Neighbor tag\n" | |
4400 | "Configure peer-group\n") | |
4401 | { | |
d62a17ae | 4402 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4403 | int idx_word = 2; | |
4404 | struct peer_group *group; | |
718e3744 | 4405 | |
d62a17ae | 4406 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
4407 | if (group) { |
4408 | peer_group_notify_unconfig(group); | |
d62a17ae | 4409 | peer_group_delete(group); |
4e2786df | 4410 | } else { |
d62a17ae | 4411 | vty_out(vty, "%% Create the peer-group first\n"); |
4412 | return CMD_WARNING_CONFIG_FAILED; | |
4413 | } | |
4414 | return CMD_SUCCESS; | |
718e3744 | 4415 | } |
4416 | ||
a80beece DS |
4417 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
4418 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 4419 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 4420 | NO_STR |
4421 | NEIGHBOR_STR | |
a80beece | 4422 | "Interface name or neighbor tag\n" |
718e3744 | 4423 | "Specify a BGP neighbor\n" |
3a2d747c QY |
4424 | AS_STR |
4425 | "Internal BGP peer\n" | |
4426 | "External BGP peer\n") | |
718e3744 | 4427 | { |
d62a17ae | 4428 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4429 | int idx_word = 2; | |
4430 | struct peer_group *group; | |
4431 | struct peer *peer; | |
4432 | ||
4433 | /* look up for neighbor by interface name config. */ | |
4434 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4435 | if (peer) { | |
390485fd | 4436 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 4437 | return CMD_SUCCESS; |
4438 | } | |
4439 | ||
4440 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4441 | if (group) | |
4442 | peer_group_remote_as_delete(group); | |
4443 | else { | |
4444 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4445 | return CMD_WARNING_CONFIG_FAILED; | |
4446 | } | |
4447 | return CMD_SUCCESS; | |
718e3744 | 4448 | } |
6b0655a2 | 4449 | |
718e3744 | 4450 | DEFUN (neighbor_local_as, |
4451 | neighbor_local_as_cmd, | |
9ccf14f7 | 4452 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 4453 | NEIGHBOR_STR |
4454 | NEIGHBOR_ADDR_STR2 | |
4455 | "Specify a local-as number\n" | |
4456 | "AS number used as local AS\n") | |
4457 | { | |
d62a17ae | 4458 | int idx_peer = 1; |
4459 | int idx_number = 3; | |
4460 | struct peer *peer; | |
4461 | int ret; | |
4462 | as_t as; | |
718e3744 | 4463 | |
d62a17ae | 4464 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4465 | if (!peer) | |
4466 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4467 | |
d62a17ae | 4468 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4469 | ret = peer_local_as_set(peer, as, 0, 0); | |
4470 | return bgp_vty_return(vty, ret); | |
718e3744 | 4471 | } |
4472 | ||
4473 | DEFUN (neighbor_local_as_no_prepend, | |
4474 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 4475 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 4476 | NEIGHBOR_STR |
4477 | NEIGHBOR_ADDR_STR2 | |
4478 | "Specify a local-as number\n" | |
4479 | "AS number used as local AS\n" | |
4480 | "Do not prepend local-as to updates from ebgp peers\n") | |
4481 | { | |
d62a17ae | 4482 | int idx_peer = 1; |
4483 | int idx_number = 3; | |
4484 | struct peer *peer; | |
4485 | int ret; | |
4486 | as_t as; | |
718e3744 | 4487 | |
d62a17ae | 4488 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4489 | if (!peer) | |
4490 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4491 | |
d62a17ae | 4492 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4493 | ret = peer_local_as_set(peer, as, 1, 0); | |
4494 | return bgp_vty_return(vty, ret); | |
718e3744 | 4495 | } |
4496 | ||
9d3f9705 AC |
4497 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4498 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 4499 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
4500 | NEIGHBOR_STR |
4501 | NEIGHBOR_ADDR_STR2 | |
4502 | "Specify a local-as number\n" | |
4503 | "AS number used as local AS\n" | |
4504 | "Do not prepend local-as to updates from ebgp peers\n" | |
4505 | "Do not prepend local-as to updates from ibgp peers\n") | |
4506 | { | |
d62a17ae | 4507 | int idx_peer = 1; |
4508 | int idx_number = 3; | |
4509 | struct peer *peer; | |
4510 | int ret; | |
4511 | as_t as; | |
9d3f9705 | 4512 | |
d62a17ae | 4513 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4514 | if (!peer) | |
4515 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 4516 | |
d62a17ae | 4517 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4518 | ret = peer_local_as_set(peer, as, 1, 1); | |
4519 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4520 | } |
4521 | ||
718e3744 | 4522 | DEFUN (no_neighbor_local_as, |
4523 | no_neighbor_local_as_cmd, | |
a636c635 | 4524 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 4525 | NO_STR |
4526 | NEIGHBOR_STR | |
4527 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4528 | "Specify a local-as number\n" |
4529 | "AS number used as local AS\n" | |
4530 | "Do not prepend local-as to updates from ebgp peers\n" | |
4531 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4532 | { |
d62a17ae | 4533 | int idx_peer = 2; |
4534 | struct peer *peer; | |
4535 | int ret; | |
718e3744 | 4536 | |
d62a17ae | 4537 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4538 | if (!peer) | |
4539 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4540 | |
d62a17ae | 4541 | ret = peer_local_as_unset(peer); |
4542 | return bgp_vty_return(vty, ret); | |
718e3744 | 4543 | } |
4544 | ||
718e3744 | 4545 | |
3f9c7369 DS |
4546 | DEFUN (neighbor_solo, |
4547 | neighbor_solo_cmd, | |
9ccf14f7 | 4548 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4549 | NEIGHBOR_STR |
4550 | NEIGHBOR_ADDR_STR2 | |
4551 | "Solo peer - part of its own update group\n") | |
4552 | { | |
d62a17ae | 4553 | int idx_peer = 1; |
4554 | struct peer *peer; | |
4555 | int ret; | |
3f9c7369 | 4556 | |
d62a17ae | 4557 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4558 | if (!peer) | |
4559 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4560 | |
d62a17ae | 4561 | ret = update_group_adjust_soloness(peer, 1); |
4562 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4563 | } |
4564 | ||
4565 | DEFUN (no_neighbor_solo, | |
4566 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4567 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4568 | NO_STR |
4569 | NEIGHBOR_STR | |
4570 | NEIGHBOR_ADDR_STR2 | |
4571 | "Solo peer - part of its own update group\n") | |
4572 | { | |
d62a17ae | 4573 | int idx_peer = 2; |
4574 | struct peer *peer; | |
4575 | int ret; | |
3f9c7369 | 4576 | |
d62a17ae | 4577 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4578 | if (!peer) | |
4579 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4580 | |
d62a17ae | 4581 | ret = update_group_adjust_soloness(peer, 0); |
4582 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4583 | } |
4584 | ||
0df7c91f PJ |
4585 | DEFUN (neighbor_password, |
4586 | neighbor_password_cmd, | |
9ccf14f7 | 4587 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
4588 | NEIGHBOR_STR |
4589 | NEIGHBOR_ADDR_STR2 | |
4590 | "Set a password\n" | |
4591 | "The password\n") | |
4592 | { | |
d62a17ae | 4593 | int idx_peer = 1; |
4594 | int idx_line = 3; | |
4595 | struct peer *peer; | |
4596 | int ret; | |
0df7c91f | 4597 | |
d62a17ae | 4598 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4599 | if (!peer) | |
4600 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4601 | |
d62a17ae | 4602 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4603 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4604 | } |
4605 | ||
4606 | DEFUN (no_neighbor_password, | |
4607 | no_neighbor_password_cmd, | |
a636c635 | 4608 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
4609 | NO_STR |
4610 | NEIGHBOR_STR | |
4611 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
4612 | "Set a password\n" |
4613 | "The password\n") | |
0df7c91f | 4614 | { |
d62a17ae | 4615 | int idx_peer = 2; |
4616 | struct peer *peer; | |
4617 | int ret; | |
0df7c91f | 4618 | |
d62a17ae | 4619 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4620 | if (!peer) | |
4621 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4622 | |
d62a17ae | 4623 | ret = peer_password_unset(peer); |
4624 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4625 | } |
6b0655a2 | 4626 | |
718e3744 | 4627 | DEFUN (neighbor_activate, |
4628 | neighbor_activate_cmd, | |
9ccf14f7 | 4629 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4630 | NEIGHBOR_STR |
4631 | NEIGHBOR_ADDR_STR2 | |
4632 | "Enable the Address Family for this Neighbor\n") | |
4633 | { | |
d62a17ae | 4634 | int idx_peer = 1; |
4635 | int ret; | |
4636 | struct peer *peer; | |
718e3744 | 4637 | |
d62a17ae | 4638 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4639 | if (!peer) | |
4640 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4641 | |
d62a17ae | 4642 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4643 | return bgp_vty_return(vty, ret); | |
718e3744 | 4644 | } |
4645 | ||
d62a17ae | 4646 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4647 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4648 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4649 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4650 | |
718e3744 | 4651 | DEFUN (no_neighbor_activate, |
4652 | no_neighbor_activate_cmd, | |
9ccf14f7 | 4653 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4654 | NO_STR |
4655 | NEIGHBOR_STR | |
4656 | NEIGHBOR_ADDR_STR2 | |
4657 | "Enable the Address Family for this Neighbor\n") | |
4658 | { | |
d62a17ae | 4659 | int idx_peer = 2; |
4660 | int ret; | |
4661 | struct peer *peer; | |
718e3744 | 4662 | |
d62a17ae | 4663 | /* Lookup peer. */ |
4664 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4665 | if (!peer) | |
4666 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4667 | |
d62a17ae | 4668 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4669 | return bgp_vty_return(vty, ret); | |
718e3744 | 4670 | } |
6b0655a2 | 4671 | |
d62a17ae | 4672 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4673 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4674 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4675 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4676 | |
718e3744 | 4677 | DEFUN (neighbor_set_peer_group, |
4678 | neighbor_set_peer_group_cmd, | |
d7b9898c | 4679 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4680 | NEIGHBOR_STR |
a80beece | 4681 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4682 | "Member of the peer-group\n" |
16cedbb0 | 4683 | "Peer-group name\n") |
718e3744 | 4684 | { |
d62a17ae | 4685 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4686 | int idx_peer = 1; | |
4687 | int idx_word = 3; | |
4688 | int ret; | |
4689 | as_t as; | |
4690 | union sockunion su; | |
4691 | struct peer *peer; | |
4692 | struct peer_group *group; | |
4693 | ||
d62a17ae | 4694 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4695 | if (ret < 0) { | |
4696 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4697 | if (!peer) { | |
4698 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4699 | argv[idx_peer]->arg); | |
4700 | return CMD_WARNING_CONFIG_FAILED; | |
4701 | } | |
4702 | } else { | |
4703 | if (peer_address_self_check(bgp, &su)) { | |
4704 | vty_out(vty, | |
4705 | "%% Can not configure the local system as neighbor\n"); | |
4706 | return CMD_WARNING_CONFIG_FAILED; | |
4707 | } | |
4708 | ||
4709 | /* Disallow for dynamic neighbor. */ | |
4710 | peer = peer_lookup(bgp, &su); | |
4711 | if (peer && peer_dynamic_neighbor(peer)) { | |
4712 | vty_out(vty, | |
4713 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4714 | return CMD_WARNING_CONFIG_FAILED; | |
4715 | } | |
4716 | } | |
4717 | ||
4718 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4719 | if (!group) { | |
4720 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4721 | return CMD_WARNING_CONFIG_FAILED; | |
4722 | } | |
4723 | ||
4724 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4725 | ||
4726 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4727 | vty_out(vty, | |
4728 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4729 | as); | |
4730 | return CMD_WARNING_CONFIG_FAILED; | |
4731 | } | |
4732 | ||
4733 | return bgp_vty_return(vty, ret); | |
4734 | } | |
4735 | ||
4736 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4737 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4738 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4739 | "Member of the peer-group\n" | |
4740 | "Peer-group name\n") | |
596c17ba | 4741 | |
718e3744 | 4742 | DEFUN (no_neighbor_set_peer_group, |
4743 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4744 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4745 | NO_STR |
4746 | NEIGHBOR_STR | |
a80beece | 4747 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4748 | "Member of the peer-group\n" |
16cedbb0 | 4749 | "Peer-group name\n") |
718e3744 | 4750 | { |
d62a17ae | 4751 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4752 | int idx_peer = 2; | |
4753 | int idx_word = 4; | |
4754 | int ret; | |
4755 | struct peer *peer; | |
4756 | struct peer_group *group; | |
4757 | ||
4758 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4759 | if (!peer) | |
4760 | return CMD_WARNING_CONFIG_FAILED; | |
4761 | ||
4762 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4763 | if (!group) { | |
4764 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4765 | return CMD_WARNING_CONFIG_FAILED; | |
4766 | } | |
718e3744 | 4767 | |
b3a3290e DS |
4768 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4769 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4770 | ||
4e2786df | 4771 | peer_notify_unconfig(peer); |
827ed707 | 4772 | ret = peer_delete(peer); |
718e3744 | 4773 | |
d62a17ae | 4774 | return bgp_vty_return(vty, ret); |
718e3744 | 4775 | } |
6b0655a2 | 4776 | |
d62a17ae | 4777 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4778 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4779 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4780 | "Member of the peer-group\n" | |
4781 | "Peer-group name\n") | |
596c17ba | 4782 | |
d62a17ae | 4783 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4784 | uint32_t flag, int set) |
718e3744 | 4785 | { |
d62a17ae | 4786 | int ret; |
4787 | struct peer *peer; | |
718e3744 | 4788 | |
d62a17ae | 4789 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4790 | if (!peer) | |
4791 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4792 | |
7ebe625c QY |
4793 | /* |
4794 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4795 | * we should not accept disable-connected-check. | |
4796 | */ | |
4797 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4798 | vty_out(vty, | |
3efd0893 | 4799 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
4800 | ip_str); |
4801 | return CMD_WARNING_CONFIG_FAILED; | |
4802 | } | |
4803 | ||
d62a17ae | 4804 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4805 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4806 | |
d62a17ae | 4807 | if (set) |
4808 | ret = peer_flag_set(peer, flag); | |
4809 | else | |
4810 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4811 | |
d62a17ae | 4812 | return bgp_vty_return(vty, ret); |
718e3744 | 4813 | } |
4814 | ||
47cbc09b | 4815 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4816 | { |
d62a17ae | 4817 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4818 | } |
4819 | ||
d62a17ae | 4820 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4821 | uint32_t flag) |
718e3744 | 4822 | { |
d62a17ae | 4823 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4824 | } |
4825 | ||
4826 | /* neighbor passive. */ | |
4827 | DEFUN (neighbor_passive, | |
4828 | neighbor_passive_cmd, | |
9ccf14f7 | 4829 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4830 | NEIGHBOR_STR |
4831 | NEIGHBOR_ADDR_STR2 | |
4832 | "Don't send open messages to this neighbor\n") | |
4833 | { | |
d62a17ae | 4834 | int idx_peer = 1; |
4835 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4836 | } |
4837 | ||
4838 | DEFUN (no_neighbor_passive, | |
4839 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4840 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4841 | NO_STR |
4842 | NEIGHBOR_STR | |
4843 | NEIGHBOR_ADDR_STR2 | |
4844 | "Don't send open messages to this neighbor\n") | |
4845 | { | |
d62a17ae | 4846 | int idx_peer = 2; |
4847 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4848 | } |
6b0655a2 | 4849 | |
718e3744 | 4850 | /* neighbor shutdown. */ |
73d70fa6 DL |
4851 | DEFUN (neighbor_shutdown_msg, |
4852 | neighbor_shutdown_msg_cmd, | |
4853 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4854 | NEIGHBOR_STR |
4855 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 | 4856 | "Administratively shut down this neighbor\n" |
70335e0a | 4857 | "Add a shutdown message (RFC 8203)\n" |
73d70fa6 | 4858 | "Shutdown message\n") |
718e3744 | 4859 | { |
d62a17ae | 4860 | int idx_peer = 1; |
73d70fa6 | 4861 | |
d62a17ae | 4862 | if (argc >= 5) { |
4863 | struct peer *peer = | |
4864 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4865 | char *message; | |
73d70fa6 | 4866 | |
d62a17ae | 4867 | if (!peer) |
4868 | return CMD_WARNING_CONFIG_FAILED; | |
4869 | message = argv_concat(argv, argc, 4); | |
4870 | peer_tx_shutdown_message_set(peer, message); | |
4871 | XFREE(MTYPE_TMP, message); | |
4872 | } | |
73d70fa6 | 4873 | |
d62a17ae | 4874 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4875 | } |
4876 | ||
d62a17ae | 4877 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4878 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4879 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4880 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4881 | |
4882 | DEFUN (no_neighbor_shutdown_msg, | |
4883 | no_neighbor_shutdown_msg_cmd, | |
4884 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4885 | NO_STR | |
4886 | NEIGHBOR_STR | |
4887 | NEIGHBOR_ADDR_STR2 | |
4888 | "Administratively shut down this neighbor\n" | |
70335e0a | 4889 | "Remove a shutdown message (RFC 8203)\n" |
73d70fa6 | 4890 | "Shutdown message\n") |
718e3744 | 4891 | { |
d62a17ae | 4892 | int idx_peer = 2; |
73d70fa6 | 4893 | |
d62a17ae | 4894 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4895 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4896 | } |
6b0655a2 | 4897 | |
d62a17ae | 4898 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4899 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4900 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4901 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4902 | |
8336c896 DA |
4903 | DEFUN(neighbor_shutdown_rtt, |
4904 | neighbor_shutdown_rtt_cmd, | |
4905 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
4906 | NEIGHBOR_STR | |
4907 | NEIGHBOR_ADDR_STR2 | |
4908 | "Administratively shut down this neighbor\n" | |
4909 | "Shutdown if round-trip-time is higher than expected\n" | |
4910 | "Round-trip-time in milliseconds\n" | |
4911 | "Specify the number of keepalives before shutdown\n" | |
4912 | "The number of keepalives with higher RTT to shutdown\n") | |
4913 | { | |
4914 | int idx_peer = 1; | |
4915 | int idx_rtt = 4; | |
4916 | int idx_count = 0; | |
4917 | struct peer *peer; | |
4918 | ||
4919 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4920 | ||
4921 | if (!peer) | |
4922 | return CMD_WARNING_CONFIG_FAILED; | |
4923 | ||
4924 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
4925 | ||
4926 | if (argv_find(argv, argc, "count", &idx_count)) | |
4927 | peer->rtt_keepalive_conf = | |
4928 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
4929 | ||
4930 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4931 | PEER_FLAG_RTT_SHUTDOWN); | |
4932 | } | |
4933 | ||
4934 | DEFUN(no_neighbor_shutdown_rtt, | |
4935 | no_neighbor_shutdown_rtt_cmd, | |
4936 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
4937 | NO_STR | |
4938 | NEIGHBOR_STR | |
4939 | NEIGHBOR_ADDR_STR2 | |
4940 | "Administratively shut down this neighbor\n" | |
4941 | "Shutdown if round-trip-time is higher than expected\n" | |
4942 | "Round-trip-time in milliseconds\n" | |
4943 | "Specify the number of keepalives before shutdown\n" | |
4944 | "The number of keepalives with higher RTT to shutdown\n") | |
4945 | { | |
4946 | int idx_peer = 2; | |
4947 | struct peer *peer; | |
4948 | ||
4949 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4950 | ||
4951 | if (!peer) | |
4952 | return CMD_WARNING_CONFIG_FAILED; | |
4953 | ||
4954 | peer->rtt_expected = 0; | |
4955 | peer->rtt_keepalive_conf = 1; | |
4956 | ||
4957 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4958 | PEER_FLAG_RTT_SHUTDOWN); | |
4959 | } | |
4960 | ||
718e3744 | 4961 | /* neighbor capability dynamic. */ |
4962 | DEFUN (neighbor_capability_dynamic, | |
4963 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4964 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4965 | NEIGHBOR_STR |
4966 | NEIGHBOR_ADDR_STR2 | |
4967 | "Advertise capability to the peer\n" | |
4968 | "Advertise dynamic capability to this neighbor\n") | |
4969 | { | |
d62a17ae | 4970 | int idx_peer = 1; |
4971 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4972 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4973 | } |
4974 | ||
4975 | DEFUN (no_neighbor_capability_dynamic, | |
4976 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4977 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4978 | NO_STR |
4979 | NEIGHBOR_STR | |
4980 | NEIGHBOR_ADDR_STR2 | |
4981 | "Advertise capability to the peer\n" | |
4982 | "Advertise dynamic capability to this neighbor\n") | |
4983 | { | |
d62a17ae | 4984 | int idx_peer = 2; |
4985 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4986 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4987 | } |
6b0655a2 | 4988 | |
718e3744 | 4989 | /* neighbor dont-capability-negotiate */ |
4990 | DEFUN (neighbor_dont_capability_negotiate, | |
4991 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4992 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4993 | NEIGHBOR_STR |
4994 | NEIGHBOR_ADDR_STR2 | |
4995 | "Do not perform capability negotiation\n") | |
4996 | { | |
d62a17ae | 4997 | int idx_peer = 1; |
4998 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4999 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5000 | } |
5001 | ||
5002 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5003 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5004 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5005 | NO_STR |
5006 | NEIGHBOR_STR | |
5007 | NEIGHBOR_ADDR_STR2 | |
5008 | "Do not perform capability negotiation\n") | |
5009 | { | |
d62a17ae | 5010 | int idx_peer = 2; |
5011 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5012 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5013 | } |
6b0655a2 | 5014 | |
8a92a8a0 DS |
5015 | /* neighbor capability extended next hop encoding */ |
5016 | DEFUN (neighbor_capability_enhe, | |
5017 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 5018 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
5019 | NEIGHBOR_STR |
5020 | NEIGHBOR_ADDR_STR2 | |
5021 | "Advertise capability to the peer\n" | |
5022 | "Advertise extended next-hop capability to the peer\n") | |
5023 | { | |
d62a17ae | 5024 | int idx_peer = 1; |
5025 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5026 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5027 | } |
5028 | ||
5029 | DEFUN (no_neighbor_capability_enhe, | |
5030 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 5031 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
5032 | NO_STR |
5033 | NEIGHBOR_STR | |
5034 | NEIGHBOR_ADDR_STR2 | |
5035 | "Advertise capability to the peer\n" | |
5036 | "Advertise extended next-hop capability to the peer\n") | |
5037 | { | |
d62a17ae | 5038 | int idx_peer = 2; |
5039 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5040 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5041 | } |
5042 | ||
d62a17ae | 5043 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5044 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5045 | int set) |
718e3744 | 5046 | { |
d62a17ae | 5047 | int ret; |
5048 | struct peer *peer; | |
718e3744 | 5049 | |
d62a17ae | 5050 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5051 | if (!peer) | |
5052 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5053 | |
d62a17ae | 5054 | if (set) |
5055 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5056 | else | |
5057 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5058 | |
d62a17ae | 5059 | return bgp_vty_return(vty, ret); |
718e3744 | 5060 | } |
5061 | ||
d62a17ae | 5062 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5063 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5064 | { |
d62a17ae | 5065 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5066 | } |
5067 | ||
d62a17ae | 5068 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5069 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5070 | { |
d62a17ae | 5071 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5072 | } |
6b0655a2 | 5073 | |
718e3744 | 5074 | /* neighbor capability orf prefix-list. */ |
5075 | DEFUN (neighbor_capability_orf_prefix, | |
5076 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5077 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5078 | NEIGHBOR_STR |
5079 | NEIGHBOR_ADDR_STR2 | |
5080 | "Advertise capability to the peer\n" | |
5081 | "Advertise ORF capability to the peer\n" | |
5082 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5083 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5084 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5085 | "Capability to SEND the ORF to this neighbor\n") | |
5086 | { | |
d62a17ae | 5087 | int idx_send_recv = 5; |
db45f64d DS |
5088 | char *peer_str = argv[1]->arg; |
5089 | struct peer *peer; | |
5090 | afi_t afi = bgp_node_afi(vty); | |
5091 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5092 | |
db45f64d DS |
5093 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5094 | if (!peer) | |
d62a17ae | 5095 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5096 | |
db45f64d DS |
5097 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5098 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5099 | PEER_FLAG_ORF_PREFIX_SM); | |
5100 | ||
5101 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5102 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5103 | PEER_FLAG_ORF_PREFIX_RM); | |
5104 | ||
5105 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5106 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5107 | PEER_FLAG_ORF_PREFIX_SM) | |
5108 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5109 | PEER_FLAG_ORF_PREFIX_RM); | |
5110 | ||
5111 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5112 | } |
5113 | ||
5114 | ALIAS_HIDDEN( | |
5115 | neighbor_capability_orf_prefix, | |
5116 | neighbor_capability_orf_prefix_hidden_cmd, | |
5117 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5118 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5119 | "Advertise capability to the peer\n" | |
5120 | "Advertise ORF capability to the peer\n" | |
5121 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5122 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5123 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5124 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5125 | |
718e3744 | 5126 | DEFUN (no_neighbor_capability_orf_prefix, |
5127 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5128 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5129 | NO_STR |
5130 | NEIGHBOR_STR | |
5131 | NEIGHBOR_ADDR_STR2 | |
5132 | "Advertise capability to the peer\n" | |
5133 | "Advertise ORF capability to the peer\n" | |
5134 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5135 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5136 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5137 | "Capability to SEND the ORF to this neighbor\n") | |
5138 | { | |
d62a17ae | 5139 | int idx_send_recv = 6; |
db45f64d DS |
5140 | char *peer_str = argv[2]->arg; |
5141 | struct peer *peer; | |
5142 | afi_t afi = bgp_node_afi(vty); | |
5143 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5144 | |
db45f64d DS |
5145 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5146 | if (!peer) | |
d62a17ae | 5147 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5148 | |
db45f64d DS |
5149 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5150 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5151 | PEER_FLAG_ORF_PREFIX_SM); | |
5152 | ||
5153 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5154 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5155 | PEER_FLAG_ORF_PREFIX_RM); | |
5156 | ||
5157 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5158 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5159 | PEER_FLAG_ORF_PREFIX_SM) | |
5160 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5161 | PEER_FLAG_ORF_PREFIX_RM); | |
5162 | ||
5163 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5164 | } |
5165 | ||
5166 | ALIAS_HIDDEN( | |
5167 | no_neighbor_capability_orf_prefix, | |
5168 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5169 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5170 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5171 | "Advertise capability to the peer\n" | |
5172 | "Advertise ORF capability to the peer\n" | |
5173 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5174 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5175 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5176 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5177 | |
718e3744 | 5178 | /* neighbor next-hop-self. */ |
5179 | DEFUN (neighbor_nexthop_self, | |
5180 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 5181 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 5182 | NEIGHBOR_STR |
5183 | NEIGHBOR_ADDR_STR2 | |
a538debe | 5184 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 5185 | { |
d62a17ae | 5186 | int idx_peer = 1; |
5187 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5188 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5189 | } |
9e7a53c1 | 5190 | |
d62a17ae | 5191 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5192 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5193 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5194 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5195 | |
a538debe DS |
5196 | /* neighbor next-hop-self. */ |
5197 | DEFUN (neighbor_nexthop_self_force, | |
5198 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 5199 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
5200 | NEIGHBOR_STR |
5201 | NEIGHBOR_ADDR_STR2 | |
5202 | "Disable the next hop calculation for this neighbor\n" | |
5203 | "Set the next hop to self for reflected routes\n") | |
5204 | { | |
d62a17ae | 5205 | int idx_peer = 1; |
5206 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5207 | bgp_node_safi(vty), | |
5208 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5209 | } |
5210 | ||
d62a17ae | 5211 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5212 | neighbor_nexthop_self_force_hidden_cmd, | |
5213 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5214 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5215 | "Disable the next hop calculation for this neighbor\n" | |
5216 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5217 | |
1bc4e531 DA |
5218 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5219 | neighbor_nexthop_self_all_hidden_cmd, | |
5220 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5221 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5222 | "Disable the next hop calculation for this neighbor\n" | |
5223 | "Set the next hop to self for reflected routes\n") | |
5224 | ||
718e3744 | 5225 | DEFUN (no_neighbor_nexthop_self, |
5226 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 5227 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 5228 | NO_STR |
5229 | NEIGHBOR_STR | |
5230 | NEIGHBOR_ADDR_STR2 | |
a538debe | 5231 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 5232 | { |
d62a17ae | 5233 | int idx_peer = 2; |
5234 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5235 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5236 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5237 | } |
6b0655a2 | 5238 | |
d62a17ae | 5239 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5240 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5241 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5242 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5243 | |
88b8ed8d | 5244 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 5245 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 5246 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
5247 | NO_STR |
5248 | NEIGHBOR_STR | |
5249 | NEIGHBOR_ADDR_STR2 | |
5250 | "Disable the next hop calculation for this neighbor\n" | |
5251 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5252 | { |
d62a17ae | 5253 | int idx_peer = 2; |
5254 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5255 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5256 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5257 | } |
a538debe | 5258 | |
d62a17ae | 5259 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5260 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5261 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5262 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5263 | "Disable the next hop calculation for this neighbor\n" | |
5264 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5265 | |
1bc4e531 DA |
5266 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5267 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5268 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5269 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5270 | "Disable the next hop calculation for this neighbor\n" | |
5271 | "Set the next hop to self for reflected routes\n") | |
5272 | ||
c7122e14 DS |
5273 | /* neighbor as-override */ |
5274 | DEFUN (neighbor_as_override, | |
5275 | neighbor_as_override_cmd, | |
9ccf14f7 | 5276 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
5277 | NEIGHBOR_STR |
5278 | NEIGHBOR_ADDR_STR2 | |
5279 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
5280 | { | |
d62a17ae | 5281 | int idx_peer = 1; |
5282 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5283 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5284 | } |
5285 | ||
d62a17ae | 5286 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5287 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5288 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5289 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5290 | |
c7122e14 DS |
5291 | DEFUN (no_neighbor_as_override, |
5292 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 5293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
5294 | NO_STR |
5295 | NEIGHBOR_STR | |
5296 | NEIGHBOR_ADDR_STR2 | |
5297 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
5298 | { | |
d62a17ae | 5299 | int idx_peer = 2; |
5300 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5301 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5302 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5303 | } |
5304 | ||
d62a17ae | 5305 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5306 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5307 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5308 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5309 | |
718e3744 | 5310 | /* neighbor remove-private-AS. */ |
5311 | DEFUN (neighbor_remove_private_as, | |
5312 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 5313 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 5314 | NEIGHBOR_STR |
5315 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 5316 | "Remove private ASNs in outbound updates\n") |
718e3744 | 5317 | { |
d62a17ae | 5318 | int idx_peer = 1; |
5319 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5320 | bgp_node_safi(vty), | |
5321 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5322 | } |
5323 | ||
d62a17ae | 5324 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5325 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5326 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5327 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5328 | |
5000f21c DS |
5329 | DEFUN (neighbor_remove_private_as_all, |
5330 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 5331 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
5332 | NEIGHBOR_STR |
5333 | NEIGHBOR_ADDR_STR2 | |
5334 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 5335 | "Apply to all AS numbers\n") |
5000f21c | 5336 | { |
d62a17ae | 5337 | int idx_peer = 1; |
5338 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5339 | bgp_node_safi(vty), | |
5340 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5341 | } |
5342 | ||
d62a17ae | 5343 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5344 | neighbor_remove_private_as_all_hidden_cmd, | |
5345 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5346 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5347 | "Remove private ASNs in outbound updates\n" | |
5348 | "Apply to all AS numbers") | |
596c17ba | 5349 | |
5000f21c DS |
5350 | DEFUN (neighbor_remove_private_as_replace_as, |
5351 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 5352 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
5353 | NEIGHBOR_STR |
5354 | NEIGHBOR_ADDR_STR2 | |
5355 | "Remove private ASNs in outbound updates\n" | |
5356 | "Replace private ASNs with our ASN in outbound updates\n") | |
5357 | { | |
d62a17ae | 5358 | int idx_peer = 1; |
5359 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5360 | bgp_node_safi(vty), | |
5361 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5362 | } |
5363 | ||
d62a17ae | 5364 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5365 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5366 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5367 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5368 | "Remove private ASNs in outbound updates\n" | |
5369 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5370 | |
5000f21c DS |
5371 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5372 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 5373 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
5374 | NEIGHBOR_STR |
5375 | NEIGHBOR_ADDR_STR2 | |
5376 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 5377 | "Apply to all AS numbers\n" |
5000f21c DS |
5378 | "Replace private ASNs with our ASN in outbound updates\n") |
5379 | { | |
d62a17ae | 5380 | int idx_peer = 1; |
5381 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5382 | bgp_node_safi(vty), | |
5383 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
5384 | } |
5385 | ||
d62a17ae | 5386 | ALIAS_HIDDEN( |
5387 | neighbor_remove_private_as_all_replace_as, | |
5388 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5389 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5390 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5391 | "Remove private ASNs in outbound updates\n" | |
5392 | "Apply to all AS numbers\n" | |
5393 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5394 | |
718e3744 | 5395 | DEFUN (no_neighbor_remove_private_as, |
5396 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 5397 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 5398 | NO_STR |
5399 | NEIGHBOR_STR | |
5400 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 5401 | "Remove private ASNs in outbound updates\n") |
718e3744 | 5402 | { |
d62a17ae | 5403 | int idx_peer = 2; |
5404 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5405 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5406 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5407 | } |
6b0655a2 | 5408 | |
d62a17ae | 5409 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5410 | no_neighbor_remove_private_as_hidden_cmd, | |
5411 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5412 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5413 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5414 | |
88b8ed8d | 5415 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 5416 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 5417 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
5418 | NO_STR |
5419 | NEIGHBOR_STR | |
5420 | NEIGHBOR_ADDR_STR2 | |
5421 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 5422 | "Apply to all AS numbers\n") |
88b8ed8d | 5423 | { |
d62a17ae | 5424 | int idx_peer = 2; |
5425 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5426 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5427 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 5428 | } |
5000f21c | 5429 | |
d62a17ae | 5430 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5431 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5432 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5433 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5434 | "Remove private ASNs in outbound updates\n" | |
5435 | "Apply to all AS numbers\n") | |
596c17ba | 5436 | |
88b8ed8d | 5437 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 5438 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 5439 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
5440 | NO_STR |
5441 | NEIGHBOR_STR | |
5442 | NEIGHBOR_ADDR_STR2 | |
5443 | "Remove private ASNs in outbound updates\n" | |
5444 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5445 | { |
d62a17ae | 5446 | int idx_peer = 2; |
5447 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5448 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5449 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 5450 | } |
5000f21c | 5451 | |
d62a17ae | 5452 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5453 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5454 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5455 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5456 | "Remove private ASNs in outbound updates\n" | |
5457 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5458 | |
88b8ed8d | 5459 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 5460 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 5461 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
5462 | NO_STR |
5463 | NEIGHBOR_STR | |
5464 | NEIGHBOR_ADDR_STR2 | |
5465 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 5466 | "Apply to all AS numbers\n" |
5000f21c | 5467 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 5468 | { |
d62a17ae | 5469 | int idx_peer = 2; |
5470 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5471 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5472 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 5473 | } |
5000f21c | 5474 | |
d62a17ae | 5475 | ALIAS_HIDDEN( |
5476 | no_neighbor_remove_private_as_all_replace_as, | |
5477 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5478 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5479 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5480 | "Remove private ASNs in outbound updates\n" | |
5481 | "Apply to all AS numbers\n" | |
5482 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5483 | |
5000f21c | 5484 | |
718e3744 | 5485 | /* neighbor send-community. */ |
5486 | DEFUN (neighbor_send_community, | |
5487 | neighbor_send_community_cmd, | |
9ccf14f7 | 5488 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 5489 | NEIGHBOR_STR |
5490 | NEIGHBOR_ADDR_STR2 | |
5491 | "Send Community attribute to this neighbor\n") | |
5492 | { | |
d62a17ae | 5493 | int idx_peer = 1; |
27c05d4d | 5494 | |
d62a17ae | 5495 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5496 | bgp_node_safi(vty), | |
5497 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5498 | } |
5499 | ||
d62a17ae | 5500 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
5501 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5502 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5503 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5504 | |
718e3744 | 5505 | DEFUN (no_neighbor_send_community, |
5506 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 5507 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 5508 | NO_STR |
5509 | NEIGHBOR_STR | |
5510 | NEIGHBOR_ADDR_STR2 | |
5511 | "Send Community attribute to this neighbor\n") | |
5512 | { | |
d62a17ae | 5513 | int idx_peer = 2; |
27c05d4d | 5514 | |
d62a17ae | 5515 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5516 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5517 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5518 | } |
6b0655a2 | 5519 | |
d62a17ae | 5520 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
5521 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5522 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5523 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5524 | |
718e3744 | 5525 | /* neighbor send-community extended. */ |
5526 | DEFUN (neighbor_send_community_type, | |
5527 | neighbor_send_community_type_cmd, | |
57d187bc | 5528 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5529 | NEIGHBOR_STR |
5530 | NEIGHBOR_ADDR_STR2 | |
5531 | "Send Community attribute to this neighbor\n" | |
5532 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5533 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5534 | "Send Extended Community attributes\n" |
57d187bc JS |
5535 | "Send Standard Community attributes\n" |
5536 | "Send Large Community attributes\n") | |
718e3744 | 5537 | { |
27c05d4d | 5538 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
5539 | char *peer_str = argv[1]->arg; |
5540 | struct peer *peer; | |
5541 | afi_t afi = bgp_node_afi(vty); | |
5542 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5543 | |
db45f64d DS |
5544 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5545 | if (!peer) | |
5546 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5547 | |
db45f64d DS |
5548 | if (strmatch(type, "standard")) |
5549 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5550 | PEER_FLAG_SEND_COMMUNITY); | |
5551 | ||
5552 | if (strmatch(type, "extended")) | |
5553 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5554 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5555 | ||
5556 | if (strmatch(type, "large")) | |
5557 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5558 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5559 | ||
5560 | if (strmatch(type, "both")) { | |
5561 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5562 | PEER_FLAG_SEND_COMMUNITY) | |
5563 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5564 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5565 | } | |
5566 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5567 | PEER_FLAG_SEND_COMMUNITY) | |
5568 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5569 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5570 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5571 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5572 | } |
5573 | ||
5574 | ALIAS_HIDDEN( | |
5575 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5576 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5577 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5578 | "Send Community attribute to this neighbor\n" | |
5579 | "Send Standard and Extended Community attributes\n" | |
5580 | "Send Standard, Large and Extended Community attributes\n" | |
5581 | "Send Extended Community attributes\n" | |
5582 | "Send Standard Community attributes\n" | |
5583 | "Send Large Community attributes\n") | |
596c17ba | 5584 | |
718e3744 | 5585 | DEFUN (no_neighbor_send_community_type, |
5586 | no_neighbor_send_community_type_cmd, | |
57d187bc | 5587 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5588 | NO_STR |
5589 | NEIGHBOR_STR | |
5590 | NEIGHBOR_ADDR_STR2 | |
5591 | "Send Community attribute to this neighbor\n" | |
5592 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5593 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5594 | "Send Extended Community attributes\n" |
57d187bc JS |
5595 | "Send Standard Community attributes\n" |
5596 | "Send Large Community attributes\n") | |
718e3744 | 5597 | { |
d62a17ae | 5598 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
5599 | char *peer_str = argv[2]->arg; |
5600 | struct peer *peer; | |
5601 | afi_t afi = bgp_node_afi(vty); | |
5602 | safi_t safi = bgp_node_safi(vty); | |
5603 | ||
5604 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5605 | if (!peer) | |
5606 | return CMD_WARNING_CONFIG_FAILED; | |
5607 | ||
5608 | if (strmatch(type, "standard")) | |
5609 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5610 | PEER_FLAG_SEND_COMMUNITY); | |
5611 | ||
5612 | if (strmatch(type, "extended")) | |
5613 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5614 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5615 | ||
5616 | if (strmatch(type, "large")) | |
5617 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5618 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5619 | ||
5620 | if (strmatch(type, "both")) { | |
d62a17ae | 5621 | |
db45f64d DS |
5622 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5623 | PEER_FLAG_SEND_COMMUNITY) | |
5624 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5625 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5626 | } |
5627 | ||
db45f64d DS |
5628 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5629 | PEER_FLAG_SEND_COMMUNITY) | |
5630 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5631 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5632 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5633 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5634 | } |
5635 | ||
5636 | ALIAS_HIDDEN( | |
5637 | no_neighbor_send_community_type, | |
5638 | no_neighbor_send_community_type_hidden_cmd, | |
5639 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5640 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5641 | "Send Community attribute to this neighbor\n" | |
5642 | "Send Standard and Extended Community attributes\n" | |
5643 | "Send Standard, Large and Extended Community attributes\n" | |
5644 | "Send Extended Community attributes\n" | |
5645 | "Send Standard Community attributes\n" | |
5646 | "Send Large Community attributes\n") | |
596c17ba | 5647 | |
718e3744 | 5648 | /* neighbor soft-reconfig. */ |
5649 | DEFUN (neighbor_soft_reconfiguration, | |
5650 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5651 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5652 | NEIGHBOR_STR |
5653 | NEIGHBOR_ADDR_STR2 | |
5654 | "Per neighbor soft reconfiguration\n" | |
5655 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5656 | { | |
d62a17ae | 5657 | int idx_peer = 1; |
5658 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5659 | bgp_node_safi(vty), | |
5660 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5661 | } |
5662 | ||
d62a17ae | 5663 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5664 | neighbor_soft_reconfiguration_hidden_cmd, | |
5665 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5666 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5667 | "Per neighbor soft reconfiguration\n" | |
5668 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5669 | |
718e3744 | 5670 | DEFUN (no_neighbor_soft_reconfiguration, |
5671 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5672 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5673 | NO_STR |
5674 | NEIGHBOR_STR | |
5675 | NEIGHBOR_ADDR_STR2 | |
5676 | "Per neighbor soft reconfiguration\n" | |
5677 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5678 | { | |
d62a17ae | 5679 | int idx_peer = 2; |
5680 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5681 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5682 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5683 | } |
6b0655a2 | 5684 | |
d62a17ae | 5685 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5686 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5687 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5688 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5689 | "Per neighbor soft reconfiguration\n" | |
5690 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5691 | |
718e3744 | 5692 | DEFUN (neighbor_route_reflector_client, |
5693 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5694 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5695 | NEIGHBOR_STR |
5696 | NEIGHBOR_ADDR_STR2 | |
5697 | "Configure a neighbor as Route Reflector client\n") | |
5698 | { | |
d62a17ae | 5699 | int idx_peer = 1; |
5700 | struct peer *peer; | |
718e3744 | 5701 | |
5702 | ||
d62a17ae | 5703 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5704 | if (!peer) | |
5705 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5706 | |
d62a17ae | 5707 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5708 | bgp_node_safi(vty), | |
5709 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5710 | } |
5711 | ||
d62a17ae | 5712 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5713 | neighbor_route_reflector_client_hidden_cmd, | |
5714 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5715 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5716 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5717 | |
718e3744 | 5718 | DEFUN (no_neighbor_route_reflector_client, |
5719 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5720 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5721 | NO_STR |
5722 | NEIGHBOR_STR | |
5723 | NEIGHBOR_ADDR_STR2 | |
5724 | "Configure a neighbor as Route Reflector client\n") | |
5725 | { | |
d62a17ae | 5726 | int idx_peer = 2; |
5727 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5728 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5729 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5730 | } |
6b0655a2 | 5731 | |
d62a17ae | 5732 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5733 | no_neighbor_route_reflector_client_hidden_cmd, | |
5734 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5735 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5736 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5737 | |
718e3744 | 5738 | /* neighbor route-server-client. */ |
5739 | DEFUN (neighbor_route_server_client, | |
5740 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5741 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5742 | NEIGHBOR_STR |
5743 | NEIGHBOR_ADDR_STR2 | |
5744 | "Configure a neighbor as Route Server client\n") | |
5745 | { | |
d62a17ae | 5746 | int idx_peer = 1; |
5747 | struct peer *peer; | |
2a3d5731 | 5748 | |
d62a17ae | 5749 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5750 | if (!peer) | |
5751 | return CMD_WARNING_CONFIG_FAILED; | |
5752 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5753 | bgp_node_safi(vty), | |
5754 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5755 | } |
5756 | ||
d62a17ae | 5757 | ALIAS_HIDDEN(neighbor_route_server_client, |
5758 | neighbor_route_server_client_hidden_cmd, | |
5759 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5760 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5761 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5762 | |
718e3744 | 5763 | DEFUN (no_neighbor_route_server_client, |
5764 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5765 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5766 | NO_STR |
5767 | NEIGHBOR_STR | |
5768 | NEIGHBOR_ADDR_STR2 | |
5769 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5770 | { |
d62a17ae | 5771 | int idx_peer = 2; |
5772 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5773 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5774 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5775 | } |
6b0655a2 | 5776 | |
d62a17ae | 5777 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5778 | no_neighbor_route_server_client_hidden_cmd, | |
5779 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5780 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5781 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5782 | |
fee0f4c6 | 5783 | DEFUN (neighbor_nexthop_local_unchanged, |
5784 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5785 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5786 | NEIGHBOR_STR |
5787 | NEIGHBOR_ADDR_STR2 | |
5788 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5789 | "Leave link-local nexthop unchanged for this peer\n") | |
5790 | { | |
d62a17ae | 5791 | int idx_peer = 1; |
5792 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5793 | bgp_node_safi(vty), | |
5794 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5795 | } |
6b0655a2 | 5796 | |
fee0f4c6 | 5797 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5798 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5799 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5800 | NO_STR |
5801 | NEIGHBOR_STR | |
5802 | NEIGHBOR_ADDR_STR2 | |
5803 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5804 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5805 | { |
d62a17ae | 5806 | int idx_peer = 2; |
5807 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5808 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5809 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5810 | } |
6b0655a2 | 5811 | |
718e3744 | 5812 | DEFUN (neighbor_attr_unchanged, |
5813 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5814 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5815 | NEIGHBOR_STR |
5816 | NEIGHBOR_ADDR_STR2 | |
5817 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5818 | "As-path attribute\n" | |
5819 | "Nexthop attribute\n" | |
a8206004 | 5820 | "Med attribute\n") |
718e3744 | 5821 | { |
d62a17ae | 5822 | int idx = 0; |
8eeb0335 DW |
5823 | char *peer_str = argv[1]->arg; |
5824 | struct peer *peer; | |
db45f64d DS |
5825 | bool aspath = false; |
5826 | bool nexthop = false; | |
5827 | bool med = false; | |
8eeb0335 DW |
5828 | afi_t afi = bgp_node_afi(vty); |
5829 | safi_t safi = bgp_node_safi(vty); | |
db45f64d | 5830 | int ret = 0; |
8eeb0335 DW |
5831 | |
5832 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5833 | if (!peer) | |
5834 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5835 | |
5836 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5837 | aspath = true; |
5838 | ||
d62a17ae | 5839 | idx = 0; |
5840 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5841 | nexthop = true; |
5842 | ||
d62a17ae | 5843 | idx = 0; |
5844 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5845 | med = true; |
d62a17ae | 5846 | |
8eeb0335 | 5847 | /* no flags means all of them! */ |
db45f64d DS |
5848 | if (!aspath && !nexthop && !med) { |
5849 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5850 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5851 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5852 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5853 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5854 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5855 | } else { |
db45f64d DS |
5856 | if (!aspath) { |
5857 | if (peer_af_flag_check(peer, afi, safi, | |
5858 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
5859 | ret |= peer_af_flag_unset_vty( | |
5860 | vty, peer_str, afi, safi, | |
5861 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5862 | } | |
5863 | } else | |
5864 | ret |= peer_af_flag_set_vty( | |
5865 | vty, peer_str, afi, safi, | |
5866 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5867 | ||
5868 | if (!nexthop) { | |
5869 | if (peer_af_flag_check(peer, afi, safi, | |
5870 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
5871 | ret |= peer_af_flag_unset_vty( | |
5872 | vty, peer_str, afi, safi, | |
5873 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5874 | } | |
5875 | } else | |
5876 | ret |= peer_af_flag_set_vty( | |
5877 | vty, peer_str, afi, safi, | |
5878 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5879 | ||
5880 | if (!med) { | |
5881 | if (peer_af_flag_check(peer, afi, safi, | |
5882 | PEER_FLAG_MED_UNCHANGED)) { | |
5883 | ret |= peer_af_flag_unset_vty( | |
5884 | vty, peer_str, afi, safi, | |
5885 | PEER_FLAG_MED_UNCHANGED); | |
5886 | } | |
5887 | } else | |
5888 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5889 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 5890 | } |
5891 | ||
db45f64d | 5892 | return ret; |
d62a17ae | 5893 | } |
5894 | ||
5895 | ALIAS_HIDDEN( | |
5896 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5897 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5898 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5899 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5900 | "As-path attribute\n" | |
5901 | "Nexthop attribute\n" | |
5902 | "Med attribute\n") | |
596c17ba | 5903 | |
718e3744 | 5904 | DEFUN (no_neighbor_attr_unchanged, |
5905 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5906 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5907 | NO_STR |
718e3744 | 5908 | NEIGHBOR_STR |
5909 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5910 | "BGP attribute is propagated unchanged to this neighbor\n" |
5911 | "As-path attribute\n" | |
40e718b5 | 5912 | "Nexthop attribute\n" |
a8206004 | 5913 | "Med attribute\n") |
718e3744 | 5914 | { |
d62a17ae | 5915 | int idx = 0; |
db45f64d DS |
5916 | char *peer_str = argv[2]->arg; |
5917 | struct peer *peer; | |
5918 | bool aspath = false; | |
5919 | bool nexthop = false; | |
5920 | bool med = false; | |
5921 | afi_t afi = bgp_node_afi(vty); | |
5922 | safi_t safi = bgp_node_safi(vty); | |
5923 | int ret = 0; | |
5924 | ||
5925 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5926 | if (!peer) | |
5927 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5928 | |
5929 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5930 | aspath = true; |
5931 | ||
d62a17ae | 5932 | idx = 0; |
5933 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5934 | nexthop = true; |
5935 | ||
d62a17ae | 5936 | idx = 0; |
5937 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5938 | med = true; |
d62a17ae | 5939 | |
db45f64d DS |
5940 | if (!aspath && !nexthop && !med) // no flags means all of them! |
5941 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5942 | PEER_FLAG_AS_PATH_UNCHANGED) | |
5943 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5944 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
5945 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5946 | PEER_FLAG_MED_UNCHANGED); | |
5947 | ||
5948 | if (aspath) | |
5949 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5950 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5951 | ||
5952 | if (nexthop) | |
5953 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5954 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 5955 | |
db45f64d DS |
5956 | if (med) |
5957 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5958 | PEER_FLAG_MED_UNCHANGED); | |
5959 | ||
5960 | return ret; | |
d62a17ae | 5961 | } |
5962 | ||
5963 | ALIAS_HIDDEN( | |
5964 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5965 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5966 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5967 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5968 | "As-path attribute\n" | |
5969 | "Nexthop attribute\n" | |
5970 | "Med attribute\n") | |
718e3744 | 5971 | |
718e3744 | 5972 | /* EBGP multihop configuration. */ |
d62a17ae | 5973 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5974 | const char *ttl_str) | |
718e3744 | 5975 | { |
d62a17ae | 5976 | struct peer *peer; |
5977 | unsigned int ttl; | |
718e3744 | 5978 | |
d62a17ae | 5979 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5980 | if (!peer) | |
5981 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5982 | |
d62a17ae | 5983 | if (peer->conf_if) |
5984 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5985 | |
d62a17ae | 5986 | if (!ttl_str) |
5987 | ttl = MAXTTL; | |
5988 | else | |
5989 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5990 | |
d62a17ae | 5991 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5992 | } |
5993 | ||
d62a17ae | 5994 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5995 | { |
d62a17ae | 5996 | struct peer *peer; |
718e3744 | 5997 | |
d62a17ae | 5998 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5999 | if (!peer) | |
6000 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6001 | |
d62a17ae | 6002 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6003 | } |
6004 | ||
6005 | /* neighbor ebgp-multihop. */ | |
6006 | DEFUN (neighbor_ebgp_multihop, | |
6007 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 6008 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 6009 | NEIGHBOR_STR |
6010 | NEIGHBOR_ADDR_STR2 | |
6011 | "Allow EBGP neighbors not on directly connected networks\n") | |
6012 | { | |
d62a17ae | 6013 | int idx_peer = 1; |
6014 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6015 | } |
6016 | ||
6017 | DEFUN (neighbor_ebgp_multihop_ttl, | |
6018 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 6019 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 6020 | NEIGHBOR_STR |
6021 | NEIGHBOR_ADDR_STR2 | |
6022 | "Allow EBGP neighbors not on directly connected networks\n" | |
6023 | "maximum hop count\n") | |
6024 | { | |
d62a17ae | 6025 | int idx_peer = 1; |
6026 | int idx_number = 3; | |
6027 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6028 | argv[idx_number]->arg); | |
718e3744 | 6029 | } |
6030 | ||
6031 | DEFUN (no_neighbor_ebgp_multihop, | |
6032 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 6033 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 6034 | NO_STR |
6035 | NEIGHBOR_STR | |
6036 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6037 | "Allow EBGP neighbors not on directly connected networks\n" |
6038 | "maximum hop count\n") | |
718e3744 | 6039 | { |
d62a17ae | 6040 | int idx_peer = 2; |
6041 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6042 | } |
6043 | ||
6b0655a2 | 6044 | |
6ffd2079 | 6045 | /* disable-connected-check */ |
6046 | DEFUN (neighbor_disable_connected_check, | |
6047 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 6048 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 6049 | NEIGHBOR_STR |
7ebe625c | 6050 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
6051 | "one-hop away EBGP peer using loopback address\n" |
6052 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6053 | { |
d62a17ae | 6054 | int idx_peer = 1; |
6055 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6056 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6057 | } |
6058 | ||
6059 | DEFUN (no_neighbor_disable_connected_check, | |
6060 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 6061 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 6062 | NO_STR |
6063 | NEIGHBOR_STR | |
7ebe625c | 6064 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
6065 | "one-hop away EBGP peer using loopback address\n" |
6066 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6067 | { |
d62a17ae | 6068 | int idx_peer = 2; |
6069 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6070 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6071 | } |
6072 | ||
47cbc09b PM |
6073 | |
6074 | /* enforce-first-as */ | |
6075 | DEFUN (neighbor_enforce_first_as, | |
6076 | neighbor_enforce_first_as_cmd, | |
6077 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6078 | NEIGHBOR_STR | |
6079 | NEIGHBOR_ADDR_STR2 | |
6080 | "Enforce the first AS for EBGP routes\n") | |
6081 | { | |
6082 | int idx_peer = 1; | |
6083 | ||
6084 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6085 | PEER_FLAG_ENFORCE_FIRST_AS); | |
6086 | } | |
6087 | ||
6088 | DEFUN (no_neighbor_enforce_first_as, | |
6089 | no_neighbor_enforce_first_as_cmd, | |
6090 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6091 | NO_STR | |
6092 | NEIGHBOR_STR | |
6093 | NEIGHBOR_ADDR_STR2 | |
6094 | "Enforce the first AS for EBGP routes\n") | |
6095 | { | |
6096 | int idx_peer = 2; | |
6097 | ||
6098 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6099 | PEER_FLAG_ENFORCE_FIRST_AS); | |
6100 | } | |
6101 | ||
6102 | ||
718e3744 | 6103 | DEFUN (neighbor_description, |
6104 | neighbor_description_cmd, | |
e961923c | 6105 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 6106 | NEIGHBOR_STR |
6107 | NEIGHBOR_ADDR_STR2 | |
6108 | "Neighbor specific description\n" | |
6109 | "Up to 80 characters describing this neighbor\n") | |
6110 | { | |
d62a17ae | 6111 | int idx_peer = 1; |
6112 | int idx_line = 3; | |
6113 | struct peer *peer; | |
6114 | char *str; | |
718e3744 | 6115 | |
d62a17ae | 6116 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6117 | if (!peer) | |
6118 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6119 | |
d62a17ae | 6120 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6121 | |
d62a17ae | 6122 | peer_description_set(peer, str); |
718e3744 | 6123 | |
d62a17ae | 6124 | XFREE(MTYPE_TMP, str); |
718e3744 | 6125 | |
d62a17ae | 6126 | return CMD_SUCCESS; |
718e3744 | 6127 | } |
6128 | ||
6129 | DEFUN (no_neighbor_description, | |
6130 | no_neighbor_description_cmd, | |
a14810f4 | 6131 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 6132 | NO_STR |
6133 | NEIGHBOR_STR | |
6134 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 6135 | "Neighbor specific description\n") |
718e3744 | 6136 | { |
d62a17ae | 6137 | int idx_peer = 2; |
6138 | struct peer *peer; | |
718e3744 | 6139 | |
d62a17ae | 6140 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6141 | if (!peer) | |
6142 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6143 | |
d62a17ae | 6144 | peer_description_unset(peer); |
718e3744 | 6145 | |
d62a17ae | 6146 | return CMD_SUCCESS; |
718e3744 | 6147 | } |
6148 | ||
a14810f4 PM |
6149 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
6150 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6151 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6152 | "Neighbor specific description\n" | |
6153 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6154 | |
718e3744 | 6155 | /* Neighbor update-source. */ |
d62a17ae | 6156 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
6157 | const char *source_str) | |
6158 | { | |
6159 | struct peer *peer; | |
6160 | struct prefix p; | |
a14810f4 | 6161 | union sockunion su; |
d62a17ae | 6162 | |
6163 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6164 | if (!peer) | |
6165 | return CMD_WARNING_CONFIG_FAILED; | |
6166 | ||
6167 | if (peer->conf_if) | |
6168 | return CMD_WARNING; | |
6169 | ||
6170 | if (source_str) { | |
a14810f4 | 6171 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 6172 | peer_update_source_addr_set(peer, &su); |
6173 | else { | |
6174 | if (str2prefix(source_str, &p)) { | |
6175 | vty_out(vty, | |
6176 | "%% Invalid update-source, remove prefix length \n"); | |
6177 | return CMD_WARNING_CONFIG_FAILED; | |
6178 | } else | |
6179 | peer_update_source_if_set(peer, source_str); | |
6180 | } | |
6181 | } else | |
6182 | peer_update_source_unset(peer); | |
6183 | ||
6184 | return CMD_SUCCESS; | |
6185 | } | |
6186 | ||
6187 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
6188 | "IPv4 address\n" \ | |
6189 | "IPv6 address\n" \ | |
6190 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6191 | |
718e3744 | 6192 | DEFUN (neighbor_update_source, |
6193 | neighbor_update_source_cmd, | |
9ccf14f7 | 6194 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 6195 | NEIGHBOR_STR |
6196 | NEIGHBOR_ADDR_STR2 | |
6197 | "Source of routing updates\n" | |
369688c0 | 6198 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 6199 | { |
d62a17ae | 6200 | int idx_peer = 1; |
6201 | int idx_peer_2 = 3; | |
6202 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
6203 | argv[idx_peer_2]->arg); | |
718e3744 | 6204 | } |
6205 | ||
6206 | DEFUN (no_neighbor_update_source, | |
6207 | no_neighbor_update_source_cmd, | |
c7178fe7 | 6208 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 6209 | NO_STR |
6210 | NEIGHBOR_STR | |
6211 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
6212 | "Source of routing updates\n" |
6213 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6214 | { |
d62a17ae | 6215 | int idx_peer = 2; |
6216 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6217 | } |
6b0655a2 | 6218 | |
d62a17ae | 6219 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6220 | afi_t afi, safi_t safi, | |
6221 | const char *rmap, int set) | |
718e3744 | 6222 | { |
d62a17ae | 6223 | int ret; |
6224 | struct peer *peer; | |
80912664 | 6225 | struct route_map *route_map = NULL; |
718e3744 | 6226 | |
d62a17ae | 6227 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6228 | if (!peer) | |
6229 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6230 | |
1de27621 | 6231 | if (set) { |
80912664 DS |
6232 | if (rmap) |
6233 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6234 | ret = peer_default_originate_set(peer, afi, safi, |
6235 | rmap, route_map); | |
6236 | } else | |
d62a17ae | 6237 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6238 | |
d62a17ae | 6239 | return bgp_vty_return(vty, ret); |
718e3744 | 6240 | } |
6241 | ||
6242 | /* neighbor default-originate. */ | |
6243 | DEFUN (neighbor_default_originate, | |
6244 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6245 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6246 | NEIGHBOR_STR |
6247 | NEIGHBOR_ADDR_STR2 | |
6248 | "Originate default route to this neighbor\n") | |
6249 | { | |
d62a17ae | 6250 | int idx_peer = 1; |
6251 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6252 | bgp_node_afi(vty), | |
6253 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6254 | } |
6255 | ||
d62a17ae | 6256 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6257 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6258 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6259 | "Originate default route to this neighbor\n") | |
596c17ba | 6260 | |
718e3744 | 6261 | DEFUN (neighbor_default_originate_rmap, |
6262 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 6263 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 6264 | NEIGHBOR_STR |
6265 | NEIGHBOR_ADDR_STR2 | |
6266 | "Originate default route to this neighbor\n" | |
6267 | "Route-map to specify criteria to originate default\n" | |
6268 | "route-map name\n") | |
6269 | { | |
d62a17ae | 6270 | int idx_peer = 1; |
6271 | int idx_word = 4; | |
6272 | return peer_default_originate_set_vty( | |
6273 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6274 | argv[idx_word]->arg, 1); | |
718e3744 | 6275 | } |
6276 | ||
d62a17ae | 6277 | ALIAS_HIDDEN( |
6278 | neighbor_default_originate_rmap, | |
6279 | neighbor_default_originate_rmap_hidden_cmd, | |
6280 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
6281 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6282 | "Originate default route to this neighbor\n" | |
6283 | "Route-map to specify criteria to originate default\n" | |
6284 | "route-map name\n") | |
596c17ba | 6285 | |
718e3744 | 6286 | DEFUN (no_neighbor_default_originate, |
6287 | no_neighbor_default_originate_cmd, | |
a636c635 | 6288 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 6289 | NO_STR |
6290 | NEIGHBOR_STR | |
6291 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6292 | "Originate default route to this neighbor\n" |
6293 | "Route-map to specify criteria to originate default\n" | |
6294 | "route-map name\n") | |
718e3744 | 6295 | { |
d62a17ae | 6296 | int idx_peer = 2; |
6297 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6298 | bgp_node_afi(vty), | |
6299 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 6300 | } |
6301 | ||
d62a17ae | 6302 | ALIAS_HIDDEN( |
6303 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
6304 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
6305 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6306 | "Originate default route to this neighbor\n" | |
6307 | "Route-map to specify criteria to originate default\n" | |
6308 | "route-map name\n") | |
596c17ba | 6309 | |
6b0655a2 | 6310 | |
718e3744 | 6311 | /* Set neighbor's BGP port. */ |
d62a17ae | 6312 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
6313 | const char *port_str) | |
6314 | { | |
6315 | struct peer *peer; | |
d7c0a89a | 6316 | uint16_t port; |
d62a17ae | 6317 | struct servent *sp; |
6318 | ||
6319 | peer = peer_lookup_vty(vty, ip_str); | |
6320 | if (!peer) | |
6321 | return CMD_WARNING_CONFIG_FAILED; | |
6322 | ||
6323 | if (!port_str) { | |
6324 | sp = getservbyname("bgp", "tcp"); | |
6325 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
6326 | } else { | |
6327 | port = strtoul(port_str, NULL, 10); | |
6328 | } | |
718e3744 | 6329 | |
d62a17ae | 6330 | peer_port_set(peer, port); |
718e3744 | 6331 | |
d62a17ae | 6332 | return CMD_SUCCESS; |
718e3744 | 6333 | } |
6334 | ||
f418446b | 6335 | /* Set specified peer's BGP port. */ |
718e3744 | 6336 | DEFUN (neighbor_port, |
6337 | neighbor_port_cmd, | |
9ccf14f7 | 6338 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 6339 | NEIGHBOR_STR |
6340 | NEIGHBOR_ADDR_STR | |
6341 | "Neighbor's BGP port\n" | |
6342 | "TCP port number\n") | |
6343 | { | |
d62a17ae | 6344 | int idx_ip = 1; |
6345 | int idx_number = 3; | |
6346 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
6347 | argv[idx_number]->arg); | |
718e3744 | 6348 | } |
6349 | ||
6350 | DEFUN (no_neighbor_port, | |
6351 | no_neighbor_port_cmd, | |
9ccf14f7 | 6352 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 6353 | NO_STR |
6354 | NEIGHBOR_STR | |
6355 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
6356 | "Neighbor's BGP port\n" |
6357 | "TCP port number\n") | |
718e3744 | 6358 | { |
d62a17ae | 6359 | int idx_ip = 2; |
6360 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 6361 | } |
6362 | ||
6b0655a2 | 6363 | |
718e3744 | 6364 | /* neighbor weight. */ |
d62a17ae | 6365 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6366 | safi_t safi, const char *weight_str) | |
718e3744 | 6367 | { |
d62a17ae | 6368 | int ret; |
6369 | struct peer *peer; | |
6370 | unsigned long weight; | |
718e3744 | 6371 | |
d62a17ae | 6372 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6373 | if (!peer) | |
6374 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6375 | |
d62a17ae | 6376 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 6377 | |
d62a17ae | 6378 | ret = peer_weight_set(peer, afi, safi, weight); |
6379 | return bgp_vty_return(vty, ret); | |
718e3744 | 6380 | } |
6381 | ||
d62a17ae | 6382 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6383 | safi_t safi) | |
718e3744 | 6384 | { |
d62a17ae | 6385 | int ret; |
6386 | struct peer *peer; | |
718e3744 | 6387 | |
d62a17ae | 6388 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6389 | if (!peer) | |
6390 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6391 | |
d62a17ae | 6392 | ret = peer_weight_unset(peer, afi, safi); |
6393 | return bgp_vty_return(vty, ret); | |
718e3744 | 6394 | } |
6395 | ||
6396 | DEFUN (neighbor_weight, | |
6397 | neighbor_weight_cmd, | |
9ccf14f7 | 6398 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 6399 | NEIGHBOR_STR |
6400 | NEIGHBOR_ADDR_STR2 | |
6401 | "Set default weight for routes from this neighbor\n" | |
6402 | "default weight\n") | |
6403 | { | |
d62a17ae | 6404 | int idx_peer = 1; |
6405 | int idx_number = 3; | |
6406 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6407 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 6408 | } |
6409 | ||
d62a17ae | 6410 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
6411 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6412 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6413 | "Set default weight for routes from this neighbor\n" | |
6414 | "default weight\n") | |
596c17ba | 6415 | |
718e3744 | 6416 | DEFUN (no_neighbor_weight, |
6417 | no_neighbor_weight_cmd, | |
9ccf14f7 | 6418 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 6419 | NO_STR |
6420 | NEIGHBOR_STR | |
6421 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
6422 | "Set default weight for routes from this neighbor\n" |
6423 | "default weight\n") | |
718e3744 | 6424 | { |
d62a17ae | 6425 | int idx_peer = 2; |
6426 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
6427 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 6428 | } |
6429 | ||
d62a17ae | 6430 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
6431 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6432 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6433 | "Set default weight for routes from this neighbor\n" | |
6434 | "default weight\n") | |
596c17ba | 6435 | |
6b0655a2 | 6436 | |
718e3744 | 6437 | /* Override capability negotiation. */ |
6438 | DEFUN (neighbor_override_capability, | |
6439 | neighbor_override_capability_cmd, | |
9ccf14f7 | 6440 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 6441 | NEIGHBOR_STR |
6442 | NEIGHBOR_ADDR_STR2 | |
6443 | "Override capability negotiation result\n") | |
6444 | { | |
d62a17ae | 6445 | int idx_peer = 1; |
6446 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6447 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6448 | } |
6449 | ||
6450 | DEFUN (no_neighbor_override_capability, | |
6451 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 6452 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 6453 | NO_STR |
6454 | NEIGHBOR_STR | |
6455 | NEIGHBOR_ADDR_STR2 | |
6456 | "Override capability negotiation result\n") | |
6457 | { | |
d62a17ae | 6458 | int idx_peer = 2; |
6459 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6460 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6461 | } |
6b0655a2 | 6462 | |
718e3744 | 6463 | DEFUN (neighbor_strict_capability, |
6464 | neighbor_strict_capability_cmd, | |
9fb964de | 6465 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 6466 | NEIGHBOR_STR |
9fb964de | 6467 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6468 | "Strict capability negotiation match\n") |
6469 | { | |
9fb964de PM |
6470 | int idx_peer = 1; |
6471 | ||
6472 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 6473 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 6474 | } |
6475 | ||
6476 | DEFUN (no_neighbor_strict_capability, | |
6477 | no_neighbor_strict_capability_cmd, | |
9fb964de | 6478 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 6479 | NO_STR |
6480 | NEIGHBOR_STR | |
9fb964de | 6481 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6482 | "Strict capability negotiation match\n") |
6483 | { | |
9fb964de PM |
6484 | int idx_peer = 2; |
6485 | ||
6486 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 6487 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 6488 | } |
6b0655a2 | 6489 | |
d62a17ae | 6490 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
6491 | const char *keep_str, const char *hold_str) | |
718e3744 | 6492 | { |
d62a17ae | 6493 | int ret; |
6494 | struct peer *peer; | |
d7c0a89a QY |
6495 | uint32_t keepalive; |
6496 | uint32_t holdtime; | |
718e3744 | 6497 | |
d62a17ae | 6498 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6499 | if (!peer) | |
6500 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6501 | |
d62a17ae | 6502 | keepalive = strtoul(keep_str, NULL, 10); |
6503 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 6504 | |
d62a17ae | 6505 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 6506 | |
d62a17ae | 6507 | return bgp_vty_return(vty, ret); |
718e3744 | 6508 | } |
6b0655a2 | 6509 | |
d62a17ae | 6510 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6511 | { |
d62a17ae | 6512 | int ret; |
6513 | struct peer *peer; | |
718e3744 | 6514 | |
d62a17ae | 6515 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6516 | if (!peer) | |
6517 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6518 | |
d62a17ae | 6519 | ret = peer_timers_unset(peer); |
718e3744 | 6520 | |
d62a17ae | 6521 | return bgp_vty_return(vty, ret); |
718e3744 | 6522 | } |
6523 | ||
6524 | DEFUN (neighbor_timers, | |
6525 | neighbor_timers_cmd, | |
9ccf14f7 | 6526 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 6527 | NEIGHBOR_STR |
6528 | NEIGHBOR_ADDR_STR2 | |
6529 | "BGP per neighbor timers\n" | |
6530 | "Keepalive interval\n" | |
6531 | "Holdtime\n") | |
6532 | { | |
d62a17ae | 6533 | int idx_peer = 1; |
6534 | int idx_number = 3; | |
6535 | int idx_number_2 = 4; | |
6536 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6537 | argv[idx_number]->arg, | |
6538 | argv[idx_number_2]->arg); | |
718e3744 | 6539 | } |
6540 | ||
6541 | DEFUN (no_neighbor_timers, | |
6542 | no_neighbor_timers_cmd, | |
9ccf14f7 | 6543 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 6544 | NO_STR |
6545 | NEIGHBOR_STR | |
6546 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
6547 | "BGP per neighbor timers\n" |
6548 | "Keepalive interval\n" | |
6549 | "Holdtime\n") | |
718e3744 | 6550 | { |
d62a17ae | 6551 | int idx_peer = 2; |
6552 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6553 | } |
6b0655a2 | 6554 | |
813d4307 | 6555 | |
d62a17ae | 6556 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
6557 | const char *time_str) | |
718e3744 | 6558 | { |
d62a17ae | 6559 | int ret; |
6560 | struct peer *peer; | |
d7c0a89a | 6561 | uint32_t connect; |
718e3744 | 6562 | |
d62a17ae | 6563 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6564 | if (!peer) | |
6565 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6566 | |
d62a17ae | 6567 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 6568 | |
d62a17ae | 6569 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 6570 | |
d62a17ae | 6571 | return bgp_vty_return(vty, ret); |
718e3744 | 6572 | } |
6573 | ||
d62a17ae | 6574 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6575 | { |
d62a17ae | 6576 | int ret; |
6577 | struct peer *peer; | |
718e3744 | 6578 | |
d62a17ae | 6579 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6580 | if (!peer) | |
6581 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6582 | |
d62a17ae | 6583 | ret = peer_timers_connect_unset(peer); |
718e3744 | 6584 | |
d62a17ae | 6585 | return bgp_vty_return(vty, ret); |
718e3744 | 6586 | } |
6587 | ||
6588 | DEFUN (neighbor_timers_connect, | |
6589 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 6590 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 6591 | NEIGHBOR_STR |
966f821c | 6592 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6593 | "BGP per neighbor timers\n" |
6594 | "BGP connect timer\n" | |
6595 | "Connect timer\n") | |
6596 | { | |
d62a17ae | 6597 | int idx_peer = 1; |
6598 | int idx_number = 4; | |
6599 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6600 | argv[idx_number]->arg); | |
718e3744 | 6601 | } |
6602 | ||
6603 | DEFUN (no_neighbor_timers_connect, | |
6604 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 6605 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 6606 | NO_STR |
6607 | NEIGHBOR_STR | |
966f821c | 6608 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6609 | "BGP per neighbor timers\n" |
8334fd5a DW |
6610 | "BGP connect timer\n" |
6611 | "Connect timer\n") | |
718e3744 | 6612 | { |
d62a17ae | 6613 | int idx_peer = 2; |
6614 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6615 | } |
6616 | ||
6b0655a2 | 6617 | |
d62a17ae | 6618 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
6619 | const char *time_str, int set) | |
718e3744 | 6620 | { |
d62a17ae | 6621 | int ret; |
6622 | struct peer *peer; | |
d7c0a89a | 6623 | uint32_t routeadv = 0; |
718e3744 | 6624 | |
d62a17ae | 6625 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6626 | if (!peer) | |
6627 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6628 | |
d62a17ae | 6629 | if (time_str) |
6630 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 6631 | |
d62a17ae | 6632 | if (set) |
6633 | ret = peer_advertise_interval_set(peer, routeadv); | |
6634 | else | |
6635 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 6636 | |
d62a17ae | 6637 | return bgp_vty_return(vty, ret); |
718e3744 | 6638 | } |
6639 | ||
6640 | DEFUN (neighbor_advertise_interval, | |
6641 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6642 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 6643 | NEIGHBOR_STR |
966f821c | 6644 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6645 | "Minimum interval between sending BGP routing updates\n" |
6646 | "time in seconds\n") | |
6647 | { | |
d62a17ae | 6648 | int idx_peer = 1; |
6649 | int idx_number = 3; | |
6650 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6651 | argv[idx_number]->arg, 1); | |
718e3744 | 6652 | } |
6653 | ||
6654 | DEFUN (no_neighbor_advertise_interval, | |
6655 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6656 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 6657 | NO_STR |
6658 | NEIGHBOR_STR | |
966f821c | 6659 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
6660 | "Minimum interval between sending BGP routing updates\n" |
6661 | "time in seconds\n") | |
718e3744 | 6662 | { |
d62a17ae | 6663 | int idx_peer = 2; |
6664 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6665 | } |
6666 | ||
6b0655a2 | 6667 | |
518f0eb1 DS |
6668 | /* Time to wait before processing route-map updates */ |
6669 | DEFUN (bgp_set_route_map_delay_timer, | |
6670 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6671 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6672 | SET_STR |
6673 | "BGP route-map delay timer\n" | |
6674 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6675 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6676 | { |
d62a17ae | 6677 | int idx_number = 3; |
d7c0a89a | 6678 | uint32_t rmap_delay_timer; |
d62a17ae | 6679 | |
6680 | if (argv[idx_number]->arg) { | |
6681 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6682 | bm->rmap_update_timer = rmap_delay_timer; | |
6683 | ||
6684 | /* if the dynamic update handling is being disabled, and a timer | |
6685 | * is | |
6686 | * running, stop the timer and act as if the timer has already | |
6687 | * fired. | |
6688 | */ | |
6689 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6690 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6691 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6692 | NULL, 0); | |
6693 | } | |
6694 | return CMD_SUCCESS; | |
6695 | } else { | |
6696 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6697 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6698 | } |
518f0eb1 DS |
6699 | } |
6700 | ||
6701 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6702 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6703 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6704 | NO_STR |
3a2d747c | 6705 | BGP_STR |
518f0eb1 | 6706 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6707 | "Reset to default time to wait for processing route-map changes\n" |
6708 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6709 | { |
518f0eb1 | 6710 | |
d62a17ae | 6711 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6712 | |
d62a17ae | 6713 | return CMD_SUCCESS; |
518f0eb1 DS |
6714 | } |
6715 | ||
718e3744 | 6716 | /* neighbor interface */ |
d62a17ae | 6717 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
6718 | const char *str) | |
718e3744 | 6719 | { |
d62a17ae | 6720 | struct peer *peer; |
718e3744 | 6721 | |
d62a17ae | 6722 | peer = peer_lookup_vty(vty, ip_str); |
6723 | if (!peer || peer->conf_if) { | |
6724 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6725 | return CMD_WARNING_CONFIG_FAILED; | |
6726 | } | |
718e3744 | 6727 | |
d62a17ae | 6728 | if (str) |
6729 | peer_interface_set(peer, str); | |
6730 | else | |
6731 | peer_interface_unset(peer); | |
718e3744 | 6732 | |
d62a17ae | 6733 | return CMD_SUCCESS; |
718e3744 | 6734 | } |
6735 | ||
6736 | DEFUN (neighbor_interface, | |
6737 | neighbor_interface_cmd, | |
9ccf14f7 | 6738 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6739 | NEIGHBOR_STR |
6740 | NEIGHBOR_ADDR_STR | |
6741 | "Interface\n" | |
6742 | "Interface name\n") | |
6743 | { | |
d62a17ae | 6744 | int idx_ip = 1; |
6745 | int idx_word = 3; | |
6746 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6747 | } |
6748 | ||
6749 | DEFUN (no_neighbor_interface, | |
6750 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6751 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6752 | NO_STR |
6753 | NEIGHBOR_STR | |
16cedbb0 | 6754 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6755 | "Interface\n" |
6756 | "Interface name\n") | |
6757 | { | |
d62a17ae | 6758 | int idx_peer = 2; |
6759 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6760 | } |
6b0655a2 | 6761 | |
718e3744 | 6762 | DEFUN (neighbor_distribute_list, |
6763 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6764 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6765 | NEIGHBOR_STR |
6766 | NEIGHBOR_ADDR_STR2 | |
6767 | "Filter updates to/from this neighbor\n" | |
6768 | "IP access-list number\n" | |
6769 | "IP access-list number (expanded range)\n" | |
6770 | "IP Access-list name\n" | |
6771 | "Filter incoming updates\n" | |
6772 | "Filter outgoing updates\n") | |
6773 | { | |
d62a17ae | 6774 | int idx_peer = 1; |
6775 | int idx_acl = 3; | |
6776 | int direct, ret; | |
6777 | struct peer *peer; | |
a8206004 | 6778 | |
d62a17ae | 6779 | const char *pstr = argv[idx_peer]->arg; |
6780 | const char *acl = argv[idx_acl]->arg; | |
6781 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6782 | |
d62a17ae | 6783 | peer = peer_and_group_lookup_vty(vty, pstr); |
6784 | if (!peer) | |
6785 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6786 | |
d62a17ae | 6787 | /* Check filter direction. */ |
6788 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6789 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6790 | direct, acl); | |
a8206004 | 6791 | |
d62a17ae | 6792 | return bgp_vty_return(vty, ret); |
718e3744 | 6793 | } |
6794 | ||
d62a17ae | 6795 | ALIAS_HIDDEN( |
6796 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6797 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6798 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6799 | "Filter updates to/from this neighbor\n" | |
6800 | "IP access-list number\n" | |
6801 | "IP access-list number (expanded range)\n" | |
6802 | "IP Access-list name\n" | |
6803 | "Filter incoming updates\n" | |
6804 | "Filter outgoing updates\n") | |
596c17ba | 6805 | |
718e3744 | 6806 | DEFUN (no_neighbor_distribute_list, |
6807 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6808 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6809 | NO_STR |
6810 | NEIGHBOR_STR | |
6811 | NEIGHBOR_ADDR_STR2 | |
6812 | "Filter updates to/from this neighbor\n" | |
6813 | "IP access-list number\n" | |
6814 | "IP access-list number (expanded range)\n" | |
6815 | "IP Access-list name\n" | |
6816 | "Filter incoming updates\n" | |
6817 | "Filter outgoing updates\n") | |
6818 | { | |
d62a17ae | 6819 | int idx_peer = 2; |
6820 | int direct, ret; | |
6821 | struct peer *peer; | |
a8206004 | 6822 | |
d62a17ae | 6823 | const char *pstr = argv[idx_peer]->arg; |
6824 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6825 | |
d62a17ae | 6826 | peer = peer_and_group_lookup_vty(vty, pstr); |
6827 | if (!peer) | |
6828 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6829 | |
d62a17ae | 6830 | /* Check filter direction. */ |
6831 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6832 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6833 | direct); | |
a8206004 | 6834 | |
d62a17ae | 6835 | return bgp_vty_return(vty, ret); |
718e3744 | 6836 | } |
6b0655a2 | 6837 | |
d62a17ae | 6838 | ALIAS_HIDDEN( |
6839 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6840 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6841 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6842 | "Filter updates to/from this neighbor\n" | |
6843 | "IP access-list number\n" | |
6844 | "IP access-list number (expanded range)\n" | |
6845 | "IP Access-list name\n" | |
6846 | "Filter incoming updates\n" | |
6847 | "Filter outgoing updates\n") | |
596c17ba | 6848 | |
718e3744 | 6849 | /* Set prefix list to the peer. */ |
d62a17ae | 6850 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6851 | afi_t afi, safi_t safi, | |
6852 | const char *name_str, | |
6853 | const char *direct_str) | |
718e3744 | 6854 | { |
d62a17ae | 6855 | int ret; |
d62a17ae | 6856 | int direct = FILTER_IN; |
cf9ac8bf | 6857 | struct peer *peer; |
718e3744 | 6858 | |
d62a17ae | 6859 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6860 | if (!peer) | |
6861 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6862 | |
d62a17ae | 6863 | /* Check filter direction. */ |
6864 | if (strncmp(direct_str, "i", 1) == 0) | |
6865 | direct = FILTER_IN; | |
6866 | else if (strncmp(direct_str, "o", 1) == 0) | |
6867 | direct = FILTER_OUT; | |
718e3744 | 6868 | |
d62a17ae | 6869 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6870 | |
d62a17ae | 6871 | return bgp_vty_return(vty, ret); |
718e3744 | 6872 | } |
6873 | ||
d62a17ae | 6874 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6875 | afi_t afi, safi_t safi, | |
6876 | const char *direct_str) | |
718e3744 | 6877 | { |
d62a17ae | 6878 | int ret; |
6879 | struct peer *peer; | |
6880 | int direct = FILTER_IN; | |
718e3744 | 6881 | |
d62a17ae | 6882 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6883 | if (!peer) | |
6884 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6885 | |
d62a17ae | 6886 | /* Check filter direction. */ |
6887 | if (strncmp(direct_str, "i", 1) == 0) | |
6888 | direct = FILTER_IN; | |
6889 | else if (strncmp(direct_str, "o", 1) == 0) | |
6890 | direct = FILTER_OUT; | |
718e3744 | 6891 | |
d62a17ae | 6892 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6893 | |
d62a17ae | 6894 | return bgp_vty_return(vty, ret); |
718e3744 | 6895 | } |
6896 | ||
6897 | DEFUN (neighbor_prefix_list, | |
6898 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6899 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6900 | NEIGHBOR_STR |
6901 | NEIGHBOR_ADDR_STR2 | |
6902 | "Filter updates to/from this neighbor\n" | |
6903 | "Name of a prefix list\n" | |
6904 | "Filter incoming updates\n" | |
6905 | "Filter outgoing updates\n") | |
6906 | { | |
d62a17ae | 6907 | int idx_peer = 1; |
6908 | int idx_word = 3; | |
6909 | int idx_in_out = 4; | |
6910 | return peer_prefix_list_set_vty( | |
6911 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6912 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6913 | } |
6914 | ||
d62a17ae | 6915 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6916 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6917 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6918 | "Filter updates to/from this neighbor\n" | |
6919 | "Name of a prefix list\n" | |
6920 | "Filter incoming updates\n" | |
6921 | "Filter outgoing updates\n") | |
596c17ba | 6922 | |
718e3744 | 6923 | DEFUN (no_neighbor_prefix_list, |
6924 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6925 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6926 | NO_STR |
6927 | NEIGHBOR_STR | |
6928 | NEIGHBOR_ADDR_STR2 | |
6929 | "Filter updates to/from this neighbor\n" | |
6930 | "Name of a prefix list\n" | |
6931 | "Filter incoming updates\n" | |
6932 | "Filter outgoing updates\n") | |
6933 | { | |
d62a17ae | 6934 | int idx_peer = 2; |
6935 | int idx_in_out = 5; | |
6936 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6937 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6938 | argv[idx_in_out]->arg); | |
718e3744 | 6939 | } |
6b0655a2 | 6940 | |
d62a17ae | 6941 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6942 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6943 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6944 | "Filter updates to/from this neighbor\n" | |
6945 | "Name of a prefix list\n" | |
6946 | "Filter incoming updates\n" | |
6947 | "Filter outgoing updates\n") | |
596c17ba | 6948 | |
d62a17ae | 6949 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6950 | safi_t safi, const char *name_str, | |
6951 | const char *direct_str) | |
718e3744 | 6952 | { |
d62a17ae | 6953 | int ret; |
6954 | struct peer *peer; | |
6955 | int direct = FILTER_IN; | |
718e3744 | 6956 | |
d62a17ae | 6957 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6958 | if (!peer) | |
6959 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6960 | |
d62a17ae | 6961 | /* Check filter direction. */ |
6962 | if (strncmp(direct_str, "i", 1) == 0) | |
6963 | direct = FILTER_IN; | |
6964 | else if (strncmp(direct_str, "o", 1) == 0) | |
6965 | direct = FILTER_OUT; | |
718e3744 | 6966 | |
d62a17ae | 6967 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6968 | |
d62a17ae | 6969 | return bgp_vty_return(vty, ret); |
718e3744 | 6970 | } |
6971 | ||
d62a17ae | 6972 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6973 | safi_t safi, const char *direct_str) | |
718e3744 | 6974 | { |
d62a17ae | 6975 | int ret; |
6976 | struct peer *peer; | |
6977 | int direct = FILTER_IN; | |
718e3744 | 6978 | |
d62a17ae | 6979 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6980 | if (!peer) | |
6981 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6982 | |
d62a17ae | 6983 | /* Check filter direction. */ |
6984 | if (strncmp(direct_str, "i", 1) == 0) | |
6985 | direct = FILTER_IN; | |
6986 | else if (strncmp(direct_str, "o", 1) == 0) | |
6987 | direct = FILTER_OUT; | |
718e3744 | 6988 | |
d62a17ae | 6989 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6990 | |
d62a17ae | 6991 | return bgp_vty_return(vty, ret); |
718e3744 | 6992 | } |
6993 | ||
6994 | DEFUN (neighbor_filter_list, | |
6995 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6996 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6997 | NEIGHBOR_STR |
6998 | NEIGHBOR_ADDR_STR2 | |
6999 | "Establish BGP filters\n" | |
7000 | "AS path access-list name\n" | |
7001 | "Filter incoming routes\n" | |
7002 | "Filter outgoing routes\n") | |
7003 | { | |
d62a17ae | 7004 | int idx_peer = 1; |
7005 | int idx_word = 3; | |
7006 | int idx_in_out = 4; | |
7007 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7008 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7009 | argv[idx_in_out]->arg); | |
718e3744 | 7010 | } |
7011 | ||
d62a17ae | 7012 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
7013 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7014 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7015 | "Establish BGP filters\n" | |
7016 | "AS path access-list name\n" | |
7017 | "Filter incoming routes\n" | |
7018 | "Filter outgoing routes\n") | |
596c17ba | 7019 | |
718e3744 | 7020 | DEFUN (no_neighbor_filter_list, |
7021 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 7022 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7023 | NO_STR |
7024 | NEIGHBOR_STR | |
7025 | NEIGHBOR_ADDR_STR2 | |
7026 | "Establish BGP filters\n" | |
7027 | "AS path access-list name\n" | |
7028 | "Filter incoming routes\n" | |
7029 | "Filter outgoing routes\n") | |
7030 | { | |
d62a17ae | 7031 | int idx_peer = 2; |
7032 | int idx_in_out = 5; | |
7033 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7034 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7035 | argv[idx_in_out]->arg); | |
718e3744 | 7036 | } |
6b0655a2 | 7037 | |
d62a17ae | 7038 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
7039 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7040 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7041 | "Establish BGP filters\n" | |
7042 | "AS path access-list name\n" | |
7043 | "Filter incoming routes\n" | |
7044 | "Filter outgoing routes\n") | |
596c17ba | 7045 | |
7f7940e6 MK |
7046 | /* Set advertise-map to the peer. */ |
7047 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7048 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7049 | const char *advertise_str, |
7050 | const char *condition_str, bool condition, | |
7051 | bool set) | |
7f7940e6 MK |
7052 | { |
7053 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7054 | struct peer *peer; | |
7055 | struct route_map *advertise_map; | |
7056 | struct route_map *condition_map; | |
7057 | ||
7058 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7059 | if (!peer) | |
7060 | return ret; | |
7061 | ||
7062 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7063 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7064 | ||
cf2ad4d8 MK |
7065 | if (set) |
7066 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7067 | advertise_map, condition_str, | |
7068 | condition_map, condition); | |
7069 | else | |
7070 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7071 | advertise_map, condition_str, | |
7072 | condition_map, condition); | |
7f7940e6 MK |
7073 | |
7074 | return bgp_vty_return(vty, ret); | |
7075 | } | |
7076 | ||
cf2ad4d8 | 7077 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7078 | neighbor_advertise_map_cmd, |
cf2ad4d8 MK |
7079 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD> advertise-map WORD <exist-map WORD|non-exist-map WORD>", |
7080 | NO_STR | |
7f7940e6 MK |
7081 | NEIGHBOR_STR |
7082 | NEIGHBOR_ADDR_STR2 | |
7083 | "Route-map to conditionally advertise routes\n" | |
7084 | "Name of advertise map\n" | |
7085 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7086 | "Name of the exist map\n" | |
7087 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" | |
7088 | "Name of the non exist map\n") | |
7089 | { | |
7090 | int idx = 0; | |
7091 | int idx_peer = 1; | |
7092 | int idx_advertise_word = 3; | |
7093 | int idx_condition_word = 5; | |
7094 | bool condition = CONDITION_EXIST; | |
7095 | ||
cf2ad4d8 MK |
7096 | if (no) { |
7097 | idx_peer++; | |
7098 | idx_advertise_word++; | |
7099 | idx_condition_word++; | |
7100 | } | |
7101 | ||
7f7940e6 MK |
7102 | if (argv_find(argv, argc, "non-exist-map", &idx)) |
7103 | condition = CONDITION_NON_EXIST; | |
7104 | ||
7105 | return peer_advertise_map_set_vty( | |
7106 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
cf2ad4d8 MK |
7107 | argv[idx_advertise_word]->arg, argv[idx_condition_word]->arg, |
7108 | condition, !no); | |
7f7940e6 MK |
7109 | } |
7110 | ||
7111 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
cf2ad4d8 | 7112 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD> advertise-map WORD <exist-map WORD|non-exist-map WORD>", |
7f7940e6 MK |
7113 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7114 | "Route-map to conditionally advertise routes\n" | |
7115 | "Name of advertise map\n" | |
7116 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7117 | "Name of the exist map\n" | |
7118 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" | |
7119 | "Name of the non exist map\n") | |
7120 | ||
718e3744 | 7121 | /* Set route-map to the peer. */ |
d62a17ae | 7122 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7123 | afi_t afi, safi_t safi, const char *name_str, | |
7124 | const char *direct_str) | |
718e3744 | 7125 | { |
d62a17ae | 7126 | int ret; |
7127 | struct peer *peer; | |
7128 | int direct = RMAP_IN; | |
1de27621 | 7129 | struct route_map *route_map; |
718e3744 | 7130 | |
d62a17ae | 7131 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7132 | if (!peer) | |
7133 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7134 | |
d62a17ae | 7135 | /* Check filter direction. */ |
7136 | if (strncmp(direct_str, "in", 2) == 0) | |
7137 | direct = RMAP_IN; | |
7138 | else if (strncmp(direct_str, "o", 1) == 0) | |
7139 | direct = RMAP_OUT; | |
718e3744 | 7140 | |
1de27621 DA |
7141 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7142 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7143 | |
d62a17ae | 7144 | return bgp_vty_return(vty, ret); |
718e3744 | 7145 | } |
7146 | ||
d62a17ae | 7147 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
7148 | afi_t afi, safi_t safi, | |
7149 | const char *direct_str) | |
718e3744 | 7150 | { |
d62a17ae | 7151 | int ret; |
7152 | struct peer *peer; | |
7153 | int direct = RMAP_IN; | |
718e3744 | 7154 | |
d62a17ae | 7155 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7156 | if (!peer) | |
7157 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7158 | |
d62a17ae | 7159 | /* Check filter direction. */ |
7160 | if (strncmp(direct_str, "in", 2) == 0) | |
7161 | direct = RMAP_IN; | |
7162 | else if (strncmp(direct_str, "o", 1) == 0) | |
7163 | direct = RMAP_OUT; | |
718e3744 | 7164 | |
d62a17ae | 7165 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 7166 | |
d62a17ae | 7167 | return bgp_vty_return(vty, ret); |
718e3744 | 7168 | } |
7169 | ||
7170 | DEFUN (neighbor_route_map, | |
7171 | neighbor_route_map_cmd, | |
9ccf14f7 | 7172 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 7173 | NEIGHBOR_STR |
7174 | NEIGHBOR_ADDR_STR2 | |
7175 | "Apply route map to neighbor\n" | |
7176 | "Name of route map\n" | |
7177 | "Apply map to incoming routes\n" | |
2a3d5731 | 7178 | "Apply map to outbound routes\n") |
718e3744 | 7179 | { |
d62a17ae | 7180 | int idx_peer = 1; |
7181 | int idx_word = 3; | |
7182 | int idx_in_out = 4; | |
7183 | return peer_route_map_set_vty( | |
7184 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7185 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7186 | } |
7187 | ||
d62a17ae | 7188 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
7189 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7190 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7191 | "Apply route map to neighbor\n" | |
7192 | "Name of route map\n" | |
7193 | "Apply map to incoming routes\n" | |
7194 | "Apply map to outbound routes\n") | |
596c17ba | 7195 | |
718e3744 | 7196 | DEFUN (no_neighbor_route_map, |
7197 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 7198 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 7199 | NO_STR |
7200 | NEIGHBOR_STR | |
7201 | NEIGHBOR_ADDR_STR2 | |
7202 | "Apply route map to neighbor\n" | |
7203 | "Name of route map\n" | |
7204 | "Apply map to incoming routes\n" | |
2a3d5731 | 7205 | "Apply map to outbound routes\n") |
718e3744 | 7206 | { |
d62a17ae | 7207 | int idx_peer = 2; |
7208 | int idx_in_out = 5; | |
7209 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7210 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7211 | argv[idx_in_out]->arg); | |
718e3744 | 7212 | } |
6b0655a2 | 7213 | |
d62a17ae | 7214 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
7215 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7216 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7217 | "Apply route map to neighbor\n" | |
7218 | "Name of route map\n" | |
7219 | "Apply map to incoming routes\n" | |
7220 | "Apply map to outbound routes\n") | |
596c17ba | 7221 | |
718e3744 | 7222 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7223 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7224 | afi_t afi, safi_t safi, | |
7225 | const char *name_str) | |
718e3744 | 7226 | { |
d62a17ae | 7227 | int ret; |
7228 | struct peer *peer; | |
1de27621 | 7229 | struct route_map *route_map; |
718e3744 | 7230 | |
d62a17ae | 7231 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7232 | if (!peer) | |
7233 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7234 | |
1de27621 DA |
7235 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7236 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7237 | |
d62a17ae | 7238 | return bgp_vty_return(vty, ret); |
718e3744 | 7239 | } |
7240 | ||
7241 | /* Unset route-map from the peer. */ | |
d62a17ae | 7242 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7243 | afi_t afi, safi_t safi) | |
718e3744 | 7244 | { |
d62a17ae | 7245 | int ret; |
7246 | struct peer *peer; | |
718e3744 | 7247 | |
d62a17ae | 7248 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7249 | if (!peer) | |
7250 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7251 | |
d62a17ae | 7252 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7253 | |
d62a17ae | 7254 | return bgp_vty_return(vty, ret); |
718e3744 | 7255 | } |
7256 | ||
7257 | DEFUN (neighbor_unsuppress_map, | |
7258 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7259 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7260 | NEIGHBOR_STR |
7261 | NEIGHBOR_ADDR_STR2 | |
7262 | "Route-map to selectively unsuppress suppressed routes\n" | |
7263 | "Name of route map\n") | |
7264 | { | |
d62a17ae | 7265 | int idx_peer = 1; |
7266 | int idx_word = 3; | |
7267 | return peer_unsuppress_map_set_vty( | |
7268 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7269 | argv[idx_word]->arg); | |
718e3744 | 7270 | } |
7271 | ||
d62a17ae | 7272 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
7273 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7274 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7275 | "Route-map to selectively unsuppress suppressed routes\n" | |
7276 | "Name of route map\n") | |
596c17ba | 7277 | |
718e3744 | 7278 | DEFUN (no_neighbor_unsuppress_map, |
7279 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7280 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7281 | NO_STR |
7282 | NEIGHBOR_STR | |
7283 | NEIGHBOR_ADDR_STR2 | |
7284 | "Route-map to selectively unsuppress suppressed routes\n" | |
7285 | "Name of route map\n") | |
7286 | { | |
d62a17ae | 7287 | int idx_peer = 2; |
7288 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
7289 | bgp_node_afi(vty), | |
7290 | bgp_node_safi(vty)); | |
718e3744 | 7291 | } |
6b0655a2 | 7292 | |
d62a17ae | 7293 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
7294 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7295 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7296 | "Route-map to selectively unsuppress suppressed routes\n" | |
7297 | "Name of route map\n") | |
596c17ba | 7298 | |
d62a17ae | 7299 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
7300 | afi_t afi, safi_t safi, | |
7301 | const char *num_str, | |
7302 | const char *threshold_str, int warning, | |
9cbd06e0 DA |
7303 | const char *restart_str, |
7304 | const char *force_str) | |
718e3744 | 7305 | { |
d62a17ae | 7306 | int ret; |
7307 | struct peer *peer; | |
d7c0a89a QY |
7308 | uint32_t max; |
7309 | uint8_t threshold; | |
7310 | uint16_t restart; | |
718e3744 | 7311 | |
d62a17ae | 7312 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7313 | if (!peer) | |
7314 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7315 | |
d62a17ae | 7316 | max = strtoul(num_str, NULL, 10); |
7317 | if (threshold_str) | |
7318 | threshold = atoi(threshold_str); | |
7319 | else | |
7320 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 7321 | |
d62a17ae | 7322 | if (restart_str) |
7323 | restart = atoi(restart_str); | |
7324 | else | |
7325 | restart = 0; | |
0a486e5f | 7326 | |
d62a17ae | 7327 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
9cbd06e0 | 7328 | restart, force_str ? true : false); |
718e3744 | 7329 | |
d62a17ae | 7330 | return bgp_vty_return(vty, ret); |
718e3744 | 7331 | } |
7332 | ||
d62a17ae | 7333 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
7334 | afi_t afi, safi_t safi) | |
718e3744 | 7335 | { |
d62a17ae | 7336 | int ret; |
7337 | struct peer *peer; | |
718e3744 | 7338 | |
d62a17ae | 7339 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7340 | if (!peer) | |
7341 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7342 | |
d62a17ae | 7343 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 7344 | |
d62a17ae | 7345 | return bgp_vty_return(vty, ret); |
718e3744 | 7346 | } |
7347 | ||
fde246e8 DA |
7348 | /* Maximum number of prefix to be sent to the neighbor. */ |
7349 | DEFUN(neighbor_maximum_prefix_out, | |
7350 | neighbor_maximum_prefix_out_cmd, | |
7351 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
7352 | NEIGHBOR_STR | |
7353 | NEIGHBOR_ADDR_STR2 | |
7354 | "Maximum number of prefixes to be sent to this peer\n" | |
7355 | "Maximum no. of prefix limit\n") | |
7356 | { | |
7357 | int idx_peer = 1; | |
7358 | int idx_number = 3; | |
7359 | struct peer *peer; | |
7360 | uint32_t max; | |
7361 | afi_t afi = bgp_node_afi(vty); | |
7362 | safi_t safi = bgp_node_safi(vty); | |
7363 | ||
7364 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7365 | if (!peer) | |
7366 | return CMD_WARNING_CONFIG_FAILED; | |
7367 | ||
7368 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
7369 | ||
7370 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
7371 | peer->pmax_out[afi][safi] = max; | |
7372 | ||
7373 | return CMD_SUCCESS; | |
7374 | } | |
7375 | ||
7376 | DEFUN(no_neighbor_maximum_prefix_out, | |
7377 | no_neighbor_maximum_prefix_out_cmd, | |
7378 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
7379 | NO_STR | |
7380 | NEIGHBOR_STR | |
7381 | NEIGHBOR_ADDR_STR2 | |
7382 | "Maximum number of prefixes to be sent to this peer\n") | |
7383 | { | |
7384 | int idx_peer = 2; | |
7385 | struct peer *peer; | |
7386 | afi_t afi = bgp_node_afi(vty); | |
7387 | safi_t safi = bgp_node_safi(vty); | |
7388 | ||
7389 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7390 | if (!peer) | |
7391 | return CMD_WARNING_CONFIG_FAILED; | |
7392 | ||
ae00326a | 7393 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
fde246e8 DA |
7394 | peer->pmax_out[afi][safi] = 0; |
7395 | ||
7396 | return CMD_SUCCESS; | |
7397 | } | |
7398 | ||
9cbd06e0 DA |
7399 | /* Maximum number of prefix configuration. Prefix count is different |
7400 | for each peer configuration. So this configuration can be set for | |
718e3744 | 7401 | each peer configuration. */ |
7402 | DEFUN (neighbor_maximum_prefix, | |
7403 | neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 7404 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
718e3744 | 7405 | NEIGHBOR_STR |
7406 | NEIGHBOR_ADDR_STR2 | |
7407 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
7408 | "maximum no. of prefix limit\n" |
7409 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7410 | { |
d62a17ae | 7411 | int idx_peer = 1; |
7412 | int idx_number = 3; | |
9cbd06e0 DA |
7413 | int idx_force = 0; |
7414 | char *force = NULL; | |
7415 | ||
7416 | if (argv_find(argv, argc, "force", &idx_force)) | |
7417 | force = argv[idx_force]->arg; | |
7418 | ||
d62a17ae | 7419 | return peer_maximum_prefix_set_vty( |
7420 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7421 | argv[idx_number]->arg, NULL, 0, NULL, force); |
718e3744 | 7422 | } |
7423 | ||
d62a17ae | 7424 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 7425 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 7426 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7427 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
7428 | "maximum no. of prefix limit\n" |
7429 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7430 | |
e0701b79 | 7431 | DEFUN (neighbor_maximum_prefix_threshold, |
7432 | neighbor_maximum_prefix_threshold_cmd, | |
9cbd06e0 | 7433 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
e0701b79 | 7434 | NEIGHBOR_STR |
7435 | NEIGHBOR_ADDR_STR2 | |
7436 | "Maximum number of prefix accept from this peer\n" | |
7437 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7438 | "Threshold value (%) at which to generate a warning msg\n" |
7439 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7440 | { |
d62a17ae | 7441 | int idx_peer = 1; |
7442 | int idx_number = 3; | |
7443 | int idx_number_2 = 4; | |
9cbd06e0 DA |
7444 | int idx_force = 0; |
7445 | char *force = NULL; | |
7446 | ||
7447 | if (argv_find(argv, argc, "force", &idx_force)) | |
7448 | force = argv[idx_force]->arg; | |
7449 | ||
d62a17ae | 7450 | return peer_maximum_prefix_set_vty( |
7451 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7452 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); |
0a486e5f | 7453 | } |
e0701b79 | 7454 | |
d62a17ae | 7455 | ALIAS_HIDDEN( |
7456 | neighbor_maximum_prefix_threshold, | |
7457 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 7458 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 7459 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7460 | "Maximum number of prefix accept from this peer\n" | |
7461 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7462 | "Threshold value (%) at which to generate a warning msg\n" |
7463 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7464 | |
718e3744 | 7465 | DEFUN (neighbor_maximum_prefix_warning, |
7466 | neighbor_maximum_prefix_warning_cmd, | |
9cbd06e0 | 7467 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
718e3744 | 7468 | NEIGHBOR_STR |
7469 | NEIGHBOR_ADDR_STR2 | |
7470 | "Maximum number of prefix accept from this peer\n" | |
7471 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7472 | "Only give warning message when limit is exceeded\n" |
7473 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7474 | { |
d62a17ae | 7475 | int idx_peer = 1; |
7476 | int idx_number = 3; | |
9cbd06e0 DA |
7477 | int idx_force = 0; |
7478 | char *force = NULL; | |
7479 | ||
7480 | if (argv_find(argv, argc, "force", &idx_force)) | |
7481 | force = argv[idx_force]->arg; | |
7482 | ||
d62a17ae | 7483 | return peer_maximum_prefix_set_vty( |
7484 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7485 | argv[idx_number]->arg, NULL, 1, NULL, force); |
718e3744 | 7486 | } |
7487 | ||
d62a17ae | 7488 | ALIAS_HIDDEN( |
7489 | neighbor_maximum_prefix_warning, | |
7490 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 7491 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 7492 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7493 | "Maximum number of prefix accept from this peer\n" | |
7494 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7495 | "Only give warning message when limit is exceeded\n" |
7496 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7497 | |
e0701b79 | 7498 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
7499 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9cbd06e0 | 7500 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
e0701b79 | 7501 | NEIGHBOR_STR |
7502 | NEIGHBOR_ADDR_STR2 | |
7503 | "Maximum number of prefix accept from this peer\n" | |
7504 | "maximum no. of prefix limit\n" | |
7505 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
7506 | "Only give warning message when limit is exceeded\n" |
7507 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7508 | { |
d62a17ae | 7509 | int idx_peer = 1; |
7510 | int idx_number = 3; | |
7511 | int idx_number_2 = 4; | |
9cbd06e0 DA |
7512 | int idx_force = 0; |
7513 | char *force = NULL; | |
7514 | ||
7515 | if (argv_find(argv, argc, "force", &idx_force)) | |
7516 | force = argv[idx_force]->arg; | |
7517 | ||
d62a17ae | 7518 | return peer_maximum_prefix_set_vty( |
7519 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7520 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); |
0a486e5f | 7521 | } |
7522 | ||
d62a17ae | 7523 | ALIAS_HIDDEN( |
7524 | neighbor_maximum_prefix_threshold_warning, | |
7525 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 7526 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 7527 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7528 | "Maximum number of prefix accept from this peer\n" | |
7529 | "maximum no. of prefix limit\n" | |
7530 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
7531 | "Only give warning message when limit is exceeded\n" |
7532 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7533 | |
0a486e5f | 7534 | DEFUN (neighbor_maximum_prefix_restart, |
7535 | neighbor_maximum_prefix_restart_cmd, | |
9cbd06e0 | 7536 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
0a486e5f | 7537 | NEIGHBOR_STR |
7538 | NEIGHBOR_ADDR_STR2 | |
7539 | "Maximum number of prefix accept from this peer\n" | |
7540 | "maximum no. of prefix limit\n" | |
7541 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7542 | "Restart interval in minutes\n" |
7543 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7544 | { |
d62a17ae | 7545 | int idx_peer = 1; |
7546 | int idx_number = 3; | |
7547 | int idx_number_2 = 5; | |
9cbd06e0 DA |
7548 | int idx_force = 0; |
7549 | char *force = NULL; | |
7550 | ||
7551 | if (argv_find(argv, argc, "force", &idx_force)) | |
7552 | force = argv[idx_force]->arg; | |
7553 | ||
d62a17ae | 7554 | return peer_maximum_prefix_set_vty( |
7555 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7556 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); |
0a486e5f | 7557 | } |
7558 | ||
d62a17ae | 7559 | ALIAS_HIDDEN( |
7560 | neighbor_maximum_prefix_restart, | |
7561 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 7562 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 7563 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7564 | "Maximum number of prefix accept from this peer\n" | |
7565 | "maximum no. of prefix limit\n" | |
7566 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7567 | "Restart interval in minutes\n" |
7568 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7569 | |
0a486e5f | 7570 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
7571 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9cbd06e0 | 7572 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
0a486e5f | 7573 | NEIGHBOR_STR |
7574 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 7575 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 7576 | "maximum no. of prefix limit\n" |
7577 | "Threshold value (%) at which to generate a warning msg\n" | |
7578 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7579 | "Restart interval in minutes\n" |
7580 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7581 | { |
d62a17ae | 7582 | int idx_peer = 1; |
7583 | int idx_number = 3; | |
7584 | int idx_number_2 = 4; | |
7585 | int idx_number_3 = 6; | |
9cbd06e0 DA |
7586 | int idx_force = 0; |
7587 | char *force = NULL; | |
7588 | ||
7589 | if (argv_find(argv, argc, "force", &idx_force)) | |
7590 | force = argv[idx_force]->arg; | |
7591 | ||
d62a17ae | 7592 | return peer_maximum_prefix_set_vty( |
7593 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7594 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
9cbd06e0 | 7595 | argv[idx_number_3]->arg, force); |
d62a17ae | 7596 | } |
7597 | ||
7598 | ALIAS_HIDDEN( | |
7599 | neighbor_maximum_prefix_threshold_restart, | |
7600 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 7601 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 7602 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7603 | "Maximum number of prefixes to accept from this peer\n" | |
7604 | "maximum no. of prefix limit\n" | |
7605 | "Threshold value (%) at which to generate a warning msg\n" | |
7606 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7607 | "Restart interval in minutes\n" |
7608 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7609 | |
718e3744 | 7610 | DEFUN (no_neighbor_maximum_prefix, |
7611 | no_neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 7612 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
718e3744 | 7613 | NO_STR |
7614 | NEIGHBOR_STR | |
7615 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 7616 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
7617 | "maximum no. of prefix limit\n" |
7618 | "Threshold value (%) at which to generate a warning msg\n" | |
7619 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 7620 | "Restart interval in minutes\n" |
9cbd06e0 DA |
7621 | "Only give warning message when limit is exceeded\n" |
7622 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7623 | { |
d62a17ae | 7624 | int idx_peer = 2; |
7625 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
7626 | bgp_node_afi(vty), | |
7627 | bgp_node_safi(vty)); | |
718e3744 | 7628 | } |
e52702f2 | 7629 | |
d62a17ae | 7630 | ALIAS_HIDDEN( |
7631 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 7632 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 7633 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7634 | "Maximum number of prefixes to accept from this peer\n" | |
7635 | "maximum no. of prefix limit\n" | |
7636 | "Threshold value (%) at which to generate a warning msg\n" | |
7637 | "Restart bgp connection after limit is exceeded\n" | |
7638 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
7639 | "Only give warning message when limit is exceeded\n" |
7640 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7641 | |
718e3744 | 7642 | |
718e3744 | 7643 | /* "neighbor allowas-in" */ |
7644 | DEFUN (neighbor_allowas_in, | |
7645 | neighbor_allowas_in_cmd, | |
fd8503f5 | 7646 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7647 | NEIGHBOR_STR |
7648 | NEIGHBOR_ADDR_STR2 | |
31500417 | 7649 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 7650 | "Number of occurrences of AS number\n" |
fd8503f5 | 7651 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7652 | { |
d62a17ae | 7653 | int idx_peer = 1; |
7654 | int idx_number_origin = 3; | |
7655 | int ret; | |
7656 | int origin = 0; | |
7657 | struct peer *peer; | |
7658 | int allow_num = 0; | |
7659 | ||
7660 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7661 | if (!peer) | |
7662 | return CMD_WARNING_CONFIG_FAILED; | |
7663 | ||
7664 | if (argc <= idx_number_origin) | |
7665 | allow_num = 3; | |
7666 | else { | |
7667 | if (argv[idx_number_origin]->type == WORD_TKN) | |
7668 | origin = 1; | |
7669 | else | |
7670 | allow_num = atoi(argv[idx_number_origin]->arg); | |
7671 | } | |
7672 | ||
7673 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7674 | allow_num, origin); | |
7675 | ||
7676 | return bgp_vty_return(vty, ret); | |
7677 | } | |
7678 | ||
7679 | ALIAS_HIDDEN( | |
7680 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
7681 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7682 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7683 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 7684 | "Number of occurrences of AS number\n" |
d62a17ae | 7685 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7686 | |
718e3744 | 7687 | DEFUN (no_neighbor_allowas_in, |
7688 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 7689 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7690 | NO_STR |
7691 | NEIGHBOR_STR | |
7692 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 7693 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 7694 | "Number of occurrences of AS number\n" |
fd8503f5 | 7695 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7696 | { |
d62a17ae | 7697 | int idx_peer = 2; |
7698 | int ret; | |
7699 | struct peer *peer; | |
718e3744 | 7700 | |
d62a17ae | 7701 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7702 | if (!peer) | |
7703 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7704 | |
d62a17ae | 7705 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
7706 | bgp_node_safi(vty)); | |
718e3744 | 7707 | |
d62a17ae | 7708 | return bgp_vty_return(vty, ret); |
718e3744 | 7709 | } |
6b0655a2 | 7710 | |
d62a17ae | 7711 | ALIAS_HIDDEN( |
7712 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
7713 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7714 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7715 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 7716 | "Number of occurrences of AS number\n" |
d62a17ae | 7717 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7718 | |
fa411a21 NH |
7719 | DEFUN (neighbor_ttl_security, |
7720 | neighbor_ttl_security_cmd, | |
7ebe625c | 7721 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 7722 | NEIGHBOR_STR |
7ebe625c | 7723 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7724 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
7725 | "Specify the maximum number of hops to the BGP peer\n" |
7726 | "Number of hops to BGP peer\n") | |
fa411a21 | 7727 | { |
d62a17ae | 7728 | int idx_peer = 1; |
7729 | int idx_number = 4; | |
7730 | struct peer *peer; | |
7731 | int gtsm_hops; | |
7732 | ||
7733 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7734 | if (!peer) | |
7735 | return CMD_WARNING_CONFIG_FAILED; | |
7736 | ||
7737 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
7738 | ||
7ebe625c QY |
7739 | /* |
7740 | * If 'neighbor swpX', then this is for directly connected peers, | |
7741 | * we should not accept a ttl-security hops value greater than 1. | |
7742 | */ | |
e2521429 | 7743 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { |
7ebe625c QY |
7744 | vty_out(vty, |
7745 | "%s is directly connected peer, hops cannot exceed 1\n", | |
7746 | argv[idx_peer]->arg); | |
7747 | return CMD_WARNING_CONFIG_FAILED; | |
7748 | } | |
7749 | ||
d62a17ae | 7750 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
7751 | } |
7752 | ||
7753 | DEFUN (no_neighbor_ttl_security, | |
7754 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 7755 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
7756 | NO_STR |
7757 | NEIGHBOR_STR | |
7ebe625c | 7758 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7759 | "BGP ttl-security parameters\n" |
3a2d747c QY |
7760 | "Specify the maximum number of hops to the BGP peer\n" |
7761 | "Number of hops to BGP peer\n") | |
fa411a21 | 7762 | { |
d62a17ae | 7763 | int idx_peer = 2; |
7764 | struct peer *peer; | |
fa411a21 | 7765 | |
d62a17ae | 7766 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7767 | if (!peer) | |
7768 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 7769 | |
d62a17ae | 7770 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 7771 | } |
6b0655a2 | 7772 | |
adbac85e DW |
7773 | DEFUN (neighbor_addpath_tx_all_paths, |
7774 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7775 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7776 | NEIGHBOR_STR |
7777 | NEIGHBOR_ADDR_STR2 | |
7778 | "Use addpath to advertise all paths to a neighbor\n") | |
7779 | { | |
d62a17ae | 7780 | int idx_peer = 1; |
7781 | struct peer *peer; | |
adbac85e | 7782 | |
d62a17ae | 7783 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7784 | if (!peer) | |
7785 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 7786 | |
dcc68b5e MS |
7787 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7788 | BGP_ADDPATH_ALL); | |
7789 | return CMD_SUCCESS; | |
adbac85e DW |
7790 | } |
7791 | ||
d62a17ae | 7792 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
7793 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
7794 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7795 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7796 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7797 | |
adbac85e DW |
7798 | DEFUN (no_neighbor_addpath_tx_all_paths, |
7799 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7800 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7801 | NO_STR |
7802 | NEIGHBOR_STR | |
7803 | NEIGHBOR_ADDR_STR2 | |
7804 | "Use addpath to advertise all paths to a neighbor\n") | |
7805 | { | |
d62a17ae | 7806 | int idx_peer = 2; |
dcc68b5e MS |
7807 | struct peer *peer; |
7808 | ||
7809 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7810 | if (!peer) | |
7811 | return CMD_WARNING_CONFIG_FAILED; | |
7812 | ||
7813 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7814 | != BGP_ADDPATH_ALL) { | |
7815 | vty_out(vty, | |
7816 | "%% Peer not currently configured to transmit all paths."); | |
7817 | return CMD_WARNING_CONFIG_FAILED; | |
7818 | } | |
7819 | ||
7820 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7821 | BGP_ADDPATH_NONE); | |
7822 | ||
7823 | return CMD_SUCCESS; | |
adbac85e DW |
7824 | } |
7825 | ||
d62a17ae | 7826 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
7827 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
7828 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7829 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7830 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7831 | |
06370dac DW |
7832 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
7833 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7834 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7835 | NEIGHBOR_STR |
7836 | NEIGHBOR_ADDR_STR2 | |
7837 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7838 | { | |
d62a17ae | 7839 | int idx_peer = 1; |
7840 | struct peer *peer; | |
06370dac | 7841 | |
d62a17ae | 7842 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7843 | if (!peer) | |
7844 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 7845 | |
dcc68b5e MS |
7846 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7847 | BGP_ADDPATH_BEST_PER_AS); | |
7848 | ||
7849 | return CMD_SUCCESS; | |
06370dac DW |
7850 | } |
7851 | ||
d62a17ae | 7852 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7853 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7854 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7855 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7856 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7857 | |
06370dac DW |
7858 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7859 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7860 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7861 | NO_STR |
7862 | NEIGHBOR_STR | |
7863 | NEIGHBOR_ADDR_STR2 | |
7864 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7865 | { | |
d62a17ae | 7866 | int idx_peer = 2; |
dcc68b5e MS |
7867 | struct peer *peer; |
7868 | ||
7869 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7870 | if (!peer) | |
7871 | return CMD_WARNING_CONFIG_FAILED; | |
7872 | ||
7873 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7874 | != BGP_ADDPATH_BEST_PER_AS) { | |
7875 | vty_out(vty, | |
7876 | "%% Peer not currently configured to transmit all best path per as."); | |
7877 | return CMD_WARNING_CONFIG_FAILED; | |
7878 | } | |
7879 | ||
7880 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7881 | BGP_ADDPATH_NONE); | |
7882 | ||
7883 | return CMD_SUCCESS; | |
06370dac DW |
7884 | } |
7885 | ||
d62a17ae | 7886 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7887 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7888 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7889 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7890 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7891 | |
2b31007c RZ |
7892 | DEFPY( |
7893 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7894 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7895 | NEIGHBOR_STR | |
7896 | NEIGHBOR_ADDR_STR2 | |
7897 | "Detect AS loops before sending to neighbor\n") | |
7898 | { | |
7899 | struct peer *peer; | |
7900 | ||
7901 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7902 | if (!peer) | |
7903 | return CMD_WARNING_CONFIG_FAILED; | |
7904 | ||
7905 | peer->as_path_loop_detection = true; | |
7906 | ||
7907 | return CMD_SUCCESS; | |
7908 | } | |
7909 | ||
7910 | DEFPY( | |
7911 | no_neighbor_aspath_loop_detection, | |
7912 | no_neighbor_aspath_loop_detection_cmd, | |
7913 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7914 | NO_STR | |
7915 | NEIGHBOR_STR | |
7916 | NEIGHBOR_ADDR_STR2 | |
7917 | "Detect AS loops before sending to neighbor\n") | |
7918 | { | |
7919 | struct peer *peer; | |
7920 | ||
7921 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7922 | if (!peer) | |
7923 | return CMD_WARNING_CONFIG_FAILED; | |
7924 | ||
7925 | peer->as_path_loop_detection = false; | |
7926 | ||
7927 | return CMD_SUCCESS; | |
7928 | } | |
7929 | ||
b9c7bc5a | 7930 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 7931 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 7932 | { |
b9c7bc5a PZ |
7933 | struct ecommunity *ecom = NULL; |
7934 | struct ecommunity *ecomadd; | |
ddb5b488 | 7935 | |
b9c7bc5a | 7936 | for (; argc; --argc, ++argv) { |
9a659715 PG |
7937 | if (is_rt6) |
7938 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
7939 | ECOMMUNITY_ROUTE_TARGET, | |
7940 | 0); | |
7941 | else | |
7942 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
7943 | ECOMMUNITY_ROUTE_TARGET, | |
7944 | 0); | |
b9c7bc5a PZ |
7945 | if (!ecomadd) { |
7946 | vty_out(vty, "Malformed community-list value\n"); | |
7947 | if (ecom) | |
7948 | ecommunity_free(&ecom); | |
7949 | return CMD_WARNING_CONFIG_FAILED; | |
7950 | } | |
ddb5b488 | 7951 | |
b9c7bc5a PZ |
7952 | if (ecom) { |
7953 | ecommunity_merge(ecom, ecomadd); | |
7954 | ecommunity_free(&ecomadd); | |
7955 | } else { | |
7956 | ecom = ecomadd; | |
7957 | } | |
7958 | } | |
7959 | ||
7960 | if (*list) { | |
7961 | ecommunity_free(&*list); | |
ddb5b488 | 7962 | } |
b9c7bc5a PZ |
7963 | *list = ecom; |
7964 | ||
7965 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7966 | } |
7967 | ||
0ca70ba5 DS |
7968 | /* |
7969 | * v2vimport is true if we are handling a `import vrf ...` command | |
7970 | */ | |
7971 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7972 | { |
0ca70ba5 DS |
7973 | afi_t afi; |
7974 | ||
ddb5b488 | 7975 | switch (vty->node) { |
b9c7bc5a | 7976 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7977 | afi = AFI_IP; |
7978 | break; | |
b9c7bc5a | 7979 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7980 | afi = AFI_IP6; |
7981 | break; | |
ddb5b488 PZ |
7982 | default: |
7983 | vty_out(vty, | |
b9c7bc5a | 7984 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7985 | return AFI_MAX; |
ddb5b488 | 7986 | } |
69b07479 | 7987 | |
0ca70ba5 DS |
7988 | if (!v2vimport) { |
7989 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7990 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7991 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7992 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7993 | vty_out(vty, | |
7994 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7995 | return AFI_MAX; | |
7996 | } | |
7997 | } else { | |
7998 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7999 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8000 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8001 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8002 | vty_out(vty, | |
8003 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8004 | return AFI_MAX; | |
8005 | } | |
8006 | } | |
8007 | return afi; | |
ddb5b488 PZ |
8008 | } |
8009 | ||
b9c7bc5a PZ |
8010 | DEFPY (af_rd_vpn_export, |
8011 | af_rd_vpn_export_cmd, | |
8012 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8013 | NO_STR | |
ddb5b488 | 8014 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
8015 | "Between current address-family and vpn\n" |
8016 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8017 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
8018 | { | |
8019 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8020 | struct prefix_rd prd; | |
8021 | int ret; | |
ddb5b488 | 8022 | afi_t afi; |
b9c7bc5a | 8023 | int idx = 0; |
c6423c31 | 8024 | bool yes = true; |
ddb5b488 | 8025 | |
b9c7bc5a | 8026 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8027 | yes = false; |
b9c7bc5a PZ |
8028 | |
8029 | if (yes) { | |
8030 | ret = str2prefix_rd(rd_str, &prd); | |
8031 | if (!ret) { | |
8032 | vty_out(vty, "%% Malformed rd\n"); | |
8033 | return CMD_WARNING_CONFIG_FAILED; | |
8034 | } | |
ddb5b488 PZ |
8035 | } |
8036 | ||
0ca70ba5 | 8037 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8038 | if (afi == AFI_MAX) |
8039 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8040 | |
69b07479 DS |
8041 | /* |
8042 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8043 | */ | |
8044 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8045 | bgp_get_default(), bgp); | |
ddb5b488 | 8046 | |
69b07479 DS |
8047 | if (yes) { |
8048 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8049 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8050 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8051 | } else { | |
8052 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8053 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
8054 | } |
8055 | ||
69b07479 DS |
8056 | /* post-change: re-export vpn routes */ |
8057 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8058 | bgp_get_default(), bgp); | |
8059 | ||
ddb5b488 PZ |
8060 | return CMD_SUCCESS; |
8061 | } | |
8062 | ||
b9c7bc5a PZ |
8063 | ALIAS (af_rd_vpn_export, |
8064 | af_no_rd_vpn_export_cmd, | |
8065 | "no rd vpn export", | |
ddb5b488 | 8066 | NO_STR |
b9c7bc5a PZ |
8067 | "Specify route distinguisher\n" |
8068 | "Between current address-family and vpn\n" | |
8069 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8070 | |
b9c7bc5a PZ |
8071 | DEFPY (af_label_vpn_export, |
8072 | af_label_vpn_export_cmd, | |
e70e9f8e | 8073 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8074 | NO_STR |
ddb5b488 | 8075 | "label value for VRF\n" |
b9c7bc5a PZ |
8076 | "Between current address-family and vpn\n" |
8077 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8078 | "Label Value <0-1048575>\n" |
8079 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8080 | { |
8081 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8082 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8083 | afi_t afi; |
b9c7bc5a | 8084 | int idx = 0; |
c6423c31 | 8085 | bool yes = true; |
b9c7bc5a PZ |
8086 | |
8087 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8088 | yes = false; |
ddb5b488 | 8089 | |
21a16cc2 PZ |
8090 | /* If "no ...", squash trailing parameter */ |
8091 | if (!yes) | |
8092 | label_auto = NULL; | |
8093 | ||
e70e9f8e PZ |
8094 | if (yes) { |
8095 | if (!label_auto) | |
8096 | label = label_val; /* parser should force unsigned */ | |
8097 | } | |
ddb5b488 | 8098 | |
0ca70ba5 | 8099 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8100 | if (afi == AFI_MAX) |
8101 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8102 | |
e70e9f8e | 8103 | |
69b07479 DS |
8104 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8105 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8106 | /* no change */ | |
8107 | return CMD_SUCCESS; | |
e70e9f8e | 8108 | |
69b07479 DS |
8109 | /* |
8110 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8111 | */ | |
8112 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8113 | bgp_get_default(), bgp); | |
8114 | ||
8115 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8116 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8117 | ||
8118 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8119 | ||
8120 | /* | |
8121 | * label has previously been automatically | |
8122 | * assigned by labelpool: release it | |
8123 | * | |
8124 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8125 | * means the automatic assignment is in flight | |
8126 | * and therefore the labelpool callback must | |
8127 | * detect that the auto label is not needed. | |
8128 | */ | |
8129 | ||
8130 | bgp_lp_release(LP_TYPE_VRF, | |
8131 | &bgp->vpn_policy[afi], | |
8132 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8133 | } |
69b07479 DS |
8134 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8135 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8136 | } | |
ddb5b488 | 8137 | |
69b07479 DS |
8138 | bgp->vpn_policy[afi].tovpn_label = label; |
8139 | if (label_auto) { | |
8140 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8141 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8142 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8143 | vpn_leak_label_callback); | |
ddb5b488 PZ |
8144 | } |
8145 | ||
69b07479 DS |
8146 | /* post-change: re-export vpn routes */ |
8147 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8148 | bgp_get_default(), bgp); | |
8149 | ||
ddb5b488 PZ |
8150 | return CMD_SUCCESS; |
8151 | } | |
8152 | ||
b9c7bc5a PZ |
8153 | ALIAS (af_label_vpn_export, |
8154 | af_no_label_vpn_export_cmd, | |
8155 | "no label vpn export", | |
8156 | NO_STR | |
8157 | "label value for VRF\n" | |
8158 | "Between current address-family and vpn\n" | |
8159 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8160 | |
b9c7bc5a PZ |
8161 | DEFPY (af_nexthop_vpn_export, |
8162 | af_nexthop_vpn_export_cmd, | |
8c85ca28 | 8163 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 8164 | NO_STR |
ddb5b488 | 8165 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
8166 | "Between current address-family and vpn\n" |
8167 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8168 | "IPv4 prefix\n" |
8169 | "IPv6 prefix\n") | |
8170 | { | |
8171 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 8172 | afi_t afi; |
ddb5b488 PZ |
8173 | struct prefix p; |
8174 | ||
8c85ca28 QY |
8175 | if (!no) { |
8176 | if (!nexthop_su) { | |
8177 | vty_out(vty, "%% Nexthop required\n"); | |
8178 | return CMD_WARNING_CONFIG_FAILED; | |
8179 | } | |
8c85ca28 | 8180 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
8181 | return CMD_WARNING_CONFIG_FAILED; |
8182 | } | |
ddb5b488 | 8183 | |
0ca70ba5 | 8184 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8185 | if (afi == AFI_MAX) |
8186 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8187 | |
69b07479 DS |
8188 | /* |
8189 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8190 | */ | |
8191 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8192 | bgp_get_default(), bgp); | |
ddb5b488 | 8193 | |
8c85ca28 | 8194 | if (!no) { |
69b07479 DS |
8195 | bgp->vpn_policy[afi].tovpn_nexthop = p; |
8196 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8197 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8198 | } else { | |
8199 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8200 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
8201 | } |
8202 | ||
69b07479 DS |
8203 | /* post-change: re-export vpn routes */ |
8204 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8205 | bgp_get_default(), bgp); | |
8206 | ||
ddb5b488 PZ |
8207 | return CMD_SUCCESS; |
8208 | } | |
8209 | ||
b9c7bc5a | 8210 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 8211 | { |
b9c7bc5a PZ |
8212 | if (!strcmp(dstr, "import")) { |
8213 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8214 | } else if (!strcmp(dstr, "export")) { | |
8215 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8216 | } else if (!strcmp(dstr, "both")) { | |
8217 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8218 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8219 | } else { | |
8220 | vty_out(vty, "%% direction parse error\n"); | |
8221 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8222 | } |
ddb5b488 PZ |
8223 | return CMD_SUCCESS; |
8224 | } | |
8225 | ||
b9c7bc5a PZ |
8226 | DEFPY (af_rt_vpn_imexport, |
8227 | af_rt_vpn_imexport_cmd, | |
8228 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
8229 | NO_STR | |
8230 | "Specify route target list\n" | |
ddb5b488 | 8231 | "Specify route target list\n" |
b9c7bc5a PZ |
8232 | "Between current address-family and vpn\n" |
8233 | "For routes leaked from vpn to current address-family: match any\n" | |
8234 | "For routes leaked from current address-family to vpn: set\n" | |
8235 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
8236 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
8237 | { | |
8238 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8239 | int ret; | |
8240 | struct ecommunity *ecom = NULL; | |
8241 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
8242 | vpn_policy_direction_t dir; |
8243 | afi_t afi; | |
8244 | int idx = 0; | |
c6423c31 | 8245 | bool yes = true; |
ddb5b488 | 8246 | |
b9c7bc5a | 8247 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8248 | yes = false; |
b9c7bc5a | 8249 | |
0ca70ba5 | 8250 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8251 | if (afi == AFI_MAX) |
8252 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8253 | |
b9c7bc5a | 8254 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
8255 | if (ret != CMD_SUCCESS) |
8256 | return ret; | |
8257 | ||
b9c7bc5a PZ |
8258 | if (yes) { |
8259 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8260 | vty_out(vty, "%% Missing RTLIST\n"); | |
8261 | return CMD_WARNING_CONFIG_FAILED; | |
8262 | } | |
c6423c31 | 8263 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
8264 | if (ret != CMD_SUCCESS) { |
8265 | return ret; | |
8266 | } | |
ddb5b488 PZ |
8267 | } |
8268 | ||
69b07479 DS |
8269 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8270 | if (!dodir[dir]) | |
ddb5b488 | 8271 | continue; |
ddb5b488 | 8272 | |
69b07479 | 8273 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 8274 | |
69b07479 DS |
8275 | if (yes) { |
8276 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8277 | ecommunity_free( | |
8278 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8279 | bgp->vpn_policy[afi].rtlist[dir] = | |
8280 | ecommunity_dup(ecom); | |
8281 | } else { | |
8282 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8283 | ecommunity_free( | |
8284 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8285 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 8286 | } |
69b07479 DS |
8287 | |
8288 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 8289 | } |
69b07479 | 8290 | |
d555f3e9 PZ |
8291 | if (ecom) |
8292 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
8293 | |
8294 | return CMD_SUCCESS; | |
8295 | } | |
8296 | ||
b9c7bc5a PZ |
8297 | ALIAS (af_rt_vpn_imexport, |
8298 | af_no_rt_vpn_imexport_cmd, | |
8299 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
8300 | NO_STR |
8301 | "Specify route target list\n" | |
b9c7bc5a PZ |
8302 | "Specify route target list\n" |
8303 | "Between current address-family and vpn\n" | |
8304 | "For routes leaked from vpn to current address-family\n" | |
8305 | "For routes leaked from current address-family to vpn\n" | |
8306 | "both import and export\n") | |
8307 | ||
8308 | DEFPY (af_route_map_vpn_imexport, | |
8309 | af_route_map_vpn_imexport_cmd, | |
8310 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
8311 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
8312 | NO_STR | |
ddb5b488 | 8313 | "Specify route map\n" |
b9c7bc5a PZ |
8314 | "Between current address-family and vpn\n" |
8315 | "For routes leaked from vpn to current address-family\n" | |
8316 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8317 | "name of route-map\n") |
8318 | { | |
8319 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8320 | int ret; | |
8321 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
8322 | vpn_policy_direction_t dir; |
8323 | afi_t afi; | |
ddb5b488 | 8324 | int idx = 0; |
c6423c31 | 8325 | bool yes = true; |
ddb5b488 | 8326 | |
b9c7bc5a | 8327 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8328 | yes = false; |
b9c7bc5a | 8329 | |
0ca70ba5 | 8330 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8331 | if (afi == AFI_MAX) |
8332 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8333 | |
b9c7bc5a | 8334 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
8335 | if (ret != CMD_SUCCESS) |
8336 | return ret; | |
8337 | ||
69b07479 DS |
8338 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8339 | if (!dodir[dir]) | |
ddb5b488 | 8340 | continue; |
ddb5b488 | 8341 | |
69b07479 | 8342 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 8343 | |
69b07479 DS |
8344 | if (yes) { |
8345 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8346 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8347 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8348 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
8349 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8350 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 8351 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
8352 | if (!bgp->vpn_policy[afi].rmap[dir]) |
8353 | return CMD_SUCCESS; | |
8354 | } else { | |
8355 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8356 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8357 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8358 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8359 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 8360 | } |
69b07479 DS |
8361 | |
8362 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
8363 | } |
8364 | ||
8365 | return CMD_SUCCESS; | |
8366 | } | |
8367 | ||
b9c7bc5a PZ |
8368 | ALIAS (af_route_map_vpn_imexport, |
8369 | af_no_route_map_vpn_imexport_cmd, | |
8370 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
8371 | NO_STR |
8372 | "Specify route map\n" | |
b9c7bc5a PZ |
8373 | "Between current address-family and vpn\n" |
8374 | "For routes leaked from vpn to current address-family\n" | |
8375 | "For routes leaked from current address-family to vpn\n") | |
8376 | ||
bb4f6190 | 8377 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 8378 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
8379 | "Import routes from another VRF\n" |
8380 | "Vrf routes being filtered\n" | |
8381 | "Specify route map\n" | |
8382 | "name of route-map\n") | |
8383 | { | |
8384 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
8385 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
8386 | afi_t afi; | |
bb4f6190 DS |
8387 | struct bgp *bgp_default; |
8388 | ||
0ca70ba5 | 8389 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
8390 | if (afi == AFI_MAX) |
8391 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
8392 | |
8393 | bgp_default = bgp_get_default(); | |
8394 | if (!bgp_default) { | |
8395 | int32_t ret; | |
8396 | as_t as = bgp->as; | |
8397 | ||
8398 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
8399 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
8400 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
8401 | |
8402 | if (ret) { | |
8403 | vty_out(vty, | |
8404 | "VRF default is not configured as a bgp instance\n"); | |
8405 | return CMD_WARNING; | |
8406 | } | |
8407 | } | |
8408 | ||
69b07479 | 8409 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 8410 | |
ae6a6fb4 DS |
8411 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
8412 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8413 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8414 | bgp->vpn_policy[afi].rmap_name[dir] = | |
8415 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8416 | bgp->vpn_policy[afi].rmap[dir] = | |
8417 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8418 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8419 | return CMD_SUCCESS; | |
8420 | ||
8421 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8422 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 8423 | |
69b07479 DS |
8424 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8425 | ||
bb4f6190 DS |
8426 | return CMD_SUCCESS; |
8427 | } | |
8428 | ||
ae6a6fb4 DS |
8429 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
8430 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
8431 | NO_STR |
8432 | "Import routes from another VRF\n" | |
8433 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
8434 | "Specify route map\n" |
8435 | "name of route-map\n") | |
8436 | { | |
8437 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8438 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8439 | afi_t afi; | |
8440 | ||
8441 | afi = vpn_policy_getafi(vty, bgp, true); | |
8442 | if (afi == AFI_MAX) | |
8443 | return CMD_WARNING_CONFIG_FAILED; | |
8444 | ||
8445 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8446 | ||
8447 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8448 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8449 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8450 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8451 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8452 | ||
8453 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
8454 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8455 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
8456 | ||
8457 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8458 | ||
8459 | return CMD_SUCCESS; | |
8460 | } | |
bb4f6190 | 8461 | |
4d1b335c DA |
8462 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
8463 | "[no] import vrf VIEWVRFNAME$import_name", | |
8464 | NO_STR | |
8465 | "Import routes from another VRF\n" | |
8466 | "VRF to import from\n" | |
8467 | "The name of the VRF\n") | |
12a844a5 DS |
8468 | { |
8469 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8470 | struct listnode *node; | |
79ef8664 DS |
8471 | struct bgp *vrf_bgp, *bgp_default; |
8472 | int32_t ret = 0; | |
8473 | as_t as = bgp->as; | |
12a844a5 DS |
8474 | bool remove = false; |
8475 | int32_t idx = 0; | |
8476 | char *vname; | |
a8dadcf6 | 8477 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
8478 | safi_t safi; |
8479 | afi_t afi; | |
8480 | ||
867f0cca | 8481 | if (import_name == NULL) { |
8482 | vty_out(vty, "%% Missing import name\n"); | |
8483 | return CMD_WARNING; | |
8484 | } | |
8485 | ||
ae6a6fb4 DS |
8486 | if (strcmp(import_name, "route-map") == 0) { |
8487 | vty_out(vty, "%% Must include route-map name\n"); | |
8488 | return CMD_WARNING; | |
8489 | } | |
8490 | ||
12a844a5 DS |
8491 | if (argv_find(argv, argc, "no", &idx)) |
8492 | remove = true; | |
8493 | ||
0ca70ba5 DS |
8494 | afi = vpn_policy_getafi(vty, bgp, true); |
8495 | if (afi == AFI_MAX) | |
8496 | return CMD_WARNING_CONFIG_FAILED; | |
8497 | ||
12a844a5 DS |
8498 | safi = bgp_node_safi(vty); |
8499 | ||
25679caa | 8500 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 8501 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
8502 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
8503 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
8504 | remove ? "unimport" : "import", import_name); | |
8505 | return CMD_WARNING; | |
8506 | } | |
8507 | ||
79ef8664 DS |
8508 | bgp_default = bgp_get_default(); |
8509 | if (!bgp_default) { | |
8510 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
8511 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
8512 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
8513 | |
8514 | if (ret) { | |
8515 | vty_out(vty, | |
8516 | "VRF default is not configured as a bgp instance\n"); | |
8517 | return CMD_WARNING; | |
8518 | } | |
8519 | } | |
8520 | ||
12a844a5 DS |
8521 | vrf_bgp = bgp_lookup_by_name(import_name); |
8522 | if (!vrf_bgp) { | |
5742e42b | 8523 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
8524 | vrf_bgp = bgp_default; |
8525 | else | |
0fb8d6e6 | 8526 | /* Auto-create assuming the same AS */ |
5d5393b9 | 8527 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 8528 | |
6e2c7fe6 | 8529 | if (ret) { |
020a3f60 DS |
8530 | vty_out(vty, |
8531 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
8532 | import_name); |
8533 | return CMD_WARNING; | |
8534 | } | |
12a844a5 DS |
8535 | } |
8536 | ||
12a844a5 | 8537 | if (remove) { |
44338987 | 8538 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 8539 | } else { |
44338987 | 8540 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
8541 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
8542 | vname)) { | |
8543 | if (strcmp(vname, import_name) == 0) | |
8544 | return CMD_WARNING; | |
8545 | } | |
8546 | ||
44338987 | 8547 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
8548 | } |
8549 | ||
8550 | return CMD_SUCCESS; | |
8551 | } | |
8552 | ||
b9c7bc5a PZ |
8553 | /* This command is valid only in a bgp vrf instance or the default instance */ |
8554 | DEFPY (bgp_imexport_vpn, | |
8555 | bgp_imexport_vpn_cmd, | |
8556 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
8557 | NO_STR |
8558 | "Import routes to this address-family\n" | |
8559 | "Export routes from this address-family\n" | |
8560 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
8561 | { |
8562 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8563 | int previous_state; |
ddb5b488 | 8564 | afi_t afi; |
b9c7bc5a | 8565 | safi_t safi; |
ddb5b488 | 8566 | int idx = 0; |
c6423c31 | 8567 | bool yes = true; |
b9c7bc5a PZ |
8568 | int flag; |
8569 | vpn_policy_direction_t dir; | |
ddb5b488 | 8570 | |
b9c7bc5a | 8571 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8572 | yes = false; |
ddb5b488 | 8573 | |
b9c7bc5a PZ |
8574 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
8575 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 8576 | |
b9c7bc5a PZ |
8577 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
8578 | return CMD_WARNING_CONFIG_FAILED; | |
8579 | } | |
ddb5b488 | 8580 | |
b9c7bc5a PZ |
8581 | afi = bgp_node_afi(vty); |
8582 | safi = bgp_node_safi(vty); | |
8583 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
8584 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
8585 | return CMD_WARNING_CONFIG_FAILED; | |
8586 | } | |
ddb5b488 | 8587 | |
b9c7bc5a PZ |
8588 | if (!strcmp(direction_str, "import")) { |
8589 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
8590 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8591 | } else if (!strcmp(direction_str, "export")) { | |
8592 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
8593 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
8594 | } else { | |
8595 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
8596 | return CMD_WARNING_CONFIG_FAILED; | |
8597 | } | |
8598 | ||
8599 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 8600 | |
b9c7bc5a PZ |
8601 | if (yes) { |
8602 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
8603 | if (!previous_state) { | |
8604 | /* trigger export current vrf */ | |
ddb5b488 PZ |
8605 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8606 | } | |
b9c7bc5a PZ |
8607 | } else { |
8608 | if (previous_state) { | |
8609 | /* trigger un-export current vrf */ | |
8610 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8611 | } | |
8612 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
8613 | } |
8614 | ||
8615 | return CMD_SUCCESS; | |
8616 | } | |
8617 | ||
301ad80a PG |
8618 | DEFPY (af_routetarget_import, |
8619 | af_routetarget_import_cmd, | |
9a659715 | 8620 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
8621 | NO_STR |
8622 | "Specify route target list\n" | |
8623 | "Specify route target list\n" | |
9a659715 PG |
8624 | "Specify route target list\n" |
8625 | "Specify route target list\n" | |
301ad80a PG |
8626 | "Flow-spec redirect type route target\n" |
8627 | "Import routes to this address-family\n" | |
9a659715 | 8628 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
8629 | { |
8630 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8631 | int ret; | |
8632 | struct ecommunity *ecom = NULL; | |
301ad80a | 8633 | afi_t afi; |
9a659715 | 8634 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
8635 | bool yes = true; |
8636 | bool rt6 = false; | |
301ad80a PG |
8637 | |
8638 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8639 | yes = false; |
301ad80a | 8640 | |
9a659715 PG |
8641 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
8642 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 8643 | rt6 = true; |
301ad80a | 8644 | |
0ca70ba5 | 8645 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8646 | if (afi == AFI_MAX) |
8647 | return CMD_WARNING_CONFIG_FAILED; | |
8648 | ||
9a659715 PG |
8649 | if (rt6 && afi != AFI_IP6) |
8650 | return CMD_WARNING_CONFIG_FAILED; | |
8651 | ||
301ad80a PG |
8652 | if (yes) { |
8653 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8654 | vty_out(vty, "%% Missing RTLIST\n"); | |
8655 | return CMD_WARNING_CONFIG_FAILED; | |
8656 | } | |
9a659715 | 8657 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
8658 | if (ret != CMD_SUCCESS) |
8659 | return ret; | |
8660 | } | |
69b07479 DS |
8661 | |
8662 | if (yes) { | |
8663 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8664 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8665 | .import_redirect_rtlist); |
69b07479 DS |
8666 | bgp->vpn_policy[afi].import_redirect_rtlist = |
8667 | ecommunity_dup(ecom); | |
8668 | } else { | |
8669 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8670 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8671 | .import_redirect_rtlist); |
69b07479 | 8672 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 8673 | } |
69b07479 | 8674 | |
301ad80a PG |
8675 | if (ecom) |
8676 | ecommunity_free(&ecom); | |
8677 | ||
8678 | return CMD_SUCCESS; | |
8679 | } | |
8680 | ||
505e5056 | 8681 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 8682 | address_family_ipv4_safi_cmd, |
8683 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
8684 | "Enter Address Family command mode\n" | |
8685 | "Address Family\n" | |
8686 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 8687 | { |
f51bae9c | 8688 | |
d62a17ae | 8689 | if (argc == 3) { |
2131d5cf | 8690 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8691 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
8692 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
8693 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8694 | && safi != SAFI_EVPN) { |
31947174 MK |
8695 | vty_out(vty, |
8696 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8697 | return CMD_WARNING_CONFIG_FAILED; |
8698 | } | |
d62a17ae | 8699 | vty->node = bgp_node_type(AFI_IP, safi); |
8700 | } else | |
8701 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 8702 | |
d62a17ae | 8703 | return CMD_SUCCESS; |
718e3744 | 8704 | } |
8705 | ||
505e5056 | 8706 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 8707 | address_family_ipv6_safi_cmd, |
8708 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
8709 | "Enter Address Family command mode\n" | |
8710 | "Address Family\n" | |
8711 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 8712 | { |
d62a17ae | 8713 | if (argc == 3) { |
2131d5cf | 8714 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8715 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
8716 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
8717 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8718 | && safi != SAFI_EVPN) { |
31947174 MK |
8719 | vty_out(vty, |
8720 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8721 | return CMD_WARNING_CONFIG_FAILED; |
8722 | } | |
d62a17ae | 8723 | vty->node = bgp_node_type(AFI_IP6, safi); |
8724 | } else | |
8725 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 8726 | |
d62a17ae | 8727 | return CMD_SUCCESS; |
25ffbdc1 | 8728 | } |
718e3744 | 8729 | |
d6902373 | 8730 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 8731 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 8732 | address_family_vpnv4_cmd, |
8334fd5a | 8733 | "address-family vpnv4 [unicast]", |
718e3744 | 8734 | "Enter Address Family command mode\n" |
8c3deaae | 8735 | "Address Family\n" |
3a2d747c | 8736 | "Address Family modifier\n") |
718e3744 | 8737 | { |
d62a17ae | 8738 | vty->node = BGP_VPNV4_NODE; |
8739 | return CMD_SUCCESS; | |
718e3744 | 8740 | } |
8741 | ||
505e5056 | 8742 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 8743 | address_family_vpnv6_cmd, |
8334fd5a | 8744 | "address-family vpnv6 [unicast]", |
8ecd3266 | 8745 | "Enter Address Family command mode\n" |
8c3deaae | 8746 | "Address Family\n" |
3a2d747c | 8747 | "Address Family modifier\n") |
8ecd3266 | 8748 | { |
d62a17ae | 8749 | vty->node = BGP_VPNV6_NODE; |
8750 | return CMD_SUCCESS; | |
8ecd3266 | 8751 | } |
64e4a6c5 | 8752 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 8753 | |
505e5056 | 8754 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 8755 | address_family_evpn_cmd, |
7111c1a0 | 8756 | "address-family l2vpn evpn", |
4e0b7b6d | 8757 | "Enter Address Family command mode\n" |
7111c1a0 QY |
8758 | "Address Family\n" |
8759 | "Address Family modifier\n") | |
4e0b7b6d | 8760 | { |
2131d5cf | 8761 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8762 | vty->node = BGP_EVPN_NODE; |
8763 | return CMD_SUCCESS; | |
4e0b7b6d PG |
8764 | } |
8765 | ||
505e5056 | 8766 | DEFUN_NOSH (exit_address_family, |
718e3744 | 8767 | exit_address_family_cmd, |
8768 | "exit-address-family", | |
8769 | "Exit from Address Family configuration mode\n") | |
8770 | { | |
d62a17ae | 8771 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
8772 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
8773 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
8774 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
8775 | || vty->node == BGP_EVPN_NODE |
8776 | || vty->node == BGP_FLOWSPECV4_NODE | |
8777 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 8778 | vty->node = BGP_NODE; |
8779 | return CMD_SUCCESS; | |
718e3744 | 8780 | } |
6b0655a2 | 8781 | |
8ad7271d | 8782 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 8783 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
8784 | const char *ip_str, afi_t afi, safi_t safi, | |
8785 | struct prefix_rd *prd) | |
8786 | { | |
8787 | int ret; | |
8788 | struct prefix match; | |
9bcb3eef DS |
8789 | struct bgp_dest *dest; |
8790 | struct bgp_dest *rm; | |
d62a17ae | 8791 | struct bgp *bgp; |
8792 | struct bgp_table *table; | |
8793 | struct bgp_table *rib; | |
8794 | ||
8795 | /* BGP structure lookup. */ | |
8796 | if (view_name) { | |
8797 | bgp = bgp_lookup_by_name(view_name); | |
8798 | if (bgp == NULL) { | |
8799 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
8800 | view_name); | |
8801 | return CMD_WARNING; | |
8802 | } | |
8803 | } else { | |
8804 | bgp = bgp_get_default(); | |
8805 | if (bgp == NULL) { | |
8806 | vty_out(vty, "%% No BGP process is configured\n"); | |
8807 | return CMD_WARNING; | |
8808 | } | |
8809 | } | |
8810 | ||
8811 | /* Check IP address argument. */ | |
8812 | ret = str2prefix(ip_str, &match); | |
8813 | if (!ret) { | |
8814 | vty_out(vty, "%% address is malformed\n"); | |
8815 | return CMD_WARNING; | |
8816 | } | |
8817 | ||
8818 | match.family = afi2family(afi); | |
8819 | rib = bgp->rib[afi][safi]; | |
8820 | ||
8821 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
8822 | for (dest = bgp_table_top(rib); dest; |
8823 | dest = bgp_route_next(dest)) { | |
8824 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8825 | |
9bcb3eef | 8826 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 8827 | continue; |
8828 | ||
9bcb3eef | 8829 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
8830 | if (table == NULL) |
8831 | continue; | |
8832 | ||
8833 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
8834 | const struct prefix *rm_p = | |
9bcb3eef | 8835 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
8836 | |
8837 | if (rm_p->prefixlen == match.prefixlen) { | |
8838 | SET_FLAG(rm->flags, | |
8839 | BGP_NODE_USER_CLEAR); | |
8840 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 8841 | } |
9bcb3eef | 8842 | bgp_dest_unlock_node(rm); |
d62a17ae | 8843 | } |
8844 | } | |
8845 | } else { | |
9bcb3eef DS |
8846 | if ((dest = bgp_node_match(rib, &match)) != NULL) { |
8847 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8848 | |
9bcb3eef DS |
8849 | if (dest_p->prefixlen == match.prefixlen) { |
8850 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
8851 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 8852 | } |
9bcb3eef | 8853 | bgp_dest_unlock_node(dest); |
d62a17ae | 8854 | } |
8855 | } | |
8856 | ||
8857 | return CMD_SUCCESS; | |
8ad7271d DS |
8858 | } |
8859 | ||
b09b5ae0 | 8860 | /* one clear bgp command to rule them all */ |
718e3744 | 8861 | DEFUN (clear_ip_bgp_all, |
8862 | clear_ip_bgp_all_cmd, | |
453c92f6 | 8863 | "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 | 8864 | CLEAR_STR |
8865 | IP_STR | |
8866 | BGP_STR | |
838758ac | 8867 | BGP_INSTANCE_HELP_STR |
510afcd6 | 8868 | BGP_AFI_HELP_STR |
fd5e7b70 | 8869 | "Address Family\n" |
510afcd6 | 8870 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8871 | "Address Family modifier\n" |
b09b5ae0 | 8872 | "Clear all peers\n" |
453c92f6 | 8873 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8874 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8875 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8876 | "Clear peers with the AS number\n" |
8877 | "Clear all external peers\n" | |
718e3744 | 8878 | "Clear all members of peer-group\n" |
b09b5ae0 | 8879 | "BGP peer-group name\n" |
b09b5ae0 DW |
8880 | BGP_SOFT_STR |
8881 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8882 | BGP_SOFT_OUT_STR |
8883 | BGP_SOFT_IN_STR | |
8884 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8885 | BGP_SOFT_OUT_STR) |
718e3744 | 8886 | { |
d62a17ae | 8887 | char *vrf = NULL; |
8888 | ||
dc912615 DS |
8889 | afi_t afi = AFI_UNSPEC; |
8890 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8891 | enum clear_sort clr_sort = clear_peer; |
8892 | enum bgp_clear_type clr_type; | |
8893 | char *clr_arg = NULL; | |
8894 | ||
8895 | int idx = 0; | |
ff8a8a7a CS |
8896 | char errmsg[BUFSIZ] = {'\0'}; |
8897 | int ret; | |
d62a17ae | 8898 | |
8899 | /* clear [ip] bgp */ | |
8900 | if (argv_find(argv, argc, "ip", &idx)) | |
8901 | afi = AFI_IP; | |
8902 | ||
9a8bdf1c PG |
8903 | /* [<vrf> VIEWVRFNAME] */ |
8904 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8905 | vrf = argv[idx + 1]->arg; | |
8906 | idx += 2; | |
8907 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8908 | vrf = NULL; | |
8909 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8910 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8911 | vrf = argv[idx + 1]->arg; |
8912 | idx += 2; | |
8913 | } | |
d62a17ae | 8914 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8915 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8916 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8917 | ||
d7b9898c | 8918 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8919 | if (argv_find(argv, argc, "*", &idx)) { |
8920 | clr_sort = clear_all; | |
8921 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8922 | clr_sort = clear_peer; | |
8923 | clr_arg = argv[idx]->arg; | |
8924 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8925 | clr_sort = clear_peer; | |
8926 | clr_arg = argv[idx]->arg; | |
8927 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8928 | clr_sort = clear_group; | |
8929 | idx++; | |
8930 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8931 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8932 | clr_sort = clear_peer; |
8933 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8934 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8935 | clr_sort = clear_peer; | |
8936 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8937 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8938 | clr_sort = clear_as; | |
8939 | clr_arg = argv[idx]->arg; | |
8940 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8941 | clr_sort = clear_external; | |
8942 | } | |
8943 | ||
8944 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8945 | if (argv_find(argv, argc, "soft", &idx)) { | |
8946 | if (argv_find(argv, argc, "in", &idx) | |
8947 | || argv_find(argv, argc, "out", &idx)) | |
8948 | clr_type = strmatch(argv[idx]->text, "in") | |
8949 | ? BGP_CLEAR_SOFT_IN | |
8950 | : BGP_CLEAR_SOFT_OUT; | |
8951 | else | |
8952 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8953 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8954 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8955 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8956 | : BGP_CLEAR_SOFT_IN; | |
8957 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8958 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8959 | } else | |
8960 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8961 | ||
ff8a8a7a CS |
8962 | ret = bgp_clear_vty(vrf, afi, safi, clr_sort, clr_type, clr_arg, errmsg, |
8963 | sizeof(errmsg)); | |
8964 | if (ret != NB_OK) | |
8965 | vty_out(vty, "Error description: %s\n", errmsg); | |
8966 | ||
8967 | return ret; | |
838758ac | 8968 | } |
01080f7c | 8969 | |
8ad7271d DS |
8970 | DEFUN (clear_ip_bgp_prefix, |
8971 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8972 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8973 | CLEAR_STR |
8974 | IP_STR | |
8975 | BGP_STR | |
838758ac | 8976 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8977 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8978 | "IPv4 prefix\n") |
8ad7271d | 8979 | { |
d62a17ae | 8980 | char *vrf = NULL; |
8981 | char *prefix = NULL; | |
8ad7271d | 8982 | |
d62a17ae | 8983 | int idx = 0; |
01080f7c | 8984 | |
d62a17ae | 8985 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8986 | if (argv_find(argv, argc, "vrf", &idx)) { |
8987 | vrf = argv[idx + 1]->arg; | |
8988 | idx += 2; | |
8989 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8990 | vrf = NULL; | |
8991 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8992 | /* [<view> VIEWVRFNAME] */ | |
8993 | vrf = argv[idx + 1]->arg; | |
8994 | idx += 2; | |
8995 | } | |
0c7b1b01 | 8996 | |
d62a17ae | 8997 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8998 | |
d62a17ae | 8999 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 9000 | } |
8ad7271d | 9001 | |
b09b5ae0 DW |
9002 | DEFUN (clear_bgp_ipv6_safi_prefix, |
9003 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 9004 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9005 | CLEAR_STR |
3a2d747c | 9006 | IP_STR |
718e3744 | 9007 | BGP_STR |
8c3deaae | 9008 | "Address Family\n" |
46f296b4 | 9009 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9010 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9011 | "IPv6 prefix\n") |
718e3744 | 9012 | { |
9b475e76 PG |
9013 | int idx_safi = 0; |
9014 | int idx_ipv6_prefix = 0; | |
9015 | safi_t safi = SAFI_UNICAST; | |
9016 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9017 | argv[idx_ipv6_prefix]->arg : NULL; | |
9018 | ||
9019 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 9020 | return bgp_clear_prefix( |
9b475e76 PG |
9021 | vty, NULL, prefix, AFI_IP6, |
9022 | safi, NULL); | |
838758ac | 9023 | } |
01080f7c | 9024 | |
b09b5ae0 DW |
9025 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
9026 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 9027 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9028 | CLEAR_STR |
3a2d747c | 9029 | IP_STR |
718e3744 | 9030 | BGP_STR |
838758ac | 9031 | BGP_INSTANCE_HELP_STR |
8c3deaae | 9032 | "Address Family\n" |
46f296b4 | 9033 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9034 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9035 | "IPv6 prefix\n") |
718e3744 | 9036 | { |
9b475e76 | 9037 | int idx_safi = 0; |
9a8bdf1c | 9038 | int idx_vrfview = 0; |
9b475e76 PG |
9039 | int idx_ipv6_prefix = 0; |
9040 | safi_t safi = SAFI_UNICAST; | |
9041 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9042 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 9043 | char *vrfview = NULL; |
9b475e76 | 9044 | |
9a8bdf1c PG |
9045 | /* [<view|vrf> VIEWVRFNAME] */ |
9046 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9047 | vrfview = argv[idx_vrfview + 1]->arg; | |
9048 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9049 | vrfview = NULL; | |
9050 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9051 | /* [<view> VIEWVRFNAME] */ | |
9052 | vrfview = argv[idx_vrfview + 1]->arg; | |
9053 | } | |
9b475e76 PG |
9054 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
9055 | ||
d62a17ae | 9056 | return bgp_clear_prefix( |
9b475e76 PG |
9057 | vty, vrfview, prefix, |
9058 | AFI_IP6, safi, NULL); | |
718e3744 | 9059 | } |
9060 | ||
b09b5ae0 DW |
9061 | DEFUN (show_bgp_views, |
9062 | show_bgp_views_cmd, | |
d6e3c605 | 9063 | "show [ip] bgp views", |
b09b5ae0 | 9064 | SHOW_STR |
d6e3c605 | 9065 | IP_STR |
01080f7c | 9066 | BGP_STR |
b09b5ae0 | 9067 | "Show the defined BGP views\n") |
01080f7c | 9068 | { |
d62a17ae | 9069 | struct list *inst = bm->bgp; |
9070 | struct listnode *node; | |
9071 | struct bgp *bgp; | |
01080f7c | 9072 | |
d62a17ae | 9073 | vty_out(vty, "Defined BGP views:\n"); |
9074 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9075 | /* Skip VRFs. */ | |
9076 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9077 | continue; | |
9078 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9079 | bgp->as); | |
9080 | } | |
e52702f2 | 9081 | |
d62a17ae | 9082 | return CMD_SUCCESS; |
e0081f70 ML |
9083 | } |
9084 | ||
8386ac43 | 9085 | DEFUN (show_bgp_vrfs, |
9086 | show_bgp_vrfs_cmd, | |
d6e3c605 | 9087 | "show [ip] bgp vrfs [json]", |
8386ac43 | 9088 | SHOW_STR |
d6e3c605 | 9089 | IP_STR |
8386ac43 | 9090 | BGP_STR |
9091 | "Show BGP VRFs\n" | |
9973d184 | 9092 | JSON_STR) |
8386ac43 | 9093 | { |
fe1dc5a3 | 9094 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 9095 | struct list *inst = bm->bgp; |
9096 | struct listnode *node; | |
9097 | struct bgp *bgp; | |
9f049418 | 9098 | bool uj = use_json(argc, argv); |
d62a17ae | 9099 | json_object *json = NULL; |
9100 | json_object *json_vrfs = NULL; | |
9101 | int count = 0; | |
d62a17ae | 9102 | |
d62a17ae | 9103 | if (uj) { |
9104 | json = json_object_new_object(); | |
9105 | json_vrfs = json_object_new_object(); | |
9106 | } | |
9107 | ||
9108 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9109 | const char *name, *type; | |
9110 | struct peer *peer; | |
7fe96307 | 9111 | struct listnode *node2, *nnode2; |
d62a17ae | 9112 | int peers_cfg, peers_estb; |
9113 | json_object *json_vrf = NULL; | |
d62a17ae | 9114 | |
9115 | /* Skip Views. */ | |
9116 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9117 | continue; | |
9118 | ||
9119 | count++; | |
efb4077a | 9120 | if (!uj && count == 1) { |
fe1dc5a3 | 9121 | vty_out(vty, |
efb4077a | 9122 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 9123 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
9124 | "#PeersEstb", "Name"); |
9125 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
9126 | "L3-VNI", "RouterMAC", "Interface"); | |
9127 | } | |
d62a17ae | 9128 | |
9129 | peers_cfg = peers_estb = 0; | |
9130 | if (uj) | |
9131 | json_vrf = json_object_new_object(); | |
9132 | ||
9133 | ||
7fe96307 | 9134 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 9135 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
9136 | continue; | |
9137 | peers_cfg++; | |
9138 | if (peer->status == Established) | |
9139 | peers_estb++; | |
9140 | } | |
9141 | ||
9142 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 9143 | name = VRF_DEFAULT_NAME; |
d62a17ae | 9144 | type = "DFLT"; |
9145 | } else { | |
9146 | name = bgp->name; | |
9147 | type = "VRF"; | |
9148 | } | |
9149 | ||
a8bf7d9c | 9150 | |
d62a17ae | 9151 | if (uj) { |
a4d82a8a PZ |
9152 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9153 | ? -1 | |
9154 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
9155 | char buf[BUFSIZ] = {0}; |
9156 | ||
d62a17ae | 9157 | json_object_string_add(json_vrf, "type", type); |
9158 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
9159 | json_object_string_add(json_vrf, "routerId", | |
23d0a753 DA |
9160 | inet_ntop(AF_INET, |
9161 | &bgp->router_id, buf, | |
9162 | sizeof(buf))); | |
d62a17ae | 9163 | json_object_int_add(json_vrf, "numConfiguredPeers", |
9164 | peers_cfg); | |
9165 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
9166 | peers_estb); | |
9167 | ||
fe1dc5a3 | 9168 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
9169 | json_object_string_add( |
9170 | json_vrf, "rmac", | |
9171 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
9172 | json_object_string_add(json_vrf, "interface", |
9173 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9174 | bgp->vrf_id)); | |
d62a17ae | 9175 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 9176 | } else { |
23d0a753 | 9177 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
9178 | type, |
9179 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
9180 | : (int)bgp->vrf_id, | |
23d0a753 | 9181 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
9182 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
9183 | bgp->l3vni, | |
9184 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
9185 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9186 | bgp->vrf_id)); | |
9187 | } | |
d62a17ae | 9188 | } |
9189 | ||
9190 | if (uj) { | |
9191 | json_object_object_add(json, "vrfs", json_vrfs); | |
9192 | ||
9193 | json_object_int_add(json, "totalVrfs", count); | |
9194 | ||
996c9314 LB |
9195 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9196 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9197 | json_object_free(json); |
9198 | } else { | |
9199 | if (count) | |
9200 | vty_out(vty, | |
9201 | "\nTotal number of VRFs (including default): %d\n", | |
9202 | count); | |
9203 | } | |
9204 | ||
9205 | return CMD_SUCCESS; | |
8386ac43 | 9206 | } |
9207 | ||
48ecf8f5 DS |
9208 | DEFUN (show_bgp_mac_hash, |
9209 | show_bgp_mac_hash_cmd, | |
9210 | "show bgp mac hash", | |
9211 | SHOW_STR | |
9212 | BGP_STR | |
9213 | "Mac Address\n" | |
9214 | "Mac Address database\n") | |
9215 | { | |
9216 | bgp_mac_dump_table(vty); | |
9217 | ||
9218 | return CMD_SUCCESS; | |
9219 | } | |
acf71666 | 9220 | |
e3b78da8 | 9221 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 9222 | { |
0291c246 | 9223 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 9224 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 9225 | |
23d0a753 | 9226 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
9227 | } |
9228 | ||
9229 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
9230 | { | |
9231 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 9232 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
9233 | |
9234 | vty_out(vty, "Tunnel-ip database:\n"); | |
9235 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 9236 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
9237 | vty); |
9238 | } | |
9239 | ||
15c81ca4 DS |
9240 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
9241 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
9242 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
9243 | "martian next-hops\n" |
9244 | "martian next-hop database\n") | |
acf71666 | 9245 | { |
0291c246 | 9246 | struct bgp *bgp = NULL; |
15c81ca4 | 9247 | int idx = 0; |
9a8bdf1c PG |
9248 | char *name = NULL; |
9249 | ||
9250 | /* [<vrf> VIEWVRFNAME] */ | |
9251 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9252 | name = argv[idx + 1]->arg; | |
9253 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
9254 | name = NULL; | |
9255 | } else if (argv_find(argv, argc, "view", &idx)) | |
9256 | /* [<view> VIEWVRFNAME] */ | |
9257 | name = argv[idx + 1]->arg; | |
9258 | if (name) | |
9259 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
9260 | else |
9261 | bgp = bgp_get_default(); | |
acf71666 | 9262 | |
acf71666 MK |
9263 | if (!bgp) { |
9264 | vty_out(vty, "%% No BGP process is configured\n"); | |
9265 | return CMD_WARNING; | |
9266 | } | |
9267 | bgp_show_martian_nexthops(vty, bgp); | |
9268 | ||
9269 | return CMD_SUCCESS; | |
9270 | } | |
9271 | ||
f412b39a | 9272 | DEFUN (show_bgp_memory, |
4bf6a362 | 9273 | show_bgp_memory_cmd, |
7fa12b13 | 9274 | "show [ip] bgp memory", |
4bf6a362 | 9275 | SHOW_STR |
3a2d747c | 9276 | IP_STR |
4bf6a362 PJ |
9277 | BGP_STR |
9278 | "Global BGP memory statistics\n") | |
9279 | { | |
d62a17ae | 9280 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
9281 | unsigned long count; | |
9282 | ||
9283 | /* RIB related usage stats */ | |
9284 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
9285 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
9286 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 9287 | count * sizeof(struct bgp_dest))); |
d62a17ae | 9288 | |
9289 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
9290 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
9291 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 9292 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 9293 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
9294 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
9295 | count, | |
4b7e6066 DS |
9296 | mtype_memstr( |
9297 | memstrbuf, sizeof(memstrbuf), | |
9298 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 9299 | |
9300 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
9301 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
9302 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9303 | count * sizeof(struct bgp_static))); | |
9304 | ||
9305 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
9306 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
9307 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9308 | count * sizeof(struct bpacket))); | |
9309 | ||
9310 | /* Adj-In/Out */ | |
9311 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
9312 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
9313 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9314 | count * sizeof(struct bgp_adj_in))); | |
9315 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
9316 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
9317 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9318 | count * sizeof(struct bgp_adj_out))); | |
9319 | ||
9320 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
9321 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
9322 | count, | |
9323 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9324 | count * sizeof(struct bgp_nexthop_cache))); | |
9325 | ||
9326 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
9327 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
9328 | count, | |
9329 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9330 | count * sizeof(struct bgp_damp_info))); | |
9331 | ||
9332 | /* Attributes */ | |
9333 | count = attr_count(); | |
9334 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
9335 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9336 | count * sizeof(struct attr))); | |
9337 | ||
9338 | if ((count = attr_unknown_count())) | |
9339 | vty_out(vty, "%ld unknown attributes\n", count); | |
9340 | ||
9341 | /* AS_PATH attributes */ | |
9342 | count = aspath_count(); | |
9343 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
9344 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9345 | count * sizeof(struct aspath))); | |
9346 | ||
9347 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
9348 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
9349 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9350 | count * sizeof(struct assegment))); | |
9351 | ||
9352 | /* Other attributes */ | |
9353 | if ((count = community_count())) | |
9354 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9355 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9356 | count * sizeof(struct community))); | |
d62a17ae | 9357 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
9358 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9359 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9360 | count * sizeof(struct ecommunity))); | |
d62a17ae | 9361 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
9362 | vty_out(vty, | |
9363 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
9364 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9365 | count * sizeof(struct lcommunity))); | |
d62a17ae | 9366 | |
9367 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
9368 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
9369 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9370 | count * sizeof(struct cluster_list))); | |
9371 | ||
9372 | /* Peer related usage */ | |
9373 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
9374 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
9375 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9376 | count * sizeof(struct peer))); | |
9377 | ||
9378 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
9379 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
9380 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9381 | count * sizeof(struct peer_group))); | |
9382 | ||
9383 | /* Other */ | |
d62a17ae | 9384 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
9385 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
9386 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9387 | count * sizeof(regex_t))); | |
d62a17ae | 9388 | return CMD_SUCCESS; |
4bf6a362 | 9389 | } |
fee0f4c6 | 9390 | |
57a9c8a8 DS |
9391 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
9392 | { | |
9393 | json_object *bestpath = json_object_new_object(); | |
9394 | ||
892fedb6 | 9395 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
9396 | json_object_string_add(bestpath, "asPath", "ignore"); |
9397 | ||
892fedb6 | 9398 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
9399 | json_object_string_add(bestpath, "asPath", "confed"); |
9400 | ||
892fedb6 DA |
9401 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
9402 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 9403 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9404 | "as-set"); |
9405 | else | |
a4d82a8a | 9406 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9407 | "true"); |
9408 | } else | |
a4d82a8a | 9409 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 9410 | |
892fedb6 | 9411 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 9412 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
9413 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
9414 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
9415 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 9416 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 9417 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
9418 | json_object_string_add(bestpath, "med", |
9419 | "missing-as-worst"); | |
9420 | else | |
9421 | json_object_string_add(bestpath, "med", "true"); | |
9422 | } | |
9423 | ||
9424 | json_object_object_add(json, "bestPath", bestpath); | |
9425 | } | |
9426 | ||
3577f1c5 DD |
9427 | /* Print the error code/subcode for why the peer is down */ |
9428 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
9429 | json_object *json_peer, bool use_json) | |
9430 | { | |
9431 | const char *code_str; | |
9432 | const char *subcode_str; | |
9433 | ||
9434 | if (use_json) { | |
9435 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9436 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9437 | char errorcodesubcode_hexstr[5]; | |
9438 | char errorcodesubcode_str[256]; | |
9439 | ||
9440 | code_str = bgp_notify_code_str(peer->notify.code); | |
9441 | subcode_str = bgp_notify_subcode_str( | |
9442 | peer->notify.code, | |
9443 | peer->notify.subcode); | |
9444 | ||
772270f3 QY |
9445 | snprintf(errorcodesubcode_hexstr, |
9446 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
9447 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
9448 | json_object_string_add(json_peer, |
9449 | "lastErrorCodeSubcode", | |
9450 | errorcodesubcode_hexstr); | |
9451 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9452 | code_str, subcode_str); | |
9453 | json_object_string_add(json_peer, | |
9454 | "lastNotificationReason", | |
9455 | errorcodesubcode_str); | |
9456 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9457 | && peer->notify.code == BGP_NOTIFY_CEASE | |
9458 | && (peer->notify.subcode | |
9459 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9460 | || peer->notify.subcode | |
9461 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9462 | && peer->notify.length) { | |
9463 | char msgbuf[1024]; | |
9464 | const char *msg_str; | |
9465 | ||
9466 | msg_str = bgp_notify_admin_message( | |
9467 | msgbuf, sizeof(msgbuf), | |
9468 | (uint8_t *)peer->notify.data, | |
9469 | peer->notify.length); | |
9470 | if (msg_str) | |
9471 | json_object_string_add( | |
9472 | json_peer, | |
9473 | "lastShutdownDescription", | |
9474 | msg_str); | |
9475 | } | |
9476 | ||
c258527b | 9477 | } |
3577f1c5 DD |
9478 | json_object_string_add(json_peer, "lastResetDueTo", |
9479 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
9480 | json_object_int_add(json_peer, "lastResetCode", |
9481 | peer->last_reset); | |
3577f1c5 DD |
9482 | } else { |
9483 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9484 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9485 | code_str = bgp_notify_code_str(peer->notify.code); | |
9486 | subcode_str = | |
9487 | bgp_notify_subcode_str(peer->notify.code, | |
9488 | peer->notify.subcode); | |
9489 | vty_out(vty, " Notification %s (%s%s)\n", | |
9490 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9491 | ? "sent" | |
9492 | : "received", | |
9493 | code_str, subcode_str); | |
9494 | } else { | |
e91c24c8 | 9495 | vty_out(vty, " %s\n", |
3577f1c5 DD |
9496 | peer_down_str[(int)peer->last_reset]); |
9497 | } | |
9498 | } | |
9499 | } | |
9500 | ||
9501 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
9502 | safi_t safi) | |
9503 | { | |
9504 | return ((peer->status != Established) || | |
9505 | !peer->afc_recv[afi][safi]); | |
9506 | } | |
9507 | ||
9508 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
9509 | struct peer *peer, json_object *json_peer, | |
9510 | int max_neighbor_width, bool use_json) | |
9511 | { | |
9512 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
9513 | int len; | |
9514 | ||
9515 | if (use_json) { | |
9516 | if (peer_dynamic_neighbor(peer)) | |
9517 | json_object_boolean_true_add(json_peer, | |
9518 | "dynamicPeer"); | |
9519 | if (peer->hostname) | |
9520 | json_object_string_add(json_peer, "hostname", | |
9521 | peer->hostname); | |
9522 | ||
9523 | if (peer->domainname) | |
9524 | json_object_string_add(json_peer, "domainname", | |
9525 | peer->domainname); | |
9526 | json_object_int_add(json_peer, "connectionsEstablished", | |
9527 | peer->established); | |
9528 | json_object_int_add(json_peer, "connectionsDropped", | |
9529 | peer->dropped); | |
9530 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
9531 | use_json, json_peer); | |
9532 | if (peer->status == Established) | |
9533 | json_object_string_add(json_peer, "lastResetDueTo", | |
9534 | "AFI/SAFI Not Negotiated"); | |
9535 | else | |
9536 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
9537 | } else { | |
9538 | dn_flag[1] = '\0'; | |
9539 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
9540 | if (peer->hostname | |
892fedb6 | 9541 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
9542 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
9543 | peer->hostname, peer->host); | |
9544 | else | |
9545 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
9546 | ||
9547 | /* pad the neighbor column with spaces */ | |
9548 | if (len < max_neighbor_width) | |
9549 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9550 | " "); | |
e91c24c8 | 9551 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
9552 | peer->dropped, |
9553 | peer_uptime(peer->uptime, timebuf, | |
9554 | BGP_UPTIME_LEN, 0, NULL)); | |
9555 | if (peer->status == Established) | |
9556 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
9557 | else | |
9558 | bgp_show_peer_reset(vty, peer, NULL, | |
9559 | false); | |
9560 | } | |
9561 | } | |
c258527b | 9562 | |
3577f1c5 | 9563 | |
718e3744 | 9564 | /* Show BGP peer's summary information. */ |
d62a17ae | 9565 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
10b49f14 DA |
9566 | bool show_failed, bool show_established, |
9567 | bool use_json) | |
d62a17ae | 9568 | { |
9569 | struct peer *peer; | |
9570 | struct listnode *node, *nnode; | |
9571 | unsigned int count = 0, dn_count = 0; | |
9572 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
9573 | char neighbor_buf[VTY_BUFSIZ]; | |
9574 | int neighbor_col_default_width = 16; | |
3577f1c5 | 9575 | int len, failed_count = 0; |
d62a17ae | 9576 | int max_neighbor_width = 0; |
9577 | int pfx_rcd_safi; | |
3c13337d | 9578 | json_object *json = NULL; |
d62a17ae | 9579 | json_object *json_peer = NULL; |
9580 | json_object *json_peers = NULL; | |
50e05855 | 9581 | struct peer_af *paf; |
d3ada366 | 9582 | struct bgp_filter *filter; |
d62a17ae | 9583 | |
9584 | /* labeled-unicast routes are installed in the unicast table so in order | |
9585 | * to | |
9586 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
9587 | */ | |
3577f1c5 | 9588 | |
d62a17ae | 9589 | if (safi == SAFI_LABELED_UNICAST) |
9590 | pfx_rcd_safi = SAFI_UNICAST; | |
9591 | else | |
9592 | pfx_rcd_safi = safi; | |
9593 | ||
9594 | if (use_json) { | |
3c13337d | 9595 | json = json_object_new_object(); |
d62a17ae | 9596 | json_peers = json_object_new_object(); |
3577f1c5 DD |
9597 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
9598 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9599 | continue; | |
9600 | ||
9601 | if (peer->afc[afi][safi]) { | |
9602 | /* See if we have at least a single failed peer */ | |
9603 | if (bgp_has_peer_failed(peer, afi, safi)) | |
9604 | failed_count++; | |
9605 | count++; | |
9606 | } | |
9607 | if (peer_dynamic_neighbor(peer)) | |
9608 | dn_count++; | |
9609 | } | |
c258527b | 9610 | |
d62a17ae | 9611 | } else { |
9612 | /* Loop over all neighbors that will be displayed to determine | |
9613 | * how many | |
9614 | * characters are needed for the Neighbor column | |
9615 | */ | |
9616 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
9617 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9618 | continue; | |
9619 | ||
9620 | if (peer->afc[afi][safi]) { | |
9621 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9622 | if (peer_dynamic_neighbor(peer)) | |
9623 | dn_flag[0] = '*'; | |
9624 | ||
9625 | if (peer->hostname | |
892fedb6 DA |
9626 | && CHECK_FLAG(bgp->flags, |
9627 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
9628 | snprintf(neighbor_buf, |
9629 | sizeof(neighbor_buf), | |
9630 | "%s%s(%s) ", dn_flag, | |
9631 | peer->hostname, peer->host); | |
d62a17ae | 9632 | else |
772270f3 QY |
9633 | snprintf(neighbor_buf, |
9634 | sizeof(neighbor_buf), "%s%s ", | |
9635 | dn_flag, peer->host); | |
d62a17ae | 9636 | |
9637 | len = strlen(neighbor_buf); | |
9638 | ||
9639 | if (len > max_neighbor_width) | |
9640 | max_neighbor_width = len; | |
c258527b | 9641 | |
3577f1c5 DD |
9642 | /* See if we have at least a single failed peer */ |
9643 | if (bgp_has_peer_failed(peer, afi, safi)) | |
9644 | failed_count++; | |
9645 | count++; | |
d62a17ae | 9646 | } |
9647 | } | |
f933309e | 9648 | |
d62a17ae | 9649 | /* Originally we displayed the Neighbor column as 16 |
9650 | * characters wide so make that the default | |
9651 | */ | |
9652 | if (max_neighbor_width < neighbor_col_default_width) | |
9653 | max_neighbor_width = neighbor_col_default_width; | |
9654 | } | |
f933309e | 9655 | |
3577f1c5 DD |
9656 | if (show_failed && !failed_count) { |
9657 | if (use_json) { | |
9658 | json_object_int_add(json, "failedPeersCount", 0); | |
9659 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 9660 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
9661 | |
9662 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
9663 | json, JSON_C_TO_STRING_PRETTY)); | |
9664 | json_object_free(json); | |
9665 | } else { | |
9666 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
9667 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9668 | } | |
9669 | return CMD_SUCCESS; | |
9670 | } | |
c258527b | 9671 | |
3577f1c5 | 9672 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 9673 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
9674 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9675 | continue; | |
9676 | ||
ea47320b DL |
9677 | if (!peer->afc[afi][safi]) |
9678 | continue; | |
d62a17ae | 9679 | |
ea47320b DL |
9680 | if (!count) { |
9681 | unsigned long ents; | |
9682 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 9683 | int64_t vrf_id_ui; |
d62a17ae | 9684 | |
a4d82a8a PZ |
9685 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9686 | ? -1 | |
9687 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
9688 | |
9689 | /* Usage summary and header */ | |
9690 | if (use_json) { | |
23d0a753 DA |
9691 | char buf[BUFSIZ] = {0}; |
9692 | ||
ea47320b DL |
9693 | json_object_string_add( |
9694 | json, "routerId", | |
23d0a753 DA |
9695 | inet_ntop(AF_INET, &bgp->router_id, buf, |
9696 | sizeof(buf))); | |
60466a63 QY |
9697 | json_object_int_add(json, "as", bgp->as); |
9698 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
9699 | json_object_string_add( |
9700 | json, "vrfName", | |
9701 | (bgp->inst_type | |
9702 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9703 | ? VRF_DEFAULT_NAME |
ea47320b DL |
9704 | : bgp->name); |
9705 | } else { | |
9706 | vty_out(vty, | |
23d0a753 DA |
9707 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
9708 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
9709 | bgp->vrf_id == VRF_UNKNOWN |
9710 | ? -1 | |
9711 | : (int)bgp->vrf_id); | |
ea47320b DL |
9712 | vty_out(vty, "\n"); |
9713 | } | |
d62a17ae | 9714 | |
ea47320b | 9715 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 9716 | if (use_json) { |
ea47320b | 9717 | json_object_int_add( |
60466a63 | 9718 | json, "updateDelayLimit", |
ea47320b | 9719 | bgp->v_update_delay); |
d62a17ae | 9720 | |
ea47320b DL |
9721 | if (bgp->v_update_delay |
9722 | != bgp->v_establish_wait) | |
d62a17ae | 9723 | json_object_int_add( |
9724 | json, | |
ea47320b DL |
9725 | "updateDelayEstablishWait", |
9726 | bgp->v_establish_wait); | |
d62a17ae | 9727 | |
60466a63 | 9728 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9729 | json_object_string_add( |
9730 | json, | |
9731 | "updateDelayFirstNeighbor", | |
9732 | bgp->update_delay_begin_time); | |
9733 | json_object_boolean_true_add( | |
9734 | json, | |
9735 | "updateDelayInProgress"); | |
9736 | } else { | |
9737 | if (bgp->update_delay_over) { | |
d62a17ae | 9738 | json_object_string_add( |
9739 | json, | |
9740 | "updateDelayFirstNeighbor", | |
9741 | bgp->update_delay_begin_time); | |
ea47320b | 9742 | json_object_string_add( |
d62a17ae | 9743 | json, |
ea47320b DL |
9744 | "updateDelayBestpathResumed", |
9745 | bgp->update_delay_end_time); | |
9746 | json_object_string_add( | |
d62a17ae | 9747 | json, |
ea47320b DL |
9748 | "updateDelayZebraUpdateResume", |
9749 | bgp->update_delay_zebra_resume_time); | |
9750 | json_object_string_add( | |
9751 | json, | |
9752 | "updateDelayPeerUpdateResume", | |
9753 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9754 | } |
ea47320b DL |
9755 | } |
9756 | } else { | |
9757 | vty_out(vty, | |
9758 | "Read-only mode update-delay limit: %d seconds\n", | |
9759 | bgp->v_update_delay); | |
9760 | if (bgp->v_update_delay | |
9761 | != bgp->v_establish_wait) | |
d62a17ae | 9762 | vty_out(vty, |
ea47320b DL |
9763 | " Establish wait: %d seconds\n", |
9764 | bgp->v_establish_wait); | |
d62a17ae | 9765 | |
60466a63 | 9766 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9767 | vty_out(vty, |
9768 | " First neighbor established: %s\n", | |
9769 | bgp->update_delay_begin_time); | |
9770 | vty_out(vty, | |
9771 | " Delay in progress\n"); | |
9772 | } else { | |
9773 | if (bgp->update_delay_over) { | |
d62a17ae | 9774 | vty_out(vty, |
9775 | " First neighbor established: %s\n", | |
9776 | bgp->update_delay_begin_time); | |
9777 | vty_out(vty, | |
ea47320b DL |
9778 | " Best-paths resumed: %s\n", |
9779 | bgp->update_delay_end_time); | |
9780 | vty_out(vty, | |
9781 | " zebra update resumed: %s\n", | |
9782 | bgp->update_delay_zebra_resume_time); | |
9783 | vty_out(vty, | |
9784 | " peers update resumed: %s\n", | |
9785 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9786 | } |
9787 | } | |
9788 | } | |
ea47320b | 9789 | } |
d62a17ae | 9790 | |
ea47320b DL |
9791 | if (use_json) { |
9792 | if (bgp_maxmed_onstartup_configured(bgp) | |
9793 | && bgp->maxmed_active) | |
9794 | json_object_boolean_true_add( | |
60466a63 | 9795 | json, "maxMedOnStartup"); |
ea47320b DL |
9796 | if (bgp->v_maxmed_admin) |
9797 | json_object_boolean_true_add( | |
60466a63 | 9798 | json, "maxMedAdministrative"); |
d62a17ae | 9799 | |
ea47320b DL |
9800 | json_object_int_add( |
9801 | json, "tableVersion", | |
60466a63 | 9802 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 9803 | |
60466a63 QY |
9804 | ents = bgp_table_count(bgp->rib[afi][safi]); |
9805 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
9806 | json_object_int_add( |
9807 | json, "ribMemory", | |
9bcb3eef | 9808 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 9809 | |
210ec2a0 | 9810 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
9811 | json_object_int_add(json, "peerCount", ents); |
9812 | json_object_int_add(json, "peerMemory", | |
9813 | ents * sizeof(struct peer)); | |
d62a17ae | 9814 | |
ea47320b DL |
9815 | if ((ents = listcount(bgp->group))) { |
9816 | json_object_int_add( | |
60466a63 | 9817 | json, "peerGroupCount", ents); |
ea47320b DL |
9818 | json_object_int_add( |
9819 | json, "peerGroupMemory", | |
996c9314 LB |
9820 | ents * sizeof(struct |
9821 | peer_group)); | |
ea47320b | 9822 | } |
d62a17ae | 9823 | |
ea47320b DL |
9824 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9825 | BGP_CONFIG_DAMPENING)) | |
9826 | json_object_boolean_true_add( | |
60466a63 | 9827 | json, "dampeningEnabled"); |
ea47320b DL |
9828 | } else { |
9829 | if (bgp_maxmed_onstartup_configured(bgp) | |
9830 | && bgp->maxmed_active) | |
d62a17ae | 9831 | vty_out(vty, |
ea47320b DL |
9832 | "Max-med on-startup active\n"); |
9833 | if (bgp->v_maxmed_admin) | |
d62a17ae | 9834 | vty_out(vty, |
ea47320b | 9835 | "Max-med administrative active\n"); |
d62a17ae | 9836 | |
60466a63 QY |
9837 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
9838 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 9839 | |
60466a63 | 9840 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
9841 | vty_out(vty, |
9842 | "RIB entries %ld, using %s of memory\n", | |
9843 | ents, | |
9bcb3eef DS |
9844 | mtype_memstr( |
9845 | memstrbuf, sizeof(memstrbuf), | |
9846 | ents | |
9847 | * sizeof(struct | |
9848 | bgp_dest))); | |
ea47320b DL |
9849 | |
9850 | /* Peer related usage */ | |
210ec2a0 | 9851 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 9852 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
9853 | ents, |
9854 | mtype_memstr( | |
60466a63 QY |
9855 | memstrbuf, sizeof(memstrbuf), |
9856 | ents * sizeof(struct peer))); | |
ea47320b DL |
9857 | |
9858 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 9859 | vty_out(vty, |
ea47320b | 9860 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 9861 | ents, |
9862 | mtype_memstr( | |
9863 | memstrbuf, | |
9864 | sizeof(memstrbuf), | |
996c9314 LB |
9865 | ents * sizeof(struct |
9866 | peer_group))); | |
d62a17ae | 9867 | |
ea47320b DL |
9868 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9869 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 9870 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 9871 | vty_out(vty, "\n"); |
d62a17ae | 9872 | |
ea47320b DL |
9873 | /* Subtract 8 here because 'Neighbor' is |
9874 | * 8 characters */ | |
9875 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
9876 | vty_out(vty, "%*s", max_neighbor_width - 8, |
9877 | " "); | |
3577f1c5 DD |
9878 | if (show_failed) |
9879 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
9880 | else | |
9881 | vty_out(vty, | |
db92d226 | 9882 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n"); |
d62a17ae | 9883 | } |
ea47320b | 9884 | } |
d62a17ae | 9885 | |
d55811cc | 9886 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 9887 | filter = &peer->filter[afi][safi]; |
db92d226 | 9888 | |
ea47320b | 9889 | count++; |
3577f1c5 DD |
9890 | /* Works for both failed & successful cases */ |
9891 | if (peer_dynamic_neighbor(peer)) | |
9892 | dn_count++; | |
d62a17ae | 9893 | |
ea47320b | 9894 | if (use_json) { |
3577f1c5 DD |
9895 | json_peer = NULL; |
9896 | ||
9897 | if (show_failed && | |
9898 | bgp_has_peer_failed(peer, afi, safi)) { | |
9899 | json_peer = json_object_new_object(); | |
9900 | bgp_show_failed_summary(vty, bgp, peer, | |
9901 | json_peer, 0, use_json); | |
9902 | } else if (!show_failed) { | |
10b49f14 DA |
9903 | if (show_established |
9904 | && bgp_has_peer_failed(peer, afi, safi)) | |
9905 | continue; | |
9906 | ||
3577f1c5 DD |
9907 | json_peer = json_object_new_object(); |
9908 | if (peer_dynamic_neighbor(peer)) { | |
9909 | json_object_boolean_true_add(json_peer, | |
9910 | "dynamicPeer"); | |
9911 | } | |
d62a17ae | 9912 | |
3577f1c5 DD |
9913 | if (peer->hostname) |
9914 | json_object_string_add(json_peer, "hostname", | |
9915 | peer->hostname); | |
9916 | ||
9917 | if (peer->domainname) | |
9918 | json_object_string_add(json_peer, "domainname", | |
9919 | peer->domainname); | |
9920 | ||
9921 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9922 | json_object_int_add(json_peer, "version", 4); | |
9923 | json_object_int_add(json_peer, "msgRcvd", | |
9924 | PEER_TOTAL_RX(peer)); | |
9925 | json_object_int_add(json_peer, "msgSent", | |
9926 | PEER_TOTAL_TX(peer)); | |
9927 | ||
43aa5965 QY |
9928 | atomic_size_t outq_count, inq_count; |
9929 | outq_count = atomic_load_explicit( | |
9930 | &peer->obuf->count, | |
9931 | memory_order_relaxed); | |
9932 | inq_count = atomic_load_explicit( | |
9933 | &peer->ibuf->count, | |
9934 | memory_order_relaxed); | |
9935 | ||
3577f1c5 DD |
9936 | json_object_int_add(json_peer, "tableVersion", |
9937 | peer->version[afi][safi]); | |
9938 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
9939 | outq_count); |
9940 | json_object_int_add(json_peer, "inq", | |
9941 | inq_count); | |
3577f1c5 DD |
9942 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
9943 | use_json, json_peer); | |
9944 | ||
3577f1c5 DD |
9945 | json_object_int_add(json_peer, "pfxRcd", |
9946 | peer->pcount[afi][pfx_rcd_safi]); | |
9947 | ||
3577f1c5 DD |
9948 | if (paf && PAF_SUBGRP(paf)) |
9949 | json_object_int_add(json_peer, | |
9950 | "pfxSnt", | |
9951 | (PAF_SUBGRP(paf))->scount); | |
cb9196e7 | 9952 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
9953 | || CHECK_FLAG(peer->bgp->flags, |
9954 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
9955 | json_object_string_add(json_peer, "state", |
9956 | "Idle (Admin)"); | |
9957 | else if (peer->afc_recv[afi][safi]) | |
9958 | json_object_string_add( | |
9959 | json_peer, "state", | |
9960 | lookup_msg(bgp_status_msg, peer->status, | |
9961 | NULL)); | |
9962 | else if (CHECK_FLAG(peer->sflags, | |
9963 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9964 | json_object_string_add(json_peer, "state", | |
9965 | "Idle (PfxCt)"); | |
9966 | else | |
9967 | json_object_string_add( | |
9968 | json_peer, "state", | |
9969 | lookup_msg(bgp_status_msg, peer->status, | |
9970 | NULL)); | |
200116db DD |
9971 | json_object_int_add(json_peer, "connectionsEstablished", |
9972 | peer->established); | |
9973 | json_object_int_add(json_peer, "connectionsDropped", | |
9974 | peer->dropped); | |
b4e9dcba | 9975 | } |
3577f1c5 DD |
9976 | /* Avoid creating empty peer dicts in JSON */ |
9977 | if (json_peer == NULL) | |
9978 | continue; | |
ea47320b DL |
9979 | |
9980 | if (peer->conf_if) | |
60466a63 | 9981 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9982 | "interface"); |
9983 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9984 | json_object_string_add(json_peer, "idType", |
9985 | "ipv4"); | |
ea47320b | 9986 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9987 | json_object_string_add(json_peer, "idType", |
9988 | "ipv6"); | |
ea47320b DL |
9989 | json_object_object_add(json_peers, peer->host, |
9990 | json_peer); | |
9991 | } else { | |
3577f1c5 DD |
9992 | if (show_failed && |
9993 | bgp_has_peer_failed(peer, afi, safi)) { | |
9994 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9995 | max_neighbor_width, | |
9996 | use_json); | |
9997 | } else if (!show_failed) { | |
10b49f14 DA |
9998 | if (show_established |
9999 | && bgp_has_peer_failed(peer, afi, safi)) | |
10000 | continue; | |
10001 | ||
3577f1c5 DD |
10002 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10003 | if (peer_dynamic_neighbor(peer)) { | |
10004 | dn_flag[0] = '*'; | |
10005 | } | |
d62a17ae | 10006 | |
3577f1c5 | 10007 | if (peer->hostname |
892fedb6 DA |
10008 | && CHECK_FLAG(bgp->flags, |
10009 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10010 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10011 | peer->hostname, |
10012 | peer->host); | |
d62a17ae | 10013 | else |
3577f1c5 DD |
10014 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10015 | ||
10016 | /* pad the neighbor column with spaces */ | |
10017 | if (len < max_neighbor_width) | |
10018 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10019 | " "); | |
10020 | ||
43aa5965 QY |
10021 | atomic_size_t outq_count, inq_count; |
10022 | outq_count = atomic_load_explicit( | |
10023 | &peer->obuf->count, | |
10024 | memory_order_relaxed); | |
10025 | inq_count = atomic_load_explicit( | |
10026 | &peer->ibuf->count, | |
10027 | memory_order_relaxed); | |
10028 | ||
566bdaf6 | 10029 | vty_out(vty, |
6cde4b45 | 10030 | "4 %10u %9u %9u %8" PRIu64" %4zu %4zu %8s", |
3577f1c5 | 10031 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 10032 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
10033 | peer->version[afi][safi], inq_count, |
10034 | outq_count, | |
3577f1c5 DD |
10035 | peer_uptime(peer->uptime, timebuf, |
10036 | BGP_UPTIME_LEN, 0, NULL)); | |
10037 | ||
db92d226 | 10038 | if (peer->status == Established) { |
d3ada366 DA |
10039 | if (peer->afc_recv[afi][safi]) { |
10040 | if (CHECK_FLAG( | |
10041 | bgp->flags, | |
10042 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10043 | && !bgp_inbound_policy_exists( | |
10044 | peer, filter)) | |
10045 | vty_out(vty, " %12s", | |
10046 | "(Policy)"); | |
10047 | else | |
10048 | vty_out(vty, | |
6cde4b45 | 10049 | " %12u", |
d3ada366 DA |
10050 | peer->pcount |
10051 | [afi] | |
10052 | [pfx_rcd_safi]); | |
10053 | } else { | |
3577f1c5 | 10054 | vty_out(vty, " NoNeg"); |
d3ada366 | 10055 | } |
db92d226 | 10056 | |
d3ada366 DA |
10057 | if (paf && PAF_SUBGRP(paf)) { |
10058 | if (CHECK_FLAG( | |
10059 | bgp->flags, | |
10060 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10061 | && !bgp_outbound_policy_exists( | |
10062 | peer, filter)) | |
10063 | vty_out(vty, " %8s", | |
10064 | "(Policy)"); | |
10065 | else | |
10066 | vty_out(vty, | |
6cde4b45 | 10067 | " %8u", |
d3ada366 DA |
10068 | (PAF_SUBGRP( |
10069 | paf)) | |
10070 | ->scount); | |
10071 | } | |
db92d226 | 10072 | } else { |
736b68f3 DS |
10073 | if (CHECK_FLAG(peer->flags, |
10074 | PEER_FLAG_SHUTDOWN) | |
10075 | || CHECK_FLAG(peer->bgp->flags, | |
10076 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10077 | vty_out(vty, " Idle (Admin)"); |
10078 | else if (CHECK_FLAG( | |
10079 | peer->sflags, | |
10080 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10081 | vty_out(vty, " Idle (PfxCt)"); | |
10082 | else | |
10083 | vty_out(vty, " %12s", | |
10084 | lookup_msg(bgp_status_msg, | |
10085 | peer->status, NULL)); | |
db92d226 | 10086 | |
6cde4b45 | 10087 | vty_out(vty, " %8u", 0); |
3577f1c5 DD |
10088 | } |
10089 | vty_out(vty, "\n"); | |
d62a17ae | 10090 | } |
3577f1c5 | 10091 | |
d62a17ae | 10092 | } |
10093 | } | |
f933309e | 10094 | |
d62a17ae | 10095 | if (use_json) { |
10096 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 10097 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 10098 | json_object_int_add(json, "totalPeers", count); |
10099 | json_object_int_add(json, "dynamicPeers", dn_count); | |
10100 | ||
3577f1c5 DD |
10101 | if (!show_failed) |
10102 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 10103 | |
996c9314 LB |
10104 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10105 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10106 | json_object_free(json); |
10107 | } else { | |
10108 | if (count) | |
10109 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
10110 | else { | |
d6ceaca3 | 10111 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 10112 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10113 | } |
b05a1c8b | 10114 | |
d6ceaca3 | 10115 | if (dn_count) { |
d62a17ae | 10116 | vty_out(vty, "* - dynamic neighbor\n"); |
10117 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
10118 | dn_count, bgp->dynamic_neighbors_limit); | |
10119 | } | |
10120 | } | |
1ff9a340 | 10121 | |
d62a17ae | 10122 | return CMD_SUCCESS; |
718e3744 | 10123 | } |
10124 | ||
d62a17ae | 10125 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
10b49f14 DA |
10126 | int safi, bool show_failed, |
10127 | bool show_established, bool use_json) | |
d62a17ae | 10128 | { |
10129 | int is_first = 1; | |
10130 | int afi_wildcard = (afi == AFI_MAX); | |
10131 | int safi_wildcard = (safi == SAFI_MAX); | |
10132 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 10133 | bool nbr_output = false; |
d62a17ae | 10134 | |
10135 | if (use_json && is_wildcard) | |
10136 | vty_out(vty, "{\n"); | |
10137 | if (afi_wildcard) | |
10138 | afi = 1; /* AFI_IP */ | |
10139 | while (afi < AFI_MAX) { | |
10140 | if (safi_wildcard) | |
10141 | safi = 1; /* SAFI_UNICAST */ | |
10142 | while (safi < SAFI_MAX) { | |
318cac96 | 10143 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 10144 | nbr_output = true; |
f86897b9 | 10145 | |
d62a17ae | 10146 | if (is_wildcard) { |
10147 | /* | |
10148 | * So limit output to those afi/safi | |
10149 | * pairs that | |
10150 | * actualy have something interesting in | |
10151 | * them | |
10152 | */ | |
10153 | if (use_json) { | |
d62a17ae | 10154 | if (!is_first) |
10155 | vty_out(vty, ",\n"); | |
10156 | else | |
10157 | is_first = 0; | |
10158 | ||
10159 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
10160 | get_afi_safi_str(afi, |
10161 | safi, | |
10162 | true)); | |
d62a17ae | 10163 | } else { |
10164 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
10165 | get_afi_safi_str(afi, |
10166 | safi, | |
10167 | false)); | |
d62a17ae | 10168 | } |
10169 | } | |
10b49f14 DA |
10170 | bgp_show_summary(vty, bgp, afi, safi, |
10171 | show_failed, show_established, | |
3577f1c5 | 10172 | use_json); |
d62a17ae | 10173 | } |
10174 | safi++; | |
d62a17ae | 10175 | if (!safi_wildcard) |
10176 | safi = SAFI_MAX; | |
10177 | } | |
10178 | afi++; | |
ee851c8c | 10179 | if (!afi_wildcard) |
d62a17ae | 10180 | afi = AFI_MAX; |
10181 | } | |
10182 | ||
10183 | if (use_json && is_wildcard) | |
10184 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
10185 | else if (!nbr_output) { |
10186 | if (use_json) | |
10187 | vty_out(vty, "{}\n"); | |
10188 | else | |
10189 | vty_out(vty, "%% No BGP neighbors found\n"); | |
10190 | } | |
d62a17ae | 10191 | } |
10192 | ||
10193 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 | 10194 | safi_t safi, bool show_failed, |
10b49f14 | 10195 | bool show_established, |
3577f1c5 | 10196 | bool use_json) |
d62a17ae | 10197 | { |
10198 | struct listnode *node, *nnode; | |
10199 | struct bgp *bgp; | |
d62a17ae | 10200 | int is_first = 1; |
9f049418 | 10201 | bool nbr_output = false; |
d62a17ae | 10202 | |
10203 | if (use_json) | |
10204 | vty_out(vty, "{\n"); | |
10205 | ||
10206 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 10207 | nbr_output = true; |
d62a17ae | 10208 | if (use_json) { |
d62a17ae | 10209 | if (!is_first) |
10210 | vty_out(vty, ",\n"); | |
10211 | else | |
10212 | is_first = 0; | |
10213 | ||
10214 | vty_out(vty, "\"%s\":", | |
10215 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10216 | ? VRF_DEFAULT_NAME |
d62a17ae | 10217 | : bgp->name); |
10218 | } else { | |
10219 | vty_out(vty, "\nInstance %s:\n", | |
10220 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10221 | ? VRF_DEFAULT_NAME |
d62a17ae | 10222 | : bgp->name); |
10223 | } | |
3577f1c5 | 10224 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 10225 | show_established, use_json); |
d62a17ae | 10226 | } |
10227 | ||
10228 | if (use_json) | |
10229 | vty_out(vty, "}\n"); | |
9f049418 DS |
10230 | else if (!nbr_output) |
10231 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 10232 | } |
10233 | ||
10234 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
10b49f14 DA |
10235 | safi_t safi, bool show_failed, bool show_established, |
10236 | bool use_json) | |
d62a17ae | 10237 | { |
10238 | struct bgp *bgp; | |
10239 | ||
10240 | if (name) { | |
10241 | if (strmatch(name, "all")) { | |
10b49f14 DA |
10242 | bgp_show_all_instances_summary_vty( |
10243 | vty, afi, safi, show_failed, show_established, | |
10244 | use_json); | |
d62a17ae | 10245 | return CMD_SUCCESS; |
10246 | } else { | |
10247 | bgp = bgp_lookup_by_name(name); | |
10248 | ||
10249 | if (!bgp) { | |
10250 | if (use_json) | |
10251 | vty_out(vty, "{}\n"); | |
10252 | else | |
10253 | vty_out(vty, | |
ca61fd25 | 10254 | "%% BGP instance not found\n"); |
d62a17ae | 10255 | return CMD_WARNING; |
10256 | } | |
10257 | ||
f86897b9 | 10258 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
10b49f14 DA |
10259 | show_failed, show_established, |
10260 | use_json); | |
d62a17ae | 10261 | return CMD_SUCCESS; |
10262 | } | |
10263 | } | |
10264 | ||
10265 | bgp = bgp_get_default(); | |
10266 | ||
10267 | if (bgp) | |
3577f1c5 | 10268 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 10269 | show_established, use_json); |
9f049418 | 10270 | else { |
ca61fd25 DS |
10271 | if (use_json) |
10272 | vty_out(vty, "{}\n"); | |
10273 | else | |
10274 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
10275 | return CMD_WARNING; |
10276 | } | |
d62a17ae | 10277 | |
10278 | return CMD_SUCCESS; | |
4fb25c53 DW |
10279 | } |
10280 | ||
716b2d8a | 10281 | /* `show [ip] bgp summary' commands. */ |
96f3485c | 10282 | DEFPY (show_ip_bgp_summary, |
718e3744 | 10283 | show_ip_bgp_summary_cmd, |
96f3485c | 10284 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] summary [established|failed] [json$uj]", |
718e3744 | 10285 | SHOW_STR |
10286 | IP_STR | |
10287 | BGP_STR | |
8386ac43 | 10288 | BGP_INSTANCE_HELP_STR |
46f296b4 | 10289 | BGP_AFI_HELP_STR |
dd6bd0f1 | 10290 | BGP_SAFI_WITH_LABEL_HELP_STR |
96f3485c | 10291 | "Display the entries for all address families\n" |
b05a1c8b | 10292 | "Summary of BGP neighbor status\n" |
10b49f14 | 10293 | "Show only sessions in Established state\n" |
3577f1c5 | 10294 | "Show only sessions not in Established state\n" |
9973d184 | 10295 | JSON_STR) |
718e3744 | 10296 | { |
d62a17ae | 10297 | char *vrf = NULL; |
10298 | afi_t afi = AFI_MAX; | |
10299 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 10300 | bool show_failed = false; |
10b49f14 | 10301 | bool show_established = false; |
d62a17ae | 10302 | |
10303 | int idx = 0; | |
10304 | ||
10305 | /* show [ip] bgp */ | |
96f3485c | 10306 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 10307 | afi = AFI_IP; |
9a8bdf1c PG |
10308 | /* [<vrf> VIEWVRFNAME] */ |
10309 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10310 | vrf = argv[idx + 1]->arg; | |
10311 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10312 | vrf = NULL; | |
10313 | } else if (argv_find(argv, argc, "view", &idx)) | |
10314 | /* [<view> VIEWVRFNAME] */ | |
10315 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 10316 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
10317 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
10318 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10319 | } | |
10320 | ||
3577f1c5 DD |
10321 | if (argv_find(argv, argc, "failed", &idx)) |
10322 | show_failed = true; | |
10b49f14 DA |
10323 | if (argv_find(argv, argc, "established", &idx)) |
10324 | show_established = true; | |
3577f1c5 | 10325 | |
10b49f14 DA |
10326 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, |
10327 | show_established, uj); | |
d62a17ae | 10328 | } |
10329 | ||
5cb5f4d0 | 10330 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 10331 | { |
5cb5f4d0 DD |
10332 | if (for_json) |
10333 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 10334 | else |
5cb5f4d0 | 10335 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
10336 | } |
10337 | ||
d62a17ae | 10338 | |
10339 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
10340 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
10341 | uint16_t adv_smcap, uint16_t adv_rmcap, |
10342 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 10343 | bool use_json, json_object *json_pref) |
d62a17ae | 10344 | { |
10345 | /* Send-Mode */ | |
10346 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
10347 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
10348 | if (use_json) { | |
10349 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
10350 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
10351 | json_object_string_add(json_pref, "sendMode", | |
10352 | "advertisedAndReceived"); | |
10353 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
10354 | json_object_string_add(json_pref, "sendMode", | |
10355 | "advertised"); | |
10356 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
10357 | json_object_string_add(json_pref, "sendMode", | |
10358 | "received"); | |
10359 | } else { | |
10360 | vty_out(vty, " Send-mode: "); | |
10361 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
10362 | vty_out(vty, "advertised"); | |
10363 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
10364 | vty_out(vty, "%sreceived", | |
10365 | CHECK_FLAG(p->af_cap[afi][safi], | |
10366 | adv_smcap) | |
10367 | ? ", " | |
10368 | : ""); | |
10369 | vty_out(vty, "\n"); | |
10370 | } | |
10371 | } | |
10372 | ||
10373 | /* Receive-Mode */ | |
10374 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
10375 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
10376 | if (use_json) { | |
10377 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
10378 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
10379 | json_object_string_add(json_pref, "recvMode", | |
10380 | "advertisedAndReceived"); | |
10381 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
10382 | json_object_string_add(json_pref, "recvMode", | |
10383 | "advertised"); | |
10384 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
10385 | json_object_string_add(json_pref, "recvMode", | |
10386 | "received"); | |
10387 | } else { | |
10388 | vty_out(vty, " Receive-mode: "); | |
10389 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
10390 | vty_out(vty, "advertised"); | |
10391 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
10392 | vty_out(vty, "%sreceived", | |
10393 | CHECK_FLAG(p->af_cap[afi][safi], | |
10394 | adv_rmcap) | |
10395 | ? ", " | |
10396 | : ""); | |
10397 | vty_out(vty, "\n"); | |
10398 | } | |
10399 | } | |
10400 | } | |
10401 | ||
13909c4f DS |
10402 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
10403 | struct peer *p, | |
10404 | bool use_json, | |
10405 | json_object *json) | |
2986cac2 | 10406 | { |
08c2d52a | 10407 | bool rbit_status = false; |
2986cac2 | 10408 | |
10409 | if (!use_json) | |
a53ca37b | 10410 | vty_out(vty, "\n R bit: "); |
2986cac2 | 10411 | |
13909c4f DS |
10412 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
10413 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
10414 | && (p->status == Established)) { | |
2986cac2 | 10415 | |
10416 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 10417 | rbit_status = true; |
2986cac2 | 10418 | else |
08c2d52a | 10419 | rbit_status = false; |
2986cac2 | 10420 | } |
10421 | ||
10422 | if (rbit_status) { | |
10423 | if (use_json) | |
13909c4f | 10424 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 10425 | else |
10426 | vty_out(vty, "True\n"); | |
10427 | } else { | |
10428 | if (use_json) | |
13909c4f | 10429 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 10430 | else |
10431 | vty_out(vty, "False\n"); | |
10432 | } | |
10433 | } | |
10434 | ||
13909c4f DS |
10435 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
10436 | struct peer *peer, | |
10437 | bool use_json, | |
10438 | json_object *json) | |
2986cac2 | 10439 | { |
2bb5d39b | 10440 | const char *mode = "NotApplicable"; |
2986cac2 | 10441 | |
10442 | if (!use_json) | |
a53ca37b | 10443 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 10444 | |
13909c4f DS |
10445 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
10446 | && (peer->status == Established)) { | |
2986cac2 | 10447 | |
13909c4f DS |
10448 | if ((peer->nsf_af_count == 0) |
10449 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 10450 | |
2986cac2 | 10451 | mode = "Disable"; |
10452 | ||
13909c4f DS |
10453 | } else if (peer->nsf_af_count == 0 |
10454 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 10455 | |
2986cac2 | 10456 | mode = "Helper"; |
10457 | ||
13909c4f DS |
10458 | } else if (peer->nsf_af_count != 0 |
10459 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 10460 | |
2986cac2 | 10461 | mode = "Restart"; |
2986cac2 | 10462 | } |
10463 | } | |
10464 | ||
10465 | if (use_json) { | |
13909c4f | 10466 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 10467 | } else |
10468 | vty_out(vty, mode, "\n"); | |
10469 | } | |
10470 | ||
13909c4f DS |
10471 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
10472 | struct peer *p, | |
10473 | bool use_json, | |
10474 | json_object *json) | |
2986cac2 | 10475 | { |
10476 | const char *mode = "Invalid"; | |
10477 | ||
10478 | if (!use_json) | |
a53ca37b | 10479 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 10480 | |
10481 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
10482 | mode = "Helper"; | |
10483 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
10484 | mode = "Restart"; | |
10485 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
10486 | mode = "Disable"; | |
2ba1fe69 | 10487 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 10488 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
10489 | mode = "Helper*"; | |
10490 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
10491 | mode = "Restart*"; | |
10492 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
10493 | mode = "Disable*"; | |
10494 | else | |
10495 | mode = "Invalid*"; | |
2ba1fe69 | 10496 | } |
2986cac2 | 10497 | |
10498 | if (use_json) { | |
13909c4f | 10499 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 10500 | } else { |
10501 | vty_out(vty, mode, "\n"); | |
10502 | } | |
10503 | } | |
10504 | ||
13909c4f DS |
10505 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
10506 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 10507 | { |
2ba1fe69 | 10508 | afi_t afi; |
10509 | safi_t safi; | |
2986cac2 | 10510 | json_object *json_afi_safi = NULL; |
10511 | json_object *json_timer = NULL; | |
10512 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 10513 | bool eor_flag = false; |
2986cac2 | 10514 | |
10515 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
10516 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
10517 | if (!peer->afc[afi][safi]) |
10518 | continue; | |
2986cac2 | 10519 | |
13909c4f DS |
10520 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
10521 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
10522 | continue; | |
9e3b51a7 | 10523 | |
13909c4f DS |
10524 | if (use_json) { |
10525 | json_afi_safi = json_object_new_object(); | |
10526 | json_endofrib_status = json_object_new_object(); | |
10527 | json_timer = json_object_new_object(); | |
10528 | } | |
2986cac2 | 10529 | |
13909c4f DS |
10530 | if (peer->eor_stime[afi][safi] |
10531 | >= peer->pkt_stime[afi][safi]) | |
10532 | eor_flag = true; | |
10533 | else | |
10534 | eor_flag = false; | |
2986cac2 | 10535 | |
13909c4f | 10536 | if (!use_json) { |
a53ca37b | 10537 | vty_out(vty, " %s:\n", |
13909c4f | 10538 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 10539 | |
a53ca37b | 10540 | vty_out(vty, " F bit: "); |
698ba8d0 | 10541 | } |
2986cac2 | 10542 | |
13909c4f DS |
10543 | if (peer->nsf[afi][safi] |
10544 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
10545 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 10546 | |
13909c4f DS |
10547 | if (use_json) { |
10548 | json_object_boolean_true_add( | |
2986cac2 | 10549 | json_afi_safi, "fBit"); |
13909c4f DS |
10550 | } else |
10551 | vty_out(vty, "True\n"); | |
10552 | } else { | |
10553 | if (use_json) | |
10554 | json_object_boolean_false_add( | |
10555 | json_afi_safi, "fBit"); | |
10556 | else | |
10557 | vty_out(vty, "False\n"); | |
10558 | } | |
2986cac2 | 10559 | |
13909c4f | 10560 | if (!use_json) |
a53ca37b | 10561 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 10562 | |
13909c4f DS |
10563 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
10564 | PEER_STATUS_EOR_SEND)) { | |
10565 | if (use_json) { | |
10566 | json_object_boolean_true_add( | |
2986cac2 | 10567 | json_endofrib_status, |
13909c4f | 10568 | "endOfRibSend"); |
9e3b51a7 | 10569 | |
13909c4f DS |
10570 | PRINT_EOR_JSON(eor_flag); |
10571 | } else { | |
10572 | vty_out(vty, "Yes\n"); | |
10573 | vty_out(vty, | |
a53ca37b | 10574 | " End-of-RIB sent after update: "); |
2986cac2 | 10575 | |
13909c4f DS |
10576 | PRINT_EOR(eor_flag); |
10577 | } | |
10578 | } else { | |
10579 | if (use_json) { | |
10580 | json_object_boolean_false_add( | |
2986cac2 | 10581 | json_endofrib_status, |
13909c4f DS |
10582 | "endOfRibSend"); |
10583 | json_object_boolean_false_add( | |
9e3b51a7 | 10584 | json_endofrib_status, |
13909c4f DS |
10585 | "endOfRibSentAfterUpdate"); |
10586 | } else { | |
10587 | vty_out(vty, "No\n"); | |
10588 | vty_out(vty, | |
a53ca37b | 10589 | " End-of-RIB sent after update: "); |
13909c4f | 10590 | vty_out(vty, "No\n"); |
2986cac2 | 10591 | } |
13909c4f | 10592 | } |
2986cac2 | 10593 | |
a53ca37b DA |
10594 | if (!use_json) |
10595 | vty_out(vty, " End-of-RIB received: "); | |
10596 | ||
10597 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
10598 | PEER_STATUS_EOR_RECEIVED)) { | |
10599 | if (use_json) | |
10600 | json_object_boolean_true_add( | |
10601 | json_endofrib_status, | |
10602 | "endOfRibRecv"); | |
10603 | else | |
10604 | vty_out(vty, "Yes\n"); | |
10605 | } else { | |
10606 | if (use_json) | |
10607 | json_object_boolean_false_add( | |
10608 | json_endofrib_status, | |
10609 | "endOfRibRecv"); | |
10610 | else | |
10611 | vty_out(vty, "No\n"); | |
10612 | } | |
10613 | ||
13909c4f DS |
10614 | if (use_json) { |
10615 | json_object_int_add(json_timer, | |
10616 | "stalePathTimer", | |
10617 | peer->bgp->stalepath_time); | |
2986cac2 | 10618 | |
13909c4f DS |
10619 | if (peer->t_gr_stale != NULL) { |
10620 | json_object_int_add( | |
2986cac2 | 10621 | json_timer, |
10622 | "stalePathTimerRemaining", | |
10623 | thread_timer_remain_second( | |
13909c4f DS |
10624 | peer->t_gr_stale)); |
10625 | } | |
3a75afa4 | 10626 | |
13909c4f DS |
10627 | /* Display Configured Selection |
10628 | * Deferral only when when | |
10629 | * Gr mode is enabled. | |
10630 | */ | |
10631 | if (CHECK_FLAG(peer->flags, | |
10632 | PEER_FLAG_GRACEFUL_RESTART)) { | |
10633 | json_object_int_add( | |
3a75afa4 | 10634 | json_timer, |
2986cac2 | 10635 | "selectionDeferralTimer", |
10636 | peer->bgp->stalepath_time); | |
13909c4f | 10637 | } |
2986cac2 | 10638 | |
13909c4f DS |
10639 | if (peer->bgp->gr_info[afi][safi] |
10640 | .t_select_deferral | |
10641 | != NULL) { | |
2986cac2 | 10642 | |
13909c4f | 10643 | json_object_int_add( |
2986cac2 | 10644 | json_timer, |
10645 | "selectionDeferralTimerRemaining", | |
10646 | thread_timer_remain_second( | |
13909c4f DS |
10647 | peer->bgp |
10648 | ->gr_info[afi] | |
10649 | [safi] | |
10650 | .t_select_deferral)); | |
10651 | } | |
10652 | } else { | |
a53ca37b | 10653 | vty_out(vty, " Timers:\n"); |
13909c4f | 10654 | vty_out(vty, |
a53ca37b DA |
10655 | " Configured Stale Path Time(sec): %u\n", |
10656 | peer->bgp->stalepath_time); | |
2986cac2 | 10657 | |
a53ca37b | 10658 | if (peer->t_gr_stale != NULL) |
2986cac2 | 10659 | vty_out(vty, |
a53ca37b | 10660 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 10661 | thread_timer_remain_second( |
13909c4f | 10662 | peer->t_gr_stale)); |
13909c4f DS |
10663 | /* Display Configured Selection |
10664 | * Deferral only when when | |
10665 | * Gr mode is enabled. | |
10666 | */ | |
10667 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 10668 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 10669 | vty_out(vty, |
a53ca37b | 10670 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 10671 | peer->bgp->select_defer_time); |
2986cac2 | 10672 | |
13909c4f DS |
10673 | if (peer->bgp->gr_info[afi][safi] |
10674 | .t_select_deferral | |
a53ca37b | 10675 | != NULL) |
13909c4f | 10676 | vty_out(vty, |
a53ca37b | 10677 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 10678 | thread_timer_remain_second( |
13909c4f DS |
10679 | peer->bgp |
10680 | ->gr_info[afi] | |
10681 | [safi] | |
10682 | .t_select_deferral)); | |
2986cac2 | 10683 | } |
13909c4f DS |
10684 | if (use_json) { |
10685 | json_object_object_add(json_afi_safi, | |
10686 | "endOfRibStatus", | |
10687 | json_endofrib_status); | |
10688 | json_object_object_add(json_afi_safi, "timers", | |
10689 | json_timer); | |
10690 | json_object_object_add( | |
10691 | json, get_afi_safi_str(afi, safi, true), | |
10692 | json_afi_safi); | |
10693 | } | |
2986cac2 | 10694 | } |
10695 | } | |
10696 | } | |
10697 | ||
36235319 QY |
10698 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
10699 | struct peer *p, | |
10700 | bool use_json, | |
10701 | json_object *json) | |
2986cac2 | 10702 | { |
10703 | if (use_json) { | |
10704 | json_object *json_timer = NULL; | |
10705 | ||
10706 | json_timer = json_object_new_object(); | |
10707 | ||
13909c4f DS |
10708 | json_object_int_add(json_timer, "configuredRestartTimer", |
10709 | p->bgp->restart_time); | |
2986cac2 | 10710 | |
13909c4f DS |
10711 | json_object_int_add(json_timer, "receivedRestartTimer", |
10712 | p->v_gr_restart); | |
2986cac2 | 10713 | |
13909c4f DS |
10714 | if (p->t_gr_restart != NULL) |
10715 | json_object_int_add( | |
10716 | json_timer, "restartTimerRemaining", | |
10717 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 10718 | |
10719 | json_object_object_add(json, "timers", json_timer); | |
10720 | } else { | |
10721 | ||
a53ca37b DA |
10722 | vty_out(vty, " Timers:\n"); |
10723 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 10724 | p->bgp->restart_time); |
2986cac2 | 10725 | |
a53ca37b | 10726 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
10727 | p->v_gr_restart); |
10728 | if (p->t_gr_restart != NULL) | |
a53ca37b | 10729 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 10730 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 10731 | if (p->t_gr_restart != NULL) { |
a53ca37b | 10732 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
10733 | thread_timer_remain_second(p->t_gr_restart)); |
10734 | } | |
2986cac2 | 10735 | } |
10736 | } | |
10737 | ||
10738 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 10739 | bool use_json, json_object *json) |
2986cac2 | 10740 | { |
10741 | char buf[SU_ADDRSTRLEN] = {0}; | |
10742 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
10743 | /* '*' + v6 address of neighbor */ |
10744 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 10745 | |
2986cac2 | 10746 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
10747 | dn_flag[0] = '*'; | |
10748 | ||
10749 | if (p->conf_if) { | |
10750 | if (use_json) | |
13909c4f DS |
10751 | json_object_string_add( |
10752 | json, "neighborAddr", | |
2986cac2 | 10753 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
10754 | ? "none" |
10755 | : sockunion2str(&p->su, buf, | |
10756 | SU_ADDRSTRLEN)); | |
2986cac2 | 10757 | else |
13909c4f | 10758 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 10759 | BGP_PEER_SU_UNSPEC(p) |
10760 | ? "none" | |
10761 | : sockunion2str(&p->su, buf, | |
10762 | SU_ADDRSTRLEN)); | |
10763 | } else { | |
772270f3 QY |
10764 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
10765 | p->host); | |
2986cac2 | 10766 | |
10767 | if (use_json) | |
36235319 QY |
10768 | json_object_string_add(json, "neighborAddr", |
10769 | neighborAddr); | |
2986cac2 | 10770 | else |
36235319 | 10771 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 10772 | } |
10773 | ||
10774 | /* more gr info in new format */ | |
10775 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
10776 | } | |
10777 | ||
d62a17ae | 10778 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 10779 | safi_t safi, bool use_json, |
d62a17ae | 10780 | json_object *json_neigh) |
10781 | { | |
0291c246 MK |
10782 | struct bgp_filter *filter; |
10783 | struct peer_af *paf; | |
10784 | char orf_pfx_name[BUFSIZ]; | |
10785 | int orf_pfx_count; | |
10786 | json_object *json_af = NULL; | |
10787 | json_object *json_prefA = NULL; | |
10788 | json_object *json_prefB = NULL; | |
10789 | json_object *json_addr = NULL; | |
d62a17ae | 10790 | |
10791 | if (use_json) { | |
10792 | json_addr = json_object_new_object(); | |
10793 | json_af = json_object_new_object(); | |
10794 | filter = &p->filter[afi][safi]; | |
10795 | ||
10796 | if (peer_group_active(p)) | |
10797 | json_object_string_add(json_addr, "peerGroupMember", | |
10798 | p->group->name); | |
10799 | ||
10800 | paf = peer_af_find(p, afi, safi); | |
10801 | if (paf && PAF_SUBGRP(paf)) { | |
10802 | json_object_int_add(json_addr, "updateGroupId", | |
10803 | PAF_UPDGRP(paf)->id); | |
10804 | json_object_int_add(json_addr, "subGroupId", | |
10805 | PAF_SUBGRP(paf)->id); | |
10806 | json_object_int_add(json_addr, "packetQueueLength", | |
10807 | bpacket_queue_virtual_length(paf)); | |
10808 | } | |
10809 | ||
10810 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10811 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10812 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10813 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10814 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10815 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10816 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10817 | json_object_int_add(json_af, "orfType", | |
10818 | ORF_TYPE_PREFIX); | |
10819 | json_prefA = json_object_new_object(); | |
10820 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
10821 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
10822 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10823 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10824 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
10825 | use_json, json_prefA); | |
10826 | json_object_object_add(json_af, "orfPrefixList", | |
10827 | json_prefA); | |
10828 | } | |
10829 | ||
10830 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10831 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10832 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10833 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10834 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10835 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10836 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10837 | json_object_int_add(json_af, "orfOldType", | |
10838 | ORF_TYPE_PREFIX_OLD); | |
10839 | json_prefB = json_object_new_object(); | |
10840 | bgp_show_peer_afi_orf_cap( | |
10841 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10842 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10843 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10844 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
10845 | json_prefB); | |
10846 | json_object_object_add(json_af, "orfOldPrefixList", | |
10847 | json_prefB); | |
10848 | } | |
10849 | ||
10850 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10851 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10852 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10853 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10854 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10855 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10856 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10857 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10858 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10859 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10860 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10861 | json_object_object_add(json_addr, "afDependentCap", | |
10862 | json_af); | |
10863 | else | |
10864 | json_object_free(json_af); | |
10865 | ||
772270f3 QY |
10866 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10867 | p->host, afi, safi); | |
d62a17ae | 10868 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10869 | NULL, afi, orf_pfx_name, use_json); | |
10870 | ||
10871 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10872 | PEER_STATUS_ORF_PREFIX_SEND) | |
10873 | || orf_pfx_count) { | |
10874 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10875 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10876 | json_object_boolean_true_add(json_neigh, | |
10877 | "orfSent"); | |
10878 | if (orf_pfx_count) | |
10879 | json_object_int_add(json_addr, "orfRecvCounter", | |
10880 | orf_pfx_count); | |
10881 | } | |
10882 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10883 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10884 | json_object_string_add( | |
10885 | json_addr, "orfFirstUpdate", | |
10886 | "deferredUntilORFOrRouteRefreshRecvd"); | |
10887 | ||
10888 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10889 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10890 | json_object_boolean_true_add(json_addr, | |
10891 | "routeReflectorClient"); | |
10892 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10893 | PEER_FLAG_RSERVER_CLIENT)) | |
10894 | json_object_boolean_true_add(json_addr, | |
10895 | "routeServerClient"); | |
10896 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10897 | json_object_boolean_true_add(json_addr, | |
10898 | "inboundSoftConfigPermit"); | |
10899 | ||
10900 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10901 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10902 | json_object_boolean_true_add( | |
10903 | json_addr, | |
10904 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
10905 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10906 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10907 | json_object_boolean_true_add( | |
10908 | json_addr, | |
10909 | "privateAsNumsReplacedInUpdatesToNbr"); | |
10910 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10911 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10912 | json_object_boolean_true_add( | |
10913 | json_addr, | |
10914 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
10915 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10916 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10917 | json_object_boolean_true_add( | |
10918 | json_addr, | |
10919 | "privateAsNumsRemovedInUpdatesToNbr"); | |
10920 | ||
dcc68b5e MS |
10921 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10922 | json_object_boolean_true_add( | |
10923 | json_addr, | |
10924 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10925 | ->type_json_name); | |
d62a17ae | 10926 | |
10927 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10928 | json_object_string_add(json_addr, | |
10929 | "overrideASNsInOutboundUpdates", | |
10930 | "ifAspathEqualRemoteAs"); | |
10931 | ||
10932 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10933 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10934 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10935 | json_object_boolean_true_add(json_addr, | |
10936 | "routerAlwaysNextHop"); | |
10937 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10938 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10939 | json_object_boolean_true_add( | |
10940 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
10941 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10942 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10943 | json_object_boolean_true_add( | |
10944 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
10945 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10946 | json_object_boolean_true_add( | |
10947 | json_addr, "unchangedMedPropogatedToNbr"); | |
10948 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10949 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10950 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
10951 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10952 | PEER_FLAG_SEND_COMMUNITY) | |
10953 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10954 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10955 | json_object_string_add(json_addr, | |
10956 | "commAttriSentToNbr", | |
10957 | "extendedAndStandard"); | |
10958 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10959 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10960 | json_object_string_add(json_addr, | |
10961 | "commAttriSentToNbr", | |
10962 | "extended"); | |
10963 | else | |
10964 | json_object_string_add(json_addr, | |
10965 | "commAttriSentToNbr", | |
10966 | "standard"); | |
10967 | } | |
10968 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10969 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10970 | if (p->default_rmap[afi][safi].name) | |
10971 | json_object_string_add( | |
10972 | json_addr, "defaultRouteMap", | |
10973 | p->default_rmap[afi][safi].name); | |
10974 | ||
10975 | if (paf && PAF_SUBGRP(paf) | |
10976 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10977 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10978 | json_object_boolean_true_add(json_addr, | |
10979 | "defaultSent"); | |
10980 | else | |
10981 | json_object_boolean_true_add(json_addr, | |
10982 | "defaultNotSent"); | |
10983 | } | |
10984 | ||
dff8f48d | 10985 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10986 | if (is_evpn_enabled()) |
60466a63 QY |
10987 | json_object_boolean_true_add( |
10988 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10989 | } |
10990 | ||
d62a17ae | 10991 | if (filter->plist[FILTER_IN].name |
10992 | || filter->dlist[FILTER_IN].name | |
10993 | || filter->aslist[FILTER_IN].name | |
10994 | || filter->map[RMAP_IN].name) | |
10995 | json_object_boolean_true_add(json_addr, | |
10996 | "inboundPathPolicyConfig"); | |
10997 | if (filter->plist[FILTER_OUT].name | |
10998 | || filter->dlist[FILTER_OUT].name | |
10999 | || filter->aslist[FILTER_OUT].name | |
11000 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11001 | json_object_boolean_true_add( | |
11002 | json_addr, "outboundPathPolicyConfig"); | |
11003 | ||
11004 | /* prefix-list */ | |
11005 | if (filter->plist[FILTER_IN].name) | |
11006 | json_object_string_add(json_addr, | |
11007 | "incomingUpdatePrefixFilterList", | |
11008 | filter->plist[FILTER_IN].name); | |
11009 | if (filter->plist[FILTER_OUT].name) | |
11010 | json_object_string_add(json_addr, | |
11011 | "outgoingUpdatePrefixFilterList", | |
11012 | filter->plist[FILTER_OUT].name); | |
11013 | ||
11014 | /* distribute-list */ | |
11015 | if (filter->dlist[FILTER_IN].name) | |
11016 | json_object_string_add( | |
11017 | json_addr, "incomingUpdateNetworkFilterList", | |
11018 | filter->dlist[FILTER_IN].name); | |
11019 | if (filter->dlist[FILTER_OUT].name) | |
11020 | json_object_string_add( | |
11021 | json_addr, "outgoingUpdateNetworkFilterList", | |
11022 | filter->dlist[FILTER_OUT].name); | |
11023 | ||
11024 | /* filter-list. */ | |
11025 | if (filter->aslist[FILTER_IN].name) | |
11026 | json_object_string_add(json_addr, | |
11027 | "incomingUpdateAsPathFilterList", | |
11028 | filter->aslist[FILTER_IN].name); | |
11029 | if (filter->aslist[FILTER_OUT].name) | |
11030 | json_object_string_add(json_addr, | |
11031 | "outgoingUpdateAsPathFilterList", | |
11032 | filter->aslist[FILTER_OUT].name); | |
11033 | ||
11034 | /* route-map. */ | |
11035 | if (filter->map[RMAP_IN].name) | |
11036 | json_object_string_add( | |
11037 | json_addr, "routeMapForIncomingAdvertisements", | |
11038 | filter->map[RMAP_IN].name); | |
11039 | if (filter->map[RMAP_OUT].name) | |
11040 | json_object_string_add( | |
11041 | json_addr, "routeMapForOutgoingAdvertisements", | |
11042 | filter->map[RMAP_OUT].name); | |
11043 | ||
9dac9fc8 | 11044 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11045 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11046 | && !bgp_inbound_policy_exists(p, filter)) |
11047 | json_object_string_add( | |
11048 | json_addr, "inboundEbgpRequiresPolicy", | |
11049 | "Inbound updates discarded due to missing policy"); | |
11050 | ||
11051 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11052 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11053 | && (!bgp_outbound_policy_exists(p, filter))) |
11054 | json_object_string_add( | |
11055 | json_addr, "outboundEbgpRequiresPolicy", | |
11056 | "Outbound updates discarded due to missing policy"); | |
11057 | ||
d62a17ae | 11058 | /* unsuppress-map */ |
11059 | if (filter->usmap.name) | |
11060 | json_object_string_add(json_addr, | |
11061 | "selectiveUnsuppressRouteMap", | |
11062 | filter->usmap.name); | |
11063 | ||
11064 | /* Receive prefix count */ | |
11065 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11066 | p->pcount[afi][safi]); | |
50e05855 AD |
11067 | if (paf && PAF_SUBGRP(paf)) |
11068 | json_object_int_add(json_addr, "sentPrefixCounter", | |
11069 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 11070 | |
fde246e8 DA |
11071 | /* Maximum prefix */ |
11072 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
11073 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
11074 | p->pmax_out[afi][safi]); | |
11075 | ||
d62a17ae | 11076 | /* Maximum prefix */ |
11077 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
11078 | json_object_int_add(json_addr, "prefixAllowedMax", | |
11079 | p->pmax[afi][safi]); | |
11080 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11081 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
11082 | json_object_boolean_true_add( | |
11083 | json_addr, "prefixAllowedMaxWarning"); | |
11084 | json_object_int_add(json_addr, | |
11085 | "prefixAllowedWarningThresh", | |
11086 | p->pmax_threshold[afi][safi]); | |
11087 | if (p->pmax_restart[afi][safi]) | |
11088 | json_object_int_add( | |
11089 | json_addr, | |
11090 | "prefixAllowedRestartIntervalMsecs", | |
11091 | p->pmax_restart[afi][safi] * 60000); | |
11092 | } | |
2986cac2 | 11093 | json_object_object_add(json_neigh, |
36235319 | 11094 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 11095 | json_addr); |
11096 | ||
11097 | } else { | |
11098 | filter = &p->filter[afi][safi]; | |
11099 | ||
11100 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 11101 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11102 | |
11103 | if (peer_group_active(p)) | |
11104 | vty_out(vty, " %s peer-group member\n", | |
11105 | p->group->name); | |
11106 | ||
11107 | paf = peer_af_find(p, afi, safi); | |
11108 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 11109 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 11110 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
11111 | vty_out(vty, " Packet Queue length %d\n", | |
11112 | bpacket_queue_virtual_length(paf)); | |
11113 | } else { | |
11114 | vty_out(vty, " Not part of any update group\n"); | |
11115 | } | |
11116 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11117 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11118 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11119 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11120 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11121 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11122 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11123 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11124 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11125 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11126 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11127 | vty_out(vty, " AF-dependant capabilities:\n"); | |
11128 | ||
11129 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11130 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11131 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11132 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11133 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11134 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11135 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11136 | vty_out(vty, | |
11137 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11138 | ORF_TYPE_PREFIX); | |
11139 | bgp_show_peer_afi_orf_cap( | |
11140 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11141 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11142 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11143 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
11144 | } | |
11145 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11146 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11147 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11148 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11149 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11150 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11151 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11152 | vty_out(vty, | |
11153 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11154 | ORF_TYPE_PREFIX_OLD); | |
11155 | bgp_show_peer_afi_orf_cap( | |
11156 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11157 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11158 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11159 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
11160 | } | |
11161 | ||
772270f3 QY |
11162 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11163 | p->host, afi, safi); | |
d62a17ae | 11164 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11165 | NULL, afi, orf_pfx_name, use_json); | |
11166 | ||
11167 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11168 | PEER_STATUS_ORF_PREFIX_SEND) | |
11169 | || orf_pfx_count) { | |
11170 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
11171 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11172 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11173 | vty_out(vty, " sent;"); | |
11174 | if (orf_pfx_count) | |
11175 | vty_out(vty, " received (%d entries)", | |
11176 | orf_pfx_count); | |
11177 | vty_out(vty, "\n"); | |
11178 | } | |
11179 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11180 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11181 | vty_out(vty, | |
11182 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
11183 | ||
11184 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11185 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11186 | vty_out(vty, " Route-Reflector Client\n"); | |
11187 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11188 | PEER_FLAG_RSERVER_CLIENT)) | |
11189 | vty_out(vty, " Route-Server Client\n"); | |
11190 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11191 | vty_out(vty, | |
11192 | " Inbound soft reconfiguration allowed\n"); | |
11193 | ||
11194 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11195 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11196 | vty_out(vty, | |
11197 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
11198 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11199 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11200 | vty_out(vty, | |
11201 | " Private AS numbers replaced in updates to this neighbor\n"); | |
11202 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11203 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11204 | vty_out(vty, | |
11205 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
11206 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11207 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11208 | vty_out(vty, | |
11209 | " Private AS numbers removed in updates to this neighbor\n"); | |
11210 | ||
dcc68b5e MS |
11211 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11212 | vty_out(vty, " %s\n", | |
11213 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11214 | ->human_description); | |
d62a17ae | 11215 | |
11216 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11217 | vty_out(vty, | |
11218 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
11219 | ||
11220 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11221 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11222 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11223 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
11224 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11225 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11226 | vty_out(vty, | |
11227 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
11228 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11229 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11230 | vty_out(vty, | |
11231 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
11232 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11233 | vty_out(vty, | |
11234 | " MED is propagated unchanged to this neighbor\n"); | |
11235 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11236 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11237 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
11238 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11239 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
11240 | vty_out(vty, | |
11241 | " Community attribute sent to this neighbor"); | |
11242 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11243 | PEER_FLAG_SEND_COMMUNITY) | |
11244 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11245 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
11246 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11247 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
11248 | vty_out(vty, "(all)\n"); | |
11249 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11250 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
11251 | vty_out(vty, "(large)\n"); | |
11252 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11253 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11254 | vty_out(vty, "(extended)\n"); | |
11255 | else | |
11256 | vty_out(vty, "(standard)\n"); | |
11257 | } | |
11258 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11259 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11260 | vty_out(vty, " Default information originate,"); | |
11261 | ||
11262 | if (p->default_rmap[afi][safi].name) | |
11263 | vty_out(vty, " default route-map %s%s,", | |
11264 | p->default_rmap[afi][safi].map ? "*" | |
11265 | : "", | |
11266 | p->default_rmap[afi][safi].name); | |
11267 | if (paf && PAF_SUBGRP(paf) | |
11268 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11269 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11270 | vty_out(vty, " default sent\n"); | |
11271 | else | |
11272 | vty_out(vty, " default not sent\n"); | |
11273 | } | |
11274 | ||
dff8f48d MK |
11275 | /* advertise-vni-all */ |
11276 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 11277 | if (is_evpn_enabled()) |
dff8f48d MK |
11278 | vty_out(vty, " advertise-all-vni\n"); |
11279 | } | |
11280 | ||
d62a17ae | 11281 | if (filter->plist[FILTER_IN].name |
11282 | || filter->dlist[FILTER_IN].name | |
11283 | || filter->aslist[FILTER_IN].name | |
11284 | || filter->map[RMAP_IN].name) | |
11285 | vty_out(vty, " Inbound path policy configured\n"); | |
11286 | if (filter->plist[FILTER_OUT].name | |
11287 | || filter->dlist[FILTER_OUT].name | |
11288 | || filter->aslist[FILTER_OUT].name | |
11289 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11290 | vty_out(vty, " Outbound path policy configured\n"); | |
11291 | ||
11292 | /* prefix-list */ | |
11293 | if (filter->plist[FILTER_IN].name) | |
11294 | vty_out(vty, | |
11295 | " Incoming update prefix filter list is %s%s\n", | |
11296 | filter->plist[FILTER_IN].plist ? "*" : "", | |
11297 | filter->plist[FILTER_IN].name); | |
11298 | if (filter->plist[FILTER_OUT].name) | |
11299 | vty_out(vty, | |
11300 | " Outgoing update prefix filter list is %s%s\n", | |
11301 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
11302 | filter->plist[FILTER_OUT].name); | |
11303 | ||
11304 | /* distribute-list */ | |
11305 | if (filter->dlist[FILTER_IN].name) | |
11306 | vty_out(vty, | |
11307 | " Incoming update network filter list is %s%s\n", | |
11308 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
11309 | filter->dlist[FILTER_IN].name); | |
11310 | if (filter->dlist[FILTER_OUT].name) | |
11311 | vty_out(vty, | |
11312 | " Outgoing update network filter list is %s%s\n", | |
11313 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
11314 | filter->dlist[FILTER_OUT].name); | |
11315 | ||
11316 | /* filter-list. */ | |
11317 | if (filter->aslist[FILTER_IN].name) | |
11318 | vty_out(vty, | |
11319 | " Incoming update AS path filter list is %s%s\n", | |
11320 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
11321 | filter->aslist[FILTER_IN].name); | |
11322 | if (filter->aslist[FILTER_OUT].name) | |
11323 | vty_out(vty, | |
11324 | " Outgoing update AS path filter list is %s%s\n", | |
11325 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
11326 | filter->aslist[FILTER_OUT].name); | |
11327 | ||
11328 | /* route-map. */ | |
11329 | if (filter->map[RMAP_IN].name) | |
11330 | vty_out(vty, | |
11331 | " Route map for incoming advertisements is %s%s\n", | |
11332 | filter->map[RMAP_IN].map ? "*" : "", | |
11333 | filter->map[RMAP_IN].name); | |
11334 | if (filter->map[RMAP_OUT].name) | |
11335 | vty_out(vty, | |
11336 | " Route map for outgoing advertisements is %s%s\n", | |
11337 | filter->map[RMAP_OUT].map ? "*" : "", | |
11338 | filter->map[RMAP_OUT].name); | |
11339 | ||
9dac9fc8 | 11340 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11341 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11342 | && !bgp_inbound_policy_exists(p, filter)) |
11343 | vty_out(vty, | |
11344 | " Inbound updates discarded due to missing policy\n"); | |
11345 | ||
11346 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11347 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11348 | && !bgp_outbound_policy_exists(p, filter)) |
11349 | vty_out(vty, | |
11350 | " Outbound updates discarded due to missing policy\n"); | |
11351 | ||
d62a17ae | 11352 | /* unsuppress-map */ |
11353 | if (filter->usmap.name) | |
11354 | vty_out(vty, | |
11355 | " Route map for selective unsuppress is %s%s\n", | |
11356 | filter->usmap.map ? "*" : "", | |
11357 | filter->usmap.name); | |
11358 | ||
7f7940e6 MK |
11359 | /* advertise-map */ |
11360 | if (filter->advmap.aname && filter->advmap.cname) | |
11361 | vty_out(vty, | |
11362 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
11363 | filter->advmap.condition ? "EXIST" | |
11364 | : "NON_EXIST", | |
11365 | filter->advmap.cmap ? "*" : "", | |
11366 | filter->advmap.cname, | |
11367 | filter->advmap.amap ? "*" : "", | |
11368 | filter->advmap.aname, | |
c385f82a MK |
11369 | filter->advmap.advertise == ADVERTISE |
11370 | ? "Advertise" | |
11371 | : "Withdraw"); | |
7f7940e6 | 11372 | |
d62a17ae | 11373 | /* Receive prefix count */ |
6cde4b45 | 11374 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 11375 | p->pcount[afi][safi]); |
d62a17ae | 11376 | |
fde246e8 DA |
11377 | /* maximum-prefix-out */ |
11378 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11379 | PEER_FLAG_MAX_PREFIX_OUT)) | |
11380 | vty_out(vty, | |
6cde4b45 | 11381 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
11382 | p->pmax_out[afi][safi]); |
11383 | ||
d62a17ae | 11384 | /* Maximum prefix */ |
11385 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 11386 | vty_out(vty, |
6cde4b45 | 11387 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 11388 | p->pmax[afi][safi], |
11389 | CHECK_FLAG(p->af_flags[afi][safi], | |
11390 | PEER_FLAG_MAX_PREFIX_WARNING) | |
11391 | ? " (warning-only)" | |
11392 | : ""); | |
11393 | vty_out(vty, " Threshold for warning message %d%%", | |
11394 | p->pmax_threshold[afi][safi]); | |
11395 | if (p->pmax_restart[afi][safi]) | |
11396 | vty_out(vty, ", restart interval %d min", | |
11397 | p->pmax_restart[afi][safi]); | |
11398 | vty_out(vty, "\n"); | |
11399 | } | |
11400 | ||
11401 | vty_out(vty, "\n"); | |
11402 | } | |
11403 | } | |
11404 | ||
9f049418 | 11405 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 11406 | json_object *json) |
718e3744 | 11407 | { |
d62a17ae | 11408 | struct bgp *bgp; |
11409 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
11410 | char timebuf[BGP_UPTIME_LEN]; | |
11411 | char dn_flag[2]; | |
d62a17ae | 11412 | afi_t afi; |
11413 | safi_t safi; | |
d7c0a89a QY |
11414 | uint16_t i; |
11415 | uint8_t *msg; | |
d62a17ae | 11416 | json_object *json_neigh = NULL; |
11417 | time_t epoch_tbuf; | |
718e3744 | 11418 | |
d62a17ae | 11419 | bgp = p->bgp; |
11420 | ||
11421 | if (use_json) | |
11422 | json_neigh = json_object_new_object(); | |
11423 | ||
11424 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
11425 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
11426 | dn_flag[0] = '*'; | |
11427 | ||
11428 | if (!use_json) { | |
11429 | if (p->conf_if) /* Configured interface name. */ | |
11430 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
11431 | BGP_PEER_SU_UNSPEC(p) | |
11432 | ? "None" | |
11433 | : sockunion2str(&p->su, buf, | |
11434 | SU_ADDRSTRLEN)); | |
11435 | else /* Configured IP address. */ | |
11436 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
11437 | p->host); | |
11438 | } | |
11439 | ||
11440 | if (use_json) { | |
11441 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
11442 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
11443 | "none"); | |
11444 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
11445 | json_object_string_add( | |
11446 | json_neigh, "bgpNeighborAddr", | |
11447 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
11448 | ||
11449 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
11450 | ||
11451 | if (p->change_local_as) | |
11452 | json_object_int_add(json_neigh, "localAs", | |
11453 | p->change_local_as); | |
11454 | else | |
11455 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
11456 | ||
11457 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
11458 | json_object_boolean_true_add(json_neigh, | |
11459 | "localAsNoPrepend"); | |
11460 | ||
11461 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
11462 | json_object_boolean_true_add(json_neigh, | |
11463 | "localAsReplaceAs"); | |
11464 | } else { | |
11465 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
11466 | || (p->as_type == AS_INTERNAL)) | |
11467 | vty_out(vty, "remote AS %u, ", p->as); | |
11468 | else | |
11469 | vty_out(vty, "remote AS Unspecified, "); | |
11470 | vty_out(vty, "local AS %u%s%s, ", | |
11471 | p->change_local_as ? p->change_local_as : p->local_as, | |
11472 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
11473 | ? " no-prepend" | |
11474 | : "", | |
11475 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
11476 | ? " replace-as" | |
11477 | : ""); | |
11478 | } | |
faa16034 DS |
11479 | /* peer type internal or confed-internal */ |
11480 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 11481 | if (use_json) { |
11482 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
11483 | json_object_boolean_true_add( | |
11484 | json_neigh, "nbrConfedInternalLink"); | |
11485 | else | |
11486 | json_object_boolean_true_add(json_neigh, | |
11487 | "nbrInternalLink"); | |
11488 | } else { | |
11489 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
11490 | vty_out(vty, "confed-internal link\n"); | |
11491 | else | |
11492 | vty_out(vty, "internal link\n"); | |
11493 | } | |
faa16034 DS |
11494 | /* peer type external or confed-external */ |
11495 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 11496 | if (use_json) { |
11497 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
11498 | json_object_boolean_true_add( | |
11499 | json_neigh, "nbrConfedExternalLink"); | |
11500 | else | |
11501 | json_object_boolean_true_add(json_neigh, | |
11502 | "nbrExternalLink"); | |
11503 | } else { | |
11504 | if (bgp_confederation_peers_check(bgp, p->as)) | |
11505 | vty_out(vty, "confed-external link\n"); | |
11506 | else | |
11507 | vty_out(vty, "external link\n"); | |
11508 | } | |
faa16034 DS |
11509 | } else { |
11510 | if (use_json) | |
11511 | json_object_boolean_true_add(json_neigh, | |
11512 | "nbrUnspecifiedLink"); | |
11513 | else | |
11514 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 11515 | } |
11516 | ||
11517 | /* Description. */ | |
11518 | if (p->desc) { | |
11519 | if (use_json) | |
11520 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
11521 | else | |
11522 | vty_out(vty, " Description: %s\n", p->desc); | |
11523 | } | |
11524 | ||
11525 | if (p->hostname) { | |
11526 | if (use_json) { | |
11527 | if (p->hostname) | |
11528 | json_object_string_add(json_neigh, "hostname", | |
11529 | p->hostname); | |
11530 | ||
11531 | if (p->domainname) | |
11532 | json_object_string_add(json_neigh, "domainname", | |
11533 | p->domainname); | |
11534 | } else { | |
11535 | if (p->domainname && (p->domainname[0] != '\0')) | |
11536 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
11537 | p->domainname); | |
11538 | else | |
11539 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
11540 | } | |
11541 | } | |
11542 | ||
11543 | /* Peer-group */ | |
11544 | if (p->group) { | |
11545 | if (use_json) { | |
11546 | json_object_string_add(json_neigh, "peerGroup", | |
11547 | p->group->name); | |
11548 | ||
11549 | if (dn_flag[0]) { | |
11550 | struct prefix prefix, *range = NULL; | |
11551 | ||
11552 | sockunion2hostprefix(&(p->su), &prefix); | |
11553 | range = peer_group_lookup_dynamic_neighbor_range( | |
11554 | p->group, &prefix); | |
11555 | ||
11556 | if (range) { | |
11557 | prefix2str(range, buf1, sizeof(buf1)); | |
11558 | json_object_string_add( | |
11559 | json_neigh, | |
11560 | "peerSubnetRangeGroup", buf1); | |
11561 | } | |
11562 | } | |
11563 | } else { | |
11564 | vty_out(vty, | |
11565 | " Member of peer-group %s for session parameters\n", | |
11566 | p->group->name); | |
11567 | ||
11568 | if (dn_flag[0]) { | |
11569 | struct prefix prefix, *range = NULL; | |
11570 | ||
11571 | sockunion2hostprefix(&(p->su), &prefix); | |
11572 | range = peer_group_lookup_dynamic_neighbor_range( | |
11573 | p->group, &prefix); | |
11574 | ||
11575 | if (range) { | |
d62a17ae | 11576 | vty_out(vty, |
1b78780b DL |
11577 | " Belongs to the subnet range group: %pFX\n", |
11578 | range); | |
d62a17ae | 11579 | } |
11580 | } | |
11581 | } | |
11582 | } | |
11583 | ||
11584 | if (use_json) { | |
11585 | /* Administrative shutdown. */ | |
cb9196e7 DS |
11586 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
11587 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 11588 | json_object_boolean_true_add(json_neigh, |
11589 | "adminShutDown"); | |
11590 | ||
11591 | /* BGP Version. */ | |
11592 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
11593 | json_object_string_add( | |
11594 | json_neigh, "remoteRouterId", | |
11595 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
11596 | json_object_string_add( |
11597 | json_neigh, "localRouterId", | |
11598 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
11599 | sizeof(buf1))); | |
d62a17ae | 11600 | |
11601 | /* Confederation */ | |
11602 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
11603 | && bgp_confederation_peers_check(bgp, p->as)) | |
11604 | json_object_boolean_true_add(json_neigh, | |
11605 | "nbrCommonAdmin"); | |
11606 | ||
11607 | /* Status. */ | |
11608 | json_object_string_add( | |
11609 | json_neigh, "bgpState", | |
11610 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
11611 | ||
11612 | if (p->status == Established) { | |
11613 | time_t uptime; | |
d62a17ae | 11614 | |
11615 | uptime = bgp_clock(); | |
11616 | uptime -= p->uptime; | |
d62a17ae | 11617 | epoch_tbuf = time(NULL) - uptime; |
11618 | ||
d3c7efed DS |
11619 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
11620 | uptime * 1000); | |
d62a17ae | 11621 | json_object_string_add(json_neigh, "bgpTimerUpString", |
11622 | peer_uptime(p->uptime, timebuf, | |
11623 | BGP_UPTIME_LEN, 0, | |
11624 | NULL)); | |
11625 | json_object_int_add(json_neigh, | |
11626 | "bgpTimerUpEstablishedEpoch", | |
11627 | epoch_tbuf); | |
11628 | } | |
11629 | ||
11630 | else if (p->status == Active) { | |
11631 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
11632 | json_object_string_add(json_neigh, "bgpStateIs", | |
11633 | "passive"); | |
11634 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
11635 | json_object_string_add(json_neigh, "bgpStateIs", | |
11636 | "passiveNSF"); | |
11637 | } | |
11638 | ||
11639 | /* read timer */ | |
11640 | time_t uptime; | |
a2700b50 | 11641 | struct tm tm; |
d62a17ae | 11642 | |
11643 | uptime = bgp_clock(); | |
11644 | uptime -= p->readtime; | |
a2700b50 MS |
11645 | gmtime_r(&uptime, &tm); |
11646 | ||
d62a17ae | 11647 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
11648 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11649 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11650 | |
11651 | uptime = bgp_clock(); | |
11652 | uptime -= p->last_write; | |
a2700b50 MS |
11653 | gmtime_r(&uptime, &tm); |
11654 | ||
d62a17ae | 11655 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
11656 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11657 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11658 | |
11659 | uptime = bgp_clock(); | |
11660 | uptime -= p->update_time; | |
a2700b50 MS |
11661 | gmtime_r(&uptime, &tm); |
11662 | ||
d62a17ae | 11663 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
11664 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11665 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11666 | |
11667 | /* Configured timer values. */ | |
11668 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
11669 | p->v_holdtime * 1000); | |
11670 | json_object_int_add(json_neigh, | |
11671 | "bgpTimerKeepAliveIntervalMsecs", | |
11672 | p->v_keepalive * 1000); | |
b90a8e13 | 11673 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 11674 | json_object_int_add(json_neigh, |
11675 | "bgpTimerConfiguredHoldTimeMsecs", | |
11676 | p->holdtime * 1000); | |
11677 | json_object_int_add( | |
11678 | json_neigh, | |
11679 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
11680 | p->keepalive * 1000); | |
5d5393b9 DL |
11681 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
11682 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
11683 | json_object_int_add(json_neigh, |
11684 | "bgpTimerConfiguredHoldTimeMsecs", | |
11685 | bgp->default_holdtime); | |
11686 | json_object_int_add( | |
11687 | json_neigh, | |
11688 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
11689 | bgp->default_keepalive); | |
d62a17ae | 11690 | } |
11691 | } else { | |
11692 | /* Administrative shutdown. */ | |
cb9196e7 DS |
11693 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
11694 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 11695 | vty_out(vty, " Administratively shut down\n"); |
11696 | ||
11697 | /* BGP Version. */ | |
11698 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 11699 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 11700 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
11701 | vty_out(vty, ", local router ID %s\n", |
11702 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
11703 | sizeof(buf1))); | |
d62a17ae | 11704 | |
11705 | /* Confederation */ | |
11706 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
11707 | && bgp_confederation_peers_check(bgp, p->as)) | |
11708 | vty_out(vty, | |
11709 | " Neighbor under common administration\n"); | |
11710 | ||
11711 | /* Status. */ | |
11712 | vty_out(vty, " BGP state = %s", | |
11713 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
11714 | ||
11715 | if (p->status == Established) | |
11716 | vty_out(vty, ", up for %8s", | |
11717 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
11718 | 0, NULL)); | |
11719 | ||
11720 | else if (p->status == Active) { | |
11721 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
11722 | vty_out(vty, " (passive)"); | |
11723 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
11724 | vty_out(vty, " (NSF passive)"); | |
11725 | } | |
11726 | vty_out(vty, "\n"); | |
11727 | ||
11728 | /* read timer */ | |
11729 | vty_out(vty, " Last read %s", | |
11730 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
11731 | NULL)); | |
11732 | vty_out(vty, ", Last write %s\n", | |
11733 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
11734 | NULL)); | |
11735 | ||
11736 | /* Configured timer values. */ | |
11737 | vty_out(vty, | |
11738 | " Hold time is %d, keepalive interval is %d seconds\n", | |
11739 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 11740 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 11741 | vty_out(vty, " Configured hold time is %d", |
11742 | p->holdtime); | |
11743 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11744 | p->keepalive); | |
5d5393b9 DL |
11745 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
11746 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
11747 | vty_out(vty, " Configured hold time is %d", |
11748 | bgp->default_holdtime); | |
11749 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11750 | bgp->default_keepalive); | |
d62a17ae | 11751 | } |
11752 | } | |
11753 | /* Capability. */ | |
11754 | if (p->status == Established) { | |
11755 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
11756 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
11757 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
11758 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
11759 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
11760 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
11761 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
11762 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
11763 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
11764 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
11765 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
11766 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 11767 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
11768 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 11769 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
11770 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 11771 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
11772 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 11773 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
11774 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
11775 | if (use_json) { | |
11776 | json_object *json_cap = NULL; | |
11777 | ||
11778 | json_cap = json_object_new_object(); | |
11779 | ||
11780 | /* AS4 */ | |
11781 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11782 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11783 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
11784 | && CHECK_FLAG(p->cap, | |
11785 | PEER_CAP_AS4_RCV)) | |
11786 | json_object_string_add( | |
11787 | json_cap, "4byteAs", | |
11788 | "advertisedAndReceived"); | |
11789 | else if (CHECK_FLAG(p->cap, | |
11790 | PEER_CAP_AS4_ADV)) | |
11791 | json_object_string_add( | |
11792 | json_cap, "4byteAs", | |
11793 | "advertised"); | |
11794 | else if (CHECK_FLAG(p->cap, | |
11795 | PEER_CAP_AS4_RCV)) | |
11796 | json_object_string_add( | |
11797 | json_cap, "4byteAs", | |
11798 | "received"); | |
11799 | } | |
11800 | ||
11801 | /* AddPath */ | |
11802 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11803 | || CHECK_FLAG(p->cap, | |
11804 | PEER_CAP_ADDPATH_ADV)) { | |
11805 | json_object *json_add = NULL; | |
11806 | const char *print_store; | |
11807 | ||
11808 | json_add = json_object_new_object(); | |
11809 | ||
05c7a1cc QY |
11810 | FOREACH_AFI_SAFI (afi, safi) { |
11811 | json_object *json_sub = NULL; | |
11812 | json_sub = | |
11813 | json_object_new_object(); | |
5cb5f4d0 DD |
11814 | print_store = get_afi_safi_str( |
11815 | afi, safi, true); | |
d62a17ae | 11816 | |
05c7a1cc QY |
11817 | if (CHECK_FLAG( |
11818 | p->af_cap[afi] | |
11819 | [safi], | |
11820 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11821 | || CHECK_FLAG( | |
11822 | p->af_cap[afi] | |
11823 | [safi], | |
11824 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 11825 | if (CHECK_FLAG( |
11826 | p->af_cap | |
11827 | [afi] | |
11828 | [safi], | |
11829 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 11830 | && CHECK_FLAG( |
d62a17ae | 11831 | p->af_cap |
11832 | [afi] | |
11833 | [safi], | |
05c7a1cc QY |
11834 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
11835 | json_object_boolean_true_add( | |
11836 | json_sub, | |
11837 | "txAdvertisedAndReceived"); | |
11838 | else if ( | |
11839 | CHECK_FLAG( | |
11840 | p->af_cap | |
11841 | [afi] | |
11842 | [safi], | |
11843 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
11844 | json_object_boolean_true_add( | |
11845 | json_sub, | |
11846 | "txAdvertised"); | |
11847 | else if ( | |
11848 | CHECK_FLAG( | |
11849 | p->af_cap | |
11850 | [afi] | |
11851 | [safi], | |
11852 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11853 | json_object_boolean_true_add( | |
11854 | json_sub, | |
11855 | "txReceived"); | |
11856 | } | |
d62a17ae | 11857 | |
05c7a1cc QY |
11858 | if (CHECK_FLAG( |
11859 | p->af_cap[afi] | |
11860 | [safi], | |
11861 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11862 | || CHECK_FLAG( | |
11863 | p->af_cap[afi] | |
11864 | [safi], | |
11865 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 11866 | if (CHECK_FLAG( |
11867 | p->af_cap | |
11868 | [afi] | |
11869 | [safi], | |
11870 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 11871 | && CHECK_FLAG( |
d62a17ae | 11872 | p->af_cap |
11873 | [afi] | |
11874 | [safi], | |
11875 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
11876 | json_object_boolean_true_add( |
11877 | json_sub, | |
11878 | "rxAdvertisedAndReceived"); | |
11879 | else if ( | |
11880 | CHECK_FLAG( | |
11881 | p->af_cap | |
11882 | [afi] | |
11883 | [safi], | |
11884 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
11885 | json_object_boolean_true_add( | |
11886 | json_sub, | |
11887 | "rxAdvertised"); | |
11888 | else if ( | |
11889 | CHECK_FLAG( | |
11890 | p->af_cap | |
11891 | [afi] | |
11892 | [safi], | |
11893 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11894 | json_object_boolean_true_add( | |
11895 | json_sub, | |
11896 | "rxReceived"); | |
d62a17ae | 11897 | } |
11898 | ||
05c7a1cc QY |
11899 | if (CHECK_FLAG( |
11900 | p->af_cap[afi] | |
11901 | [safi], | |
11902 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11903 | || CHECK_FLAG( | |
11904 | p->af_cap[afi] | |
11905 | [safi], | |
11906 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
11907 | || CHECK_FLAG( | |
11908 | p->af_cap[afi] | |
11909 | [safi], | |
11910 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11911 | || CHECK_FLAG( | |
11912 | p->af_cap[afi] | |
11913 | [safi], | |
11914 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11915 | json_object_object_add( | |
11916 | json_add, | |
11917 | print_store, | |
11918 | json_sub); | |
11919 | else | |
11920 | json_object_free( | |
11921 | json_sub); | |
11922 | } | |
11923 | ||
d62a17ae | 11924 | json_object_object_add( |
11925 | json_cap, "addPath", json_add); | |
11926 | } | |
11927 | ||
11928 | /* Dynamic */ | |
11929 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11930 | || CHECK_FLAG(p->cap, | |
11931 | PEER_CAP_DYNAMIC_ADV)) { | |
11932 | if (CHECK_FLAG(p->cap, | |
11933 | PEER_CAP_DYNAMIC_ADV) | |
11934 | && CHECK_FLAG(p->cap, | |
11935 | PEER_CAP_DYNAMIC_RCV)) | |
11936 | json_object_string_add( | |
11937 | json_cap, "dynamic", | |
11938 | "advertisedAndReceived"); | |
11939 | else if (CHECK_FLAG( | |
11940 | p->cap, | |
11941 | PEER_CAP_DYNAMIC_ADV)) | |
11942 | json_object_string_add( | |
11943 | json_cap, "dynamic", | |
11944 | "advertised"); | |
11945 | else if (CHECK_FLAG( | |
11946 | p->cap, | |
11947 | PEER_CAP_DYNAMIC_RCV)) | |
11948 | json_object_string_add( | |
11949 | json_cap, "dynamic", | |
11950 | "received"); | |
11951 | } | |
11952 | ||
11953 | /* Extended nexthop */ | |
11954 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11955 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11956 | json_object *json_nxt = NULL; | |
11957 | const char *print_store; | |
11958 | ||
11959 | ||
11960 | if (CHECK_FLAG(p->cap, | |
11961 | PEER_CAP_ENHE_ADV) | |
11962 | && CHECK_FLAG(p->cap, | |
11963 | PEER_CAP_ENHE_RCV)) | |
11964 | json_object_string_add( | |
11965 | json_cap, | |
11966 | "extendedNexthop", | |
11967 | "advertisedAndReceived"); | |
11968 | else if (CHECK_FLAG(p->cap, | |
11969 | PEER_CAP_ENHE_ADV)) | |
11970 | json_object_string_add( | |
11971 | json_cap, | |
11972 | "extendedNexthop", | |
11973 | "advertised"); | |
11974 | else if (CHECK_FLAG(p->cap, | |
11975 | PEER_CAP_ENHE_RCV)) | |
11976 | json_object_string_add( | |
11977 | json_cap, | |
11978 | "extendedNexthop", | |
11979 | "received"); | |
11980 | ||
11981 | if (CHECK_FLAG(p->cap, | |
11982 | PEER_CAP_ENHE_RCV)) { | |
11983 | json_nxt = | |
11984 | json_object_new_object(); | |
11985 | ||
11986 | for (safi = SAFI_UNICAST; | |
11987 | safi < SAFI_MAX; safi++) { | |
11988 | if (CHECK_FLAG( | |
11989 | p->af_cap | |
11990 | [AFI_IP] | |
11991 | [safi], | |
11992 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11993 | print_store = get_afi_safi_str( |
d62a17ae | 11994 | AFI_IP, |
5cb5f4d0 | 11995 | safi, true); |
d62a17ae | 11996 | json_object_string_add( |
11997 | json_nxt, | |
11998 | print_store, | |
54f29523 | 11999 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 12000 | } |
12001 | } | |
12002 | json_object_object_add( | |
12003 | json_cap, | |
12004 | "extendedNexthopFamililesByPeer", | |
12005 | json_nxt); | |
12006 | } | |
12007 | } | |
12008 | ||
12009 | /* Route Refresh */ | |
12010 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12011 | || CHECK_FLAG(p->cap, | |
12012 | PEER_CAP_REFRESH_NEW_RCV) | |
12013 | || CHECK_FLAG(p->cap, | |
12014 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12015 | if (CHECK_FLAG(p->cap, | |
12016 | PEER_CAP_REFRESH_ADV) | |
12017 | && (CHECK_FLAG( | |
12018 | p->cap, | |
12019 | PEER_CAP_REFRESH_NEW_RCV) | |
12020 | || CHECK_FLAG( | |
12021 | p->cap, | |
12022 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12023 | if (CHECK_FLAG( | |
12024 | p->cap, | |
12025 | PEER_CAP_REFRESH_OLD_RCV) | |
12026 | && CHECK_FLAG( | |
12027 | p->cap, | |
12028 | PEER_CAP_REFRESH_NEW_RCV)) | |
12029 | json_object_string_add( | |
12030 | json_cap, | |
12031 | "routeRefresh", | |
12032 | "advertisedAndReceivedOldNew"); | |
12033 | else { | |
12034 | if (CHECK_FLAG( | |
12035 | p->cap, | |
12036 | PEER_CAP_REFRESH_OLD_RCV)) | |
12037 | json_object_string_add( | |
12038 | json_cap, | |
12039 | "routeRefresh", | |
12040 | "advertisedAndReceivedOld"); | |
12041 | else | |
12042 | json_object_string_add( | |
12043 | json_cap, | |
12044 | "routeRefresh", | |
12045 | "advertisedAndReceivedNew"); | |
12046 | } | |
12047 | } else if ( | |
12048 | CHECK_FLAG( | |
12049 | p->cap, | |
12050 | PEER_CAP_REFRESH_ADV)) | |
12051 | json_object_string_add( | |
12052 | json_cap, | |
12053 | "routeRefresh", | |
12054 | "advertised"); | |
12055 | else if ( | |
12056 | CHECK_FLAG( | |
12057 | p->cap, | |
12058 | PEER_CAP_REFRESH_NEW_RCV) | |
12059 | || CHECK_FLAG( | |
12060 | p->cap, | |
12061 | PEER_CAP_REFRESH_OLD_RCV)) | |
12062 | json_object_string_add( | |
12063 | json_cap, | |
12064 | "routeRefresh", | |
12065 | "received"); | |
12066 | } | |
12067 | ||
12068 | /* Multiprotocol Extensions */ | |
12069 | json_object *json_multi = NULL; | |
12070 | json_multi = json_object_new_object(); | |
12071 | ||
05c7a1cc QY |
12072 | FOREACH_AFI_SAFI (afi, safi) { |
12073 | if (p->afc_adv[afi][safi] | |
12074 | || p->afc_recv[afi][safi]) { | |
12075 | json_object *json_exten = NULL; | |
12076 | json_exten = | |
12077 | json_object_new_object(); | |
12078 | ||
d62a17ae | 12079 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
12080 | && p->afc_recv[afi][safi]) |
12081 | json_object_boolean_true_add( | |
12082 | json_exten, | |
12083 | "advertisedAndReceived"); | |
12084 | else if (p->afc_adv[afi][safi]) | |
12085 | json_object_boolean_true_add( | |
12086 | json_exten, | |
12087 | "advertised"); | |
12088 | else if (p->afc_recv[afi][safi]) | |
12089 | json_object_boolean_true_add( | |
12090 | json_exten, | |
12091 | "received"); | |
d62a17ae | 12092 | |
05c7a1cc QY |
12093 | json_object_object_add( |
12094 | json_multi, | |
5cb5f4d0 DD |
12095 | get_afi_safi_str(afi, |
12096 | safi, | |
12097 | true), | |
05c7a1cc | 12098 | json_exten); |
d62a17ae | 12099 | } |
12100 | } | |
12101 | json_object_object_add( | |
12102 | json_cap, "multiprotocolExtensions", | |
12103 | json_multi); | |
12104 | ||
d77114b7 | 12105 | /* Hostname capabilities */ |
60466a63 | 12106 | json_object *json_hname = NULL; |
d77114b7 MK |
12107 | |
12108 | json_hname = json_object_new_object(); | |
12109 | ||
12110 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
12111 | json_object_string_add( | |
60466a63 QY |
12112 | json_hname, "advHostName", |
12113 | bgp->peer_self->hostname | |
12114 | ? bgp->peer_self | |
12115 | ->hostname | |
d77114b7 MK |
12116 | : "n/a"); |
12117 | json_object_string_add( | |
60466a63 QY |
12118 | json_hname, "advDomainName", |
12119 | bgp->peer_self->domainname | |
12120 | ? bgp->peer_self | |
12121 | ->domainname | |
d77114b7 MK |
12122 | : "n/a"); |
12123 | } | |
12124 | ||
12125 | ||
12126 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
12127 | json_object_string_add( | |
60466a63 QY |
12128 | json_hname, "rcvHostName", |
12129 | p->hostname ? p->hostname | |
12130 | : "n/a"); | |
d77114b7 | 12131 | json_object_string_add( |
60466a63 QY |
12132 | json_hname, "rcvDomainName", |
12133 | p->domainname ? p->domainname | |
12134 | : "n/a"); | |
d77114b7 MK |
12135 | } |
12136 | ||
60466a63 | 12137 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
12138 | json_hname); |
12139 | ||
d62a17ae | 12140 | /* Gracefull Restart */ |
12141 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
12142 | || CHECK_FLAG(p->cap, | |
12143 | PEER_CAP_RESTART_ADV)) { | |
12144 | if (CHECK_FLAG(p->cap, | |
12145 | PEER_CAP_RESTART_ADV) | |
12146 | && CHECK_FLAG(p->cap, | |
12147 | PEER_CAP_RESTART_RCV)) | |
12148 | json_object_string_add( | |
12149 | json_cap, | |
12150 | "gracefulRestart", | |
12151 | "advertisedAndReceived"); | |
12152 | else if (CHECK_FLAG( | |
12153 | p->cap, | |
12154 | PEER_CAP_RESTART_ADV)) | |
12155 | json_object_string_add( | |
12156 | json_cap, | |
12157 | "gracefulRestartCapability", | |
12158 | "advertised"); | |
12159 | else if (CHECK_FLAG( | |
12160 | p->cap, | |
12161 | PEER_CAP_RESTART_RCV)) | |
12162 | json_object_string_add( | |
12163 | json_cap, | |
12164 | "gracefulRestartCapability", | |
12165 | "received"); | |
12166 | ||
12167 | if (CHECK_FLAG(p->cap, | |
12168 | PEER_CAP_RESTART_RCV)) { | |
12169 | int restart_af_count = 0; | |
12170 | json_object *json_restart = | |
12171 | NULL; | |
12172 | json_restart = | |
12173 | json_object_new_object(); | |
12174 | ||
12175 | json_object_int_add( | |
12176 | json_cap, | |
12177 | "gracefulRestartRemoteTimerMsecs", | |
12178 | p->v_gr_restart * 1000); | |
12179 | ||
05c7a1cc QY |
12180 | FOREACH_AFI_SAFI (afi, safi) { |
12181 | if (CHECK_FLAG( | |
12182 | p->af_cap | |
12183 | [afi] | |
12184 | [safi], | |
12185 | PEER_CAP_RESTART_AF_RCV)) { | |
12186 | json_object * | |
12187 | json_sub = | |
12188 | NULL; | |
12189 | json_sub = | |
12190 | json_object_new_object(); | |
12191 | ||
d62a17ae | 12192 | if (CHECK_FLAG( |
12193 | p->af_cap | |
12194 | [afi] | |
12195 | [safi], | |
05c7a1cc QY |
12196 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
12197 | json_object_boolean_true_add( | |
12198 | json_sub, | |
12199 | "preserved"); | |
12200 | restart_af_count++; | |
12201 | json_object_object_add( | |
12202 | json_restart, | |
5cb5f4d0 | 12203 | get_afi_safi_str( |
05c7a1cc | 12204 | afi, |
5cb5f4d0 DD |
12205 | safi, |
12206 | true), | |
05c7a1cc | 12207 | json_sub); |
d62a17ae | 12208 | } |
12209 | } | |
12210 | if (!restart_af_count) { | |
12211 | json_object_string_add( | |
12212 | json_cap, | |
12213 | "addressFamiliesByPeer", | |
12214 | "none"); | |
12215 | json_object_free( | |
12216 | json_restart); | |
12217 | } else | |
12218 | json_object_object_add( | |
12219 | json_cap, | |
12220 | "addressFamiliesByPeer", | |
12221 | json_restart); | |
12222 | } | |
12223 | } | |
12224 | json_object_object_add(json_neigh, | |
12225 | "neighborCapabilities", | |
12226 | json_cap); | |
12227 | } else { | |
12228 | vty_out(vty, " Neighbor capabilities:\n"); | |
12229 | ||
12230 | /* AS4 */ | |
12231 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
12232 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12233 | vty_out(vty, " 4 Byte AS:"); | |
12234 | if (CHECK_FLAG(p->cap, | |
12235 | PEER_CAP_AS4_ADV)) | |
12236 | vty_out(vty, " advertised"); | |
12237 | if (CHECK_FLAG(p->cap, | |
12238 | PEER_CAP_AS4_RCV)) | |
12239 | vty_out(vty, " %sreceived", | |
12240 | CHECK_FLAG( | |
12241 | p->cap, | |
12242 | PEER_CAP_AS4_ADV) | |
12243 | ? "and " | |
12244 | : ""); | |
12245 | vty_out(vty, "\n"); | |
12246 | } | |
12247 | ||
12248 | /* AddPath */ | |
12249 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
12250 | || CHECK_FLAG(p->cap, | |
12251 | PEER_CAP_ADDPATH_ADV)) { | |
12252 | vty_out(vty, " AddPath:\n"); | |
12253 | ||
05c7a1cc QY |
12254 | FOREACH_AFI_SAFI (afi, safi) { |
12255 | if (CHECK_FLAG( | |
12256 | p->af_cap[afi] | |
12257 | [safi], | |
12258 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12259 | || CHECK_FLAG( | |
12260 | p->af_cap[afi] | |
12261 | [safi], | |
12262 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
12263 | vty_out(vty, | |
12264 | " %s: TX ", | |
5cb5f4d0 | 12265 | get_afi_safi_str( |
05c7a1cc | 12266 | afi, |
5cb5f4d0 DD |
12267 | safi, |
12268 | false)); | |
05c7a1cc | 12269 | |
d62a17ae | 12270 | if (CHECK_FLAG( |
12271 | p->af_cap | |
12272 | [afi] | |
12273 | [safi], | |
05c7a1cc | 12274 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 12275 | vty_out(vty, |
05c7a1cc | 12276 | "advertised %s", |
5cb5f4d0 | 12277 | get_afi_safi_str( |
d62a17ae | 12278 | afi, |
5cb5f4d0 DD |
12279 | safi, |
12280 | false)); | |
d62a17ae | 12281 | |
05c7a1cc QY |
12282 | if (CHECK_FLAG( |
12283 | p->af_cap | |
12284 | [afi] | |
12285 | [safi], | |
12286 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12287 | vty_out(vty, | |
12288 | "%sreceived", | |
12289 | CHECK_FLAG( | |
12290 | p->af_cap | |
12291 | [afi] | |
12292 | [safi], | |
12293 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12294 | ? " and " | |
12295 | : ""); | |
d62a17ae | 12296 | |
05c7a1cc QY |
12297 | vty_out(vty, "\n"); |
12298 | } | |
d62a17ae | 12299 | |
05c7a1cc QY |
12300 | if (CHECK_FLAG( |
12301 | p->af_cap[afi] | |
12302 | [safi], | |
12303 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12304 | || CHECK_FLAG( | |
12305 | p->af_cap[afi] | |
12306 | [safi], | |
12307 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
12308 | vty_out(vty, | |
12309 | " %s: RX ", | |
5cb5f4d0 | 12310 | get_afi_safi_str( |
05c7a1cc | 12311 | afi, |
5cb5f4d0 DD |
12312 | safi, |
12313 | false)); | |
d62a17ae | 12314 | |
12315 | if (CHECK_FLAG( | |
12316 | p->af_cap | |
12317 | [afi] | |
12318 | [safi], | |
05c7a1cc | 12319 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 12320 | vty_out(vty, |
05c7a1cc | 12321 | "advertised %s", |
5cb5f4d0 | 12322 | get_afi_safi_str( |
d62a17ae | 12323 | afi, |
5cb5f4d0 DD |
12324 | safi, |
12325 | false)); | |
d62a17ae | 12326 | |
05c7a1cc QY |
12327 | if (CHECK_FLAG( |
12328 | p->af_cap | |
12329 | [afi] | |
12330 | [safi], | |
12331 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 12332 | vty_out(vty, |
05c7a1cc QY |
12333 | "%sreceived", |
12334 | CHECK_FLAG( | |
12335 | p->af_cap | |
12336 | [afi] | |
12337 | [safi], | |
12338 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12339 | ? " and " | |
12340 | : ""); | |
12341 | ||
12342 | vty_out(vty, "\n"); | |
d62a17ae | 12343 | } |
05c7a1cc | 12344 | } |
d62a17ae | 12345 | } |
12346 | ||
12347 | /* Dynamic */ | |
12348 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
12349 | || CHECK_FLAG(p->cap, | |
12350 | PEER_CAP_DYNAMIC_ADV)) { | |
12351 | vty_out(vty, " Dynamic:"); | |
12352 | if (CHECK_FLAG(p->cap, | |
12353 | PEER_CAP_DYNAMIC_ADV)) | |
12354 | vty_out(vty, " advertised"); | |
12355 | if (CHECK_FLAG(p->cap, | |
12356 | PEER_CAP_DYNAMIC_RCV)) | |
12357 | vty_out(vty, " %sreceived", | |
12358 | CHECK_FLAG( | |
12359 | p->cap, | |
12360 | PEER_CAP_DYNAMIC_ADV) | |
12361 | ? "and " | |
12362 | : ""); | |
12363 | vty_out(vty, "\n"); | |
12364 | } | |
12365 | ||
12366 | /* Extended nexthop */ | |
12367 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
12368 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12369 | vty_out(vty, " Extended nexthop:"); | |
12370 | if (CHECK_FLAG(p->cap, | |
12371 | PEER_CAP_ENHE_ADV)) | |
12372 | vty_out(vty, " advertised"); | |
12373 | if (CHECK_FLAG(p->cap, | |
12374 | PEER_CAP_ENHE_RCV)) | |
12375 | vty_out(vty, " %sreceived", | |
12376 | CHECK_FLAG( | |
12377 | p->cap, | |
12378 | PEER_CAP_ENHE_ADV) | |
12379 | ? "and " | |
12380 | : ""); | |
12381 | vty_out(vty, "\n"); | |
12382 | ||
12383 | if (CHECK_FLAG(p->cap, | |
12384 | PEER_CAP_ENHE_RCV)) { | |
12385 | vty_out(vty, | |
12386 | " Address families by peer:\n "); | |
12387 | for (safi = SAFI_UNICAST; | |
12388 | safi < SAFI_MAX; safi++) | |
12389 | if (CHECK_FLAG( | |
12390 | p->af_cap | |
12391 | [AFI_IP] | |
12392 | [safi], | |
12393 | PEER_CAP_ENHE_AF_RCV)) | |
12394 | vty_out(vty, | |
12395 | " %s\n", | |
5cb5f4d0 | 12396 | get_afi_safi_str( |
d62a17ae | 12397 | AFI_IP, |
5cb5f4d0 DD |
12398 | safi, |
12399 | false)); | |
d62a17ae | 12400 | } |
12401 | } | |
12402 | ||
12403 | /* Route Refresh */ | |
12404 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12405 | || CHECK_FLAG(p->cap, | |
12406 | PEER_CAP_REFRESH_NEW_RCV) | |
12407 | || CHECK_FLAG(p->cap, | |
12408 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12409 | vty_out(vty, " Route refresh:"); | |
12410 | if (CHECK_FLAG(p->cap, | |
12411 | PEER_CAP_REFRESH_ADV)) | |
12412 | vty_out(vty, " advertised"); | |
12413 | if (CHECK_FLAG(p->cap, | |
12414 | PEER_CAP_REFRESH_NEW_RCV) | |
12415 | || CHECK_FLAG( | |
12416 | p->cap, | |
12417 | PEER_CAP_REFRESH_OLD_RCV)) | |
12418 | vty_out(vty, " %sreceived(%s)", | |
12419 | CHECK_FLAG( | |
12420 | p->cap, | |
12421 | PEER_CAP_REFRESH_ADV) | |
12422 | ? "and " | |
12423 | : "", | |
12424 | (CHECK_FLAG( | |
12425 | p->cap, | |
12426 | PEER_CAP_REFRESH_OLD_RCV) | |
12427 | && CHECK_FLAG( | |
12428 | p->cap, | |
12429 | PEER_CAP_REFRESH_NEW_RCV)) | |
12430 | ? "old & new" | |
12431 | : CHECK_FLAG( | |
12432 | p->cap, | |
12433 | PEER_CAP_REFRESH_OLD_RCV) | |
12434 | ? "old" | |
12435 | : "new"); | |
12436 | ||
12437 | vty_out(vty, "\n"); | |
12438 | } | |
12439 | ||
12440 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
12441 | FOREACH_AFI_SAFI (afi, safi) |
12442 | if (p->afc_adv[afi][safi] | |
12443 | || p->afc_recv[afi][safi]) { | |
12444 | vty_out(vty, | |
12445 | " Address Family %s:", | |
5cb5f4d0 DD |
12446 | get_afi_safi_str( |
12447 | afi, | |
12448 | safi, | |
12449 | false)); | |
05c7a1cc | 12450 | if (p->afc_adv[afi][safi]) |
d62a17ae | 12451 | vty_out(vty, |
05c7a1cc QY |
12452 | " advertised"); |
12453 | if (p->afc_recv[afi][safi]) | |
12454 | vty_out(vty, | |
12455 | " %sreceived", | |
12456 | p->afc_adv[afi] | |
12457 | [safi] | |
12458 | ? "and " | |
12459 | : ""); | |
12460 | vty_out(vty, "\n"); | |
12461 | } | |
d62a17ae | 12462 | |
12463 | /* Hostname capability */ | |
60466a63 | 12464 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
12465 | |
12466 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
12467 | vty_out(vty, |
12468 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
12469 | bgp->peer_self->hostname |
12470 | ? bgp->peer_self | |
12471 | ->hostname | |
d77114b7 | 12472 | : "n/a", |
60466a63 QY |
12473 | bgp->peer_self->domainname |
12474 | ? bgp->peer_self | |
12475 | ->domainname | |
d77114b7 MK |
12476 | : "n/a"); |
12477 | } else { | |
12478 | vty_out(vty, " not advertised"); | |
d62a17ae | 12479 | } |
12480 | ||
d77114b7 | 12481 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
12482 | vty_out(vty, |
12483 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
12484 | p->hostname ? p->hostname |
12485 | : "n/a", | |
12486 | p->domainname ? p->domainname | |
12487 | : "n/a"); | |
d77114b7 MK |
12488 | } else { |
12489 | vty_out(vty, " not received"); | |
12490 | } | |
12491 | ||
12492 | vty_out(vty, "\n"); | |
12493 | ||
61bfbd51 | 12494 | /* Graceful Restart */ |
d62a17ae | 12495 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
12496 | || CHECK_FLAG(p->cap, | |
12497 | PEER_CAP_RESTART_ADV)) { | |
12498 | vty_out(vty, | |
61bfbd51 | 12499 | " Graceful Restart Capability:"); |
d62a17ae | 12500 | if (CHECK_FLAG(p->cap, |
12501 | PEER_CAP_RESTART_ADV)) | |
12502 | vty_out(vty, " advertised"); | |
12503 | if (CHECK_FLAG(p->cap, | |
12504 | PEER_CAP_RESTART_RCV)) | |
12505 | vty_out(vty, " %sreceived", | |
12506 | CHECK_FLAG( | |
12507 | p->cap, | |
12508 | PEER_CAP_RESTART_ADV) | |
12509 | ? "and " | |
12510 | : ""); | |
12511 | vty_out(vty, "\n"); | |
12512 | ||
12513 | if (CHECK_FLAG(p->cap, | |
12514 | PEER_CAP_RESTART_RCV)) { | |
12515 | int restart_af_count = 0; | |
12516 | ||
12517 | vty_out(vty, | |
12518 | " Remote Restart timer is %d seconds\n", | |
12519 | p->v_gr_restart); | |
12520 | vty_out(vty, | |
12521 | " Address families by peer:\n "); | |
12522 | ||
05c7a1cc QY |
12523 | FOREACH_AFI_SAFI (afi, safi) |
12524 | if (CHECK_FLAG( | |
12525 | p->af_cap | |
12526 | [afi] | |
12527 | [safi], | |
12528 | PEER_CAP_RESTART_AF_RCV)) { | |
12529 | vty_out(vty, | |
12530 | "%s%s(%s)", | |
12531 | restart_af_count | |
12532 | ? ", " | |
12533 | : "", | |
5cb5f4d0 | 12534 | get_afi_safi_str( |
05c7a1cc | 12535 | afi, |
5cb5f4d0 DD |
12536 | safi, |
12537 | false), | |
05c7a1cc QY |
12538 | CHECK_FLAG( |
12539 | p->af_cap | |
12540 | [afi] | |
12541 | [safi], | |
12542 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
12543 | ? "preserved" | |
12544 | : "not preserved"); | |
12545 | restart_af_count++; | |
12546 | } | |
d62a17ae | 12547 | if (!restart_af_count) |
12548 | vty_out(vty, "none"); | |
12549 | vty_out(vty, "\n"); | |
12550 | } | |
2986cac2 | 12551 | } /* Gracefull Restart */ |
d62a17ae | 12552 | } |
12553 | } | |
12554 | } | |
12555 | ||
12556 | /* graceful restart information */ | |
d62a17ae | 12557 | json_object *json_grace = NULL; |
12558 | json_object *json_grace_send = NULL; | |
12559 | json_object *json_grace_recv = NULL; | |
12560 | int eor_send_af_count = 0; | |
12561 | int eor_receive_af_count = 0; | |
12562 | ||
12563 | if (use_json) { | |
12564 | json_grace = json_object_new_object(); | |
12565 | json_grace_send = json_object_new_object(); | |
12566 | json_grace_recv = json_object_new_object(); | |
12567 | ||
36235319 QY |
12568 | if ((p->status == Established) |
12569 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
12570 | FOREACH_AFI_SAFI (afi, safi) { |
12571 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 12572 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
12573 | json_object_boolean_true_add( |
12574 | json_grace_send, | |
5cb5f4d0 DD |
12575 | get_afi_safi_str(afi, |
12576 | safi, | |
12577 | true)); | |
05c7a1cc | 12578 | eor_send_af_count++; |
d62a17ae | 12579 | } |
12580 | } | |
05c7a1cc QY |
12581 | FOREACH_AFI_SAFI (afi, safi) { |
12582 | if (CHECK_FLAG( | |
36235319 QY |
12583 | p->af_sflags[afi][safi], |
12584 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
12585 | json_object_boolean_true_add( |
12586 | json_grace_recv, | |
5cb5f4d0 DD |
12587 | get_afi_safi_str(afi, |
12588 | safi, | |
12589 | true)); | |
05c7a1cc | 12590 | eor_receive_af_count++; |
d62a17ae | 12591 | } |
12592 | } | |
12593 | } | |
36235319 QY |
12594 | json_object_object_add(json_grace, "endOfRibSend", |
12595 | json_grace_send); | |
12596 | json_object_object_add(json_grace, "endOfRibRecv", | |
12597 | json_grace_recv); | |
d62a17ae | 12598 | |
d62a17ae | 12599 | |
12600 | if (p->t_gr_restart) | |
12601 | json_object_int_add(json_grace, | |
12602 | "gracefulRestartTimerMsecs", | |
12603 | thread_timer_remain_second( | |
12604 | p->t_gr_restart) | |
12605 | * 1000); | |
12606 | ||
12607 | if (p->t_gr_stale) | |
12608 | json_object_int_add( | |
12609 | json_grace, | |
12610 | "gracefulStalepathTimerMsecs", | |
12611 | thread_timer_remain_second( | |
12612 | p->t_gr_stale) | |
12613 | * 1000); | |
2986cac2 | 12614 | /* more gr info in new format */ |
12615 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 12616 | json_grace); |
d62a17ae | 12617 | json_object_object_add( |
12618 | json_neigh, "gracefulRestartInfo", json_grace); | |
12619 | } else { | |
2089dd80 | 12620 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
12621 | if ((p->status == Established) |
12622 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 12623 | |
d62a17ae | 12624 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
12625 | FOREACH_AFI_SAFI (afi, safi) { |
12626 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12627 | PEER_STATUS_EOR_SEND)) { | |
12628 | vty_out(vty, "%s%s", | |
12629 | eor_send_af_count ? ", " | |
12630 | : "", | |
36235319 QY |
12631 | get_afi_safi_str( |
12632 | afi, safi, | |
12633 | false)); | |
05c7a1cc | 12634 | eor_send_af_count++; |
d62a17ae | 12635 | } |
12636 | } | |
12637 | vty_out(vty, "\n"); | |
12638 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
12639 | FOREACH_AFI_SAFI (afi, safi) { |
12640 | if (CHECK_FLAG( | |
12641 | p->af_sflags[afi][safi], | |
12642 | PEER_STATUS_EOR_RECEIVED)) { | |
12643 | vty_out(vty, "%s%s", | |
12644 | eor_receive_af_count | |
12645 | ? ", " | |
12646 | : "", | |
5cb5f4d0 DD |
12647 | get_afi_safi_str(afi, |
12648 | safi, | |
12649 | false)); | |
05c7a1cc | 12650 | eor_receive_af_count++; |
d62a17ae | 12651 | } |
12652 | } | |
12653 | vty_out(vty, "\n"); | |
12654 | } | |
12655 | ||
12656 | if (p->t_gr_restart) | |
12657 | vty_out(vty, | |
12658 | " The remaining time of restart timer is %ld\n", | |
12659 | thread_timer_remain_second( | |
12660 | p->t_gr_restart)); | |
12661 | ||
12662 | if (p->t_gr_stale) | |
12663 | vty_out(vty, | |
12664 | " The remaining time of stalepath timer is %ld\n", | |
12665 | thread_timer_remain_second( | |
12666 | p->t_gr_stale)); | |
2986cac2 | 12667 | |
12668 | /* more gr info in new format */ | |
12669 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 12670 | } |
2986cac2 | 12671 | |
d62a17ae | 12672 | if (use_json) { |
12673 | json_object *json_stat = NULL; | |
12674 | json_stat = json_object_new_object(); | |
12675 | /* Packet counts. */ | |
43aa5965 QY |
12676 | |
12677 | atomic_size_t outq_count, inq_count; | |
12678 | outq_count = atomic_load_explicit(&p->obuf->count, | |
12679 | memory_order_relaxed); | |
12680 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
12681 | memory_order_relaxed); | |
12682 | ||
12683 | json_object_int_add(json_stat, "depthInq", | |
12684 | (unsigned long)inq_count); | |
d62a17ae | 12685 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 12686 | (unsigned long)outq_count); |
0112e9e0 QY |
12687 | json_object_int_add(json_stat, "opensSent", |
12688 | atomic_load_explicit(&p->open_out, | |
12689 | memory_order_relaxed)); | |
12690 | json_object_int_add(json_stat, "opensRecv", | |
12691 | atomic_load_explicit(&p->open_in, | |
12692 | memory_order_relaxed)); | |
d62a17ae | 12693 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
12694 | atomic_load_explicit(&p->notify_out, |
12695 | memory_order_relaxed)); | |
d62a17ae | 12696 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
12697 | atomic_load_explicit(&p->notify_in, |
12698 | memory_order_relaxed)); | |
12699 | json_object_int_add(json_stat, "updatesSent", | |
12700 | atomic_load_explicit(&p->update_out, | |
12701 | memory_order_relaxed)); | |
12702 | json_object_int_add(json_stat, "updatesRecv", | |
12703 | atomic_load_explicit(&p->update_in, | |
12704 | memory_order_relaxed)); | |
d62a17ae | 12705 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
12706 | atomic_load_explicit(&p->keepalive_out, |
12707 | memory_order_relaxed)); | |
d62a17ae | 12708 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
12709 | atomic_load_explicit(&p->keepalive_in, |
12710 | memory_order_relaxed)); | |
d62a17ae | 12711 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
12712 | atomic_load_explicit(&p->refresh_out, |
12713 | memory_order_relaxed)); | |
d62a17ae | 12714 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
12715 | atomic_load_explicit(&p->refresh_in, |
12716 | memory_order_relaxed)); | |
d62a17ae | 12717 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
12718 | atomic_load_explicit(&p->dynamic_cap_out, |
12719 | memory_order_relaxed)); | |
d62a17ae | 12720 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
12721 | atomic_load_explicit(&p->dynamic_cap_in, |
12722 | memory_order_relaxed)); | |
12723 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
12724 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 12725 | json_object_object_add(json_neigh, "messageStats", json_stat); |
12726 | } else { | |
43aa5965 QY |
12727 | atomic_size_t outq_count, inq_count; |
12728 | outq_count = atomic_load_explicit(&p->obuf->count, | |
12729 | memory_order_relaxed); | |
12730 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
12731 | memory_order_relaxed); | |
12732 | ||
d62a17ae | 12733 | /* Packet counts. */ |
12734 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
12735 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
12736 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 12737 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
12738 | vty_out(vty, " Opens: %10d %10d\n", |
12739 | atomic_load_explicit(&p->open_out, | |
12740 | memory_order_relaxed), | |
12741 | atomic_load_explicit(&p->open_in, | |
12742 | memory_order_relaxed)); | |
12743 | vty_out(vty, " Notifications: %10d %10d\n", | |
12744 | atomic_load_explicit(&p->notify_out, | |
12745 | memory_order_relaxed), | |
12746 | atomic_load_explicit(&p->notify_in, | |
12747 | memory_order_relaxed)); | |
12748 | vty_out(vty, " Updates: %10d %10d\n", | |
12749 | atomic_load_explicit(&p->update_out, | |
12750 | memory_order_relaxed), | |
12751 | atomic_load_explicit(&p->update_in, | |
12752 | memory_order_relaxed)); | |
12753 | vty_out(vty, " Keepalives: %10d %10d\n", | |
12754 | atomic_load_explicit(&p->keepalive_out, | |
12755 | memory_order_relaxed), | |
12756 | atomic_load_explicit(&p->keepalive_in, | |
12757 | memory_order_relaxed)); | |
12758 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
12759 | atomic_load_explicit(&p->refresh_out, | |
12760 | memory_order_relaxed), | |
12761 | atomic_load_explicit(&p->refresh_in, | |
12762 | memory_order_relaxed)); | |
d62a17ae | 12763 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
12764 | atomic_load_explicit(&p->dynamic_cap_out, |
12765 | memory_order_relaxed), | |
12766 | atomic_load_explicit(&p->dynamic_cap_in, | |
12767 | memory_order_relaxed)); | |
12768 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
12769 | PEER_TOTAL_RX(p)); | |
d62a17ae | 12770 | } |
12771 | ||
12772 | if (use_json) { | |
12773 | /* advertisement-interval */ | |
12774 | json_object_int_add(json_neigh, | |
12775 | "minBtwnAdvertisementRunsTimerMsecs", | |
12776 | p->v_routeadv * 1000); | |
12777 | ||
12778 | /* Update-source. */ | |
12779 | if (p->update_if || p->update_source) { | |
12780 | if (p->update_if) | |
12781 | json_object_string_add(json_neigh, | |
12782 | "updateSource", | |
12783 | p->update_if); | |
12784 | else if (p->update_source) | |
12785 | json_object_string_add( | |
12786 | json_neigh, "updateSource", | |
12787 | sockunion2str(p->update_source, buf1, | |
12788 | SU_ADDRSTRLEN)); | |
12789 | } | |
12790 | } else { | |
12791 | /* advertisement-interval */ | |
12792 | vty_out(vty, | |
12793 | " Minimum time between advertisement runs is %d seconds\n", | |
12794 | p->v_routeadv); | |
12795 | ||
12796 | /* Update-source. */ | |
12797 | if (p->update_if || p->update_source) { | |
12798 | vty_out(vty, " Update source is "); | |
12799 | if (p->update_if) | |
12800 | vty_out(vty, "%s", p->update_if); | |
12801 | else if (p->update_source) | |
12802 | vty_out(vty, "%s", | |
12803 | sockunion2str(p->update_source, buf1, | |
12804 | SU_ADDRSTRLEN)); | |
12805 | vty_out(vty, "\n"); | |
12806 | } | |
12807 | ||
12808 | vty_out(vty, "\n"); | |
12809 | } | |
12810 | ||
12811 | /* Address Family Information */ | |
12812 | json_object *json_hold = NULL; | |
12813 | ||
12814 | if (use_json) | |
12815 | json_hold = json_object_new_object(); | |
12816 | ||
05c7a1cc QY |
12817 | FOREACH_AFI_SAFI (afi, safi) |
12818 | if (p->afc[afi][safi]) | |
12819 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
12820 | json_hold); | |
d62a17ae | 12821 | |
12822 | if (use_json) { | |
12823 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
12824 | json_hold); | |
12825 | json_object_int_add(json_neigh, "connectionsEstablished", | |
12826 | p->established); | |
12827 | json_object_int_add(json_neigh, "connectionsDropped", | |
12828 | p->dropped); | |
12829 | } else | |
12830 | vty_out(vty, " Connections established %d; dropped %d\n", | |
12831 | p->established, p->dropped); | |
12832 | ||
12833 | if (!p->last_reset) { | |
12834 | if (use_json) | |
12835 | json_object_string_add(json_neigh, "lastReset", | |
12836 | "never"); | |
12837 | else | |
12838 | vty_out(vty, " Last reset never\n"); | |
12839 | } else { | |
12840 | if (use_json) { | |
12841 | time_t uptime; | |
a2700b50 | 12842 | struct tm tm; |
d62a17ae | 12843 | |
12844 | uptime = bgp_clock(); | |
12845 | uptime -= p->resettime; | |
a2700b50 MS |
12846 | gmtime_r(&uptime, &tm); |
12847 | ||
d62a17ae | 12848 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
12849 | (tm.tm_sec * 1000) |
12850 | + (tm.tm_min * 60000) | |
12851 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 12852 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 12853 | } else { |
12854 | vty_out(vty, " Last reset %s, ", | |
12855 | peer_uptime(p->resettime, timebuf, | |
12856 | BGP_UPTIME_LEN, 0, NULL)); | |
12857 | ||
3577f1c5 | 12858 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 12859 | if (p->last_reset_cause_size) { |
12860 | msg = p->last_reset_cause; | |
12861 | vty_out(vty, | |
12862 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
12863 | for (i = 1; i <= p->last_reset_cause_size; | |
12864 | i++) { | |
12865 | vty_out(vty, "%02X", *msg++); | |
12866 | ||
12867 | if (i != p->last_reset_cause_size) { | |
12868 | if (i % 16 == 0) { | |
12869 | vty_out(vty, "\n "); | |
12870 | } else if (i % 4 == 0) { | |
12871 | vty_out(vty, " "); | |
12872 | } | |
12873 | } | |
12874 | } | |
12875 | vty_out(vty, "\n"); | |
12876 | } | |
12877 | } | |
12878 | } | |
12879 | ||
12880 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
12881 | if (use_json) | |
12882 | json_object_boolean_true_add(json_neigh, | |
12883 | "prefixesConfigExceedMax"); | |
12884 | else | |
12885 | vty_out(vty, | |
12886 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
12887 | ||
12888 | if (p->t_pmax_restart) { | |
12889 | if (use_json) { | |
12890 | json_object_boolean_true_add( | |
12891 | json_neigh, "reducePrefixNumFrom"); | |
12892 | json_object_int_add(json_neigh, | |
12893 | "restartInTimerMsec", | |
12894 | thread_timer_remain_second( | |
12895 | p->t_pmax_restart) | |
12896 | * 1000); | |
12897 | } else | |
12898 | vty_out(vty, | |
12899 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
12900 | p->host, thread_timer_remain_second( |
12901 | p->t_pmax_restart)); | |
d62a17ae | 12902 | } else { |
12903 | if (use_json) | |
12904 | json_object_boolean_true_add( | |
12905 | json_neigh, | |
12906 | "reducePrefixNumAndClearIpBgp"); | |
12907 | else | |
12908 | vty_out(vty, | |
12909 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
12910 | p->host); | |
12911 | } | |
12912 | } | |
12913 | ||
12914 | /* EBGP Multihop and GTSM */ | |
12915 | if (p->sort != BGP_PEER_IBGP) { | |
12916 | if (use_json) { | |
e2521429 | 12917 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12918 | json_object_int_add(json_neigh, |
12919 | "externalBgpNbrMaxHopsAway", | |
12920 | p->gtsm_hops); | |
c8d6f0d6 | 12921 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12922 | json_object_int_add(json_neigh, |
12923 | "externalBgpNbrMaxHopsAway", | |
12924 | p->ttl); | |
12925 | } else { | |
e2521429 | 12926 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12927 | vty_out(vty, |
12928 | " External BGP neighbor may be up to %d hops away.\n", | |
12929 | p->gtsm_hops); | |
c8d6f0d6 | 12930 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12931 | vty_out(vty, |
12932 | " External BGP neighbor may be up to %d hops away.\n", | |
12933 | p->ttl); | |
12934 | } | |
12935 | } else { | |
e2521429 | 12936 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 12937 | if (use_json) |
12938 | json_object_int_add(json_neigh, | |
12939 | "internalBgpNbrMaxHopsAway", | |
12940 | p->gtsm_hops); | |
12941 | else | |
12942 | vty_out(vty, | |
12943 | " Internal BGP neighbor may be up to %d hops away.\n", | |
12944 | p->gtsm_hops); | |
12945 | } | |
12946 | } | |
12947 | ||
12948 | /* Local address. */ | |
12949 | if (p->su_local) { | |
12950 | if (use_json) { | |
12951 | json_object_string_add(json_neigh, "hostLocal", | |
12952 | sockunion2str(p->su_local, buf1, | |
12953 | SU_ADDRSTRLEN)); | |
12954 | json_object_int_add(json_neigh, "portLocal", | |
12955 | ntohs(p->su_local->sin.sin_port)); | |
12956 | } else | |
12957 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
12958 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
12959 | ntohs(p->su_local->sin.sin_port)); | |
12960 | } | |
12961 | ||
12962 | /* Remote address. */ | |
12963 | if (p->su_remote) { | |
12964 | if (use_json) { | |
12965 | json_object_string_add(json_neigh, "hostForeign", | |
12966 | sockunion2str(p->su_remote, buf1, | |
12967 | SU_ADDRSTRLEN)); | |
12968 | json_object_int_add(json_neigh, "portForeign", | |
12969 | ntohs(p->su_remote->sin.sin_port)); | |
12970 | } else | |
12971 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
12972 | sockunion2str(p->su_remote, buf1, | |
12973 | SU_ADDRSTRLEN), | |
12974 | ntohs(p->su_remote->sin.sin_port)); | |
12975 | } | |
12976 | ||
12977 | /* Nexthop display. */ | |
12978 | if (p->su_local) { | |
12979 | if (use_json) { | |
12980 | json_object_string_add(json_neigh, "nexthop", | |
12981 | inet_ntop(AF_INET, | |
12982 | &p->nexthop.v4, buf1, | |
12983 | sizeof(buf1))); | |
12984 | json_object_string_add(json_neigh, "nexthopGlobal", | |
12985 | inet_ntop(AF_INET6, | |
12986 | &p->nexthop.v6_global, | |
12987 | buf1, sizeof(buf1))); | |
12988 | json_object_string_add(json_neigh, "nexthopLocal", | |
12989 | inet_ntop(AF_INET6, | |
12990 | &p->nexthop.v6_local, | |
12991 | buf1, sizeof(buf1))); | |
12992 | if (p->shared_network) | |
12993 | json_object_string_add(json_neigh, | |
12994 | "bgpConnection", | |
12995 | "sharedNetwork"); | |
12996 | else | |
12997 | json_object_string_add(json_neigh, | |
12998 | "bgpConnection", | |
12999 | "nonSharedNetwork"); | |
13000 | } else { | |
13001 | vty_out(vty, "Nexthop: %s\n", | |
13002 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
13003 | sizeof(buf1))); | |
13004 | vty_out(vty, "Nexthop global: %s\n", | |
13005 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
13006 | sizeof(buf1))); | |
13007 | vty_out(vty, "Nexthop local: %s\n", | |
13008 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
13009 | sizeof(buf1))); | |
13010 | vty_out(vty, "BGP connection: %s\n", | |
13011 | p->shared_network ? "shared network" | |
13012 | : "non shared network"); | |
13013 | } | |
13014 | } | |
13015 | ||
13016 | /* Timer information. */ | |
13017 | if (use_json) { | |
13018 | json_object_int_add(json_neigh, "connectRetryTimer", | |
13019 | p->v_connect); | |
13020 | if (p->status == Established && p->rtt) | |
13021 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
13022 | p->rtt); | |
13023 | if (p->t_start) | |
13024 | json_object_int_add( | |
13025 | json_neigh, "nextStartTimerDueInMsecs", | |
13026 | thread_timer_remain_second(p->t_start) * 1000); | |
13027 | if (p->t_connect) | |
13028 | json_object_int_add( | |
13029 | json_neigh, "nextConnectTimerDueInMsecs", | |
13030 | thread_timer_remain_second(p->t_connect) | |
13031 | * 1000); | |
13032 | if (p->t_routeadv) { | |
13033 | json_object_int_add(json_neigh, "mraiInterval", | |
13034 | p->v_routeadv); | |
13035 | json_object_int_add( | |
13036 | json_neigh, "mraiTimerExpireInMsecs", | |
13037 | thread_timer_remain_second(p->t_routeadv) | |
13038 | * 1000); | |
13039 | } | |
13040 | if (p->password) | |
13041 | json_object_int_add(json_neigh, "authenticationEnabled", | |
13042 | 1); | |
13043 | ||
13044 | if (p->t_read) | |
13045 | json_object_string_add(json_neigh, "readThread", "on"); | |
13046 | else | |
13047 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
13048 | |
13049 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 13050 | json_object_string_add(json_neigh, "writeThread", "on"); |
13051 | else | |
13052 | json_object_string_add(json_neigh, "writeThread", | |
13053 | "off"); | |
13054 | } else { | |
13055 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
13056 | p->v_connect); | |
13057 | if (p->status == Established && p->rtt) | |
13058 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
13059 | p->rtt); | |
13060 | if (p->t_start) | |
13061 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
13062 | thread_timer_remain_second(p->t_start)); | |
13063 | if (p->t_connect) | |
13064 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
13065 | thread_timer_remain_second(p->t_connect)); | |
13066 | if (p->t_routeadv) | |
13067 | vty_out(vty, | |
13068 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
13069 | p->v_routeadv, | |
13070 | thread_timer_remain_second(p->t_routeadv)); | |
13071 | if (p->password) | |
13072 | vty_out(vty, "Peer Authentication Enabled\n"); | |
13073 | ||
cac9e917 | 13074 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
13075 | p->t_read ? "on" : "off", |
13076 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
13077 | ? "on" | |
cac9e917 | 13078 | : "off", p->fd); |
d62a17ae | 13079 | } |
13080 | ||
13081 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
13082 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
13083 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
13084 | ||
13085 | if (!use_json) | |
13086 | vty_out(vty, "\n"); | |
13087 | ||
13088 | /* BFD information. */ | |
13089 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
13090 | ||
13091 | if (use_json) { | |
13092 | if (p->conf_if) /* Configured interface name. */ | |
13093 | json_object_object_add(json, p->conf_if, json_neigh); | |
13094 | else /* Configured IP address. */ | |
13095 | json_object_object_add(json, p->host, json_neigh); | |
13096 | } | |
13097 | } | |
13098 | ||
36235319 QY |
13099 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
13100 | enum show_type type, | |
13101 | union sockunion *su, | |
13102 | const char *conf_if, afi_t afi, | |
74a630b6 | 13103 | bool use_json) |
2986cac2 | 13104 | { |
13105 | struct listnode *node, *nnode; | |
13106 | struct peer *peer; | |
13107 | int find = 0; | |
13108 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 13109 | json_object *json = NULL; |
2986cac2 | 13110 | json_object *json_neighbor = NULL; |
13111 | ||
74a630b6 NT |
13112 | if (use_json) { |
13113 | json = json_object_new_object(); | |
13114 | json_neighbor = json_object_new_object(); | |
13115 | } | |
13116 | ||
2986cac2 | 13117 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
13118 | ||
13119 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
13120 | continue; | |
13121 | ||
13122 | if ((peer->afc[afi][safi]) == 0) | |
13123 | continue; | |
13124 | ||
2ba1fe69 | 13125 | if (type == show_all) { |
2986cac2 | 13126 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 13127 | json_neighbor); |
2986cac2 | 13128 | |
74a630b6 | 13129 | if (use_json) { |
13909c4f DS |
13130 | json_object_object_add(json, peer->host, |
13131 | json_neighbor); | |
74a630b6 NT |
13132 | json_neighbor = NULL; |
13133 | } | |
2986cac2 | 13134 | |
2ba1fe69 | 13135 | } else if (type == show_peer) { |
2986cac2 | 13136 | if (conf_if) { |
13137 | if ((peer->conf_if | |
13909c4f DS |
13138 | && !strcmp(peer->conf_if, conf_if)) |
13139 | || (peer->hostname | |
2986cac2 | 13140 | && !strcmp(peer->hostname, conf_if))) { |
13141 | find = 1; | |
13909c4f DS |
13142 | bgp_show_peer_gr_status(vty, peer, |
13143 | use_json, | |
13144 | json_neighbor); | |
2986cac2 | 13145 | } |
13146 | } else { | |
13147 | if (sockunion_same(&peer->su, su)) { | |
13148 | find = 1; | |
13909c4f DS |
13149 | bgp_show_peer_gr_status(vty, peer, |
13150 | use_json, | |
13151 | json_neighbor); | |
2986cac2 | 13152 | } |
13153 | } | |
13909c4f DS |
13154 | if (use_json && find) |
13155 | json_object_object_add(json, peer->host, | |
13156 | json_neighbor); | |
2986cac2 | 13157 | } |
13158 | ||
74a630b6 NT |
13159 | if (find) { |
13160 | json_neighbor = NULL; | |
2986cac2 | 13161 | break; |
74a630b6 | 13162 | } |
2986cac2 | 13163 | } |
13164 | ||
13165 | if (type == show_peer && !find) { | |
13166 | if (use_json) | |
13909c4f | 13167 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 13168 | else |
13169 | vty_out(vty, "%% No such neighbor\n"); | |
13170 | } | |
13171 | if (use_json) { | |
13909c4f DS |
13172 | vty_out(vty, "%s\n", |
13173 | json_object_to_json_string_ext( | |
13174 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
13175 | |
13176 | if (json_neighbor) | |
13177 | json_object_free(json_neighbor); | |
13178 | json_object_free(json); | |
2986cac2 | 13179 | } else { |
13180 | vty_out(vty, "\n"); | |
13181 | } | |
13182 | ||
13183 | return CMD_SUCCESS; | |
13184 | } | |
13185 | ||
d62a17ae | 13186 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
13187 | enum show_type type, union sockunion *su, | |
9f049418 | 13188 | const char *conf_if, bool use_json, |
d62a17ae | 13189 | json_object *json) |
13190 | { | |
13191 | struct listnode *node, *nnode; | |
13192 | struct peer *peer; | |
13193 | int find = 0; | |
9f049418 | 13194 | bool nbr_output = false; |
d1927ebe AS |
13195 | afi_t afi = AFI_MAX; |
13196 | safi_t safi = SAFI_MAX; | |
13197 | ||
13198 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
13199 | afi = AFI_IP; | |
13200 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
13201 | afi = AFI_IP6; | |
13202 | } | |
d62a17ae | 13203 | |
13204 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
13205 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
13206 | continue; | |
13207 | ||
13208 | switch (type) { | |
13209 | case show_all: | |
13210 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 13211 | nbr_output = true; |
d62a17ae | 13212 | break; |
13213 | case show_peer: | |
13214 | if (conf_if) { | |
13215 | if ((peer->conf_if | |
13216 | && !strcmp(peer->conf_if, conf_if)) | |
13217 | || (peer->hostname | |
13218 | && !strcmp(peer->hostname, conf_if))) { | |
13219 | find = 1; | |
13220 | bgp_show_peer(vty, peer, use_json, | |
13221 | json); | |
13222 | } | |
13223 | } else { | |
13224 | if (sockunion_same(&peer->su, su)) { | |
13225 | find = 1; | |
13226 | bgp_show_peer(vty, peer, use_json, | |
13227 | json); | |
13228 | } | |
13229 | } | |
13230 | break; | |
d1927ebe AS |
13231 | case show_ipv4_peer: |
13232 | case show_ipv6_peer: | |
13233 | FOREACH_SAFI (safi) { | |
13234 | if (peer->afc[afi][safi]) { | |
13235 | if (conf_if) { | |
13236 | if ((peer->conf_if | |
13237 | && !strcmp(peer->conf_if, conf_if)) | |
13238 | || (peer->hostname | |
13239 | && !strcmp(peer->hostname, conf_if))) { | |
13240 | find = 1; | |
13241 | bgp_show_peer(vty, peer, use_json, | |
13242 | json); | |
13243 | break; | |
13244 | } | |
13245 | } else { | |
13246 | if (sockunion_same(&peer->su, su)) { | |
13247 | find = 1; | |
13248 | bgp_show_peer(vty, peer, use_json, | |
13249 | json); | |
13250 | break; | |
13251 | } | |
13252 | } | |
13253 | } | |
13254 | } | |
13255 | break; | |
13256 | case show_ipv4_all: | |
13257 | case show_ipv6_all: | |
13258 | FOREACH_SAFI (safi) { | |
13259 | if (peer->afc[afi][safi]) { | |
13260 | bgp_show_peer(vty, peer, use_json, json); | |
13261 | nbr_output = true; | |
13262 | break; | |
13263 | } | |
13264 | } | |
13265 | break; | |
d62a17ae | 13266 | } |
13267 | } | |
13268 | ||
d1927ebe AS |
13269 | if ((type == show_peer || type == show_ipv4_peer || |
13270 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 13271 | if (use_json) |
13272 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
13273 | else | |
88b7d255 | 13274 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 13275 | } |
13276 | ||
d1927ebe AS |
13277 | if (type != show_peer && type != show_ipv4_peer && |
13278 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 13279 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 13280 | |
d62a17ae | 13281 | if (use_json) { |
996c9314 LB |
13282 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
13283 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 13284 | } else { |
13285 | vty_out(vty, "\n"); | |
13286 | } | |
13287 | ||
13288 | return CMD_SUCCESS; | |
13289 | } | |
13290 | ||
36235319 QY |
13291 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
13292 | enum show_type type, | |
13293 | const char *ip_str, | |
13294 | afi_t afi, bool use_json) | |
2986cac2 | 13295 | { |
13296 | ||
13297 | int ret; | |
13298 | struct bgp *bgp; | |
13299 | union sockunion su; | |
2986cac2 | 13300 | |
13301 | bgp = bgp_get_default(); | |
13302 | ||
13909c4f DS |
13303 | if (!bgp) |
13304 | return; | |
2986cac2 | 13305 | |
13909c4f DS |
13306 | if (!use_json) |
13307 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
13308 | NULL); | |
2986cac2 | 13309 | |
13909c4f DS |
13310 | if (ip_str) { |
13311 | ret = str2sockunion(ip_str, &su); | |
13312 | if (ret < 0) | |
13909c4f | 13313 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
13314 | vty, bgp, type, NULL, ip_str, afi, use_json); |
13315 | else | |
13316 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
13317 | NULL, afi, use_json); | |
13909c4f DS |
13318 | } else |
13319 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 13320 | afi, use_json); |
2986cac2 | 13321 | } |
13322 | ||
d62a17ae | 13323 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
13324 | enum show_type type, |
13325 | const char *ip_str, | |
9f049418 | 13326 | bool use_json) |
d62a17ae | 13327 | { |
0291c246 MK |
13328 | struct listnode *node, *nnode; |
13329 | struct bgp *bgp; | |
71aedaa3 | 13330 | union sockunion su; |
0291c246 | 13331 | json_object *json = NULL; |
71aedaa3 | 13332 | int ret, is_first = 1; |
9f049418 | 13333 | bool nbr_output = false; |
d62a17ae | 13334 | |
13335 | if (use_json) | |
13336 | vty_out(vty, "{\n"); | |
13337 | ||
13338 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 13339 | nbr_output = true; |
d62a17ae | 13340 | if (use_json) { |
13341 | if (!(json = json_object_new_object())) { | |
af4c2728 | 13342 | flog_err( |
e50f7cfd | 13343 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 13344 | "Unable to allocate memory for JSON object"); |
13345 | vty_out(vty, | |
13346 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
13347 | return; | |
13348 | } | |
13349 | ||
13350 | json_object_int_add(json, "vrfId", | |
13351 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
13352 | ? -1 |
13353 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 13354 | json_object_string_add( |
13355 | json, "vrfName", | |
13356 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13357 | ? VRF_DEFAULT_NAME |
d62a17ae | 13358 | : bgp->name); |
13359 | ||
13360 | if (!is_first) | |
13361 | vty_out(vty, ",\n"); | |
13362 | else | |
13363 | is_first = 0; | |
13364 | ||
13365 | vty_out(vty, "\"%s\":", | |
13366 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13367 | ? VRF_DEFAULT_NAME |
d62a17ae | 13368 | : bgp->name); |
13369 | } else { | |
13370 | vty_out(vty, "\nInstance %s:\n", | |
13371 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13372 | ? VRF_DEFAULT_NAME |
d62a17ae | 13373 | : bgp->name); |
13374 | } | |
71aedaa3 | 13375 | |
d1927ebe AS |
13376 | if (type == show_peer || type == show_ipv4_peer || |
13377 | type == show_ipv6_peer) { | |
71aedaa3 DS |
13378 | ret = str2sockunion(ip_str, &su); |
13379 | if (ret < 0) | |
13380 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
13381 | use_json, json); | |
13382 | else | |
13383 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
13384 | use_json, json); | |
13385 | } else { | |
d1927ebe | 13386 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
13387 | use_json, json); |
13388 | } | |
b77004d6 | 13389 | json_object_free(json); |
121067e9 | 13390 | json = NULL; |
d62a17ae | 13391 | } |
13392 | ||
3e78a6ce | 13393 | if (use_json) |
d62a17ae | 13394 | vty_out(vty, "}\n"); |
9f049418 DS |
13395 | else if (!nbr_output) |
13396 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 13397 | } |
13398 | ||
13399 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
13400 | enum show_type type, const char *ip_str, | |
9f049418 | 13401 | bool use_json) |
d62a17ae | 13402 | { |
13403 | int ret; | |
13404 | struct bgp *bgp; | |
13405 | union sockunion su; | |
13406 | json_object *json = NULL; | |
13407 | ||
13408 | if (name) { | |
13409 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
13410 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
13411 | use_json); | |
d62a17ae | 13412 | return CMD_SUCCESS; |
13413 | } else { | |
13414 | bgp = bgp_lookup_by_name(name); | |
13415 | if (!bgp) { | |
13416 | if (use_json) { | |
13417 | json = json_object_new_object(); | |
d62a17ae | 13418 | vty_out(vty, "%s\n", |
13419 | json_object_to_json_string_ext( | |
13420 | json, | |
13421 | JSON_C_TO_STRING_PRETTY)); | |
13422 | json_object_free(json); | |
13423 | } else | |
13424 | vty_out(vty, | |
9f049418 | 13425 | "%% BGP instance not found\n"); |
d62a17ae | 13426 | |
13427 | return CMD_WARNING; | |
13428 | } | |
13429 | } | |
13430 | } else { | |
13431 | bgp = bgp_get_default(); | |
13432 | } | |
13433 | ||
13434 | if (bgp) { | |
13435 | json = json_object_new_object(); | |
13436 | if (ip_str) { | |
13437 | ret = str2sockunion(ip_str, &su); | |
13438 | if (ret < 0) | |
13439 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
13440 | use_json, json); | |
13441 | else | |
13442 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
13443 | use_json, json); | |
13444 | } else { | |
13445 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
13446 | json); | |
13447 | } | |
13448 | json_object_free(json); | |
ca61fd25 DS |
13449 | } else { |
13450 | if (use_json) | |
13451 | vty_out(vty, "{}\n"); | |
13452 | else | |
13453 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 13454 | } |
13455 | ||
13456 | return CMD_SUCCESS; | |
4fb25c53 DW |
13457 | } |
13458 | ||
2986cac2 | 13459 | |
13460 | ||
13461 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
13462 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
13463 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
13464 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
13465 | SHOW_STR | |
13466 | BGP_STR | |
13467 | IP_STR | |
13468 | IPV6_STR | |
13469 | NEIGHBOR_STR | |
13470 | "Neighbor to display information about\n" | |
13471 | "Neighbor to display information about\n" | |
13472 | "Neighbor on BGP configured interface\n" | |
13473 | GR_SHOW | |
13474 | JSON_STR) | |
13475 | { | |
13476 | char *sh_arg = NULL; | |
13477 | enum show_type sh_type; | |
13478 | int idx = 0; | |
13479 | afi_t afi = AFI_MAX; | |
2986cac2 | 13480 | bool uj = use_json(argc, argv); |
13481 | ||
36235319 | 13482 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 13483 | afi = AFI_MAX; |
13484 | ||
13485 | idx++; | |
13486 | ||
13487 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
13488 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
13489 | || argv_find(argv, argc, "WORD", &idx)) { | |
13490 | sh_type = show_peer; | |
13491 | sh_arg = argv[idx]->arg; | |
13492 | } else | |
13493 | sh_type = show_all; | |
13494 | ||
13495 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
13496 | return CMD_SUCCESS; | |
13497 | ||
13498 | ||
36235319 QY |
13499 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
13500 | afi, uj); | |
2986cac2 | 13501 | } |
13502 | ||
716b2d8a | 13503 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 13504 | DEFUN (show_ip_bgp_neighbors, |
13505 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 13506 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 13507 | SHOW_STR |
13508 | IP_STR | |
13509 | BGP_STR | |
f2a8972b | 13510 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
13511 | "Address Family\n" |
13512 | "Address Family\n" | |
718e3744 | 13513 | "Detailed information on TCP and BGP neighbor connections\n" |
13514 | "Neighbor to display information about\n" | |
a80beece | 13515 | "Neighbor to display information about\n" |
91d37724 | 13516 | "Neighbor on BGP configured interface\n" |
9973d184 | 13517 | JSON_STR) |
718e3744 | 13518 | { |
d62a17ae | 13519 | char *vrf = NULL; |
13520 | char *sh_arg = NULL; | |
13521 | enum show_type sh_type; | |
d1927ebe | 13522 | afi_t afi = AFI_MAX; |
718e3744 | 13523 | |
9f049418 | 13524 | bool uj = use_json(argc, argv); |
718e3744 | 13525 | |
d62a17ae | 13526 | int idx = 0; |
718e3744 | 13527 | |
9a8bdf1c PG |
13528 | /* [<vrf> VIEWVRFNAME] */ |
13529 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13530 | vrf = argv[idx + 1]->arg; | |
13531 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13532 | vrf = NULL; | |
13533 | } else if (argv_find(argv, argc, "view", &idx)) | |
13534 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 13535 | vrf = argv[idx + 1]->arg; |
718e3744 | 13536 | |
d62a17ae | 13537 | idx++; |
d1927ebe AS |
13538 | |
13539 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
13540 | sh_type = show_ipv4_all; | |
13541 | afi = AFI_IP; | |
13542 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
13543 | sh_type = show_ipv6_all; | |
13544 | afi = AFI_IP6; | |
13545 | } else { | |
13546 | sh_type = show_all; | |
13547 | } | |
13548 | ||
d62a17ae | 13549 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
13550 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
13551 | || argv_find(argv, argc, "WORD", &idx)) { | |
13552 | sh_type = show_peer; | |
13553 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
13554 | } |
13555 | ||
13556 | if (sh_type == show_peer && afi == AFI_IP) { | |
13557 | sh_type = show_ipv4_peer; | |
13558 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
13559 | sh_type = show_ipv6_peer; | |
13560 | } | |
856ca177 | 13561 | |
d62a17ae | 13562 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 13563 | } |
13564 | ||
716b2d8a | 13565 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 13566 | paths' and `show ip mbgp paths'. Those functions results are the |
13567 | same.*/ | |
f412b39a | 13568 | DEFUN (show_ip_bgp_paths, |
718e3744 | 13569 | show_ip_bgp_paths_cmd, |
46f296b4 | 13570 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 13571 | SHOW_STR |
13572 | IP_STR | |
13573 | BGP_STR | |
46f296b4 | 13574 | BGP_SAFI_HELP_STR |
718e3744 | 13575 | "Path information\n") |
13576 | { | |
d62a17ae | 13577 | vty_out(vty, "Address Refcnt Path\n"); |
13578 | aspath_print_all_vty(vty); | |
13579 | return CMD_SUCCESS; | |
718e3744 | 13580 | } |
13581 | ||
718e3744 | 13582 | #include "hash.h" |
13583 | ||
e3b78da8 | 13584 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 13585 | struct vty *vty) |
718e3744 | 13586 | { |
d62a17ae | 13587 | struct community *com; |
718e3744 | 13588 | |
e3b78da8 | 13589 | com = (struct community *)bucket->data; |
3f65c5b1 | 13590 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 13591 | community_str(com, false)); |
718e3744 | 13592 | } |
13593 | ||
13594 | /* Show BGP's community internal data. */ | |
f412b39a | 13595 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 13596 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 13597 | "show [ip] bgp community-info", |
718e3744 | 13598 | SHOW_STR |
13599 | IP_STR | |
13600 | BGP_STR | |
13601 | "List all bgp community information\n") | |
13602 | { | |
d62a17ae | 13603 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 13604 | |
d62a17ae | 13605 | hash_iterate(community_hash(), |
e3b78da8 | 13606 | (void (*)(struct hash_bucket *, |
d62a17ae | 13607 | void *))community_show_all_iterator, |
13608 | vty); | |
718e3744 | 13609 | |
d62a17ae | 13610 | return CMD_SUCCESS; |
718e3744 | 13611 | } |
13612 | ||
e3b78da8 | 13613 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 13614 | struct vty *vty) |
57d187bc | 13615 | { |
d62a17ae | 13616 | struct lcommunity *lcom; |
57d187bc | 13617 | |
e3b78da8 | 13618 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 13619 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 13620 | lcommunity_str(lcom, false)); |
57d187bc JS |
13621 | } |
13622 | ||
13623 | /* Show BGP's community internal data. */ | |
13624 | DEFUN (show_ip_bgp_lcommunity_info, | |
13625 | show_ip_bgp_lcommunity_info_cmd, | |
13626 | "show ip bgp large-community-info", | |
13627 | SHOW_STR | |
13628 | IP_STR | |
13629 | BGP_STR | |
13630 | "List all bgp large-community information\n") | |
13631 | { | |
d62a17ae | 13632 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 13633 | |
d62a17ae | 13634 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 13635 | (void (*)(struct hash_bucket *, |
d62a17ae | 13636 | void *))lcommunity_show_all_iterator, |
13637 | vty); | |
57d187bc | 13638 | |
d62a17ae | 13639 | return CMD_SUCCESS; |
57d187bc | 13640 | } |
2986cac2 | 13641 | /* Graceful Restart */ |
13642 | ||
13643 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
13644 | struct bgp *bgp, |
13645 | bool use_json, | |
13646 | json_object *json) | |
2986cac2 | 13647 | { |
57d187bc JS |
13648 | |
13649 | ||
2986cac2 | 13650 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
13651 | ||
7318ae88 | 13652 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 13653 | |
13654 | switch (bgp_global_gr_mode) { | |
13655 | ||
13656 | case GLOBAL_HELPER: | |
13909c4f | 13657 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 13658 | break; |
13659 | ||
13660 | case GLOBAL_GR: | |
13909c4f | 13661 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 13662 | break; |
13663 | ||
13664 | case GLOBAL_DISABLE: | |
13909c4f | 13665 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 13666 | break; |
13667 | ||
13668 | case GLOBAL_INVALID: | |
2986cac2 | 13669 | vty_out(vty, |
2ba1fe69 | 13670 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 13671 | break; |
13672 | } | |
13673 | vty_out(vty, "\n"); | |
13674 | } | |
13675 | ||
36235319 QY |
13676 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
13677 | enum show_type type, | |
13678 | const char *ip_str, | |
13679 | afi_t afi, bool use_json) | |
2986cac2 | 13680 | { |
13681 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
13682 | afi = AFI_IP; | |
13683 | ||
13684 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
13685 | ||
36235319 QY |
13686 | bgp_show_neighbor_graceful_restart_vty( |
13687 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 13688 | afi++; |
13689 | } | |
13690 | } else if (afi != AFI_MAX) { | |
36235319 QY |
13691 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
13692 | use_json); | |
2986cac2 | 13693 | } else { |
13694 | return CMD_ERR_INCOMPLETE; | |
13695 | } | |
13696 | ||
13697 | return CMD_SUCCESS; | |
13698 | } | |
13699 | /* Graceful Restart */ | |
13700 | ||
f412b39a | 13701 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 13702 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 13703 | "show [ip] bgp attribute-info", |
718e3744 | 13704 | SHOW_STR |
13705 | IP_STR | |
13706 | BGP_STR | |
13707 | "List all bgp attribute information\n") | |
13708 | { | |
d62a17ae | 13709 | attr_show_all(vty); |
13710 | return CMD_SUCCESS; | |
718e3744 | 13711 | } |
6b0655a2 | 13712 | |
03915806 CS |
13713 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
13714 | afi_t afi, safi_t safi, | |
13715 | bool use_json, json_object *json) | |
53089bec | 13716 | { |
13717 | struct bgp *bgp; | |
13718 | struct listnode *node; | |
13719 | char *vname; | |
13720 | char buf1[INET6_ADDRSTRLEN]; | |
13721 | char *ecom_str; | |
13722 | vpn_policy_direction_t dir; | |
13723 | ||
03915806 | 13724 | if (json) { |
b46dfd20 DS |
13725 | json_object *json_import_vrfs = NULL; |
13726 | json_object *json_export_vrfs = NULL; | |
13727 | ||
b46dfd20 DS |
13728 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13729 | ||
53089bec | 13730 | if (!bgp) { |
b46dfd20 DS |
13731 | vty_out(vty, "%s\n", |
13732 | json_object_to_json_string_ext( | |
13733 | json, | |
13734 | JSON_C_TO_STRING_PRETTY)); | |
13735 | json_object_free(json); | |
13736 | ||
53089bec | 13737 | return CMD_WARNING; |
13738 | } | |
b46dfd20 | 13739 | |
94d4c685 DS |
13740 | /* Provide context for the block */ |
13741 | json_object_string_add(json, "vrf", name ? name : "default"); | |
13742 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 13743 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 13744 | |
b46dfd20 DS |
13745 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13746 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
13747 | json_object_string_add(json, "importFromVrfs", "none"); | |
13748 | json_object_string_add(json, "importRts", "none"); | |
13749 | } else { | |
6ce24e52 DS |
13750 | json_import_vrfs = json_object_new_array(); |
13751 | ||
b46dfd20 DS |
13752 | for (ALL_LIST_ELEMENTS_RO( |
13753 | bgp->vpn_policy[afi].import_vrf, | |
13754 | node, vname)) | |
13755 | json_object_array_add(json_import_vrfs, | |
13756 | json_object_new_string(vname)); | |
13757 | ||
b20875ea CS |
13758 | json_object_object_add(json, "importFromVrfs", |
13759 | json_import_vrfs); | |
b46dfd20 | 13760 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
13761 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13762 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13763 | bgp->vpn_policy[afi].rtlist[dir], |
13764 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13765 | json_object_string_add(json, "importRts", |
13766 | ecom_str); | |
13767 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13768 | } else | |
13769 | json_object_string_add(json, "importRts", | |
13770 | "none"); | |
b46dfd20 DS |
13771 | } |
13772 | ||
13773 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
13774 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
13775 | json_object_string_add(json, "exportToVrfs", "none"); | |
13776 | json_object_string_add(json, "routeDistinguisher", | |
13777 | "none"); | |
13778 | json_object_string_add(json, "exportRts", "none"); | |
13779 | } else { | |
6ce24e52 DS |
13780 | json_export_vrfs = json_object_new_array(); |
13781 | ||
b46dfd20 DS |
13782 | for (ALL_LIST_ELEMENTS_RO( |
13783 | bgp->vpn_policy[afi].export_vrf, | |
13784 | node, vname)) | |
13785 | json_object_array_add(json_export_vrfs, | |
13786 | json_object_new_string(vname)); | |
13787 | json_object_object_add(json, "exportToVrfs", | |
13788 | json_export_vrfs); | |
13789 | json_object_string_add(json, "routeDistinguisher", | |
13790 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13791 | buf1, RD_ADDRSTRLEN)); | |
13792 | ||
13793 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13794 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13795 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13796 | bgp->vpn_policy[afi].rtlist[dir], |
13797 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13798 | json_object_string_add(json, "exportRts", |
13799 | ecom_str); | |
13800 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13801 | } else | |
13802 | json_object_string_add(json, "exportRts", | |
13803 | "none"); | |
b46dfd20 DS |
13804 | } |
13805 | ||
03915806 CS |
13806 | if (use_json) { |
13807 | vty_out(vty, "%s\n", | |
13808 | json_object_to_json_string_ext(json, | |
b46dfd20 | 13809 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
13810 | json_object_free(json); |
13811 | } | |
53089bec | 13812 | } else { |
b46dfd20 DS |
13813 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13814 | ||
53089bec | 13815 | if (!bgp) { |
b46dfd20 | 13816 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 13817 | return CMD_WARNING; |
13818 | } | |
53089bec | 13819 | |
b46dfd20 DS |
13820 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13821 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
13822 | vty_out(vty, | |
13823 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 13824 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13825 | else { |
13826 | vty_out(vty, | |
13827 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 13828 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13829 | |
13830 | for (ALL_LIST_ELEMENTS_RO( | |
13831 | bgp->vpn_policy[afi].import_vrf, | |
13832 | node, vname)) | |
13833 | vty_out(vty, " %s\n", vname); | |
13834 | ||
13835 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
13836 | ecom_str = NULL; |
13837 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
13838 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13839 | bgp->vpn_policy[afi].rtlist[dir], |
13840 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 13841 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 13842 | |
b20875ea CS |
13843 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
13844 | } else | |
13845 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13846 | } |
53089bec | 13847 | |
b46dfd20 DS |
13848 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13849 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
13850 | vty_out(vty, | |
13851 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 13852 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13853 | else { |
13854 | vty_out(vty, | |
04c9077f | 13855 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 13856 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13857 | |
13858 | for (ALL_LIST_ELEMENTS_RO( | |
13859 | bgp->vpn_policy[afi].export_vrf, | |
13860 | node, vname)) | |
13861 | vty_out(vty, " %s\n", vname); | |
13862 | ||
13863 | vty_out(vty, "RD: %s\n", | |
13864 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13865 | buf1, RD_ADDRSTRLEN)); | |
13866 | ||
13867 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13868 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13869 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13870 | bgp->vpn_policy[afi].rtlist[dir], |
13871 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13872 | vty_out(vty, "Export RT: %s\n", ecom_str); |
13873 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13874 | } else | |
13875 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13876 | } |
53089bec | 13877 | } |
13878 | ||
13879 | return CMD_SUCCESS; | |
13880 | } | |
13881 | ||
03915806 CS |
13882 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
13883 | safi_t safi, bool use_json) | |
13884 | { | |
13885 | struct listnode *node, *nnode; | |
13886 | struct bgp *bgp; | |
13887 | char *vrf_name = NULL; | |
13888 | json_object *json = NULL; | |
13889 | json_object *json_vrf = NULL; | |
13890 | json_object *json_vrfs = NULL; | |
13891 | ||
13892 | if (use_json) { | |
13893 | json = json_object_new_object(); | |
13894 | json_vrfs = json_object_new_object(); | |
13895 | } | |
13896 | ||
13897 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
13898 | ||
13899 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
13900 | vrf_name = bgp->name; | |
13901 | ||
13902 | if (use_json) { | |
13903 | json_vrf = json_object_new_object(); | |
13904 | } else { | |
13905 | vty_out(vty, "\nInstance %s:\n", | |
13906 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13907 | ? VRF_DEFAULT_NAME : bgp->name); | |
13908 | } | |
13909 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
13910 | if (use_json) { | |
13911 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13912 | json_object_object_add(json_vrfs, | |
13913 | VRF_DEFAULT_NAME, json_vrf); | |
13914 | else | |
13915 | json_object_object_add(json_vrfs, vrf_name, | |
13916 | json_vrf); | |
13917 | } | |
13918 | } | |
13919 | ||
13920 | if (use_json) { | |
13921 | json_object_object_add(json, "vrfs", json_vrfs); | |
13922 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
13923 | JSON_C_TO_STRING_PRETTY)); | |
13924 | json_object_free(json); | |
13925 | } | |
13926 | ||
13927 | return CMD_SUCCESS; | |
13928 | } | |
13929 | ||
53089bec | 13930 | /* "show [ip] bgp route-leak" command. */ |
13931 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
13932 | show_ip_bgp_route_leak_cmd, |
13933 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
13934 | SHOW_STR |
13935 | IP_STR | |
13936 | BGP_STR | |
13937 | BGP_INSTANCE_HELP_STR | |
13938 | BGP_AFI_HELP_STR | |
13939 | BGP_SAFI_HELP_STR | |
13940 | "Route leaking information\n" | |
13941 | JSON_STR) | |
53089bec | 13942 | { |
13943 | char *vrf = NULL; | |
13944 | afi_t afi = AFI_MAX; | |
13945 | safi_t safi = SAFI_MAX; | |
13946 | ||
9f049418 | 13947 | bool uj = use_json(argc, argv); |
53089bec | 13948 | int idx = 0; |
03915806 | 13949 | json_object *json = NULL; |
53089bec | 13950 | |
13951 | /* show [ip] bgp */ | |
13952 | if (argv_find(argv, argc, "ip", &idx)) { | |
13953 | afi = AFI_IP; | |
13954 | safi = SAFI_UNICAST; | |
13955 | } | |
13956 | /* [vrf VIEWVRFNAME] */ | |
13957 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
13958 | vty_out(vty, |
13959 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 13960 | return CMD_WARNING; |
13961 | } | |
13962 | ||
9a8bdf1c PG |
13963 | if (argv_find(argv, argc, "vrf", &idx)) { |
13964 | vrf = argv[idx + 1]->arg; | |
13965 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13966 | vrf = NULL; | |
13967 | } | |
53089bec | 13968 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13969 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13970 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13971 | } | |
13972 | ||
13973 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
13974 | vty_out(vty, |
13975 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 13976 | return CMD_WARNING; |
13977 | } | |
13978 | ||
03915806 CS |
13979 | if (vrf && strmatch(vrf, "all")) |
13980 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
13981 | ||
13982 | if (uj) | |
13983 | json = json_object_new_object(); | |
13984 | ||
13985 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 13986 | } |
13987 | ||
d62a17ae | 13988 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
13989 | safi_t safi) | |
f186de26 | 13990 | { |
d62a17ae | 13991 | struct listnode *node, *nnode; |
13992 | struct bgp *bgp; | |
f186de26 | 13993 | |
d62a17ae | 13994 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
13995 | vty_out(vty, "\nInstance %s:\n", | |
13996 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13997 | ? VRF_DEFAULT_NAME |
d62a17ae | 13998 | : bgp->name); |
13999 | update_group_show(bgp, afi, safi, vty, 0); | |
14000 | } | |
f186de26 | 14001 | } |
14002 | ||
d62a17ae | 14003 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
14004 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 14005 | { |
d62a17ae | 14006 | struct bgp *bgp; |
4fb25c53 | 14007 | |
d62a17ae | 14008 | if (name) { |
14009 | if (strmatch(name, "all")) { | |
14010 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
14011 | return CMD_SUCCESS; | |
14012 | } else { | |
14013 | bgp = bgp_lookup_by_name(name); | |
14014 | } | |
14015 | } else { | |
14016 | bgp = bgp_get_default(); | |
14017 | } | |
4fb25c53 | 14018 | |
d62a17ae | 14019 | if (bgp) |
14020 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
14021 | return CMD_SUCCESS; | |
4fb25c53 DW |
14022 | } |
14023 | ||
8fe8a7f6 DS |
14024 | DEFUN (show_ip_bgp_updgrps, |
14025 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 14026 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 14027 | SHOW_STR |
14028 | IP_STR | |
14029 | BGP_STR | |
14030 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 14031 | BGP_AFI_HELP_STR |
9bedbb1e | 14032 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
14033 | "Detailed info about dynamic update groups\n" |
14034 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 14035 | { |
d62a17ae | 14036 | char *vrf = NULL; |
14037 | afi_t afi = AFI_IP6; | |
14038 | safi_t safi = SAFI_UNICAST; | |
14039 | uint64_t subgrp_id = 0; | |
14040 | ||
14041 | int idx = 0; | |
14042 | ||
14043 | /* show [ip] bgp */ | |
14044 | if (argv_find(argv, argc, "ip", &idx)) | |
14045 | afi = AFI_IP; | |
9a8bdf1c PG |
14046 | /* [<vrf> VIEWVRFNAME] */ |
14047 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14048 | vrf = argv[idx + 1]->arg; | |
14049 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14050 | vrf = NULL; | |
14051 | } else if (argv_find(argv, argc, "view", &idx)) | |
14052 | /* [<view> VIEWVRFNAME] */ | |
14053 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 14054 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14055 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14056 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14057 | } | |
5bf15956 | 14058 | |
d62a17ae | 14059 | /* get subgroup id, if provided */ |
14060 | idx = argc - 1; | |
14061 | if (argv[idx]->type == VARIABLE_TKN) | |
14062 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 14063 | |
d62a17ae | 14064 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
14065 | } |
14066 | ||
f186de26 | 14067 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
14068 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 14069 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 14070 | SHOW_STR |
716b2d8a | 14071 | IP_STR |
f186de26 | 14072 | BGP_STR |
14073 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 14074 | "Detailed info about dynamic update groups\n") |
f186de26 | 14075 | { |
d62a17ae | 14076 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
14077 | return CMD_SUCCESS; | |
f186de26 | 14078 | } |
14079 | ||
43d3f4fc DS |
14080 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
14081 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
14082 | "show [ip] bgp l2vpn evpn update-groups", | |
14083 | SHOW_STR | |
14084 | IP_STR | |
14085 | BGP_STR | |
14086 | "l2vpn address family\n" | |
14087 | "evpn sub-address family\n" | |
14088 | "Detailed info about dynamic update groups\n") | |
14089 | { | |
14090 | char *vrf = NULL; | |
14091 | uint64_t subgrp_id = 0; | |
14092 | ||
14093 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
14094 | return CMD_SUCCESS; | |
14095 | } | |
14096 | ||
5bf15956 DW |
14097 | DEFUN (show_bgp_updgrps_stats, |
14098 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 14099 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 14100 | SHOW_STR |
716b2d8a | 14101 | IP_STR |
3f9c7369 | 14102 | BGP_STR |
0c7b1b01 | 14103 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
14104 | "Statistics\n") |
14105 | { | |
d62a17ae | 14106 | struct bgp *bgp; |
3f9c7369 | 14107 | |
d62a17ae | 14108 | bgp = bgp_get_default(); |
14109 | if (bgp) | |
14110 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 14111 | |
d62a17ae | 14112 | return CMD_SUCCESS; |
3f9c7369 DS |
14113 | } |
14114 | ||
8386ac43 | 14115 | DEFUN (show_bgp_instance_updgrps_stats, |
14116 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 14117 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 14118 | SHOW_STR |
716b2d8a | 14119 | IP_STR |
8386ac43 | 14120 | BGP_STR |
14121 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 14122 | "Detailed info about dynamic update groups\n" |
8386ac43 | 14123 | "Statistics\n") |
14124 | { | |
d62a17ae | 14125 | int idx_word = 3; |
14126 | struct bgp *bgp; | |
8386ac43 | 14127 | |
d62a17ae | 14128 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
14129 | if (bgp) | |
14130 | update_group_show_stats(bgp, vty); | |
8386ac43 | 14131 | |
d62a17ae | 14132 | return CMD_SUCCESS; |
8386ac43 | 14133 | } |
14134 | ||
d62a17ae | 14135 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
14136 | afi_t afi, safi_t safi, | |
14137 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 14138 | { |
d62a17ae | 14139 | struct bgp *bgp; |
8386ac43 | 14140 | |
d62a17ae | 14141 | if (name) |
14142 | bgp = bgp_lookup_by_name(name); | |
14143 | else | |
14144 | bgp = bgp_get_default(); | |
8386ac43 | 14145 | |
d62a17ae | 14146 | if (bgp) { |
14147 | if (!strcmp(what, "advertise-queue")) | |
14148 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
14149 | subgrp_id); | |
14150 | else if (!strcmp(what, "advertised-routes")) | |
14151 | update_group_show_advertised(bgp, afi, safi, vty, | |
14152 | subgrp_id); | |
14153 | else if (!strcmp(what, "packet-queue")) | |
14154 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
14155 | subgrp_id); | |
14156 | } | |
3f9c7369 DS |
14157 | } |
14158 | ||
dc64bdec QY |
14159 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
14160 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
14161 | "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", | |
14162 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
14163 | BGP_SAFI_HELP_STR | |
14164 | "Detailed info about dynamic update groups\n" | |
14165 | "Specific subgroup to display info for\n" | |
14166 | "Advertisement queue\n" | |
14167 | "Announced routes\n" | |
14168 | "Packet queue\n") | |
3f9c7369 | 14169 | { |
dc64bdec QY |
14170 | uint64_t subgrp_id = 0; |
14171 | afi_t afiz; | |
14172 | safi_t safiz; | |
14173 | if (sgid) | |
14174 | subgrp_id = strtoull(sgid, NULL, 10); | |
14175 | ||
14176 | if (!ip && !afi) | |
14177 | afiz = AFI_IP6; | |
14178 | if (!ip && afi) | |
14179 | afiz = bgp_vty_afi_from_str(afi); | |
14180 | if (ip && !afi) | |
14181 | afiz = AFI_IP; | |
14182 | if (ip && afi) { | |
14183 | afiz = bgp_vty_afi_from_str(afi); | |
14184 | if (afiz != AFI_IP) | |
14185 | vty_out(vty, | |
14186 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
14187 | return CMD_WARNING; | |
14188 | } | |
d62a17ae | 14189 | |
dc64bdec | 14190 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 14191 | |
dc64bdec | 14192 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 14193 | return CMD_SUCCESS; |
14194 | } | |
14195 | ||
d62a17ae | 14196 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
14197 | { | |
14198 | struct listnode *node, *nnode; | |
14199 | struct prefix *range; | |
14200 | struct peer *conf; | |
14201 | struct peer *peer; | |
d62a17ae | 14202 | afi_t afi; |
14203 | safi_t safi; | |
14204 | const char *peer_status; | |
14205 | const char *af_str; | |
14206 | int lr_count; | |
14207 | int dynamic; | |
14208 | int af_cfgd; | |
14209 | ||
14210 | conf = group->conf; | |
14211 | ||
14212 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
6cde4b45 | 14213 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 14214 | group->name, conf->as); |
d62a17ae | 14215 | } else if (conf->as_type == AS_INTERNAL) { |
6cde4b45 | 14216 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 14217 | group->name, group->bgp->as); |
d62a17ae | 14218 | } else { |
14219 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
14220 | } | |
f14e6fdb | 14221 | |
d62a17ae | 14222 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
14223 | vty_out(vty, " Peer-group type is internal\n"); | |
14224 | else | |
14225 | vty_out(vty, " Peer-group type is external\n"); | |
14226 | ||
14227 | /* Display AFs configured. */ | |
14228 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
14229 | FOREACH_AFI_SAFI (afi, safi) { |
14230 | if (conf->afc[afi][safi]) { | |
14231 | af_cfgd = 1; | |
5cb5f4d0 | 14232 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 14233 | } |
05c7a1cc | 14234 | } |
d62a17ae | 14235 | if (!af_cfgd) |
14236 | vty_out(vty, " none\n"); | |
14237 | else | |
14238 | vty_out(vty, "\n"); | |
14239 | ||
14240 | /* Display listen ranges (for dynamic neighbors), if any */ | |
14241 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
14242 | if (afi == AFI_IP) | |
14243 | af_str = "IPv4"; | |
14244 | else if (afi == AFI_IP6) | |
14245 | af_str = "IPv6"; | |
14246 | else | |
14247 | af_str = "???"; | |
14248 | lr_count = listcount(group->listen_range[afi]); | |
14249 | if (lr_count) { | |
14250 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
14251 | af_str); | |
14252 | ||
14253 | ||
14254 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
2dbe669b DA |
14255 | nnode, range)) |
14256 | vty_out(vty, " %pFX\n", range); | |
d62a17ae | 14257 | } |
14258 | } | |
f14e6fdb | 14259 | |
d62a17ae | 14260 | /* Display group members and their status */ |
14261 | if (listcount(group->peer)) { | |
14262 | vty_out(vty, " Peer-group members:\n"); | |
14263 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
cb9196e7 DS |
14264 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
14265 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 14266 | peer_status = "Idle (Admin)"; |
14267 | else if (CHECK_FLAG(peer->sflags, | |
14268 | PEER_STATUS_PREFIX_OVERFLOW)) | |
14269 | peer_status = "Idle (PfxCt)"; | |
14270 | else | |
14271 | peer_status = lookup_msg(bgp_status_msg, | |
14272 | peer->status, NULL); | |
14273 | ||
14274 | dynamic = peer_dynamic_neighbor(peer); | |
14275 | vty_out(vty, " %s %s %s \n", peer->host, | |
14276 | dynamic ? "(dynamic)" : "", peer_status); | |
14277 | } | |
14278 | } | |
f14e6fdb | 14279 | |
d62a17ae | 14280 | return CMD_SUCCESS; |
14281 | } | |
14282 | ||
ff9959b0 QY |
14283 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
14284 | const char *group_name) | |
d62a17ae | 14285 | { |
ff9959b0 | 14286 | struct bgp *bgp; |
d62a17ae | 14287 | struct listnode *node, *nnode; |
14288 | struct peer_group *group; | |
ff9959b0 QY |
14289 | bool found = false; |
14290 | ||
14291 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
14292 | ||
14293 | if (!bgp) { | |
9f049418 | 14294 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
14295 | return CMD_WARNING; |
14296 | } | |
d62a17ae | 14297 | |
14298 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
14299 | if (group_name) { |
14300 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 14301 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
14302 | found = true; |
14303 | break; | |
d62a17ae | 14304 | } |
ff9959b0 QY |
14305 | } else { |
14306 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 14307 | } |
f14e6fdb | 14308 | } |
f14e6fdb | 14309 | |
ff9959b0 | 14310 | if (group_name && !found) |
d62a17ae | 14311 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 14312 | |
d62a17ae | 14313 | return CMD_SUCCESS; |
f14e6fdb DS |
14314 | } |
14315 | ||
f14e6fdb DS |
14316 | DEFUN (show_ip_bgp_peer_groups, |
14317 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 14318 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
14319 | SHOW_STR |
14320 | IP_STR | |
14321 | BGP_STR | |
8386ac43 | 14322 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
14323 | "Detailed information on BGP peer groups\n" |
14324 | "Peer group name\n") | |
f14e6fdb | 14325 | { |
d62a17ae | 14326 | char *vrf, *pg; |
d62a17ae | 14327 | int idx = 0; |
f14e6fdb | 14328 | |
a4d82a8a PZ |
14329 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
14330 | : NULL; | |
d62a17ae | 14331 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 14332 | |
ff9959b0 | 14333 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 14334 | } |
3f9c7369 | 14335 | |
d6e3c605 | 14336 | |
718e3744 | 14337 | /* Redistribute VTY commands. */ |
14338 | ||
718e3744 | 14339 | DEFUN (bgp_redistribute_ipv4, |
14340 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 14341 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 14342 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14343 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 14344 | { |
d62a17ae | 14345 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14346 | int idx_protocol = 1; | |
14347 | int type; | |
718e3744 | 14348 | |
d62a17ae | 14349 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
14350 | if (type < 0) { | |
14351 | vty_out(vty, "%% Invalid route type\n"); | |
14352 | return CMD_WARNING_CONFIG_FAILED; | |
14353 | } | |
7f323236 | 14354 | |
d62a17ae | 14355 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 14356 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 14357 | } |
14358 | ||
d62a17ae | 14359 | ALIAS_HIDDEN( |
14360 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
14361 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
14362 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 14363 | |
718e3744 | 14364 | DEFUN (bgp_redistribute_ipv4_rmap, |
14365 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 14366 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 14367 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14368 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 14369 | "Route map reference\n" |
14370 | "Pointer to route-map entries\n") | |
14371 | { | |
d62a17ae | 14372 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14373 | int idx_protocol = 1; | |
14374 | int idx_word = 3; | |
14375 | int type; | |
14376 | struct bgp_redist *red; | |
e923dd62 | 14377 | bool changed; |
1de27621 DA |
14378 | struct route_map *route_map = route_map_lookup_warn_noexist( |
14379 | vty, argv[idx_word]->arg); | |
718e3744 | 14380 | |
d62a17ae | 14381 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
14382 | if (type < 0) { | |
14383 | vty_out(vty, "%% Invalid route type\n"); | |
14384 | return CMD_WARNING_CONFIG_FAILED; | |
14385 | } | |
718e3744 | 14386 | |
d62a17ae | 14387 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
14388 | changed = |
14389 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14390 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 14391 | } |
14392 | ||
d62a17ae | 14393 | ALIAS_HIDDEN( |
14394 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
14395 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
14396 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14397 | "Route map reference\n" | |
14398 | "Pointer to route-map entries\n") | |
596c17ba | 14399 | |
718e3744 | 14400 | DEFUN (bgp_redistribute_ipv4_metric, |
14401 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 14402 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 14403 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14404 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 14405 | "Metric for redistributed routes\n" |
14406 | "Default metric\n") | |
14407 | { | |
d62a17ae | 14408 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14409 | int idx_protocol = 1; | |
14410 | int idx_number = 3; | |
14411 | int type; | |
d7c0a89a | 14412 | uint32_t metric; |
d62a17ae | 14413 | struct bgp_redist *red; |
e923dd62 | 14414 | bool changed; |
d62a17ae | 14415 | |
14416 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14417 | if (type < 0) { | |
14418 | vty_out(vty, "%% Invalid route type\n"); | |
14419 | return CMD_WARNING_CONFIG_FAILED; | |
14420 | } | |
14421 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
14422 | ||
14423 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 14424 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
14425 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 14426 | } |
14427 | ||
14428 | ALIAS_HIDDEN( | |
14429 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
14430 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
14431 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14432 | "Metric for redistributed routes\n" | |
14433 | "Default metric\n") | |
596c17ba | 14434 | |
718e3744 | 14435 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
14436 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 14437 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 14438 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14439 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 14440 | "Route map reference\n" |
14441 | "Pointer to route-map entries\n" | |
14442 | "Metric for redistributed routes\n" | |
14443 | "Default metric\n") | |
14444 | { | |
d62a17ae | 14445 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14446 | int idx_protocol = 1; | |
14447 | int idx_word = 3; | |
14448 | int idx_number = 5; | |
14449 | int type; | |
d7c0a89a | 14450 | uint32_t metric; |
d62a17ae | 14451 | struct bgp_redist *red; |
e923dd62 | 14452 | bool changed; |
1de27621 DA |
14453 | struct route_map *route_map = |
14454 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14455 | |
14456 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14457 | if (type < 0) { | |
14458 | vty_out(vty, "%% Invalid route type\n"); | |
14459 | return CMD_WARNING_CONFIG_FAILED; | |
14460 | } | |
14461 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
14462 | ||
14463 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
14464 | changed = |
14465 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14466 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
14467 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 14468 | } |
14469 | ||
14470 | ALIAS_HIDDEN( | |
14471 | bgp_redistribute_ipv4_rmap_metric, | |
14472 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
14473 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
14474 | " route-map WORD metric (0-4294967295)", | |
14475 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14476 | "Route map reference\n" | |
14477 | "Pointer to route-map entries\n" | |
14478 | "Metric for redistributed routes\n" | |
14479 | "Default metric\n") | |
596c17ba | 14480 | |
718e3744 | 14481 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
14482 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 14483 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14484 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14485 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 14486 | "Metric for redistributed routes\n" |
14487 | "Default metric\n" | |
14488 | "Route map reference\n" | |
14489 | "Pointer to route-map entries\n") | |
14490 | { | |
d62a17ae | 14491 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14492 | int idx_protocol = 1; | |
14493 | int idx_number = 3; | |
14494 | int idx_word = 5; | |
14495 | int type; | |
d7c0a89a | 14496 | uint32_t metric; |
d62a17ae | 14497 | struct bgp_redist *red; |
e923dd62 | 14498 | bool changed; |
1de27621 DA |
14499 | struct route_map *route_map = |
14500 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14501 | |
14502 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14503 | if (type < 0) { | |
14504 | vty_out(vty, "%% Invalid route type\n"); | |
14505 | return CMD_WARNING_CONFIG_FAILED; | |
14506 | } | |
14507 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
14508 | ||
14509 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 14510 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
14511 | changed |= |
14512 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14513 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 14514 | } |
14515 | ||
14516 | ALIAS_HIDDEN( | |
14517 | bgp_redistribute_ipv4_metric_rmap, | |
14518 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
14519 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
14520 | " metric (0-4294967295) route-map WORD", | |
14521 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14522 | "Metric for redistributed routes\n" | |
14523 | "Default metric\n" | |
14524 | "Route map reference\n" | |
14525 | "Pointer to route-map entries\n") | |
596c17ba | 14526 | |
7c8ff89e DS |
14527 | DEFUN (bgp_redistribute_ipv4_ospf, |
14528 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 14529 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
14530 | "Redistribute information from another routing protocol\n" |
14531 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14532 | "Non-main Kernel Routing Table\n" |
14533 | "Instance ID/Table ID\n") | |
7c8ff89e | 14534 | { |
d62a17ae | 14535 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14536 | int idx_ospf_table = 1; | |
14537 | int idx_number = 2; | |
d7c0a89a QY |
14538 | unsigned short instance; |
14539 | unsigned short protocol; | |
7c8ff89e | 14540 | |
d62a17ae | 14541 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 14542 | |
d62a17ae | 14543 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
14544 | protocol = ZEBRA_ROUTE_OSPF; | |
14545 | else | |
14546 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 14547 | |
d62a17ae | 14548 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 14549 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
14550 | } |
14551 | ||
d62a17ae | 14552 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
14553 | "redistribute <ospf|table> (1-65535)", | |
14554 | "Redistribute information from another routing protocol\n" | |
14555 | "Open Shortest Path First (OSPFv2)\n" | |
14556 | "Non-main Kernel Routing Table\n" | |
14557 | "Instance ID/Table ID\n") | |
596c17ba | 14558 | |
7c8ff89e DS |
14559 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
14560 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 14561 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
14562 | "Redistribute information from another routing protocol\n" |
14563 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14564 | "Non-main Kernel Routing Table\n" |
14565 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14566 | "Route map reference\n" |
14567 | "Pointer to route-map entries\n") | |
14568 | { | |
d62a17ae | 14569 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14570 | int idx_ospf_table = 1; | |
14571 | int idx_number = 2; | |
14572 | int idx_word = 4; | |
14573 | struct bgp_redist *red; | |
d7c0a89a | 14574 | unsigned short instance; |
d62a17ae | 14575 | int protocol; |
e923dd62 | 14576 | bool changed; |
1de27621 DA |
14577 | struct route_map *route_map = |
14578 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14579 | |
14580 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14581 | protocol = ZEBRA_ROUTE_OSPF; | |
14582 | else | |
14583 | protocol = ZEBRA_ROUTE_TABLE; | |
14584 | ||
14585 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14586 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
14587 | changed = |
14588 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14589 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 14590 | } |
14591 | ||
14592 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
14593 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
14594 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
14595 | "Redistribute information from another routing protocol\n" | |
14596 | "Open Shortest Path First (OSPFv2)\n" | |
14597 | "Non-main Kernel Routing Table\n" | |
14598 | "Instance ID/Table ID\n" | |
14599 | "Route map reference\n" | |
14600 | "Pointer to route-map entries\n") | |
596c17ba | 14601 | |
7c8ff89e DS |
14602 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
14603 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 14604 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
14605 | "Redistribute information from another routing protocol\n" |
14606 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14607 | "Non-main Kernel Routing Table\n" |
14608 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14609 | "Metric for redistributed routes\n" |
14610 | "Default metric\n") | |
14611 | { | |
d62a17ae | 14612 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14613 | int idx_ospf_table = 1; | |
14614 | int idx_number = 2; | |
14615 | int idx_number_2 = 4; | |
d7c0a89a | 14616 | uint32_t metric; |
d62a17ae | 14617 | struct bgp_redist *red; |
d7c0a89a | 14618 | unsigned short instance; |
d62a17ae | 14619 | int protocol; |
e923dd62 | 14620 | bool changed; |
d62a17ae | 14621 | |
14622 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14623 | protocol = ZEBRA_ROUTE_OSPF; | |
14624 | else | |
14625 | protocol = ZEBRA_ROUTE_TABLE; | |
14626 | ||
14627 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14628 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14629 | ||
14630 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 14631 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14632 | metric); | |
14633 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 14634 | } |
14635 | ||
14636 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
14637 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
14638 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
14639 | "Redistribute information from another routing protocol\n" | |
14640 | "Open Shortest Path First (OSPFv2)\n" | |
14641 | "Non-main Kernel Routing Table\n" | |
14642 | "Instance ID/Table ID\n" | |
14643 | "Metric for redistributed routes\n" | |
14644 | "Default metric\n") | |
596c17ba | 14645 | |
7c8ff89e DS |
14646 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
14647 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 14648 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
14649 | "Redistribute information from another routing protocol\n" |
14650 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14651 | "Non-main Kernel Routing Table\n" |
14652 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14653 | "Route map reference\n" |
14654 | "Pointer to route-map entries\n" | |
14655 | "Metric for redistributed routes\n" | |
14656 | "Default metric\n") | |
14657 | { | |
d62a17ae | 14658 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14659 | int idx_ospf_table = 1; | |
14660 | int idx_number = 2; | |
14661 | int idx_word = 4; | |
14662 | int idx_number_2 = 6; | |
d7c0a89a | 14663 | uint32_t metric; |
d62a17ae | 14664 | struct bgp_redist *red; |
d7c0a89a | 14665 | unsigned short instance; |
d62a17ae | 14666 | int protocol; |
e923dd62 | 14667 | bool changed; |
1de27621 DA |
14668 | struct route_map *route_map = |
14669 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14670 | |
14671 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14672 | protocol = ZEBRA_ROUTE_OSPF; | |
14673 | else | |
14674 | protocol = ZEBRA_ROUTE_TABLE; | |
14675 | ||
14676 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14677 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14678 | ||
14679 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
14680 | changed = |
14681 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14682 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14683 | metric); | |
14684 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 14685 | } |
14686 | ||
14687 | ALIAS_HIDDEN( | |
14688 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
14689 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
14690 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
14691 | "Redistribute information from another routing protocol\n" | |
14692 | "Open Shortest Path First (OSPFv2)\n" | |
14693 | "Non-main Kernel Routing Table\n" | |
14694 | "Instance ID/Table ID\n" | |
14695 | "Route map reference\n" | |
14696 | "Pointer to route-map entries\n" | |
14697 | "Metric for redistributed routes\n" | |
14698 | "Default metric\n") | |
596c17ba | 14699 | |
7c8ff89e DS |
14700 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
14701 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 14702 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
14703 | "Redistribute information from another routing protocol\n" |
14704 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14705 | "Non-main Kernel Routing Table\n" |
14706 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14707 | "Metric for redistributed routes\n" |
14708 | "Default metric\n" | |
14709 | "Route map reference\n" | |
14710 | "Pointer to route-map entries\n") | |
14711 | { | |
d62a17ae | 14712 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14713 | int idx_ospf_table = 1; | |
14714 | int idx_number = 2; | |
14715 | int idx_number_2 = 4; | |
14716 | int idx_word = 6; | |
d7c0a89a | 14717 | uint32_t metric; |
d62a17ae | 14718 | struct bgp_redist *red; |
d7c0a89a | 14719 | unsigned short instance; |
d62a17ae | 14720 | int protocol; |
e923dd62 | 14721 | bool changed; |
1de27621 DA |
14722 | struct route_map *route_map = |
14723 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14724 | |
14725 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14726 | protocol = ZEBRA_ROUTE_OSPF; | |
14727 | else | |
14728 | protocol = ZEBRA_ROUTE_TABLE; | |
14729 | ||
14730 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14731 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14732 | ||
14733 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 14734 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14735 | metric); | |
1de27621 DA |
14736 | changed |= |
14737 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14738 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 14739 | } |
14740 | ||
14741 | ALIAS_HIDDEN( | |
14742 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
14743 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
14744 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
14745 | "Redistribute information from another routing protocol\n" | |
14746 | "Open Shortest Path First (OSPFv2)\n" | |
14747 | "Non-main Kernel Routing Table\n" | |
14748 | "Instance ID/Table ID\n" | |
14749 | "Metric for redistributed routes\n" | |
14750 | "Default metric\n" | |
14751 | "Route map reference\n" | |
14752 | "Pointer to route-map entries\n") | |
596c17ba | 14753 | |
7c8ff89e DS |
14754 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
14755 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 14756 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
14757 | NO_STR |
14758 | "Redistribute information from another routing protocol\n" | |
14759 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 14760 | "Non-main Kernel Routing Table\n" |
31500417 DW |
14761 | "Instance ID/Table ID\n" |
14762 | "Metric for redistributed routes\n" | |
14763 | "Default metric\n" | |
14764 | "Route map reference\n" | |
14765 | "Pointer to route-map entries\n") | |
7c8ff89e | 14766 | { |
d62a17ae | 14767 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14768 | int idx_ospf_table = 2; | |
14769 | int idx_number = 3; | |
d7c0a89a | 14770 | unsigned short instance; |
d62a17ae | 14771 | int protocol; |
14772 | ||
14773 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14774 | protocol = ZEBRA_ROUTE_OSPF; | |
14775 | else | |
14776 | protocol = ZEBRA_ROUTE_TABLE; | |
14777 | ||
14778 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14779 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
14780 | } | |
14781 | ||
14782 | ALIAS_HIDDEN( | |
14783 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 14784 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14785 | NO_STR |
14786 | "Redistribute information from another routing protocol\n" | |
14787 | "Open Shortest Path First (OSPFv2)\n" | |
14788 | "Non-main Kernel Routing Table\n" | |
14789 | "Instance ID/Table ID\n" | |
14790 | "Metric for redistributed routes\n" | |
14791 | "Default metric\n" | |
14792 | "Route map reference\n" | |
14793 | "Pointer to route-map entries\n") | |
596c17ba | 14794 | |
718e3744 | 14795 | DEFUN (no_bgp_redistribute_ipv4, |
14796 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 14797 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14798 | NO_STR |
14799 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14800 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
14801 | "Metric for redistributed routes\n" |
14802 | "Default metric\n" | |
14803 | "Route map reference\n" | |
14804 | "Pointer to route-map entries\n") | |
718e3744 | 14805 | { |
d62a17ae | 14806 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14807 | int idx_protocol = 2; | |
14808 | int type; | |
14809 | ||
14810 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14811 | if (type < 0) { | |
14812 | vty_out(vty, "%% Invalid route type\n"); | |
14813 | return CMD_WARNING_CONFIG_FAILED; | |
14814 | } | |
14815 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
14816 | } | |
14817 | ||
14818 | ALIAS_HIDDEN( | |
14819 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
14820 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 14821 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14822 | NO_STR |
14823 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14824 | "Metric for redistributed routes\n" | |
14825 | "Default metric\n" | |
14826 | "Route map reference\n" | |
14827 | "Pointer to route-map entries\n") | |
596c17ba | 14828 | |
718e3744 | 14829 | DEFUN (bgp_redistribute_ipv6, |
14830 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 14831 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 14832 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14833 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 14834 | { |
d62a17ae | 14835 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14836 | int idx_protocol = 1; | |
14837 | int type; | |
718e3744 | 14838 | |
d62a17ae | 14839 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14840 | if (type < 0) { | |
14841 | vty_out(vty, "%% Invalid route type\n"); | |
14842 | return CMD_WARNING_CONFIG_FAILED; | |
14843 | } | |
718e3744 | 14844 | |
d62a17ae | 14845 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14846 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 14847 | } |
14848 | ||
14849 | DEFUN (bgp_redistribute_ipv6_rmap, | |
14850 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 14851 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 14852 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14853 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14854 | "Route map reference\n" |
14855 | "Pointer to route-map entries\n") | |
14856 | { | |
d62a17ae | 14857 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14858 | int idx_protocol = 1; | |
14859 | int idx_word = 3; | |
14860 | int type; | |
14861 | struct bgp_redist *red; | |
e923dd62 | 14862 | bool changed; |
1de27621 DA |
14863 | struct route_map *route_map = |
14864 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 14865 | |
d62a17ae | 14866 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14867 | if (type < 0) { | |
14868 | vty_out(vty, "%% Invalid route type\n"); | |
14869 | return CMD_WARNING_CONFIG_FAILED; | |
14870 | } | |
718e3744 | 14871 | |
d62a17ae | 14872 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14873 | changed = |
14874 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14875 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14876 | } |
14877 | ||
14878 | DEFUN (bgp_redistribute_ipv6_metric, | |
14879 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 14880 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 14881 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14882 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14883 | "Metric for redistributed routes\n" |
14884 | "Default metric\n") | |
14885 | { | |
d62a17ae | 14886 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14887 | int idx_protocol = 1; | |
14888 | int idx_number = 3; | |
14889 | int type; | |
d7c0a89a | 14890 | uint32_t metric; |
d62a17ae | 14891 | struct bgp_redist *red; |
e923dd62 | 14892 | bool changed; |
d62a17ae | 14893 | |
14894 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14895 | if (type < 0) { | |
14896 | vty_out(vty, "%% Invalid route type\n"); | |
14897 | return CMD_WARNING_CONFIG_FAILED; | |
14898 | } | |
14899 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14900 | |
d62a17ae | 14901 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14902 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
14903 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14904 | } |
14905 | ||
14906 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
14907 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 14908 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 14909 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14910 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14911 | "Route map reference\n" |
14912 | "Pointer to route-map entries\n" | |
14913 | "Metric for redistributed routes\n" | |
14914 | "Default metric\n") | |
14915 | { | |
d62a17ae | 14916 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14917 | int idx_protocol = 1; | |
14918 | int idx_word = 3; | |
14919 | int idx_number = 5; | |
14920 | int type; | |
d7c0a89a | 14921 | uint32_t metric; |
d62a17ae | 14922 | struct bgp_redist *red; |
e923dd62 | 14923 | bool changed; |
1de27621 DA |
14924 | struct route_map *route_map = |
14925 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14926 | |
14927 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14928 | if (type < 0) { | |
14929 | vty_out(vty, "%% Invalid route type\n"); | |
14930 | return CMD_WARNING_CONFIG_FAILED; | |
14931 | } | |
14932 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14933 | |
d62a17ae | 14934 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14935 | changed = |
14936 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14937 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
14938 | metric); | |
14939 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14940 | } |
14941 | ||
14942 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
14943 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 14944 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14945 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14946 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14947 | "Metric for redistributed routes\n" |
14948 | "Default metric\n" | |
14949 | "Route map reference\n" | |
14950 | "Pointer to route-map entries\n") | |
14951 | { | |
d62a17ae | 14952 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14953 | int idx_protocol = 1; | |
14954 | int idx_number = 3; | |
14955 | int idx_word = 5; | |
14956 | int type; | |
d7c0a89a | 14957 | uint32_t metric; |
d62a17ae | 14958 | struct bgp_redist *red; |
e923dd62 | 14959 | bool changed; |
1de27621 DA |
14960 | struct route_map *route_map = |
14961 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14962 | |
14963 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14964 | if (type < 0) { | |
14965 | vty_out(vty, "%% Invalid route type\n"); | |
14966 | return CMD_WARNING_CONFIG_FAILED; | |
14967 | } | |
14968 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14969 | |
d62a17ae | 14970 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14971 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
14972 | metric); | |
1de27621 DA |
14973 | changed |= |
14974 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14975 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14976 | } |
14977 | ||
14978 | DEFUN (no_bgp_redistribute_ipv6, | |
14979 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 14980 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14981 | NO_STR |
14982 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14983 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
14984 | "Metric for redistributed routes\n" |
14985 | "Default metric\n" | |
14986 | "Route map reference\n" | |
14987 | "Pointer to route-map entries\n") | |
718e3744 | 14988 | { |
d62a17ae | 14989 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14990 | int idx_protocol = 2; | |
14991 | int type; | |
718e3744 | 14992 | |
d62a17ae | 14993 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14994 | if (type < 0) { | |
14995 | vty_out(vty, "%% Invalid route type\n"); | |
14996 | return CMD_WARNING_CONFIG_FAILED; | |
14997 | } | |
718e3744 | 14998 | |
d62a17ae | 14999 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
15000 | } | |
15001 | ||
dd65f45e DL |
15002 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
15003 | afi_t afi, safi_t safi) | |
d62a17ae | 15004 | { |
15005 | int i; | |
15006 | ||
15007 | /* Unicast redistribution only. */ | |
15008 | if (safi != SAFI_UNICAST) | |
2b791107 | 15009 | return; |
d62a17ae | 15010 | |
15011 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
15012 | /* Redistribute BGP does not make sense. */ | |
15013 | if (i != ZEBRA_ROUTE_BGP) { | |
15014 | struct list *red_list; | |
15015 | struct listnode *node; | |
15016 | struct bgp_redist *red; | |
15017 | ||
15018 | red_list = bgp->redist[afi][i]; | |
15019 | if (!red_list) | |
15020 | continue; | |
15021 | ||
15022 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 15023 | /* "redistribute" configuration. */ |
15024 | vty_out(vty, " redistribute %s", | |
15025 | zebra_route_string(i)); | |
15026 | if (red->instance) | |
15027 | vty_out(vty, " %d", red->instance); | |
15028 | if (red->redist_metric_flag) | |
15029 | vty_out(vty, " metric %u", | |
15030 | red->redist_metric); | |
15031 | if (red->rmap.name) | |
15032 | vty_out(vty, " route-map %s", | |
15033 | red->rmap.name); | |
15034 | vty_out(vty, "\n"); | |
15035 | } | |
15036 | } | |
15037 | } | |
718e3744 | 15038 | } |
6b0655a2 | 15039 | |
dd65f45e DL |
15040 | /* peer-group helpers for config-write */ |
15041 | ||
15042 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
15043 | { | |
15044 | if (!peer_group_active(peer)) { | |
15045 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
15046 | return !CHECK_FLAG(peer->flags, flag); | |
15047 | else | |
15048 | return !!CHECK_FLAG(peer->flags, flag); | |
15049 | } | |
15050 | ||
15051 | return !!CHECK_FLAG(peer->flags_override, flag); | |
15052 | } | |
15053 | ||
15054 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
15055 | uint32_t flag) | |
15056 | { | |
15057 | if (!peer_group_active(peer)) { | |
15058 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
15059 | return !peer_af_flag_check(peer, afi, safi, flag); | |
15060 | else | |
15061 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
15062 | } | |
15063 | ||
15064 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
15065 | } | |
15066 | ||
15067 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
15068 | uint8_t type, int direct) | |
15069 | { | |
15070 | struct bgp_filter *filter; | |
15071 | ||
15072 | if (peer_group_active(peer)) | |
15073 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
15074 | type); | |
15075 | ||
15076 | filter = &peer->filter[afi][safi]; | |
15077 | switch (type) { | |
15078 | case PEER_FT_DISTRIBUTE_LIST: | |
15079 | return !!(filter->dlist[direct].name); | |
15080 | case PEER_FT_FILTER_LIST: | |
15081 | return !!(filter->aslist[direct].name); | |
15082 | case PEER_FT_PREFIX_LIST: | |
15083 | return !!(filter->plist[direct].name); | |
15084 | case PEER_FT_ROUTE_MAP: | |
15085 | return !!(filter->map[direct].name); | |
15086 | case PEER_FT_UNSUPPRESS_MAP: | |
15087 | return !!(filter->usmap.name); | |
7f7940e6 MK |
15088 | case PEER_FT_ADVERTISE_MAP: |
15089 | return !!(filter->advmap.aname | |
15090 | && ((filter->advmap.condition == direct) | |
15091 | && filter->advmap.cname)); | |
dd65f45e DL |
15092 | default: |
15093 | return false; | |
15094 | } | |
15095 | } | |
15096 | ||
15097 | /* Return true if the addpath type is set for peer and different from | |
15098 | * peer-group. | |
15099 | */ | |
3dc339cd DA |
15100 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
15101 | safi_t safi) | |
dd65f45e DL |
15102 | { |
15103 | enum bgp_addpath_strat type, g_type; | |
15104 | ||
15105 | type = peer->addpath_type[afi][safi]; | |
15106 | ||
15107 | if (type != BGP_ADDPATH_NONE) { | |
15108 | if (peer_group_active(peer)) { | |
15109 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
15110 | ||
15111 | if (type != g_type) | |
3dc339cd | 15112 | return true; |
dd65f45e | 15113 | else |
3dc339cd | 15114 | return false; |
dd65f45e DL |
15115 | } |
15116 | ||
3dc339cd | 15117 | return true; |
dd65f45e DL |
15118 | } |
15119 | ||
3dc339cd | 15120 | return false; |
dd65f45e DL |
15121 | } |
15122 | ||
b9c7bc5a | 15123 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 15124 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
15125 | afi_t afi) |
15126 | { | |
b9c7bc5a | 15127 | int indent = 2; |
ddb5b488 | 15128 | |
8a066a70 | 15129 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
15130 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
15131 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
15132 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
15133 | bgp->vpn_policy[afi] | |
bb4f6190 | 15134 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
15135 | else |
15136 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
15137 | bgp->vpn_policy[afi] | |
15138 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
15139 | } | |
12a844a5 DS |
15140 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
15141 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
15142 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
15143 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
15144 | return; | |
15145 | ||
e70e9f8e PZ |
15146 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
15147 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
15148 | ||
15149 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
15150 | ||
15151 | } else { | |
15152 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
15153 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
15154 | bgp->vpn_policy[afi].tovpn_label); | |
15155 | } | |
ddb5b488 PZ |
15156 | } |
15157 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
15158 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
15159 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 15160 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
15161 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
15162 | sizeof(buf))); | |
15163 | } | |
15164 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
15165 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
15166 | ||
15167 | char buf[PREFIX_STRLEN]; | |
15168 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
15169 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
15170 | sizeof(buf))) { | |
15171 | ||
b9c7bc5a PZ |
15172 | vty_out(vty, "%*snexthop vpn export %s\n", |
15173 | indent, "", buf); | |
ddb5b488 PZ |
15174 | } |
15175 | } | |
15176 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
15177 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
15178 | && ecommunity_cmp( | |
15179 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
15180 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
15181 | ||
15182 | char *b = ecommunity_ecom2str( | |
15183 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
15184 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 15185 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
15186 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
15187 | } else { | |
15188 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
15189 | char *b = ecommunity_ecom2str( | |
15190 | bgp->vpn_policy[afi] | |
15191 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
15192 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
15193 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 15194 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
15195 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
15196 | } | |
15197 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
15198 | char *b = ecommunity_ecom2str( | |
15199 | bgp->vpn_policy[afi] | |
15200 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
15201 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
15202 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 15203 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
15204 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
15205 | } | |
15206 | } | |
bb4f6190 DS |
15207 | |
15208 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 15209 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
15210 | bgp->vpn_policy[afi] |
15211 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 15212 | |
301ad80a PG |
15213 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
15214 | char *b = ecommunity_ecom2str( | |
15215 | bgp->vpn_policy[afi] | |
15216 | .import_redirect_rtlist, | |
15217 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
15218 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 15219 | |
9a659715 PG |
15220 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
15221 | != ECOMMUNITY_SIZE) | |
c6423c31 | 15222 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
15223 | indent, "", b); |
15224 | else | |
15225 | vty_out(vty, "%*srt redirect import %s\n", | |
15226 | indent, "", b); | |
301ad80a PG |
15227 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
15228 | } | |
ddb5b488 PZ |
15229 | } |
15230 | ||
dd65f45e DL |
15231 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
15232 | afi_t afi, safi_t safi) | |
15233 | { | |
15234 | struct bgp_filter *filter; | |
15235 | char *addr; | |
15236 | ||
15237 | addr = peer->host; | |
15238 | filter = &peer->filter[afi][safi]; | |
15239 | ||
15240 | /* distribute-list. */ | |
15241 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
15242 | FILTER_IN)) | |
15243 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
15244 | filter->dlist[FILTER_IN].name); | |
15245 | ||
15246 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
15247 | FILTER_OUT)) | |
15248 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
15249 | filter->dlist[FILTER_OUT].name); | |
15250 | ||
15251 | /* prefix-list. */ | |
15252 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
15253 | FILTER_IN)) | |
15254 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
15255 | filter->plist[FILTER_IN].name); | |
15256 | ||
15257 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
15258 | FILTER_OUT)) | |
15259 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
15260 | filter->plist[FILTER_OUT].name); | |
15261 | ||
15262 | /* route-map. */ | |
15263 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
15264 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
15265 | filter->map[RMAP_IN].name); | |
15266 | ||
15267 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
15268 | RMAP_OUT)) | |
15269 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
15270 | filter->map[RMAP_OUT].name); | |
15271 | ||
15272 | /* unsuppress-map */ | |
15273 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
15274 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
15275 | filter->usmap.name); | |
15276 | ||
7f7940e6 MK |
15277 | /* advertise-map : always applied in OUT direction*/ |
15278 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
15279 | CONDITION_NON_EXIST)) | |
15280 | vty_out(vty, | |
15281 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
15282 | addr, filter->advmap.aname, filter->advmap.cname); | |
15283 | ||
15284 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
15285 | CONDITION_EXIST)) | |
15286 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
15287 | addr, filter->advmap.aname, filter->advmap.cname); | |
15288 | ||
dd65f45e DL |
15289 | /* filter-list. */ |
15290 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
15291 | FILTER_IN)) | |
15292 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
15293 | filter->aslist[FILTER_IN].name); | |
15294 | ||
15295 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
15296 | FILTER_OUT)) | |
15297 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
15298 | filter->aslist[FILTER_OUT].name); | |
15299 | } | |
15300 | ||
15301 | /* BGP peer configuration display function. */ | |
15302 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
15303 | struct peer *peer) | |
15304 | { | |
15305 | struct peer *g_peer = NULL; | |
15306 | char buf[SU_ADDRSTRLEN]; | |
15307 | char *addr; | |
15308 | int if_pg_printed = false; | |
15309 | int if_ras_printed = false; | |
15310 | ||
15311 | /* Skip dynamic neighbors. */ | |
15312 | if (peer_dynamic_neighbor(peer)) | |
15313 | return; | |
15314 | ||
15315 | if (peer->conf_if) | |
15316 | addr = peer->conf_if; | |
15317 | else | |
15318 | addr = peer->host; | |
15319 | ||
15320 | /************************************ | |
15321 | ****** Global to the neighbor ****** | |
15322 | ************************************/ | |
15323 | if (peer->conf_if) { | |
15324 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
15325 | vty_out(vty, " neighbor %s interface v6only", addr); | |
15326 | else | |
15327 | vty_out(vty, " neighbor %s interface", addr); | |
15328 | ||
15329 | if (peer_group_active(peer)) { | |
15330 | vty_out(vty, " peer-group %s", peer->group->name); | |
15331 | if_pg_printed = true; | |
15332 | } else if (peer->as_type == AS_SPECIFIED) { | |
15333 | vty_out(vty, " remote-as %u", peer->as); | |
15334 | if_ras_printed = true; | |
15335 | } else if (peer->as_type == AS_INTERNAL) { | |
15336 | vty_out(vty, " remote-as internal"); | |
15337 | if_ras_printed = true; | |
15338 | } else if (peer->as_type == AS_EXTERNAL) { | |
15339 | vty_out(vty, " remote-as external"); | |
15340 | if_ras_printed = true; | |
15341 | } | |
15342 | ||
15343 | vty_out(vty, "\n"); | |
15344 | } | |
15345 | ||
15346 | /* remote-as and peer-group */ | |
15347 | /* peer is a member of a peer-group */ | |
15348 | if (peer_group_active(peer)) { | |
15349 | g_peer = peer->group->conf; | |
15350 | ||
15351 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
15352 | if (peer->as_type == AS_SPECIFIED) { | |
15353 | vty_out(vty, " neighbor %s remote-as %u\n", | |
15354 | addr, peer->as); | |
15355 | } else if (peer->as_type == AS_INTERNAL) { | |
15356 | vty_out(vty, | |
15357 | " neighbor %s remote-as internal\n", | |
15358 | addr); | |
15359 | } else if (peer->as_type == AS_EXTERNAL) { | |
15360 | vty_out(vty, | |
15361 | " neighbor %s remote-as external\n", | |
15362 | addr); | |
15363 | } | |
15364 | } | |
15365 | ||
15366 | /* For swpX peers we displayed the peer-group | |
15367 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
15368 | if (!if_pg_printed) | |
15369 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
15370 | peer->group->name); | |
15371 | } | |
15372 | ||
15373 | /* peer is NOT a member of a peer-group */ | |
15374 | else { | |
15375 | /* peer is a peer-group, declare the peer-group */ | |
15376 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
15377 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
15378 | } | |
15379 | ||
15380 | if (!if_ras_printed) { | |
15381 | if (peer->as_type == AS_SPECIFIED) { | |
15382 | vty_out(vty, " neighbor %s remote-as %u\n", | |
15383 | addr, peer->as); | |
15384 | } else if (peer->as_type == AS_INTERNAL) { | |
15385 | vty_out(vty, | |
15386 | " neighbor %s remote-as internal\n", | |
15387 | addr); | |
15388 | } else if (peer->as_type == AS_EXTERNAL) { | |
15389 | vty_out(vty, | |
15390 | " neighbor %s remote-as external\n", | |
15391 | addr); | |
15392 | } | |
15393 | } | |
15394 | } | |
15395 | ||
15396 | /* local-as */ | |
15397 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
15398 | vty_out(vty, " neighbor %s local-as %u", addr, | |
15399 | peer->change_local_as); | |
15400 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
15401 | vty_out(vty, " no-prepend"); | |
15402 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
15403 | vty_out(vty, " replace-as"); | |
15404 | vty_out(vty, "\n"); | |
15405 | } | |
15406 | ||
15407 | /* description */ | |
15408 | if (peer->desc) { | |
15409 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
15410 | } | |
15411 | ||
15412 | /* shutdown */ | |
15413 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
15414 | if (peer->tx_shutdown_message) | |
15415 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
15416 | peer->tx_shutdown_message); | |
15417 | else | |
15418 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
15419 | } | |
15420 | ||
8336c896 DA |
15421 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
15422 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
15423 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
15424 | ||
dd65f45e DL |
15425 | /* bfd */ |
15426 | if (peer->bfd_info) { | |
15427 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
15428 | bgp_bfd_peer_config_write(vty, peer, addr); | |
15429 | } | |
15430 | } | |
15431 | ||
15432 | /* password */ | |
15433 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
15434 | vty_out(vty, " neighbor %s password %s\n", addr, | |
15435 | peer->password); | |
15436 | ||
15437 | /* neighbor solo */ | |
15438 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
15439 | if (!peer_group_active(peer)) { | |
15440 | vty_out(vty, " neighbor %s solo\n", addr); | |
15441 | } | |
15442 | } | |
15443 | ||
15444 | /* BGP port */ | |
15445 | if (peer->port != BGP_PORT_DEFAULT) { | |
15446 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
15447 | } | |
15448 | ||
15449 | /* Local interface name */ | |
15450 | if (peer->ifname) { | |
15451 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
15452 | } | |
15453 | ||
15454 | /* passive */ | |
15455 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
15456 | vty_out(vty, " neighbor %s passive\n", addr); | |
15457 | ||
15458 | /* ebgp-multihop */ | |
15459 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
15460 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
15461 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
15462 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
15463 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
15464 | peer->ttl); | |
15465 | } | |
15466 | } | |
15467 | ||
15468 | /* ttl-security hops */ | |
e2521429 | 15469 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
15470 | if (!peer_group_active(peer) |
15471 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
15472 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
15473 | addr, peer->gtsm_hops); | |
15474 | } | |
15475 | } | |
15476 | ||
15477 | /* disable-connected-check */ | |
15478 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
15479 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
15480 | ||
15481 | /* enforce-first-as */ | |
15482 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
15483 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
15484 | ||
15485 | /* update-source */ | |
15486 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
15487 | if (peer->update_source) | |
15488 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
15489 | sockunion2str(peer->update_source, buf, | |
15490 | SU_ADDRSTRLEN)); | |
15491 | else if (peer->update_if) | |
15492 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
15493 | peer->update_if); | |
15494 | } | |
15495 | ||
15496 | /* advertisement-interval */ | |
15497 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
15498 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
15499 | peer->routeadv); | |
15500 | ||
15501 | /* timers */ | |
15502 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
15503 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
15504 | peer->keepalive, peer->holdtime); | |
15505 | ||
15506 | /* timers connect */ | |
15507 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
15508 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
15509 | peer->connect); | |
5d5393b9 DL |
15510 | /* need special-case handling for changed default values due to |
15511 | * config profile / version (because there is no "timers bgp connect" | |
15512 | * command, we need to save this per-peer :/) | |
15513 | */ | |
15514 | else if (!peer_group_active(peer) && !peer->connect && | |
15515 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
15516 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
15517 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
15518 | |
15519 | /* capability dynamic */ | |
15520 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
15521 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
15522 | ||
15523 | /* capability extended-nexthop */ | |
15524 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
15525 | if (!peer->conf_if) { | |
15526 | if (CHECK_FLAG(peer->flags_invert, | |
15527 | PEER_FLAG_CAPABILITY_ENHE)) | |
15528 | vty_out(vty, | |
15529 | " no neighbor %s capability extended-nexthop\n", | |
15530 | addr); | |
15531 | else | |
15532 | vty_out(vty, | |
15533 | " neighbor %s capability extended-nexthop\n", | |
15534 | addr); | |
15535 | } | |
15536 | } | |
15537 | ||
15538 | /* dont-capability-negotiation */ | |
15539 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
15540 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
15541 | ||
15542 | /* override-capability */ | |
15543 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
15544 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
15545 | ||
15546 | /* strict-capability-match */ | |
15547 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
15548 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
15549 | ||
15550 | /* Sender side AS path loop detection. */ | |
15551 | if (peer->as_path_loop_detection) | |
15552 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
15553 | addr); | |
cfd47646 | 15554 | |
15555 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 15556 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 15557 | |
15558 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 15559 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 15560 | vty_out(vty, |
15561 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
15562 | } else if (CHECK_FLAG( |
15563 | peer->peer_gr_new_status_flag, | |
15564 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 15565 | vty_out(vty, |
15566 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
15567 | } else if ( |
15568 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
15569 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
15570 | && !(CHECK_FLAG( | |
15571 | peer->peer_gr_new_status_flag, | |
15572 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
15573 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
15574 | addr); | |
cfd47646 | 15575 | } |
15576 | } | |
dd65f45e DL |
15577 | } |
15578 | ||
15579 | /* BGP peer configuration display function. */ | |
15580 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
15581 | struct peer *peer, afi_t afi, safi_t safi) | |
15582 | { | |
15583 | struct peer *g_peer = NULL; | |
15584 | char *addr; | |
15585 | bool flag_scomm, flag_secomm, flag_slcomm; | |
15586 | ||
15587 | /* Skip dynamic neighbors. */ | |
15588 | if (peer_dynamic_neighbor(peer)) | |
15589 | return; | |
15590 | ||
15591 | if (peer->conf_if) | |
15592 | addr = peer->conf_if; | |
15593 | else | |
15594 | addr = peer->host; | |
15595 | ||
15596 | /************************************ | |
15597 | ****** Per AF to the neighbor ****** | |
15598 | ************************************/ | |
15599 | if (peer_group_active(peer)) { | |
15600 | g_peer = peer->group->conf; | |
15601 | ||
15602 | /* If the peer-group is active but peer is not, print a 'no | |
15603 | * activate' */ | |
15604 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
15605 | vty_out(vty, " no neighbor %s activate\n", addr); | |
15606 | } | |
15607 | ||
15608 | /* If the peer-group is not active but peer is, print an | |
15609 | 'activate' */ | |
15610 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
15611 | vty_out(vty, " neighbor %s activate\n", addr); | |
15612 | } | |
15613 | } else { | |
15614 | if (peer->afc[afi][safi]) { | |
15615 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
15616 | if (CHECK_FLAG(bgp->flags, |
15617 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
15618 | vty_out(vty, " neighbor %s activate\n", |
15619 | addr); | |
15620 | } | |
15621 | } else | |
15622 | vty_out(vty, " neighbor %s activate\n", addr); | |
15623 | } else { | |
15624 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
15625 | if (!CHECK_FLAG(bgp->flags, |
15626 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
15627 | vty_out(vty, |
15628 | " no neighbor %s activate\n", | |
15629 | addr); | |
15630 | } | |
15631 | } | |
15632 | } | |
15633 | } | |
15634 | ||
15635 | /* addpath TX knobs */ | |
15636 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
15637 | switch (peer->addpath_type[afi][safi]) { | |
15638 | case BGP_ADDPATH_ALL: | |
15639 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
15640 | addr); | |
15641 | break; | |
15642 | case BGP_ADDPATH_BEST_PER_AS: | |
15643 | vty_out(vty, | |
15644 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
15645 | addr); | |
15646 | break; | |
15647 | case BGP_ADDPATH_MAX: | |
15648 | case BGP_ADDPATH_NONE: | |
15649 | break; | |
15650 | } | |
15651 | } | |
15652 | ||
15653 | /* ORF capability. */ | |
15654 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
15655 | || peergroup_af_flag_check(peer, afi, safi, | |
15656 | PEER_FLAG_ORF_PREFIX_RM)) { | |
15657 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
15658 | ||
15659 | if (peergroup_af_flag_check(peer, afi, safi, | |
15660 | PEER_FLAG_ORF_PREFIX_SM) | |
15661 | && peergroup_af_flag_check(peer, afi, safi, | |
15662 | PEER_FLAG_ORF_PREFIX_RM)) | |
15663 | vty_out(vty, " both"); | |
15664 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15665 | PEER_FLAG_ORF_PREFIX_SM)) | |
15666 | vty_out(vty, " send"); | |
15667 | else | |
15668 | vty_out(vty, " receive"); | |
15669 | vty_out(vty, "\n"); | |
15670 | } | |
15671 | ||
dd65f45e DL |
15672 | /* Route reflector client. */ |
15673 | if (peergroup_af_flag_check(peer, afi, safi, | |
15674 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
15675 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
15676 | } | |
15677 | ||
15678 | /* next-hop-self force */ | |
15679 | if (peergroup_af_flag_check(peer, afi, safi, | |
15680 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
15681 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
15682 | } | |
15683 | ||
15684 | /* next-hop-self */ | |
15685 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
15686 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
15687 | } | |
15688 | ||
15689 | /* remove-private-AS */ | |
15690 | if (peergroup_af_flag_check(peer, afi, safi, | |
15691 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
15692 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
15693 | addr); | |
15694 | } | |
15695 | ||
15696 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15697 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
15698 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
15699 | addr); | |
15700 | } | |
15701 | ||
15702 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15703 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
15704 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
15705 | } | |
15706 | ||
15707 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15708 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
15709 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
15710 | } | |
15711 | ||
15712 | /* as-override */ | |
15713 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
15714 | vty_out(vty, " neighbor %s as-override\n", addr); | |
15715 | } | |
15716 | ||
15717 | /* send-community print. */ | |
15718 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
15719 | PEER_FLAG_SEND_COMMUNITY); | |
15720 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
15721 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
15722 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
15723 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
15724 | ||
15725 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
15726 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
15727 | } else { | |
15728 | if (flag_scomm) | |
15729 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
15730 | if (flag_secomm) | |
15731 | vty_out(vty, | |
15732 | " no neighbor %s send-community extended\n", | |
15733 | addr); | |
15734 | ||
15735 | if (flag_slcomm) | |
15736 | vty_out(vty, " no neighbor %s send-community large\n", | |
15737 | addr); | |
15738 | } | |
15739 | ||
15740 | /* Default information */ | |
15741 | if (peergroup_af_flag_check(peer, afi, safi, | |
15742 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
15743 | vty_out(vty, " neighbor %s default-originate", addr); | |
15744 | ||
15745 | if (peer->default_rmap[afi][safi].name) | |
15746 | vty_out(vty, " route-map %s", | |
15747 | peer->default_rmap[afi][safi].name); | |
15748 | ||
15749 | vty_out(vty, "\n"); | |
15750 | } | |
15751 | ||
15752 | /* Soft reconfiguration inbound. */ | |
15753 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
15754 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
15755 | addr); | |
15756 | } | |
15757 | ||
15758 | /* maximum-prefix. */ | |
15759 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 15760 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
15761 | peer->pmax[afi][safi]); |
15762 | ||
15763 | if (peer->pmax_threshold[afi][safi] | |
15764 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
15765 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
15766 | if (peer_af_flag_check(peer, afi, safi, | |
15767 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
15768 | vty_out(vty, " warning-only"); | |
15769 | if (peer->pmax_restart[afi][safi]) | |
15770 | vty_out(vty, " restart %u", | |
15771 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
15772 | if (peer_af_flag_check(peer, afi, safi, |
15773 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
15774 | vty_out(vty, " force"); | |
dd65f45e DL |
15775 | |
15776 | vty_out(vty, "\n"); | |
15777 | } | |
15778 | ||
fde246e8 DA |
15779 | /* maximum-prefix-out */ |
15780 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 15781 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
15782 | addr, peer->pmax_out[afi][safi]); |
15783 | ||
dd65f45e DL |
15784 | /* Route server client. */ |
15785 | if (peergroup_af_flag_check(peer, afi, safi, | |
15786 | PEER_FLAG_RSERVER_CLIENT)) { | |
15787 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
15788 | } | |
15789 | ||
15790 | /* Nexthop-local unchanged. */ | |
15791 | if (peergroup_af_flag_check(peer, afi, safi, | |
15792 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
15793 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
15794 | } | |
15795 | ||
15796 | /* allowas-in <1-10> */ | |
15797 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
15798 | if (peer_af_flag_check(peer, afi, safi, | |
15799 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
15800 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
15801 | } else if (peer->allowas_in[afi][safi] == 3) { | |
15802 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
15803 | } else { | |
15804 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
15805 | peer->allowas_in[afi][safi]); | |
15806 | } | |
15807 | } | |
15808 | ||
15809 | /* weight */ | |
15810 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
15811 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
15812 | peer->weight[afi][safi]); | |
15813 | ||
15814 | /* Filter. */ | |
15815 | bgp_config_write_filter(vty, peer, afi, safi); | |
15816 | ||
15817 | /* atribute-unchanged. */ | |
15818 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
15819 | || (safi != SAFI_EVPN | |
15820 | && peer_af_flag_check(peer, afi, safi, | |
15821 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
15822 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
15823 | ||
15824 | if (!peer_group_active(peer) | |
15825 | || peergroup_af_flag_check(peer, afi, safi, | |
15826 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15827 | || peergroup_af_flag_check(peer, afi, safi, | |
15828 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15829 | || peergroup_af_flag_check(peer, afi, safi, | |
15830 | PEER_FLAG_MED_UNCHANGED)) { | |
15831 | ||
15832 | vty_out(vty, | |
15833 | " neighbor %s attribute-unchanged%s%s%s\n", | |
15834 | addr, | |
15835 | peer_af_flag_check(peer, afi, safi, | |
15836 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15837 | ? " as-path" | |
15838 | : "", | |
15839 | peer_af_flag_check(peer, afi, safi, | |
15840 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15841 | ? " next-hop" | |
15842 | : "", | |
15843 | peer_af_flag_check(peer, afi, safi, | |
15844 | PEER_FLAG_MED_UNCHANGED) | |
15845 | ? " med" | |
15846 | : ""); | |
15847 | } | |
15848 | } | |
15849 | } | |
15850 | ||
15851 | /* Address family based peer configuration display. */ | |
15852 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
15853 | safi_t safi) | |
15854 | { | |
15855 | struct peer *peer; | |
15856 | struct peer_group *group; | |
15857 | struct listnode *node, *nnode; | |
15858 | ||
15859 | ||
15860 | vty_frame(vty, " !\n address-family "); | |
15861 | if (afi == AFI_IP) { | |
15862 | if (safi == SAFI_UNICAST) | |
15863 | vty_frame(vty, "ipv4 unicast"); | |
15864 | else if (safi == SAFI_LABELED_UNICAST) | |
15865 | vty_frame(vty, "ipv4 labeled-unicast"); | |
15866 | else if (safi == SAFI_MULTICAST) | |
15867 | vty_frame(vty, "ipv4 multicast"); | |
15868 | else if (safi == SAFI_MPLS_VPN) | |
15869 | vty_frame(vty, "ipv4 vpn"); | |
15870 | else if (safi == SAFI_ENCAP) | |
15871 | vty_frame(vty, "ipv4 encap"); | |
15872 | else if (safi == SAFI_FLOWSPEC) | |
15873 | vty_frame(vty, "ipv4 flowspec"); | |
15874 | } else if (afi == AFI_IP6) { | |
15875 | if (safi == SAFI_UNICAST) | |
15876 | vty_frame(vty, "ipv6 unicast"); | |
15877 | else if (safi == SAFI_LABELED_UNICAST) | |
15878 | vty_frame(vty, "ipv6 labeled-unicast"); | |
15879 | else if (safi == SAFI_MULTICAST) | |
15880 | vty_frame(vty, "ipv6 multicast"); | |
15881 | else if (safi == SAFI_MPLS_VPN) | |
15882 | vty_frame(vty, "ipv6 vpn"); | |
15883 | else if (safi == SAFI_ENCAP) | |
15884 | vty_frame(vty, "ipv6 encap"); | |
15885 | else if (safi == SAFI_FLOWSPEC) | |
15886 | vty_frame(vty, "ipv6 flowspec"); | |
15887 | } else if (afi == AFI_L2VPN) { | |
15888 | if (safi == SAFI_EVPN) | |
15889 | vty_frame(vty, "l2vpn evpn"); | |
15890 | } | |
15891 | vty_frame(vty, "\n"); | |
15892 | ||
15893 | bgp_config_write_distance(vty, bgp, afi, safi); | |
15894 | ||
15895 | bgp_config_write_network(vty, bgp, afi, safi); | |
15896 | ||
15897 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
15898 | ||
8a4e7fe6 DA |
15899 | /* BGP flag dampening. */ |
15900 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
15901 | bgp_config_write_damp(vty, afi, safi); | |
15902 | ||
dd65f45e DL |
15903 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
15904 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
15905 | ||
15906 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15907 | /* Skip dynamic neighbors. */ | |
15908 | if (peer_dynamic_neighbor(peer)) | |
15909 | continue; | |
15910 | ||
15911 | /* Do not display doppelganger peers */ | |
15912 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15913 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
15914 | } | |
15915 | ||
15916 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
15917 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
15918 | ||
15919 | if (safi == SAFI_EVPN) | |
15920 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
15921 | ||
15922 | if (safi == SAFI_FLOWSPEC) | |
15923 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
15924 | ||
15925 | if (safi == SAFI_UNICAST) { | |
15926 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
15927 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15928 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
15929 | ||
15930 | vty_out(vty, " export vpn\n"); | |
15931 | } | |
15932 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15933 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
15934 | ||
15935 | vty_out(vty, " import vpn\n"); | |
15936 | } | |
15937 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15938 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15939 | char *name; | |
15940 | ||
15941 | for (ALL_LIST_ELEMENTS_RO( | |
15942 | bgp->vpn_policy[afi].import_vrf, node, | |
15943 | name)) | |
15944 | vty_out(vty, " import vrf %s\n", name); | |
15945 | } | |
15946 | } | |
15947 | ||
15948 | vty_endframe(vty, " exit-address-family\n"); | |
15949 | } | |
15950 | ||
15951 | int bgp_config_write(struct vty *vty) | |
15952 | { | |
15953 | struct bgp *bgp; | |
15954 | struct peer_group *group; | |
15955 | struct peer *peer; | |
15956 | struct listnode *node, *nnode; | |
15957 | struct listnode *mnode, *mnnode; | |
15958 | ||
15959 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
15960 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
15961 | bm->rmap_update_timer); | |
15962 | ||
d70583f7 D |
15963 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
15964 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
15965 | if (bm->v_update_delay != bm->v_establish_wait) | |
15966 | vty_out(vty, " %d", bm->v_establish_wait); | |
15967 | vty_out(vty, "\n"); | |
15968 | } | |
15969 | ||
05bd726c | 15970 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
15971 | vty_out(vty, "bgp graceful-shutdown\n"); | |
15972 | ||
c163f297 DS |
15973 | /* No-RIB (Zebra) option flag configuration */ |
15974 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
15975 | vty_out(vty, "bgp no-rib\n"); | |
15976 | ||
dd65f45e DL |
15977 | /* BGP configuration. */ |
15978 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
15979 | ||
15980 | /* skip all auto created vrf as they dont have user config */ | |
15981 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
15982 | continue; | |
15983 | ||
15984 | /* Router bgp ASN */ | |
15985 | vty_out(vty, "router bgp %u", bgp->as); | |
15986 | ||
15987 | if (bgp->name) | |
15988 | vty_out(vty, " %s %s", | |
15989 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
15990 | ? "view" : "vrf", bgp->name); | |
15991 | vty_out(vty, "\n"); | |
15992 | ||
15993 | /* BGP fast-external-failover. */ | |
15994 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
15995 | vty_out(vty, " no bgp fast-external-failover\n"); | |
15996 | ||
15997 | /* BGP router ID. */ | |
15998 | if (bgp->router_id_static.s_addr != 0) | |
23d0a753 DA |
15999 | vty_out(vty, " bgp router-id %pI4\n", |
16000 | &bgp->router_id_static); | |
dd65f45e DL |
16001 | |
16002 | /* BGP log-neighbor-changes. */ | |
892fedb6 | 16003 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 16004 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 16005 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
16006 | CHECK_FLAG(bgp->flags, |
16007 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
16008 | ? "" |
16009 | : "no "); | |
16010 | ||
16011 | /* BGP configuration. */ | |
892fedb6 | 16012 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
16013 | vty_out(vty, " bgp always-compare-med\n"); |
16014 | ||
16015 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
16016 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
16017 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
16018 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
16019 | CHECK_FLAG(bgp->flags, | |
16020 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
16021 | ? "" | |
16022 | : "no "); | |
dd65f45e DL |
16023 | |
16024 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 16025 | if (bgp->reject_as_sets) |
dd65f45e DL |
16026 | vty_out(vty, " bgp reject-as-sets\n"); |
16027 | ||
16028 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 16029 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
16030 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
16031 | ||
16032 | /* BGP default local-preference. */ | |
16033 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
16034 | vty_out(vty, " bgp default local-preference %u\n", | |
16035 | bgp->default_local_pref); | |
16036 | ||
16037 | /* BGP default show-hostname */ | |
892fedb6 | 16038 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 16039 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 16040 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 16041 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
16042 | ? "" |
16043 | : "no "); | |
16044 | ||
aef999a2 DA |
16045 | /* BGP default show-nexthop-hostname */ |
16046 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16047 | != SAVE_BGP_SHOW_HOSTNAME) | |
16048 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
16049 | CHECK_FLAG(bgp->flags, | |
16050 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16051 | ? "" | |
16052 | : "no "); | |
16053 | ||
dd65f45e DL |
16054 | /* BGP default subgroup-pkt-queue-max. */ |
16055 | if (bgp->default_subgroup_pkt_queue_max | |
16056 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
16057 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
16058 | bgp->default_subgroup_pkt_queue_max); | |
16059 | ||
16060 | /* BGP client-to-client reflection. */ | |
892fedb6 | 16061 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
16062 | vty_out(vty, " no bgp client-to-client reflection\n"); |
16063 | ||
16064 | /* BGP cluster ID. */ | |
16065 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
16066 | vty_out(vty, " bgp cluster-id %pI4\n", |
16067 | &bgp->cluster_id); | |
dd65f45e DL |
16068 | |
16069 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 16070 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
16071 | vty_out(vty, |
16072 | " bgp disable-ebgp-connected-route-check\n"); | |
16073 | ||
16074 | /* Confederation identifier*/ | |
16075 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
16076 | vty_out(vty, " bgp confederation identifier %u\n", | |
16077 | bgp->confed_id); | |
16078 | ||
16079 | /* Confederation peer */ | |
16080 | if (bgp->confed_peers_cnt > 0) { | |
16081 | int i; | |
16082 | ||
16083 | vty_out(vty, " bgp confederation peers"); | |
16084 | ||
16085 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
16086 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
16087 | ||
16088 | vty_out(vty, "\n"); | |
16089 | } | |
16090 | ||
16091 | /* BGP deterministic-med. */ | |
892fedb6 | 16092 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 16093 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 16094 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
16095 | CHECK_FLAG(bgp->flags, |
16096 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
16097 | ? "" |
16098 | : "no "); | |
16099 | ||
16100 | /* BGP update-delay. */ | |
16101 | bgp_config_write_update_delay(vty, bgp); | |
16102 | ||
16103 | if (bgp->v_maxmed_onstartup | |
16104 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
16105 | vty_out(vty, " bgp max-med on-startup %u", | |
16106 | bgp->v_maxmed_onstartup); | |
16107 | if (bgp->maxmed_onstartup_value | |
16108 | != BGP_MAXMED_VALUE_DEFAULT) | |
16109 | vty_out(vty, " %u", | |
16110 | bgp->maxmed_onstartup_value); | |
16111 | vty_out(vty, "\n"); | |
16112 | } | |
16113 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
16114 | vty_out(vty, " bgp max-med administrative"); | |
16115 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
16116 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
16117 | vty_out(vty, "\n"); | |
16118 | } | |
16119 | ||
16120 | /* write quanta */ | |
16121 | bgp_config_write_wpkt_quanta(vty, bgp); | |
16122 | /* read quanta */ | |
16123 | bgp_config_write_rpkt_quanta(vty, bgp); | |
16124 | ||
16125 | /* coalesce time */ | |
16126 | bgp_config_write_coalesce_time(vty, bgp); | |
16127 | ||
05bd726c | 16128 | /* BGP per-instance graceful-shutdown */ |
16129 | /* BGP-wide settings and per-instance settings are mutually | |
16130 | * exclusive. | |
16131 | */ | |
16132 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
16133 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
16134 | vty_out(vty, " bgp graceful-shutdown\n"); | |
16135 | ||
dd65f45e DL |
16136 | /* BGP graceful-restart. */ |
16137 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
16138 | vty_out(vty, | |
16139 | " bgp graceful-restart stalepath-time %u\n", | |
16140 | bgp->stalepath_time); | |
cfd47646 | 16141 | |
dd65f45e DL |
16142 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
16143 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
16144 | bgp->restart_time); | |
cfd47646 | 16145 | |
16146 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
16147 | vty_out(vty, | |
16148 | " bgp graceful-restart select-defer-time %u\n", | |
16149 | bgp->select_defer_time); | |
16150 | ||
16151 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
16152 | vty_out(vty, " bgp graceful-restart\n"); |
16153 | ||
cfd47646 | 16154 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
16155 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
16156 | ||
dd65f45e | 16157 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 16158 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
16159 | vty_out(vty, |
16160 | " bgp graceful-restart preserve-fw-state\n"); | |
16161 | ||
dc95985f | 16162 | /* Stale timer for RIB */ |
16163 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
16164 | vty_out(vty, | |
16165 | " bgp graceful-restart rib-stale-time %u\n", | |
16166 | bgp->rib_stale_time); | |
16167 | ||
dd65f45e | 16168 | /* BGP bestpath method. */ |
892fedb6 | 16169 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 16170 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 16171 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
16172 | vty_out(vty, " bgp bestpath as-path confed\n"); |
16173 | ||
892fedb6 DA |
16174 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
16175 | if (CHECK_FLAG(bgp->flags, | |
16176 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
16177 | vty_out(vty, |
16178 | " bgp bestpath as-path multipath-relax as-set\n"); | |
16179 | } else { | |
16180 | vty_out(vty, | |
16181 | " bgp bestpath as-path multipath-relax\n"); | |
16182 | } | |
16183 | } | |
16184 | ||
892fedb6 | 16185 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
16186 | vty_out(vty, |
16187 | " bgp route-reflector allow-outbound-policy\n"); | |
16188 | } | |
892fedb6 | 16189 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 16190 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
16191 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
16192 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 16193 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 16194 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 16195 | vty_out(vty, " confed"); |
892fedb6 DA |
16196 | if (CHECK_FLAG(bgp->flags, |
16197 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
16198 | vty_out(vty, " missing-as-worst"); |
16199 | vty_out(vty, "\n"); | |
16200 | } | |
16201 | ||
f7e1c681 | 16202 | /* Link bandwidth handling. */ |
16203 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
16204 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
16205 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
16206 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
16207 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
16208 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
16209 | ||
dd65f45e | 16210 | /* BGP network import check. */ |
892fedb6 | 16211 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 16212 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 16213 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 16214 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
16215 | ? "" |
16216 | : "no "); | |
16217 | ||
16218 | /* BGP timers configuration. */ | |
5d5393b9 DL |
16219 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
16220 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
16221 | vty_out(vty, " timers bgp %u %u\n", |
16222 | bgp->default_keepalive, bgp->default_holdtime); | |
16223 | ||
16224 | /* peer-group */ | |
16225 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
16226 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
16227 | } | |
16228 | ||
16229 | /* Normal neighbor configuration. */ | |
16230 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
16231 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
16232 | bgp_config_write_peer_global(vty, bgp, peer); | |
16233 | } | |
16234 | ||
16235 | /* listen range and limit for dynamic BGP neighbors */ | |
16236 | bgp_config_write_listen(vty, bgp); | |
16237 | ||
16238 | /* | |
16239 | * BGP default autoshutdown neighbors | |
16240 | * | |
16241 | * This must be placed after any peer and peer-group | |
16242 | * configuration, to avoid setting all peers to shutdown after | |
16243 | * a daemon restart, which is undesired behavior. (see #2286) | |
16244 | */ | |
16245 | if (bgp->autoshutdown) | |
16246 | vty_out(vty, " bgp default shutdown\n"); | |
16247 | ||
9cf59432 DS |
16248 | /* BGP instance administrative shutdown */ |
16249 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
16250 | vty_out(vty, " bgp shutdown\n"); | |
16251 | ||
dd65f45e DL |
16252 | /* IPv4 unicast configuration. */ |
16253 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
16254 | ||
16255 | /* IPv4 multicast configuration. */ | |
16256 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
16257 | ||
16258 | /* IPv4 labeled-unicast configuration. */ | |
16259 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
16260 | ||
16261 | /* IPv4 VPN configuration. */ | |
16262 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
16263 | ||
16264 | /* ENCAPv4 configuration. */ | |
16265 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
16266 | ||
16267 | /* FLOWSPEC v4 configuration. */ | |
16268 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
16269 | ||
16270 | /* IPv6 unicast configuration. */ | |
16271 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
16272 | ||
16273 | /* IPv6 multicast configuration. */ | |
16274 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
16275 | ||
16276 | /* IPv6 labeled-unicast configuration. */ | |
16277 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
16278 | SAFI_LABELED_UNICAST); | |
16279 | ||
16280 | /* IPv6 VPN configuration. */ | |
16281 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
16282 | ||
16283 | /* ENCAPv6 configuration. */ | |
16284 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
16285 | ||
16286 | /* FLOWSPEC v6 configuration. */ | |
16287 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
16288 | ||
16289 | /* EVPN configuration. */ | |
16290 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
16291 | ||
16292 | hook_call(bgp_inst_config_write, bgp, vty); | |
16293 | ||
49e5a4a0 | 16294 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
16295 | bgp_rfapi_cfg_write(vty, bgp); |
16296 | #endif | |
16297 | ||
16298 | vty_out(vty, "!\n"); | |
16299 | } | |
16300 | return 0; | |
16301 | } | |
16302 | ||
ddb5b488 | 16303 | |
718e3744 | 16304 | /* BGP node structure. */ |
d62a17ae | 16305 | static struct cmd_node bgp_node = { |
f4b8291f | 16306 | .name = "bgp", |
62b346ee | 16307 | .node = BGP_NODE, |
24389580 | 16308 | .parent_node = CONFIG_NODE, |
62b346ee | 16309 | .prompt = "%s(config-router)# ", |
612c2c15 | 16310 | .config_write = bgp_config_write, |
718e3744 | 16311 | }; |
16312 | ||
d62a17ae | 16313 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 16314 | .name = "bgp ipv4 unicast", |
62b346ee | 16315 | .node = BGP_IPV4_NODE, |
24389580 | 16316 | .parent_node = BGP_NODE, |
62b346ee | 16317 | .prompt = "%s(config-router-af)# ", |
718e3744 | 16318 | }; |
16319 | ||
d62a17ae | 16320 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 16321 | .name = "bgp ipv4 multicast", |
62b346ee | 16322 | .node = BGP_IPV4M_NODE, |
24389580 | 16323 | .parent_node = BGP_NODE, |
62b346ee | 16324 | .prompt = "%s(config-router-af)# ", |
718e3744 | 16325 | }; |
16326 | ||
d62a17ae | 16327 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 16328 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 16329 | .node = BGP_IPV4L_NODE, |
24389580 | 16330 | .parent_node = BGP_NODE, |
62b346ee | 16331 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
16332 | }; |
16333 | ||
d62a17ae | 16334 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 16335 | .name = "bgp ipv6", |
62b346ee | 16336 | .node = BGP_IPV6_NODE, |
24389580 | 16337 | .parent_node = BGP_NODE, |
62b346ee | 16338 | .prompt = "%s(config-router-af)# ", |
718e3744 | 16339 | }; |
16340 | ||
d62a17ae | 16341 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 16342 | .name = "bgp ipv6 multicast", |
62b346ee | 16343 | .node = BGP_IPV6M_NODE, |
24389580 | 16344 | .parent_node = BGP_NODE, |
62b346ee | 16345 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 16346 | }; |
16347 | ||
d62a17ae | 16348 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 16349 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 16350 | .node = BGP_IPV6L_NODE, |
24389580 | 16351 | .parent_node = BGP_NODE, |
62b346ee | 16352 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
16353 | }; |
16354 | ||
62b346ee | 16355 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 16356 | .name = "bgp vpnv4", |
62b346ee | 16357 | .node = BGP_VPNV4_NODE, |
24389580 | 16358 | .parent_node = BGP_NODE, |
62b346ee | 16359 | .prompt = "%s(config-router-af)# ", |
62b346ee | 16360 | }; |
6b0655a2 | 16361 | |
62b346ee | 16362 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 16363 | .name = "bgp vpnv6", |
62b346ee | 16364 | .node = BGP_VPNV6_NODE, |
24389580 | 16365 | .parent_node = BGP_NODE, |
62b346ee | 16366 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 16367 | }; |
8ecd3266 | 16368 | |
62b346ee | 16369 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 16370 | .name = "bgp evpn", |
62b346ee | 16371 | .node = BGP_EVPN_NODE, |
24389580 | 16372 | .parent_node = BGP_NODE, |
62b346ee | 16373 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 16374 | }; |
4e0b7b6d | 16375 | |
62b346ee | 16376 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 16377 | .name = "bgp evpn vni", |
62b346ee | 16378 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 16379 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 16380 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 16381 | }; |
90e60aa7 | 16382 | |
62b346ee | 16383 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 16384 | .name = "bgp ipv4 flowspec", |
62b346ee | 16385 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 16386 | .parent_node = BGP_NODE, |
62b346ee | 16387 | .prompt = "%s(config-router-af)# ", |
62b346ee | 16388 | }; |
7c40bf39 | 16389 | |
62b346ee | 16390 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 16391 | .name = "bgp ipv6 flowspec", |
62b346ee | 16392 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 16393 | .parent_node = BGP_NODE, |
62b346ee | 16394 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 16395 | }; |
7c40bf39 | 16396 | |
d62a17ae | 16397 | static void community_list_vty(void); |
1f8ae70b | 16398 | |
d62a17ae | 16399 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 16400 | { |
d62a17ae | 16401 | struct bgp *bgp; |
16402 | struct peer *peer; | |
d62a17ae | 16403 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 16404 | |
d62a17ae | 16405 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
16406 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
16407 | /* only provide suggestions on the appropriate input | |
16408 | * token type, | |
16409 | * they'll otherwise show up multiple times */ | |
16410 | enum cmd_token_type match_type; | |
16411 | char *name = peer->host; | |
d48ed3e0 | 16412 | |
d62a17ae | 16413 | if (peer->conf_if) { |
16414 | match_type = VARIABLE_TKN; | |
16415 | name = peer->conf_if; | |
16416 | } else if (strchr(peer->host, ':')) | |
16417 | match_type = IPV6_TKN; | |
16418 | else | |
16419 | match_type = IPV4_TKN; | |
d48ed3e0 | 16420 | |
d62a17ae | 16421 | if (token->type != match_type) |
16422 | continue; | |
d48ed3e0 | 16423 | |
d62a17ae | 16424 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
16425 | } | |
d62a17ae | 16426 | } |
b8a815e5 DL |
16427 | } |
16428 | ||
16429 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 16430 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
16431 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 16432 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 16433 | {.completions = NULL}}; |
16434 | ||
47a306a0 DS |
16435 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
16436 | { | |
16437 | struct bgp *bgp; | |
16438 | struct peer_group *group; | |
16439 | struct listnode *lnbgp, *lnpeer; | |
16440 | ||
16441 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
16442 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
16443 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
16444 | group->name)); | |
16445 | } | |
16446 | } | |
16447 | ||
16448 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
16449 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
16450 | {.completions = NULL} }; | |
16451 | ||
d62a17ae | 16452 | void bgp_vty_init(void) |
16453 | { | |
16454 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 16455 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 16456 | |
16457 | /* Install bgp top node. */ | |
612c2c15 DL |
16458 | install_node(&bgp_node); |
16459 | install_node(&bgp_ipv4_unicast_node); | |
16460 | install_node(&bgp_ipv4_multicast_node); | |
16461 | install_node(&bgp_ipv4_labeled_unicast_node); | |
16462 | install_node(&bgp_ipv6_unicast_node); | |
16463 | install_node(&bgp_ipv6_multicast_node); | |
16464 | install_node(&bgp_ipv6_labeled_unicast_node); | |
16465 | install_node(&bgp_vpnv4_node); | |
16466 | install_node(&bgp_vpnv6_node); | |
16467 | install_node(&bgp_evpn_node); | |
16468 | install_node(&bgp_evpn_vni_node); | |
16469 | install_node(&bgp_flowspecv4_node); | |
16470 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 16471 | |
16472 | /* Install default VTY commands to new nodes. */ | |
16473 | install_default(BGP_NODE); | |
16474 | install_default(BGP_IPV4_NODE); | |
16475 | install_default(BGP_IPV4M_NODE); | |
16476 | install_default(BGP_IPV4L_NODE); | |
16477 | install_default(BGP_IPV6_NODE); | |
16478 | install_default(BGP_IPV6M_NODE); | |
16479 | install_default(BGP_IPV6L_NODE); | |
16480 | install_default(BGP_VPNV4_NODE); | |
16481 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 16482 | install_default(BGP_FLOWSPECV4_NODE); |
16483 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 16484 | install_default(BGP_EVPN_NODE); |
16485 | install_default(BGP_EVPN_VNI_NODE); | |
16486 | ||
8029b216 AK |
16487 | /* "bgp local-mac" hidden commands. */ |
16488 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
16489 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
16490 | ||
d62a17ae | 16491 | /* bgp route-map delay-timer commands. */ |
16492 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
16493 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
16494 | ||
d70583f7 D |
16495 | /* global bgp update-delay command */ |
16496 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
16497 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
16498 | ||
05bd726c | 16499 | /* global bgp graceful-shutdown command */ |
16500 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
16501 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
16502 | ||
d62a17ae | 16503 | /* Dummy commands (Currently not supported) */ |
16504 | install_element(BGP_NODE, &no_synchronization_cmd); | |
16505 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
16506 | ||
16507 | /* "router bgp" commands. */ | |
16508 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
16509 | ||
16510 | /* "no router bgp" commands. */ | |
16511 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
16512 | ||
16513 | /* "bgp router-id" commands. */ | |
16514 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
16515 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
16516 | ||
16517 | /* "bgp cluster-id" commands. */ | |
16518 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
16519 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
16520 | ||
c163f297 DS |
16521 | /* "bgp no-rib" commands. */ |
16522 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
16523 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
16524 | ||
d62a17ae | 16525 | /* "bgp confederation" commands. */ |
16526 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
16527 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
16528 | ||
16529 | /* "bgp confederation peers" commands. */ | |
16530 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
16531 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
16532 | ||
16533 | /* bgp max-med command */ | |
16534 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
16535 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
16536 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
16537 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
16538 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
16539 | ||
16540 | /* bgp disable-ebgp-connected-nh-check */ | |
16541 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
16542 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
16543 | ||
16544 | /* bgp update-delay command */ | |
16545 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
16546 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 16547 | |
16548 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 16549 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 16550 | |
16551 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
16552 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
16553 | ||
16554 | /* "maximum-paths" commands. */ | |
16555 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
16556 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
16557 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
16558 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
16559 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
16560 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
16561 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
16562 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
16563 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
16564 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
16565 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
16566 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
16567 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
16568 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
16569 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
16570 | ||
39edabac PG |
16571 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
16572 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
16573 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
16574 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
16575 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 16576 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
16577 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
16578 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
16579 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
16580 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
16581 | ||
16582 | /* "timers bgp" commands. */ | |
16583 | install_element(BGP_NODE, &bgp_timers_cmd); | |
16584 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
16585 | ||
16586 | /* route-map delay-timer commands - per instance for backwards compat. | |
16587 | */ | |
16588 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
16589 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
16590 | ||
16591 | /* "bgp client-to-client reflection" commands */ | |
16592 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
16593 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
16594 | ||
16595 | /* "bgp always-compare-med" commands */ | |
16596 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
16597 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
16598 | ||
9dac9fc8 DA |
16599 | /* bgp ebgp-requires-policy */ |
16600 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
16601 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
16602 | ||
fb29348a DA |
16603 | /* bgp reject-as-sets */ |
16604 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
16605 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
16606 | ||
d62a17ae | 16607 | /* "bgp deterministic-med" commands */ |
16608 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
16609 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
16610 | ||
055679e9 | 16611 | /* "bgp graceful-restart" command */ |
36235319 QY |
16612 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
16613 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 16614 | |
16615 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
16616 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
16617 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 16618 | |
16619 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
16620 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
16621 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 16622 | |
16623 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
16624 | install_element(BGP_NODE, | |
16625 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
16626 | install_element(BGP_NODE, | |
16627 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
16628 | ||
16629 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
16630 | install_element(BGP_NODE, | |
16631 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
16632 | install_element(BGP_NODE, | |
16633 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
16634 | ||
d62a17ae | 16635 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
16636 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
16637 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
16638 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 16639 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 16640 | install_element(BGP_NODE, |
16641 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 16642 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
16643 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
16644 | ||
d6e3c15b | 16645 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
16646 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 16647 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
16648 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 16649 | |
7f323236 DW |
16650 | /* "bgp graceful-shutdown" commands */ |
16651 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
16652 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
16653 | ||
d62a17ae | 16654 | /* "bgp fast-external-failover" commands */ |
16655 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
16656 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
16657 | ||
d62a17ae | 16658 | /* "bgp bestpath compare-routerid" commands */ |
16659 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
16660 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
16661 | ||
16662 | /* "bgp bestpath as-path ignore" commands */ | |
16663 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
16664 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
16665 | ||
16666 | /* "bgp bestpath as-path confed" commands */ | |
16667 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
16668 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
16669 | ||
16670 | /* "bgp bestpath as-path multipath-relax" commands */ | |
16671 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
16672 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
16673 | ||
16674 | /* "bgp log-neighbor-changes" commands */ | |
16675 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
16676 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
16677 | ||
16678 | /* "bgp bestpath med" commands */ | |
16679 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
16680 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
16681 | ||
f7e1c681 | 16682 | /* "bgp bestpath bandwidth" commands */ |
16683 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 16684 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 16685 | |
d62a17ae | 16686 | /* "no bgp default ipv4-unicast" commands. */ |
16687 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
16688 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
16689 | ||
16690 | /* "bgp network import-check" commands. */ | |
16691 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
16692 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
16693 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
16694 | ||
16695 | /* "bgp default local-preference" commands. */ | |
16696 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
16697 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
16698 | ||
16699 | /* bgp default show-hostname */ | |
16700 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
16701 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
16702 | ||
aef999a2 DA |
16703 | /* bgp default show-nexthop-hostname */ |
16704 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
16705 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
16706 | ||
d62a17ae | 16707 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
16708 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
16709 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
16710 | ||
16711 | /* bgp ibgp-allow-policy-mods command */ | |
16712 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
16713 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
16714 | ||
16715 | /* "bgp listen limit" commands. */ | |
16716 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
16717 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
16718 | ||
16719 | /* "bgp listen range" commands. */ | |
16720 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
16721 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
16722 | ||
8175f54a | 16723 | /* "bgp default shutdown" command */ |
f26845f9 | 16724 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
16725 | |
16726 | /* "bgp shutdown" commands */ | |
16727 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 16728 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 16729 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 16730 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 16731 | |
d62a17ae | 16732 | /* "neighbor remote-as" commands. */ |
16733 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
16734 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
16735 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
16736 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
16737 | install_element(BGP_NODE, | |
16738 | &neighbor_interface_v6only_config_remote_as_cmd); | |
16739 | install_element(BGP_NODE, &no_neighbor_cmd); | |
16740 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
16741 | ||
16742 | /* "neighbor peer-group" commands. */ | |
16743 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
16744 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
16745 | install_element(BGP_NODE, | |
16746 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
16747 | ||
16748 | /* "neighbor local-as" commands. */ | |
16749 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
16750 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
16751 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
16752 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
16753 | ||
16754 | /* "neighbor solo" commands. */ | |
16755 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
16756 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
16757 | ||
16758 | /* "neighbor password" commands. */ | |
16759 | install_element(BGP_NODE, &neighbor_password_cmd); | |
16760 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
16761 | ||
16762 | /* "neighbor activate" commands. */ | |
16763 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
16764 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
16765 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
16766 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
16767 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
16768 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
16769 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
16770 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
16771 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 16772 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
16773 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 16774 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
16775 | ||
16776 | /* "no neighbor activate" commands. */ | |
16777 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
16778 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
16779 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
16780 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
16781 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
16782 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
16783 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
16784 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
16785 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 16786 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
16787 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 16788 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
16789 | ||
16790 | /* "neighbor peer-group" set commands. */ | |
16791 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
16792 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16793 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16794 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16795 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16796 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16797 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16798 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 16799 | install_element(BGP_FLOWSPECV4_NODE, |
16800 | &neighbor_set_peer_group_hidden_cmd); | |
16801 | install_element(BGP_FLOWSPECV6_NODE, | |
16802 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16803 | |
16804 | /* "no neighbor peer-group unset" commands. */ | |
16805 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
16806 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16807 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16808 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16809 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16810 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16811 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16812 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 16813 | install_element(BGP_FLOWSPECV4_NODE, |
16814 | &no_neighbor_set_peer_group_hidden_cmd); | |
16815 | install_element(BGP_FLOWSPECV6_NODE, | |
16816 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16817 | |
16818 | /* "neighbor softreconfiguration inbound" commands.*/ | |
16819 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
16820 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
16821 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16822 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16823 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16824 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16825 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16826 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16827 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16828 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16829 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16830 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16831 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16832 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16833 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16834 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16835 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16836 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 16837 | install_element(BGP_FLOWSPECV4_NODE, |
16838 | &neighbor_soft_reconfiguration_cmd); | |
16839 | install_element(BGP_FLOWSPECV4_NODE, | |
16840 | &no_neighbor_soft_reconfiguration_cmd); | |
16841 | install_element(BGP_FLOWSPECV6_NODE, | |
16842 | &neighbor_soft_reconfiguration_cmd); | |
16843 | install_element(BGP_FLOWSPECV6_NODE, | |
16844 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
16845 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
16846 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 16847 | |
16848 | /* "neighbor attribute-unchanged" commands. */ | |
16849 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
16850 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
16851 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
16852 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16853 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
16854 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16855 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
16856 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16857 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
16858 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16859 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
16860 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16861 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
16862 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16863 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
16864 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16865 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
16866 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16867 | ||
16868 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
16869 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
16870 | ||
16871 | /* "nexthop-local unchanged" commands */ | |
16872 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
16873 | install_element(BGP_IPV6_NODE, | |
16874 | &no_neighbor_nexthop_local_unchanged_cmd); | |
16875 | ||
16876 | /* "neighbor next-hop-self" commands. */ | |
16877 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
16878 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
16879 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
16880 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16881 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
16882 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
16883 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
16884 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
16885 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
16886 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
16887 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
16888 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
16889 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
16890 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
16891 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
16892 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16893 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
16894 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
16895 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
16896 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 16897 | |
16898 | /* "neighbor next-hop-self force" commands. */ | |
16899 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
16900 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
16901 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16902 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16903 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
16904 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16905 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16906 | install_element(BGP_IPV4_NODE, | |
16907 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16908 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
16909 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16910 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16911 | install_element(BGP_IPV4M_NODE, | |
16912 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16913 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
16914 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16915 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16916 | install_element(BGP_IPV4L_NODE, | |
16917 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16918 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
16919 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16920 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16921 | install_element(BGP_IPV6_NODE, | |
16922 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16923 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
16924 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16925 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16926 | install_element(BGP_IPV6M_NODE, | |
16927 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16928 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
16929 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16930 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16931 | install_element(BGP_IPV6L_NODE, | |
16932 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16933 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
16934 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16935 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16936 | install_element(BGP_VPNV4_NODE, | |
16937 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16938 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
16939 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16940 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16941 | install_element(BGP_VPNV6_NODE, | |
16942 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
16943 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
16944 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 16945 | |
16946 | /* "neighbor as-override" commands. */ | |
16947 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
16948 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
16949 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
16950 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
16951 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
16952 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
16953 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
16954 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
16955 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
16956 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
16957 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
16958 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
16959 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
16960 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
16961 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
16962 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
16963 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
16964 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
16965 | ||
16966 | /* "neighbor remove-private-AS" commands. */ | |
16967 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
16968 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
16969 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
16970 | install_element(BGP_NODE, | |
16971 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
16972 | install_element(BGP_NODE, | |
16973 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
16974 | install_element(BGP_NODE, | |
16975 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
16976 | install_element(BGP_NODE, | |
16977 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16978 | install_element( | |
16979 | BGP_NODE, | |
16980 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16981 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
16982 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16983 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16984 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16985 | install_element(BGP_IPV4_NODE, | |
16986 | &neighbor_remove_private_as_replace_as_cmd); | |
16987 | install_element(BGP_IPV4_NODE, | |
16988 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16989 | install_element(BGP_IPV4_NODE, | |
16990 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16991 | install_element(BGP_IPV4_NODE, | |
16992 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16993 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
16994 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
16995 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
16996 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16997 | install_element(BGP_IPV4M_NODE, | |
16998 | &neighbor_remove_private_as_replace_as_cmd); | |
16999 | install_element(BGP_IPV4M_NODE, | |
17000 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17001 | install_element(BGP_IPV4M_NODE, | |
17002 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17003 | install_element(BGP_IPV4M_NODE, | |
17004 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17005 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
17006 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
17007 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
17008 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17009 | install_element(BGP_IPV4L_NODE, | |
17010 | &neighbor_remove_private_as_replace_as_cmd); | |
17011 | install_element(BGP_IPV4L_NODE, | |
17012 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17013 | install_element(BGP_IPV4L_NODE, | |
17014 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17015 | install_element(BGP_IPV4L_NODE, | |
17016 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17017 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
17018 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17019 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17020 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17021 | install_element(BGP_IPV6_NODE, | |
17022 | &neighbor_remove_private_as_replace_as_cmd); | |
17023 | install_element(BGP_IPV6_NODE, | |
17024 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17025 | install_element(BGP_IPV6_NODE, | |
17026 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17027 | install_element(BGP_IPV6_NODE, | |
17028 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17029 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
17030 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
17031 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
17032 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17033 | install_element(BGP_IPV6M_NODE, | |
17034 | &neighbor_remove_private_as_replace_as_cmd); | |
17035 | install_element(BGP_IPV6M_NODE, | |
17036 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17037 | install_element(BGP_IPV6M_NODE, | |
17038 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17039 | install_element(BGP_IPV6M_NODE, | |
17040 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17041 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
17042 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
17043 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
17044 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17045 | install_element(BGP_IPV6L_NODE, | |
17046 | &neighbor_remove_private_as_replace_as_cmd); | |
17047 | install_element(BGP_IPV6L_NODE, | |
17048 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17049 | install_element(BGP_IPV6L_NODE, | |
17050 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17051 | install_element(BGP_IPV6L_NODE, | |
17052 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17053 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
17054 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
17055 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
17056 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17057 | install_element(BGP_VPNV4_NODE, | |
17058 | &neighbor_remove_private_as_replace_as_cmd); | |
17059 | install_element(BGP_VPNV4_NODE, | |
17060 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17061 | install_element(BGP_VPNV4_NODE, | |
17062 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17063 | install_element(BGP_VPNV4_NODE, | |
17064 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17065 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
17066 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17067 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17068 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17069 | install_element(BGP_VPNV6_NODE, | |
17070 | &neighbor_remove_private_as_replace_as_cmd); | |
17071 | install_element(BGP_VPNV6_NODE, | |
17072 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17073 | install_element(BGP_VPNV6_NODE, | |
17074 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17075 | install_element(BGP_VPNV6_NODE, | |
17076 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17077 | ||
17078 | /* "neighbor send-community" commands.*/ | |
17079 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
17080 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
17081 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
17082 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
17083 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
17084 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
17085 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
17086 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
17087 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
17088 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
17089 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
17090 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
17091 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
17092 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
17093 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
17094 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
17095 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
17096 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
17097 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
17098 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
17099 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
17100 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
17101 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
17102 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
17103 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
17104 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
17105 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
17106 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
17107 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
17108 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
17109 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
17110 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
17111 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
17112 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
17113 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
17114 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
17115 | ||
17116 | /* "neighbor route-reflector" commands.*/ | |
17117 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
17118 | install_element(BGP_NODE, | |
17119 | &no_neighbor_route_reflector_client_hidden_cmd); | |
17120 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
17121 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
17122 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
17123 | install_element(BGP_IPV4M_NODE, | |
17124 | &no_neighbor_route_reflector_client_cmd); | |
17125 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
17126 | install_element(BGP_IPV4L_NODE, | |
17127 | &no_neighbor_route_reflector_client_cmd); | |
17128 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
17129 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
17130 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
17131 | install_element(BGP_IPV6M_NODE, | |
17132 | &no_neighbor_route_reflector_client_cmd); | |
17133 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
17134 | install_element(BGP_IPV6L_NODE, | |
17135 | &no_neighbor_route_reflector_client_cmd); | |
17136 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
17137 | install_element(BGP_VPNV4_NODE, | |
17138 | &no_neighbor_route_reflector_client_cmd); | |
17139 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
17140 | install_element(BGP_VPNV6_NODE, | |
17141 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 17142 | install_element(BGP_FLOWSPECV4_NODE, |
17143 | &neighbor_route_reflector_client_cmd); | |
17144 | install_element(BGP_FLOWSPECV4_NODE, | |
17145 | &no_neighbor_route_reflector_client_cmd); | |
17146 | install_element(BGP_FLOWSPECV6_NODE, | |
17147 | &neighbor_route_reflector_client_cmd); | |
17148 | install_element(BGP_FLOWSPECV6_NODE, | |
17149 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 17150 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
17151 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
17152 | ||
17153 | /* "neighbor route-server" commands.*/ | |
17154 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
17155 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
17156 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
17157 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
17158 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
17159 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
17160 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
17161 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
17162 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
17163 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
17164 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
17165 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
17166 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
17167 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
17168 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
17169 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
17170 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
17171 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
17172 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
17173 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 17174 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
17175 | install_element(BGP_FLOWSPECV4_NODE, | |
17176 | &no_neighbor_route_server_client_cmd); | |
17177 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
17178 | install_element(BGP_FLOWSPECV6_NODE, | |
17179 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 17180 | |
17181 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
17182 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
17183 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
17184 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17185 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17186 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17187 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17188 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17189 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17190 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17191 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17192 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17193 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17194 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17195 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17196 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17197 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17198 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17199 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17200 | ||
17201 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
17202 | install_element(BGP_NODE, | |
17203 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
17204 | install_element(BGP_NODE, | |
17205 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
17206 | install_element(BGP_IPV4_NODE, | |
17207 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17208 | install_element(BGP_IPV4_NODE, | |
17209 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17210 | install_element(BGP_IPV4M_NODE, | |
17211 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17212 | install_element(BGP_IPV4M_NODE, | |
17213 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17214 | install_element(BGP_IPV4L_NODE, | |
17215 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17216 | install_element(BGP_IPV4L_NODE, | |
17217 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17218 | install_element(BGP_IPV6_NODE, | |
17219 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17220 | install_element(BGP_IPV6_NODE, | |
17221 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17222 | install_element(BGP_IPV6M_NODE, | |
17223 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17224 | install_element(BGP_IPV6M_NODE, | |
17225 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17226 | install_element(BGP_IPV6L_NODE, | |
17227 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17228 | install_element(BGP_IPV6L_NODE, | |
17229 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17230 | install_element(BGP_VPNV4_NODE, | |
17231 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17232 | install_element(BGP_VPNV4_NODE, | |
17233 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17234 | install_element(BGP_VPNV6_NODE, | |
17235 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17236 | install_element(BGP_VPNV6_NODE, | |
17237 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17238 | ||
2b31007c RZ |
17239 | /* "neighbor sender-as-path-loop-detection" commands. */ |
17240 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
17241 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
17242 | ||
d62a17ae | 17243 | /* "neighbor passive" commands. */ |
17244 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
17245 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
17246 | ||
17247 | ||
17248 | /* "neighbor shutdown" commands. */ | |
17249 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
17250 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
17251 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
17252 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
17253 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
17254 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 17255 | |
17256 | /* "neighbor capability extended-nexthop" commands.*/ | |
17257 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
17258 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
17259 | ||
17260 | /* "neighbor capability orf prefix-list" commands.*/ | |
17261 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
17262 | install_element(BGP_NODE, | |
17263 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
17264 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
17265 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17266 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
17267 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17268 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
17269 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17270 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
17271 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17272 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
17273 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17274 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
17275 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17276 | ||
17277 | /* "neighbor capability dynamic" commands.*/ | |
17278 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
17279 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
17280 | ||
17281 | /* "neighbor dont-capability-negotiate" commands. */ | |
17282 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
17283 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
17284 | ||
17285 | /* "neighbor ebgp-multihop" commands. */ | |
17286 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
17287 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
17288 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
17289 | ||
17290 | /* "neighbor disable-connected-check" commands. */ | |
17291 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
17292 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
17293 | ||
47cbc09b PM |
17294 | /* "neighbor enforce-first-as" commands. */ |
17295 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
17296 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
17297 | ||
d62a17ae | 17298 | /* "neighbor description" commands. */ |
17299 | install_element(BGP_NODE, &neighbor_description_cmd); | |
17300 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 17301 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 17302 | |
17303 | /* "neighbor update-source" commands. "*/ | |
17304 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
17305 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
17306 | ||
17307 | /* "neighbor default-originate" commands. */ | |
17308 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
17309 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
17310 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
17311 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
17312 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
17313 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
17314 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
17315 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
17316 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
17317 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
17318 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
17319 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
17320 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
17321 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
17322 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
17323 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
17324 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
17325 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
17326 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
17327 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
17328 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
17329 | ||
17330 | /* "neighbor port" commands. */ | |
17331 | install_element(BGP_NODE, &neighbor_port_cmd); | |
17332 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
17333 | ||
17334 | /* "neighbor weight" commands. */ | |
17335 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
17336 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
17337 | ||
17338 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
17339 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
17340 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
17341 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
17342 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
17343 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
17344 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
17345 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
17346 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
17347 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
17348 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
17349 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
17350 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
17351 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
17352 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
17353 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
17354 | ||
17355 | /* "neighbor override-capability" commands. */ | |
17356 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
17357 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
17358 | ||
17359 | /* "neighbor strict-capability-match" commands. */ | |
17360 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
17361 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
17362 | ||
17363 | /* "neighbor timers" commands. */ | |
17364 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
17365 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
17366 | ||
17367 | /* "neighbor timers connect" commands. */ | |
17368 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
17369 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
17370 | ||
17371 | /* "neighbor advertisement-interval" commands. */ | |
17372 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
17373 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
17374 | ||
17375 | /* "neighbor interface" commands. */ | |
17376 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
17377 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
17378 | ||
17379 | /* "neighbor distribute" commands. */ | |
17380 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
17381 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
17382 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
17383 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
17384 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
17385 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
17386 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
17387 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
17388 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
17389 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
17390 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
17391 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
17392 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
17393 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
17394 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
17395 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
17396 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
17397 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
17398 | ||
17399 | /* "neighbor prefix-list" commands. */ | |
17400 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
17401 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
17402 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
17403 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
17404 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
17405 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
17406 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
17407 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
17408 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
17409 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
17410 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
17411 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
17412 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
17413 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
17414 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
17415 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
17416 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
17417 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 17418 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
17419 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
17420 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
17421 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 17422 | |
17423 | /* "neighbor filter-list" commands. */ | |
17424 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
17425 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
17426 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
17427 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
17428 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
17429 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
17430 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
17431 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
17432 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
17433 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
17434 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
17435 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
17436 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
17437 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
17438 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
17439 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
17440 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
17441 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 17442 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
17443 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
17444 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
17445 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 17446 | |
17447 | /* "neighbor route-map" commands. */ | |
17448 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
17449 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
17450 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
17451 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
17452 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
17453 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
17454 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
17455 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
17456 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
17457 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
17458 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
17459 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
17460 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
17461 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
17462 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
17463 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
17464 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
17465 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 17466 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
17467 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
17468 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
17469 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
17470 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
17471 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 17472 | |
17473 | /* "neighbor unsuppress-map" commands. */ | |
17474 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
17475 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
17476 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
17477 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
17478 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
17479 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
17480 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
17481 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
17482 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
17483 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
17484 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
17485 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
17486 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
17487 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
17488 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
17489 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
17490 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
17491 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
17492 | ||
7f7940e6 MK |
17493 | /* "neighbor advertise-map" commands. */ |
17494 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); | |
7f7940e6 | 17495 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 17496 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 17497 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 17498 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 17499 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 17500 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 17501 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 17502 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 17503 | |
fde246e8 DA |
17504 | /* neighbor maximum-prefix-out commands. */ |
17505 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
17506 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17507 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
17508 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17509 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
17510 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17511 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
17512 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17513 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
17514 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17515 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
17516 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17517 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
17518 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17519 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
17520 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17521 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
17522 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17523 | ||
d62a17ae | 17524 | /* "neighbor maximum-prefix" commands. */ |
17525 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
17526 | install_element(BGP_NODE, | |
17527 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
17528 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
17529 | install_element(BGP_NODE, | |
17530 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
17531 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
17532 | install_element(BGP_NODE, | |
17533 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
17534 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
17535 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
17536 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17537 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17538 | install_element(BGP_IPV4_NODE, | |
17539 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17540 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17541 | install_element(BGP_IPV4_NODE, | |
17542 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17543 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
17544 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
17545 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17546 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17547 | install_element(BGP_IPV4M_NODE, | |
17548 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17549 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17550 | install_element(BGP_IPV4M_NODE, | |
17551 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17552 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
17553 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
17554 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17555 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17556 | install_element(BGP_IPV4L_NODE, | |
17557 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17558 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17559 | install_element(BGP_IPV4L_NODE, | |
17560 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17561 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
17562 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
17563 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17564 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17565 | install_element(BGP_IPV6_NODE, | |
17566 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17567 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17568 | install_element(BGP_IPV6_NODE, | |
17569 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17570 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
17571 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
17572 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17573 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17574 | install_element(BGP_IPV6M_NODE, | |
17575 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17576 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17577 | install_element(BGP_IPV6M_NODE, | |
17578 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17579 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
17580 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
17581 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17582 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17583 | install_element(BGP_IPV6L_NODE, | |
17584 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17585 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17586 | install_element(BGP_IPV6L_NODE, | |
17587 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17588 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
17589 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
17590 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17591 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17592 | install_element(BGP_VPNV4_NODE, | |
17593 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17594 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17595 | install_element(BGP_VPNV4_NODE, | |
17596 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17597 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
17598 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
17599 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17600 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17601 | install_element(BGP_VPNV6_NODE, | |
17602 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17603 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17604 | install_element(BGP_VPNV6_NODE, | |
17605 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17606 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
17607 | ||
17608 | /* "neighbor allowas-in" */ | |
17609 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
17610 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
17611 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
17612 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
17613 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
17614 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
17615 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
17616 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
17617 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
17618 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
17619 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
17620 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
17621 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
17622 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
17623 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
17624 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
17625 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
17626 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
17627 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
17628 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
17629 | ||
17630 | /* address-family commands. */ | |
17631 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
17632 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 17633 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 17634 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
17635 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 17636 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 17637 | |
d62a17ae | 17638 | install_element(BGP_NODE, &address_family_evpn_cmd); |
17639 | ||
17640 | /* "exit-address-family" command. */ | |
17641 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
17642 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
17643 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
17644 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
17645 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
17646 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
17647 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
17648 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 17649 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
17650 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 17651 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
17652 | ||
17653 | /* "clear ip bgp commands" */ | |
17654 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
17655 | ||
17656 | /* clear ip bgp prefix */ | |
17657 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
17658 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
17659 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
17660 | ||
17661 | /* "show [ip] bgp summary" commands. */ | |
17662 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 17663 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 17664 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 17665 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 17666 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
17667 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 17668 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
17669 | ||
17670 | /* "show [ip] bgp neighbors" commands. */ | |
17671 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
17672 | ||
36235319 | 17673 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 17674 | |
d62a17ae | 17675 | /* "show [ip] bgp peer-group" commands. */ |
17676 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
17677 | ||
17678 | /* "show [ip] bgp paths" commands. */ | |
17679 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
17680 | ||
17681 | /* "show [ip] bgp community" commands. */ | |
17682 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
17683 | ||
17684 | /* "show ip bgp large-community" commands. */ | |
17685 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
17686 | /* "show [ip] bgp attribute-info" commands. */ | |
17687 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 17688 | /* "show [ip] bgp route-leak" command */ |
17689 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 17690 | |
17691 | /* "redistribute" commands. */ | |
17692 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
17693 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
17694 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
17695 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
17696 | install_element(BGP_NODE, | |
17697 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
17698 | install_element(BGP_NODE, | |
17699 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
17700 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
17701 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
17702 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
17703 | install_element(BGP_NODE, | |
17704 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
17705 | install_element(BGP_NODE, | |
17706 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
17707 | install_element(BGP_NODE, | |
17708 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
17709 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
17710 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
17711 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
17712 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
17713 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
17714 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
17715 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
17716 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
17717 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
17718 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
17719 | install_element(BGP_IPV4_NODE, | |
17720 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
17721 | install_element(BGP_IPV4_NODE, | |
17722 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
17723 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
17724 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
17725 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
17726 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
17727 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
17728 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
17729 | ||
b9c7bc5a PZ |
17730 | /* import|export vpn [route-map WORD] */ |
17731 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
17732 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 17733 | |
12a844a5 DS |
17734 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
17735 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
17736 | ||
d62a17ae | 17737 | /* ttl_security commands */ |
17738 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
17739 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
17740 | ||
17741 | /* "show [ip] bgp memory" commands. */ | |
17742 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
17743 | ||
acf71666 MK |
17744 | /* "show bgp martian next-hop" */ |
17745 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
17746 | ||
48ecf8f5 DS |
17747 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
17748 | ||
d62a17ae | 17749 | /* "show [ip] bgp views" commands. */ |
17750 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
17751 | ||
17752 | /* "show [ip] bgp vrfs" commands. */ | |
17753 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
17754 | ||
17755 | /* Community-list. */ | |
17756 | community_list_vty(); | |
ddb5b488 PZ |
17757 | |
17758 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
17759 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
17760 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
17761 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
17762 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
17763 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
17764 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
17765 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
17766 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
17767 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
17768 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
17769 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
17770 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 17771 | |
301ad80a PG |
17772 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
17773 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
17774 | ||
b9c7bc5a PZ |
17775 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
17776 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
17777 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
17778 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
17779 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
17780 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
17781 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
17782 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
17783 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
17784 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 17785 | } |
6b0655a2 | 17786 | |
718e3744 | 17787 | #include "memory.h" |
17788 | #include "bgp_regex.h" | |
17789 | #include "bgp_clist.h" | |
17790 | #include "bgp_ecommunity.h" | |
17791 | ||
17792 | /* VTY functions. */ | |
17793 | ||
17794 | /* Direction value to string conversion. */ | |
d62a17ae | 17795 | static const char *community_direct_str(int direct) |
17796 | { | |
17797 | switch (direct) { | |
17798 | case COMMUNITY_DENY: | |
17799 | return "deny"; | |
17800 | case COMMUNITY_PERMIT: | |
17801 | return "permit"; | |
17802 | default: | |
17803 | return "unknown"; | |
17804 | } | |
718e3744 | 17805 | } |
17806 | ||
17807 | /* Display error string. */ | |
d62a17ae | 17808 | static void community_list_perror(struct vty *vty, int ret) |
17809 | { | |
17810 | switch (ret) { | |
17811 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
17812 | vty_out(vty, "%% Can't find community-list\n"); | |
17813 | break; | |
17814 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
17815 | vty_out(vty, "%% Malformed community-list value\n"); | |
17816 | break; | |
17817 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
17818 | vty_out(vty, | |
17819 | "%% Community name conflict, previously defined as standard community\n"); | |
17820 | break; | |
17821 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
17822 | vty_out(vty, | |
17823 | "%% Community name conflict, previously defined as expanded community\n"); | |
17824 | break; | |
17825 | } | |
718e3744 | 17826 | } |
17827 | ||
5bf15956 DW |
17828 | /* "community-list" keyword help string. */ |
17829 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
17830 | ||
7336e101 SP |
17831 | /*community-list standard */ |
17832 | DEFUN (community_list_standard, | |
17833 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 17834 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17835 | BGP_STR |
718e3744 | 17836 | COMMUNITY_LIST_STR |
17837 | "Community list number (standard)\n" | |
5bf15956 | 17838 | "Add an standard community-list entry\n" |
718e3744 | 17839 | "Community list name\n" |
2f8cc0e5 DA |
17840 | "Sequence number of an entry\n" |
17841 | "Sequence number\n" | |
718e3744 | 17842 | "Specify community to reject\n" |
17843 | "Specify community to accept\n" | |
17844 | COMMUNITY_VAL_STR) | |
17845 | { | |
d62a17ae | 17846 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17847 | char *seq = NULL; |
d62a17ae | 17848 | int direct = 0; |
17849 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 17850 | int idx = 0; |
7336e101 | 17851 | |
2f8cc0e5 DA |
17852 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17853 | if (idx) | |
17854 | seq = argv[idx]->arg; | |
17855 | ||
17856 | idx = 0; | |
d62a17ae | 17857 | argv_find(argv, argc, "(1-99)", &idx); |
17858 | argv_find(argv, argc, "WORD", &idx); | |
17859 | cl_name_or_number = argv[idx]->arg; | |
17860 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17861 | : COMMUNITY_DENY; | |
17862 | argv_find(argv, argc, "AA:NN", &idx); | |
17863 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17864 | |
2f8cc0e5 DA |
17865 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
17866 | direct, style); | |
42f914d4 | 17867 | |
d62a17ae | 17868 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17869 | |
d62a17ae | 17870 | if (ret < 0) { |
17871 | /* Display error string. */ | |
17872 | community_list_perror(vty, ret); | |
17873 | return CMD_WARNING_CONFIG_FAILED; | |
17874 | } | |
42f914d4 | 17875 | |
d62a17ae | 17876 | return CMD_SUCCESS; |
718e3744 | 17877 | } |
17878 | ||
7336e101 SP |
17879 | DEFUN (no_community_list_standard_all, |
17880 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 17881 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17882 | NO_STR |
17883 | BGP_STR | |
17884 | COMMUNITY_LIST_STR | |
17885 | "Community list number (standard)\n" | |
17886 | "Add an standard community-list entry\n" | |
17887 | "Community list name\n" | |
2f8cc0e5 DA |
17888 | "Sequence number of an entry\n" |
17889 | "Sequence number\n" | |
7336e101 SP |
17890 | "Specify community to reject\n" |
17891 | "Specify community to accept\n" | |
17892 | COMMUNITY_VAL_STR) | |
718e3744 | 17893 | { |
d62a17ae | 17894 | char *cl_name_or_number = NULL; |
174b5cb9 | 17895 | char *str = NULL; |
d62a17ae | 17896 | int direct = 0; |
17897 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 17898 | char *seq = NULL; |
d62a17ae | 17899 | int idx = 0; |
7336e101 | 17900 | |
2f8cc0e5 DA |
17901 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17902 | if (idx) | |
17903 | seq = argv[idx]->arg; | |
17904 | ||
17905 | idx = 0; | |
174b5cb9 DA |
17906 | argv_find(argv, argc, "permit", &idx); |
17907 | argv_find(argv, argc, "deny", &idx); | |
17908 | ||
17909 | if (idx) { | |
17910 | direct = argv_find(argv, argc, "permit", &idx) | |
17911 | ? COMMUNITY_PERMIT | |
17912 | : COMMUNITY_DENY; | |
17913 | ||
17914 | idx = 0; | |
17915 | argv_find(argv, argc, "AA:NN", &idx); | |
17916 | str = argv_concat(argv, argc, idx); | |
17917 | } | |
17918 | ||
17919 | idx = 0; | |
d62a17ae | 17920 | argv_find(argv, argc, "(1-99)", &idx); |
17921 | argv_find(argv, argc, "WORD", &idx); | |
17922 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 17923 | |
2f8cc0e5 | 17924 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 17925 | direct, style); |
42f914d4 | 17926 | |
d62a17ae | 17927 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17928 | |
d62a17ae | 17929 | if (ret < 0) { |
17930 | community_list_perror(vty, ret); | |
17931 | return CMD_WARNING_CONFIG_FAILED; | |
17932 | } | |
42f914d4 | 17933 | |
d62a17ae | 17934 | return CMD_SUCCESS; |
718e3744 | 17935 | } |
7336e101 | 17936 | |
174b5cb9 DA |
17937 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
17938 | "no bgp community-list <(1-99)|standard WORD>", | |
17939 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
17940 | "Community list number (standard)\n" | |
17941 | "Add an standard community-list entry\n" | |
17942 | "Community list name\n") | |
17943 | ||
7336e101 SP |
17944 | /*community-list expanded */ |
17945 | DEFUN (community_list_expanded_all, | |
17946 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17947 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17948 | BGP_STR |
17949 | COMMUNITY_LIST_STR | |
718e3744 | 17950 | "Community list number (expanded)\n" |
5bf15956 | 17951 | "Add an expanded community-list entry\n" |
718e3744 | 17952 | "Community list name\n" |
2f8cc0e5 DA |
17953 | "Sequence number of an entry\n" |
17954 | "Sequence number\n" | |
718e3744 | 17955 | "Specify community to reject\n" |
17956 | "Specify community to accept\n" | |
17957 | COMMUNITY_VAL_STR) | |
17958 | { | |
d62a17ae | 17959 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17960 | char *seq = NULL; |
d62a17ae | 17961 | int direct = 0; |
17962 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17963 | int idx = 0; |
7b9a4750 | 17964 | |
2f8cc0e5 DA |
17965 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17966 | if (idx) | |
17967 | seq = argv[idx]->arg; | |
17968 | ||
17969 | idx = 0; | |
17970 | ||
d62a17ae | 17971 | argv_find(argv, argc, "(100-500)", &idx); |
17972 | argv_find(argv, argc, "WORD", &idx); | |
17973 | cl_name_or_number = argv[idx]->arg; | |
17974 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17975 | : COMMUNITY_DENY; | |
17976 | argv_find(argv, argc, "AA:NN", &idx); | |
17977 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17978 | |
2f8cc0e5 DA |
17979 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
17980 | direct, style); | |
42f914d4 | 17981 | |
d62a17ae | 17982 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17983 | |
d62a17ae | 17984 | if (ret < 0) { |
17985 | /* Display error string. */ | |
17986 | community_list_perror(vty, ret); | |
17987 | return CMD_WARNING_CONFIG_FAILED; | |
17988 | } | |
42f914d4 | 17989 | |
d62a17ae | 17990 | return CMD_SUCCESS; |
718e3744 | 17991 | } |
17992 | ||
7336e101 SP |
17993 | DEFUN (no_community_list_expanded_all, |
17994 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17995 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17996 | NO_STR |
17997 | BGP_STR | |
17998 | COMMUNITY_LIST_STR | |
17999 | "Community list number (expanded)\n" | |
18000 | "Add an expanded community-list entry\n" | |
18001 | "Community list name\n" | |
2f8cc0e5 DA |
18002 | "Sequence number of an entry\n" |
18003 | "Sequence number\n" | |
7336e101 SP |
18004 | "Specify community to reject\n" |
18005 | "Specify community to accept\n" | |
18006 | COMMUNITY_VAL_STR) | |
718e3744 | 18007 | { |
d62a17ae | 18008 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18009 | char *seq = NULL; |
174b5cb9 | 18010 | char *str = NULL; |
d62a17ae | 18011 | int direct = 0; |
18012 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 18013 | int idx = 0; |
174b5cb9 | 18014 | |
2f8cc0e5 DA |
18015 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18016 | if (idx) | |
18017 | seq = argv[idx]->arg; | |
18018 | ||
18019 | idx = 0; | |
174b5cb9 DA |
18020 | argv_find(argv, argc, "permit", &idx); |
18021 | argv_find(argv, argc, "deny", &idx); | |
18022 | ||
18023 | if (idx) { | |
18024 | direct = argv_find(argv, argc, "permit", &idx) | |
18025 | ? COMMUNITY_PERMIT | |
18026 | : COMMUNITY_DENY; | |
18027 | ||
18028 | idx = 0; | |
18029 | argv_find(argv, argc, "AA:NN", &idx); | |
18030 | str = argv_concat(argv, argc, idx); | |
7336e101 | 18031 | } |
174b5cb9 DA |
18032 | |
18033 | idx = 0; | |
d62a17ae | 18034 | argv_find(argv, argc, "(100-500)", &idx); |
18035 | argv_find(argv, argc, "WORD", &idx); | |
18036 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 18037 | |
2f8cc0e5 | 18038 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 18039 | direct, style); |
42f914d4 | 18040 | |
d62a17ae | 18041 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 18042 | |
d62a17ae | 18043 | if (ret < 0) { |
18044 | community_list_perror(vty, ret); | |
18045 | return CMD_WARNING_CONFIG_FAILED; | |
18046 | } | |
42f914d4 | 18047 | |
d62a17ae | 18048 | return CMD_SUCCESS; |
718e3744 | 18049 | } |
18050 | ||
36d4bb44 EB |
18051 | ALIAS(no_community_list_expanded_all, |
18052 | no_bgp_community_list_expanded_all_list_cmd, | |
174b5cb9 | 18053 | "no bgp community-list <(100-500)|expanded WORD>", |
36d4bb44 | 18054 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
18055 | "Community list number (expanded)\n" |
18056 | "Add an expanded community-list entry\n" | |
18057 | "Community list name\n") | |
18058 | ||
8d9b8ed9 PM |
18059 | /* Return configuration string of community-list entry. */ |
18060 | static const char *community_list_config_str(struct community_entry *entry) | |
18061 | { | |
18062 | const char *str; | |
18063 | ||
18064 | if (entry->any) | |
18065 | str = ""; | |
18066 | else { | |
18067 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
18068 | str = community_str(entry->u.com, false); | |
18069 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
18070 | str = lcommunity_str(entry->u.lcom, false); | |
18071 | else | |
18072 | str = entry->config; | |
18073 | } | |
18074 | return str; | |
18075 | } | |
18076 | ||
d62a17ae | 18077 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 18078 | { |
d62a17ae | 18079 | struct community_entry *entry; |
718e3744 | 18080 | |
d62a17ae | 18081 | for (entry = list->head; entry; entry = entry->next) { |
18082 | if (entry == list->head) { | |
18083 | if (all_digit(list->name)) | |
18084 | vty_out(vty, "Community %s list %s\n", | |
18085 | entry->style == COMMUNITY_LIST_STANDARD | |
18086 | ? "standard" | |
18087 | : "(expanded) access", | |
18088 | list->name); | |
18089 | else | |
18090 | vty_out(vty, "Named Community %s list %s\n", | |
18091 | entry->style == COMMUNITY_LIST_STANDARD | |
18092 | ? "standard" | |
18093 | : "expanded", | |
18094 | list->name); | |
18095 | } | |
18096 | if (entry->any) | |
18097 | vty_out(vty, " %s\n", | |
18098 | community_direct_str(entry->direct)); | |
18099 | else | |
18100 | vty_out(vty, " %s %s\n", | |
18101 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18102 | community_list_config_str(entry)); |
d62a17ae | 18103 | } |
718e3744 | 18104 | } |
18105 | ||
7336e101 SP |
18106 | DEFUN (show_community_list, |
18107 | show_bgp_community_list_cmd, | |
18108 | "show bgp community-list", | |
718e3744 | 18109 | SHOW_STR |
7336e101 | 18110 | BGP_STR |
718e3744 | 18111 | "List community-list\n") |
18112 | { | |
d62a17ae | 18113 | struct community_list *list; |
18114 | struct community_list_master *cm; | |
718e3744 | 18115 | |
d62a17ae | 18116 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
18117 | if (!cm) | |
18118 | return CMD_SUCCESS; | |
718e3744 | 18119 | |
d62a17ae | 18120 | for (list = cm->num.head; list; list = list->next) |
18121 | community_list_show(vty, list); | |
718e3744 | 18122 | |
d62a17ae | 18123 | for (list = cm->str.head; list; list = list->next) |
18124 | community_list_show(vty, list); | |
718e3744 | 18125 | |
d62a17ae | 18126 | return CMD_SUCCESS; |
718e3744 | 18127 | } |
18128 | ||
7336e101 SP |
18129 | DEFUN (show_community_list_arg, |
18130 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 18131 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
18132 | SHOW_STR |
18133 | BGP_STR | |
718e3744 | 18134 | "List community-list\n" |
18135 | "Community-list number\n" | |
960b69b9 | 18136 | "Community-list name\n" |
18137 | "Detailed information on community-list\n") | |
718e3744 | 18138 | { |
d62a17ae | 18139 | int idx_comm_list = 3; |
18140 | struct community_list *list; | |
718e3744 | 18141 | |
e237b0d2 | 18142 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 18143 | COMMUNITY_LIST_MASTER); |
18144 | if (!list) { | |
18145 | vty_out(vty, "%% Can't find community-list\n"); | |
18146 | return CMD_WARNING; | |
18147 | } | |
718e3744 | 18148 | |
d62a17ae | 18149 | community_list_show(vty, list); |
718e3744 | 18150 | |
d62a17ae | 18151 | return CMD_SUCCESS; |
718e3744 | 18152 | } |
6b0655a2 | 18153 | |
57d187bc JS |
18154 | /* |
18155 | * Large Community code. | |
18156 | */ | |
d62a17ae | 18157 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
18158 | struct cmd_token **argv, int style, | |
18159 | int reject_all_digit_name) | |
18160 | { | |
18161 | int ret; | |
18162 | int direct; | |
18163 | char *str; | |
18164 | int idx = 0; | |
18165 | char *cl_name; | |
2f8cc0e5 DA |
18166 | char *seq = NULL; |
18167 | ||
947073e3 | 18168 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 18169 | seq = argv[idx]->arg; |
d62a17ae | 18170 | |
2f8cc0e5 | 18171 | idx = 0; |
d62a17ae | 18172 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
18173 | : COMMUNITY_DENY; | |
18174 | ||
18175 | /* All digit name check. */ | |
18176 | idx = 0; | |
18177 | argv_find(argv, argc, "WORD", &idx); | |
18178 | argv_find(argv, argc, "(1-99)", &idx); | |
18179 | argv_find(argv, argc, "(100-500)", &idx); | |
18180 | cl_name = argv[idx]->arg; | |
18181 | if (reject_all_digit_name && all_digit(cl_name)) { | |
18182 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
18183 | return CMD_WARNING_CONFIG_FAILED; | |
18184 | } | |
18185 | ||
18186 | idx = 0; | |
18187 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
18188 | argv_find(argv, argc, "LINE", &idx); | |
18189 | /* Concat community string argument. */ | |
18190 | if (idx) | |
18191 | str = argv_concat(argv, argc, idx); | |
18192 | else | |
18193 | str = NULL; | |
18194 | ||
2f8cc0e5 | 18195 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 18196 | |
18197 | /* Free temporary community list string allocated by | |
18198 | argv_concat(). */ | |
0a22ddfb | 18199 | XFREE(MTYPE_TMP, str); |
d62a17ae | 18200 | |
18201 | if (ret < 0) { | |
18202 | community_list_perror(vty, ret); | |
18203 | return CMD_WARNING_CONFIG_FAILED; | |
18204 | } | |
18205 | return CMD_SUCCESS; | |
18206 | } | |
18207 | ||
18208 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
18209 | struct cmd_token **argv, int style) | |
18210 | { | |
18211 | int ret; | |
18212 | int direct = 0; | |
18213 | char *str = NULL; | |
18214 | int idx = 0; | |
2f8cc0e5 | 18215 | char *seq = NULL; |
d62a17ae | 18216 | |
947073e3 | 18217 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 18218 | seq = argv[idx]->arg; |
d62a17ae | 18219 | |
2f8cc0e5 | 18220 | idx = 0; |
d62a17ae | 18221 | argv_find(argv, argc, "permit", &idx); |
18222 | argv_find(argv, argc, "deny", &idx); | |
18223 | ||
18224 | if (idx) { | |
18225 | /* Check the list direct. */ | |
18226 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
18227 | direct = COMMUNITY_PERMIT; | |
18228 | else | |
18229 | direct = COMMUNITY_DENY; | |
18230 | ||
18231 | idx = 0; | |
18232 | argv_find(argv, argc, "LINE", &idx); | |
18233 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
18234 | /* Concat community string argument. */ | |
18235 | str = argv_concat(argv, argc, idx); | |
18236 | } | |
18237 | ||
18238 | idx = 0; | |
18239 | argv_find(argv, argc, "(1-99)", &idx); | |
18240 | argv_find(argv, argc, "(100-500)", &idx); | |
18241 | argv_find(argv, argc, "WORD", &idx); | |
18242 | ||
18243 | /* Unset community list. */ | |
2f8cc0e5 | 18244 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 18245 | style); |
18246 | ||
18247 | /* Free temporary community list string allocated by | |
18248 | argv_concat(). */ | |
0a22ddfb | 18249 | XFREE(MTYPE_TMP, str); |
d62a17ae | 18250 | |
18251 | if (ret < 0) { | |
18252 | community_list_perror(vty, ret); | |
18253 | return CMD_WARNING_CONFIG_FAILED; | |
18254 | } | |
18255 | ||
18256 | return CMD_SUCCESS; | |
57d187bc JS |
18257 | } |
18258 | ||
18259 | /* "large-community-list" keyword help string. */ | |
18260 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
18261 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
18262 | ||
7336e101 SP |
18263 | DEFUN (lcommunity_list_standard, |
18264 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 18265 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
18266 | BGP_STR |
18267 | LCOMMUNITY_LIST_STR | |
18268 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
18269 | "Sequence number of an entry\n" |
18270 | "Sequence number\n" | |
7336e101 SP |
18271 | "Specify large community to reject\n" |
18272 | "Specify large community to accept\n" | |
18273 | LCOMMUNITY_VAL_STR) | |
52951b63 | 18274 | { |
d62a17ae | 18275 | return lcommunity_list_set_vty(vty, argc, argv, |
18276 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
18277 | } |
18278 | ||
7336e101 SP |
18279 | DEFUN (lcommunity_list_expanded, |
18280 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 18281 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18282 | BGP_STR |
18283 | LCOMMUNITY_LIST_STR | |
18284 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
18285 | "Sequence number of an entry\n" |
18286 | "Sequence number\n" | |
7336e101 SP |
18287 | "Specify large community to reject\n" |
18288 | "Specify large community to accept\n" | |
18289 | "An ordered list as a regular-expression\n") | |
57d187bc | 18290 | { |
d62a17ae | 18291 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 18292 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
18293 | } |
18294 | ||
7336e101 SP |
18295 | DEFUN (lcommunity_list_name_standard, |
18296 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 18297 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
18298 | BGP_STR |
18299 | LCOMMUNITY_LIST_STR | |
18300 | "Specify standard large-community-list\n" | |
18301 | "Large Community list name\n" | |
2f8cc0e5 DA |
18302 | "Sequence number of an entry\n" |
18303 | "Sequence number\n" | |
7336e101 SP |
18304 | "Specify large community to reject\n" |
18305 | "Specify large community to accept\n" | |
18306 | LCOMMUNITY_VAL_STR) | |
52951b63 | 18307 | { |
d62a17ae | 18308 | return lcommunity_list_set_vty(vty, argc, argv, |
18309 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
18310 | } |
18311 | ||
7336e101 SP |
18312 | DEFUN (lcommunity_list_name_expanded, |
18313 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 18314 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18315 | BGP_STR |
18316 | LCOMMUNITY_LIST_STR | |
18317 | "Specify expanded large-community-list\n" | |
18318 | "Large Community list name\n" | |
2f8cc0e5 DA |
18319 | "Sequence number of an entry\n" |
18320 | "Sequence number\n" | |
7336e101 SP |
18321 | "Specify large community to reject\n" |
18322 | "Specify large community to accept\n" | |
18323 | "An ordered list as a regular-expression\n") | |
57d187bc | 18324 | { |
d62a17ae | 18325 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 18326 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
18327 | } |
18328 | ||
4378f57c DA |
18329 | DEFUN (no_lcommunity_list_all, |
18330 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
18331 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
18332 | NO_STR | |
18333 | BGP_STR | |
18334 | LCOMMUNITY_LIST_STR | |
18335 | "Large Community list number (standard)\n" | |
18336 | "Large Community list number (expanded)\n" | |
18337 | "Large Community list name\n") | |
57d187bc | 18338 | { |
7336e101 SP |
18339 | return lcommunity_list_unset_vty(vty, argc, argv, |
18340 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
18341 | } |
18342 | ||
4378f57c DA |
18343 | DEFUN (no_lcommunity_list_name_standard_all, |
18344 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
18345 | "no bgp large-community-list standard WORD", | |
18346 | NO_STR | |
18347 | BGP_STR | |
18348 | LCOMMUNITY_LIST_STR | |
18349 | "Specify standard large-community-list\n" | |
18350 | "Large Community list name\n") | |
18351 | { | |
18352 | return lcommunity_list_unset_vty(vty, argc, argv, | |
18353 | LARGE_COMMUNITY_LIST_STANDARD); | |
18354 | } | |
18355 | ||
7336e101 SP |
18356 | DEFUN (no_lcommunity_list_name_expanded_all, |
18357 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
18358 | "no bgp large-community-list expanded WORD", | |
18359 | NO_STR | |
18360 | BGP_STR | |
18361 | LCOMMUNITY_LIST_STR | |
18362 | "Specify expanded large-community-list\n" | |
18363 | "Large Community list name\n") | |
57d187bc | 18364 | { |
d62a17ae | 18365 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18366 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
18367 | } |
18368 | ||
7336e101 SP |
18369 | DEFUN (no_lcommunity_list_standard, |
18370 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 18371 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
18372 | NO_STR |
18373 | BGP_STR | |
18374 | LCOMMUNITY_LIST_STR | |
18375 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
18376 | "Sequence number of an entry\n" |
18377 | "Sequence number\n" | |
7336e101 SP |
18378 | "Specify large community to reject\n" |
18379 | "Specify large community to accept\n" | |
18380 | LCOMMUNITY_VAL_STR) | |
57d187bc | 18381 | { |
d62a17ae | 18382 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18383 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
18384 | } |
18385 | ||
7336e101 SP |
18386 | DEFUN (no_lcommunity_list_expanded, |
18387 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 18388 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18389 | NO_STR |
18390 | BGP_STR | |
18391 | LCOMMUNITY_LIST_STR | |
18392 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
18393 | "Sequence number of an entry\n" |
18394 | "Sequence number\n" | |
7336e101 SP |
18395 | "Specify large community to reject\n" |
18396 | "Specify large community to accept\n" | |
18397 | "An ordered list as a regular-expression\n") | |
57d187bc | 18398 | { |
d62a17ae | 18399 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18400 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
18401 | } |
18402 | ||
7336e101 SP |
18403 | DEFUN (no_lcommunity_list_name_standard, |
18404 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 18405 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
18406 | NO_STR |
18407 | BGP_STR | |
18408 | LCOMMUNITY_LIST_STR | |
18409 | "Specify standard large-community-list\n" | |
18410 | "Large Community list name\n" | |
2f8cc0e5 DA |
18411 | "Sequence number of an entry\n" |
18412 | "Sequence number\n" | |
7336e101 SP |
18413 | "Specify large community to reject\n" |
18414 | "Specify large community to accept\n" | |
18415 | LCOMMUNITY_VAL_STR) | |
57d187bc | 18416 | { |
d62a17ae | 18417 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18418 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
18419 | } |
18420 | ||
7336e101 SP |
18421 | DEFUN (no_lcommunity_list_name_expanded, |
18422 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 18423 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18424 | NO_STR |
18425 | BGP_STR | |
18426 | LCOMMUNITY_LIST_STR | |
18427 | "Specify expanded large-community-list\n" | |
18428 | "Large community list name\n" | |
2f8cc0e5 DA |
18429 | "Sequence number of an entry\n" |
18430 | "Sequence number\n" | |
7336e101 SP |
18431 | "Specify large community to reject\n" |
18432 | "Specify large community to accept\n" | |
18433 | "An ordered list as a regular-expression\n") | |
57d187bc | 18434 | { |
d62a17ae | 18435 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18436 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
18437 | } |
18438 | ||
d62a17ae | 18439 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
18440 | { | |
18441 | struct community_entry *entry; | |
18442 | ||
18443 | for (entry = list->head; entry; entry = entry->next) { | |
18444 | if (entry == list->head) { | |
18445 | if (all_digit(list->name)) | |
18446 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 18447 | entry->style == |
18448 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 18449 | ? "standard" |
18450 | : "(expanded) access", | |
18451 | list->name); | |
18452 | else | |
18453 | vty_out(vty, | |
18454 | "Named large community %s list %s\n", | |
169b72c8 | 18455 | entry->style == |
18456 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 18457 | ? "standard" |
18458 | : "expanded", | |
18459 | list->name); | |
18460 | } | |
18461 | if (entry->any) | |
18462 | vty_out(vty, " %s\n", | |
18463 | community_direct_str(entry->direct)); | |
18464 | else | |
18465 | vty_out(vty, " %s %s\n", | |
18466 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18467 | community_list_config_str(entry)); |
d62a17ae | 18468 | } |
57d187bc JS |
18469 | } |
18470 | ||
7336e101 SP |
18471 | DEFUN (show_lcommunity_list, |
18472 | show_bgp_lcommunity_list_cmd, | |
18473 | "show bgp large-community-list", | |
57d187bc | 18474 | SHOW_STR |
7336e101 | 18475 | BGP_STR |
57d187bc JS |
18476 | "List large-community list\n") |
18477 | { | |
d62a17ae | 18478 | struct community_list *list; |
18479 | struct community_list_master *cm; | |
57d187bc | 18480 | |
d62a17ae | 18481 | cm = community_list_master_lookup(bgp_clist, |
18482 | LARGE_COMMUNITY_LIST_MASTER); | |
18483 | if (!cm) | |
18484 | return CMD_SUCCESS; | |
57d187bc | 18485 | |
d62a17ae | 18486 | for (list = cm->num.head; list; list = list->next) |
18487 | lcommunity_list_show(vty, list); | |
57d187bc | 18488 | |
d62a17ae | 18489 | for (list = cm->str.head; list; list = list->next) |
18490 | lcommunity_list_show(vty, list); | |
57d187bc | 18491 | |
d62a17ae | 18492 | return CMD_SUCCESS; |
57d187bc JS |
18493 | } |
18494 | ||
7336e101 SP |
18495 | DEFUN (show_lcommunity_list_arg, |
18496 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 18497 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
18498 | SHOW_STR |
18499 | BGP_STR | |
57d187bc | 18500 | "List large-community list\n" |
960b69b9 | 18501 | "Large-community-list number\n" |
18502 | "Large-community-list name\n" | |
18503 | "Detailed information on large-community-list\n") | |
57d187bc | 18504 | { |
d62a17ae | 18505 | struct community_list *list; |
57d187bc | 18506 | |
e237b0d2 | 18507 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 18508 | LARGE_COMMUNITY_LIST_MASTER); |
18509 | if (!list) { | |
960b69b9 | 18510 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 18511 | return CMD_WARNING; |
18512 | } | |
57d187bc | 18513 | |
d62a17ae | 18514 | lcommunity_list_show(vty, list); |
57d187bc | 18515 | |
d62a17ae | 18516 | return CMD_SUCCESS; |
57d187bc JS |
18517 | } |
18518 | ||
718e3744 | 18519 | /* "extcommunity-list" keyword help string. */ |
18520 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
18521 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
18522 | ||
7336e101 SP |
18523 | DEFUN (extcommunity_list_standard, |
18524 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 18525 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 18526 | BGP_STR |
718e3744 | 18527 | EXTCOMMUNITY_LIST_STR |
18528 | "Extended Community list number (standard)\n" | |
718e3744 | 18529 | "Specify standard extcommunity-list\n" |
5bf15956 | 18530 | "Community list name\n" |
2f8cc0e5 DA |
18531 | "Sequence number of an entry\n" |
18532 | "Sequence number\n" | |
718e3744 | 18533 | "Specify community to reject\n" |
18534 | "Specify community to accept\n" | |
18535 | EXTCOMMUNITY_VAL_STR) | |
18536 | { | |
d62a17ae | 18537 | int style = EXTCOMMUNITY_LIST_STANDARD; |
18538 | int direct = 0; | |
18539 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 18540 | char *seq = NULL; |
42f914d4 | 18541 | |
d62a17ae | 18542 | int idx = 0; |
7b9a4750 | 18543 | |
d62a17ae | 18544 | argv_find(argv, argc, "(1-99)", &idx); |
18545 | argv_find(argv, argc, "WORD", &idx); | |
18546 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 18547 | |
409148f6 | 18548 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
18549 | seq = argv[idx]->arg; |
18550 | ||
d62a17ae | 18551 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
18552 | : COMMUNITY_DENY; | |
18553 | argv_find(argv, argc, "AA:NN", &idx); | |
18554 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18555 | |
2f8cc0e5 | 18556 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 18557 | direct, style); |
42f914d4 | 18558 | |
d62a17ae | 18559 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18560 | |
d62a17ae | 18561 | if (ret < 0) { |
18562 | community_list_perror(vty, ret); | |
18563 | return CMD_WARNING_CONFIG_FAILED; | |
18564 | } | |
42f914d4 | 18565 | |
d62a17ae | 18566 | return CMD_SUCCESS; |
718e3744 | 18567 | } |
18568 | ||
7336e101 SP |
18569 | DEFUN (extcommunity_list_name_expanded, |
18570 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 18571 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18572 | BGP_STR |
18573 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 18574 | "Extended Community list number (expanded)\n" |
718e3744 | 18575 | "Specify expanded extcommunity-list\n" |
18576 | "Extended Community list name\n" | |
2f8cc0e5 DA |
18577 | "Sequence number of an entry\n" |
18578 | "Sequence number\n" | |
718e3744 | 18579 | "Specify community to reject\n" |
18580 | "Specify community to accept\n" | |
18581 | "An ordered list as a regular-expression\n") | |
18582 | { | |
d62a17ae | 18583 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
18584 | int direct = 0; | |
18585 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 18586 | char *seq = NULL; |
d62a17ae | 18587 | int idx = 0; |
7336e101 | 18588 | |
d62a17ae | 18589 | argv_find(argv, argc, "(100-500)", &idx); |
18590 | argv_find(argv, argc, "WORD", &idx); | |
18591 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 18592 | |
409148f6 | 18593 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
18594 | seq = argv[idx]->arg; |
18595 | ||
d62a17ae | 18596 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
18597 | : COMMUNITY_DENY; | |
18598 | argv_find(argv, argc, "LINE", &idx); | |
18599 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18600 | |
2f8cc0e5 | 18601 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 18602 | direct, style); |
42f914d4 | 18603 | |
d62a17ae | 18604 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18605 | |
d62a17ae | 18606 | if (ret < 0) { |
18607 | community_list_perror(vty, ret); | |
18608 | return CMD_WARNING_CONFIG_FAILED; | |
18609 | } | |
42f914d4 | 18610 | |
d62a17ae | 18611 | return CMD_SUCCESS; |
718e3744 | 18612 | } |
18613 | ||
7336e101 SP |
18614 | DEFUN (no_extcommunity_list_standard_all, |
18615 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 18616 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18617 | NO_STR |
18618 | BGP_STR | |
18619 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 18620 | "Extended Community list number (standard)\n" |
718e3744 | 18621 | "Specify standard extcommunity-list\n" |
5bf15956 | 18622 | "Community list name\n" |
2f8cc0e5 DA |
18623 | "Sequence number of an entry\n" |
18624 | "Sequence number\n" | |
718e3744 | 18625 | "Specify community to reject\n" |
18626 | "Specify community to accept\n" | |
18627 | EXTCOMMUNITY_VAL_STR) | |
18628 | { | |
d62a17ae | 18629 | int style = EXTCOMMUNITY_LIST_STANDARD; |
18630 | int direct = 0; | |
18631 | char *cl_number_or_name = NULL; | |
d4455c89 | 18632 | char *str = NULL; |
2f8cc0e5 | 18633 | char *seq = NULL; |
d62a17ae | 18634 | int idx = 0; |
d4455c89 | 18635 | |
409148f6 | 18636 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
18637 | seq = argv[idx]->arg; |
18638 | ||
18639 | idx = 0; | |
d4455c89 DA |
18640 | argv_find(argv, argc, "permit", &idx); |
18641 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
18642 | if (idx) { |
18643 | direct = argv_find(argv, argc, "permit", &idx) | |
18644 | ? COMMUNITY_PERMIT | |
18645 | : COMMUNITY_DENY; | |
18646 | ||
18647 | idx = 0; | |
18648 | argv_find(argv, argc, "AA:NN", &idx); | |
18649 | str = argv_concat(argv, argc, idx); | |
18650 | } | |
18651 | ||
18652 | idx = 0; | |
d62a17ae | 18653 | argv_find(argv, argc, "(1-99)", &idx); |
18654 | argv_find(argv, argc, "WORD", &idx); | |
18655 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 18656 | |
d62a17ae | 18657 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 18658 | seq, direct, style); |
42f914d4 | 18659 | |
d62a17ae | 18660 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18661 | |
d62a17ae | 18662 | if (ret < 0) { |
18663 | community_list_perror(vty, ret); | |
18664 | return CMD_WARNING_CONFIG_FAILED; | |
18665 | } | |
42f914d4 | 18666 | |
d62a17ae | 18667 | return CMD_SUCCESS; |
718e3744 | 18668 | } |
18669 | ||
d4455c89 DA |
18670 | ALIAS(no_extcommunity_list_standard_all, |
18671 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
18672 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
36d4bb44 | 18673 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
18674 | "Extended Community list number (standard)\n" |
18675 | "Specify standard extcommunity-list\n" | |
18676 | "Community list name\n") | |
18677 | ||
7336e101 SP |
18678 | DEFUN (no_extcommunity_list_expanded_all, |
18679 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 18680 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18681 | NO_STR |
18682 | BGP_STR | |
18683 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 18684 | "Extended Community list number (expanded)\n" |
718e3744 | 18685 | "Specify expanded extcommunity-list\n" |
5bf15956 | 18686 | "Extended Community list name\n" |
2f8cc0e5 DA |
18687 | "Sequence number of an entry\n" |
18688 | "Sequence number\n" | |
718e3744 | 18689 | "Specify community to reject\n" |
18690 | "Specify community to accept\n" | |
18691 | "An ordered list as a regular-expression\n") | |
18692 | { | |
d62a17ae | 18693 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
18694 | int direct = 0; | |
18695 | char *cl_number_or_name = NULL; | |
d4455c89 | 18696 | char *str = NULL; |
2f8cc0e5 | 18697 | char *seq = NULL; |
d62a17ae | 18698 | int idx = 0; |
d4455c89 | 18699 | |
409148f6 | 18700 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
18701 | seq = argv[idx]->arg; |
18702 | ||
18703 | idx = 0; | |
d4455c89 DA |
18704 | argv_find(argv, argc, "permit", &idx); |
18705 | argv_find(argv, argc, "deny", &idx); | |
18706 | ||
18707 | if (idx) { | |
18708 | direct = argv_find(argv, argc, "permit", &idx) | |
18709 | ? COMMUNITY_PERMIT | |
18710 | : COMMUNITY_DENY; | |
18711 | ||
18712 | idx = 0; | |
18713 | argv_find(argv, argc, "LINE", &idx); | |
18714 | str = argv_concat(argv, argc, idx); | |
18715 | } | |
18716 | ||
18717 | idx = 0; | |
d62a17ae | 18718 | argv_find(argv, argc, "(100-500)", &idx); |
18719 | argv_find(argv, argc, "WORD", &idx); | |
18720 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 18721 | |
d62a17ae | 18722 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 18723 | seq, direct, style); |
42f914d4 | 18724 | |
d62a17ae | 18725 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18726 | |
d62a17ae | 18727 | if (ret < 0) { |
18728 | community_list_perror(vty, ret); | |
18729 | return CMD_WARNING_CONFIG_FAILED; | |
18730 | } | |
42f914d4 | 18731 | |
d62a17ae | 18732 | return CMD_SUCCESS; |
718e3744 | 18733 | } |
18734 | ||
d4455c89 DA |
18735 | ALIAS(no_extcommunity_list_expanded_all, |
18736 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
18737 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
36d4bb44 | 18738 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
18739 | "Extended Community list number (expanded)\n" |
18740 | "Specify expanded extcommunity-list\n" | |
18741 | "Extended Community list name\n") | |
18742 | ||
d62a17ae | 18743 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 18744 | { |
d62a17ae | 18745 | struct community_entry *entry; |
718e3744 | 18746 | |
d62a17ae | 18747 | for (entry = list->head; entry; entry = entry->next) { |
18748 | if (entry == list->head) { | |
18749 | if (all_digit(list->name)) | |
18750 | vty_out(vty, "Extended community %s list %s\n", | |
18751 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
18752 | ? "standard" | |
18753 | : "(expanded) access", | |
18754 | list->name); | |
18755 | else | |
18756 | vty_out(vty, | |
18757 | "Named extended community %s list %s\n", | |
18758 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
18759 | ? "standard" | |
18760 | : "expanded", | |
18761 | list->name); | |
18762 | } | |
18763 | if (entry->any) | |
18764 | vty_out(vty, " %s\n", | |
18765 | community_direct_str(entry->direct)); | |
18766 | else | |
18767 | vty_out(vty, " %s %s\n", | |
18768 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18769 | community_list_config_str(entry)); |
d62a17ae | 18770 | } |
718e3744 | 18771 | } |
18772 | ||
7336e101 SP |
18773 | DEFUN (show_extcommunity_list, |
18774 | show_bgp_extcommunity_list_cmd, | |
18775 | "show bgp extcommunity-list", | |
718e3744 | 18776 | SHOW_STR |
7336e101 | 18777 | BGP_STR |
718e3744 | 18778 | "List extended-community list\n") |
18779 | { | |
d62a17ae | 18780 | struct community_list *list; |
18781 | struct community_list_master *cm; | |
718e3744 | 18782 | |
d62a17ae | 18783 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
18784 | if (!cm) | |
18785 | return CMD_SUCCESS; | |
718e3744 | 18786 | |
d62a17ae | 18787 | for (list = cm->num.head; list; list = list->next) |
18788 | extcommunity_list_show(vty, list); | |
718e3744 | 18789 | |
d62a17ae | 18790 | for (list = cm->str.head; list; list = list->next) |
18791 | extcommunity_list_show(vty, list); | |
718e3744 | 18792 | |
d62a17ae | 18793 | return CMD_SUCCESS; |
718e3744 | 18794 | } |
18795 | ||
7336e101 SP |
18796 | DEFUN (show_extcommunity_list_arg, |
18797 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 18798 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
18799 | SHOW_STR |
18800 | BGP_STR | |
718e3744 | 18801 | "List extended-community list\n" |
18802 | "Extcommunity-list number\n" | |
960b69b9 | 18803 | "Extcommunity-list name\n" |
18804 | "Detailed information on extcommunity-list\n") | |
718e3744 | 18805 | { |
d62a17ae | 18806 | int idx_comm_list = 3; |
18807 | struct community_list *list; | |
718e3744 | 18808 | |
e237b0d2 | 18809 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 18810 | EXTCOMMUNITY_LIST_MASTER); |
18811 | if (!list) { | |
18812 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
18813 | return CMD_WARNING; | |
18814 | } | |
718e3744 | 18815 | |
d62a17ae | 18816 | extcommunity_list_show(vty, list); |
718e3744 | 18817 | |
d62a17ae | 18818 | return CMD_SUCCESS; |
718e3744 | 18819 | } |
6b0655a2 | 18820 | |
718e3744 | 18821 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 18822 | static int community_list_config_write(struct vty *vty) |
18823 | { | |
18824 | struct community_list *list; | |
18825 | struct community_entry *entry; | |
18826 | struct community_list_master *cm; | |
18827 | int write = 0; | |
18828 | ||
18829 | /* Community-list. */ | |
18830 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
18831 | ||
18832 | for (list = cm->num.head; list; list = list->next) | |
18833 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18834 | vty_out(vty, |
18835 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
18836 | list->name, entry->seq, | |
d62a17ae | 18837 | community_direct_str(entry->direct), |
18838 | community_list_config_str(entry)); | |
18839 | write++; | |
18840 | } | |
18841 | for (list = cm->str.head; list; list = list->next) | |
18842 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18843 | vty_out(vty, |
18844 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 18845 | entry->style == COMMUNITY_LIST_STANDARD |
18846 | ? "standard" | |
18847 | : "expanded", | |
2f8cc0e5 DA |
18848 | list->name, entry->seq, |
18849 | community_direct_str(entry->direct), | |
d62a17ae | 18850 | community_list_config_str(entry)); |
18851 | write++; | |
18852 | } | |
18853 | ||
18854 | /* Extcommunity-list. */ | |
18855 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
18856 | ||
18857 | for (list = cm->num.head; list; list = list->next) | |
18858 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18859 | vty_out(vty, |
18860 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
18861 | list->name, entry->seq, | |
18862 | community_direct_str(entry->direct), | |
d62a17ae | 18863 | community_list_config_str(entry)); |
18864 | write++; | |
18865 | } | |
18866 | for (list = cm->str.head; list; list = list->next) | |
18867 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18868 | vty_out(vty, |
6cde4b45 | 18869 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 18870 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
18871 | ? "standard" | |
18872 | : "expanded", | |
2f8cc0e5 DA |
18873 | list->name, entry->seq, |
18874 | community_direct_str(entry->direct), | |
d62a17ae | 18875 | community_list_config_str(entry)); |
18876 | write++; | |
18877 | } | |
18878 | ||
18879 | ||
18880 | /* lcommunity-list. */ | |
18881 | cm = community_list_master_lookup(bgp_clist, | |
18882 | LARGE_COMMUNITY_LIST_MASTER); | |
18883 | ||
18884 | for (list = cm->num.head; list; list = list->next) | |
18885 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18886 | vty_out(vty, |
6cde4b45 | 18887 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
18888 | list->name, entry->seq, |
18889 | community_direct_str(entry->direct), | |
d62a17ae | 18890 | community_list_config_str(entry)); |
18891 | write++; | |
18892 | } | |
18893 | for (list = cm->str.head; list; list = list->next) | |
18894 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18895 | vty_out(vty, |
6cde4b45 | 18896 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 18897 | |
d62a17ae | 18898 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
18899 | ? "standard" | |
18900 | : "expanded", | |
2f8cc0e5 | 18901 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 18902 | community_list_config_str(entry)); |
18903 | write++; | |
18904 | } | |
18905 | ||
18906 | return write; | |
18907 | } | |
18908 | ||
612c2c15 | 18909 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 18910 | static struct cmd_node community_list_node = { |
f4b8291f | 18911 | .name = "community list", |
62b346ee DL |
18912 | .node = COMMUNITY_LIST_NODE, |
18913 | .prompt = "", | |
612c2c15 | 18914 | .config_write = community_list_config_write, |
718e3744 | 18915 | }; |
18916 | ||
d62a17ae | 18917 | static void community_list_vty(void) |
18918 | { | |
612c2c15 | 18919 | install_node(&community_list_node); |
d62a17ae | 18920 | |
18921 | /* Community-list. */ | |
7336e101 SP |
18922 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
18923 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
18924 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 18925 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 18926 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 18927 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
18928 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
18929 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 18930 | |
18931 | /* Extcommunity-list. */ | |
7336e101 SP |
18932 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
18933 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
18934 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
18935 | install_element(CONFIG_NODE, |
18936 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 18937 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
18938 | install_element(CONFIG_NODE, |
18939 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
18940 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
18941 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 18942 | |
18943 | /* Large Community List */ | |
7336e101 | 18944 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
18945 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
18946 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 18947 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
18948 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
18949 | install_element(CONFIG_NODE, | |
18950 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
18951 | install_element(CONFIG_NODE, |
18952 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
18953 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
18954 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
18955 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
18956 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
18957 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
18958 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 18959 | } |