]>
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 | ||
5d5393b9 | 76 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
77 | { |
78 | .val_bool = false, | |
79 | .match_profile = "traditional", | |
80 | .match_version = "< 7.4", | |
81 | }, | |
82 | { .val_bool = true }, | |
5d5393b9 DL |
83 | ) |
84 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
4c1458b5 DL |
85 | { .val_bool = true, .match_profile = "datacenter", }, |
86 | { .val_bool = false }, | |
5d5393b9 | 87 | ) |
aef999a2 DA |
88 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
89 | { .val_bool = true, .match_profile = "datacenter", }, | |
90 | { .val_bool = false }, | |
91 | ) | |
5d5393b9 | 92 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
93 | { .val_bool = true, .match_profile = "datacenter", }, |
94 | { .val_bool = false }, | |
5d5393b9 DL |
95 | ) |
96 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
4c1458b5 DL |
97 | { .val_bool = true, .match_profile = "datacenter", }, |
98 | { .val_bool = false }, | |
5d5393b9 DL |
99 | ) |
100 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
101 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
102 | { .val_ulong = 120 }, | |
103 | ) | |
104 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
105 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
106 | { .val_ulong = 180 }, | |
107 | ) | |
108 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
109 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
110 | { .val_ulong = 60 }, | |
111 | ) | |
1d3fdccf DA |
112 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
113 | { .val_bool = false, .match_profile = "datacenter", }, | |
114 | { .val_bool = false, .match_version = "< 7.4", }, | |
115 | { .val_bool = true }, | |
116 | ) | |
5d5393b9 | 117 | |
dd65f45e DL |
118 | DEFINE_HOOK(bgp_inst_config_write, |
119 | (struct bgp *bgp, struct vty *vty), | |
120 | (bgp, vty)) | |
718e3744 | 121 | |
36235319 QY |
122 | #define GR_NO_OPER \ |
123 | "The Graceful Restart No Operation was executed as cmd same as previous one." | |
124 | #define GR_INVALID \ | |
125 | "The Graceful Restart command used is not valid at this moment." | |
d62a17ae | 126 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
127 | struct prefix *range, int exact); | |
128 | ||
055679e9 | 129 | /* Show BGP peer's information. */ |
130 | enum show_type { | |
131 | show_all, | |
132 | show_peer, | |
133 | show_ipv4_all, | |
134 | show_ipv6_all, | |
135 | show_ipv4_peer, | |
136 | show_ipv6_peer | |
137 | }; | |
138 | ||
36235319 QY |
139 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
140 | struct prefix *range, int exact); | |
2986cac2 | 141 | |
36235319 QY |
142 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
143 | struct bgp *bgp, | |
144 | bool use_json, | |
145 | json_object *json); | |
2986cac2 | 146 | |
36235319 QY |
147 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
148 | enum show_type type, | |
149 | const char *ip_str, | |
150 | afi_t afi, bool use_json); | |
2986cac2 | 151 | |
d62a17ae | 152 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
153 | { | |
154 | switch (afi) { | |
155 | case AFI_IP: | |
156 | switch (safi) { | |
157 | case SAFI_UNICAST: | |
158 | return BGP_IPV4_NODE; | |
d62a17ae | 159 | case SAFI_MULTICAST: |
160 | return BGP_IPV4M_NODE; | |
d62a17ae | 161 | case SAFI_LABELED_UNICAST: |
162 | return BGP_IPV4L_NODE; | |
d62a17ae | 163 | case SAFI_MPLS_VPN: |
164 | return BGP_VPNV4_NODE; | |
7c40bf39 | 165 | case SAFI_FLOWSPEC: |
166 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
167 | default: |
168 | /* not expected */ | |
169 | return BGP_IPV4_NODE; | |
d62a17ae | 170 | } |
171 | break; | |
172 | case AFI_IP6: | |
173 | switch (safi) { | |
174 | case SAFI_UNICAST: | |
175 | return BGP_IPV6_NODE; | |
d62a17ae | 176 | case SAFI_MULTICAST: |
177 | return BGP_IPV6M_NODE; | |
d62a17ae | 178 | case SAFI_LABELED_UNICAST: |
179 | return BGP_IPV6L_NODE; | |
d62a17ae | 180 | case SAFI_MPLS_VPN: |
181 | return BGP_VPNV6_NODE; | |
7c40bf39 | 182 | case SAFI_FLOWSPEC: |
183 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
184 | default: |
185 | /* not expected */ | |
186 | return BGP_IPV4_NODE; | |
d62a17ae | 187 | } |
188 | break; | |
189 | case AFI_L2VPN: | |
190 | return BGP_EVPN_NODE; | |
b26f891d | 191 | case AFI_UNSPEC: |
d62a17ae | 192 | case AFI_MAX: |
193 | // We should never be here but to clarify the switch statement.. | |
194 | return BGP_IPV4_NODE; | |
d62a17ae | 195 | } |
196 | ||
197 | // Impossible to happen | |
198 | return BGP_IPV4_NODE; | |
f51bae9c | 199 | } |
20eb8864 | 200 | |
5cb5f4d0 DD |
201 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
202 | { | |
203 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
204 | return "IPv4 Unicast"; | |
205 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
206 | return "IPv4 Multicast"; | |
207 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
208 | return "IPv4 Labeled Unicast"; | |
209 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
210 | return "IPv4 VPN"; | |
211 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
212 | return "IPv4 Encap"; | |
213 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
214 | return "IPv4 Flowspec"; | |
215 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
216 | return "IPv6 Unicast"; | |
217 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
218 | return "IPv6 Multicast"; | |
219 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
220 | return "IPv6 Labeled Unicast"; | |
221 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
222 | return "IPv6 VPN"; | |
223 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
224 | return "IPv6 Encap"; | |
225 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
226 | return "IPv6 Flowspec"; | |
227 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
228 | return "L2VPN EVPN"; | |
8e5509b0 | 229 | else |
5cb5f4d0 | 230 | return "Unknown"; |
5cb5f4d0 DD |
231 | } |
232 | ||
233 | /* | |
234 | * Please note that we have intentionally camelCased | |
235 | * the return strings here. So if you want | |
236 | * to use this function, please ensure you | |
237 | * are doing this within json output | |
238 | */ | |
239 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
240 | { | |
241 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
242 | return "ipv4Unicast"; | |
243 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
244 | return "ipv4Multicast"; | |
245 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
246 | return "ipv4LabeledUnicast"; | |
247 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
248 | return "ipv4Vpn"; | |
249 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
250 | return "ipv4Encap"; | |
251 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
252 | return "ipv4Flowspec"; | |
253 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
254 | return "ipv6Unicast"; | |
255 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
256 | return "ipv6Multicast"; | |
257 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
258 | return "ipv6LabeledUnicast"; | |
259 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
260 | return "ipv6Vpn"; | |
261 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
262 | return "ipv6Encap"; | |
263 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
264 | return "ipv6Flowspec"; | |
265 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
266 | return "l2VpnEvpn"; | |
8e5509b0 | 267 | else |
5cb5f4d0 | 268 | return "Unknown"; |
5cb5f4d0 DD |
269 | } |
270 | ||
718e3744 | 271 | /* Utility function to get address family from current node. */ |
d62a17ae | 272 | afi_t bgp_node_afi(struct vty *vty) |
273 | { | |
274 | afi_t afi; | |
275 | switch (vty->node) { | |
276 | case BGP_IPV6_NODE: | |
277 | case BGP_IPV6M_NODE: | |
278 | case BGP_IPV6L_NODE: | |
279 | case BGP_VPNV6_NODE: | |
7c40bf39 | 280 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 281 | afi = AFI_IP6; |
282 | break; | |
283 | case BGP_EVPN_NODE: | |
284 | afi = AFI_L2VPN; | |
285 | break; | |
286 | default: | |
287 | afi = AFI_IP; | |
288 | break; | |
289 | } | |
290 | return afi; | |
718e3744 | 291 | } |
292 | ||
293 | /* Utility function to get subsequent address family from current | |
294 | node. */ | |
d62a17ae | 295 | safi_t bgp_node_safi(struct vty *vty) |
296 | { | |
297 | safi_t safi; | |
298 | switch (vty->node) { | |
299 | case BGP_VPNV4_NODE: | |
300 | case BGP_VPNV6_NODE: | |
301 | safi = SAFI_MPLS_VPN; | |
302 | break; | |
303 | case BGP_IPV4M_NODE: | |
304 | case BGP_IPV6M_NODE: | |
305 | safi = SAFI_MULTICAST; | |
306 | break; | |
307 | case BGP_EVPN_NODE: | |
308 | safi = SAFI_EVPN; | |
309 | break; | |
310 | case BGP_IPV4L_NODE: | |
311 | case BGP_IPV6L_NODE: | |
312 | safi = SAFI_LABELED_UNICAST; | |
313 | break; | |
7c40bf39 | 314 | case BGP_FLOWSPECV4_NODE: |
315 | case BGP_FLOWSPECV6_NODE: | |
316 | safi = SAFI_FLOWSPEC; | |
317 | break; | |
d62a17ae | 318 | default: |
319 | safi = SAFI_UNICAST; | |
320 | break; | |
321 | } | |
322 | return safi; | |
718e3744 | 323 | } |
324 | ||
55f91488 QY |
325 | /** |
326 | * Converts an AFI in string form to afi_t | |
327 | * | |
328 | * @param afi string, one of | |
329 | * - "ipv4" | |
330 | * - "ipv6" | |
81cf0de5 | 331 | * - "l2vpn" |
55f91488 QY |
332 | * @return the corresponding afi_t |
333 | */ | |
d62a17ae | 334 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
335 | { | |
336 | afi_t afi = AFI_MAX; /* unknown */ | |
337 | if (strmatch(afi_str, "ipv4")) | |
338 | afi = AFI_IP; | |
339 | else if (strmatch(afi_str, "ipv6")) | |
340 | afi = AFI_IP6; | |
81cf0de5 CS |
341 | else if (strmatch(afi_str, "l2vpn")) |
342 | afi = AFI_L2VPN; | |
d62a17ae | 343 | return afi; |
344 | } | |
345 | ||
346 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
347 | afi_t *afi) | |
348 | { | |
349 | int ret = 0; | |
350 | if (argv_find(argv, argc, "ipv4", index)) { | |
351 | ret = 1; | |
352 | if (afi) | |
353 | *afi = AFI_IP; | |
354 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
355 | ret = 1; | |
356 | if (afi) | |
357 | *afi = AFI_IP6; | |
8688b3e7 DS |
358 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
359 | ret = 1; | |
360 | if (afi) | |
361 | *afi = AFI_L2VPN; | |
d62a17ae | 362 | } |
363 | return ret; | |
46f296b4 LB |
364 | } |
365 | ||
375a2e67 | 366 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 367 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
368 | { | |
369 | safi_t safi = SAFI_MAX; /* unknown */ | |
370 | if (strmatch(safi_str, "multicast")) | |
371 | safi = SAFI_MULTICAST; | |
372 | else if (strmatch(safi_str, "unicast")) | |
373 | safi = SAFI_UNICAST; | |
374 | else if (strmatch(safi_str, "vpn")) | |
375 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
376 | else if (strmatch(safi_str, "evpn")) |
377 | safi = SAFI_EVPN; | |
d62a17ae | 378 | else if (strmatch(safi_str, "labeled-unicast")) |
379 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 380 | else if (strmatch(safi_str, "flowspec")) |
381 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 382 | return safi; |
383 | } | |
384 | ||
385 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
386 | safi_t *safi) | |
387 | { | |
388 | int ret = 0; | |
389 | if (argv_find(argv, argc, "unicast", index)) { | |
390 | ret = 1; | |
391 | if (safi) | |
392 | *safi = SAFI_UNICAST; | |
393 | } else if (argv_find(argv, argc, "multicast", index)) { | |
394 | ret = 1; | |
395 | if (safi) | |
396 | *safi = SAFI_MULTICAST; | |
397 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
398 | ret = 1; | |
399 | if (safi) | |
400 | *safi = SAFI_LABELED_UNICAST; | |
401 | } else if (argv_find(argv, argc, "vpn", index)) { | |
402 | ret = 1; | |
403 | if (safi) | |
404 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
405 | } else if (argv_find(argv, argc, "evpn", index)) { |
406 | ret = 1; | |
407 | if (safi) | |
408 | *safi = SAFI_EVPN; | |
7c40bf39 | 409 | } else if (argv_find(argv, argc, "flowspec", index)) { |
410 | ret = 1; | |
411 | if (safi) | |
412 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 413 | } |
414 | return ret; | |
46f296b4 LB |
415 | } |
416 | ||
5d5393b9 DL |
417 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
418 | enum bgp_instance_type inst_type) | |
419 | { | |
420 | int ret = bgp_get(bgp, as, name, inst_type); | |
421 | ||
422 | if (ret == BGP_CREATED) { | |
423 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
424 | DFLT_BGP_CONNECT_RETRY); | |
425 | ||
426 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 427 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 428 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 429 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
430 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
431 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 432 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 433 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 434 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 435 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
436 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
437 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
5d5393b9 DL |
438 | |
439 | ret = BGP_SUCCESS; | |
440 | } | |
441 | return ret; | |
442 | } | |
443 | ||
7eeee51e | 444 | /* |
f212a857 | 445 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 446 | * |
f212a857 DS |
447 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
448 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
449 | * to appropriate values for the calling function. This is to allow the |
450 | * calling function to make decisions appropriate for the show command | |
451 | * that is being parsed. | |
452 | * | |
453 | * The show commands are generally of the form: | |
d62a17ae | 454 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
455 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
456 | * |
457 | * Since we use argv_find if the show command in particular doesn't have: | |
458 | * [ip] | |
18c57037 | 459 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 460 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
461 | * The command parsing should still be ok. |
462 | * | |
463 | * vty -> The vty for the command so we can output some useful data in | |
464 | * the event of a parse error in the vrf. | |
465 | * argv -> The command tokens | |
466 | * argc -> How many command tokens we have | |
d62a17ae | 467 | * idx -> The current place in the command, generally should be 0 for this |
468 | * function | |
7eeee51e DS |
469 | * afi -> The parsed afi if it was included in the show command, returned here |
470 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 471 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 472 | * use_json -> json is configured or not |
7eeee51e DS |
473 | * |
474 | * The function returns the correct location in the parse tree for the | |
475 | * last token found. | |
0e37c258 DS |
476 | * |
477 | * Returns 0 for failure to parse correctly, else the idx position of where | |
478 | * it found the last token. | |
7eeee51e | 479 | */ |
d62a17ae | 480 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
481 | struct cmd_token **argv, int argc, | |
482 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 483 | struct bgp **bgp, bool use_json) |
d62a17ae | 484 | { |
485 | char *vrf_name = NULL; | |
486 | ||
487 | assert(afi); | |
488 | assert(safi); | |
489 | assert(bgp); | |
490 | ||
491 | if (argv_find(argv, argc, "ip", idx)) | |
492 | *afi = AFI_IP; | |
493 | ||
9a8bdf1c | 494 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 495 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
496 | else if (argv_find(argv, argc, "vrf", idx)) { |
497 | vrf_name = argv[*idx + 1]->arg; | |
498 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
499 | vrf_name = NULL; | |
500 | } | |
501 | if (vrf_name) { | |
d62a17ae | 502 | if (strmatch(vrf_name, "all")) |
503 | *bgp = NULL; | |
504 | else { | |
505 | *bgp = bgp_lookup_by_name(vrf_name); | |
506 | if (!*bgp) { | |
52e5b8c4 SP |
507 | if (use_json) { |
508 | json_object *json = NULL; | |
509 | json = json_object_new_object(); | |
510 | json_object_string_add( | |
511 | json, "warning", | |
512 | "View/Vrf is unknown"); | |
513 | vty_out(vty, "%s\n", | |
514 | json_object_to_json_string_ext(json, | |
515 | JSON_C_TO_STRING_PRETTY)); | |
516 | json_object_free(json); | |
517 | } | |
ca61fd25 DS |
518 | else |
519 | vty_out(vty, "View/Vrf %s is unknown\n", | |
520 | vrf_name); | |
d62a17ae | 521 | *idx = 0; |
522 | return 0; | |
523 | } | |
524 | } | |
525 | } else { | |
526 | *bgp = bgp_get_default(); | |
527 | if (!*bgp) { | |
52e5b8c4 SP |
528 | if (use_json) { |
529 | json_object *json = NULL; | |
530 | json = json_object_new_object(); | |
531 | json_object_string_add( | |
532 | json, "warning", | |
533 | "Default BGP instance not found"); | |
534 | vty_out(vty, "%s\n", | |
535 | json_object_to_json_string_ext(json, | |
536 | JSON_C_TO_STRING_PRETTY)); | |
537 | json_object_free(json); | |
538 | } | |
ca61fd25 DS |
539 | else |
540 | vty_out(vty, | |
541 | "Default BGP instance not found\n"); | |
d62a17ae | 542 | *idx = 0; |
543 | return 0; | |
544 | } | |
545 | } | |
546 | ||
547 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
548 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
549 | ||
550 | *idx += 1; | |
551 | return *idx; | |
552 | } | |
553 | ||
3dc339cd | 554 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 555 | { |
556 | struct interface *ifp = NULL; | |
557 | ||
558 | if (su->sa.sa_family == AF_INET) | |
559 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
560 | else if (su->sa.sa_family == AF_INET6) | |
561 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
562 | su->sin6.sin6_scope_id, | |
563 | bgp->vrf_id); | |
564 | ||
565 | if (ifp) | |
3dc339cd | 566 | return true; |
d62a17ae | 567 | |
3dc339cd | 568 | return false; |
718e3744 | 569 | } |
570 | ||
571 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
572 | /* This is used only for configuration, so disallow if attempted on |
573 | * a dynamic neighbor. | |
574 | */ | |
d62a17ae | 575 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
576 | { | |
577 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
578 | int ret; | |
579 | union sockunion su; | |
580 | struct peer *peer; | |
581 | ||
582 | if (!bgp) { | |
583 | return NULL; | |
584 | } | |
585 | ||
586 | ret = str2sockunion(ip_str, &su); | |
587 | if (ret < 0) { | |
588 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
589 | if (!peer) { | |
590 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
591 | == NULL) { | |
592 | vty_out(vty, | |
593 | "%% Malformed address or name: %s\n", | |
594 | ip_str); | |
595 | return NULL; | |
596 | } | |
597 | } | |
598 | } else { | |
599 | peer = peer_lookup(bgp, &su); | |
600 | if (!peer) { | |
601 | vty_out(vty, | |
602 | "%% Specify remote-as or peer-group commands first\n"); | |
603 | return NULL; | |
604 | } | |
605 | if (peer_dynamic_neighbor(peer)) { | |
606 | vty_out(vty, | |
607 | "%% Operation not allowed on a dynamic neighbor\n"); | |
608 | return NULL; | |
609 | } | |
610 | } | |
611 | return peer; | |
718e3744 | 612 | } |
613 | ||
614 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
615 | /* This is used only for configuration, so disallow if attempted on |
616 | * a dynamic neighbor. | |
617 | */ | |
d62a17ae | 618 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
619 | { | |
620 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
621 | int ret; | |
622 | union sockunion su; | |
623 | struct peer *peer = NULL; | |
624 | struct peer_group *group = NULL; | |
625 | ||
626 | if (!bgp) { | |
627 | return NULL; | |
628 | } | |
629 | ||
630 | ret = str2sockunion(peer_str, &su); | |
631 | if (ret == 0) { | |
632 | /* IP address, locate peer. */ | |
633 | peer = peer_lookup(bgp, &su); | |
634 | } else { | |
635 | /* Not IP, could match either peer configured on interface or a | |
636 | * group. */ | |
637 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
638 | if (!peer) | |
639 | group = peer_group_lookup(bgp, peer_str); | |
640 | } | |
641 | ||
642 | if (peer) { | |
643 | if (peer_dynamic_neighbor(peer)) { | |
644 | vty_out(vty, | |
645 | "%% Operation not allowed on a dynamic neighbor\n"); | |
646 | return NULL; | |
647 | } | |
648 | ||
649 | return peer; | |
650 | } | |
651 | ||
652 | if (group) | |
653 | return group->conf; | |
654 | ||
655 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
656 | ||
657 | return NULL; | |
658 | } | |
659 | ||
660 | int bgp_vty_return(struct vty *vty, int ret) | |
661 | { | |
662 | const char *str = NULL; | |
663 | ||
664 | switch (ret) { | |
665 | case BGP_ERR_INVALID_VALUE: | |
666 | str = "Invalid value"; | |
667 | break; | |
668 | case BGP_ERR_INVALID_FLAG: | |
669 | str = "Invalid flag"; | |
670 | break; | |
671 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
672 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
673 | break; | |
674 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
675 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
676 | break; | |
677 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
678 | str = "Specify remote-as or peer-group remote AS first"; | |
679 | break; | |
680 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
681 | str = "Cannot change the peer-group. Deconfigure first"; | |
682 | break; | |
683 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
684 | str = "Peer is not a member of this peer-group"; | |
685 | break; | |
686 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
687 | str = "Prefix/distribute list can not co-exist"; | |
688 | break; | |
689 | case BGP_ERR_NOT_INTERNAL_PEER: | |
690 | str = "Invalid command. Not an internal neighbor"; | |
691 | break; | |
692 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
693 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
694 | break; | |
695 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
696 | str = "Local-AS allowed only for EBGP peers"; | |
697 | break; | |
698 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
699 | str = "Cannot have local-as same as BGP AS number"; | |
700 | break; | |
701 | case BGP_ERR_TCPSIG_FAILED: | |
702 | str = "Error while applying TCP-Sig to session(s)"; | |
703 | break; | |
704 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
705 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
706 | break; | |
707 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
708 | str = "ttl-security only allowed for EBGP peers"; | |
709 | break; | |
710 | case BGP_ERR_AS_OVERRIDE: | |
711 | str = "as-override cannot be configured for IBGP peers"; | |
712 | break; | |
713 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
714 | str = "Invalid limit for number of dynamic neighbors"; | |
715 | break; | |
716 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
717 | str = "Dynamic neighbor listen range already exists"; | |
718 | break; | |
719 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
720 | str = "Operation not allowed on a dynamic neighbor"; | |
721 | break; | |
722 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
723 | str = "Operation not allowed on a directly connected neighbor"; | |
724 | break; | |
725 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 726 | str = GR_INVALID; |
727 | break; | |
728 | case BGP_ERR_GR_INVALID_CMD: | |
729 | str = "The Graceful Restart command used is not valid at this moment."; | |
730 | break; | |
731 | case BGP_ERR_GR_OPERATION_FAILED: | |
732 | str = "The Graceful Restart Operation failed due to an err."; | |
733 | break; | |
734 | case BGP_GR_NO_OPERATION: | |
735 | str = GR_NO_OPER; | |
d62a17ae | 736 | break; |
737 | } | |
738 | if (str) { | |
739 | vty_out(vty, "%% %s\n", str); | |
740 | return CMD_WARNING_CONFIG_FAILED; | |
741 | } | |
742 | return CMD_SUCCESS; | |
718e3744 | 743 | } |
744 | ||
7aafcaca | 745 | /* BGP clear sort. */ |
d62a17ae | 746 | enum clear_sort { |
747 | clear_all, | |
748 | clear_peer, | |
749 | clear_group, | |
750 | clear_external, | |
751 | clear_as | |
7aafcaca DS |
752 | }; |
753 | ||
d62a17ae | 754 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
755 | safi_t safi, int error) | |
756 | { | |
757 | switch (error) { | |
758 | case BGP_ERR_AF_UNCONFIGURED: | |
759 | vty_out(vty, | |
760 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
5cb5f4d0 | 761 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 762 | break; |
763 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
764 | vty_out(vty, | |
765 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
766 | peer->host); | |
767 | break; | |
768 | default: | |
769 | break; | |
770 | } | |
7aafcaca DS |
771 | } |
772 | ||
dc912615 | 773 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 774 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
775 | { |
776 | int ret = 0; | |
777 | ||
778 | /* if afi/.safi not specified, spin thru all of them */ | |
779 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
780 | afi_t tmp_afi; | |
781 | safi_t tmp_safi; | |
782 | ||
783 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
784 | if (!peer->afc[tmp_afi][tmp_safi]) | |
785 | continue; | |
786 | ||
787 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 788 | ret = peer_clear(peer, nnode); |
dc912615 DS |
789 | else |
790 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
791 | stype); | |
792 | } | |
793 | /* if afi specified and safi not, spin thru safis on this afi */ | |
794 | } else if (safi == SAFI_UNSPEC) { | |
795 | safi_t tmp_safi; | |
796 | ||
797 | for (tmp_safi = SAFI_UNICAST; | |
798 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
799 | if (!peer->afc[afi][tmp_safi]) | |
800 | continue; | |
801 | ||
802 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 803 | ret = peer_clear(peer, nnode); |
dc912615 DS |
804 | else |
805 | ret = peer_clear_soft(peer, afi, | |
806 | tmp_safi, stype); | |
807 | } | |
808 | /* both afi/safi specified, let the caller know if not defined */ | |
809 | } else { | |
810 | if (!peer->afc[afi][safi]) | |
811 | return 1; | |
812 | ||
813 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 814 | ret = peer_clear(peer, nnode); |
dc912615 DS |
815 | else |
816 | ret = peer_clear_soft(peer, afi, safi, stype); | |
817 | } | |
818 | ||
819 | return ret; | |
820 | } | |
821 | ||
7aafcaca | 822 | /* `clear ip bgp' functions. */ |
d62a17ae | 823 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
824 | enum clear_sort sort, enum bgp_clear_type stype, | |
825 | const char *arg) | |
826 | { | |
dc912615 | 827 | int ret = 0; |
3ae8bfa5 | 828 | bool found = false; |
d62a17ae | 829 | struct peer *peer; |
dc95985f | 830 | |
831 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 832 | |
833 | /* Clear all neighbors. */ | |
834 | /* | |
835 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
836 | * nodes on the BGP instance as that may get freed if it is a |
837 | * doppelganger | |
d62a17ae | 838 | */ |
839 | if (sort == clear_all) { | |
840 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 841 | |
842 | bgp_peer_gr_flags_update(peer); | |
843 | ||
36235319 | 844 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 845 | gr_router_detected = true; |
846 | ||
c368171c | 847 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 848 | stype); |
d62a17ae | 849 | |
850 | if (ret < 0) | |
851 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
dc95985f | 852 | } |
853 | ||
36235319 QY |
854 | if (gr_router_detected |
855 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 856 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
857 | } else if (!gr_router_detected |
858 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 859 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 860 | } |
d62a17ae | 861 | |
862 | /* This is to apply read-only mode on this clear. */ | |
863 | if (stype == BGP_CLEAR_SOFT_NONE) | |
864 | bgp->update_delay_over = 0; | |
865 | ||
866 | return CMD_SUCCESS; | |
7aafcaca DS |
867 | } |
868 | ||
3ae8bfa5 | 869 | /* Clear specified neighbor. */ |
d62a17ae | 870 | if (sort == clear_peer) { |
871 | union sockunion su; | |
d62a17ae | 872 | |
873 | /* Make sockunion for lookup. */ | |
874 | ret = str2sockunion(arg, &su); | |
875 | if (ret < 0) { | |
876 | peer = peer_lookup_by_conf_if(bgp, arg); | |
877 | if (!peer) { | |
878 | peer = peer_lookup_by_hostname(bgp, arg); | |
879 | if (!peer) { | |
880 | vty_out(vty, | |
881 | "Malformed address or name: %s\n", | |
882 | arg); | |
883 | return CMD_WARNING; | |
884 | } | |
885 | } | |
886 | } else { | |
887 | peer = peer_lookup(bgp, &su); | |
888 | if (!peer) { | |
889 | vty_out(vty, | |
890 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
891 | arg); | |
892 | return CMD_WARNING; | |
893 | } | |
894 | } | |
7aafcaca | 895 | |
dc95985f | 896 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
897 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
898 | ||
dc912615 DS |
899 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
900 | ||
901 | /* if afi/safi not defined for this peer, let caller know */ | |
902 | if (ret == 1) | |
3ae8bfa5 | 903 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 904 | |
d62a17ae | 905 | if (ret < 0) |
906 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 907 | |
d62a17ae | 908 | return CMD_SUCCESS; |
7aafcaca | 909 | } |
7aafcaca | 910 | |
3ae8bfa5 | 911 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 912 | if (sort == clear_group) { |
913 | struct peer_group *group; | |
7aafcaca | 914 | |
d62a17ae | 915 | group = peer_group_lookup(bgp, arg); |
916 | if (!group) { | |
917 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
918 | return CMD_WARNING; | |
919 | } | |
920 | ||
921 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 922 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 923 | |
d62a17ae | 924 | if (ret < 0) |
925 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
926 | else |
927 | found = true; | |
d62a17ae | 928 | } |
3ae8bfa5 PM |
929 | |
930 | if (!found) | |
931 | vty_out(vty, | |
932 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 933 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 934 | |
d62a17ae | 935 | return CMD_SUCCESS; |
7aafcaca | 936 | } |
7aafcaca | 937 | |
3ae8bfa5 | 938 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 939 | if (sort == clear_external) { |
940 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
941 | if (peer->sort == BGP_PEER_IBGP) | |
942 | continue; | |
7aafcaca | 943 | |
dc95985f | 944 | bgp_peer_gr_flags_update(peer); |
945 | ||
36235319 | 946 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 947 | gr_router_detected = true; |
dc95985f | 948 | |
c368171c | 949 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 950 | |
d62a17ae | 951 | if (ret < 0) |
952 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
953 | else |
954 | found = true; | |
d62a17ae | 955 | } |
3ae8bfa5 | 956 | |
36235319 QY |
957 | if (gr_router_detected |
958 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 959 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
960 | } else if (!gr_router_detected |
961 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 962 | bgp_zebra_send_capabilities(bgp, true); |
963 | } | |
964 | ||
3ae8bfa5 PM |
965 | if (!found) |
966 | vty_out(vty, | |
967 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 968 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 969 | |
d62a17ae | 970 | return CMD_SUCCESS; |
971 | } | |
972 | ||
3ae8bfa5 | 973 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 974 | if (sort == clear_as) { |
3ae8bfa5 | 975 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 976 | |
977 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
978 | if (peer->as != as) | |
979 | continue; | |
980 | ||
dc95985f | 981 | bgp_peer_gr_flags_update(peer); |
982 | ||
36235319 | 983 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 984 | gr_router_detected = true; |
dc95985f | 985 | |
c368171c | 986 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 987 | |
988 | if (ret < 0) | |
989 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
990 | else |
991 | found = true; | |
d62a17ae | 992 | } |
3ae8bfa5 | 993 | |
36235319 QY |
994 | if (gr_router_detected |
995 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 996 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
997 | } else if (!gr_router_detected |
998 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 999 | bgp_zebra_send_capabilities(bgp, true); |
1000 | } | |
1001 | ||
3ae8bfa5 | 1002 | if (!found) |
d62a17ae | 1003 | vty_out(vty, |
3ae8bfa5 | 1004 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 1005 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1006 | |
d62a17ae | 1007 | return CMD_SUCCESS; |
1008 | } | |
1009 | ||
1010 | return CMD_SUCCESS; | |
1011 | } | |
1012 | ||
1013 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
1014 | safi_t safi, enum clear_sort sort, | |
1015 | enum bgp_clear_type stype, const char *arg) | |
1016 | { | |
1017 | struct bgp *bgp; | |
1018 | ||
1019 | /* BGP structure lookup. */ | |
1020 | if (name) { | |
1021 | bgp = bgp_lookup_by_name(name); | |
1022 | if (bgp == NULL) { | |
1023 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
1024 | return CMD_WARNING; | |
1025 | } | |
1026 | } else { | |
1027 | bgp = bgp_get_default(); | |
1028 | if (bgp == NULL) { | |
1029 | vty_out(vty, "No BGP process is configured\n"); | |
1030 | return CMD_WARNING; | |
1031 | } | |
1032 | } | |
1033 | ||
1034 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
1035 | } |
1036 | ||
1037 | /* clear soft inbound */ | |
d62a17ae | 1038 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1039 | { |
99b3ebd3 NS |
1040 | afi_t afi; |
1041 | safi_t safi; | |
1042 | ||
1043 | FOREACH_AFI_SAFI (afi, safi) | |
1044 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1045 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1046 | } |
1047 | ||
1048 | /* clear soft outbound */ | |
d62a17ae | 1049 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1050 | { |
99b3ebd3 NS |
1051 | afi_t afi; |
1052 | safi_t safi; | |
1053 | ||
1054 | FOREACH_AFI_SAFI (afi, safi) | |
1055 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1056 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1057 | } |
1058 | ||
1059 | ||
f787d7a0 | 1060 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1061 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1062 | #endif |
1063 | ||
8029b216 AK |
1064 | DEFUN_HIDDEN (bgp_local_mac, |
1065 | bgp_local_mac_cmd, | |
093e3f23 | 1066 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1067 | BGP_STR |
1068 | "Local MAC config\n" | |
1069 | "VxLAN Network Identifier\n" | |
1070 | "VNI number\n" | |
1071 | "local mac\n" | |
1072 | "mac address\n" | |
1073 | "mac-mobility sequence\n" | |
1074 | "seq number\n") | |
1075 | { | |
1076 | int rv; | |
1077 | vni_t vni; | |
1078 | struct ethaddr mac; | |
1079 | struct ipaddr ip; | |
1080 | uint32_t seq; | |
1081 | struct bgp *bgp; | |
1082 | ||
1083 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1084 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1085 | vty_out(vty, "%% Malformed MAC address\n"); | |
1086 | return CMD_WARNING; | |
1087 | } | |
1088 | memset(&ip, 0, sizeof(ip)); | |
1089 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1090 | ||
1091 | bgp = bgp_get_default(); | |
1092 | if (!bgp) { | |
1093 | vty_out(vty, "Default BGP instance is not there\n"); | |
1094 | return CMD_WARNING; | |
1095 | } | |
1096 | ||
b5e140c8 AK |
1097 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1098 | zero_esi); | |
8029b216 AK |
1099 | if (rv < 0) { |
1100 | vty_out(vty, "Internal error\n"); | |
1101 | return CMD_WARNING; | |
1102 | } | |
1103 | ||
1104 | return CMD_SUCCESS; | |
1105 | } | |
1106 | ||
1107 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1108 | no_bgp_local_mac_cmd, | |
093e3f23 | 1109 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1110 | NO_STR |
1111 | BGP_STR | |
1112 | "Local MAC config\n" | |
1113 | "VxLAN Network Identifier\n" | |
1114 | "VNI number\n" | |
1115 | "local mac\n" | |
1116 | "mac address\n") | |
1117 | { | |
1118 | int rv; | |
1119 | vni_t vni; | |
1120 | struct ethaddr mac; | |
1121 | struct ipaddr ip; | |
1122 | struct bgp *bgp; | |
1123 | ||
1124 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1125 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1126 | vty_out(vty, "%% Malformed MAC address\n"); | |
1127 | return CMD_WARNING; | |
1128 | } | |
1129 | memset(&ip, 0, sizeof(ip)); | |
1130 | ||
1131 | bgp = bgp_get_default(); | |
1132 | if (!bgp) { | |
1133 | vty_out(vty, "Default BGP instance is not there\n"); | |
1134 | return CMD_WARNING; | |
1135 | } | |
1136 | ||
ec0ab544 | 1137 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1138 | if (rv < 0) { |
1139 | vty_out(vty, "Internal error\n"); | |
1140 | return CMD_WARNING; | |
1141 | } | |
1142 | ||
1143 | return CMD_SUCCESS; | |
1144 | } | |
1145 | ||
718e3744 | 1146 | DEFUN (no_synchronization, |
1147 | no_synchronization_cmd, | |
1148 | "no synchronization", | |
1149 | NO_STR | |
1150 | "Perform IGP synchronization\n") | |
1151 | { | |
d62a17ae | 1152 | return CMD_SUCCESS; |
718e3744 | 1153 | } |
1154 | ||
1155 | DEFUN (no_auto_summary, | |
1156 | no_auto_summary_cmd, | |
1157 | "no auto-summary", | |
1158 | NO_STR | |
1159 | "Enable automatic network number summarization\n") | |
1160 | { | |
d62a17ae | 1161 | return CMD_SUCCESS; |
718e3744 | 1162 | } |
3d515fd9 | 1163 | |
718e3744 | 1164 | /* "router bgp" commands. */ |
505e5056 | 1165 | DEFUN_NOSH (router_bgp, |
f412b39a | 1166 | router_bgp_cmd, |
2ed9fe4a | 1167 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1168 | ROUTER_STR |
1169 | BGP_STR | |
31500417 DW |
1170 | AS_STR |
1171 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1172 | { |
d62a17ae | 1173 | int idx_asn = 2; |
1174 | int idx_view_vrf = 3; | |
1175 | int idx_vrf = 4; | |
ecec9495 | 1176 | int is_new_bgp = 0; |
d62a17ae | 1177 | int ret; |
1178 | as_t as; | |
1179 | struct bgp *bgp; | |
1180 | const char *name = NULL; | |
1181 | enum bgp_instance_type inst_type; | |
1182 | ||
1183 | // "router bgp" without an ASN | |
1184 | if (argc == 2) { | |
1185 | // Pending: Make VRF option available for ASN less config | |
1186 | bgp = bgp_get_default(); | |
1187 | ||
1188 | if (bgp == NULL) { | |
1189 | vty_out(vty, "%% No BGP process is configured\n"); | |
1190 | return CMD_WARNING_CONFIG_FAILED; | |
1191 | } | |
1192 | ||
1193 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1194 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1195 | return CMD_WARNING_CONFIG_FAILED; |
1196 | } | |
1197 | } | |
1198 | ||
1199 | // "router bgp X" | |
1200 | else { | |
1201 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1202 | ||
1203 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1204 | if (argc > 3) { | |
1205 | name = argv[idx_vrf]->arg; | |
1206 | ||
9a8bdf1c PG |
1207 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1208 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1209 | name = NULL; | |
1210 | else | |
1211 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1212 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1213 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1214 | } | |
1215 | ||
ecec9495 AD |
1216 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1217 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1218 | ||
5d5393b9 | 1219 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
d62a17ae | 1220 | switch (ret) { |
d62a17ae | 1221 | case BGP_ERR_AS_MISMATCH: |
1222 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1223 | return CMD_WARNING_CONFIG_FAILED; | |
1224 | case BGP_ERR_INSTANCE_MISMATCH: | |
1225 | vty_out(vty, | |
1226 | "BGP instance name and AS number mismatch\n"); | |
1227 | vty_out(vty, | |
1228 | "BGP instance is already running; AS is %u\n", | |
1229 | as); | |
1230 | return CMD_WARNING_CONFIG_FAILED; | |
1231 | } | |
1232 | ||
3bd70bf8 PZ |
1233 | /* |
1234 | * If we just instantiated the default instance, complete | |
1235 | * any pending VRF-VPN leaking that was configured via | |
1236 | * earlier "router bgp X vrf FOO" blocks. | |
1237 | */ | |
ecec9495 | 1238 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1239 | vpn_leak_postchange_all(); |
1240 | ||
48381346 CS |
1241 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1242 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1243 | /* Pending: handle when user tries to change a view to vrf n vv. |
1244 | */ | |
1245 | } | |
1246 | ||
0b5131c9 MK |
1247 | /* unset the auto created flag as the user config is now present */ |
1248 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1249 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1250 | ||
1251 | return CMD_SUCCESS; | |
718e3744 | 1252 | } |
1253 | ||
718e3744 | 1254 | /* "no router bgp" commands. */ |
1255 | DEFUN (no_router_bgp, | |
1256 | no_router_bgp_cmd, | |
2ed9fe4a | 1257 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1258 | NO_STR |
1259 | ROUTER_STR | |
1260 | BGP_STR | |
31500417 DW |
1261 | AS_STR |
1262 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1263 | { |
d62a17ae | 1264 | int idx_asn = 3; |
1265 | int idx_vrf = 5; | |
1266 | as_t as; | |
1267 | struct bgp *bgp; | |
1268 | const char *name = NULL; | |
718e3744 | 1269 | |
d62a17ae | 1270 | // "no router bgp" without an ASN |
1271 | if (argc == 3) { | |
1272 | // Pending: Make VRF option available for ASN less config | |
1273 | bgp = bgp_get_default(); | |
718e3744 | 1274 | |
d62a17ae | 1275 | if (bgp == NULL) { |
1276 | vty_out(vty, "%% No BGP process is configured\n"); | |
1277 | return CMD_WARNING_CONFIG_FAILED; | |
1278 | } | |
7fb21a9f | 1279 | |
d62a17ae | 1280 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1281 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1282 | return CMD_WARNING_CONFIG_FAILED; |
1283 | } | |
0b5131c9 MK |
1284 | |
1285 | if (bgp->l3vni) { | |
1286 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1287 | bgp->l3vni); | |
1288 | return CMD_WARNING_CONFIG_FAILED; | |
1289 | } | |
d62a17ae | 1290 | } else { |
1291 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1292 | |
d62a17ae | 1293 | if (argc > 4) |
1294 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1295 | |
d62a17ae | 1296 | /* Lookup bgp structure. */ |
1297 | bgp = bgp_lookup(as, name); | |
1298 | if (!bgp) { | |
1299 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1300 | return CMD_WARNING_CONFIG_FAILED; | |
1301 | } | |
0b5131c9 MK |
1302 | |
1303 | if (bgp->l3vni) { | |
dd5868c2 | 1304 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1305 | bgp->l3vni); |
1306 | return CMD_WARNING_CONFIG_FAILED; | |
1307 | } | |
dd5868c2 DS |
1308 | |
1309 | /* Cannot delete default instance if vrf instances exist */ | |
1310 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1311 | struct listnode *node; | |
1312 | struct bgp *tmp_bgp; | |
1313 | ||
1314 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1315 | if (tmp_bgp->inst_type | |
1316 | == BGP_INSTANCE_TYPE_VRF) { | |
1317 | vty_out(vty, | |
1318 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1319 | return CMD_WARNING_CONFIG_FAILED; | |
1320 | } | |
1321 | } | |
1322 | } | |
d62a17ae | 1323 | } |
718e3744 | 1324 | |
9ecf931b CS |
1325 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1326 | return CMD_WARNING_CONFIG_FAILED; | |
1327 | ||
d62a17ae | 1328 | bgp_delete(bgp); |
718e3744 | 1329 | |
d62a17ae | 1330 | return CMD_SUCCESS; |
718e3744 | 1331 | } |
1332 | ||
6b0655a2 | 1333 | |
718e3744 | 1334 | /* BGP router-id. */ |
1335 | ||
f787d7a0 | 1336 | DEFPY (bgp_router_id, |
718e3744 | 1337 | bgp_router_id_cmd, |
1338 | "bgp router-id A.B.C.D", | |
1339 | BGP_STR | |
1340 | "Override configured router identifier\n" | |
1341 | "Manually configured router identifier\n") | |
1342 | { | |
d62a17ae | 1343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1344 | bgp_router_id_static_set(bgp, router_id); | |
1345 | return CMD_SUCCESS; | |
718e3744 | 1346 | } |
1347 | ||
f787d7a0 | 1348 | DEFPY (no_bgp_router_id, |
718e3744 | 1349 | no_bgp_router_id_cmd, |
31500417 | 1350 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1351 | NO_STR |
1352 | BGP_STR | |
31500417 DW |
1353 | "Override configured router identifier\n" |
1354 | "Manually configured router identifier\n") | |
718e3744 | 1355 | { |
d62a17ae | 1356 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1357 | |
d62a17ae | 1358 | if (router_id_str) { |
1359 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1360 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1361 | return CMD_WARNING_CONFIG_FAILED; | |
1362 | } | |
e018c7cc | 1363 | } |
718e3744 | 1364 | |
d62a17ae | 1365 | router_id.s_addr = 0; |
1366 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1367 | |
d62a17ae | 1368 | return CMD_SUCCESS; |
718e3744 | 1369 | } |
1370 | ||
6b0655a2 | 1371 | |
718e3744 | 1372 | /* BGP Cluster ID. */ |
718e3744 | 1373 | DEFUN (bgp_cluster_id, |
1374 | bgp_cluster_id_cmd, | |
838758ac | 1375 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1376 | BGP_STR |
1377 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1378 | "Route-Reflector Cluster-id in IP address format\n" |
1379 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1380 | { |
d62a17ae | 1381 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1382 | int idx_ipv4 = 2; | |
1383 | int ret; | |
1384 | struct in_addr cluster; | |
718e3744 | 1385 | |
d62a17ae | 1386 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1387 | if (!ret) { | |
1388 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1389 | return CMD_WARNING_CONFIG_FAILED; | |
1390 | } | |
718e3744 | 1391 | |
d62a17ae | 1392 | bgp_cluster_id_set(bgp, &cluster); |
1393 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1394 | |
d62a17ae | 1395 | return CMD_SUCCESS; |
718e3744 | 1396 | } |
1397 | ||
718e3744 | 1398 | DEFUN (no_bgp_cluster_id, |
1399 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1400 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1401 | NO_STR |
1402 | BGP_STR | |
838758ac DW |
1403 | "Configure Route-Reflector Cluster-id\n" |
1404 | "Route-Reflector Cluster-id in IP address format\n" | |
1405 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1406 | { |
d62a17ae | 1407 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1408 | bgp_cluster_id_unset(bgp); | |
1409 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1410 | |
d62a17ae | 1411 | return CMD_SUCCESS; |
718e3744 | 1412 | } |
1413 | ||
718e3744 | 1414 | DEFUN (bgp_confederation_identifier, |
1415 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1416 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1417 | "BGP specific commands\n" |
1418 | "AS confederation parameters\n" | |
1419 | "AS number\n" | |
1420 | "Set routing domain confederation AS\n") | |
1421 | { | |
d62a17ae | 1422 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1423 | int idx_number = 3; | |
1424 | as_t as; | |
718e3744 | 1425 | |
d62a17ae | 1426 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1427 | |
d62a17ae | 1428 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1429 | |
d62a17ae | 1430 | return CMD_SUCCESS; |
718e3744 | 1431 | } |
1432 | ||
1433 | DEFUN (no_bgp_confederation_identifier, | |
1434 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1435 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1436 | NO_STR |
1437 | "BGP specific commands\n" | |
1438 | "AS confederation parameters\n" | |
3a2d747c QY |
1439 | "AS number\n" |
1440 | "Set routing domain confederation AS\n") | |
718e3744 | 1441 | { |
d62a17ae | 1442 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1443 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1444 | |
d62a17ae | 1445 | return CMD_SUCCESS; |
718e3744 | 1446 | } |
1447 | ||
718e3744 | 1448 | DEFUN (bgp_confederation_peers, |
1449 | bgp_confederation_peers_cmd, | |
12dcf78e | 1450 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1451 | "BGP specific commands\n" |
1452 | "AS confederation parameters\n" | |
1453 | "Peer ASs in BGP confederation\n" | |
1454 | AS_STR) | |
1455 | { | |
d62a17ae | 1456 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1457 | int idx_asn = 3; | |
1458 | as_t as; | |
1459 | int i; | |
718e3744 | 1460 | |
d62a17ae | 1461 | for (i = idx_asn; i < argc; i++) { |
1462 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1463 | |
d62a17ae | 1464 | if (bgp->as == as) { |
1465 | vty_out(vty, | |
1466 | "%% Local member-AS not allowed in confed peer list\n"); | |
1467 | continue; | |
1468 | } | |
718e3744 | 1469 | |
d62a17ae | 1470 | bgp_confederation_peers_add(bgp, as); |
1471 | } | |
1472 | return CMD_SUCCESS; | |
718e3744 | 1473 | } |
1474 | ||
1475 | DEFUN (no_bgp_confederation_peers, | |
1476 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1477 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1478 | NO_STR |
1479 | "BGP specific commands\n" | |
1480 | "AS confederation parameters\n" | |
1481 | "Peer ASs in BGP confederation\n" | |
1482 | AS_STR) | |
1483 | { | |
d62a17ae | 1484 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1485 | int idx_asn = 4; | |
1486 | as_t as; | |
1487 | int i; | |
718e3744 | 1488 | |
d62a17ae | 1489 | for (i = idx_asn; i < argc; i++) { |
1490 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1491 | |
d62a17ae | 1492 | bgp_confederation_peers_remove(bgp, as); |
1493 | } | |
1494 | return CMD_SUCCESS; | |
718e3744 | 1495 | } |
6b0655a2 | 1496 | |
5e242b0d DS |
1497 | /** |
1498 | * Central routine for maximum-paths configuration. | |
1499 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1500 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1501 | */ | |
d62a17ae | 1502 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1503 | const char *mpaths, uint16_t options, |
d62a17ae | 1504 | int set) |
1505 | { | |
1506 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1507 | uint16_t maxpaths = 0; |
d62a17ae | 1508 | int ret; |
1509 | afi_t afi; | |
1510 | safi_t safi; | |
1511 | ||
1512 | afi = bgp_node_afi(vty); | |
1513 | safi = bgp_node_safi(vty); | |
1514 | ||
1515 | if (set) { | |
1516 | maxpaths = strtol(mpaths, NULL, 10); | |
1517 | if (maxpaths > multipath_num) { | |
1518 | vty_out(vty, | |
1519 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1520 | maxpaths, multipath_num); | |
1521 | return CMD_WARNING_CONFIG_FAILED; | |
1522 | } | |
1523 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1524 | options); | |
1525 | } else | |
1526 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1527 | ||
1528 | if (ret < 0) { | |
1529 | vty_out(vty, | |
1530 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1531 | (set == 1) ? "" : "un", | |
1532 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1533 | maxpaths, afi, safi); | |
1534 | return CMD_WARNING_CONFIG_FAILED; | |
1535 | } | |
1536 | ||
1537 | bgp_recalculate_all_bestpaths(bgp); | |
1538 | ||
1539 | return CMD_SUCCESS; | |
165b5fff JB |
1540 | } |
1541 | ||
abc920f8 DS |
1542 | DEFUN (bgp_maxmed_admin, |
1543 | bgp_maxmed_admin_cmd, | |
1544 | "bgp max-med administrative ", | |
1545 | BGP_STR | |
1546 | "Advertise routes with max-med\n" | |
1547 | "Administratively applied, for an indefinite period\n") | |
1548 | { | |
d62a17ae | 1549 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1550 | |
d62a17ae | 1551 | bgp->v_maxmed_admin = 1; |
1552 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1553 | |
d62a17ae | 1554 | bgp_maxmed_update(bgp); |
abc920f8 | 1555 | |
d62a17ae | 1556 | return CMD_SUCCESS; |
abc920f8 DS |
1557 | } |
1558 | ||
1559 | DEFUN (bgp_maxmed_admin_medv, | |
1560 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1561 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1562 | BGP_STR |
1563 | "Advertise routes with max-med\n" | |
1564 | "Administratively applied, for an indefinite period\n" | |
1565 | "Max MED value to be used\n") | |
1566 | { | |
d62a17ae | 1567 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1568 | int idx_number = 3; | |
abc920f8 | 1569 | |
d62a17ae | 1570 | bgp->v_maxmed_admin = 1; |
1571 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1572 | |
d62a17ae | 1573 | bgp_maxmed_update(bgp); |
abc920f8 | 1574 | |
d62a17ae | 1575 | return CMD_SUCCESS; |
abc920f8 DS |
1576 | } |
1577 | ||
1578 | DEFUN (no_bgp_maxmed_admin, | |
1579 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1580 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1581 | NO_STR |
1582 | BGP_STR | |
1583 | "Advertise routes with max-med\n" | |
838758ac DW |
1584 | "Administratively applied, for an indefinite period\n" |
1585 | "Max MED value to be used\n") | |
abc920f8 | 1586 | { |
d62a17ae | 1587 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1588 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1589 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1590 | bgp_maxmed_update(bgp); | |
abc920f8 | 1591 | |
d62a17ae | 1592 | return CMD_SUCCESS; |
abc920f8 DS |
1593 | } |
1594 | ||
abc920f8 DS |
1595 | DEFUN (bgp_maxmed_onstartup, |
1596 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1597 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1598 | BGP_STR |
1599 | "Advertise routes with max-med\n" | |
1600 | "Effective on a startup\n" | |
1601 | "Time (seconds) period for max-med\n" | |
1602 | "Max MED value to be used\n") | |
1603 | { | |
d62a17ae | 1604 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1605 | int idx = 0; | |
4668a151 | 1606 | |
d62a17ae | 1607 | argv_find(argv, argc, "(5-86400)", &idx); |
1608 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1609 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1610 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1611 | else | |
1612 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1613 | |
d62a17ae | 1614 | bgp_maxmed_update(bgp); |
abc920f8 | 1615 | |
d62a17ae | 1616 | return CMD_SUCCESS; |
abc920f8 DS |
1617 | } |
1618 | ||
1619 | DEFUN (no_bgp_maxmed_onstartup, | |
1620 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1621 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1622 | NO_STR |
1623 | BGP_STR | |
1624 | "Advertise routes with max-med\n" | |
838758ac DW |
1625 | "Effective on a startup\n" |
1626 | "Time (seconds) period for max-med\n" | |
1627 | "Max MED value to be used\n") | |
abc920f8 | 1628 | { |
d62a17ae | 1629 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1630 | |
d62a17ae | 1631 | /* Cancel max-med onstartup if its on */ |
1632 | if (bgp->t_maxmed_onstartup) { | |
1633 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1634 | bgp->maxmed_onstartup_over = 1; | |
1635 | } | |
abc920f8 | 1636 | |
d62a17ae | 1637 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1638 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1639 | |
d62a17ae | 1640 | bgp_maxmed_update(bgp); |
abc920f8 | 1641 | |
d62a17ae | 1642 | return CMD_SUCCESS; |
abc920f8 DS |
1643 | } |
1644 | ||
d62a17ae | 1645 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1646 | const char *wait) | |
f188f2c4 | 1647 | { |
d62a17ae | 1648 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1649 | uint16_t update_delay; |
1650 | uint16_t establish_wait; | |
f188f2c4 | 1651 | |
d62a17ae | 1652 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1653 | |
d62a17ae | 1654 | if (!wait) /* update-delay <delay> */ |
1655 | { | |
1656 | bgp->v_update_delay = update_delay; | |
1657 | bgp->v_establish_wait = bgp->v_update_delay; | |
1658 | return CMD_SUCCESS; | |
1659 | } | |
f188f2c4 | 1660 | |
d62a17ae | 1661 | /* update-delay <delay> <establish-wait> */ |
1662 | establish_wait = atoi(wait); | |
1663 | if (update_delay < establish_wait) { | |
1664 | vty_out(vty, | |
1665 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1666 | return CMD_WARNING_CONFIG_FAILED; | |
1667 | } | |
f188f2c4 | 1668 | |
d62a17ae | 1669 | bgp->v_update_delay = update_delay; |
1670 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1671 | |
d62a17ae | 1672 | return CMD_SUCCESS; |
f188f2c4 DS |
1673 | } |
1674 | ||
d62a17ae | 1675 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1676 | { |
d62a17ae | 1677 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1678 | |
d62a17ae | 1679 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1680 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1681 | |
d62a17ae | 1682 | return CMD_SUCCESS; |
f188f2c4 DS |
1683 | } |
1684 | ||
2b791107 | 1685 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1686 | { |
d62a17ae | 1687 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1688 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1689 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1690 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1691 | vty_out(vty, "\n"); | |
1692 | } | |
f188f2c4 DS |
1693 | } |
1694 | ||
1695 | ||
1696 | /* Update-delay configuration */ | |
1697 | DEFUN (bgp_update_delay, | |
1698 | bgp_update_delay_cmd, | |
6147e2c6 | 1699 | "update-delay (0-3600)", |
f188f2c4 DS |
1700 | "Force initial delay for best-path and updates\n" |
1701 | "Seconds\n") | |
1702 | { | |
d62a17ae | 1703 | int idx_number = 1; |
1704 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1705 | } |
1706 | ||
1707 | DEFUN (bgp_update_delay_establish_wait, | |
1708 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1709 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1710 | "Force initial delay for best-path and updates\n" |
1711 | "Seconds\n" | |
f188f2c4 DS |
1712 | "Seconds\n") |
1713 | { | |
d62a17ae | 1714 | int idx_number = 1; |
1715 | int idx_number_2 = 2; | |
1716 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1717 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1718 | } |
1719 | ||
1720 | /* Update-delay deconfiguration */ | |
1721 | DEFUN (no_bgp_update_delay, | |
1722 | no_bgp_update_delay_cmd, | |
838758ac DW |
1723 | "no update-delay [(0-3600) [(1-3600)]]", |
1724 | NO_STR | |
f188f2c4 | 1725 | "Force initial delay for best-path and updates\n" |
838758ac | 1726 | "Seconds\n" |
7111c1a0 | 1727 | "Seconds\n") |
f188f2c4 | 1728 | { |
d62a17ae | 1729 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1730 | } |
1731 | ||
5e242b0d | 1732 | |
8fa7732f QY |
1733 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1734 | bool set) | |
cb1faec9 | 1735 | { |
d62a17ae | 1736 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1737 | |
8fa7732f QY |
1738 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1739 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1740 | |
1741 | return CMD_SUCCESS; | |
1742 | } | |
1743 | ||
8fa7732f QY |
1744 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1745 | bool set) | |
555e09d4 QY |
1746 | { |
1747 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1748 | ||
8fa7732f QY |
1749 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1750 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1751 | |
d62a17ae | 1752 | return CMD_SUCCESS; |
cb1faec9 DS |
1753 | } |
1754 | ||
2b791107 | 1755 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1756 | { |
555e09d4 QY |
1757 | uint32_t quanta = |
1758 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1759 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1760 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1761 | } |
1762 | ||
555e09d4 QY |
1763 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1764 | { | |
1765 | uint32_t quanta = | |
1766 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1767 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1768 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1769 | } |
cb1faec9 | 1770 | |
8fa7732f QY |
1771 | /* Packet quanta configuration |
1772 | * | |
1773 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1774 | * thread. When changing these limits be careful to prevent stack overflow. | |
1775 | * | |
1776 | * Furthermore, the maximums used here should correspond to | |
1777 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1778 | */ | |
1779 | DEFPY (bgp_wpkt_quanta, | |
cb1faec9 | 1780 | bgp_wpkt_quanta_cmd, |
8fa7732f | 1781 | "[no] write-quanta (1-64)$quanta", |
d7fa34c1 | 1782 | NO_STR |
8fa7732f | 1783 | "How many packets to write to peer socket per run\n" |
cb1faec9 DS |
1784 | "Number of packets\n") |
1785 | { | |
8fa7732f | 1786 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); |
cb1faec9 DS |
1787 | } |
1788 | ||
8fa7732f | 1789 | DEFPY (bgp_rpkt_quanta, |
555e09d4 | 1790 | bgp_rpkt_quanta_cmd, |
8fa7732f | 1791 | "[no] read-quanta (1-10)$quanta", |
555e09d4 QY |
1792 | NO_STR |
1793 | "How many packets to read from peer socket per I/O cycle\n" | |
1794 | "Number of packets\n") | |
1795 | { | |
8fa7732f | 1796 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); |
555e09d4 QY |
1797 | } |
1798 | ||
2b791107 | 1799 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1800 | { |
37a333fe | 1801 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1802 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1803 | } |
1804 | ||
1805 | ||
1806 | DEFUN (bgp_coalesce_time, | |
1807 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1808 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1809 | "Subgroup coalesce timer\n" |
1810 | "Subgroup coalesce timer value (in ms)\n") | |
1811 | { | |
d62a17ae | 1812 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1813 | |
d62a17ae | 1814 | int idx = 0; |
1815 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1816 | bgp->heuristic_coalesce = false; |
d62a17ae | 1817 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1818 | return CMD_SUCCESS; | |
3f9c7369 DS |
1819 | } |
1820 | ||
1821 | DEFUN (no_bgp_coalesce_time, | |
1822 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1823 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1824 | NO_STR |
3f9c7369 DS |
1825 | "Subgroup coalesce timer\n" |
1826 | "Subgroup coalesce timer value (in ms)\n") | |
1827 | { | |
d62a17ae | 1828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1829 | |
37a333fe | 1830 | bgp->heuristic_coalesce = true; |
d62a17ae | 1831 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1832 | return CMD_SUCCESS; | |
3f9c7369 DS |
1833 | } |
1834 | ||
5e242b0d DS |
1835 | /* Maximum-paths configuration */ |
1836 | DEFUN (bgp_maxpaths, | |
1837 | bgp_maxpaths_cmd, | |
6319fd63 | 1838 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1839 | "Forward packets over multiple paths\n" |
1840 | "Number of paths\n") | |
1841 | { | |
d62a17ae | 1842 | int idx_number = 1; |
1843 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1844 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1845 | } |
1846 | ||
d62a17ae | 1847 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1848 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1849 | "Forward packets over multiple paths\n" | |
1850 | "Number of paths\n") | |
596c17ba | 1851 | |
165b5fff JB |
1852 | DEFUN (bgp_maxpaths_ibgp, |
1853 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1854 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1855 | "Forward packets over multiple paths\n" |
1856 | "iBGP-multipath\n" | |
1857 | "Number of paths\n") | |
1858 | { | |
d62a17ae | 1859 | int idx_number = 2; |
1860 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1861 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1862 | } |
165b5fff | 1863 | |
d62a17ae | 1864 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1865 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1866 | "Forward packets over multiple paths\n" | |
1867 | "iBGP-multipath\n" | |
1868 | "Number of paths\n") | |
596c17ba | 1869 | |
5e242b0d DS |
1870 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1871 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1872 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1873 | "Forward packets over multiple paths\n" |
1874 | "iBGP-multipath\n" | |
1875 | "Number of paths\n" | |
1876 | "Match the cluster length\n") | |
1877 | { | |
d62a17ae | 1878 | int idx_number = 2; |
1879 | return bgp_maxpaths_config_vty( | |
1880 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1881 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1882 | } |
1883 | ||
d62a17ae | 1884 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1885 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1886 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1887 | "Forward packets over multiple paths\n" | |
1888 | "iBGP-multipath\n" | |
1889 | "Number of paths\n" | |
1890 | "Match the cluster length\n") | |
596c17ba | 1891 | |
165b5fff JB |
1892 | DEFUN (no_bgp_maxpaths, |
1893 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1894 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1895 | NO_STR |
1896 | "Forward packets over multiple paths\n" | |
1897 | "Number of paths\n") | |
1898 | { | |
d62a17ae | 1899 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1900 | } |
1901 | ||
d62a17ae | 1902 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1903 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1904 | "Forward packets over multiple paths\n" |
1905 | "Number of paths\n") | |
596c17ba | 1906 | |
165b5fff JB |
1907 | DEFUN (no_bgp_maxpaths_ibgp, |
1908 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1909 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1910 | NO_STR |
1911 | "Forward packets over multiple paths\n" | |
1912 | "iBGP-multipath\n" | |
838758ac DW |
1913 | "Number of paths\n" |
1914 | "Match the cluster length\n") | |
165b5fff | 1915 | { |
d62a17ae | 1916 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1917 | } |
1918 | ||
d62a17ae | 1919 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1920 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1921 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1922 | NO_STR | |
1923 | "Forward packets over multiple paths\n" | |
1924 | "iBGP-multipath\n" | |
1925 | "Number of paths\n" | |
1926 | "Match the cluster length\n") | |
596c17ba | 1927 | |
dd65f45e DL |
1928 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
1929 | afi_t afi, safi_t safi) | |
165b5fff | 1930 | { |
d62a17ae | 1931 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1932 | vty_out(vty, " maximum-paths %d\n", |
1933 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1934 | } | |
165b5fff | 1935 | |
d62a17ae | 1936 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1937 | vty_out(vty, " maximum-paths ibgp %d", |
1938 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1939 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1940 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1941 | vty_out(vty, " equal-cluster-length"); | |
1942 | vty_out(vty, "\n"); | |
1943 | } | |
165b5fff | 1944 | } |
6b0655a2 | 1945 | |
718e3744 | 1946 | /* BGP timers. */ |
1947 | ||
1948 | DEFUN (bgp_timers, | |
1949 | bgp_timers_cmd, | |
6147e2c6 | 1950 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1951 | "Adjust routing timers\n" |
1952 | "BGP timers\n" | |
1953 | "Keepalive interval\n" | |
1954 | "Holdtime\n") | |
1955 | { | |
d62a17ae | 1956 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1957 | int idx_number = 2; | |
1958 | int idx_number_2 = 3; | |
1959 | unsigned long keepalive = 0; | |
1960 | unsigned long holdtime = 0; | |
718e3744 | 1961 | |
d62a17ae | 1962 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1963 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1964 | |
d62a17ae | 1965 | /* Holdtime value check. */ |
1966 | if (holdtime < 3 && holdtime != 0) { | |
1967 | vty_out(vty, | |
1968 | "%% hold time value must be either 0 or greater than 3\n"); | |
1969 | return CMD_WARNING_CONFIG_FAILED; | |
1970 | } | |
718e3744 | 1971 | |
5d5393b9 | 1972 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY); |
718e3744 | 1973 | |
d62a17ae | 1974 | return CMD_SUCCESS; |
718e3744 | 1975 | } |
1976 | ||
1977 | DEFUN (no_bgp_timers, | |
1978 | no_bgp_timers_cmd, | |
838758ac | 1979 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1980 | NO_STR |
1981 | "Adjust routing timers\n" | |
838758ac DW |
1982 | "BGP timers\n" |
1983 | "Keepalive interval\n" | |
1984 | "Holdtime\n") | |
718e3744 | 1985 | { |
d62a17ae | 1986 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5d5393b9 DL |
1987 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, |
1988 | DFLT_BGP_CONNECT_RETRY); | |
718e3744 | 1989 | |
d62a17ae | 1990 | return CMD_SUCCESS; |
718e3744 | 1991 | } |
1992 | ||
6b0655a2 | 1993 | |
718e3744 | 1994 | DEFUN (bgp_client_to_client_reflection, |
1995 | bgp_client_to_client_reflection_cmd, | |
1996 | "bgp client-to-client reflection", | |
1997 | "BGP specific commands\n" | |
1998 | "Configure client to client route reflection\n" | |
1999 | "reflection of routes allowed\n") | |
2000 | { | |
d62a17ae | 2001 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2002 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
d62a17ae | 2003 | bgp_clear_star_soft_out(vty, bgp->name); |
7aafcaca | 2004 | |
d62a17ae | 2005 | return CMD_SUCCESS; |
718e3744 | 2006 | } |
2007 | ||
2008 | DEFUN (no_bgp_client_to_client_reflection, | |
2009 | no_bgp_client_to_client_reflection_cmd, | |
2010 | "no bgp client-to-client reflection", | |
2011 | NO_STR | |
2012 | "BGP specific commands\n" | |
2013 | "Configure client to client route reflection\n" | |
2014 | "reflection of routes allowed\n") | |
2015 | { | |
d62a17ae | 2016 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2017 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
d62a17ae | 2018 | bgp_clear_star_soft_out(vty, bgp->name); |
7aafcaca | 2019 | |
d62a17ae | 2020 | return CMD_SUCCESS; |
718e3744 | 2021 | } |
2022 | ||
2023 | /* "bgp always-compare-med" configuration. */ | |
2024 | DEFUN (bgp_always_compare_med, | |
2025 | bgp_always_compare_med_cmd, | |
2026 | "bgp always-compare-med", | |
2027 | "BGP specific commands\n" | |
2028 | "Allow comparing MED from different neighbors\n") | |
2029 | { | |
d62a17ae | 2030 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2031 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); |
d62a17ae | 2032 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2033 | |
d62a17ae | 2034 | return CMD_SUCCESS; |
718e3744 | 2035 | } |
2036 | ||
2037 | DEFUN (no_bgp_always_compare_med, | |
2038 | no_bgp_always_compare_med_cmd, | |
2039 | "no bgp always-compare-med", | |
2040 | NO_STR | |
2041 | "BGP specific commands\n" | |
2042 | "Allow comparing MED from different neighbors\n") | |
2043 | { | |
d62a17ae | 2044 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2045 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); |
d62a17ae | 2046 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2047 | |
d62a17ae | 2048 | return CMD_SUCCESS; |
718e3744 | 2049 | } |
6b0655a2 | 2050 | |
9dac9fc8 DA |
2051 | |
2052 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
2053 | "bgp ebgp-requires-policy", | |
2054 | "BGP specific commands\n" | |
2055 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2056 | { | |
2057 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1d3fdccf | 2058 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); |
9dac9fc8 DA |
2059 | return CMD_SUCCESS; |
2060 | } | |
2061 | ||
2062 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
2063 | "no bgp ebgp-requires-policy", | |
2064 | NO_STR | |
2065 | "BGP specific commands\n" | |
2066 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2067 | { | |
2068 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1d3fdccf | 2069 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); |
9dac9fc8 DA |
2070 | return CMD_SUCCESS; |
2071 | } | |
2072 | ||
fb29348a DA |
2073 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2074 | "bgp reject-as-sets", | |
2075 | "BGP specific commands\n" | |
2076 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2077 | { | |
2078 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2079 | struct listnode *node, *nnode; | |
2080 | struct peer *peer; | |
2081 | ||
7f972cd8 | 2082 | bgp->reject_as_sets = true; |
fb29348a DA |
2083 | |
2084 | /* Reset existing BGP sessions to reject routes | |
2085 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2086 | */ | |
2087 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2088 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2089 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2090 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2091 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2092 | } | |
2093 | } | |
2094 | ||
2095 | return CMD_SUCCESS; | |
2096 | } | |
2097 | ||
2098 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2099 | "no bgp reject-as-sets", | |
2100 | NO_STR | |
2101 | "BGP specific commands\n" | |
2102 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2103 | { | |
2104 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2105 | struct listnode *node, *nnode; | |
2106 | struct peer *peer; | |
2107 | ||
7f972cd8 | 2108 | bgp->reject_as_sets = false; |
fb29348a DA |
2109 | |
2110 | /* Reset existing BGP sessions to reject routes | |
2111 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2112 | */ | |
2113 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2114 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2115 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2116 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2117 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2118 | } | |
2119 | } | |
2120 | ||
2121 | return CMD_SUCCESS; | |
2122 | } | |
9dac9fc8 | 2123 | |
718e3744 | 2124 | /* "bgp deterministic-med" configuration. */ |
2125 | DEFUN (bgp_deterministic_med, | |
2126 | bgp_deterministic_med_cmd, | |
2127 | "bgp deterministic-med", | |
2128 | "BGP specific commands\n" | |
2129 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2130 | { | |
d62a17ae | 2131 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 2132 | |
892fedb6 DA |
2133 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { |
2134 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
d62a17ae | 2135 | bgp_recalculate_all_bestpaths(bgp); |
2136 | } | |
7aafcaca | 2137 | |
d62a17ae | 2138 | return CMD_SUCCESS; |
718e3744 | 2139 | } |
2140 | ||
2141 | DEFUN (no_bgp_deterministic_med, | |
2142 | no_bgp_deterministic_med_cmd, | |
2143 | "no bgp deterministic-med", | |
2144 | NO_STR | |
2145 | "BGP specific commands\n" | |
2146 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2147 | { | |
d62a17ae | 2148 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2149 | int bestpath_per_as_used; | |
2150 | afi_t afi; | |
2151 | safi_t safi; | |
2152 | struct peer *peer; | |
2153 | struct listnode *node, *nnode; | |
2154 | ||
892fedb6 | 2155 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { |
d62a17ae | 2156 | bestpath_per_as_used = 0; |
2157 | ||
2158 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 2159 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
2160 | if (bgp_addpath_dmed_required( |
2161 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
2162 | bestpath_per_as_used = 1; |
2163 | break; | |
2164 | } | |
d62a17ae | 2165 | |
2166 | if (bestpath_per_as_used) | |
2167 | break; | |
2168 | } | |
2169 | ||
2170 | if (bestpath_per_as_used) { | |
2171 | vty_out(vty, | |
2172 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2173 | return CMD_WARNING_CONFIG_FAILED; | |
2174 | } else { | |
892fedb6 | 2175 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); |
d62a17ae | 2176 | bgp_recalculate_all_bestpaths(bgp); |
2177 | } | |
2178 | } | |
2179 | ||
2180 | return CMD_SUCCESS; | |
718e3744 | 2181 | } |
538621f2 | 2182 | |
055679e9 | 2183 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2184 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2185 | bgp_graceful_restart_cmd, |
2186 | "bgp graceful-restart", | |
2187 | "BGP specific commands\n" | |
2188 | GR_CMD | |
055679e9 | 2189 | ) |
538621f2 | 2190 | { |
055679e9 | 2191 | int ret = BGP_GR_FAILURE; |
2192 | ||
2193 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2194 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2195 | |
d62a17ae | 2196 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2197 | |
2198 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2199 | ||
36235319 QY |
2200 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2201 | ret); | |
5cce3f05 | 2202 | |
055679e9 | 2203 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2204 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2205 | vty_out(vty, |
2206 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2207 | return bgp_vty_return(vty, ret); |
538621f2 | 2208 | } |
2209 | ||
2210 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2211 | no_bgp_graceful_restart_cmd, |
2212 | "no bgp graceful-restart", | |
2213 | NO_STR | |
2214 | "BGP specific commands\n" | |
2215 | NO_GR_CMD | |
055679e9 | 2216 | ) |
538621f2 | 2217 | { |
d62a17ae | 2218 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2219 | |
2220 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2221 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2222 | |
2223 | int ret = BGP_GR_FAILURE; | |
2224 | ||
2225 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2226 | ||
36235319 QY |
2227 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2228 | ret); | |
5cce3f05 | 2229 | |
055679e9 | 2230 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2231 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2232 | vty_out(vty, |
2233 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2234 | |
2235 | return bgp_vty_return(vty, ret); | |
538621f2 | 2236 | } |
2237 | ||
93406d87 | 2238 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2239 | bgp_graceful_restart_stalepath_time_cmd, |
2240 | "bgp graceful-restart stalepath-time (1-4095)", | |
2241 | "BGP specific commands\n" | |
2242 | "Graceful restart capability parameters\n" | |
2243 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2244 | "Delay value (seconds)\n") | |
93406d87 | 2245 | { |
d62a17ae | 2246 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2247 | int idx_number = 3; | |
d7c0a89a | 2248 | uint32_t stalepath; |
93406d87 | 2249 | |
d62a17ae | 2250 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2251 | bgp->stalepath_time = stalepath; | |
2252 | return CMD_SUCCESS; | |
93406d87 | 2253 | } |
2254 | ||
eb6f1b41 | 2255 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2256 | bgp_graceful_restart_restart_time_cmd, |
2257 | "bgp graceful-restart restart-time (1-4095)", | |
2258 | "BGP specific commands\n" | |
2259 | "Graceful restart capability parameters\n" | |
2260 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2261 | "Delay value (seconds)\n") | |
eb6f1b41 | 2262 | { |
d62a17ae | 2263 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2264 | int idx_number = 3; | |
d7c0a89a | 2265 | uint32_t restart; |
eb6f1b41 | 2266 | |
d62a17ae | 2267 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2268 | bgp->restart_time = restart; | |
2269 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2270 | } |
2271 | ||
cfd47646 | 2272 | DEFUN (bgp_graceful_restart_select_defer_time, |
2273 | bgp_graceful_restart_select_defer_time_cmd, | |
2274 | "bgp graceful-restart select-defer-time (0-3600)", | |
2275 | "BGP specific commands\n" | |
2276 | "Graceful restart capability parameters\n" | |
2277 | "Set the time to defer the BGP route selection after restart\n" | |
2278 | "Delay value (seconds, 0 - disable)\n") | |
2279 | { | |
2280 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2281 | int idx_number = 3; | |
2282 | uint32_t defer_time; | |
2283 | ||
2284 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2285 | bgp->select_defer_time = defer_time; | |
2286 | if (defer_time == 0) | |
892fedb6 | 2287 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2288 | else |
892fedb6 | 2289 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2290 | |
2291 | return CMD_SUCCESS; | |
2292 | } | |
2293 | ||
93406d87 | 2294 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2295 | no_bgp_graceful_restart_stalepath_time_cmd, |
2296 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2297 | NO_STR | |
2298 | "BGP specific commands\n" | |
2299 | "Graceful restart capability parameters\n" | |
2300 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2301 | "Delay value (seconds)\n") | |
93406d87 | 2302 | { |
d62a17ae | 2303 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2304 | |
d62a17ae | 2305 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2306 | return CMD_SUCCESS; | |
93406d87 | 2307 | } |
2308 | ||
eb6f1b41 | 2309 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2310 | no_bgp_graceful_restart_restart_time_cmd, |
2311 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2312 | NO_STR | |
2313 | "BGP specific commands\n" | |
2314 | "Graceful restart capability parameters\n" | |
2315 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2316 | "Delay value (seconds)\n") | |
eb6f1b41 | 2317 | { |
d62a17ae | 2318 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2319 | |
d62a17ae | 2320 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2321 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2322 | } |
2323 | ||
cfd47646 | 2324 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2325 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2326 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2327 | NO_STR | |
2328 | "BGP specific commands\n" | |
2329 | "Graceful restart capability parameters\n" | |
2330 | "Set the time to defer the BGP route selection after restart\n" | |
2331 | "Delay value (seconds)\n") | |
2332 | { | |
2333 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2334 | ||
2335 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2336 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2337 | |
2338 | return CMD_SUCCESS; | |
2339 | } | |
2340 | ||
43fc21b3 | 2341 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2342 | bgp_graceful_restart_preserve_fw_cmd, |
2343 | "bgp graceful-restart preserve-fw-state", | |
2344 | "BGP specific commands\n" | |
2345 | "Graceful restart capability parameters\n" | |
2346 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2347 | { |
d62a17ae | 2348 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2349 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2350 | return CMD_SUCCESS; |
43fc21b3 JC |
2351 | } |
2352 | ||
2353 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2354 | no_bgp_graceful_restart_preserve_fw_cmd, |
2355 | "no bgp graceful-restart preserve-fw-state", | |
2356 | NO_STR | |
2357 | "BGP specific commands\n" | |
2358 | "Graceful restart capability parameters\n" | |
2359 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2360 | { |
d62a17ae | 2361 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2362 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2363 | return CMD_SUCCESS; |
43fc21b3 JC |
2364 | } |
2365 | ||
055679e9 | 2366 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2367 | bgp_graceful_restart_disable_cmd, |
2368 | "bgp graceful-restart-disable", | |
2369 | "BGP specific commands\n" | |
2370 | GR_DISABLE) | |
055679e9 | 2371 | { |
2372 | int ret = BGP_GR_FAILURE; | |
2373 | ||
2374 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2375 | zlog_debug( | |
2ba1fe69 | 2376 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2377 | |
055679e9 | 2378 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2379 | ||
2380 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2381 | ||
dc95985f | 2382 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2383 | bgp->peer, ret); | |
5cce3f05 | 2384 | |
055679e9 | 2385 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2386 | zlog_debug( | |
2ba1fe69 | 2387 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2388 | vty_out(vty, |
2389 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2390 | ||
055679e9 | 2391 | return bgp_vty_return(vty, ret); |
2392 | } | |
2393 | ||
2394 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2395 | no_bgp_graceful_restart_disable_cmd, |
2396 | "no bgp graceful-restart-disable", | |
2397 | NO_STR | |
2398 | "BGP specific commands\n" | |
2399 | NO_GR_DISABLE | |
055679e9 | 2400 | ) |
2401 | { | |
2402 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2403 | ||
2404 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2405 | zlog_debug( | |
2ba1fe69 | 2406 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2407 | |
2408 | int ret = BGP_GR_FAILURE; | |
2409 | ||
2410 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2411 | ||
36235319 QY |
2412 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2413 | ret); | |
5cce3f05 | 2414 | |
055679e9 | 2415 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2416 | zlog_debug( | |
2ba1fe69 | 2417 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2418 | vty_out(vty, |
2419 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2420 | |
2421 | return bgp_vty_return(vty, ret); | |
2422 | } | |
2423 | ||
2424 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2425 | bgp_neighbor_graceful_restart_set_cmd, |
2426 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2427 | NEIGHBOR_STR | |
2428 | NEIGHBOR_ADDR_STR2 | |
2429 | GR_NEIGHBOR_CMD | |
055679e9 | 2430 | ) |
2431 | { | |
2432 | int idx_peer = 1; | |
2433 | struct peer *peer; | |
2434 | int ret = BGP_GR_FAILURE; | |
2435 | ||
dc95985f | 2436 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2437 | ||
055679e9 | 2438 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2439 | zlog_debug( | |
2ba1fe69 | 2440 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2441 | |
055679e9 | 2442 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2443 | if (!peer) | |
2444 | return CMD_WARNING_CONFIG_FAILED; | |
2445 | ||
2446 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2447 | ||
dc95985f | 2448 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2449 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2450 | |
2451 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2452 | zlog_debug( | |
2ba1fe69 | 2453 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2454 | vty_out(vty, |
2455 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2456 | |
2457 | return bgp_vty_return(vty, ret); | |
2458 | } | |
2459 | ||
2460 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2461 | no_bgp_neighbor_graceful_restart_set_cmd, |
2462 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2463 | NO_STR | |
2464 | NEIGHBOR_STR | |
2465 | NEIGHBOR_ADDR_STR2 | |
2466 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2467 | ) |
2468 | { | |
2469 | int idx_peer = 2; | |
2470 | int ret = BGP_GR_FAILURE; | |
2471 | struct peer *peer; | |
2472 | ||
dc95985f | 2473 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2474 | ||
055679e9 | 2475 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2476 | if (!peer) | |
2477 | return CMD_WARNING_CONFIG_FAILED; | |
2478 | ||
2479 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2480 | zlog_debug( | |
2ba1fe69 | 2481 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2482 | |
2483 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2484 | ||
dc95985f | 2485 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2486 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2487 | |
2488 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2489 | zlog_debug( | |
2ba1fe69 | 2490 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2491 | vty_out(vty, |
2492 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2493 | |
2494 | return bgp_vty_return(vty, ret); | |
2495 | } | |
2496 | ||
2497 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2498 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2499 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2500 | NEIGHBOR_STR | |
2501 | NEIGHBOR_ADDR_STR2 | |
2502 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2503 | ) |
2504 | { | |
2505 | int idx_peer = 1; | |
2506 | struct peer *peer; | |
2507 | int ret = BGP_GR_FAILURE; | |
2508 | ||
dc95985f | 2509 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2510 | ||
055679e9 | 2511 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2512 | zlog_debug( | |
2ba1fe69 | 2513 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2514 | |
055679e9 | 2515 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2516 | ||
055679e9 | 2517 | if (!peer) |
2518 | return CMD_WARNING_CONFIG_FAILED; | |
2519 | ||
2520 | ||
2521 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2522 | |
dc95985f | 2523 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2524 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2525 | |
055679e9 | 2526 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2527 | zlog_debug( | |
2ba1fe69 | 2528 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2529 | vty_out(vty, |
2530 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2531 | |
2532 | return bgp_vty_return(vty, ret); | |
2533 | } | |
2534 | ||
2535 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2536 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2537 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2538 | NO_STR | |
2539 | NEIGHBOR_STR | |
2540 | NEIGHBOR_ADDR_STR2 | |
2541 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2542 | ) |
2543 | { | |
2544 | int idx_peer = 2; | |
2545 | int ret = BGP_GR_FAILURE; | |
2546 | struct peer *peer; | |
2547 | ||
dc95985f | 2548 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2549 | ||
055679e9 | 2550 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2551 | if (!peer) | |
2552 | return CMD_WARNING_CONFIG_FAILED; | |
2553 | ||
2554 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2555 | zlog_debug( | |
2ba1fe69 | 2556 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2557 | |
36235319 | 2558 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 2559 | |
dc95985f | 2560 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2561 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2562 | |
2563 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2564 | zlog_debug( | |
2ba1fe69 | 2565 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2566 | vty_out(vty, |
2567 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2568 | |
2569 | return bgp_vty_return(vty, ret); | |
2570 | } | |
2571 | ||
2572 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 2573 | bgp_neighbor_graceful_restart_disable_set_cmd, |
2574 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2575 | NEIGHBOR_STR | |
2576 | NEIGHBOR_ADDR_STR2 | |
2577 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2578 | ) |
2579 | { | |
2580 | int idx_peer = 1; | |
2581 | struct peer *peer; | |
2582 | int ret = BGP_GR_FAILURE; | |
2583 | ||
dc95985f | 2584 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2585 | ||
055679e9 | 2586 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2587 | zlog_debug( | |
2ba1fe69 | 2588 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2589 | |
2590 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2591 | if (!peer) | |
2592 | return CMD_WARNING_CONFIG_FAILED; | |
2593 | ||
36235319 | 2594 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 2595 | |
2596 | if (peer->bgp->t_startup) | |
2597 | bgp_peer_gr_flags_update(peer); | |
2598 | ||
dc95985f | 2599 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2600 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2601 | ||
055679e9 | 2602 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2603 | zlog_debug( | |
2ba1fe69 | 2604 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2605 | vty_out(vty, |
2606 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2607 | |
2608 | return bgp_vty_return(vty, ret); | |
2609 | } | |
2610 | ||
2611 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 2612 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
2613 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2614 | NO_STR | |
2615 | NEIGHBOR_STR | |
2616 | NEIGHBOR_ADDR_STR2 | |
2617 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2618 | ) |
2619 | { | |
2620 | int idx_peer = 2; | |
2621 | int ret = BGP_GR_FAILURE; | |
2622 | struct peer *peer; | |
2623 | ||
dc95985f | 2624 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2625 | ||
055679e9 | 2626 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2627 | if (!peer) | |
2628 | return CMD_WARNING_CONFIG_FAILED; | |
2629 | ||
2630 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2631 | zlog_debug( | |
2ba1fe69 | 2632 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2633 | |
2634 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
2635 | ||
dc95985f | 2636 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2637 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2638 | |
2639 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2640 | zlog_debug( | |
2ba1fe69 | 2641 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2642 | vty_out(vty, |
2643 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2644 | |
2645 | return bgp_vty_return(vty, ret); | |
2646 | } | |
2647 | ||
d6e3c15b | 2648 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
2649 | bgp_graceful_restart_disable_eor_cmd, | |
2650 | "bgp graceful-restart disable-eor", | |
2651 | "BGP specific commands\n" | |
2652 | "Graceful restart configuration parameters\n" | |
2653 | "Disable EOR Check\n") | |
2654 | { | |
2655 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2656 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2657 | |
d6e3c15b | 2658 | return CMD_SUCCESS; |
2659 | } | |
2660 | ||
2661 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
2662 | no_bgp_graceful_restart_disable_eor_cmd, | |
2663 | "no bgp graceful-restart disable-eor", | |
2664 | NO_STR | |
2665 | "BGP specific commands\n" | |
2666 | "Graceful restart configuration parameters\n" | |
2667 | "Disable EOR Check\n") | |
2668 | { | |
2669 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2670 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2671 | |
2672 | return CMD_SUCCESS; | |
2673 | } | |
2674 | ||
2675 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
2676 | bgp_graceful_restart_rib_stale_time_cmd, | |
2677 | "bgp graceful-restart rib-stale-time (1-3600)", | |
2678 | "BGP specific commands\n" | |
2679 | "Graceful restart configuration parameters\n" | |
2680 | "Specify the stale route removal timer in rib\n" | |
2681 | "Delay value (seconds)\n") | |
2682 | { | |
2683 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2684 | int idx_number = 3; | |
2685 | uint32_t stale_time; | |
2686 | ||
2687 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2688 | bgp->rib_stale_time = stale_time; | |
2689 | /* Send the stale timer update message to RIB */ | |
2690 | if (bgp_zebra_stale_timer_update(bgp)) | |
2691 | return CMD_WARNING; | |
2692 | ||
2693 | return CMD_SUCCESS; | |
2694 | } | |
2695 | ||
2696 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
2697 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
2698 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
2699 | NO_STR | |
2700 | "BGP specific commands\n" | |
2701 | "Graceful restart configuration parameters\n" | |
2702 | "Specify the stale route removal timer in rib\n" | |
2703 | "Delay value (seconds)\n") | |
2704 | { | |
2705 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2706 | ||
2707 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
2708 | /* Send the stale timer update message to RIB */ | |
2709 | if (bgp_zebra_stale_timer_update(bgp)) | |
2710 | return CMD_WARNING; | |
2711 | ||
d6e3c15b | 2712 | return CMD_SUCCESS; |
2713 | } | |
2714 | ||
7f323236 DW |
2715 | /* "bgp graceful-shutdown" configuration */ |
2716 | DEFUN (bgp_graceful_shutdown, | |
2717 | bgp_graceful_shutdown_cmd, | |
2718 | "bgp graceful-shutdown", | |
2719 | BGP_STR | |
2720 | "Graceful shutdown parameters\n") | |
2721 | { | |
2722 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2723 | ||
892fedb6 DA |
2724 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
2725 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
7f323236 DW |
2726 | bgp_static_redo_import_check(bgp); |
2727 | bgp_redistribute_redo(bgp); | |
2728 | bgp_clear_star_soft_out(vty, bgp->name); | |
2729 | bgp_clear_star_soft_in(vty, bgp->name); | |
2730 | } | |
2731 | ||
2732 | return CMD_SUCCESS; | |
2733 | } | |
2734 | ||
2735 | DEFUN (no_bgp_graceful_shutdown, | |
2736 | no_bgp_graceful_shutdown_cmd, | |
2737 | "no bgp graceful-shutdown", | |
2738 | NO_STR | |
2739 | BGP_STR | |
2740 | "Graceful shutdown parameters\n") | |
2741 | { | |
2742 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2743 | ||
892fedb6 DA |
2744 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
2745 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
7f323236 DW |
2746 | bgp_static_redo_import_check(bgp); |
2747 | bgp_redistribute_redo(bgp); | |
2748 | bgp_clear_star_soft_out(vty, bgp->name); | |
2749 | bgp_clear_star_soft_in(vty, bgp->name); | |
2750 | } | |
2751 | ||
2752 | return CMD_SUCCESS; | |
2753 | } | |
2754 | ||
718e3744 | 2755 | /* "bgp fast-external-failover" configuration. */ |
2756 | DEFUN (bgp_fast_external_failover, | |
2757 | bgp_fast_external_failover_cmd, | |
2758 | "bgp fast-external-failover", | |
2759 | BGP_STR | |
2760 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2761 | { | |
d62a17ae | 2762 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2763 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
d62a17ae | 2764 | return CMD_SUCCESS; |
718e3744 | 2765 | } |
2766 | ||
2767 | DEFUN (no_bgp_fast_external_failover, | |
2768 | no_bgp_fast_external_failover_cmd, | |
2769 | "no bgp fast-external-failover", | |
2770 | NO_STR | |
2771 | BGP_STR | |
2772 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2773 | { | |
d62a17ae | 2774 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2775 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
d62a17ae | 2776 | return CMD_SUCCESS; |
718e3744 | 2777 | } |
6b0655a2 | 2778 | |
718e3744 | 2779 | /* "bgp bestpath compare-routerid" configuration. */ |
2780 | DEFUN (bgp_bestpath_compare_router_id, | |
2781 | bgp_bestpath_compare_router_id_cmd, | |
2782 | "bgp bestpath compare-routerid", | |
2783 | "BGP specific commands\n" | |
2784 | "Change the default bestpath selection\n" | |
2785 | "Compare router-id for identical EBGP paths\n") | |
2786 | { | |
d62a17ae | 2787 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2788 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); |
d62a17ae | 2789 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2790 | |
d62a17ae | 2791 | return CMD_SUCCESS; |
718e3744 | 2792 | } |
2793 | ||
2794 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2795 | no_bgp_bestpath_compare_router_id_cmd, | |
2796 | "no bgp bestpath compare-routerid", | |
2797 | NO_STR | |
2798 | "BGP specific commands\n" | |
2799 | "Change the default bestpath selection\n" | |
2800 | "Compare router-id for identical EBGP paths\n") | |
2801 | { | |
d62a17ae | 2802 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2803 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); |
d62a17ae | 2804 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2805 | |
d62a17ae | 2806 | return CMD_SUCCESS; |
718e3744 | 2807 | } |
6b0655a2 | 2808 | |
718e3744 | 2809 | /* "bgp bestpath as-path ignore" configuration. */ |
2810 | DEFUN (bgp_bestpath_aspath_ignore, | |
2811 | bgp_bestpath_aspath_ignore_cmd, | |
2812 | "bgp bestpath as-path ignore", | |
2813 | "BGP specific commands\n" | |
2814 | "Change the default bestpath selection\n" | |
2815 | "AS-path attribute\n" | |
2816 | "Ignore as-path length in selecting a route\n") | |
2817 | { | |
d62a17ae | 2818 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2819 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); |
d62a17ae | 2820 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2821 | |
d62a17ae | 2822 | return CMD_SUCCESS; |
718e3744 | 2823 | } |
2824 | ||
2825 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2826 | no_bgp_bestpath_aspath_ignore_cmd, | |
2827 | "no bgp bestpath as-path ignore", | |
2828 | NO_STR | |
2829 | "BGP specific commands\n" | |
2830 | "Change the default bestpath selection\n" | |
2831 | "AS-path attribute\n" | |
2832 | "Ignore as-path length in selecting a route\n") | |
2833 | { | |
d62a17ae | 2834 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2835 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); |
d62a17ae | 2836 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2837 | |
d62a17ae | 2838 | return CMD_SUCCESS; |
718e3744 | 2839 | } |
6b0655a2 | 2840 | |
6811845b | 2841 | /* "bgp bestpath as-path confed" configuration. */ |
2842 | DEFUN (bgp_bestpath_aspath_confed, | |
2843 | bgp_bestpath_aspath_confed_cmd, | |
2844 | "bgp bestpath as-path confed", | |
2845 | "BGP specific commands\n" | |
2846 | "Change the default bestpath selection\n" | |
2847 | "AS-path attribute\n" | |
2848 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2849 | { | |
d62a17ae | 2850 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2851 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); |
d62a17ae | 2852 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2853 | |
d62a17ae | 2854 | return CMD_SUCCESS; |
6811845b | 2855 | } |
2856 | ||
2857 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2858 | no_bgp_bestpath_aspath_confed_cmd, | |
2859 | "no bgp bestpath as-path confed", | |
2860 | NO_STR | |
2861 | "BGP specific commands\n" | |
2862 | "Change the default bestpath selection\n" | |
2863 | "AS-path attribute\n" | |
2864 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2865 | { | |
d62a17ae | 2866 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2867 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); |
d62a17ae | 2868 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2869 | |
d62a17ae | 2870 | return CMD_SUCCESS; |
6811845b | 2871 | } |
6b0655a2 | 2872 | |
2fdd455c PM |
2873 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2874 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2875 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2876 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2877 | "BGP specific commands\n" |
2878 | "Change the default bestpath selection\n" | |
2879 | "AS-path attribute\n" | |
2880 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2881 | "Generate an AS_SET\n" |
16fc1eec DS |
2882 | "Do not generate an AS_SET\n") |
2883 | { | |
d62a17ae | 2884 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2885 | int idx = 0; | |
892fedb6 | 2886 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2887 | |
d62a17ae | 2888 | /* no-as-set is now the default behavior so we can silently |
2889 | * ignore it */ | |
2890 | if (argv_find(argv, argc, "as-set", &idx)) | |
892fedb6 | 2891 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 2892 | else |
892fedb6 | 2893 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
219178b6 | 2894 | |
d62a17ae | 2895 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2896 | |
d62a17ae | 2897 | return CMD_SUCCESS; |
16fc1eec DS |
2898 | } |
2899 | ||
219178b6 DW |
2900 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2901 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2902 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2903 | NO_STR |
2904 | "BGP specific commands\n" | |
2905 | "Change the default bestpath selection\n" | |
2906 | "AS-path attribute\n" | |
2907 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2908 | "Generate an AS_SET\n" |
16fc1eec DS |
2909 | "Do not generate an AS_SET\n") |
2910 | { | |
d62a17ae | 2911 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
2912 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
2913 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
d62a17ae | 2914 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2915 | |
d62a17ae | 2916 | return CMD_SUCCESS; |
2fdd455c | 2917 | } |
6b0655a2 | 2918 | |
848973c7 | 2919 | /* "bgp log-neighbor-changes" configuration. */ |
2920 | DEFUN (bgp_log_neighbor_changes, | |
2921 | bgp_log_neighbor_changes_cmd, | |
2922 | "bgp log-neighbor-changes", | |
2923 | "BGP specific commands\n" | |
2924 | "Log neighbor up/down and reset reason\n") | |
2925 | { | |
d62a17ae | 2926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2927 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
d62a17ae | 2928 | return CMD_SUCCESS; |
848973c7 | 2929 | } |
2930 | ||
2931 | DEFUN (no_bgp_log_neighbor_changes, | |
2932 | no_bgp_log_neighbor_changes_cmd, | |
2933 | "no bgp log-neighbor-changes", | |
2934 | NO_STR | |
2935 | "BGP specific commands\n" | |
2936 | "Log neighbor up/down and reset reason\n") | |
2937 | { | |
d62a17ae | 2938 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2939 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
d62a17ae | 2940 | return CMD_SUCCESS; |
848973c7 | 2941 | } |
6b0655a2 | 2942 | |
718e3744 | 2943 | /* "bgp bestpath med" configuration. */ |
2944 | DEFUN (bgp_bestpath_med, | |
2945 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2946 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2947 | "BGP specific commands\n" |
2948 | "Change the default bestpath selection\n" | |
2949 | "MED attribute\n" | |
2950 | "Compare MED among confederation paths\n" | |
838758ac DW |
2951 | "Treat missing MED as the least preferred one\n" |
2952 | "Treat missing MED as the least preferred one\n" | |
2953 | "Compare MED among confederation paths\n") | |
718e3744 | 2954 | { |
d62a17ae | 2955 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2956 | |
d62a17ae | 2957 | int idx = 0; |
2958 | if (argv_find(argv, argc, "confed", &idx)) | |
892fedb6 | 2959 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 2960 | idx = 0; |
2961 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
892fedb6 | 2962 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 2963 | |
d62a17ae | 2964 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2965 | |
d62a17ae | 2966 | return CMD_SUCCESS; |
718e3744 | 2967 | } |
2968 | ||
718e3744 | 2969 | DEFUN (no_bgp_bestpath_med, |
2970 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2971 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2972 | NO_STR |
2973 | "BGP specific commands\n" | |
2974 | "Change the default bestpath selection\n" | |
2975 | "MED attribute\n" | |
2976 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2977 | "Treat missing MED as the least preferred one\n" |
2978 | "Treat missing MED as the least preferred one\n" | |
2979 | "Compare MED among confederation paths\n") | |
718e3744 | 2980 | { |
d62a17ae | 2981 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2982 | |
d62a17ae | 2983 | int idx = 0; |
2984 | if (argv_find(argv, argc, "confed", &idx)) | |
892fedb6 | 2985 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 2986 | idx = 0; |
2987 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
892fedb6 | 2988 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
718e3744 | 2989 | |
d62a17ae | 2990 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2991 | |
d62a17ae | 2992 | return CMD_SUCCESS; |
718e3744 | 2993 | } |
2994 | ||
f7e1c681 | 2995 | /* "bgp bestpath bandwidth" configuration. */ |
2996 | DEFPY (bgp_bestpath_bw, | |
2997 | bgp_bestpath_bw_cmd, | |
ad36d216 | 2998 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
f7e1c681 | 2999 | "BGP specific commands\n" |
3000 | "Change the default bestpath selection\n" | |
3001 | "Link Bandwidth attribute\n" | |
3002 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3003 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3004 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3005 | { | |
3006 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3007 | afi_t afi; | |
3008 | safi_t safi; | |
3009 | ||
ad36d216 DS |
3010 | if (!bw_cfg) { |
3011 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3012 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3013 | } |
ad36d216 DS |
3014 | if (!strcmp(bw_cfg, "ignore")) |
3015 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3016 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3017 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3018 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3019 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3020 | else | |
3021 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3022 | |
3023 | /* This config is used in route install, so redo that. */ | |
3024 | FOREACH_AFI_SAFI (afi, safi) { | |
3025 | if (!bgp_fibupd_safi(safi)) | |
3026 | continue; | |
3027 | bgp_zebra_announce_table(bgp, afi, safi); | |
3028 | } | |
3029 | ||
3030 | return CMD_SUCCESS; | |
3031 | } | |
3032 | ||
ad36d216 DS |
3033 | DEFPY (no_bgp_bestpath_bw, |
3034 | no_bgp_bestpath_bw_cmd, | |
3035 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3036 | NO_STR | |
3037 | "BGP specific commands\n" | |
3038 | "Change the default bestpath selection\n" | |
3039 | "Link Bandwidth attribute\n" | |
3040 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3041 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3042 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3043 | { | |
3044 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3045 | afi_t afi; | |
3046 | safi_t safi; | |
3047 | ||
3048 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3049 | ||
3050 | /* This config is used in route install, so redo that. */ | |
3051 | FOREACH_AFI_SAFI (afi, safi) { | |
3052 | if (!bgp_fibupd_safi(safi)) | |
3053 | continue; | |
3054 | bgp_zebra_announce_table(bgp, afi, safi); | |
3055 | } | |
3056 | return CMD_SUCCESS; | |
3057 | } | |
3058 | ||
718e3744 | 3059 | /* "no bgp default ipv4-unicast". */ |
3060 | DEFUN (no_bgp_default_ipv4_unicast, | |
3061 | no_bgp_default_ipv4_unicast_cmd, | |
3062 | "no bgp default ipv4-unicast", | |
3063 | NO_STR | |
3064 | "BGP specific commands\n" | |
3065 | "Configure BGP defaults\n" | |
3066 | "Activate ipv4-unicast for a peer by default\n") | |
3067 | { | |
d62a17ae | 3068 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3069 | SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3070 | return CMD_SUCCESS; |
718e3744 | 3071 | } |
3072 | ||
3073 | DEFUN (bgp_default_ipv4_unicast, | |
3074 | bgp_default_ipv4_unicast_cmd, | |
3075 | "bgp default ipv4-unicast", | |
3076 | "BGP specific commands\n" | |
3077 | "Configure BGP defaults\n" | |
3078 | "Activate ipv4-unicast for a peer by default\n") | |
3079 | { | |
d62a17ae | 3080 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3081 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3082 | return CMD_SUCCESS; |
718e3744 | 3083 | } |
6b0655a2 | 3084 | |
04b6bdc0 DW |
3085 | /* Display hostname in certain command outputs */ |
3086 | DEFUN (bgp_default_show_hostname, | |
3087 | bgp_default_show_hostname_cmd, | |
3088 | "bgp default show-hostname", | |
3089 | "BGP specific commands\n" | |
3090 | "Configure BGP defaults\n" | |
0437e105 | 3091 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3092 | { |
d62a17ae | 3093 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3094 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); |
d62a17ae | 3095 | return CMD_SUCCESS; |
04b6bdc0 DW |
3096 | } |
3097 | ||
3098 | DEFUN (no_bgp_default_show_hostname, | |
3099 | no_bgp_default_show_hostname_cmd, | |
3100 | "no bgp default show-hostname", | |
3101 | NO_STR | |
3102 | "BGP specific commands\n" | |
3103 | "Configure BGP defaults\n" | |
0437e105 | 3104 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3105 | { |
d62a17ae | 3106 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3107 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); |
d62a17ae | 3108 | return CMD_SUCCESS; |
04b6bdc0 DW |
3109 | } |
3110 | ||
aef999a2 DA |
3111 | /* Display hostname in certain command outputs */ |
3112 | DEFUN (bgp_default_show_nexthop_hostname, | |
3113 | bgp_default_show_nexthop_hostname_cmd, | |
3114 | "bgp default show-nexthop-hostname", | |
3115 | "BGP specific commands\n" | |
3116 | "Configure BGP defaults\n" | |
3117 | "Show hostname for nexthop in certain command outputs\n") | |
3118 | { | |
3119 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3120 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3121 | return CMD_SUCCESS; | |
3122 | } | |
3123 | ||
3124 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3125 | no_bgp_default_show_nexthop_hostname_cmd, | |
3126 | "no bgp default show-nexthop-hostname", | |
3127 | NO_STR | |
3128 | "BGP specific commands\n" | |
3129 | "Configure BGP defaults\n" | |
3130 | "Show hostname for nexthop in certain command outputs\n") | |
3131 | { | |
3132 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3133 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3134 | return CMD_SUCCESS; | |
3135 | } | |
3136 | ||
8233ef81 | 3137 | /* "bgp network import-check" configuration. */ |
718e3744 | 3138 | DEFUN (bgp_network_import_check, |
3139 | bgp_network_import_check_cmd, | |
5623e905 | 3140 | "bgp network import-check", |
718e3744 | 3141 | "BGP specific commands\n" |
3142 | "BGP network command\n" | |
5623e905 | 3143 | "Check BGP network route exists in IGP\n") |
718e3744 | 3144 | { |
d62a17ae | 3145 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
3146 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { |
3147 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
d62a17ae | 3148 | bgp_static_redo_import_check(bgp); |
3149 | } | |
078430f6 | 3150 | |
d62a17ae | 3151 | return CMD_SUCCESS; |
718e3744 | 3152 | } |
3153 | ||
d62a17ae | 3154 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3155 | "bgp network import-check exact", | |
3156 | "BGP specific commands\n" | |
3157 | "BGP network command\n" | |
3158 | "Check BGP network route exists in IGP\n" | |
3159 | "Match route precisely\n") | |
8233ef81 | 3160 | |
718e3744 | 3161 | DEFUN (no_bgp_network_import_check, |
3162 | no_bgp_network_import_check_cmd, | |
5623e905 | 3163 | "no bgp network import-check", |
718e3744 | 3164 | NO_STR |
3165 | "BGP specific commands\n" | |
3166 | "BGP network command\n" | |
3167 | "Check BGP network route exists in IGP\n") | |
3168 | { | |
d62a17ae | 3169 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
3170 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { |
3171 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
d62a17ae | 3172 | bgp_static_redo_import_check(bgp); |
3173 | } | |
5623e905 | 3174 | |
d62a17ae | 3175 | return CMD_SUCCESS; |
718e3744 | 3176 | } |
6b0655a2 | 3177 | |
718e3744 | 3178 | DEFUN (bgp_default_local_preference, |
3179 | bgp_default_local_preference_cmd, | |
6147e2c6 | 3180 | "bgp default local-preference (0-4294967295)", |
718e3744 | 3181 | "BGP specific commands\n" |
3182 | "Configure BGP defaults\n" | |
3183 | "local preference (higher=more preferred)\n" | |
3184 | "Configure default local preference value\n") | |
3185 | { | |
d62a17ae | 3186 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3187 | int idx_number = 3; | |
d7c0a89a | 3188 | uint32_t local_pref; |
718e3744 | 3189 | |
d62a17ae | 3190 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3191 | |
d62a17ae | 3192 | bgp_default_local_preference_set(bgp, local_pref); |
3193 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3194 | |
d62a17ae | 3195 | return CMD_SUCCESS; |
718e3744 | 3196 | } |
3197 | ||
3198 | DEFUN (no_bgp_default_local_preference, | |
3199 | no_bgp_default_local_preference_cmd, | |
838758ac | 3200 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 3201 | NO_STR |
3202 | "BGP specific commands\n" | |
3203 | "Configure BGP defaults\n" | |
838758ac DW |
3204 | "local preference (higher=more preferred)\n" |
3205 | "Configure default local preference value\n") | |
718e3744 | 3206 | { |
d62a17ae | 3207 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3208 | bgp_default_local_preference_unset(bgp); | |
3209 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 3210 | |
d62a17ae | 3211 | return CMD_SUCCESS; |
718e3744 | 3212 | } |
3213 | ||
6b0655a2 | 3214 | |
3f9c7369 DS |
3215 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3216 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 3217 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
3218 | "BGP specific commands\n" |
3219 | "Configure BGP defaults\n" | |
3220 | "subgroup-pkt-queue-max\n" | |
3221 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3222 | { |
d62a17ae | 3223 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3224 | int idx_number = 3; | |
d7c0a89a | 3225 | uint32_t max_size; |
8bd9d948 | 3226 | |
d62a17ae | 3227 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3228 | |
d62a17ae | 3229 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 3230 | |
d62a17ae | 3231 | return CMD_SUCCESS; |
3f9c7369 DS |
3232 | } |
3233 | ||
3234 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
3235 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 3236 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
3237 | NO_STR |
3238 | "BGP specific commands\n" | |
3239 | "Configure BGP defaults\n" | |
838758ac DW |
3240 | "subgroup-pkt-queue-max\n" |
3241 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3242 | { |
d62a17ae | 3243 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3244 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3245 | return CMD_SUCCESS; | |
8bd9d948 DS |
3246 | } |
3247 | ||
813d4307 | 3248 | |
8bd9d948 DS |
3249 | DEFUN (bgp_rr_allow_outbound_policy, |
3250 | bgp_rr_allow_outbound_policy_cmd, | |
3251 | "bgp route-reflector allow-outbound-policy", | |
3252 | "BGP specific commands\n" | |
3253 | "Allow modifications made by out route-map\n" | |
3254 | "on ibgp neighbors\n") | |
3255 | { | |
d62a17ae | 3256 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3257 | |
892fedb6 DA |
3258 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3259 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
d62a17ae | 3260 | update_group_announce_rrclients(bgp); |
3261 | bgp_clear_star_soft_out(vty, bgp->name); | |
3262 | } | |
8bd9d948 | 3263 | |
d62a17ae | 3264 | return CMD_SUCCESS; |
8bd9d948 DS |
3265 | } |
3266 | ||
3267 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
3268 | no_bgp_rr_allow_outbound_policy_cmd, | |
3269 | "no bgp route-reflector allow-outbound-policy", | |
3270 | NO_STR | |
3271 | "BGP specific commands\n" | |
3272 | "Allow modifications made by out route-map\n" | |
3273 | "on ibgp neighbors\n") | |
3274 | { | |
d62a17ae | 3275 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3276 | |
892fedb6 DA |
3277 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3278 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
d62a17ae | 3279 | update_group_announce_rrclients(bgp); |
3280 | bgp_clear_star_soft_out(vty, bgp->name); | |
3281 | } | |
8bd9d948 | 3282 | |
d62a17ae | 3283 | return CMD_SUCCESS; |
8bd9d948 DS |
3284 | } |
3285 | ||
f14e6fdb DS |
3286 | DEFUN (bgp_listen_limit, |
3287 | bgp_listen_limit_cmd, | |
9ccf14f7 | 3288 | "bgp listen limit (1-5000)", |
f14e6fdb | 3289 | "BGP specific commands\n" |
1601a46f | 3290 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3291 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
f14e6fdb DS |
3292 | "Configure Dynamic Neighbors listen limit value\n") |
3293 | { | |
d62a17ae | 3294 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3295 | int idx_number = 3; | |
3296 | int listen_limit; | |
f14e6fdb | 3297 | |
d62a17ae | 3298 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 3299 | |
d62a17ae | 3300 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3301 | |
d62a17ae | 3302 | return CMD_SUCCESS; |
f14e6fdb DS |
3303 | } |
3304 | ||
3305 | DEFUN (no_bgp_listen_limit, | |
3306 | no_bgp_listen_limit_cmd, | |
838758ac | 3307 | "no bgp listen limit [(1-5000)]", |
1601a46f | 3308 | NO_STR |
f14e6fdb | 3309 | "BGP specific commands\n" |
1601a46f | 3310 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3311 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
838758ac | 3312 | "Configure Dynamic Neighbors listen limit value\n") |
f14e6fdb | 3313 | { |
d62a17ae | 3314 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3315 | bgp_listen_limit_unset(bgp); | |
3316 | return CMD_SUCCESS; | |
f14e6fdb DS |
3317 | } |
3318 | ||
3319 | ||
20eb8864 | 3320 | /* |
3321 | * Check if this listen range is already configured. Check for exact | |
3322 | * match or overlap based on input. | |
3323 | */ | |
d62a17ae | 3324 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3325 | struct prefix *range, int exact) | |
3326 | { | |
3327 | struct listnode *node, *nnode; | |
3328 | struct listnode *node1, *nnode1; | |
3329 | struct peer_group *group; | |
3330 | struct prefix *lr; | |
3331 | afi_t afi; | |
3332 | int match; | |
3333 | ||
3334 | afi = family2afi(range->family); | |
3335 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3336 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3337 | lr)) { | |
3338 | if (exact) | |
3339 | match = prefix_same(range, lr); | |
3340 | else | |
3341 | match = (prefix_match(range, lr) | |
3342 | || prefix_match(lr, range)); | |
3343 | if (match) | |
3344 | return group; | |
3345 | } | |
3346 | } | |
3347 | ||
3348 | return NULL; | |
20eb8864 | 3349 | } |
3350 | ||
f14e6fdb DS |
3351 | DEFUN (bgp_listen_range, |
3352 | bgp_listen_range_cmd, | |
d7b9898c | 3353 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3354 | "BGP specific commands\n" |
d7fa34c1 QY |
3355 | "Configure BGP dynamic neighbors listen range\n" |
3356 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3357 | NEIGHBOR_ADDR_STR |
3358 | "Member of the peer-group\n" | |
3359 | "Peer-group name\n") | |
f14e6fdb | 3360 | { |
d62a17ae | 3361 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3362 | struct prefix range; | |
3363 | struct peer_group *group, *existing_group; | |
3364 | afi_t afi; | |
3365 | int ret; | |
3366 | int idx = 0; | |
3367 | ||
3368 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3369 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3370 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3371 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3372 | char *peergroup = argv[idx]->arg; |
3373 | ||
3374 | /* Convert IP prefix string to struct prefix. */ | |
3375 | ret = str2prefix(prefix, &range); | |
3376 | if (!ret) { | |
3377 | vty_out(vty, "%% Malformed listen range\n"); | |
3378 | return CMD_WARNING_CONFIG_FAILED; | |
3379 | } | |
3380 | ||
3381 | afi = family2afi(range.family); | |
3382 | ||
3383 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3384 | vty_out(vty, | |
3385 | "%% Malformed listen range (link-local address)\n"); | |
3386 | return CMD_WARNING_CONFIG_FAILED; | |
3387 | } | |
3388 | ||
3389 | apply_mask(&range); | |
3390 | ||
3391 | /* Check if same listen range is already configured. */ | |
3392 | existing_group = listen_range_exists(bgp, &range, 1); | |
3393 | if (existing_group) { | |
3394 | if (strcmp(existing_group->name, peergroup) == 0) | |
3395 | return CMD_SUCCESS; | |
3396 | else { | |
3397 | vty_out(vty, | |
3398 | "%% Same listen range is attached to peer-group %s\n", | |
3399 | existing_group->name); | |
3400 | return CMD_WARNING_CONFIG_FAILED; | |
3401 | } | |
3402 | } | |
3403 | ||
3404 | /* Check if an overlapping listen range exists. */ | |
3405 | if (listen_range_exists(bgp, &range, 0)) { | |
3406 | vty_out(vty, | |
3407 | "%% Listen range overlaps with existing listen range\n"); | |
3408 | return CMD_WARNING_CONFIG_FAILED; | |
3409 | } | |
3410 | ||
3411 | group = peer_group_lookup(bgp, peergroup); | |
3412 | if (!group) { | |
3413 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3414 | return CMD_WARNING_CONFIG_FAILED; | |
3415 | } | |
3416 | ||
3417 | ret = peer_group_listen_range_add(group, &range); | |
3418 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3419 | } |
3420 | ||
3421 | DEFUN (no_bgp_listen_range, | |
3422 | no_bgp_listen_range_cmd, | |
d7b9898c | 3423 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3424 | NO_STR |
f14e6fdb | 3425 | "BGP specific commands\n" |
d7fa34c1 QY |
3426 | "Unconfigure BGP dynamic neighbors listen range\n" |
3427 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3428 | NEIGHBOR_ADDR_STR | |
3429 | "Member of the peer-group\n" | |
3430 | "Peer-group name\n") | |
f14e6fdb | 3431 | { |
d62a17ae | 3432 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3433 | struct prefix range; | |
3434 | struct peer_group *group; | |
3435 | afi_t afi; | |
3436 | int ret; | |
3437 | int idx = 0; | |
3438 | ||
3439 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3440 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3441 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3442 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3443 | char *peergroup = argv[idx]->arg; |
3444 | ||
3445 | /* Convert IP prefix string to struct prefix. */ | |
3446 | ret = str2prefix(prefix, &range); | |
3447 | if (!ret) { | |
3448 | vty_out(vty, "%% Malformed listen range\n"); | |
3449 | return CMD_WARNING_CONFIG_FAILED; | |
3450 | } | |
3451 | ||
3452 | afi = family2afi(range.family); | |
3453 | ||
3454 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3455 | vty_out(vty, | |
3456 | "%% Malformed listen range (link-local address)\n"); | |
3457 | return CMD_WARNING_CONFIG_FAILED; | |
3458 | } | |
3459 | ||
3460 | apply_mask(&range); | |
3461 | ||
3462 | group = peer_group_lookup(bgp, peergroup); | |
3463 | if (!group) { | |
3464 | vty_out(vty, "%% Peer-group does not exist\n"); | |
3465 | return CMD_WARNING_CONFIG_FAILED; | |
3466 | } | |
3467 | ||
3468 | ret = peer_group_listen_range_del(group, &range); | |
3469 | return bgp_vty_return(vty, ret); | |
3470 | } | |
3471 | ||
2b791107 | 3472 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 3473 | { |
3474 | struct peer_group *group; | |
3475 | struct listnode *node, *nnode, *rnode, *nrnode; | |
3476 | struct prefix *range; | |
3477 | afi_t afi; | |
3478 | char buf[PREFIX2STR_BUFFER]; | |
3479 | ||
3480 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
3481 | vty_out(vty, " bgp listen limit %d\n", | |
3482 | bgp->dynamic_neighbors_limit); | |
3483 | ||
3484 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3485 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
3486 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
3487 | nrnode, range)) { | |
3488 | prefix2str(range, buf, sizeof(buf)); | |
3489 | vty_out(vty, | |
3490 | " bgp listen range %s peer-group %s\n", | |
3491 | buf, group->name); | |
3492 | } | |
3493 | } | |
3494 | } | |
f14e6fdb DS |
3495 | } |
3496 | ||
3497 | ||
907f92c8 DS |
3498 | DEFUN (bgp_disable_connected_route_check, |
3499 | bgp_disable_connected_route_check_cmd, | |
3500 | "bgp disable-ebgp-connected-route-check", | |
3501 | "BGP specific commands\n" | |
3502 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3503 | { | |
d62a17ae | 3504 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3505 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
d62a17ae | 3506 | bgp_clear_star_soft_in(vty, bgp->name); |
7aafcaca | 3507 | |
d62a17ae | 3508 | return CMD_SUCCESS; |
907f92c8 DS |
3509 | } |
3510 | ||
3511 | DEFUN (no_bgp_disable_connected_route_check, | |
3512 | no_bgp_disable_connected_route_check_cmd, | |
3513 | "no bgp disable-ebgp-connected-route-check", | |
3514 | NO_STR | |
3515 | "BGP specific commands\n" | |
3516 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3517 | { | |
d62a17ae | 3518 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3519 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
d62a17ae | 3520 | bgp_clear_star_soft_in(vty, bgp->name); |
3521 | ||
3522 | return CMD_SUCCESS; | |
3523 | } | |
3524 | ||
3525 | ||
3526 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
3527 | const char *as_str, afi_t afi, safi_t safi) | |
3528 | { | |
3529 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3530 | int ret; | |
3531 | as_t as; | |
3532 | int as_type = AS_SPECIFIED; | |
3533 | union sockunion su; | |
3534 | ||
3535 | if (as_str[0] == 'i') { | |
3536 | as = 0; | |
3537 | as_type = AS_INTERNAL; | |
3538 | } else if (as_str[0] == 'e') { | |
3539 | as = 0; | |
3540 | as_type = AS_EXTERNAL; | |
3541 | } else { | |
3542 | /* Get AS number. */ | |
3543 | as = strtoul(as_str, NULL, 10); | |
3544 | } | |
3545 | ||
390485fd | 3546 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 3547 | ret = str2sockunion(peer_str, &su); |
3548 | if (ret < 0) { | |
390485fd DS |
3549 | struct peer *peer; |
3550 | ||
3551 | /* Check if existing interface peer */ | |
3552 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
3553 | ||
d62a17ae | 3554 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
3555 | safi); | |
390485fd DS |
3556 | |
3557 | /* if not interface peer, check peer-group settings */ | |
3558 | if (ret < 0 && !peer) { | |
d62a17ae | 3559 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
3560 | if (ret < 0) { | |
3561 | vty_out(vty, | |
390485fd | 3562 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 3563 | return CMD_WARNING_CONFIG_FAILED; |
3564 | } | |
3565 | return CMD_SUCCESS; | |
3566 | } | |
3567 | } else { | |
3568 | if (peer_address_self_check(bgp, &su)) { | |
3569 | vty_out(vty, | |
3570 | "%% Can not configure the local system as neighbor\n"); | |
3571 | return CMD_WARNING_CONFIG_FAILED; | |
3572 | } | |
3573 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
3574 | } | |
3575 | ||
3576 | /* This peer belongs to peer group. */ | |
3577 | switch (ret) { | |
3578 | case BGP_ERR_PEER_GROUP_MEMBER: | |
3579 | vty_out(vty, | |
faa16034 | 3580 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 3581 | return CMD_WARNING_CONFIG_FAILED; |
3582 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
3583 | vty_out(vty, | |
faa16034 | 3584 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 3585 | return CMD_WARNING_CONFIG_FAILED; |
3586 | } | |
3587 | return bgp_vty_return(vty, ret); | |
718e3744 | 3588 | } |
3589 | ||
f26845f9 QY |
3590 | DEFUN (bgp_default_shutdown, |
3591 | bgp_default_shutdown_cmd, | |
3592 | "[no] bgp default shutdown", | |
3593 | NO_STR | |
3594 | BGP_STR | |
3595 | "Configure BGP defaults\n" | |
b012cbe2 | 3596 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
3597 | { |
3598 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3599 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
3600 | return CMD_SUCCESS; | |
3601 | } | |
3602 | ||
9cf59432 | 3603 | DEFPY (bgp_shutdown, |
8389c83a DS |
3604 | bgp_shutdown_msg_cmd, |
3605 | "bgp shutdown message MSG...", | |
9cf59432 | 3606 | BGP_STR |
8389c83a DS |
3607 | "Enable administrative shutdown of the BGP instance\n" |
3608 | "Add a shutdown message (RFC 8203)\n" | |
3609 | "Shutdown message\n") | |
9cf59432 | 3610 | { |
8389c83a DS |
3611 | char* msgstr = NULL; |
3612 | ||
9cf59432 DS |
3613 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3614 | ||
8389c83a DS |
3615 | if (argc > 3) |
3616 | msgstr = argv_concat(argv, argc, 4); | |
3617 | ||
3618 | bgp_shutdown_enable(bgp, msgstr); | |
3619 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
3620 | |
3621 | return CMD_SUCCESS; | |
3622 | } | |
3623 | ||
8389c83a DS |
3624 | ALIAS(bgp_shutdown, bgp_shutdown_cmd, |
3625 | "bgp shutdown", | |
3626 | BGP_STR | |
3627 | "Enable administrative shutdown of the BGP instance\n") | |
3628 | ||
9cf59432 DS |
3629 | DEFPY (no_bgp_shutdown, |
3630 | no_bgp_shutdown_cmd, | |
3631 | "no bgp shutdown", | |
3632 | NO_STR | |
3633 | BGP_STR | |
3634 | "Disable administrative shutdown of the BGP instance\n") | |
3635 | { | |
3636 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3637 | ||
3638 | bgp_shutdown_disable(bgp); | |
3639 | ||
3640 | return CMD_SUCCESS; | |
3641 | } | |
3642 | ||
718e3744 | 3643 | DEFUN (neighbor_remote_as, |
3644 | neighbor_remote_as_cmd, | |
3a2d747c | 3645 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3646 | NEIGHBOR_STR |
3647 | NEIGHBOR_ADDR_STR2 | |
3648 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 3649 | AS_STR |
3a2d747c QY |
3650 | "Internal BGP peer\n" |
3651 | "External BGP peer\n") | |
718e3744 | 3652 | { |
d62a17ae | 3653 | int idx_peer = 1; |
3654 | int idx_remote_as = 3; | |
3655 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
3656 | argv[idx_remote_as]->arg, AFI_IP, | |
3657 | SAFI_UNICAST); | |
3658 | } | |
3659 | ||
3660 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
3661 | afi_t afi, safi_t safi, int v6only, | |
3662 | const char *peer_group_name, | |
3663 | const char *as_str) | |
3664 | { | |
3665 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3666 | as_t as = 0; | |
3667 | int as_type = AS_UNSPECIFIED; | |
3668 | struct peer *peer; | |
3669 | struct peer_group *group; | |
3670 | int ret = 0; | |
3671 | union sockunion su; | |
3672 | ||
3673 | group = peer_group_lookup(bgp, conf_if); | |
3674 | ||
3675 | if (group) { | |
3676 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
3677 | return CMD_WARNING_CONFIG_FAILED; | |
3678 | } | |
3679 | ||
3680 | if (as_str) { | |
3681 | if (as_str[0] == 'i') { | |
3682 | as_type = AS_INTERNAL; | |
3683 | } else if (as_str[0] == 'e') { | |
3684 | as_type = AS_EXTERNAL; | |
3685 | } else { | |
3686 | /* Get AS number. */ | |
3687 | as = strtoul(as_str, NULL, 10); | |
3688 | as_type = AS_SPECIFIED; | |
3689 | } | |
3690 | } | |
3691 | ||
3692 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
3693 | if (peer) { | |
3694 | if (as_str) | |
cc4d4ce8 | 3695 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 3696 | afi, safi); |
3697 | } else { | |
892fedb6 | 3698 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4) |
d62a17ae | 3699 | && afi == AFI_IP && safi == SAFI_UNICAST) |
3700 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3701 | as_type, 0, 0, NULL); | |
3702 | else | |
3703 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3704 | as_type, afi, safi, NULL); | |
3705 | ||
3706 | if (!peer) { | |
3707 | vty_out(vty, "%% BGP failed to create peer\n"); | |
3708 | return CMD_WARNING_CONFIG_FAILED; | |
3709 | } | |
3710 | ||
3711 | if (v6only) | |
527de3dc | 3712 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3713 | |
3714 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
3715 | * this | |
3716 | * any unnumbered peer in order to not worry about run-time | |
3717 | * transitions | |
3718 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3719 | * address | |
3720 | * gets deleted later etc.) | |
3721 | */ | |
3722 | if (peer->ifp) | |
3723 | bgp_zebra_initiate_radv(bgp, peer); | |
3724 | } | |
3725 | ||
3726 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3727 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3728 | if (v6only) | |
527de3dc | 3729 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3730 | else |
527de3dc | 3731 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3732 | |
3733 | /* v6only flag changed. Reset bgp seesion */ | |
3734 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3735 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3736 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3737 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3738 | } else | |
3739 | bgp_session_reset(peer); | |
3740 | } | |
3741 | ||
9fb964de PM |
3742 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3743 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3744 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3745 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3746 | } |
d62a17ae | 3747 | |
3748 | if (peer_group_name) { | |
3749 | group = peer_group_lookup(bgp, peer_group_name); | |
3750 | if (!group) { | |
3751 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3752 | return CMD_WARNING_CONFIG_FAILED; | |
3753 | } | |
3754 | ||
3755 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3756 | } | |
3757 | ||
3758 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3759 | } |
3760 | ||
4c48cf63 DW |
3761 | DEFUN (neighbor_interface_config, |
3762 | neighbor_interface_config_cmd, | |
d7b9898c | 3763 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3764 | NEIGHBOR_STR |
3765 | "Interface name or neighbor tag\n" | |
31500417 DW |
3766 | "Enable BGP on interface\n" |
3767 | "Member of the peer-group\n" | |
16cedbb0 | 3768 | "Peer-group name\n") |
4c48cf63 | 3769 | { |
d62a17ae | 3770 | int idx_word = 1; |
3771 | int idx_peer_group_word = 4; | |
31500417 | 3772 | |
d62a17ae | 3773 | if (argc > idx_peer_group_word) |
3774 | return peer_conf_interface_get( | |
3775 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3776 | argv[idx_peer_group_word]->arg, NULL); | |
3777 | else | |
3778 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3779 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3780 | } |
3781 | ||
4c48cf63 DW |
3782 | DEFUN (neighbor_interface_config_v6only, |
3783 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3784 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3785 | NEIGHBOR_STR |
3786 | "Interface name or neighbor tag\n" | |
3787 | "Enable BGP on interface\n" | |
31500417 DW |
3788 | "Enable BGP with v6 link-local only\n" |
3789 | "Member of the peer-group\n" | |
16cedbb0 | 3790 | "Peer-group name\n") |
4c48cf63 | 3791 | { |
d62a17ae | 3792 | int idx_word = 1; |
3793 | int idx_peer_group_word = 5; | |
31500417 | 3794 | |
d62a17ae | 3795 | if (argc > idx_peer_group_word) |
3796 | return peer_conf_interface_get( | |
3797 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3798 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3799 | |
d62a17ae | 3800 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3801 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3802 | } |
3803 | ||
a80beece | 3804 | |
b3a39dc5 DD |
3805 | DEFUN (neighbor_interface_config_remote_as, |
3806 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3807 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3808 | NEIGHBOR_STR |
3809 | "Interface name or neighbor tag\n" | |
3810 | "Enable BGP on interface\n" | |
3a2d747c | 3811 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3812 | AS_STR |
3a2d747c QY |
3813 | "Internal BGP peer\n" |
3814 | "External BGP peer\n") | |
b3a39dc5 | 3815 | { |
d62a17ae | 3816 | int idx_word = 1; |
3817 | int idx_remote_as = 4; | |
3818 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3819 | SAFI_UNICAST, 0, NULL, | |
3820 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3821 | } |
3822 | ||
3823 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3824 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3825 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3826 | NEIGHBOR_STR |
3827 | "Interface name or neighbor tag\n" | |
3a2d747c | 3828 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3829 | "Enable BGP on interface\n" |
3a2d747c | 3830 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3831 | AS_STR |
3a2d747c QY |
3832 | "Internal BGP peer\n" |
3833 | "External BGP peer\n") | |
b3a39dc5 | 3834 | { |
d62a17ae | 3835 | int idx_word = 1; |
3836 | int idx_remote_as = 5; | |
3837 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3838 | SAFI_UNICAST, 1, NULL, | |
3839 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3840 | } |
3841 | ||
718e3744 | 3842 | DEFUN (neighbor_peer_group, |
3843 | neighbor_peer_group_cmd, | |
3844 | "neighbor WORD peer-group", | |
3845 | NEIGHBOR_STR | |
a80beece | 3846 | "Interface name or neighbor tag\n" |
718e3744 | 3847 | "Configure peer-group\n") |
3848 | { | |
d62a17ae | 3849 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3850 | int idx_word = 1; | |
3851 | struct peer *peer; | |
3852 | struct peer_group *group; | |
718e3744 | 3853 | |
d62a17ae | 3854 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3855 | if (peer) { | |
3856 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3857 | return CMD_WARNING_CONFIG_FAILED; | |
3858 | } | |
718e3744 | 3859 | |
d62a17ae | 3860 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3861 | if (!group) { | |
3862 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3863 | return CMD_WARNING_CONFIG_FAILED; | |
3864 | } | |
718e3744 | 3865 | |
d62a17ae | 3866 | return CMD_SUCCESS; |
718e3744 | 3867 | } |
3868 | ||
3869 | DEFUN (no_neighbor, | |
3870 | no_neighbor_cmd, | |
dab8cd00 | 3871 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3872 | NO_STR |
3873 | NEIGHBOR_STR | |
3a2d747c QY |
3874 | NEIGHBOR_ADDR_STR2 |
3875 | "Specify a BGP neighbor\n" | |
3876 | AS_STR | |
3877 | "Internal BGP peer\n" | |
3878 | "External BGP peer\n") | |
718e3744 | 3879 | { |
d62a17ae | 3880 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3881 | int idx_peer = 2; | |
3882 | int ret; | |
3883 | union sockunion su; | |
3884 | struct peer_group *group; | |
3885 | struct peer *peer; | |
3886 | struct peer *other; | |
3887 | ||
3888 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3889 | if (ret < 0) { | |
3890 | /* look up for neighbor by interface name config. */ | |
3891 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3892 | if (peer) { | |
3893 | /* Request zebra to terminate IPv6 RAs on this | |
3894 | * interface. */ | |
3895 | if (peer->ifp) | |
3896 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3897 | peer_notify_unconfig(peer); |
d62a17ae | 3898 | peer_delete(peer); |
3899 | return CMD_SUCCESS; | |
3900 | } | |
f14e6fdb | 3901 | |
d62a17ae | 3902 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
3903 | if (group) { |
3904 | peer_group_notify_unconfig(group); | |
d62a17ae | 3905 | peer_group_delete(group); |
4e2786df | 3906 | } else { |
d62a17ae | 3907 | vty_out(vty, "%% Create the peer-group first\n"); |
3908 | return CMD_WARNING_CONFIG_FAILED; | |
3909 | } | |
3910 | } else { | |
3911 | peer = peer_lookup(bgp, &su); | |
3912 | if (peer) { | |
3913 | if (peer_dynamic_neighbor(peer)) { | |
3914 | vty_out(vty, | |
3915 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3916 | return CMD_WARNING_CONFIG_FAILED; | |
3917 | } | |
3918 | ||
3919 | other = peer->doppelganger; | |
b3a3290e DS |
3920 | |
3921 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
3922 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3923 | ||
4e2786df | 3924 | peer_notify_unconfig(peer); |
d62a17ae | 3925 | peer_delete(peer); |
4e2786df DA |
3926 | if (other && other->status != Deleted) { |
3927 | peer_notify_unconfig(other); | |
d62a17ae | 3928 | peer_delete(other); |
4e2786df | 3929 | } |
d62a17ae | 3930 | } |
1ff9a340 | 3931 | } |
718e3744 | 3932 | |
d62a17ae | 3933 | return CMD_SUCCESS; |
718e3744 | 3934 | } |
3935 | ||
a80beece DS |
3936 | DEFUN (no_neighbor_interface_config, |
3937 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3938 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3939 | NO_STR |
3940 | NEIGHBOR_STR | |
3941 | "Interface name\n" | |
31500417 DW |
3942 | "Configure BGP on interface\n" |
3943 | "Enable BGP with v6 link-local only\n" | |
3944 | "Member of the peer-group\n" | |
16cedbb0 | 3945 | "Peer-group name\n" |
3a2d747c QY |
3946 | "Specify a BGP neighbor\n" |
3947 | AS_STR | |
3948 | "Internal BGP peer\n" | |
3949 | "External BGP peer\n") | |
a80beece | 3950 | { |
d62a17ae | 3951 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3952 | int idx_word = 2; | |
3953 | struct peer *peer; | |
3954 | ||
3955 | /* look up for neighbor by interface name config. */ | |
3956 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3957 | if (peer) { | |
3958 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3959 | if (peer->ifp) | |
3960 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3961 | peer_notify_unconfig(peer); |
d62a17ae | 3962 | peer_delete(peer); |
3963 | } else { | |
3964 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3965 | return CMD_WARNING_CONFIG_FAILED; | |
3966 | } | |
3967 | return CMD_SUCCESS; | |
a80beece DS |
3968 | } |
3969 | ||
718e3744 | 3970 | DEFUN (no_neighbor_peer_group, |
3971 | no_neighbor_peer_group_cmd, | |
3972 | "no neighbor WORD peer-group", | |
3973 | NO_STR | |
3974 | NEIGHBOR_STR | |
3975 | "Neighbor tag\n" | |
3976 | "Configure peer-group\n") | |
3977 | { | |
d62a17ae | 3978 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3979 | int idx_word = 2; | |
3980 | struct peer_group *group; | |
718e3744 | 3981 | |
d62a17ae | 3982 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
3983 | if (group) { |
3984 | peer_group_notify_unconfig(group); | |
d62a17ae | 3985 | peer_group_delete(group); |
4e2786df | 3986 | } else { |
d62a17ae | 3987 | vty_out(vty, "%% Create the peer-group first\n"); |
3988 | return CMD_WARNING_CONFIG_FAILED; | |
3989 | } | |
3990 | return CMD_SUCCESS; | |
718e3744 | 3991 | } |
3992 | ||
a80beece DS |
3993 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3994 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3995 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3996 | NO_STR |
3997 | NEIGHBOR_STR | |
a80beece | 3998 | "Interface name or neighbor tag\n" |
718e3744 | 3999 | "Specify a BGP neighbor\n" |
3a2d747c QY |
4000 | AS_STR |
4001 | "Internal BGP peer\n" | |
4002 | "External BGP peer\n") | |
718e3744 | 4003 | { |
d62a17ae | 4004 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4005 | int idx_word = 2; | |
4006 | struct peer_group *group; | |
4007 | struct peer *peer; | |
4008 | ||
4009 | /* look up for neighbor by interface name config. */ | |
4010 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4011 | if (peer) { | |
390485fd | 4012 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 4013 | return CMD_SUCCESS; |
4014 | } | |
4015 | ||
4016 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4017 | if (group) | |
4018 | peer_group_remote_as_delete(group); | |
4019 | else { | |
4020 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4021 | return CMD_WARNING_CONFIG_FAILED; | |
4022 | } | |
4023 | return CMD_SUCCESS; | |
718e3744 | 4024 | } |
6b0655a2 | 4025 | |
718e3744 | 4026 | DEFUN (neighbor_local_as, |
4027 | neighbor_local_as_cmd, | |
9ccf14f7 | 4028 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 4029 | NEIGHBOR_STR |
4030 | NEIGHBOR_ADDR_STR2 | |
4031 | "Specify a local-as number\n" | |
4032 | "AS number used as local AS\n") | |
4033 | { | |
d62a17ae | 4034 | int idx_peer = 1; |
4035 | int idx_number = 3; | |
4036 | struct peer *peer; | |
4037 | int ret; | |
4038 | as_t as; | |
718e3744 | 4039 | |
d62a17ae | 4040 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4041 | if (!peer) | |
4042 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4043 | |
d62a17ae | 4044 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4045 | ret = peer_local_as_set(peer, as, 0, 0); | |
4046 | return bgp_vty_return(vty, ret); | |
718e3744 | 4047 | } |
4048 | ||
4049 | DEFUN (neighbor_local_as_no_prepend, | |
4050 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 4051 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 4052 | NEIGHBOR_STR |
4053 | NEIGHBOR_ADDR_STR2 | |
4054 | "Specify a local-as number\n" | |
4055 | "AS number used as local AS\n" | |
4056 | "Do not prepend local-as to updates from ebgp peers\n") | |
4057 | { | |
d62a17ae | 4058 | int idx_peer = 1; |
4059 | int idx_number = 3; | |
4060 | struct peer *peer; | |
4061 | int ret; | |
4062 | as_t as; | |
718e3744 | 4063 | |
d62a17ae | 4064 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4065 | if (!peer) | |
4066 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4067 | |
d62a17ae | 4068 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4069 | ret = peer_local_as_set(peer, as, 1, 0); | |
4070 | return bgp_vty_return(vty, ret); | |
718e3744 | 4071 | } |
4072 | ||
9d3f9705 AC |
4073 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4074 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 4075 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
4076 | NEIGHBOR_STR |
4077 | NEIGHBOR_ADDR_STR2 | |
4078 | "Specify a local-as number\n" | |
4079 | "AS number used as local AS\n" | |
4080 | "Do not prepend local-as to updates from ebgp peers\n" | |
4081 | "Do not prepend local-as to updates from ibgp peers\n") | |
4082 | { | |
d62a17ae | 4083 | int idx_peer = 1; |
4084 | int idx_number = 3; | |
4085 | struct peer *peer; | |
4086 | int ret; | |
4087 | as_t as; | |
9d3f9705 | 4088 | |
d62a17ae | 4089 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4090 | if (!peer) | |
4091 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 4092 | |
d62a17ae | 4093 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4094 | ret = peer_local_as_set(peer, as, 1, 1); | |
4095 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4096 | } |
4097 | ||
718e3744 | 4098 | DEFUN (no_neighbor_local_as, |
4099 | no_neighbor_local_as_cmd, | |
a636c635 | 4100 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 4101 | NO_STR |
4102 | NEIGHBOR_STR | |
4103 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4104 | "Specify a local-as number\n" |
4105 | "AS number used as local AS\n" | |
4106 | "Do not prepend local-as to updates from ebgp peers\n" | |
4107 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4108 | { |
d62a17ae | 4109 | int idx_peer = 2; |
4110 | struct peer *peer; | |
4111 | int ret; | |
718e3744 | 4112 | |
d62a17ae | 4113 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4114 | if (!peer) | |
4115 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4116 | |
d62a17ae | 4117 | ret = peer_local_as_unset(peer); |
4118 | return bgp_vty_return(vty, ret); | |
718e3744 | 4119 | } |
4120 | ||
718e3744 | 4121 | |
3f9c7369 DS |
4122 | DEFUN (neighbor_solo, |
4123 | neighbor_solo_cmd, | |
9ccf14f7 | 4124 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4125 | NEIGHBOR_STR |
4126 | NEIGHBOR_ADDR_STR2 | |
4127 | "Solo peer - part of its own update group\n") | |
4128 | { | |
d62a17ae | 4129 | int idx_peer = 1; |
4130 | struct peer *peer; | |
4131 | int ret; | |
3f9c7369 | 4132 | |
d62a17ae | 4133 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4134 | if (!peer) | |
4135 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4136 | |
d62a17ae | 4137 | ret = update_group_adjust_soloness(peer, 1); |
4138 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4139 | } |
4140 | ||
4141 | DEFUN (no_neighbor_solo, | |
4142 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4143 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4144 | NO_STR |
4145 | NEIGHBOR_STR | |
4146 | NEIGHBOR_ADDR_STR2 | |
4147 | "Solo peer - part of its own update group\n") | |
4148 | { | |
d62a17ae | 4149 | int idx_peer = 2; |
4150 | struct peer *peer; | |
4151 | int ret; | |
3f9c7369 | 4152 | |
d62a17ae | 4153 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4154 | if (!peer) | |
4155 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4156 | |
d62a17ae | 4157 | ret = update_group_adjust_soloness(peer, 0); |
4158 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4159 | } |
4160 | ||
0df7c91f PJ |
4161 | DEFUN (neighbor_password, |
4162 | neighbor_password_cmd, | |
9ccf14f7 | 4163 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
4164 | NEIGHBOR_STR |
4165 | NEIGHBOR_ADDR_STR2 | |
4166 | "Set a password\n" | |
4167 | "The password\n") | |
4168 | { | |
d62a17ae | 4169 | int idx_peer = 1; |
4170 | int idx_line = 3; | |
4171 | struct peer *peer; | |
4172 | int ret; | |
0df7c91f | 4173 | |
d62a17ae | 4174 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4175 | if (!peer) | |
4176 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4177 | |
d62a17ae | 4178 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4179 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4180 | } |
4181 | ||
4182 | DEFUN (no_neighbor_password, | |
4183 | no_neighbor_password_cmd, | |
a636c635 | 4184 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
4185 | NO_STR |
4186 | NEIGHBOR_STR | |
4187 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
4188 | "Set a password\n" |
4189 | "The password\n") | |
0df7c91f | 4190 | { |
d62a17ae | 4191 | int idx_peer = 2; |
4192 | struct peer *peer; | |
4193 | int ret; | |
0df7c91f | 4194 | |
d62a17ae | 4195 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4196 | if (!peer) | |
4197 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4198 | |
d62a17ae | 4199 | ret = peer_password_unset(peer); |
4200 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4201 | } |
6b0655a2 | 4202 | |
718e3744 | 4203 | DEFUN (neighbor_activate, |
4204 | neighbor_activate_cmd, | |
9ccf14f7 | 4205 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4206 | NEIGHBOR_STR |
4207 | NEIGHBOR_ADDR_STR2 | |
4208 | "Enable the Address Family for this Neighbor\n") | |
4209 | { | |
d62a17ae | 4210 | int idx_peer = 1; |
4211 | int ret; | |
4212 | struct peer *peer; | |
718e3744 | 4213 | |
d62a17ae | 4214 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4215 | if (!peer) | |
4216 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4217 | |
d62a17ae | 4218 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4219 | return bgp_vty_return(vty, ret); | |
718e3744 | 4220 | } |
4221 | ||
d62a17ae | 4222 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4223 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4224 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4225 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4226 | |
718e3744 | 4227 | DEFUN (no_neighbor_activate, |
4228 | no_neighbor_activate_cmd, | |
9ccf14f7 | 4229 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4230 | NO_STR |
4231 | NEIGHBOR_STR | |
4232 | NEIGHBOR_ADDR_STR2 | |
4233 | "Enable the Address Family for this Neighbor\n") | |
4234 | { | |
d62a17ae | 4235 | int idx_peer = 2; |
4236 | int ret; | |
4237 | struct peer *peer; | |
718e3744 | 4238 | |
d62a17ae | 4239 | /* Lookup peer. */ |
4240 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4241 | if (!peer) | |
4242 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4243 | |
d62a17ae | 4244 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4245 | return bgp_vty_return(vty, ret); | |
718e3744 | 4246 | } |
6b0655a2 | 4247 | |
d62a17ae | 4248 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4249 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4250 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4251 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4252 | |
718e3744 | 4253 | DEFUN (neighbor_set_peer_group, |
4254 | neighbor_set_peer_group_cmd, | |
d7b9898c | 4255 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4256 | NEIGHBOR_STR |
a80beece | 4257 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4258 | "Member of the peer-group\n" |
16cedbb0 | 4259 | "Peer-group name\n") |
718e3744 | 4260 | { |
d62a17ae | 4261 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4262 | int idx_peer = 1; | |
4263 | int idx_word = 3; | |
4264 | int ret; | |
4265 | as_t as; | |
4266 | union sockunion su; | |
4267 | struct peer *peer; | |
4268 | struct peer_group *group; | |
4269 | ||
d62a17ae | 4270 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4271 | if (ret < 0) { | |
4272 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4273 | if (!peer) { | |
4274 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4275 | argv[idx_peer]->arg); | |
4276 | return CMD_WARNING_CONFIG_FAILED; | |
4277 | } | |
4278 | } else { | |
4279 | if (peer_address_self_check(bgp, &su)) { | |
4280 | vty_out(vty, | |
4281 | "%% Can not configure the local system as neighbor\n"); | |
4282 | return CMD_WARNING_CONFIG_FAILED; | |
4283 | } | |
4284 | ||
4285 | /* Disallow for dynamic neighbor. */ | |
4286 | peer = peer_lookup(bgp, &su); | |
4287 | if (peer && peer_dynamic_neighbor(peer)) { | |
4288 | vty_out(vty, | |
4289 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4290 | return CMD_WARNING_CONFIG_FAILED; | |
4291 | } | |
4292 | } | |
4293 | ||
4294 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4295 | if (!group) { | |
4296 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4297 | return CMD_WARNING_CONFIG_FAILED; | |
4298 | } | |
4299 | ||
4300 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4301 | ||
4302 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4303 | vty_out(vty, | |
4304 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4305 | as); | |
4306 | return CMD_WARNING_CONFIG_FAILED; | |
4307 | } | |
4308 | ||
4309 | return bgp_vty_return(vty, ret); | |
4310 | } | |
4311 | ||
4312 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4313 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4314 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4315 | "Member of the peer-group\n" | |
4316 | "Peer-group name\n") | |
596c17ba | 4317 | |
718e3744 | 4318 | DEFUN (no_neighbor_set_peer_group, |
4319 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4320 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4321 | NO_STR |
4322 | NEIGHBOR_STR | |
a80beece | 4323 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4324 | "Member of the peer-group\n" |
16cedbb0 | 4325 | "Peer-group name\n") |
718e3744 | 4326 | { |
d62a17ae | 4327 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4328 | int idx_peer = 2; | |
4329 | int idx_word = 4; | |
4330 | int ret; | |
4331 | struct peer *peer; | |
4332 | struct peer_group *group; | |
4333 | ||
4334 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4335 | if (!peer) | |
4336 | return CMD_WARNING_CONFIG_FAILED; | |
4337 | ||
4338 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4339 | if (!group) { | |
4340 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4341 | return CMD_WARNING_CONFIG_FAILED; | |
4342 | } | |
718e3744 | 4343 | |
b3a3290e DS |
4344 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4345 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4346 | ||
4e2786df | 4347 | peer_notify_unconfig(peer); |
827ed707 | 4348 | ret = peer_delete(peer); |
718e3744 | 4349 | |
d62a17ae | 4350 | return bgp_vty_return(vty, ret); |
718e3744 | 4351 | } |
6b0655a2 | 4352 | |
d62a17ae | 4353 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4354 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4355 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4356 | "Member of the peer-group\n" | |
4357 | "Peer-group name\n") | |
596c17ba | 4358 | |
d62a17ae | 4359 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4360 | uint32_t flag, int set) |
718e3744 | 4361 | { |
d62a17ae | 4362 | int ret; |
4363 | struct peer *peer; | |
718e3744 | 4364 | |
d62a17ae | 4365 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4366 | if (!peer) | |
4367 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4368 | |
7ebe625c QY |
4369 | /* |
4370 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4371 | * we should not accept disable-connected-check. | |
4372 | */ | |
4373 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4374 | vty_out(vty, | |
3efd0893 | 4375 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
4376 | ip_str); |
4377 | return CMD_WARNING_CONFIG_FAILED; | |
4378 | } | |
4379 | ||
d62a17ae | 4380 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4381 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4382 | |
d62a17ae | 4383 | if (set) |
4384 | ret = peer_flag_set(peer, flag); | |
4385 | else | |
4386 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4387 | |
d62a17ae | 4388 | return bgp_vty_return(vty, ret); |
718e3744 | 4389 | } |
4390 | ||
47cbc09b | 4391 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4392 | { |
d62a17ae | 4393 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4394 | } |
4395 | ||
d62a17ae | 4396 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4397 | uint32_t flag) |
718e3744 | 4398 | { |
d62a17ae | 4399 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4400 | } |
4401 | ||
4402 | /* neighbor passive. */ | |
4403 | DEFUN (neighbor_passive, | |
4404 | neighbor_passive_cmd, | |
9ccf14f7 | 4405 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4406 | NEIGHBOR_STR |
4407 | NEIGHBOR_ADDR_STR2 | |
4408 | "Don't send open messages to this neighbor\n") | |
4409 | { | |
d62a17ae | 4410 | int idx_peer = 1; |
4411 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4412 | } |
4413 | ||
4414 | DEFUN (no_neighbor_passive, | |
4415 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4416 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4417 | NO_STR |
4418 | NEIGHBOR_STR | |
4419 | NEIGHBOR_ADDR_STR2 | |
4420 | "Don't send open messages to this neighbor\n") | |
4421 | { | |
d62a17ae | 4422 | int idx_peer = 2; |
4423 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4424 | } |
6b0655a2 | 4425 | |
718e3744 | 4426 | /* neighbor shutdown. */ |
73d70fa6 DL |
4427 | DEFUN (neighbor_shutdown_msg, |
4428 | neighbor_shutdown_msg_cmd, | |
4429 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4430 | NEIGHBOR_STR |
4431 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 | 4432 | "Administratively shut down this neighbor\n" |
70335e0a | 4433 | "Add a shutdown message (RFC 8203)\n" |
73d70fa6 | 4434 | "Shutdown message\n") |
718e3744 | 4435 | { |
d62a17ae | 4436 | int idx_peer = 1; |
73d70fa6 | 4437 | |
d62a17ae | 4438 | if (argc >= 5) { |
4439 | struct peer *peer = | |
4440 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4441 | char *message; | |
73d70fa6 | 4442 | |
d62a17ae | 4443 | if (!peer) |
4444 | return CMD_WARNING_CONFIG_FAILED; | |
4445 | message = argv_concat(argv, argc, 4); | |
4446 | peer_tx_shutdown_message_set(peer, message); | |
4447 | XFREE(MTYPE_TMP, message); | |
4448 | } | |
73d70fa6 | 4449 | |
d62a17ae | 4450 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4451 | } |
4452 | ||
d62a17ae | 4453 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4454 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4455 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4456 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4457 | |
4458 | DEFUN (no_neighbor_shutdown_msg, | |
4459 | no_neighbor_shutdown_msg_cmd, | |
4460 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4461 | NO_STR | |
4462 | NEIGHBOR_STR | |
4463 | NEIGHBOR_ADDR_STR2 | |
4464 | "Administratively shut down this neighbor\n" | |
70335e0a | 4465 | "Remove a shutdown message (RFC 8203)\n" |
73d70fa6 | 4466 | "Shutdown message\n") |
718e3744 | 4467 | { |
d62a17ae | 4468 | int idx_peer = 2; |
73d70fa6 | 4469 | |
d62a17ae | 4470 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4471 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4472 | } |
6b0655a2 | 4473 | |
d62a17ae | 4474 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4475 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4476 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4477 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4478 | |
718e3744 | 4479 | /* neighbor capability dynamic. */ |
4480 | DEFUN (neighbor_capability_dynamic, | |
4481 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4482 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4483 | NEIGHBOR_STR |
4484 | NEIGHBOR_ADDR_STR2 | |
4485 | "Advertise capability to the peer\n" | |
4486 | "Advertise dynamic capability to this neighbor\n") | |
4487 | { | |
d62a17ae | 4488 | int idx_peer = 1; |
4489 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4490 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4491 | } |
4492 | ||
4493 | DEFUN (no_neighbor_capability_dynamic, | |
4494 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4495 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4496 | NO_STR |
4497 | NEIGHBOR_STR | |
4498 | NEIGHBOR_ADDR_STR2 | |
4499 | "Advertise capability to the peer\n" | |
4500 | "Advertise dynamic capability to this neighbor\n") | |
4501 | { | |
d62a17ae | 4502 | int idx_peer = 2; |
4503 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4504 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4505 | } |
6b0655a2 | 4506 | |
718e3744 | 4507 | /* neighbor dont-capability-negotiate */ |
4508 | DEFUN (neighbor_dont_capability_negotiate, | |
4509 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4510 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4511 | NEIGHBOR_STR |
4512 | NEIGHBOR_ADDR_STR2 | |
4513 | "Do not perform capability negotiation\n") | |
4514 | { | |
d62a17ae | 4515 | int idx_peer = 1; |
4516 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4517 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4518 | } |
4519 | ||
4520 | DEFUN (no_neighbor_dont_capability_negotiate, | |
4521 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4522 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4523 | NO_STR |
4524 | NEIGHBOR_STR | |
4525 | NEIGHBOR_ADDR_STR2 | |
4526 | "Do not perform capability negotiation\n") | |
4527 | { | |
d62a17ae | 4528 | int idx_peer = 2; |
4529 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4530 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4531 | } |
6b0655a2 | 4532 | |
8a92a8a0 DS |
4533 | /* neighbor capability extended next hop encoding */ |
4534 | DEFUN (neighbor_capability_enhe, | |
4535 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4536 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4537 | NEIGHBOR_STR |
4538 | NEIGHBOR_ADDR_STR2 | |
4539 | "Advertise capability to the peer\n" | |
4540 | "Advertise extended next-hop capability to the peer\n") | |
4541 | { | |
d62a17ae | 4542 | int idx_peer = 1; |
4543 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4544 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4545 | } |
4546 | ||
4547 | DEFUN (no_neighbor_capability_enhe, | |
4548 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4549 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4550 | NO_STR |
4551 | NEIGHBOR_STR | |
4552 | NEIGHBOR_ADDR_STR2 | |
4553 | "Advertise capability to the peer\n" | |
4554 | "Advertise extended next-hop capability to the peer\n") | |
4555 | { | |
d62a17ae | 4556 | int idx_peer = 2; |
4557 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4558 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4559 | } |
4560 | ||
d62a17ae | 4561 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4562 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 4563 | int set) |
718e3744 | 4564 | { |
d62a17ae | 4565 | int ret; |
4566 | struct peer *peer; | |
718e3744 | 4567 | |
d62a17ae | 4568 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4569 | if (!peer) | |
4570 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4571 | |
d62a17ae | 4572 | if (set) |
4573 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
4574 | else | |
4575 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 4576 | |
d62a17ae | 4577 | return bgp_vty_return(vty, ret); |
718e3744 | 4578 | } |
4579 | ||
d62a17ae | 4580 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4581 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4582 | { |
d62a17ae | 4583 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 4584 | } |
4585 | ||
d62a17ae | 4586 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4587 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4588 | { |
d62a17ae | 4589 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 4590 | } |
6b0655a2 | 4591 | |
718e3744 | 4592 | /* neighbor capability orf prefix-list. */ |
4593 | DEFUN (neighbor_capability_orf_prefix, | |
4594 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4595 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4596 | NEIGHBOR_STR |
4597 | NEIGHBOR_ADDR_STR2 | |
4598 | "Advertise capability to the peer\n" | |
4599 | "Advertise ORF capability to the peer\n" | |
4600 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4601 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4602 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4603 | "Capability to SEND the ORF to this neighbor\n") | |
4604 | { | |
d62a17ae | 4605 | int idx_send_recv = 5; |
db45f64d DS |
4606 | char *peer_str = argv[1]->arg; |
4607 | struct peer *peer; | |
4608 | afi_t afi = bgp_node_afi(vty); | |
4609 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 4610 | |
db45f64d DS |
4611 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4612 | if (!peer) | |
d62a17ae | 4613 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 4614 | |
db45f64d DS |
4615 | if (strmatch(argv[idx_send_recv]->text, "send")) |
4616 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4617 | PEER_FLAG_ORF_PREFIX_SM); | |
4618 | ||
4619 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4620 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4621 | PEER_FLAG_ORF_PREFIX_RM); | |
4622 | ||
4623 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
4624 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4625 | PEER_FLAG_ORF_PREFIX_SM) | |
4626 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4627 | PEER_FLAG_ORF_PREFIX_RM); | |
4628 | ||
4629 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4630 | } |
4631 | ||
4632 | ALIAS_HIDDEN( | |
4633 | neighbor_capability_orf_prefix, | |
4634 | neighbor_capability_orf_prefix_hidden_cmd, | |
4635 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4636 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4637 | "Advertise capability to the peer\n" | |
4638 | "Advertise ORF capability to the peer\n" | |
4639 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4640 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4641 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4642 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4643 | |
718e3744 | 4644 | DEFUN (no_neighbor_capability_orf_prefix, |
4645 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4646 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4647 | NO_STR |
4648 | NEIGHBOR_STR | |
4649 | NEIGHBOR_ADDR_STR2 | |
4650 | "Advertise capability to the peer\n" | |
4651 | "Advertise ORF capability to the peer\n" | |
4652 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4653 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4654 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4655 | "Capability to SEND the ORF to this neighbor\n") | |
4656 | { | |
d62a17ae | 4657 | int idx_send_recv = 6; |
db45f64d DS |
4658 | char *peer_str = argv[2]->arg; |
4659 | struct peer *peer; | |
4660 | afi_t afi = bgp_node_afi(vty); | |
4661 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 4662 | |
db45f64d DS |
4663 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4664 | if (!peer) | |
d62a17ae | 4665 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 4666 | |
db45f64d DS |
4667 | if (strmatch(argv[idx_send_recv]->text, "send")) |
4668 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4669 | PEER_FLAG_ORF_PREFIX_SM); | |
4670 | ||
4671 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4672 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4673 | PEER_FLAG_ORF_PREFIX_RM); | |
4674 | ||
4675 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
4676 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4677 | PEER_FLAG_ORF_PREFIX_SM) | |
4678 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4679 | PEER_FLAG_ORF_PREFIX_RM); | |
4680 | ||
4681 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4682 | } |
4683 | ||
4684 | ALIAS_HIDDEN( | |
4685 | no_neighbor_capability_orf_prefix, | |
4686 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4687 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4688 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4689 | "Advertise capability to the peer\n" | |
4690 | "Advertise ORF capability to the peer\n" | |
4691 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4692 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4693 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4694 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4695 | |
718e3744 | 4696 | /* neighbor next-hop-self. */ |
4697 | DEFUN (neighbor_nexthop_self, | |
4698 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4699 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4700 | NEIGHBOR_STR |
4701 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4702 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4703 | { |
d62a17ae | 4704 | int idx_peer = 1; |
4705 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4706 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4707 | } |
9e7a53c1 | 4708 | |
d62a17ae | 4709 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4710 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4711 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4712 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4713 | |
a538debe DS |
4714 | /* neighbor next-hop-self. */ |
4715 | DEFUN (neighbor_nexthop_self_force, | |
4716 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4717 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4718 | NEIGHBOR_STR |
4719 | NEIGHBOR_ADDR_STR2 | |
4720 | "Disable the next hop calculation for this neighbor\n" | |
4721 | "Set the next hop to self for reflected routes\n") | |
4722 | { | |
d62a17ae | 4723 | int idx_peer = 1; |
4724 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4725 | bgp_node_safi(vty), | |
4726 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4727 | } |
4728 | ||
d62a17ae | 4729 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4730 | neighbor_nexthop_self_force_hidden_cmd, | |
4731 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4732 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4733 | "Disable the next hop calculation for this neighbor\n" | |
4734 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4735 | |
1bc4e531 DA |
4736 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4737 | neighbor_nexthop_self_all_hidden_cmd, | |
4738 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4739 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4740 | "Disable the next hop calculation for this neighbor\n" | |
4741 | "Set the next hop to self for reflected routes\n") | |
4742 | ||
718e3744 | 4743 | DEFUN (no_neighbor_nexthop_self, |
4744 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4745 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4746 | NO_STR |
4747 | NEIGHBOR_STR | |
4748 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4749 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4750 | { |
d62a17ae | 4751 | int idx_peer = 2; |
4752 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4753 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4754 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4755 | } |
6b0655a2 | 4756 | |
d62a17ae | 4757 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4758 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4759 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4760 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4761 | |
88b8ed8d | 4762 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4763 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4764 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4765 | NO_STR |
4766 | NEIGHBOR_STR | |
4767 | NEIGHBOR_ADDR_STR2 | |
4768 | "Disable the next hop calculation for this neighbor\n" | |
4769 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4770 | { |
d62a17ae | 4771 | int idx_peer = 2; |
4772 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4773 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4774 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4775 | } |
a538debe | 4776 | |
d62a17ae | 4777 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4778 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4779 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4780 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4781 | "Disable the next hop calculation for this neighbor\n" | |
4782 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4783 | |
1bc4e531 DA |
4784 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4785 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4786 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4787 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4788 | "Disable the next hop calculation for this neighbor\n" | |
4789 | "Set the next hop to self for reflected routes\n") | |
4790 | ||
c7122e14 DS |
4791 | /* neighbor as-override */ |
4792 | DEFUN (neighbor_as_override, | |
4793 | neighbor_as_override_cmd, | |
9ccf14f7 | 4794 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4795 | NEIGHBOR_STR |
4796 | NEIGHBOR_ADDR_STR2 | |
4797 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4798 | { | |
d62a17ae | 4799 | int idx_peer = 1; |
4800 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4801 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4802 | } |
4803 | ||
d62a17ae | 4804 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4805 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4806 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4807 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4808 | |
c7122e14 DS |
4809 | DEFUN (no_neighbor_as_override, |
4810 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4811 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4812 | NO_STR |
4813 | NEIGHBOR_STR | |
4814 | NEIGHBOR_ADDR_STR2 | |
4815 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4816 | { | |
d62a17ae | 4817 | int idx_peer = 2; |
4818 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4819 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4820 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4821 | } |
4822 | ||
d62a17ae | 4823 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4824 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4825 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4826 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4827 | |
718e3744 | 4828 | /* neighbor remove-private-AS. */ |
4829 | DEFUN (neighbor_remove_private_as, | |
4830 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4831 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4832 | NEIGHBOR_STR |
4833 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4834 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4835 | { |
d62a17ae | 4836 | int idx_peer = 1; |
4837 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4838 | bgp_node_safi(vty), | |
4839 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4840 | } |
4841 | ||
d62a17ae | 4842 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4843 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4844 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4845 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4846 | |
5000f21c DS |
4847 | DEFUN (neighbor_remove_private_as_all, |
4848 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4849 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4850 | NEIGHBOR_STR |
4851 | NEIGHBOR_ADDR_STR2 | |
4852 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4853 | "Apply to all AS numbers\n") |
5000f21c | 4854 | { |
d62a17ae | 4855 | int idx_peer = 1; |
4856 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4857 | bgp_node_safi(vty), | |
4858 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4859 | } |
4860 | ||
d62a17ae | 4861 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4862 | neighbor_remove_private_as_all_hidden_cmd, | |
4863 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4864 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4865 | "Remove private ASNs in outbound updates\n" | |
4866 | "Apply to all AS numbers") | |
596c17ba | 4867 | |
5000f21c DS |
4868 | DEFUN (neighbor_remove_private_as_replace_as, |
4869 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4870 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4871 | NEIGHBOR_STR |
4872 | NEIGHBOR_ADDR_STR2 | |
4873 | "Remove private ASNs in outbound updates\n" | |
4874 | "Replace private ASNs with our ASN in outbound updates\n") | |
4875 | { | |
d62a17ae | 4876 | int idx_peer = 1; |
4877 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4878 | bgp_node_safi(vty), | |
4879 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4880 | } |
4881 | ||
d62a17ae | 4882 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4883 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4884 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4885 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4886 | "Remove private ASNs in outbound updates\n" | |
4887 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4888 | |
5000f21c DS |
4889 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4890 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4891 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4892 | NEIGHBOR_STR |
4893 | NEIGHBOR_ADDR_STR2 | |
4894 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4895 | "Apply to all AS numbers\n" |
5000f21c DS |
4896 | "Replace private ASNs with our ASN in outbound updates\n") |
4897 | { | |
d62a17ae | 4898 | int idx_peer = 1; |
4899 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4900 | bgp_node_safi(vty), | |
4901 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4902 | } |
4903 | ||
d62a17ae | 4904 | ALIAS_HIDDEN( |
4905 | neighbor_remove_private_as_all_replace_as, | |
4906 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4907 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4908 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4909 | "Remove private ASNs in outbound updates\n" | |
4910 | "Apply to all AS numbers\n" | |
4911 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4912 | |
718e3744 | 4913 | DEFUN (no_neighbor_remove_private_as, |
4914 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4915 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4916 | NO_STR |
4917 | NEIGHBOR_STR | |
4918 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4919 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4920 | { |
d62a17ae | 4921 | int idx_peer = 2; |
4922 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4923 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4924 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4925 | } |
6b0655a2 | 4926 | |
d62a17ae | 4927 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4928 | no_neighbor_remove_private_as_hidden_cmd, | |
4929 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4930 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4931 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4932 | |
88b8ed8d | 4933 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4934 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4935 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4936 | NO_STR |
4937 | NEIGHBOR_STR | |
4938 | NEIGHBOR_ADDR_STR2 | |
4939 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4940 | "Apply to all AS numbers\n") |
88b8ed8d | 4941 | { |
d62a17ae | 4942 | int idx_peer = 2; |
4943 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4944 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4945 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4946 | } |
5000f21c | 4947 | |
d62a17ae | 4948 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4949 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4950 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4951 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4952 | "Remove private ASNs in outbound updates\n" | |
4953 | "Apply to all AS numbers\n") | |
596c17ba | 4954 | |
88b8ed8d | 4955 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4956 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4957 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4958 | NO_STR |
4959 | NEIGHBOR_STR | |
4960 | NEIGHBOR_ADDR_STR2 | |
4961 | "Remove private ASNs in outbound updates\n" | |
4962 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4963 | { |
d62a17ae | 4964 | int idx_peer = 2; |
4965 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4966 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4967 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4968 | } |
5000f21c | 4969 | |
d62a17ae | 4970 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4971 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4972 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4973 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4974 | "Remove private ASNs in outbound updates\n" | |
4975 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4976 | |
88b8ed8d | 4977 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4978 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4979 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4980 | NO_STR |
4981 | NEIGHBOR_STR | |
4982 | NEIGHBOR_ADDR_STR2 | |
4983 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4984 | "Apply to all AS numbers\n" |
5000f21c | 4985 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4986 | { |
d62a17ae | 4987 | int idx_peer = 2; |
4988 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4989 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4990 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4991 | } |
5000f21c | 4992 | |
d62a17ae | 4993 | ALIAS_HIDDEN( |
4994 | no_neighbor_remove_private_as_all_replace_as, | |
4995 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4996 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4997 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4998 | "Remove private ASNs in outbound updates\n" | |
4999 | "Apply to all AS numbers\n" | |
5000 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5001 | |
5000f21c | 5002 | |
718e3744 | 5003 | /* neighbor send-community. */ |
5004 | DEFUN (neighbor_send_community, | |
5005 | neighbor_send_community_cmd, | |
9ccf14f7 | 5006 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 5007 | NEIGHBOR_STR |
5008 | NEIGHBOR_ADDR_STR2 | |
5009 | "Send Community attribute to this neighbor\n") | |
5010 | { | |
d62a17ae | 5011 | int idx_peer = 1; |
27c05d4d | 5012 | |
d62a17ae | 5013 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5014 | bgp_node_safi(vty), | |
5015 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5016 | } |
5017 | ||
d62a17ae | 5018 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
5019 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5020 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5021 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5022 | |
718e3744 | 5023 | DEFUN (no_neighbor_send_community, |
5024 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 5025 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 5026 | NO_STR |
5027 | NEIGHBOR_STR | |
5028 | NEIGHBOR_ADDR_STR2 | |
5029 | "Send Community attribute to this neighbor\n") | |
5030 | { | |
d62a17ae | 5031 | int idx_peer = 2; |
27c05d4d | 5032 | |
d62a17ae | 5033 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5034 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5035 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5036 | } |
6b0655a2 | 5037 | |
d62a17ae | 5038 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
5039 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5040 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5041 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5042 | |
718e3744 | 5043 | /* neighbor send-community extended. */ |
5044 | DEFUN (neighbor_send_community_type, | |
5045 | neighbor_send_community_type_cmd, | |
57d187bc | 5046 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5047 | NEIGHBOR_STR |
5048 | NEIGHBOR_ADDR_STR2 | |
5049 | "Send Community attribute to this neighbor\n" | |
5050 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5051 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5052 | "Send Extended Community attributes\n" |
57d187bc JS |
5053 | "Send Standard Community attributes\n" |
5054 | "Send Large Community attributes\n") | |
718e3744 | 5055 | { |
27c05d4d | 5056 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
5057 | char *peer_str = argv[1]->arg; |
5058 | struct peer *peer; | |
5059 | afi_t afi = bgp_node_afi(vty); | |
5060 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5061 | |
db45f64d DS |
5062 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5063 | if (!peer) | |
5064 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5065 | |
db45f64d DS |
5066 | if (strmatch(type, "standard")) |
5067 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5068 | PEER_FLAG_SEND_COMMUNITY); | |
5069 | ||
5070 | if (strmatch(type, "extended")) | |
5071 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5072 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5073 | ||
5074 | if (strmatch(type, "large")) | |
5075 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5076 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5077 | ||
5078 | if (strmatch(type, "both")) { | |
5079 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5080 | PEER_FLAG_SEND_COMMUNITY) | |
5081 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5082 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5083 | } | |
5084 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5085 | PEER_FLAG_SEND_COMMUNITY) | |
5086 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5087 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5088 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5089 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5090 | } |
5091 | ||
5092 | ALIAS_HIDDEN( | |
5093 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5094 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5095 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5096 | "Send Community attribute to this neighbor\n" | |
5097 | "Send Standard and Extended Community attributes\n" | |
5098 | "Send Standard, Large and Extended Community attributes\n" | |
5099 | "Send Extended Community attributes\n" | |
5100 | "Send Standard Community attributes\n" | |
5101 | "Send Large Community attributes\n") | |
596c17ba | 5102 | |
718e3744 | 5103 | DEFUN (no_neighbor_send_community_type, |
5104 | no_neighbor_send_community_type_cmd, | |
57d187bc | 5105 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5106 | NO_STR |
5107 | NEIGHBOR_STR | |
5108 | NEIGHBOR_ADDR_STR2 | |
5109 | "Send Community attribute to this neighbor\n" | |
5110 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5111 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5112 | "Send Extended Community attributes\n" |
57d187bc JS |
5113 | "Send Standard Community attributes\n" |
5114 | "Send Large Community attributes\n") | |
718e3744 | 5115 | { |
d62a17ae | 5116 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
5117 | char *peer_str = argv[2]->arg; |
5118 | struct peer *peer; | |
5119 | afi_t afi = bgp_node_afi(vty); | |
5120 | safi_t safi = bgp_node_safi(vty); | |
5121 | ||
5122 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5123 | if (!peer) | |
5124 | return CMD_WARNING_CONFIG_FAILED; | |
5125 | ||
5126 | if (strmatch(type, "standard")) | |
5127 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5128 | PEER_FLAG_SEND_COMMUNITY); | |
5129 | ||
5130 | if (strmatch(type, "extended")) | |
5131 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5132 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5133 | ||
5134 | if (strmatch(type, "large")) | |
5135 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5136 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5137 | ||
5138 | if (strmatch(type, "both")) { | |
d62a17ae | 5139 | |
db45f64d DS |
5140 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5141 | PEER_FLAG_SEND_COMMUNITY) | |
5142 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5143 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5144 | } |
5145 | ||
db45f64d DS |
5146 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5147 | PEER_FLAG_SEND_COMMUNITY) | |
5148 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5149 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5150 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5151 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5152 | } |
5153 | ||
5154 | ALIAS_HIDDEN( | |
5155 | no_neighbor_send_community_type, | |
5156 | no_neighbor_send_community_type_hidden_cmd, | |
5157 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5158 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5159 | "Send Community attribute to this neighbor\n" | |
5160 | "Send Standard and Extended Community attributes\n" | |
5161 | "Send Standard, Large and Extended Community attributes\n" | |
5162 | "Send Extended Community attributes\n" | |
5163 | "Send Standard Community attributes\n" | |
5164 | "Send Large Community attributes\n") | |
596c17ba | 5165 | |
718e3744 | 5166 | /* neighbor soft-reconfig. */ |
5167 | DEFUN (neighbor_soft_reconfiguration, | |
5168 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5169 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5170 | NEIGHBOR_STR |
5171 | NEIGHBOR_ADDR_STR2 | |
5172 | "Per neighbor soft reconfiguration\n" | |
5173 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5174 | { | |
d62a17ae | 5175 | int idx_peer = 1; |
5176 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5177 | bgp_node_safi(vty), | |
5178 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5179 | } |
5180 | ||
d62a17ae | 5181 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5182 | neighbor_soft_reconfiguration_hidden_cmd, | |
5183 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5184 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5185 | "Per neighbor soft reconfiguration\n" | |
5186 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5187 | |
718e3744 | 5188 | DEFUN (no_neighbor_soft_reconfiguration, |
5189 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5190 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5191 | NO_STR |
5192 | NEIGHBOR_STR | |
5193 | NEIGHBOR_ADDR_STR2 | |
5194 | "Per neighbor soft reconfiguration\n" | |
5195 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5196 | { | |
d62a17ae | 5197 | int idx_peer = 2; |
5198 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5199 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5200 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5201 | } |
6b0655a2 | 5202 | |
d62a17ae | 5203 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5204 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5205 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5206 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5207 | "Per neighbor soft reconfiguration\n" | |
5208 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5209 | |
718e3744 | 5210 | DEFUN (neighbor_route_reflector_client, |
5211 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5212 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5213 | NEIGHBOR_STR |
5214 | NEIGHBOR_ADDR_STR2 | |
5215 | "Configure a neighbor as Route Reflector client\n") | |
5216 | { | |
d62a17ae | 5217 | int idx_peer = 1; |
5218 | struct peer *peer; | |
718e3744 | 5219 | |
5220 | ||
d62a17ae | 5221 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5222 | if (!peer) | |
5223 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5224 | |
d62a17ae | 5225 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5226 | bgp_node_safi(vty), | |
5227 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5228 | } |
5229 | ||
d62a17ae | 5230 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5231 | neighbor_route_reflector_client_hidden_cmd, | |
5232 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5233 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5234 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5235 | |
718e3744 | 5236 | DEFUN (no_neighbor_route_reflector_client, |
5237 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5238 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5239 | NO_STR |
5240 | NEIGHBOR_STR | |
5241 | NEIGHBOR_ADDR_STR2 | |
5242 | "Configure a neighbor as Route Reflector client\n") | |
5243 | { | |
d62a17ae | 5244 | int idx_peer = 2; |
5245 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5246 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5247 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5248 | } |
6b0655a2 | 5249 | |
d62a17ae | 5250 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5251 | no_neighbor_route_reflector_client_hidden_cmd, | |
5252 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5253 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5254 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5255 | |
718e3744 | 5256 | /* neighbor route-server-client. */ |
5257 | DEFUN (neighbor_route_server_client, | |
5258 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5259 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5260 | NEIGHBOR_STR |
5261 | NEIGHBOR_ADDR_STR2 | |
5262 | "Configure a neighbor as Route Server client\n") | |
5263 | { | |
d62a17ae | 5264 | int idx_peer = 1; |
5265 | struct peer *peer; | |
2a3d5731 | 5266 | |
d62a17ae | 5267 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5268 | if (!peer) | |
5269 | return CMD_WARNING_CONFIG_FAILED; | |
5270 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5271 | bgp_node_safi(vty), | |
5272 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5273 | } |
5274 | ||
d62a17ae | 5275 | ALIAS_HIDDEN(neighbor_route_server_client, |
5276 | neighbor_route_server_client_hidden_cmd, | |
5277 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5278 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5279 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5280 | |
718e3744 | 5281 | DEFUN (no_neighbor_route_server_client, |
5282 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5283 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5284 | NO_STR |
5285 | NEIGHBOR_STR | |
5286 | NEIGHBOR_ADDR_STR2 | |
5287 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5288 | { |
d62a17ae | 5289 | int idx_peer = 2; |
5290 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5291 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5292 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5293 | } |
6b0655a2 | 5294 | |
d62a17ae | 5295 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5296 | no_neighbor_route_server_client_hidden_cmd, | |
5297 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5298 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5299 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5300 | |
fee0f4c6 | 5301 | DEFUN (neighbor_nexthop_local_unchanged, |
5302 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5303 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5304 | NEIGHBOR_STR |
5305 | NEIGHBOR_ADDR_STR2 | |
5306 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5307 | "Leave link-local nexthop unchanged for this peer\n") | |
5308 | { | |
d62a17ae | 5309 | int idx_peer = 1; |
5310 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5311 | bgp_node_safi(vty), | |
5312 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5313 | } |
6b0655a2 | 5314 | |
fee0f4c6 | 5315 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5316 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5317 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5318 | NO_STR |
5319 | NEIGHBOR_STR | |
5320 | NEIGHBOR_ADDR_STR2 | |
5321 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5322 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5323 | { |
d62a17ae | 5324 | int idx_peer = 2; |
5325 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5326 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5327 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5328 | } |
6b0655a2 | 5329 | |
718e3744 | 5330 | DEFUN (neighbor_attr_unchanged, |
5331 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5332 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5333 | NEIGHBOR_STR |
5334 | NEIGHBOR_ADDR_STR2 | |
5335 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5336 | "As-path attribute\n" | |
5337 | "Nexthop attribute\n" | |
a8206004 | 5338 | "Med attribute\n") |
718e3744 | 5339 | { |
d62a17ae | 5340 | int idx = 0; |
8eeb0335 DW |
5341 | char *peer_str = argv[1]->arg; |
5342 | struct peer *peer; | |
db45f64d DS |
5343 | bool aspath = false; |
5344 | bool nexthop = false; | |
5345 | bool med = false; | |
8eeb0335 DW |
5346 | afi_t afi = bgp_node_afi(vty); |
5347 | safi_t safi = bgp_node_safi(vty); | |
db45f64d | 5348 | int ret = 0; |
8eeb0335 DW |
5349 | |
5350 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5351 | if (!peer) | |
5352 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5353 | |
5354 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5355 | aspath = true; |
5356 | ||
d62a17ae | 5357 | idx = 0; |
5358 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5359 | nexthop = true; |
5360 | ||
d62a17ae | 5361 | idx = 0; |
5362 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5363 | med = true; |
d62a17ae | 5364 | |
8eeb0335 | 5365 | /* no flags means all of them! */ |
db45f64d DS |
5366 | if (!aspath && !nexthop && !med) { |
5367 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5368 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5369 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5370 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5371 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5372 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5373 | } else { |
db45f64d DS |
5374 | if (!aspath) { |
5375 | if (peer_af_flag_check(peer, afi, safi, | |
5376 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
5377 | ret |= peer_af_flag_unset_vty( | |
5378 | vty, peer_str, afi, safi, | |
5379 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5380 | } | |
5381 | } else | |
5382 | ret |= peer_af_flag_set_vty( | |
5383 | vty, peer_str, afi, safi, | |
5384 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5385 | ||
5386 | if (!nexthop) { | |
5387 | if (peer_af_flag_check(peer, afi, safi, | |
5388 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
5389 | ret |= peer_af_flag_unset_vty( | |
5390 | vty, peer_str, afi, safi, | |
5391 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5392 | } | |
5393 | } else | |
5394 | ret |= peer_af_flag_set_vty( | |
5395 | vty, peer_str, afi, safi, | |
5396 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5397 | ||
5398 | if (!med) { | |
5399 | if (peer_af_flag_check(peer, afi, safi, | |
5400 | PEER_FLAG_MED_UNCHANGED)) { | |
5401 | ret |= peer_af_flag_unset_vty( | |
5402 | vty, peer_str, afi, safi, | |
5403 | PEER_FLAG_MED_UNCHANGED); | |
5404 | } | |
5405 | } else | |
5406 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5407 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 5408 | } |
5409 | ||
db45f64d | 5410 | return ret; |
d62a17ae | 5411 | } |
5412 | ||
5413 | ALIAS_HIDDEN( | |
5414 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5415 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5416 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5417 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5418 | "As-path attribute\n" | |
5419 | "Nexthop attribute\n" | |
5420 | "Med attribute\n") | |
596c17ba | 5421 | |
718e3744 | 5422 | DEFUN (no_neighbor_attr_unchanged, |
5423 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5424 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5425 | NO_STR |
718e3744 | 5426 | NEIGHBOR_STR |
5427 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5428 | "BGP attribute is propagated unchanged to this neighbor\n" |
5429 | "As-path attribute\n" | |
40e718b5 | 5430 | "Nexthop attribute\n" |
a8206004 | 5431 | "Med attribute\n") |
718e3744 | 5432 | { |
d62a17ae | 5433 | int idx = 0; |
db45f64d DS |
5434 | char *peer_str = argv[2]->arg; |
5435 | struct peer *peer; | |
5436 | bool aspath = false; | |
5437 | bool nexthop = false; | |
5438 | bool med = false; | |
5439 | afi_t afi = bgp_node_afi(vty); | |
5440 | safi_t safi = bgp_node_safi(vty); | |
5441 | int ret = 0; | |
5442 | ||
5443 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5444 | if (!peer) | |
5445 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5446 | |
5447 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5448 | aspath = true; |
5449 | ||
d62a17ae | 5450 | idx = 0; |
5451 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5452 | nexthop = true; |
5453 | ||
d62a17ae | 5454 | idx = 0; |
5455 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5456 | med = true; |
d62a17ae | 5457 | |
db45f64d DS |
5458 | if (!aspath && !nexthop && !med) // no flags means all of them! |
5459 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5460 | PEER_FLAG_AS_PATH_UNCHANGED) | |
5461 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5462 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
5463 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5464 | PEER_FLAG_MED_UNCHANGED); | |
5465 | ||
5466 | if (aspath) | |
5467 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5468 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5469 | ||
5470 | if (nexthop) | |
5471 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5472 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 5473 | |
db45f64d DS |
5474 | if (med) |
5475 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5476 | PEER_FLAG_MED_UNCHANGED); | |
5477 | ||
5478 | return ret; | |
d62a17ae | 5479 | } |
5480 | ||
5481 | ALIAS_HIDDEN( | |
5482 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5483 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5484 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5485 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5486 | "As-path attribute\n" | |
5487 | "Nexthop attribute\n" | |
5488 | "Med attribute\n") | |
718e3744 | 5489 | |
718e3744 | 5490 | /* EBGP multihop configuration. */ |
d62a17ae | 5491 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5492 | const char *ttl_str) | |
718e3744 | 5493 | { |
d62a17ae | 5494 | struct peer *peer; |
5495 | unsigned int ttl; | |
718e3744 | 5496 | |
d62a17ae | 5497 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5498 | if (!peer) | |
5499 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5500 | |
d62a17ae | 5501 | if (peer->conf_if) |
5502 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5503 | |
d62a17ae | 5504 | if (!ttl_str) |
5505 | ttl = MAXTTL; | |
5506 | else | |
5507 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5508 | |
d62a17ae | 5509 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5510 | } |
5511 | ||
d62a17ae | 5512 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5513 | { |
d62a17ae | 5514 | struct peer *peer; |
718e3744 | 5515 | |
d62a17ae | 5516 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5517 | if (!peer) | |
5518 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5519 | |
d62a17ae | 5520 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 5521 | } |
5522 | ||
5523 | /* neighbor ebgp-multihop. */ | |
5524 | DEFUN (neighbor_ebgp_multihop, | |
5525 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 5526 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 5527 | NEIGHBOR_STR |
5528 | NEIGHBOR_ADDR_STR2 | |
5529 | "Allow EBGP neighbors not on directly connected networks\n") | |
5530 | { | |
d62a17ae | 5531 | int idx_peer = 1; |
5532 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5533 | } |
5534 | ||
5535 | DEFUN (neighbor_ebgp_multihop_ttl, | |
5536 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 5537 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 5538 | NEIGHBOR_STR |
5539 | NEIGHBOR_ADDR_STR2 | |
5540 | "Allow EBGP neighbors not on directly connected networks\n" | |
5541 | "maximum hop count\n") | |
5542 | { | |
d62a17ae | 5543 | int idx_peer = 1; |
5544 | int idx_number = 3; | |
5545 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
5546 | argv[idx_number]->arg); | |
718e3744 | 5547 | } |
5548 | ||
5549 | DEFUN (no_neighbor_ebgp_multihop, | |
5550 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 5551 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 5552 | NO_STR |
5553 | NEIGHBOR_STR | |
5554 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5555 | "Allow EBGP neighbors not on directly connected networks\n" |
5556 | "maximum hop count\n") | |
718e3744 | 5557 | { |
d62a17ae | 5558 | int idx_peer = 2; |
5559 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5560 | } |
5561 | ||
6b0655a2 | 5562 | |
6ffd2079 | 5563 | /* disable-connected-check */ |
5564 | DEFUN (neighbor_disable_connected_check, | |
5565 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 5566 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5567 | NEIGHBOR_STR |
7ebe625c | 5568 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5569 | "one-hop away EBGP peer using loopback address\n" |
5570 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5571 | { |
d62a17ae | 5572 | int idx_peer = 1; |
5573 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5574 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5575 | } |
5576 | ||
5577 | DEFUN (no_neighbor_disable_connected_check, | |
5578 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 5579 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5580 | NO_STR |
5581 | NEIGHBOR_STR | |
7ebe625c | 5582 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5583 | "one-hop away EBGP peer using loopback address\n" |
5584 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5585 | { |
d62a17ae | 5586 | int idx_peer = 2; |
5587 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5588 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5589 | } |
5590 | ||
47cbc09b PM |
5591 | |
5592 | /* enforce-first-as */ | |
5593 | DEFUN (neighbor_enforce_first_as, | |
5594 | neighbor_enforce_first_as_cmd, | |
5595 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5596 | NEIGHBOR_STR | |
5597 | NEIGHBOR_ADDR_STR2 | |
5598 | "Enforce the first AS for EBGP routes\n") | |
5599 | { | |
5600 | int idx_peer = 1; | |
5601 | ||
5602 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5603 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5604 | } | |
5605 | ||
5606 | DEFUN (no_neighbor_enforce_first_as, | |
5607 | no_neighbor_enforce_first_as_cmd, | |
5608 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5609 | NO_STR | |
5610 | NEIGHBOR_STR | |
5611 | NEIGHBOR_ADDR_STR2 | |
5612 | "Enforce the first AS for EBGP routes\n") | |
5613 | { | |
5614 | int idx_peer = 2; | |
5615 | ||
5616 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5617 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5618 | } | |
5619 | ||
5620 | ||
718e3744 | 5621 | DEFUN (neighbor_description, |
5622 | neighbor_description_cmd, | |
e961923c | 5623 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 5624 | NEIGHBOR_STR |
5625 | NEIGHBOR_ADDR_STR2 | |
5626 | "Neighbor specific description\n" | |
5627 | "Up to 80 characters describing this neighbor\n") | |
5628 | { | |
d62a17ae | 5629 | int idx_peer = 1; |
5630 | int idx_line = 3; | |
5631 | struct peer *peer; | |
5632 | char *str; | |
718e3744 | 5633 | |
d62a17ae | 5634 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5635 | if (!peer) | |
5636 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5637 | |
d62a17ae | 5638 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 5639 | |
d62a17ae | 5640 | peer_description_set(peer, str); |
718e3744 | 5641 | |
d62a17ae | 5642 | XFREE(MTYPE_TMP, str); |
718e3744 | 5643 | |
d62a17ae | 5644 | return CMD_SUCCESS; |
718e3744 | 5645 | } |
5646 | ||
5647 | DEFUN (no_neighbor_description, | |
5648 | no_neighbor_description_cmd, | |
a14810f4 | 5649 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 5650 | NO_STR |
5651 | NEIGHBOR_STR | |
5652 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 5653 | "Neighbor specific description\n") |
718e3744 | 5654 | { |
d62a17ae | 5655 | int idx_peer = 2; |
5656 | struct peer *peer; | |
718e3744 | 5657 | |
d62a17ae | 5658 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5659 | if (!peer) | |
5660 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5661 | |
d62a17ae | 5662 | peer_description_unset(peer); |
718e3744 | 5663 | |
d62a17ae | 5664 | return CMD_SUCCESS; |
718e3744 | 5665 | } |
5666 | ||
a14810f4 PM |
5667 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
5668 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
5669 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5670 | "Neighbor specific description\n" | |
5671 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 5672 | |
718e3744 | 5673 | /* Neighbor update-source. */ |
d62a17ae | 5674 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
5675 | const char *source_str) | |
5676 | { | |
5677 | struct peer *peer; | |
5678 | struct prefix p; | |
a14810f4 | 5679 | union sockunion su; |
d62a17ae | 5680 | |
5681 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5682 | if (!peer) | |
5683 | return CMD_WARNING_CONFIG_FAILED; | |
5684 | ||
5685 | if (peer->conf_if) | |
5686 | return CMD_WARNING; | |
5687 | ||
5688 | if (source_str) { | |
a14810f4 | 5689 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 5690 | peer_update_source_addr_set(peer, &su); |
5691 | else { | |
5692 | if (str2prefix(source_str, &p)) { | |
5693 | vty_out(vty, | |
5694 | "%% Invalid update-source, remove prefix length \n"); | |
5695 | return CMD_WARNING_CONFIG_FAILED; | |
5696 | } else | |
5697 | peer_update_source_if_set(peer, source_str); | |
5698 | } | |
5699 | } else | |
5700 | peer_update_source_unset(peer); | |
5701 | ||
5702 | return CMD_SUCCESS; | |
5703 | } | |
5704 | ||
5705 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
5706 | "IPv4 address\n" \ | |
5707 | "IPv6 address\n" \ | |
5708 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 5709 | |
718e3744 | 5710 | DEFUN (neighbor_update_source, |
5711 | neighbor_update_source_cmd, | |
9ccf14f7 | 5712 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 5713 | NEIGHBOR_STR |
5714 | NEIGHBOR_ADDR_STR2 | |
5715 | "Source of routing updates\n" | |
369688c0 | 5716 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 5717 | { |
d62a17ae | 5718 | int idx_peer = 1; |
5719 | int idx_peer_2 = 3; | |
5720 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
5721 | argv[idx_peer_2]->arg); | |
718e3744 | 5722 | } |
5723 | ||
5724 | DEFUN (no_neighbor_update_source, | |
5725 | no_neighbor_update_source_cmd, | |
c7178fe7 | 5726 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 5727 | NO_STR |
5728 | NEIGHBOR_STR | |
5729 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5730 | "Source of routing updates\n" |
5731 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5732 | { |
d62a17ae | 5733 | int idx_peer = 2; |
5734 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5735 | } |
6b0655a2 | 5736 | |
d62a17ae | 5737 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5738 | afi_t afi, safi_t safi, | |
5739 | const char *rmap, int set) | |
718e3744 | 5740 | { |
d62a17ae | 5741 | int ret; |
5742 | struct peer *peer; | |
80912664 | 5743 | struct route_map *route_map = NULL; |
718e3744 | 5744 | |
d62a17ae | 5745 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5746 | if (!peer) | |
5747 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5748 | |
1de27621 | 5749 | if (set) { |
80912664 DS |
5750 | if (rmap) |
5751 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5752 | ret = peer_default_originate_set(peer, afi, safi, |
5753 | rmap, route_map); | |
5754 | } else | |
d62a17ae | 5755 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5756 | |
d62a17ae | 5757 | return bgp_vty_return(vty, ret); |
718e3744 | 5758 | } |
5759 | ||
5760 | /* neighbor default-originate. */ | |
5761 | DEFUN (neighbor_default_originate, | |
5762 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5763 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5764 | NEIGHBOR_STR |
5765 | NEIGHBOR_ADDR_STR2 | |
5766 | "Originate default route to this neighbor\n") | |
5767 | { | |
d62a17ae | 5768 | int idx_peer = 1; |
5769 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5770 | bgp_node_afi(vty), | |
5771 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5772 | } |
5773 | ||
d62a17ae | 5774 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5775 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5776 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5777 | "Originate default route to this neighbor\n") | |
596c17ba | 5778 | |
718e3744 | 5779 | DEFUN (neighbor_default_originate_rmap, |
5780 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5781 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5782 | NEIGHBOR_STR |
5783 | NEIGHBOR_ADDR_STR2 | |
5784 | "Originate default route to this neighbor\n" | |
5785 | "Route-map to specify criteria to originate default\n" | |
5786 | "route-map name\n") | |
5787 | { | |
d62a17ae | 5788 | int idx_peer = 1; |
5789 | int idx_word = 4; | |
5790 | return peer_default_originate_set_vty( | |
5791 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5792 | argv[idx_word]->arg, 1); | |
718e3744 | 5793 | } |
5794 | ||
d62a17ae | 5795 | ALIAS_HIDDEN( |
5796 | neighbor_default_originate_rmap, | |
5797 | neighbor_default_originate_rmap_hidden_cmd, | |
5798 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5799 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5800 | "Originate default route to this neighbor\n" | |
5801 | "Route-map to specify criteria to originate default\n" | |
5802 | "route-map name\n") | |
596c17ba | 5803 | |
718e3744 | 5804 | DEFUN (no_neighbor_default_originate, |
5805 | no_neighbor_default_originate_cmd, | |
a636c635 | 5806 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5807 | NO_STR |
5808 | NEIGHBOR_STR | |
5809 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5810 | "Originate default route to this neighbor\n" |
5811 | "Route-map to specify criteria to originate default\n" | |
5812 | "route-map name\n") | |
718e3744 | 5813 | { |
d62a17ae | 5814 | int idx_peer = 2; |
5815 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5816 | bgp_node_afi(vty), | |
5817 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5818 | } |
5819 | ||
d62a17ae | 5820 | ALIAS_HIDDEN( |
5821 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5822 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5823 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5824 | "Originate default route to this neighbor\n" | |
5825 | "Route-map to specify criteria to originate default\n" | |
5826 | "route-map name\n") | |
596c17ba | 5827 | |
6b0655a2 | 5828 | |
718e3744 | 5829 | /* Set neighbor's BGP port. */ |
d62a17ae | 5830 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5831 | const char *port_str) | |
5832 | { | |
5833 | struct peer *peer; | |
d7c0a89a | 5834 | uint16_t port; |
d62a17ae | 5835 | struct servent *sp; |
5836 | ||
5837 | peer = peer_lookup_vty(vty, ip_str); | |
5838 | if (!peer) | |
5839 | return CMD_WARNING_CONFIG_FAILED; | |
5840 | ||
5841 | if (!port_str) { | |
5842 | sp = getservbyname("bgp", "tcp"); | |
5843 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5844 | } else { | |
5845 | port = strtoul(port_str, NULL, 10); | |
5846 | } | |
718e3744 | 5847 | |
d62a17ae | 5848 | peer_port_set(peer, port); |
718e3744 | 5849 | |
d62a17ae | 5850 | return CMD_SUCCESS; |
718e3744 | 5851 | } |
5852 | ||
f418446b | 5853 | /* Set specified peer's BGP port. */ |
718e3744 | 5854 | DEFUN (neighbor_port, |
5855 | neighbor_port_cmd, | |
9ccf14f7 | 5856 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5857 | NEIGHBOR_STR |
5858 | NEIGHBOR_ADDR_STR | |
5859 | "Neighbor's BGP port\n" | |
5860 | "TCP port number\n") | |
5861 | { | |
d62a17ae | 5862 | int idx_ip = 1; |
5863 | int idx_number = 3; | |
5864 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5865 | argv[idx_number]->arg); | |
718e3744 | 5866 | } |
5867 | ||
5868 | DEFUN (no_neighbor_port, | |
5869 | no_neighbor_port_cmd, | |
9ccf14f7 | 5870 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5871 | NO_STR |
5872 | NEIGHBOR_STR | |
5873 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5874 | "Neighbor's BGP port\n" |
5875 | "TCP port number\n") | |
718e3744 | 5876 | { |
d62a17ae | 5877 | int idx_ip = 2; |
5878 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5879 | } |
5880 | ||
6b0655a2 | 5881 | |
718e3744 | 5882 | /* neighbor weight. */ |
d62a17ae | 5883 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5884 | safi_t safi, const char *weight_str) | |
718e3744 | 5885 | { |
d62a17ae | 5886 | int ret; |
5887 | struct peer *peer; | |
5888 | unsigned long weight; | |
718e3744 | 5889 | |
d62a17ae | 5890 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5891 | if (!peer) | |
5892 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5893 | |
d62a17ae | 5894 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5895 | |
d62a17ae | 5896 | ret = peer_weight_set(peer, afi, safi, weight); |
5897 | return bgp_vty_return(vty, ret); | |
718e3744 | 5898 | } |
5899 | ||
d62a17ae | 5900 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5901 | safi_t safi) | |
718e3744 | 5902 | { |
d62a17ae | 5903 | int ret; |
5904 | struct peer *peer; | |
718e3744 | 5905 | |
d62a17ae | 5906 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5907 | if (!peer) | |
5908 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5909 | |
d62a17ae | 5910 | ret = peer_weight_unset(peer, afi, safi); |
5911 | return bgp_vty_return(vty, ret); | |
718e3744 | 5912 | } |
5913 | ||
5914 | DEFUN (neighbor_weight, | |
5915 | neighbor_weight_cmd, | |
9ccf14f7 | 5916 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5917 | NEIGHBOR_STR |
5918 | NEIGHBOR_ADDR_STR2 | |
5919 | "Set default weight for routes from this neighbor\n" | |
5920 | "default weight\n") | |
5921 | { | |
d62a17ae | 5922 | int idx_peer = 1; |
5923 | int idx_number = 3; | |
5924 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5925 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5926 | } |
5927 | ||
d62a17ae | 5928 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5929 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5930 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5931 | "Set default weight for routes from this neighbor\n" | |
5932 | "default weight\n") | |
596c17ba | 5933 | |
718e3744 | 5934 | DEFUN (no_neighbor_weight, |
5935 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5936 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5937 | NO_STR |
5938 | NEIGHBOR_STR | |
5939 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5940 | "Set default weight for routes from this neighbor\n" |
5941 | "default weight\n") | |
718e3744 | 5942 | { |
d62a17ae | 5943 | int idx_peer = 2; |
5944 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5945 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5946 | } |
5947 | ||
d62a17ae | 5948 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5949 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5950 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5951 | "Set default weight for routes from this neighbor\n" | |
5952 | "default weight\n") | |
596c17ba | 5953 | |
6b0655a2 | 5954 | |
718e3744 | 5955 | /* Override capability negotiation. */ |
5956 | DEFUN (neighbor_override_capability, | |
5957 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5958 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5959 | NEIGHBOR_STR |
5960 | NEIGHBOR_ADDR_STR2 | |
5961 | "Override capability negotiation result\n") | |
5962 | { | |
d62a17ae | 5963 | int idx_peer = 1; |
5964 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5965 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5966 | } |
5967 | ||
5968 | DEFUN (no_neighbor_override_capability, | |
5969 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5970 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5971 | NO_STR |
5972 | NEIGHBOR_STR | |
5973 | NEIGHBOR_ADDR_STR2 | |
5974 | "Override capability negotiation result\n") | |
5975 | { | |
d62a17ae | 5976 | int idx_peer = 2; |
5977 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5978 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5979 | } |
6b0655a2 | 5980 | |
718e3744 | 5981 | DEFUN (neighbor_strict_capability, |
5982 | neighbor_strict_capability_cmd, | |
9fb964de | 5983 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5984 | NEIGHBOR_STR |
9fb964de | 5985 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5986 | "Strict capability negotiation match\n") |
5987 | { | |
9fb964de PM |
5988 | int idx_peer = 1; |
5989 | ||
5990 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5991 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5992 | } |
5993 | ||
5994 | DEFUN (no_neighbor_strict_capability, | |
5995 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5996 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5997 | NO_STR |
5998 | NEIGHBOR_STR | |
9fb964de | 5999 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6000 | "Strict capability negotiation match\n") |
6001 | { | |
9fb964de PM |
6002 | int idx_peer = 2; |
6003 | ||
6004 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 6005 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 6006 | } |
6b0655a2 | 6007 | |
d62a17ae | 6008 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
6009 | const char *keep_str, const char *hold_str) | |
718e3744 | 6010 | { |
d62a17ae | 6011 | int ret; |
6012 | struct peer *peer; | |
d7c0a89a QY |
6013 | uint32_t keepalive; |
6014 | uint32_t holdtime; | |
718e3744 | 6015 | |
d62a17ae | 6016 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6017 | if (!peer) | |
6018 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6019 | |
d62a17ae | 6020 | keepalive = strtoul(keep_str, NULL, 10); |
6021 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 6022 | |
d62a17ae | 6023 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 6024 | |
d62a17ae | 6025 | return bgp_vty_return(vty, ret); |
718e3744 | 6026 | } |
6b0655a2 | 6027 | |
d62a17ae | 6028 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6029 | { |
d62a17ae | 6030 | int ret; |
6031 | struct peer *peer; | |
718e3744 | 6032 | |
d62a17ae | 6033 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6034 | if (!peer) | |
6035 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6036 | |
d62a17ae | 6037 | ret = peer_timers_unset(peer); |
718e3744 | 6038 | |
d62a17ae | 6039 | return bgp_vty_return(vty, ret); |
718e3744 | 6040 | } |
6041 | ||
6042 | DEFUN (neighbor_timers, | |
6043 | neighbor_timers_cmd, | |
9ccf14f7 | 6044 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 6045 | NEIGHBOR_STR |
6046 | NEIGHBOR_ADDR_STR2 | |
6047 | "BGP per neighbor timers\n" | |
6048 | "Keepalive interval\n" | |
6049 | "Holdtime\n") | |
6050 | { | |
d62a17ae | 6051 | int idx_peer = 1; |
6052 | int idx_number = 3; | |
6053 | int idx_number_2 = 4; | |
6054 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6055 | argv[idx_number]->arg, | |
6056 | argv[idx_number_2]->arg); | |
718e3744 | 6057 | } |
6058 | ||
6059 | DEFUN (no_neighbor_timers, | |
6060 | no_neighbor_timers_cmd, | |
9ccf14f7 | 6061 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 6062 | NO_STR |
6063 | NEIGHBOR_STR | |
6064 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
6065 | "BGP per neighbor timers\n" |
6066 | "Keepalive interval\n" | |
6067 | "Holdtime\n") | |
718e3744 | 6068 | { |
d62a17ae | 6069 | int idx_peer = 2; |
6070 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6071 | } |
6b0655a2 | 6072 | |
813d4307 | 6073 | |
d62a17ae | 6074 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
6075 | const char *time_str) | |
718e3744 | 6076 | { |
d62a17ae | 6077 | int ret; |
6078 | struct peer *peer; | |
d7c0a89a | 6079 | uint32_t connect; |
718e3744 | 6080 | |
d62a17ae | 6081 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6082 | if (!peer) | |
6083 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6084 | |
d62a17ae | 6085 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 6086 | |
d62a17ae | 6087 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 6088 | |
d62a17ae | 6089 | return bgp_vty_return(vty, ret); |
718e3744 | 6090 | } |
6091 | ||
d62a17ae | 6092 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6093 | { |
d62a17ae | 6094 | int ret; |
6095 | struct peer *peer; | |
718e3744 | 6096 | |
d62a17ae | 6097 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6098 | if (!peer) | |
6099 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6100 | |
d62a17ae | 6101 | ret = peer_timers_connect_unset(peer); |
718e3744 | 6102 | |
d62a17ae | 6103 | return bgp_vty_return(vty, ret); |
718e3744 | 6104 | } |
6105 | ||
6106 | DEFUN (neighbor_timers_connect, | |
6107 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 6108 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 6109 | NEIGHBOR_STR |
966f821c | 6110 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6111 | "BGP per neighbor timers\n" |
6112 | "BGP connect timer\n" | |
6113 | "Connect timer\n") | |
6114 | { | |
d62a17ae | 6115 | int idx_peer = 1; |
6116 | int idx_number = 4; | |
6117 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6118 | argv[idx_number]->arg); | |
718e3744 | 6119 | } |
6120 | ||
6121 | DEFUN (no_neighbor_timers_connect, | |
6122 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 6123 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 6124 | NO_STR |
6125 | NEIGHBOR_STR | |
966f821c | 6126 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6127 | "BGP per neighbor timers\n" |
8334fd5a DW |
6128 | "BGP connect timer\n" |
6129 | "Connect timer\n") | |
718e3744 | 6130 | { |
d62a17ae | 6131 | int idx_peer = 2; |
6132 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6133 | } |
6134 | ||
6b0655a2 | 6135 | |
d62a17ae | 6136 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
6137 | const char *time_str, int set) | |
718e3744 | 6138 | { |
d62a17ae | 6139 | int ret; |
6140 | struct peer *peer; | |
d7c0a89a | 6141 | uint32_t routeadv = 0; |
718e3744 | 6142 | |
d62a17ae | 6143 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6144 | if (!peer) | |
6145 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6146 | |
d62a17ae | 6147 | if (time_str) |
6148 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 6149 | |
d62a17ae | 6150 | if (set) |
6151 | ret = peer_advertise_interval_set(peer, routeadv); | |
6152 | else | |
6153 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 6154 | |
d62a17ae | 6155 | return bgp_vty_return(vty, ret); |
718e3744 | 6156 | } |
6157 | ||
6158 | DEFUN (neighbor_advertise_interval, | |
6159 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6160 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 6161 | NEIGHBOR_STR |
966f821c | 6162 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6163 | "Minimum interval between sending BGP routing updates\n" |
6164 | "time in seconds\n") | |
6165 | { | |
d62a17ae | 6166 | int idx_peer = 1; |
6167 | int idx_number = 3; | |
6168 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6169 | argv[idx_number]->arg, 1); | |
718e3744 | 6170 | } |
6171 | ||
6172 | DEFUN (no_neighbor_advertise_interval, | |
6173 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6174 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 6175 | NO_STR |
6176 | NEIGHBOR_STR | |
966f821c | 6177 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
6178 | "Minimum interval between sending BGP routing updates\n" |
6179 | "time in seconds\n") | |
718e3744 | 6180 | { |
d62a17ae | 6181 | int idx_peer = 2; |
6182 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6183 | } |
6184 | ||
6b0655a2 | 6185 | |
518f0eb1 DS |
6186 | /* Time to wait before processing route-map updates */ |
6187 | DEFUN (bgp_set_route_map_delay_timer, | |
6188 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6189 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6190 | SET_STR |
6191 | "BGP route-map delay timer\n" | |
6192 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6193 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6194 | { |
d62a17ae | 6195 | int idx_number = 3; |
d7c0a89a | 6196 | uint32_t rmap_delay_timer; |
d62a17ae | 6197 | |
6198 | if (argv[idx_number]->arg) { | |
6199 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6200 | bm->rmap_update_timer = rmap_delay_timer; | |
6201 | ||
6202 | /* if the dynamic update handling is being disabled, and a timer | |
6203 | * is | |
6204 | * running, stop the timer and act as if the timer has already | |
6205 | * fired. | |
6206 | */ | |
6207 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6208 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6209 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6210 | NULL, 0); | |
6211 | } | |
6212 | return CMD_SUCCESS; | |
6213 | } else { | |
6214 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6215 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6216 | } |
518f0eb1 DS |
6217 | } |
6218 | ||
6219 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6220 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6221 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6222 | NO_STR |
3a2d747c | 6223 | BGP_STR |
518f0eb1 | 6224 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6225 | "Reset to default time to wait for processing route-map changes\n" |
6226 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6227 | { |
518f0eb1 | 6228 | |
d62a17ae | 6229 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6230 | |
d62a17ae | 6231 | return CMD_SUCCESS; |
518f0eb1 DS |
6232 | } |
6233 | ||
f414725f | 6234 | |
718e3744 | 6235 | /* neighbor interface */ |
d62a17ae | 6236 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
6237 | const char *str) | |
718e3744 | 6238 | { |
d62a17ae | 6239 | struct peer *peer; |
718e3744 | 6240 | |
d62a17ae | 6241 | peer = peer_lookup_vty(vty, ip_str); |
6242 | if (!peer || peer->conf_if) { | |
6243 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6244 | return CMD_WARNING_CONFIG_FAILED; | |
6245 | } | |
718e3744 | 6246 | |
d62a17ae | 6247 | if (str) |
6248 | peer_interface_set(peer, str); | |
6249 | else | |
6250 | peer_interface_unset(peer); | |
718e3744 | 6251 | |
d62a17ae | 6252 | return CMD_SUCCESS; |
718e3744 | 6253 | } |
6254 | ||
6255 | DEFUN (neighbor_interface, | |
6256 | neighbor_interface_cmd, | |
9ccf14f7 | 6257 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6258 | NEIGHBOR_STR |
6259 | NEIGHBOR_ADDR_STR | |
6260 | "Interface\n" | |
6261 | "Interface name\n") | |
6262 | { | |
d62a17ae | 6263 | int idx_ip = 1; |
6264 | int idx_word = 3; | |
6265 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6266 | } |
6267 | ||
6268 | DEFUN (no_neighbor_interface, | |
6269 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6270 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6271 | NO_STR |
6272 | NEIGHBOR_STR | |
16cedbb0 | 6273 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6274 | "Interface\n" |
6275 | "Interface name\n") | |
6276 | { | |
d62a17ae | 6277 | int idx_peer = 2; |
6278 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6279 | } |
6b0655a2 | 6280 | |
718e3744 | 6281 | DEFUN (neighbor_distribute_list, |
6282 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6283 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6284 | NEIGHBOR_STR |
6285 | NEIGHBOR_ADDR_STR2 | |
6286 | "Filter updates to/from this neighbor\n" | |
6287 | "IP access-list number\n" | |
6288 | "IP access-list number (expanded range)\n" | |
6289 | "IP Access-list name\n" | |
6290 | "Filter incoming updates\n" | |
6291 | "Filter outgoing updates\n") | |
6292 | { | |
d62a17ae | 6293 | int idx_peer = 1; |
6294 | int idx_acl = 3; | |
6295 | int direct, ret; | |
6296 | struct peer *peer; | |
a8206004 | 6297 | |
d62a17ae | 6298 | const char *pstr = argv[idx_peer]->arg; |
6299 | const char *acl = argv[idx_acl]->arg; | |
6300 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6301 | |
d62a17ae | 6302 | peer = peer_and_group_lookup_vty(vty, pstr); |
6303 | if (!peer) | |
6304 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6305 | |
d62a17ae | 6306 | /* Check filter direction. */ |
6307 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6308 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6309 | direct, acl); | |
a8206004 | 6310 | |
d62a17ae | 6311 | return bgp_vty_return(vty, ret); |
718e3744 | 6312 | } |
6313 | ||
d62a17ae | 6314 | ALIAS_HIDDEN( |
6315 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6316 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6317 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6318 | "Filter updates to/from this neighbor\n" | |
6319 | "IP access-list number\n" | |
6320 | "IP access-list number (expanded range)\n" | |
6321 | "IP Access-list name\n" | |
6322 | "Filter incoming updates\n" | |
6323 | "Filter outgoing updates\n") | |
596c17ba | 6324 | |
718e3744 | 6325 | DEFUN (no_neighbor_distribute_list, |
6326 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6327 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6328 | NO_STR |
6329 | NEIGHBOR_STR | |
6330 | NEIGHBOR_ADDR_STR2 | |
6331 | "Filter updates to/from this neighbor\n" | |
6332 | "IP access-list number\n" | |
6333 | "IP access-list number (expanded range)\n" | |
6334 | "IP Access-list name\n" | |
6335 | "Filter incoming updates\n" | |
6336 | "Filter outgoing updates\n") | |
6337 | { | |
d62a17ae | 6338 | int idx_peer = 2; |
6339 | int direct, ret; | |
6340 | struct peer *peer; | |
a8206004 | 6341 | |
d62a17ae | 6342 | const char *pstr = argv[idx_peer]->arg; |
6343 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6344 | |
d62a17ae | 6345 | peer = peer_and_group_lookup_vty(vty, pstr); |
6346 | if (!peer) | |
6347 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6348 | |
d62a17ae | 6349 | /* Check filter direction. */ |
6350 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6351 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6352 | direct); | |
a8206004 | 6353 | |
d62a17ae | 6354 | return bgp_vty_return(vty, ret); |
718e3744 | 6355 | } |
6b0655a2 | 6356 | |
d62a17ae | 6357 | ALIAS_HIDDEN( |
6358 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6359 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6360 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6361 | "Filter updates to/from this neighbor\n" | |
6362 | "IP access-list number\n" | |
6363 | "IP access-list number (expanded range)\n" | |
6364 | "IP Access-list name\n" | |
6365 | "Filter incoming updates\n" | |
6366 | "Filter outgoing updates\n") | |
596c17ba | 6367 | |
718e3744 | 6368 | /* Set prefix list to the peer. */ |
d62a17ae | 6369 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6370 | afi_t afi, safi_t safi, | |
6371 | const char *name_str, | |
6372 | const char *direct_str) | |
718e3744 | 6373 | { |
d62a17ae | 6374 | int ret; |
d62a17ae | 6375 | int direct = FILTER_IN; |
cf9ac8bf | 6376 | struct peer *peer; |
718e3744 | 6377 | |
d62a17ae | 6378 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6379 | if (!peer) | |
6380 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6381 | |
d62a17ae | 6382 | /* Check filter direction. */ |
6383 | if (strncmp(direct_str, "i", 1) == 0) | |
6384 | direct = FILTER_IN; | |
6385 | else if (strncmp(direct_str, "o", 1) == 0) | |
6386 | direct = FILTER_OUT; | |
718e3744 | 6387 | |
d62a17ae | 6388 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6389 | |
d62a17ae | 6390 | return bgp_vty_return(vty, ret); |
718e3744 | 6391 | } |
6392 | ||
d62a17ae | 6393 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6394 | afi_t afi, safi_t safi, | |
6395 | const char *direct_str) | |
718e3744 | 6396 | { |
d62a17ae | 6397 | int ret; |
6398 | struct peer *peer; | |
6399 | int direct = FILTER_IN; | |
718e3744 | 6400 | |
d62a17ae | 6401 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6402 | if (!peer) | |
6403 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6404 | |
d62a17ae | 6405 | /* Check filter direction. */ |
6406 | if (strncmp(direct_str, "i", 1) == 0) | |
6407 | direct = FILTER_IN; | |
6408 | else if (strncmp(direct_str, "o", 1) == 0) | |
6409 | direct = FILTER_OUT; | |
718e3744 | 6410 | |
d62a17ae | 6411 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6412 | |
d62a17ae | 6413 | return bgp_vty_return(vty, ret); |
718e3744 | 6414 | } |
6415 | ||
6416 | DEFUN (neighbor_prefix_list, | |
6417 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6418 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6419 | NEIGHBOR_STR |
6420 | NEIGHBOR_ADDR_STR2 | |
6421 | "Filter updates to/from this neighbor\n" | |
6422 | "Name of a prefix list\n" | |
6423 | "Filter incoming updates\n" | |
6424 | "Filter outgoing updates\n") | |
6425 | { | |
d62a17ae | 6426 | int idx_peer = 1; |
6427 | int idx_word = 3; | |
6428 | int idx_in_out = 4; | |
6429 | return peer_prefix_list_set_vty( | |
6430 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6431 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6432 | } |
6433 | ||
d62a17ae | 6434 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6435 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6436 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6437 | "Filter updates to/from this neighbor\n" | |
6438 | "Name of a prefix list\n" | |
6439 | "Filter incoming updates\n" | |
6440 | "Filter outgoing updates\n") | |
596c17ba | 6441 | |
718e3744 | 6442 | DEFUN (no_neighbor_prefix_list, |
6443 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6444 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6445 | NO_STR |
6446 | NEIGHBOR_STR | |
6447 | NEIGHBOR_ADDR_STR2 | |
6448 | "Filter updates to/from this neighbor\n" | |
6449 | "Name of a prefix list\n" | |
6450 | "Filter incoming updates\n" | |
6451 | "Filter outgoing updates\n") | |
6452 | { | |
d62a17ae | 6453 | int idx_peer = 2; |
6454 | int idx_in_out = 5; | |
6455 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6456 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6457 | argv[idx_in_out]->arg); | |
718e3744 | 6458 | } |
6b0655a2 | 6459 | |
d62a17ae | 6460 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6461 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6462 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6463 | "Filter updates to/from this neighbor\n" | |
6464 | "Name of a prefix list\n" | |
6465 | "Filter incoming updates\n" | |
6466 | "Filter outgoing updates\n") | |
596c17ba | 6467 | |
d62a17ae | 6468 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6469 | safi_t safi, const char *name_str, | |
6470 | const char *direct_str) | |
718e3744 | 6471 | { |
d62a17ae | 6472 | int ret; |
6473 | struct peer *peer; | |
6474 | int direct = FILTER_IN; | |
718e3744 | 6475 | |
d62a17ae | 6476 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6477 | if (!peer) | |
6478 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6479 | |
d62a17ae | 6480 | /* Check filter direction. */ |
6481 | if (strncmp(direct_str, "i", 1) == 0) | |
6482 | direct = FILTER_IN; | |
6483 | else if (strncmp(direct_str, "o", 1) == 0) | |
6484 | direct = FILTER_OUT; | |
718e3744 | 6485 | |
d62a17ae | 6486 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6487 | |
d62a17ae | 6488 | return bgp_vty_return(vty, ret); |
718e3744 | 6489 | } |
6490 | ||
d62a17ae | 6491 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6492 | safi_t safi, const char *direct_str) | |
718e3744 | 6493 | { |
d62a17ae | 6494 | int ret; |
6495 | struct peer *peer; | |
6496 | int direct = FILTER_IN; | |
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 | /* Check filter direction. */ |
6503 | if (strncmp(direct_str, "i", 1) == 0) | |
6504 | direct = FILTER_IN; | |
6505 | else if (strncmp(direct_str, "o", 1) == 0) | |
6506 | direct = FILTER_OUT; | |
718e3744 | 6507 | |
d62a17ae | 6508 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6509 | |
d62a17ae | 6510 | return bgp_vty_return(vty, ret); |
718e3744 | 6511 | } |
6512 | ||
6513 | DEFUN (neighbor_filter_list, | |
6514 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6515 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6516 | NEIGHBOR_STR |
6517 | NEIGHBOR_ADDR_STR2 | |
6518 | "Establish BGP filters\n" | |
6519 | "AS path access-list name\n" | |
6520 | "Filter incoming routes\n" | |
6521 | "Filter outgoing routes\n") | |
6522 | { | |
d62a17ae | 6523 | int idx_peer = 1; |
6524 | int idx_word = 3; | |
6525 | int idx_in_out = 4; | |
6526 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6527 | bgp_node_safi(vty), argv[idx_word]->arg, | |
6528 | argv[idx_in_out]->arg); | |
718e3744 | 6529 | } |
6530 | ||
d62a17ae | 6531 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
6532 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6533 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6534 | "Establish BGP filters\n" | |
6535 | "AS path access-list name\n" | |
6536 | "Filter incoming routes\n" | |
6537 | "Filter outgoing routes\n") | |
596c17ba | 6538 | |
718e3744 | 6539 | DEFUN (no_neighbor_filter_list, |
6540 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 6541 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6542 | NO_STR |
6543 | NEIGHBOR_STR | |
6544 | NEIGHBOR_ADDR_STR2 | |
6545 | "Establish BGP filters\n" | |
6546 | "AS path access-list name\n" | |
6547 | "Filter incoming routes\n" | |
6548 | "Filter outgoing routes\n") | |
6549 | { | |
d62a17ae | 6550 | int idx_peer = 2; |
6551 | int idx_in_out = 5; | |
6552 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
6553 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6554 | argv[idx_in_out]->arg); | |
718e3744 | 6555 | } |
6b0655a2 | 6556 | |
d62a17ae | 6557 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
6558 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6559 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6560 | "Establish BGP filters\n" | |
6561 | "AS path access-list name\n" | |
6562 | "Filter incoming routes\n" | |
6563 | "Filter outgoing routes\n") | |
596c17ba | 6564 | |
718e3744 | 6565 | /* Set route-map to the peer. */ |
d62a17ae | 6566 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
6567 | afi_t afi, safi_t safi, const char *name_str, | |
6568 | const char *direct_str) | |
718e3744 | 6569 | { |
d62a17ae | 6570 | int ret; |
6571 | struct peer *peer; | |
6572 | int direct = RMAP_IN; | |
1de27621 | 6573 | struct route_map *route_map; |
718e3744 | 6574 | |
d62a17ae | 6575 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6576 | if (!peer) | |
6577 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6578 | |
d62a17ae | 6579 | /* Check filter direction. */ |
6580 | if (strncmp(direct_str, "in", 2) == 0) | |
6581 | direct = RMAP_IN; | |
6582 | else if (strncmp(direct_str, "o", 1) == 0) | |
6583 | direct = RMAP_OUT; | |
718e3744 | 6584 | |
1de27621 DA |
6585 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6586 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 6587 | |
d62a17ae | 6588 | return bgp_vty_return(vty, ret); |
718e3744 | 6589 | } |
6590 | ||
d62a17ae | 6591 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
6592 | afi_t afi, safi_t safi, | |
6593 | const char *direct_str) | |
718e3744 | 6594 | { |
d62a17ae | 6595 | int ret; |
6596 | struct peer *peer; | |
6597 | int direct = RMAP_IN; | |
718e3744 | 6598 | |
d62a17ae | 6599 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6600 | if (!peer) | |
6601 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6602 | |
d62a17ae | 6603 | /* Check filter direction. */ |
6604 | if (strncmp(direct_str, "in", 2) == 0) | |
6605 | direct = RMAP_IN; | |
6606 | else if (strncmp(direct_str, "o", 1) == 0) | |
6607 | direct = RMAP_OUT; | |
718e3744 | 6608 | |
d62a17ae | 6609 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 6610 | |
d62a17ae | 6611 | return bgp_vty_return(vty, ret); |
718e3744 | 6612 | } |
6613 | ||
6614 | DEFUN (neighbor_route_map, | |
6615 | neighbor_route_map_cmd, | |
9ccf14f7 | 6616 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6617 | NEIGHBOR_STR |
6618 | NEIGHBOR_ADDR_STR2 | |
6619 | "Apply route map to neighbor\n" | |
6620 | "Name of route map\n" | |
6621 | "Apply map to incoming routes\n" | |
2a3d5731 | 6622 | "Apply map to outbound routes\n") |
718e3744 | 6623 | { |
d62a17ae | 6624 | int idx_peer = 1; |
6625 | int idx_word = 3; | |
6626 | int idx_in_out = 4; | |
6627 | return peer_route_map_set_vty( | |
6628 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6629 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6630 | } |
6631 | ||
d62a17ae | 6632 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
6633 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6634 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6635 | "Apply route map to neighbor\n" | |
6636 | "Name of route map\n" | |
6637 | "Apply map to incoming routes\n" | |
6638 | "Apply map to outbound routes\n") | |
596c17ba | 6639 | |
718e3744 | 6640 | DEFUN (no_neighbor_route_map, |
6641 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 6642 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6643 | NO_STR |
6644 | NEIGHBOR_STR | |
6645 | NEIGHBOR_ADDR_STR2 | |
6646 | "Apply route map to neighbor\n" | |
6647 | "Name of route map\n" | |
6648 | "Apply map to incoming routes\n" | |
2a3d5731 | 6649 | "Apply map to outbound routes\n") |
718e3744 | 6650 | { |
d62a17ae | 6651 | int idx_peer = 2; |
6652 | int idx_in_out = 5; | |
6653 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
6654 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6655 | argv[idx_in_out]->arg); | |
718e3744 | 6656 | } |
6b0655a2 | 6657 | |
d62a17ae | 6658 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
6659 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6660 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6661 | "Apply route map to neighbor\n" | |
6662 | "Name of route map\n" | |
6663 | "Apply map to incoming routes\n" | |
6664 | "Apply map to outbound routes\n") | |
596c17ba | 6665 | |
718e3744 | 6666 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 6667 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
6668 | afi_t afi, safi_t safi, | |
6669 | const char *name_str) | |
718e3744 | 6670 | { |
d62a17ae | 6671 | int ret; |
6672 | struct peer *peer; | |
1de27621 | 6673 | struct route_map *route_map; |
718e3744 | 6674 | |
d62a17ae | 6675 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6676 | if (!peer) | |
6677 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6678 | |
1de27621 DA |
6679 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6680 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 6681 | |
d62a17ae | 6682 | return bgp_vty_return(vty, ret); |
718e3744 | 6683 | } |
6684 | ||
6685 | /* Unset route-map from the peer. */ | |
d62a17ae | 6686 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
6687 | afi_t afi, safi_t safi) | |
718e3744 | 6688 | { |
d62a17ae | 6689 | int ret; |
6690 | struct peer *peer; | |
718e3744 | 6691 | |
d62a17ae | 6692 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6693 | if (!peer) | |
6694 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6695 | |
d62a17ae | 6696 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 6697 | |
d62a17ae | 6698 | return bgp_vty_return(vty, ret); |
718e3744 | 6699 | } |
6700 | ||
6701 | DEFUN (neighbor_unsuppress_map, | |
6702 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6703 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6704 | NEIGHBOR_STR |
6705 | NEIGHBOR_ADDR_STR2 | |
6706 | "Route-map to selectively unsuppress suppressed routes\n" | |
6707 | "Name of route map\n") | |
6708 | { | |
d62a17ae | 6709 | int idx_peer = 1; |
6710 | int idx_word = 3; | |
6711 | return peer_unsuppress_map_set_vty( | |
6712 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6713 | argv[idx_word]->arg); | |
718e3744 | 6714 | } |
6715 | ||
d62a17ae | 6716 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
6717 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6718 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6719 | "Route-map to selectively unsuppress suppressed routes\n" | |
6720 | "Name of route map\n") | |
596c17ba | 6721 | |
718e3744 | 6722 | DEFUN (no_neighbor_unsuppress_map, |
6723 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6724 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6725 | NO_STR |
6726 | NEIGHBOR_STR | |
6727 | NEIGHBOR_ADDR_STR2 | |
6728 | "Route-map to selectively unsuppress suppressed routes\n" | |
6729 | "Name of route map\n") | |
6730 | { | |
d62a17ae | 6731 | int idx_peer = 2; |
6732 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6733 | bgp_node_afi(vty), | |
6734 | bgp_node_safi(vty)); | |
718e3744 | 6735 | } |
6b0655a2 | 6736 | |
d62a17ae | 6737 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6738 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6739 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6740 | "Route-map to selectively unsuppress suppressed routes\n" | |
6741 | "Name of route map\n") | |
596c17ba | 6742 | |
d62a17ae | 6743 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6744 | afi_t afi, safi_t safi, | |
6745 | const char *num_str, | |
6746 | const char *threshold_str, int warning, | |
9cbd06e0 DA |
6747 | const char *restart_str, |
6748 | const char *force_str) | |
718e3744 | 6749 | { |
d62a17ae | 6750 | int ret; |
6751 | struct peer *peer; | |
d7c0a89a QY |
6752 | uint32_t max; |
6753 | uint8_t threshold; | |
6754 | uint16_t restart; | |
718e3744 | 6755 | |
d62a17ae | 6756 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6757 | if (!peer) | |
6758 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6759 | |
d62a17ae | 6760 | max = strtoul(num_str, NULL, 10); |
6761 | if (threshold_str) | |
6762 | threshold = atoi(threshold_str); | |
6763 | else | |
6764 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6765 | |
d62a17ae | 6766 | if (restart_str) |
6767 | restart = atoi(restart_str); | |
6768 | else | |
6769 | restart = 0; | |
0a486e5f | 6770 | |
d62a17ae | 6771 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
9cbd06e0 | 6772 | restart, force_str ? true : false); |
718e3744 | 6773 | |
d62a17ae | 6774 | return bgp_vty_return(vty, ret); |
718e3744 | 6775 | } |
6776 | ||
d62a17ae | 6777 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6778 | afi_t afi, safi_t safi) | |
718e3744 | 6779 | { |
d62a17ae | 6780 | int ret; |
6781 | struct peer *peer; | |
718e3744 | 6782 | |
d62a17ae | 6783 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6784 | if (!peer) | |
6785 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6786 | |
d62a17ae | 6787 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6788 | |
d62a17ae | 6789 | return bgp_vty_return(vty, ret); |
718e3744 | 6790 | } |
6791 | ||
fde246e8 DA |
6792 | /* Maximum number of prefix to be sent to the neighbor. */ |
6793 | DEFUN(neighbor_maximum_prefix_out, | |
6794 | neighbor_maximum_prefix_out_cmd, | |
6795 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6796 | NEIGHBOR_STR | |
6797 | NEIGHBOR_ADDR_STR2 | |
6798 | "Maximum number of prefixes to be sent to this peer\n" | |
6799 | "Maximum no. of prefix limit\n") | |
6800 | { | |
6801 | int idx_peer = 1; | |
6802 | int idx_number = 3; | |
6803 | struct peer *peer; | |
6804 | uint32_t max; | |
6805 | afi_t afi = bgp_node_afi(vty); | |
6806 | safi_t safi = bgp_node_safi(vty); | |
6807 | ||
6808 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6809 | if (!peer) | |
6810 | return CMD_WARNING_CONFIG_FAILED; | |
6811 | ||
6812 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6813 | ||
6814 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6815 | peer->pmax_out[afi][safi] = max; | |
6816 | ||
6817 | return CMD_SUCCESS; | |
6818 | } | |
6819 | ||
6820 | DEFUN(no_neighbor_maximum_prefix_out, | |
6821 | no_neighbor_maximum_prefix_out_cmd, | |
6822 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6823 | NO_STR | |
6824 | NEIGHBOR_STR | |
6825 | NEIGHBOR_ADDR_STR2 | |
6826 | "Maximum number of prefixes to be sent to this peer\n") | |
6827 | { | |
6828 | int idx_peer = 2; | |
6829 | struct peer *peer; | |
6830 | afi_t afi = bgp_node_afi(vty); | |
6831 | safi_t safi = bgp_node_safi(vty); | |
6832 | ||
6833 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6834 | if (!peer) | |
6835 | return CMD_WARNING_CONFIG_FAILED; | |
6836 | ||
ae00326a | 6837 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
fde246e8 DA |
6838 | peer->pmax_out[afi][safi] = 0; |
6839 | ||
6840 | return CMD_SUCCESS; | |
6841 | } | |
6842 | ||
9cbd06e0 DA |
6843 | /* Maximum number of prefix configuration. Prefix count is different |
6844 | for each peer configuration. So this configuration can be set for | |
718e3744 | 6845 | each peer configuration. */ |
6846 | DEFUN (neighbor_maximum_prefix, | |
6847 | neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 6848 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
718e3744 | 6849 | NEIGHBOR_STR |
6850 | NEIGHBOR_ADDR_STR2 | |
6851 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
6852 | "maximum no. of prefix limit\n" |
6853 | "Force checking all received routes not only accepted\n") | |
718e3744 | 6854 | { |
d62a17ae | 6855 | int idx_peer = 1; |
6856 | int idx_number = 3; | |
9cbd06e0 DA |
6857 | int idx_force = 0; |
6858 | char *force = NULL; | |
6859 | ||
6860 | if (argv_find(argv, argc, "force", &idx_force)) | |
6861 | force = argv[idx_force]->arg; | |
6862 | ||
d62a17ae | 6863 | return peer_maximum_prefix_set_vty( |
6864 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 6865 | argv[idx_number]->arg, NULL, 0, NULL, force); |
718e3744 | 6866 | } |
6867 | ||
d62a17ae | 6868 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 6869 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 6870 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6871 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
6872 | "maximum no. of prefix limit\n" |
6873 | "Force checking all received routes not only accepted\n") | |
596c17ba | 6874 | |
e0701b79 | 6875 | DEFUN (neighbor_maximum_prefix_threshold, |
6876 | neighbor_maximum_prefix_threshold_cmd, | |
9cbd06e0 | 6877 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
e0701b79 | 6878 | NEIGHBOR_STR |
6879 | NEIGHBOR_ADDR_STR2 | |
6880 | "Maximum number of prefix accept from this peer\n" | |
6881 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
6882 | "Threshold value (%) at which to generate a warning msg\n" |
6883 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 6884 | { |
d62a17ae | 6885 | int idx_peer = 1; |
6886 | int idx_number = 3; | |
6887 | int idx_number_2 = 4; | |
9cbd06e0 DA |
6888 | int idx_force = 0; |
6889 | char *force = NULL; | |
6890 | ||
6891 | if (argv_find(argv, argc, "force", &idx_force)) | |
6892 | force = argv[idx_force]->arg; | |
6893 | ||
d62a17ae | 6894 | return peer_maximum_prefix_set_vty( |
6895 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 6896 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); |
0a486e5f | 6897 | } |
e0701b79 | 6898 | |
d62a17ae | 6899 | ALIAS_HIDDEN( |
6900 | neighbor_maximum_prefix_threshold, | |
6901 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 6902 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 6903 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6904 | "Maximum number of prefix accept from this peer\n" | |
6905 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
6906 | "Threshold value (%) at which to generate a warning msg\n" |
6907 | "Force checking all received routes not only accepted\n") | |
596c17ba | 6908 | |
718e3744 | 6909 | DEFUN (neighbor_maximum_prefix_warning, |
6910 | neighbor_maximum_prefix_warning_cmd, | |
9cbd06e0 | 6911 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
718e3744 | 6912 | NEIGHBOR_STR |
6913 | NEIGHBOR_ADDR_STR2 | |
6914 | "Maximum number of prefix accept from this peer\n" | |
6915 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
6916 | "Only give warning message when limit is exceeded\n" |
6917 | "Force checking all received routes not only accepted\n") | |
718e3744 | 6918 | { |
d62a17ae | 6919 | int idx_peer = 1; |
6920 | int idx_number = 3; | |
9cbd06e0 DA |
6921 | int idx_force = 0; |
6922 | char *force = NULL; | |
6923 | ||
6924 | if (argv_find(argv, argc, "force", &idx_force)) | |
6925 | force = argv[idx_force]->arg; | |
6926 | ||
d62a17ae | 6927 | return peer_maximum_prefix_set_vty( |
6928 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 6929 | argv[idx_number]->arg, NULL, 1, NULL, force); |
718e3744 | 6930 | } |
6931 | ||
d62a17ae | 6932 | ALIAS_HIDDEN( |
6933 | neighbor_maximum_prefix_warning, | |
6934 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 6935 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 6936 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6937 | "Maximum number of prefix accept from this peer\n" | |
6938 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
6939 | "Only give warning message when limit is exceeded\n" |
6940 | "Force checking all received routes not only accepted\n") | |
596c17ba | 6941 | |
e0701b79 | 6942 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6943 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9cbd06e0 | 6944 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
e0701b79 | 6945 | NEIGHBOR_STR |
6946 | NEIGHBOR_ADDR_STR2 | |
6947 | "Maximum number of prefix accept from this peer\n" | |
6948 | "maximum no. of prefix limit\n" | |
6949 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
6950 | "Only give warning message when limit is exceeded\n" |
6951 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 6952 | { |
d62a17ae | 6953 | int idx_peer = 1; |
6954 | int idx_number = 3; | |
6955 | int idx_number_2 = 4; | |
9cbd06e0 DA |
6956 | int idx_force = 0; |
6957 | char *force = NULL; | |
6958 | ||
6959 | if (argv_find(argv, argc, "force", &idx_force)) | |
6960 | force = argv[idx_force]->arg; | |
6961 | ||
d62a17ae | 6962 | return peer_maximum_prefix_set_vty( |
6963 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 6964 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); |
0a486e5f | 6965 | } |
6966 | ||
d62a17ae | 6967 | ALIAS_HIDDEN( |
6968 | neighbor_maximum_prefix_threshold_warning, | |
6969 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 6970 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 6971 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6972 | "Maximum number of prefix accept from this peer\n" | |
6973 | "maximum no. of prefix limit\n" | |
6974 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
6975 | "Only give warning message when limit is exceeded\n" |
6976 | "Force checking all received routes not only accepted\n") | |
596c17ba | 6977 | |
0a486e5f | 6978 | DEFUN (neighbor_maximum_prefix_restart, |
6979 | neighbor_maximum_prefix_restart_cmd, | |
9cbd06e0 | 6980 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
0a486e5f | 6981 | NEIGHBOR_STR |
6982 | NEIGHBOR_ADDR_STR2 | |
6983 | "Maximum number of prefix accept from this peer\n" | |
6984 | "maximum no. of prefix limit\n" | |
6985 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
6986 | "Restart interval in minutes\n" |
6987 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 6988 | { |
d62a17ae | 6989 | int idx_peer = 1; |
6990 | int idx_number = 3; | |
6991 | int idx_number_2 = 5; | |
9cbd06e0 DA |
6992 | int idx_force = 0; |
6993 | char *force = NULL; | |
6994 | ||
6995 | if (argv_find(argv, argc, "force", &idx_force)) | |
6996 | force = argv[idx_force]->arg; | |
6997 | ||
d62a17ae | 6998 | return peer_maximum_prefix_set_vty( |
6999 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7000 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); |
0a486e5f | 7001 | } |
7002 | ||
d62a17ae | 7003 | ALIAS_HIDDEN( |
7004 | neighbor_maximum_prefix_restart, | |
7005 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 7006 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 7007 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7008 | "Maximum number of prefix accept from this peer\n" | |
7009 | "maximum no. of prefix limit\n" | |
7010 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7011 | "Restart interval in minutes\n" |
7012 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7013 | |
0a486e5f | 7014 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
7015 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9cbd06e0 | 7016 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
0a486e5f | 7017 | NEIGHBOR_STR |
7018 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 7019 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 7020 | "maximum no. of prefix limit\n" |
7021 | "Threshold value (%) at which to generate a warning msg\n" | |
7022 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7023 | "Restart interval in minutes\n" |
7024 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7025 | { |
d62a17ae | 7026 | int idx_peer = 1; |
7027 | int idx_number = 3; | |
7028 | int idx_number_2 = 4; | |
7029 | int idx_number_3 = 6; | |
9cbd06e0 DA |
7030 | int idx_force = 0; |
7031 | char *force = NULL; | |
7032 | ||
7033 | if (argv_find(argv, argc, "force", &idx_force)) | |
7034 | force = argv[idx_force]->arg; | |
7035 | ||
d62a17ae | 7036 | return peer_maximum_prefix_set_vty( |
7037 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7038 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
9cbd06e0 | 7039 | argv[idx_number_3]->arg, force); |
d62a17ae | 7040 | } |
7041 | ||
7042 | ALIAS_HIDDEN( | |
7043 | neighbor_maximum_prefix_threshold_restart, | |
7044 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 7045 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 7046 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7047 | "Maximum number of prefixes to accept from this peer\n" | |
7048 | "maximum no. of prefix limit\n" | |
7049 | "Threshold value (%) at which to generate a warning msg\n" | |
7050 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7051 | "Restart interval in minutes\n" |
7052 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7053 | |
718e3744 | 7054 | DEFUN (no_neighbor_maximum_prefix, |
7055 | no_neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 7056 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
718e3744 | 7057 | NO_STR |
7058 | NEIGHBOR_STR | |
7059 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 7060 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
7061 | "maximum no. of prefix limit\n" |
7062 | "Threshold value (%) at which to generate a warning msg\n" | |
7063 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 7064 | "Restart interval in minutes\n" |
9cbd06e0 DA |
7065 | "Only give warning message when limit is exceeded\n" |
7066 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7067 | { |
d62a17ae | 7068 | int idx_peer = 2; |
7069 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
7070 | bgp_node_afi(vty), | |
7071 | bgp_node_safi(vty)); | |
718e3744 | 7072 | } |
e52702f2 | 7073 | |
d62a17ae | 7074 | ALIAS_HIDDEN( |
7075 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 7076 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 7077 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7078 | "Maximum number of prefixes to accept from this peer\n" | |
7079 | "maximum no. of prefix limit\n" | |
7080 | "Threshold value (%) at which to generate a warning msg\n" | |
7081 | "Restart bgp connection after limit is exceeded\n" | |
7082 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
7083 | "Only give warning message when limit is exceeded\n" |
7084 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7085 | |
718e3744 | 7086 | |
718e3744 | 7087 | /* "neighbor allowas-in" */ |
7088 | DEFUN (neighbor_allowas_in, | |
7089 | neighbor_allowas_in_cmd, | |
fd8503f5 | 7090 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7091 | NEIGHBOR_STR |
7092 | NEIGHBOR_ADDR_STR2 | |
31500417 | 7093 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 7094 | "Number of occurrences of AS number\n" |
fd8503f5 | 7095 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7096 | { |
d62a17ae | 7097 | int idx_peer = 1; |
7098 | int idx_number_origin = 3; | |
7099 | int ret; | |
7100 | int origin = 0; | |
7101 | struct peer *peer; | |
7102 | int allow_num = 0; | |
7103 | ||
7104 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7105 | if (!peer) | |
7106 | return CMD_WARNING_CONFIG_FAILED; | |
7107 | ||
7108 | if (argc <= idx_number_origin) | |
7109 | allow_num = 3; | |
7110 | else { | |
7111 | if (argv[idx_number_origin]->type == WORD_TKN) | |
7112 | origin = 1; | |
7113 | else | |
7114 | allow_num = atoi(argv[idx_number_origin]->arg); | |
7115 | } | |
7116 | ||
7117 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7118 | allow_num, origin); | |
7119 | ||
7120 | return bgp_vty_return(vty, ret); | |
7121 | } | |
7122 | ||
7123 | ALIAS_HIDDEN( | |
7124 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
7125 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7126 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7127 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 7128 | "Number of occurrences of AS number\n" |
d62a17ae | 7129 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7130 | |
718e3744 | 7131 | DEFUN (no_neighbor_allowas_in, |
7132 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 7133 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7134 | NO_STR |
7135 | NEIGHBOR_STR | |
7136 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 7137 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 7138 | "Number of occurrences of AS number\n" |
fd8503f5 | 7139 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7140 | { |
d62a17ae | 7141 | int idx_peer = 2; |
7142 | int ret; | |
7143 | struct peer *peer; | |
718e3744 | 7144 | |
d62a17ae | 7145 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7146 | if (!peer) | |
7147 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7148 | |
d62a17ae | 7149 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
7150 | bgp_node_safi(vty)); | |
718e3744 | 7151 | |
d62a17ae | 7152 | return bgp_vty_return(vty, ret); |
718e3744 | 7153 | } |
6b0655a2 | 7154 | |
d62a17ae | 7155 | ALIAS_HIDDEN( |
7156 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
7157 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7158 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7159 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 7160 | "Number of occurrences of AS number\n" |
d62a17ae | 7161 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7162 | |
fa411a21 NH |
7163 | DEFUN (neighbor_ttl_security, |
7164 | neighbor_ttl_security_cmd, | |
7ebe625c | 7165 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 7166 | NEIGHBOR_STR |
7ebe625c | 7167 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7168 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
7169 | "Specify the maximum number of hops to the BGP peer\n" |
7170 | "Number of hops to BGP peer\n") | |
fa411a21 | 7171 | { |
d62a17ae | 7172 | int idx_peer = 1; |
7173 | int idx_number = 4; | |
7174 | struct peer *peer; | |
7175 | int gtsm_hops; | |
7176 | ||
7177 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7178 | if (!peer) | |
7179 | return CMD_WARNING_CONFIG_FAILED; | |
7180 | ||
7181 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
7182 | ||
7ebe625c QY |
7183 | /* |
7184 | * If 'neighbor swpX', then this is for directly connected peers, | |
7185 | * we should not accept a ttl-security hops value greater than 1. | |
7186 | */ | |
e2521429 | 7187 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { |
7ebe625c QY |
7188 | vty_out(vty, |
7189 | "%s is directly connected peer, hops cannot exceed 1\n", | |
7190 | argv[idx_peer]->arg); | |
7191 | return CMD_WARNING_CONFIG_FAILED; | |
7192 | } | |
7193 | ||
d62a17ae | 7194 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
7195 | } |
7196 | ||
7197 | DEFUN (no_neighbor_ttl_security, | |
7198 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 7199 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
7200 | NO_STR |
7201 | NEIGHBOR_STR | |
7ebe625c | 7202 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7203 | "BGP ttl-security parameters\n" |
3a2d747c QY |
7204 | "Specify the maximum number of hops to the BGP peer\n" |
7205 | "Number of hops to BGP peer\n") | |
fa411a21 | 7206 | { |
d62a17ae | 7207 | int idx_peer = 2; |
7208 | struct peer *peer; | |
fa411a21 | 7209 | |
d62a17ae | 7210 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7211 | if (!peer) | |
7212 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 7213 | |
d62a17ae | 7214 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 7215 | } |
6b0655a2 | 7216 | |
adbac85e DW |
7217 | DEFUN (neighbor_addpath_tx_all_paths, |
7218 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7219 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7220 | NEIGHBOR_STR |
7221 | NEIGHBOR_ADDR_STR2 | |
7222 | "Use addpath to advertise all paths to a neighbor\n") | |
7223 | { | |
d62a17ae | 7224 | int idx_peer = 1; |
7225 | struct peer *peer; | |
adbac85e | 7226 | |
d62a17ae | 7227 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7228 | if (!peer) | |
7229 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 7230 | |
dcc68b5e MS |
7231 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7232 | BGP_ADDPATH_ALL); | |
7233 | return CMD_SUCCESS; | |
adbac85e DW |
7234 | } |
7235 | ||
d62a17ae | 7236 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
7237 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
7238 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7239 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7240 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7241 | |
adbac85e DW |
7242 | DEFUN (no_neighbor_addpath_tx_all_paths, |
7243 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7244 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7245 | NO_STR |
7246 | NEIGHBOR_STR | |
7247 | NEIGHBOR_ADDR_STR2 | |
7248 | "Use addpath to advertise all paths to a neighbor\n") | |
7249 | { | |
d62a17ae | 7250 | int idx_peer = 2; |
dcc68b5e MS |
7251 | struct peer *peer; |
7252 | ||
7253 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7254 | if (!peer) | |
7255 | return CMD_WARNING_CONFIG_FAILED; | |
7256 | ||
7257 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7258 | != BGP_ADDPATH_ALL) { | |
7259 | vty_out(vty, | |
7260 | "%% Peer not currently configured to transmit all paths."); | |
7261 | return CMD_WARNING_CONFIG_FAILED; | |
7262 | } | |
7263 | ||
7264 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7265 | BGP_ADDPATH_NONE); | |
7266 | ||
7267 | return CMD_SUCCESS; | |
adbac85e DW |
7268 | } |
7269 | ||
d62a17ae | 7270 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
7271 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
7272 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7273 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7274 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7275 | |
06370dac DW |
7276 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
7277 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7278 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7279 | NEIGHBOR_STR |
7280 | NEIGHBOR_ADDR_STR2 | |
7281 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7282 | { | |
d62a17ae | 7283 | int idx_peer = 1; |
7284 | struct peer *peer; | |
06370dac | 7285 | |
d62a17ae | 7286 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7287 | if (!peer) | |
7288 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 7289 | |
dcc68b5e MS |
7290 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7291 | BGP_ADDPATH_BEST_PER_AS); | |
7292 | ||
7293 | return CMD_SUCCESS; | |
06370dac DW |
7294 | } |
7295 | ||
d62a17ae | 7296 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7297 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7298 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7299 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7300 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7301 | |
06370dac DW |
7302 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7303 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7304 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7305 | NO_STR |
7306 | NEIGHBOR_STR | |
7307 | NEIGHBOR_ADDR_STR2 | |
7308 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7309 | { | |
d62a17ae | 7310 | int idx_peer = 2; |
dcc68b5e MS |
7311 | struct peer *peer; |
7312 | ||
7313 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7314 | if (!peer) | |
7315 | return CMD_WARNING_CONFIG_FAILED; | |
7316 | ||
7317 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7318 | != BGP_ADDPATH_BEST_PER_AS) { | |
7319 | vty_out(vty, | |
7320 | "%% Peer not currently configured to transmit all best path per as."); | |
7321 | return CMD_WARNING_CONFIG_FAILED; | |
7322 | } | |
7323 | ||
7324 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7325 | BGP_ADDPATH_NONE); | |
7326 | ||
7327 | return CMD_SUCCESS; | |
06370dac DW |
7328 | } |
7329 | ||
d62a17ae | 7330 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7331 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7332 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7333 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7334 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7335 | |
2b31007c RZ |
7336 | DEFPY( |
7337 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7338 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7339 | NEIGHBOR_STR | |
7340 | NEIGHBOR_ADDR_STR2 | |
7341 | "Detect AS loops before sending to neighbor\n") | |
7342 | { | |
7343 | struct peer *peer; | |
7344 | ||
7345 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7346 | if (!peer) | |
7347 | return CMD_WARNING_CONFIG_FAILED; | |
7348 | ||
7349 | peer->as_path_loop_detection = true; | |
7350 | ||
7351 | return CMD_SUCCESS; | |
7352 | } | |
7353 | ||
7354 | DEFPY( | |
7355 | no_neighbor_aspath_loop_detection, | |
7356 | no_neighbor_aspath_loop_detection_cmd, | |
7357 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7358 | NO_STR | |
7359 | NEIGHBOR_STR | |
7360 | NEIGHBOR_ADDR_STR2 | |
7361 | "Detect AS loops before sending to neighbor\n") | |
7362 | { | |
7363 | struct peer *peer; | |
7364 | ||
7365 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7366 | if (!peer) | |
7367 | return CMD_WARNING_CONFIG_FAILED; | |
7368 | ||
7369 | peer->as_path_loop_detection = false; | |
7370 | ||
7371 | return CMD_SUCCESS; | |
7372 | } | |
7373 | ||
b9c7bc5a PZ |
7374 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
7375 | struct ecommunity **list) | |
ddb5b488 | 7376 | { |
b9c7bc5a PZ |
7377 | struct ecommunity *ecom = NULL; |
7378 | struct ecommunity *ecomadd; | |
ddb5b488 | 7379 | |
b9c7bc5a | 7380 | for (; argc; --argc, ++argv) { |
ddb5b488 | 7381 | |
b9c7bc5a PZ |
7382 | ecomadd = ecommunity_str2com(argv[0]->arg, |
7383 | ECOMMUNITY_ROUTE_TARGET, 0); | |
7384 | if (!ecomadd) { | |
7385 | vty_out(vty, "Malformed community-list value\n"); | |
7386 | if (ecom) | |
7387 | ecommunity_free(&ecom); | |
7388 | return CMD_WARNING_CONFIG_FAILED; | |
7389 | } | |
ddb5b488 | 7390 | |
b9c7bc5a PZ |
7391 | if (ecom) { |
7392 | ecommunity_merge(ecom, ecomadd); | |
7393 | ecommunity_free(&ecomadd); | |
7394 | } else { | |
7395 | ecom = ecomadd; | |
7396 | } | |
7397 | } | |
7398 | ||
7399 | if (*list) { | |
7400 | ecommunity_free(&*list); | |
ddb5b488 | 7401 | } |
b9c7bc5a PZ |
7402 | *list = ecom; |
7403 | ||
7404 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7405 | } |
7406 | ||
0ca70ba5 DS |
7407 | /* |
7408 | * v2vimport is true if we are handling a `import vrf ...` command | |
7409 | */ | |
7410 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7411 | { |
0ca70ba5 DS |
7412 | afi_t afi; |
7413 | ||
ddb5b488 | 7414 | switch (vty->node) { |
b9c7bc5a | 7415 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7416 | afi = AFI_IP; |
7417 | break; | |
b9c7bc5a | 7418 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7419 | afi = AFI_IP6; |
7420 | break; | |
ddb5b488 PZ |
7421 | default: |
7422 | vty_out(vty, | |
b9c7bc5a | 7423 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7424 | return AFI_MAX; |
ddb5b488 | 7425 | } |
69b07479 | 7426 | |
0ca70ba5 DS |
7427 | if (!v2vimport) { |
7428 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7429 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7430 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7431 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7432 | vty_out(vty, | |
7433 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7434 | return AFI_MAX; | |
7435 | } | |
7436 | } else { | |
7437 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7438 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7439 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7440 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7441 | vty_out(vty, | |
7442 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7443 | return AFI_MAX; | |
7444 | } | |
7445 | } | |
7446 | return afi; | |
ddb5b488 PZ |
7447 | } |
7448 | ||
b9c7bc5a PZ |
7449 | DEFPY (af_rd_vpn_export, |
7450 | af_rd_vpn_export_cmd, | |
7451 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7452 | NO_STR | |
ddb5b488 | 7453 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7454 | "Between current address-family and vpn\n" |
7455 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7456 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7457 | { | |
7458 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7459 | struct prefix_rd prd; | |
7460 | int ret; | |
ddb5b488 | 7461 | afi_t afi; |
b9c7bc5a PZ |
7462 | int idx = 0; |
7463 | int yes = 1; | |
ddb5b488 | 7464 | |
b9c7bc5a | 7465 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7466 | yes = 0; |
b9c7bc5a PZ |
7467 | |
7468 | if (yes) { | |
7469 | ret = str2prefix_rd(rd_str, &prd); | |
7470 | if (!ret) { | |
7471 | vty_out(vty, "%% Malformed rd\n"); | |
7472 | return CMD_WARNING_CONFIG_FAILED; | |
7473 | } | |
ddb5b488 PZ |
7474 | } |
7475 | ||
0ca70ba5 | 7476 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7477 | if (afi == AFI_MAX) |
7478 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7479 | |
69b07479 DS |
7480 | /* |
7481 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7482 | */ | |
7483 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7484 | bgp_get_default(), bgp); | |
ddb5b488 | 7485 | |
69b07479 DS |
7486 | if (yes) { |
7487 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7488 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7489 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7490 | } else { | |
7491 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7492 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7493 | } |
7494 | ||
69b07479 DS |
7495 | /* post-change: re-export vpn routes */ |
7496 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7497 | bgp_get_default(), bgp); | |
7498 | ||
ddb5b488 PZ |
7499 | return CMD_SUCCESS; |
7500 | } | |
7501 | ||
b9c7bc5a PZ |
7502 | ALIAS (af_rd_vpn_export, |
7503 | af_no_rd_vpn_export_cmd, | |
7504 | "no rd vpn export", | |
ddb5b488 | 7505 | NO_STR |
b9c7bc5a PZ |
7506 | "Specify route distinguisher\n" |
7507 | "Between current address-family and vpn\n" | |
7508 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7509 | |
b9c7bc5a PZ |
7510 | DEFPY (af_label_vpn_export, |
7511 | af_label_vpn_export_cmd, | |
e70e9f8e | 7512 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7513 | NO_STR |
ddb5b488 | 7514 | "label value for VRF\n" |
b9c7bc5a PZ |
7515 | "Between current address-family and vpn\n" |
7516 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7517 | "Label Value <0-1048575>\n" |
7518 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7519 | { |
7520 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7521 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7522 | afi_t afi; |
b9c7bc5a PZ |
7523 | int idx = 0; |
7524 | int yes = 1; | |
7525 | ||
7526 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7527 | yes = 0; |
ddb5b488 | 7528 | |
21a16cc2 PZ |
7529 | /* If "no ...", squash trailing parameter */ |
7530 | if (!yes) | |
7531 | label_auto = NULL; | |
7532 | ||
e70e9f8e PZ |
7533 | if (yes) { |
7534 | if (!label_auto) | |
7535 | label = label_val; /* parser should force unsigned */ | |
7536 | } | |
ddb5b488 | 7537 | |
0ca70ba5 | 7538 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7539 | if (afi == AFI_MAX) |
7540 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7541 | |
e70e9f8e | 7542 | |
69b07479 DS |
7543 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7544 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7545 | /* no change */ | |
7546 | return CMD_SUCCESS; | |
e70e9f8e | 7547 | |
69b07479 DS |
7548 | /* |
7549 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7550 | */ | |
7551 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7552 | bgp_get_default(), bgp); | |
7553 | ||
7554 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7555 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7556 | ||
7557 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7558 | ||
7559 | /* | |
7560 | * label has previously been automatically | |
7561 | * assigned by labelpool: release it | |
7562 | * | |
7563 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7564 | * means the automatic assignment is in flight | |
7565 | * and therefore the labelpool callback must | |
7566 | * detect that the auto label is not needed. | |
7567 | */ | |
7568 | ||
7569 | bgp_lp_release(LP_TYPE_VRF, | |
7570 | &bgp->vpn_policy[afi], | |
7571 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7572 | } |
69b07479 DS |
7573 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7574 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7575 | } | |
ddb5b488 | 7576 | |
69b07479 DS |
7577 | bgp->vpn_policy[afi].tovpn_label = label; |
7578 | if (label_auto) { | |
7579 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7580 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7581 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7582 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7583 | } |
7584 | ||
69b07479 DS |
7585 | /* post-change: re-export vpn routes */ |
7586 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7587 | bgp_get_default(), bgp); | |
7588 | ||
ddb5b488 PZ |
7589 | return CMD_SUCCESS; |
7590 | } | |
7591 | ||
b9c7bc5a PZ |
7592 | ALIAS (af_label_vpn_export, |
7593 | af_no_label_vpn_export_cmd, | |
7594 | "no label vpn export", | |
7595 | NO_STR | |
7596 | "label value for VRF\n" | |
7597 | "Between current address-family and vpn\n" | |
7598 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7599 | |
b9c7bc5a PZ |
7600 | DEFPY (af_nexthop_vpn_export, |
7601 | af_nexthop_vpn_export_cmd, | |
8c85ca28 | 7602 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 7603 | NO_STR |
ddb5b488 | 7604 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7605 | "Between current address-family and vpn\n" |
7606 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7607 | "IPv4 prefix\n" |
7608 | "IPv6 prefix\n") | |
7609 | { | |
7610 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7611 | afi_t afi; |
ddb5b488 PZ |
7612 | struct prefix p; |
7613 | ||
8c85ca28 QY |
7614 | if (!no) { |
7615 | if (!nexthop_su) { | |
7616 | vty_out(vty, "%% Nexthop required\n"); | |
7617 | return CMD_WARNING_CONFIG_FAILED; | |
7618 | } | |
b9c7bc5a | 7619 | |
8c85ca28 | 7620 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
7621 | return CMD_WARNING_CONFIG_FAILED; |
7622 | } | |
ddb5b488 | 7623 | |
0ca70ba5 | 7624 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7625 | if (afi == AFI_MAX) |
7626 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7627 | |
69b07479 DS |
7628 | /* |
7629 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7630 | */ | |
7631 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7632 | bgp_get_default(), bgp); | |
ddb5b488 | 7633 | |
8c85ca28 | 7634 | if (!no) { |
69b07479 DS |
7635 | bgp->vpn_policy[afi].tovpn_nexthop = p; |
7636 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7637 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7638 | } else { | |
7639 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7640 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7641 | } |
7642 | ||
69b07479 DS |
7643 | /* post-change: re-export vpn routes */ |
7644 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7645 | bgp_get_default(), bgp); | |
7646 | ||
ddb5b488 PZ |
7647 | return CMD_SUCCESS; |
7648 | } | |
7649 | ||
b9c7bc5a | 7650 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7651 | { |
b9c7bc5a PZ |
7652 | if (!strcmp(dstr, "import")) { |
7653 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7654 | } else if (!strcmp(dstr, "export")) { | |
7655 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7656 | } else if (!strcmp(dstr, "both")) { | |
7657 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7658 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7659 | } else { | |
7660 | vty_out(vty, "%% direction parse error\n"); | |
7661 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7662 | } |
ddb5b488 PZ |
7663 | return CMD_SUCCESS; |
7664 | } | |
7665 | ||
b9c7bc5a PZ |
7666 | DEFPY (af_rt_vpn_imexport, |
7667 | af_rt_vpn_imexport_cmd, | |
7668 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7669 | NO_STR | |
7670 | "Specify route target list\n" | |
ddb5b488 | 7671 | "Specify route target list\n" |
b9c7bc5a PZ |
7672 | "Between current address-family and vpn\n" |
7673 | "For routes leaked from vpn to current address-family: match any\n" | |
7674 | "For routes leaked from current address-family to vpn: set\n" | |
7675 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7676 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7677 | { | |
7678 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7679 | int ret; | |
7680 | struct ecommunity *ecom = NULL; | |
7681 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7682 | vpn_policy_direction_t dir; |
7683 | afi_t afi; | |
7684 | int idx = 0; | |
b9c7bc5a | 7685 | int yes = 1; |
ddb5b488 | 7686 | |
b9c7bc5a | 7687 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7688 | yes = 0; |
b9c7bc5a | 7689 | |
0ca70ba5 | 7690 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7691 | if (afi == AFI_MAX) |
7692 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7693 | |
b9c7bc5a | 7694 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7695 | if (ret != CMD_SUCCESS) |
7696 | return ret; | |
7697 | ||
b9c7bc5a PZ |
7698 | if (yes) { |
7699 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7700 | vty_out(vty, "%% Missing RTLIST\n"); | |
7701 | return CMD_WARNING_CONFIG_FAILED; | |
7702 | } | |
7703 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7704 | if (ret != CMD_SUCCESS) { | |
7705 | return ret; | |
7706 | } | |
ddb5b488 PZ |
7707 | } |
7708 | ||
69b07479 DS |
7709 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7710 | if (!dodir[dir]) | |
ddb5b488 | 7711 | continue; |
ddb5b488 | 7712 | |
69b07479 | 7713 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7714 | |
69b07479 DS |
7715 | if (yes) { |
7716 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7717 | ecommunity_free( | |
7718 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7719 | bgp->vpn_policy[afi].rtlist[dir] = | |
7720 | ecommunity_dup(ecom); | |
7721 | } else { | |
7722 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7723 | ecommunity_free( | |
7724 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7725 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7726 | } |
69b07479 DS |
7727 | |
7728 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7729 | } |
69b07479 | 7730 | |
d555f3e9 PZ |
7731 | if (ecom) |
7732 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7733 | |
7734 | return CMD_SUCCESS; | |
7735 | } | |
7736 | ||
b9c7bc5a PZ |
7737 | ALIAS (af_rt_vpn_imexport, |
7738 | af_no_rt_vpn_imexport_cmd, | |
7739 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7740 | NO_STR |
7741 | "Specify route target list\n" | |
b9c7bc5a PZ |
7742 | "Specify route target list\n" |
7743 | "Between current address-family and vpn\n" | |
7744 | "For routes leaked from vpn to current address-family\n" | |
7745 | "For routes leaked from current address-family to vpn\n" | |
7746 | "both import and export\n") | |
7747 | ||
7748 | DEFPY (af_route_map_vpn_imexport, | |
7749 | af_route_map_vpn_imexport_cmd, | |
7750 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7751 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7752 | NO_STR | |
ddb5b488 | 7753 | "Specify route map\n" |
b9c7bc5a PZ |
7754 | "Between current address-family and vpn\n" |
7755 | "For routes leaked from vpn to current address-family\n" | |
7756 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7757 | "name of route-map\n") |
7758 | { | |
7759 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7760 | int ret; | |
7761 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7762 | vpn_policy_direction_t dir; |
7763 | afi_t afi; | |
ddb5b488 | 7764 | int idx = 0; |
b9c7bc5a | 7765 | int yes = 1; |
ddb5b488 | 7766 | |
b9c7bc5a | 7767 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7768 | yes = 0; |
b9c7bc5a | 7769 | |
0ca70ba5 | 7770 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7771 | if (afi == AFI_MAX) |
7772 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7773 | |
b9c7bc5a | 7774 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7775 | if (ret != CMD_SUCCESS) |
7776 | return ret; | |
7777 | ||
69b07479 DS |
7778 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7779 | if (!dodir[dir]) | |
ddb5b488 | 7780 | continue; |
ddb5b488 | 7781 | |
69b07479 | 7782 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7783 | |
69b07479 DS |
7784 | if (yes) { |
7785 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7786 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7787 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7788 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7789 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7790 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7791 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7792 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7793 | return CMD_SUCCESS; | |
7794 | } else { | |
7795 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7796 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7797 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7798 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7799 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7800 | } |
69b07479 DS |
7801 | |
7802 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7803 | } |
7804 | ||
7805 | return CMD_SUCCESS; | |
7806 | } | |
7807 | ||
b9c7bc5a PZ |
7808 | ALIAS (af_route_map_vpn_imexport, |
7809 | af_no_route_map_vpn_imexport_cmd, | |
7810 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7811 | NO_STR |
7812 | "Specify route map\n" | |
b9c7bc5a PZ |
7813 | "Between current address-family and vpn\n" |
7814 | "For routes leaked from vpn to current address-family\n" | |
7815 | "For routes leaked from current address-family to vpn\n") | |
7816 | ||
bb4f6190 | 7817 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 7818 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
7819 | "Import routes from another VRF\n" |
7820 | "Vrf routes being filtered\n" | |
7821 | "Specify route map\n" | |
7822 | "name of route-map\n") | |
7823 | { | |
7824 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7825 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7826 | afi_t afi; | |
bb4f6190 DS |
7827 | struct bgp *bgp_default; |
7828 | ||
0ca70ba5 | 7829 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7830 | if (afi == AFI_MAX) |
7831 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7832 | |
7833 | bgp_default = bgp_get_default(); | |
7834 | if (!bgp_default) { | |
7835 | int32_t ret; | |
7836 | as_t as = bgp->as; | |
7837 | ||
7838 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7839 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7840 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7841 | |
7842 | if (ret) { | |
7843 | vty_out(vty, | |
7844 | "VRF default is not configured as a bgp instance\n"); | |
7845 | return CMD_WARNING; | |
7846 | } | |
7847 | } | |
7848 | ||
69b07479 | 7849 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7850 | |
ae6a6fb4 DS |
7851 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
7852 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7853 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7854 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7855 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7856 | bgp->vpn_policy[afi].rmap[dir] = | |
7857 | route_map_lookup_warn_noexist(vty, rmap_str); | |
7858 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
7859 | return CMD_SUCCESS; | |
7860 | ||
7861 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7862 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 7863 | |
69b07479 DS |
7864 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7865 | ||
bb4f6190 DS |
7866 | return CMD_SUCCESS; |
7867 | } | |
7868 | ||
ae6a6fb4 DS |
7869 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
7870 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
7871 | NO_STR |
7872 | "Import routes from another VRF\n" | |
7873 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
7874 | "Specify route map\n" |
7875 | "name of route-map\n") | |
7876 | { | |
7877 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7878 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7879 | afi_t afi; | |
7880 | ||
7881 | afi = vpn_policy_getafi(vty, bgp, true); | |
7882 | if (afi == AFI_MAX) | |
7883 | return CMD_WARNING_CONFIG_FAILED; | |
7884 | ||
7885 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7886 | ||
7887 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7888 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7889 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7890 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7891 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
7892 | ||
7893 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
7894 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7895 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
7896 | ||
7897 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
7898 | ||
7899 | return CMD_SUCCESS; | |
7900 | } | |
bb4f6190 | 7901 | |
4d1b335c DA |
7902 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7903 | "[no] import vrf VIEWVRFNAME$import_name", | |
7904 | NO_STR | |
7905 | "Import routes from another VRF\n" | |
7906 | "VRF to import from\n" | |
7907 | "The name of the VRF\n") | |
12a844a5 DS |
7908 | { |
7909 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7910 | struct listnode *node; | |
79ef8664 DS |
7911 | struct bgp *vrf_bgp, *bgp_default; |
7912 | int32_t ret = 0; | |
7913 | as_t as = bgp->as; | |
12a844a5 DS |
7914 | bool remove = false; |
7915 | int32_t idx = 0; | |
7916 | char *vname; | |
a8dadcf6 | 7917 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7918 | safi_t safi; |
7919 | afi_t afi; | |
7920 | ||
867f0cca | 7921 | if (import_name == NULL) { |
7922 | vty_out(vty, "%% Missing import name\n"); | |
7923 | return CMD_WARNING; | |
7924 | } | |
7925 | ||
ae6a6fb4 DS |
7926 | if (strcmp(import_name, "route-map") == 0) { |
7927 | vty_out(vty, "%% Must include route-map name\n"); | |
7928 | return CMD_WARNING; | |
7929 | } | |
7930 | ||
12a844a5 DS |
7931 | if (argv_find(argv, argc, "no", &idx)) |
7932 | remove = true; | |
7933 | ||
0ca70ba5 DS |
7934 | afi = vpn_policy_getafi(vty, bgp, true); |
7935 | if (afi == AFI_MAX) | |
7936 | return CMD_WARNING_CONFIG_FAILED; | |
7937 | ||
12a844a5 DS |
7938 | safi = bgp_node_safi(vty); |
7939 | ||
25679caa | 7940 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7941 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7942 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7943 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7944 | remove ? "unimport" : "import", import_name); | |
7945 | return CMD_WARNING; | |
7946 | } | |
7947 | ||
79ef8664 DS |
7948 | bgp_default = bgp_get_default(); |
7949 | if (!bgp_default) { | |
7950 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7951 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7952 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7953 | |
7954 | if (ret) { | |
7955 | vty_out(vty, | |
7956 | "VRF default is not configured as a bgp instance\n"); | |
7957 | return CMD_WARNING; | |
7958 | } | |
7959 | } | |
7960 | ||
12a844a5 DS |
7961 | vrf_bgp = bgp_lookup_by_name(import_name); |
7962 | if (!vrf_bgp) { | |
5742e42b | 7963 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7964 | vrf_bgp = bgp_default; |
7965 | else | |
0fb8d6e6 | 7966 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7967 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7968 | |
6e2c7fe6 | 7969 | if (ret) { |
020a3f60 DS |
7970 | vty_out(vty, |
7971 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7972 | import_name); |
7973 | return CMD_WARNING; | |
7974 | } | |
12a844a5 DS |
7975 | } |
7976 | ||
12a844a5 | 7977 | if (remove) { |
44338987 | 7978 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7979 | } else { |
44338987 | 7980 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7981 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7982 | vname)) { | |
7983 | if (strcmp(vname, import_name) == 0) | |
7984 | return CMD_WARNING; | |
7985 | } | |
7986 | ||
44338987 | 7987 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7988 | } |
7989 | ||
7990 | return CMD_SUCCESS; | |
7991 | } | |
7992 | ||
b9c7bc5a PZ |
7993 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7994 | DEFPY (bgp_imexport_vpn, | |
7995 | bgp_imexport_vpn_cmd, | |
7996 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7997 | NO_STR |
7998 | "Import routes to this address-family\n" | |
7999 | "Export routes from this address-family\n" | |
8000 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
8001 | { |
8002 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8003 | int previous_state; |
ddb5b488 | 8004 | afi_t afi; |
b9c7bc5a | 8005 | safi_t safi; |
ddb5b488 | 8006 | int idx = 0; |
b9c7bc5a PZ |
8007 | int yes = 1; |
8008 | int flag; | |
8009 | vpn_policy_direction_t dir; | |
ddb5b488 | 8010 | |
b9c7bc5a | 8011 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 8012 | yes = 0; |
ddb5b488 | 8013 | |
b9c7bc5a PZ |
8014 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
8015 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 8016 | |
b9c7bc5a PZ |
8017 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
8018 | return CMD_WARNING_CONFIG_FAILED; | |
8019 | } | |
ddb5b488 | 8020 | |
b9c7bc5a PZ |
8021 | afi = bgp_node_afi(vty); |
8022 | safi = bgp_node_safi(vty); | |
8023 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
8024 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
8025 | return CMD_WARNING_CONFIG_FAILED; | |
8026 | } | |
ddb5b488 | 8027 | |
b9c7bc5a PZ |
8028 | if (!strcmp(direction_str, "import")) { |
8029 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
8030 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8031 | } else if (!strcmp(direction_str, "export")) { | |
8032 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
8033 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
8034 | } else { | |
8035 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
8036 | return CMD_WARNING_CONFIG_FAILED; | |
8037 | } | |
8038 | ||
8039 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 8040 | |
b9c7bc5a PZ |
8041 | if (yes) { |
8042 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
8043 | if (!previous_state) { | |
8044 | /* trigger export current vrf */ | |
ddb5b488 PZ |
8045 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8046 | } | |
b9c7bc5a PZ |
8047 | } else { |
8048 | if (previous_state) { | |
8049 | /* trigger un-export current vrf */ | |
8050 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8051 | } | |
8052 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
8053 | } |
8054 | ||
8055 | return CMD_SUCCESS; | |
8056 | } | |
8057 | ||
301ad80a PG |
8058 | DEFPY (af_routetarget_import, |
8059 | af_routetarget_import_cmd, | |
8060 | "[no] <rt|route-target> redirect import RTLIST...", | |
8061 | NO_STR | |
8062 | "Specify route target list\n" | |
8063 | "Specify route target list\n" | |
8064 | "Flow-spec redirect type route target\n" | |
8065 | "Import routes to this address-family\n" | |
8066 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
8067 | { | |
8068 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8069 | int ret; | |
8070 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
8071 | afi_t afi; |
8072 | int idx = 0; | |
8073 | int yes = 1; | |
8074 | ||
8075 | if (argv_find(argv, argc, "no", &idx)) | |
8076 | yes = 0; | |
8077 | ||
0ca70ba5 | 8078 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8079 | if (afi == AFI_MAX) |
8080 | return CMD_WARNING_CONFIG_FAILED; | |
8081 | ||
301ad80a PG |
8082 | if (yes) { |
8083 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8084 | vty_out(vty, "%% Missing RTLIST\n"); | |
8085 | return CMD_WARNING_CONFIG_FAILED; | |
8086 | } | |
8087 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
8088 | if (ret != CMD_SUCCESS) | |
8089 | return ret; | |
8090 | } | |
69b07479 DS |
8091 | |
8092 | if (yes) { | |
8093 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8094 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8095 | .import_redirect_rtlist); |
69b07479 DS |
8096 | bgp->vpn_policy[afi].import_redirect_rtlist = |
8097 | ecommunity_dup(ecom); | |
8098 | } else { | |
8099 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8100 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8101 | .import_redirect_rtlist); |
69b07479 | 8102 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 8103 | } |
69b07479 | 8104 | |
301ad80a PG |
8105 | if (ecom) |
8106 | ecommunity_free(&ecom); | |
8107 | ||
8108 | return CMD_SUCCESS; | |
8109 | } | |
8110 | ||
505e5056 | 8111 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 8112 | address_family_ipv4_safi_cmd, |
8113 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
8114 | "Enter Address Family command mode\n" | |
8115 | "Address Family\n" | |
8116 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 8117 | { |
f51bae9c | 8118 | |
d62a17ae | 8119 | if (argc == 3) { |
2131d5cf | 8120 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8121 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
8122 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
8123 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8124 | && safi != SAFI_EVPN) { |
31947174 MK |
8125 | vty_out(vty, |
8126 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8127 | return CMD_WARNING_CONFIG_FAILED; |
8128 | } | |
d62a17ae | 8129 | vty->node = bgp_node_type(AFI_IP, safi); |
8130 | } else | |
8131 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 8132 | |
d62a17ae | 8133 | return CMD_SUCCESS; |
718e3744 | 8134 | } |
8135 | ||
505e5056 | 8136 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 8137 | address_family_ipv6_safi_cmd, |
8138 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
8139 | "Enter Address Family command mode\n" | |
8140 | "Address Family\n" | |
8141 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 8142 | { |
d62a17ae | 8143 | if (argc == 3) { |
2131d5cf | 8144 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8145 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
8146 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
8147 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8148 | && safi != SAFI_EVPN) { |
31947174 MK |
8149 | vty_out(vty, |
8150 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8151 | return CMD_WARNING_CONFIG_FAILED; |
8152 | } | |
d62a17ae | 8153 | vty->node = bgp_node_type(AFI_IP6, safi); |
8154 | } else | |
8155 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 8156 | |
d62a17ae | 8157 | return CMD_SUCCESS; |
25ffbdc1 | 8158 | } |
718e3744 | 8159 | |
d6902373 | 8160 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 8161 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 8162 | address_family_vpnv4_cmd, |
8334fd5a | 8163 | "address-family vpnv4 [unicast]", |
718e3744 | 8164 | "Enter Address Family command mode\n" |
8c3deaae | 8165 | "Address Family\n" |
3a2d747c | 8166 | "Address Family modifier\n") |
718e3744 | 8167 | { |
d62a17ae | 8168 | vty->node = BGP_VPNV4_NODE; |
8169 | return CMD_SUCCESS; | |
718e3744 | 8170 | } |
8171 | ||
505e5056 | 8172 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 8173 | address_family_vpnv6_cmd, |
8334fd5a | 8174 | "address-family vpnv6 [unicast]", |
8ecd3266 | 8175 | "Enter Address Family command mode\n" |
8c3deaae | 8176 | "Address Family\n" |
3a2d747c | 8177 | "Address Family modifier\n") |
8ecd3266 | 8178 | { |
d62a17ae | 8179 | vty->node = BGP_VPNV6_NODE; |
8180 | return CMD_SUCCESS; | |
8ecd3266 | 8181 | } |
64e4a6c5 | 8182 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 8183 | |
505e5056 | 8184 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 8185 | address_family_evpn_cmd, |
7111c1a0 | 8186 | "address-family l2vpn evpn", |
4e0b7b6d | 8187 | "Enter Address Family command mode\n" |
7111c1a0 QY |
8188 | "Address Family\n" |
8189 | "Address Family modifier\n") | |
4e0b7b6d | 8190 | { |
2131d5cf | 8191 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8192 | vty->node = BGP_EVPN_NODE; |
8193 | return CMD_SUCCESS; | |
4e0b7b6d PG |
8194 | } |
8195 | ||
505e5056 | 8196 | DEFUN_NOSH (exit_address_family, |
718e3744 | 8197 | exit_address_family_cmd, |
8198 | "exit-address-family", | |
8199 | "Exit from Address Family configuration mode\n") | |
8200 | { | |
d62a17ae | 8201 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
8202 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
8203 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
8204 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
8205 | || vty->node == BGP_EVPN_NODE |
8206 | || vty->node == BGP_FLOWSPECV4_NODE | |
8207 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 8208 | vty->node = BGP_NODE; |
8209 | return CMD_SUCCESS; | |
718e3744 | 8210 | } |
6b0655a2 | 8211 | |
8ad7271d | 8212 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 8213 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
8214 | const char *ip_str, afi_t afi, safi_t safi, | |
8215 | struct prefix_rd *prd) | |
8216 | { | |
8217 | int ret; | |
8218 | struct prefix match; | |
9bcb3eef DS |
8219 | struct bgp_dest *dest; |
8220 | struct bgp_dest *rm; | |
d62a17ae | 8221 | struct bgp *bgp; |
8222 | struct bgp_table *table; | |
8223 | struct bgp_table *rib; | |
8224 | ||
8225 | /* BGP structure lookup. */ | |
8226 | if (view_name) { | |
8227 | bgp = bgp_lookup_by_name(view_name); | |
8228 | if (bgp == NULL) { | |
8229 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
8230 | view_name); | |
8231 | return CMD_WARNING; | |
8232 | } | |
8233 | } else { | |
8234 | bgp = bgp_get_default(); | |
8235 | if (bgp == NULL) { | |
8236 | vty_out(vty, "%% No BGP process is configured\n"); | |
8237 | return CMD_WARNING; | |
8238 | } | |
8239 | } | |
8240 | ||
8241 | /* Check IP address argument. */ | |
8242 | ret = str2prefix(ip_str, &match); | |
8243 | if (!ret) { | |
8244 | vty_out(vty, "%% address is malformed\n"); | |
8245 | return CMD_WARNING; | |
8246 | } | |
8247 | ||
8248 | match.family = afi2family(afi); | |
8249 | rib = bgp->rib[afi][safi]; | |
8250 | ||
8251 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
8252 | for (dest = bgp_table_top(rib); dest; |
8253 | dest = bgp_route_next(dest)) { | |
8254 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8255 | |
9bcb3eef | 8256 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 8257 | continue; |
8258 | ||
9bcb3eef | 8259 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
8260 | if (table == NULL) |
8261 | continue; | |
8262 | ||
8263 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
8264 | const struct prefix *rm_p = | |
9bcb3eef | 8265 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
8266 | |
8267 | if (rm_p->prefixlen == match.prefixlen) { | |
8268 | SET_FLAG(rm->flags, | |
8269 | BGP_NODE_USER_CLEAR); | |
8270 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 8271 | } |
9bcb3eef | 8272 | bgp_dest_unlock_node(rm); |
d62a17ae | 8273 | } |
8274 | } | |
8275 | } else { | |
9bcb3eef DS |
8276 | if ((dest = bgp_node_match(rib, &match)) != NULL) { |
8277 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8278 | |
9bcb3eef DS |
8279 | if (dest_p->prefixlen == match.prefixlen) { |
8280 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
8281 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 8282 | } |
9bcb3eef | 8283 | bgp_dest_unlock_node(dest); |
d62a17ae | 8284 | } |
8285 | } | |
8286 | ||
8287 | return CMD_SUCCESS; | |
8ad7271d DS |
8288 | } |
8289 | ||
b09b5ae0 | 8290 | /* one clear bgp command to rule them all */ |
718e3744 | 8291 | DEFUN (clear_ip_bgp_all, |
8292 | clear_ip_bgp_all_cmd, | |
453c92f6 | 8293 | "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 | 8294 | CLEAR_STR |
8295 | IP_STR | |
8296 | BGP_STR | |
838758ac | 8297 | BGP_INSTANCE_HELP_STR |
510afcd6 | 8298 | BGP_AFI_HELP_STR |
fd5e7b70 | 8299 | "Address Family\n" |
510afcd6 | 8300 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8301 | "Address Family modifier\n" |
b09b5ae0 | 8302 | "Clear all peers\n" |
453c92f6 | 8303 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8304 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8305 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8306 | "Clear peers with the AS number\n" |
8307 | "Clear all external peers\n" | |
718e3744 | 8308 | "Clear all members of peer-group\n" |
b09b5ae0 | 8309 | "BGP peer-group name\n" |
b09b5ae0 DW |
8310 | BGP_SOFT_STR |
8311 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8312 | BGP_SOFT_OUT_STR |
8313 | BGP_SOFT_IN_STR | |
8314 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8315 | BGP_SOFT_OUT_STR) |
718e3744 | 8316 | { |
d62a17ae | 8317 | char *vrf = NULL; |
8318 | ||
dc912615 DS |
8319 | afi_t afi = AFI_UNSPEC; |
8320 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8321 | enum clear_sort clr_sort = clear_peer; |
8322 | enum bgp_clear_type clr_type; | |
8323 | char *clr_arg = NULL; | |
8324 | ||
8325 | int idx = 0; | |
8326 | ||
8327 | /* clear [ip] bgp */ | |
8328 | if (argv_find(argv, argc, "ip", &idx)) | |
8329 | afi = AFI_IP; | |
8330 | ||
9a8bdf1c PG |
8331 | /* [<vrf> VIEWVRFNAME] */ |
8332 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8333 | vrf = argv[idx + 1]->arg; | |
8334 | idx += 2; | |
8335 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8336 | vrf = NULL; | |
8337 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8338 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8339 | vrf = argv[idx + 1]->arg; |
8340 | idx += 2; | |
8341 | } | |
d62a17ae | 8342 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8343 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8344 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8345 | ||
d7b9898c | 8346 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8347 | if (argv_find(argv, argc, "*", &idx)) { |
8348 | clr_sort = clear_all; | |
8349 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8350 | clr_sort = clear_peer; | |
8351 | clr_arg = argv[idx]->arg; | |
8352 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8353 | clr_sort = clear_peer; | |
8354 | clr_arg = argv[idx]->arg; | |
8355 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8356 | clr_sort = clear_group; | |
8357 | idx++; | |
8358 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8359 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8360 | clr_sort = clear_peer; |
8361 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8362 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8363 | clr_sort = clear_peer; | |
8364 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8365 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8366 | clr_sort = clear_as; | |
8367 | clr_arg = argv[idx]->arg; | |
8368 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8369 | clr_sort = clear_external; | |
8370 | } | |
8371 | ||
8372 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8373 | if (argv_find(argv, argc, "soft", &idx)) { | |
8374 | if (argv_find(argv, argc, "in", &idx) | |
8375 | || argv_find(argv, argc, "out", &idx)) | |
8376 | clr_type = strmatch(argv[idx]->text, "in") | |
8377 | ? BGP_CLEAR_SOFT_IN | |
8378 | : BGP_CLEAR_SOFT_OUT; | |
8379 | else | |
8380 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8381 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8382 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8383 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8384 | : BGP_CLEAR_SOFT_IN; | |
8385 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8386 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8387 | } else | |
8388 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8389 | ||
8390 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 8391 | } |
01080f7c | 8392 | |
8ad7271d DS |
8393 | DEFUN (clear_ip_bgp_prefix, |
8394 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8395 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8396 | CLEAR_STR |
8397 | IP_STR | |
8398 | BGP_STR | |
838758ac | 8399 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8400 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8401 | "IPv4 prefix\n") |
8ad7271d | 8402 | { |
d62a17ae | 8403 | char *vrf = NULL; |
8404 | char *prefix = NULL; | |
8ad7271d | 8405 | |
d62a17ae | 8406 | int idx = 0; |
01080f7c | 8407 | |
d62a17ae | 8408 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8409 | if (argv_find(argv, argc, "vrf", &idx)) { |
8410 | vrf = argv[idx + 1]->arg; | |
8411 | idx += 2; | |
8412 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8413 | vrf = NULL; | |
8414 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8415 | /* [<view> VIEWVRFNAME] */ | |
8416 | vrf = argv[idx + 1]->arg; | |
8417 | idx += 2; | |
8418 | } | |
0c7b1b01 | 8419 | |
d62a17ae | 8420 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8421 | |
d62a17ae | 8422 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8423 | } |
8ad7271d | 8424 | |
b09b5ae0 DW |
8425 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8426 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8427 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8428 | CLEAR_STR |
3a2d747c | 8429 | IP_STR |
718e3744 | 8430 | BGP_STR |
8c3deaae | 8431 | "Address Family\n" |
46f296b4 | 8432 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8433 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8434 | "IPv6 prefix\n") |
718e3744 | 8435 | { |
9b475e76 PG |
8436 | int idx_safi = 0; |
8437 | int idx_ipv6_prefix = 0; | |
8438 | safi_t safi = SAFI_UNICAST; | |
8439 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8440 | argv[idx_ipv6_prefix]->arg : NULL; | |
8441 | ||
8442 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8443 | return bgp_clear_prefix( |
9b475e76 PG |
8444 | vty, NULL, prefix, AFI_IP6, |
8445 | safi, NULL); | |
838758ac | 8446 | } |
01080f7c | 8447 | |
b09b5ae0 DW |
8448 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8449 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8450 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8451 | CLEAR_STR |
3a2d747c | 8452 | IP_STR |
718e3744 | 8453 | BGP_STR |
838758ac | 8454 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8455 | "Address Family\n" |
46f296b4 | 8456 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8457 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8458 | "IPv6 prefix\n") |
718e3744 | 8459 | { |
9b475e76 | 8460 | int idx_safi = 0; |
9a8bdf1c | 8461 | int idx_vrfview = 0; |
9b475e76 PG |
8462 | int idx_ipv6_prefix = 0; |
8463 | safi_t safi = SAFI_UNICAST; | |
8464 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8465 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8466 | char *vrfview = NULL; |
9b475e76 | 8467 | |
9a8bdf1c PG |
8468 | /* [<view|vrf> VIEWVRFNAME] */ |
8469 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8470 | vrfview = argv[idx_vrfview + 1]->arg; | |
8471 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8472 | vrfview = NULL; | |
8473 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8474 | /* [<view> VIEWVRFNAME] */ | |
8475 | vrfview = argv[idx_vrfview + 1]->arg; | |
8476 | } | |
9b475e76 PG |
8477 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8478 | ||
d62a17ae | 8479 | return bgp_clear_prefix( |
9b475e76 PG |
8480 | vty, vrfview, prefix, |
8481 | AFI_IP6, safi, NULL); | |
718e3744 | 8482 | } |
8483 | ||
b09b5ae0 DW |
8484 | DEFUN (show_bgp_views, |
8485 | show_bgp_views_cmd, | |
d6e3c605 | 8486 | "show [ip] bgp views", |
b09b5ae0 | 8487 | SHOW_STR |
d6e3c605 | 8488 | IP_STR |
01080f7c | 8489 | BGP_STR |
b09b5ae0 | 8490 | "Show the defined BGP views\n") |
01080f7c | 8491 | { |
d62a17ae | 8492 | struct list *inst = bm->bgp; |
8493 | struct listnode *node; | |
8494 | struct bgp *bgp; | |
01080f7c | 8495 | |
d62a17ae | 8496 | vty_out(vty, "Defined BGP views:\n"); |
8497 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8498 | /* Skip VRFs. */ | |
8499 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8500 | continue; | |
8501 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8502 | bgp->as); | |
8503 | } | |
e52702f2 | 8504 | |
d62a17ae | 8505 | return CMD_SUCCESS; |
e0081f70 ML |
8506 | } |
8507 | ||
8386ac43 | 8508 | DEFUN (show_bgp_vrfs, |
8509 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8510 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8511 | SHOW_STR |
d6e3c605 | 8512 | IP_STR |
8386ac43 | 8513 | BGP_STR |
8514 | "Show BGP VRFs\n" | |
9973d184 | 8515 | JSON_STR) |
8386ac43 | 8516 | { |
fe1dc5a3 | 8517 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8518 | struct list *inst = bm->bgp; |
8519 | struct listnode *node; | |
8520 | struct bgp *bgp; | |
9f049418 | 8521 | bool uj = use_json(argc, argv); |
d62a17ae | 8522 | json_object *json = NULL; |
8523 | json_object *json_vrfs = NULL; | |
8524 | int count = 0; | |
d62a17ae | 8525 | |
d62a17ae | 8526 | if (uj) { |
8527 | json = json_object_new_object(); | |
8528 | json_vrfs = json_object_new_object(); | |
8529 | } | |
8530 | ||
8531 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8532 | const char *name, *type; | |
8533 | struct peer *peer; | |
7fe96307 | 8534 | struct listnode *node2, *nnode2; |
d62a17ae | 8535 | int peers_cfg, peers_estb; |
8536 | json_object *json_vrf = NULL; | |
d62a17ae | 8537 | |
8538 | /* Skip Views. */ | |
8539 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8540 | continue; | |
8541 | ||
8542 | count++; | |
efb4077a | 8543 | if (!uj && count == 1) { |
fe1dc5a3 | 8544 | vty_out(vty, |
efb4077a | 8545 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8546 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8547 | "#PeersEstb", "Name"); |
8548 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8549 | "L3-VNI", "RouterMAC", "Interface"); | |
8550 | } | |
d62a17ae | 8551 | |
8552 | peers_cfg = peers_estb = 0; | |
8553 | if (uj) | |
8554 | json_vrf = json_object_new_object(); | |
8555 | ||
8556 | ||
7fe96307 | 8557 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8558 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8559 | continue; | |
8560 | peers_cfg++; | |
8561 | if (peer->status == Established) | |
8562 | peers_estb++; | |
8563 | } | |
8564 | ||
8565 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8566 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8567 | type = "DFLT"; |
8568 | } else { | |
8569 | name = bgp->name; | |
8570 | type = "VRF"; | |
8571 | } | |
8572 | ||
a8bf7d9c | 8573 | |
d62a17ae | 8574 | if (uj) { |
a4d82a8a PZ |
8575 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8576 | ? -1 | |
8577 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8578 | json_object_string_add(json_vrf, "type", type); |
8579 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8580 | json_object_string_add(json_vrf, "routerId", | |
8581 | inet_ntoa(bgp->router_id)); | |
8582 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8583 | peers_cfg); | |
8584 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8585 | peers_estb); | |
8586 | ||
fe1dc5a3 | 8587 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8588 | json_object_string_add( |
8589 | json_vrf, "rmac", | |
8590 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8591 | json_object_string_add(json_vrf, "interface", |
8592 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8593 | bgp->vrf_id)); | |
d62a17ae | 8594 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8595 | } else { |
fe1dc5a3 | 8596 | vty_out(vty, |
efb4077a | 8597 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8598 | type, |
8599 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8600 | : (int)bgp->vrf_id, | |
8601 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8602 | peers_estb, name); |
8603 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8604 | bgp->l3vni, | |
8605 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8606 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8607 | bgp->vrf_id)); | |
8608 | } | |
d62a17ae | 8609 | } |
8610 | ||
8611 | if (uj) { | |
8612 | json_object_object_add(json, "vrfs", json_vrfs); | |
8613 | ||
8614 | json_object_int_add(json, "totalVrfs", count); | |
8615 | ||
996c9314 LB |
8616 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8617 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8618 | json_object_free(json); |
8619 | } else { | |
8620 | if (count) | |
8621 | vty_out(vty, | |
8622 | "\nTotal number of VRFs (including default): %d\n", | |
8623 | count); | |
8624 | } | |
8625 | ||
8626 | return CMD_SUCCESS; | |
8386ac43 | 8627 | } |
8628 | ||
48ecf8f5 DS |
8629 | DEFUN (show_bgp_mac_hash, |
8630 | show_bgp_mac_hash_cmd, | |
8631 | "show bgp mac hash", | |
8632 | SHOW_STR | |
8633 | BGP_STR | |
8634 | "Mac Address\n" | |
8635 | "Mac Address database\n") | |
8636 | { | |
8637 | bgp_mac_dump_table(vty); | |
8638 | ||
8639 | return CMD_SUCCESS; | |
8640 | } | |
acf71666 | 8641 | |
e3b78da8 | 8642 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8643 | { |
0291c246 | 8644 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8645 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8646 | |
60466a63 | 8647 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8648 | tip->refcnt); |
8649 | } | |
8650 | ||
8651 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8652 | { | |
8653 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8654 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8655 | |
8656 | vty_out(vty, "Tunnel-ip database:\n"); | |
8657 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8658 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8659 | vty); |
8660 | } | |
8661 | ||
15c81ca4 DS |
8662 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8663 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8664 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8665 | "martian next-hops\n" |
8666 | "martian next-hop database\n") | |
acf71666 | 8667 | { |
0291c246 | 8668 | struct bgp *bgp = NULL; |
15c81ca4 | 8669 | int idx = 0; |
9a8bdf1c PG |
8670 | char *name = NULL; |
8671 | ||
8672 | /* [<vrf> VIEWVRFNAME] */ | |
8673 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8674 | name = argv[idx + 1]->arg; | |
8675 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8676 | name = NULL; | |
8677 | } else if (argv_find(argv, argc, "view", &idx)) | |
8678 | /* [<view> VIEWVRFNAME] */ | |
8679 | name = argv[idx + 1]->arg; | |
8680 | if (name) | |
8681 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8682 | else |
8683 | bgp = bgp_get_default(); | |
acf71666 | 8684 | |
acf71666 MK |
8685 | if (!bgp) { |
8686 | vty_out(vty, "%% No BGP process is configured\n"); | |
8687 | return CMD_WARNING; | |
8688 | } | |
8689 | bgp_show_martian_nexthops(vty, bgp); | |
8690 | ||
8691 | return CMD_SUCCESS; | |
8692 | } | |
8693 | ||
f412b39a | 8694 | DEFUN (show_bgp_memory, |
4bf6a362 | 8695 | show_bgp_memory_cmd, |
7fa12b13 | 8696 | "show [ip] bgp memory", |
4bf6a362 | 8697 | SHOW_STR |
3a2d747c | 8698 | IP_STR |
4bf6a362 PJ |
8699 | BGP_STR |
8700 | "Global BGP memory statistics\n") | |
8701 | { | |
d62a17ae | 8702 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8703 | unsigned long count; | |
8704 | ||
8705 | /* RIB related usage stats */ | |
8706 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8707 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8708 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 8709 | count * sizeof(struct bgp_dest))); |
d62a17ae | 8710 | |
8711 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8712 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8713 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8714 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8715 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8716 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8717 | count, | |
4b7e6066 DS |
8718 | mtype_memstr( |
8719 | memstrbuf, sizeof(memstrbuf), | |
8720 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8721 | |
8722 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8723 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8724 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8725 | count * sizeof(struct bgp_static))); | |
8726 | ||
8727 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8728 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8729 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8730 | count * sizeof(struct bpacket))); | |
8731 | ||
8732 | /* Adj-In/Out */ | |
8733 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8734 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8735 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8736 | count * sizeof(struct bgp_adj_in))); | |
8737 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8738 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8739 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8740 | count * sizeof(struct bgp_adj_out))); | |
8741 | ||
8742 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8743 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8744 | count, | |
8745 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8746 | count * sizeof(struct bgp_nexthop_cache))); | |
8747 | ||
8748 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8749 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8750 | count, | |
8751 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8752 | count * sizeof(struct bgp_damp_info))); | |
8753 | ||
8754 | /* Attributes */ | |
8755 | count = attr_count(); | |
8756 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8757 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8758 | count * sizeof(struct attr))); | |
8759 | ||
8760 | if ((count = attr_unknown_count())) | |
8761 | vty_out(vty, "%ld unknown attributes\n", count); | |
8762 | ||
8763 | /* AS_PATH attributes */ | |
8764 | count = aspath_count(); | |
8765 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8766 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8767 | count * sizeof(struct aspath))); | |
8768 | ||
8769 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8770 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8771 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8772 | count * sizeof(struct assegment))); | |
8773 | ||
8774 | /* Other attributes */ | |
8775 | if ((count = community_count())) | |
8776 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8777 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8778 | count * sizeof(struct community))); | |
d62a17ae | 8779 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8780 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8781 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8782 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8783 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8784 | vty_out(vty, | |
8785 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8786 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8787 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8788 | |
8789 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8790 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8791 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8792 | count * sizeof(struct cluster_list))); | |
8793 | ||
8794 | /* Peer related usage */ | |
8795 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8796 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8797 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8798 | count * sizeof(struct peer))); | |
8799 | ||
8800 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8801 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8802 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8803 | count * sizeof(struct peer_group))); | |
8804 | ||
8805 | /* Other */ | |
d62a17ae | 8806 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8807 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8808 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8809 | count * sizeof(regex_t))); | |
d62a17ae | 8810 | return CMD_SUCCESS; |
4bf6a362 | 8811 | } |
fee0f4c6 | 8812 | |
57a9c8a8 DS |
8813 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8814 | { | |
8815 | json_object *bestpath = json_object_new_object(); | |
8816 | ||
892fedb6 | 8817 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
8818 | json_object_string_add(bestpath, "asPath", "ignore"); |
8819 | ||
892fedb6 | 8820 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
8821 | json_object_string_add(bestpath, "asPath", "confed"); |
8822 | ||
892fedb6 DA |
8823 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
8824 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 8825 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8826 | "as-set"); |
8827 | else | |
a4d82a8a | 8828 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8829 | "true"); |
8830 | } else | |
a4d82a8a | 8831 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 8832 | |
892fedb6 | 8833 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 8834 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
8835 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
8836 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8837 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8838 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 8839 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
8840 | json_object_string_add(bestpath, "med", |
8841 | "missing-as-worst"); | |
8842 | else | |
8843 | json_object_string_add(bestpath, "med", "true"); | |
8844 | } | |
8845 | ||
8846 | json_object_object_add(json, "bestPath", bestpath); | |
8847 | } | |
8848 | ||
3577f1c5 DD |
8849 | /* Print the error code/subcode for why the peer is down */ |
8850 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8851 | json_object *json_peer, bool use_json) | |
8852 | { | |
8853 | const char *code_str; | |
8854 | const char *subcode_str; | |
8855 | ||
8856 | if (use_json) { | |
8857 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8858 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8859 | char errorcodesubcode_hexstr[5]; | |
8860 | char errorcodesubcode_str[256]; | |
8861 | ||
8862 | code_str = bgp_notify_code_str(peer->notify.code); | |
8863 | subcode_str = bgp_notify_subcode_str( | |
8864 | peer->notify.code, | |
8865 | peer->notify.subcode); | |
8866 | ||
772270f3 QY |
8867 | snprintf(errorcodesubcode_hexstr, |
8868 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
8869 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
8870 | json_object_string_add(json_peer, |
8871 | "lastErrorCodeSubcode", | |
8872 | errorcodesubcode_hexstr); | |
8873 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8874 | code_str, subcode_str); | |
8875 | json_object_string_add(json_peer, | |
8876 | "lastNotificationReason", | |
8877 | errorcodesubcode_str); | |
8878 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8879 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8880 | && (peer->notify.subcode | |
8881 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8882 | || peer->notify.subcode | |
8883 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8884 | && peer->notify.length) { | |
8885 | char msgbuf[1024]; | |
8886 | const char *msg_str; | |
8887 | ||
8888 | msg_str = bgp_notify_admin_message( | |
8889 | msgbuf, sizeof(msgbuf), | |
8890 | (uint8_t *)peer->notify.data, | |
8891 | peer->notify.length); | |
8892 | if (msg_str) | |
8893 | json_object_string_add( | |
8894 | json_peer, | |
8895 | "lastShutdownDescription", | |
8896 | msg_str); | |
8897 | } | |
8898 | ||
c258527b | 8899 | } |
3577f1c5 DD |
8900 | json_object_string_add(json_peer, "lastResetDueTo", |
8901 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8902 | json_object_int_add(json_peer, "lastResetCode", |
8903 | peer->last_reset); | |
3577f1c5 DD |
8904 | } else { |
8905 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8906 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8907 | code_str = bgp_notify_code_str(peer->notify.code); | |
8908 | subcode_str = | |
8909 | bgp_notify_subcode_str(peer->notify.code, | |
8910 | peer->notify.subcode); | |
8911 | vty_out(vty, " Notification %s (%s%s)\n", | |
8912 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8913 | ? "sent" | |
8914 | : "received", | |
8915 | code_str, subcode_str); | |
8916 | } else { | |
e91c24c8 | 8917 | vty_out(vty, " %s\n", |
3577f1c5 DD |
8918 | peer_down_str[(int)peer->last_reset]); |
8919 | } | |
8920 | } | |
8921 | } | |
8922 | ||
8923 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8924 | safi_t safi) | |
8925 | { | |
8926 | return ((peer->status != Established) || | |
8927 | !peer->afc_recv[afi][safi]); | |
8928 | } | |
8929 | ||
8930 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8931 | struct peer *peer, json_object *json_peer, | |
8932 | int max_neighbor_width, bool use_json) | |
8933 | { | |
8934 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8935 | int len; | |
8936 | ||
8937 | if (use_json) { | |
8938 | if (peer_dynamic_neighbor(peer)) | |
8939 | json_object_boolean_true_add(json_peer, | |
8940 | "dynamicPeer"); | |
8941 | if (peer->hostname) | |
8942 | json_object_string_add(json_peer, "hostname", | |
8943 | peer->hostname); | |
8944 | ||
8945 | if (peer->domainname) | |
8946 | json_object_string_add(json_peer, "domainname", | |
8947 | peer->domainname); | |
8948 | json_object_int_add(json_peer, "connectionsEstablished", | |
8949 | peer->established); | |
8950 | json_object_int_add(json_peer, "connectionsDropped", | |
8951 | peer->dropped); | |
8952 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8953 | use_json, json_peer); | |
8954 | if (peer->status == Established) | |
8955 | json_object_string_add(json_peer, "lastResetDueTo", | |
8956 | "AFI/SAFI Not Negotiated"); | |
8957 | else | |
8958 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8959 | } else { | |
8960 | dn_flag[1] = '\0'; | |
8961 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8962 | if (peer->hostname | |
892fedb6 | 8963 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
8964 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
8965 | peer->hostname, peer->host); | |
8966 | else | |
8967 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8968 | ||
8969 | /* pad the neighbor column with spaces */ | |
8970 | if (len < max_neighbor_width) | |
8971 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8972 | " "); | |
e91c24c8 | 8973 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
8974 | peer->dropped, |
8975 | peer_uptime(peer->uptime, timebuf, | |
8976 | BGP_UPTIME_LEN, 0, NULL)); | |
8977 | if (peer->status == Established) | |
8978 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8979 | else | |
8980 | bgp_show_peer_reset(vty, peer, NULL, | |
8981 | false); | |
8982 | } | |
8983 | } | |
c258527b | 8984 | |
3577f1c5 | 8985 | |
718e3744 | 8986 | /* Show BGP peer's summary information. */ |
d62a17ae | 8987 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
10b49f14 DA |
8988 | bool show_failed, bool show_established, |
8989 | bool use_json) | |
d62a17ae | 8990 | { |
8991 | struct peer *peer; | |
8992 | struct listnode *node, *nnode; | |
8993 | unsigned int count = 0, dn_count = 0; | |
8994 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8995 | char neighbor_buf[VTY_BUFSIZ]; | |
8996 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8997 | int len, failed_count = 0; |
d62a17ae | 8998 | int max_neighbor_width = 0; |
8999 | int pfx_rcd_safi; | |
3c13337d | 9000 | json_object *json = NULL; |
d62a17ae | 9001 | json_object *json_peer = NULL; |
9002 | json_object *json_peers = NULL; | |
50e05855 | 9003 | struct peer_af *paf; |
d3ada366 | 9004 | struct bgp_filter *filter; |
d62a17ae | 9005 | |
9006 | /* labeled-unicast routes are installed in the unicast table so in order | |
9007 | * to | |
9008 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
9009 | */ | |
3577f1c5 | 9010 | |
d62a17ae | 9011 | if (safi == SAFI_LABELED_UNICAST) |
9012 | pfx_rcd_safi = SAFI_UNICAST; | |
9013 | else | |
9014 | pfx_rcd_safi = safi; | |
9015 | ||
9016 | if (use_json) { | |
3c13337d | 9017 | json = json_object_new_object(); |
d62a17ae | 9018 | json_peers = json_object_new_object(); |
3577f1c5 DD |
9019 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
9020 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9021 | continue; | |
9022 | ||
9023 | if (peer->afc[afi][safi]) { | |
9024 | /* See if we have at least a single failed peer */ | |
9025 | if (bgp_has_peer_failed(peer, afi, safi)) | |
9026 | failed_count++; | |
9027 | count++; | |
9028 | } | |
9029 | if (peer_dynamic_neighbor(peer)) | |
9030 | dn_count++; | |
9031 | } | |
c258527b | 9032 | |
d62a17ae | 9033 | } else { |
9034 | /* Loop over all neighbors that will be displayed to determine | |
9035 | * how many | |
9036 | * characters are needed for the Neighbor column | |
9037 | */ | |
9038 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
9039 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9040 | continue; | |
9041 | ||
9042 | if (peer->afc[afi][safi]) { | |
9043 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9044 | if (peer_dynamic_neighbor(peer)) | |
9045 | dn_flag[0] = '*'; | |
9046 | ||
9047 | if (peer->hostname | |
892fedb6 DA |
9048 | && CHECK_FLAG(bgp->flags, |
9049 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
9050 | snprintf(neighbor_buf, |
9051 | sizeof(neighbor_buf), | |
9052 | "%s%s(%s) ", dn_flag, | |
9053 | peer->hostname, peer->host); | |
d62a17ae | 9054 | else |
772270f3 QY |
9055 | snprintf(neighbor_buf, |
9056 | sizeof(neighbor_buf), "%s%s ", | |
9057 | dn_flag, peer->host); | |
d62a17ae | 9058 | |
9059 | len = strlen(neighbor_buf); | |
9060 | ||
9061 | if (len > max_neighbor_width) | |
9062 | max_neighbor_width = len; | |
c258527b | 9063 | |
3577f1c5 DD |
9064 | /* See if we have at least a single failed peer */ |
9065 | if (bgp_has_peer_failed(peer, afi, safi)) | |
9066 | failed_count++; | |
9067 | count++; | |
d62a17ae | 9068 | } |
9069 | } | |
f933309e | 9070 | |
d62a17ae | 9071 | /* Originally we displayed the Neighbor column as 16 |
9072 | * characters wide so make that the default | |
9073 | */ | |
9074 | if (max_neighbor_width < neighbor_col_default_width) | |
9075 | max_neighbor_width = neighbor_col_default_width; | |
9076 | } | |
f933309e | 9077 | |
3577f1c5 DD |
9078 | if (show_failed && !failed_count) { |
9079 | if (use_json) { | |
9080 | json_object_int_add(json, "failedPeersCount", 0); | |
9081 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 9082 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
9083 | |
9084 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
9085 | json, JSON_C_TO_STRING_PRETTY)); | |
9086 | json_object_free(json); | |
9087 | } else { | |
9088 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
9089 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9090 | } | |
9091 | return CMD_SUCCESS; | |
9092 | } | |
c258527b | 9093 | |
3577f1c5 | 9094 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 9095 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
9096 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9097 | continue; | |
9098 | ||
ea47320b DL |
9099 | if (!peer->afc[afi][safi]) |
9100 | continue; | |
d62a17ae | 9101 | |
ea47320b DL |
9102 | if (!count) { |
9103 | unsigned long ents; | |
9104 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 9105 | int64_t vrf_id_ui; |
d62a17ae | 9106 | |
a4d82a8a PZ |
9107 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9108 | ? -1 | |
9109 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
9110 | |
9111 | /* Usage summary and header */ | |
9112 | if (use_json) { | |
9113 | json_object_string_add( | |
9114 | json, "routerId", | |
9115 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
9116 | json_object_int_add(json, "as", bgp->as); |
9117 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
9118 | json_object_string_add( |
9119 | json, "vrfName", | |
9120 | (bgp->inst_type | |
9121 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9122 | ? VRF_DEFAULT_NAME |
ea47320b DL |
9123 | : bgp->name); |
9124 | } else { | |
9125 | vty_out(vty, | |
9126 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 9127 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
9128 | bgp->vrf_id == VRF_UNKNOWN |
9129 | ? -1 | |
9130 | : (int)bgp->vrf_id); | |
ea47320b DL |
9131 | vty_out(vty, "\n"); |
9132 | } | |
d62a17ae | 9133 | |
ea47320b | 9134 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 9135 | if (use_json) { |
ea47320b | 9136 | json_object_int_add( |
60466a63 | 9137 | json, "updateDelayLimit", |
ea47320b | 9138 | bgp->v_update_delay); |
d62a17ae | 9139 | |
ea47320b DL |
9140 | if (bgp->v_update_delay |
9141 | != bgp->v_establish_wait) | |
d62a17ae | 9142 | json_object_int_add( |
9143 | json, | |
ea47320b DL |
9144 | "updateDelayEstablishWait", |
9145 | bgp->v_establish_wait); | |
d62a17ae | 9146 | |
60466a63 | 9147 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9148 | json_object_string_add( |
9149 | json, | |
9150 | "updateDelayFirstNeighbor", | |
9151 | bgp->update_delay_begin_time); | |
9152 | json_object_boolean_true_add( | |
9153 | json, | |
9154 | "updateDelayInProgress"); | |
9155 | } else { | |
9156 | if (bgp->update_delay_over) { | |
d62a17ae | 9157 | json_object_string_add( |
9158 | json, | |
9159 | "updateDelayFirstNeighbor", | |
9160 | bgp->update_delay_begin_time); | |
ea47320b | 9161 | json_object_string_add( |
d62a17ae | 9162 | json, |
ea47320b DL |
9163 | "updateDelayBestpathResumed", |
9164 | bgp->update_delay_end_time); | |
9165 | json_object_string_add( | |
d62a17ae | 9166 | json, |
ea47320b DL |
9167 | "updateDelayZebraUpdateResume", |
9168 | bgp->update_delay_zebra_resume_time); | |
9169 | json_object_string_add( | |
9170 | json, | |
9171 | "updateDelayPeerUpdateResume", | |
9172 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9173 | } |
ea47320b DL |
9174 | } |
9175 | } else { | |
9176 | vty_out(vty, | |
9177 | "Read-only mode update-delay limit: %d seconds\n", | |
9178 | bgp->v_update_delay); | |
9179 | if (bgp->v_update_delay | |
9180 | != bgp->v_establish_wait) | |
d62a17ae | 9181 | vty_out(vty, |
ea47320b DL |
9182 | " Establish wait: %d seconds\n", |
9183 | bgp->v_establish_wait); | |
d62a17ae | 9184 | |
60466a63 | 9185 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9186 | vty_out(vty, |
9187 | " First neighbor established: %s\n", | |
9188 | bgp->update_delay_begin_time); | |
9189 | vty_out(vty, | |
9190 | " Delay in progress\n"); | |
9191 | } else { | |
9192 | if (bgp->update_delay_over) { | |
d62a17ae | 9193 | vty_out(vty, |
9194 | " First neighbor established: %s\n", | |
9195 | bgp->update_delay_begin_time); | |
9196 | vty_out(vty, | |
ea47320b DL |
9197 | " Best-paths resumed: %s\n", |
9198 | bgp->update_delay_end_time); | |
9199 | vty_out(vty, | |
9200 | " zebra update resumed: %s\n", | |
9201 | bgp->update_delay_zebra_resume_time); | |
9202 | vty_out(vty, | |
9203 | " peers update resumed: %s\n", | |
9204 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9205 | } |
9206 | } | |
9207 | } | |
ea47320b | 9208 | } |
d62a17ae | 9209 | |
ea47320b DL |
9210 | if (use_json) { |
9211 | if (bgp_maxmed_onstartup_configured(bgp) | |
9212 | && bgp->maxmed_active) | |
9213 | json_object_boolean_true_add( | |
60466a63 | 9214 | json, "maxMedOnStartup"); |
ea47320b DL |
9215 | if (bgp->v_maxmed_admin) |
9216 | json_object_boolean_true_add( | |
60466a63 | 9217 | json, "maxMedAdministrative"); |
d62a17ae | 9218 | |
ea47320b DL |
9219 | json_object_int_add( |
9220 | json, "tableVersion", | |
60466a63 | 9221 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 9222 | |
60466a63 QY |
9223 | ents = bgp_table_count(bgp->rib[afi][safi]); |
9224 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
9225 | json_object_int_add( |
9226 | json, "ribMemory", | |
9bcb3eef | 9227 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 9228 | |
210ec2a0 | 9229 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
9230 | json_object_int_add(json, "peerCount", ents); |
9231 | json_object_int_add(json, "peerMemory", | |
9232 | ents * sizeof(struct peer)); | |
d62a17ae | 9233 | |
ea47320b DL |
9234 | if ((ents = listcount(bgp->group))) { |
9235 | json_object_int_add( | |
60466a63 | 9236 | json, "peerGroupCount", ents); |
ea47320b DL |
9237 | json_object_int_add( |
9238 | json, "peerGroupMemory", | |
996c9314 LB |
9239 | ents * sizeof(struct |
9240 | peer_group)); | |
ea47320b | 9241 | } |
d62a17ae | 9242 | |
ea47320b DL |
9243 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9244 | BGP_CONFIG_DAMPENING)) | |
9245 | json_object_boolean_true_add( | |
60466a63 | 9246 | json, "dampeningEnabled"); |
ea47320b DL |
9247 | } else { |
9248 | if (bgp_maxmed_onstartup_configured(bgp) | |
9249 | && bgp->maxmed_active) | |
d62a17ae | 9250 | vty_out(vty, |
ea47320b DL |
9251 | "Max-med on-startup active\n"); |
9252 | if (bgp->v_maxmed_admin) | |
d62a17ae | 9253 | vty_out(vty, |
ea47320b | 9254 | "Max-med administrative active\n"); |
d62a17ae | 9255 | |
60466a63 QY |
9256 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
9257 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 9258 | |
60466a63 | 9259 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
9260 | vty_out(vty, |
9261 | "RIB entries %ld, using %s of memory\n", | |
9262 | ents, | |
9bcb3eef DS |
9263 | mtype_memstr( |
9264 | memstrbuf, sizeof(memstrbuf), | |
9265 | ents | |
9266 | * sizeof(struct | |
9267 | bgp_dest))); | |
ea47320b DL |
9268 | |
9269 | /* Peer related usage */ | |
210ec2a0 | 9270 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 9271 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
9272 | ents, |
9273 | mtype_memstr( | |
60466a63 QY |
9274 | memstrbuf, sizeof(memstrbuf), |
9275 | ents * sizeof(struct peer))); | |
ea47320b DL |
9276 | |
9277 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 9278 | vty_out(vty, |
ea47320b | 9279 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 9280 | ents, |
9281 | mtype_memstr( | |
9282 | memstrbuf, | |
9283 | sizeof(memstrbuf), | |
996c9314 LB |
9284 | ents * sizeof(struct |
9285 | peer_group))); | |
d62a17ae | 9286 | |
ea47320b DL |
9287 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9288 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 9289 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 9290 | vty_out(vty, "\n"); |
d62a17ae | 9291 | |
ea47320b DL |
9292 | /* Subtract 8 here because 'Neighbor' is |
9293 | * 8 characters */ | |
9294 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
9295 | vty_out(vty, "%*s", max_neighbor_width - 8, |
9296 | " "); | |
3577f1c5 DD |
9297 | if (show_failed) |
9298 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
9299 | else | |
9300 | vty_out(vty, | |
db92d226 | 9301 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n"); |
d62a17ae | 9302 | } |
ea47320b | 9303 | } |
d62a17ae | 9304 | |
d55811cc | 9305 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 9306 | filter = &peer->filter[afi][safi]; |
db92d226 | 9307 | |
ea47320b | 9308 | count++; |
3577f1c5 DD |
9309 | /* Works for both failed & successful cases */ |
9310 | if (peer_dynamic_neighbor(peer)) | |
9311 | dn_count++; | |
d62a17ae | 9312 | |
ea47320b | 9313 | if (use_json) { |
3577f1c5 DD |
9314 | json_peer = NULL; |
9315 | ||
9316 | if (show_failed && | |
9317 | bgp_has_peer_failed(peer, afi, safi)) { | |
9318 | json_peer = json_object_new_object(); | |
9319 | bgp_show_failed_summary(vty, bgp, peer, | |
9320 | json_peer, 0, use_json); | |
9321 | } else if (!show_failed) { | |
10b49f14 DA |
9322 | if (show_established |
9323 | && bgp_has_peer_failed(peer, afi, safi)) | |
9324 | continue; | |
9325 | ||
3577f1c5 DD |
9326 | json_peer = json_object_new_object(); |
9327 | if (peer_dynamic_neighbor(peer)) { | |
9328 | json_object_boolean_true_add(json_peer, | |
9329 | "dynamicPeer"); | |
9330 | } | |
d62a17ae | 9331 | |
3577f1c5 DD |
9332 | if (peer->hostname) |
9333 | json_object_string_add(json_peer, "hostname", | |
9334 | peer->hostname); | |
9335 | ||
9336 | if (peer->domainname) | |
9337 | json_object_string_add(json_peer, "domainname", | |
9338 | peer->domainname); | |
9339 | ||
9340 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9341 | json_object_int_add(json_peer, "version", 4); | |
9342 | json_object_int_add(json_peer, "msgRcvd", | |
9343 | PEER_TOTAL_RX(peer)); | |
9344 | json_object_int_add(json_peer, "msgSent", | |
9345 | PEER_TOTAL_TX(peer)); | |
9346 | ||
43aa5965 QY |
9347 | atomic_size_t outq_count, inq_count; |
9348 | outq_count = atomic_load_explicit( | |
9349 | &peer->obuf->count, | |
9350 | memory_order_relaxed); | |
9351 | inq_count = atomic_load_explicit( | |
9352 | &peer->ibuf->count, | |
9353 | memory_order_relaxed); | |
9354 | ||
3577f1c5 DD |
9355 | json_object_int_add(json_peer, "tableVersion", |
9356 | peer->version[afi][safi]); | |
9357 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
9358 | outq_count); |
9359 | json_object_int_add(json_peer, "inq", | |
9360 | inq_count); | |
3577f1c5 DD |
9361 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
9362 | use_json, json_peer); | |
9363 | ||
3577f1c5 DD |
9364 | json_object_int_add(json_peer, "pfxRcd", |
9365 | peer->pcount[afi][pfx_rcd_safi]); | |
9366 | ||
3577f1c5 DD |
9367 | if (paf && PAF_SUBGRP(paf)) |
9368 | json_object_int_add(json_peer, | |
9369 | "pfxSnt", | |
9370 | (PAF_SUBGRP(paf))->scount); | |
cb9196e7 DS |
9371 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
9372 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
9373 | json_object_string_add(json_peer, "state", |
9374 | "Idle (Admin)"); | |
9375 | else if (peer->afc_recv[afi][safi]) | |
9376 | json_object_string_add( | |
9377 | json_peer, "state", | |
9378 | lookup_msg(bgp_status_msg, peer->status, | |
9379 | NULL)); | |
9380 | else if (CHECK_FLAG(peer->sflags, | |
9381 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9382 | json_object_string_add(json_peer, "state", | |
9383 | "Idle (PfxCt)"); | |
9384 | else | |
9385 | json_object_string_add( | |
9386 | json_peer, "state", | |
9387 | lookup_msg(bgp_status_msg, peer->status, | |
9388 | NULL)); | |
200116db DD |
9389 | json_object_int_add(json_peer, "connectionsEstablished", |
9390 | peer->established); | |
9391 | json_object_int_add(json_peer, "connectionsDropped", | |
9392 | peer->dropped); | |
b4e9dcba | 9393 | } |
3577f1c5 DD |
9394 | /* Avoid creating empty peer dicts in JSON */ |
9395 | if (json_peer == NULL) | |
9396 | continue; | |
ea47320b DL |
9397 | |
9398 | if (peer->conf_if) | |
60466a63 | 9399 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9400 | "interface"); |
9401 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9402 | json_object_string_add(json_peer, "idType", |
9403 | "ipv4"); | |
ea47320b | 9404 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9405 | json_object_string_add(json_peer, "idType", |
9406 | "ipv6"); | |
ea47320b DL |
9407 | json_object_object_add(json_peers, peer->host, |
9408 | json_peer); | |
9409 | } else { | |
3577f1c5 DD |
9410 | if (show_failed && |
9411 | bgp_has_peer_failed(peer, afi, safi)) { | |
9412 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9413 | max_neighbor_width, | |
9414 | use_json); | |
9415 | } else if (!show_failed) { | |
10b49f14 DA |
9416 | if (show_established |
9417 | && bgp_has_peer_failed(peer, afi, safi)) | |
9418 | continue; | |
9419 | ||
3577f1c5 DD |
9420 | memset(dn_flag, '\0', sizeof(dn_flag)); |
9421 | if (peer_dynamic_neighbor(peer)) { | |
9422 | dn_flag[0] = '*'; | |
9423 | } | |
d62a17ae | 9424 | |
3577f1c5 | 9425 | if (peer->hostname |
892fedb6 DA |
9426 | && CHECK_FLAG(bgp->flags, |
9427 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 9428 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
9429 | peer->hostname, |
9430 | peer->host); | |
d62a17ae | 9431 | else |
3577f1c5 DD |
9432 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
9433 | ||
9434 | /* pad the neighbor column with spaces */ | |
9435 | if (len < max_neighbor_width) | |
9436 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9437 | " "); | |
9438 | ||
43aa5965 QY |
9439 | atomic_size_t outq_count, inq_count; |
9440 | outq_count = atomic_load_explicit( | |
9441 | &peer->obuf->count, | |
9442 | memory_order_relaxed); | |
9443 | inq_count = atomic_load_explicit( | |
9444 | &peer->ibuf->count, | |
9445 | memory_order_relaxed); | |
9446 | ||
566bdaf6 | 9447 | vty_out(vty, |
6cde4b45 | 9448 | "4 %10u %9u %9u %8" PRIu64" %4zu %4zu %8s", |
3577f1c5 | 9449 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 9450 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
9451 | peer->version[afi][safi], inq_count, |
9452 | outq_count, | |
3577f1c5 DD |
9453 | peer_uptime(peer->uptime, timebuf, |
9454 | BGP_UPTIME_LEN, 0, NULL)); | |
9455 | ||
db92d226 | 9456 | if (peer->status == Established) { |
d3ada366 DA |
9457 | if (peer->afc_recv[afi][safi]) { |
9458 | if (CHECK_FLAG( | |
9459 | bgp->flags, | |
9460 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
9461 | && !bgp_inbound_policy_exists( | |
9462 | peer, filter)) | |
9463 | vty_out(vty, " %12s", | |
9464 | "(Policy)"); | |
9465 | else | |
9466 | vty_out(vty, | |
6cde4b45 | 9467 | " %12u", |
d3ada366 DA |
9468 | peer->pcount |
9469 | [afi] | |
9470 | [pfx_rcd_safi]); | |
9471 | } else { | |
3577f1c5 | 9472 | vty_out(vty, " NoNeg"); |
d3ada366 | 9473 | } |
db92d226 | 9474 | |
d3ada366 DA |
9475 | if (paf && PAF_SUBGRP(paf)) { |
9476 | if (CHECK_FLAG( | |
9477 | bgp->flags, | |
9478 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
9479 | && !bgp_outbound_policy_exists( | |
9480 | peer, filter)) | |
9481 | vty_out(vty, " %8s", | |
9482 | "(Policy)"); | |
9483 | else | |
9484 | vty_out(vty, | |
6cde4b45 | 9485 | " %8u", |
d3ada366 DA |
9486 | (PAF_SUBGRP( |
9487 | paf)) | |
9488 | ->scount); | |
9489 | } | |
db92d226 | 9490 | } else { |
cb9196e7 DS |
9491 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
9492 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
9493 | vty_out(vty, " Idle (Admin)"); |
9494 | else if (CHECK_FLAG( | |
9495 | peer->sflags, | |
9496 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9497 | vty_out(vty, " Idle (PfxCt)"); | |
9498 | else | |
9499 | vty_out(vty, " %12s", | |
9500 | lookup_msg(bgp_status_msg, | |
9501 | peer->status, NULL)); | |
db92d226 | 9502 | |
6cde4b45 | 9503 | vty_out(vty, " %8u", 0); |
3577f1c5 DD |
9504 | } |
9505 | vty_out(vty, "\n"); | |
d62a17ae | 9506 | } |
3577f1c5 | 9507 | |
d62a17ae | 9508 | } |
9509 | } | |
f933309e | 9510 | |
d62a17ae | 9511 | if (use_json) { |
9512 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9513 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9514 | json_object_int_add(json, "totalPeers", count); |
9515 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9516 | ||
3577f1c5 DD |
9517 | if (!show_failed) |
9518 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9519 | |
996c9314 LB |
9520 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9521 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9522 | json_object_free(json); |
9523 | } else { | |
9524 | if (count) | |
9525 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9526 | else { | |
d6ceaca3 | 9527 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9528 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9529 | } |
b05a1c8b | 9530 | |
d6ceaca3 | 9531 | if (dn_count) { |
d62a17ae | 9532 | vty_out(vty, "* - dynamic neighbor\n"); |
9533 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9534 | dn_count, bgp->dynamic_neighbors_limit); | |
9535 | } | |
9536 | } | |
1ff9a340 | 9537 | |
d62a17ae | 9538 | return CMD_SUCCESS; |
718e3744 | 9539 | } |
9540 | ||
d62a17ae | 9541 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
10b49f14 DA |
9542 | int safi, bool show_failed, |
9543 | bool show_established, bool use_json) | |
d62a17ae | 9544 | { |
9545 | int is_first = 1; | |
9546 | int afi_wildcard = (afi == AFI_MAX); | |
9547 | int safi_wildcard = (safi == SAFI_MAX); | |
9548 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9549 | bool nbr_output = false; |
d62a17ae | 9550 | |
9551 | if (use_json && is_wildcard) | |
9552 | vty_out(vty, "{\n"); | |
9553 | if (afi_wildcard) | |
9554 | afi = 1; /* AFI_IP */ | |
9555 | while (afi < AFI_MAX) { | |
9556 | if (safi_wildcard) | |
9557 | safi = 1; /* SAFI_UNICAST */ | |
9558 | while (safi < SAFI_MAX) { | |
318cac96 | 9559 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9560 | nbr_output = true; |
f86897b9 | 9561 | |
d62a17ae | 9562 | if (is_wildcard) { |
9563 | /* | |
9564 | * So limit output to those afi/safi | |
9565 | * pairs that | |
9566 | * actualy have something interesting in | |
9567 | * them | |
9568 | */ | |
9569 | if (use_json) { | |
d62a17ae | 9570 | if (!is_first) |
9571 | vty_out(vty, ",\n"); | |
9572 | else | |
9573 | is_first = 0; | |
9574 | ||
9575 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9576 | get_afi_safi_str(afi, |
9577 | safi, | |
9578 | true)); | |
d62a17ae | 9579 | } else { |
9580 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9581 | get_afi_safi_str(afi, |
9582 | safi, | |
9583 | false)); | |
d62a17ae | 9584 | } |
9585 | } | |
10b49f14 DA |
9586 | bgp_show_summary(vty, bgp, afi, safi, |
9587 | show_failed, show_established, | |
3577f1c5 | 9588 | use_json); |
d62a17ae | 9589 | } |
9590 | safi++; | |
d62a17ae | 9591 | if (!safi_wildcard) |
9592 | safi = SAFI_MAX; | |
9593 | } | |
9594 | afi++; | |
ee851c8c | 9595 | if (!afi_wildcard) |
d62a17ae | 9596 | afi = AFI_MAX; |
9597 | } | |
9598 | ||
9599 | if (use_json && is_wildcard) | |
9600 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9601 | else if (!nbr_output) { |
9602 | if (use_json) | |
9603 | vty_out(vty, "{}\n"); | |
9604 | else | |
9605 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9606 | } | |
d62a17ae | 9607 | } |
9608 | ||
9609 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 | 9610 | safi_t safi, bool show_failed, |
10b49f14 | 9611 | bool show_established, |
3577f1c5 | 9612 | bool use_json) |
d62a17ae | 9613 | { |
9614 | struct listnode *node, *nnode; | |
9615 | struct bgp *bgp; | |
d62a17ae | 9616 | int is_first = 1; |
9f049418 | 9617 | bool nbr_output = false; |
d62a17ae | 9618 | |
9619 | if (use_json) | |
9620 | vty_out(vty, "{\n"); | |
9621 | ||
9622 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9623 | nbr_output = true; |
d62a17ae | 9624 | if (use_json) { |
d62a17ae | 9625 | if (!is_first) |
9626 | vty_out(vty, ",\n"); | |
9627 | else | |
9628 | is_first = 0; | |
9629 | ||
9630 | vty_out(vty, "\"%s\":", | |
9631 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9632 | ? VRF_DEFAULT_NAME |
d62a17ae | 9633 | : bgp->name); |
9634 | } else { | |
9635 | vty_out(vty, "\nInstance %s:\n", | |
9636 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9637 | ? VRF_DEFAULT_NAME |
d62a17ae | 9638 | : bgp->name); |
9639 | } | |
3577f1c5 | 9640 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 9641 | show_established, use_json); |
d62a17ae | 9642 | } |
9643 | ||
9644 | if (use_json) | |
9645 | vty_out(vty, "}\n"); | |
9f049418 DS |
9646 | else if (!nbr_output) |
9647 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9648 | } |
9649 | ||
9650 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
10b49f14 DA |
9651 | safi_t safi, bool show_failed, bool show_established, |
9652 | bool use_json) | |
d62a17ae | 9653 | { |
9654 | struct bgp *bgp; | |
9655 | ||
9656 | if (name) { | |
9657 | if (strmatch(name, "all")) { | |
10b49f14 DA |
9658 | bgp_show_all_instances_summary_vty( |
9659 | vty, afi, safi, show_failed, show_established, | |
9660 | use_json); | |
d62a17ae | 9661 | return CMD_SUCCESS; |
9662 | } else { | |
9663 | bgp = bgp_lookup_by_name(name); | |
9664 | ||
9665 | if (!bgp) { | |
9666 | if (use_json) | |
9667 | vty_out(vty, "{}\n"); | |
9668 | else | |
9669 | vty_out(vty, | |
ca61fd25 | 9670 | "%% BGP instance not found\n"); |
d62a17ae | 9671 | return CMD_WARNING; |
9672 | } | |
9673 | ||
f86897b9 | 9674 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
10b49f14 DA |
9675 | show_failed, show_established, |
9676 | use_json); | |
d62a17ae | 9677 | return CMD_SUCCESS; |
9678 | } | |
9679 | } | |
9680 | ||
9681 | bgp = bgp_get_default(); | |
9682 | ||
9683 | if (bgp) | |
3577f1c5 | 9684 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 9685 | show_established, use_json); |
9f049418 | 9686 | else { |
ca61fd25 DS |
9687 | if (use_json) |
9688 | vty_out(vty, "{}\n"); | |
9689 | else | |
9690 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9691 | return CMD_WARNING; |
9692 | } | |
d62a17ae | 9693 | |
9694 | return CMD_SUCCESS; | |
4fb25c53 DW |
9695 | } |
9696 | ||
716b2d8a | 9697 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9698 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9699 | show_ip_bgp_summary_cmd, |
10b49f14 | 9700 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [established|failed] [json]", |
718e3744 | 9701 | SHOW_STR |
9702 | IP_STR | |
9703 | BGP_STR | |
8386ac43 | 9704 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9705 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9706 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9707 | "Summary of BGP neighbor status\n" |
10b49f14 | 9708 | "Show only sessions in Established state\n" |
3577f1c5 | 9709 | "Show only sessions not in Established state\n" |
9973d184 | 9710 | JSON_STR) |
718e3744 | 9711 | { |
d62a17ae | 9712 | char *vrf = NULL; |
9713 | afi_t afi = AFI_MAX; | |
9714 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9715 | bool show_failed = false; |
10b49f14 | 9716 | bool show_established = false; |
d62a17ae | 9717 | |
9718 | int idx = 0; | |
9719 | ||
9720 | /* show [ip] bgp */ | |
9721 | if (argv_find(argv, argc, "ip", &idx)) | |
9722 | afi = AFI_IP; | |
9a8bdf1c PG |
9723 | /* [<vrf> VIEWVRFNAME] */ |
9724 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9725 | vrf = argv[idx + 1]->arg; | |
9726 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9727 | vrf = NULL; | |
9728 | } else if (argv_find(argv, argc, "view", &idx)) | |
9729 | /* [<view> VIEWVRFNAME] */ | |
9730 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9731 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9732 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9733 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9734 | } | |
9735 | ||
3577f1c5 DD |
9736 | if (argv_find(argv, argc, "failed", &idx)) |
9737 | show_failed = true; | |
10b49f14 DA |
9738 | if (argv_find(argv, argc, "established", &idx)) |
9739 | show_established = true; | |
3577f1c5 | 9740 | |
9f049418 | 9741 | bool uj = use_json(argc, argv); |
d62a17ae | 9742 | |
10b49f14 DA |
9743 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, |
9744 | show_established, uj); | |
d62a17ae | 9745 | } |
9746 | ||
5cb5f4d0 | 9747 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9748 | { |
5cb5f4d0 DD |
9749 | if (for_json) |
9750 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9751 | else |
5cb5f4d0 | 9752 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9753 | } |
9754 | ||
d62a17ae | 9755 | |
9756 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9757 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9758 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9759 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9760 | bool use_json, json_object *json_pref) |
d62a17ae | 9761 | { |
9762 | /* Send-Mode */ | |
9763 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9764 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9765 | if (use_json) { | |
9766 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9767 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9768 | json_object_string_add(json_pref, "sendMode", | |
9769 | "advertisedAndReceived"); | |
9770 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9771 | json_object_string_add(json_pref, "sendMode", | |
9772 | "advertised"); | |
9773 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9774 | json_object_string_add(json_pref, "sendMode", | |
9775 | "received"); | |
9776 | } else { | |
9777 | vty_out(vty, " Send-mode: "); | |
9778 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9779 | vty_out(vty, "advertised"); | |
9780 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9781 | vty_out(vty, "%sreceived", | |
9782 | CHECK_FLAG(p->af_cap[afi][safi], | |
9783 | adv_smcap) | |
9784 | ? ", " | |
9785 | : ""); | |
9786 | vty_out(vty, "\n"); | |
9787 | } | |
9788 | } | |
9789 | ||
9790 | /* Receive-Mode */ | |
9791 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9792 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9793 | if (use_json) { | |
9794 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9795 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9796 | json_object_string_add(json_pref, "recvMode", | |
9797 | "advertisedAndReceived"); | |
9798 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9799 | json_object_string_add(json_pref, "recvMode", | |
9800 | "advertised"); | |
9801 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9802 | json_object_string_add(json_pref, "recvMode", | |
9803 | "received"); | |
9804 | } else { | |
9805 | vty_out(vty, " Receive-mode: "); | |
9806 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9807 | vty_out(vty, "advertised"); | |
9808 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9809 | vty_out(vty, "%sreceived", | |
9810 | CHECK_FLAG(p->af_cap[afi][safi], | |
9811 | adv_rmcap) | |
9812 | ? ", " | |
9813 | : ""); | |
9814 | vty_out(vty, "\n"); | |
9815 | } | |
9816 | } | |
9817 | } | |
9818 | ||
13909c4f DS |
9819 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
9820 | struct peer *p, | |
9821 | bool use_json, | |
9822 | json_object *json) | |
2986cac2 | 9823 | { |
08c2d52a | 9824 | bool rbit_status = false; |
2986cac2 | 9825 | |
9826 | if (!use_json) | |
a53ca37b | 9827 | vty_out(vty, "\n R bit: "); |
2986cac2 | 9828 | |
13909c4f DS |
9829 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
9830 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
9831 | && (p->status == Established)) { | |
2986cac2 | 9832 | |
9833 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 9834 | rbit_status = true; |
2986cac2 | 9835 | else |
08c2d52a | 9836 | rbit_status = false; |
2986cac2 | 9837 | } |
9838 | ||
9839 | if (rbit_status) { | |
9840 | if (use_json) | |
13909c4f | 9841 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 9842 | else |
9843 | vty_out(vty, "True\n"); | |
9844 | } else { | |
9845 | if (use_json) | |
13909c4f | 9846 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 9847 | else |
9848 | vty_out(vty, "False\n"); | |
9849 | } | |
9850 | } | |
9851 | ||
13909c4f DS |
9852 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
9853 | struct peer *peer, | |
9854 | bool use_json, | |
9855 | json_object *json) | |
2986cac2 | 9856 | { |
2bb5d39b | 9857 | const char *mode = "NotApplicable"; |
2986cac2 | 9858 | |
9859 | if (!use_json) | |
a53ca37b | 9860 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 9861 | |
13909c4f DS |
9862 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9863 | && (peer->status == Established)) { | |
2986cac2 | 9864 | |
13909c4f DS |
9865 | if ((peer->nsf_af_count == 0) |
9866 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9867 | |
2986cac2 | 9868 | mode = "Disable"; |
9869 | ||
13909c4f DS |
9870 | } else if (peer->nsf_af_count == 0 |
9871 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9872 | |
2986cac2 | 9873 | mode = "Helper"; |
9874 | ||
13909c4f DS |
9875 | } else if (peer->nsf_af_count != 0 |
9876 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9877 | |
2986cac2 | 9878 | mode = "Restart"; |
2986cac2 | 9879 | } |
9880 | } | |
9881 | ||
9882 | if (use_json) { | |
13909c4f | 9883 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 9884 | } else |
9885 | vty_out(vty, mode, "\n"); | |
9886 | } | |
9887 | ||
13909c4f DS |
9888 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
9889 | struct peer *p, | |
9890 | bool use_json, | |
9891 | json_object *json) | |
2986cac2 | 9892 | { |
9893 | const char *mode = "Invalid"; | |
9894 | ||
9895 | if (!use_json) | |
a53ca37b | 9896 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 9897 | |
9898 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9899 | mode = "Helper"; | |
9900 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9901 | mode = "Restart"; | |
9902 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9903 | mode = "Disable"; | |
2ba1fe69 | 9904 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 9905 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
9906 | mode = "Helper*"; | |
9907 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9908 | mode = "Restart*"; | |
9909 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9910 | mode = "Disable*"; | |
9911 | else | |
9912 | mode = "Invalid*"; | |
2ba1fe69 | 9913 | } |
2986cac2 | 9914 | |
9915 | if (use_json) { | |
13909c4f | 9916 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 9917 | } else { |
9918 | vty_out(vty, mode, "\n"); | |
9919 | } | |
9920 | } | |
9921 | ||
13909c4f DS |
9922 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
9923 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 9924 | { |
2ba1fe69 | 9925 | afi_t afi; |
9926 | safi_t safi; | |
2986cac2 | 9927 | json_object *json_afi_safi = NULL; |
9928 | json_object *json_timer = NULL; | |
9929 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 9930 | bool eor_flag = false; |
2986cac2 | 9931 | |
9932 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9933 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
9934 | if (!peer->afc[afi][safi]) |
9935 | continue; | |
2986cac2 | 9936 | |
13909c4f DS |
9937 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9938 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
9939 | continue; | |
9e3b51a7 | 9940 | |
13909c4f DS |
9941 | if (use_json) { |
9942 | json_afi_safi = json_object_new_object(); | |
9943 | json_endofrib_status = json_object_new_object(); | |
9944 | json_timer = json_object_new_object(); | |
9945 | } | |
2986cac2 | 9946 | |
13909c4f DS |
9947 | if (peer->eor_stime[afi][safi] |
9948 | >= peer->pkt_stime[afi][safi]) | |
9949 | eor_flag = true; | |
9950 | else | |
9951 | eor_flag = false; | |
2986cac2 | 9952 | |
13909c4f | 9953 | if (!use_json) { |
a53ca37b | 9954 | vty_out(vty, " %s:\n", |
13909c4f | 9955 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 9956 | |
a53ca37b | 9957 | vty_out(vty, " F bit: "); |
698ba8d0 | 9958 | } |
2986cac2 | 9959 | |
13909c4f DS |
9960 | if (peer->nsf[afi][safi] |
9961 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
9962 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 9963 | |
13909c4f DS |
9964 | if (use_json) { |
9965 | json_object_boolean_true_add( | |
2986cac2 | 9966 | json_afi_safi, "fBit"); |
13909c4f DS |
9967 | } else |
9968 | vty_out(vty, "True\n"); | |
9969 | } else { | |
9970 | if (use_json) | |
9971 | json_object_boolean_false_add( | |
9972 | json_afi_safi, "fBit"); | |
9973 | else | |
9974 | vty_out(vty, "False\n"); | |
9975 | } | |
2986cac2 | 9976 | |
13909c4f | 9977 | if (!use_json) |
a53ca37b | 9978 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 9979 | |
13909c4f DS |
9980 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
9981 | PEER_STATUS_EOR_SEND)) { | |
9982 | if (use_json) { | |
9983 | json_object_boolean_true_add( | |
2986cac2 | 9984 | json_endofrib_status, |
13909c4f | 9985 | "endOfRibSend"); |
9e3b51a7 | 9986 | |
13909c4f DS |
9987 | PRINT_EOR_JSON(eor_flag); |
9988 | } else { | |
9989 | vty_out(vty, "Yes\n"); | |
9990 | vty_out(vty, | |
a53ca37b | 9991 | " End-of-RIB sent after update: "); |
2986cac2 | 9992 | |
13909c4f DS |
9993 | PRINT_EOR(eor_flag); |
9994 | } | |
9995 | } else { | |
9996 | if (use_json) { | |
9997 | json_object_boolean_false_add( | |
2986cac2 | 9998 | json_endofrib_status, |
13909c4f DS |
9999 | "endOfRibSend"); |
10000 | json_object_boolean_false_add( | |
9e3b51a7 | 10001 | json_endofrib_status, |
13909c4f DS |
10002 | "endOfRibSentAfterUpdate"); |
10003 | } else { | |
10004 | vty_out(vty, "No\n"); | |
10005 | vty_out(vty, | |
a53ca37b | 10006 | " End-of-RIB sent after update: "); |
13909c4f | 10007 | vty_out(vty, "No\n"); |
2986cac2 | 10008 | } |
13909c4f | 10009 | } |
2986cac2 | 10010 | |
a53ca37b DA |
10011 | if (!use_json) |
10012 | vty_out(vty, " End-of-RIB received: "); | |
10013 | ||
10014 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
10015 | PEER_STATUS_EOR_RECEIVED)) { | |
10016 | if (use_json) | |
10017 | json_object_boolean_true_add( | |
10018 | json_endofrib_status, | |
10019 | "endOfRibRecv"); | |
10020 | else | |
10021 | vty_out(vty, "Yes\n"); | |
10022 | } else { | |
10023 | if (use_json) | |
10024 | json_object_boolean_false_add( | |
10025 | json_endofrib_status, | |
10026 | "endOfRibRecv"); | |
10027 | else | |
10028 | vty_out(vty, "No\n"); | |
10029 | } | |
10030 | ||
13909c4f DS |
10031 | if (use_json) { |
10032 | json_object_int_add(json_timer, | |
10033 | "stalePathTimer", | |
10034 | peer->bgp->stalepath_time); | |
2986cac2 | 10035 | |
13909c4f DS |
10036 | if (peer->t_gr_stale != NULL) { |
10037 | json_object_int_add( | |
2986cac2 | 10038 | json_timer, |
10039 | "stalePathTimerRemaining", | |
10040 | thread_timer_remain_second( | |
13909c4f DS |
10041 | peer->t_gr_stale)); |
10042 | } | |
3a75afa4 | 10043 | |
13909c4f DS |
10044 | /* Display Configured Selection |
10045 | * Deferral only when when | |
10046 | * Gr mode is enabled. | |
10047 | */ | |
10048 | if (CHECK_FLAG(peer->flags, | |
10049 | PEER_FLAG_GRACEFUL_RESTART)) { | |
10050 | json_object_int_add( | |
3a75afa4 | 10051 | json_timer, |
2986cac2 | 10052 | "selectionDeferralTimer", |
10053 | peer->bgp->stalepath_time); | |
13909c4f | 10054 | } |
2986cac2 | 10055 | |
13909c4f DS |
10056 | if (peer->bgp->gr_info[afi][safi] |
10057 | .t_select_deferral | |
10058 | != NULL) { | |
2986cac2 | 10059 | |
13909c4f | 10060 | json_object_int_add( |
2986cac2 | 10061 | json_timer, |
10062 | "selectionDeferralTimerRemaining", | |
10063 | thread_timer_remain_second( | |
13909c4f DS |
10064 | peer->bgp |
10065 | ->gr_info[afi] | |
10066 | [safi] | |
10067 | .t_select_deferral)); | |
10068 | } | |
10069 | } else { | |
a53ca37b | 10070 | vty_out(vty, " Timers:\n"); |
13909c4f | 10071 | vty_out(vty, |
a53ca37b DA |
10072 | " Configured Stale Path Time(sec): %u\n", |
10073 | peer->bgp->stalepath_time); | |
2986cac2 | 10074 | |
a53ca37b | 10075 | if (peer->t_gr_stale != NULL) |
2986cac2 | 10076 | vty_out(vty, |
a53ca37b | 10077 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 10078 | thread_timer_remain_second( |
13909c4f | 10079 | peer->t_gr_stale)); |
13909c4f DS |
10080 | /* Display Configured Selection |
10081 | * Deferral only when when | |
10082 | * Gr mode is enabled. | |
10083 | */ | |
10084 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 10085 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 10086 | vty_out(vty, |
a53ca37b | 10087 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 10088 | peer->bgp->select_defer_time); |
2986cac2 | 10089 | |
13909c4f DS |
10090 | if (peer->bgp->gr_info[afi][safi] |
10091 | .t_select_deferral | |
a53ca37b | 10092 | != NULL) |
13909c4f | 10093 | vty_out(vty, |
a53ca37b | 10094 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 10095 | thread_timer_remain_second( |
13909c4f DS |
10096 | peer->bgp |
10097 | ->gr_info[afi] | |
10098 | [safi] | |
10099 | .t_select_deferral)); | |
2986cac2 | 10100 | } |
13909c4f DS |
10101 | if (use_json) { |
10102 | json_object_object_add(json_afi_safi, | |
10103 | "endOfRibStatus", | |
10104 | json_endofrib_status); | |
10105 | json_object_object_add(json_afi_safi, "timers", | |
10106 | json_timer); | |
10107 | json_object_object_add( | |
10108 | json, get_afi_safi_str(afi, safi, true), | |
10109 | json_afi_safi); | |
10110 | } | |
2986cac2 | 10111 | } |
10112 | } | |
10113 | } | |
10114 | ||
36235319 QY |
10115 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
10116 | struct peer *p, | |
10117 | bool use_json, | |
10118 | json_object *json) | |
2986cac2 | 10119 | { |
10120 | if (use_json) { | |
10121 | json_object *json_timer = NULL; | |
10122 | ||
10123 | json_timer = json_object_new_object(); | |
10124 | ||
13909c4f DS |
10125 | json_object_int_add(json_timer, "configuredRestartTimer", |
10126 | p->bgp->restart_time); | |
2986cac2 | 10127 | |
13909c4f DS |
10128 | json_object_int_add(json_timer, "receivedRestartTimer", |
10129 | p->v_gr_restart); | |
2986cac2 | 10130 | |
13909c4f DS |
10131 | if (p->t_gr_restart != NULL) |
10132 | json_object_int_add( | |
10133 | json_timer, "restartTimerRemaining", | |
10134 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 10135 | |
10136 | json_object_object_add(json, "timers", json_timer); | |
10137 | } else { | |
10138 | ||
a53ca37b DA |
10139 | vty_out(vty, " Timers:\n"); |
10140 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 10141 | p->bgp->restart_time); |
2986cac2 | 10142 | |
a53ca37b | 10143 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
10144 | p->v_gr_restart); |
10145 | if (p->t_gr_restart != NULL) | |
a53ca37b | 10146 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 10147 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 10148 | if (p->t_gr_restart != NULL) { |
a53ca37b | 10149 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
10150 | thread_timer_remain_second(p->t_gr_restart)); |
10151 | } | |
2986cac2 | 10152 | } |
10153 | } | |
10154 | ||
10155 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 10156 | bool use_json, json_object *json) |
2986cac2 | 10157 | { |
10158 | char buf[SU_ADDRSTRLEN] = {0}; | |
10159 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
10160 | /* '*' + v6 address of neighbor */ |
10161 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 10162 | |
2986cac2 | 10163 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
10164 | dn_flag[0] = '*'; | |
10165 | ||
10166 | if (p->conf_if) { | |
10167 | if (use_json) | |
13909c4f DS |
10168 | json_object_string_add( |
10169 | json, "neighborAddr", | |
2986cac2 | 10170 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
10171 | ? "none" |
10172 | : sockunion2str(&p->su, buf, | |
10173 | SU_ADDRSTRLEN)); | |
2986cac2 | 10174 | else |
13909c4f | 10175 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 10176 | BGP_PEER_SU_UNSPEC(p) |
10177 | ? "none" | |
10178 | : sockunion2str(&p->su, buf, | |
10179 | SU_ADDRSTRLEN)); | |
10180 | } else { | |
772270f3 QY |
10181 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
10182 | p->host); | |
2986cac2 | 10183 | |
10184 | if (use_json) | |
36235319 QY |
10185 | json_object_string_add(json, "neighborAddr", |
10186 | neighborAddr); | |
2986cac2 | 10187 | else |
36235319 | 10188 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 10189 | } |
10190 | ||
10191 | /* more gr info in new format */ | |
10192 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
10193 | } | |
10194 | ||
d62a17ae | 10195 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 10196 | safi_t safi, bool use_json, |
d62a17ae | 10197 | json_object *json_neigh) |
10198 | { | |
0291c246 MK |
10199 | struct bgp_filter *filter; |
10200 | struct peer_af *paf; | |
10201 | char orf_pfx_name[BUFSIZ]; | |
10202 | int orf_pfx_count; | |
10203 | json_object *json_af = NULL; | |
10204 | json_object *json_prefA = NULL; | |
10205 | json_object *json_prefB = NULL; | |
10206 | json_object *json_addr = NULL; | |
d62a17ae | 10207 | |
10208 | if (use_json) { | |
10209 | json_addr = json_object_new_object(); | |
10210 | json_af = json_object_new_object(); | |
10211 | filter = &p->filter[afi][safi]; | |
10212 | ||
10213 | if (peer_group_active(p)) | |
10214 | json_object_string_add(json_addr, "peerGroupMember", | |
10215 | p->group->name); | |
10216 | ||
10217 | paf = peer_af_find(p, afi, safi); | |
10218 | if (paf && PAF_SUBGRP(paf)) { | |
10219 | json_object_int_add(json_addr, "updateGroupId", | |
10220 | PAF_UPDGRP(paf)->id); | |
10221 | json_object_int_add(json_addr, "subGroupId", | |
10222 | PAF_SUBGRP(paf)->id); | |
10223 | json_object_int_add(json_addr, "packetQueueLength", | |
10224 | bpacket_queue_virtual_length(paf)); | |
10225 | } | |
10226 | ||
10227 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10228 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10229 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10230 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10231 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10232 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10233 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10234 | json_object_int_add(json_af, "orfType", | |
10235 | ORF_TYPE_PREFIX); | |
10236 | json_prefA = json_object_new_object(); | |
10237 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
10238 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
10239 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10240 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10241 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
10242 | use_json, json_prefA); | |
10243 | json_object_object_add(json_af, "orfPrefixList", | |
10244 | json_prefA); | |
10245 | } | |
10246 | ||
10247 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10248 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10249 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10250 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10251 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10252 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10253 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10254 | json_object_int_add(json_af, "orfOldType", | |
10255 | ORF_TYPE_PREFIX_OLD); | |
10256 | json_prefB = json_object_new_object(); | |
10257 | bgp_show_peer_afi_orf_cap( | |
10258 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10259 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10260 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10261 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
10262 | json_prefB); | |
10263 | json_object_object_add(json_af, "orfOldPrefixList", | |
10264 | json_prefB); | |
10265 | } | |
10266 | ||
10267 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10268 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10269 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10270 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10271 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10272 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10273 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10274 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10275 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10276 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10277 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10278 | json_object_object_add(json_addr, "afDependentCap", | |
10279 | json_af); | |
10280 | else | |
10281 | json_object_free(json_af); | |
10282 | ||
772270f3 QY |
10283 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10284 | p->host, afi, safi); | |
d62a17ae | 10285 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10286 | NULL, afi, orf_pfx_name, use_json); | |
10287 | ||
10288 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10289 | PEER_STATUS_ORF_PREFIX_SEND) | |
10290 | || orf_pfx_count) { | |
10291 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10292 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10293 | json_object_boolean_true_add(json_neigh, | |
10294 | "orfSent"); | |
10295 | if (orf_pfx_count) | |
10296 | json_object_int_add(json_addr, "orfRecvCounter", | |
10297 | orf_pfx_count); | |
10298 | } | |
10299 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10300 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10301 | json_object_string_add( | |
10302 | json_addr, "orfFirstUpdate", | |
10303 | "deferredUntilORFOrRouteRefreshRecvd"); | |
10304 | ||
10305 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10306 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10307 | json_object_boolean_true_add(json_addr, | |
10308 | "routeReflectorClient"); | |
10309 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10310 | PEER_FLAG_RSERVER_CLIENT)) | |
10311 | json_object_boolean_true_add(json_addr, | |
10312 | "routeServerClient"); | |
10313 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10314 | json_object_boolean_true_add(json_addr, | |
10315 | "inboundSoftConfigPermit"); | |
10316 | ||
10317 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10318 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10319 | json_object_boolean_true_add( | |
10320 | json_addr, | |
10321 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
10322 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10323 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10324 | json_object_boolean_true_add( | |
10325 | json_addr, | |
10326 | "privateAsNumsReplacedInUpdatesToNbr"); | |
10327 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10328 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10329 | json_object_boolean_true_add( | |
10330 | json_addr, | |
10331 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
10332 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10333 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10334 | json_object_boolean_true_add( | |
10335 | json_addr, | |
10336 | "privateAsNumsRemovedInUpdatesToNbr"); | |
10337 | ||
dcc68b5e MS |
10338 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10339 | json_object_boolean_true_add( | |
10340 | json_addr, | |
10341 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10342 | ->type_json_name); | |
d62a17ae | 10343 | |
10344 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10345 | json_object_string_add(json_addr, | |
10346 | "overrideASNsInOutboundUpdates", | |
10347 | "ifAspathEqualRemoteAs"); | |
10348 | ||
10349 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10350 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10351 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10352 | json_object_boolean_true_add(json_addr, | |
10353 | "routerAlwaysNextHop"); | |
10354 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10355 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10356 | json_object_boolean_true_add( | |
10357 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
10358 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10359 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10360 | json_object_boolean_true_add( | |
10361 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
10362 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10363 | json_object_boolean_true_add( | |
10364 | json_addr, "unchangedMedPropogatedToNbr"); | |
10365 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10366 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10367 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
10368 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10369 | PEER_FLAG_SEND_COMMUNITY) | |
10370 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10371 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10372 | json_object_string_add(json_addr, | |
10373 | "commAttriSentToNbr", | |
10374 | "extendedAndStandard"); | |
10375 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10376 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10377 | json_object_string_add(json_addr, | |
10378 | "commAttriSentToNbr", | |
10379 | "extended"); | |
10380 | else | |
10381 | json_object_string_add(json_addr, | |
10382 | "commAttriSentToNbr", | |
10383 | "standard"); | |
10384 | } | |
10385 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10386 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10387 | if (p->default_rmap[afi][safi].name) | |
10388 | json_object_string_add( | |
10389 | json_addr, "defaultRouteMap", | |
10390 | p->default_rmap[afi][safi].name); | |
10391 | ||
10392 | if (paf && PAF_SUBGRP(paf) | |
10393 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10394 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10395 | json_object_boolean_true_add(json_addr, | |
10396 | "defaultSent"); | |
10397 | else | |
10398 | json_object_boolean_true_add(json_addr, | |
10399 | "defaultNotSent"); | |
10400 | } | |
10401 | ||
dff8f48d | 10402 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10403 | if (is_evpn_enabled()) |
60466a63 QY |
10404 | json_object_boolean_true_add( |
10405 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10406 | } |
10407 | ||
d62a17ae | 10408 | if (filter->plist[FILTER_IN].name |
10409 | || filter->dlist[FILTER_IN].name | |
10410 | || filter->aslist[FILTER_IN].name | |
10411 | || filter->map[RMAP_IN].name) | |
10412 | json_object_boolean_true_add(json_addr, | |
10413 | "inboundPathPolicyConfig"); | |
10414 | if (filter->plist[FILTER_OUT].name | |
10415 | || filter->dlist[FILTER_OUT].name | |
10416 | || filter->aslist[FILTER_OUT].name | |
10417 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10418 | json_object_boolean_true_add( | |
10419 | json_addr, "outboundPathPolicyConfig"); | |
10420 | ||
10421 | /* prefix-list */ | |
10422 | if (filter->plist[FILTER_IN].name) | |
10423 | json_object_string_add(json_addr, | |
10424 | "incomingUpdatePrefixFilterList", | |
10425 | filter->plist[FILTER_IN].name); | |
10426 | if (filter->plist[FILTER_OUT].name) | |
10427 | json_object_string_add(json_addr, | |
10428 | "outgoingUpdatePrefixFilterList", | |
10429 | filter->plist[FILTER_OUT].name); | |
10430 | ||
10431 | /* distribute-list */ | |
10432 | if (filter->dlist[FILTER_IN].name) | |
10433 | json_object_string_add( | |
10434 | json_addr, "incomingUpdateNetworkFilterList", | |
10435 | filter->dlist[FILTER_IN].name); | |
10436 | if (filter->dlist[FILTER_OUT].name) | |
10437 | json_object_string_add( | |
10438 | json_addr, "outgoingUpdateNetworkFilterList", | |
10439 | filter->dlist[FILTER_OUT].name); | |
10440 | ||
10441 | /* filter-list. */ | |
10442 | if (filter->aslist[FILTER_IN].name) | |
10443 | json_object_string_add(json_addr, | |
10444 | "incomingUpdateAsPathFilterList", | |
10445 | filter->aslist[FILTER_IN].name); | |
10446 | if (filter->aslist[FILTER_OUT].name) | |
10447 | json_object_string_add(json_addr, | |
10448 | "outgoingUpdateAsPathFilterList", | |
10449 | filter->aslist[FILTER_OUT].name); | |
10450 | ||
10451 | /* route-map. */ | |
10452 | if (filter->map[RMAP_IN].name) | |
10453 | json_object_string_add( | |
10454 | json_addr, "routeMapForIncomingAdvertisements", | |
10455 | filter->map[RMAP_IN].name); | |
10456 | if (filter->map[RMAP_OUT].name) | |
10457 | json_object_string_add( | |
10458 | json_addr, "routeMapForOutgoingAdvertisements", | |
10459 | filter->map[RMAP_OUT].name); | |
10460 | ||
9dac9fc8 | 10461 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10462 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10463 | && !bgp_inbound_policy_exists(p, filter)) |
10464 | json_object_string_add( | |
10465 | json_addr, "inboundEbgpRequiresPolicy", | |
10466 | "Inbound updates discarded due to missing policy"); | |
10467 | ||
10468 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10469 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10470 | && (!bgp_outbound_policy_exists(p, filter))) |
10471 | json_object_string_add( | |
10472 | json_addr, "outboundEbgpRequiresPolicy", | |
10473 | "Outbound updates discarded due to missing policy"); | |
10474 | ||
d62a17ae | 10475 | /* unsuppress-map */ |
10476 | if (filter->usmap.name) | |
10477 | json_object_string_add(json_addr, | |
10478 | "selectiveUnsuppressRouteMap", | |
10479 | filter->usmap.name); | |
10480 | ||
10481 | /* Receive prefix count */ | |
10482 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10483 | p->pcount[afi][safi]); | |
50e05855 AD |
10484 | if (paf && PAF_SUBGRP(paf)) |
10485 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10486 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10487 | |
fde246e8 DA |
10488 | /* Maximum prefix */ |
10489 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10490 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10491 | p->pmax_out[afi][safi]); | |
10492 | ||
d62a17ae | 10493 | /* Maximum prefix */ |
10494 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10495 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10496 | p->pmax[afi][safi]); | |
10497 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10498 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10499 | json_object_boolean_true_add( | |
10500 | json_addr, "prefixAllowedMaxWarning"); | |
10501 | json_object_int_add(json_addr, | |
10502 | "prefixAllowedWarningThresh", | |
10503 | p->pmax_threshold[afi][safi]); | |
10504 | if (p->pmax_restart[afi][safi]) | |
10505 | json_object_int_add( | |
10506 | json_addr, | |
10507 | "prefixAllowedRestartIntervalMsecs", | |
10508 | p->pmax_restart[afi][safi] * 60000); | |
10509 | } | |
2986cac2 | 10510 | json_object_object_add(json_neigh, |
36235319 | 10511 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 10512 | json_addr); |
10513 | ||
10514 | } else { | |
10515 | filter = &p->filter[afi][safi]; | |
10516 | ||
10517 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10518 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10519 | |
10520 | if (peer_group_active(p)) | |
10521 | vty_out(vty, " %s peer-group member\n", | |
10522 | p->group->name); | |
10523 | ||
10524 | paf = peer_af_find(p, afi, safi); | |
10525 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 10526 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 10527 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10528 | vty_out(vty, " Packet Queue length %d\n", | |
10529 | bpacket_queue_virtual_length(paf)); | |
10530 | } else { | |
10531 | vty_out(vty, " Not part of any update group\n"); | |
10532 | } | |
10533 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10534 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10535 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10536 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10537 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10538 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10539 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10540 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10541 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10542 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10543 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10544 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10545 | ||
10546 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10547 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10548 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10549 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10550 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10551 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10552 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10553 | vty_out(vty, | |
10554 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10555 | ORF_TYPE_PREFIX); | |
10556 | bgp_show_peer_afi_orf_cap( | |
10557 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10558 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10559 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10560 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10561 | } | |
10562 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10563 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10564 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10565 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10566 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10567 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10568 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10569 | vty_out(vty, | |
10570 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10571 | ORF_TYPE_PREFIX_OLD); | |
10572 | bgp_show_peer_afi_orf_cap( | |
10573 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10574 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10575 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10576 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10577 | } | |
10578 | ||
772270f3 QY |
10579 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10580 | p->host, afi, safi); | |
d62a17ae | 10581 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10582 | NULL, afi, orf_pfx_name, use_json); | |
10583 | ||
10584 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10585 | PEER_STATUS_ORF_PREFIX_SEND) | |
10586 | || orf_pfx_count) { | |
10587 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10588 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10589 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10590 | vty_out(vty, " sent;"); | |
10591 | if (orf_pfx_count) | |
10592 | vty_out(vty, " received (%d entries)", | |
10593 | orf_pfx_count); | |
10594 | vty_out(vty, "\n"); | |
10595 | } | |
10596 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10597 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10598 | vty_out(vty, | |
10599 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10600 | ||
10601 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10602 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10603 | vty_out(vty, " Route-Reflector Client\n"); | |
10604 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10605 | PEER_FLAG_RSERVER_CLIENT)) | |
10606 | vty_out(vty, " Route-Server Client\n"); | |
10607 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10608 | vty_out(vty, | |
10609 | " Inbound soft reconfiguration allowed\n"); | |
10610 | ||
10611 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10612 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10613 | vty_out(vty, | |
10614 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10615 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10616 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10617 | vty_out(vty, | |
10618 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10619 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10620 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10621 | vty_out(vty, | |
10622 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10623 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10624 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10625 | vty_out(vty, | |
10626 | " Private AS numbers removed in updates to this neighbor\n"); | |
10627 | ||
dcc68b5e MS |
10628 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10629 | vty_out(vty, " %s\n", | |
10630 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10631 | ->human_description); | |
d62a17ae | 10632 | |
10633 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10634 | vty_out(vty, | |
10635 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10636 | ||
10637 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10638 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10639 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10640 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10641 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10642 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10643 | vty_out(vty, | |
10644 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10645 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10646 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10647 | vty_out(vty, | |
10648 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10649 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10650 | vty_out(vty, | |
10651 | " MED is propagated unchanged to this neighbor\n"); | |
10652 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10653 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10654 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10655 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10656 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10657 | vty_out(vty, | |
10658 | " Community attribute sent to this neighbor"); | |
10659 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10660 | PEER_FLAG_SEND_COMMUNITY) | |
10661 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10662 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10663 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10664 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10665 | vty_out(vty, "(all)\n"); | |
10666 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10667 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10668 | vty_out(vty, "(large)\n"); | |
10669 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10670 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10671 | vty_out(vty, "(extended)\n"); | |
10672 | else | |
10673 | vty_out(vty, "(standard)\n"); | |
10674 | } | |
10675 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10676 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10677 | vty_out(vty, " Default information originate,"); | |
10678 | ||
10679 | if (p->default_rmap[afi][safi].name) | |
10680 | vty_out(vty, " default route-map %s%s,", | |
10681 | p->default_rmap[afi][safi].map ? "*" | |
10682 | : "", | |
10683 | p->default_rmap[afi][safi].name); | |
10684 | if (paf && PAF_SUBGRP(paf) | |
10685 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10686 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10687 | vty_out(vty, " default sent\n"); | |
10688 | else | |
10689 | vty_out(vty, " default not sent\n"); | |
10690 | } | |
10691 | ||
dff8f48d MK |
10692 | /* advertise-vni-all */ |
10693 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10694 | if (is_evpn_enabled()) |
dff8f48d MK |
10695 | vty_out(vty, " advertise-all-vni\n"); |
10696 | } | |
10697 | ||
d62a17ae | 10698 | if (filter->plist[FILTER_IN].name |
10699 | || filter->dlist[FILTER_IN].name | |
10700 | || filter->aslist[FILTER_IN].name | |
10701 | || filter->map[RMAP_IN].name) | |
10702 | vty_out(vty, " Inbound path policy configured\n"); | |
10703 | if (filter->plist[FILTER_OUT].name | |
10704 | || filter->dlist[FILTER_OUT].name | |
10705 | || filter->aslist[FILTER_OUT].name | |
10706 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10707 | vty_out(vty, " Outbound path policy configured\n"); | |
10708 | ||
10709 | /* prefix-list */ | |
10710 | if (filter->plist[FILTER_IN].name) | |
10711 | vty_out(vty, | |
10712 | " Incoming update prefix filter list is %s%s\n", | |
10713 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10714 | filter->plist[FILTER_IN].name); | |
10715 | if (filter->plist[FILTER_OUT].name) | |
10716 | vty_out(vty, | |
10717 | " Outgoing update prefix filter list is %s%s\n", | |
10718 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10719 | filter->plist[FILTER_OUT].name); | |
10720 | ||
10721 | /* distribute-list */ | |
10722 | if (filter->dlist[FILTER_IN].name) | |
10723 | vty_out(vty, | |
10724 | " Incoming update network filter list is %s%s\n", | |
10725 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10726 | filter->dlist[FILTER_IN].name); | |
10727 | if (filter->dlist[FILTER_OUT].name) | |
10728 | vty_out(vty, | |
10729 | " Outgoing update network filter list is %s%s\n", | |
10730 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10731 | filter->dlist[FILTER_OUT].name); | |
10732 | ||
10733 | /* filter-list. */ | |
10734 | if (filter->aslist[FILTER_IN].name) | |
10735 | vty_out(vty, | |
10736 | " Incoming update AS path filter list is %s%s\n", | |
10737 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10738 | filter->aslist[FILTER_IN].name); | |
10739 | if (filter->aslist[FILTER_OUT].name) | |
10740 | vty_out(vty, | |
10741 | " Outgoing update AS path filter list is %s%s\n", | |
10742 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10743 | filter->aslist[FILTER_OUT].name); | |
10744 | ||
10745 | /* route-map. */ | |
10746 | if (filter->map[RMAP_IN].name) | |
10747 | vty_out(vty, | |
10748 | " Route map for incoming advertisements is %s%s\n", | |
10749 | filter->map[RMAP_IN].map ? "*" : "", | |
10750 | filter->map[RMAP_IN].name); | |
10751 | if (filter->map[RMAP_OUT].name) | |
10752 | vty_out(vty, | |
10753 | " Route map for outgoing advertisements is %s%s\n", | |
10754 | filter->map[RMAP_OUT].map ? "*" : "", | |
10755 | filter->map[RMAP_OUT].name); | |
10756 | ||
9dac9fc8 | 10757 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10758 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10759 | && !bgp_inbound_policy_exists(p, filter)) |
10760 | vty_out(vty, | |
10761 | " Inbound updates discarded due to missing policy\n"); | |
10762 | ||
10763 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10764 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10765 | && !bgp_outbound_policy_exists(p, filter)) |
10766 | vty_out(vty, | |
10767 | " Outbound updates discarded due to missing policy\n"); | |
10768 | ||
d62a17ae | 10769 | /* unsuppress-map */ |
10770 | if (filter->usmap.name) | |
10771 | vty_out(vty, | |
10772 | " Route map for selective unsuppress is %s%s\n", | |
10773 | filter->usmap.map ? "*" : "", | |
10774 | filter->usmap.name); | |
10775 | ||
10776 | /* Receive prefix count */ | |
6cde4b45 | 10777 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 10778 | p->pcount[afi][safi]); |
d62a17ae | 10779 | |
fde246e8 DA |
10780 | /* maximum-prefix-out */ |
10781 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10782 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10783 | vty_out(vty, | |
6cde4b45 | 10784 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
10785 | p->pmax_out[afi][safi]); |
10786 | ||
d62a17ae | 10787 | /* Maximum prefix */ |
10788 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 10789 | vty_out(vty, |
6cde4b45 | 10790 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 10791 | p->pmax[afi][safi], |
10792 | CHECK_FLAG(p->af_flags[afi][safi], | |
10793 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10794 | ? " (warning-only)" | |
10795 | : ""); | |
10796 | vty_out(vty, " Threshold for warning message %d%%", | |
10797 | p->pmax_threshold[afi][safi]); | |
10798 | if (p->pmax_restart[afi][safi]) | |
10799 | vty_out(vty, ", restart interval %d min", | |
10800 | p->pmax_restart[afi][safi]); | |
10801 | vty_out(vty, "\n"); | |
10802 | } | |
10803 | ||
10804 | vty_out(vty, "\n"); | |
10805 | } | |
10806 | } | |
10807 | ||
9f049418 | 10808 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10809 | json_object *json) |
718e3744 | 10810 | { |
d62a17ae | 10811 | struct bgp *bgp; |
10812 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10813 | char timebuf[BGP_UPTIME_LEN]; | |
10814 | char dn_flag[2]; | |
d62a17ae | 10815 | afi_t afi; |
10816 | safi_t safi; | |
d7c0a89a QY |
10817 | uint16_t i; |
10818 | uint8_t *msg; | |
d62a17ae | 10819 | json_object *json_neigh = NULL; |
10820 | time_t epoch_tbuf; | |
718e3744 | 10821 | |
d62a17ae | 10822 | bgp = p->bgp; |
10823 | ||
10824 | if (use_json) | |
10825 | json_neigh = json_object_new_object(); | |
10826 | ||
10827 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10828 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10829 | dn_flag[0] = '*'; | |
10830 | ||
10831 | if (!use_json) { | |
10832 | if (p->conf_if) /* Configured interface name. */ | |
10833 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10834 | BGP_PEER_SU_UNSPEC(p) | |
10835 | ? "None" | |
10836 | : sockunion2str(&p->su, buf, | |
10837 | SU_ADDRSTRLEN)); | |
10838 | else /* Configured IP address. */ | |
10839 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10840 | p->host); | |
10841 | } | |
10842 | ||
10843 | if (use_json) { | |
10844 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10845 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10846 | "none"); | |
10847 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10848 | json_object_string_add( | |
10849 | json_neigh, "bgpNeighborAddr", | |
10850 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10851 | ||
10852 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10853 | ||
10854 | if (p->change_local_as) | |
10855 | json_object_int_add(json_neigh, "localAs", | |
10856 | p->change_local_as); | |
10857 | else | |
10858 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10859 | ||
10860 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10861 | json_object_boolean_true_add(json_neigh, | |
10862 | "localAsNoPrepend"); | |
10863 | ||
10864 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10865 | json_object_boolean_true_add(json_neigh, | |
10866 | "localAsReplaceAs"); | |
10867 | } else { | |
10868 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10869 | || (p->as_type == AS_INTERNAL)) | |
10870 | vty_out(vty, "remote AS %u, ", p->as); | |
10871 | else | |
10872 | vty_out(vty, "remote AS Unspecified, "); | |
10873 | vty_out(vty, "local AS %u%s%s, ", | |
10874 | p->change_local_as ? p->change_local_as : p->local_as, | |
10875 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10876 | ? " no-prepend" | |
10877 | : "", | |
10878 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10879 | ? " replace-as" | |
10880 | : ""); | |
10881 | } | |
faa16034 DS |
10882 | /* peer type internal or confed-internal */ |
10883 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10884 | if (use_json) { |
10885 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10886 | json_object_boolean_true_add( | |
10887 | json_neigh, "nbrConfedInternalLink"); | |
10888 | else | |
10889 | json_object_boolean_true_add(json_neigh, | |
10890 | "nbrInternalLink"); | |
10891 | } else { | |
10892 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10893 | vty_out(vty, "confed-internal link\n"); | |
10894 | else | |
10895 | vty_out(vty, "internal link\n"); | |
10896 | } | |
faa16034 DS |
10897 | /* peer type external or confed-external */ |
10898 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10899 | if (use_json) { |
10900 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10901 | json_object_boolean_true_add( | |
10902 | json_neigh, "nbrConfedExternalLink"); | |
10903 | else | |
10904 | json_object_boolean_true_add(json_neigh, | |
10905 | "nbrExternalLink"); | |
10906 | } else { | |
10907 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10908 | vty_out(vty, "confed-external link\n"); | |
10909 | else | |
10910 | vty_out(vty, "external link\n"); | |
10911 | } | |
faa16034 DS |
10912 | } else { |
10913 | if (use_json) | |
10914 | json_object_boolean_true_add(json_neigh, | |
10915 | "nbrUnspecifiedLink"); | |
10916 | else | |
10917 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10918 | } |
10919 | ||
10920 | /* Description. */ | |
10921 | if (p->desc) { | |
10922 | if (use_json) | |
10923 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10924 | else | |
10925 | vty_out(vty, " Description: %s\n", p->desc); | |
10926 | } | |
10927 | ||
10928 | if (p->hostname) { | |
10929 | if (use_json) { | |
10930 | if (p->hostname) | |
10931 | json_object_string_add(json_neigh, "hostname", | |
10932 | p->hostname); | |
10933 | ||
10934 | if (p->domainname) | |
10935 | json_object_string_add(json_neigh, "domainname", | |
10936 | p->domainname); | |
10937 | } else { | |
10938 | if (p->domainname && (p->domainname[0] != '\0')) | |
10939 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10940 | p->domainname); | |
10941 | else | |
10942 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10943 | } | |
10944 | } | |
10945 | ||
10946 | /* Peer-group */ | |
10947 | if (p->group) { | |
10948 | if (use_json) { | |
10949 | json_object_string_add(json_neigh, "peerGroup", | |
10950 | p->group->name); | |
10951 | ||
10952 | if (dn_flag[0]) { | |
10953 | struct prefix prefix, *range = NULL; | |
10954 | ||
10955 | sockunion2hostprefix(&(p->su), &prefix); | |
10956 | range = peer_group_lookup_dynamic_neighbor_range( | |
10957 | p->group, &prefix); | |
10958 | ||
10959 | if (range) { | |
10960 | prefix2str(range, buf1, sizeof(buf1)); | |
10961 | json_object_string_add( | |
10962 | json_neigh, | |
10963 | "peerSubnetRangeGroup", buf1); | |
10964 | } | |
10965 | } | |
10966 | } else { | |
10967 | vty_out(vty, | |
10968 | " Member of peer-group %s for session parameters\n", | |
10969 | p->group->name); | |
10970 | ||
10971 | if (dn_flag[0]) { | |
10972 | struct prefix prefix, *range = NULL; | |
10973 | ||
10974 | sockunion2hostprefix(&(p->su), &prefix); | |
10975 | range = peer_group_lookup_dynamic_neighbor_range( | |
10976 | p->group, &prefix); | |
10977 | ||
10978 | if (range) { | |
d62a17ae | 10979 | vty_out(vty, |
1b78780b DL |
10980 | " Belongs to the subnet range group: %pFX\n", |
10981 | range); | |
d62a17ae | 10982 | } |
10983 | } | |
10984 | } | |
10985 | } | |
10986 | ||
10987 | if (use_json) { | |
10988 | /* Administrative shutdown. */ | |
cb9196e7 DS |
10989 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
10990 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 10991 | json_object_boolean_true_add(json_neigh, |
10992 | "adminShutDown"); | |
10993 | ||
10994 | /* BGP Version. */ | |
10995 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10996 | json_object_string_add( | |
10997 | json_neigh, "remoteRouterId", | |
10998 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10999 | json_object_string_add( |
11000 | json_neigh, "localRouterId", | |
11001 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
11002 | sizeof(buf1))); | |
d62a17ae | 11003 | |
11004 | /* Confederation */ | |
11005 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
11006 | && bgp_confederation_peers_check(bgp, p->as)) | |
11007 | json_object_boolean_true_add(json_neigh, | |
11008 | "nbrCommonAdmin"); | |
11009 | ||
11010 | /* Status. */ | |
11011 | json_object_string_add( | |
11012 | json_neigh, "bgpState", | |
11013 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
11014 | ||
11015 | if (p->status == Established) { | |
11016 | time_t uptime; | |
d62a17ae | 11017 | |
11018 | uptime = bgp_clock(); | |
11019 | uptime -= p->uptime; | |
d62a17ae | 11020 | epoch_tbuf = time(NULL) - uptime; |
11021 | ||
d3c7efed DS |
11022 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
11023 | uptime * 1000); | |
d62a17ae | 11024 | json_object_string_add(json_neigh, "bgpTimerUpString", |
11025 | peer_uptime(p->uptime, timebuf, | |
11026 | BGP_UPTIME_LEN, 0, | |
11027 | NULL)); | |
11028 | json_object_int_add(json_neigh, | |
11029 | "bgpTimerUpEstablishedEpoch", | |
11030 | epoch_tbuf); | |
11031 | } | |
11032 | ||
11033 | else if (p->status == Active) { | |
11034 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
11035 | json_object_string_add(json_neigh, "bgpStateIs", | |
11036 | "passive"); | |
11037 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
11038 | json_object_string_add(json_neigh, "bgpStateIs", | |
11039 | "passiveNSF"); | |
11040 | } | |
11041 | ||
11042 | /* read timer */ | |
11043 | time_t uptime; | |
a2700b50 | 11044 | struct tm tm; |
d62a17ae | 11045 | |
11046 | uptime = bgp_clock(); | |
11047 | uptime -= p->readtime; | |
a2700b50 MS |
11048 | gmtime_r(&uptime, &tm); |
11049 | ||
d62a17ae | 11050 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
11051 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11052 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11053 | |
11054 | uptime = bgp_clock(); | |
11055 | uptime -= p->last_write; | |
a2700b50 MS |
11056 | gmtime_r(&uptime, &tm); |
11057 | ||
d62a17ae | 11058 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
11059 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11060 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11061 | |
11062 | uptime = bgp_clock(); | |
11063 | uptime -= p->update_time; | |
a2700b50 MS |
11064 | gmtime_r(&uptime, &tm); |
11065 | ||
d62a17ae | 11066 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
11067 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11068 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11069 | |
11070 | /* Configured timer values. */ | |
11071 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
11072 | p->v_holdtime * 1000); | |
11073 | json_object_int_add(json_neigh, | |
11074 | "bgpTimerKeepAliveIntervalMsecs", | |
11075 | p->v_keepalive * 1000); | |
b90a8e13 | 11076 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 11077 | json_object_int_add(json_neigh, |
11078 | "bgpTimerConfiguredHoldTimeMsecs", | |
11079 | p->holdtime * 1000); | |
11080 | json_object_int_add( | |
11081 | json_neigh, | |
11082 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
11083 | p->keepalive * 1000); | |
5d5393b9 DL |
11084 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
11085 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
11086 | json_object_int_add(json_neigh, |
11087 | "bgpTimerConfiguredHoldTimeMsecs", | |
11088 | bgp->default_holdtime); | |
11089 | json_object_int_add( | |
11090 | json_neigh, | |
11091 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
11092 | bgp->default_keepalive); | |
d62a17ae | 11093 | } |
11094 | } else { | |
11095 | /* Administrative shutdown. */ | |
cb9196e7 DS |
11096 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
11097 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 11098 | vty_out(vty, " Administratively shut down\n"); |
11099 | ||
11100 | /* BGP Version. */ | |
11101 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 11102 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 11103 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
11104 | vty_out(vty, ", local router ID %s\n", |
11105 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
11106 | sizeof(buf1))); | |
d62a17ae | 11107 | |
11108 | /* Confederation */ | |
11109 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
11110 | && bgp_confederation_peers_check(bgp, p->as)) | |
11111 | vty_out(vty, | |
11112 | " Neighbor under common administration\n"); | |
11113 | ||
11114 | /* Status. */ | |
11115 | vty_out(vty, " BGP state = %s", | |
11116 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
11117 | ||
11118 | if (p->status == Established) | |
11119 | vty_out(vty, ", up for %8s", | |
11120 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
11121 | 0, NULL)); | |
11122 | ||
11123 | else if (p->status == Active) { | |
11124 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
11125 | vty_out(vty, " (passive)"); | |
11126 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
11127 | vty_out(vty, " (NSF passive)"); | |
11128 | } | |
11129 | vty_out(vty, "\n"); | |
11130 | ||
11131 | /* read timer */ | |
11132 | vty_out(vty, " Last read %s", | |
11133 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
11134 | NULL)); | |
11135 | vty_out(vty, ", Last write %s\n", | |
11136 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
11137 | NULL)); | |
11138 | ||
11139 | /* Configured timer values. */ | |
11140 | vty_out(vty, | |
11141 | " Hold time is %d, keepalive interval is %d seconds\n", | |
11142 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 11143 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 11144 | vty_out(vty, " Configured hold time is %d", |
11145 | p->holdtime); | |
11146 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11147 | p->keepalive); | |
5d5393b9 DL |
11148 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
11149 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
11150 | vty_out(vty, " Configured hold time is %d", |
11151 | bgp->default_holdtime); | |
11152 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11153 | bgp->default_keepalive); | |
d62a17ae | 11154 | } |
11155 | } | |
11156 | /* Capability. */ | |
11157 | if (p->status == Established) { | |
11158 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
11159 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
11160 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
11161 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
11162 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
11163 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
11164 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
11165 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
11166 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
11167 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
11168 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
11169 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 11170 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
11171 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 11172 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
11173 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 11174 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
11175 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 11176 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
11177 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
11178 | if (use_json) { | |
11179 | json_object *json_cap = NULL; | |
11180 | ||
11181 | json_cap = json_object_new_object(); | |
11182 | ||
11183 | /* AS4 */ | |
11184 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11185 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11186 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
11187 | && CHECK_FLAG(p->cap, | |
11188 | PEER_CAP_AS4_RCV)) | |
11189 | json_object_string_add( | |
11190 | json_cap, "4byteAs", | |
11191 | "advertisedAndReceived"); | |
11192 | else if (CHECK_FLAG(p->cap, | |
11193 | PEER_CAP_AS4_ADV)) | |
11194 | json_object_string_add( | |
11195 | json_cap, "4byteAs", | |
11196 | "advertised"); | |
11197 | else if (CHECK_FLAG(p->cap, | |
11198 | PEER_CAP_AS4_RCV)) | |
11199 | json_object_string_add( | |
11200 | json_cap, "4byteAs", | |
11201 | "received"); | |
11202 | } | |
11203 | ||
11204 | /* AddPath */ | |
11205 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11206 | || CHECK_FLAG(p->cap, | |
11207 | PEER_CAP_ADDPATH_ADV)) { | |
11208 | json_object *json_add = NULL; | |
11209 | const char *print_store; | |
11210 | ||
11211 | json_add = json_object_new_object(); | |
11212 | ||
05c7a1cc QY |
11213 | FOREACH_AFI_SAFI (afi, safi) { |
11214 | json_object *json_sub = NULL; | |
11215 | json_sub = | |
11216 | json_object_new_object(); | |
5cb5f4d0 DD |
11217 | print_store = get_afi_safi_str( |
11218 | afi, safi, true); | |
d62a17ae | 11219 | |
05c7a1cc QY |
11220 | if (CHECK_FLAG( |
11221 | p->af_cap[afi] | |
11222 | [safi], | |
11223 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11224 | || CHECK_FLAG( | |
11225 | p->af_cap[afi] | |
11226 | [safi], | |
11227 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 11228 | if (CHECK_FLAG( |
11229 | p->af_cap | |
11230 | [afi] | |
11231 | [safi], | |
11232 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 11233 | && CHECK_FLAG( |
d62a17ae | 11234 | p->af_cap |
11235 | [afi] | |
11236 | [safi], | |
05c7a1cc QY |
11237 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
11238 | json_object_boolean_true_add( | |
11239 | json_sub, | |
11240 | "txAdvertisedAndReceived"); | |
11241 | else if ( | |
11242 | CHECK_FLAG( | |
11243 | p->af_cap | |
11244 | [afi] | |
11245 | [safi], | |
11246 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
11247 | json_object_boolean_true_add( | |
11248 | json_sub, | |
11249 | "txAdvertised"); | |
11250 | else if ( | |
11251 | CHECK_FLAG( | |
11252 | p->af_cap | |
11253 | [afi] | |
11254 | [safi], | |
11255 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11256 | json_object_boolean_true_add( | |
11257 | json_sub, | |
11258 | "txReceived"); | |
11259 | } | |
d62a17ae | 11260 | |
05c7a1cc QY |
11261 | if (CHECK_FLAG( |
11262 | p->af_cap[afi] | |
11263 | [safi], | |
11264 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11265 | || CHECK_FLAG( | |
11266 | p->af_cap[afi] | |
11267 | [safi], | |
11268 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 11269 | if (CHECK_FLAG( |
11270 | p->af_cap | |
11271 | [afi] | |
11272 | [safi], | |
11273 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 11274 | && CHECK_FLAG( |
d62a17ae | 11275 | p->af_cap |
11276 | [afi] | |
11277 | [safi], | |
11278 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
11279 | json_object_boolean_true_add( |
11280 | json_sub, | |
11281 | "rxAdvertisedAndReceived"); | |
11282 | else if ( | |
11283 | CHECK_FLAG( | |
11284 | p->af_cap | |
11285 | [afi] | |
11286 | [safi], | |
11287 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
11288 | json_object_boolean_true_add( | |
11289 | json_sub, | |
11290 | "rxAdvertised"); | |
11291 | else if ( | |
11292 | CHECK_FLAG( | |
11293 | p->af_cap | |
11294 | [afi] | |
11295 | [safi], | |
11296 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11297 | json_object_boolean_true_add( | |
11298 | json_sub, | |
11299 | "rxReceived"); | |
d62a17ae | 11300 | } |
11301 | ||
05c7a1cc QY |
11302 | if (CHECK_FLAG( |
11303 | p->af_cap[afi] | |
11304 | [safi], | |
11305 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11306 | || CHECK_FLAG( | |
11307 | p->af_cap[afi] | |
11308 | [safi], | |
11309 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
11310 | || CHECK_FLAG( | |
11311 | p->af_cap[afi] | |
11312 | [safi], | |
11313 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11314 | || CHECK_FLAG( | |
11315 | p->af_cap[afi] | |
11316 | [safi], | |
11317 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11318 | json_object_object_add( | |
11319 | json_add, | |
11320 | print_store, | |
11321 | json_sub); | |
11322 | else | |
11323 | json_object_free( | |
11324 | json_sub); | |
11325 | } | |
11326 | ||
d62a17ae | 11327 | json_object_object_add( |
11328 | json_cap, "addPath", json_add); | |
11329 | } | |
11330 | ||
11331 | /* Dynamic */ | |
11332 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11333 | || CHECK_FLAG(p->cap, | |
11334 | PEER_CAP_DYNAMIC_ADV)) { | |
11335 | if (CHECK_FLAG(p->cap, | |
11336 | PEER_CAP_DYNAMIC_ADV) | |
11337 | && CHECK_FLAG(p->cap, | |
11338 | PEER_CAP_DYNAMIC_RCV)) | |
11339 | json_object_string_add( | |
11340 | json_cap, "dynamic", | |
11341 | "advertisedAndReceived"); | |
11342 | else if (CHECK_FLAG( | |
11343 | p->cap, | |
11344 | PEER_CAP_DYNAMIC_ADV)) | |
11345 | json_object_string_add( | |
11346 | json_cap, "dynamic", | |
11347 | "advertised"); | |
11348 | else if (CHECK_FLAG( | |
11349 | p->cap, | |
11350 | PEER_CAP_DYNAMIC_RCV)) | |
11351 | json_object_string_add( | |
11352 | json_cap, "dynamic", | |
11353 | "received"); | |
11354 | } | |
11355 | ||
11356 | /* Extended nexthop */ | |
11357 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11358 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11359 | json_object *json_nxt = NULL; | |
11360 | const char *print_store; | |
11361 | ||
11362 | ||
11363 | if (CHECK_FLAG(p->cap, | |
11364 | PEER_CAP_ENHE_ADV) | |
11365 | && CHECK_FLAG(p->cap, | |
11366 | PEER_CAP_ENHE_RCV)) | |
11367 | json_object_string_add( | |
11368 | json_cap, | |
11369 | "extendedNexthop", | |
11370 | "advertisedAndReceived"); | |
11371 | else if (CHECK_FLAG(p->cap, | |
11372 | PEER_CAP_ENHE_ADV)) | |
11373 | json_object_string_add( | |
11374 | json_cap, | |
11375 | "extendedNexthop", | |
11376 | "advertised"); | |
11377 | else if (CHECK_FLAG(p->cap, | |
11378 | PEER_CAP_ENHE_RCV)) | |
11379 | json_object_string_add( | |
11380 | json_cap, | |
11381 | "extendedNexthop", | |
11382 | "received"); | |
11383 | ||
11384 | if (CHECK_FLAG(p->cap, | |
11385 | PEER_CAP_ENHE_RCV)) { | |
11386 | json_nxt = | |
11387 | json_object_new_object(); | |
11388 | ||
11389 | for (safi = SAFI_UNICAST; | |
11390 | safi < SAFI_MAX; safi++) { | |
11391 | if (CHECK_FLAG( | |
11392 | p->af_cap | |
11393 | [AFI_IP] | |
11394 | [safi], | |
11395 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11396 | print_store = get_afi_safi_str( |
d62a17ae | 11397 | AFI_IP, |
5cb5f4d0 | 11398 | safi, true); |
d62a17ae | 11399 | json_object_string_add( |
11400 | json_nxt, | |
11401 | print_store, | |
54f29523 | 11402 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 11403 | } |
11404 | } | |
11405 | json_object_object_add( | |
11406 | json_cap, | |
11407 | "extendedNexthopFamililesByPeer", | |
11408 | json_nxt); | |
11409 | } | |
11410 | } | |
11411 | ||
11412 | /* Route Refresh */ | |
11413 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11414 | || CHECK_FLAG(p->cap, | |
11415 | PEER_CAP_REFRESH_NEW_RCV) | |
11416 | || CHECK_FLAG(p->cap, | |
11417 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11418 | if (CHECK_FLAG(p->cap, | |
11419 | PEER_CAP_REFRESH_ADV) | |
11420 | && (CHECK_FLAG( | |
11421 | p->cap, | |
11422 | PEER_CAP_REFRESH_NEW_RCV) | |
11423 | || CHECK_FLAG( | |
11424 | p->cap, | |
11425 | PEER_CAP_REFRESH_OLD_RCV))) { | |
11426 | if (CHECK_FLAG( | |
11427 | p->cap, | |
11428 | PEER_CAP_REFRESH_OLD_RCV) | |
11429 | && CHECK_FLAG( | |
11430 | p->cap, | |
11431 | PEER_CAP_REFRESH_NEW_RCV)) | |
11432 | json_object_string_add( | |
11433 | json_cap, | |
11434 | "routeRefresh", | |
11435 | "advertisedAndReceivedOldNew"); | |
11436 | else { | |
11437 | if (CHECK_FLAG( | |
11438 | p->cap, | |
11439 | PEER_CAP_REFRESH_OLD_RCV)) | |
11440 | json_object_string_add( | |
11441 | json_cap, | |
11442 | "routeRefresh", | |
11443 | "advertisedAndReceivedOld"); | |
11444 | else | |
11445 | json_object_string_add( | |
11446 | json_cap, | |
11447 | "routeRefresh", | |
11448 | "advertisedAndReceivedNew"); | |
11449 | } | |
11450 | } else if ( | |
11451 | CHECK_FLAG( | |
11452 | p->cap, | |
11453 | PEER_CAP_REFRESH_ADV)) | |
11454 | json_object_string_add( | |
11455 | json_cap, | |
11456 | "routeRefresh", | |
11457 | "advertised"); | |
11458 | else if ( | |
11459 | CHECK_FLAG( | |
11460 | p->cap, | |
11461 | PEER_CAP_REFRESH_NEW_RCV) | |
11462 | || CHECK_FLAG( | |
11463 | p->cap, | |
11464 | PEER_CAP_REFRESH_OLD_RCV)) | |
11465 | json_object_string_add( | |
11466 | json_cap, | |
11467 | "routeRefresh", | |
11468 | "received"); | |
11469 | } | |
11470 | ||
11471 | /* Multiprotocol Extensions */ | |
11472 | json_object *json_multi = NULL; | |
11473 | json_multi = json_object_new_object(); | |
11474 | ||
05c7a1cc QY |
11475 | FOREACH_AFI_SAFI (afi, safi) { |
11476 | if (p->afc_adv[afi][safi] | |
11477 | || p->afc_recv[afi][safi]) { | |
11478 | json_object *json_exten = NULL; | |
11479 | json_exten = | |
11480 | json_object_new_object(); | |
11481 | ||
d62a17ae | 11482 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11483 | && p->afc_recv[afi][safi]) |
11484 | json_object_boolean_true_add( | |
11485 | json_exten, | |
11486 | "advertisedAndReceived"); | |
11487 | else if (p->afc_adv[afi][safi]) | |
11488 | json_object_boolean_true_add( | |
11489 | json_exten, | |
11490 | "advertised"); | |
11491 | else if (p->afc_recv[afi][safi]) | |
11492 | json_object_boolean_true_add( | |
11493 | json_exten, | |
11494 | "received"); | |
d62a17ae | 11495 | |
05c7a1cc QY |
11496 | json_object_object_add( |
11497 | json_multi, | |
5cb5f4d0 DD |
11498 | get_afi_safi_str(afi, |
11499 | safi, | |
11500 | true), | |
05c7a1cc | 11501 | json_exten); |
d62a17ae | 11502 | } |
11503 | } | |
11504 | json_object_object_add( | |
11505 | json_cap, "multiprotocolExtensions", | |
11506 | json_multi); | |
11507 | ||
d77114b7 | 11508 | /* Hostname capabilities */ |
60466a63 | 11509 | json_object *json_hname = NULL; |
d77114b7 MK |
11510 | |
11511 | json_hname = json_object_new_object(); | |
11512 | ||
11513 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11514 | json_object_string_add( | |
60466a63 QY |
11515 | json_hname, "advHostName", |
11516 | bgp->peer_self->hostname | |
11517 | ? bgp->peer_self | |
11518 | ->hostname | |
d77114b7 MK |
11519 | : "n/a"); |
11520 | json_object_string_add( | |
60466a63 QY |
11521 | json_hname, "advDomainName", |
11522 | bgp->peer_self->domainname | |
11523 | ? bgp->peer_self | |
11524 | ->domainname | |
d77114b7 MK |
11525 | : "n/a"); |
11526 | } | |
11527 | ||
11528 | ||
11529 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11530 | json_object_string_add( | |
60466a63 QY |
11531 | json_hname, "rcvHostName", |
11532 | p->hostname ? p->hostname | |
11533 | : "n/a"); | |
d77114b7 | 11534 | json_object_string_add( |
60466a63 QY |
11535 | json_hname, "rcvDomainName", |
11536 | p->domainname ? p->domainname | |
11537 | : "n/a"); | |
d77114b7 MK |
11538 | } |
11539 | ||
60466a63 | 11540 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11541 | json_hname); |
11542 | ||
d62a17ae | 11543 | /* Gracefull Restart */ |
11544 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11545 | || CHECK_FLAG(p->cap, | |
11546 | PEER_CAP_RESTART_ADV)) { | |
11547 | if (CHECK_FLAG(p->cap, | |
11548 | PEER_CAP_RESTART_ADV) | |
11549 | && CHECK_FLAG(p->cap, | |
11550 | PEER_CAP_RESTART_RCV)) | |
11551 | json_object_string_add( | |
11552 | json_cap, | |
11553 | "gracefulRestart", | |
11554 | "advertisedAndReceived"); | |
11555 | else if (CHECK_FLAG( | |
11556 | p->cap, | |
11557 | PEER_CAP_RESTART_ADV)) | |
11558 | json_object_string_add( | |
11559 | json_cap, | |
11560 | "gracefulRestartCapability", | |
11561 | "advertised"); | |
11562 | else if (CHECK_FLAG( | |
11563 | p->cap, | |
11564 | PEER_CAP_RESTART_RCV)) | |
11565 | json_object_string_add( | |
11566 | json_cap, | |
11567 | "gracefulRestartCapability", | |
11568 | "received"); | |
11569 | ||
11570 | if (CHECK_FLAG(p->cap, | |
11571 | PEER_CAP_RESTART_RCV)) { | |
11572 | int restart_af_count = 0; | |
11573 | json_object *json_restart = | |
11574 | NULL; | |
11575 | json_restart = | |
11576 | json_object_new_object(); | |
11577 | ||
11578 | json_object_int_add( | |
11579 | json_cap, | |
11580 | "gracefulRestartRemoteTimerMsecs", | |
11581 | p->v_gr_restart * 1000); | |
11582 | ||
05c7a1cc QY |
11583 | FOREACH_AFI_SAFI (afi, safi) { |
11584 | if (CHECK_FLAG( | |
11585 | p->af_cap | |
11586 | [afi] | |
11587 | [safi], | |
11588 | PEER_CAP_RESTART_AF_RCV)) { | |
11589 | json_object * | |
11590 | json_sub = | |
11591 | NULL; | |
11592 | json_sub = | |
11593 | json_object_new_object(); | |
11594 | ||
d62a17ae | 11595 | if (CHECK_FLAG( |
11596 | p->af_cap | |
11597 | [afi] | |
11598 | [safi], | |
05c7a1cc QY |
11599 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11600 | json_object_boolean_true_add( | |
11601 | json_sub, | |
11602 | "preserved"); | |
11603 | restart_af_count++; | |
11604 | json_object_object_add( | |
11605 | json_restart, | |
5cb5f4d0 | 11606 | get_afi_safi_str( |
05c7a1cc | 11607 | afi, |
5cb5f4d0 DD |
11608 | safi, |
11609 | true), | |
05c7a1cc | 11610 | json_sub); |
d62a17ae | 11611 | } |
11612 | } | |
11613 | if (!restart_af_count) { | |
11614 | json_object_string_add( | |
11615 | json_cap, | |
11616 | "addressFamiliesByPeer", | |
11617 | "none"); | |
11618 | json_object_free( | |
11619 | json_restart); | |
11620 | } else | |
11621 | json_object_object_add( | |
11622 | json_cap, | |
11623 | "addressFamiliesByPeer", | |
11624 | json_restart); | |
11625 | } | |
11626 | } | |
11627 | json_object_object_add(json_neigh, | |
11628 | "neighborCapabilities", | |
11629 | json_cap); | |
11630 | } else { | |
11631 | vty_out(vty, " Neighbor capabilities:\n"); | |
11632 | ||
11633 | /* AS4 */ | |
11634 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11635 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11636 | vty_out(vty, " 4 Byte AS:"); | |
11637 | if (CHECK_FLAG(p->cap, | |
11638 | PEER_CAP_AS4_ADV)) | |
11639 | vty_out(vty, " advertised"); | |
11640 | if (CHECK_FLAG(p->cap, | |
11641 | PEER_CAP_AS4_RCV)) | |
11642 | vty_out(vty, " %sreceived", | |
11643 | CHECK_FLAG( | |
11644 | p->cap, | |
11645 | PEER_CAP_AS4_ADV) | |
11646 | ? "and " | |
11647 | : ""); | |
11648 | vty_out(vty, "\n"); | |
11649 | } | |
11650 | ||
11651 | /* AddPath */ | |
11652 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11653 | || CHECK_FLAG(p->cap, | |
11654 | PEER_CAP_ADDPATH_ADV)) { | |
11655 | vty_out(vty, " AddPath:\n"); | |
11656 | ||
05c7a1cc QY |
11657 | FOREACH_AFI_SAFI (afi, safi) { |
11658 | if (CHECK_FLAG( | |
11659 | p->af_cap[afi] | |
11660 | [safi], | |
11661 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11662 | || CHECK_FLAG( | |
11663 | p->af_cap[afi] | |
11664 | [safi], | |
11665 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11666 | vty_out(vty, | |
11667 | " %s: TX ", | |
5cb5f4d0 | 11668 | get_afi_safi_str( |
05c7a1cc | 11669 | afi, |
5cb5f4d0 DD |
11670 | safi, |
11671 | false)); | |
05c7a1cc | 11672 | |
d62a17ae | 11673 | if (CHECK_FLAG( |
11674 | p->af_cap | |
11675 | [afi] | |
11676 | [safi], | |
05c7a1cc | 11677 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11678 | vty_out(vty, |
05c7a1cc | 11679 | "advertised %s", |
5cb5f4d0 | 11680 | get_afi_safi_str( |
d62a17ae | 11681 | afi, |
5cb5f4d0 DD |
11682 | safi, |
11683 | false)); | |
d62a17ae | 11684 | |
05c7a1cc QY |
11685 | if (CHECK_FLAG( |
11686 | p->af_cap | |
11687 | [afi] | |
11688 | [safi], | |
11689 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11690 | vty_out(vty, | |
11691 | "%sreceived", | |
11692 | CHECK_FLAG( | |
11693 | p->af_cap | |
11694 | [afi] | |
11695 | [safi], | |
11696 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11697 | ? " and " | |
11698 | : ""); | |
d62a17ae | 11699 | |
05c7a1cc QY |
11700 | vty_out(vty, "\n"); |
11701 | } | |
d62a17ae | 11702 | |
05c7a1cc QY |
11703 | if (CHECK_FLAG( |
11704 | p->af_cap[afi] | |
11705 | [safi], | |
11706 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11707 | || CHECK_FLAG( | |
11708 | p->af_cap[afi] | |
11709 | [safi], | |
11710 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11711 | vty_out(vty, | |
11712 | " %s: RX ", | |
5cb5f4d0 | 11713 | get_afi_safi_str( |
05c7a1cc | 11714 | afi, |
5cb5f4d0 DD |
11715 | safi, |
11716 | false)); | |
d62a17ae | 11717 | |
11718 | if (CHECK_FLAG( | |
11719 | p->af_cap | |
11720 | [afi] | |
11721 | [safi], | |
05c7a1cc | 11722 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11723 | vty_out(vty, |
05c7a1cc | 11724 | "advertised %s", |
5cb5f4d0 | 11725 | get_afi_safi_str( |
d62a17ae | 11726 | afi, |
5cb5f4d0 DD |
11727 | safi, |
11728 | false)); | |
d62a17ae | 11729 | |
05c7a1cc QY |
11730 | if (CHECK_FLAG( |
11731 | p->af_cap | |
11732 | [afi] | |
11733 | [safi], | |
11734 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11735 | vty_out(vty, |
05c7a1cc QY |
11736 | "%sreceived", |
11737 | CHECK_FLAG( | |
11738 | p->af_cap | |
11739 | [afi] | |
11740 | [safi], | |
11741 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11742 | ? " and " | |
11743 | : ""); | |
11744 | ||
11745 | vty_out(vty, "\n"); | |
d62a17ae | 11746 | } |
05c7a1cc | 11747 | } |
d62a17ae | 11748 | } |
11749 | ||
11750 | /* Dynamic */ | |
11751 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11752 | || CHECK_FLAG(p->cap, | |
11753 | PEER_CAP_DYNAMIC_ADV)) { | |
11754 | vty_out(vty, " Dynamic:"); | |
11755 | if (CHECK_FLAG(p->cap, | |
11756 | PEER_CAP_DYNAMIC_ADV)) | |
11757 | vty_out(vty, " advertised"); | |
11758 | if (CHECK_FLAG(p->cap, | |
11759 | PEER_CAP_DYNAMIC_RCV)) | |
11760 | vty_out(vty, " %sreceived", | |
11761 | CHECK_FLAG( | |
11762 | p->cap, | |
11763 | PEER_CAP_DYNAMIC_ADV) | |
11764 | ? "and " | |
11765 | : ""); | |
11766 | vty_out(vty, "\n"); | |
11767 | } | |
11768 | ||
11769 | /* Extended nexthop */ | |
11770 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11771 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11772 | vty_out(vty, " Extended nexthop:"); | |
11773 | if (CHECK_FLAG(p->cap, | |
11774 | PEER_CAP_ENHE_ADV)) | |
11775 | vty_out(vty, " advertised"); | |
11776 | if (CHECK_FLAG(p->cap, | |
11777 | PEER_CAP_ENHE_RCV)) | |
11778 | vty_out(vty, " %sreceived", | |
11779 | CHECK_FLAG( | |
11780 | p->cap, | |
11781 | PEER_CAP_ENHE_ADV) | |
11782 | ? "and " | |
11783 | : ""); | |
11784 | vty_out(vty, "\n"); | |
11785 | ||
11786 | if (CHECK_FLAG(p->cap, | |
11787 | PEER_CAP_ENHE_RCV)) { | |
11788 | vty_out(vty, | |
11789 | " Address families by peer:\n "); | |
11790 | for (safi = SAFI_UNICAST; | |
11791 | safi < SAFI_MAX; safi++) | |
11792 | if (CHECK_FLAG( | |
11793 | p->af_cap | |
11794 | [AFI_IP] | |
11795 | [safi], | |
11796 | PEER_CAP_ENHE_AF_RCV)) | |
11797 | vty_out(vty, | |
11798 | " %s\n", | |
5cb5f4d0 | 11799 | get_afi_safi_str( |
d62a17ae | 11800 | AFI_IP, |
5cb5f4d0 DD |
11801 | safi, |
11802 | false)); | |
d62a17ae | 11803 | } |
11804 | } | |
11805 | ||
11806 | /* Route Refresh */ | |
11807 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11808 | || CHECK_FLAG(p->cap, | |
11809 | PEER_CAP_REFRESH_NEW_RCV) | |
11810 | || CHECK_FLAG(p->cap, | |
11811 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11812 | vty_out(vty, " Route refresh:"); | |
11813 | if (CHECK_FLAG(p->cap, | |
11814 | PEER_CAP_REFRESH_ADV)) | |
11815 | vty_out(vty, " advertised"); | |
11816 | if (CHECK_FLAG(p->cap, | |
11817 | PEER_CAP_REFRESH_NEW_RCV) | |
11818 | || CHECK_FLAG( | |
11819 | p->cap, | |
11820 | PEER_CAP_REFRESH_OLD_RCV)) | |
11821 | vty_out(vty, " %sreceived(%s)", | |
11822 | CHECK_FLAG( | |
11823 | p->cap, | |
11824 | PEER_CAP_REFRESH_ADV) | |
11825 | ? "and " | |
11826 | : "", | |
11827 | (CHECK_FLAG( | |
11828 | p->cap, | |
11829 | PEER_CAP_REFRESH_OLD_RCV) | |
11830 | && CHECK_FLAG( | |
11831 | p->cap, | |
11832 | PEER_CAP_REFRESH_NEW_RCV)) | |
11833 | ? "old & new" | |
11834 | : CHECK_FLAG( | |
11835 | p->cap, | |
11836 | PEER_CAP_REFRESH_OLD_RCV) | |
11837 | ? "old" | |
11838 | : "new"); | |
11839 | ||
11840 | vty_out(vty, "\n"); | |
11841 | } | |
11842 | ||
11843 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11844 | FOREACH_AFI_SAFI (afi, safi) |
11845 | if (p->afc_adv[afi][safi] | |
11846 | || p->afc_recv[afi][safi]) { | |
11847 | vty_out(vty, | |
11848 | " Address Family %s:", | |
5cb5f4d0 DD |
11849 | get_afi_safi_str( |
11850 | afi, | |
11851 | safi, | |
11852 | false)); | |
05c7a1cc | 11853 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11854 | vty_out(vty, |
05c7a1cc QY |
11855 | " advertised"); |
11856 | if (p->afc_recv[afi][safi]) | |
11857 | vty_out(vty, | |
11858 | " %sreceived", | |
11859 | p->afc_adv[afi] | |
11860 | [safi] | |
11861 | ? "and " | |
11862 | : ""); | |
11863 | vty_out(vty, "\n"); | |
11864 | } | |
d62a17ae | 11865 | |
11866 | /* Hostname capability */ | |
60466a63 | 11867 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11868 | |
11869 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11870 | vty_out(vty, |
11871 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11872 | bgp->peer_self->hostname |
11873 | ? bgp->peer_self | |
11874 | ->hostname | |
d77114b7 | 11875 | : "n/a", |
60466a63 QY |
11876 | bgp->peer_self->domainname |
11877 | ? bgp->peer_self | |
11878 | ->domainname | |
d77114b7 MK |
11879 | : "n/a"); |
11880 | } else { | |
11881 | vty_out(vty, " not advertised"); | |
d62a17ae | 11882 | } |
11883 | ||
d77114b7 | 11884 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11885 | vty_out(vty, |
11886 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11887 | p->hostname ? p->hostname |
11888 | : "n/a", | |
11889 | p->domainname ? p->domainname | |
11890 | : "n/a"); | |
d77114b7 MK |
11891 | } else { |
11892 | vty_out(vty, " not received"); | |
11893 | } | |
11894 | ||
11895 | vty_out(vty, "\n"); | |
11896 | ||
61bfbd51 | 11897 | /* Graceful Restart */ |
d62a17ae | 11898 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
11899 | || CHECK_FLAG(p->cap, | |
11900 | PEER_CAP_RESTART_ADV)) { | |
11901 | vty_out(vty, | |
61bfbd51 | 11902 | " Graceful Restart Capability:"); |
d62a17ae | 11903 | if (CHECK_FLAG(p->cap, |
11904 | PEER_CAP_RESTART_ADV)) | |
11905 | vty_out(vty, " advertised"); | |
11906 | if (CHECK_FLAG(p->cap, | |
11907 | PEER_CAP_RESTART_RCV)) | |
11908 | vty_out(vty, " %sreceived", | |
11909 | CHECK_FLAG( | |
11910 | p->cap, | |
11911 | PEER_CAP_RESTART_ADV) | |
11912 | ? "and " | |
11913 | : ""); | |
11914 | vty_out(vty, "\n"); | |
11915 | ||
11916 | if (CHECK_FLAG(p->cap, | |
11917 | PEER_CAP_RESTART_RCV)) { | |
11918 | int restart_af_count = 0; | |
11919 | ||
11920 | vty_out(vty, | |
11921 | " Remote Restart timer is %d seconds\n", | |
11922 | p->v_gr_restart); | |
11923 | vty_out(vty, | |
11924 | " Address families by peer:\n "); | |
11925 | ||
05c7a1cc QY |
11926 | FOREACH_AFI_SAFI (afi, safi) |
11927 | if (CHECK_FLAG( | |
11928 | p->af_cap | |
11929 | [afi] | |
11930 | [safi], | |
11931 | PEER_CAP_RESTART_AF_RCV)) { | |
11932 | vty_out(vty, | |
11933 | "%s%s(%s)", | |
11934 | restart_af_count | |
11935 | ? ", " | |
11936 | : "", | |
5cb5f4d0 | 11937 | get_afi_safi_str( |
05c7a1cc | 11938 | afi, |
5cb5f4d0 DD |
11939 | safi, |
11940 | false), | |
05c7a1cc QY |
11941 | CHECK_FLAG( |
11942 | p->af_cap | |
11943 | [afi] | |
11944 | [safi], | |
11945 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11946 | ? "preserved" | |
11947 | : "not preserved"); | |
11948 | restart_af_count++; | |
11949 | } | |
d62a17ae | 11950 | if (!restart_af_count) |
11951 | vty_out(vty, "none"); | |
11952 | vty_out(vty, "\n"); | |
11953 | } | |
2986cac2 | 11954 | } /* Gracefull Restart */ |
d62a17ae | 11955 | } |
11956 | } | |
11957 | } | |
11958 | ||
11959 | /* graceful restart information */ | |
d62a17ae | 11960 | json_object *json_grace = NULL; |
11961 | json_object *json_grace_send = NULL; | |
11962 | json_object *json_grace_recv = NULL; | |
11963 | int eor_send_af_count = 0; | |
11964 | int eor_receive_af_count = 0; | |
11965 | ||
11966 | if (use_json) { | |
11967 | json_grace = json_object_new_object(); | |
11968 | json_grace_send = json_object_new_object(); | |
11969 | json_grace_recv = json_object_new_object(); | |
11970 | ||
36235319 QY |
11971 | if ((p->status == Established) |
11972 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11973 | FOREACH_AFI_SAFI (afi, safi) { |
11974 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 11975 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11976 | json_object_boolean_true_add( |
11977 | json_grace_send, | |
5cb5f4d0 DD |
11978 | get_afi_safi_str(afi, |
11979 | safi, | |
11980 | true)); | |
05c7a1cc | 11981 | eor_send_af_count++; |
d62a17ae | 11982 | } |
11983 | } | |
05c7a1cc QY |
11984 | FOREACH_AFI_SAFI (afi, safi) { |
11985 | if (CHECK_FLAG( | |
36235319 QY |
11986 | p->af_sflags[afi][safi], |
11987 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11988 | json_object_boolean_true_add( |
11989 | json_grace_recv, | |
5cb5f4d0 DD |
11990 | get_afi_safi_str(afi, |
11991 | safi, | |
11992 | true)); | |
05c7a1cc | 11993 | eor_receive_af_count++; |
d62a17ae | 11994 | } |
11995 | } | |
11996 | } | |
36235319 QY |
11997 | json_object_object_add(json_grace, "endOfRibSend", |
11998 | json_grace_send); | |
11999 | json_object_object_add(json_grace, "endOfRibRecv", | |
12000 | json_grace_recv); | |
d62a17ae | 12001 | |
d62a17ae | 12002 | |
12003 | if (p->t_gr_restart) | |
12004 | json_object_int_add(json_grace, | |
12005 | "gracefulRestartTimerMsecs", | |
12006 | thread_timer_remain_second( | |
12007 | p->t_gr_restart) | |
12008 | * 1000); | |
12009 | ||
12010 | if (p->t_gr_stale) | |
12011 | json_object_int_add( | |
12012 | json_grace, | |
12013 | "gracefulStalepathTimerMsecs", | |
12014 | thread_timer_remain_second( | |
12015 | p->t_gr_stale) | |
12016 | * 1000); | |
2986cac2 | 12017 | /* more gr info in new format */ |
12018 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 12019 | json_grace); |
d62a17ae | 12020 | json_object_object_add( |
12021 | json_neigh, "gracefulRestartInfo", json_grace); | |
12022 | } else { | |
2089dd80 | 12023 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
12024 | if ((p->status == Established) |
12025 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 12026 | |
d62a17ae | 12027 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
12028 | FOREACH_AFI_SAFI (afi, safi) { |
12029 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12030 | PEER_STATUS_EOR_SEND)) { | |
12031 | vty_out(vty, "%s%s", | |
12032 | eor_send_af_count ? ", " | |
12033 | : "", | |
36235319 QY |
12034 | get_afi_safi_str( |
12035 | afi, safi, | |
12036 | false)); | |
05c7a1cc | 12037 | eor_send_af_count++; |
d62a17ae | 12038 | } |
12039 | } | |
12040 | vty_out(vty, "\n"); | |
12041 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
12042 | FOREACH_AFI_SAFI (afi, safi) { |
12043 | if (CHECK_FLAG( | |
12044 | p->af_sflags[afi][safi], | |
12045 | PEER_STATUS_EOR_RECEIVED)) { | |
12046 | vty_out(vty, "%s%s", | |
12047 | eor_receive_af_count | |
12048 | ? ", " | |
12049 | : "", | |
5cb5f4d0 DD |
12050 | get_afi_safi_str(afi, |
12051 | safi, | |
12052 | false)); | |
05c7a1cc | 12053 | eor_receive_af_count++; |
d62a17ae | 12054 | } |
12055 | } | |
12056 | vty_out(vty, "\n"); | |
12057 | } | |
12058 | ||
12059 | if (p->t_gr_restart) | |
12060 | vty_out(vty, | |
12061 | " The remaining time of restart timer is %ld\n", | |
12062 | thread_timer_remain_second( | |
12063 | p->t_gr_restart)); | |
12064 | ||
12065 | if (p->t_gr_stale) | |
12066 | vty_out(vty, | |
12067 | " The remaining time of stalepath timer is %ld\n", | |
12068 | thread_timer_remain_second( | |
12069 | p->t_gr_stale)); | |
2986cac2 | 12070 | |
12071 | /* more gr info in new format */ | |
12072 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 12073 | } |
2986cac2 | 12074 | |
d62a17ae | 12075 | if (use_json) { |
12076 | json_object *json_stat = NULL; | |
12077 | json_stat = json_object_new_object(); | |
12078 | /* Packet counts. */ | |
43aa5965 QY |
12079 | |
12080 | atomic_size_t outq_count, inq_count; | |
12081 | outq_count = atomic_load_explicit(&p->obuf->count, | |
12082 | memory_order_relaxed); | |
12083 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
12084 | memory_order_relaxed); | |
12085 | ||
12086 | json_object_int_add(json_stat, "depthInq", | |
12087 | (unsigned long)inq_count); | |
d62a17ae | 12088 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 12089 | (unsigned long)outq_count); |
0112e9e0 QY |
12090 | json_object_int_add(json_stat, "opensSent", |
12091 | atomic_load_explicit(&p->open_out, | |
12092 | memory_order_relaxed)); | |
12093 | json_object_int_add(json_stat, "opensRecv", | |
12094 | atomic_load_explicit(&p->open_in, | |
12095 | memory_order_relaxed)); | |
d62a17ae | 12096 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
12097 | atomic_load_explicit(&p->notify_out, |
12098 | memory_order_relaxed)); | |
d62a17ae | 12099 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
12100 | atomic_load_explicit(&p->notify_in, |
12101 | memory_order_relaxed)); | |
12102 | json_object_int_add(json_stat, "updatesSent", | |
12103 | atomic_load_explicit(&p->update_out, | |
12104 | memory_order_relaxed)); | |
12105 | json_object_int_add(json_stat, "updatesRecv", | |
12106 | atomic_load_explicit(&p->update_in, | |
12107 | memory_order_relaxed)); | |
d62a17ae | 12108 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
12109 | atomic_load_explicit(&p->keepalive_out, |
12110 | memory_order_relaxed)); | |
d62a17ae | 12111 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
12112 | atomic_load_explicit(&p->keepalive_in, |
12113 | memory_order_relaxed)); | |
d62a17ae | 12114 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
12115 | atomic_load_explicit(&p->refresh_out, |
12116 | memory_order_relaxed)); | |
d62a17ae | 12117 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
12118 | atomic_load_explicit(&p->refresh_in, |
12119 | memory_order_relaxed)); | |
d62a17ae | 12120 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
12121 | atomic_load_explicit(&p->dynamic_cap_out, |
12122 | memory_order_relaxed)); | |
d62a17ae | 12123 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
12124 | atomic_load_explicit(&p->dynamic_cap_in, |
12125 | memory_order_relaxed)); | |
12126 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
12127 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 12128 | json_object_object_add(json_neigh, "messageStats", json_stat); |
12129 | } else { | |
43aa5965 QY |
12130 | atomic_size_t outq_count, inq_count; |
12131 | outq_count = atomic_load_explicit(&p->obuf->count, | |
12132 | memory_order_relaxed); | |
12133 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
12134 | memory_order_relaxed); | |
12135 | ||
d62a17ae | 12136 | /* Packet counts. */ |
12137 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
12138 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
12139 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 12140 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
12141 | vty_out(vty, " Opens: %10d %10d\n", |
12142 | atomic_load_explicit(&p->open_out, | |
12143 | memory_order_relaxed), | |
12144 | atomic_load_explicit(&p->open_in, | |
12145 | memory_order_relaxed)); | |
12146 | vty_out(vty, " Notifications: %10d %10d\n", | |
12147 | atomic_load_explicit(&p->notify_out, | |
12148 | memory_order_relaxed), | |
12149 | atomic_load_explicit(&p->notify_in, | |
12150 | memory_order_relaxed)); | |
12151 | vty_out(vty, " Updates: %10d %10d\n", | |
12152 | atomic_load_explicit(&p->update_out, | |
12153 | memory_order_relaxed), | |
12154 | atomic_load_explicit(&p->update_in, | |
12155 | memory_order_relaxed)); | |
12156 | vty_out(vty, " Keepalives: %10d %10d\n", | |
12157 | atomic_load_explicit(&p->keepalive_out, | |
12158 | memory_order_relaxed), | |
12159 | atomic_load_explicit(&p->keepalive_in, | |
12160 | memory_order_relaxed)); | |
12161 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
12162 | atomic_load_explicit(&p->refresh_out, | |
12163 | memory_order_relaxed), | |
12164 | atomic_load_explicit(&p->refresh_in, | |
12165 | memory_order_relaxed)); | |
d62a17ae | 12166 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
12167 | atomic_load_explicit(&p->dynamic_cap_out, |
12168 | memory_order_relaxed), | |
12169 | atomic_load_explicit(&p->dynamic_cap_in, | |
12170 | memory_order_relaxed)); | |
12171 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
12172 | PEER_TOTAL_RX(p)); | |
d62a17ae | 12173 | } |
12174 | ||
12175 | if (use_json) { | |
12176 | /* advertisement-interval */ | |
12177 | json_object_int_add(json_neigh, | |
12178 | "minBtwnAdvertisementRunsTimerMsecs", | |
12179 | p->v_routeadv * 1000); | |
12180 | ||
12181 | /* Update-source. */ | |
12182 | if (p->update_if || p->update_source) { | |
12183 | if (p->update_if) | |
12184 | json_object_string_add(json_neigh, | |
12185 | "updateSource", | |
12186 | p->update_if); | |
12187 | else if (p->update_source) | |
12188 | json_object_string_add( | |
12189 | json_neigh, "updateSource", | |
12190 | sockunion2str(p->update_source, buf1, | |
12191 | SU_ADDRSTRLEN)); | |
12192 | } | |
12193 | } else { | |
12194 | /* advertisement-interval */ | |
12195 | vty_out(vty, | |
12196 | " Minimum time between advertisement runs is %d seconds\n", | |
12197 | p->v_routeadv); | |
12198 | ||
12199 | /* Update-source. */ | |
12200 | if (p->update_if || p->update_source) { | |
12201 | vty_out(vty, " Update source is "); | |
12202 | if (p->update_if) | |
12203 | vty_out(vty, "%s", p->update_if); | |
12204 | else if (p->update_source) | |
12205 | vty_out(vty, "%s", | |
12206 | sockunion2str(p->update_source, buf1, | |
12207 | SU_ADDRSTRLEN)); | |
12208 | vty_out(vty, "\n"); | |
12209 | } | |
12210 | ||
12211 | vty_out(vty, "\n"); | |
12212 | } | |
12213 | ||
12214 | /* Address Family Information */ | |
12215 | json_object *json_hold = NULL; | |
12216 | ||
12217 | if (use_json) | |
12218 | json_hold = json_object_new_object(); | |
12219 | ||
05c7a1cc QY |
12220 | FOREACH_AFI_SAFI (afi, safi) |
12221 | if (p->afc[afi][safi]) | |
12222 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
12223 | json_hold); | |
d62a17ae | 12224 | |
12225 | if (use_json) { | |
12226 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
12227 | json_hold); | |
12228 | json_object_int_add(json_neigh, "connectionsEstablished", | |
12229 | p->established); | |
12230 | json_object_int_add(json_neigh, "connectionsDropped", | |
12231 | p->dropped); | |
12232 | } else | |
12233 | vty_out(vty, " Connections established %d; dropped %d\n", | |
12234 | p->established, p->dropped); | |
12235 | ||
12236 | if (!p->last_reset) { | |
12237 | if (use_json) | |
12238 | json_object_string_add(json_neigh, "lastReset", | |
12239 | "never"); | |
12240 | else | |
12241 | vty_out(vty, " Last reset never\n"); | |
12242 | } else { | |
12243 | if (use_json) { | |
12244 | time_t uptime; | |
a2700b50 | 12245 | struct tm tm; |
d62a17ae | 12246 | |
12247 | uptime = bgp_clock(); | |
12248 | uptime -= p->resettime; | |
a2700b50 MS |
12249 | gmtime_r(&uptime, &tm); |
12250 | ||
d62a17ae | 12251 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
12252 | (tm.tm_sec * 1000) |
12253 | + (tm.tm_min * 60000) | |
12254 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 12255 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 12256 | } else { |
12257 | vty_out(vty, " Last reset %s, ", | |
12258 | peer_uptime(p->resettime, timebuf, | |
12259 | BGP_UPTIME_LEN, 0, NULL)); | |
12260 | ||
3577f1c5 | 12261 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 12262 | if (p->last_reset_cause_size) { |
12263 | msg = p->last_reset_cause; | |
12264 | vty_out(vty, | |
12265 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
12266 | for (i = 1; i <= p->last_reset_cause_size; | |
12267 | i++) { | |
12268 | vty_out(vty, "%02X", *msg++); | |
12269 | ||
12270 | if (i != p->last_reset_cause_size) { | |
12271 | if (i % 16 == 0) { | |
12272 | vty_out(vty, "\n "); | |
12273 | } else if (i % 4 == 0) { | |
12274 | vty_out(vty, " "); | |
12275 | } | |
12276 | } | |
12277 | } | |
12278 | vty_out(vty, "\n"); | |
12279 | } | |
12280 | } | |
12281 | } | |
12282 | ||
12283 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
12284 | if (use_json) | |
12285 | json_object_boolean_true_add(json_neigh, | |
12286 | "prefixesConfigExceedMax"); | |
12287 | else | |
12288 | vty_out(vty, | |
12289 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
12290 | ||
12291 | if (p->t_pmax_restart) { | |
12292 | if (use_json) { | |
12293 | json_object_boolean_true_add( | |
12294 | json_neigh, "reducePrefixNumFrom"); | |
12295 | json_object_int_add(json_neigh, | |
12296 | "restartInTimerMsec", | |
12297 | thread_timer_remain_second( | |
12298 | p->t_pmax_restart) | |
12299 | * 1000); | |
12300 | } else | |
12301 | vty_out(vty, | |
12302 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
12303 | p->host, thread_timer_remain_second( |
12304 | p->t_pmax_restart)); | |
d62a17ae | 12305 | } else { |
12306 | if (use_json) | |
12307 | json_object_boolean_true_add( | |
12308 | json_neigh, | |
12309 | "reducePrefixNumAndClearIpBgp"); | |
12310 | else | |
12311 | vty_out(vty, | |
12312 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
12313 | p->host); | |
12314 | } | |
12315 | } | |
12316 | ||
12317 | /* EBGP Multihop and GTSM */ | |
12318 | if (p->sort != BGP_PEER_IBGP) { | |
12319 | if (use_json) { | |
e2521429 | 12320 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12321 | json_object_int_add(json_neigh, |
12322 | "externalBgpNbrMaxHopsAway", | |
12323 | p->gtsm_hops); | |
c8d6f0d6 | 12324 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12325 | json_object_int_add(json_neigh, |
12326 | "externalBgpNbrMaxHopsAway", | |
12327 | p->ttl); | |
12328 | } else { | |
e2521429 | 12329 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12330 | vty_out(vty, |
12331 | " External BGP neighbor may be up to %d hops away.\n", | |
12332 | p->gtsm_hops); | |
c8d6f0d6 | 12333 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12334 | vty_out(vty, |
12335 | " External BGP neighbor may be up to %d hops away.\n", | |
12336 | p->ttl); | |
12337 | } | |
12338 | } else { | |
e2521429 | 12339 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 12340 | if (use_json) |
12341 | json_object_int_add(json_neigh, | |
12342 | "internalBgpNbrMaxHopsAway", | |
12343 | p->gtsm_hops); | |
12344 | else | |
12345 | vty_out(vty, | |
12346 | " Internal BGP neighbor may be up to %d hops away.\n", | |
12347 | p->gtsm_hops); | |
12348 | } | |
12349 | } | |
12350 | ||
12351 | /* Local address. */ | |
12352 | if (p->su_local) { | |
12353 | if (use_json) { | |
12354 | json_object_string_add(json_neigh, "hostLocal", | |
12355 | sockunion2str(p->su_local, buf1, | |
12356 | SU_ADDRSTRLEN)); | |
12357 | json_object_int_add(json_neigh, "portLocal", | |
12358 | ntohs(p->su_local->sin.sin_port)); | |
12359 | } else | |
12360 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
12361 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
12362 | ntohs(p->su_local->sin.sin_port)); | |
12363 | } | |
12364 | ||
12365 | /* Remote address. */ | |
12366 | if (p->su_remote) { | |
12367 | if (use_json) { | |
12368 | json_object_string_add(json_neigh, "hostForeign", | |
12369 | sockunion2str(p->su_remote, buf1, | |
12370 | SU_ADDRSTRLEN)); | |
12371 | json_object_int_add(json_neigh, "portForeign", | |
12372 | ntohs(p->su_remote->sin.sin_port)); | |
12373 | } else | |
12374 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
12375 | sockunion2str(p->su_remote, buf1, | |
12376 | SU_ADDRSTRLEN), | |
12377 | ntohs(p->su_remote->sin.sin_port)); | |
12378 | } | |
12379 | ||
12380 | /* Nexthop display. */ | |
12381 | if (p->su_local) { | |
12382 | if (use_json) { | |
12383 | json_object_string_add(json_neigh, "nexthop", | |
12384 | inet_ntop(AF_INET, | |
12385 | &p->nexthop.v4, buf1, | |
12386 | sizeof(buf1))); | |
12387 | json_object_string_add(json_neigh, "nexthopGlobal", | |
12388 | inet_ntop(AF_INET6, | |
12389 | &p->nexthop.v6_global, | |
12390 | buf1, sizeof(buf1))); | |
12391 | json_object_string_add(json_neigh, "nexthopLocal", | |
12392 | inet_ntop(AF_INET6, | |
12393 | &p->nexthop.v6_local, | |
12394 | buf1, sizeof(buf1))); | |
12395 | if (p->shared_network) | |
12396 | json_object_string_add(json_neigh, | |
12397 | "bgpConnection", | |
12398 | "sharedNetwork"); | |
12399 | else | |
12400 | json_object_string_add(json_neigh, | |
12401 | "bgpConnection", | |
12402 | "nonSharedNetwork"); | |
12403 | } else { | |
12404 | vty_out(vty, "Nexthop: %s\n", | |
12405 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
12406 | sizeof(buf1))); | |
12407 | vty_out(vty, "Nexthop global: %s\n", | |
12408 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
12409 | sizeof(buf1))); | |
12410 | vty_out(vty, "Nexthop local: %s\n", | |
12411 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
12412 | sizeof(buf1))); | |
12413 | vty_out(vty, "BGP connection: %s\n", | |
12414 | p->shared_network ? "shared network" | |
12415 | : "non shared network"); | |
12416 | } | |
12417 | } | |
12418 | ||
12419 | /* Timer information. */ | |
12420 | if (use_json) { | |
12421 | json_object_int_add(json_neigh, "connectRetryTimer", | |
12422 | p->v_connect); | |
12423 | if (p->status == Established && p->rtt) | |
12424 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
12425 | p->rtt); | |
12426 | if (p->t_start) | |
12427 | json_object_int_add( | |
12428 | json_neigh, "nextStartTimerDueInMsecs", | |
12429 | thread_timer_remain_second(p->t_start) * 1000); | |
12430 | if (p->t_connect) | |
12431 | json_object_int_add( | |
12432 | json_neigh, "nextConnectTimerDueInMsecs", | |
12433 | thread_timer_remain_second(p->t_connect) | |
12434 | * 1000); | |
12435 | if (p->t_routeadv) { | |
12436 | json_object_int_add(json_neigh, "mraiInterval", | |
12437 | p->v_routeadv); | |
12438 | json_object_int_add( | |
12439 | json_neigh, "mraiTimerExpireInMsecs", | |
12440 | thread_timer_remain_second(p->t_routeadv) | |
12441 | * 1000); | |
12442 | } | |
12443 | if (p->password) | |
12444 | json_object_int_add(json_neigh, "authenticationEnabled", | |
12445 | 1); | |
12446 | ||
12447 | if (p->t_read) | |
12448 | json_object_string_add(json_neigh, "readThread", "on"); | |
12449 | else | |
12450 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
12451 | |
12452 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 12453 | json_object_string_add(json_neigh, "writeThread", "on"); |
12454 | else | |
12455 | json_object_string_add(json_neigh, "writeThread", | |
12456 | "off"); | |
12457 | } else { | |
12458 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
12459 | p->v_connect); | |
12460 | if (p->status == Established && p->rtt) | |
12461 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
12462 | p->rtt); | |
12463 | if (p->t_start) | |
12464 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
12465 | thread_timer_remain_second(p->t_start)); | |
12466 | if (p->t_connect) | |
12467 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
12468 | thread_timer_remain_second(p->t_connect)); | |
12469 | if (p->t_routeadv) | |
12470 | vty_out(vty, | |
12471 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12472 | p->v_routeadv, | |
12473 | thread_timer_remain_second(p->t_routeadv)); | |
12474 | if (p->password) | |
12475 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12476 | ||
cac9e917 | 12477 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12478 | p->t_read ? "on" : "off", |
12479 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12480 | ? "on" | |
cac9e917 | 12481 | : "off", p->fd); |
d62a17ae | 12482 | } |
12483 | ||
12484 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12485 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12486 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12487 | ||
12488 | if (!use_json) | |
12489 | vty_out(vty, "\n"); | |
12490 | ||
12491 | /* BFD information. */ | |
12492 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12493 | ||
12494 | if (use_json) { | |
12495 | if (p->conf_if) /* Configured interface name. */ | |
12496 | json_object_object_add(json, p->conf_if, json_neigh); | |
12497 | else /* Configured IP address. */ | |
12498 | json_object_object_add(json, p->host, json_neigh); | |
12499 | } | |
12500 | } | |
12501 | ||
36235319 QY |
12502 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
12503 | enum show_type type, | |
12504 | union sockunion *su, | |
12505 | const char *conf_if, afi_t afi, | |
74a630b6 | 12506 | bool use_json) |
2986cac2 | 12507 | { |
12508 | struct listnode *node, *nnode; | |
12509 | struct peer *peer; | |
12510 | int find = 0; | |
12511 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 12512 | json_object *json = NULL; |
2986cac2 | 12513 | json_object *json_neighbor = NULL; |
12514 | ||
74a630b6 NT |
12515 | if (use_json) { |
12516 | json = json_object_new_object(); | |
12517 | json_neighbor = json_object_new_object(); | |
12518 | } | |
12519 | ||
2986cac2 | 12520 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
12521 | ||
12522 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12523 | continue; | |
12524 | ||
12525 | if ((peer->afc[afi][safi]) == 0) | |
12526 | continue; | |
12527 | ||
2ba1fe69 | 12528 | if (type == show_all) { |
2986cac2 | 12529 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 12530 | json_neighbor); |
2986cac2 | 12531 | |
74a630b6 | 12532 | if (use_json) { |
13909c4f DS |
12533 | json_object_object_add(json, peer->host, |
12534 | json_neighbor); | |
74a630b6 NT |
12535 | json_neighbor = NULL; |
12536 | } | |
2986cac2 | 12537 | |
2ba1fe69 | 12538 | } else if (type == show_peer) { |
2986cac2 | 12539 | if (conf_if) { |
12540 | if ((peer->conf_if | |
13909c4f DS |
12541 | && !strcmp(peer->conf_if, conf_if)) |
12542 | || (peer->hostname | |
2986cac2 | 12543 | && !strcmp(peer->hostname, conf_if))) { |
12544 | find = 1; | |
13909c4f DS |
12545 | bgp_show_peer_gr_status(vty, peer, |
12546 | use_json, | |
12547 | json_neighbor); | |
2986cac2 | 12548 | } |
12549 | } else { | |
12550 | if (sockunion_same(&peer->su, su)) { | |
12551 | find = 1; | |
13909c4f DS |
12552 | bgp_show_peer_gr_status(vty, peer, |
12553 | use_json, | |
12554 | json_neighbor); | |
2986cac2 | 12555 | } |
12556 | } | |
13909c4f DS |
12557 | if (use_json && find) |
12558 | json_object_object_add(json, peer->host, | |
12559 | json_neighbor); | |
2986cac2 | 12560 | } |
12561 | ||
74a630b6 NT |
12562 | if (find) { |
12563 | json_neighbor = NULL; | |
2986cac2 | 12564 | break; |
74a630b6 | 12565 | } |
2986cac2 | 12566 | } |
12567 | ||
12568 | if (type == show_peer && !find) { | |
12569 | if (use_json) | |
13909c4f | 12570 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 12571 | else |
12572 | vty_out(vty, "%% No such neighbor\n"); | |
12573 | } | |
12574 | if (use_json) { | |
13909c4f DS |
12575 | vty_out(vty, "%s\n", |
12576 | json_object_to_json_string_ext( | |
12577 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
12578 | |
12579 | if (json_neighbor) | |
12580 | json_object_free(json_neighbor); | |
12581 | json_object_free(json); | |
2986cac2 | 12582 | } else { |
12583 | vty_out(vty, "\n"); | |
12584 | } | |
12585 | ||
12586 | return CMD_SUCCESS; | |
12587 | } | |
12588 | ||
d62a17ae | 12589 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12590 | enum show_type type, union sockunion *su, | |
9f049418 | 12591 | const char *conf_if, bool use_json, |
d62a17ae | 12592 | json_object *json) |
12593 | { | |
12594 | struct listnode *node, *nnode; | |
12595 | struct peer *peer; | |
12596 | int find = 0; | |
9f049418 | 12597 | bool nbr_output = false; |
d1927ebe AS |
12598 | afi_t afi = AFI_MAX; |
12599 | safi_t safi = SAFI_MAX; | |
12600 | ||
12601 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12602 | afi = AFI_IP; | |
12603 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12604 | afi = AFI_IP6; | |
12605 | } | |
d62a17ae | 12606 | |
12607 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12608 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12609 | continue; | |
12610 | ||
12611 | switch (type) { | |
12612 | case show_all: | |
12613 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12614 | nbr_output = true; |
d62a17ae | 12615 | break; |
12616 | case show_peer: | |
12617 | if (conf_if) { | |
12618 | if ((peer->conf_if | |
12619 | && !strcmp(peer->conf_if, conf_if)) | |
12620 | || (peer->hostname | |
12621 | && !strcmp(peer->hostname, conf_if))) { | |
12622 | find = 1; | |
12623 | bgp_show_peer(vty, peer, use_json, | |
12624 | json); | |
12625 | } | |
12626 | } else { | |
12627 | if (sockunion_same(&peer->su, su)) { | |
12628 | find = 1; | |
12629 | bgp_show_peer(vty, peer, use_json, | |
12630 | json); | |
12631 | } | |
12632 | } | |
12633 | break; | |
d1927ebe AS |
12634 | case show_ipv4_peer: |
12635 | case show_ipv6_peer: | |
12636 | FOREACH_SAFI (safi) { | |
12637 | if (peer->afc[afi][safi]) { | |
12638 | if (conf_if) { | |
12639 | if ((peer->conf_if | |
12640 | && !strcmp(peer->conf_if, conf_if)) | |
12641 | || (peer->hostname | |
12642 | && !strcmp(peer->hostname, conf_if))) { | |
12643 | find = 1; | |
12644 | bgp_show_peer(vty, peer, use_json, | |
12645 | json); | |
12646 | break; | |
12647 | } | |
12648 | } else { | |
12649 | if (sockunion_same(&peer->su, su)) { | |
12650 | find = 1; | |
12651 | bgp_show_peer(vty, peer, use_json, | |
12652 | json); | |
12653 | break; | |
12654 | } | |
12655 | } | |
12656 | } | |
12657 | } | |
12658 | break; | |
12659 | case show_ipv4_all: | |
12660 | case show_ipv6_all: | |
12661 | FOREACH_SAFI (safi) { | |
12662 | if (peer->afc[afi][safi]) { | |
12663 | bgp_show_peer(vty, peer, use_json, json); | |
12664 | nbr_output = true; | |
12665 | break; | |
12666 | } | |
12667 | } | |
12668 | break; | |
d62a17ae | 12669 | } |
12670 | } | |
12671 | ||
d1927ebe AS |
12672 | if ((type == show_peer || type == show_ipv4_peer || |
12673 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12674 | if (use_json) |
12675 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12676 | else | |
88b7d255 | 12677 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12678 | } |
12679 | ||
d1927ebe AS |
12680 | if (type != show_peer && type != show_ipv4_peer && |
12681 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12682 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12683 | |
d62a17ae | 12684 | if (use_json) { |
996c9314 LB |
12685 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12686 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12687 | } else { |
12688 | vty_out(vty, "\n"); | |
12689 | } | |
12690 | ||
12691 | return CMD_SUCCESS; | |
12692 | } | |
12693 | ||
36235319 QY |
12694 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12695 | enum show_type type, | |
12696 | const char *ip_str, | |
12697 | afi_t afi, bool use_json) | |
2986cac2 | 12698 | { |
12699 | ||
12700 | int ret; | |
12701 | struct bgp *bgp; | |
12702 | union sockunion su; | |
2986cac2 | 12703 | |
12704 | bgp = bgp_get_default(); | |
12705 | ||
13909c4f DS |
12706 | if (!bgp) |
12707 | return; | |
2986cac2 | 12708 | |
13909c4f DS |
12709 | if (!use_json) |
12710 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
12711 | NULL); | |
2986cac2 | 12712 | |
13909c4f DS |
12713 | if (ip_str) { |
12714 | ret = str2sockunion(ip_str, &su); | |
12715 | if (ret < 0) | |
13909c4f | 12716 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
12717 | vty, bgp, type, NULL, ip_str, afi, use_json); |
12718 | else | |
12719 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
12720 | NULL, afi, use_json); | |
13909c4f DS |
12721 | } else |
12722 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 12723 | afi, use_json); |
2986cac2 | 12724 | } |
12725 | ||
d62a17ae | 12726 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12727 | enum show_type type, |
12728 | const char *ip_str, | |
9f049418 | 12729 | bool use_json) |
d62a17ae | 12730 | { |
0291c246 MK |
12731 | struct listnode *node, *nnode; |
12732 | struct bgp *bgp; | |
71aedaa3 | 12733 | union sockunion su; |
0291c246 | 12734 | json_object *json = NULL; |
71aedaa3 | 12735 | int ret, is_first = 1; |
9f049418 | 12736 | bool nbr_output = false; |
d62a17ae | 12737 | |
12738 | if (use_json) | |
12739 | vty_out(vty, "{\n"); | |
12740 | ||
12741 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12742 | nbr_output = true; |
d62a17ae | 12743 | if (use_json) { |
12744 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12745 | flog_err( |
e50f7cfd | 12746 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12747 | "Unable to allocate memory for JSON object"); |
12748 | vty_out(vty, | |
12749 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12750 | return; | |
12751 | } | |
12752 | ||
12753 | json_object_int_add(json, "vrfId", | |
12754 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12755 | ? -1 |
12756 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12757 | json_object_string_add( |
12758 | json, "vrfName", | |
12759 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12760 | ? VRF_DEFAULT_NAME |
d62a17ae | 12761 | : bgp->name); |
12762 | ||
12763 | if (!is_first) | |
12764 | vty_out(vty, ",\n"); | |
12765 | else | |
12766 | is_first = 0; | |
12767 | ||
12768 | vty_out(vty, "\"%s\":", | |
12769 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12770 | ? VRF_DEFAULT_NAME |
d62a17ae | 12771 | : bgp->name); |
12772 | } else { | |
12773 | vty_out(vty, "\nInstance %s:\n", | |
12774 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12775 | ? VRF_DEFAULT_NAME |
d62a17ae | 12776 | : bgp->name); |
12777 | } | |
71aedaa3 | 12778 | |
d1927ebe AS |
12779 | if (type == show_peer || type == show_ipv4_peer || |
12780 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12781 | ret = str2sockunion(ip_str, &su); |
12782 | if (ret < 0) | |
12783 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12784 | use_json, json); | |
12785 | else | |
12786 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12787 | use_json, json); | |
12788 | } else { | |
d1927ebe | 12789 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12790 | use_json, json); |
12791 | } | |
b77004d6 | 12792 | json_object_free(json); |
d62a17ae | 12793 | } |
12794 | ||
01cbfd04 | 12795 | if (use_json) { |
d62a17ae | 12796 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12797 | json_object_free(json); |
12798 | } | |
9f049418 DS |
12799 | else if (!nbr_output) |
12800 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12801 | } |
12802 | ||
12803 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12804 | enum show_type type, const char *ip_str, | |
9f049418 | 12805 | bool use_json) |
d62a17ae | 12806 | { |
12807 | int ret; | |
12808 | struct bgp *bgp; | |
12809 | union sockunion su; | |
12810 | json_object *json = NULL; | |
12811 | ||
12812 | if (name) { | |
12813 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12814 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12815 | use_json); | |
d62a17ae | 12816 | return CMD_SUCCESS; |
12817 | } else { | |
12818 | bgp = bgp_lookup_by_name(name); | |
12819 | if (!bgp) { | |
12820 | if (use_json) { | |
12821 | json = json_object_new_object(); | |
d62a17ae | 12822 | vty_out(vty, "%s\n", |
12823 | json_object_to_json_string_ext( | |
12824 | json, | |
12825 | JSON_C_TO_STRING_PRETTY)); | |
12826 | json_object_free(json); | |
12827 | } else | |
12828 | vty_out(vty, | |
9f049418 | 12829 | "%% BGP instance not found\n"); |
d62a17ae | 12830 | |
12831 | return CMD_WARNING; | |
12832 | } | |
12833 | } | |
12834 | } else { | |
12835 | bgp = bgp_get_default(); | |
12836 | } | |
12837 | ||
12838 | if (bgp) { | |
12839 | json = json_object_new_object(); | |
12840 | if (ip_str) { | |
12841 | ret = str2sockunion(ip_str, &su); | |
12842 | if (ret < 0) | |
12843 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12844 | use_json, json); | |
12845 | else | |
12846 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12847 | use_json, json); | |
12848 | } else { | |
12849 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12850 | json); | |
12851 | } | |
12852 | json_object_free(json); | |
ca61fd25 DS |
12853 | } else { |
12854 | if (use_json) | |
12855 | vty_out(vty, "{}\n"); | |
12856 | else | |
12857 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12858 | } |
12859 | ||
12860 | return CMD_SUCCESS; | |
4fb25c53 DW |
12861 | } |
12862 | ||
2986cac2 | 12863 | |
12864 | ||
12865 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12866 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12867 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12868 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12869 | SHOW_STR | |
12870 | BGP_STR | |
12871 | IP_STR | |
12872 | IPV6_STR | |
12873 | NEIGHBOR_STR | |
12874 | "Neighbor to display information about\n" | |
12875 | "Neighbor to display information about\n" | |
12876 | "Neighbor on BGP configured interface\n" | |
12877 | GR_SHOW | |
12878 | JSON_STR) | |
12879 | { | |
12880 | char *sh_arg = NULL; | |
12881 | enum show_type sh_type; | |
12882 | int idx = 0; | |
12883 | afi_t afi = AFI_MAX; | |
2986cac2 | 12884 | bool uj = use_json(argc, argv); |
12885 | ||
36235319 | 12886 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 12887 | afi = AFI_MAX; |
12888 | ||
12889 | idx++; | |
12890 | ||
12891 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12892 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12893 | || argv_find(argv, argc, "WORD", &idx)) { | |
12894 | sh_type = show_peer; | |
12895 | sh_arg = argv[idx]->arg; | |
12896 | } else | |
12897 | sh_type = show_all; | |
12898 | ||
12899 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12900 | return CMD_SUCCESS; | |
12901 | ||
12902 | ||
36235319 QY |
12903 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
12904 | afi, uj); | |
2986cac2 | 12905 | } |
12906 | ||
716b2d8a | 12907 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12908 | DEFUN (show_ip_bgp_neighbors, |
12909 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12910 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12911 | SHOW_STR |
12912 | IP_STR | |
12913 | BGP_STR | |
f2a8972b | 12914 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12915 | "Address Family\n" |
12916 | "Address Family\n" | |
718e3744 | 12917 | "Detailed information on TCP and BGP neighbor connections\n" |
12918 | "Neighbor to display information about\n" | |
a80beece | 12919 | "Neighbor to display information about\n" |
91d37724 | 12920 | "Neighbor on BGP configured interface\n" |
9973d184 | 12921 | JSON_STR) |
718e3744 | 12922 | { |
d62a17ae | 12923 | char *vrf = NULL; |
12924 | char *sh_arg = NULL; | |
12925 | enum show_type sh_type; | |
d1927ebe | 12926 | afi_t afi = AFI_MAX; |
718e3744 | 12927 | |
9f049418 | 12928 | bool uj = use_json(argc, argv); |
718e3744 | 12929 | |
d62a17ae | 12930 | int idx = 0; |
718e3744 | 12931 | |
9a8bdf1c PG |
12932 | /* [<vrf> VIEWVRFNAME] */ |
12933 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12934 | vrf = argv[idx + 1]->arg; | |
12935 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12936 | vrf = NULL; | |
12937 | } else if (argv_find(argv, argc, "view", &idx)) | |
12938 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12939 | vrf = argv[idx + 1]->arg; |
718e3744 | 12940 | |
d62a17ae | 12941 | idx++; |
d1927ebe AS |
12942 | |
12943 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12944 | sh_type = show_ipv4_all; | |
12945 | afi = AFI_IP; | |
12946 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12947 | sh_type = show_ipv6_all; | |
12948 | afi = AFI_IP6; | |
12949 | } else { | |
12950 | sh_type = show_all; | |
12951 | } | |
12952 | ||
d62a17ae | 12953 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12954 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12955 | || argv_find(argv, argc, "WORD", &idx)) { | |
12956 | sh_type = show_peer; | |
12957 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12958 | } |
12959 | ||
12960 | if (sh_type == show_peer && afi == AFI_IP) { | |
12961 | sh_type = show_ipv4_peer; | |
12962 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12963 | sh_type = show_ipv6_peer; | |
12964 | } | |
856ca177 | 12965 | |
d62a17ae | 12966 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12967 | } |
12968 | ||
716b2d8a | 12969 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12970 | paths' and `show ip mbgp paths'. Those functions results are the |
12971 | same.*/ | |
f412b39a | 12972 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12973 | show_ip_bgp_paths_cmd, |
46f296b4 | 12974 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12975 | SHOW_STR |
12976 | IP_STR | |
12977 | BGP_STR | |
46f296b4 | 12978 | BGP_SAFI_HELP_STR |
718e3744 | 12979 | "Path information\n") |
12980 | { | |
d62a17ae | 12981 | vty_out(vty, "Address Refcnt Path\n"); |
12982 | aspath_print_all_vty(vty); | |
12983 | return CMD_SUCCESS; | |
718e3744 | 12984 | } |
12985 | ||
718e3744 | 12986 | #include "hash.h" |
12987 | ||
e3b78da8 | 12988 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12989 | struct vty *vty) |
718e3744 | 12990 | { |
d62a17ae | 12991 | struct community *com; |
718e3744 | 12992 | |
e3b78da8 | 12993 | com = (struct community *)bucket->data; |
3f65c5b1 | 12994 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12995 | community_str(com, false)); |
718e3744 | 12996 | } |
12997 | ||
12998 | /* Show BGP's community internal data. */ | |
f412b39a | 12999 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 13000 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 13001 | "show [ip] bgp community-info", |
718e3744 | 13002 | SHOW_STR |
13003 | IP_STR | |
13004 | BGP_STR | |
13005 | "List all bgp community information\n") | |
13006 | { | |
d62a17ae | 13007 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 13008 | |
d62a17ae | 13009 | hash_iterate(community_hash(), |
e3b78da8 | 13010 | (void (*)(struct hash_bucket *, |
d62a17ae | 13011 | void *))community_show_all_iterator, |
13012 | vty); | |
718e3744 | 13013 | |
d62a17ae | 13014 | return CMD_SUCCESS; |
718e3744 | 13015 | } |
13016 | ||
e3b78da8 | 13017 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 13018 | struct vty *vty) |
57d187bc | 13019 | { |
d62a17ae | 13020 | struct lcommunity *lcom; |
57d187bc | 13021 | |
e3b78da8 | 13022 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 13023 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 13024 | lcommunity_str(lcom, false)); |
57d187bc JS |
13025 | } |
13026 | ||
13027 | /* Show BGP's community internal data. */ | |
13028 | DEFUN (show_ip_bgp_lcommunity_info, | |
13029 | show_ip_bgp_lcommunity_info_cmd, | |
13030 | "show ip bgp large-community-info", | |
13031 | SHOW_STR | |
13032 | IP_STR | |
13033 | BGP_STR | |
13034 | "List all bgp large-community information\n") | |
13035 | { | |
d62a17ae | 13036 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 13037 | |
d62a17ae | 13038 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 13039 | (void (*)(struct hash_bucket *, |
d62a17ae | 13040 | void *))lcommunity_show_all_iterator, |
13041 | vty); | |
57d187bc | 13042 | |
d62a17ae | 13043 | return CMD_SUCCESS; |
57d187bc | 13044 | } |
2986cac2 | 13045 | /* Graceful Restart */ |
13046 | ||
13047 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
13048 | struct bgp *bgp, |
13049 | bool use_json, | |
13050 | json_object *json) | |
2986cac2 | 13051 | { |
57d187bc JS |
13052 | |
13053 | ||
2986cac2 | 13054 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
13055 | ||
7318ae88 | 13056 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 13057 | |
13058 | switch (bgp_global_gr_mode) { | |
13059 | ||
13060 | case GLOBAL_HELPER: | |
13909c4f | 13061 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 13062 | break; |
13063 | ||
13064 | case GLOBAL_GR: | |
13909c4f | 13065 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 13066 | break; |
13067 | ||
13068 | case GLOBAL_DISABLE: | |
13909c4f | 13069 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 13070 | break; |
13071 | ||
13072 | case GLOBAL_INVALID: | |
2986cac2 | 13073 | vty_out(vty, |
2ba1fe69 | 13074 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 13075 | break; |
13076 | } | |
13077 | vty_out(vty, "\n"); | |
13078 | } | |
13079 | ||
36235319 QY |
13080 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
13081 | enum show_type type, | |
13082 | const char *ip_str, | |
13083 | afi_t afi, bool use_json) | |
2986cac2 | 13084 | { |
13085 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
13086 | afi = AFI_IP; | |
13087 | ||
13088 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
13089 | ||
36235319 QY |
13090 | bgp_show_neighbor_graceful_restart_vty( |
13091 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 13092 | afi++; |
13093 | } | |
13094 | } else if (afi != AFI_MAX) { | |
36235319 QY |
13095 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
13096 | use_json); | |
2986cac2 | 13097 | } else { |
13098 | return CMD_ERR_INCOMPLETE; | |
13099 | } | |
13100 | ||
13101 | return CMD_SUCCESS; | |
13102 | } | |
13103 | /* Graceful Restart */ | |
13104 | ||
f412b39a | 13105 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 13106 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 13107 | "show [ip] bgp attribute-info", |
718e3744 | 13108 | SHOW_STR |
13109 | IP_STR | |
13110 | BGP_STR | |
13111 | "List all bgp attribute information\n") | |
13112 | { | |
d62a17ae | 13113 | attr_show_all(vty); |
13114 | return CMD_SUCCESS; | |
718e3744 | 13115 | } |
6b0655a2 | 13116 | |
03915806 CS |
13117 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
13118 | afi_t afi, safi_t safi, | |
13119 | bool use_json, json_object *json) | |
53089bec | 13120 | { |
13121 | struct bgp *bgp; | |
13122 | struct listnode *node; | |
13123 | char *vname; | |
13124 | char buf1[INET6_ADDRSTRLEN]; | |
13125 | char *ecom_str; | |
13126 | vpn_policy_direction_t dir; | |
13127 | ||
03915806 | 13128 | if (json) { |
b46dfd20 DS |
13129 | json_object *json_import_vrfs = NULL; |
13130 | json_object *json_export_vrfs = NULL; | |
13131 | ||
b46dfd20 DS |
13132 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13133 | ||
53089bec | 13134 | if (!bgp) { |
b46dfd20 DS |
13135 | vty_out(vty, "%s\n", |
13136 | json_object_to_json_string_ext( | |
13137 | json, | |
13138 | JSON_C_TO_STRING_PRETTY)); | |
13139 | json_object_free(json); | |
13140 | ||
53089bec | 13141 | return CMD_WARNING; |
13142 | } | |
b46dfd20 | 13143 | |
94d4c685 DS |
13144 | /* Provide context for the block */ |
13145 | json_object_string_add(json, "vrf", name ? name : "default"); | |
13146 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 13147 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 13148 | |
b46dfd20 DS |
13149 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13150 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
13151 | json_object_string_add(json, "importFromVrfs", "none"); | |
13152 | json_object_string_add(json, "importRts", "none"); | |
13153 | } else { | |
6ce24e52 DS |
13154 | json_import_vrfs = json_object_new_array(); |
13155 | ||
b46dfd20 DS |
13156 | for (ALL_LIST_ELEMENTS_RO( |
13157 | bgp->vpn_policy[afi].import_vrf, | |
13158 | node, vname)) | |
13159 | json_object_array_add(json_import_vrfs, | |
13160 | json_object_new_string(vname)); | |
13161 | ||
b20875ea CS |
13162 | json_object_object_add(json, "importFromVrfs", |
13163 | json_import_vrfs); | |
b46dfd20 | 13164 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
13165 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13166 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13167 | bgp->vpn_policy[afi].rtlist[dir], |
13168 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13169 | json_object_string_add(json, "importRts", |
13170 | ecom_str); | |
13171 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13172 | } else | |
13173 | json_object_string_add(json, "importRts", | |
13174 | "none"); | |
b46dfd20 DS |
13175 | } |
13176 | ||
13177 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
13178 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
13179 | json_object_string_add(json, "exportToVrfs", "none"); | |
13180 | json_object_string_add(json, "routeDistinguisher", | |
13181 | "none"); | |
13182 | json_object_string_add(json, "exportRts", "none"); | |
13183 | } else { | |
6ce24e52 DS |
13184 | json_export_vrfs = json_object_new_array(); |
13185 | ||
b46dfd20 DS |
13186 | for (ALL_LIST_ELEMENTS_RO( |
13187 | bgp->vpn_policy[afi].export_vrf, | |
13188 | node, vname)) | |
13189 | json_object_array_add(json_export_vrfs, | |
13190 | json_object_new_string(vname)); | |
13191 | json_object_object_add(json, "exportToVrfs", | |
13192 | json_export_vrfs); | |
13193 | json_object_string_add(json, "routeDistinguisher", | |
13194 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13195 | buf1, RD_ADDRSTRLEN)); | |
13196 | ||
13197 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13198 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13199 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13200 | bgp->vpn_policy[afi].rtlist[dir], |
13201 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13202 | json_object_string_add(json, "exportRts", |
13203 | ecom_str); | |
13204 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13205 | } else | |
13206 | json_object_string_add(json, "exportRts", | |
13207 | "none"); | |
b46dfd20 DS |
13208 | } |
13209 | ||
03915806 CS |
13210 | if (use_json) { |
13211 | vty_out(vty, "%s\n", | |
13212 | json_object_to_json_string_ext(json, | |
b46dfd20 | 13213 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
13214 | json_object_free(json); |
13215 | } | |
53089bec | 13216 | } else { |
b46dfd20 DS |
13217 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13218 | ||
53089bec | 13219 | if (!bgp) { |
b46dfd20 | 13220 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 13221 | return CMD_WARNING; |
13222 | } | |
53089bec | 13223 | |
b46dfd20 DS |
13224 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13225 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
13226 | vty_out(vty, | |
13227 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 13228 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13229 | else { |
13230 | vty_out(vty, | |
13231 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 13232 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13233 | |
13234 | for (ALL_LIST_ELEMENTS_RO( | |
13235 | bgp->vpn_policy[afi].import_vrf, | |
13236 | node, vname)) | |
13237 | vty_out(vty, " %s\n", vname); | |
13238 | ||
13239 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
13240 | ecom_str = NULL; |
13241 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
13242 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13243 | bgp->vpn_policy[afi].rtlist[dir], |
13244 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 13245 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 13246 | |
b20875ea CS |
13247 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
13248 | } else | |
13249 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13250 | } |
53089bec | 13251 | |
b46dfd20 DS |
13252 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13253 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
13254 | vty_out(vty, | |
13255 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 13256 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13257 | else { |
13258 | vty_out(vty, | |
04c9077f | 13259 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 13260 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13261 | |
13262 | for (ALL_LIST_ELEMENTS_RO( | |
13263 | bgp->vpn_policy[afi].export_vrf, | |
13264 | node, vname)) | |
13265 | vty_out(vty, " %s\n", vname); | |
13266 | ||
13267 | vty_out(vty, "RD: %s\n", | |
13268 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13269 | buf1, RD_ADDRSTRLEN)); | |
13270 | ||
13271 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13272 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13273 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13274 | bgp->vpn_policy[afi].rtlist[dir], |
13275 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13276 | vty_out(vty, "Export RT: %s\n", ecom_str); |
13277 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13278 | } else | |
13279 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13280 | } |
53089bec | 13281 | } |
13282 | ||
13283 | return CMD_SUCCESS; | |
13284 | } | |
13285 | ||
03915806 CS |
13286 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
13287 | safi_t safi, bool use_json) | |
13288 | { | |
13289 | struct listnode *node, *nnode; | |
13290 | struct bgp *bgp; | |
13291 | char *vrf_name = NULL; | |
13292 | json_object *json = NULL; | |
13293 | json_object *json_vrf = NULL; | |
13294 | json_object *json_vrfs = NULL; | |
13295 | ||
13296 | if (use_json) { | |
13297 | json = json_object_new_object(); | |
13298 | json_vrfs = json_object_new_object(); | |
13299 | } | |
13300 | ||
13301 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
13302 | ||
13303 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
13304 | vrf_name = bgp->name; | |
13305 | ||
13306 | if (use_json) { | |
13307 | json_vrf = json_object_new_object(); | |
13308 | } else { | |
13309 | vty_out(vty, "\nInstance %s:\n", | |
13310 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13311 | ? VRF_DEFAULT_NAME : bgp->name); | |
13312 | } | |
13313 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
13314 | if (use_json) { | |
13315 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13316 | json_object_object_add(json_vrfs, | |
13317 | VRF_DEFAULT_NAME, json_vrf); | |
13318 | else | |
13319 | json_object_object_add(json_vrfs, vrf_name, | |
13320 | json_vrf); | |
13321 | } | |
13322 | } | |
13323 | ||
13324 | if (use_json) { | |
13325 | json_object_object_add(json, "vrfs", json_vrfs); | |
13326 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
13327 | JSON_C_TO_STRING_PRETTY)); | |
13328 | json_object_free(json); | |
13329 | } | |
13330 | ||
13331 | return CMD_SUCCESS; | |
13332 | } | |
13333 | ||
53089bec | 13334 | /* "show [ip] bgp route-leak" command. */ |
13335 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
13336 | show_ip_bgp_route_leak_cmd, |
13337 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
13338 | SHOW_STR |
13339 | IP_STR | |
13340 | BGP_STR | |
13341 | BGP_INSTANCE_HELP_STR | |
13342 | BGP_AFI_HELP_STR | |
13343 | BGP_SAFI_HELP_STR | |
13344 | "Route leaking information\n" | |
13345 | JSON_STR) | |
53089bec | 13346 | { |
13347 | char *vrf = NULL; | |
13348 | afi_t afi = AFI_MAX; | |
13349 | safi_t safi = SAFI_MAX; | |
13350 | ||
9f049418 | 13351 | bool uj = use_json(argc, argv); |
53089bec | 13352 | int idx = 0; |
03915806 | 13353 | json_object *json = NULL; |
53089bec | 13354 | |
13355 | /* show [ip] bgp */ | |
13356 | if (argv_find(argv, argc, "ip", &idx)) { | |
13357 | afi = AFI_IP; | |
13358 | safi = SAFI_UNICAST; | |
13359 | } | |
13360 | /* [vrf VIEWVRFNAME] */ | |
13361 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
13362 | vty_out(vty, |
13363 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 13364 | return CMD_WARNING; |
13365 | } | |
13366 | ||
9a8bdf1c PG |
13367 | if (argv_find(argv, argc, "vrf", &idx)) { |
13368 | vrf = argv[idx + 1]->arg; | |
13369 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13370 | vrf = NULL; | |
13371 | } | |
53089bec | 13372 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13373 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13374 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13375 | } | |
13376 | ||
13377 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
13378 | vty_out(vty, |
13379 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 13380 | return CMD_WARNING; |
13381 | } | |
13382 | ||
03915806 CS |
13383 | if (vrf && strmatch(vrf, "all")) |
13384 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
13385 | ||
13386 | if (uj) | |
13387 | json = json_object_new_object(); | |
13388 | ||
13389 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 13390 | } |
13391 | ||
d62a17ae | 13392 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
13393 | safi_t safi) | |
f186de26 | 13394 | { |
d62a17ae | 13395 | struct listnode *node, *nnode; |
13396 | struct bgp *bgp; | |
f186de26 | 13397 | |
d62a17ae | 13398 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
13399 | vty_out(vty, "\nInstance %s:\n", | |
13400 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13401 | ? VRF_DEFAULT_NAME |
d62a17ae | 13402 | : bgp->name); |
13403 | update_group_show(bgp, afi, safi, vty, 0); | |
13404 | } | |
f186de26 | 13405 | } |
13406 | ||
d62a17ae | 13407 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
13408 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 13409 | { |
d62a17ae | 13410 | struct bgp *bgp; |
4fb25c53 | 13411 | |
d62a17ae | 13412 | if (name) { |
13413 | if (strmatch(name, "all")) { | |
13414 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
13415 | return CMD_SUCCESS; | |
13416 | } else { | |
13417 | bgp = bgp_lookup_by_name(name); | |
13418 | } | |
13419 | } else { | |
13420 | bgp = bgp_get_default(); | |
13421 | } | |
4fb25c53 | 13422 | |
d62a17ae | 13423 | if (bgp) |
13424 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
13425 | return CMD_SUCCESS; | |
4fb25c53 DW |
13426 | } |
13427 | ||
8fe8a7f6 DS |
13428 | DEFUN (show_ip_bgp_updgrps, |
13429 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 13430 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 13431 | SHOW_STR |
13432 | IP_STR | |
13433 | BGP_STR | |
13434 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 13435 | BGP_AFI_HELP_STR |
9bedbb1e | 13436 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
13437 | "Detailed info about dynamic update groups\n" |
13438 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 13439 | { |
d62a17ae | 13440 | char *vrf = NULL; |
13441 | afi_t afi = AFI_IP6; | |
13442 | safi_t safi = SAFI_UNICAST; | |
13443 | uint64_t subgrp_id = 0; | |
13444 | ||
13445 | int idx = 0; | |
13446 | ||
13447 | /* show [ip] bgp */ | |
13448 | if (argv_find(argv, argc, "ip", &idx)) | |
13449 | afi = AFI_IP; | |
9a8bdf1c PG |
13450 | /* [<vrf> VIEWVRFNAME] */ |
13451 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13452 | vrf = argv[idx + 1]->arg; | |
13453 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13454 | vrf = NULL; | |
13455 | } else if (argv_find(argv, argc, "view", &idx)) | |
13456 | /* [<view> VIEWVRFNAME] */ | |
13457 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 13458 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13459 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13460 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13461 | } | |
5bf15956 | 13462 | |
d62a17ae | 13463 | /* get subgroup id, if provided */ |
13464 | idx = argc - 1; | |
13465 | if (argv[idx]->type == VARIABLE_TKN) | |
13466 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13467 | |
d62a17ae | 13468 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13469 | } |
13470 | ||
f186de26 | 13471 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13472 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13473 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13474 | SHOW_STR |
716b2d8a | 13475 | IP_STR |
f186de26 | 13476 | BGP_STR |
13477 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13478 | "Detailed info about dynamic update groups\n") |
f186de26 | 13479 | { |
d62a17ae | 13480 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13481 | return CMD_SUCCESS; | |
f186de26 | 13482 | } |
13483 | ||
43d3f4fc DS |
13484 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13485 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13486 | "show [ip] bgp l2vpn evpn update-groups", | |
13487 | SHOW_STR | |
13488 | IP_STR | |
13489 | BGP_STR | |
13490 | "l2vpn address family\n" | |
13491 | "evpn sub-address family\n" | |
13492 | "Detailed info about dynamic update groups\n") | |
13493 | { | |
13494 | char *vrf = NULL; | |
13495 | uint64_t subgrp_id = 0; | |
13496 | ||
13497 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13498 | return CMD_SUCCESS; | |
13499 | } | |
13500 | ||
5bf15956 DW |
13501 | DEFUN (show_bgp_updgrps_stats, |
13502 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13503 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13504 | SHOW_STR |
716b2d8a | 13505 | IP_STR |
3f9c7369 | 13506 | BGP_STR |
0c7b1b01 | 13507 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13508 | "Statistics\n") |
13509 | { | |
d62a17ae | 13510 | struct bgp *bgp; |
3f9c7369 | 13511 | |
d62a17ae | 13512 | bgp = bgp_get_default(); |
13513 | if (bgp) | |
13514 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13515 | |
d62a17ae | 13516 | return CMD_SUCCESS; |
3f9c7369 DS |
13517 | } |
13518 | ||
8386ac43 | 13519 | DEFUN (show_bgp_instance_updgrps_stats, |
13520 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13521 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13522 | SHOW_STR |
716b2d8a | 13523 | IP_STR |
8386ac43 | 13524 | BGP_STR |
13525 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13526 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13527 | "Statistics\n") |
13528 | { | |
d62a17ae | 13529 | int idx_word = 3; |
13530 | struct bgp *bgp; | |
8386ac43 | 13531 | |
d62a17ae | 13532 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13533 | if (bgp) | |
13534 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13535 | |
d62a17ae | 13536 | return CMD_SUCCESS; |
8386ac43 | 13537 | } |
13538 | ||
d62a17ae | 13539 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13540 | afi_t afi, safi_t safi, | |
13541 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13542 | { |
d62a17ae | 13543 | struct bgp *bgp; |
8386ac43 | 13544 | |
d62a17ae | 13545 | if (name) |
13546 | bgp = bgp_lookup_by_name(name); | |
13547 | else | |
13548 | bgp = bgp_get_default(); | |
8386ac43 | 13549 | |
d62a17ae | 13550 | if (bgp) { |
13551 | if (!strcmp(what, "advertise-queue")) | |
13552 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13553 | subgrp_id); | |
13554 | else if (!strcmp(what, "advertised-routes")) | |
13555 | update_group_show_advertised(bgp, afi, safi, vty, | |
13556 | subgrp_id); | |
13557 | else if (!strcmp(what, "packet-queue")) | |
13558 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13559 | subgrp_id); | |
13560 | } | |
3f9c7369 DS |
13561 | } |
13562 | ||
dc64bdec QY |
13563 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13564 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13565 | "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", | |
13566 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13567 | BGP_SAFI_HELP_STR | |
13568 | "Detailed info about dynamic update groups\n" | |
13569 | "Specific subgroup to display info for\n" | |
13570 | "Advertisement queue\n" | |
13571 | "Announced routes\n" | |
13572 | "Packet queue\n") | |
3f9c7369 | 13573 | { |
dc64bdec QY |
13574 | uint64_t subgrp_id = 0; |
13575 | afi_t afiz; | |
13576 | safi_t safiz; | |
13577 | if (sgid) | |
13578 | subgrp_id = strtoull(sgid, NULL, 10); | |
13579 | ||
13580 | if (!ip && !afi) | |
13581 | afiz = AFI_IP6; | |
13582 | if (!ip && afi) | |
13583 | afiz = bgp_vty_afi_from_str(afi); | |
13584 | if (ip && !afi) | |
13585 | afiz = AFI_IP; | |
13586 | if (ip && afi) { | |
13587 | afiz = bgp_vty_afi_from_str(afi); | |
13588 | if (afiz != AFI_IP) | |
13589 | vty_out(vty, | |
13590 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13591 | return CMD_WARNING; | |
13592 | } | |
d62a17ae | 13593 | |
dc64bdec | 13594 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13595 | |
dc64bdec | 13596 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13597 | return CMD_SUCCESS; |
13598 | } | |
13599 | ||
d62a17ae | 13600 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13601 | { | |
13602 | struct listnode *node, *nnode; | |
13603 | struct prefix *range; | |
13604 | struct peer *conf; | |
13605 | struct peer *peer; | |
13606 | char buf[PREFIX2STR_BUFFER]; | |
13607 | afi_t afi; | |
13608 | safi_t safi; | |
13609 | const char *peer_status; | |
13610 | const char *af_str; | |
13611 | int lr_count; | |
13612 | int dynamic; | |
13613 | int af_cfgd; | |
13614 | ||
13615 | conf = group->conf; | |
13616 | ||
13617 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
6cde4b45 | 13618 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 13619 | group->name, conf->as); |
d62a17ae | 13620 | } else if (conf->as_type == AS_INTERNAL) { |
6cde4b45 | 13621 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 13622 | group->name, group->bgp->as); |
d62a17ae | 13623 | } else { |
13624 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13625 | } | |
f14e6fdb | 13626 | |
d62a17ae | 13627 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13628 | vty_out(vty, " Peer-group type is internal\n"); | |
13629 | else | |
13630 | vty_out(vty, " Peer-group type is external\n"); | |
13631 | ||
13632 | /* Display AFs configured. */ | |
13633 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13634 | FOREACH_AFI_SAFI (afi, safi) { |
13635 | if (conf->afc[afi][safi]) { | |
13636 | af_cfgd = 1; | |
5cb5f4d0 | 13637 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13638 | } |
05c7a1cc | 13639 | } |
d62a17ae | 13640 | if (!af_cfgd) |
13641 | vty_out(vty, " none\n"); | |
13642 | else | |
13643 | vty_out(vty, "\n"); | |
13644 | ||
13645 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13646 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13647 | if (afi == AFI_IP) | |
13648 | af_str = "IPv4"; | |
13649 | else if (afi == AFI_IP6) | |
13650 | af_str = "IPv6"; | |
13651 | else | |
13652 | af_str = "???"; | |
13653 | lr_count = listcount(group->listen_range[afi]); | |
13654 | if (lr_count) { | |
13655 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13656 | af_str); | |
13657 | ||
13658 | ||
13659 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13660 | nnode, range)) { | |
13661 | prefix2str(range, buf, sizeof(buf)); | |
13662 | vty_out(vty, " %s\n", buf); | |
13663 | } | |
13664 | } | |
13665 | } | |
f14e6fdb | 13666 | |
d62a17ae | 13667 | /* Display group members and their status */ |
13668 | if (listcount(group->peer)) { | |
13669 | vty_out(vty, " Peer-group members:\n"); | |
13670 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
cb9196e7 DS |
13671 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
13672 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13673 | peer_status = "Idle (Admin)"; |
13674 | else if (CHECK_FLAG(peer->sflags, | |
13675 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13676 | peer_status = "Idle (PfxCt)"; | |
13677 | else | |
13678 | peer_status = lookup_msg(bgp_status_msg, | |
13679 | peer->status, NULL); | |
13680 | ||
13681 | dynamic = peer_dynamic_neighbor(peer); | |
13682 | vty_out(vty, " %s %s %s \n", peer->host, | |
13683 | dynamic ? "(dynamic)" : "", peer_status); | |
13684 | } | |
13685 | } | |
f14e6fdb | 13686 | |
d62a17ae | 13687 | return CMD_SUCCESS; |
13688 | } | |
13689 | ||
ff9959b0 QY |
13690 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13691 | const char *group_name) | |
d62a17ae | 13692 | { |
ff9959b0 | 13693 | struct bgp *bgp; |
d62a17ae | 13694 | struct listnode *node, *nnode; |
13695 | struct peer_group *group; | |
ff9959b0 QY |
13696 | bool found = false; |
13697 | ||
13698 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13699 | ||
13700 | if (!bgp) { | |
9f049418 | 13701 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13702 | return CMD_WARNING; |
13703 | } | |
d62a17ae | 13704 | |
13705 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13706 | if (group_name) { |
13707 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13708 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13709 | found = true; |
13710 | break; | |
d62a17ae | 13711 | } |
ff9959b0 QY |
13712 | } else { |
13713 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13714 | } |
f14e6fdb | 13715 | } |
f14e6fdb | 13716 | |
ff9959b0 | 13717 | if (group_name && !found) |
d62a17ae | 13718 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13719 | |
d62a17ae | 13720 | return CMD_SUCCESS; |
f14e6fdb DS |
13721 | } |
13722 | ||
f14e6fdb DS |
13723 | DEFUN (show_ip_bgp_peer_groups, |
13724 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13725 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13726 | SHOW_STR |
13727 | IP_STR | |
13728 | BGP_STR | |
8386ac43 | 13729 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13730 | "Detailed information on BGP peer groups\n" |
13731 | "Peer group name\n") | |
f14e6fdb | 13732 | { |
d62a17ae | 13733 | char *vrf, *pg; |
d62a17ae | 13734 | int idx = 0; |
f14e6fdb | 13735 | |
a4d82a8a PZ |
13736 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13737 | : NULL; | |
d62a17ae | 13738 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13739 | |
ff9959b0 | 13740 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13741 | } |
3f9c7369 | 13742 | |
d6e3c605 | 13743 | |
718e3744 | 13744 | /* Redistribute VTY commands. */ |
13745 | ||
718e3744 | 13746 | DEFUN (bgp_redistribute_ipv4, |
13747 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13748 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13749 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13750 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13751 | { |
d62a17ae | 13752 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13753 | int idx_protocol = 1; | |
13754 | int type; | |
718e3744 | 13755 | |
d62a17ae | 13756 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13757 | if (type < 0) { | |
13758 | vty_out(vty, "%% Invalid route type\n"); | |
13759 | return CMD_WARNING_CONFIG_FAILED; | |
13760 | } | |
7f323236 | 13761 | |
d62a17ae | 13762 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13763 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13764 | } |
13765 | ||
d62a17ae | 13766 | ALIAS_HIDDEN( |
13767 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13768 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13769 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13770 | |
718e3744 | 13771 | DEFUN (bgp_redistribute_ipv4_rmap, |
13772 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13773 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13774 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13775 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13776 | "Route map reference\n" |
13777 | "Pointer to route-map entries\n") | |
13778 | { | |
d62a17ae | 13779 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13780 | int idx_protocol = 1; | |
13781 | int idx_word = 3; | |
13782 | int type; | |
13783 | struct bgp_redist *red; | |
e923dd62 | 13784 | bool changed; |
1de27621 DA |
13785 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13786 | vty, argv[idx_word]->arg); | |
718e3744 | 13787 | |
d62a17ae | 13788 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13789 | if (type < 0) { | |
13790 | vty_out(vty, "%% Invalid route type\n"); | |
13791 | return CMD_WARNING_CONFIG_FAILED; | |
13792 | } | |
718e3744 | 13793 | |
d62a17ae | 13794 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13795 | changed = |
13796 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13797 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13798 | } |
13799 | ||
d62a17ae | 13800 | ALIAS_HIDDEN( |
13801 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13802 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13803 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13804 | "Route map reference\n" | |
13805 | "Pointer to route-map entries\n") | |
596c17ba | 13806 | |
718e3744 | 13807 | DEFUN (bgp_redistribute_ipv4_metric, |
13808 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13809 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13810 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13811 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13812 | "Metric for redistributed routes\n" |
13813 | "Default metric\n") | |
13814 | { | |
d62a17ae | 13815 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13816 | int idx_protocol = 1; | |
13817 | int idx_number = 3; | |
13818 | int type; | |
d7c0a89a | 13819 | uint32_t metric; |
d62a17ae | 13820 | struct bgp_redist *red; |
e923dd62 | 13821 | bool changed; |
d62a17ae | 13822 | |
13823 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13824 | if (type < 0) { | |
13825 | vty_out(vty, "%% Invalid route type\n"); | |
13826 | return CMD_WARNING_CONFIG_FAILED; | |
13827 | } | |
13828 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13829 | ||
13830 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13831 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13832 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13833 | } |
13834 | ||
13835 | ALIAS_HIDDEN( | |
13836 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13837 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13838 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13839 | "Metric for redistributed routes\n" | |
13840 | "Default metric\n") | |
596c17ba | 13841 | |
718e3744 | 13842 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13843 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13844 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13845 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13846 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13847 | "Route map reference\n" |
13848 | "Pointer to route-map entries\n" | |
13849 | "Metric for redistributed routes\n" | |
13850 | "Default metric\n") | |
13851 | { | |
d62a17ae | 13852 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13853 | int idx_protocol = 1; | |
13854 | int idx_word = 3; | |
13855 | int idx_number = 5; | |
13856 | int type; | |
d7c0a89a | 13857 | uint32_t metric; |
d62a17ae | 13858 | struct bgp_redist *red; |
e923dd62 | 13859 | bool changed; |
1de27621 DA |
13860 | struct route_map *route_map = |
13861 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13862 | |
13863 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13864 | if (type < 0) { | |
13865 | vty_out(vty, "%% Invalid route type\n"); | |
13866 | return CMD_WARNING_CONFIG_FAILED; | |
13867 | } | |
13868 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13869 | ||
13870 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13871 | changed = |
13872 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13873 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13874 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13875 | } |
13876 | ||
13877 | ALIAS_HIDDEN( | |
13878 | bgp_redistribute_ipv4_rmap_metric, | |
13879 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13880 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13881 | " route-map WORD metric (0-4294967295)", | |
13882 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13883 | "Route map reference\n" | |
13884 | "Pointer to route-map entries\n" | |
13885 | "Metric for redistributed routes\n" | |
13886 | "Default metric\n") | |
596c17ba | 13887 | |
718e3744 | 13888 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13889 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13890 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13891 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13892 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13893 | "Metric for redistributed routes\n" |
13894 | "Default metric\n" | |
13895 | "Route map reference\n" | |
13896 | "Pointer to route-map entries\n") | |
13897 | { | |
d62a17ae | 13898 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13899 | int idx_protocol = 1; | |
13900 | int idx_number = 3; | |
13901 | int idx_word = 5; | |
13902 | int type; | |
d7c0a89a | 13903 | uint32_t metric; |
d62a17ae | 13904 | struct bgp_redist *red; |
e923dd62 | 13905 | bool changed; |
1de27621 DA |
13906 | struct route_map *route_map = |
13907 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13908 | |
13909 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13910 | if (type < 0) { | |
13911 | vty_out(vty, "%% Invalid route type\n"); | |
13912 | return CMD_WARNING_CONFIG_FAILED; | |
13913 | } | |
13914 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13915 | ||
13916 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13917 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13918 | changed |= |
13919 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13920 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13921 | } |
13922 | ||
13923 | ALIAS_HIDDEN( | |
13924 | bgp_redistribute_ipv4_metric_rmap, | |
13925 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13926 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13927 | " metric (0-4294967295) route-map WORD", | |
13928 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13929 | "Metric for redistributed routes\n" | |
13930 | "Default metric\n" | |
13931 | "Route map reference\n" | |
13932 | "Pointer to route-map entries\n") | |
596c17ba | 13933 | |
7c8ff89e DS |
13934 | DEFUN (bgp_redistribute_ipv4_ospf, |
13935 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13936 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13937 | "Redistribute information from another routing protocol\n" |
13938 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13939 | "Non-main Kernel Routing Table\n" |
13940 | "Instance ID/Table ID\n") | |
7c8ff89e | 13941 | { |
d62a17ae | 13942 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13943 | int idx_ospf_table = 1; | |
13944 | int idx_number = 2; | |
d7c0a89a QY |
13945 | unsigned short instance; |
13946 | unsigned short protocol; | |
7c8ff89e | 13947 | |
d62a17ae | 13948 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13949 | |
d62a17ae | 13950 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13951 | protocol = ZEBRA_ROUTE_OSPF; | |
13952 | else | |
13953 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13954 | |
d62a17ae | 13955 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13956 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13957 | } |
13958 | ||
d62a17ae | 13959 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13960 | "redistribute <ospf|table> (1-65535)", | |
13961 | "Redistribute information from another routing protocol\n" | |
13962 | "Open Shortest Path First (OSPFv2)\n" | |
13963 | "Non-main Kernel Routing Table\n" | |
13964 | "Instance ID/Table ID\n") | |
596c17ba | 13965 | |
7c8ff89e DS |
13966 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13967 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13968 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13969 | "Redistribute information from another routing protocol\n" |
13970 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13971 | "Non-main Kernel Routing Table\n" |
13972 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13973 | "Route map reference\n" |
13974 | "Pointer to route-map entries\n") | |
13975 | { | |
d62a17ae | 13976 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13977 | int idx_ospf_table = 1; | |
13978 | int idx_number = 2; | |
13979 | int idx_word = 4; | |
13980 | struct bgp_redist *red; | |
d7c0a89a | 13981 | unsigned short instance; |
d62a17ae | 13982 | int protocol; |
e923dd62 | 13983 | bool changed; |
1de27621 DA |
13984 | struct route_map *route_map = |
13985 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13986 | |
13987 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13988 | protocol = ZEBRA_ROUTE_OSPF; | |
13989 | else | |
13990 | protocol = ZEBRA_ROUTE_TABLE; | |
13991 | ||
13992 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13993 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13994 | changed = |
13995 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13996 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13997 | } |
13998 | ||
13999 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
14000 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
14001 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
14002 | "Redistribute information from another routing protocol\n" | |
14003 | "Open Shortest Path First (OSPFv2)\n" | |
14004 | "Non-main Kernel Routing Table\n" | |
14005 | "Instance ID/Table ID\n" | |
14006 | "Route map reference\n" | |
14007 | "Pointer to route-map entries\n") | |
596c17ba | 14008 | |
7c8ff89e DS |
14009 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
14010 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 14011 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
14012 | "Redistribute information from another routing protocol\n" |
14013 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14014 | "Non-main Kernel Routing Table\n" |
14015 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14016 | "Metric for redistributed routes\n" |
14017 | "Default metric\n") | |
14018 | { | |
d62a17ae | 14019 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14020 | int idx_ospf_table = 1; | |
14021 | int idx_number = 2; | |
14022 | int idx_number_2 = 4; | |
d7c0a89a | 14023 | uint32_t metric; |
d62a17ae | 14024 | struct bgp_redist *red; |
d7c0a89a | 14025 | unsigned short instance; |
d62a17ae | 14026 | int protocol; |
e923dd62 | 14027 | bool changed; |
d62a17ae | 14028 | |
14029 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14030 | protocol = ZEBRA_ROUTE_OSPF; | |
14031 | else | |
14032 | protocol = ZEBRA_ROUTE_TABLE; | |
14033 | ||
14034 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14035 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14036 | ||
14037 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 14038 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14039 | metric); | |
14040 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 14041 | } |
14042 | ||
14043 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
14044 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
14045 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
14046 | "Redistribute information from another routing protocol\n" | |
14047 | "Open Shortest Path First (OSPFv2)\n" | |
14048 | "Non-main Kernel Routing Table\n" | |
14049 | "Instance ID/Table ID\n" | |
14050 | "Metric for redistributed routes\n" | |
14051 | "Default metric\n") | |
596c17ba | 14052 | |
7c8ff89e DS |
14053 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
14054 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 14055 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
14056 | "Redistribute information from another routing protocol\n" |
14057 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14058 | "Non-main Kernel Routing Table\n" |
14059 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14060 | "Route map reference\n" |
14061 | "Pointer to route-map entries\n" | |
14062 | "Metric for redistributed routes\n" | |
14063 | "Default metric\n") | |
14064 | { | |
d62a17ae | 14065 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14066 | int idx_ospf_table = 1; | |
14067 | int idx_number = 2; | |
14068 | int idx_word = 4; | |
14069 | int idx_number_2 = 6; | |
d7c0a89a | 14070 | uint32_t metric; |
d62a17ae | 14071 | struct bgp_redist *red; |
d7c0a89a | 14072 | unsigned short instance; |
d62a17ae | 14073 | int protocol; |
e923dd62 | 14074 | bool changed; |
1de27621 DA |
14075 | struct route_map *route_map = |
14076 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14077 | |
14078 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14079 | protocol = ZEBRA_ROUTE_OSPF; | |
14080 | else | |
14081 | protocol = ZEBRA_ROUTE_TABLE; | |
14082 | ||
14083 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14084 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14085 | ||
14086 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
14087 | changed = |
14088 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14089 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14090 | metric); | |
14091 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 14092 | } |
14093 | ||
14094 | ALIAS_HIDDEN( | |
14095 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
14096 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
14097 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
14098 | "Redistribute information from another routing protocol\n" | |
14099 | "Open Shortest Path First (OSPFv2)\n" | |
14100 | "Non-main Kernel Routing Table\n" | |
14101 | "Instance ID/Table ID\n" | |
14102 | "Route map reference\n" | |
14103 | "Pointer to route-map entries\n" | |
14104 | "Metric for redistributed routes\n" | |
14105 | "Default metric\n") | |
596c17ba | 14106 | |
7c8ff89e DS |
14107 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
14108 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 14109 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
14110 | "Redistribute information from another routing protocol\n" |
14111 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14112 | "Non-main Kernel Routing Table\n" |
14113 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14114 | "Metric for redistributed routes\n" |
14115 | "Default metric\n" | |
14116 | "Route map reference\n" | |
14117 | "Pointer to route-map entries\n") | |
14118 | { | |
d62a17ae | 14119 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14120 | int idx_ospf_table = 1; | |
14121 | int idx_number = 2; | |
14122 | int idx_number_2 = 4; | |
14123 | int idx_word = 6; | |
d7c0a89a | 14124 | uint32_t metric; |
d62a17ae | 14125 | struct bgp_redist *red; |
d7c0a89a | 14126 | unsigned short instance; |
d62a17ae | 14127 | int protocol; |
e923dd62 | 14128 | bool changed; |
1de27621 DA |
14129 | struct route_map *route_map = |
14130 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14131 | |
14132 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14133 | protocol = ZEBRA_ROUTE_OSPF; | |
14134 | else | |
14135 | protocol = ZEBRA_ROUTE_TABLE; | |
14136 | ||
14137 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14138 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14139 | ||
14140 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 14141 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14142 | metric); | |
1de27621 DA |
14143 | changed |= |
14144 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14145 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 14146 | } |
14147 | ||
14148 | ALIAS_HIDDEN( | |
14149 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
14150 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
14151 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
14152 | "Redistribute information from another routing protocol\n" | |
14153 | "Open Shortest Path First (OSPFv2)\n" | |
14154 | "Non-main Kernel Routing Table\n" | |
14155 | "Instance ID/Table ID\n" | |
14156 | "Metric for redistributed routes\n" | |
14157 | "Default metric\n" | |
14158 | "Route map reference\n" | |
14159 | "Pointer to route-map entries\n") | |
596c17ba | 14160 | |
7c8ff89e DS |
14161 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
14162 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 14163 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
14164 | NO_STR |
14165 | "Redistribute information from another routing protocol\n" | |
14166 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 14167 | "Non-main Kernel Routing Table\n" |
31500417 DW |
14168 | "Instance ID/Table ID\n" |
14169 | "Metric for redistributed routes\n" | |
14170 | "Default metric\n" | |
14171 | "Route map reference\n" | |
14172 | "Pointer to route-map entries\n") | |
7c8ff89e | 14173 | { |
d62a17ae | 14174 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14175 | int idx_ospf_table = 2; | |
14176 | int idx_number = 3; | |
d7c0a89a | 14177 | unsigned short instance; |
d62a17ae | 14178 | int protocol; |
14179 | ||
14180 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14181 | protocol = ZEBRA_ROUTE_OSPF; | |
14182 | else | |
14183 | protocol = ZEBRA_ROUTE_TABLE; | |
14184 | ||
14185 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14186 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
14187 | } | |
14188 | ||
14189 | ALIAS_HIDDEN( | |
14190 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 14191 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14192 | NO_STR |
14193 | "Redistribute information from another routing protocol\n" | |
14194 | "Open Shortest Path First (OSPFv2)\n" | |
14195 | "Non-main Kernel Routing Table\n" | |
14196 | "Instance ID/Table ID\n" | |
14197 | "Metric for redistributed routes\n" | |
14198 | "Default metric\n" | |
14199 | "Route map reference\n" | |
14200 | "Pointer to route-map entries\n") | |
596c17ba | 14201 | |
718e3744 | 14202 | DEFUN (no_bgp_redistribute_ipv4, |
14203 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 14204 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14205 | NO_STR |
14206 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14207 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
14208 | "Metric for redistributed routes\n" |
14209 | "Default metric\n" | |
14210 | "Route map reference\n" | |
14211 | "Pointer to route-map entries\n") | |
718e3744 | 14212 | { |
d62a17ae | 14213 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14214 | int idx_protocol = 2; | |
14215 | int type; | |
14216 | ||
14217 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14218 | if (type < 0) { | |
14219 | vty_out(vty, "%% Invalid route type\n"); | |
14220 | return CMD_WARNING_CONFIG_FAILED; | |
14221 | } | |
14222 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
14223 | } | |
14224 | ||
14225 | ALIAS_HIDDEN( | |
14226 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
14227 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 14228 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14229 | NO_STR |
14230 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14231 | "Metric for redistributed routes\n" | |
14232 | "Default metric\n" | |
14233 | "Route map reference\n" | |
14234 | "Pointer to route-map entries\n") | |
596c17ba | 14235 | |
718e3744 | 14236 | DEFUN (bgp_redistribute_ipv6, |
14237 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 14238 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 14239 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14240 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 14241 | { |
d62a17ae | 14242 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14243 | int idx_protocol = 1; | |
14244 | int type; | |
718e3744 | 14245 | |
d62a17ae | 14246 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14247 | if (type < 0) { | |
14248 | vty_out(vty, "%% Invalid route type\n"); | |
14249 | return CMD_WARNING_CONFIG_FAILED; | |
14250 | } | |
718e3744 | 14251 | |
d62a17ae | 14252 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14253 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 14254 | } |
14255 | ||
14256 | DEFUN (bgp_redistribute_ipv6_rmap, | |
14257 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 14258 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 14259 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14260 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14261 | "Route map reference\n" |
14262 | "Pointer to route-map entries\n") | |
14263 | { | |
d62a17ae | 14264 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14265 | int idx_protocol = 1; | |
14266 | int idx_word = 3; | |
14267 | int type; | |
14268 | struct bgp_redist *red; | |
e923dd62 | 14269 | bool changed; |
1de27621 DA |
14270 | struct route_map *route_map = |
14271 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 14272 | |
d62a17ae | 14273 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14274 | if (type < 0) { | |
14275 | vty_out(vty, "%% Invalid route type\n"); | |
14276 | return CMD_WARNING_CONFIG_FAILED; | |
14277 | } | |
718e3744 | 14278 | |
d62a17ae | 14279 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14280 | changed = |
14281 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14282 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14283 | } |
14284 | ||
14285 | DEFUN (bgp_redistribute_ipv6_metric, | |
14286 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 14287 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 14288 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14289 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14290 | "Metric for redistributed routes\n" |
14291 | "Default metric\n") | |
14292 | { | |
d62a17ae | 14293 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14294 | int idx_protocol = 1; | |
14295 | int idx_number = 3; | |
14296 | int type; | |
d7c0a89a | 14297 | uint32_t metric; |
d62a17ae | 14298 | struct bgp_redist *red; |
e923dd62 | 14299 | bool changed; |
d62a17ae | 14300 | |
14301 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14302 | if (type < 0) { | |
14303 | vty_out(vty, "%% Invalid route type\n"); | |
14304 | return CMD_WARNING_CONFIG_FAILED; | |
14305 | } | |
14306 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14307 | |
d62a17ae | 14308 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14309 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
14310 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14311 | } |
14312 | ||
14313 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
14314 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 14315 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 14316 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14317 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14318 | "Route map reference\n" |
14319 | "Pointer to route-map entries\n" | |
14320 | "Metric for redistributed routes\n" | |
14321 | "Default metric\n") | |
14322 | { | |
d62a17ae | 14323 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14324 | int idx_protocol = 1; | |
14325 | int idx_word = 3; | |
14326 | int idx_number = 5; | |
14327 | int type; | |
d7c0a89a | 14328 | uint32_t metric; |
d62a17ae | 14329 | struct bgp_redist *red; |
e923dd62 | 14330 | bool changed; |
1de27621 DA |
14331 | struct route_map *route_map = |
14332 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14333 | |
14334 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14335 | if (type < 0) { | |
14336 | vty_out(vty, "%% Invalid route type\n"); | |
14337 | return CMD_WARNING_CONFIG_FAILED; | |
14338 | } | |
14339 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14340 | |
d62a17ae | 14341 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14342 | changed = |
14343 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14344 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
14345 | metric); | |
14346 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14347 | } |
14348 | ||
14349 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
14350 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 14351 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14352 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14353 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14354 | "Metric for redistributed routes\n" |
14355 | "Default metric\n" | |
14356 | "Route map reference\n" | |
14357 | "Pointer to route-map entries\n") | |
14358 | { | |
d62a17ae | 14359 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14360 | int idx_protocol = 1; | |
14361 | int idx_number = 3; | |
14362 | int idx_word = 5; | |
14363 | int type; | |
d7c0a89a | 14364 | uint32_t metric; |
d62a17ae | 14365 | struct bgp_redist *red; |
e923dd62 | 14366 | bool changed; |
1de27621 DA |
14367 | struct route_map *route_map = |
14368 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14369 | |
14370 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14371 | if (type < 0) { | |
14372 | vty_out(vty, "%% Invalid route type\n"); | |
14373 | return CMD_WARNING_CONFIG_FAILED; | |
14374 | } | |
14375 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14376 | |
d62a17ae | 14377 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14378 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
14379 | metric); | |
1de27621 DA |
14380 | changed |= |
14381 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14382 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14383 | } |
14384 | ||
14385 | DEFUN (no_bgp_redistribute_ipv6, | |
14386 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 14387 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14388 | NO_STR |
14389 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14390 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
14391 | "Metric for redistributed routes\n" |
14392 | "Default metric\n" | |
14393 | "Route map reference\n" | |
14394 | "Pointer to route-map entries\n") | |
718e3744 | 14395 | { |
d62a17ae | 14396 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14397 | int idx_protocol = 2; | |
14398 | int type; | |
718e3744 | 14399 | |
d62a17ae | 14400 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14401 | if (type < 0) { | |
14402 | vty_out(vty, "%% Invalid route type\n"); | |
14403 | return CMD_WARNING_CONFIG_FAILED; | |
14404 | } | |
718e3744 | 14405 | |
d62a17ae | 14406 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
14407 | } | |
14408 | ||
dd65f45e DL |
14409 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
14410 | afi_t afi, safi_t safi) | |
d62a17ae | 14411 | { |
14412 | int i; | |
14413 | ||
14414 | /* Unicast redistribution only. */ | |
14415 | if (safi != SAFI_UNICAST) | |
2b791107 | 14416 | return; |
d62a17ae | 14417 | |
14418 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
14419 | /* Redistribute BGP does not make sense. */ | |
14420 | if (i != ZEBRA_ROUTE_BGP) { | |
14421 | struct list *red_list; | |
14422 | struct listnode *node; | |
14423 | struct bgp_redist *red; | |
14424 | ||
14425 | red_list = bgp->redist[afi][i]; | |
14426 | if (!red_list) | |
14427 | continue; | |
14428 | ||
14429 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 14430 | /* "redistribute" configuration. */ |
14431 | vty_out(vty, " redistribute %s", | |
14432 | zebra_route_string(i)); | |
14433 | if (red->instance) | |
14434 | vty_out(vty, " %d", red->instance); | |
14435 | if (red->redist_metric_flag) | |
14436 | vty_out(vty, " metric %u", | |
14437 | red->redist_metric); | |
14438 | if (red->rmap.name) | |
14439 | vty_out(vty, " route-map %s", | |
14440 | red->rmap.name); | |
14441 | vty_out(vty, "\n"); | |
14442 | } | |
14443 | } | |
14444 | } | |
718e3744 | 14445 | } |
6b0655a2 | 14446 | |
dd65f45e DL |
14447 | /* peer-group helpers for config-write */ |
14448 | ||
14449 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
14450 | { | |
14451 | if (!peer_group_active(peer)) { | |
14452 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
14453 | return !CHECK_FLAG(peer->flags, flag); | |
14454 | else | |
14455 | return !!CHECK_FLAG(peer->flags, flag); | |
14456 | } | |
14457 | ||
14458 | return !!CHECK_FLAG(peer->flags_override, flag); | |
14459 | } | |
14460 | ||
14461 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
14462 | uint32_t flag) | |
14463 | { | |
14464 | if (!peer_group_active(peer)) { | |
14465 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14466 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14467 | else | |
14468 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14469 | } | |
14470 | ||
14471 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14472 | } | |
14473 | ||
14474 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14475 | uint8_t type, int direct) | |
14476 | { | |
14477 | struct bgp_filter *filter; | |
14478 | ||
14479 | if (peer_group_active(peer)) | |
14480 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14481 | type); | |
14482 | ||
14483 | filter = &peer->filter[afi][safi]; | |
14484 | switch (type) { | |
14485 | case PEER_FT_DISTRIBUTE_LIST: | |
14486 | return !!(filter->dlist[direct].name); | |
14487 | case PEER_FT_FILTER_LIST: | |
14488 | return !!(filter->aslist[direct].name); | |
14489 | case PEER_FT_PREFIX_LIST: | |
14490 | return !!(filter->plist[direct].name); | |
14491 | case PEER_FT_ROUTE_MAP: | |
14492 | return !!(filter->map[direct].name); | |
14493 | case PEER_FT_UNSUPPRESS_MAP: | |
14494 | return !!(filter->usmap.name); | |
14495 | default: | |
14496 | return false; | |
14497 | } | |
14498 | } | |
14499 | ||
14500 | /* Return true if the addpath type is set for peer and different from | |
14501 | * peer-group. | |
14502 | */ | |
3dc339cd DA |
14503 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
14504 | safi_t safi) | |
dd65f45e DL |
14505 | { |
14506 | enum bgp_addpath_strat type, g_type; | |
14507 | ||
14508 | type = peer->addpath_type[afi][safi]; | |
14509 | ||
14510 | if (type != BGP_ADDPATH_NONE) { | |
14511 | if (peer_group_active(peer)) { | |
14512 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14513 | ||
14514 | if (type != g_type) | |
3dc339cd | 14515 | return true; |
dd65f45e | 14516 | else |
3dc339cd | 14517 | return false; |
dd65f45e DL |
14518 | } |
14519 | ||
3dc339cd | 14520 | return true; |
dd65f45e DL |
14521 | } |
14522 | ||
3dc339cd | 14523 | return false; |
dd65f45e DL |
14524 | } |
14525 | ||
b9c7bc5a | 14526 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14527 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14528 | afi_t afi) |
14529 | { | |
b9c7bc5a | 14530 | int indent = 2; |
ddb5b488 | 14531 | |
8a066a70 | 14532 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
14533 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14534 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
14535 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
14536 | bgp->vpn_policy[afi] | |
bb4f6190 | 14537 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14538 | else |
14539 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14540 | bgp->vpn_policy[afi] | |
14541 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14542 | } | |
12a844a5 DS |
14543 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14544 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14545 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14546 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14547 | return; | |
14548 | ||
e70e9f8e PZ |
14549 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14550 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14551 | ||
14552 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14553 | ||
14554 | } else { | |
14555 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14556 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14557 | bgp->vpn_policy[afi].tovpn_label); | |
14558 | } | |
ddb5b488 PZ |
14559 | } |
14560 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14561 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14562 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14563 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14564 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14565 | sizeof(buf))); | |
14566 | } | |
14567 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14568 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14569 | ||
14570 | char buf[PREFIX_STRLEN]; | |
14571 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14572 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14573 | sizeof(buf))) { | |
14574 | ||
b9c7bc5a PZ |
14575 | vty_out(vty, "%*snexthop vpn export %s\n", |
14576 | indent, "", buf); | |
ddb5b488 PZ |
14577 | } |
14578 | } | |
14579 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14580 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14581 | && ecommunity_cmp( | |
14582 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14583 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14584 | ||
14585 | char *b = ecommunity_ecom2str( | |
14586 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14587 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14588 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14589 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14590 | } else { | |
14591 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14592 | char *b = ecommunity_ecom2str( | |
14593 | bgp->vpn_policy[afi] | |
14594 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14595 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14596 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14597 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14598 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14599 | } | |
14600 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14601 | char *b = ecommunity_ecom2str( | |
14602 | bgp->vpn_policy[afi] | |
14603 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14604 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14605 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14606 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14607 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14608 | } | |
14609 | } | |
bb4f6190 DS |
14610 | |
14611 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14612 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14613 | bgp->vpn_policy[afi] |
14614 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14615 | |
301ad80a PG |
14616 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14617 | char *b = ecommunity_ecom2str( | |
14618 | bgp->vpn_policy[afi] | |
14619 | .import_redirect_rtlist, | |
14620 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14621 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14622 | |
301ad80a PG |
14623 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14624 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14625 | } | |
ddb5b488 PZ |
14626 | } |
14627 | ||
dd65f45e DL |
14628 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14629 | afi_t afi, safi_t safi) | |
14630 | { | |
14631 | struct bgp_filter *filter; | |
14632 | char *addr; | |
14633 | ||
14634 | addr = peer->host; | |
14635 | filter = &peer->filter[afi][safi]; | |
14636 | ||
14637 | /* distribute-list. */ | |
14638 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14639 | FILTER_IN)) | |
14640 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14641 | filter->dlist[FILTER_IN].name); | |
14642 | ||
14643 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14644 | FILTER_OUT)) | |
14645 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14646 | filter->dlist[FILTER_OUT].name); | |
14647 | ||
14648 | /* prefix-list. */ | |
14649 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14650 | FILTER_IN)) | |
14651 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14652 | filter->plist[FILTER_IN].name); | |
14653 | ||
14654 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14655 | FILTER_OUT)) | |
14656 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14657 | filter->plist[FILTER_OUT].name); | |
14658 | ||
14659 | /* route-map. */ | |
14660 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14661 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14662 | filter->map[RMAP_IN].name); | |
14663 | ||
14664 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14665 | RMAP_OUT)) | |
14666 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14667 | filter->map[RMAP_OUT].name); | |
14668 | ||
14669 | /* unsuppress-map */ | |
14670 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14671 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14672 | filter->usmap.name); | |
14673 | ||
14674 | /* filter-list. */ | |
14675 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14676 | FILTER_IN)) | |
14677 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14678 | filter->aslist[FILTER_IN].name); | |
14679 | ||
14680 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14681 | FILTER_OUT)) | |
14682 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14683 | filter->aslist[FILTER_OUT].name); | |
14684 | } | |
14685 | ||
14686 | /* BGP peer configuration display function. */ | |
14687 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14688 | struct peer *peer) | |
14689 | { | |
14690 | struct peer *g_peer = NULL; | |
14691 | char buf[SU_ADDRSTRLEN]; | |
14692 | char *addr; | |
14693 | int if_pg_printed = false; | |
14694 | int if_ras_printed = false; | |
14695 | ||
14696 | /* Skip dynamic neighbors. */ | |
14697 | if (peer_dynamic_neighbor(peer)) | |
14698 | return; | |
14699 | ||
14700 | if (peer->conf_if) | |
14701 | addr = peer->conf_if; | |
14702 | else | |
14703 | addr = peer->host; | |
14704 | ||
14705 | /************************************ | |
14706 | ****** Global to the neighbor ****** | |
14707 | ************************************/ | |
14708 | if (peer->conf_if) { | |
14709 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14710 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14711 | else | |
14712 | vty_out(vty, " neighbor %s interface", addr); | |
14713 | ||
14714 | if (peer_group_active(peer)) { | |
14715 | vty_out(vty, " peer-group %s", peer->group->name); | |
14716 | if_pg_printed = true; | |
14717 | } else if (peer->as_type == AS_SPECIFIED) { | |
14718 | vty_out(vty, " remote-as %u", peer->as); | |
14719 | if_ras_printed = true; | |
14720 | } else if (peer->as_type == AS_INTERNAL) { | |
14721 | vty_out(vty, " remote-as internal"); | |
14722 | if_ras_printed = true; | |
14723 | } else if (peer->as_type == AS_EXTERNAL) { | |
14724 | vty_out(vty, " remote-as external"); | |
14725 | if_ras_printed = true; | |
14726 | } | |
14727 | ||
14728 | vty_out(vty, "\n"); | |
14729 | } | |
14730 | ||
14731 | /* remote-as and peer-group */ | |
14732 | /* peer is a member of a peer-group */ | |
14733 | if (peer_group_active(peer)) { | |
14734 | g_peer = peer->group->conf; | |
14735 | ||
14736 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14737 | if (peer->as_type == AS_SPECIFIED) { | |
14738 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14739 | addr, peer->as); | |
14740 | } else if (peer->as_type == AS_INTERNAL) { | |
14741 | vty_out(vty, | |
14742 | " neighbor %s remote-as internal\n", | |
14743 | addr); | |
14744 | } else if (peer->as_type == AS_EXTERNAL) { | |
14745 | vty_out(vty, | |
14746 | " neighbor %s remote-as external\n", | |
14747 | addr); | |
14748 | } | |
14749 | } | |
14750 | ||
14751 | /* For swpX peers we displayed the peer-group | |
14752 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14753 | if (!if_pg_printed) | |
14754 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14755 | peer->group->name); | |
14756 | } | |
14757 | ||
14758 | /* peer is NOT a member of a peer-group */ | |
14759 | else { | |
14760 | /* peer is a peer-group, declare the peer-group */ | |
14761 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14762 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14763 | } | |
14764 | ||
14765 | if (!if_ras_printed) { | |
14766 | if (peer->as_type == AS_SPECIFIED) { | |
14767 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14768 | addr, peer->as); | |
14769 | } else if (peer->as_type == AS_INTERNAL) { | |
14770 | vty_out(vty, | |
14771 | " neighbor %s remote-as internal\n", | |
14772 | addr); | |
14773 | } else if (peer->as_type == AS_EXTERNAL) { | |
14774 | vty_out(vty, | |
14775 | " neighbor %s remote-as external\n", | |
14776 | addr); | |
14777 | } | |
14778 | } | |
14779 | } | |
14780 | ||
14781 | /* local-as */ | |
14782 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14783 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14784 | peer->change_local_as); | |
14785 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14786 | vty_out(vty, " no-prepend"); | |
14787 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14788 | vty_out(vty, " replace-as"); | |
14789 | vty_out(vty, "\n"); | |
14790 | } | |
14791 | ||
14792 | /* description */ | |
14793 | if (peer->desc) { | |
14794 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14795 | } | |
14796 | ||
14797 | /* shutdown */ | |
14798 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14799 | if (peer->tx_shutdown_message) | |
14800 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14801 | peer->tx_shutdown_message); | |
14802 | else | |
14803 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14804 | } | |
14805 | ||
14806 | /* bfd */ | |
14807 | if (peer->bfd_info) { | |
14808 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14809 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14810 | } | |
14811 | } | |
14812 | ||
14813 | /* password */ | |
14814 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14815 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14816 | peer->password); | |
14817 | ||
14818 | /* neighbor solo */ | |
14819 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14820 | if (!peer_group_active(peer)) { | |
14821 | vty_out(vty, " neighbor %s solo\n", addr); | |
14822 | } | |
14823 | } | |
14824 | ||
14825 | /* BGP port */ | |
14826 | if (peer->port != BGP_PORT_DEFAULT) { | |
14827 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14828 | } | |
14829 | ||
14830 | /* Local interface name */ | |
14831 | if (peer->ifname) { | |
14832 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14833 | } | |
14834 | ||
14835 | /* passive */ | |
14836 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14837 | vty_out(vty, " neighbor %s passive\n", addr); | |
14838 | ||
14839 | /* ebgp-multihop */ | |
14840 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
14841 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
14842 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
14843 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
14844 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14845 | peer->ttl); | |
14846 | } | |
14847 | } | |
14848 | ||
14849 | /* ttl-security hops */ | |
e2521429 | 14850 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
14851 | if (!peer_group_active(peer) |
14852 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14853 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14854 | addr, peer->gtsm_hops); | |
14855 | } | |
14856 | } | |
14857 | ||
14858 | /* disable-connected-check */ | |
14859 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14860 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14861 | ||
14862 | /* enforce-first-as */ | |
14863 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14864 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14865 | ||
14866 | /* update-source */ | |
14867 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14868 | if (peer->update_source) | |
14869 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14870 | sockunion2str(peer->update_source, buf, | |
14871 | SU_ADDRSTRLEN)); | |
14872 | else if (peer->update_if) | |
14873 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14874 | peer->update_if); | |
14875 | } | |
14876 | ||
14877 | /* advertisement-interval */ | |
14878 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14879 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14880 | peer->routeadv); | |
14881 | ||
14882 | /* timers */ | |
14883 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14884 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14885 | peer->keepalive, peer->holdtime); | |
14886 | ||
14887 | /* timers connect */ | |
14888 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14889 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14890 | peer->connect); | |
5d5393b9 DL |
14891 | /* need special-case handling for changed default values due to |
14892 | * config profile / version (because there is no "timers bgp connect" | |
14893 | * command, we need to save this per-peer :/) | |
14894 | */ | |
14895 | else if (!peer_group_active(peer) && !peer->connect && | |
14896 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14897 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14898 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14899 | |
14900 | /* capability dynamic */ | |
14901 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14902 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14903 | ||
14904 | /* capability extended-nexthop */ | |
14905 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14906 | if (!peer->conf_if) { | |
14907 | if (CHECK_FLAG(peer->flags_invert, | |
14908 | PEER_FLAG_CAPABILITY_ENHE)) | |
14909 | vty_out(vty, | |
14910 | " no neighbor %s capability extended-nexthop\n", | |
14911 | addr); | |
14912 | else | |
14913 | vty_out(vty, | |
14914 | " neighbor %s capability extended-nexthop\n", | |
14915 | addr); | |
14916 | } | |
14917 | } | |
14918 | ||
14919 | /* dont-capability-negotiation */ | |
14920 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14921 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14922 | ||
14923 | /* override-capability */ | |
14924 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14925 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14926 | ||
14927 | /* strict-capability-match */ | |
14928 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14929 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14930 | ||
14931 | /* Sender side AS path loop detection. */ | |
14932 | if (peer->as_path_loop_detection) | |
14933 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14934 | addr); | |
cfd47646 | 14935 | |
14936 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14937 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 14938 | |
14939 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14940 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 14941 | vty_out(vty, |
14942 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
14943 | } else if (CHECK_FLAG( |
14944 | peer->peer_gr_new_status_flag, | |
14945 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 14946 | vty_out(vty, |
14947 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
14948 | } else if ( |
14949 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14950 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14951 | && !(CHECK_FLAG( | |
14952 | peer->peer_gr_new_status_flag, | |
14953 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14954 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
14955 | addr); | |
cfd47646 | 14956 | } |
14957 | } | |
dd65f45e DL |
14958 | } |
14959 | ||
14960 | /* BGP peer configuration display function. */ | |
14961 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14962 | struct peer *peer, afi_t afi, safi_t safi) | |
14963 | { | |
14964 | struct peer *g_peer = NULL; | |
14965 | char *addr; | |
14966 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14967 | ||
14968 | /* Skip dynamic neighbors. */ | |
14969 | if (peer_dynamic_neighbor(peer)) | |
14970 | return; | |
14971 | ||
14972 | if (peer->conf_if) | |
14973 | addr = peer->conf_if; | |
14974 | else | |
14975 | addr = peer->host; | |
14976 | ||
14977 | /************************************ | |
14978 | ****** Per AF to the neighbor ****** | |
14979 | ************************************/ | |
14980 | if (peer_group_active(peer)) { | |
14981 | g_peer = peer->group->conf; | |
14982 | ||
14983 | /* If the peer-group is active but peer is not, print a 'no | |
14984 | * activate' */ | |
14985 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14986 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14987 | } | |
14988 | ||
14989 | /* If the peer-group is not active but peer is, print an | |
14990 | 'activate' */ | |
14991 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14992 | vty_out(vty, " neighbor %s activate\n", addr); | |
14993 | } | |
14994 | } else { | |
14995 | if (peer->afc[afi][safi]) { | |
14996 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14997 | if (CHECK_FLAG(bgp->flags, |
14998 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14999 | vty_out(vty, " neighbor %s activate\n", |
15000 | addr); | |
15001 | } | |
15002 | } else | |
15003 | vty_out(vty, " neighbor %s activate\n", addr); | |
15004 | } else { | |
15005 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
15006 | if (!CHECK_FLAG(bgp->flags, |
15007 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
15008 | vty_out(vty, |
15009 | " no neighbor %s activate\n", | |
15010 | addr); | |
15011 | } | |
15012 | } | |
15013 | } | |
15014 | } | |
15015 | ||
15016 | /* addpath TX knobs */ | |
15017 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
15018 | switch (peer->addpath_type[afi][safi]) { | |
15019 | case BGP_ADDPATH_ALL: | |
15020 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
15021 | addr); | |
15022 | break; | |
15023 | case BGP_ADDPATH_BEST_PER_AS: | |
15024 | vty_out(vty, | |
15025 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
15026 | addr); | |
15027 | break; | |
15028 | case BGP_ADDPATH_MAX: | |
15029 | case BGP_ADDPATH_NONE: | |
15030 | break; | |
15031 | } | |
15032 | } | |
15033 | ||
15034 | /* ORF capability. */ | |
15035 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
15036 | || peergroup_af_flag_check(peer, afi, safi, | |
15037 | PEER_FLAG_ORF_PREFIX_RM)) { | |
15038 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
15039 | ||
15040 | if (peergroup_af_flag_check(peer, afi, safi, | |
15041 | PEER_FLAG_ORF_PREFIX_SM) | |
15042 | && peergroup_af_flag_check(peer, afi, safi, | |
15043 | PEER_FLAG_ORF_PREFIX_RM)) | |
15044 | vty_out(vty, " both"); | |
15045 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15046 | PEER_FLAG_ORF_PREFIX_SM)) | |
15047 | vty_out(vty, " send"); | |
15048 | else | |
15049 | vty_out(vty, " receive"); | |
15050 | vty_out(vty, "\n"); | |
15051 | } | |
15052 | ||
dd65f45e DL |
15053 | /* Route reflector client. */ |
15054 | if (peergroup_af_flag_check(peer, afi, safi, | |
15055 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
15056 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
15057 | } | |
15058 | ||
15059 | /* next-hop-self force */ | |
15060 | if (peergroup_af_flag_check(peer, afi, safi, | |
15061 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
15062 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
15063 | } | |
15064 | ||
15065 | /* next-hop-self */ | |
15066 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
15067 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
15068 | } | |
15069 | ||
15070 | /* remove-private-AS */ | |
15071 | if (peergroup_af_flag_check(peer, afi, safi, | |
15072 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
15073 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
15074 | addr); | |
15075 | } | |
15076 | ||
15077 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15078 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
15079 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
15080 | addr); | |
15081 | } | |
15082 | ||
15083 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15084 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
15085 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
15086 | } | |
15087 | ||
15088 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15089 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
15090 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
15091 | } | |
15092 | ||
15093 | /* as-override */ | |
15094 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
15095 | vty_out(vty, " neighbor %s as-override\n", addr); | |
15096 | } | |
15097 | ||
15098 | /* send-community print. */ | |
15099 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
15100 | PEER_FLAG_SEND_COMMUNITY); | |
15101 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
15102 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
15103 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
15104 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
15105 | ||
15106 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
15107 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
15108 | } else { | |
15109 | if (flag_scomm) | |
15110 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
15111 | if (flag_secomm) | |
15112 | vty_out(vty, | |
15113 | " no neighbor %s send-community extended\n", | |
15114 | addr); | |
15115 | ||
15116 | if (flag_slcomm) | |
15117 | vty_out(vty, " no neighbor %s send-community large\n", | |
15118 | addr); | |
15119 | } | |
15120 | ||
15121 | /* Default information */ | |
15122 | if (peergroup_af_flag_check(peer, afi, safi, | |
15123 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
15124 | vty_out(vty, " neighbor %s default-originate", addr); | |
15125 | ||
15126 | if (peer->default_rmap[afi][safi].name) | |
15127 | vty_out(vty, " route-map %s", | |
15128 | peer->default_rmap[afi][safi].name); | |
15129 | ||
15130 | vty_out(vty, "\n"); | |
15131 | } | |
15132 | ||
15133 | /* Soft reconfiguration inbound. */ | |
15134 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
15135 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
15136 | addr); | |
15137 | } | |
15138 | ||
15139 | /* maximum-prefix. */ | |
15140 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 15141 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
15142 | peer->pmax[afi][safi]); |
15143 | ||
15144 | if (peer->pmax_threshold[afi][safi] | |
15145 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
15146 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
15147 | if (peer_af_flag_check(peer, afi, safi, | |
15148 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
15149 | vty_out(vty, " warning-only"); | |
15150 | if (peer->pmax_restart[afi][safi]) | |
15151 | vty_out(vty, " restart %u", | |
15152 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
15153 | if (peer_af_flag_check(peer, afi, safi, |
15154 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
15155 | vty_out(vty, " force"); | |
dd65f45e DL |
15156 | |
15157 | vty_out(vty, "\n"); | |
15158 | } | |
15159 | ||
fde246e8 DA |
15160 | /* maximum-prefix-out */ |
15161 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 15162 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
15163 | addr, peer->pmax_out[afi][safi]); |
15164 | ||
dd65f45e DL |
15165 | /* Route server client. */ |
15166 | if (peergroup_af_flag_check(peer, afi, safi, | |
15167 | PEER_FLAG_RSERVER_CLIENT)) { | |
15168 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
15169 | } | |
15170 | ||
15171 | /* Nexthop-local unchanged. */ | |
15172 | if (peergroup_af_flag_check(peer, afi, safi, | |
15173 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
15174 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
15175 | } | |
15176 | ||
15177 | /* allowas-in <1-10> */ | |
15178 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
15179 | if (peer_af_flag_check(peer, afi, safi, | |
15180 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
15181 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
15182 | } else if (peer->allowas_in[afi][safi] == 3) { | |
15183 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
15184 | } else { | |
15185 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
15186 | peer->allowas_in[afi][safi]); | |
15187 | } | |
15188 | } | |
15189 | ||
15190 | /* weight */ | |
15191 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
15192 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
15193 | peer->weight[afi][safi]); | |
15194 | ||
15195 | /* Filter. */ | |
15196 | bgp_config_write_filter(vty, peer, afi, safi); | |
15197 | ||
15198 | /* atribute-unchanged. */ | |
15199 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
15200 | || (safi != SAFI_EVPN | |
15201 | && peer_af_flag_check(peer, afi, safi, | |
15202 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
15203 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
15204 | ||
15205 | if (!peer_group_active(peer) | |
15206 | || peergroup_af_flag_check(peer, afi, safi, | |
15207 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15208 | || peergroup_af_flag_check(peer, afi, safi, | |
15209 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15210 | || peergroup_af_flag_check(peer, afi, safi, | |
15211 | PEER_FLAG_MED_UNCHANGED)) { | |
15212 | ||
15213 | vty_out(vty, | |
15214 | " neighbor %s attribute-unchanged%s%s%s\n", | |
15215 | addr, | |
15216 | peer_af_flag_check(peer, afi, safi, | |
15217 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15218 | ? " as-path" | |
15219 | : "", | |
15220 | peer_af_flag_check(peer, afi, safi, | |
15221 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15222 | ? " next-hop" | |
15223 | : "", | |
15224 | peer_af_flag_check(peer, afi, safi, | |
15225 | PEER_FLAG_MED_UNCHANGED) | |
15226 | ? " med" | |
15227 | : ""); | |
15228 | } | |
15229 | } | |
15230 | } | |
15231 | ||
15232 | /* Address family based peer configuration display. */ | |
15233 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
15234 | safi_t safi) | |
15235 | { | |
15236 | struct peer *peer; | |
15237 | struct peer_group *group; | |
15238 | struct listnode *node, *nnode; | |
15239 | ||
15240 | ||
15241 | vty_frame(vty, " !\n address-family "); | |
15242 | if (afi == AFI_IP) { | |
15243 | if (safi == SAFI_UNICAST) | |
15244 | vty_frame(vty, "ipv4 unicast"); | |
15245 | else if (safi == SAFI_LABELED_UNICAST) | |
15246 | vty_frame(vty, "ipv4 labeled-unicast"); | |
15247 | else if (safi == SAFI_MULTICAST) | |
15248 | vty_frame(vty, "ipv4 multicast"); | |
15249 | else if (safi == SAFI_MPLS_VPN) | |
15250 | vty_frame(vty, "ipv4 vpn"); | |
15251 | else if (safi == SAFI_ENCAP) | |
15252 | vty_frame(vty, "ipv4 encap"); | |
15253 | else if (safi == SAFI_FLOWSPEC) | |
15254 | vty_frame(vty, "ipv4 flowspec"); | |
15255 | } else if (afi == AFI_IP6) { | |
15256 | if (safi == SAFI_UNICAST) | |
15257 | vty_frame(vty, "ipv6 unicast"); | |
15258 | else if (safi == SAFI_LABELED_UNICAST) | |
15259 | vty_frame(vty, "ipv6 labeled-unicast"); | |
15260 | else if (safi == SAFI_MULTICAST) | |
15261 | vty_frame(vty, "ipv6 multicast"); | |
15262 | else if (safi == SAFI_MPLS_VPN) | |
15263 | vty_frame(vty, "ipv6 vpn"); | |
15264 | else if (safi == SAFI_ENCAP) | |
15265 | vty_frame(vty, "ipv6 encap"); | |
15266 | else if (safi == SAFI_FLOWSPEC) | |
15267 | vty_frame(vty, "ipv6 flowspec"); | |
15268 | } else if (afi == AFI_L2VPN) { | |
15269 | if (safi == SAFI_EVPN) | |
15270 | vty_frame(vty, "l2vpn evpn"); | |
15271 | } | |
15272 | vty_frame(vty, "\n"); | |
15273 | ||
15274 | bgp_config_write_distance(vty, bgp, afi, safi); | |
15275 | ||
15276 | bgp_config_write_network(vty, bgp, afi, safi); | |
15277 | ||
15278 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
15279 | ||
8a4e7fe6 DA |
15280 | /* BGP flag dampening. */ |
15281 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
15282 | bgp_config_write_damp(vty, afi, safi); | |
15283 | ||
dd65f45e DL |
15284 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
15285 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
15286 | ||
15287 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15288 | /* Skip dynamic neighbors. */ | |
15289 | if (peer_dynamic_neighbor(peer)) | |
15290 | continue; | |
15291 | ||
15292 | /* Do not display doppelganger peers */ | |
15293 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15294 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
15295 | } | |
15296 | ||
15297 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
15298 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
15299 | ||
15300 | if (safi == SAFI_EVPN) | |
15301 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
15302 | ||
15303 | if (safi == SAFI_FLOWSPEC) | |
15304 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
15305 | ||
15306 | if (safi == SAFI_UNICAST) { | |
15307 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
15308 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15309 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
15310 | ||
15311 | vty_out(vty, " export vpn\n"); | |
15312 | } | |
15313 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15314 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
15315 | ||
15316 | vty_out(vty, " import vpn\n"); | |
15317 | } | |
15318 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15319 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15320 | char *name; | |
15321 | ||
15322 | for (ALL_LIST_ELEMENTS_RO( | |
15323 | bgp->vpn_policy[afi].import_vrf, node, | |
15324 | name)) | |
15325 | vty_out(vty, " import vrf %s\n", name); | |
15326 | } | |
15327 | } | |
15328 | ||
15329 | vty_endframe(vty, " exit-address-family\n"); | |
15330 | } | |
15331 | ||
15332 | int bgp_config_write(struct vty *vty) | |
15333 | { | |
15334 | struct bgp *bgp; | |
15335 | struct peer_group *group; | |
15336 | struct peer *peer; | |
15337 | struct listnode *node, *nnode; | |
15338 | struct listnode *mnode, *mnnode; | |
15339 | ||
15340 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
15341 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
15342 | bm->rmap_update_timer); | |
15343 | ||
15344 | /* BGP configuration. */ | |
15345 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
15346 | ||
15347 | /* skip all auto created vrf as they dont have user config */ | |
15348 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
15349 | continue; | |
15350 | ||
15351 | /* Router bgp ASN */ | |
15352 | vty_out(vty, "router bgp %u", bgp->as); | |
15353 | ||
15354 | if (bgp->name) | |
15355 | vty_out(vty, " %s %s", | |
15356 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
15357 | ? "view" : "vrf", bgp->name); | |
15358 | vty_out(vty, "\n"); | |
15359 | ||
15360 | /* BGP fast-external-failover. */ | |
15361 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
15362 | vty_out(vty, " no bgp fast-external-failover\n"); | |
15363 | ||
15364 | /* BGP router ID. */ | |
15365 | if (bgp->router_id_static.s_addr != 0) | |
15366 | vty_out(vty, " bgp router-id %s\n", | |
15367 | inet_ntoa(bgp->router_id_static)); | |
15368 | ||
15369 | /* BGP log-neighbor-changes. */ | |
892fedb6 | 15370 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 15371 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 15372 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
15373 | CHECK_FLAG(bgp->flags, |
15374 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
15375 | ? "" |
15376 | : "no "); | |
15377 | ||
15378 | /* BGP configuration. */ | |
892fedb6 | 15379 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
15380 | vty_out(vty, " bgp always-compare-med\n"); |
15381 | ||
15382 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
15383 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
15384 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
15385 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
15386 | CHECK_FLAG(bgp->flags, | |
15387 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
15388 | ? "" | |
15389 | : "no "); | |
dd65f45e DL |
15390 | |
15391 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 15392 | if (bgp->reject_as_sets) |
dd65f45e DL |
15393 | vty_out(vty, " bgp reject-as-sets\n"); |
15394 | ||
15395 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 15396 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
15397 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
15398 | ||
15399 | /* BGP default local-preference. */ | |
15400 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
15401 | vty_out(vty, " bgp default local-preference %u\n", | |
15402 | bgp->default_local_pref); | |
15403 | ||
15404 | /* BGP default show-hostname */ | |
892fedb6 | 15405 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 15406 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 15407 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 15408 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
15409 | ? "" |
15410 | : "no "); | |
15411 | ||
aef999a2 DA |
15412 | /* BGP default show-nexthop-hostname */ |
15413 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
15414 | != SAVE_BGP_SHOW_HOSTNAME) | |
15415 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
15416 | CHECK_FLAG(bgp->flags, | |
15417 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
15418 | ? "" | |
15419 | : "no "); | |
15420 | ||
dd65f45e DL |
15421 | /* BGP default subgroup-pkt-queue-max. */ |
15422 | if (bgp->default_subgroup_pkt_queue_max | |
15423 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
15424 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
15425 | bgp->default_subgroup_pkt_queue_max); | |
15426 | ||
15427 | /* BGP client-to-client reflection. */ | |
892fedb6 | 15428 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
15429 | vty_out(vty, " no bgp client-to-client reflection\n"); |
15430 | ||
15431 | /* BGP cluster ID. */ | |
15432 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
15433 | vty_out(vty, " bgp cluster-id %s\n", | |
15434 | inet_ntoa(bgp->cluster_id)); | |
15435 | ||
15436 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 15437 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
15438 | vty_out(vty, |
15439 | " bgp disable-ebgp-connected-route-check\n"); | |
15440 | ||
15441 | /* Confederation identifier*/ | |
15442 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
15443 | vty_out(vty, " bgp confederation identifier %u\n", | |
15444 | bgp->confed_id); | |
15445 | ||
15446 | /* Confederation peer */ | |
15447 | if (bgp->confed_peers_cnt > 0) { | |
15448 | int i; | |
15449 | ||
15450 | vty_out(vty, " bgp confederation peers"); | |
15451 | ||
15452 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
15453 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
15454 | ||
15455 | vty_out(vty, "\n"); | |
15456 | } | |
15457 | ||
15458 | /* BGP deterministic-med. */ | |
892fedb6 | 15459 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 15460 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 15461 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
15462 | CHECK_FLAG(bgp->flags, |
15463 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
15464 | ? "" |
15465 | : "no "); | |
15466 | ||
15467 | /* BGP update-delay. */ | |
15468 | bgp_config_write_update_delay(vty, bgp); | |
15469 | ||
15470 | if (bgp->v_maxmed_onstartup | |
15471 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
15472 | vty_out(vty, " bgp max-med on-startup %u", | |
15473 | bgp->v_maxmed_onstartup); | |
15474 | if (bgp->maxmed_onstartup_value | |
15475 | != BGP_MAXMED_VALUE_DEFAULT) | |
15476 | vty_out(vty, " %u", | |
15477 | bgp->maxmed_onstartup_value); | |
15478 | vty_out(vty, "\n"); | |
15479 | } | |
15480 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
15481 | vty_out(vty, " bgp max-med administrative"); | |
15482 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
15483 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15484 | vty_out(vty, "\n"); | |
15485 | } | |
15486 | ||
15487 | /* write quanta */ | |
15488 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15489 | /* read quanta */ | |
15490 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15491 | ||
15492 | /* coalesce time */ | |
15493 | bgp_config_write_coalesce_time(vty, bgp); | |
15494 | ||
15495 | /* BGP graceful-restart. */ | |
15496 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15497 | vty_out(vty, | |
15498 | " bgp graceful-restart stalepath-time %u\n", | |
15499 | bgp->stalepath_time); | |
cfd47646 | 15500 | |
dd65f45e DL |
15501 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15502 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15503 | bgp->restart_time); | |
cfd47646 | 15504 | |
15505 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15506 | vty_out(vty, | |
15507 | " bgp graceful-restart select-defer-time %u\n", | |
15508 | bgp->select_defer_time); | |
15509 | ||
15510 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15511 | vty_out(vty, " bgp graceful-restart\n"); |
15512 | ||
cfd47646 | 15513 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15514 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15515 | ||
dd65f45e | 15516 | /* BGP graceful-shutdown */ |
892fedb6 | 15517 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) |
dd65f45e DL |
15518 | vty_out(vty, " bgp graceful-shutdown\n"); |
15519 | ||
15520 | /* BGP graceful-restart Preserve State F bit. */ | |
892fedb6 | 15521 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
15522 | vty_out(vty, |
15523 | " bgp graceful-restart preserve-fw-state\n"); | |
15524 | ||
dc95985f | 15525 | /* Stale timer for RIB */ |
15526 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
15527 | vty_out(vty, | |
15528 | " bgp graceful-restart rib-stale-time %u\n", | |
15529 | bgp->rib_stale_time); | |
15530 | ||
dd65f45e | 15531 | /* BGP bestpath method. */ |
892fedb6 | 15532 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 15533 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 15534 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
15535 | vty_out(vty, " bgp bestpath as-path confed\n"); |
15536 | ||
892fedb6 DA |
15537 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
15538 | if (CHECK_FLAG(bgp->flags, | |
15539 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
15540 | vty_out(vty, |
15541 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15542 | } else { | |
15543 | vty_out(vty, | |
15544 | " bgp bestpath as-path multipath-relax\n"); | |
15545 | } | |
15546 | } | |
15547 | ||
892fedb6 | 15548 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
15549 | vty_out(vty, |
15550 | " bgp route-reflector allow-outbound-policy\n"); | |
15551 | } | |
892fedb6 | 15552 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 15553 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
15554 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
15555 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 15556 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 15557 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 15558 | vty_out(vty, " confed"); |
892fedb6 DA |
15559 | if (CHECK_FLAG(bgp->flags, |
15560 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
15561 | vty_out(vty, " missing-as-worst"); |
15562 | vty_out(vty, "\n"); | |
15563 | } | |
15564 | ||
f7e1c681 | 15565 | /* Link bandwidth handling. */ |
15566 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
15567 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
15568 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
15569 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
15570 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
15571 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
15572 | ||
dd65f45e | 15573 | /* BGP network import check. */ |
892fedb6 | 15574 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 15575 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 15576 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 15577 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
15578 | ? "" |
15579 | : "no "); | |
15580 | ||
15581 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15582 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15583 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15584 | vty_out(vty, " timers bgp %u %u\n", |
15585 | bgp->default_keepalive, bgp->default_holdtime); | |
15586 | ||
15587 | /* peer-group */ | |
15588 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15589 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15590 | } | |
15591 | ||
15592 | /* Normal neighbor configuration. */ | |
15593 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15594 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15595 | bgp_config_write_peer_global(vty, bgp, peer); | |
15596 | } | |
15597 | ||
15598 | /* listen range and limit for dynamic BGP neighbors */ | |
15599 | bgp_config_write_listen(vty, bgp); | |
15600 | ||
15601 | /* | |
15602 | * BGP default autoshutdown neighbors | |
15603 | * | |
15604 | * This must be placed after any peer and peer-group | |
15605 | * configuration, to avoid setting all peers to shutdown after | |
15606 | * a daemon restart, which is undesired behavior. (see #2286) | |
15607 | */ | |
15608 | if (bgp->autoshutdown) | |
15609 | vty_out(vty, " bgp default shutdown\n"); | |
15610 | ||
9cf59432 DS |
15611 | /* BGP instance administrative shutdown */ |
15612 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
15613 | vty_out(vty, " bgp shutdown\n"); | |
15614 | ||
dd65f45e DL |
15615 | /* IPv4 unicast configuration. */ |
15616 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15617 | ||
15618 | /* IPv4 multicast configuration. */ | |
15619 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15620 | ||
15621 | /* IPv4 labeled-unicast configuration. */ | |
15622 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15623 | ||
15624 | /* IPv4 VPN configuration. */ | |
15625 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15626 | ||
15627 | /* ENCAPv4 configuration. */ | |
15628 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15629 | ||
15630 | /* FLOWSPEC v4 configuration. */ | |
15631 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15632 | ||
15633 | /* IPv6 unicast configuration. */ | |
15634 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15635 | ||
15636 | /* IPv6 multicast configuration. */ | |
15637 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15638 | ||
15639 | /* IPv6 labeled-unicast configuration. */ | |
15640 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15641 | SAFI_LABELED_UNICAST); | |
15642 | ||
15643 | /* IPv6 VPN configuration. */ | |
15644 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15645 | ||
15646 | /* ENCAPv6 configuration. */ | |
15647 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15648 | ||
15649 | /* FLOWSPEC v6 configuration. */ | |
15650 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15651 | ||
15652 | /* EVPN configuration. */ | |
15653 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15654 | ||
15655 | hook_call(bgp_inst_config_write, bgp, vty); | |
15656 | ||
49e5a4a0 | 15657 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
15658 | bgp_rfapi_cfg_write(vty, bgp); |
15659 | #endif | |
15660 | ||
15661 | vty_out(vty, "!\n"); | |
15662 | } | |
15663 | return 0; | |
15664 | } | |
15665 | ||
ddb5b488 | 15666 | |
718e3744 | 15667 | /* BGP node structure. */ |
d62a17ae | 15668 | static struct cmd_node bgp_node = { |
f4b8291f | 15669 | .name = "bgp", |
62b346ee | 15670 | .node = BGP_NODE, |
24389580 | 15671 | .parent_node = CONFIG_NODE, |
62b346ee | 15672 | .prompt = "%s(config-router)# ", |
612c2c15 | 15673 | .config_write = bgp_config_write, |
718e3744 | 15674 | }; |
15675 | ||
d62a17ae | 15676 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 15677 | .name = "bgp ipv4 unicast", |
62b346ee | 15678 | .node = BGP_IPV4_NODE, |
24389580 | 15679 | .parent_node = BGP_NODE, |
62b346ee | 15680 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15681 | }; |
15682 | ||
d62a17ae | 15683 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 15684 | .name = "bgp ipv4 multicast", |
62b346ee | 15685 | .node = BGP_IPV4M_NODE, |
24389580 | 15686 | .parent_node = BGP_NODE, |
62b346ee | 15687 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15688 | }; |
15689 | ||
d62a17ae | 15690 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 15691 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 15692 | .node = BGP_IPV4L_NODE, |
24389580 | 15693 | .parent_node = BGP_NODE, |
62b346ee | 15694 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15695 | }; |
15696 | ||
d62a17ae | 15697 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 15698 | .name = "bgp ipv6", |
62b346ee | 15699 | .node = BGP_IPV6_NODE, |
24389580 | 15700 | .parent_node = BGP_NODE, |
62b346ee | 15701 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15702 | }; |
15703 | ||
d62a17ae | 15704 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 15705 | .name = "bgp ipv6 multicast", |
62b346ee | 15706 | .node = BGP_IPV6M_NODE, |
24389580 | 15707 | .parent_node = BGP_NODE, |
62b346ee | 15708 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 15709 | }; |
15710 | ||
d62a17ae | 15711 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 15712 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 15713 | .node = BGP_IPV6L_NODE, |
24389580 | 15714 | .parent_node = BGP_NODE, |
62b346ee | 15715 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15716 | }; |
15717 | ||
62b346ee | 15718 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 15719 | .name = "bgp vpnv4", |
62b346ee | 15720 | .node = BGP_VPNV4_NODE, |
24389580 | 15721 | .parent_node = BGP_NODE, |
62b346ee | 15722 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15723 | }; |
6b0655a2 | 15724 | |
62b346ee | 15725 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 15726 | .name = "bgp vpnv6", |
62b346ee | 15727 | .node = BGP_VPNV6_NODE, |
24389580 | 15728 | .parent_node = BGP_NODE, |
62b346ee | 15729 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15730 | }; |
8ecd3266 | 15731 | |
62b346ee | 15732 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 15733 | .name = "bgp evpn", |
62b346ee | 15734 | .node = BGP_EVPN_NODE, |
24389580 | 15735 | .parent_node = BGP_NODE, |
62b346ee | 15736 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 15737 | }; |
4e0b7b6d | 15738 | |
62b346ee | 15739 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 15740 | .name = "bgp evpn vni", |
62b346ee | 15741 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 15742 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 15743 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 15744 | }; |
90e60aa7 | 15745 | |
62b346ee | 15746 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 15747 | .name = "bgp ipv4 flowspec", |
62b346ee | 15748 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 15749 | .parent_node = BGP_NODE, |
62b346ee | 15750 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15751 | }; |
7c40bf39 | 15752 | |
62b346ee | 15753 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 15754 | .name = "bgp ipv6 flowspec", |
62b346ee | 15755 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 15756 | .parent_node = BGP_NODE, |
62b346ee | 15757 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15758 | }; |
7c40bf39 | 15759 | |
d62a17ae | 15760 | static void community_list_vty(void); |
1f8ae70b | 15761 | |
d62a17ae | 15762 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15763 | { |
d62a17ae | 15764 | struct bgp *bgp; |
15765 | struct peer *peer; | |
d62a17ae | 15766 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15767 | |
d62a17ae | 15768 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15769 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15770 | /* only provide suggestions on the appropriate input | |
15771 | * token type, | |
15772 | * they'll otherwise show up multiple times */ | |
15773 | enum cmd_token_type match_type; | |
15774 | char *name = peer->host; | |
d48ed3e0 | 15775 | |
d62a17ae | 15776 | if (peer->conf_if) { |
15777 | match_type = VARIABLE_TKN; | |
15778 | name = peer->conf_if; | |
15779 | } else if (strchr(peer->host, ':')) | |
15780 | match_type = IPV6_TKN; | |
15781 | else | |
15782 | match_type = IPV4_TKN; | |
d48ed3e0 | 15783 | |
d62a17ae | 15784 | if (token->type != match_type) |
15785 | continue; | |
d48ed3e0 | 15786 | |
d62a17ae | 15787 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15788 | } | |
d62a17ae | 15789 | } |
b8a815e5 DL |
15790 | } |
15791 | ||
15792 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15793 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15794 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15795 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15796 | {.completions = NULL}}; |
15797 | ||
47a306a0 DS |
15798 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15799 | { | |
15800 | struct bgp *bgp; | |
15801 | struct peer_group *group; | |
15802 | struct listnode *lnbgp, *lnpeer; | |
15803 | ||
15804 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15805 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15806 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15807 | group->name)); | |
15808 | } | |
15809 | } | |
15810 | ||
15811 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15812 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15813 | {.completions = NULL} }; | |
15814 | ||
d62a17ae | 15815 | void bgp_vty_init(void) |
15816 | { | |
15817 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15818 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15819 | |
15820 | /* Install bgp top node. */ | |
612c2c15 DL |
15821 | install_node(&bgp_node); |
15822 | install_node(&bgp_ipv4_unicast_node); | |
15823 | install_node(&bgp_ipv4_multicast_node); | |
15824 | install_node(&bgp_ipv4_labeled_unicast_node); | |
15825 | install_node(&bgp_ipv6_unicast_node); | |
15826 | install_node(&bgp_ipv6_multicast_node); | |
15827 | install_node(&bgp_ipv6_labeled_unicast_node); | |
15828 | install_node(&bgp_vpnv4_node); | |
15829 | install_node(&bgp_vpnv6_node); | |
15830 | install_node(&bgp_evpn_node); | |
15831 | install_node(&bgp_evpn_vni_node); | |
15832 | install_node(&bgp_flowspecv4_node); | |
15833 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 15834 | |
15835 | /* Install default VTY commands to new nodes. */ | |
15836 | install_default(BGP_NODE); | |
15837 | install_default(BGP_IPV4_NODE); | |
15838 | install_default(BGP_IPV4M_NODE); | |
15839 | install_default(BGP_IPV4L_NODE); | |
15840 | install_default(BGP_IPV6_NODE); | |
15841 | install_default(BGP_IPV6M_NODE); | |
15842 | install_default(BGP_IPV6L_NODE); | |
15843 | install_default(BGP_VPNV4_NODE); | |
15844 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15845 | install_default(BGP_FLOWSPECV4_NODE); |
15846 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15847 | install_default(BGP_EVPN_NODE); |
15848 | install_default(BGP_EVPN_VNI_NODE); | |
15849 | ||
8029b216 AK |
15850 | /* "bgp local-mac" hidden commands. */ |
15851 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15852 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15853 | ||
d62a17ae | 15854 | /* bgp route-map delay-timer commands. */ |
15855 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15856 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15857 | ||
15858 | /* Dummy commands (Currently not supported) */ | |
15859 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15860 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15861 | ||
15862 | /* "router bgp" commands. */ | |
15863 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15864 | ||
15865 | /* "no router bgp" commands. */ | |
15866 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15867 | ||
15868 | /* "bgp router-id" commands. */ | |
15869 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15870 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15871 | ||
15872 | /* "bgp cluster-id" commands. */ | |
15873 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15874 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15875 | ||
15876 | /* "bgp confederation" commands. */ | |
15877 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15878 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15879 | ||
15880 | /* "bgp confederation peers" commands. */ | |
15881 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15882 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15883 | ||
15884 | /* bgp max-med command */ | |
15885 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15886 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15887 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15888 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15889 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15890 | ||
15891 | /* bgp disable-ebgp-connected-nh-check */ | |
15892 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15893 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15894 | ||
15895 | /* bgp update-delay command */ | |
15896 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15897 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15898 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15899 | ||
15900 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15901 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15902 | |
15903 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15904 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15905 | ||
15906 | /* "maximum-paths" commands. */ | |
15907 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15908 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15909 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15910 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15911 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15912 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15913 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15914 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15915 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15916 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15917 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15918 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15919 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15920 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15921 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15922 | ||
39edabac PG |
15923 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
15924 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
15925 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15926 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15927 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 15928 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
15929 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15930 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15931 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15932 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15933 | ||
15934 | /* "timers bgp" commands. */ | |
15935 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15936 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15937 | ||
15938 | /* route-map delay-timer commands - per instance for backwards compat. | |
15939 | */ | |
15940 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15941 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15942 | ||
15943 | /* "bgp client-to-client reflection" commands */ | |
15944 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15945 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15946 | ||
15947 | /* "bgp always-compare-med" commands */ | |
15948 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15949 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15950 | ||
9dac9fc8 DA |
15951 | /* bgp ebgp-requires-policy */ |
15952 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15953 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15954 | ||
fb29348a DA |
15955 | /* bgp reject-as-sets */ |
15956 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15957 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15958 | ||
d62a17ae | 15959 | /* "bgp deterministic-med" commands */ |
15960 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15961 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15962 | ||
055679e9 | 15963 | /* "bgp graceful-restart" command */ |
36235319 QY |
15964 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
15965 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 15966 | |
15967 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
15968 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
15969 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 15970 | |
15971 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
15972 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
15973 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 15974 | |
15975 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15976 | install_element(BGP_NODE, | |
15977 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15978 | install_element(BGP_NODE, | |
15979 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15980 | ||
15981 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15982 | install_element(BGP_NODE, | |
15983 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15984 | install_element(BGP_NODE, | |
15985 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15986 | ||
d62a17ae | 15987 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15988 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15989 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15990 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15991 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15992 | install_element(BGP_NODE, |
15993 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15994 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15995 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15996 | ||
d6e3c15b | 15997 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
15998 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 15999 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
16000 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 16001 | |
7f323236 DW |
16002 | /* "bgp graceful-shutdown" commands */ |
16003 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
16004 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
16005 | ||
d62a17ae | 16006 | /* "bgp fast-external-failover" commands */ |
16007 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
16008 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
16009 | ||
d62a17ae | 16010 | /* "bgp bestpath compare-routerid" commands */ |
16011 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
16012 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
16013 | ||
16014 | /* "bgp bestpath as-path ignore" commands */ | |
16015 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
16016 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
16017 | ||
16018 | /* "bgp bestpath as-path confed" commands */ | |
16019 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
16020 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
16021 | ||
16022 | /* "bgp bestpath as-path multipath-relax" commands */ | |
16023 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
16024 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
16025 | ||
16026 | /* "bgp log-neighbor-changes" commands */ | |
16027 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
16028 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
16029 | ||
16030 | /* "bgp bestpath med" commands */ | |
16031 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
16032 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
16033 | ||
f7e1c681 | 16034 | /* "bgp bestpath bandwidth" commands */ |
16035 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 16036 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 16037 | |
d62a17ae | 16038 | /* "no bgp default ipv4-unicast" commands. */ |
16039 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
16040 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
16041 | ||
16042 | /* "bgp network import-check" commands. */ | |
16043 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
16044 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
16045 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
16046 | ||
16047 | /* "bgp default local-preference" commands. */ | |
16048 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
16049 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
16050 | ||
16051 | /* bgp default show-hostname */ | |
16052 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
16053 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
16054 | ||
aef999a2 DA |
16055 | /* bgp default show-nexthop-hostname */ |
16056 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
16057 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
16058 | ||
d62a17ae | 16059 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
16060 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
16061 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
16062 | ||
16063 | /* bgp ibgp-allow-policy-mods command */ | |
16064 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
16065 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
16066 | ||
16067 | /* "bgp listen limit" commands. */ | |
16068 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
16069 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
16070 | ||
16071 | /* "bgp listen range" commands. */ | |
16072 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
16073 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
16074 | ||
8175f54a | 16075 | /* "bgp default shutdown" command */ |
f26845f9 | 16076 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
16077 | |
16078 | /* "bgp shutdown" commands */ | |
16079 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 16080 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 16081 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
f26845f9 | 16082 | |
d62a17ae | 16083 | /* "neighbor remote-as" commands. */ |
16084 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
16085 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
16086 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
16087 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
16088 | install_element(BGP_NODE, | |
16089 | &neighbor_interface_v6only_config_remote_as_cmd); | |
16090 | install_element(BGP_NODE, &no_neighbor_cmd); | |
16091 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
16092 | ||
16093 | /* "neighbor peer-group" commands. */ | |
16094 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
16095 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
16096 | install_element(BGP_NODE, | |
16097 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
16098 | ||
16099 | /* "neighbor local-as" commands. */ | |
16100 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
16101 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
16102 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
16103 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
16104 | ||
16105 | /* "neighbor solo" commands. */ | |
16106 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
16107 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
16108 | ||
16109 | /* "neighbor password" commands. */ | |
16110 | install_element(BGP_NODE, &neighbor_password_cmd); | |
16111 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
16112 | ||
16113 | /* "neighbor activate" commands. */ | |
16114 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
16115 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
16116 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
16117 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
16118 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
16119 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
16120 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
16121 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
16122 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 16123 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
16124 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 16125 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
16126 | ||
16127 | /* "no neighbor activate" commands. */ | |
16128 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
16129 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
16130 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
16131 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
16132 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
16133 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
16134 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
16135 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
16136 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 16137 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
16138 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 16139 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
16140 | ||
16141 | /* "neighbor peer-group" set commands. */ | |
16142 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
16143 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16144 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16145 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16146 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16147 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16148 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16149 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 16150 | install_element(BGP_FLOWSPECV4_NODE, |
16151 | &neighbor_set_peer_group_hidden_cmd); | |
16152 | install_element(BGP_FLOWSPECV6_NODE, | |
16153 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16154 | |
16155 | /* "no neighbor peer-group unset" commands. */ | |
16156 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
16157 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16158 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16159 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16160 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16161 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16162 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16163 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 16164 | install_element(BGP_FLOWSPECV4_NODE, |
16165 | &no_neighbor_set_peer_group_hidden_cmd); | |
16166 | install_element(BGP_FLOWSPECV6_NODE, | |
16167 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16168 | |
16169 | /* "neighbor softreconfiguration inbound" commands.*/ | |
16170 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
16171 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
16172 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16173 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16174 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16175 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16176 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16177 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16178 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16179 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16180 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16181 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16182 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16183 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16184 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16185 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16186 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16187 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 16188 | install_element(BGP_FLOWSPECV4_NODE, |
16189 | &neighbor_soft_reconfiguration_cmd); | |
16190 | install_element(BGP_FLOWSPECV4_NODE, | |
16191 | &no_neighbor_soft_reconfiguration_cmd); | |
16192 | install_element(BGP_FLOWSPECV6_NODE, | |
16193 | &neighbor_soft_reconfiguration_cmd); | |
16194 | install_element(BGP_FLOWSPECV6_NODE, | |
16195 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
16196 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
16197 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 16198 | |
16199 | /* "neighbor attribute-unchanged" commands. */ | |
16200 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
16201 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
16202 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
16203 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16204 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
16205 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16206 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
16207 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16208 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
16209 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16210 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
16211 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16212 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
16213 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16214 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
16215 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16216 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
16217 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16218 | ||
16219 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
16220 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
16221 | ||
16222 | /* "nexthop-local unchanged" commands */ | |
16223 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
16224 | install_element(BGP_IPV6_NODE, | |
16225 | &no_neighbor_nexthop_local_unchanged_cmd); | |
16226 | ||
16227 | /* "neighbor next-hop-self" commands. */ | |
16228 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
16229 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
16230 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
16231 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16232 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
16233 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
16234 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
16235 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
16236 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
16237 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
16238 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
16239 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
16240 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
16241 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
16242 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
16243 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16244 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
16245 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
16246 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
16247 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 16248 | |
16249 | /* "neighbor next-hop-self force" commands. */ | |
16250 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
16251 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
16252 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16253 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16254 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
16255 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16256 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16257 | install_element(BGP_IPV4_NODE, | |
16258 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16259 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
16260 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16261 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16262 | install_element(BGP_IPV4M_NODE, | |
16263 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16264 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
16265 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16266 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16267 | install_element(BGP_IPV4L_NODE, | |
16268 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16269 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
16270 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16271 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16272 | install_element(BGP_IPV6_NODE, | |
16273 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16274 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
16275 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16276 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16277 | install_element(BGP_IPV6M_NODE, | |
16278 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16279 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
16280 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16281 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16282 | install_element(BGP_IPV6L_NODE, | |
16283 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16284 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
16285 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16286 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16287 | install_element(BGP_VPNV4_NODE, | |
16288 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16289 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
16290 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16291 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16292 | install_element(BGP_VPNV6_NODE, | |
16293 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
16294 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
16295 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 16296 | |
16297 | /* "neighbor as-override" commands. */ | |
16298 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
16299 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
16300 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
16301 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
16302 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
16303 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
16304 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
16305 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
16306 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
16307 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
16308 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
16309 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
16310 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
16311 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
16312 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
16313 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
16314 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
16315 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
16316 | ||
16317 | /* "neighbor remove-private-AS" commands. */ | |
16318 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
16319 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
16320 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
16321 | install_element(BGP_NODE, | |
16322 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
16323 | install_element(BGP_NODE, | |
16324 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
16325 | install_element(BGP_NODE, | |
16326 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
16327 | install_element(BGP_NODE, | |
16328 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16329 | install_element( | |
16330 | BGP_NODE, | |
16331 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16332 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
16333 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16334 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16335 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16336 | install_element(BGP_IPV4_NODE, | |
16337 | &neighbor_remove_private_as_replace_as_cmd); | |
16338 | install_element(BGP_IPV4_NODE, | |
16339 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16340 | install_element(BGP_IPV4_NODE, | |
16341 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16342 | install_element(BGP_IPV4_NODE, | |
16343 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16344 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
16345 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
16346 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
16347 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16348 | install_element(BGP_IPV4M_NODE, | |
16349 | &neighbor_remove_private_as_replace_as_cmd); | |
16350 | install_element(BGP_IPV4M_NODE, | |
16351 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16352 | install_element(BGP_IPV4M_NODE, | |
16353 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16354 | install_element(BGP_IPV4M_NODE, | |
16355 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16356 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
16357 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
16358 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
16359 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16360 | install_element(BGP_IPV4L_NODE, | |
16361 | &neighbor_remove_private_as_replace_as_cmd); | |
16362 | install_element(BGP_IPV4L_NODE, | |
16363 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16364 | install_element(BGP_IPV4L_NODE, | |
16365 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16366 | install_element(BGP_IPV4L_NODE, | |
16367 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16368 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
16369 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16370 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16371 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16372 | install_element(BGP_IPV6_NODE, | |
16373 | &neighbor_remove_private_as_replace_as_cmd); | |
16374 | install_element(BGP_IPV6_NODE, | |
16375 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16376 | install_element(BGP_IPV6_NODE, | |
16377 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16378 | install_element(BGP_IPV6_NODE, | |
16379 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16380 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
16381 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
16382 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
16383 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16384 | install_element(BGP_IPV6M_NODE, | |
16385 | &neighbor_remove_private_as_replace_as_cmd); | |
16386 | install_element(BGP_IPV6M_NODE, | |
16387 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16388 | install_element(BGP_IPV6M_NODE, | |
16389 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16390 | install_element(BGP_IPV6M_NODE, | |
16391 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16392 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
16393 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
16394 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
16395 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16396 | install_element(BGP_IPV6L_NODE, | |
16397 | &neighbor_remove_private_as_replace_as_cmd); | |
16398 | install_element(BGP_IPV6L_NODE, | |
16399 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16400 | install_element(BGP_IPV6L_NODE, | |
16401 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16402 | install_element(BGP_IPV6L_NODE, | |
16403 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16404 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
16405 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16406 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16407 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16408 | install_element(BGP_VPNV4_NODE, | |
16409 | &neighbor_remove_private_as_replace_as_cmd); | |
16410 | install_element(BGP_VPNV4_NODE, | |
16411 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16412 | install_element(BGP_VPNV4_NODE, | |
16413 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16414 | install_element(BGP_VPNV4_NODE, | |
16415 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16416 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
16417 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16418 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16419 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16420 | install_element(BGP_VPNV6_NODE, | |
16421 | &neighbor_remove_private_as_replace_as_cmd); | |
16422 | install_element(BGP_VPNV6_NODE, | |
16423 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16424 | install_element(BGP_VPNV6_NODE, | |
16425 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16426 | install_element(BGP_VPNV6_NODE, | |
16427 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16428 | ||
16429 | /* "neighbor send-community" commands.*/ | |
16430 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
16431 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
16432 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
16433 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
16434 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
16435 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
16436 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
16437 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
16438 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
16439 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
16440 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
16441 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
16442 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
16443 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
16444 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
16445 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
16446 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
16447 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
16448 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
16449 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
16450 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
16451 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
16452 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
16453 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
16454 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
16455 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
16456 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
16457 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
16458 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
16459 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
16460 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
16461 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
16462 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
16463 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
16464 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
16465 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
16466 | ||
16467 | /* "neighbor route-reflector" commands.*/ | |
16468 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
16469 | install_element(BGP_NODE, | |
16470 | &no_neighbor_route_reflector_client_hidden_cmd); | |
16471 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
16472 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
16473 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
16474 | install_element(BGP_IPV4M_NODE, | |
16475 | &no_neighbor_route_reflector_client_cmd); | |
16476 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
16477 | install_element(BGP_IPV4L_NODE, | |
16478 | &no_neighbor_route_reflector_client_cmd); | |
16479 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
16480 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
16481 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
16482 | install_element(BGP_IPV6M_NODE, | |
16483 | &no_neighbor_route_reflector_client_cmd); | |
16484 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
16485 | install_element(BGP_IPV6L_NODE, | |
16486 | &no_neighbor_route_reflector_client_cmd); | |
16487 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
16488 | install_element(BGP_VPNV4_NODE, | |
16489 | &no_neighbor_route_reflector_client_cmd); | |
16490 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
16491 | install_element(BGP_VPNV6_NODE, | |
16492 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 16493 | install_element(BGP_FLOWSPECV4_NODE, |
16494 | &neighbor_route_reflector_client_cmd); | |
16495 | install_element(BGP_FLOWSPECV4_NODE, | |
16496 | &no_neighbor_route_reflector_client_cmd); | |
16497 | install_element(BGP_FLOWSPECV6_NODE, | |
16498 | &neighbor_route_reflector_client_cmd); | |
16499 | install_element(BGP_FLOWSPECV6_NODE, | |
16500 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 16501 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
16502 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
16503 | ||
16504 | /* "neighbor route-server" commands.*/ | |
16505 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
16506 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
16507 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
16508 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
16509 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
16510 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
16511 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
16512 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
16513 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
16514 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
16515 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
16516 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
16517 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
16518 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
16519 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
16520 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
16521 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
16522 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
16523 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
16524 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 16525 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
16526 | install_element(BGP_FLOWSPECV4_NODE, | |
16527 | &no_neighbor_route_server_client_cmd); | |
16528 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
16529 | install_element(BGP_FLOWSPECV6_NODE, | |
16530 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 16531 | |
16532 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
16533 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
16534 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
16535 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16536 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16537 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16538 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16539 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16540 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16541 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16542 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16543 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16544 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16545 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16546 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16547 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16548 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16549 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16550 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16551 | ||
16552 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
16553 | install_element(BGP_NODE, | |
16554 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16555 | install_element(BGP_NODE, | |
16556 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16557 | install_element(BGP_IPV4_NODE, | |
16558 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16559 | install_element(BGP_IPV4_NODE, | |
16560 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16561 | install_element(BGP_IPV4M_NODE, | |
16562 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16563 | install_element(BGP_IPV4M_NODE, | |
16564 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16565 | install_element(BGP_IPV4L_NODE, | |
16566 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16567 | install_element(BGP_IPV4L_NODE, | |
16568 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16569 | install_element(BGP_IPV6_NODE, | |
16570 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16571 | install_element(BGP_IPV6_NODE, | |
16572 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16573 | install_element(BGP_IPV6M_NODE, | |
16574 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16575 | install_element(BGP_IPV6M_NODE, | |
16576 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16577 | install_element(BGP_IPV6L_NODE, | |
16578 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16579 | install_element(BGP_IPV6L_NODE, | |
16580 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16581 | install_element(BGP_VPNV4_NODE, | |
16582 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16583 | install_element(BGP_VPNV4_NODE, | |
16584 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16585 | install_element(BGP_VPNV6_NODE, | |
16586 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16587 | install_element(BGP_VPNV6_NODE, | |
16588 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16589 | ||
2b31007c RZ |
16590 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16591 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16592 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16593 | ||
d62a17ae | 16594 | /* "neighbor passive" commands. */ |
16595 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16596 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16597 | ||
16598 | ||
16599 | /* "neighbor shutdown" commands. */ | |
16600 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16601 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16602 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16603 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16604 | ||
16605 | /* "neighbor capability extended-nexthop" commands.*/ | |
16606 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16607 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16608 | ||
16609 | /* "neighbor capability orf prefix-list" commands.*/ | |
16610 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16611 | install_element(BGP_NODE, | |
16612 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16613 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16614 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16615 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16616 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16617 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16618 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16619 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16620 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16621 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16622 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16623 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16624 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16625 | ||
16626 | /* "neighbor capability dynamic" commands.*/ | |
16627 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16628 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16629 | ||
16630 | /* "neighbor dont-capability-negotiate" commands. */ | |
16631 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16632 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16633 | ||
16634 | /* "neighbor ebgp-multihop" commands. */ | |
16635 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16636 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16637 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16638 | ||
16639 | /* "neighbor disable-connected-check" commands. */ | |
16640 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16641 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16642 | ||
47cbc09b PM |
16643 | /* "neighbor enforce-first-as" commands. */ |
16644 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16645 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16646 | ||
d62a17ae | 16647 | /* "neighbor description" commands. */ |
16648 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16649 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16650 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16651 | |
16652 | /* "neighbor update-source" commands. "*/ | |
16653 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16654 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16655 | ||
16656 | /* "neighbor default-originate" commands. */ | |
16657 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16658 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16659 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16660 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16661 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16662 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16663 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16664 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16665 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16666 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16667 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16668 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16669 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16670 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16671 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16672 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16673 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16674 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16675 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16676 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16677 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16678 | ||
16679 | /* "neighbor port" commands. */ | |
16680 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16681 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16682 | ||
16683 | /* "neighbor weight" commands. */ | |
16684 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16685 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16686 | ||
16687 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16688 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16689 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16690 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16691 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16692 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16693 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16694 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16695 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16696 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16697 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16698 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16699 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16700 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16701 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16702 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16703 | ||
16704 | /* "neighbor override-capability" commands. */ | |
16705 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16706 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16707 | ||
16708 | /* "neighbor strict-capability-match" commands. */ | |
16709 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16710 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16711 | ||
16712 | /* "neighbor timers" commands. */ | |
16713 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16714 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16715 | ||
16716 | /* "neighbor timers connect" commands. */ | |
16717 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16718 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16719 | ||
16720 | /* "neighbor advertisement-interval" commands. */ | |
16721 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16722 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16723 | ||
16724 | /* "neighbor interface" commands. */ | |
16725 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16726 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16727 | ||
16728 | /* "neighbor distribute" commands. */ | |
16729 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16730 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16731 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16732 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16733 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16734 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16735 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16736 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16737 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16738 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16739 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16740 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16741 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16742 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16743 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16744 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16745 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16746 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16747 | ||
16748 | /* "neighbor prefix-list" commands. */ | |
16749 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16750 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16751 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16752 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16753 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16754 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16755 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16756 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16757 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16758 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16759 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16760 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16761 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16762 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16763 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16764 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16765 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16766 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16767 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16768 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16769 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16770 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16771 | |
16772 | /* "neighbor filter-list" commands. */ | |
16773 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16774 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16775 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16776 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16777 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16778 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16779 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16780 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16781 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16782 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16783 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16784 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16785 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16786 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16787 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16788 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16789 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16790 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16791 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16792 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16793 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16794 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16795 | |
16796 | /* "neighbor route-map" commands. */ | |
16797 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16798 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16799 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16800 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16801 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16802 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16803 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16804 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16805 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16806 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16807 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16808 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16809 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16810 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16811 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16812 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16813 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16814 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16815 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16816 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16817 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16818 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16819 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16820 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16821 | |
16822 | /* "neighbor unsuppress-map" commands. */ | |
16823 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16824 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16825 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16826 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16827 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16828 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16829 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16830 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16831 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16832 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16833 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16834 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16835 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16836 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16837 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16838 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16839 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16840 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16841 | ||
fde246e8 DA |
16842 | /* neighbor maximum-prefix-out commands. */ |
16843 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16844 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16845 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16846 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16847 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16848 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16849 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16850 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16851 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16852 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16853 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16854 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16855 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16856 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16857 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16858 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16859 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16860 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16861 | ||
d62a17ae | 16862 | /* "neighbor maximum-prefix" commands. */ |
16863 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16864 | install_element(BGP_NODE, | |
16865 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16866 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16867 | install_element(BGP_NODE, | |
16868 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16869 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16870 | install_element(BGP_NODE, | |
16871 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16872 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16873 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16874 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16875 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16876 | install_element(BGP_IPV4_NODE, | |
16877 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16878 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16879 | install_element(BGP_IPV4_NODE, | |
16880 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16881 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16882 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16883 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16884 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16885 | install_element(BGP_IPV4M_NODE, | |
16886 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16887 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16888 | install_element(BGP_IPV4M_NODE, | |
16889 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16890 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16891 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16892 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16893 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16894 | install_element(BGP_IPV4L_NODE, | |
16895 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16896 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16897 | install_element(BGP_IPV4L_NODE, | |
16898 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16899 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16900 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16901 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16902 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16903 | install_element(BGP_IPV6_NODE, | |
16904 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16905 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16906 | install_element(BGP_IPV6_NODE, | |
16907 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16908 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16909 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16910 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16911 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16912 | install_element(BGP_IPV6M_NODE, | |
16913 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16914 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16915 | install_element(BGP_IPV6M_NODE, | |
16916 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16917 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16918 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16919 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16920 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16921 | install_element(BGP_IPV6L_NODE, | |
16922 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16923 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16924 | install_element(BGP_IPV6L_NODE, | |
16925 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16926 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16927 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16928 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16929 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16930 | install_element(BGP_VPNV4_NODE, | |
16931 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16932 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16933 | install_element(BGP_VPNV4_NODE, | |
16934 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16935 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16936 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16937 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16938 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16939 | install_element(BGP_VPNV6_NODE, | |
16940 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16941 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16942 | install_element(BGP_VPNV6_NODE, | |
16943 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16944 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16945 | ||
16946 | /* "neighbor allowas-in" */ | |
16947 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16948 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16949 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16950 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16951 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16952 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16953 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16954 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16955 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16956 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16957 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16958 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16959 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16960 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16961 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16962 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16963 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16964 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16965 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16966 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16967 | ||
16968 | /* address-family commands. */ | |
16969 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16970 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16971 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16972 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16973 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16974 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16975 | |
d62a17ae | 16976 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16977 | ||
16978 | /* "exit-address-family" command. */ | |
16979 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16980 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16981 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16982 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16983 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16984 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16985 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16986 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16987 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16988 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16989 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16990 | ||
16991 | /* "clear ip bgp commands" */ | |
16992 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16993 | ||
16994 | /* clear ip bgp prefix */ | |
16995 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16996 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16997 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16998 | ||
16999 | /* "show [ip] bgp summary" commands. */ | |
17000 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 17001 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 17002 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 17003 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 17004 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
17005 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 17006 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
17007 | ||
17008 | /* "show [ip] bgp neighbors" commands. */ | |
17009 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
17010 | ||
36235319 | 17011 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 17012 | |
d62a17ae | 17013 | /* "show [ip] bgp peer-group" commands. */ |
17014 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
17015 | ||
17016 | /* "show [ip] bgp paths" commands. */ | |
17017 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
17018 | ||
17019 | /* "show [ip] bgp community" commands. */ | |
17020 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
17021 | ||
17022 | /* "show ip bgp large-community" commands. */ | |
17023 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
17024 | /* "show [ip] bgp attribute-info" commands. */ | |
17025 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 17026 | /* "show [ip] bgp route-leak" command */ |
17027 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 17028 | |
17029 | /* "redistribute" commands. */ | |
17030 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
17031 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
17032 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
17033 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
17034 | install_element(BGP_NODE, | |
17035 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
17036 | install_element(BGP_NODE, | |
17037 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
17038 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
17039 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
17040 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
17041 | install_element(BGP_NODE, | |
17042 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
17043 | install_element(BGP_NODE, | |
17044 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
17045 | install_element(BGP_NODE, | |
17046 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
17047 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
17048 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
17049 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
17050 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
17051 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
17052 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
17053 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
17054 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
17055 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
17056 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
17057 | install_element(BGP_IPV4_NODE, | |
17058 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
17059 | install_element(BGP_IPV4_NODE, | |
17060 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
17061 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
17062 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
17063 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
17064 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
17065 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
17066 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
17067 | ||
b9c7bc5a PZ |
17068 | /* import|export vpn [route-map WORD] */ |
17069 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
17070 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 17071 | |
12a844a5 DS |
17072 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
17073 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
17074 | ||
d62a17ae | 17075 | /* ttl_security commands */ |
17076 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
17077 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
17078 | ||
17079 | /* "show [ip] bgp memory" commands. */ | |
17080 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
17081 | ||
acf71666 MK |
17082 | /* "show bgp martian next-hop" */ |
17083 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
17084 | ||
48ecf8f5 DS |
17085 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
17086 | ||
d62a17ae | 17087 | /* "show [ip] bgp views" commands. */ |
17088 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
17089 | ||
17090 | /* "show [ip] bgp vrfs" commands. */ | |
17091 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
17092 | ||
17093 | /* Community-list. */ | |
17094 | community_list_vty(); | |
ddb5b488 PZ |
17095 | |
17096 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
17097 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
17098 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
17099 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
17100 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
17101 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
17102 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
17103 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
17104 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
17105 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
17106 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
17107 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
17108 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 17109 | |
301ad80a PG |
17110 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
17111 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
17112 | ||
b9c7bc5a PZ |
17113 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
17114 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
17115 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
17116 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
17117 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
17118 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
17119 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
17120 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
17121 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
17122 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 17123 | } |
6b0655a2 | 17124 | |
718e3744 | 17125 | #include "memory.h" |
17126 | #include "bgp_regex.h" | |
17127 | #include "bgp_clist.h" | |
17128 | #include "bgp_ecommunity.h" | |
17129 | ||
17130 | /* VTY functions. */ | |
17131 | ||
17132 | /* Direction value to string conversion. */ | |
d62a17ae | 17133 | static const char *community_direct_str(int direct) |
17134 | { | |
17135 | switch (direct) { | |
17136 | case COMMUNITY_DENY: | |
17137 | return "deny"; | |
17138 | case COMMUNITY_PERMIT: | |
17139 | return "permit"; | |
17140 | default: | |
17141 | return "unknown"; | |
17142 | } | |
718e3744 | 17143 | } |
17144 | ||
17145 | /* Display error string. */ | |
d62a17ae | 17146 | static void community_list_perror(struct vty *vty, int ret) |
17147 | { | |
17148 | switch (ret) { | |
17149 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
17150 | vty_out(vty, "%% Can't find community-list\n"); | |
17151 | break; | |
17152 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
17153 | vty_out(vty, "%% Malformed community-list value\n"); | |
17154 | break; | |
17155 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
17156 | vty_out(vty, | |
17157 | "%% Community name conflict, previously defined as standard community\n"); | |
17158 | break; | |
17159 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
17160 | vty_out(vty, | |
17161 | "%% Community name conflict, previously defined as expanded community\n"); | |
17162 | break; | |
17163 | } | |
718e3744 | 17164 | } |
17165 | ||
5bf15956 DW |
17166 | /* "community-list" keyword help string. */ |
17167 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
17168 | ||
7336e101 SP |
17169 | /*community-list standard */ |
17170 | DEFUN (community_list_standard, | |
17171 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 17172 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17173 | BGP_STR |
718e3744 | 17174 | COMMUNITY_LIST_STR |
17175 | "Community list number (standard)\n" | |
5bf15956 | 17176 | "Add an standard community-list entry\n" |
718e3744 | 17177 | "Community list name\n" |
2f8cc0e5 DA |
17178 | "Sequence number of an entry\n" |
17179 | "Sequence number\n" | |
718e3744 | 17180 | "Specify community to reject\n" |
17181 | "Specify community to accept\n" | |
17182 | COMMUNITY_VAL_STR) | |
17183 | { | |
d62a17ae | 17184 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17185 | char *seq = NULL; |
d62a17ae | 17186 | int direct = 0; |
17187 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 17188 | int idx = 0; |
7336e101 | 17189 | |
2f8cc0e5 DA |
17190 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17191 | if (idx) | |
17192 | seq = argv[idx]->arg; | |
17193 | ||
17194 | idx = 0; | |
d62a17ae | 17195 | argv_find(argv, argc, "(1-99)", &idx); |
17196 | argv_find(argv, argc, "WORD", &idx); | |
17197 | cl_name_or_number = argv[idx]->arg; | |
17198 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17199 | : COMMUNITY_DENY; | |
17200 | argv_find(argv, argc, "AA:NN", &idx); | |
17201 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17202 | |
2f8cc0e5 DA |
17203 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
17204 | direct, style); | |
42f914d4 | 17205 | |
d62a17ae | 17206 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17207 | |
d62a17ae | 17208 | if (ret < 0) { |
17209 | /* Display error string. */ | |
17210 | community_list_perror(vty, ret); | |
17211 | return CMD_WARNING_CONFIG_FAILED; | |
17212 | } | |
42f914d4 | 17213 | |
d62a17ae | 17214 | return CMD_SUCCESS; |
718e3744 | 17215 | } |
17216 | ||
7336e101 SP |
17217 | DEFUN (no_community_list_standard_all, |
17218 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 17219 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17220 | NO_STR |
17221 | BGP_STR | |
17222 | COMMUNITY_LIST_STR | |
17223 | "Community list number (standard)\n" | |
17224 | "Add an standard community-list entry\n" | |
17225 | "Community list name\n" | |
2f8cc0e5 DA |
17226 | "Sequence number of an entry\n" |
17227 | "Sequence number\n" | |
7336e101 SP |
17228 | "Specify community to reject\n" |
17229 | "Specify community to accept\n" | |
17230 | COMMUNITY_VAL_STR) | |
718e3744 | 17231 | { |
d62a17ae | 17232 | char *cl_name_or_number = NULL; |
174b5cb9 | 17233 | char *str = NULL; |
d62a17ae | 17234 | int direct = 0; |
17235 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 17236 | char *seq = NULL; |
d62a17ae | 17237 | int idx = 0; |
7336e101 | 17238 | |
2f8cc0e5 DA |
17239 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17240 | if (idx) | |
17241 | seq = argv[idx]->arg; | |
17242 | ||
17243 | idx = 0; | |
174b5cb9 DA |
17244 | argv_find(argv, argc, "permit", &idx); |
17245 | argv_find(argv, argc, "deny", &idx); | |
17246 | ||
17247 | if (idx) { | |
17248 | direct = argv_find(argv, argc, "permit", &idx) | |
17249 | ? COMMUNITY_PERMIT | |
17250 | : COMMUNITY_DENY; | |
17251 | ||
17252 | idx = 0; | |
17253 | argv_find(argv, argc, "AA:NN", &idx); | |
17254 | str = argv_concat(argv, argc, idx); | |
17255 | } | |
17256 | ||
17257 | idx = 0; | |
d62a17ae | 17258 | argv_find(argv, argc, "(1-99)", &idx); |
17259 | argv_find(argv, argc, "WORD", &idx); | |
17260 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 17261 | |
2f8cc0e5 | 17262 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 17263 | direct, style); |
42f914d4 | 17264 | |
d62a17ae | 17265 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17266 | |
d62a17ae | 17267 | if (ret < 0) { |
17268 | community_list_perror(vty, ret); | |
17269 | return CMD_WARNING_CONFIG_FAILED; | |
17270 | } | |
42f914d4 | 17271 | |
d62a17ae | 17272 | return CMD_SUCCESS; |
718e3744 | 17273 | } |
7336e101 | 17274 | |
174b5cb9 DA |
17275 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
17276 | "no bgp community-list <(1-99)|standard WORD>", | |
17277 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
17278 | "Community list number (standard)\n" | |
17279 | "Add an standard community-list entry\n" | |
17280 | "Community list name\n") | |
17281 | ||
7336e101 SP |
17282 | /*community-list expanded */ |
17283 | DEFUN (community_list_expanded_all, | |
17284 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17285 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17286 | BGP_STR |
17287 | COMMUNITY_LIST_STR | |
718e3744 | 17288 | "Community list number (expanded)\n" |
5bf15956 | 17289 | "Add an expanded community-list entry\n" |
718e3744 | 17290 | "Community list name\n" |
2f8cc0e5 DA |
17291 | "Sequence number of an entry\n" |
17292 | "Sequence number\n" | |
718e3744 | 17293 | "Specify community to reject\n" |
17294 | "Specify community to accept\n" | |
17295 | COMMUNITY_VAL_STR) | |
17296 | { | |
d62a17ae | 17297 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17298 | char *seq = NULL; |
d62a17ae | 17299 | int direct = 0; |
17300 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17301 | int idx = 0; |
7b9a4750 | 17302 | |
2f8cc0e5 DA |
17303 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17304 | if (idx) | |
17305 | seq = argv[idx]->arg; | |
17306 | ||
17307 | idx = 0; | |
17308 | ||
d62a17ae | 17309 | argv_find(argv, argc, "(100-500)", &idx); |
17310 | argv_find(argv, argc, "WORD", &idx); | |
17311 | cl_name_or_number = argv[idx]->arg; | |
17312 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17313 | : COMMUNITY_DENY; | |
17314 | argv_find(argv, argc, "AA:NN", &idx); | |
17315 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17316 | |
2f8cc0e5 DA |
17317 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
17318 | direct, style); | |
42f914d4 | 17319 | |
d62a17ae | 17320 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17321 | |
d62a17ae | 17322 | if (ret < 0) { |
17323 | /* Display error string. */ | |
17324 | community_list_perror(vty, ret); | |
17325 | return CMD_WARNING_CONFIG_FAILED; | |
17326 | } | |
42f914d4 | 17327 | |
d62a17ae | 17328 | return CMD_SUCCESS; |
718e3744 | 17329 | } |
17330 | ||
7336e101 SP |
17331 | DEFUN (no_community_list_expanded_all, |
17332 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17333 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17334 | NO_STR |
17335 | BGP_STR | |
17336 | COMMUNITY_LIST_STR | |
17337 | "Community list number (expanded)\n" | |
17338 | "Add an expanded community-list entry\n" | |
17339 | "Community list name\n" | |
2f8cc0e5 DA |
17340 | "Sequence number of an entry\n" |
17341 | "Sequence number\n" | |
7336e101 SP |
17342 | "Specify community to reject\n" |
17343 | "Specify community to accept\n" | |
17344 | COMMUNITY_VAL_STR) | |
718e3744 | 17345 | { |
d62a17ae | 17346 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17347 | char *seq = NULL; |
174b5cb9 | 17348 | char *str = NULL; |
d62a17ae | 17349 | int direct = 0; |
17350 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17351 | int idx = 0; |
174b5cb9 | 17352 | |
2f8cc0e5 DA |
17353 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17354 | if (idx) | |
17355 | seq = argv[idx]->arg; | |
17356 | ||
17357 | idx = 0; | |
174b5cb9 DA |
17358 | argv_find(argv, argc, "permit", &idx); |
17359 | argv_find(argv, argc, "deny", &idx); | |
17360 | ||
17361 | if (idx) { | |
17362 | direct = argv_find(argv, argc, "permit", &idx) | |
17363 | ? COMMUNITY_PERMIT | |
17364 | : COMMUNITY_DENY; | |
17365 | ||
17366 | idx = 0; | |
17367 | argv_find(argv, argc, "AA:NN", &idx); | |
17368 | str = argv_concat(argv, argc, idx); | |
7336e101 | 17369 | } |
174b5cb9 DA |
17370 | |
17371 | idx = 0; | |
d62a17ae | 17372 | argv_find(argv, argc, "(100-500)", &idx); |
17373 | argv_find(argv, argc, "WORD", &idx); | |
17374 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 17375 | |
2f8cc0e5 | 17376 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 17377 | direct, style); |
42f914d4 | 17378 | |
d62a17ae | 17379 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17380 | |
d62a17ae | 17381 | if (ret < 0) { |
17382 | community_list_perror(vty, ret); | |
17383 | return CMD_WARNING_CONFIG_FAILED; | |
17384 | } | |
42f914d4 | 17385 | |
d62a17ae | 17386 | return CMD_SUCCESS; |
718e3744 | 17387 | } |
17388 | ||
174b5cb9 DA |
17389 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
17390 | "no bgp community-list <(100-500)|expanded WORD>", | |
17391 | NO_STR IP_STR COMMUNITY_LIST_STR | |
17392 | "Community list number (expanded)\n" | |
17393 | "Add an expanded community-list entry\n" | |
17394 | "Community list name\n") | |
17395 | ||
8d9b8ed9 PM |
17396 | /* Return configuration string of community-list entry. */ |
17397 | static const char *community_list_config_str(struct community_entry *entry) | |
17398 | { | |
17399 | const char *str; | |
17400 | ||
17401 | if (entry->any) | |
17402 | str = ""; | |
17403 | else { | |
17404 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
17405 | str = community_str(entry->u.com, false); | |
17406 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
17407 | str = lcommunity_str(entry->u.lcom, false); | |
17408 | else | |
17409 | str = entry->config; | |
17410 | } | |
17411 | return str; | |
17412 | } | |
17413 | ||
d62a17ae | 17414 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17415 | { |
d62a17ae | 17416 | struct community_entry *entry; |
718e3744 | 17417 | |
d62a17ae | 17418 | for (entry = list->head; entry; entry = entry->next) { |
17419 | if (entry == list->head) { | |
17420 | if (all_digit(list->name)) | |
17421 | vty_out(vty, "Community %s list %s\n", | |
17422 | entry->style == COMMUNITY_LIST_STANDARD | |
17423 | ? "standard" | |
17424 | : "(expanded) access", | |
17425 | list->name); | |
17426 | else | |
17427 | vty_out(vty, "Named Community %s list %s\n", | |
17428 | entry->style == COMMUNITY_LIST_STANDARD | |
17429 | ? "standard" | |
17430 | : "expanded", | |
17431 | list->name); | |
17432 | } | |
17433 | if (entry->any) | |
17434 | vty_out(vty, " %s\n", | |
17435 | community_direct_str(entry->direct)); | |
17436 | else | |
17437 | vty_out(vty, " %s %s\n", | |
17438 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17439 | community_list_config_str(entry)); |
d62a17ae | 17440 | } |
718e3744 | 17441 | } |
17442 | ||
7336e101 SP |
17443 | DEFUN (show_community_list, |
17444 | show_bgp_community_list_cmd, | |
17445 | "show bgp community-list", | |
718e3744 | 17446 | SHOW_STR |
7336e101 | 17447 | BGP_STR |
718e3744 | 17448 | "List community-list\n") |
17449 | { | |
d62a17ae | 17450 | struct community_list *list; |
17451 | struct community_list_master *cm; | |
718e3744 | 17452 | |
d62a17ae | 17453 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
17454 | if (!cm) | |
17455 | return CMD_SUCCESS; | |
718e3744 | 17456 | |
d62a17ae | 17457 | for (list = cm->num.head; list; list = list->next) |
17458 | community_list_show(vty, list); | |
718e3744 | 17459 | |
d62a17ae | 17460 | for (list = cm->str.head; list; list = list->next) |
17461 | community_list_show(vty, list); | |
718e3744 | 17462 | |
d62a17ae | 17463 | return CMD_SUCCESS; |
718e3744 | 17464 | } |
17465 | ||
7336e101 SP |
17466 | DEFUN (show_community_list_arg, |
17467 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 17468 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
17469 | SHOW_STR |
17470 | BGP_STR | |
718e3744 | 17471 | "List community-list\n" |
17472 | "Community-list number\n" | |
960b69b9 | 17473 | "Community-list name\n" |
17474 | "Detailed information on community-list\n") | |
718e3744 | 17475 | { |
d62a17ae | 17476 | int idx_comm_list = 3; |
17477 | struct community_list *list; | |
718e3744 | 17478 | |
e237b0d2 | 17479 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17480 | COMMUNITY_LIST_MASTER); |
17481 | if (!list) { | |
17482 | vty_out(vty, "%% Can't find community-list\n"); | |
17483 | return CMD_WARNING; | |
17484 | } | |
718e3744 | 17485 | |
d62a17ae | 17486 | community_list_show(vty, list); |
718e3744 | 17487 | |
d62a17ae | 17488 | return CMD_SUCCESS; |
718e3744 | 17489 | } |
6b0655a2 | 17490 | |
57d187bc JS |
17491 | /* |
17492 | * Large Community code. | |
17493 | */ | |
d62a17ae | 17494 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
17495 | struct cmd_token **argv, int style, | |
17496 | int reject_all_digit_name) | |
17497 | { | |
17498 | int ret; | |
17499 | int direct; | |
17500 | char *str; | |
17501 | int idx = 0; | |
17502 | char *cl_name; | |
2f8cc0e5 DA |
17503 | char *seq = NULL; |
17504 | ||
947073e3 | 17505 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 17506 | seq = argv[idx]->arg; |
d62a17ae | 17507 | |
2f8cc0e5 | 17508 | idx = 0; |
d62a17ae | 17509 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17510 | : COMMUNITY_DENY; | |
17511 | ||
17512 | /* All digit name check. */ | |
17513 | idx = 0; | |
17514 | argv_find(argv, argc, "WORD", &idx); | |
17515 | argv_find(argv, argc, "(1-99)", &idx); | |
17516 | argv_find(argv, argc, "(100-500)", &idx); | |
17517 | cl_name = argv[idx]->arg; | |
17518 | if (reject_all_digit_name && all_digit(cl_name)) { | |
17519 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
17520 | return CMD_WARNING_CONFIG_FAILED; | |
17521 | } | |
17522 | ||
17523 | idx = 0; | |
17524 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
17525 | argv_find(argv, argc, "LINE", &idx); | |
17526 | /* Concat community string argument. */ | |
17527 | if (idx) | |
17528 | str = argv_concat(argv, argc, idx); | |
17529 | else | |
17530 | str = NULL; | |
17531 | ||
2f8cc0e5 | 17532 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 17533 | |
17534 | /* Free temporary community list string allocated by | |
17535 | argv_concat(). */ | |
0a22ddfb | 17536 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17537 | |
17538 | if (ret < 0) { | |
17539 | community_list_perror(vty, ret); | |
17540 | return CMD_WARNING_CONFIG_FAILED; | |
17541 | } | |
17542 | return CMD_SUCCESS; | |
17543 | } | |
17544 | ||
17545 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
17546 | struct cmd_token **argv, int style) | |
17547 | { | |
17548 | int ret; | |
17549 | int direct = 0; | |
17550 | char *str = NULL; | |
17551 | int idx = 0; | |
2f8cc0e5 | 17552 | char *seq = NULL; |
d62a17ae | 17553 | |
947073e3 | 17554 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 17555 | seq = argv[idx]->arg; |
d62a17ae | 17556 | |
2f8cc0e5 | 17557 | idx = 0; |
d62a17ae | 17558 | argv_find(argv, argc, "permit", &idx); |
17559 | argv_find(argv, argc, "deny", &idx); | |
17560 | ||
17561 | if (idx) { | |
17562 | /* Check the list direct. */ | |
17563 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
17564 | direct = COMMUNITY_PERMIT; | |
17565 | else | |
17566 | direct = COMMUNITY_DENY; | |
17567 | ||
17568 | idx = 0; | |
17569 | argv_find(argv, argc, "LINE", &idx); | |
17570 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
17571 | /* Concat community string argument. */ | |
17572 | str = argv_concat(argv, argc, idx); | |
17573 | } | |
17574 | ||
17575 | idx = 0; | |
17576 | argv_find(argv, argc, "(1-99)", &idx); | |
17577 | argv_find(argv, argc, "(100-500)", &idx); | |
17578 | argv_find(argv, argc, "WORD", &idx); | |
17579 | ||
17580 | /* Unset community list. */ | |
2f8cc0e5 | 17581 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 17582 | style); |
17583 | ||
17584 | /* Free temporary community list string allocated by | |
17585 | argv_concat(). */ | |
0a22ddfb | 17586 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17587 | |
17588 | if (ret < 0) { | |
17589 | community_list_perror(vty, ret); | |
17590 | return CMD_WARNING_CONFIG_FAILED; | |
17591 | } | |
17592 | ||
17593 | return CMD_SUCCESS; | |
57d187bc JS |
17594 | } |
17595 | ||
17596 | /* "large-community-list" keyword help string. */ | |
17597 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
17598 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
17599 | ||
7336e101 SP |
17600 | DEFUN (lcommunity_list_standard, |
17601 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17602 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17603 | BGP_STR |
17604 | LCOMMUNITY_LIST_STR | |
17605 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17606 | "Sequence number of an entry\n" |
17607 | "Sequence number\n" | |
7336e101 SP |
17608 | "Specify large community to reject\n" |
17609 | "Specify large community to accept\n" | |
17610 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17611 | { |
d62a17ae | 17612 | return lcommunity_list_set_vty(vty, argc, argv, |
17613 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17614 | } |
17615 | ||
7336e101 SP |
17616 | DEFUN (lcommunity_list_expanded, |
17617 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17618 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17619 | BGP_STR |
17620 | LCOMMUNITY_LIST_STR | |
17621 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17622 | "Sequence number of an entry\n" |
17623 | "Sequence number\n" | |
7336e101 SP |
17624 | "Specify large community to reject\n" |
17625 | "Specify large community to accept\n" | |
17626 | "An ordered list as a regular-expression\n") | |
57d187bc | 17627 | { |
d62a17ae | 17628 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17629 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17630 | } |
17631 | ||
7336e101 SP |
17632 | DEFUN (lcommunity_list_name_standard, |
17633 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17634 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17635 | BGP_STR |
17636 | LCOMMUNITY_LIST_STR | |
17637 | "Specify standard large-community-list\n" | |
17638 | "Large Community list name\n" | |
2f8cc0e5 DA |
17639 | "Sequence number of an entry\n" |
17640 | "Sequence number\n" | |
7336e101 SP |
17641 | "Specify large community to reject\n" |
17642 | "Specify large community to accept\n" | |
17643 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17644 | { |
d62a17ae | 17645 | return lcommunity_list_set_vty(vty, argc, argv, |
17646 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17647 | } |
17648 | ||
7336e101 SP |
17649 | DEFUN (lcommunity_list_name_expanded, |
17650 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17651 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17652 | BGP_STR |
17653 | LCOMMUNITY_LIST_STR | |
17654 | "Specify expanded large-community-list\n" | |
17655 | "Large Community list name\n" | |
2f8cc0e5 DA |
17656 | "Sequence number of an entry\n" |
17657 | "Sequence number\n" | |
7336e101 SP |
17658 | "Specify large community to reject\n" |
17659 | "Specify large community to accept\n" | |
17660 | "An ordered list as a regular-expression\n") | |
57d187bc | 17661 | { |
d62a17ae | 17662 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17663 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17664 | } |
17665 | ||
4378f57c DA |
17666 | DEFUN (no_lcommunity_list_all, |
17667 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
17668 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
17669 | NO_STR | |
17670 | BGP_STR | |
17671 | LCOMMUNITY_LIST_STR | |
17672 | "Large Community list number (standard)\n" | |
17673 | "Large Community list number (expanded)\n" | |
17674 | "Large Community list name\n") | |
57d187bc | 17675 | { |
7336e101 SP |
17676 | return lcommunity_list_unset_vty(vty, argc, argv, |
17677 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17678 | } |
17679 | ||
4378f57c DA |
17680 | DEFUN (no_lcommunity_list_name_standard_all, |
17681 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
17682 | "no bgp large-community-list standard WORD", | |
17683 | NO_STR | |
17684 | BGP_STR | |
17685 | LCOMMUNITY_LIST_STR | |
17686 | "Specify standard large-community-list\n" | |
17687 | "Large Community list name\n") | |
17688 | { | |
17689 | return lcommunity_list_unset_vty(vty, argc, argv, | |
17690 | LARGE_COMMUNITY_LIST_STANDARD); | |
17691 | } | |
17692 | ||
7336e101 SP |
17693 | DEFUN (no_lcommunity_list_name_expanded_all, |
17694 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17695 | "no bgp large-community-list expanded WORD", | |
17696 | NO_STR | |
17697 | BGP_STR | |
17698 | LCOMMUNITY_LIST_STR | |
17699 | "Specify expanded large-community-list\n" | |
17700 | "Large Community list name\n") | |
57d187bc | 17701 | { |
d62a17ae | 17702 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17703 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17704 | } |
17705 | ||
7336e101 SP |
17706 | DEFUN (no_lcommunity_list_standard, |
17707 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17708 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17709 | NO_STR |
17710 | BGP_STR | |
17711 | LCOMMUNITY_LIST_STR | |
17712 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17713 | "Sequence number of an entry\n" |
17714 | "Sequence number\n" | |
7336e101 SP |
17715 | "Specify large community to reject\n" |
17716 | "Specify large community to accept\n" | |
17717 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17718 | { |
d62a17ae | 17719 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17720 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17721 | } |
17722 | ||
7336e101 SP |
17723 | DEFUN (no_lcommunity_list_expanded, |
17724 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17725 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17726 | NO_STR |
17727 | BGP_STR | |
17728 | LCOMMUNITY_LIST_STR | |
17729 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17730 | "Sequence number of an entry\n" |
17731 | "Sequence number\n" | |
7336e101 SP |
17732 | "Specify large community to reject\n" |
17733 | "Specify large community to accept\n" | |
17734 | "An ordered list as a regular-expression\n") | |
57d187bc | 17735 | { |
d62a17ae | 17736 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17737 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17738 | } |
17739 | ||
7336e101 SP |
17740 | DEFUN (no_lcommunity_list_name_standard, |
17741 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17742 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17743 | NO_STR |
17744 | BGP_STR | |
17745 | LCOMMUNITY_LIST_STR | |
17746 | "Specify standard large-community-list\n" | |
17747 | "Large Community list name\n" | |
2f8cc0e5 DA |
17748 | "Sequence number of an entry\n" |
17749 | "Sequence number\n" | |
7336e101 SP |
17750 | "Specify large community to reject\n" |
17751 | "Specify large community to accept\n" | |
17752 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17753 | { |
d62a17ae | 17754 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17755 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17756 | } |
17757 | ||
7336e101 SP |
17758 | DEFUN (no_lcommunity_list_name_expanded, |
17759 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17760 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17761 | NO_STR |
17762 | BGP_STR | |
17763 | LCOMMUNITY_LIST_STR | |
17764 | "Specify expanded large-community-list\n" | |
17765 | "Large community list name\n" | |
2f8cc0e5 DA |
17766 | "Sequence number of an entry\n" |
17767 | "Sequence number\n" | |
7336e101 SP |
17768 | "Specify large community to reject\n" |
17769 | "Specify large community to accept\n" | |
17770 | "An ordered list as a regular-expression\n") | |
57d187bc | 17771 | { |
d62a17ae | 17772 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17773 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17774 | } |
17775 | ||
d62a17ae | 17776 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17777 | { | |
17778 | struct community_entry *entry; | |
17779 | ||
17780 | for (entry = list->head; entry; entry = entry->next) { | |
17781 | if (entry == list->head) { | |
17782 | if (all_digit(list->name)) | |
17783 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17784 | entry->style == |
17785 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17786 | ? "standard" |
17787 | : "(expanded) access", | |
17788 | list->name); | |
17789 | else | |
17790 | vty_out(vty, | |
17791 | "Named large community %s list %s\n", | |
169b72c8 | 17792 | entry->style == |
17793 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17794 | ? "standard" |
17795 | : "expanded", | |
17796 | list->name); | |
17797 | } | |
17798 | if (entry->any) | |
17799 | vty_out(vty, " %s\n", | |
17800 | community_direct_str(entry->direct)); | |
17801 | else | |
17802 | vty_out(vty, " %s %s\n", | |
17803 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17804 | community_list_config_str(entry)); |
d62a17ae | 17805 | } |
57d187bc JS |
17806 | } |
17807 | ||
7336e101 SP |
17808 | DEFUN (show_lcommunity_list, |
17809 | show_bgp_lcommunity_list_cmd, | |
17810 | "show bgp large-community-list", | |
57d187bc | 17811 | SHOW_STR |
7336e101 | 17812 | BGP_STR |
57d187bc JS |
17813 | "List large-community list\n") |
17814 | { | |
d62a17ae | 17815 | struct community_list *list; |
17816 | struct community_list_master *cm; | |
57d187bc | 17817 | |
d62a17ae | 17818 | cm = community_list_master_lookup(bgp_clist, |
17819 | LARGE_COMMUNITY_LIST_MASTER); | |
17820 | if (!cm) | |
17821 | return CMD_SUCCESS; | |
57d187bc | 17822 | |
d62a17ae | 17823 | for (list = cm->num.head; list; list = list->next) |
17824 | lcommunity_list_show(vty, list); | |
57d187bc | 17825 | |
d62a17ae | 17826 | for (list = cm->str.head; list; list = list->next) |
17827 | lcommunity_list_show(vty, list); | |
57d187bc | 17828 | |
d62a17ae | 17829 | return CMD_SUCCESS; |
57d187bc JS |
17830 | } |
17831 | ||
7336e101 SP |
17832 | DEFUN (show_lcommunity_list_arg, |
17833 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17834 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17835 | SHOW_STR |
17836 | BGP_STR | |
57d187bc | 17837 | "List large-community list\n" |
960b69b9 | 17838 | "Large-community-list number\n" |
17839 | "Large-community-list name\n" | |
17840 | "Detailed information on large-community-list\n") | |
57d187bc | 17841 | { |
d62a17ae | 17842 | struct community_list *list; |
57d187bc | 17843 | |
e237b0d2 | 17844 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17845 | LARGE_COMMUNITY_LIST_MASTER); |
17846 | if (!list) { | |
960b69b9 | 17847 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17848 | return CMD_WARNING; |
17849 | } | |
57d187bc | 17850 | |
d62a17ae | 17851 | lcommunity_list_show(vty, list); |
57d187bc | 17852 | |
d62a17ae | 17853 | return CMD_SUCCESS; |
57d187bc JS |
17854 | } |
17855 | ||
718e3744 | 17856 | /* "extcommunity-list" keyword help string. */ |
17857 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17858 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17859 | ||
7336e101 SP |
17860 | DEFUN (extcommunity_list_standard, |
17861 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 17862 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17863 | BGP_STR |
718e3744 | 17864 | EXTCOMMUNITY_LIST_STR |
17865 | "Extended Community list number (standard)\n" | |
718e3744 | 17866 | "Specify standard extcommunity-list\n" |
5bf15956 | 17867 | "Community list name\n" |
2f8cc0e5 DA |
17868 | "Sequence number of an entry\n" |
17869 | "Sequence number\n" | |
718e3744 | 17870 | "Specify community to reject\n" |
17871 | "Specify community to accept\n" | |
17872 | EXTCOMMUNITY_VAL_STR) | |
17873 | { | |
d62a17ae | 17874 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17875 | int direct = 0; | |
17876 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17877 | char *seq = NULL; |
42f914d4 | 17878 | |
d62a17ae | 17879 | int idx = 0; |
7b9a4750 | 17880 | |
d62a17ae | 17881 | argv_find(argv, argc, "(1-99)", &idx); |
17882 | argv_find(argv, argc, "WORD", &idx); | |
17883 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 17884 | |
409148f6 | 17885 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17886 | seq = argv[idx]->arg; |
17887 | ||
d62a17ae | 17888 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17889 | : COMMUNITY_DENY; | |
17890 | argv_find(argv, argc, "AA:NN", &idx); | |
17891 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17892 | |
2f8cc0e5 | 17893 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17894 | direct, style); |
42f914d4 | 17895 | |
d62a17ae | 17896 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17897 | |
d62a17ae | 17898 | if (ret < 0) { |
17899 | community_list_perror(vty, ret); | |
17900 | return CMD_WARNING_CONFIG_FAILED; | |
17901 | } | |
42f914d4 | 17902 | |
d62a17ae | 17903 | return CMD_SUCCESS; |
718e3744 | 17904 | } |
17905 | ||
7336e101 SP |
17906 | DEFUN (extcommunity_list_name_expanded, |
17907 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17908 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17909 | BGP_STR |
17910 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17911 | "Extended Community list number (expanded)\n" |
718e3744 | 17912 | "Specify expanded extcommunity-list\n" |
17913 | "Extended Community list name\n" | |
2f8cc0e5 DA |
17914 | "Sequence number of an entry\n" |
17915 | "Sequence number\n" | |
718e3744 | 17916 | "Specify community to reject\n" |
17917 | "Specify community to accept\n" | |
17918 | "An ordered list as a regular-expression\n") | |
17919 | { | |
d62a17ae | 17920 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17921 | int direct = 0; | |
17922 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17923 | char *seq = NULL; |
d62a17ae | 17924 | int idx = 0; |
7336e101 | 17925 | |
d62a17ae | 17926 | argv_find(argv, argc, "(100-500)", &idx); |
17927 | argv_find(argv, argc, "WORD", &idx); | |
17928 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 17929 | |
409148f6 | 17930 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17931 | seq = argv[idx]->arg; |
17932 | ||
d62a17ae | 17933 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17934 | : COMMUNITY_DENY; | |
17935 | argv_find(argv, argc, "LINE", &idx); | |
17936 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17937 | |
2f8cc0e5 | 17938 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17939 | direct, style); |
42f914d4 | 17940 | |
d62a17ae | 17941 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17942 | |
d62a17ae | 17943 | if (ret < 0) { |
17944 | community_list_perror(vty, ret); | |
17945 | return CMD_WARNING_CONFIG_FAILED; | |
17946 | } | |
42f914d4 | 17947 | |
d62a17ae | 17948 | return CMD_SUCCESS; |
718e3744 | 17949 | } |
17950 | ||
7336e101 SP |
17951 | DEFUN (no_extcommunity_list_standard_all, |
17952 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 17953 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17954 | NO_STR |
17955 | BGP_STR | |
17956 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17957 | "Extended Community list number (standard)\n" |
718e3744 | 17958 | "Specify standard extcommunity-list\n" |
5bf15956 | 17959 | "Community list name\n" |
2f8cc0e5 DA |
17960 | "Sequence number of an entry\n" |
17961 | "Sequence number\n" | |
718e3744 | 17962 | "Specify community to reject\n" |
17963 | "Specify community to accept\n" | |
17964 | EXTCOMMUNITY_VAL_STR) | |
17965 | { | |
d62a17ae | 17966 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17967 | int direct = 0; | |
17968 | char *cl_number_or_name = NULL; | |
d4455c89 | 17969 | char *str = NULL; |
2f8cc0e5 | 17970 | char *seq = NULL; |
d62a17ae | 17971 | int idx = 0; |
d4455c89 | 17972 | |
409148f6 | 17973 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17974 | seq = argv[idx]->arg; |
17975 | ||
17976 | idx = 0; | |
d4455c89 DA |
17977 | argv_find(argv, argc, "permit", &idx); |
17978 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
17979 | if (idx) { |
17980 | direct = argv_find(argv, argc, "permit", &idx) | |
17981 | ? COMMUNITY_PERMIT | |
17982 | : COMMUNITY_DENY; | |
17983 | ||
17984 | idx = 0; | |
17985 | argv_find(argv, argc, "AA:NN", &idx); | |
17986 | str = argv_concat(argv, argc, idx); | |
17987 | } | |
17988 | ||
17989 | idx = 0; | |
d62a17ae | 17990 | argv_find(argv, argc, "(1-99)", &idx); |
17991 | argv_find(argv, argc, "WORD", &idx); | |
17992 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17993 | |
d62a17ae | 17994 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17995 | seq, direct, style); |
42f914d4 | 17996 | |
d62a17ae | 17997 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17998 | |
d62a17ae | 17999 | if (ret < 0) { |
18000 | community_list_perror(vty, ret); | |
18001 | return CMD_WARNING_CONFIG_FAILED; | |
18002 | } | |
42f914d4 | 18003 | |
d62a17ae | 18004 | return CMD_SUCCESS; |
718e3744 | 18005 | } |
18006 | ||
d4455c89 DA |
18007 | ALIAS(no_extcommunity_list_standard_all, |
18008 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
18009 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
18010 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
18011 | "Extended Community list number (standard)\n" | |
18012 | "Specify standard extcommunity-list\n" | |
18013 | "Community list name\n") | |
18014 | ||
7336e101 SP |
18015 | DEFUN (no_extcommunity_list_expanded_all, |
18016 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 18017 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18018 | NO_STR |
18019 | BGP_STR | |
18020 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 18021 | "Extended Community list number (expanded)\n" |
718e3744 | 18022 | "Specify expanded extcommunity-list\n" |
5bf15956 | 18023 | "Extended Community list name\n" |
2f8cc0e5 DA |
18024 | "Sequence number of an entry\n" |
18025 | "Sequence number\n" | |
718e3744 | 18026 | "Specify community to reject\n" |
18027 | "Specify community to accept\n" | |
18028 | "An ordered list as a regular-expression\n") | |
18029 | { | |
d62a17ae | 18030 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
18031 | int direct = 0; | |
18032 | char *cl_number_or_name = NULL; | |
d4455c89 | 18033 | char *str = NULL; |
2f8cc0e5 | 18034 | char *seq = NULL; |
d62a17ae | 18035 | int idx = 0; |
d4455c89 | 18036 | |
409148f6 | 18037 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
18038 | seq = argv[idx]->arg; |
18039 | ||
18040 | idx = 0; | |
d4455c89 DA |
18041 | argv_find(argv, argc, "permit", &idx); |
18042 | argv_find(argv, argc, "deny", &idx); | |
18043 | ||
18044 | if (idx) { | |
18045 | direct = argv_find(argv, argc, "permit", &idx) | |
18046 | ? COMMUNITY_PERMIT | |
18047 | : COMMUNITY_DENY; | |
18048 | ||
18049 | idx = 0; | |
18050 | argv_find(argv, argc, "LINE", &idx); | |
18051 | str = argv_concat(argv, argc, idx); | |
18052 | } | |
18053 | ||
18054 | idx = 0; | |
d62a17ae | 18055 | argv_find(argv, argc, "(100-500)", &idx); |
18056 | argv_find(argv, argc, "WORD", &idx); | |
18057 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 18058 | |
d62a17ae | 18059 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 18060 | seq, direct, style); |
42f914d4 | 18061 | |
d62a17ae | 18062 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18063 | |
d62a17ae | 18064 | if (ret < 0) { |
18065 | community_list_perror(vty, ret); | |
18066 | return CMD_WARNING_CONFIG_FAILED; | |
18067 | } | |
42f914d4 | 18068 | |
d62a17ae | 18069 | return CMD_SUCCESS; |
718e3744 | 18070 | } |
18071 | ||
d4455c89 DA |
18072 | ALIAS(no_extcommunity_list_expanded_all, |
18073 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
18074 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
18075 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
18076 | "Extended Community list number (expanded)\n" | |
18077 | "Specify expanded extcommunity-list\n" | |
18078 | "Extended Community list name\n") | |
18079 | ||
d62a17ae | 18080 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 18081 | { |
d62a17ae | 18082 | struct community_entry *entry; |
718e3744 | 18083 | |
d62a17ae | 18084 | for (entry = list->head; entry; entry = entry->next) { |
18085 | if (entry == list->head) { | |
18086 | if (all_digit(list->name)) | |
18087 | vty_out(vty, "Extended community %s list %s\n", | |
18088 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
18089 | ? "standard" | |
18090 | : "(expanded) access", | |
18091 | list->name); | |
18092 | else | |
18093 | vty_out(vty, | |
18094 | "Named extended community %s list %s\n", | |
18095 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
18096 | ? "standard" | |
18097 | : "expanded", | |
18098 | list->name); | |
18099 | } | |
18100 | if (entry->any) | |
18101 | vty_out(vty, " %s\n", | |
18102 | community_direct_str(entry->direct)); | |
18103 | else | |
18104 | vty_out(vty, " %s %s\n", | |
18105 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18106 | community_list_config_str(entry)); |
d62a17ae | 18107 | } |
718e3744 | 18108 | } |
18109 | ||
7336e101 SP |
18110 | DEFUN (show_extcommunity_list, |
18111 | show_bgp_extcommunity_list_cmd, | |
18112 | "show bgp extcommunity-list", | |
718e3744 | 18113 | SHOW_STR |
7336e101 | 18114 | BGP_STR |
718e3744 | 18115 | "List extended-community list\n") |
18116 | { | |
d62a17ae | 18117 | struct community_list *list; |
18118 | struct community_list_master *cm; | |
718e3744 | 18119 | |
d62a17ae | 18120 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
18121 | if (!cm) | |
18122 | return CMD_SUCCESS; | |
718e3744 | 18123 | |
d62a17ae | 18124 | for (list = cm->num.head; list; list = list->next) |
18125 | extcommunity_list_show(vty, list); | |
718e3744 | 18126 | |
d62a17ae | 18127 | for (list = cm->str.head; list; list = list->next) |
18128 | extcommunity_list_show(vty, list); | |
718e3744 | 18129 | |
d62a17ae | 18130 | return CMD_SUCCESS; |
718e3744 | 18131 | } |
18132 | ||
7336e101 SP |
18133 | DEFUN (show_extcommunity_list_arg, |
18134 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 18135 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
18136 | SHOW_STR |
18137 | BGP_STR | |
718e3744 | 18138 | "List extended-community list\n" |
18139 | "Extcommunity-list number\n" | |
960b69b9 | 18140 | "Extcommunity-list name\n" |
18141 | "Detailed information on extcommunity-list\n") | |
718e3744 | 18142 | { |
d62a17ae | 18143 | int idx_comm_list = 3; |
18144 | struct community_list *list; | |
718e3744 | 18145 | |
e237b0d2 | 18146 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 18147 | EXTCOMMUNITY_LIST_MASTER); |
18148 | if (!list) { | |
18149 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
18150 | return CMD_WARNING; | |
18151 | } | |
718e3744 | 18152 | |
d62a17ae | 18153 | extcommunity_list_show(vty, list); |
718e3744 | 18154 | |
d62a17ae | 18155 | return CMD_SUCCESS; |
718e3744 | 18156 | } |
6b0655a2 | 18157 | |
718e3744 | 18158 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 18159 | static int community_list_config_write(struct vty *vty) |
18160 | { | |
18161 | struct community_list *list; | |
18162 | struct community_entry *entry; | |
18163 | struct community_list_master *cm; | |
18164 | int write = 0; | |
18165 | ||
18166 | /* Community-list. */ | |
18167 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
18168 | ||
18169 | for (list = cm->num.head; list; list = list->next) | |
18170 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18171 | vty_out(vty, |
18172 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
18173 | list->name, entry->seq, | |
d62a17ae | 18174 | community_direct_str(entry->direct), |
18175 | community_list_config_str(entry)); | |
18176 | write++; | |
18177 | } | |
18178 | for (list = cm->str.head; list; list = list->next) | |
18179 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18180 | vty_out(vty, |
18181 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 18182 | entry->style == COMMUNITY_LIST_STANDARD |
18183 | ? "standard" | |
18184 | : "expanded", | |
2f8cc0e5 DA |
18185 | list->name, entry->seq, |
18186 | community_direct_str(entry->direct), | |
d62a17ae | 18187 | community_list_config_str(entry)); |
18188 | write++; | |
18189 | } | |
18190 | ||
18191 | /* Extcommunity-list. */ | |
18192 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
18193 | ||
18194 | for (list = cm->num.head; list; list = list->next) | |
18195 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18196 | vty_out(vty, |
18197 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
18198 | list->name, entry->seq, | |
18199 | community_direct_str(entry->direct), | |
d62a17ae | 18200 | community_list_config_str(entry)); |
18201 | write++; | |
18202 | } | |
18203 | for (list = cm->str.head; list; list = list->next) | |
18204 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18205 | vty_out(vty, |
6cde4b45 | 18206 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 18207 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
18208 | ? "standard" | |
18209 | : "expanded", | |
2f8cc0e5 DA |
18210 | list->name, entry->seq, |
18211 | community_direct_str(entry->direct), | |
d62a17ae | 18212 | community_list_config_str(entry)); |
18213 | write++; | |
18214 | } | |
18215 | ||
18216 | ||
18217 | /* lcommunity-list. */ | |
18218 | cm = community_list_master_lookup(bgp_clist, | |
18219 | LARGE_COMMUNITY_LIST_MASTER); | |
18220 | ||
18221 | for (list = cm->num.head; list; list = list->next) | |
18222 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18223 | vty_out(vty, |
6cde4b45 | 18224 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
18225 | list->name, entry->seq, |
18226 | community_direct_str(entry->direct), | |
d62a17ae | 18227 | community_list_config_str(entry)); |
18228 | write++; | |
18229 | } | |
18230 | for (list = cm->str.head; list; list = list->next) | |
18231 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18232 | vty_out(vty, |
6cde4b45 | 18233 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 18234 | |
d62a17ae | 18235 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
18236 | ? "standard" | |
18237 | : "expanded", | |
2f8cc0e5 | 18238 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 18239 | community_list_config_str(entry)); |
18240 | write++; | |
18241 | } | |
18242 | ||
18243 | return write; | |
18244 | } | |
18245 | ||
612c2c15 | 18246 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 18247 | static struct cmd_node community_list_node = { |
f4b8291f | 18248 | .name = "community list", |
62b346ee DL |
18249 | .node = COMMUNITY_LIST_NODE, |
18250 | .prompt = "", | |
612c2c15 | 18251 | .config_write = community_list_config_write, |
718e3744 | 18252 | }; |
18253 | ||
d62a17ae | 18254 | static void community_list_vty(void) |
18255 | { | |
612c2c15 | 18256 | install_node(&community_list_node); |
d62a17ae | 18257 | |
18258 | /* Community-list. */ | |
7336e101 SP |
18259 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
18260 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
18261 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 18262 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 18263 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 18264 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
18265 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
18266 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 18267 | |
18268 | /* Extcommunity-list. */ | |
7336e101 SP |
18269 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
18270 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
18271 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
18272 | install_element(CONFIG_NODE, |
18273 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 18274 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
18275 | install_element(CONFIG_NODE, |
18276 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
18277 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
18278 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 18279 | |
18280 | /* Large Community List */ | |
7336e101 | 18281 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
18282 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
18283 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 18284 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
18285 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
18286 | install_element(CONFIG_NODE, | |
18287 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
18288 | install_element(CONFIG_NODE, |
18289 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
18290 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
18291 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
18292 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
18293 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
18294 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
18295 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 18296 | } |