]>
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 | ||
718e3744 | 3603 | DEFUN (neighbor_remote_as, |
3604 | neighbor_remote_as_cmd, | |
3a2d747c | 3605 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3606 | NEIGHBOR_STR |
3607 | NEIGHBOR_ADDR_STR2 | |
3608 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 3609 | AS_STR |
3a2d747c QY |
3610 | "Internal BGP peer\n" |
3611 | "External BGP peer\n") | |
718e3744 | 3612 | { |
d62a17ae | 3613 | int idx_peer = 1; |
3614 | int idx_remote_as = 3; | |
3615 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
3616 | argv[idx_remote_as]->arg, AFI_IP, | |
3617 | SAFI_UNICAST); | |
3618 | } | |
3619 | ||
3620 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
3621 | afi_t afi, safi_t safi, int v6only, | |
3622 | const char *peer_group_name, | |
3623 | const char *as_str) | |
3624 | { | |
3625 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3626 | as_t as = 0; | |
3627 | int as_type = AS_UNSPECIFIED; | |
3628 | struct peer *peer; | |
3629 | struct peer_group *group; | |
3630 | int ret = 0; | |
3631 | union sockunion su; | |
3632 | ||
3633 | group = peer_group_lookup(bgp, conf_if); | |
3634 | ||
3635 | if (group) { | |
3636 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
3637 | return CMD_WARNING_CONFIG_FAILED; | |
3638 | } | |
3639 | ||
3640 | if (as_str) { | |
3641 | if (as_str[0] == 'i') { | |
3642 | as_type = AS_INTERNAL; | |
3643 | } else if (as_str[0] == 'e') { | |
3644 | as_type = AS_EXTERNAL; | |
3645 | } else { | |
3646 | /* Get AS number. */ | |
3647 | as = strtoul(as_str, NULL, 10); | |
3648 | as_type = AS_SPECIFIED; | |
3649 | } | |
3650 | } | |
3651 | ||
3652 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
3653 | if (peer) { | |
3654 | if (as_str) | |
cc4d4ce8 | 3655 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 3656 | afi, safi); |
3657 | } else { | |
892fedb6 | 3658 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4) |
d62a17ae | 3659 | && afi == AFI_IP && safi == SAFI_UNICAST) |
3660 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3661 | as_type, 0, 0, NULL); | |
3662 | else | |
3663 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3664 | as_type, afi, safi, NULL); | |
3665 | ||
3666 | if (!peer) { | |
3667 | vty_out(vty, "%% BGP failed to create peer\n"); | |
3668 | return CMD_WARNING_CONFIG_FAILED; | |
3669 | } | |
3670 | ||
3671 | if (v6only) | |
527de3dc | 3672 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3673 | |
3674 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
3675 | * this | |
3676 | * any unnumbered peer in order to not worry about run-time | |
3677 | * transitions | |
3678 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3679 | * address | |
3680 | * gets deleted later etc.) | |
3681 | */ | |
3682 | if (peer->ifp) | |
3683 | bgp_zebra_initiate_radv(bgp, peer); | |
3684 | } | |
3685 | ||
3686 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3687 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3688 | if (v6only) | |
527de3dc | 3689 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3690 | else |
527de3dc | 3691 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3692 | |
3693 | /* v6only flag changed. Reset bgp seesion */ | |
3694 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3695 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3696 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3697 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3698 | } else | |
3699 | bgp_session_reset(peer); | |
3700 | } | |
3701 | ||
9fb964de PM |
3702 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3703 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3704 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3705 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3706 | } |
d62a17ae | 3707 | |
3708 | if (peer_group_name) { | |
3709 | group = peer_group_lookup(bgp, peer_group_name); | |
3710 | if (!group) { | |
3711 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3712 | return CMD_WARNING_CONFIG_FAILED; | |
3713 | } | |
3714 | ||
3715 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3716 | } | |
3717 | ||
3718 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3719 | } |
3720 | ||
4c48cf63 DW |
3721 | DEFUN (neighbor_interface_config, |
3722 | neighbor_interface_config_cmd, | |
d7b9898c | 3723 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3724 | NEIGHBOR_STR |
3725 | "Interface name or neighbor tag\n" | |
31500417 DW |
3726 | "Enable BGP on interface\n" |
3727 | "Member of the peer-group\n" | |
16cedbb0 | 3728 | "Peer-group name\n") |
4c48cf63 | 3729 | { |
d62a17ae | 3730 | int idx_word = 1; |
3731 | int idx_peer_group_word = 4; | |
31500417 | 3732 | |
d62a17ae | 3733 | if (argc > idx_peer_group_word) |
3734 | return peer_conf_interface_get( | |
3735 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3736 | argv[idx_peer_group_word]->arg, NULL); | |
3737 | else | |
3738 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3739 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3740 | } |
3741 | ||
4c48cf63 DW |
3742 | DEFUN (neighbor_interface_config_v6only, |
3743 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3744 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3745 | NEIGHBOR_STR |
3746 | "Interface name or neighbor tag\n" | |
3747 | "Enable BGP on interface\n" | |
31500417 DW |
3748 | "Enable BGP with v6 link-local only\n" |
3749 | "Member of the peer-group\n" | |
16cedbb0 | 3750 | "Peer-group name\n") |
4c48cf63 | 3751 | { |
d62a17ae | 3752 | int idx_word = 1; |
3753 | int idx_peer_group_word = 5; | |
31500417 | 3754 | |
d62a17ae | 3755 | if (argc > idx_peer_group_word) |
3756 | return peer_conf_interface_get( | |
3757 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3758 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3759 | |
d62a17ae | 3760 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3761 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3762 | } |
3763 | ||
a80beece | 3764 | |
b3a39dc5 DD |
3765 | DEFUN (neighbor_interface_config_remote_as, |
3766 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3767 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3768 | NEIGHBOR_STR |
3769 | "Interface name or neighbor tag\n" | |
3770 | "Enable BGP on interface\n" | |
3a2d747c | 3771 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3772 | AS_STR |
3a2d747c QY |
3773 | "Internal BGP peer\n" |
3774 | "External BGP peer\n") | |
b3a39dc5 | 3775 | { |
d62a17ae | 3776 | int idx_word = 1; |
3777 | int idx_remote_as = 4; | |
3778 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3779 | SAFI_UNICAST, 0, NULL, | |
3780 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3781 | } |
3782 | ||
3783 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3784 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3785 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3786 | NEIGHBOR_STR |
3787 | "Interface name or neighbor tag\n" | |
3a2d747c | 3788 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3789 | "Enable BGP on interface\n" |
3a2d747c | 3790 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3791 | AS_STR |
3a2d747c QY |
3792 | "Internal BGP peer\n" |
3793 | "External BGP peer\n") | |
b3a39dc5 | 3794 | { |
d62a17ae | 3795 | int idx_word = 1; |
3796 | int idx_remote_as = 5; | |
3797 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3798 | SAFI_UNICAST, 1, NULL, | |
3799 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3800 | } |
3801 | ||
718e3744 | 3802 | DEFUN (neighbor_peer_group, |
3803 | neighbor_peer_group_cmd, | |
3804 | "neighbor WORD peer-group", | |
3805 | NEIGHBOR_STR | |
a80beece | 3806 | "Interface name or neighbor tag\n" |
718e3744 | 3807 | "Configure peer-group\n") |
3808 | { | |
d62a17ae | 3809 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3810 | int idx_word = 1; | |
3811 | struct peer *peer; | |
3812 | struct peer_group *group; | |
718e3744 | 3813 | |
d62a17ae | 3814 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3815 | if (peer) { | |
3816 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3817 | return CMD_WARNING_CONFIG_FAILED; | |
3818 | } | |
718e3744 | 3819 | |
d62a17ae | 3820 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3821 | if (!group) { | |
3822 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3823 | return CMD_WARNING_CONFIG_FAILED; | |
3824 | } | |
718e3744 | 3825 | |
d62a17ae | 3826 | return CMD_SUCCESS; |
718e3744 | 3827 | } |
3828 | ||
3829 | DEFUN (no_neighbor, | |
3830 | no_neighbor_cmd, | |
dab8cd00 | 3831 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3832 | NO_STR |
3833 | NEIGHBOR_STR | |
3a2d747c QY |
3834 | NEIGHBOR_ADDR_STR2 |
3835 | "Specify a BGP neighbor\n" | |
3836 | AS_STR | |
3837 | "Internal BGP peer\n" | |
3838 | "External BGP peer\n") | |
718e3744 | 3839 | { |
d62a17ae | 3840 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3841 | int idx_peer = 2; | |
3842 | int ret; | |
3843 | union sockunion su; | |
3844 | struct peer_group *group; | |
3845 | struct peer *peer; | |
3846 | struct peer *other; | |
3847 | ||
3848 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3849 | if (ret < 0) { | |
3850 | /* look up for neighbor by interface name config. */ | |
3851 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3852 | if (peer) { | |
3853 | /* Request zebra to terminate IPv6 RAs on this | |
3854 | * interface. */ | |
3855 | if (peer->ifp) | |
3856 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3857 | peer_notify_unconfig(peer); |
d62a17ae | 3858 | peer_delete(peer); |
3859 | return CMD_SUCCESS; | |
3860 | } | |
f14e6fdb | 3861 | |
d62a17ae | 3862 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
3863 | if (group) { |
3864 | peer_group_notify_unconfig(group); | |
d62a17ae | 3865 | peer_group_delete(group); |
4e2786df | 3866 | } else { |
d62a17ae | 3867 | vty_out(vty, "%% Create the peer-group first\n"); |
3868 | return CMD_WARNING_CONFIG_FAILED; | |
3869 | } | |
3870 | } else { | |
3871 | peer = peer_lookup(bgp, &su); | |
3872 | if (peer) { | |
3873 | if (peer_dynamic_neighbor(peer)) { | |
3874 | vty_out(vty, | |
3875 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3876 | return CMD_WARNING_CONFIG_FAILED; | |
3877 | } | |
3878 | ||
3879 | other = peer->doppelganger; | |
b3a3290e DS |
3880 | |
3881 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
3882 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3883 | ||
4e2786df | 3884 | peer_notify_unconfig(peer); |
d62a17ae | 3885 | peer_delete(peer); |
4e2786df DA |
3886 | if (other && other->status != Deleted) { |
3887 | peer_notify_unconfig(other); | |
d62a17ae | 3888 | peer_delete(other); |
4e2786df | 3889 | } |
d62a17ae | 3890 | } |
1ff9a340 | 3891 | } |
718e3744 | 3892 | |
d62a17ae | 3893 | return CMD_SUCCESS; |
718e3744 | 3894 | } |
3895 | ||
a80beece DS |
3896 | DEFUN (no_neighbor_interface_config, |
3897 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3898 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3899 | NO_STR |
3900 | NEIGHBOR_STR | |
3901 | "Interface name\n" | |
31500417 DW |
3902 | "Configure BGP on interface\n" |
3903 | "Enable BGP with v6 link-local only\n" | |
3904 | "Member of the peer-group\n" | |
16cedbb0 | 3905 | "Peer-group name\n" |
3a2d747c QY |
3906 | "Specify a BGP neighbor\n" |
3907 | AS_STR | |
3908 | "Internal BGP peer\n" | |
3909 | "External BGP peer\n") | |
a80beece | 3910 | { |
d62a17ae | 3911 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3912 | int idx_word = 2; | |
3913 | struct peer *peer; | |
3914 | ||
3915 | /* look up for neighbor by interface name config. */ | |
3916 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3917 | if (peer) { | |
3918 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3919 | if (peer->ifp) | |
3920 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3921 | peer_notify_unconfig(peer); |
d62a17ae | 3922 | peer_delete(peer); |
3923 | } else { | |
3924 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3925 | return CMD_WARNING_CONFIG_FAILED; | |
3926 | } | |
3927 | return CMD_SUCCESS; | |
a80beece DS |
3928 | } |
3929 | ||
718e3744 | 3930 | DEFUN (no_neighbor_peer_group, |
3931 | no_neighbor_peer_group_cmd, | |
3932 | "no neighbor WORD peer-group", | |
3933 | NO_STR | |
3934 | NEIGHBOR_STR | |
3935 | "Neighbor tag\n" | |
3936 | "Configure peer-group\n") | |
3937 | { | |
d62a17ae | 3938 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3939 | int idx_word = 2; | |
3940 | struct peer_group *group; | |
718e3744 | 3941 | |
d62a17ae | 3942 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
3943 | if (group) { |
3944 | peer_group_notify_unconfig(group); | |
d62a17ae | 3945 | peer_group_delete(group); |
4e2786df | 3946 | } else { |
d62a17ae | 3947 | vty_out(vty, "%% Create the peer-group first\n"); |
3948 | return CMD_WARNING_CONFIG_FAILED; | |
3949 | } | |
3950 | return CMD_SUCCESS; | |
718e3744 | 3951 | } |
3952 | ||
a80beece DS |
3953 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3954 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3955 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3956 | NO_STR |
3957 | NEIGHBOR_STR | |
a80beece | 3958 | "Interface name or neighbor tag\n" |
718e3744 | 3959 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3960 | AS_STR |
3961 | "Internal BGP peer\n" | |
3962 | "External BGP peer\n") | |
718e3744 | 3963 | { |
d62a17ae | 3964 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3965 | int idx_word = 2; | |
3966 | struct peer_group *group; | |
3967 | struct peer *peer; | |
3968 | ||
3969 | /* look up for neighbor by interface name config. */ | |
3970 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3971 | if (peer) { | |
390485fd | 3972 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3973 | return CMD_SUCCESS; |
3974 | } | |
3975 | ||
3976 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3977 | if (group) | |
3978 | peer_group_remote_as_delete(group); | |
3979 | else { | |
3980 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3981 | return CMD_WARNING_CONFIG_FAILED; | |
3982 | } | |
3983 | return CMD_SUCCESS; | |
718e3744 | 3984 | } |
6b0655a2 | 3985 | |
718e3744 | 3986 | DEFUN (neighbor_local_as, |
3987 | neighbor_local_as_cmd, | |
9ccf14f7 | 3988 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3989 | NEIGHBOR_STR |
3990 | NEIGHBOR_ADDR_STR2 | |
3991 | "Specify a local-as number\n" | |
3992 | "AS number used as local AS\n") | |
3993 | { | |
d62a17ae | 3994 | int idx_peer = 1; |
3995 | int idx_number = 3; | |
3996 | struct peer *peer; | |
3997 | int ret; | |
3998 | as_t as; | |
718e3744 | 3999 | |
d62a17ae | 4000 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4001 | if (!peer) | |
4002 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4003 | |
d62a17ae | 4004 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4005 | ret = peer_local_as_set(peer, as, 0, 0); | |
4006 | return bgp_vty_return(vty, ret); | |
718e3744 | 4007 | } |
4008 | ||
4009 | DEFUN (neighbor_local_as_no_prepend, | |
4010 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 4011 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 4012 | NEIGHBOR_STR |
4013 | NEIGHBOR_ADDR_STR2 | |
4014 | "Specify a local-as number\n" | |
4015 | "AS number used as local AS\n" | |
4016 | "Do not prepend local-as to updates from ebgp peers\n") | |
4017 | { | |
d62a17ae | 4018 | int idx_peer = 1; |
4019 | int idx_number = 3; | |
4020 | struct peer *peer; | |
4021 | int ret; | |
4022 | as_t as; | |
718e3744 | 4023 | |
d62a17ae | 4024 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4025 | if (!peer) | |
4026 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4027 | |
d62a17ae | 4028 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4029 | ret = peer_local_as_set(peer, as, 1, 0); | |
4030 | return bgp_vty_return(vty, ret); | |
718e3744 | 4031 | } |
4032 | ||
9d3f9705 AC |
4033 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4034 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 4035 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
4036 | NEIGHBOR_STR |
4037 | NEIGHBOR_ADDR_STR2 | |
4038 | "Specify a local-as number\n" | |
4039 | "AS number used as local AS\n" | |
4040 | "Do not prepend local-as to updates from ebgp peers\n" | |
4041 | "Do not prepend local-as to updates from ibgp peers\n") | |
4042 | { | |
d62a17ae | 4043 | int idx_peer = 1; |
4044 | int idx_number = 3; | |
4045 | struct peer *peer; | |
4046 | int ret; | |
4047 | as_t as; | |
9d3f9705 | 4048 | |
d62a17ae | 4049 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4050 | if (!peer) | |
4051 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 4052 | |
d62a17ae | 4053 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4054 | ret = peer_local_as_set(peer, as, 1, 1); | |
4055 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4056 | } |
4057 | ||
718e3744 | 4058 | DEFUN (no_neighbor_local_as, |
4059 | no_neighbor_local_as_cmd, | |
a636c635 | 4060 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 4061 | NO_STR |
4062 | NEIGHBOR_STR | |
4063 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4064 | "Specify a local-as number\n" |
4065 | "AS number used as local AS\n" | |
4066 | "Do not prepend local-as to updates from ebgp peers\n" | |
4067 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4068 | { |
d62a17ae | 4069 | int idx_peer = 2; |
4070 | struct peer *peer; | |
4071 | int ret; | |
718e3744 | 4072 | |
d62a17ae | 4073 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4074 | if (!peer) | |
4075 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4076 | |
d62a17ae | 4077 | ret = peer_local_as_unset(peer); |
4078 | return bgp_vty_return(vty, ret); | |
718e3744 | 4079 | } |
4080 | ||
718e3744 | 4081 | |
3f9c7369 DS |
4082 | DEFUN (neighbor_solo, |
4083 | neighbor_solo_cmd, | |
9ccf14f7 | 4084 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4085 | NEIGHBOR_STR |
4086 | NEIGHBOR_ADDR_STR2 | |
4087 | "Solo peer - part of its own update group\n") | |
4088 | { | |
d62a17ae | 4089 | int idx_peer = 1; |
4090 | struct peer *peer; | |
4091 | int ret; | |
3f9c7369 | 4092 | |
d62a17ae | 4093 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4094 | if (!peer) | |
4095 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4096 | |
d62a17ae | 4097 | ret = update_group_adjust_soloness(peer, 1); |
4098 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4099 | } |
4100 | ||
4101 | DEFUN (no_neighbor_solo, | |
4102 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4103 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4104 | NO_STR |
4105 | NEIGHBOR_STR | |
4106 | NEIGHBOR_ADDR_STR2 | |
4107 | "Solo peer - part of its own update group\n") | |
4108 | { | |
d62a17ae | 4109 | int idx_peer = 2; |
4110 | struct peer *peer; | |
4111 | int ret; | |
3f9c7369 | 4112 | |
d62a17ae | 4113 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4114 | if (!peer) | |
4115 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4116 | |
d62a17ae | 4117 | ret = update_group_adjust_soloness(peer, 0); |
4118 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4119 | } |
4120 | ||
0df7c91f PJ |
4121 | DEFUN (neighbor_password, |
4122 | neighbor_password_cmd, | |
9ccf14f7 | 4123 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
4124 | NEIGHBOR_STR |
4125 | NEIGHBOR_ADDR_STR2 | |
4126 | "Set a password\n" | |
4127 | "The password\n") | |
4128 | { | |
d62a17ae | 4129 | int idx_peer = 1; |
4130 | int idx_line = 3; | |
4131 | struct peer *peer; | |
4132 | int ret; | |
0df7c91f | 4133 | |
d62a17ae | 4134 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4135 | if (!peer) | |
4136 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4137 | |
d62a17ae | 4138 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4139 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4140 | } |
4141 | ||
4142 | DEFUN (no_neighbor_password, | |
4143 | no_neighbor_password_cmd, | |
a636c635 | 4144 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
4145 | NO_STR |
4146 | NEIGHBOR_STR | |
4147 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
4148 | "Set a password\n" |
4149 | "The password\n") | |
0df7c91f | 4150 | { |
d62a17ae | 4151 | int idx_peer = 2; |
4152 | struct peer *peer; | |
4153 | int ret; | |
0df7c91f | 4154 | |
d62a17ae | 4155 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4156 | if (!peer) | |
4157 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4158 | |
d62a17ae | 4159 | ret = peer_password_unset(peer); |
4160 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4161 | } |
6b0655a2 | 4162 | |
718e3744 | 4163 | DEFUN (neighbor_activate, |
4164 | neighbor_activate_cmd, | |
9ccf14f7 | 4165 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4166 | NEIGHBOR_STR |
4167 | NEIGHBOR_ADDR_STR2 | |
4168 | "Enable the Address Family for this Neighbor\n") | |
4169 | { | |
d62a17ae | 4170 | int idx_peer = 1; |
4171 | int ret; | |
4172 | struct peer *peer; | |
718e3744 | 4173 | |
d62a17ae | 4174 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4175 | if (!peer) | |
4176 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4177 | |
d62a17ae | 4178 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4179 | return bgp_vty_return(vty, ret); | |
718e3744 | 4180 | } |
4181 | ||
d62a17ae | 4182 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4183 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4184 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4185 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4186 | |
718e3744 | 4187 | DEFUN (no_neighbor_activate, |
4188 | no_neighbor_activate_cmd, | |
9ccf14f7 | 4189 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4190 | NO_STR |
4191 | NEIGHBOR_STR | |
4192 | NEIGHBOR_ADDR_STR2 | |
4193 | "Enable the Address Family for this Neighbor\n") | |
4194 | { | |
d62a17ae | 4195 | int idx_peer = 2; |
4196 | int ret; | |
4197 | struct peer *peer; | |
718e3744 | 4198 | |
d62a17ae | 4199 | /* Lookup peer. */ |
4200 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4201 | if (!peer) | |
4202 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4203 | |
d62a17ae | 4204 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4205 | return bgp_vty_return(vty, ret); | |
718e3744 | 4206 | } |
6b0655a2 | 4207 | |
d62a17ae | 4208 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4209 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4210 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4211 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4212 | |
718e3744 | 4213 | DEFUN (neighbor_set_peer_group, |
4214 | neighbor_set_peer_group_cmd, | |
d7b9898c | 4215 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4216 | NEIGHBOR_STR |
a80beece | 4217 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4218 | "Member of the peer-group\n" |
16cedbb0 | 4219 | "Peer-group name\n") |
718e3744 | 4220 | { |
d62a17ae | 4221 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4222 | int idx_peer = 1; | |
4223 | int idx_word = 3; | |
4224 | int ret; | |
4225 | as_t as; | |
4226 | union sockunion su; | |
4227 | struct peer *peer; | |
4228 | struct peer_group *group; | |
4229 | ||
d62a17ae | 4230 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4231 | if (ret < 0) { | |
4232 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4233 | if (!peer) { | |
4234 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4235 | argv[idx_peer]->arg); | |
4236 | return CMD_WARNING_CONFIG_FAILED; | |
4237 | } | |
4238 | } else { | |
4239 | if (peer_address_self_check(bgp, &su)) { | |
4240 | vty_out(vty, | |
4241 | "%% Can not configure the local system as neighbor\n"); | |
4242 | return CMD_WARNING_CONFIG_FAILED; | |
4243 | } | |
4244 | ||
4245 | /* Disallow for dynamic neighbor. */ | |
4246 | peer = peer_lookup(bgp, &su); | |
4247 | if (peer && peer_dynamic_neighbor(peer)) { | |
4248 | vty_out(vty, | |
4249 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4250 | return CMD_WARNING_CONFIG_FAILED; | |
4251 | } | |
4252 | } | |
4253 | ||
4254 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4255 | if (!group) { | |
4256 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4257 | return CMD_WARNING_CONFIG_FAILED; | |
4258 | } | |
4259 | ||
4260 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4261 | ||
4262 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4263 | vty_out(vty, | |
4264 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4265 | as); | |
4266 | return CMD_WARNING_CONFIG_FAILED; | |
4267 | } | |
4268 | ||
4269 | return bgp_vty_return(vty, ret); | |
4270 | } | |
4271 | ||
4272 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4273 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4274 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4275 | "Member of the peer-group\n" | |
4276 | "Peer-group name\n") | |
596c17ba | 4277 | |
718e3744 | 4278 | DEFUN (no_neighbor_set_peer_group, |
4279 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4280 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4281 | NO_STR |
4282 | NEIGHBOR_STR | |
a80beece | 4283 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4284 | "Member of the peer-group\n" |
16cedbb0 | 4285 | "Peer-group name\n") |
718e3744 | 4286 | { |
d62a17ae | 4287 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4288 | int idx_peer = 2; | |
4289 | int idx_word = 4; | |
4290 | int ret; | |
4291 | struct peer *peer; | |
4292 | struct peer_group *group; | |
4293 | ||
4294 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4295 | if (!peer) | |
4296 | return CMD_WARNING_CONFIG_FAILED; | |
4297 | ||
4298 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4299 | if (!group) { | |
4300 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4301 | return CMD_WARNING_CONFIG_FAILED; | |
4302 | } | |
718e3744 | 4303 | |
b3a3290e DS |
4304 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4305 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4306 | ||
4e2786df | 4307 | peer_notify_unconfig(peer); |
827ed707 | 4308 | ret = peer_delete(peer); |
718e3744 | 4309 | |
d62a17ae | 4310 | return bgp_vty_return(vty, ret); |
718e3744 | 4311 | } |
6b0655a2 | 4312 | |
d62a17ae | 4313 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4314 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4315 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4316 | "Member of the peer-group\n" | |
4317 | "Peer-group name\n") | |
596c17ba | 4318 | |
d62a17ae | 4319 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4320 | uint32_t flag, int set) |
718e3744 | 4321 | { |
d62a17ae | 4322 | int ret; |
4323 | struct peer *peer; | |
718e3744 | 4324 | |
d62a17ae | 4325 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4326 | if (!peer) | |
4327 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4328 | |
7ebe625c QY |
4329 | /* |
4330 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4331 | * we should not accept disable-connected-check. | |
4332 | */ | |
4333 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4334 | vty_out(vty, | |
3efd0893 | 4335 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
4336 | ip_str); |
4337 | return CMD_WARNING_CONFIG_FAILED; | |
4338 | } | |
4339 | ||
d62a17ae | 4340 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4341 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4342 | |
d62a17ae | 4343 | if (set) |
4344 | ret = peer_flag_set(peer, flag); | |
4345 | else | |
4346 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4347 | |
d62a17ae | 4348 | return bgp_vty_return(vty, ret); |
718e3744 | 4349 | } |
4350 | ||
47cbc09b | 4351 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4352 | { |
d62a17ae | 4353 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4354 | } |
4355 | ||
d62a17ae | 4356 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4357 | uint32_t flag) |
718e3744 | 4358 | { |
d62a17ae | 4359 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4360 | } |
4361 | ||
4362 | /* neighbor passive. */ | |
4363 | DEFUN (neighbor_passive, | |
4364 | neighbor_passive_cmd, | |
9ccf14f7 | 4365 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4366 | NEIGHBOR_STR |
4367 | NEIGHBOR_ADDR_STR2 | |
4368 | "Don't send open messages to this neighbor\n") | |
4369 | { | |
d62a17ae | 4370 | int idx_peer = 1; |
4371 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4372 | } |
4373 | ||
4374 | DEFUN (no_neighbor_passive, | |
4375 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4376 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4377 | NO_STR |
4378 | NEIGHBOR_STR | |
4379 | NEIGHBOR_ADDR_STR2 | |
4380 | "Don't send open messages to this neighbor\n") | |
4381 | { | |
d62a17ae | 4382 | int idx_peer = 2; |
4383 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4384 | } |
6b0655a2 | 4385 | |
718e3744 | 4386 | /* neighbor shutdown. */ |
73d70fa6 DL |
4387 | DEFUN (neighbor_shutdown_msg, |
4388 | neighbor_shutdown_msg_cmd, | |
4389 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4390 | NEIGHBOR_STR |
4391 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 | 4392 | "Administratively shut down this neighbor\n" |
70335e0a | 4393 | "Add a shutdown message (RFC 8203)\n" |
73d70fa6 | 4394 | "Shutdown message\n") |
718e3744 | 4395 | { |
d62a17ae | 4396 | int idx_peer = 1; |
73d70fa6 | 4397 | |
d62a17ae | 4398 | if (argc >= 5) { |
4399 | struct peer *peer = | |
4400 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4401 | char *message; | |
73d70fa6 | 4402 | |
d62a17ae | 4403 | if (!peer) |
4404 | return CMD_WARNING_CONFIG_FAILED; | |
4405 | message = argv_concat(argv, argc, 4); | |
4406 | peer_tx_shutdown_message_set(peer, message); | |
4407 | XFREE(MTYPE_TMP, message); | |
4408 | } | |
73d70fa6 | 4409 | |
d62a17ae | 4410 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4411 | } |
4412 | ||
d62a17ae | 4413 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4414 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4415 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4416 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4417 | |
4418 | DEFUN (no_neighbor_shutdown_msg, | |
4419 | no_neighbor_shutdown_msg_cmd, | |
4420 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4421 | NO_STR | |
4422 | NEIGHBOR_STR | |
4423 | NEIGHBOR_ADDR_STR2 | |
4424 | "Administratively shut down this neighbor\n" | |
70335e0a | 4425 | "Remove a shutdown message (RFC 8203)\n" |
73d70fa6 | 4426 | "Shutdown message\n") |
718e3744 | 4427 | { |
d62a17ae | 4428 | int idx_peer = 2; |
73d70fa6 | 4429 | |
d62a17ae | 4430 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4431 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4432 | } |
6b0655a2 | 4433 | |
d62a17ae | 4434 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4435 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4436 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4437 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4438 | |
718e3744 | 4439 | /* neighbor capability dynamic. */ |
4440 | DEFUN (neighbor_capability_dynamic, | |
4441 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4442 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4443 | NEIGHBOR_STR |
4444 | NEIGHBOR_ADDR_STR2 | |
4445 | "Advertise capability to the peer\n" | |
4446 | "Advertise dynamic capability to this neighbor\n") | |
4447 | { | |
d62a17ae | 4448 | int idx_peer = 1; |
4449 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4450 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4451 | } |
4452 | ||
4453 | DEFUN (no_neighbor_capability_dynamic, | |
4454 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4455 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4456 | NO_STR |
4457 | NEIGHBOR_STR | |
4458 | NEIGHBOR_ADDR_STR2 | |
4459 | "Advertise capability to the peer\n" | |
4460 | "Advertise dynamic capability to this neighbor\n") | |
4461 | { | |
d62a17ae | 4462 | int idx_peer = 2; |
4463 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4464 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4465 | } |
6b0655a2 | 4466 | |
718e3744 | 4467 | /* neighbor dont-capability-negotiate */ |
4468 | DEFUN (neighbor_dont_capability_negotiate, | |
4469 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4470 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4471 | NEIGHBOR_STR |
4472 | NEIGHBOR_ADDR_STR2 | |
4473 | "Do not perform capability negotiation\n") | |
4474 | { | |
d62a17ae | 4475 | int idx_peer = 1; |
4476 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4477 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4478 | } |
4479 | ||
4480 | DEFUN (no_neighbor_dont_capability_negotiate, | |
4481 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4482 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4483 | NO_STR |
4484 | NEIGHBOR_STR | |
4485 | NEIGHBOR_ADDR_STR2 | |
4486 | "Do not perform capability negotiation\n") | |
4487 | { | |
d62a17ae | 4488 | int idx_peer = 2; |
4489 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4490 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4491 | } |
6b0655a2 | 4492 | |
8a92a8a0 DS |
4493 | /* neighbor capability extended next hop encoding */ |
4494 | DEFUN (neighbor_capability_enhe, | |
4495 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4496 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4497 | NEIGHBOR_STR |
4498 | NEIGHBOR_ADDR_STR2 | |
4499 | "Advertise capability to the peer\n" | |
4500 | "Advertise extended next-hop capability to the peer\n") | |
4501 | { | |
d62a17ae | 4502 | int idx_peer = 1; |
4503 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4504 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4505 | } |
4506 | ||
4507 | DEFUN (no_neighbor_capability_enhe, | |
4508 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4509 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4510 | NO_STR |
4511 | NEIGHBOR_STR | |
4512 | NEIGHBOR_ADDR_STR2 | |
4513 | "Advertise capability to the peer\n" | |
4514 | "Advertise extended next-hop capability to the peer\n") | |
4515 | { | |
d62a17ae | 4516 | int idx_peer = 2; |
4517 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4518 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4519 | } |
4520 | ||
d62a17ae | 4521 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4522 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 4523 | int set) |
718e3744 | 4524 | { |
d62a17ae | 4525 | int ret; |
4526 | struct peer *peer; | |
718e3744 | 4527 | |
d62a17ae | 4528 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4529 | if (!peer) | |
4530 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4531 | |
d62a17ae | 4532 | if (set) |
4533 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
4534 | else | |
4535 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 4536 | |
d62a17ae | 4537 | return bgp_vty_return(vty, ret); |
718e3744 | 4538 | } |
4539 | ||
d62a17ae | 4540 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4541 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4542 | { |
d62a17ae | 4543 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 4544 | } |
4545 | ||
d62a17ae | 4546 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4547 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4548 | { |
d62a17ae | 4549 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 4550 | } |
6b0655a2 | 4551 | |
718e3744 | 4552 | /* neighbor capability orf prefix-list. */ |
4553 | DEFUN (neighbor_capability_orf_prefix, | |
4554 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4555 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4556 | NEIGHBOR_STR |
4557 | NEIGHBOR_ADDR_STR2 | |
4558 | "Advertise capability to the peer\n" | |
4559 | "Advertise ORF capability to the peer\n" | |
4560 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4561 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4562 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4563 | "Capability to SEND the ORF to this neighbor\n") | |
4564 | { | |
d62a17ae | 4565 | int idx_send_recv = 5; |
db45f64d DS |
4566 | char *peer_str = argv[1]->arg; |
4567 | struct peer *peer; | |
4568 | afi_t afi = bgp_node_afi(vty); | |
4569 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 4570 | |
db45f64d DS |
4571 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4572 | if (!peer) | |
d62a17ae | 4573 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 4574 | |
db45f64d DS |
4575 | if (strmatch(argv[idx_send_recv]->text, "send")) |
4576 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4577 | PEER_FLAG_ORF_PREFIX_SM); | |
4578 | ||
4579 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4580 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4581 | PEER_FLAG_ORF_PREFIX_RM); | |
4582 | ||
4583 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
4584 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4585 | PEER_FLAG_ORF_PREFIX_SM) | |
4586 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4587 | PEER_FLAG_ORF_PREFIX_RM); | |
4588 | ||
4589 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4590 | } |
4591 | ||
4592 | ALIAS_HIDDEN( | |
4593 | neighbor_capability_orf_prefix, | |
4594 | neighbor_capability_orf_prefix_hidden_cmd, | |
4595 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4596 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4597 | "Advertise capability to the peer\n" | |
4598 | "Advertise ORF capability to the peer\n" | |
4599 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4600 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4601 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4602 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4603 | |
718e3744 | 4604 | DEFUN (no_neighbor_capability_orf_prefix, |
4605 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4606 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4607 | NO_STR |
4608 | NEIGHBOR_STR | |
4609 | NEIGHBOR_ADDR_STR2 | |
4610 | "Advertise capability to the peer\n" | |
4611 | "Advertise ORF capability to the peer\n" | |
4612 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4613 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4614 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4615 | "Capability to SEND the ORF to this neighbor\n") | |
4616 | { | |
d62a17ae | 4617 | int idx_send_recv = 6; |
db45f64d DS |
4618 | char *peer_str = argv[2]->arg; |
4619 | struct peer *peer; | |
4620 | afi_t afi = bgp_node_afi(vty); | |
4621 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 4622 | |
db45f64d DS |
4623 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4624 | if (!peer) | |
d62a17ae | 4625 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 4626 | |
db45f64d DS |
4627 | if (strmatch(argv[idx_send_recv]->text, "send")) |
4628 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4629 | PEER_FLAG_ORF_PREFIX_SM); | |
4630 | ||
4631 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4632 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4633 | PEER_FLAG_ORF_PREFIX_RM); | |
4634 | ||
4635 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
4636 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4637 | PEER_FLAG_ORF_PREFIX_SM) | |
4638 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4639 | PEER_FLAG_ORF_PREFIX_RM); | |
4640 | ||
4641 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4642 | } |
4643 | ||
4644 | ALIAS_HIDDEN( | |
4645 | no_neighbor_capability_orf_prefix, | |
4646 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4647 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4648 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4649 | "Advertise capability to the peer\n" | |
4650 | "Advertise ORF capability to the peer\n" | |
4651 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4652 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4653 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4654 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4655 | |
718e3744 | 4656 | /* neighbor next-hop-self. */ |
4657 | DEFUN (neighbor_nexthop_self, | |
4658 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4659 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4660 | NEIGHBOR_STR |
4661 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4662 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4663 | { |
d62a17ae | 4664 | int idx_peer = 1; |
4665 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4666 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4667 | } |
9e7a53c1 | 4668 | |
d62a17ae | 4669 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4670 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4671 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4672 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4673 | |
a538debe DS |
4674 | /* neighbor next-hop-self. */ |
4675 | DEFUN (neighbor_nexthop_self_force, | |
4676 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4677 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4678 | NEIGHBOR_STR |
4679 | NEIGHBOR_ADDR_STR2 | |
4680 | "Disable the next hop calculation for this neighbor\n" | |
4681 | "Set the next hop to self for reflected routes\n") | |
4682 | { | |
d62a17ae | 4683 | int idx_peer = 1; |
4684 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4685 | bgp_node_safi(vty), | |
4686 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4687 | } |
4688 | ||
d62a17ae | 4689 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4690 | neighbor_nexthop_self_force_hidden_cmd, | |
4691 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4692 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4693 | "Disable the next hop calculation for this neighbor\n" | |
4694 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4695 | |
1bc4e531 DA |
4696 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4697 | neighbor_nexthop_self_all_hidden_cmd, | |
4698 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4699 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4700 | "Disable the next hop calculation for this neighbor\n" | |
4701 | "Set the next hop to self for reflected routes\n") | |
4702 | ||
718e3744 | 4703 | DEFUN (no_neighbor_nexthop_self, |
4704 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4705 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4706 | NO_STR |
4707 | NEIGHBOR_STR | |
4708 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4709 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4710 | { |
d62a17ae | 4711 | int idx_peer = 2; |
4712 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4713 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4714 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4715 | } |
6b0655a2 | 4716 | |
d62a17ae | 4717 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4718 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4719 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4720 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4721 | |
88b8ed8d | 4722 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4723 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4724 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4725 | NO_STR |
4726 | NEIGHBOR_STR | |
4727 | NEIGHBOR_ADDR_STR2 | |
4728 | "Disable the next hop calculation for this neighbor\n" | |
4729 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4730 | { |
d62a17ae | 4731 | int idx_peer = 2; |
4732 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4733 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4734 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4735 | } |
a538debe | 4736 | |
d62a17ae | 4737 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4738 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4739 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4740 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4741 | "Disable the next hop calculation for this neighbor\n" | |
4742 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4743 | |
1bc4e531 DA |
4744 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4745 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4746 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4747 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4748 | "Disable the next hop calculation for this neighbor\n" | |
4749 | "Set the next hop to self for reflected routes\n") | |
4750 | ||
c7122e14 DS |
4751 | /* neighbor as-override */ |
4752 | DEFUN (neighbor_as_override, | |
4753 | neighbor_as_override_cmd, | |
9ccf14f7 | 4754 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4755 | NEIGHBOR_STR |
4756 | NEIGHBOR_ADDR_STR2 | |
4757 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4758 | { | |
d62a17ae | 4759 | int idx_peer = 1; |
4760 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4761 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4762 | } |
4763 | ||
d62a17ae | 4764 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4765 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4766 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4767 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4768 | |
c7122e14 DS |
4769 | DEFUN (no_neighbor_as_override, |
4770 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4771 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4772 | NO_STR |
4773 | NEIGHBOR_STR | |
4774 | NEIGHBOR_ADDR_STR2 | |
4775 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4776 | { | |
d62a17ae | 4777 | int idx_peer = 2; |
4778 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4779 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4780 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4781 | } |
4782 | ||
d62a17ae | 4783 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4784 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4785 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4786 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4787 | |
718e3744 | 4788 | /* neighbor remove-private-AS. */ |
4789 | DEFUN (neighbor_remove_private_as, | |
4790 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4791 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4792 | NEIGHBOR_STR |
4793 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4794 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4795 | { |
d62a17ae | 4796 | int idx_peer = 1; |
4797 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4798 | bgp_node_safi(vty), | |
4799 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4800 | } |
4801 | ||
d62a17ae | 4802 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4803 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4804 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4805 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4806 | |
5000f21c DS |
4807 | DEFUN (neighbor_remove_private_as_all, |
4808 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4809 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4810 | NEIGHBOR_STR |
4811 | NEIGHBOR_ADDR_STR2 | |
4812 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4813 | "Apply to all AS numbers\n") |
5000f21c | 4814 | { |
d62a17ae | 4815 | int idx_peer = 1; |
4816 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4817 | bgp_node_safi(vty), | |
4818 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4819 | } |
4820 | ||
d62a17ae | 4821 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4822 | neighbor_remove_private_as_all_hidden_cmd, | |
4823 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4824 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4825 | "Remove private ASNs in outbound updates\n" | |
4826 | "Apply to all AS numbers") | |
596c17ba | 4827 | |
5000f21c DS |
4828 | DEFUN (neighbor_remove_private_as_replace_as, |
4829 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4830 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4831 | NEIGHBOR_STR |
4832 | NEIGHBOR_ADDR_STR2 | |
4833 | "Remove private ASNs in outbound updates\n" | |
4834 | "Replace private ASNs with our ASN in outbound updates\n") | |
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_REPLACE); | |
5000f21c DS |
4840 | } |
4841 | ||
d62a17ae | 4842 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4843 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4844 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4845 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4846 | "Remove private ASNs in outbound updates\n" | |
4847 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4848 | |
5000f21c DS |
4849 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4850 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4851 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4852 | NEIGHBOR_STR |
4853 | NEIGHBOR_ADDR_STR2 | |
4854 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4855 | "Apply to all AS numbers\n" |
5000f21c DS |
4856 | "Replace private ASNs with our ASN in outbound updates\n") |
4857 | { | |
d62a17ae | 4858 | int idx_peer = 1; |
4859 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4860 | bgp_node_safi(vty), | |
4861 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4862 | } |
4863 | ||
d62a17ae | 4864 | ALIAS_HIDDEN( |
4865 | neighbor_remove_private_as_all_replace_as, | |
4866 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4867 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4868 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4869 | "Remove private ASNs in outbound updates\n" | |
4870 | "Apply to all AS numbers\n" | |
4871 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4872 | |
718e3744 | 4873 | DEFUN (no_neighbor_remove_private_as, |
4874 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4875 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4876 | NO_STR |
4877 | NEIGHBOR_STR | |
4878 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4879 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4880 | { |
d62a17ae | 4881 | int idx_peer = 2; |
4882 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4883 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4884 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4885 | } |
6b0655a2 | 4886 | |
d62a17ae | 4887 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4888 | no_neighbor_remove_private_as_hidden_cmd, | |
4889 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4890 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4891 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4892 | |
88b8ed8d | 4893 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4894 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4895 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4896 | NO_STR |
4897 | NEIGHBOR_STR | |
4898 | NEIGHBOR_ADDR_STR2 | |
4899 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4900 | "Apply to all AS numbers\n") |
88b8ed8d | 4901 | { |
d62a17ae | 4902 | int idx_peer = 2; |
4903 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4904 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4905 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4906 | } |
5000f21c | 4907 | |
d62a17ae | 4908 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4909 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4910 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4911 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4912 | "Remove private ASNs in outbound updates\n" | |
4913 | "Apply to all AS numbers\n") | |
596c17ba | 4914 | |
88b8ed8d | 4915 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4916 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4917 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4918 | NO_STR |
4919 | NEIGHBOR_STR | |
4920 | NEIGHBOR_ADDR_STR2 | |
4921 | "Remove private ASNs in outbound updates\n" | |
4922 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4923 | { |
d62a17ae | 4924 | int idx_peer = 2; |
4925 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4926 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4927 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4928 | } |
5000f21c | 4929 | |
d62a17ae | 4930 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4931 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4932 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4933 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4934 | "Remove private ASNs in outbound updates\n" | |
4935 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4936 | |
88b8ed8d | 4937 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4938 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4939 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4940 | NO_STR |
4941 | NEIGHBOR_STR | |
4942 | NEIGHBOR_ADDR_STR2 | |
4943 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4944 | "Apply to all AS numbers\n" |
5000f21c | 4945 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4946 | { |
d62a17ae | 4947 | int idx_peer = 2; |
4948 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4949 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4950 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4951 | } |
5000f21c | 4952 | |
d62a17ae | 4953 | ALIAS_HIDDEN( |
4954 | no_neighbor_remove_private_as_all_replace_as, | |
4955 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4956 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4957 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4958 | "Remove private ASNs in outbound updates\n" | |
4959 | "Apply to all AS numbers\n" | |
4960 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4961 | |
5000f21c | 4962 | |
718e3744 | 4963 | /* neighbor send-community. */ |
4964 | DEFUN (neighbor_send_community, | |
4965 | neighbor_send_community_cmd, | |
9ccf14f7 | 4966 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4967 | NEIGHBOR_STR |
4968 | NEIGHBOR_ADDR_STR2 | |
4969 | "Send Community attribute to this neighbor\n") | |
4970 | { | |
d62a17ae | 4971 | int idx_peer = 1; |
27c05d4d | 4972 | |
d62a17ae | 4973 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4974 | bgp_node_safi(vty), | |
4975 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4976 | } |
4977 | ||
d62a17ae | 4978 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4979 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4980 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4981 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4982 | |
718e3744 | 4983 | DEFUN (no_neighbor_send_community, |
4984 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4985 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4986 | NO_STR |
4987 | NEIGHBOR_STR | |
4988 | NEIGHBOR_ADDR_STR2 | |
4989 | "Send Community attribute to this neighbor\n") | |
4990 | { | |
d62a17ae | 4991 | int idx_peer = 2; |
27c05d4d | 4992 | |
d62a17ae | 4993 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4994 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4995 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4996 | } |
6b0655a2 | 4997 | |
d62a17ae | 4998 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4999 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5000 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5001 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5002 | |
718e3744 | 5003 | /* neighbor send-community extended. */ |
5004 | DEFUN (neighbor_send_community_type, | |
5005 | neighbor_send_community_type_cmd, | |
57d187bc | 5006 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5007 | NEIGHBOR_STR |
5008 | NEIGHBOR_ADDR_STR2 | |
5009 | "Send Community attribute to this neighbor\n" | |
5010 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5011 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5012 | "Send Extended Community attributes\n" |
57d187bc JS |
5013 | "Send Standard Community attributes\n" |
5014 | "Send Large Community attributes\n") | |
718e3744 | 5015 | { |
27c05d4d | 5016 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
5017 | char *peer_str = argv[1]->arg; |
5018 | struct peer *peer; | |
5019 | afi_t afi = bgp_node_afi(vty); | |
5020 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5021 | |
db45f64d DS |
5022 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5023 | if (!peer) | |
5024 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5025 | |
db45f64d DS |
5026 | if (strmatch(type, "standard")) |
5027 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5028 | PEER_FLAG_SEND_COMMUNITY); | |
5029 | ||
5030 | if (strmatch(type, "extended")) | |
5031 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5032 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5033 | ||
5034 | if (strmatch(type, "large")) | |
5035 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5036 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5037 | ||
5038 | if (strmatch(type, "both")) { | |
5039 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5040 | PEER_FLAG_SEND_COMMUNITY) | |
5041 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5042 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5043 | } | |
5044 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5045 | PEER_FLAG_SEND_COMMUNITY) | |
5046 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5047 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5048 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5049 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5050 | } |
5051 | ||
5052 | ALIAS_HIDDEN( | |
5053 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5054 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5055 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5056 | "Send Community attribute to this neighbor\n" | |
5057 | "Send Standard and Extended Community attributes\n" | |
5058 | "Send Standard, Large and Extended Community attributes\n" | |
5059 | "Send Extended Community attributes\n" | |
5060 | "Send Standard Community attributes\n" | |
5061 | "Send Large Community attributes\n") | |
596c17ba | 5062 | |
718e3744 | 5063 | DEFUN (no_neighbor_send_community_type, |
5064 | no_neighbor_send_community_type_cmd, | |
57d187bc | 5065 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5066 | NO_STR |
5067 | NEIGHBOR_STR | |
5068 | NEIGHBOR_ADDR_STR2 | |
5069 | "Send Community attribute to this neighbor\n" | |
5070 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5071 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5072 | "Send Extended Community attributes\n" |
57d187bc JS |
5073 | "Send Standard Community attributes\n" |
5074 | "Send Large Community attributes\n") | |
718e3744 | 5075 | { |
d62a17ae | 5076 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
5077 | char *peer_str = argv[2]->arg; |
5078 | struct peer *peer; | |
5079 | afi_t afi = bgp_node_afi(vty); | |
5080 | safi_t safi = bgp_node_safi(vty); | |
5081 | ||
5082 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5083 | if (!peer) | |
5084 | return CMD_WARNING_CONFIG_FAILED; | |
5085 | ||
5086 | if (strmatch(type, "standard")) | |
5087 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5088 | PEER_FLAG_SEND_COMMUNITY); | |
5089 | ||
5090 | if (strmatch(type, "extended")) | |
5091 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5092 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5093 | ||
5094 | if (strmatch(type, "large")) | |
5095 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5096 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5097 | ||
5098 | if (strmatch(type, "both")) { | |
d62a17ae | 5099 | |
db45f64d DS |
5100 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5101 | PEER_FLAG_SEND_COMMUNITY) | |
5102 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5103 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5104 | } |
5105 | ||
db45f64d DS |
5106 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5107 | PEER_FLAG_SEND_COMMUNITY) | |
5108 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5109 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5110 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5111 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5112 | } |
5113 | ||
5114 | ALIAS_HIDDEN( | |
5115 | no_neighbor_send_community_type, | |
5116 | no_neighbor_send_community_type_hidden_cmd, | |
5117 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5118 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5119 | "Send Community attribute to this neighbor\n" | |
5120 | "Send Standard and Extended Community attributes\n" | |
5121 | "Send Standard, Large and Extended Community attributes\n" | |
5122 | "Send Extended Community attributes\n" | |
5123 | "Send Standard Community attributes\n" | |
5124 | "Send Large Community attributes\n") | |
596c17ba | 5125 | |
718e3744 | 5126 | /* neighbor soft-reconfig. */ |
5127 | DEFUN (neighbor_soft_reconfiguration, | |
5128 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5129 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5130 | NEIGHBOR_STR |
5131 | NEIGHBOR_ADDR_STR2 | |
5132 | "Per neighbor soft reconfiguration\n" | |
5133 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5134 | { | |
d62a17ae | 5135 | int idx_peer = 1; |
5136 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5137 | bgp_node_safi(vty), | |
5138 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5139 | } |
5140 | ||
d62a17ae | 5141 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5142 | neighbor_soft_reconfiguration_hidden_cmd, | |
5143 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5144 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5145 | "Per neighbor soft reconfiguration\n" | |
5146 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5147 | |
718e3744 | 5148 | DEFUN (no_neighbor_soft_reconfiguration, |
5149 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5150 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5151 | NO_STR |
5152 | NEIGHBOR_STR | |
5153 | NEIGHBOR_ADDR_STR2 | |
5154 | "Per neighbor soft reconfiguration\n" | |
5155 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5156 | { | |
d62a17ae | 5157 | int idx_peer = 2; |
5158 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5159 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5160 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5161 | } |
6b0655a2 | 5162 | |
d62a17ae | 5163 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5164 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5165 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5166 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5167 | "Per neighbor soft reconfiguration\n" | |
5168 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5169 | |
718e3744 | 5170 | DEFUN (neighbor_route_reflector_client, |
5171 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5172 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5173 | NEIGHBOR_STR |
5174 | NEIGHBOR_ADDR_STR2 | |
5175 | "Configure a neighbor as Route Reflector client\n") | |
5176 | { | |
d62a17ae | 5177 | int idx_peer = 1; |
5178 | struct peer *peer; | |
718e3744 | 5179 | |
5180 | ||
d62a17ae | 5181 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5182 | if (!peer) | |
5183 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5184 | |
d62a17ae | 5185 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5186 | bgp_node_safi(vty), | |
5187 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5188 | } |
5189 | ||
d62a17ae | 5190 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5191 | neighbor_route_reflector_client_hidden_cmd, | |
5192 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5193 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5194 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5195 | |
718e3744 | 5196 | DEFUN (no_neighbor_route_reflector_client, |
5197 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5198 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5199 | NO_STR |
5200 | NEIGHBOR_STR | |
5201 | NEIGHBOR_ADDR_STR2 | |
5202 | "Configure a neighbor as Route Reflector client\n") | |
5203 | { | |
d62a17ae | 5204 | int idx_peer = 2; |
5205 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5206 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5207 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5208 | } |
6b0655a2 | 5209 | |
d62a17ae | 5210 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5211 | no_neighbor_route_reflector_client_hidden_cmd, | |
5212 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5213 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5214 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5215 | |
718e3744 | 5216 | /* neighbor route-server-client. */ |
5217 | DEFUN (neighbor_route_server_client, | |
5218 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5219 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5220 | NEIGHBOR_STR |
5221 | NEIGHBOR_ADDR_STR2 | |
5222 | "Configure a neighbor as Route Server client\n") | |
5223 | { | |
d62a17ae | 5224 | int idx_peer = 1; |
5225 | struct peer *peer; | |
2a3d5731 | 5226 | |
d62a17ae | 5227 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5228 | if (!peer) | |
5229 | return CMD_WARNING_CONFIG_FAILED; | |
5230 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5231 | bgp_node_safi(vty), | |
5232 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5233 | } |
5234 | ||
d62a17ae | 5235 | ALIAS_HIDDEN(neighbor_route_server_client, |
5236 | neighbor_route_server_client_hidden_cmd, | |
5237 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5238 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5239 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5240 | |
718e3744 | 5241 | DEFUN (no_neighbor_route_server_client, |
5242 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5243 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5244 | NO_STR |
5245 | NEIGHBOR_STR | |
5246 | NEIGHBOR_ADDR_STR2 | |
5247 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5248 | { |
d62a17ae | 5249 | int idx_peer = 2; |
5250 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5251 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5252 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5253 | } |
6b0655a2 | 5254 | |
d62a17ae | 5255 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5256 | no_neighbor_route_server_client_hidden_cmd, | |
5257 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5258 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5259 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5260 | |
fee0f4c6 | 5261 | DEFUN (neighbor_nexthop_local_unchanged, |
5262 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5263 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5264 | NEIGHBOR_STR |
5265 | NEIGHBOR_ADDR_STR2 | |
5266 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5267 | "Leave link-local nexthop unchanged for this peer\n") | |
5268 | { | |
d62a17ae | 5269 | int idx_peer = 1; |
5270 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5271 | bgp_node_safi(vty), | |
5272 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5273 | } |
6b0655a2 | 5274 | |
fee0f4c6 | 5275 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5276 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5277 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5278 | NO_STR |
5279 | NEIGHBOR_STR | |
5280 | NEIGHBOR_ADDR_STR2 | |
5281 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5282 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5283 | { |
d62a17ae | 5284 | int idx_peer = 2; |
5285 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5286 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5287 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5288 | } |
6b0655a2 | 5289 | |
718e3744 | 5290 | DEFUN (neighbor_attr_unchanged, |
5291 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5292 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5293 | NEIGHBOR_STR |
5294 | NEIGHBOR_ADDR_STR2 | |
5295 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5296 | "As-path attribute\n" | |
5297 | "Nexthop attribute\n" | |
a8206004 | 5298 | "Med attribute\n") |
718e3744 | 5299 | { |
d62a17ae | 5300 | int idx = 0; |
8eeb0335 DW |
5301 | char *peer_str = argv[1]->arg; |
5302 | struct peer *peer; | |
db45f64d DS |
5303 | bool aspath = false; |
5304 | bool nexthop = false; | |
5305 | bool med = false; | |
8eeb0335 DW |
5306 | afi_t afi = bgp_node_afi(vty); |
5307 | safi_t safi = bgp_node_safi(vty); | |
db45f64d | 5308 | int ret = 0; |
8eeb0335 DW |
5309 | |
5310 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5311 | if (!peer) | |
5312 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5313 | |
5314 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5315 | aspath = true; |
5316 | ||
d62a17ae | 5317 | idx = 0; |
5318 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5319 | nexthop = true; |
5320 | ||
d62a17ae | 5321 | idx = 0; |
5322 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5323 | med = true; |
d62a17ae | 5324 | |
8eeb0335 | 5325 | /* no flags means all of them! */ |
db45f64d DS |
5326 | if (!aspath && !nexthop && !med) { |
5327 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5328 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5329 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5330 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5331 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5332 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5333 | } else { |
db45f64d DS |
5334 | if (!aspath) { |
5335 | if (peer_af_flag_check(peer, afi, safi, | |
5336 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
5337 | ret |= peer_af_flag_unset_vty( | |
5338 | vty, peer_str, afi, safi, | |
5339 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5340 | } | |
5341 | } else | |
5342 | ret |= peer_af_flag_set_vty( | |
5343 | vty, peer_str, afi, safi, | |
5344 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5345 | ||
5346 | if (!nexthop) { | |
5347 | if (peer_af_flag_check(peer, afi, safi, | |
5348 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
5349 | ret |= peer_af_flag_unset_vty( | |
5350 | vty, peer_str, afi, safi, | |
5351 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5352 | } | |
5353 | } else | |
5354 | ret |= peer_af_flag_set_vty( | |
5355 | vty, peer_str, afi, safi, | |
5356 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5357 | ||
5358 | if (!med) { | |
5359 | if (peer_af_flag_check(peer, afi, safi, | |
5360 | PEER_FLAG_MED_UNCHANGED)) { | |
5361 | ret |= peer_af_flag_unset_vty( | |
5362 | vty, peer_str, afi, safi, | |
5363 | PEER_FLAG_MED_UNCHANGED); | |
5364 | } | |
5365 | } else | |
5366 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5367 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 5368 | } |
5369 | ||
db45f64d | 5370 | return ret; |
d62a17ae | 5371 | } |
5372 | ||
5373 | ALIAS_HIDDEN( | |
5374 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5375 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5376 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5377 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5378 | "As-path attribute\n" | |
5379 | "Nexthop attribute\n" | |
5380 | "Med attribute\n") | |
596c17ba | 5381 | |
718e3744 | 5382 | DEFUN (no_neighbor_attr_unchanged, |
5383 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5384 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5385 | NO_STR |
718e3744 | 5386 | NEIGHBOR_STR |
5387 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5388 | "BGP attribute is propagated unchanged to this neighbor\n" |
5389 | "As-path attribute\n" | |
40e718b5 | 5390 | "Nexthop attribute\n" |
a8206004 | 5391 | "Med attribute\n") |
718e3744 | 5392 | { |
d62a17ae | 5393 | int idx = 0; |
db45f64d DS |
5394 | char *peer_str = argv[2]->arg; |
5395 | struct peer *peer; | |
5396 | bool aspath = false; | |
5397 | bool nexthop = false; | |
5398 | bool med = false; | |
5399 | afi_t afi = bgp_node_afi(vty); | |
5400 | safi_t safi = bgp_node_safi(vty); | |
5401 | int ret = 0; | |
5402 | ||
5403 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5404 | if (!peer) | |
5405 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5406 | |
5407 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5408 | aspath = true; |
5409 | ||
d62a17ae | 5410 | idx = 0; |
5411 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5412 | nexthop = true; |
5413 | ||
d62a17ae | 5414 | idx = 0; |
5415 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5416 | med = true; |
d62a17ae | 5417 | |
db45f64d DS |
5418 | if (!aspath && !nexthop && !med) // no flags means all of them! |
5419 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5420 | PEER_FLAG_AS_PATH_UNCHANGED) | |
5421 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5422 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
5423 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5424 | PEER_FLAG_MED_UNCHANGED); | |
5425 | ||
5426 | if (aspath) | |
5427 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5428 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5429 | ||
5430 | if (nexthop) | |
5431 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5432 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 5433 | |
db45f64d DS |
5434 | if (med) |
5435 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5436 | PEER_FLAG_MED_UNCHANGED); | |
5437 | ||
5438 | return ret; | |
d62a17ae | 5439 | } |
5440 | ||
5441 | ALIAS_HIDDEN( | |
5442 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5443 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5444 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5445 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5446 | "As-path attribute\n" | |
5447 | "Nexthop attribute\n" | |
5448 | "Med attribute\n") | |
718e3744 | 5449 | |
718e3744 | 5450 | /* EBGP multihop configuration. */ |
d62a17ae | 5451 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5452 | const char *ttl_str) | |
718e3744 | 5453 | { |
d62a17ae | 5454 | struct peer *peer; |
5455 | unsigned int ttl; | |
718e3744 | 5456 | |
d62a17ae | 5457 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5458 | if (!peer) | |
5459 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5460 | |
d62a17ae | 5461 | if (peer->conf_if) |
5462 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5463 | |
d62a17ae | 5464 | if (!ttl_str) |
5465 | ttl = MAXTTL; | |
5466 | else | |
5467 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5468 | |
d62a17ae | 5469 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5470 | } |
5471 | ||
d62a17ae | 5472 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5473 | { |
d62a17ae | 5474 | struct peer *peer; |
718e3744 | 5475 | |
d62a17ae | 5476 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5477 | if (!peer) | |
5478 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5479 | |
d62a17ae | 5480 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 5481 | } |
5482 | ||
5483 | /* neighbor ebgp-multihop. */ | |
5484 | DEFUN (neighbor_ebgp_multihop, | |
5485 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 5486 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 5487 | NEIGHBOR_STR |
5488 | NEIGHBOR_ADDR_STR2 | |
5489 | "Allow EBGP neighbors not on directly connected networks\n") | |
5490 | { | |
d62a17ae | 5491 | int idx_peer = 1; |
5492 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5493 | } |
5494 | ||
5495 | DEFUN (neighbor_ebgp_multihop_ttl, | |
5496 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 5497 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 5498 | NEIGHBOR_STR |
5499 | NEIGHBOR_ADDR_STR2 | |
5500 | "Allow EBGP neighbors not on directly connected networks\n" | |
5501 | "maximum hop count\n") | |
5502 | { | |
d62a17ae | 5503 | int idx_peer = 1; |
5504 | int idx_number = 3; | |
5505 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
5506 | argv[idx_number]->arg); | |
718e3744 | 5507 | } |
5508 | ||
5509 | DEFUN (no_neighbor_ebgp_multihop, | |
5510 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 5511 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 5512 | NO_STR |
5513 | NEIGHBOR_STR | |
5514 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5515 | "Allow EBGP neighbors not on directly connected networks\n" |
5516 | "maximum hop count\n") | |
718e3744 | 5517 | { |
d62a17ae | 5518 | int idx_peer = 2; |
5519 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5520 | } |
5521 | ||
6b0655a2 | 5522 | |
6ffd2079 | 5523 | /* disable-connected-check */ |
5524 | DEFUN (neighbor_disable_connected_check, | |
5525 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 5526 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5527 | NEIGHBOR_STR |
7ebe625c | 5528 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5529 | "one-hop away EBGP peer using loopback address\n" |
5530 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5531 | { |
d62a17ae | 5532 | int idx_peer = 1; |
5533 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5534 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5535 | } |
5536 | ||
5537 | DEFUN (no_neighbor_disable_connected_check, | |
5538 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 5539 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5540 | NO_STR |
5541 | NEIGHBOR_STR | |
7ebe625c | 5542 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5543 | "one-hop away EBGP peer using loopback address\n" |
5544 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5545 | { |
d62a17ae | 5546 | int idx_peer = 2; |
5547 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5548 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5549 | } |
5550 | ||
47cbc09b PM |
5551 | |
5552 | /* enforce-first-as */ | |
5553 | DEFUN (neighbor_enforce_first_as, | |
5554 | neighbor_enforce_first_as_cmd, | |
5555 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5556 | NEIGHBOR_STR | |
5557 | NEIGHBOR_ADDR_STR2 | |
5558 | "Enforce the first AS for EBGP routes\n") | |
5559 | { | |
5560 | int idx_peer = 1; | |
5561 | ||
5562 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5563 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5564 | } | |
5565 | ||
5566 | DEFUN (no_neighbor_enforce_first_as, | |
5567 | no_neighbor_enforce_first_as_cmd, | |
5568 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5569 | NO_STR | |
5570 | NEIGHBOR_STR | |
5571 | NEIGHBOR_ADDR_STR2 | |
5572 | "Enforce the first AS for EBGP routes\n") | |
5573 | { | |
5574 | int idx_peer = 2; | |
5575 | ||
5576 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5577 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5578 | } | |
5579 | ||
5580 | ||
718e3744 | 5581 | DEFUN (neighbor_description, |
5582 | neighbor_description_cmd, | |
e961923c | 5583 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 5584 | NEIGHBOR_STR |
5585 | NEIGHBOR_ADDR_STR2 | |
5586 | "Neighbor specific description\n" | |
5587 | "Up to 80 characters describing this neighbor\n") | |
5588 | { | |
d62a17ae | 5589 | int idx_peer = 1; |
5590 | int idx_line = 3; | |
5591 | struct peer *peer; | |
5592 | char *str; | |
718e3744 | 5593 | |
d62a17ae | 5594 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5595 | if (!peer) | |
5596 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5597 | |
d62a17ae | 5598 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 5599 | |
d62a17ae | 5600 | peer_description_set(peer, str); |
718e3744 | 5601 | |
d62a17ae | 5602 | XFREE(MTYPE_TMP, str); |
718e3744 | 5603 | |
d62a17ae | 5604 | return CMD_SUCCESS; |
718e3744 | 5605 | } |
5606 | ||
5607 | DEFUN (no_neighbor_description, | |
5608 | no_neighbor_description_cmd, | |
a14810f4 | 5609 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 5610 | NO_STR |
5611 | NEIGHBOR_STR | |
5612 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 5613 | "Neighbor specific description\n") |
718e3744 | 5614 | { |
d62a17ae | 5615 | int idx_peer = 2; |
5616 | struct peer *peer; | |
718e3744 | 5617 | |
d62a17ae | 5618 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5619 | if (!peer) | |
5620 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5621 | |
d62a17ae | 5622 | peer_description_unset(peer); |
718e3744 | 5623 | |
d62a17ae | 5624 | return CMD_SUCCESS; |
718e3744 | 5625 | } |
5626 | ||
a14810f4 PM |
5627 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
5628 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
5629 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5630 | "Neighbor specific description\n" | |
5631 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 5632 | |
718e3744 | 5633 | /* Neighbor update-source. */ |
d62a17ae | 5634 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
5635 | const char *source_str) | |
5636 | { | |
5637 | struct peer *peer; | |
5638 | struct prefix p; | |
a14810f4 | 5639 | union sockunion su; |
d62a17ae | 5640 | |
5641 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5642 | if (!peer) | |
5643 | return CMD_WARNING_CONFIG_FAILED; | |
5644 | ||
5645 | if (peer->conf_if) | |
5646 | return CMD_WARNING; | |
5647 | ||
5648 | if (source_str) { | |
a14810f4 | 5649 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 5650 | peer_update_source_addr_set(peer, &su); |
5651 | else { | |
5652 | if (str2prefix(source_str, &p)) { | |
5653 | vty_out(vty, | |
5654 | "%% Invalid update-source, remove prefix length \n"); | |
5655 | return CMD_WARNING_CONFIG_FAILED; | |
5656 | } else | |
5657 | peer_update_source_if_set(peer, source_str); | |
5658 | } | |
5659 | } else | |
5660 | peer_update_source_unset(peer); | |
5661 | ||
5662 | return CMD_SUCCESS; | |
5663 | } | |
5664 | ||
5665 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
5666 | "IPv4 address\n" \ | |
5667 | "IPv6 address\n" \ | |
5668 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 5669 | |
718e3744 | 5670 | DEFUN (neighbor_update_source, |
5671 | neighbor_update_source_cmd, | |
9ccf14f7 | 5672 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 5673 | NEIGHBOR_STR |
5674 | NEIGHBOR_ADDR_STR2 | |
5675 | "Source of routing updates\n" | |
369688c0 | 5676 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 5677 | { |
d62a17ae | 5678 | int idx_peer = 1; |
5679 | int idx_peer_2 = 3; | |
5680 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
5681 | argv[idx_peer_2]->arg); | |
718e3744 | 5682 | } |
5683 | ||
5684 | DEFUN (no_neighbor_update_source, | |
5685 | no_neighbor_update_source_cmd, | |
c7178fe7 | 5686 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 5687 | NO_STR |
5688 | NEIGHBOR_STR | |
5689 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5690 | "Source of routing updates\n" |
5691 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5692 | { |
d62a17ae | 5693 | int idx_peer = 2; |
5694 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5695 | } |
6b0655a2 | 5696 | |
d62a17ae | 5697 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5698 | afi_t afi, safi_t safi, | |
5699 | const char *rmap, int set) | |
718e3744 | 5700 | { |
d62a17ae | 5701 | int ret; |
5702 | struct peer *peer; | |
80912664 | 5703 | struct route_map *route_map = NULL; |
718e3744 | 5704 | |
d62a17ae | 5705 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5706 | if (!peer) | |
5707 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5708 | |
1de27621 | 5709 | if (set) { |
80912664 DS |
5710 | if (rmap) |
5711 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5712 | ret = peer_default_originate_set(peer, afi, safi, |
5713 | rmap, route_map); | |
5714 | } else | |
d62a17ae | 5715 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5716 | |
d62a17ae | 5717 | return bgp_vty_return(vty, ret); |
718e3744 | 5718 | } |
5719 | ||
5720 | /* neighbor default-originate. */ | |
5721 | DEFUN (neighbor_default_originate, | |
5722 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5723 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5724 | NEIGHBOR_STR |
5725 | NEIGHBOR_ADDR_STR2 | |
5726 | "Originate default route to this neighbor\n") | |
5727 | { | |
d62a17ae | 5728 | int idx_peer = 1; |
5729 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5730 | bgp_node_afi(vty), | |
5731 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5732 | } |
5733 | ||
d62a17ae | 5734 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5735 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5736 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5737 | "Originate default route to this neighbor\n") | |
596c17ba | 5738 | |
718e3744 | 5739 | DEFUN (neighbor_default_originate_rmap, |
5740 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5741 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5742 | NEIGHBOR_STR |
5743 | NEIGHBOR_ADDR_STR2 | |
5744 | "Originate default route to this neighbor\n" | |
5745 | "Route-map to specify criteria to originate default\n" | |
5746 | "route-map name\n") | |
5747 | { | |
d62a17ae | 5748 | int idx_peer = 1; |
5749 | int idx_word = 4; | |
5750 | return peer_default_originate_set_vty( | |
5751 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5752 | argv[idx_word]->arg, 1); | |
718e3744 | 5753 | } |
5754 | ||
d62a17ae | 5755 | ALIAS_HIDDEN( |
5756 | neighbor_default_originate_rmap, | |
5757 | neighbor_default_originate_rmap_hidden_cmd, | |
5758 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5759 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5760 | "Originate default route to this neighbor\n" | |
5761 | "Route-map to specify criteria to originate default\n" | |
5762 | "route-map name\n") | |
596c17ba | 5763 | |
718e3744 | 5764 | DEFUN (no_neighbor_default_originate, |
5765 | no_neighbor_default_originate_cmd, | |
a636c635 | 5766 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5767 | NO_STR |
5768 | NEIGHBOR_STR | |
5769 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5770 | "Originate default route to this neighbor\n" |
5771 | "Route-map to specify criteria to originate default\n" | |
5772 | "route-map name\n") | |
718e3744 | 5773 | { |
d62a17ae | 5774 | int idx_peer = 2; |
5775 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5776 | bgp_node_afi(vty), | |
5777 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5778 | } |
5779 | ||
d62a17ae | 5780 | ALIAS_HIDDEN( |
5781 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5782 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5783 | NO_STR NEIGHBOR_STR 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") | |
596c17ba | 5787 | |
6b0655a2 | 5788 | |
718e3744 | 5789 | /* Set neighbor's BGP port. */ |
d62a17ae | 5790 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5791 | const char *port_str) | |
5792 | { | |
5793 | struct peer *peer; | |
d7c0a89a | 5794 | uint16_t port; |
d62a17ae | 5795 | struct servent *sp; |
5796 | ||
5797 | peer = peer_lookup_vty(vty, ip_str); | |
5798 | if (!peer) | |
5799 | return CMD_WARNING_CONFIG_FAILED; | |
5800 | ||
5801 | if (!port_str) { | |
5802 | sp = getservbyname("bgp", "tcp"); | |
5803 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5804 | } else { | |
5805 | port = strtoul(port_str, NULL, 10); | |
5806 | } | |
718e3744 | 5807 | |
d62a17ae | 5808 | peer_port_set(peer, port); |
718e3744 | 5809 | |
d62a17ae | 5810 | return CMD_SUCCESS; |
718e3744 | 5811 | } |
5812 | ||
f418446b | 5813 | /* Set specified peer's BGP port. */ |
718e3744 | 5814 | DEFUN (neighbor_port, |
5815 | neighbor_port_cmd, | |
9ccf14f7 | 5816 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5817 | NEIGHBOR_STR |
5818 | NEIGHBOR_ADDR_STR | |
5819 | "Neighbor's BGP port\n" | |
5820 | "TCP port number\n") | |
5821 | { | |
d62a17ae | 5822 | int idx_ip = 1; |
5823 | int idx_number = 3; | |
5824 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5825 | argv[idx_number]->arg); | |
718e3744 | 5826 | } |
5827 | ||
5828 | DEFUN (no_neighbor_port, | |
5829 | no_neighbor_port_cmd, | |
9ccf14f7 | 5830 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5831 | NO_STR |
5832 | NEIGHBOR_STR | |
5833 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5834 | "Neighbor's BGP port\n" |
5835 | "TCP port number\n") | |
718e3744 | 5836 | { |
d62a17ae | 5837 | int idx_ip = 2; |
5838 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5839 | } |
5840 | ||
6b0655a2 | 5841 | |
718e3744 | 5842 | /* neighbor weight. */ |
d62a17ae | 5843 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5844 | safi_t safi, const char *weight_str) | |
718e3744 | 5845 | { |
d62a17ae | 5846 | int ret; |
5847 | struct peer *peer; | |
5848 | unsigned long weight; | |
718e3744 | 5849 | |
d62a17ae | 5850 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5851 | if (!peer) | |
5852 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5853 | |
d62a17ae | 5854 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5855 | |
d62a17ae | 5856 | ret = peer_weight_set(peer, afi, safi, weight); |
5857 | return bgp_vty_return(vty, ret); | |
718e3744 | 5858 | } |
5859 | ||
d62a17ae | 5860 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5861 | safi_t safi) | |
718e3744 | 5862 | { |
d62a17ae | 5863 | int ret; |
5864 | struct peer *peer; | |
718e3744 | 5865 | |
d62a17ae | 5866 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5867 | if (!peer) | |
5868 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5869 | |
d62a17ae | 5870 | ret = peer_weight_unset(peer, afi, safi); |
5871 | return bgp_vty_return(vty, ret); | |
718e3744 | 5872 | } |
5873 | ||
5874 | DEFUN (neighbor_weight, | |
5875 | neighbor_weight_cmd, | |
9ccf14f7 | 5876 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5877 | NEIGHBOR_STR |
5878 | NEIGHBOR_ADDR_STR2 | |
5879 | "Set default weight for routes from this neighbor\n" | |
5880 | "default weight\n") | |
5881 | { | |
d62a17ae | 5882 | int idx_peer = 1; |
5883 | int idx_number = 3; | |
5884 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5885 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5886 | } |
5887 | ||
d62a17ae | 5888 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5889 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5890 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5891 | "Set default weight for routes from this neighbor\n" | |
5892 | "default weight\n") | |
596c17ba | 5893 | |
718e3744 | 5894 | DEFUN (no_neighbor_weight, |
5895 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5896 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5897 | NO_STR |
5898 | NEIGHBOR_STR | |
5899 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5900 | "Set default weight for routes from this neighbor\n" |
5901 | "default weight\n") | |
718e3744 | 5902 | { |
d62a17ae | 5903 | int idx_peer = 2; |
5904 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5905 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5906 | } |
5907 | ||
d62a17ae | 5908 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5909 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5910 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5911 | "Set default weight for routes from this neighbor\n" | |
5912 | "default weight\n") | |
596c17ba | 5913 | |
6b0655a2 | 5914 | |
718e3744 | 5915 | /* Override capability negotiation. */ |
5916 | DEFUN (neighbor_override_capability, | |
5917 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5918 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5919 | NEIGHBOR_STR |
5920 | NEIGHBOR_ADDR_STR2 | |
5921 | "Override capability negotiation result\n") | |
5922 | { | |
d62a17ae | 5923 | int idx_peer = 1; |
5924 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5925 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5926 | } |
5927 | ||
5928 | DEFUN (no_neighbor_override_capability, | |
5929 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5930 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5931 | NO_STR |
5932 | NEIGHBOR_STR | |
5933 | NEIGHBOR_ADDR_STR2 | |
5934 | "Override capability negotiation result\n") | |
5935 | { | |
d62a17ae | 5936 | int idx_peer = 2; |
5937 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5938 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5939 | } |
6b0655a2 | 5940 | |
718e3744 | 5941 | DEFUN (neighbor_strict_capability, |
5942 | neighbor_strict_capability_cmd, | |
9fb964de | 5943 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5944 | NEIGHBOR_STR |
9fb964de | 5945 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5946 | "Strict capability negotiation match\n") |
5947 | { | |
9fb964de PM |
5948 | int idx_peer = 1; |
5949 | ||
5950 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5951 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5952 | } |
5953 | ||
5954 | DEFUN (no_neighbor_strict_capability, | |
5955 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5956 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5957 | NO_STR |
5958 | NEIGHBOR_STR | |
9fb964de | 5959 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5960 | "Strict capability negotiation match\n") |
5961 | { | |
9fb964de PM |
5962 | int idx_peer = 2; |
5963 | ||
5964 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5965 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5966 | } |
6b0655a2 | 5967 | |
d62a17ae | 5968 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5969 | const char *keep_str, const char *hold_str) | |
718e3744 | 5970 | { |
d62a17ae | 5971 | int ret; |
5972 | struct peer *peer; | |
d7c0a89a QY |
5973 | uint32_t keepalive; |
5974 | uint32_t holdtime; | |
718e3744 | 5975 | |
d62a17ae | 5976 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5977 | if (!peer) | |
5978 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5979 | |
d62a17ae | 5980 | keepalive = strtoul(keep_str, NULL, 10); |
5981 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5982 | |
d62a17ae | 5983 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5984 | |
d62a17ae | 5985 | return bgp_vty_return(vty, ret); |
718e3744 | 5986 | } |
6b0655a2 | 5987 | |
d62a17ae | 5988 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5989 | { |
d62a17ae | 5990 | int ret; |
5991 | struct peer *peer; | |
718e3744 | 5992 | |
d62a17ae | 5993 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5994 | if (!peer) | |
5995 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5996 | |
d62a17ae | 5997 | ret = peer_timers_unset(peer); |
718e3744 | 5998 | |
d62a17ae | 5999 | return bgp_vty_return(vty, ret); |
718e3744 | 6000 | } |
6001 | ||
6002 | DEFUN (neighbor_timers, | |
6003 | neighbor_timers_cmd, | |
9ccf14f7 | 6004 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 6005 | NEIGHBOR_STR |
6006 | NEIGHBOR_ADDR_STR2 | |
6007 | "BGP per neighbor timers\n" | |
6008 | "Keepalive interval\n" | |
6009 | "Holdtime\n") | |
6010 | { | |
d62a17ae | 6011 | int idx_peer = 1; |
6012 | int idx_number = 3; | |
6013 | int idx_number_2 = 4; | |
6014 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6015 | argv[idx_number]->arg, | |
6016 | argv[idx_number_2]->arg); | |
718e3744 | 6017 | } |
6018 | ||
6019 | DEFUN (no_neighbor_timers, | |
6020 | no_neighbor_timers_cmd, | |
9ccf14f7 | 6021 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 6022 | NO_STR |
6023 | NEIGHBOR_STR | |
6024 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
6025 | "BGP per neighbor timers\n" |
6026 | "Keepalive interval\n" | |
6027 | "Holdtime\n") | |
718e3744 | 6028 | { |
d62a17ae | 6029 | int idx_peer = 2; |
6030 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6031 | } |
6b0655a2 | 6032 | |
813d4307 | 6033 | |
d62a17ae | 6034 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
6035 | const char *time_str) | |
718e3744 | 6036 | { |
d62a17ae | 6037 | int ret; |
6038 | struct peer *peer; | |
d7c0a89a | 6039 | uint32_t connect; |
718e3744 | 6040 | |
d62a17ae | 6041 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6042 | if (!peer) | |
6043 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6044 | |
d62a17ae | 6045 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 6046 | |
d62a17ae | 6047 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 6048 | |
d62a17ae | 6049 | return bgp_vty_return(vty, ret); |
718e3744 | 6050 | } |
6051 | ||
d62a17ae | 6052 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6053 | { |
d62a17ae | 6054 | int ret; |
6055 | struct peer *peer; | |
718e3744 | 6056 | |
d62a17ae | 6057 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6058 | if (!peer) | |
6059 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6060 | |
d62a17ae | 6061 | ret = peer_timers_connect_unset(peer); |
718e3744 | 6062 | |
d62a17ae | 6063 | return bgp_vty_return(vty, ret); |
718e3744 | 6064 | } |
6065 | ||
6066 | DEFUN (neighbor_timers_connect, | |
6067 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 6068 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 6069 | NEIGHBOR_STR |
966f821c | 6070 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6071 | "BGP per neighbor timers\n" |
6072 | "BGP connect timer\n" | |
6073 | "Connect timer\n") | |
6074 | { | |
d62a17ae | 6075 | int idx_peer = 1; |
6076 | int idx_number = 4; | |
6077 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6078 | argv[idx_number]->arg); | |
718e3744 | 6079 | } |
6080 | ||
6081 | DEFUN (no_neighbor_timers_connect, | |
6082 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 6083 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 6084 | NO_STR |
6085 | NEIGHBOR_STR | |
966f821c | 6086 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6087 | "BGP per neighbor timers\n" |
8334fd5a DW |
6088 | "BGP connect timer\n" |
6089 | "Connect timer\n") | |
718e3744 | 6090 | { |
d62a17ae | 6091 | int idx_peer = 2; |
6092 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6093 | } |
6094 | ||
6b0655a2 | 6095 | |
d62a17ae | 6096 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
6097 | const char *time_str, int set) | |
718e3744 | 6098 | { |
d62a17ae | 6099 | int ret; |
6100 | struct peer *peer; | |
d7c0a89a | 6101 | uint32_t routeadv = 0; |
718e3744 | 6102 | |
d62a17ae | 6103 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6104 | if (!peer) | |
6105 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6106 | |
d62a17ae | 6107 | if (time_str) |
6108 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 6109 | |
d62a17ae | 6110 | if (set) |
6111 | ret = peer_advertise_interval_set(peer, routeadv); | |
6112 | else | |
6113 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 6114 | |
d62a17ae | 6115 | return bgp_vty_return(vty, ret); |
718e3744 | 6116 | } |
6117 | ||
6118 | DEFUN (neighbor_advertise_interval, | |
6119 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6120 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 6121 | NEIGHBOR_STR |
966f821c | 6122 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6123 | "Minimum interval between sending BGP routing updates\n" |
6124 | "time in seconds\n") | |
6125 | { | |
d62a17ae | 6126 | int idx_peer = 1; |
6127 | int idx_number = 3; | |
6128 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6129 | argv[idx_number]->arg, 1); | |
718e3744 | 6130 | } |
6131 | ||
6132 | DEFUN (no_neighbor_advertise_interval, | |
6133 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6134 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 6135 | NO_STR |
6136 | NEIGHBOR_STR | |
966f821c | 6137 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
6138 | "Minimum interval between sending BGP routing updates\n" |
6139 | "time in seconds\n") | |
718e3744 | 6140 | { |
d62a17ae | 6141 | int idx_peer = 2; |
6142 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6143 | } |
6144 | ||
6b0655a2 | 6145 | |
518f0eb1 DS |
6146 | /* Time to wait before processing route-map updates */ |
6147 | DEFUN (bgp_set_route_map_delay_timer, | |
6148 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6149 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6150 | SET_STR |
6151 | "BGP route-map delay timer\n" | |
6152 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6153 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6154 | { |
d62a17ae | 6155 | int idx_number = 3; |
d7c0a89a | 6156 | uint32_t rmap_delay_timer; |
d62a17ae | 6157 | |
6158 | if (argv[idx_number]->arg) { | |
6159 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6160 | bm->rmap_update_timer = rmap_delay_timer; | |
6161 | ||
6162 | /* if the dynamic update handling is being disabled, and a timer | |
6163 | * is | |
6164 | * running, stop the timer and act as if the timer has already | |
6165 | * fired. | |
6166 | */ | |
6167 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6168 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6169 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6170 | NULL, 0); | |
6171 | } | |
6172 | return CMD_SUCCESS; | |
6173 | } else { | |
6174 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6175 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6176 | } |
518f0eb1 DS |
6177 | } |
6178 | ||
6179 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6180 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6181 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6182 | NO_STR |
3a2d747c | 6183 | BGP_STR |
518f0eb1 | 6184 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6185 | "Reset to default time to wait for processing route-map changes\n" |
6186 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6187 | { |
518f0eb1 | 6188 | |
d62a17ae | 6189 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6190 | |
d62a17ae | 6191 | return CMD_SUCCESS; |
518f0eb1 DS |
6192 | } |
6193 | ||
f414725f | 6194 | |
718e3744 | 6195 | /* neighbor interface */ |
d62a17ae | 6196 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
6197 | const char *str) | |
718e3744 | 6198 | { |
d62a17ae | 6199 | struct peer *peer; |
718e3744 | 6200 | |
d62a17ae | 6201 | peer = peer_lookup_vty(vty, ip_str); |
6202 | if (!peer || peer->conf_if) { | |
6203 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6204 | return CMD_WARNING_CONFIG_FAILED; | |
6205 | } | |
718e3744 | 6206 | |
d62a17ae | 6207 | if (str) |
6208 | peer_interface_set(peer, str); | |
6209 | else | |
6210 | peer_interface_unset(peer); | |
718e3744 | 6211 | |
d62a17ae | 6212 | return CMD_SUCCESS; |
718e3744 | 6213 | } |
6214 | ||
6215 | DEFUN (neighbor_interface, | |
6216 | neighbor_interface_cmd, | |
9ccf14f7 | 6217 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6218 | NEIGHBOR_STR |
6219 | NEIGHBOR_ADDR_STR | |
6220 | "Interface\n" | |
6221 | "Interface name\n") | |
6222 | { | |
d62a17ae | 6223 | int idx_ip = 1; |
6224 | int idx_word = 3; | |
6225 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6226 | } |
6227 | ||
6228 | DEFUN (no_neighbor_interface, | |
6229 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6230 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6231 | NO_STR |
6232 | NEIGHBOR_STR | |
16cedbb0 | 6233 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6234 | "Interface\n" |
6235 | "Interface name\n") | |
6236 | { | |
d62a17ae | 6237 | int idx_peer = 2; |
6238 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6239 | } |
6b0655a2 | 6240 | |
718e3744 | 6241 | DEFUN (neighbor_distribute_list, |
6242 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6243 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6244 | NEIGHBOR_STR |
6245 | NEIGHBOR_ADDR_STR2 | |
6246 | "Filter updates to/from this neighbor\n" | |
6247 | "IP access-list number\n" | |
6248 | "IP access-list number (expanded range)\n" | |
6249 | "IP Access-list name\n" | |
6250 | "Filter incoming updates\n" | |
6251 | "Filter outgoing updates\n") | |
6252 | { | |
d62a17ae | 6253 | int idx_peer = 1; |
6254 | int idx_acl = 3; | |
6255 | int direct, ret; | |
6256 | struct peer *peer; | |
a8206004 | 6257 | |
d62a17ae | 6258 | const char *pstr = argv[idx_peer]->arg; |
6259 | const char *acl = argv[idx_acl]->arg; | |
6260 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6261 | |
d62a17ae | 6262 | peer = peer_and_group_lookup_vty(vty, pstr); |
6263 | if (!peer) | |
6264 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6265 | |
d62a17ae | 6266 | /* Check filter direction. */ |
6267 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6268 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6269 | direct, acl); | |
a8206004 | 6270 | |
d62a17ae | 6271 | return bgp_vty_return(vty, ret); |
718e3744 | 6272 | } |
6273 | ||
d62a17ae | 6274 | ALIAS_HIDDEN( |
6275 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6276 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6277 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6278 | "Filter updates to/from this neighbor\n" | |
6279 | "IP access-list number\n" | |
6280 | "IP access-list number (expanded range)\n" | |
6281 | "IP Access-list name\n" | |
6282 | "Filter incoming updates\n" | |
6283 | "Filter outgoing updates\n") | |
596c17ba | 6284 | |
718e3744 | 6285 | DEFUN (no_neighbor_distribute_list, |
6286 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6287 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6288 | NO_STR |
6289 | NEIGHBOR_STR | |
6290 | NEIGHBOR_ADDR_STR2 | |
6291 | "Filter updates to/from this neighbor\n" | |
6292 | "IP access-list number\n" | |
6293 | "IP access-list number (expanded range)\n" | |
6294 | "IP Access-list name\n" | |
6295 | "Filter incoming updates\n" | |
6296 | "Filter outgoing updates\n") | |
6297 | { | |
d62a17ae | 6298 | int idx_peer = 2; |
6299 | int direct, ret; | |
6300 | struct peer *peer; | |
a8206004 | 6301 | |
d62a17ae | 6302 | const char *pstr = argv[idx_peer]->arg; |
6303 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6304 | |
d62a17ae | 6305 | peer = peer_and_group_lookup_vty(vty, pstr); |
6306 | if (!peer) | |
6307 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6308 | |
d62a17ae | 6309 | /* Check filter direction. */ |
6310 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6311 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6312 | direct); | |
a8206004 | 6313 | |
d62a17ae | 6314 | return bgp_vty_return(vty, ret); |
718e3744 | 6315 | } |
6b0655a2 | 6316 | |
d62a17ae | 6317 | ALIAS_HIDDEN( |
6318 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6319 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6320 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6321 | "Filter updates to/from this neighbor\n" | |
6322 | "IP access-list number\n" | |
6323 | "IP access-list number (expanded range)\n" | |
6324 | "IP Access-list name\n" | |
6325 | "Filter incoming updates\n" | |
6326 | "Filter outgoing updates\n") | |
596c17ba | 6327 | |
718e3744 | 6328 | /* Set prefix list to the peer. */ |
d62a17ae | 6329 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6330 | afi_t afi, safi_t safi, | |
6331 | const char *name_str, | |
6332 | const char *direct_str) | |
718e3744 | 6333 | { |
d62a17ae | 6334 | int ret; |
d62a17ae | 6335 | int direct = FILTER_IN; |
cf9ac8bf | 6336 | struct peer *peer; |
718e3744 | 6337 | |
d62a17ae | 6338 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6339 | if (!peer) | |
6340 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6341 | |
d62a17ae | 6342 | /* Check filter direction. */ |
6343 | if (strncmp(direct_str, "i", 1) == 0) | |
6344 | direct = FILTER_IN; | |
6345 | else if (strncmp(direct_str, "o", 1) == 0) | |
6346 | direct = FILTER_OUT; | |
718e3744 | 6347 | |
d62a17ae | 6348 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6349 | |
d62a17ae | 6350 | return bgp_vty_return(vty, ret); |
718e3744 | 6351 | } |
6352 | ||
d62a17ae | 6353 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6354 | afi_t afi, safi_t safi, | |
6355 | const char *direct_str) | |
718e3744 | 6356 | { |
d62a17ae | 6357 | int ret; |
6358 | struct peer *peer; | |
6359 | int direct = FILTER_IN; | |
718e3744 | 6360 | |
d62a17ae | 6361 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6362 | if (!peer) | |
6363 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6364 | |
d62a17ae | 6365 | /* Check filter direction. */ |
6366 | if (strncmp(direct_str, "i", 1) == 0) | |
6367 | direct = FILTER_IN; | |
6368 | else if (strncmp(direct_str, "o", 1) == 0) | |
6369 | direct = FILTER_OUT; | |
718e3744 | 6370 | |
d62a17ae | 6371 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6372 | |
d62a17ae | 6373 | return bgp_vty_return(vty, ret); |
718e3744 | 6374 | } |
6375 | ||
6376 | DEFUN (neighbor_prefix_list, | |
6377 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6378 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6379 | NEIGHBOR_STR |
6380 | NEIGHBOR_ADDR_STR2 | |
6381 | "Filter updates to/from this neighbor\n" | |
6382 | "Name of a prefix list\n" | |
6383 | "Filter incoming updates\n" | |
6384 | "Filter outgoing updates\n") | |
6385 | { | |
d62a17ae | 6386 | int idx_peer = 1; |
6387 | int idx_word = 3; | |
6388 | int idx_in_out = 4; | |
6389 | return peer_prefix_list_set_vty( | |
6390 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6391 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6392 | } |
6393 | ||
d62a17ae | 6394 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6395 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6396 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6397 | "Filter updates to/from this neighbor\n" | |
6398 | "Name of a prefix list\n" | |
6399 | "Filter incoming updates\n" | |
6400 | "Filter outgoing updates\n") | |
596c17ba | 6401 | |
718e3744 | 6402 | DEFUN (no_neighbor_prefix_list, |
6403 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6404 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6405 | NO_STR |
6406 | NEIGHBOR_STR | |
6407 | NEIGHBOR_ADDR_STR2 | |
6408 | "Filter updates to/from this neighbor\n" | |
6409 | "Name of a prefix list\n" | |
6410 | "Filter incoming updates\n" | |
6411 | "Filter outgoing updates\n") | |
6412 | { | |
d62a17ae | 6413 | int idx_peer = 2; |
6414 | int idx_in_out = 5; | |
6415 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6416 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6417 | argv[idx_in_out]->arg); | |
718e3744 | 6418 | } |
6b0655a2 | 6419 | |
d62a17ae | 6420 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6421 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6422 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6423 | "Filter updates to/from this neighbor\n" | |
6424 | "Name of a prefix list\n" | |
6425 | "Filter incoming updates\n" | |
6426 | "Filter outgoing updates\n") | |
596c17ba | 6427 | |
d62a17ae | 6428 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6429 | safi_t safi, const char *name_str, | |
6430 | const char *direct_str) | |
718e3744 | 6431 | { |
d62a17ae | 6432 | int ret; |
6433 | struct peer *peer; | |
6434 | int direct = FILTER_IN; | |
718e3744 | 6435 | |
d62a17ae | 6436 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6437 | if (!peer) | |
6438 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6439 | |
d62a17ae | 6440 | /* Check filter direction. */ |
6441 | if (strncmp(direct_str, "i", 1) == 0) | |
6442 | direct = FILTER_IN; | |
6443 | else if (strncmp(direct_str, "o", 1) == 0) | |
6444 | direct = FILTER_OUT; | |
718e3744 | 6445 | |
d62a17ae | 6446 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6447 | |
d62a17ae | 6448 | return bgp_vty_return(vty, ret); |
718e3744 | 6449 | } |
6450 | ||
d62a17ae | 6451 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6452 | safi_t safi, const char *direct_str) | |
718e3744 | 6453 | { |
d62a17ae | 6454 | int ret; |
6455 | struct peer *peer; | |
6456 | int direct = FILTER_IN; | |
718e3744 | 6457 | |
d62a17ae | 6458 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6459 | if (!peer) | |
6460 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6461 | |
d62a17ae | 6462 | /* Check filter direction. */ |
6463 | if (strncmp(direct_str, "i", 1) == 0) | |
6464 | direct = FILTER_IN; | |
6465 | else if (strncmp(direct_str, "o", 1) == 0) | |
6466 | direct = FILTER_OUT; | |
718e3744 | 6467 | |
d62a17ae | 6468 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6469 | |
d62a17ae | 6470 | return bgp_vty_return(vty, ret); |
718e3744 | 6471 | } |
6472 | ||
6473 | DEFUN (neighbor_filter_list, | |
6474 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6475 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6476 | NEIGHBOR_STR |
6477 | NEIGHBOR_ADDR_STR2 | |
6478 | "Establish BGP filters\n" | |
6479 | "AS path access-list name\n" | |
6480 | "Filter incoming routes\n" | |
6481 | "Filter outgoing routes\n") | |
6482 | { | |
d62a17ae | 6483 | int idx_peer = 1; |
6484 | int idx_word = 3; | |
6485 | int idx_in_out = 4; | |
6486 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6487 | bgp_node_safi(vty), argv[idx_word]->arg, | |
6488 | argv[idx_in_out]->arg); | |
718e3744 | 6489 | } |
6490 | ||
d62a17ae | 6491 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
6492 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6493 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6494 | "Establish BGP filters\n" | |
6495 | "AS path access-list name\n" | |
6496 | "Filter incoming routes\n" | |
6497 | "Filter outgoing routes\n") | |
596c17ba | 6498 | |
718e3744 | 6499 | DEFUN (no_neighbor_filter_list, |
6500 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 6501 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6502 | NO_STR |
6503 | NEIGHBOR_STR | |
6504 | NEIGHBOR_ADDR_STR2 | |
6505 | "Establish BGP filters\n" | |
6506 | "AS path access-list name\n" | |
6507 | "Filter incoming routes\n" | |
6508 | "Filter outgoing routes\n") | |
6509 | { | |
d62a17ae | 6510 | int idx_peer = 2; |
6511 | int idx_in_out = 5; | |
6512 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
6513 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6514 | argv[idx_in_out]->arg); | |
718e3744 | 6515 | } |
6b0655a2 | 6516 | |
d62a17ae | 6517 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
6518 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6519 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6520 | "Establish BGP filters\n" | |
6521 | "AS path access-list name\n" | |
6522 | "Filter incoming routes\n" | |
6523 | "Filter outgoing routes\n") | |
596c17ba | 6524 | |
718e3744 | 6525 | /* Set route-map to the peer. */ |
d62a17ae | 6526 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
6527 | afi_t afi, safi_t safi, const char *name_str, | |
6528 | const char *direct_str) | |
718e3744 | 6529 | { |
d62a17ae | 6530 | int ret; |
6531 | struct peer *peer; | |
6532 | int direct = RMAP_IN; | |
1de27621 | 6533 | struct route_map *route_map; |
718e3744 | 6534 | |
d62a17ae | 6535 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6536 | if (!peer) | |
6537 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6538 | |
d62a17ae | 6539 | /* Check filter direction. */ |
6540 | if (strncmp(direct_str, "in", 2) == 0) | |
6541 | direct = RMAP_IN; | |
6542 | else if (strncmp(direct_str, "o", 1) == 0) | |
6543 | direct = RMAP_OUT; | |
718e3744 | 6544 | |
1de27621 DA |
6545 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6546 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 6547 | |
d62a17ae | 6548 | return bgp_vty_return(vty, ret); |
718e3744 | 6549 | } |
6550 | ||
d62a17ae | 6551 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
6552 | afi_t afi, safi_t safi, | |
6553 | const char *direct_str) | |
718e3744 | 6554 | { |
d62a17ae | 6555 | int ret; |
6556 | struct peer *peer; | |
6557 | int direct = RMAP_IN; | |
718e3744 | 6558 | |
d62a17ae | 6559 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6560 | if (!peer) | |
6561 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6562 | |
d62a17ae | 6563 | /* Check filter direction. */ |
6564 | if (strncmp(direct_str, "in", 2) == 0) | |
6565 | direct = RMAP_IN; | |
6566 | else if (strncmp(direct_str, "o", 1) == 0) | |
6567 | direct = RMAP_OUT; | |
718e3744 | 6568 | |
d62a17ae | 6569 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 6570 | |
d62a17ae | 6571 | return bgp_vty_return(vty, ret); |
718e3744 | 6572 | } |
6573 | ||
6574 | DEFUN (neighbor_route_map, | |
6575 | neighbor_route_map_cmd, | |
9ccf14f7 | 6576 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6577 | NEIGHBOR_STR |
6578 | NEIGHBOR_ADDR_STR2 | |
6579 | "Apply route map to neighbor\n" | |
6580 | "Name of route map\n" | |
6581 | "Apply map to incoming routes\n" | |
2a3d5731 | 6582 | "Apply map to outbound routes\n") |
718e3744 | 6583 | { |
d62a17ae | 6584 | int idx_peer = 1; |
6585 | int idx_word = 3; | |
6586 | int idx_in_out = 4; | |
6587 | return peer_route_map_set_vty( | |
6588 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6589 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6590 | } |
6591 | ||
d62a17ae | 6592 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
6593 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6594 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6595 | "Apply route map to neighbor\n" | |
6596 | "Name of route map\n" | |
6597 | "Apply map to incoming routes\n" | |
6598 | "Apply map to outbound routes\n") | |
596c17ba | 6599 | |
718e3744 | 6600 | DEFUN (no_neighbor_route_map, |
6601 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 6602 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6603 | NO_STR |
6604 | NEIGHBOR_STR | |
6605 | NEIGHBOR_ADDR_STR2 | |
6606 | "Apply route map to neighbor\n" | |
6607 | "Name of route map\n" | |
6608 | "Apply map to incoming routes\n" | |
2a3d5731 | 6609 | "Apply map to outbound routes\n") |
718e3744 | 6610 | { |
d62a17ae | 6611 | int idx_peer = 2; |
6612 | int idx_in_out = 5; | |
6613 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
6614 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6615 | argv[idx_in_out]->arg); | |
718e3744 | 6616 | } |
6b0655a2 | 6617 | |
d62a17ae | 6618 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
6619 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6620 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6621 | "Apply route map to neighbor\n" | |
6622 | "Name of route map\n" | |
6623 | "Apply map to incoming routes\n" | |
6624 | "Apply map to outbound routes\n") | |
596c17ba | 6625 | |
718e3744 | 6626 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 6627 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
6628 | afi_t afi, safi_t safi, | |
6629 | const char *name_str) | |
718e3744 | 6630 | { |
d62a17ae | 6631 | int ret; |
6632 | struct peer *peer; | |
1de27621 | 6633 | struct route_map *route_map; |
718e3744 | 6634 | |
d62a17ae | 6635 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6636 | if (!peer) | |
6637 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6638 | |
1de27621 DA |
6639 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6640 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 6641 | |
d62a17ae | 6642 | return bgp_vty_return(vty, ret); |
718e3744 | 6643 | } |
6644 | ||
6645 | /* Unset route-map from the peer. */ | |
d62a17ae | 6646 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
6647 | afi_t afi, safi_t safi) | |
718e3744 | 6648 | { |
d62a17ae | 6649 | int ret; |
6650 | struct peer *peer; | |
718e3744 | 6651 | |
d62a17ae | 6652 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6653 | if (!peer) | |
6654 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6655 | |
d62a17ae | 6656 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 6657 | |
d62a17ae | 6658 | return bgp_vty_return(vty, ret); |
718e3744 | 6659 | } |
6660 | ||
6661 | DEFUN (neighbor_unsuppress_map, | |
6662 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6663 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6664 | NEIGHBOR_STR |
6665 | NEIGHBOR_ADDR_STR2 | |
6666 | "Route-map to selectively unsuppress suppressed routes\n" | |
6667 | "Name of route map\n") | |
6668 | { | |
d62a17ae | 6669 | int idx_peer = 1; |
6670 | int idx_word = 3; | |
6671 | return peer_unsuppress_map_set_vty( | |
6672 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6673 | argv[idx_word]->arg); | |
718e3744 | 6674 | } |
6675 | ||
d62a17ae | 6676 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
6677 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6678 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6679 | "Route-map to selectively unsuppress suppressed routes\n" | |
6680 | "Name of route map\n") | |
596c17ba | 6681 | |
718e3744 | 6682 | DEFUN (no_neighbor_unsuppress_map, |
6683 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6684 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6685 | NO_STR |
6686 | NEIGHBOR_STR | |
6687 | NEIGHBOR_ADDR_STR2 | |
6688 | "Route-map to selectively unsuppress suppressed routes\n" | |
6689 | "Name of route map\n") | |
6690 | { | |
d62a17ae | 6691 | int idx_peer = 2; |
6692 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6693 | bgp_node_afi(vty), | |
6694 | bgp_node_safi(vty)); | |
718e3744 | 6695 | } |
6b0655a2 | 6696 | |
d62a17ae | 6697 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6698 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6699 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6700 | "Route-map to selectively unsuppress suppressed routes\n" | |
6701 | "Name of route map\n") | |
596c17ba | 6702 | |
d62a17ae | 6703 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6704 | afi_t afi, safi_t safi, | |
6705 | const char *num_str, | |
6706 | const char *threshold_str, int warning, | |
9cbd06e0 DA |
6707 | const char *restart_str, |
6708 | const char *force_str) | |
718e3744 | 6709 | { |
d62a17ae | 6710 | int ret; |
6711 | struct peer *peer; | |
d7c0a89a QY |
6712 | uint32_t max; |
6713 | uint8_t threshold; | |
6714 | uint16_t restart; | |
718e3744 | 6715 | |
d62a17ae | 6716 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6717 | if (!peer) | |
6718 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6719 | |
d62a17ae | 6720 | max = strtoul(num_str, NULL, 10); |
6721 | if (threshold_str) | |
6722 | threshold = atoi(threshold_str); | |
6723 | else | |
6724 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6725 | |
d62a17ae | 6726 | if (restart_str) |
6727 | restart = atoi(restart_str); | |
6728 | else | |
6729 | restart = 0; | |
0a486e5f | 6730 | |
d62a17ae | 6731 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
9cbd06e0 | 6732 | restart, force_str ? true : false); |
718e3744 | 6733 | |
d62a17ae | 6734 | return bgp_vty_return(vty, ret); |
718e3744 | 6735 | } |
6736 | ||
d62a17ae | 6737 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6738 | afi_t afi, safi_t safi) | |
718e3744 | 6739 | { |
d62a17ae | 6740 | int ret; |
6741 | struct peer *peer; | |
718e3744 | 6742 | |
d62a17ae | 6743 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6744 | if (!peer) | |
6745 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6746 | |
d62a17ae | 6747 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6748 | |
d62a17ae | 6749 | return bgp_vty_return(vty, ret); |
718e3744 | 6750 | } |
6751 | ||
fde246e8 DA |
6752 | /* Maximum number of prefix to be sent to the neighbor. */ |
6753 | DEFUN(neighbor_maximum_prefix_out, | |
6754 | neighbor_maximum_prefix_out_cmd, | |
6755 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6756 | NEIGHBOR_STR | |
6757 | NEIGHBOR_ADDR_STR2 | |
6758 | "Maximum number of prefixes to be sent to this peer\n" | |
6759 | "Maximum no. of prefix limit\n") | |
6760 | { | |
6761 | int idx_peer = 1; | |
6762 | int idx_number = 3; | |
6763 | struct peer *peer; | |
6764 | uint32_t max; | |
6765 | afi_t afi = bgp_node_afi(vty); | |
6766 | safi_t safi = bgp_node_safi(vty); | |
6767 | ||
6768 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6769 | if (!peer) | |
6770 | return CMD_WARNING_CONFIG_FAILED; | |
6771 | ||
6772 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6773 | ||
6774 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6775 | peer->pmax_out[afi][safi] = max; | |
6776 | ||
6777 | return CMD_SUCCESS; | |
6778 | } | |
6779 | ||
6780 | DEFUN(no_neighbor_maximum_prefix_out, | |
6781 | no_neighbor_maximum_prefix_out_cmd, | |
6782 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6783 | NO_STR | |
6784 | NEIGHBOR_STR | |
6785 | NEIGHBOR_ADDR_STR2 | |
6786 | "Maximum number of prefixes to be sent to this peer\n") | |
6787 | { | |
6788 | int idx_peer = 2; | |
6789 | struct peer *peer; | |
6790 | afi_t afi = bgp_node_afi(vty); | |
6791 | safi_t safi = bgp_node_safi(vty); | |
6792 | ||
6793 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6794 | if (!peer) | |
6795 | return CMD_WARNING_CONFIG_FAILED; | |
6796 | ||
ae00326a | 6797 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
fde246e8 DA |
6798 | peer->pmax_out[afi][safi] = 0; |
6799 | ||
6800 | return CMD_SUCCESS; | |
6801 | } | |
6802 | ||
9cbd06e0 DA |
6803 | /* Maximum number of prefix configuration. Prefix count is different |
6804 | for each peer configuration. So this configuration can be set for | |
718e3744 | 6805 | each peer configuration. */ |
6806 | DEFUN (neighbor_maximum_prefix, | |
6807 | neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 6808 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
718e3744 | 6809 | NEIGHBOR_STR |
6810 | NEIGHBOR_ADDR_STR2 | |
6811 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
6812 | "maximum no. of prefix limit\n" |
6813 | "Force checking all received routes not only accepted\n") | |
718e3744 | 6814 | { |
d62a17ae | 6815 | int idx_peer = 1; |
6816 | int idx_number = 3; | |
9cbd06e0 DA |
6817 | int idx_force = 0; |
6818 | char *force = NULL; | |
6819 | ||
6820 | if (argv_find(argv, argc, "force", &idx_force)) | |
6821 | force = argv[idx_force]->arg; | |
6822 | ||
d62a17ae | 6823 | return peer_maximum_prefix_set_vty( |
6824 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 6825 | argv[idx_number]->arg, NULL, 0, NULL, force); |
718e3744 | 6826 | } |
6827 | ||
d62a17ae | 6828 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 6829 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 6830 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6831 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
6832 | "maximum no. of prefix limit\n" |
6833 | "Force checking all received routes not only accepted\n") | |
596c17ba | 6834 | |
e0701b79 | 6835 | DEFUN (neighbor_maximum_prefix_threshold, |
6836 | neighbor_maximum_prefix_threshold_cmd, | |
9cbd06e0 | 6837 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
e0701b79 | 6838 | NEIGHBOR_STR |
6839 | NEIGHBOR_ADDR_STR2 | |
6840 | "Maximum number of prefix accept from this peer\n" | |
6841 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
6842 | "Threshold value (%) at which to generate a warning msg\n" |
6843 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 6844 | { |
d62a17ae | 6845 | int idx_peer = 1; |
6846 | int idx_number = 3; | |
6847 | int idx_number_2 = 4; | |
9cbd06e0 DA |
6848 | int idx_force = 0; |
6849 | char *force = NULL; | |
6850 | ||
6851 | if (argv_find(argv, argc, "force", &idx_force)) | |
6852 | force = argv[idx_force]->arg; | |
6853 | ||
d62a17ae | 6854 | return peer_maximum_prefix_set_vty( |
6855 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 6856 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); |
0a486e5f | 6857 | } |
e0701b79 | 6858 | |
d62a17ae | 6859 | ALIAS_HIDDEN( |
6860 | neighbor_maximum_prefix_threshold, | |
6861 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 6862 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 6863 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6864 | "Maximum number of prefix accept from this peer\n" | |
6865 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
6866 | "Threshold value (%) at which to generate a warning msg\n" |
6867 | "Force checking all received routes not only accepted\n") | |
596c17ba | 6868 | |
718e3744 | 6869 | DEFUN (neighbor_maximum_prefix_warning, |
6870 | neighbor_maximum_prefix_warning_cmd, | |
9cbd06e0 | 6871 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
718e3744 | 6872 | NEIGHBOR_STR |
6873 | NEIGHBOR_ADDR_STR2 | |
6874 | "Maximum number of prefix accept from this peer\n" | |
6875 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
6876 | "Only give warning message when limit is exceeded\n" |
6877 | "Force checking all received routes not only accepted\n") | |
718e3744 | 6878 | { |
d62a17ae | 6879 | int idx_peer = 1; |
6880 | int idx_number = 3; | |
9cbd06e0 DA |
6881 | int idx_force = 0; |
6882 | char *force = NULL; | |
6883 | ||
6884 | if (argv_find(argv, argc, "force", &idx_force)) | |
6885 | force = argv[idx_force]->arg; | |
6886 | ||
d62a17ae | 6887 | return peer_maximum_prefix_set_vty( |
6888 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 6889 | argv[idx_number]->arg, NULL, 1, NULL, force); |
718e3744 | 6890 | } |
6891 | ||
d62a17ae | 6892 | ALIAS_HIDDEN( |
6893 | neighbor_maximum_prefix_warning, | |
6894 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 6895 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 6896 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6897 | "Maximum number of prefix accept from this peer\n" | |
6898 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
6899 | "Only give warning message when limit is exceeded\n" |
6900 | "Force checking all received routes not only accepted\n") | |
596c17ba | 6901 | |
e0701b79 | 6902 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6903 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9cbd06e0 | 6904 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
e0701b79 | 6905 | NEIGHBOR_STR |
6906 | NEIGHBOR_ADDR_STR2 | |
6907 | "Maximum number of prefix accept from this peer\n" | |
6908 | "maximum no. of prefix limit\n" | |
6909 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
6910 | "Only give warning message when limit is exceeded\n" |
6911 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 6912 | { |
d62a17ae | 6913 | int idx_peer = 1; |
6914 | int idx_number = 3; | |
6915 | int idx_number_2 = 4; | |
9cbd06e0 DA |
6916 | int idx_force = 0; |
6917 | char *force = NULL; | |
6918 | ||
6919 | if (argv_find(argv, argc, "force", &idx_force)) | |
6920 | force = argv[idx_force]->arg; | |
6921 | ||
d62a17ae | 6922 | return peer_maximum_prefix_set_vty( |
6923 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 6924 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); |
0a486e5f | 6925 | } |
6926 | ||
d62a17ae | 6927 | ALIAS_HIDDEN( |
6928 | neighbor_maximum_prefix_threshold_warning, | |
6929 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 6930 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 6931 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6932 | "Maximum number of prefix accept from this peer\n" | |
6933 | "maximum no. of prefix limit\n" | |
6934 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
6935 | "Only give warning message when limit is exceeded\n" |
6936 | "Force checking all received routes not only accepted\n") | |
596c17ba | 6937 | |
0a486e5f | 6938 | DEFUN (neighbor_maximum_prefix_restart, |
6939 | neighbor_maximum_prefix_restart_cmd, | |
9cbd06e0 | 6940 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
0a486e5f | 6941 | NEIGHBOR_STR |
6942 | NEIGHBOR_ADDR_STR2 | |
6943 | "Maximum number of prefix accept from this peer\n" | |
6944 | "maximum no. of prefix limit\n" | |
6945 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
6946 | "Restart interval in minutes\n" |
6947 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 6948 | { |
d62a17ae | 6949 | int idx_peer = 1; |
6950 | int idx_number = 3; | |
6951 | int idx_number_2 = 5; | |
9cbd06e0 DA |
6952 | int idx_force = 0; |
6953 | char *force = NULL; | |
6954 | ||
6955 | if (argv_find(argv, argc, "force", &idx_force)) | |
6956 | force = argv[idx_force]->arg; | |
6957 | ||
d62a17ae | 6958 | return peer_maximum_prefix_set_vty( |
6959 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 6960 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); |
0a486e5f | 6961 | } |
6962 | ||
d62a17ae | 6963 | ALIAS_HIDDEN( |
6964 | neighbor_maximum_prefix_restart, | |
6965 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 6966 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 6967 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6968 | "Maximum number of prefix accept from this peer\n" | |
6969 | "maximum no. of prefix limit\n" | |
6970 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
6971 | "Restart interval in minutes\n" |
6972 | "Force checking all received routes not only accepted\n") | |
596c17ba | 6973 | |
0a486e5f | 6974 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6975 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9cbd06e0 | 6976 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
0a486e5f | 6977 | NEIGHBOR_STR |
6978 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6979 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6980 | "maximum no. of prefix limit\n" |
6981 | "Threshold value (%) at which to generate a warning msg\n" | |
6982 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
6983 | "Restart interval in minutes\n" |
6984 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 6985 | { |
d62a17ae | 6986 | int idx_peer = 1; |
6987 | int idx_number = 3; | |
6988 | int idx_number_2 = 4; | |
6989 | int idx_number_3 = 6; | |
9cbd06e0 DA |
6990 | int idx_force = 0; |
6991 | char *force = NULL; | |
6992 | ||
6993 | if (argv_find(argv, argc, "force", &idx_force)) | |
6994 | force = argv[idx_force]->arg; | |
6995 | ||
d62a17ae | 6996 | return peer_maximum_prefix_set_vty( |
6997 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6998 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
9cbd06e0 | 6999 | argv[idx_number_3]->arg, force); |
d62a17ae | 7000 | } |
7001 | ||
7002 | ALIAS_HIDDEN( | |
7003 | neighbor_maximum_prefix_threshold_restart, | |
7004 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 7005 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 7006 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7007 | "Maximum number of prefixes to accept from this peer\n" | |
7008 | "maximum no. of prefix limit\n" | |
7009 | "Threshold value (%) at which to generate a warning msg\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 | |
718e3744 | 7014 | DEFUN (no_neighbor_maximum_prefix, |
7015 | no_neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 7016 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
718e3744 | 7017 | NO_STR |
7018 | NEIGHBOR_STR | |
7019 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 7020 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
7021 | "maximum no. of prefix limit\n" |
7022 | "Threshold value (%) at which to generate a warning msg\n" | |
7023 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 7024 | "Restart interval in minutes\n" |
9cbd06e0 DA |
7025 | "Only give warning message when limit is exceeded\n" |
7026 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7027 | { |
d62a17ae | 7028 | int idx_peer = 2; |
7029 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
7030 | bgp_node_afi(vty), | |
7031 | bgp_node_safi(vty)); | |
718e3744 | 7032 | } |
e52702f2 | 7033 | |
d62a17ae | 7034 | ALIAS_HIDDEN( |
7035 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 7036 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 7037 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7038 | "Maximum number of prefixes to accept from this peer\n" | |
7039 | "maximum no. of prefix limit\n" | |
7040 | "Threshold value (%) at which to generate a warning msg\n" | |
7041 | "Restart bgp connection after limit is exceeded\n" | |
7042 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
7043 | "Only give warning message when limit is exceeded\n" |
7044 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7045 | |
718e3744 | 7046 | |
718e3744 | 7047 | /* "neighbor allowas-in" */ |
7048 | DEFUN (neighbor_allowas_in, | |
7049 | neighbor_allowas_in_cmd, | |
fd8503f5 | 7050 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7051 | NEIGHBOR_STR |
7052 | NEIGHBOR_ADDR_STR2 | |
31500417 | 7053 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 7054 | "Number of occurrences of AS number\n" |
fd8503f5 | 7055 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7056 | { |
d62a17ae | 7057 | int idx_peer = 1; |
7058 | int idx_number_origin = 3; | |
7059 | int ret; | |
7060 | int origin = 0; | |
7061 | struct peer *peer; | |
7062 | int allow_num = 0; | |
7063 | ||
7064 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7065 | if (!peer) | |
7066 | return CMD_WARNING_CONFIG_FAILED; | |
7067 | ||
7068 | if (argc <= idx_number_origin) | |
7069 | allow_num = 3; | |
7070 | else { | |
7071 | if (argv[idx_number_origin]->type == WORD_TKN) | |
7072 | origin = 1; | |
7073 | else | |
7074 | allow_num = atoi(argv[idx_number_origin]->arg); | |
7075 | } | |
7076 | ||
7077 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7078 | allow_num, origin); | |
7079 | ||
7080 | return bgp_vty_return(vty, ret); | |
7081 | } | |
7082 | ||
7083 | ALIAS_HIDDEN( | |
7084 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
7085 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7086 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7087 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 7088 | "Number of occurrences of AS number\n" |
d62a17ae | 7089 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7090 | |
718e3744 | 7091 | DEFUN (no_neighbor_allowas_in, |
7092 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 7093 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7094 | NO_STR |
7095 | NEIGHBOR_STR | |
7096 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 7097 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 7098 | "Number of occurrences of AS number\n" |
fd8503f5 | 7099 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7100 | { |
d62a17ae | 7101 | int idx_peer = 2; |
7102 | int ret; | |
7103 | struct peer *peer; | |
718e3744 | 7104 | |
d62a17ae | 7105 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7106 | if (!peer) | |
7107 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7108 | |
d62a17ae | 7109 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
7110 | bgp_node_safi(vty)); | |
718e3744 | 7111 | |
d62a17ae | 7112 | return bgp_vty_return(vty, ret); |
718e3744 | 7113 | } |
6b0655a2 | 7114 | |
d62a17ae | 7115 | ALIAS_HIDDEN( |
7116 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
7117 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7118 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7119 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 7120 | "Number of occurrences of AS number\n" |
d62a17ae | 7121 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7122 | |
fa411a21 NH |
7123 | DEFUN (neighbor_ttl_security, |
7124 | neighbor_ttl_security_cmd, | |
7ebe625c | 7125 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 7126 | NEIGHBOR_STR |
7ebe625c | 7127 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7128 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
7129 | "Specify the maximum number of hops to the BGP peer\n" |
7130 | "Number of hops to BGP peer\n") | |
fa411a21 | 7131 | { |
d62a17ae | 7132 | int idx_peer = 1; |
7133 | int idx_number = 4; | |
7134 | struct peer *peer; | |
7135 | int gtsm_hops; | |
7136 | ||
7137 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7138 | if (!peer) | |
7139 | return CMD_WARNING_CONFIG_FAILED; | |
7140 | ||
7141 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
7142 | ||
7ebe625c QY |
7143 | /* |
7144 | * If 'neighbor swpX', then this is for directly connected peers, | |
7145 | * we should not accept a ttl-security hops value greater than 1. | |
7146 | */ | |
e2521429 | 7147 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { |
7ebe625c QY |
7148 | vty_out(vty, |
7149 | "%s is directly connected peer, hops cannot exceed 1\n", | |
7150 | argv[idx_peer]->arg); | |
7151 | return CMD_WARNING_CONFIG_FAILED; | |
7152 | } | |
7153 | ||
d62a17ae | 7154 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
7155 | } |
7156 | ||
7157 | DEFUN (no_neighbor_ttl_security, | |
7158 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 7159 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
7160 | NO_STR |
7161 | NEIGHBOR_STR | |
7ebe625c | 7162 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7163 | "BGP ttl-security parameters\n" |
3a2d747c QY |
7164 | "Specify the maximum number of hops to the BGP peer\n" |
7165 | "Number of hops to BGP peer\n") | |
fa411a21 | 7166 | { |
d62a17ae | 7167 | int idx_peer = 2; |
7168 | struct peer *peer; | |
fa411a21 | 7169 | |
d62a17ae | 7170 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7171 | if (!peer) | |
7172 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 7173 | |
d62a17ae | 7174 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 7175 | } |
6b0655a2 | 7176 | |
adbac85e DW |
7177 | DEFUN (neighbor_addpath_tx_all_paths, |
7178 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7179 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7180 | NEIGHBOR_STR |
7181 | NEIGHBOR_ADDR_STR2 | |
7182 | "Use addpath to advertise all paths to a neighbor\n") | |
7183 | { | |
d62a17ae | 7184 | int idx_peer = 1; |
7185 | struct peer *peer; | |
adbac85e | 7186 | |
d62a17ae | 7187 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7188 | if (!peer) | |
7189 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 7190 | |
dcc68b5e MS |
7191 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7192 | BGP_ADDPATH_ALL); | |
7193 | return CMD_SUCCESS; | |
adbac85e DW |
7194 | } |
7195 | ||
d62a17ae | 7196 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
7197 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
7198 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7199 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7200 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7201 | |
adbac85e DW |
7202 | DEFUN (no_neighbor_addpath_tx_all_paths, |
7203 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7204 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7205 | NO_STR |
7206 | NEIGHBOR_STR | |
7207 | NEIGHBOR_ADDR_STR2 | |
7208 | "Use addpath to advertise all paths to a neighbor\n") | |
7209 | { | |
d62a17ae | 7210 | int idx_peer = 2; |
dcc68b5e MS |
7211 | struct peer *peer; |
7212 | ||
7213 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7214 | if (!peer) | |
7215 | return CMD_WARNING_CONFIG_FAILED; | |
7216 | ||
7217 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7218 | != BGP_ADDPATH_ALL) { | |
7219 | vty_out(vty, | |
7220 | "%% Peer not currently configured to transmit all paths."); | |
7221 | return CMD_WARNING_CONFIG_FAILED; | |
7222 | } | |
7223 | ||
7224 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7225 | BGP_ADDPATH_NONE); | |
7226 | ||
7227 | return CMD_SUCCESS; | |
adbac85e DW |
7228 | } |
7229 | ||
d62a17ae | 7230 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
7231 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
7232 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7233 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7234 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7235 | |
06370dac DW |
7236 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
7237 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7238 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7239 | NEIGHBOR_STR |
7240 | NEIGHBOR_ADDR_STR2 | |
7241 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7242 | { | |
d62a17ae | 7243 | int idx_peer = 1; |
7244 | struct peer *peer; | |
06370dac | 7245 | |
d62a17ae | 7246 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7247 | if (!peer) | |
7248 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 7249 | |
dcc68b5e MS |
7250 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7251 | BGP_ADDPATH_BEST_PER_AS); | |
7252 | ||
7253 | return CMD_SUCCESS; | |
06370dac DW |
7254 | } |
7255 | ||
d62a17ae | 7256 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7257 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7258 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7259 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7260 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7261 | |
06370dac DW |
7262 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7263 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7264 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7265 | NO_STR |
7266 | NEIGHBOR_STR | |
7267 | NEIGHBOR_ADDR_STR2 | |
7268 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7269 | { | |
d62a17ae | 7270 | int idx_peer = 2; |
dcc68b5e MS |
7271 | struct peer *peer; |
7272 | ||
7273 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7274 | if (!peer) | |
7275 | return CMD_WARNING_CONFIG_FAILED; | |
7276 | ||
7277 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7278 | != BGP_ADDPATH_BEST_PER_AS) { | |
7279 | vty_out(vty, | |
7280 | "%% Peer not currently configured to transmit all best path per as."); | |
7281 | return CMD_WARNING_CONFIG_FAILED; | |
7282 | } | |
7283 | ||
7284 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7285 | BGP_ADDPATH_NONE); | |
7286 | ||
7287 | return CMD_SUCCESS; | |
06370dac DW |
7288 | } |
7289 | ||
d62a17ae | 7290 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7291 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7292 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7293 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7294 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7295 | |
2b31007c RZ |
7296 | DEFPY( |
7297 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7298 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7299 | NEIGHBOR_STR | |
7300 | NEIGHBOR_ADDR_STR2 | |
7301 | "Detect AS loops before sending to neighbor\n") | |
7302 | { | |
7303 | struct peer *peer; | |
7304 | ||
7305 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7306 | if (!peer) | |
7307 | return CMD_WARNING_CONFIG_FAILED; | |
7308 | ||
7309 | peer->as_path_loop_detection = true; | |
7310 | ||
7311 | return CMD_SUCCESS; | |
7312 | } | |
7313 | ||
7314 | DEFPY( | |
7315 | no_neighbor_aspath_loop_detection, | |
7316 | no_neighbor_aspath_loop_detection_cmd, | |
7317 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7318 | NO_STR | |
7319 | NEIGHBOR_STR | |
7320 | NEIGHBOR_ADDR_STR2 | |
7321 | "Detect AS loops before sending to neighbor\n") | |
7322 | { | |
7323 | struct peer *peer; | |
7324 | ||
7325 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7326 | if (!peer) | |
7327 | return CMD_WARNING_CONFIG_FAILED; | |
7328 | ||
7329 | peer->as_path_loop_detection = false; | |
7330 | ||
7331 | return CMD_SUCCESS; | |
7332 | } | |
7333 | ||
b9c7bc5a PZ |
7334 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
7335 | struct ecommunity **list) | |
ddb5b488 | 7336 | { |
b9c7bc5a PZ |
7337 | struct ecommunity *ecom = NULL; |
7338 | struct ecommunity *ecomadd; | |
ddb5b488 | 7339 | |
b9c7bc5a | 7340 | for (; argc; --argc, ++argv) { |
ddb5b488 | 7341 | |
b9c7bc5a PZ |
7342 | ecomadd = ecommunity_str2com(argv[0]->arg, |
7343 | ECOMMUNITY_ROUTE_TARGET, 0); | |
7344 | if (!ecomadd) { | |
7345 | vty_out(vty, "Malformed community-list value\n"); | |
7346 | if (ecom) | |
7347 | ecommunity_free(&ecom); | |
7348 | return CMD_WARNING_CONFIG_FAILED; | |
7349 | } | |
ddb5b488 | 7350 | |
b9c7bc5a PZ |
7351 | if (ecom) { |
7352 | ecommunity_merge(ecom, ecomadd); | |
7353 | ecommunity_free(&ecomadd); | |
7354 | } else { | |
7355 | ecom = ecomadd; | |
7356 | } | |
7357 | } | |
7358 | ||
7359 | if (*list) { | |
7360 | ecommunity_free(&*list); | |
ddb5b488 | 7361 | } |
b9c7bc5a PZ |
7362 | *list = ecom; |
7363 | ||
7364 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7365 | } |
7366 | ||
0ca70ba5 DS |
7367 | /* |
7368 | * v2vimport is true if we are handling a `import vrf ...` command | |
7369 | */ | |
7370 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7371 | { |
0ca70ba5 DS |
7372 | afi_t afi; |
7373 | ||
ddb5b488 | 7374 | switch (vty->node) { |
b9c7bc5a | 7375 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7376 | afi = AFI_IP; |
7377 | break; | |
b9c7bc5a | 7378 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7379 | afi = AFI_IP6; |
7380 | break; | |
ddb5b488 PZ |
7381 | default: |
7382 | vty_out(vty, | |
b9c7bc5a | 7383 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7384 | return AFI_MAX; |
ddb5b488 | 7385 | } |
69b07479 | 7386 | |
0ca70ba5 DS |
7387 | if (!v2vimport) { |
7388 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7389 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7390 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7391 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7392 | vty_out(vty, | |
7393 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7394 | return AFI_MAX; | |
7395 | } | |
7396 | } else { | |
7397 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7398 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7399 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7400 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7401 | vty_out(vty, | |
7402 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7403 | return AFI_MAX; | |
7404 | } | |
7405 | } | |
7406 | return afi; | |
ddb5b488 PZ |
7407 | } |
7408 | ||
b9c7bc5a PZ |
7409 | DEFPY (af_rd_vpn_export, |
7410 | af_rd_vpn_export_cmd, | |
7411 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7412 | NO_STR | |
ddb5b488 | 7413 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7414 | "Between current address-family and vpn\n" |
7415 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7416 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7417 | { | |
7418 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7419 | struct prefix_rd prd; | |
7420 | int ret; | |
ddb5b488 | 7421 | afi_t afi; |
b9c7bc5a PZ |
7422 | int idx = 0; |
7423 | int yes = 1; | |
ddb5b488 | 7424 | |
b9c7bc5a | 7425 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7426 | yes = 0; |
b9c7bc5a PZ |
7427 | |
7428 | if (yes) { | |
7429 | ret = str2prefix_rd(rd_str, &prd); | |
7430 | if (!ret) { | |
7431 | vty_out(vty, "%% Malformed rd\n"); | |
7432 | return CMD_WARNING_CONFIG_FAILED; | |
7433 | } | |
ddb5b488 PZ |
7434 | } |
7435 | ||
0ca70ba5 | 7436 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7437 | if (afi == AFI_MAX) |
7438 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7439 | |
69b07479 DS |
7440 | /* |
7441 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7442 | */ | |
7443 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7444 | bgp_get_default(), bgp); | |
ddb5b488 | 7445 | |
69b07479 DS |
7446 | if (yes) { |
7447 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7448 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7449 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7450 | } else { | |
7451 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7452 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7453 | } |
7454 | ||
69b07479 DS |
7455 | /* post-change: re-export vpn routes */ |
7456 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7457 | bgp_get_default(), bgp); | |
7458 | ||
ddb5b488 PZ |
7459 | return CMD_SUCCESS; |
7460 | } | |
7461 | ||
b9c7bc5a PZ |
7462 | ALIAS (af_rd_vpn_export, |
7463 | af_no_rd_vpn_export_cmd, | |
7464 | "no rd vpn export", | |
ddb5b488 | 7465 | NO_STR |
b9c7bc5a PZ |
7466 | "Specify route distinguisher\n" |
7467 | "Between current address-family and vpn\n" | |
7468 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7469 | |
b9c7bc5a PZ |
7470 | DEFPY (af_label_vpn_export, |
7471 | af_label_vpn_export_cmd, | |
e70e9f8e | 7472 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7473 | NO_STR |
ddb5b488 | 7474 | "label value for VRF\n" |
b9c7bc5a PZ |
7475 | "Between current address-family and vpn\n" |
7476 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7477 | "Label Value <0-1048575>\n" |
7478 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7479 | { |
7480 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7481 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7482 | afi_t afi; |
b9c7bc5a PZ |
7483 | int idx = 0; |
7484 | int yes = 1; | |
7485 | ||
7486 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7487 | yes = 0; |
ddb5b488 | 7488 | |
21a16cc2 PZ |
7489 | /* If "no ...", squash trailing parameter */ |
7490 | if (!yes) | |
7491 | label_auto = NULL; | |
7492 | ||
e70e9f8e PZ |
7493 | if (yes) { |
7494 | if (!label_auto) | |
7495 | label = label_val; /* parser should force unsigned */ | |
7496 | } | |
ddb5b488 | 7497 | |
0ca70ba5 | 7498 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7499 | if (afi == AFI_MAX) |
7500 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7501 | |
e70e9f8e | 7502 | |
69b07479 DS |
7503 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7504 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7505 | /* no change */ | |
7506 | return CMD_SUCCESS; | |
e70e9f8e | 7507 | |
69b07479 DS |
7508 | /* |
7509 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7510 | */ | |
7511 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7512 | bgp_get_default(), bgp); | |
7513 | ||
7514 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7515 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7516 | ||
7517 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7518 | ||
7519 | /* | |
7520 | * label has previously been automatically | |
7521 | * assigned by labelpool: release it | |
7522 | * | |
7523 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7524 | * means the automatic assignment is in flight | |
7525 | * and therefore the labelpool callback must | |
7526 | * detect that the auto label is not needed. | |
7527 | */ | |
7528 | ||
7529 | bgp_lp_release(LP_TYPE_VRF, | |
7530 | &bgp->vpn_policy[afi], | |
7531 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7532 | } |
69b07479 DS |
7533 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7534 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7535 | } | |
ddb5b488 | 7536 | |
69b07479 DS |
7537 | bgp->vpn_policy[afi].tovpn_label = label; |
7538 | if (label_auto) { | |
7539 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7540 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7541 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7542 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7543 | } |
7544 | ||
69b07479 DS |
7545 | /* post-change: re-export vpn routes */ |
7546 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7547 | bgp_get_default(), bgp); | |
7548 | ||
ddb5b488 PZ |
7549 | return CMD_SUCCESS; |
7550 | } | |
7551 | ||
b9c7bc5a PZ |
7552 | ALIAS (af_label_vpn_export, |
7553 | af_no_label_vpn_export_cmd, | |
7554 | "no label vpn export", | |
7555 | NO_STR | |
7556 | "label value for VRF\n" | |
7557 | "Between current address-family and vpn\n" | |
7558 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7559 | |
b9c7bc5a PZ |
7560 | DEFPY (af_nexthop_vpn_export, |
7561 | af_nexthop_vpn_export_cmd, | |
8c85ca28 | 7562 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 7563 | NO_STR |
ddb5b488 | 7564 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7565 | "Between current address-family and vpn\n" |
7566 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7567 | "IPv4 prefix\n" |
7568 | "IPv6 prefix\n") | |
7569 | { | |
7570 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7571 | afi_t afi; |
ddb5b488 PZ |
7572 | struct prefix p; |
7573 | ||
8c85ca28 QY |
7574 | if (!no) { |
7575 | if (!nexthop_su) { | |
7576 | vty_out(vty, "%% Nexthop required\n"); | |
7577 | return CMD_WARNING_CONFIG_FAILED; | |
7578 | } | |
b9c7bc5a | 7579 | |
8c85ca28 | 7580 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
7581 | return CMD_WARNING_CONFIG_FAILED; |
7582 | } | |
ddb5b488 | 7583 | |
0ca70ba5 | 7584 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7585 | if (afi == AFI_MAX) |
7586 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7587 | |
69b07479 DS |
7588 | /* |
7589 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7590 | */ | |
7591 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7592 | bgp_get_default(), bgp); | |
ddb5b488 | 7593 | |
8c85ca28 | 7594 | if (!no) { |
69b07479 DS |
7595 | bgp->vpn_policy[afi].tovpn_nexthop = p; |
7596 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7597 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7598 | } else { | |
7599 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7600 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7601 | } |
7602 | ||
69b07479 DS |
7603 | /* post-change: re-export vpn routes */ |
7604 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7605 | bgp_get_default(), bgp); | |
7606 | ||
ddb5b488 PZ |
7607 | return CMD_SUCCESS; |
7608 | } | |
7609 | ||
b9c7bc5a | 7610 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7611 | { |
b9c7bc5a PZ |
7612 | if (!strcmp(dstr, "import")) { |
7613 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7614 | } else if (!strcmp(dstr, "export")) { | |
7615 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7616 | } else if (!strcmp(dstr, "both")) { | |
7617 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7618 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7619 | } else { | |
7620 | vty_out(vty, "%% direction parse error\n"); | |
7621 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7622 | } |
ddb5b488 PZ |
7623 | return CMD_SUCCESS; |
7624 | } | |
7625 | ||
b9c7bc5a PZ |
7626 | DEFPY (af_rt_vpn_imexport, |
7627 | af_rt_vpn_imexport_cmd, | |
7628 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7629 | NO_STR | |
7630 | "Specify route target list\n" | |
ddb5b488 | 7631 | "Specify route target list\n" |
b9c7bc5a PZ |
7632 | "Between current address-family and vpn\n" |
7633 | "For routes leaked from vpn to current address-family: match any\n" | |
7634 | "For routes leaked from current address-family to vpn: set\n" | |
7635 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7636 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7637 | { | |
7638 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7639 | int ret; | |
7640 | struct ecommunity *ecom = NULL; | |
7641 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7642 | vpn_policy_direction_t dir; |
7643 | afi_t afi; | |
7644 | int idx = 0; | |
b9c7bc5a | 7645 | int yes = 1; |
ddb5b488 | 7646 | |
b9c7bc5a | 7647 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7648 | yes = 0; |
b9c7bc5a | 7649 | |
0ca70ba5 | 7650 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7651 | if (afi == AFI_MAX) |
7652 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7653 | |
b9c7bc5a | 7654 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7655 | if (ret != CMD_SUCCESS) |
7656 | return ret; | |
7657 | ||
b9c7bc5a PZ |
7658 | if (yes) { |
7659 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7660 | vty_out(vty, "%% Missing RTLIST\n"); | |
7661 | return CMD_WARNING_CONFIG_FAILED; | |
7662 | } | |
7663 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7664 | if (ret != CMD_SUCCESS) { | |
7665 | return ret; | |
7666 | } | |
ddb5b488 PZ |
7667 | } |
7668 | ||
69b07479 DS |
7669 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7670 | if (!dodir[dir]) | |
ddb5b488 | 7671 | continue; |
ddb5b488 | 7672 | |
69b07479 | 7673 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7674 | |
69b07479 DS |
7675 | if (yes) { |
7676 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7677 | ecommunity_free( | |
7678 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7679 | bgp->vpn_policy[afi].rtlist[dir] = | |
7680 | ecommunity_dup(ecom); | |
7681 | } else { | |
7682 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7683 | ecommunity_free( | |
7684 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7685 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7686 | } |
69b07479 DS |
7687 | |
7688 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7689 | } |
69b07479 | 7690 | |
d555f3e9 PZ |
7691 | if (ecom) |
7692 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7693 | |
7694 | return CMD_SUCCESS; | |
7695 | } | |
7696 | ||
b9c7bc5a PZ |
7697 | ALIAS (af_rt_vpn_imexport, |
7698 | af_no_rt_vpn_imexport_cmd, | |
7699 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7700 | NO_STR |
7701 | "Specify route target list\n" | |
b9c7bc5a PZ |
7702 | "Specify route target list\n" |
7703 | "Between current address-family and vpn\n" | |
7704 | "For routes leaked from vpn to current address-family\n" | |
7705 | "For routes leaked from current address-family to vpn\n" | |
7706 | "both import and export\n") | |
7707 | ||
7708 | DEFPY (af_route_map_vpn_imexport, | |
7709 | af_route_map_vpn_imexport_cmd, | |
7710 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7711 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7712 | NO_STR | |
ddb5b488 | 7713 | "Specify route map\n" |
b9c7bc5a PZ |
7714 | "Between current address-family and vpn\n" |
7715 | "For routes leaked from vpn to current address-family\n" | |
7716 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7717 | "name of route-map\n") |
7718 | { | |
7719 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7720 | int ret; | |
7721 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7722 | vpn_policy_direction_t dir; |
7723 | afi_t afi; | |
ddb5b488 | 7724 | int idx = 0; |
b9c7bc5a | 7725 | int yes = 1; |
ddb5b488 | 7726 | |
b9c7bc5a | 7727 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7728 | yes = 0; |
b9c7bc5a | 7729 | |
0ca70ba5 | 7730 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7731 | if (afi == AFI_MAX) |
7732 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7733 | |
b9c7bc5a | 7734 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7735 | if (ret != CMD_SUCCESS) |
7736 | return ret; | |
7737 | ||
69b07479 DS |
7738 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7739 | if (!dodir[dir]) | |
ddb5b488 | 7740 | continue; |
ddb5b488 | 7741 | |
69b07479 | 7742 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7743 | |
69b07479 DS |
7744 | if (yes) { |
7745 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7746 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7747 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7748 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7749 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7750 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7751 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7752 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7753 | return CMD_SUCCESS; | |
7754 | } else { | |
7755 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7756 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7757 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7758 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7759 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7760 | } |
69b07479 DS |
7761 | |
7762 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7763 | } |
7764 | ||
7765 | return CMD_SUCCESS; | |
7766 | } | |
7767 | ||
b9c7bc5a PZ |
7768 | ALIAS (af_route_map_vpn_imexport, |
7769 | af_no_route_map_vpn_imexport_cmd, | |
7770 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7771 | NO_STR |
7772 | "Specify route map\n" | |
b9c7bc5a PZ |
7773 | "Between current address-family and vpn\n" |
7774 | "For routes leaked from vpn to current address-family\n" | |
7775 | "For routes leaked from current address-family to vpn\n") | |
7776 | ||
bb4f6190 | 7777 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 7778 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
7779 | "Import routes from another VRF\n" |
7780 | "Vrf routes being filtered\n" | |
7781 | "Specify route map\n" | |
7782 | "name of route-map\n") | |
7783 | { | |
7784 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7785 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7786 | afi_t afi; | |
bb4f6190 DS |
7787 | struct bgp *bgp_default; |
7788 | ||
0ca70ba5 | 7789 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7790 | if (afi == AFI_MAX) |
7791 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7792 | |
7793 | bgp_default = bgp_get_default(); | |
7794 | if (!bgp_default) { | |
7795 | int32_t ret; | |
7796 | as_t as = bgp->as; | |
7797 | ||
7798 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7799 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7800 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7801 | |
7802 | if (ret) { | |
7803 | vty_out(vty, | |
7804 | "VRF default is not configured as a bgp instance\n"); | |
7805 | return CMD_WARNING; | |
7806 | } | |
7807 | } | |
7808 | ||
69b07479 | 7809 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7810 | |
ae6a6fb4 DS |
7811 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
7812 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7813 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7814 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7815 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7816 | bgp->vpn_policy[afi].rmap[dir] = | |
7817 | route_map_lookup_warn_noexist(vty, rmap_str); | |
7818 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
7819 | return CMD_SUCCESS; | |
7820 | ||
7821 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7822 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 7823 | |
69b07479 DS |
7824 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7825 | ||
bb4f6190 DS |
7826 | return CMD_SUCCESS; |
7827 | } | |
7828 | ||
ae6a6fb4 DS |
7829 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
7830 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
7831 | NO_STR |
7832 | "Import routes from another VRF\n" | |
7833 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
7834 | "Specify route map\n" |
7835 | "name of route-map\n") | |
7836 | { | |
7837 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7838 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7839 | afi_t afi; | |
7840 | ||
7841 | afi = vpn_policy_getafi(vty, bgp, true); | |
7842 | if (afi == AFI_MAX) | |
7843 | return CMD_WARNING_CONFIG_FAILED; | |
7844 | ||
7845 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7846 | ||
7847 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7848 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7849 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7850 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7851 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
7852 | ||
7853 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
7854 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7855 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
7856 | ||
7857 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
7858 | ||
7859 | return CMD_SUCCESS; | |
7860 | } | |
bb4f6190 | 7861 | |
4d1b335c DA |
7862 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7863 | "[no] import vrf VIEWVRFNAME$import_name", | |
7864 | NO_STR | |
7865 | "Import routes from another VRF\n" | |
7866 | "VRF to import from\n" | |
7867 | "The name of the VRF\n") | |
12a844a5 DS |
7868 | { |
7869 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7870 | struct listnode *node; | |
79ef8664 DS |
7871 | struct bgp *vrf_bgp, *bgp_default; |
7872 | int32_t ret = 0; | |
7873 | as_t as = bgp->as; | |
12a844a5 DS |
7874 | bool remove = false; |
7875 | int32_t idx = 0; | |
7876 | char *vname; | |
a8dadcf6 | 7877 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7878 | safi_t safi; |
7879 | afi_t afi; | |
7880 | ||
867f0cca | 7881 | if (import_name == NULL) { |
7882 | vty_out(vty, "%% Missing import name\n"); | |
7883 | return CMD_WARNING; | |
7884 | } | |
7885 | ||
ae6a6fb4 DS |
7886 | if (strcmp(import_name, "route-map") == 0) { |
7887 | vty_out(vty, "%% Must include route-map name\n"); | |
7888 | return CMD_WARNING; | |
7889 | } | |
7890 | ||
12a844a5 DS |
7891 | if (argv_find(argv, argc, "no", &idx)) |
7892 | remove = true; | |
7893 | ||
0ca70ba5 DS |
7894 | afi = vpn_policy_getafi(vty, bgp, true); |
7895 | if (afi == AFI_MAX) | |
7896 | return CMD_WARNING_CONFIG_FAILED; | |
7897 | ||
12a844a5 DS |
7898 | safi = bgp_node_safi(vty); |
7899 | ||
25679caa | 7900 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7901 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7902 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7903 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7904 | remove ? "unimport" : "import", import_name); | |
7905 | return CMD_WARNING; | |
7906 | } | |
7907 | ||
79ef8664 DS |
7908 | bgp_default = bgp_get_default(); |
7909 | if (!bgp_default) { | |
7910 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7911 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7912 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7913 | |
7914 | if (ret) { | |
7915 | vty_out(vty, | |
7916 | "VRF default is not configured as a bgp instance\n"); | |
7917 | return CMD_WARNING; | |
7918 | } | |
7919 | } | |
7920 | ||
12a844a5 DS |
7921 | vrf_bgp = bgp_lookup_by_name(import_name); |
7922 | if (!vrf_bgp) { | |
5742e42b | 7923 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7924 | vrf_bgp = bgp_default; |
7925 | else | |
0fb8d6e6 | 7926 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7927 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7928 | |
6e2c7fe6 | 7929 | if (ret) { |
020a3f60 DS |
7930 | vty_out(vty, |
7931 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7932 | import_name); |
7933 | return CMD_WARNING; | |
7934 | } | |
12a844a5 DS |
7935 | } |
7936 | ||
12a844a5 | 7937 | if (remove) { |
44338987 | 7938 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7939 | } else { |
44338987 | 7940 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7941 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7942 | vname)) { | |
7943 | if (strcmp(vname, import_name) == 0) | |
7944 | return CMD_WARNING; | |
7945 | } | |
7946 | ||
44338987 | 7947 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7948 | } |
7949 | ||
7950 | return CMD_SUCCESS; | |
7951 | } | |
7952 | ||
b9c7bc5a PZ |
7953 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7954 | DEFPY (bgp_imexport_vpn, | |
7955 | bgp_imexport_vpn_cmd, | |
7956 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7957 | NO_STR |
7958 | "Import routes to this address-family\n" | |
7959 | "Export routes from this address-family\n" | |
7960 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7961 | { |
7962 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7963 | int previous_state; |
ddb5b488 | 7964 | afi_t afi; |
b9c7bc5a | 7965 | safi_t safi; |
ddb5b488 | 7966 | int idx = 0; |
b9c7bc5a PZ |
7967 | int yes = 1; |
7968 | int flag; | |
7969 | vpn_policy_direction_t dir; | |
ddb5b488 | 7970 | |
b9c7bc5a | 7971 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7972 | yes = 0; |
ddb5b488 | 7973 | |
b9c7bc5a PZ |
7974 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7975 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7976 | |
b9c7bc5a PZ |
7977 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7978 | return CMD_WARNING_CONFIG_FAILED; | |
7979 | } | |
ddb5b488 | 7980 | |
b9c7bc5a PZ |
7981 | afi = bgp_node_afi(vty); |
7982 | safi = bgp_node_safi(vty); | |
7983 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7984 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7985 | return CMD_WARNING_CONFIG_FAILED; | |
7986 | } | |
ddb5b488 | 7987 | |
b9c7bc5a PZ |
7988 | if (!strcmp(direction_str, "import")) { |
7989 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7990 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7991 | } else if (!strcmp(direction_str, "export")) { | |
7992 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7993 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7994 | } else { | |
7995 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7996 | return CMD_WARNING_CONFIG_FAILED; | |
7997 | } | |
7998 | ||
7999 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 8000 | |
b9c7bc5a PZ |
8001 | if (yes) { |
8002 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
8003 | if (!previous_state) { | |
8004 | /* trigger export current vrf */ | |
ddb5b488 PZ |
8005 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8006 | } | |
b9c7bc5a PZ |
8007 | } else { |
8008 | if (previous_state) { | |
8009 | /* trigger un-export current vrf */ | |
8010 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8011 | } | |
8012 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
8013 | } |
8014 | ||
8015 | return CMD_SUCCESS; | |
8016 | } | |
8017 | ||
301ad80a PG |
8018 | DEFPY (af_routetarget_import, |
8019 | af_routetarget_import_cmd, | |
8020 | "[no] <rt|route-target> redirect import RTLIST...", | |
8021 | NO_STR | |
8022 | "Specify route target list\n" | |
8023 | "Specify route target list\n" | |
8024 | "Flow-spec redirect type route target\n" | |
8025 | "Import routes to this address-family\n" | |
8026 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
8027 | { | |
8028 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8029 | int ret; | |
8030 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
8031 | afi_t afi; |
8032 | int idx = 0; | |
8033 | int yes = 1; | |
8034 | ||
8035 | if (argv_find(argv, argc, "no", &idx)) | |
8036 | yes = 0; | |
8037 | ||
0ca70ba5 | 8038 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8039 | if (afi == AFI_MAX) |
8040 | return CMD_WARNING_CONFIG_FAILED; | |
8041 | ||
301ad80a PG |
8042 | if (yes) { |
8043 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8044 | vty_out(vty, "%% Missing RTLIST\n"); | |
8045 | return CMD_WARNING_CONFIG_FAILED; | |
8046 | } | |
8047 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
8048 | if (ret != CMD_SUCCESS) | |
8049 | return ret; | |
8050 | } | |
69b07479 DS |
8051 | |
8052 | if (yes) { | |
8053 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8054 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8055 | .import_redirect_rtlist); |
69b07479 DS |
8056 | bgp->vpn_policy[afi].import_redirect_rtlist = |
8057 | ecommunity_dup(ecom); | |
8058 | } else { | |
8059 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8060 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8061 | .import_redirect_rtlist); |
69b07479 | 8062 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 8063 | } |
69b07479 | 8064 | |
301ad80a PG |
8065 | if (ecom) |
8066 | ecommunity_free(&ecom); | |
8067 | ||
8068 | return CMD_SUCCESS; | |
8069 | } | |
8070 | ||
505e5056 | 8071 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 8072 | address_family_ipv4_safi_cmd, |
8073 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
8074 | "Enter Address Family command mode\n" | |
8075 | "Address Family\n" | |
8076 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 8077 | { |
f51bae9c | 8078 | |
d62a17ae | 8079 | if (argc == 3) { |
2131d5cf | 8080 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8081 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
8082 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
8083 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8084 | && safi != SAFI_EVPN) { |
31947174 MK |
8085 | vty_out(vty, |
8086 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8087 | return CMD_WARNING_CONFIG_FAILED; |
8088 | } | |
d62a17ae | 8089 | vty->node = bgp_node_type(AFI_IP, safi); |
8090 | } else | |
8091 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 8092 | |
d62a17ae | 8093 | return CMD_SUCCESS; |
718e3744 | 8094 | } |
8095 | ||
505e5056 | 8096 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 8097 | address_family_ipv6_safi_cmd, |
8098 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
8099 | "Enter Address Family command mode\n" | |
8100 | "Address Family\n" | |
8101 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 8102 | { |
d62a17ae | 8103 | if (argc == 3) { |
2131d5cf | 8104 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8105 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
8106 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
8107 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8108 | && safi != SAFI_EVPN) { |
31947174 MK |
8109 | vty_out(vty, |
8110 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8111 | return CMD_WARNING_CONFIG_FAILED; |
8112 | } | |
d62a17ae | 8113 | vty->node = bgp_node_type(AFI_IP6, safi); |
8114 | } else | |
8115 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 8116 | |
d62a17ae | 8117 | return CMD_SUCCESS; |
25ffbdc1 | 8118 | } |
718e3744 | 8119 | |
d6902373 | 8120 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 8121 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 8122 | address_family_vpnv4_cmd, |
8334fd5a | 8123 | "address-family vpnv4 [unicast]", |
718e3744 | 8124 | "Enter Address Family command mode\n" |
8c3deaae | 8125 | "Address Family\n" |
3a2d747c | 8126 | "Address Family modifier\n") |
718e3744 | 8127 | { |
d62a17ae | 8128 | vty->node = BGP_VPNV4_NODE; |
8129 | return CMD_SUCCESS; | |
718e3744 | 8130 | } |
8131 | ||
505e5056 | 8132 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 8133 | address_family_vpnv6_cmd, |
8334fd5a | 8134 | "address-family vpnv6 [unicast]", |
8ecd3266 | 8135 | "Enter Address Family command mode\n" |
8c3deaae | 8136 | "Address Family\n" |
3a2d747c | 8137 | "Address Family modifier\n") |
8ecd3266 | 8138 | { |
d62a17ae | 8139 | vty->node = BGP_VPNV6_NODE; |
8140 | return CMD_SUCCESS; | |
8ecd3266 | 8141 | } |
64e4a6c5 | 8142 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 8143 | |
505e5056 | 8144 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 8145 | address_family_evpn_cmd, |
7111c1a0 | 8146 | "address-family l2vpn evpn", |
4e0b7b6d | 8147 | "Enter Address Family command mode\n" |
7111c1a0 QY |
8148 | "Address Family\n" |
8149 | "Address Family modifier\n") | |
4e0b7b6d | 8150 | { |
2131d5cf | 8151 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8152 | vty->node = BGP_EVPN_NODE; |
8153 | return CMD_SUCCESS; | |
4e0b7b6d PG |
8154 | } |
8155 | ||
505e5056 | 8156 | DEFUN_NOSH (exit_address_family, |
718e3744 | 8157 | exit_address_family_cmd, |
8158 | "exit-address-family", | |
8159 | "Exit from Address Family configuration mode\n") | |
8160 | { | |
d62a17ae | 8161 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
8162 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
8163 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
8164 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
8165 | || vty->node == BGP_EVPN_NODE |
8166 | || vty->node == BGP_FLOWSPECV4_NODE | |
8167 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 8168 | vty->node = BGP_NODE; |
8169 | return CMD_SUCCESS; | |
718e3744 | 8170 | } |
6b0655a2 | 8171 | |
8ad7271d | 8172 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 8173 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
8174 | const char *ip_str, afi_t afi, safi_t safi, | |
8175 | struct prefix_rd *prd) | |
8176 | { | |
8177 | int ret; | |
8178 | struct prefix match; | |
9bcb3eef DS |
8179 | struct bgp_dest *dest; |
8180 | struct bgp_dest *rm; | |
d62a17ae | 8181 | struct bgp *bgp; |
8182 | struct bgp_table *table; | |
8183 | struct bgp_table *rib; | |
8184 | ||
8185 | /* BGP structure lookup. */ | |
8186 | if (view_name) { | |
8187 | bgp = bgp_lookup_by_name(view_name); | |
8188 | if (bgp == NULL) { | |
8189 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
8190 | view_name); | |
8191 | return CMD_WARNING; | |
8192 | } | |
8193 | } else { | |
8194 | bgp = bgp_get_default(); | |
8195 | if (bgp == NULL) { | |
8196 | vty_out(vty, "%% No BGP process is configured\n"); | |
8197 | return CMD_WARNING; | |
8198 | } | |
8199 | } | |
8200 | ||
8201 | /* Check IP address argument. */ | |
8202 | ret = str2prefix(ip_str, &match); | |
8203 | if (!ret) { | |
8204 | vty_out(vty, "%% address is malformed\n"); | |
8205 | return CMD_WARNING; | |
8206 | } | |
8207 | ||
8208 | match.family = afi2family(afi); | |
8209 | rib = bgp->rib[afi][safi]; | |
8210 | ||
8211 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
8212 | for (dest = bgp_table_top(rib); dest; |
8213 | dest = bgp_route_next(dest)) { | |
8214 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8215 | |
9bcb3eef | 8216 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 8217 | continue; |
8218 | ||
9bcb3eef | 8219 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
8220 | if (table == NULL) |
8221 | continue; | |
8222 | ||
8223 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
8224 | const struct prefix *rm_p = | |
9bcb3eef | 8225 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
8226 | |
8227 | if (rm_p->prefixlen == match.prefixlen) { | |
8228 | SET_FLAG(rm->flags, | |
8229 | BGP_NODE_USER_CLEAR); | |
8230 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 8231 | } |
9bcb3eef | 8232 | bgp_dest_unlock_node(rm); |
d62a17ae | 8233 | } |
8234 | } | |
8235 | } else { | |
9bcb3eef DS |
8236 | if ((dest = bgp_node_match(rib, &match)) != NULL) { |
8237 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8238 | |
9bcb3eef DS |
8239 | if (dest_p->prefixlen == match.prefixlen) { |
8240 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
8241 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 8242 | } |
9bcb3eef | 8243 | bgp_dest_unlock_node(dest); |
d62a17ae | 8244 | } |
8245 | } | |
8246 | ||
8247 | return CMD_SUCCESS; | |
8ad7271d DS |
8248 | } |
8249 | ||
b09b5ae0 | 8250 | /* one clear bgp command to rule them all */ |
718e3744 | 8251 | DEFUN (clear_ip_bgp_all, |
8252 | clear_ip_bgp_all_cmd, | |
453c92f6 | 8253 | "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 | 8254 | CLEAR_STR |
8255 | IP_STR | |
8256 | BGP_STR | |
838758ac | 8257 | BGP_INSTANCE_HELP_STR |
510afcd6 | 8258 | BGP_AFI_HELP_STR |
fd5e7b70 | 8259 | "Address Family\n" |
510afcd6 | 8260 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8261 | "Address Family modifier\n" |
b09b5ae0 | 8262 | "Clear all peers\n" |
453c92f6 | 8263 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8264 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8265 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8266 | "Clear peers with the AS number\n" |
8267 | "Clear all external peers\n" | |
718e3744 | 8268 | "Clear all members of peer-group\n" |
b09b5ae0 | 8269 | "BGP peer-group name\n" |
b09b5ae0 DW |
8270 | BGP_SOFT_STR |
8271 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8272 | BGP_SOFT_OUT_STR |
8273 | BGP_SOFT_IN_STR | |
8274 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8275 | BGP_SOFT_OUT_STR) |
718e3744 | 8276 | { |
d62a17ae | 8277 | char *vrf = NULL; |
8278 | ||
dc912615 DS |
8279 | afi_t afi = AFI_UNSPEC; |
8280 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8281 | enum clear_sort clr_sort = clear_peer; |
8282 | enum bgp_clear_type clr_type; | |
8283 | char *clr_arg = NULL; | |
8284 | ||
8285 | int idx = 0; | |
8286 | ||
8287 | /* clear [ip] bgp */ | |
8288 | if (argv_find(argv, argc, "ip", &idx)) | |
8289 | afi = AFI_IP; | |
8290 | ||
9a8bdf1c PG |
8291 | /* [<vrf> VIEWVRFNAME] */ |
8292 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8293 | vrf = argv[idx + 1]->arg; | |
8294 | idx += 2; | |
8295 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8296 | vrf = NULL; | |
8297 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8298 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8299 | vrf = argv[idx + 1]->arg; |
8300 | idx += 2; | |
8301 | } | |
d62a17ae | 8302 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8303 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8304 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8305 | ||
d7b9898c | 8306 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8307 | if (argv_find(argv, argc, "*", &idx)) { |
8308 | clr_sort = clear_all; | |
8309 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8310 | clr_sort = clear_peer; | |
8311 | clr_arg = argv[idx]->arg; | |
8312 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8313 | clr_sort = clear_peer; | |
8314 | clr_arg = argv[idx]->arg; | |
8315 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8316 | clr_sort = clear_group; | |
8317 | idx++; | |
8318 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8319 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8320 | clr_sort = clear_peer; |
8321 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8322 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8323 | clr_sort = clear_peer; | |
8324 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8325 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8326 | clr_sort = clear_as; | |
8327 | clr_arg = argv[idx]->arg; | |
8328 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8329 | clr_sort = clear_external; | |
8330 | } | |
8331 | ||
8332 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8333 | if (argv_find(argv, argc, "soft", &idx)) { | |
8334 | if (argv_find(argv, argc, "in", &idx) | |
8335 | || argv_find(argv, argc, "out", &idx)) | |
8336 | clr_type = strmatch(argv[idx]->text, "in") | |
8337 | ? BGP_CLEAR_SOFT_IN | |
8338 | : BGP_CLEAR_SOFT_OUT; | |
8339 | else | |
8340 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8341 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8342 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8343 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8344 | : BGP_CLEAR_SOFT_IN; | |
8345 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8346 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8347 | } else | |
8348 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8349 | ||
8350 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 8351 | } |
01080f7c | 8352 | |
8ad7271d DS |
8353 | DEFUN (clear_ip_bgp_prefix, |
8354 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8355 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8356 | CLEAR_STR |
8357 | IP_STR | |
8358 | BGP_STR | |
838758ac | 8359 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8360 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8361 | "IPv4 prefix\n") |
8ad7271d | 8362 | { |
d62a17ae | 8363 | char *vrf = NULL; |
8364 | char *prefix = NULL; | |
8ad7271d | 8365 | |
d62a17ae | 8366 | int idx = 0; |
01080f7c | 8367 | |
d62a17ae | 8368 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8369 | if (argv_find(argv, argc, "vrf", &idx)) { |
8370 | vrf = argv[idx + 1]->arg; | |
8371 | idx += 2; | |
8372 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8373 | vrf = NULL; | |
8374 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8375 | /* [<view> VIEWVRFNAME] */ | |
8376 | vrf = argv[idx + 1]->arg; | |
8377 | idx += 2; | |
8378 | } | |
0c7b1b01 | 8379 | |
d62a17ae | 8380 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8381 | |
d62a17ae | 8382 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8383 | } |
8ad7271d | 8384 | |
b09b5ae0 DW |
8385 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8386 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8387 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8388 | CLEAR_STR |
3a2d747c | 8389 | IP_STR |
718e3744 | 8390 | BGP_STR |
8c3deaae | 8391 | "Address Family\n" |
46f296b4 | 8392 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8393 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8394 | "IPv6 prefix\n") |
718e3744 | 8395 | { |
9b475e76 PG |
8396 | int idx_safi = 0; |
8397 | int idx_ipv6_prefix = 0; | |
8398 | safi_t safi = SAFI_UNICAST; | |
8399 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8400 | argv[idx_ipv6_prefix]->arg : NULL; | |
8401 | ||
8402 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8403 | return bgp_clear_prefix( |
9b475e76 PG |
8404 | vty, NULL, prefix, AFI_IP6, |
8405 | safi, NULL); | |
838758ac | 8406 | } |
01080f7c | 8407 | |
b09b5ae0 DW |
8408 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8409 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8410 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8411 | CLEAR_STR |
3a2d747c | 8412 | IP_STR |
718e3744 | 8413 | BGP_STR |
838758ac | 8414 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8415 | "Address Family\n" |
46f296b4 | 8416 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8417 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8418 | "IPv6 prefix\n") |
718e3744 | 8419 | { |
9b475e76 | 8420 | int idx_safi = 0; |
9a8bdf1c | 8421 | int idx_vrfview = 0; |
9b475e76 PG |
8422 | int idx_ipv6_prefix = 0; |
8423 | safi_t safi = SAFI_UNICAST; | |
8424 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8425 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8426 | char *vrfview = NULL; |
9b475e76 | 8427 | |
9a8bdf1c PG |
8428 | /* [<view|vrf> VIEWVRFNAME] */ |
8429 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8430 | vrfview = argv[idx_vrfview + 1]->arg; | |
8431 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8432 | vrfview = NULL; | |
8433 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8434 | /* [<view> VIEWVRFNAME] */ | |
8435 | vrfview = argv[idx_vrfview + 1]->arg; | |
8436 | } | |
9b475e76 PG |
8437 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8438 | ||
d62a17ae | 8439 | return bgp_clear_prefix( |
9b475e76 PG |
8440 | vty, vrfview, prefix, |
8441 | AFI_IP6, safi, NULL); | |
718e3744 | 8442 | } |
8443 | ||
b09b5ae0 DW |
8444 | DEFUN (show_bgp_views, |
8445 | show_bgp_views_cmd, | |
d6e3c605 | 8446 | "show [ip] bgp views", |
b09b5ae0 | 8447 | SHOW_STR |
d6e3c605 | 8448 | IP_STR |
01080f7c | 8449 | BGP_STR |
b09b5ae0 | 8450 | "Show the defined BGP views\n") |
01080f7c | 8451 | { |
d62a17ae | 8452 | struct list *inst = bm->bgp; |
8453 | struct listnode *node; | |
8454 | struct bgp *bgp; | |
01080f7c | 8455 | |
d62a17ae | 8456 | vty_out(vty, "Defined BGP views:\n"); |
8457 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8458 | /* Skip VRFs. */ | |
8459 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8460 | continue; | |
8461 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8462 | bgp->as); | |
8463 | } | |
e52702f2 | 8464 | |
d62a17ae | 8465 | return CMD_SUCCESS; |
e0081f70 ML |
8466 | } |
8467 | ||
8386ac43 | 8468 | DEFUN (show_bgp_vrfs, |
8469 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8470 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8471 | SHOW_STR |
d6e3c605 | 8472 | IP_STR |
8386ac43 | 8473 | BGP_STR |
8474 | "Show BGP VRFs\n" | |
9973d184 | 8475 | JSON_STR) |
8386ac43 | 8476 | { |
fe1dc5a3 | 8477 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8478 | struct list *inst = bm->bgp; |
8479 | struct listnode *node; | |
8480 | struct bgp *bgp; | |
9f049418 | 8481 | bool uj = use_json(argc, argv); |
d62a17ae | 8482 | json_object *json = NULL; |
8483 | json_object *json_vrfs = NULL; | |
8484 | int count = 0; | |
d62a17ae | 8485 | |
d62a17ae | 8486 | if (uj) { |
8487 | json = json_object_new_object(); | |
8488 | json_vrfs = json_object_new_object(); | |
8489 | } | |
8490 | ||
8491 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8492 | const char *name, *type; | |
8493 | struct peer *peer; | |
7fe96307 | 8494 | struct listnode *node2, *nnode2; |
d62a17ae | 8495 | int peers_cfg, peers_estb; |
8496 | json_object *json_vrf = NULL; | |
d62a17ae | 8497 | |
8498 | /* Skip Views. */ | |
8499 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8500 | continue; | |
8501 | ||
8502 | count++; | |
efb4077a | 8503 | if (!uj && count == 1) { |
fe1dc5a3 | 8504 | vty_out(vty, |
efb4077a | 8505 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8506 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8507 | "#PeersEstb", "Name"); |
8508 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8509 | "L3-VNI", "RouterMAC", "Interface"); | |
8510 | } | |
d62a17ae | 8511 | |
8512 | peers_cfg = peers_estb = 0; | |
8513 | if (uj) | |
8514 | json_vrf = json_object_new_object(); | |
8515 | ||
8516 | ||
7fe96307 | 8517 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8518 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8519 | continue; | |
8520 | peers_cfg++; | |
8521 | if (peer->status == Established) | |
8522 | peers_estb++; | |
8523 | } | |
8524 | ||
8525 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8526 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8527 | type = "DFLT"; |
8528 | } else { | |
8529 | name = bgp->name; | |
8530 | type = "VRF"; | |
8531 | } | |
8532 | ||
a8bf7d9c | 8533 | |
d62a17ae | 8534 | if (uj) { |
a4d82a8a PZ |
8535 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8536 | ? -1 | |
8537 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8538 | json_object_string_add(json_vrf, "type", type); |
8539 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8540 | json_object_string_add(json_vrf, "routerId", | |
8541 | inet_ntoa(bgp->router_id)); | |
8542 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8543 | peers_cfg); | |
8544 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8545 | peers_estb); | |
8546 | ||
fe1dc5a3 | 8547 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8548 | json_object_string_add( |
8549 | json_vrf, "rmac", | |
8550 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8551 | json_object_string_add(json_vrf, "interface", |
8552 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8553 | bgp->vrf_id)); | |
d62a17ae | 8554 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8555 | } else { |
fe1dc5a3 | 8556 | vty_out(vty, |
efb4077a | 8557 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8558 | type, |
8559 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8560 | : (int)bgp->vrf_id, | |
8561 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8562 | peers_estb, name); |
8563 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8564 | bgp->l3vni, | |
8565 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8566 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8567 | bgp->vrf_id)); | |
8568 | } | |
d62a17ae | 8569 | } |
8570 | ||
8571 | if (uj) { | |
8572 | json_object_object_add(json, "vrfs", json_vrfs); | |
8573 | ||
8574 | json_object_int_add(json, "totalVrfs", count); | |
8575 | ||
996c9314 LB |
8576 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8577 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8578 | json_object_free(json); |
8579 | } else { | |
8580 | if (count) | |
8581 | vty_out(vty, | |
8582 | "\nTotal number of VRFs (including default): %d\n", | |
8583 | count); | |
8584 | } | |
8585 | ||
8586 | return CMD_SUCCESS; | |
8386ac43 | 8587 | } |
8588 | ||
48ecf8f5 DS |
8589 | DEFUN (show_bgp_mac_hash, |
8590 | show_bgp_mac_hash_cmd, | |
8591 | "show bgp mac hash", | |
8592 | SHOW_STR | |
8593 | BGP_STR | |
8594 | "Mac Address\n" | |
8595 | "Mac Address database\n") | |
8596 | { | |
8597 | bgp_mac_dump_table(vty); | |
8598 | ||
8599 | return CMD_SUCCESS; | |
8600 | } | |
acf71666 | 8601 | |
e3b78da8 | 8602 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8603 | { |
0291c246 | 8604 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8605 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8606 | |
60466a63 | 8607 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8608 | tip->refcnt); |
8609 | } | |
8610 | ||
8611 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8612 | { | |
8613 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8614 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8615 | |
8616 | vty_out(vty, "Tunnel-ip database:\n"); | |
8617 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8618 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8619 | vty); |
8620 | } | |
8621 | ||
15c81ca4 DS |
8622 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8623 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8624 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8625 | "martian next-hops\n" |
8626 | "martian next-hop database\n") | |
acf71666 | 8627 | { |
0291c246 | 8628 | struct bgp *bgp = NULL; |
15c81ca4 | 8629 | int idx = 0; |
9a8bdf1c PG |
8630 | char *name = NULL; |
8631 | ||
8632 | /* [<vrf> VIEWVRFNAME] */ | |
8633 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8634 | name = argv[idx + 1]->arg; | |
8635 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8636 | name = NULL; | |
8637 | } else if (argv_find(argv, argc, "view", &idx)) | |
8638 | /* [<view> VIEWVRFNAME] */ | |
8639 | name = argv[idx + 1]->arg; | |
8640 | if (name) | |
8641 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8642 | else |
8643 | bgp = bgp_get_default(); | |
acf71666 | 8644 | |
acf71666 MK |
8645 | if (!bgp) { |
8646 | vty_out(vty, "%% No BGP process is configured\n"); | |
8647 | return CMD_WARNING; | |
8648 | } | |
8649 | bgp_show_martian_nexthops(vty, bgp); | |
8650 | ||
8651 | return CMD_SUCCESS; | |
8652 | } | |
8653 | ||
f412b39a | 8654 | DEFUN (show_bgp_memory, |
4bf6a362 | 8655 | show_bgp_memory_cmd, |
7fa12b13 | 8656 | "show [ip] bgp memory", |
4bf6a362 | 8657 | SHOW_STR |
3a2d747c | 8658 | IP_STR |
4bf6a362 PJ |
8659 | BGP_STR |
8660 | "Global BGP memory statistics\n") | |
8661 | { | |
d62a17ae | 8662 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8663 | unsigned long count; | |
8664 | ||
8665 | /* RIB related usage stats */ | |
8666 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8667 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8668 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 8669 | count * sizeof(struct bgp_dest))); |
d62a17ae | 8670 | |
8671 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8672 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8673 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8674 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8675 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8676 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8677 | count, | |
4b7e6066 DS |
8678 | mtype_memstr( |
8679 | memstrbuf, sizeof(memstrbuf), | |
8680 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8681 | |
8682 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8683 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8684 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8685 | count * sizeof(struct bgp_static))); | |
8686 | ||
8687 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8688 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8689 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8690 | count * sizeof(struct bpacket))); | |
8691 | ||
8692 | /* Adj-In/Out */ | |
8693 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8694 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8695 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8696 | count * sizeof(struct bgp_adj_in))); | |
8697 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8698 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8699 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8700 | count * sizeof(struct bgp_adj_out))); | |
8701 | ||
8702 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8703 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8704 | count, | |
8705 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8706 | count * sizeof(struct bgp_nexthop_cache))); | |
8707 | ||
8708 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8709 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8710 | count, | |
8711 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8712 | count * sizeof(struct bgp_damp_info))); | |
8713 | ||
8714 | /* Attributes */ | |
8715 | count = attr_count(); | |
8716 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8717 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8718 | count * sizeof(struct attr))); | |
8719 | ||
8720 | if ((count = attr_unknown_count())) | |
8721 | vty_out(vty, "%ld unknown attributes\n", count); | |
8722 | ||
8723 | /* AS_PATH attributes */ | |
8724 | count = aspath_count(); | |
8725 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8726 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8727 | count * sizeof(struct aspath))); | |
8728 | ||
8729 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8730 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8731 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8732 | count * sizeof(struct assegment))); | |
8733 | ||
8734 | /* Other attributes */ | |
8735 | if ((count = community_count())) | |
8736 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8737 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8738 | count * sizeof(struct community))); | |
d62a17ae | 8739 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8740 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8741 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8742 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8743 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8744 | vty_out(vty, | |
8745 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8746 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8747 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8748 | |
8749 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8750 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8751 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8752 | count * sizeof(struct cluster_list))); | |
8753 | ||
8754 | /* Peer related usage */ | |
8755 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8756 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8757 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8758 | count * sizeof(struct peer))); | |
8759 | ||
8760 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8761 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8762 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8763 | count * sizeof(struct peer_group))); | |
8764 | ||
8765 | /* Other */ | |
d62a17ae | 8766 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8767 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8768 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8769 | count * sizeof(regex_t))); | |
d62a17ae | 8770 | return CMD_SUCCESS; |
4bf6a362 | 8771 | } |
fee0f4c6 | 8772 | |
57a9c8a8 DS |
8773 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8774 | { | |
8775 | json_object *bestpath = json_object_new_object(); | |
8776 | ||
892fedb6 | 8777 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
8778 | json_object_string_add(bestpath, "asPath", "ignore"); |
8779 | ||
892fedb6 | 8780 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
8781 | json_object_string_add(bestpath, "asPath", "confed"); |
8782 | ||
892fedb6 DA |
8783 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
8784 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 8785 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8786 | "as-set"); |
8787 | else | |
a4d82a8a | 8788 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8789 | "true"); |
8790 | } else | |
a4d82a8a | 8791 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 8792 | |
892fedb6 | 8793 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 8794 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
8795 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
8796 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8797 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8798 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 8799 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
8800 | json_object_string_add(bestpath, "med", |
8801 | "missing-as-worst"); | |
8802 | else | |
8803 | json_object_string_add(bestpath, "med", "true"); | |
8804 | } | |
8805 | ||
8806 | json_object_object_add(json, "bestPath", bestpath); | |
8807 | } | |
8808 | ||
3577f1c5 DD |
8809 | /* Print the error code/subcode for why the peer is down */ |
8810 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8811 | json_object *json_peer, bool use_json) | |
8812 | { | |
8813 | const char *code_str; | |
8814 | const char *subcode_str; | |
8815 | ||
8816 | if (use_json) { | |
8817 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8818 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8819 | char errorcodesubcode_hexstr[5]; | |
8820 | char errorcodesubcode_str[256]; | |
8821 | ||
8822 | code_str = bgp_notify_code_str(peer->notify.code); | |
8823 | subcode_str = bgp_notify_subcode_str( | |
8824 | peer->notify.code, | |
8825 | peer->notify.subcode); | |
8826 | ||
772270f3 QY |
8827 | snprintf(errorcodesubcode_hexstr, |
8828 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
8829 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
8830 | json_object_string_add(json_peer, |
8831 | "lastErrorCodeSubcode", | |
8832 | errorcodesubcode_hexstr); | |
8833 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8834 | code_str, subcode_str); | |
8835 | json_object_string_add(json_peer, | |
8836 | "lastNotificationReason", | |
8837 | errorcodesubcode_str); | |
8838 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8839 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8840 | && (peer->notify.subcode | |
8841 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8842 | || peer->notify.subcode | |
8843 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8844 | && peer->notify.length) { | |
8845 | char msgbuf[1024]; | |
8846 | const char *msg_str; | |
8847 | ||
8848 | msg_str = bgp_notify_admin_message( | |
8849 | msgbuf, sizeof(msgbuf), | |
8850 | (uint8_t *)peer->notify.data, | |
8851 | peer->notify.length); | |
8852 | if (msg_str) | |
8853 | json_object_string_add( | |
8854 | json_peer, | |
8855 | "lastShutdownDescription", | |
8856 | msg_str); | |
8857 | } | |
8858 | ||
c258527b | 8859 | } |
3577f1c5 DD |
8860 | json_object_string_add(json_peer, "lastResetDueTo", |
8861 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8862 | json_object_int_add(json_peer, "lastResetCode", |
8863 | peer->last_reset); | |
3577f1c5 DD |
8864 | } else { |
8865 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8866 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8867 | code_str = bgp_notify_code_str(peer->notify.code); | |
8868 | subcode_str = | |
8869 | bgp_notify_subcode_str(peer->notify.code, | |
8870 | peer->notify.subcode); | |
8871 | vty_out(vty, " Notification %s (%s%s)\n", | |
8872 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8873 | ? "sent" | |
8874 | : "received", | |
8875 | code_str, subcode_str); | |
8876 | } else { | |
e91c24c8 | 8877 | vty_out(vty, " %s\n", |
3577f1c5 DD |
8878 | peer_down_str[(int)peer->last_reset]); |
8879 | } | |
8880 | } | |
8881 | } | |
8882 | ||
8883 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8884 | safi_t safi) | |
8885 | { | |
8886 | return ((peer->status != Established) || | |
8887 | !peer->afc_recv[afi][safi]); | |
8888 | } | |
8889 | ||
8890 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8891 | struct peer *peer, json_object *json_peer, | |
8892 | int max_neighbor_width, bool use_json) | |
8893 | { | |
8894 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8895 | int len; | |
8896 | ||
8897 | if (use_json) { | |
8898 | if (peer_dynamic_neighbor(peer)) | |
8899 | json_object_boolean_true_add(json_peer, | |
8900 | "dynamicPeer"); | |
8901 | if (peer->hostname) | |
8902 | json_object_string_add(json_peer, "hostname", | |
8903 | peer->hostname); | |
8904 | ||
8905 | if (peer->domainname) | |
8906 | json_object_string_add(json_peer, "domainname", | |
8907 | peer->domainname); | |
8908 | json_object_int_add(json_peer, "connectionsEstablished", | |
8909 | peer->established); | |
8910 | json_object_int_add(json_peer, "connectionsDropped", | |
8911 | peer->dropped); | |
8912 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8913 | use_json, json_peer); | |
8914 | if (peer->status == Established) | |
8915 | json_object_string_add(json_peer, "lastResetDueTo", | |
8916 | "AFI/SAFI Not Negotiated"); | |
8917 | else | |
8918 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8919 | } else { | |
8920 | dn_flag[1] = '\0'; | |
8921 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8922 | if (peer->hostname | |
892fedb6 | 8923 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
8924 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
8925 | peer->hostname, peer->host); | |
8926 | else | |
8927 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8928 | ||
8929 | /* pad the neighbor column with spaces */ | |
8930 | if (len < max_neighbor_width) | |
8931 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8932 | " "); | |
e91c24c8 | 8933 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
8934 | peer->dropped, |
8935 | peer_uptime(peer->uptime, timebuf, | |
8936 | BGP_UPTIME_LEN, 0, NULL)); | |
8937 | if (peer->status == Established) | |
8938 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8939 | else | |
8940 | bgp_show_peer_reset(vty, peer, NULL, | |
8941 | false); | |
8942 | } | |
8943 | } | |
c258527b | 8944 | |
3577f1c5 | 8945 | |
718e3744 | 8946 | /* Show BGP peer's summary information. */ |
d62a17ae | 8947 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
10b49f14 DA |
8948 | bool show_failed, bool show_established, |
8949 | bool use_json) | |
d62a17ae | 8950 | { |
8951 | struct peer *peer; | |
8952 | struct listnode *node, *nnode; | |
8953 | unsigned int count = 0, dn_count = 0; | |
8954 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8955 | char neighbor_buf[VTY_BUFSIZ]; | |
8956 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8957 | int len, failed_count = 0; |
d62a17ae | 8958 | int max_neighbor_width = 0; |
8959 | int pfx_rcd_safi; | |
3c13337d | 8960 | json_object *json = NULL; |
d62a17ae | 8961 | json_object *json_peer = NULL; |
8962 | json_object *json_peers = NULL; | |
50e05855 | 8963 | struct peer_af *paf; |
d3ada366 | 8964 | struct bgp_filter *filter; |
d62a17ae | 8965 | |
8966 | /* labeled-unicast routes are installed in the unicast table so in order | |
8967 | * to | |
8968 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8969 | */ | |
3577f1c5 | 8970 | |
d62a17ae | 8971 | if (safi == SAFI_LABELED_UNICAST) |
8972 | pfx_rcd_safi = SAFI_UNICAST; | |
8973 | else | |
8974 | pfx_rcd_safi = safi; | |
8975 | ||
8976 | if (use_json) { | |
3c13337d | 8977 | json = json_object_new_object(); |
d62a17ae | 8978 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8979 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8980 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8981 | continue; | |
8982 | ||
8983 | if (peer->afc[afi][safi]) { | |
8984 | /* See if we have at least a single failed peer */ | |
8985 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8986 | failed_count++; | |
8987 | count++; | |
8988 | } | |
8989 | if (peer_dynamic_neighbor(peer)) | |
8990 | dn_count++; | |
8991 | } | |
c258527b | 8992 | |
d62a17ae | 8993 | } else { |
8994 | /* Loop over all neighbors that will be displayed to determine | |
8995 | * how many | |
8996 | * characters are needed for the Neighbor column | |
8997 | */ | |
8998 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8999 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9000 | continue; | |
9001 | ||
9002 | if (peer->afc[afi][safi]) { | |
9003 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9004 | if (peer_dynamic_neighbor(peer)) | |
9005 | dn_flag[0] = '*'; | |
9006 | ||
9007 | if (peer->hostname | |
892fedb6 DA |
9008 | && CHECK_FLAG(bgp->flags, |
9009 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
9010 | snprintf(neighbor_buf, |
9011 | sizeof(neighbor_buf), | |
9012 | "%s%s(%s) ", dn_flag, | |
9013 | peer->hostname, peer->host); | |
d62a17ae | 9014 | else |
772270f3 QY |
9015 | snprintf(neighbor_buf, |
9016 | sizeof(neighbor_buf), "%s%s ", | |
9017 | dn_flag, peer->host); | |
d62a17ae | 9018 | |
9019 | len = strlen(neighbor_buf); | |
9020 | ||
9021 | if (len > max_neighbor_width) | |
9022 | max_neighbor_width = len; | |
c258527b | 9023 | |
3577f1c5 DD |
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++; | |
d62a17ae | 9028 | } |
9029 | } | |
f933309e | 9030 | |
d62a17ae | 9031 | /* Originally we displayed the Neighbor column as 16 |
9032 | * characters wide so make that the default | |
9033 | */ | |
9034 | if (max_neighbor_width < neighbor_col_default_width) | |
9035 | max_neighbor_width = neighbor_col_default_width; | |
9036 | } | |
f933309e | 9037 | |
3577f1c5 DD |
9038 | if (show_failed && !failed_count) { |
9039 | if (use_json) { | |
9040 | json_object_int_add(json, "failedPeersCount", 0); | |
9041 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 9042 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
9043 | |
9044 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
9045 | json, JSON_C_TO_STRING_PRETTY)); | |
9046 | json_object_free(json); | |
9047 | } else { | |
9048 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
9049 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9050 | } | |
9051 | return CMD_SUCCESS; | |
9052 | } | |
c258527b | 9053 | |
3577f1c5 | 9054 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 9055 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
9056 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9057 | continue; | |
9058 | ||
ea47320b DL |
9059 | if (!peer->afc[afi][safi]) |
9060 | continue; | |
d62a17ae | 9061 | |
ea47320b DL |
9062 | if (!count) { |
9063 | unsigned long ents; | |
9064 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 9065 | int64_t vrf_id_ui; |
d62a17ae | 9066 | |
a4d82a8a PZ |
9067 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9068 | ? -1 | |
9069 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
9070 | |
9071 | /* Usage summary and header */ | |
9072 | if (use_json) { | |
9073 | json_object_string_add( | |
9074 | json, "routerId", | |
9075 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
9076 | json_object_int_add(json, "as", bgp->as); |
9077 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
9078 | json_object_string_add( |
9079 | json, "vrfName", | |
9080 | (bgp->inst_type | |
9081 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9082 | ? VRF_DEFAULT_NAME |
ea47320b DL |
9083 | : bgp->name); |
9084 | } else { | |
9085 | vty_out(vty, | |
9086 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 9087 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
9088 | bgp->vrf_id == VRF_UNKNOWN |
9089 | ? -1 | |
9090 | : (int)bgp->vrf_id); | |
ea47320b DL |
9091 | vty_out(vty, "\n"); |
9092 | } | |
d62a17ae | 9093 | |
ea47320b | 9094 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 9095 | if (use_json) { |
ea47320b | 9096 | json_object_int_add( |
60466a63 | 9097 | json, "updateDelayLimit", |
ea47320b | 9098 | bgp->v_update_delay); |
d62a17ae | 9099 | |
ea47320b DL |
9100 | if (bgp->v_update_delay |
9101 | != bgp->v_establish_wait) | |
d62a17ae | 9102 | json_object_int_add( |
9103 | json, | |
ea47320b DL |
9104 | "updateDelayEstablishWait", |
9105 | bgp->v_establish_wait); | |
d62a17ae | 9106 | |
60466a63 | 9107 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9108 | json_object_string_add( |
9109 | json, | |
9110 | "updateDelayFirstNeighbor", | |
9111 | bgp->update_delay_begin_time); | |
9112 | json_object_boolean_true_add( | |
9113 | json, | |
9114 | "updateDelayInProgress"); | |
9115 | } else { | |
9116 | if (bgp->update_delay_over) { | |
d62a17ae | 9117 | json_object_string_add( |
9118 | json, | |
9119 | "updateDelayFirstNeighbor", | |
9120 | bgp->update_delay_begin_time); | |
ea47320b | 9121 | json_object_string_add( |
d62a17ae | 9122 | json, |
ea47320b DL |
9123 | "updateDelayBestpathResumed", |
9124 | bgp->update_delay_end_time); | |
9125 | json_object_string_add( | |
d62a17ae | 9126 | json, |
ea47320b DL |
9127 | "updateDelayZebraUpdateResume", |
9128 | bgp->update_delay_zebra_resume_time); | |
9129 | json_object_string_add( | |
9130 | json, | |
9131 | "updateDelayPeerUpdateResume", | |
9132 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9133 | } |
ea47320b DL |
9134 | } |
9135 | } else { | |
9136 | vty_out(vty, | |
9137 | "Read-only mode update-delay limit: %d seconds\n", | |
9138 | bgp->v_update_delay); | |
9139 | if (bgp->v_update_delay | |
9140 | != bgp->v_establish_wait) | |
d62a17ae | 9141 | vty_out(vty, |
ea47320b DL |
9142 | " Establish wait: %d seconds\n", |
9143 | bgp->v_establish_wait); | |
d62a17ae | 9144 | |
60466a63 | 9145 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9146 | vty_out(vty, |
9147 | " First neighbor established: %s\n", | |
9148 | bgp->update_delay_begin_time); | |
9149 | vty_out(vty, | |
9150 | " Delay in progress\n"); | |
9151 | } else { | |
9152 | if (bgp->update_delay_over) { | |
d62a17ae | 9153 | vty_out(vty, |
9154 | " First neighbor established: %s\n", | |
9155 | bgp->update_delay_begin_time); | |
9156 | vty_out(vty, | |
ea47320b DL |
9157 | " Best-paths resumed: %s\n", |
9158 | bgp->update_delay_end_time); | |
9159 | vty_out(vty, | |
9160 | " zebra update resumed: %s\n", | |
9161 | bgp->update_delay_zebra_resume_time); | |
9162 | vty_out(vty, | |
9163 | " peers update resumed: %s\n", | |
9164 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9165 | } |
9166 | } | |
9167 | } | |
ea47320b | 9168 | } |
d62a17ae | 9169 | |
ea47320b DL |
9170 | if (use_json) { |
9171 | if (bgp_maxmed_onstartup_configured(bgp) | |
9172 | && bgp->maxmed_active) | |
9173 | json_object_boolean_true_add( | |
60466a63 | 9174 | json, "maxMedOnStartup"); |
ea47320b DL |
9175 | if (bgp->v_maxmed_admin) |
9176 | json_object_boolean_true_add( | |
60466a63 | 9177 | json, "maxMedAdministrative"); |
d62a17ae | 9178 | |
ea47320b DL |
9179 | json_object_int_add( |
9180 | json, "tableVersion", | |
60466a63 | 9181 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 9182 | |
60466a63 QY |
9183 | ents = bgp_table_count(bgp->rib[afi][safi]); |
9184 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
9185 | json_object_int_add( |
9186 | json, "ribMemory", | |
9bcb3eef | 9187 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 9188 | |
210ec2a0 | 9189 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
9190 | json_object_int_add(json, "peerCount", ents); |
9191 | json_object_int_add(json, "peerMemory", | |
9192 | ents * sizeof(struct peer)); | |
d62a17ae | 9193 | |
ea47320b DL |
9194 | if ((ents = listcount(bgp->group))) { |
9195 | json_object_int_add( | |
60466a63 | 9196 | json, "peerGroupCount", ents); |
ea47320b DL |
9197 | json_object_int_add( |
9198 | json, "peerGroupMemory", | |
996c9314 LB |
9199 | ents * sizeof(struct |
9200 | peer_group)); | |
ea47320b | 9201 | } |
d62a17ae | 9202 | |
ea47320b DL |
9203 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9204 | BGP_CONFIG_DAMPENING)) | |
9205 | json_object_boolean_true_add( | |
60466a63 | 9206 | json, "dampeningEnabled"); |
ea47320b DL |
9207 | } else { |
9208 | if (bgp_maxmed_onstartup_configured(bgp) | |
9209 | && bgp->maxmed_active) | |
d62a17ae | 9210 | vty_out(vty, |
ea47320b DL |
9211 | "Max-med on-startup active\n"); |
9212 | if (bgp->v_maxmed_admin) | |
d62a17ae | 9213 | vty_out(vty, |
ea47320b | 9214 | "Max-med administrative active\n"); |
d62a17ae | 9215 | |
60466a63 QY |
9216 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
9217 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 9218 | |
60466a63 | 9219 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
9220 | vty_out(vty, |
9221 | "RIB entries %ld, using %s of memory\n", | |
9222 | ents, | |
9bcb3eef DS |
9223 | mtype_memstr( |
9224 | memstrbuf, sizeof(memstrbuf), | |
9225 | ents | |
9226 | * sizeof(struct | |
9227 | bgp_dest))); | |
ea47320b DL |
9228 | |
9229 | /* Peer related usage */ | |
210ec2a0 | 9230 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 9231 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
9232 | ents, |
9233 | mtype_memstr( | |
60466a63 QY |
9234 | memstrbuf, sizeof(memstrbuf), |
9235 | ents * sizeof(struct peer))); | |
ea47320b DL |
9236 | |
9237 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 9238 | vty_out(vty, |
ea47320b | 9239 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 9240 | ents, |
9241 | mtype_memstr( | |
9242 | memstrbuf, | |
9243 | sizeof(memstrbuf), | |
996c9314 LB |
9244 | ents * sizeof(struct |
9245 | peer_group))); | |
d62a17ae | 9246 | |
ea47320b DL |
9247 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9248 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 9249 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 9250 | vty_out(vty, "\n"); |
d62a17ae | 9251 | |
ea47320b DL |
9252 | /* Subtract 8 here because 'Neighbor' is |
9253 | * 8 characters */ | |
9254 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
9255 | vty_out(vty, "%*s", max_neighbor_width - 8, |
9256 | " "); | |
3577f1c5 DD |
9257 | if (show_failed) |
9258 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
9259 | else | |
9260 | vty_out(vty, | |
db92d226 | 9261 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n"); |
d62a17ae | 9262 | } |
ea47320b | 9263 | } |
d62a17ae | 9264 | |
d55811cc | 9265 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 9266 | filter = &peer->filter[afi][safi]; |
db92d226 | 9267 | |
ea47320b | 9268 | count++; |
3577f1c5 DD |
9269 | /* Works for both failed & successful cases */ |
9270 | if (peer_dynamic_neighbor(peer)) | |
9271 | dn_count++; | |
d62a17ae | 9272 | |
ea47320b | 9273 | if (use_json) { |
3577f1c5 DD |
9274 | json_peer = NULL; |
9275 | ||
9276 | if (show_failed && | |
9277 | bgp_has_peer_failed(peer, afi, safi)) { | |
9278 | json_peer = json_object_new_object(); | |
9279 | bgp_show_failed_summary(vty, bgp, peer, | |
9280 | json_peer, 0, use_json); | |
9281 | } else if (!show_failed) { | |
10b49f14 DA |
9282 | if (show_established |
9283 | && bgp_has_peer_failed(peer, afi, safi)) | |
9284 | continue; | |
9285 | ||
3577f1c5 DD |
9286 | json_peer = json_object_new_object(); |
9287 | if (peer_dynamic_neighbor(peer)) { | |
9288 | json_object_boolean_true_add(json_peer, | |
9289 | "dynamicPeer"); | |
9290 | } | |
d62a17ae | 9291 | |
3577f1c5 DD |
9292 | if (peer->hostname) |
9293 | json_object_string_add(json_peer, "hostname", | |
9294 | peer->hostname); | |
9295 | ||
9296 | if (peer->domainname) | |
9297 | json_object_string_add(json_peer, "domainname", | |
9298 | peer->domainname); | |
9299 | ||
9300 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9301 | json_object_int_add(json_peer, "version", 4); | |
9302 | json_object_int_add(json_peer, "msgRcvd", | |
9303 | PEER_TOTAL_RX(peer)); | |
9304 | json_object_int_add(json_peer, "msgSent", | |
9305 | PEER_TOTAL_TX(peer)); | |
9306 | ||
43aa5965 QY |
9307 | atomic_size_t outq_count, inq_count; |
9308 | outq_count = atomic_load_explicit( | |
9309 | &peer->obuf->count, | |
9310 | memory_order_relaxed); | |
9311 | inq_count = atomic_load_explicit( | |
9312 | &peer->ibuf->count, | |
9313 | memory_order_relaxed); | |
9314 | ||
3577f1c5 DD |
9315 | json_object_int_add(json_peer, "tableVersion", |
9316 | peer->version[afi][safi]); | |
9317 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
9318 | outq_count); |
9319 | json_object_int_add(json_peer, "inq", | |
9320 | inq_count); | |
3577f1c5 DD |
9321 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
9322 | use_json, json_peer); | |
9323 | ||
3577f1c5 DD |
9324 | json_object_int_add(json_peer, "pfxRcd", |
9325 | peer->pcount[afi][pfx_rcd_safi]); | |
9326 | ||
3577f1c5 DD |
9327 | if (paf && PAF_SUBGRP(paf)) |
9328 | json_object_int_add(json_peer, | |
9329 | "pfxSnt", | |
9330 | (PAF_SUBGRP(paf))->scount); | |
9331 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9332 | json_object_string_add(json_peer, "state", | |
9333 | "Idle (Admin)"); | |
9334 | else if (peer->afc_recv[afi][safi]) | |
9335 | json_object_string_add( | |
9336 | json_peer, "state", | |
9337 | lookup_msg(bgp_status_msg, peer->status, | |
9338 | NULL)); | |
9339 | else if (CHECK_FLAG(peer->sflags, | |
9340 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9341 | json_object_string_add(json_peer, "state", | |
9342 | "Idle (PfxCt)"); | |
9343 | else | |
9344 | json_object_string_add( | |
9345 | json_peer, "state", | |
9346 | lookup_msg(bgp_status_msg, peer->status, | |
9347 | NULL)); | |
200116db DD |
9348 | json_object_int_add(json_peer, "connectionsEstablished", |
9349 | peer->established); | |
9350 | json_object_int_add(json_peer, "connectionsDropped", | |
9351 | peer->dropped); | |
b4e9dcba | 9352 | } |
3577f1c5 DD |
9353 | /* Avoid creating empty peer dicts in JSON */ |
9354 | if (json_peer == NULL) | |
9355 | continue; | |
ea47320b DL |
9356 | |
9357 | if (peer->conf_if) | |
60466a63 | 9358 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9359 | "interface"); |
9360 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9361 | json_object_string_add(json_peer, "idType", |
9362 | "ipv4"); | |
ea47320b | 9363 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9364 | json_object_string_add(json_peer, "idType", |
9365 | "ipv6"); | |
ea47320b DL |
9366 | json_object_object_add(json_peers, peer->host, |
9367 | json_peer); | |
9368 | } else { | |
3577f1c5 DD |
9369 | if (show_failed && |
9370 | bgp_has_peer_failed(peer, afi, safi)) { | |
9371 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9372 | max_neighbor_width, | |
9373 | use_json); | |
9374 | } else if (!show_failed) { | |
10b49f14 DA |
9375 | if (show_established |
9376 | && bgp_has_peer_failed(peer, afi, safi)) | |
9377 | continue; | |
9378 | ||
3577f1c5 DD |
9379 | memset(dn_flag, '\0', sizeof(dn_flag)); |
9380 | if (peer_dynamic_neighbor(peer)) { | |
9381 | dn_flag[0] = '*'; | |
9382 | } | |
d62a17ae | 9383 | |
3577f1c5 | 9384 | if (peer->hostname |
892fedb6 DA |
9385 | && CHECK_FLAG(bgp->flags, |
9386 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 9387 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
9388 | peer->hostname, |
9389 | peer->host); | |
d62a17ae | 9390 | else |
3577f1c5 DD |
9391 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
9392 | ||
9393 | /* pad the neighbor column with spaces */ | |
9394 | if (len < max_neighbor_width) | |
9395 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9396 | " "); | |
9397 | ||
43aa5965 QY |
9398 | atomic_size_t outq_count, inq_count; |
9399 | outq_count = atomic_load_explicit( | |
9400 | &peer->obuf->count, | |
9401 | memory_order_relaxed); | |
9402 | inq_count = atomic_load_explicit( | |
9403 | &peer->ibuf->count, | |
9404 | memory_order_relaxed); | |
9405 | ||
566bdaf6 | 9406 | vty_out(vty, |
6cde4b45 | 9407 | "4 %10u %9u %9u %8" PRIu64" %4zu %4zu %8s", |
3577f1c5 | 9408 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 9409 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
9410 | peer->version[afi][safi], inq_count, |
9411 | outq_count, | |
3577f1c5 DD |
9412 | peer_uptime(peer->uptime, timebuf, |
9413 | BGP_UPTIME_LEN, 0, NULL)); | |
9414 | ||
db92d226 | 9415 | if (peer->status == Established) { |
d3ada366 DA |
9416 | if (peer->afc_recv[afi][safi]) { |
9417 | if (CHECK_FLAG( | |
9418 | bgp->flags, | |
9419 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
9420 | && !bgp_inbound_policy_exists( | |
9421 | peer, filter)) | |
9422 | vty_out(vty, " %12s", | |
9423 | "(Policy)"); | |
9424 | else | |
9425 | vty_out(vty, | |
6cde4b45 | 9426 | " %12u", |
d3ada366 DA |
9427 | peer->pcount |
9428 | [afi] | |
9429 | [pfx_rcd_safi]); | |
9430 | } else { | |
3577f1c5 | 9431 | vty_out(vty, " NoNeg"); |
d3ada366 | 9432 | } |
db92d226 | 9433 | |
d3ada366 DA |
9434 | if (paf && PAF_SUBGRP(paf)) { |
9435 | if (CHECK_FLAG( | |
9436 | bgp->flags, | |
9437 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
9438 | && !bgp_outbound_policy_exists( | |
9439 | peer, filter)) | |
9440 | vty_out(vty, " %8s", | |
9441 | "(Policy)"); | |
9442 | else | |
9443 | vty_out(vty, | |
6cde4b45 | 9444 | " %8u", |
d3ada366 DA |
9445 | (PAF_SUBGRP( |
9446 | paf)) | |
9447 | ->scount); | |
9448 | } | |
db92d226 | 9449 | } else { |
3577f1c5 DD |
9450 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
9451 | vty_out(vty, " Idle (Admin)"); | |
9452 | else if (CHECK_FLAG( | |
9453 | peer->sflags, | |
9454 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9455 | vty_out(vty, " Idle (PfxCt)"); | |
9456 | else | |
9457 | vty_out(vty, " %12s", | |
9458 | lookup_msg(bgp_status_msg, | |
9459 | peer->status, NULL)); | |
db92d226 | 9460 | |
6cde4b45 | 9461 | vty_out(vty, " %8u", 0); |
3577f1c5 DD |
9462 | } |
9463 | vty_out(vty, "\n"); | |
d62a17ae | 9464 | } |
3577f1c5 | 9465 | |
d62a17ae | 9466 | } |
9467 | } | |
f933309e | 9468 | |
d62a17ae | 9469 | if (use_json) { |
9470 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9471 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9472 | json_object_int_add(json, "totalPeers", count); |
9473 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9474 | ||
3577f1c5 DD |
9475 | if (!show_failed) |
9476 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9477 | |
996c9314 LB |
9478 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9479 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9480 | json_object_free(json); |
9481 | } else { | |
9482 | if (count) | |
9483 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9484 | else { | |
d6ceaca3 | 9485 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9486 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9487 | } |
b05a1c8b | 9488 | |
d6ceaca3 | 9489 | if (dn_count) { |
d62a17ae | 9490 | vty_out(vty, "* - dynamic neighbor\n"); |
9491 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9492 | dn_count, bgp->dynamic_neighbors_limit); | |
9493 | } | |
9494 | } | |
1ff9a340 | 9495 | |
d62a17ae | 9496 | return CMD_SUCCESS; |
718e3744 | 9497 | } |
9498 | ||
d62a17ae | 9499 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
10b49f14 DA |
9500 | int safi, bool show_failed, |
9501 | bool show_established, bool use_json) | |
d62a17ae | 9502 | { |
9503 | int is_first = 1; | |
9504 | int afi_wildcard = (afi == AFI_MAX); | |
9505 | int safi_wildcard = (safi == SAFI_MAX); | |
9506 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9507 | bool nbr_output = false; |
d62a17ae | 9508 | |
9509 | if (use_json && is_wildcard) | |
9510 | vty_out(vty, "{\n"); | |
9511 | if (afi_wildcard) | |
9512 | afi = 1; /* AFI_IP */ | |
9513 | while (afi < AFI_MAX) { | |
9514 | if (safi_wildcard) | |
9515 | safi = 1; /* SAFI_UNICAST */ | |
9516 | while (safi < SAFI_MAX) { | |
318cac96 | 9517 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9518 | nbr_output = true; |
f86897b9 | 9519 | |
d62a17ae | 9520 | if (is_wildcard) { |
9521 | /* | |
9522 | * So limit output to those afi/safi | |
9523 | * pairs that | |
9524 | * actualy have something interesting in | |
9525 | * them | |
9526 | */ | |
9527 | if (use_json) { | |
d62a17ae | 9528 | if (!is_first) |
9529 | vty_out(vty, ",\n"); | |
9530 | else | |
9531 | is_first = 0; | |
9532 | ||
9533 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9534 | get_afi_safi_str(afi, |
9535 | safi, | |
9536 | true)); | |
d62a17ae | 9537 | } else { |
9538 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9539 | get_afi_safi_str(afi, |
9540 | safi, | |
9541 | false)); | |
d62a17ae | 9542 | } |
9543 | } | |
10b49f14 DA |
9544 | bgp_show_summary(vty, bgp, afi, safi, |
9545 | show_failed, show_established, | |
3577f1c5 | 9546 | use_json); |
d62a17ae | 9547 | } |
9548 | safi++; | |
d62a17ae | 9549 | if (!safi_wildcard) |
9550 | safi = SAFI_MAX; | |
9551 | } | |
9552 | afi++; | |
ee851c8c | 9553 | if (!afi_wildcard) |
d62a17ae | 9554 | afi = AFI_MAX; |
9555 | } | |
9556 | ||
9557 | if (use_json && is_wildcard) | |
9558 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9559 | else if (!nbr_output) { |
9560 | if (use_json) | |
9561 | vty_out(vty, "{}\n"); | |
9562 | else | |
9563 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9564 | } | |
d62a17ae | 9565 | } |
9566 | ||
9567 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 | 9568 | safi_t safi, bool show_failed, |
10b49f14 | 9569 | bool show_established, |
3577f1c5 | 9570 | bool use_json) |
d62a17ae | 9571 | { |
9572 | struct listnode *node, *nnode; | |
9573 | struct bgp *bgp; | |
d62a17ae | 9574 | int is_first = 1; |
9f049418 | 9575 | bool nbr_output = false; |
d62a17ae | 9576 | |
9577 | if (use_json) | |
9578 | vty_out(vty, "{\n"); | |
9579 | ||
9580 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9581 | nbr_output = true; |
d62a17ae | 9582 | if (use_json) { |
d62a17ae | 9583 | if (!is_first) |
9584 | vty_out(vty, ",\n"); | |
9585 | else | |
9586 | is_first = 0; | |
9587 | ||
9588 | vty_out(vty, "\"%s\":", | |
9589 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9590 | ? VRF_DEFAULT_NAME |
d62a17ae | 9591 | : bgp->name); |
9592 | } else { | |
9593 | vty_out(vty, "\nInstance %s:\n", | |
9594 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9595 | ? VRF_DEFAULT_NAME |
d62a17ae | 9596 | : bgp->name); |
9597 | } | |
3577f1c5 | 9598 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 9599 | show_established, use_json); |
d62a17ae | 9600 | } |
9601 | ||
9602 | if (use_json) | |
9603 | vty_out(vty, "}\n"); | |
9f049418 DS |
9604 | else if (!nbr_output) |
9605 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9606 | } |
9607 | ||
9608 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
10b49f14 DA |
9609 | safi_t safi, bool show_failed, bool show_established, |
9610 | bool use_json) | |
d62a17ae | 9611 | { |
9612 | struct bgp *bgp; | |
9613 | ||
9614 | if (name) { | |
9615 | if (strmatch(name, "all")) { | |
10b49f14 DA |
9616 | bgp_show_all_instances_summary_vty( |
9617 | vty, afi, safi, show_failed, show_established, | |
9618 | use_json); | |
d62a17ae | 9619 | return CMD_SUCCESS; |
9620 | } else { | |
9621 | bgp = bgp_lookup_by_name(name); | |
9622 | ||
9623 | if (!bgp) { | |
9624 | if (use_json) | |
9625 | vty_out(vty, "{}\n"); | |
9626 | else | |
9627 | vty_out(vty, | |
ca61fd25 | 9628 | "%% BGP instance not found\n"); |
d62a17ae | 9629 | return CMD_WARNING; |
9630 | } | |
9631 | ||
f86897b9 | 9632 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
10b49f14 DA |
9633 | show_failed, show_established, |
9634 | use_json); | |
d62a17ae | 9635 | return CMD_SUCCESS; |
9636 | } | |
9637 | } | |
9638 | ||
9639 | bgp = bgp_get_default(); | |
9640 | ||
9641 | if (bgp) | |
3577f1c5 | 9642 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 9643 | show_established, use_json); |
9f049418 | 9644 | else { |
ca61fd25 DS |
9645 | if (use_json) |
9646 | vty_out(vty, "{}\n"); | |
9647 | else | |
9648 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9649 | return CMD_WARNING; |
9650 | } | |
d62a17ae | 9651 | |
9652 | return CMD_SUCCESS; | |
4fb25c53 DW |
9653 | } |
9654 | ||
716b2d8a | 9655 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9656 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9657 | show_ip_bgp_summary_cmd, |
10b49f14 | 9658 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [established|failed] [json]", |
718e3744 | 9659 | SHOW_STR |
9660 | IP_STR | |
9661 | BGP_STR | |
8386ac43 | 9662 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9663 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9664 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9665 | "Summary of BGP neighbor status\n" |
10b49f14 | 9666 | "Show only sessions in Established state\n" |
3577f1c5 | 9667 | "Show only sessions not in Established state\n" |
9973d184 | 9668 | JSON_STR) |
718e3744 | 9669 | { |
d62a17ae | 9670 | char *vrf = NULL; |
9671 | afi_t afi = AFI_MAX; | |
9672 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9673 | bool show_failed = false; |
10b49f14 | 9674 | bool show_established = false; |
d62a17ae | 9675 | |
9676 | int idx = 0; | |
9677 | ||
9678 | /* show [ip] bgp */ | |
9679 | if (argv_find(argv, argc, "ip", &idx)) | |
9680 | afi = AFI_IP; | |
9a8bdf1c PG |
9681 | /* [<vrf> VIEWVRFNAME] */ |
9682 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9683 | vrf = argv[idx + 1]->arg; | |
9684 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9685 | vrf = NULL; | |
9686 | } else if (argv_find(argv, argc, "view", &idx)) | |
9687 | /* [<view> VIEWVRFNAME] */ | |
9688 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9689 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9690 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9691 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9692 | } | |
9693 | ||
3577f1c5 DD |
9694 | if (argv_find(argv, argc, "failed", &idx)) |
9695 | show_failed = true; | |
10b49f14 DA |
9696 | if (argv_find(argv, argc, "established", &idx)) |
9697 | show_established = true; | |
3577f1c5 | 9698 | |
9f049418 | 9699 | bool uj = use_json(argc, argv); |
d62a17ae | 9700 | |
10b49f14 DA |
9701 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, |
9702 | show_established, uj); | |
d62a17ae | 9703 | } |
9704 | ||
5cb5f4d0 | 9705 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9706 | { |
5cb5f4d0 DD |
9707 | if (for_json) |
9708 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9709 | else |
5cb5f4d0 | 9710 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9711 | } |
9712 | ||
d62a17ae | 9713 | |
9714 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9715 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9716 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9717 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9718 | bool use_json, json_object *json_pref) |
d62a17ae | 9719 | { |
9720 | /* Send-Mode */ | |
9721 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9722 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9723 | if (use_json) { | |
9724 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9725 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9726 | json_object_string_add(json_pref, "sendMode", | |
9727 | "advertisedAndReceived"); | |
9728 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9729 | json_object_string_add(json_pref, "sendMode", | |
9730 | "advertised"); | |
9731 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9732 | json_object_string_add(json_pref, "sendMode", | |
9733 | "received"); | |
9734 | } else { | |
9735 | vty_out(vty, " Send-mode: "); | |
9736 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9737 | vty_out(vty, "advertised"); | |
9738 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9739 | vty_out(vty, "%sreceived", | |
9740 | CHECK_FLAG(p->af_cap[afi][safi], | |
9741 | adv_smcap) | |
9742 | ? ", " | |
9743 | : ""); | |
9744 | vty_out(vty, "\n"); | |
9745 | } | |
9746 | } | |
9747 | ||
9748 | /* Receive-Mode */ | |
9749 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9750 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9751 | if (use_json) { | |
9752 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9753 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9754 | json_object_string_add(json_pref, "recvMode", | |
9755 | "advertisedAndReceived"); | |
9756 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9757 | json_object_string_add(json_pref, "recvMode", | |
9758 | "advertised"); | |
9759 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9760 | json_object_string_add(json_pref, "recvMode", | |
9761 | "received"); | |
9762 | } else { | |
9763 | vty_out(vty, " Receive-mode: "); | |
9764 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9765 | vty_out(vty, "advertised"); | |
9766 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9767 | vty_out(vty, "%sreceived", | |
9768 | CHECK_FLAG(p->af_cap[afi][safi], | |
9769 | adv_rmcap) | |
9770 | ? ", " | |
9771 | : ""); | |
9772 | vty_out(vty, "\n"); | |
9773 | } | |
9774 | } | |
9775 | } | |
9776 | ||
13909c4f DS |
9777 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
9778 | struct peer *p, | |
9779 | bool use_json, | |
9780 | json_object *json) | |
2986cac2 | 9781 | { |
08c2d52a | 9782 | bool rbit_status = false; |
2986cac2 | 9783 | |
9784 | if (!use_json) | |
a53ca37b | 9785 | vty_out(vty, "\n R bit: "); |
2986cac2 | 9786 | |
13909c4f DS |
9787 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
9788 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
9789 | && (p->status == Established)) { | |
2986cac2 | 9790 | |
9791 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 9792 | rbit_status = true; |
2986cac2 | 9793 | else |
08c2d52a | 9794 | rbit_status = false; |
2986cac2 | 9795 | } |
9796 | ||
9797 | if (rbit_status) { | |
9798 | if (use_json) | |
13909c4f | 9799 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 9800 | else |
9801 | vty_out(vty, "True\n"); | |
9802 | } else { | |
9803 | if (use_json) | |
13909c4f | 9804 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 9805 | else |
9806 | vty_out(vty, "False\n"); | |
9807 | } | |
9808 | } | |
9809 | ||
13909c4f DS |
9810 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
9811 | struct peer *peer, | |
9812 | bool use_json, | |
9813 | json_object *json) | |
2986cac2 | 9814 | { |
2bb5d39b | 9815 | const char *mode = "NotApplicable"; |
2986cac2 | 9816 | |
9817 | if (!use_json) | |
a53ca37b | 9818 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 9819 | |
13909c4f DS |
9820 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9821 | && (peer->status == Established)) { | |
2986cac2 | 9822 | |
13909c4f DS |
9823 | if ((peer->nsf_af_count == 0) |
9824 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9825 | |
2986cac2 | 9826 | mode = "Disable"; |
9827 | ||
13909c4f DS |
9828 | } else if (peer->nsf_af_count == 0 |
9829 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9830 | |
2986cac2 | 9831 | mode = "Helper"; |
9832 | ||
13909c4f DS |
9833 | } else if (peer->nsf_af_count != 0 |
9834 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9835 | |
2986cac2 | 9836 | mode = "Restart"; |
2986cac2 | 9837 | } |
9838 | } | |
9839 | ||
9840 | if (use_json) { | |
13909c4f | 9841 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 9842 | } else |
9843 | vty_out(vty, mode, "\n"); | |
9844 | } | |
9845 | ||
13909c4f DS |
9846 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
9847 | struct peer *p, | |
9848 | bool use_json, | |
9849 | json_object *json) | |
2986cac2 | 9850 | { |
9851 | const char *mode = "Invalid"; | |
9852 | ||
9853 | if (!use_json) | |
a53ca37b | 9854 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 9855 | |
9856 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9857 | mode = "Helper"; | |
9858 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9859 | mode = "Restart"; | |
9860 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9861 | mode = "Disable"; | |
2ba1fe69 | 9862 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 9863 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
9864 | mode = "Helper*"; | |
9865 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9866 | mode = "Restart*"; | |
9867 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9868 | mode = "Disable*"; | |
9869 | else | |
9870 | mode = "Invalid*"; | |
2ba1fe69 | 9871 | } |
2986cac2 | 9872 | |
9873 | if (use_json) { | |
13909c4f | 9874 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 9875 | } else { |
9876 | vty_out(vty, mode, "\n"); | |
9877 | } | |
9878 | } | |
9879 | ||
13909c4f DS |
9880 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
9881 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 9882 | { |
2ba1fe69 | 9883 | afi_t afi; |
9884 | safi_t safi; | |
2986cac2 | 9885 | json_object *json_afi_safi = NULL; |
9886 | json_object *json_timer = NULL; | |
9887 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 9888 | bool eor_flag = false; |
2986cac2 | 9889 | |
9890 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9891 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
9892 | if (!peer->afc[afi][safi]) |
9893 | continue; | |
2986cac2 | 9894 | |
13909c4f DS |
9895 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9896 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
9897 | continue; | |
9e3b51a7 | 9898 | |
13909c4f DS |
9899 | if (use_json) { |
9900 | json_afi_safi = json_object_new_object(); | |
9901 | json_endofrib_status = json_object_new_object(); | |
9902 | json_timer = json_object_new_object(); | |
9903 | } | |
2986cac2 | 9904 | |
13909c4f DS |
9905 | if (peer->eor_stime[afi][safi] |
9906 | >= peer->pkt_stime[afi][safi]) | |
9907 | eor_flag = true; | |
9908 | else | |
9909 | eor_flag = false; | |
2986cac2 | 9910 | |
13909c4f | 9911 | if (!use_json) { |
a53ca37b | 9912 | vty_out(vty, " %s:\n", |
13909c4f | 9913 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 9914 | |
a53ca37b | 9915 | vty_out(vty, " F bit: "); |
698ba8d0 | 9916 | } |
2986cac2 | 9917 | |
13909c4f DS |
9918 | if (peer->nsf[afi][safi] |
9919 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
9920 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 9921 | |
13909c4f DS |
9922 | if (use_json) { |
9923 | json_object_boolean_true_add( | |
2986cac2 | 9924 | json_afi_safi, "fBit"); |
13909c4f DS |
9925 | } else |
9926 | vty_out(vty, "True\n"); | |
9927 | } else { | |
9928 | if (use_json) | |
9929 | json_object_boolean_false_add( | |
9930 | json_afi_safi, "fBit"); | |
9931 | else | |
9932 | vty_out(vty, "False\n"); | |
9933 | } | |
2986cac2 | 9934 | |
13909c4f | 9935 | if (!use_json) |
a53ca37b | 9936 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 9937 | |
13909c4f DS |
9938 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
9939 | PEER_STATUS_EOR_SEND)) { | |
9940 | if (use_json) { | |
9941 | json_object_boolean_true_add( | |
2986cac2 | 9942 | json_endofrib_status, |
13909c4f | 9943 | "endOfRibSend"); |
9e3b51a7 | 9944 | |
13909c4f DS |
9945 | PRINT_EOR_JSON(eor_flag); |
9946 | } else { | |
9947 | vty_out(vty, "Yes\n"); | |
9948 | vty_out(vty, | |
a53ca37b | 9949 | " End-of-RIB sent after update: "); |
2986cac2 | 9950 | |
13909c4f DS |
9951 | PRINT_EOR(eor_flag); |
9952 | } | |
9953 | } else { | |
9954 | if (use_json) { | |
9955 | json_object_boolean_false_add( | |
2986cac2 | 9956 | json_endofrib_status, |
13909c4f DS |
9957 | "endOfRibSend"); |
9958 | json_object_boolean_false_add( | |
9e3b51a7 | 9959 | json_endofrib_status, |
13909c4f DS |
9960 | "endOfRibSentAfterUpdate"); |
9961 | } else { | |
9962 | vty_out(vty, "No\n"); | |
9963 | vty_out(vty, | |
a53ca37b | 9964 | " End-of-RIB sent after update: "); |
13909c4f | 9965 | vty_out(vty, "No\n"); |
2986cac2 | 9966 | } |
13909c4f | 9967 | } |
2986cac2 | 9968 | |
a53ca37b DA |
9969 | if (!use_json) |
9970 | vty_out(vty, " End-of-RIB received: "); | |
9971 | ||
9972 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9973 | PEER_STATUS_EOR_RECEIVED)) { | |
9974 | if (use_json) | |
9975 | json_object_boolean_true_add( | |
9976 | json_endofrib_status, | |
9977 | "endOfRibRecv"); | |
9978 | else | |
9979 | vty_out(vty, "Yes\n"); | |
9980 | } else { | |
9981 | if (use_json) | |
9982 | json_object_boolean_false_add( | |
9983 | json_endofrib_status, | |
9984 | "endOfRibRecv"); | |
9985 | else | |
9986 | vty_out(vty, "No\n"); | |
9987 | } | |
9988 | ||
13909c4f DS |
9989 | if (use_json) { |
9990 | json_object_int_add(json_timer, | |
9991 | "stalePathTimer", | |
9992 | peer->bgp->stalepath_time); | |
2986cac2 | 9993 | |
13909c4f DS |
9994 | if (peer->t_gr_stale != NULL) { |
9995 | json_object_int_add( | |
2986cac2 | 9996 | json_timer, |
9997 | "stalePathTimerRemaining", | |
9998 | thread_timer_remain_second( | |
13909c4f DS |
9999 | peer->t_gr_stale)); |
10000 | } | |
3a75afa4 | 10001 | |
13909c4f DS |
10002 | /* Display Configured Selection |
10003 | * Deferral only when when | |
10004 | * Gr mode is enabled. | |
10005 | */ | |
10006 | if (CHECK_FLAG(peer->flags, | |
10007 | PEER_FLAG_GRACEFUL_RESTART)) { | |
10008 | json_object_int_add( | |
3a75afa4 | 10009 | json_timer, |
2986cac2 | 10010 | "selectionDeferralTimer", |
10011 | peer->bgp->stalepath_time); | |
13909c4f | 10012 | } |
2986cac2 | 10013 | |
13909c4f DS |
10014 | if (peer->bgp->gr_info[afi][safi] |
10015 | .t_select_deferral | |
10016 | != NULL) { | |
2986cac2 | 10017 | |
13909c4f | 10018 | json_object_int_add( |
2986cac2 | 10019 | json_timer, |
10020 | "selectionDeferralTimerRemaining", | |
10021 | thread_timer_remain_second( | |
13909c4f DS |
10022 | peer->bgp |
10023 | ->gr_info[afi] | |
10024 | [safi] | |
10025 | .t_select_deferral)); | |
10026 | } | |
10027 | } else { | |
a53ca37b | 10028 | vty_out(vty, " Timers:\n"); |
13909c4f | 10029 | vty_out(vty, |
a53ca37b DA |
10030 | " Configured Stale Path Time(sec): %u\n", |
10031 | peer->bgp->stalepath_time); | |
2986cac2 | 10032 | |
a53ca37b | 10033 | if (peer->t_gr_stale != NULL) |
2986cac2 | 10034 | vty_out(vty, |
a53ca37b | 10035 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 10036 | thread_timer_remain_second( |
13909c4f | 10037 | peer->t_gr_stale)); |
13909c4f DS |
10038 | /* Display Configured Selection |
10039 | * Deferral only when when | |
10040 | * Gr mode is enabled. | |
10041 | */ | |
10042 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 10043 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 10044 | vty_out(vty, |
a53ca37b | 10045 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 10046 | peer->bgp->select_defer_time); |
2986cac2 | 10047 | |
13909c4f DS |
10048 | if (peer->bgp->gr_info[afi][safi] |
10049 | .t_select_deferral | |
a53ca37b | 10050 | != NULL) |
13909c4f | 10051 | vty_out(vty, |
a53ca37b | 10052 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 10053 | thread_timer_remain_second( |
13909c4f DS |
10054 | peer->bgp |
10055 | ->gr_info[afi] | |
10056 | [safi] | |
10057 | .t_select_deferral)); | |
2986cac2 | 10058 | } |
13909c4f DS |
10059 | if (use_json) { |
10060 | json_object_object_add(json_afi_safi, | |
10061 | "endOfRibStatus", | |
10062 | json_endofrib_status); | |
10063 | json_object_object_add(json_afi_safi, "timers", | |
10064 | json_timer); | |
10065 | json_object_object_add( | |
10066 | json, get_afi_safi_str(afi, safi, true), | |
10067 | json_afi_safi); | |
10068 | } | |
2986cac2 | 10069 | } |
10070 | } | |
10071 | } | |
10072 | ||
36235319 QY |
10073 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
10074 | struct peer *p, | |
10075 | bool use_json, | |
10076 | json_object *json) | |
2986cac2 | 10077 | { |
10078 | if (use_json) { | |
10079 | json_object *json_timer = NULL; | |
10080 | ||
10081 | json_timer = json_object_new_object(); | |
10082 | ||
13909c4f DS |
10083 | json_object_int_add(json_timer, "configuredRestartTimer", |
10084 | p->bgp->restart_time); | |
2986cac2 | 10085 | |
13909c4f DS |
10086 | json_object_int_add(json_timer, "receivedRestartTimer", |
10087 | p->v_gr_restart); | |
2986cac2 | 10088 | |
13909c4f DS |
10089 | if (p->t_gr_restart != NULL) |
10090 | json_object_int_add( | |
10091 | json_timer, "restartTimerRemaining", | |
10092 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 10093 | |
10094 | json_object_object_add(json, "timers", json_timer); | |
10095 | } else { | |
10096 | ||
a53ca37b DA |
10097 | vty_out(vty, " Timers:\n"); |
10098 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 10099 | p->bgp->restart_time); |
2986cac2 | 10100 | |
a53ca37b | 10101 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
10102 | p->v_gr_restart); |
10103 | if (p->t_gr_restart != NULL) | |
a53ca37b | 10104 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 10105 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 10106 | if (p->t_gr_restart != NULL) { |
a53ca37b | 10107 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
10108 | thread_timer_remain_second(p->t_gr_restart)); |
10109 | } | |
2986cac2 | 10110 | } |
10111 | } | |
10112 | ||
10113 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 10114 | bool use_json, json_object *json) |
2986cac2 | 10115 | { |
10116 | char buf[SU_ADDRSTRLEN] = {0}; | |
10117 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
10118 | /* '*' + v6 address of neighbor */ |
10119 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 10120 | |
2986cac2 | 10121 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
10122 | dn_flag[0] = '*'; | |
10123 | ||
10124 | if (p->conf_if) { | |
10125 | if (use_json) | |
13909c4f DS |
10126 | json_object_string_add( |
10127 | json, "neighborAddr", | |
2986cac2 | 10128 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
10129 | ? "none" |
10130 | : sockunion2str(&p->su, buf, | |
10131 | SU_ADDRSTRLEN)); | |
2986cac2 | 10132 | else |
13909c4f | 10133 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 10134 | BGP_PEER_SU_UNSPEC(p) |
10135 | ? "none" | |
10136 | : sockunion2str(&p->su, buf, | |
10137 | SU_ADDRSTRLEN)); | |
10138 | } else { | |
772270f3 QY |
10139 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
10140 | p->host); | |
2986cac2 | 10141 | |
10142 | if (use_json) | |
36235319 QY |
10143 | json_object_string_add(json, "neighborAddr", |
10144 | neighborAddr); | |
2986cac2 | 10145 | else |
36235319 | 10146 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 10147 | } |
10148 | ||
10149 | /* more gr info in new format */ | |
10150 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
10151 | } | |
10152 | ||
d62a17ae | 10153 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 10154 | safi_t safi, bool use_json, |
d62a17ae | 10155 | json_object *json_neigh) |
10156 | { | |
0291c246 MK |
10157 | struct bgp_filter *filter; |
10158 | struct peer_af *paf; | |
10159 | char orf_pfx_name[BUFSIZ]; | |
10160 | int orf_pfx_count; | |
10161 | json_object *json_af = NULL; | |
10162 | json_object *json_prefA = NULL; | |
10163 | json_object *json_prefB = NULL; | |
10164 | json_object *json_addr = NULL; | |
d62a17ae | 10165 | |
10166 | if (use_json) { | |
10167 | json_addr = json_object_new_object(); | |
10168 | json_af = json_object_new_object(); | |
10169 | filter = &p->filter[afi][safi]; | |
10170 | ||
10171 | if (peer_group_active(p)) | |
10172 | json_object_string_add(json_addr, "peerGroupMember", | |
10173 | p->group->name); | |
10174 | ||
10175 | paf = peer_af_find(p, afi, safi); | |
10176 | if (paf && PAF_SUBGRP(paf)) { | |
10177 | json_object_int_add(json_addr, "updateGroupId", | |
10178 | PAF_UPDGRP(paf)->id); | |
10179 | json_object_int_add(json_addr, "subGroupId", | |
10180 | PAF_SUBGRP(paf)->id); | |
10181 | json_object_int_add(json_addr, "packetQueueLength", | |
10182 | bpacket_queue_virtual_length(paf)); | |
10183 | } | |
10184 | ||
10185 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10186 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10187 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10188 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10189 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10190 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10191 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10192 | json_object_int_add(json_af, "orfType", | |
10193 | ORF_TYPE_PREFIX); | |
10194 | json_prefA = json_object_new_object(); | |
10195 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
10196 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
10197 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10198 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10199 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
10200 | use_json, json_prefA); | |
10201 | json_object_object_add(json_af, "orfPrefixList", | |
10202 | json_prefA); | |
10203 | } | |
10204 | ||
10205 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10206 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10207 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10208 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10209 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10210 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10211 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10212 | json_object_int_add(json_af, "orfOldType", | |
10213 | ORF_TYPE_PREFIX_OLD); | |
10214 | json_prefB = json_object_new_object(); | |
10215 | bgp_show_peer_afi_orf_cap( | |
10216 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10217 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10218 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10219 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
10220 | json_prefB); | |
10221 | json_object_object_add(json_af, "orfOldPrefixList", | |
10222 | json_prefB); | |
10223 | } | |
10224 | ||
10225 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10226 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10227 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10228 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10229 | PEER_CAP_ORF_PREFIX_SM_OLD_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 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10235 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10236 | json_object_object_add(json_addr, "afDependentCap", | |
10237 | json_af); | |
10238 | else | |
10239 | json_object_free(json_af); | |
10240 | ||
772270f3 QY |
10241 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10242 | p->host, afi, safi); | |
d62a17ae | 10243 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10244 | NULL, afi, orf_pfx_name, use_json); | |
10245 | ||
10246 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10247 | PEER_STATUS_ORF_PREFIX_SEND) | |
10248 | || orf_pfx_count) { | |
10249 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10250 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10251 | json_object_boolean_true_add(json_neigh, | |
10252 | "orfSent"); | |
10253 | if (orf_pfx_count) | |
10254 | json_object_int_add(json_addr, "orfRecvCounter", | |
10255 | orf_pfx_count); | |
10256 | } | |
10257 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10258 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10259 | json_object_string_add( | |
10260 | json_addr, "orfFirstUpdate", | |
10261 | "deferredUntilORFOrRouteRefreshRecvd"); | |
10262 | ||
10263 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10264 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10265 | json_object_boolean_true_add(json_addr, | |
10266 | "routeReflectorClient"); | |
10267 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10268 | PEER_FLAG_RSERVER_CLIENT)) | |
10269 | json_object_boolean_true_add(json_addr, | |
10270 | "routeServerClient"); | |
10271 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10272 | json_object_boolean_true_add(json_addr, | |
10273 | "inboundSoftConfigPermit"); | |
10274 | ||
10275 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10276 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10277 | json_object_boolean_true_add( | |
10278 | json_addr, | |
10279 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
10280 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10281 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10282 | json_object_boolean_true_add( | |
10283 | json_addr, | |
10284 | "privateAsNumsReplacedInUpdatesToNbr"); | |
10285 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10286 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10287 | json_object_boolean_true_add( | |
10288 | json_addr, | |
10289 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
10290 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10291 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10292 | json_object_boolean_true_add( | |
10293 | json_addr, | |
10294 | "privateAsNumsRemovedInUpdatesToNbr"); | |
10295 | ||
dcc68b5e MS |
10296 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10297 | json_object_boolean_true_add( | |
10298 | json_addr, | |
10299 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10300 | ->type_json_name); | |
d62a17ae | 10301 | |
10302 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10303 | json_object_string_add(json_addr, | |
10304 | "overrideASNsInOutboundUpdates", | |
10305 | "ifAspathEqualRemoteAs"); | |
10306 | ||
10307 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10308 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10309 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10310 | json_object_boolean_true_add(json_addr, | |
10311 | "routerAlwaysNextHop"); | |
10312 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10313 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10314 | json_object_boolean_true_add( | |
10315 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
10316 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10317 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10318 | json_object_boolean_true_add( | |
10319 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
10320 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10321 | json_object_boolean_true_add( | |
10322 | json_addr, "unchangedMedPropogatedToNbr"); | |
10323 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10324 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10325 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
10326 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10327 | PEER_FLAG_SEND_COMMUNITY) | |
10328 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10329 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10330 | json_object_string_add(json_addr, | |
10331 | "commAttriSentToNbr", | |
10332 | "extendedAndStandard"); | |
10333 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10334 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10335 | json_object_string_add(json_addr, | |
10336 | "commAttriSentToNbr", | |
10337 | "extended"); | |
10338 | else | |
10339 | json_object_string_add(json_addr, | |
10340 | "commAttriSentToNbr", | |
10341 | "standard"); | |
10342 | } | |
10343 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10344 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10345 | if (p->default_rmap[afi][safi].name) | |
10346 | json_object_string_add( | |
10347 | json_addr, "defaultRouteMap", | |
10348 | p->default_rmap[afi][safi].name); | |
10349 | ||
10350 | if (paf && PAF_SUBGRP(paf) | |
10351 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10352 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10353 | json_object_boolean_true_add(json_addr, | |
10354 | "defaultSent"); | |
10355 | else | |
10356 | json_object_boolean_true_add(json_addr, | |
10357 | "defaultNotSent"); | |
10358 | } | |
10359 | ||
dff8f48d | 10360 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10361 | if (is_evpn_enabled()) |
60466a63 QY |
10362 | json_object_boolean_true_add( |
10363 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10364 | } |
10365 | ||
d62a17ae | 10366 | if (filter->plist[FILTER_IN].name |
10367 | || filter->dlist[FILTER_IN].name | |
10368 | || filter->aslist[FILTER_IN].name | |
10369 | || filter->map[RMAP_IN].name) | |
10370 | json_object_boolean_true_add(json_addr, | |
10371 | "inboundPathPolicyConfig"); | |
10372 | if (filter->plist[FILTER_OUT].name | |
10373 | || filter->dlist[FILTER_OUT].name | |
10374 | || filter->aslist[FILTER_OUT].name | |
10375 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10376 | json_object_boolean_true_add( | |
10377 | json_addr, "outboundPathPolicyConfig"); | |
10378 | ||
10379 | /* prefix-list */ | |
10380 | if (filter->plist[FILTER_IN].name) | |
10381 | json_object_string_add(json_addr, | |
10382 | "incomingUpdatePrefixFilterList", | |
10383 | filter->plist[FILTER_IN].name); | |
10384 | if (filter->plist[FILTER_OUT].name) | |
10385 | json_object_string_add(json_addr, | |
10386 | "outgoingUpdatePrefixFilterList", | |
10387 | filter->plist[FILTER_OUT].name); | |
10388 | ||
10389 | /* distribute-list */ | |
10390 | if (filter->dlist[FILTER_IN].name) | |
10391 | json_object_string_add( | |
10392 | json_addr, "incomingUpdateNetworkFilterList", | |
10393 | filter->dlist[FILTER_IN].name); | |
10394 | if (filter->dlist[FILTER_OUT].name) | |
10395 | json_object_string_add( | |
10396 | json_addr, "outgoingUpdateNetworkFilterList", | |
10397 | filter->dlist[FILTER_OUT].name); | |
10398 | ||
10399 | /* filter-list. */ | |
10400 | if (filter->aslist[FILTER_IN].name) | |
10401 | json_object_string_add(json_addr, | |
10402 | "incomingUpdateAsPathFilterList", | |
10403 | filter->aslist[FILTER_IN].name); | |
10404 | if (filter->aslist[FILTER_OUT].name) | |
10405 | json_object_string_add(json_addr, | |
10406 | "outgoingUpdateAsPathFilterList", | |
10407 | filter->aslist[FILTER_OUT].name); | |
10408 | ||
10409 | /* route-map. */ | |
10410 | if (filter->map[RMAP_IN].name) | |
10411 | json_object_string_add( | |
10412 | json_addr, "routeMapForIncomingAdvertisements", | |
10413 | filter->map[RMAP_IN].name); | |
10414 | if (filter->map[RMAP_OUT].name) | |
10415 | json_object_string_add( | |
10416 | json_addr, "routeMapForOutgoingAdvertisements", | |
10417 | filter->map[RMAP_OUT].name); | |
10418 | ||
9dac9fc8 | 10419 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10420 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10421 | && !bgp_inbound_policy_exists(p, filter)) |
10422 | json_object_string_add( | |
10423 | json_addr, "inboundEbgpRequiresPolicy", | |
10424 | "Inbound updates discarded due to missing policy"); | |
10425 | ||
10426 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10427 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10428 | && (!bgp_outbound_policy_exists(p, filter))) |
10429 | json_object_string_add( | |
10430 | json_addr, "outboundEbgpRequiresPolicy", | |
10431 | "Outbound updates discarded due to missing policy"); | |
10432 | ||
d62a17ae | 10433 | /* unsuppress-map */ |
10434 | if (filter->usmap.name) | |
10435 | json_object_string_add(json_addr, | |
10436 | "selectiveUnsuppressRouteMap", | |
10437 | filter->usmap.name); | |
10438 | ||
10439 | /* Receive prefix count */ | |
10440 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10441 | p->pcount[afi][safi]); | |
50e05855 AD |
10442 | if (paf && PAF_SUBGRP(paf)) |
10443 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10444 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10445 | |
fde246e8 DA |
10446 | /* Maximum prefix */ |
10447 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10448 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10449 | p->pmax_out[afi][safi]); | |
10450 | ||
d62a17ae | 10451 | /* Maximum prefix */ |
10452 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10453 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10454 | p->pmax[afi][safi]); | |
10455 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10456 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10457 | json_object_boolean_true_add( | |
10458 | json_addr, "prefixAllowedMaxWarning"); | |
10459 | json_object_int_add(json_addr, | |
10460 | "prefixAllowedWarningThresh", | |
10461 | p->pmax_threshold[afi][safi]); | |
10462 | if (p->pmax_restart[afi][safi]) | |
10463 | json_object_int_add( | |
10464 | json_addr, | |
10465 | "prefixAllowedRestartIntervalMsecs", | |
10466 | p->pmax_restart[afi][safi] * 60000); | |
10467 | } | |
2986cac2 | 10468 | json_object_object_add(json_neigh, |
36235319 | 10469 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 10470 | json_addr); |
10471 | ||
10472 | } else { | |
10473 | filter = &p->filter[afi][safi]; | |
10474 | ||
10475 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10476 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10477 | |
10478 | if (peer_group_active(p)) | |
10479 | vty_out(vty, " %s peer-group member\n", | |
10480 | p->group->name); | |
10481 | ||
10482 | paf = peer_af_find(p, afi, safi); | |
10483 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 10484 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 10485 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10486 | vty_out(vty, " Packet Queue length %d\n", | |
10487 | bpacket_queue_virtual_length(paf)); | |
10488 | } else { | |
10489 | vty_out(vty, " Not part of any update group\n"); | |
10490 | } | |
10491 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10492 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10493 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10494 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10495 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10496 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10497 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10498 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10499 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10500 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10501 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10502 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10503 | ||
10504 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10505 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10506 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10507 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10508 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10509 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10510 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10511 | vty_out(vty, | |
10512 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10513 | ORF_TYPE_PREFIX); | |
10514 | bgp_show_peer_afi_orf_cap( | |
10515 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10516 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10517 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10518 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10519 | } | |
10520 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10521 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10522 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10523 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10524 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10525 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10526 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10527 | vty_out(vty, | |
10528 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10529 | ORF_TYPE_PREFIX_OLD); | |
10530 | bgp_show_peer_afi_orf_cap( | |
10531 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10532 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10533 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10534 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10535 | } | |
10536 | ||
772270f3 QY |
10537 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10538 | p->host, afi, safi); | |
d62a17ae | 10539 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10540 | NULL, afi, orf_pfx_name, use_json); | |
10541 | ||
10542 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10543 | PEER_STATUS_ORF_PREFIX_SEND) | |
10544 | || orf_pfx_count) { | |
10545 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10546 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10547 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10548 | vty_out(vty, " sent;"); | |
10549 | if (orf_pfx_count) | |
10550 | vty_out(vty, " received (%d entries)", | |
10551 | orf_pfx_count); | |
10552 | vty_out(vty, "\n"); | |
10553 | } | |
10554 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10555 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10556 | vty_out(vty, | |
10557 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10558 | ||
10559 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10560 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10561 | vty_out(vty, " Route-Reflector Client\n"); | |
10562 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10563 | PEER_FLAG_RSERVER_CLIENT)) | |
10564 | vty_out(vty, " Route-Server Client\n"); | |
10565 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10566 | vty_out(vty, | |
10567 | " Inbound soft reconfiguration allowed\n"); | |
10568 | ||
10569 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10570 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10571 | vty_out(vty, | |
10572 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10573 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10574 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10575 | vty_out(vty, | |
10576 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10577 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10578 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10579 | vty_out(vty, | |
10580 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10581 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10582 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10583 | vty_out(vty, | |
10584 | " Private AS numbers removed in updates to this neighbor\n"); | |
10585 | ||
dcc68b5e MS |
10586 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10587 | vty_out(vty, " %s\n", | |
10588 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10589 | ->human_description); | |
d62a17ae | 10590 | |
10591 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10592 | vty_out(vty, | |
10593 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10594 | ||
10595 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10596 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10597 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10598 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10599 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10600 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10601 | vty_out(vty, | |
10602 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10603 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10604 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10605 | vty_out(vty, | |
10606 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10607 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10608 | vty_out(vty, | |
10609 | " MED is propagated unchanged to this neighbor\n"); | |
10610 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10611 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10612 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10613 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10614 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10615 | vty_out(vty, | |
10616 | " Community attribute sent to this neighbor"); | |
10617 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10618 | PEER_FLAG_SEND_COMMUNITY) | |
10619 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10620 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10621 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10622 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10623 | vty_out(vty, "(all)\n"); | |
10624 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10625 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10626 | vty_out(vty, "(large)\n"); | |
10627 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10628 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10629 | vty_out(vty, "(extended)\n"); | |
10630 | else | |
10631 | vty_out(vty, "(standard)\n"); | |
10632 | } | |
10633 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10634 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10635 | vty_out(vty, " Default information originate,"); | |
10636 | ||
10637 | if (p->default_rmap[afi][safi].name) | |
10638 | vty_out(vty, " default route-map %s%s,", | |
10639 | p->default_rmap[afi][safi].map ? "*" | |
10640 | : "", | |
10641 | p->default_rmap[afi][safi].name); | |
10642 | if (paf && PAF_SUBGRP(paf) | |
10643 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10644 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10645 | vty_out(vty, " default sent\n"); | |
10646 | else | |
10647 | vty_out(vty, " default not sent\n"); | |
10648 | } | |
10649 | ||
dff8f48d MK |
10650 | /* advertise-vni-all */ |
10651 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10652 | if (is_evpn_enabled()) |
dff8f48d MK |
10653 | vty_out(vty, " advertise-all-vni\n"); |
10654 | } | |
10655 | ||
d62a17ae | 10656 | if (filter->plist[FILTER_IN].name |
10657 | || filter->dlist[FILTER_IN].name | |
10658 | || filter->aslist[FILTER_IN].name | |
10659 | || filter->map[RMAP_IN].name) | |
10660 | vty_out(vty, " Inbound path policy configured\n"); | |
10661 | if (filter->plist[FILTER_OUT].name | |
10662 | || filter->dlist[FILTER_OUT].name | |
10663 | || filter->aslist[FILTER_OUT].name | |
10664 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10665 | vty_out(vty, " Outbound path policy configured\n"); | |
10666 | ||
10667 | /* prefix-list */ | |
10668 | if (filter->plist[FILTER_IN].name) | |
10669 | vty_out(vty, | |
10670 | " Incoming update prefix filter list is %s%s\n", | |
10671 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10672 | filter->plist[FILTER_IN].name); | |
10673 | if (filter->plist[FILTER_OUT].name) | |
10674 | vty_out(vty, | |
10675 | " Outgoing update prefix filter list is %s%s\n", | |
10676 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10677 | filter->plist[FILTER_OUT].name); | |
10678 | ||
10679 | /* distribute-list */ | |
10680 | if (filter->dlist[FILTER_IN].name) | |
10681 | vty_out(vty, | |
10682 | " Incoming update network filter list is %s%s\n", | |
10683 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10684 | filter->dlist[FILTER_IN].name); | |
10685 | if (filter->dlist[FILTER_OUT].name) | |
10686 | vty_out(vty, | |
10687 | " Outgoing update network filter list is %s%s\n", | |
10688 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10689 | filter->dlist[FILTER_OUT].name); | |
10690 | ||
10691 | /* filter-list. */ | |
10692 | if (filter->aslist[FILTER_IN].name) | |
10693 | vty_out(vty, | |
10694 | " Incoming update AS path filter list is %s%s\n", | |
10695 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10696 | filter->aslist[FILTER_IN].name); | |
10697 | if (filter->aslist[FILTER_OUT].name) | |
10698 | vty_out(vty, | |
10699 | " Outgoing update AS path filter list is %s%s\n", | |
10700 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10701 | filter->aslist[FILTER_OUT].name); | |
10702 | ||
10703 | /* route-map. */ | |
10704 | if (filter->map[RMAP_IN].name) | |
10705 | vty_out(vty, | |
10706 | " Route map for incoming advertisements is %s%s\n", | |
10707 | filter->map[RMAP_IN].map ? "*" : "", | |
10708 | filter->map[RMAP_IN].name); | |
10709 | if (filter->map[RMAP_OUT].name) | |
10710 | vty_out(vty, | |
10711 | " Route map for outgoing advertisements is %s%s\n", | |
10712 | filter->map[RMAP_OUT].map ? "*" : "", | |
10713 | filter->map[RMAP_OUT].name); | |
10714 | ||
9dac9fc8 | 10715 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10716 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10717 | && !bgp_inbound_policy_exists(p, filter)) |
10718 | vty_out(vty, | |
10719 | " Inbound updates discarded due to missing policy\n"); | |
10720 | ||
10721 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10722 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10723 | && !bgp_outbound_policy_exists(p, filter)) |
10724 | vty_out(vty, | |
10725 | " Outbound updates discarded due to missing policy\n"); | |
10726 | ||
d62a17ae | 10727 | /* unsuppress-map */ |
10728 | if (filter->usmap.name) | |
10729 | vty_out(vty, | |
10730 | " Route map for selective unsuppress is %s%s\n", | |
10731 | filter->usmap.map ? "*" : "", | |
10732 | filter->usmap.name); | |
10733 | ||
10734 | /* Receive prefix count */ | |
6cde4b45 | 10735 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 10736 | p->pcount[afi][safi]); |
d62a17ae | 10737 | |
fde246e8 DA |
10738 | /* maximum-prefix-out */ |
10739 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10740 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10741 | vty_out(vty, | |
6cde4b45 | 10742 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
10743 | p->pmax_out[afi][safi]); |
10744 | ||
d62a17ae | 10745 | /* Maximum prefix */ |
10746 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 10747 | vty_out(vty, |
6cde4b45 | 10748 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 10749 | p->pmax[afi][safi], |
10750 | CHECK_FLAG(p->af_flags[afi][safi], | |
10751 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10752 | ? " (warning-only)" | |
10753 | : ""); | |
10754 | vty_out(vty, " Threshold for warning message %d%%", | |
10755 | p->pmax_threshold[afi][safi]); | |
10756 | if (p->pmax_restart[afi][safi]) | |
10757 | vty_out(vty, ", restart interval %d min", | |
10758 | p->pmax_restart[afi][safi]); | |
10759 | vty_out(vty, "\n"); | |
10760 | } | |
10761 | ||
10762 | vty_out(vty, "\n"); | |
10763 | } | |
10764 | } | |
10765 | ||
9f049418 | 10766 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10767 | json_object *json) |
718e3744 | 10768 | { |
d62a17ae | 10769 | struct bgp *bgp; |
10770 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10771 | char timebuf[BGP_UPTIME_LEN]; | |
10772 | char dn_flag[2]; | |
d62a17ae | 10773 | afi_t afi; |
10774 | safi_t safi; | |
d7c0a89a QY |
10775 | uint16_t i; |
10776 | uint8_t *msg; | |
d62a17ae | 10777 | json_object *json_neigh = NULL; |
10778 | time_t epoch_tbuf; | |
718e3744 | 10779 | |
d62a17ae | 10780 | bgp = p->bgp; |
10781 | ||
10782 | if (use_json) | |
10783 | json_neigh = json_object_new_object(); | |
10784 | ||
10785 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10786 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10787 | dn_flag[0] = '*'; | |
10788 | ||
10789 | if (!use_json) { | |
10790 | if (p->conf_if) /* Configured interface name. */ | |
10791 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10792 | BGP_PEER_SU_UNSPEC(p) | |
10793 | ? "None" | |
10794 | : sockunion2str(&p->su, buf, | |
10795 | SU_ADDRSTRLEN)); | |
10796 | else /* Configured IP address. */ | |
10797 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10798 | p->host); | |
10799 | } | |
10800 | ||
10801 | if (use_json) { | |
10802 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10803 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10804 | "none"); | |
10805 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10806 | json_object_string_add( | |
10807 | json_neigh, "bgpNeighborAddr", | |
10808 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10809 | ||
10810 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10811 | ||
10812 | if (p->change_local_as) | |
10813 | json_object_int_add(json_neigh, "localAs", | |
10814 | p->change_local_as); | |
10815 | else | |
10816 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10817 | ||
10818 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10819 | json_object_boolean_true_add(json_neigh, | |
10820 | "localAsNoPrepend"); | |
10821 | ||
10822 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10823 | json_object_boolean_true_add(json_neigh, | |
10824 | "localAsReplaceAs"); | |
10825 | } else { | |
10826 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10827 | || (p->as_type == AS_INTERNAL)) | |
10828 | vty_out(vty, "remote AS %u, ", p->as); | |
10829 | else | |
10830 | vty_out(vty, "remote AS Unspecified, "); | |
10831 | vty_out(vty, "local AS %u%s%s, ", | |
10832 | p->change_local_as ? p->change_local_as : p->local_as, | |
10833 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10834 | ? " no-prepend" | |
10835 | : "", | |
10836 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10837 | ? " replace-as" | |
10838 | : ""); | |
10839 | } | |
faa16034 DS |
10840 | /* peer type internal or confed-internal */ |
10841 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10842 | if (use_json) { |
10843 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10844 | json_object_boolean_true_add( | |
10845 | json_neigh, "nbrConfedInternalLink"); | |
10846 | else | |
10847 | json_object_boolean_true_add(json_neigh, | |
10848 | "nbrInternalLink"); | |
10849 | } else { | |
10850 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10851 | vty_out(vty, "confed-internal link\n"); | |
10852 | else | |
10853 | vty_out(vty, "internal link\n"); | |
10854 | } | |
faa16034 DS |
10855 | /* peer type external or confed-external */ |
10856 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10857 | if (use_json) { |
10858 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10859 | json_object_boolean_true_add( | |
10860 | json_neigh, "nbrConfedExternalLink"); | |
10861 | else | |
10862 | json_object_boolean_true_add(json_neigh, | |
10863 | "nbrExternalLink"); | |
10864 | } else { | |
10865 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10866 | vty_out(vty, "confed-external link\n"); | |
10867 | else | |
10868 | vty_out(vty, "external link\n"); | |
10869 | } | |
faa16034 DS |
10870 | } else { |
10871 | if (use_json) | |
10872 | json_object_boolean_true_add(json_neigh, | |
10873 | "nbrUnspecifiedLink"); | |
10874 | else | |
10875 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10876 | } |
10877 | ||
10878 | /* Description. */ | |
10879 | if (p->desc) { | |
10880 | if (use_json) | |
10881 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10882 | else | |
10883 | vty_out(vty, " Description: %s\n", p->desc); | |
10884 | } | |
10885 | ||
10886 | if (p->hostname) { | |
10887 | if (use_json) { | |
10888 | if (p->hostname) | |
10889 | json_object_string_add(json_neigh, "hostname", | |
10890 | p->hostname); | |
10891 | ||
10892 | if (p->domainname) | |
10893 | json_object_string_add(json_neigh, "domainname", | |
10894 | p->domainname); | |
10895 | } else { | |
10896 | if (p->domainname && (p->domainname[0] != '\0')) | |
10897 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10898 | p->domainname); | |
10899 | else | |
10900 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10901 | } | |
10902 | } | |
10903 | ||
10904 | /* Peer-group */ | |
10905 | if (p->group) { | |
10906 | if (use_json) { | |
10907 | json_object_string_add(json_neigh, "peerGroup", | |
10908 | p->group->name); | |
10909 | ||
10910 | if (dn_flag[0]) { | |
10911 | struct prefix prefix, *range = NULL; | |
10912 | ||
10913 | sockunion2hostprefix(&(p->su), &prefix); | |
10914 | range = peer_group_lookup_dynamic_neighbor_range( | |
10915 | p->group, &prefix); | |
10916 | ||
10917 | if (range) { | |
10918 | prefix2str(range, buf1, sizeof(buf1)); | |
10919 | json_object_string_add( | |
10920 | json_neigh, | |
10921 | "peerSubnetRangeGroup", buf1); | |
10922 | } | |
10923 | } | |
10924 | } else { | |
10925 | vty_out(vty, | |
10926 | " Member of peer-group %s for session parameters\n", | |
10927 | p->group->name); | |
10928 | ||
10929 | if (dn_flag[0]) { | |
10930 | struct prefix prefix, *range = NULL; | |
10931 | ||
10932 | sockunion2hostprefix(&(p->su), &prefix); | |
10933 | range = peer_group_lookup_dynamic_neighbor_range( | |
10934 | p->group, &prefix); | |
10935 | ||
10936 | if (range) { | |
d62a17ae | 10937 | vty_out(vty, |
1b78780b DL |
10938 | " Belongs to the subnet range group: %pFX\n", |
10939 | range); | |
d62a17ae | 10940 | } |
10941 | } | |
10942 | } | |
10943 | } | |
10944 | ||
10945 | if (use_json) { | |
10946 | /* Administrative shutdown. */ | |
10947 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10948 | json_object_boolean_true_add(json_neigh, | |
10949 | "adminShutDown"); | |
10950 | ||
10951 | /* BGP Version. */ | |
10952 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10953 | json_object_string_add( | |
10954 | json_neigh, "remoteRouterId", | |
10955 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10956 | json_object_string_add( |
10957 | json_neigh, "localRouterId", | |
10958 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10959 | sizeof(buf1))); | |
d62a17ae | 10960 | |
10961 | /* Confederation */ | |
10962 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10963 | && bgp_confederation_peers_check(bgp, p->as)) | |
10964 | json_object_boolean_true_add(json_neigh, | |
10965 | "nbrCommonAdmin"); | |
10966 | ||
10967 | /* Status. */ | |
10968 | json_object_string_add( | |
10969 | json_neigh, "bgpState", | |
10970 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10971 | ||
10972 | if (p->status == Established) { | |
10973 | time_t uptime; | |
d62a17ae | 10974 | |
10975 | uptime = bgp_clock(); | |
10976 | uptime -= p->uptime; | |
d62a17ae | 10977 | epoch_tbuf = time(NULL) - uptime; |
10978 | ||
d3c7efed DS |
10979 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
10980 | uptime * 1000); | |
d62a17ae | 10981 | json_object_string_add(json_neigh, "bgpTimerUpString", |
10982 | peer_uptime(p->uptime, timebuf, | |
10983 | BGP_UPTIME_LEN, 0, | |
10984 | NULL)); | |
10985 | json_object_int_add(json_neigh, | |
10986 | "bgpTimerUpEstablishedEpoch", | |
10987 | epoch_tbuf); | |
10988 | } | |
10989 | ||
10990 | else if (p->status == Active) { | |
10991 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10992 | json_object_string_add(json_neigh, "bgpStateIs", | |
10993 | "passive"); | |
10994 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10995 | json_object_string_add(json_neigh, "bgpStateIs", | |
10996 | "passiveNSF"); | |
10997 | } | |
10998 | ||
10999 | /* read timer */ | |
11000 | time_t uptime; | |
a2700b50 | 11001 | struct tm tm; |
d62a17ae | 11002 | |
11003 | uptime = bgp_clock(); | |
11004 | uptime -= p->readtime; | |
a2700b50 MS |
11005 | gmtime_r(&uptime, &tm); |
11006 | ||
d62a17ae | 11007 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
11008 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11009 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11010 | |
11011 | uptime = bgp_clock(); | |
11012 | uptime -= p->last_write; | |
a2700b50 MS |
11013 | gmtime_r(&uptime, &tm); |
11014 | ||
d62a17ae | 11015 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
11016 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11017 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11018 | |
11019 | uptime = bgp_clock(); | |
11020 | uptime -= p->update_time; | |
a2700b50 MS |
11021 | gmtime_r(&uptime, &tm); |
11022 | ||
d62a17ae | 11023 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
11024 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11025 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11026 | |
11027 | /* Configured timer values. */ | |
11028 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
11029 | p->v_holdtime * 1000); | |
11030 | json_object_int_add(json_neigh, | |
11031 | "bgpTimerKeepAliveIntervalMsecs", | |
11032 | p->v_keepalive * 1000); | |
b90a8e13 | 11033 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 11034 | json_object_int_add(json_neigh, |
11035 | "bgpTimerConfiguredHoldTimeMsecs", | |
11036 | p->holdtime * 1000); | |
11037 | json_object_int_add( | |
11038 | json_neigh, | |
11039 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
11040 | p->keepalive * 1000); | |
5d5393b9 DL |
11041 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
11042 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
11043 | json_object_int_add(json_neigh, |
11044 | "bgpTimerConfiguredHoldTimeMsecs", | |
11045 | bgp->default_holdtime); | |
11046 | json_object_int_add( | |
11047 | json_neigh, | |
11048 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
11049 | bgp->default_keepalive); | |
d62a17ae | 11050 | } |
11051 | } else { | |
11052 | /* Administrative shutdown. */ | |
11053 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
11054 | vty_out(vty, " Administratively shut down\n"); | |
11055 | ||
11056 | /* BGP Version. */ | |
11057 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 11058 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 11059 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
11060 | vty_out(vty, ", local router ID %s\n", |
11061 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
11062 | sizeof(buf1))); | |
d62a17ae | 11063 | |
11064 | /* Confederation */ | |
11065 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
11066 | && bgp_confederation_peers_check(bgp, p->as)) | |
11067 | vty_out(vty, | |
11068 | " Neighbor under common administration\n"); | |
11069 | ||
11070 | /* Status. */ | |
11071 | vty_out(vty, " BGP state = %s", | |
11072 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
11073 | ||
11074 | if (p->status == Established) | |
11075 | vty_out(vty, ", up for %8s", | |
11076 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
11077 | 0, NULL)); | |
11078 | ||
11079 | else if (p->status == Active) { | |
11080 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
11081 | vty_out(vty, " (passive)"); | |
11082 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
11083 | vty_out(vty, " (NSF passive)"); | |
11084 | } | |
11085 | vty_out(vty, "\n"); | |
11086 | ||
11087 | /* read timer */ | |
11088 | vty_out(vty, " Last read %s", | |
11089 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
11090 | NULL)); | |
11091 | vty_out(vty, ", Last write %s\n", | |
11092 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
11093 | NULL)); | |
11094 | ||
11095 | /* Configured timer values. */ | |
11096 | vty_out(vty, | |
11097 | " Hold time is %d, keepalive interval is %d seconds\n", | |
11098 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 11099 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 11100 | vty_out(vty, " Configured hold time is %d", |
11101 | p->holdtime); | |
11102 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11103 | p->keepalive); | |
5d5393b9 DL |
11104 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
11105 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
11106 | vty_out(vty, " Configured hold time is %d", |
11107 | bgp->default_holdtime); | |
11108 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11109 | bgp->default_keepalive); | |
d62a17ae | 11110 | } |
11111 | } | |
11112 | /* Capability. */ | |
11113 | if (p->status == Established) { | |
11114 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
11115 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
11116 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
11117 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
11118 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
11119 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
11120 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
11121 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
11122 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
11123 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
11124 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
11125 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 11126 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
11127 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 11128 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
11129 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 11130 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
11131 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 11132 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
11133 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
11134 | if (use_json) { | |
11135 | json_object *json_cap = NULL; | |
11136 | ||
11137 | json_cap = json_object_new_object(); | |
11138 | ||
11139 | /* AS4 */ | |
11140 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11141 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11142 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
11143 | && CHECK_FLAG(p->cap, | |
11144 | PEER_CAP_AS4_RCV)) | |
11145 | json_object_string_add( | |
11146 | json_cap, "4byteAs", | |
11147 | "advertisedAndReceived"); | |
11148 | else if (CHECK_FLAG(p->cap, | |
11149 | PEER_CAP_AS4_ADV)) | |
11150 | json_object_string_add( | |
11151 | json_cap, "4byteAs", | |
11152 | "advertised"); | |
11153 | else if (CHECK_FLAG(p->cap, | |
11154 | PEER_CAP_AS4_RCV)) | |
11155 | json_object_string_add( | |
11156 | json_cap, "4byteAs", | |
11157 | "received"); | |
11158 | } | |
11159 | ||
11160 | /* AddPath */ | |
11161 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11162 | || CHECK_FLAG(p->cap, | |
11163 | PEER_CAP_ADDPATH_ADV)) { | |
11164 | json_object *json_add = NULL; | |
11165 | const char *print_store; | |
11166 | ||
11167 | json_add = json_object_new_object(); | |
11168 | ||
05c7a1cc QY |
11169 | FOREACH_AFI_SAFI (afi, safi) { |
11170 | json_object *json_sub = NULL; | |
11171 | json_sub = | |
11172 | json_object_new_object(); | |
5cb5f4d0 DD |
11173 | print_store = get_afi_safi_str( |
11174 | afi, safi, true); | |
d62a17ae | 11175 | |
05c7a1cc QY |
11176 | if (CHECK_FLAG( |
11177 | p->af_cap[afi] | |
11178 | [safi], | |
11179 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11180 | || CHECK_FLAG( | |
11181 | p->af_cap[afi] | |
11182 | [safi], | |
11183 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 11184 | if (CHECK_FLAG( |
11185 | p->af_cap | |
11186 | [afi] | |
11187 | [safi], | |
11188 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 11189 | && CHECK_FLAG( |
d62a17ae | 11190 | p->af_cap |
11191 | [afi] | |
11192 | [safi], | |
05c7a1cc QY |
11193 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
11194 | json_object_boolean_true_add( | |
11195 | json_sub, | |
11196 | "txAdvertisedAndReceived"); | |
11197 | else if ( | |
11198 | CHECK_FLAG( | |
11199 | p->af_cap | |
11200 | [afi] | |
11201 | [safi], | |
11202 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
11203 | json_object_boolean_true_add( | |
11204 | json_sub, | |
11205 | "txAdvertised"); | |
11206 | else if ( | |
11207 | CHECK_FLAG( | |
11208 | p->af_cap | |
11209 | [afi] | |
11210 | [safi], | |
11211 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11212 | json_object_boolean_true_add( | |
11213 | json_sub, | |
11214 | "txReceived"); | |
11215 | } | |
d62a17ae | 11216 | |
05c7a1cc QY |
11217 | if (CHECK_FLAG( |
11218 | p->af_cap[afi] | |
11219 | [safi], | |
11220 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11221 | || CHECK_FLAG( | |
11222 | p->af_cap[afi] | |
11223 | [safi], | |
11224 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 11225 | if (CHECK_FLAG( |
11226 | p->af_cap | |
11227 | [afi] | |
11228 | [safi], | |
11229 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 11230 | && CHECK_FLAG( |
d62a17ae | 11231 | p->af_cap |
11232 | [afi] | |
11233 | [safi], | |
11234 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
11235 | json_object_boolean_true_add( |
11236 | json_sub, | |
11237 | "rxAdvertisedAndReceived"); | |
11238 | else if ( | |
11239 | CHECK_FLAG( | |
11240 | p->af_cap | |
11241 | [afi] | |
11242 | [safi], | |
11243 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
11244 | json_object_boolean_true_add( | |
11245 | json_sub, | |
11246 | "rxAdvertised"); | |
11247 | else if ( | |
11248 | CHECK_FLAG( | |
11249 | p->af_cap | |
11250 | [afi] | |
11251 | [safi], | |
11252 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11253 | json_object_boolean_true_add( | |
11254 | json_sub, | |
11255 | "rxReceived"); | |
d62a17ae | 11256 | } |
11257 | ||
05c7a1cc QY |
11258 | if (CHECK_FLAG( |
11259 | p->af_cap[afi] | |
11260 | [safi], | |
11261 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11262 | || CHECK_FLAG( | |
11263 | p->af_cap[afi] | |
11264 | [safi], | |
11265 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
11266 | || CHECK_FLAG( | |
11267 | p->af_cap[afi] | |
11268 | [safi], | |
11269 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11270 | || CHECK_FLAG( | |
11271 | p->af_cap[afi] | |
11272 | [safi], | |
11273 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11274 | json_object_object_add( | |
11275 | json_add, | |
11276 | print_store, | |
11277 | json_sub); | |
11278 | else | |
11279 | json_object_free( | |
11280 | json_sub); | |
11281 | } | |
11282 | ||
d62a17ae | 11283 | json_object_object_add( |
11284 | json_cap, "addPath", json_add); | |
11285 | } | |
11286 | ||
11287 | /* Dynamic */ | |
11288 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11289 | || CHECK_FLAG(p->cap, | |
11290 | PEER_CAP_DYNAMIC_ADV)) { | |
11291 | if (CHECK_FLAG(p->cap, | |
11292 | PEER_CAP_DYNAMIC_ADV) | |
11293 | && CHECK_FLAG(p->cap, | |
11294 | PEER_CAP_DYNAMIC_RCV)) | |
11295 | json_object_string_add( | |
11296 | json_cap, "dynamic", | |
11297 | "advertisedAndReceived"); | |
11298 | else if (CHECK_FLAG( | |
11299 | p->cap, | |
11300 | PEER_CAP_DYNAMIC_ADV)) | |
11301 | json_object_string_add( | |
11302 | json_cap, "dynamic", | |
11303 | "advertised"); | |
11304 | else if (CHECK_FLAG( | |
11305 | p->cap, | |
11306 | PEER_CAP_DYNAMIC_RCV)) | |
11307 | json_object_string_add( | |
11308 | json_cap, "dynamic", | |
11309 | "received"); | |
11310 | } | |
11311 | ||
11312 | /* Extended nexthop */ | |
11313 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11314 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11315 | json_object *json_nxt = NULL; | |
11316 | const char *print_store; | |
11317 | ||
11318 | ||
11319 | if (CHECK_FLAG(p->cap, | |
11320 | PEER_CAP_ENHE_ADV) | |
11321 | && CHECK_FLAG(p->cap, | |
11322 | PEER_CAP_ENHE_RCV)) | |
11323 | json_object_string_add( | |
11324 | json_cap, | |
11325 | "extendedNexthop", | |
11326 | "advertisedAndReceived"); | |
11327 | else if (CHECK_FLAG(p->cap, | |
11328 | PEER_CAP_ENHE_ADV)) | |
11329 | json_object_string_add( | |
11330 | json_cap, | |
11331 | "extendedNexthop", | |
11332 | "advertised"); | |
11333 | else if (CHECK_FLAG(p->cap, | |
11334 | PEER_CAP_ENHE_RCV)) | |
11335 | json_object_string_add( | |
11336 | json_cap, | |
11337 | "extendedNexthop", | |
11338 | "received"); | |
11339 | ||
11340 | if (CHECK_FLAG(p->cap, | |
11341 | PEER_CAP_ENHE_RCV)) { | |
11342 | json_nxt = | |
11343 | json_object_new_object(); | |
11344 | ||
11345 | for (safi = SAFI_UNICAST; | |
11346 | safi < SAFI_MAX; safi++) { | |
11347 | if (CHECK_FLAG( | |
11348 | p->af_cap | |
11349 | [AFI_IP] | |
11350 | [safi], | |
11351 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11352 | print_store = get_afi_safi_str( |
d62a17ae | 11353 | AFI_IP, |
5cb5f4d0 | 11354 | safi, true); |
d62a17ae | 11355 | json_object_string_add( |
11356 | json_nxt, | |
11357 | print_store, | |
54f29523 | 11358 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 11359 | } |
11360 | } | |
11361 | json_object_object_add( | |
11362 | json_cap, | |
11363 | "extendedNexthopFamililesByPeer", | |
11364 | json_nxt); | |
11365 | } | |
11366 | } | |
11367 | ||
11368 | /* Route Refresh */ | |
11369 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11370 | || CHECK_FLAG(p->cap, | |
11371 | PEER_CAP_REFRESH_NEW_RCV) | |
11372 | || CHECK_FLAG(p->cap, | |
11373 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11374 | if (CHECK_FLAG(p->cap, | |
11375 | PEER_CAP_REFRESH_ADV) | |
11376 | && (CHECK_FLAG( | |
11377 | p->cap, | |
11378 | PEER_CAP_REFRESH_NEW_RCV) | |
11379 | || CHECK_FLAG( | |
11380 | p->cap, | |
11381 | PEER_CAP_REFRESH_OLD_RCV))) { | |
11382 | if (CHECK_FLAG( | |
11383 | p->cap, | |
11384 | PEER_CAP_REFRESH_OLD_RCV) | |
11385 | && CHECK_FLAG( | |
11386 | p->cap, | |
11387 | PEER_CAP_REFRESH_NEW_RCV)) | |
11388 | json_object_string_add( | |
11389 | json_cap, | |
11390 | "routeRefresh", | |
11391 | "advertisedAndReceivedOldNew"); | |
11392 | else { | |
11393 | if (CHECK_FLAG( | |
11394 | p->cap, | |
11395 | PEER_CAP_REFRESH_OLD_RCV)) | |
11396 | json_object_string_add( | |
11397 | json_cap, | |
11398 | "routeRefresh", | |
11399 | "advertisedAndReceivedOld"); | |
11400 | else | |
11401 | json_object_string_add( | |
11402 | json_cap, | |
11403 | "routeRefresh", | |
11404 | "advertisedAndReceivedNew"); | |
11405 | } | |
11406 | } else if ( | |
11407 | CHECK_FLAG( | |
11408 | p->cap, | |
11409 | PEER_CAP_REFRESH_ADV)) | |
11410 | json_object_string_add( | |
11411 | json_cap, | |
11412 | "routeRefresh", | |
11413 | "advertised"); | |
11414 | else if ( | |
11415 | CHECK_FLAG( | |
11416 | p->cap, | |
11417 | PEER_CAP_REFRESH_NEW_RCV) | |
11418 | || CHECK_FLAG( | |
11419 | p->cap, | |
11420 | PEER_CAP_REFRESH_OLD_RCV)) | |
11421 | json_object_string_add( | |
11422 | json_cap, | |
11423 | "routeRefresh", | |
11424 | "received"); | |
11425 | } | |
11426 | ||
11427 | /* Multiprotocol Extensions */ | |
11428 | json_object *json_multi = NULL; | |
11429 | json_multi = json_object_new_object(); | |
11430 | ||
05c7a1cc QY |
11431 | FOREACH_AFI_SAFI (afi, safi) { |
11432 | if (p->afc_adv[afi][safi] | |
11433 | || p->afc_recv[afi][safi]) { | |
11434 | json_object *json_exten = NULL; | |
11435 | json_exten = | |
11436 | json_object_new_object(); | |
11437 | ||
d62a17ae | 11438 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11439 | && p->afc_recv[afi][safi]) |
11440 | json_object_boolean_true_add( | |
11441 | json_exten, | |
11442 | "advertisedAndReceived"); | |
11443 | else if (p->afc_adv[afi][safi]) | |
11444 | json_object_boolean_true_add( | |
11445 | json_exten, | |
11446 | "advertised"); | |
11447 | else if (p->afc_recv[afi][safi]) | |
11448 | json_object_boolean_true_add( | |
11449 | json_exten, | |
11450 | "received"); | |
d62a17ae | 11451 | |
05c7a1cc QY |
11452 | json_object_object_add( |
11453 | json_multi, | |
5cb5f4d0 DD |
11454 | get_afi_safi_str(afi, |
11455 | safi, | |
11456 | true), | |
05c7a1cc | 11457 | json_exten); |
d62a17ae | 11458 | } |
11459 | } | |
11460 | json_object_object_add( | |
11461 | json_cap, "multiprotocolExtensions", | |
11462 | json_multi); | |
11463 | ||
d77114b7 | 11464 | /* Hostname capabilities */ |
60466a63 | 11465 | json_object *json_hname = NULL; |
d77114b7 MK |
11466 | |
11467 | json_hname = json_object_new_object(); | |
11468 | ||
11469 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11470 | json_object_string_add( | |
60466a63 QY |
11471 | json_hname, "advHostName", |
11472 | bgp->peer_self->hostname | |
11473 | ? bgp->peer_self | |
11474 | ->hostname | |
d77114b7 MK |
11475 | : "n/a"); |
11476 | json_object_string_add( | |
60466a63 QY |
11477 | json_hname, "advDomainName", |
11478 | bgp->peer_self->domainname | |
11479 | ? bgp->peer_self | |
11480 | ->domainname | |
d77114b7 MK |
11481 | : "n/a"); |
11482 | } | |
11483 | ||
11484 | ||
11485 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11486 | json_object_string_add( | |
60466a63 QY |
11487 | json_hname, "rcvHostName", |
11488 | p->hostname ? p->hostname | |
11489 | : "n/a"); | |
d77114b7 | 11490 | json_object_string_add( |
60466a63 QY |
11491 | json_hname, "rcvDomainName", |
11492 | p->domainname ? p->domainname | |
11493 | : "n/a"); | |
d77114b7 MK |
11494 | } |
11495 | ||
60466a63 | 11496 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11497 | json_hname); |
11498 | ||
d62a17ae | 11499 | /* Gracefull Restart */ |
11500 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11501 | || CHECK_FLAG(p->cap, | |
11502 | PEER_CAP_RESTART_ADV)) { | |
11503 | if (CHECK_FLAG(p->cap, | |
11504 | PEER_CAP_RESTART_ADV) | |
11505 | && CHECK_FLAG(p->cap, | |
11506 | PEER_CAP_RESTART_RCV)) | |
11507 | json_object_string_add( | |
11508 | json_cap, | |
11509 | "gracefulRestart", | |
11510 | "advertisedAndReceived"); | |
11511 | else if (CHECK_FLAG( | |
11512 | p->cap, | |
11513 | PEER_CAP_RESTART_ADV)) | |
11514 | json_object_string_add( | |
11515 | json_cap, | |
11516 | "gracefulRestartCapability", | |
11517 | "advertised"); | |
11518 | else if (CHECK_FLAG( | |
11519 | p->cap, | |
11520 | PEER_CAP_RESTART_RCV)) | |
11521 | json_object_string_add( | |
11522 | json_cap, | |
11523 | "gracefulRestartCapability", | |
11524 | "received"); | |
11525 | ||
11526 | if (CHECK_FLAG(p->cap, | |
11527 | PEER_CAP_RESTART_RCV)) { | |
11528 | int restart_af_count = 0; | |
11529 | json_object *json_restart = | |
11530 | NULL; | |
11531 | json_restart = | |
11532 | json_object_new_object(); | |
11533 | ||
11534 | json_object_int_add( | |
11535 | json_cap, | |
11536 | "gracefulRestartRemoteTimerMsecs", | |
11537 | p->v_gr_restart * 1000); | |
11538 | ||
05c7a1cc QY |
11539 | FOREACH_AFI_SAFI (afi, safi) { |
11540 | if (CHECK_FLAG( | |
11541 | p->af_cap | |
11542 | [afi] | |
11543 | [safi], | |
11544 | PEER_CAP_RESTART_AF_RCV)) { | |
11545 | json_object * | |
11546 | json_sub = | |
11547 | NULL; | |
11548 | json_sub = | |
11549 | json_object_new_object(); | |
11550 | ||
d62a17ae | 11551 | if (CHECK_FLAG( |
11552 | p->af_cap | |
11553 | [afi] | |
11554 | [safi], | |
05c7a1cc QY |
11555 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11556 | json_object_boolean_true_add( | |
11557 | json_sub, | |
11558 | "preserved"); | |
11559 | restart_af_count++; | |
11560 | json_object_object_add( | |
11561 | json_restart, | |
5cb5f4d0 | 11562 | get_afi_safi_str( |
05c7a1cc | 11563 | afi, |
5cb5f4d0 DD |
11564 | safi, |
11565 | true), | |
05c7a1cc | 11566 | json_sub); |
d62a17ae | 11567 | } |
11568 | } | |
11569 | if (!restart_af_count) { | |
11570 | json_object_string_add( | |
11571 | json_cap, | |
11572 | "addressFamiliesByPeer", | |
11573 | "none"); | |
11574 | json_object_free( | |
11575 | json_restart); | |
11576 | } else | |
11577 | json_object_object_add( | |
11578 | json_cap, | |
11579 | "addressFamiliesByPeer", | |
11580 | json_restart); | |
11581 | } | |
11582 | } | |
11583 | json_object_object_add(json_neigh, | |
11584 | "neighborCapabilities", | |
11585 | json_cap); | |
11586 | } else { | |
11587 | vty_out(vty, " Neighbor capabilities:\n"); | |
11588 | ||
11589 | /* AS4 */ | |
11590 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11591 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11592 | vty_out(vty, " 4 Byte AS:"); | |
11593 | if (CHECK_FLAG(p->cap, | |
11594 | PEER_CAP_AS4_ADV)) | |
11595 | vty_out(vty, " advertised"); | |
11596 | if (CHECK_FLAG(p->cap, | |
11597 | PEER_CAP_AS4_RCV)) | |
11598 | vty_out(vty, " %sreceived", | |
11599 | CHECK_FLAG( | |
11600 | p->cap, | |
11601 | PEER_CAP_AS4_ADV) | |
11602 | ? "and " | |
11603 | : ""); | |
11604 | vty_out(vty, "\n"); | |
11605 | } | |
11606 | ||
11607 | /* AddPath */ | |
11608 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11609 | || CHECK_FLAG(p->cap, | |
11610 | PEER_CAP_ADDPATH_ADV)) { | |
11611 | vty_out(vty, " AddPath:\n"); | |
11612 | ||
05c7a1cc QY |
11613 | FOREACH_AFI_SAFI (afi, safi) { |
11614 | if (CHECK_FLAG( | |
11615 | p->af_cap[afi] | |
11616 | [safi], | |
11617 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11618 | || CHECK_FLAG( | |
11619 | p->af_cap[afi] | |
11620 | [safi], | |
11621 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11622 | vty_out(vty, | |
11623 | " %s: TX ", | |
5cb5f4d0 | 11624 | get_afi_safi_str( |
05c7a1cc | 11625 | afi, |
5cb5f4d0 DD |
11626 | safi, |
11627 | false)); | |
05c7a1cc | 11628 | |
d62a17ae | 11629 | if (CHECK_FLAG( |
11630 | p->af_cap | |
11631 | [afi] | |
11632 | [safi], | |
05c7a1cc | 11633 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11634 | vty_out(vty, |
05c7a1cc | 11635 | "advertised %s", |
5cb5f4d0 | 11636 | get_afi_safi_str( |
d62a17ae | 11637 | afi, |
5cb5f4d0 DD |
11638 | safi, |
11639 | false)); | |
d62a17ae | 11640 | |
05c7a1cc QY |
11641 | if (CHECK_FLAG( |
11642 | p->af_cap | |
11643 | [afi] | |
11644 | [safi], | |
11645 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11646 | vty_out(vty, | |
11647 | "%sreceived", | |
11648 | CHECK_FLAG( | |
11649 | p->af_cap | |
11650 | [afi] | |
11651 | [safi], | |
11652 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11653 | ? " and " | |
11654 | : ""); | |
d62a17ae | 11655 | |
05c7a1cc QY |
11656 | vty_out(vty, "\n"); |
11657 | } | |
d62a17ae | 11658 | |
05c7a1cc QY |
11659 | if (CHECK_FLAG( |
11660 | p->af_cap[afi] | |
11661 | [safi], | |
11662 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11663 | || CHECK_FLAG( | |
11664 | p->af_cap[afi] | |
11665 | [safi], | |
11666 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11667 | vty_out(vty, | |
11668 | " %s: RX ", | |
5cb5f4d0 | 11669 | get_afi_safi_str( |
05c7a1cc | 11670 | afi, |
5cb5f4d0 DD |
11671 | safi, |
11672 | false)); | |
d62a17ae | 11673 | |
11674 | if (CHECK_FLAG( | |
11675 | p->af_cap | |
11676 | [afi] | |
11677 | [safi], | |
05c7a1cc | 11678 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11679 | vty_out(vty, |
05c7a1cc | 11680 | "advertised %s", |
5cb5f4d0 | 11681 | get_afi_safi_str( |
d62a17ae | 11682 | afi, |
5cb5f4d0 DD |
11683 | safi, |
11684 | false)); | |
d62a17ae | 11685 | |
05c7a1cc QY |
11686 | if (CHECK_FLAG( |
11687 | p->af_cap | |
11688 | [afi] | |
11689 | [safi], | |
11690 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11691 | vty_out(vty, |
05c7a1cc QY |
11692 | "%sreceived", |
11693 | CHECK_FLAG( | |
11694 | p->af_cap | |
11695 | [afi] | |
11696 | [safi], | |
11697 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11698 | ? " and " | |
11699 | : ""); | |
11700 | ||
11701 | vty_out(vty, "\n"); | |
d62a17ae | 11702 | } |
05c7a1cc | 11703 | } |
d62a17ae | 11704 | } |
11705 | ||
11706 | /* Dynamic */ | |
11707 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11708 | || CHECK_FLAG(p->cap, | |
11709 | PEER_CAP_DYNAMIC_ADV)) { | |
11710 | vty_out(vty, " Dynamic:"); | |
11711 | if (CHECK_FLAG(p->cap, | |
11712 | PEER_CAP_DYNAMIC_ADV)) | |
11713 | vty_out(vty, " advertised"); | |
11714 | if (CHECK_FLAG(p->cap, | |
11715 | PEER_CAP_DYNAMIC_RCV)) | |
11716 | vty_out(vty, " %sreceived", | |
11717 | CHECK_FLAG( | |
11718 | p->cap, | |
11719 | PEER_CAP_DYNAMIC_ADV) | |
11720 | ? "and " | |
11721 | : ""); | |
11722 | vty_out(vty, "\n"); | |
11723 | } | |
11724 | ||
11725 | /* Extended nexthop */ | |
11726 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11727 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11728 | vty_out(vty, " Extended nexthop:"); | |
11729 | if (CHECK_FLAG(p->cap, | |
11730 | PEER_CAP_ENHE_ADV)) | |
11731 | vty_out(vty, " advertised"); | |
11732 | if (CHECK_FLAG(p->cap, | |
11733 | PEER_CAP_ENHE_RCV)) | |
11734 | vty_out(vty, " %sreceived", | |
11735 | CHECK_FLAG( | |
11736 | p->cap, | |
11737 | PEER_CAP_ENHE_ADV) | |
11738 | ? "and " | |
11739 | : ""); | |
11740 | vty_out(vty, "\n"); | |
11741 | ||
11742 | if (CHECK_FLAG(p->cap, | |
11743 | PEER_CAP_ENHE_RCV)) { | |
11744 | vty_out(vty, | |
11745 | " Address families by peer:\n "); | |
11746 | for (safi = SAFI_UNICAST; | |
11747 | safi < SAFI_MAX; safi++) | |
11748 | if (CHECK_FLAG( | |
11749 | p->af_cap | |
11750 | [AFI_IP] | |
11751 | [safi], | |
11752 | PEER_CAP_ENHE_AF_RCV)) | |
11753 | vty_out(vty, | |
11754 | " %s\n", | |
5cb5f4d0 | 11755 | get_afi_safi_str( |
d62a17ae | 11756 | AFI_IP, |
5cb5f4d0 DD |
11757 | safi, |
11758 | false)); | |
d62a17ae | 11759 | } |
11760 | } | |
11761 | ||
11762 | /* Route Refresh */ | |
11763 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11764 | || CHECK_FLAG(p->cap, | |
11765 | PEER_CAP_REFRESH_NEW_RCV) | |
11766 | || CHECK_FLAG(p->cap, | |
11767 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11768 | vty_out(vty, " Route refresh:"); | |
11769 | if (CHECK_FLAG(p->cap, | |
11770 | PEER_CAP_REFRESH_ADV)) | |
11771 | vty_out(vty, " advertised"); | |
11772 | if (CHECK_FLAG(p->cap, | |
11773 | PEER_CAP_REFRESH_NEW_RCV) | |
11774 | || CHECK_FLAG( | |
11775 | p->cap, | |
11776 | PEER_CAP_REFRESH_OLD_RCV)) | |
11777 | vty_out(vty, " %sreceived(%s)", | |
11778 | CHECK_FLAG( | |
11779 | p->cap, | |
11780 | PEER_CAP_REFRESH_ADV) | |
11781 | ? "and " | |
11782 | : "", | |
11783 | (CHECK_FLAG( | |
11784 | p->cap, | |
11785 | PEER_CAP_REFRESH_OLD_RCV) | |
11786 | && CHECK_FLAG( | |
11787 | p->cap, | |
11788 | PEER_CAP_REFRESH_NEW_RCV)) | |
11789 | ? "old & new" | |
11790 | : CHECK_FLAG( | |
11791 | p->cap, | |
11792 | PEER_CAP_REFRESH_OLD_RCV) | |
11793 | ? "old" | |
11794 | : "new"); | |
11795 | ||
11796 | vty_out(vty, "\n"); | |
11797 | } | |
11798 | ||
11799 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11800 | FOREACH_AFI_SAFI (afi, safi) |
11801 | if (p->afc_adv[afi][safi] | |
11802 | || p->afc_recv[afi][safi]) { | |
11803 | vty_out(vty, | |
11804 | " Address Family %s:", | |
5cb5f4d0 DD |
11805 | get_afi_safi_str( |
11806 | afi, | |
11807 | safi, | |
11808 | false)); | |
05c7a1cc | 11809 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11810 | vty_out(vty, |
05c7a1cc QY |
11811 | " advertised"); |
11812 | if (p->afc_recv[afi][safi]) | |
11813 | vty_out(vty, | |
11814 | " %sreceived", | |
11815 | p->afc_adv[afi] | |
11816 | [safi] | |
11817 | ? "and " | |
11818 | : ""); | |
11819 | vty_out(vty, "\n"); | |
11820 | } | |
d62a17ae | 11821 | |
11822 | /* Hostname capability */ | |
60466a63 | 11823 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11824 | |
11825 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11826 | vty_out(vty, |
11827 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11828 | bgp->peer_self->hostname |
11829 | ? bgp->peer_self | |
11830 | ->hostname | |
d77114b7 | 11831 | : "n/a", |
60466a63 QY |
11832 | bgp->peer_self->domainname |
11833 | ? bgp->peer_self | |
11834 | ->domainname | |
d77114b7 MK |
11835 | : "n/a"); |
11836 | } else { | |
11837 | vty_out(vty, " not advertised"); | |
d62a17ae | 11838 | } |
11839 | ||
d77114b7 | 11840 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11841 | vty_out(vty, |
11842 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11843 | p->hostname ? p->hostname |
11844 | : "n/a", | |
11845 | p->domainname ? p->domainname | |
11846 | : "n/a"); | |
d77114b7 MK |
11847 | } else { |
11848 | vty_out(vty, " not received"); | |
11849 | } | |
11850 | ||
11851 | vty_out(vty, "\n"); | |
11852 | ||
61bfbd51 | 11853 | /* Graceful Restart */ |
d62a17ae | 11854 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
11855 | || CHECK_FLAG(p->cap, | |
11856 | PEER_CAP_RESTART_ADV)) { | |
11857 | vty_out(vty, | |
61bfbd51 | 11858 | " Graceful Restart Capability:"); |
d62a17ae | 11859 | if (CHECK_FLAG(p->cap, |
11860 | PEER_CAP_RESTART_ADV)) | |
11861 | vty_out(vty, " advertised"); | |
11862 | if (CHECK_FLAG(p->cap, | |
11863 | PEER_CAP_RESTART_RCV)) | |
11864 | vty_out(vty, " %sreceived", | |
11865 | CHECK_FLAG( | |
11866 | p->cap, | |
11867 | PEER_CAP_RESTART_ADV) | |
11868 | ? "and " | |
11869 | : ""); | |
11870 | vty_out(vty, "\n"); | |
11871 | ||
11872 | if (CHECK_FLAG(p->cap, | |
11873 | PEER_CAP_RESTART_RCV)) { | |
11874 | int restart_af_count = 0; | |
11875 | ||
11876 | vty_out(vty, | |
11877 | " Remote Restart timer is %d seconds\n", | |
11878 | p->v_gr_restart); | |
11879 | vty_out(vty, | |
11880 | " Address families by peer:\n "); | |
11881 | ||
05c7a1cc QY |
11882 | FOREACH_AFI_SAFI (afi, safi) |
11883 | if (CHECK_FLAG( | |
11884 | p->af_cap | |
11885 | [afi] | |
11886 | [safi], | |
11887 | PEER_CAP_RESTART_AF_RCV)) { | |
11888 | vty_out(vty, | |
11889 | "%s%s(%s)", | |
11890 | restart_af_count | |
11891 | ? ", " | |
11892 | : "", | |
5cb5f4d0 | 11893 | get_afi_safi_str( |
05c7a1cc | 11894 | afi, |
5cb5f4d0 DD |
11895 | safi, |
11896 | false), | |
05c7a1cc QY |
11897 | CHECK_FLAG( |
11898 | p->af_cap | |
11899 | [afi] | |
11900 | [safi], | |
11901 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11902 | ? "preserved" | |
11903 | : "not preserved"); | |
11904 | restart_af_count++; | |
11905 | } | |
d62a17ae | 11906 | if (!restart_af_count) |
11907 | vty_out(vty, "none"); | |
11908 | vty_out(vty, "\n"); | |
11909 | } | |
2986cac2 | 11910 | } /* Gracefull Restart */ |
d62a17ae | 11911 | } |
11912 | } | |
11913 | } | |
11914 | ||
11915 | /* graceful restart information */ | |
d62a17ae | 11916 | json_object *json_grace = NULL; |
11917 | json_object *json_grace_send = NULL; | |
11918 | json_object *json_grace_recv = NULL; | |
11919 | int eor_send_af_count = 0; | |
11920 | int eor_receive_af_count = 0; | |
11921 | ||
11922 | if (use_json) { | |
11923 | json_grace = json_object_new_object(); | |
11924 | json_grace_send = json_object_new_object(); | |
11925 | json_grace_recv = json_object_new_object(); | |
11926 | ||
36235319 QY |
11927 | if ((p->status == Established) |
11928 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11929 | FOREACH_AFI_SAFI (afi, safi) { |
11930 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 11931 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11932 | json_object_boolean_true_add( |
11933 | json_grace_send, | |
5cb5f4d0 DD |
11934 | get_afi_safi_str(afi, |
11935 | safi, | |
11936 | true)); | |
05c7a1cc | 11937 | eor_send_af_count++; |
d62a17ae | 11938 | } |
11939 | } | |
05c7a1cc QY |
11940 | FOREACH_AFI_SAFI (afi, safi) { |
11941 | if (CHECK_FLAG( | |
36235319 QY |
11942 | p->af_sflags[afi][safi], |
11943 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11944 | json_object_boolean_true_add( |
11945 | json_grace_recv, | |
5cb5f4d0 DD |
11946 | get_afi_safi_str(afi, |
11947 | safi, | |
11948 | true)); | |
05c7a1cc | 11949 | eor_receive_af_count++; |
d62a17ae | 11950 | } |
11951 | } | |
11952 | } | |
36235319 QY |
11953 | json_object_object_add(json_grace, "endOfRibSend", |
11954 | json_grace_send); | |
11955 | json_object_object_add(json_grace, "endOfRibRecv", | |
11956 | json_grace_recv); | |
d62a17ae | 11957 | |
d62a17ae | 11958 | |
11959 | if (p->t_gr_restart) | |
11960 | json_object_int_add(json_grace, | |
11961 | "gracefulRestartTimerMsecs", | |
11962 | thread_timer_remain_second( | |
11963 | p->t_gr_restart) | |
11964 | * 1000); | |
11965 | ||
11966 | if (p->t_gr_stale) | |
11967 | json_object_int_add( | |
11968 | json_grace, | |
11969 | "gracefulStalepathTimerMsecs", | |
11970 | thread_timer_remain_second( | |
11971 | p->t_gr_stale) | |
11972 | * 1000); | |
2986cac2 | 11973 | /* more gr info in new format */ |
11974 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 11975 | json_grace); |
d62a17ae | 11976 | json_object_object_add( |
11977 | json_neigh, "gracefulRestartInfo", json_grace); | |
11978 | } else { | |
2089dd80 | 11979 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
11980 | if ((p->status == Established) |
11981 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11982 | |
d62a17ae | 11983 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
11984 | FOREACH_AFI_SAFI (afi, safi) { |
11985 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11986 | PEER_STATUS_EOR_SEND)) { | |
11987 | vty_out(vty, "%s%s", | |
11988 | eor_send_af_count ? ", " | |
11989 | : "", | |
36235319 QY |
11990 | get_afi_safi_str( |
11991 | afi, safi, | |
11992 | false)); | |
05c7a1cc | 11993 | eor_send_af_count++; |
d62a17ae | 11994 | } |
11995 | } | |
11996 | vty_out(vty, "\n"); | |
11997 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
11998 | FOREACH_AFI_SAFI (afi, safi) { |
11999 | if (CHECK_FLAG( | |
12000 | p->af_sflags[afi][safi], | |
12001 | PEER_STATUS_EOR_RECEIVED)) { | |
12002 | vty_out(vty, "%s%s", | |
12003 | eor_receive_af_count | |
12004 | ? ", " | |
12005 | : "", | |
5cb5f4d0 DD |
12006 | get_afi_safi_str(afi, |
12007 | safi, | |
12008 | false)); | |
05c7a1cc | 12009 | eor_receive_af_count++; |
d62a17ae | 12010 | } |
12011 | } | |
12012 | vty_out(vty, "\n"); | |
12013 | } | |
12014 | ||
12015 | if (p->t_gr_restart) | |
12016 | vty_out(vty, | |
12017 | " The remaining time of restart timer is %ld\n", | |
12018 | thread_timer_remain_second( | |
12019 | p->t_gr_restart)); | |
12020 | ||
12021 | if (p->t_gr_stale) | |
12022 | vty_out(vty, | |
12023 | " The remaining time of stalepath timer is %ld\n", | |
12024 | thread_timer_remain_second( | |
12025 | p->t_gr_stale)); | |
2986cac2 | 12026 | |
12027 | /* more gr info in new format */ | |
12028 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 12029 | } |
2986cac2 | 12030 | |
d62a17ae | 12031 | if (use_json) { |
12032 | json_object *json_stat = NULL; | |
12033 | json_stat = json_object_new_object(); | |
12034 | /* Packet counts. */ | |
43aa5965 QY |
12035 | |
12036 | atomic_size_t outq_count, inq_count; | |
12037 | outq_count = atomic_load_explicit(&p->obuf->count, | |
12038 | memory_order_relaxed); | |
12039 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
12040 | memory_order_relaxed); | |
12041 | ||
12042 | json_object_int_add(json_stat, "depthInq", | |
12043 | (unsigned long)inq_count); | |
d62a17ae | 12044 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 12045 | (unsigned long)outq_count); |
0112e9e0 QY |
12046 | json_object_int_add(json_stat, "opensSent", |
12047 | atomic_load_explicit(&p->open_out, | |
12048 | memory_order_relaxed)); | |
12049 | json_object_int_add(json_stat, "opensRecv", | |
12050 | atomic_load_explicit(&p->open_in, | |
12051 | memory_order_relaxed)); | |
d62a17ae | 12052 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
12053 | atomic_load_explicit(&p->notify_out, |
12054 | memory_order_relaxed)); | |
d62a17ae | 12055 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
12056 | atomic_load_explicit(&p->notify_in, |
12057 | memory_order_relaxed)); | |
12058 | json_object_int_add(json_stat, "updatesSent", | |
12059 | atomic_load_explicit(&p->update_out, | |
12060 | memory_order_relaxed)); | |
12061 | json_object_int_add(json_stat, "updatesRecv", | |
12062 | atomic_load_explicit(&p->update_in, | |
12063 | memory_order_relaxed)); | |
d62a17ae | 12064 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
12065 | atomic_load_explicit(&p->keepalive_out, |
12066 | memory_order_relaxed)); | |
d62a17ae | 12067 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
12068 | atomic_load_explicit(&p->keepalive_in, |
12069 | memory_order_relaxed)); | |
d62a17ae | 12070 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
12071 | atomic_load_explicit(&p->refresh_out, |
12072 | memory_order_relaxed)); | |
d62a17ae | 12073 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
12074 | atomic_load_explicit(&p->refresh_in, |
12075 | memory_order_relaxed)); | |
d62a17ae | 12076 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
12077 | atomic_load_explicit(&p->dynamic_cap_out, |
12078 | memory_order_relaxed)); | |
d62a17ae | 12079 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
12080 | atomic_load_explicit(&p->dynamic_cap_in, |
12081 | memory_order_relaxed)); | |
12082 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
12083 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 12084 | json_object_object_add(json_neigh, "messageStats", json_stat); |
12085 | } else { | |
43aa5965 QY |
12086 | atomic_size_t outq_count, inq_count; |
12087 | outq_count = atomic_load_explicit(&p->obuf->count, | |
12088 | memory_order_relaxed); | |
12089 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
12090 | memory_order_relaxed); | |
12091 | ||
d62a17ae | 12092 | /* Packet counts. */ |
12093 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
12094 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
12095 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 12096 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
12097 | vty_out(vty, " Opens: %10d %10d\n", |
12098 | atomic_load_explicit(&p->open_out, | |
12099 | memory_order_relaxed), | |
12100 | atomic_load_explicit(&p->open_in, | |
12101 | memory_order_relaxed)); | |
12102 | vty_out(vty, " Notifications: %10d %10d\n", | |
12103 | atomic_load_explicit(&p->notify_out, | |
12104 | memory_order_relaxed), | |
12105 | atomic_load_explicit(&p->notify_in, | |
12106 | memory_order_relaxed)); | |
12107 | vty_out(vty, " Updates: %10d %10d\n", | |
12108 | atomic_load_explicit(&p->update_out, | |
12109 | memory_order_relaxed), | |
12110 | atomic_load_explicit(&p->update_in, | |
12111 | memory_order_relaxed)); | |
12112 | vty_out(vty, " Keepalives: %10d %10d\n", | |
12113 | atomic_load_explicit(&p->keepalive_out, | |
12114 | memory_order_relaxed), | |
12115 | atomic_load_explicit(&p->keepalive_in, | |
12116 | memory_order_relaxed)); | |
12117 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
12118 | atomic_load_explicit(&p->refresh_out, | |
12119 | memory_order_relaxed), | |
12120 | atomic_load_explicit(&p->refresh_in, | |
12121 | memory_order_relaxed)); | |
d62a17ae | 12122 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
12123 | atomic_load_explicit(&p->dynamic_cap_out, |
12124 | memory_order_relaxed), | |
12125 | atomic_load_explicit(&p->dynamic_cap_in, | |
12126 | memory_order_relaxed)); | |
12127 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
12128 | PEER_TOTAL_RX(p)); | |
d62a17ae | 12129 | } |
12130 | ||
12131 | if (use_json) { | |
12132 | /* advertisement-interval */ | |
12133 | json_object_int_add(json_neigh, | |
12134 | "minBtwnAdvertisementRunsTimerMsecs", | |
12135 | p->v_routeadv * 1000); | |
12136 | ||
12137 | /* Update-source. */ | |
12138 | if (p->update_if || p->update_source) { | |
12139 | if (p->update_if) | |
12140 | json_object_string_add(json_neigh, | |
12141 | "updateSource", | |
12142 | p->update_if); | |
12143 | else if (p->update_source) | |
12144 | json_object_string_add( | |
12145 | json_neigh, "updateSource", | |
12146 | sockunion2str(p->update_source, buf1, | |
12147 | SU_ADDRSTRLEN)); | |
12148 | } | |
12149 | } else { | |
12150 | /* advertisement-interval */ | |
12151 | vty_out(vty, | |
12152 | " Minimum time between advertisement runs is %d seconds\n", | |
12153 | p->v_routeadv); | |
12154 | ||
12155 | /* Update-source. */ | |
12156 | if (p->update_if || p->update_source) { | |
12157 | vty_out(vty, " Update source is "); | |
12158 | if (p->update_if) | |
12159 | vty_out(vty, "%s", p->update_if); | |
12160 | else if (p->update_source) | |
12161 | vty_out(vty, "%s", | |
12162 | sockunion2str(p->update_source, buf1, | |
12163 | SU_ADDRSTRLEN)); | |
12164 | vty_out(vty, "\n"); | |
12165 | } | |
12166 | ||
12167 | vty_out(vty, "\n"); | |
12168 | } | |
12169 | ||
12170 | /* Address Family Information */ | |
12171 | json_object *json_hold = NULL; | |
12172 | ||
12173 | if (use_json) | |
12174 | json_hold = json_object_new_object(); | |
12175 | ||
05c7a1cc QY |
12176 | FOREACH_AFI_SAFI (afi, safi) |
12177 | if (p->afc[afi][safi]) | |
12178 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
12179 | json_hold); | |
d62a17ae | 12180 | |
12181 | if (use_json) { | |
12182 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
12183 | json_hold); | |
12184 | json_object_int_add(json_neigh, "connectionsEstablished", | |
12185 | p->established); | |
12186 | json_object_int_add(json_neigh, "connectionsDropped", | |
12187 | p->dropped); | |
12188 | } else | |
12189 | vty_out(vty, " Connections established %d; dropped %d\n", | |
12190 | p->established, p->dropped); | |
12191 | ||
12192 | if (!p->last_reset) { | |
12193 | if (use_json) | |
12194 | json_object_string_add(json_neigh, "lastReset", | |
12195 | "never"); | |
12196 | else | |
12197 | vty_out(vty, " Last reset never\n"); | |
12198 | } else { | |
12199 | if (use_json) { | |
12200 | time_t uptime; | |
a2700b50 | 12201 | struct tm tm; |
d62a17ae | 12202 | |
12203 | uptime = bgp_clock(); | |
12204 | uptime -= p->resettime; | |
a2700b50 MS |
12205 | gmtime_r(&uptime, &tm); |
12206 | ||
d62a17ae | 12207 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
12208 | (tm.tm_sec * 1000) |
12209 | + (tm.tm_min * 60000) | |
12210 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 12211 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 12212 | } else { |
12213 | vty_out(vty, " Last reset %s, ", | |
12214 | peer_uptime(p->resettime, timebuf, | |
12215 | BGP_UPTIME_LEN, 0, NULL)); | |
12216 | ||
3577f1c5 | 12217 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 12218 | if (p->last_reset_cause_size) { |
12219 | msg = p->last_reset_cause; | |
12220 | vty_out(vty, | |
12221 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
12222 | for (i = 1; i <= p->last_reset_cause_size; | |
12223 | i++) { | |
12224 | vty_out(vty, "%02X", *msg++); | |
12225 | ||
12226 | if (i != p->last_reset_cause_size) { | |
12227 | if (i % 16 == 0) { | |
12228 | vty_out(vty, "\n "); | |
12229 | } else if (i % 4 == 0) { | |
12230 | vty_out(vty, " "); | |
12231 | } | |
12232 | } | |
12233 | } | |
12234 | vty_out(vty, "\n"); | |
12235 | } | |
12236 | } | |
12237 | } | |
12238 | ||
12239 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
12240 | if (use_json) | |
12241 | json_object_boolean_true_add(json_neigh, | |
12242 | "prefixesConfigExceedMax"); | |
12243 | else | |
12244 | vty_out(vty, | |
12245 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
12246 | ||
12247 | if (p->t_pmax_restart) { | |
12248 | if (use_json) { | |
12249 | json_object_boolean_true_add( | |
12250 | json_neigh, "reducePrefixNumFrom"); | |
12251 | json_object_int_add(json_neigh, | |
12252 | "restartInTimerMsec", | |
12253 | thread_timer_remain_second( | |
12254 | p->t_pmax_restart) | |
12255 | * 1000); | |
12256 | } else | |
12257 | vty_out(vty, | |
12258 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
12259 | p->host, thread_timer_remain_second( |
12260 | p->t_pmax_restart)); | |
d62a17ae | 12261 | } else { |
12262 | if (use_json) | |
12263 | json_object_boolean_true_add( | |
12264 | json_neigh, | |
12265 | "reducePrefixNumAndClearIpBgp"); | |
12266 | else | |
12267 | vty_out(vty, | |
12268 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
12269 | p->host); | |
12270 | } | |
12271 | } | |
12272 | ||
12273 | /* EBGP Multihop and GTSM */ | |
12274 | if (p->sort != BGP_PEER_IBGP) { | |
12275 | if (use_json) { | |
e2521429 | 12276 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12277 | json_object_int_add(json_neigh, |
12278 | "externalBgpNbrMaxHopsAway", | |
12279 | p->gtsm_hops); | |
c8d6f0d6 | 12280 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12281 | json_object_int_add(json_neigh, |
12282 | "externalBgpNbrMaxHopsAway", | |
12283 | p->ttl); | |
12284 | } else { | |
e2521429 | 12285 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12286 | vty_out(vty, |
12287 | " External BGP neighbor may be up to %d hops away.\n", | |
12288 | p->gtsm_hops); | |
c8d6f0d6 | 12289 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12290 | vty_out(vty, |
12291 | " External BGP neighbor may be up to %d hops away.\n", | |
12292 | p->ttl); | |
12293 | } | |
12294 | } else { | |
e2521429 | 12295 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 12296 | if (use_json) |
12297 | json_object_int_add(json_neigh, | |
12298 | "internalBgpNbrMaxHopsAway", | |
12299 | p->gtsm_hops); | |
12300 | else | |
12301 | vty_out(vty, | |
12302 | " Internal BGP neighbor may be up to %d hops away.\n", | |
12303 | p->gtsm_hops); | |
12304 | } | |
12305 | } | |
12306 | ||
12307 | /* Local address. */ | |
12308 | if (p->su_local) { | |
12309 | if (use_json) { | |
12310 | json_object_string_add(json_neigh, "hostLocal", | |
12311 | sockunion2str(p->su_local, buf1, | |
12312 | SU_ADDRSTRLEN)); | |
12313 | json_object_int_add(json_neigh, "portLocal", | |
12314 | ntohs(p->su_local->sin.sin_port)); | |
12315 | } else | |
12316 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
12317 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
12318 | ntohs(p->su_local->sin.sin_port)); | |
12319 | } | |
12320 | ||
12321 | /* Remote address. */ | |
12322 | if (p->su_remote) { | |
12323 | if (use_json) { | |
12324 | json_object_string_add(json_neigh, "hostForeign", | |
12325 | sockunion2str(p->su_remote, buf1, | |
12326 | SU_ADDRSTRLEN)); | |
12327 | json_object_int_add(json_neigh, "portForeign", | |
12328 | ntohs(p->su_remote->sin.sin_port)); | |
12329 | } else | |
12330 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
12331 | sockunion2str(p->su_remote, buf1, | |
12332 | SU_ADDRSTRLEN), | |
12333 | ntohs(p->su_remote->sin.sin_port)); | |
12334 | } | |
12335 | ||
12336 | /* Nexthop display. */ | |
12337 | if (p->su_local) { | |
12338 | if (use_json) { | |
12339 | json_object_string_add(json_neigh, "nexthop", | |
12340 | inet_ntop(AF_INET, | |
12341 | &p->nexthop.v4, buf1, | |
12342 | sizeof(buf1))); | |
12343 | json_object_string_add(json_neigh, "nexthopGlobal", | |
12344 | inet_ntop(AF_INET6, | |
12345 | &p->nexthop.v6_global, | |
12346 | buf1, sizeof(buf1))); | |
12347 | json_object_string_add(json_neigh, "nexthopLocal", | |
12348 | inet_ntop(AF_INET6, | |
12349 | &p->nexthop.v6_local, | |
12350 | buf1, sizeof(buf1))); | |
12351 | if (p->shared_network) | |
12352 | json_object_string_add(json_neigh, | |
12353 | "bgpConnection", | |
12354 | "sharedNetwork"); | |
12355 | else | |
12356 | json_object_string_add(json_neigh, | |
12357 | "bgpConnection", | |
12358 | "nonSharedNetwork"); | |
12359 | } else { | |
12360 | vty_out(vty, "Nexthop: %s\n", | |
12361 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
12362 | sizeof(buf1))); | |
12363 | vty_out(vty, "Nexthop global: %s\n", | |
12364 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
12365 | sizeof(buf1))); | |
12366 | vty_out(vty, "Nexthop local: %s\n", | |
12367 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
12368 | sizeof(buf1))); | |
12369 | vty_out(vty, "BGP connection: %s\n", | |
12370 | p->shared_network ? "shared network" | |
12371 | : "non shared network"); | |
12372 | } | |
12373 | } | |
12374 | ||
12375 | /* Timer information. */ | |
12376 | if (use_json) { | |
12377 | json_object_int_add(json_neigh, "connectRetryTimer", | |
12378 | p->v_connect); | |
12379 | if (p->status == Established && p->rtt) | |
12380 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
12381 | p->rtt); | |
12382 | if (p->t_start) | |
12383 | json_object_int_add( | |
12384 | json_neigh, "nextStartTimerDueInMsecs", | |
12385 | thread_timer_remain_second(p->t_start) * 1000); | |
12386 | if (p->t_connect) | |
12387 | json_object_int_add( | |
12388 | json_neigh, "nextConnectTimerDueInMsecs", | |
12389 | thread_timer_remain_second(p->t_connect) | |
12390 | * 1000); | |
12391 | if (p->t_routeadv) { | |
12392 | json_object_int_add(json_neigh, "mraiInterval", | |
12393 | p->v_routeadv); | |
12394 | json_object_int_add( | |
12395 | json_neigh, "mraiTimerExpireInMsecs", | |
12396 | thread_timer_remain_second(p->t_routeadv) | |
12397 | * 1000); | |
12398 | } | |
12399 | if (p->password) | |
12400 | json_object_int_add(json_neigh, "authenticationEnabled", | |
12401 | 1); | |
12402 | ||
12403 | if (p->t_read) | |
12404 | json_object_string_add(json_neigh, "readThread", "on"); | |
12405 | else | |
12406 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
12407 | |
12408 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 12409 | json_object_string_add(json_neigh, "writeThread", "on"); |
12410 | else | |
12411 | json_object_string_add(json_neigh, "writeThread", | |
12412 | "off"); | |
12413 | } else { | |
12414 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
12415 | p->v_connect); | |
12416 | if (p->status == Established && p->rtt) | |
12417 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
12418 | p->rtt); | |
12419 | if (p->t_start) | |
12420 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
12421 | thread_timer_remain_second(p->t_start)); | |
12422 | if (p->t_connect) | |
12423 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
12424 | thread_timer_remain_second(p->t_connect)); | |
12425 | if (p->t_routeadv) | |
12426 | vty_out(vty, | |
12427 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12428 | p->v_routeadv, | |
12429 | thread_timer_remain_second(p->t_routeadv)); | |
12430 | if (p->password) | |
12431 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12432 | ||
cac9e917 | 12433 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12434 | p->t_read ? "on" : "off", |
12435 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12436 | ? "on" | |
cac9e917 | 12437 | : "off", p->fd); |
d62a17ae | 12438 | } |
12439 | ||
12440 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12441 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12442 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12443 | ||
12444 | if (!use_json) | |
12445 | vty_out(vty, "\n"); | |
12446 | ||
12447 | /* BFD information. */ | |
12448 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12449 | ||
12450 | if (use_json) { | |
12451 | if (p->conf_if) /* Configured interface name. */ | |
12452 | json_object_object_add(json, p->conf_if, json_neigh); | |
12453 | else /* Configured IP address. */ | |
12454 | json_object_object_add(json, p->host, json_neigh); | |
12455 | } | |
12456 | } | |
12457 | ||
36235319 QY |
12458 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
12459 | enum show_type type, | |
12460 | union sockunion *su, | |
12461 | const char *conf_if, afi_t afi, | |
74a630b6 | 12462 | bool use_json) |
2986cac2 | 12463 | { |
12464 | struct listnode *node, *nnode; | |
12465 | struct peer *peer; | |
12466 | int find = 0; | |
12467 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 12468 | json_object *json = NULL; |
2986cac2 | 12469 | json_object *json_neighbor = NULL; |
12470 | ||
74a630b6 NT |
12471 | if (use_json) { |
12472 | json = json_object_new_object(); | |
12473 | json_neighbor = json_object_new_object(); | |
12474 | } | |
12475 | ||
2986cac2 | 12476 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
12477 | ||
12478 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12479 | continue; | |
12480 | ||
12481 | if ((peer->afc[afi][safi]) == 0) | |
12482 | continue; | |
12483 | ||
2ba1fe69 | 12484 | if (type == show_all) { |
2986cac2 | 12485 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 12486 | json_neighbor); |
2986cac2 | 12487 | |
74a630b6 | 12488 | if (use_json) { |
13909c4f DS |
12489 | json_object_object_add(json, peer->host, |
12490 | json_neighbor); | |
74a630b6 NT |
12491 | json_neighbor = NULL; |
12492 | } | |
2986cac2 | 12493 | |
2ba1fe69 | 12494 | } else if (type == show_peer) { |
2986cac2 | 12495 | if (conf_if) { |
12496 | if ((peer->conf_if | |
13909c4f DS |
12497 | && !strcmp(peer->conf_if, conf_if)) |
12498 | || (peer->hostname | |
2986cac2 | 12499 | && !strcmp(peer->hostname, conf_if))) { |
12500 | find = 1; | |
13909c4f DS |
12501 | bgp_show_peer_gr_status(vty, peer, |
12502 | use_json, | |
12503 | json_neighbor); | |
2986cac2 | 12504 | } |
12505 | } else { | |
12506 | if (sockunion_same(&peer->su, su)) { | |
12507 | find = 1; | |
13909c4f DS |
12508 | bgp_show_peer_gr_status(vty, peer, |
12509 | use_json, | |
12510 | json_neighbor); | |
2986cac2 | 12511 | } |
12512 | } | |
13909c4f DS |
12513 | if (use_json && find) |
12514 | json_object_object_add(json, peer->host, | |
12515 | json_neighbor); | |
2986cac2 | 12516 | } |
12517 | ||
74a630b6 NT |
12518 | if (find) { |
12519 | json_neighbor = NULL; | |
2986cac2 | 12520 | break; |
74a630b6 | 12521 | } |
2986cac2 | 12522 | } |
12523 | ||
12524 | if (type == show_peer && !find) { | |
12525 | if (use_json) | |
13909c4f | 12526 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 12527 | else |
12528 | vty_out(vty, "%% No such neighbor\n"); | |
12529 | } | |
12530 | if (use_json) { | |
13909c4f DS |
12531 | vty_out(vty, "%s\n", |
12532 | json_object_to_json_string_ext( | |
12533 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
12534 | |
12535 | if (json_neighbor) | |
12536 | json_object_free(json_neighbor); | |
12537 | json_object_free(json); | |
2986cac2 | 12538 | } else { |
12539 | vty_out(vty, "\n"); | |
12540 | } | |
12541 | ||
12542 | return CMD_SUCCESS; | |
12543 | } | |
12544 | ||
d62a17ae | 12545 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12546 | enum show_type type, union sockunion *su, | |
9f049418 | 12547 | const char *conf_if, bool use_json, |
d62a17ae | 12548 | json_object *json) |
12549 | { | |
12550 | struct listnode *node, *nnode; | |
12551 | struct peer *peer; | |
12552 | int find = 0; | |
9f049418 | 12553 | bool nbr_output = false; |
d1927ebe AS |
12554 | afi_t afi = AFI_MAX; |
12555 | safi_t safi = SAFI_MAX; | |
12556 | ||
12557 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12558 | afi = AFI_IP; | |
12559 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12560 | afi = AFI_IP6; | |
12561 | } | |
d62a17ae | 12562 | |
12563 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12564 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12565 | continue; | |
12566 | ||
12567 | switch (type) { | |
12568 | case show_all: | |
12569 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12570 | nbr_output = true; |
d62a17ae | 12571 | break; |
12572 | case show_peer: | |
12573 | if (conf_if) { | |
12574 | if ((peer->conf_if | |
12575 | && !strcmp(peer->conf_if, conf_if)) | |
12576 | || (peer->hostname | |
12577 | && !strcmp(peer->hostname, conf_if))) { | |
12578 | find = 1; | |
12579 | bgp_show_peer(vty, peer, use_json, | |
12580 | json); | |
12581 | } | |
12582 | } else { | |
12583 | if (sockunion_same(&peer->su, su)) { | |
12584 | find = 1; | |
12585 | bgp_show_peer(vty, peer, use_json, | |
12586 | json); | |
12587 | } | |
12588 | } | |
12589 | break; | |
d1927ebe AS |
12590 | case show_ipv4_peer: |
12591 | case show_ipv6_peer: | |
12592 | FOREACH_SAFI (safi) { | |
12593 | if (peer->afc[afi][safi]) { | |
12594 | if (conf_if) { | |
12595 | if ((peer->conf_if | |
12596 | && !strcmp(peer->conf_if, conf_if)) | |
12597 | || (peer->hostname | |
12598 | && !strcmp(peer->hostname, conf_if))) { | |
12599 | find = 1; | |
12600 | bgp_show_peer(vty, peer, use_json, | |
12601 | json); | |
12602 | break; | |
12603 | } | |
12604 | } else { | |
12605 | if (sockunion_same(&peer->su, su)) { | |
12606 | find = 1; | |
12607 | bgp_show_peer(vty, peer, use_json, | |
12608 | json); | |
12609 | break; | |
12610 | } | |
12611 | } | |
12612 | } | |
12613 | } | |
12614 | break; | |
12615 | case show_ipv4_all: | |
12616 | case show_ipv6_all: | |
12617 | FOREACH_SAFI (safi) { | |
12618 | if (peer->afc[afi][safi]) { | |
12619 | bgp_show_peer(vty, peer, use_json, json); | |
12620 | nbr_output = true; | |
12621 | break; | |
12622 | } | |
12623 | } | |
12624 | break; | |
d62a17ae | 12625 | } |
12626 | } | |
12627 | ||
d1927ebe AS |
12628 | if ((type == show_peer || type == show_ipv4_peer || |
12629 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12630 | if (use_json) |
12631 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12632 | else | |
88b7d255 | 12633 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12634 | } |
12635 | ||
d1927ebe AS |
12636 | if (type != show_peer && type != show_ipv4_peer && |
12637 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12638 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12639 | |
d62a17ae | 12640 | if (use_json) { |
996c9314 LB |
12641 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12642 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12643 | } else { |
12644 | vty_out(vty, "\n"); | |
12645 | } | |
12646 | ||
12647 | return CMD_SUCCESS; | |
12648 | } | |
12649 | ||
36235319 QY |
12650 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12651 | enum show_type type, | |
12652 | const char *ip_str, | |
12653 | afi_t afi, bool use_json) | |
2986cac2 | 12654 | { |
12655 | ||
12656 | int ret; | |
12657 | struct bgp *bgp; | |
12658 | union sockunion su; | |
2986cac2 | 12659 | |
12660 | bgp = bgp_get_default(); | |
12661 | ||
13909c4f DS |
12662 | if (!bgp) |
12663 | return; | |
2986cac2 | 12664 | |
13909c4f DS |
12665 | if (!use_json) |
12666 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
12667 | NULL); | |
2986cac2 | 12668 | |
13909c4f DS |
12669 | if (ip_str) { |
12670 | ret = str2sockunion(ip_str, &su); | |
12671 | if (ret < 0) | |
13909c4f | 12672 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
12673 | vty, bgp, type, NULL, ip_str, afi, use_json); |
12674 | else | |
12675 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
12676 | NULL, afi, use_json); | |
13909c4f DS |
12677 | } else |
12678 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 12679 | afi, use_json); |
2986cac2 | 12680 | } |
12681 | ||
d62a17ae | 12682 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12683 | enum show_type type, |
12684 | const char *ip_str, | |
9f049418 | 12685 | bool use_json) |
d62a17ae | 12686 | { |
0291c246 MK |
12687 | struct listnode *node, *nnode; |
12688 | struct bgp *bgp; | |
71aedaa3 | 12689 | union sockunion su; |
0291c246 | 12690 | json_object *json = NULL; |
71aedaa3 | 12691 | int ret, is_first = 1; |
9f049418 | 12692 | bool nbr_output = false; |
d62a17ae | 12693 | |
12694 | if (use_json) | |
12695 | vty_out(vty, "{\n"); | |
12696 | ||
12697 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12698 | nbr_output = true; |
d62a17ae | 12699 | if (use_json) { |
12700 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12701 | flog_err( |
e50f7cfd | 12702 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12703 | "Unable to allocate memory for JSON object"); |
12704 | vty_out(vty, | |
12705 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12706 | return; | |
12707 | } | |
12708 | ||
12709 | json_object_int_add(json, "vrfId", | |
12710 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12711 | ? -1 |
12712 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12713 | json_object_string_add( |
12714 | json, "vrfName", | |
12715 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12716 | ? VRF_DEFAULT_NAME |
d62a17ae | 12717 | : bgp->name); |
12718 | ||
12719 | if (!is_first) | |
12720 | vty_out(vty, ",\n"); | |
12721 | else | |
12722 | is_first = 0; | |
12723 | ||
12724 | vty_out(vty, "\"%s\":", | |
12725 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12726 | ? VRF_DEFAULT_NAME |
d62a17ae | 12727 | : bgp->name); |
12728 | } else { | |
12729 | vty_out(vty, "\nInstance %s:\n", | |
12730 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12731 | ? VRF_DEFAULT_NAME |
d62a17ae | 12732 | : bgp->name); |
12733 | } | |
71aedaa3 | 12734 | |
d1927ebe AS |
12735 | if (type == show_peer || type == show_ipv4_peer || |
12736 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12737 | ret = str2sockunion(ip_str, &su); |
12738 | if (ret < 0) | |
12739 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12740 | use_json, json); | |
12741 | else | |
12742 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12743 | use_json, json); | |
12744 | } else { | |
d1927ebe | 12745 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12746 | use_json, json); |
12747 | } | |
b77004d6 | 12748 | json_object_free(json); |
d62a17ae | 12749 | } |
12750 | ||
01cbfd04 | 12751 | if (use_json) { |
d62a17ae | 12752 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12753 | json_object_free(json); |
12754 | } | |
9f049418 DS |
12755 | else if (!nbr_output) |
12756 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12757 | } |
12758 | ||
12759 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12760 | enum show_type type, const char *ip_str, | |
9f049418 | 12761 | bool use_json) |
d62a17ae | 12762 | { |
12763 | int ret; | |
12764 | struct bgp *bgp; | |
12765 | union sockunion su; | |
12766 | json_object *json = NULL; | |
12767 | ||
12768 | if (name) { | |
12769 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12770 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12771 | use_json); | |
d62a17ae | 12772 | return CMD_SUCCESS; |
12773 | } else { | |
12774 | bgp = bgp_lookup_by_name(name); | |
12775 | if (!bgp) { | |
12776 | if (use_json) { | |
12777 | json = json_object_new_object(); | |
d62a17ae | 12778 | vty_out(vty, "%s\n", |
12779 | json_object_to_json_string_ext( | |
12780 | json, | |
12781 | JSON_C_TO_STRING_PRETTY)); | |
12782 | json_object_free(json); | |
12783 | } else | |
12784 | vty_out(vty, | |
9f049418 | 12785 | "%% BGP instance not found\n"); |
d62a17ae | 12786 | |
12787 | return CMD_WARNING; | |
12788 | } | |
12789 | } | |
12790 | } else { | |
12791 | bgp = bgp_get_default(); | |
12792 | } | |
12793 | ||
12794 | if (bgp) { | |
12795 | json = json_object_new_object(); | |
12796 | if (ip_str) { | |
12797 | ret = str2sockunion(ip_str, &su); | |
12798 | if (ret < 0) | |
12799 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12800 | use_json, json); | |
12801 | else | |
12802 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12803 | use_json, json); | |
12804 | } else { | |
12805 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12806 | json); | |
12807 | } | |
12808 | json_object_free(json); | |
ca61fd25 DS |
12809 | } else { |
12810 | if (use_json) | |
12811 | vty_out(vty, "{}\n"); | |
12812 | else | |
12813 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12814 | } |
12815 | ||
12816 | return CMD_SUCCESS; | |
4fb25c53 DW |
12817 | } |
12818 | ||
2986cac2 | 12819 | |
12820 | ||
12821 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12822 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12823 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12824 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12825 | SHOW_STR | |
12826 | BGP_STR | |
12827 | IP_STR | |
12828 | IPV6_STR | |
12829 | NEIGHBOR_STR | |
12830 | "Neighbor to display information about\n" | |
12831 | "Neighbor to display information about\n" | |
12832 | "Neighbor on BGP configured interface\n" | |
12833 | GR_SHOW | |
12834 | JSON_STR) | |
12835 | { | |
12836 | char *sh_arg = NULL; | |
12837 | enum show_type sh_type; | |
12838 | int idx = 0; | |
12839 | afi_t afi = AFI_MAX; | |
2986cac2 | 12840 | bool uj = use_json(argc, argv); |
12841 | ||
36235319 | 12842 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 12843 | afi = AFI_MAX; |
12844 | ||
12845 | idx++; | |
12846 | ||
12847 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12848 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12849 | || argv_find(argv, argc, "WORD", &idx)) { | |
12850 | sh_type = show_peer; | |
12851 | sh_arg = argv[idx]->arg; | |
12852 | } else | |
12853 | sh_type = show_all; | |
12854 | ||
12855 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12856 | return CMD_SUCCESS; | |
12857 | ||
12858 | ||
36235319 QY |
12859 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
12860 | afi, uj); | |
2986cac2 | 12861 | } |
12862 | ||
716b2d8a | 12863 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12864 | DEFUN (show_ip_bgp_neighbors, |
12865 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12866 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12867 | SHOW_STR |
12868 | IP_STR | |
12869 | BGP_STR | |
f2a8972b | 12870 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12871 | "Address Family\n" |
12872 | "Address Family\n" | |
718e3744 | 12873 | "Detailed information on TCP and BGP neighbor connections\n" |
12874 | "Neighbor to display information about\n" | |
a80beece | 12875 | "Neighbor to display information about\n" |
91d37724 | 12876 | "Neighbor on BGP configured interface\n" |
9973d184 | 12877 | JSON_STR) |
718e3744 | 12878 | { |
d62a17ae | 12879 | char *vrf = NULL; |
12880 | char *sh_arg = NULL; | |
12881 | enum show_type sh_type; | |
d1927ebe | 12882 | afi_t afi = AFI_MAX; |
718e3744 | 12883 | |
9f049418 | 12884 | bool uj = use_json(argc, argv); |
718e3744 | 12885 | |
d62a17ae | 12886 | int idx = 0; |
718e3744 | 12887 | |
9a8bdf1c PG |
12888 | /* [<vrf> VIEWVRFNAME] */ |
12889 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12890 | vrf = argv[idx + 1]->arg; | |
12891 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12892 | vrf = NULL; | |
12893 | } else if (argv_find(argv, argc, "view", &idx)) | |
12894 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12895 | vrf = argv[idx + 1]->arg; |
718e3744 | 12896 | |
d62a17ae | 12897 | idx++; |
d1927ebe AS |
12898 | |
12899 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12900 | sh_type = show_ipv4_all; | |
12901 | afi = AFI_IP; | |
12902 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12903 | sh_type = show_ipv6_all; | |
12904 | afi = AFI_IP6; | |
12905 | } else { | |
12906 | sh_type = show_all; | |
12907 | } | |
12908 | ||
d62a17ae | 12909 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12910 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12911 | || argv_find(argv, argc, "WORD", &idx)) { | |
12912 | sh_type = show_peer; | |
12913 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12914 | } |
12915 | ||
12916 | if (sh_type == show_peer && afi == AFI_IP) { | |
12917 | sh_type = show_ipv4_peer; | |
12918 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12919 | sh_type = show_ipv6_peer; | |
12920 | } | |
856ca177 | 12921 | |
d62a17ae | 12922 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12923 | } |
12924 | ||
716b2d8a | 12925 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12926 | paths' and `show ip mbgp paths'. Those functions results are the |
12927 | same.*/ | |
f412b39a | 12928 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12929 | show_ip_bgp_paths_cmd, |
46f296b4 | 12930 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12931 | SHOW_STR |
12932 | IP_STR | |
12933 | BGP_STR | |
46f296b4 | 12934 | BGP_SAFI_HELP_STR |
718e3744 | 12935 | "Path information\n") |
12936 | { | |
d62a17ae | 12937 | vty_out(vty, "Address Refcnt Path\n"); |
12938 | aspath_print_all_vty(vty); | |
12939 | return CMD_SUCCESS; | |
718e3744 | 12940 | } |
12941 | ||
718e3744 | 12942 | #include "hash.h" |
12943 | ||
e3b78da8 | 12944 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12945 | struct vty *vty) |
718e3744 | 12946 | { |
d62a17ae | 12947 | struct community *com; |
718e3744 | 12948 | |
e3b78da8 | 12949 | com = (struct community *)bucket->data; |
3f65c5b1 | 12950 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12951 | community_str(com, false)); |
718e3744 | 12952 | } |
12953 | ||
12954 | /* Show BGP's community internal data. */ | |
f412b39a | 12955 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 12956 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 12957 | "show [ip] bgp community-info", |
718e3744 | 12958 | SHOW_STR |
12959 | IP_STR | |
12960 | BGP_STR | |
12961 | "List all bgp community information\n") | |
12962 | { | |
d62a17ae | 12963 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 12964 | |
d62a17ae | 12965 | hash_iterate(community_hash(), |
e3b78da8 | 12966 | (void (*)(struct hash_bucket *, |
d62a17ae | 12967 | void *))community_show_all_iterator, |
12968 | vty); | |
718e3744 | 12969 | |
d62a17ae | 12970 | return CMD_SUCCESS; |
718e3744 | 12971 | } |
12972 | ||
e3b78da8 | 12973 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12974 | struct vty *vty) |
57d187bc | 12975 | { |
d62a17ae | 12976 | struct lcommunity *lcom; |
57d187bc | 12977 | |
e3b78da8 | 12978 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 12979 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 12980 | lcommunity_str(lcom, false)); |
57d187bc JS |
12981 | } |
12982 | ||
12983 | /* Show BGP's community internal data. */ | |
12984 | DEFUN (show_ip_bgp_lcommunity_info, | |
12985 | show_ip_bgp_lcommunity_info_cmd, | |
12986 | "show ip bgp large-community-info", | |
12987 | SHOW_STR | |
12988 | IP_STR | |
12989 | BGP_STR | |
12990 | "List all bgp large-community information\n") | |
12991 | { | |
d62a17ae | 12992 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 12993 | |
d62a17ae | 12994 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 12995 | (void (*)(struct hash_bucket *, |
d62a17ae | 12996 | void *))lcommunity_show_all_iterator, |
12997 | vty); | |
57d187bc | 12998 | |
d62a17ae | 12999 | return CMD_SUCCESS; |
57d187bc | 13000 | } |
2986cac2 | 13001 | /* Graceful Restart */ |
13002 | ||
13003 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
13004 | struct bgp *bgp, |
13005 | bool use_json, | |
13006 | json_object *json) | |
2986cac2 | 13007 | { |
57d187bc JS |
13008 | |
13009 | ||
2986cac2 | 13010 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
13011 | ||
7318ae88 | 13012 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 13013 | |
13014 | switch (bgp_global_gr_mode) { | |
13015 | ||
13016 | case GLOBAL_HELPER: | |
13909c4f | 13017 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 13018 | break; |
13019 | ||
13020 | case GLOBAL_GR: | |
13909c4f | 13021 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 13022 | break; |
13023 | ||
13024 | case GLOBAL_DISABLE: | |
13909c4f | 13025 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 13026 | break; |
13027 | ||
13028 | case GLOBAL_INVALID: | |
2986cac2 | 13029 | vty_out(vty, |
2ba1fe69 | 13030 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 13031 | break; |
13032 | } | |
13033 | vty_out(vty, "\n"); | |
13034 | } | |
13035 | ||
36235319 QY |
13036 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
13037 | enum show_type type, | |
13038 | const char *ip_str, | |
13039 | afi_t afi, bool use_json) | |
2986cac2 | 13040 | { |
13041 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
13042 | afi = AFI_IP; | |
13043 | ||
13044 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
13045 | ||
36235319 QY |
13046 | bgp_show_neighbor_graceful_restart_vty( |
13047 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 13048 | afi++; |
13049 | } | |
13050 | } else if (afi != AFI_MAX) { | |
36235319 QY |
13051 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
13052 | use_json); | |
2986cac2 | 13053 | } else { |
13054 | return CMD_ERR_INCOMPLETE; | |
13055 | } | |
13056 | ||
13057 | return CMD_SUCCESS; | |
13058 | } | |
13059 | /* Graceful Restart */ | |
13060 | ||
f412b39a | 13061 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 13062 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 13063 | "show [ip] bgp attribute-info", |
718e3744 | 13064 | SHOW_STR |
13065 | IP_STR | |
13066 | BGP_STR | |
13067 | "List all bgp attribute information\n") | |
13068 | { | |
d62a17ae | 13069 | attr_show_all(vty); |
13070 | return CMD_SUCCESS; | |
718e3744 | 13071 | } |
6b0655a2 | 13072 | |
03915806 CS |
13073 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
13074 | afi_t afi, safi_t safi, | |
13075 | bool use_json, json_object *json) | |
53089bec | 13076 | { |
13077 | struct bgp *bgp; | |
13078 | struct listnode *node; | |
13079 | char *vname; | |
13080 | char buf1[INET6_ADDRSTRLEN]; | |
13081 | char *ecom_str; | |
13082 | vpn_policy_direction_t dir; | |
13083 | ||
03915806 | 13084 | if (json) { |
b46dfd20 DS |
13085 | json_object *json_import_vrfs = NULL; |
13086 | json_object *json_export_vrfs = NULL; | |
13087 | ||
b46dfd20 DS |
13088 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13089 | ||
53089bec | 13090 | if (!bgp) { |
b46dfd20 DS |
13091 | vty_out(vty, "%s\n", |
13092 | json_object_to_json_string_ext( | |
13093 | json, | |
13094 | JSON_C_TO_STRING_PRETTY)); | |
13095 | json_object_free(json); | |
13096 | ||
53089bec | 13097 | return CMD_WARNING; |
13098 | } | |
b46dfd20 | 13099 | |
94d4c685 DS |
13100 | /* Provide context for the block */ |
13101 | json_object_string_add(json, "vrf", name ? name : "default"); | |
13102 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 13103 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 13104 | |
b46dfd20 DS |
13105 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13106 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
13107 | json_object_string_add(json, "importFromVrfs", "none"); | |
13108 | json_object_string_add(json, "importRts", "none"); | |
13109 | } else { | |
6ce24e52 DS |
13110 | json_import_vrfs = json_object_new_array(); |
13111 | ||
b46dfd20 DS |
13112 | for (ALL_LIST_ELEMENTS_RO( |
13113 | bgp->vpn_policy[afi].import_vrf, | |
13114 | node, vname)) | |
13115 | json_object_array_add(json_import_vrfs, | |
13116 | json_object_new_string(vname)); | |
13117 | ||
b20875ea CS |
13118 | json_object_object_add(json, "importFromVrfs", |
13119 | json_import_vrfs); | |
b46dfd20 | 13120 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
13121 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13122 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13123 | bgp->vpn_policy[afi].rtlist[dir], |
13124 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13125 | json_object_string_add(json, "importRts", |
13126 | ecom_str); | |
13127 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13128 | } else | |
13129 | json_object_string_add(json, "importRts", | |
13130 | "none"); | |
b46dfd20 DS |
13131 | } |
13132 | ||
13133 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
13134 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
13135 | json_object_string_add(json, "exportToVrfs", "none"); | |
13136 | json_object_string_add(json, "routeDistinguisher", | |
13137 | "none"); | |
13138 | json_object_string_add(json, "exportRts", "none"); | |
13139 | } else { | |
6ce24e52 DS |
13140 | json_export_vrfs = json_object_new_array(); |
13141 | ||
b46dfd20 DS |
13142 | for (ALL_LIST_ELEMENTS_RO( |
13143 | bgp->vpn_policy[afi].export_vrf, | |
13144 | node, vname)) | |
13145 | json_object_array_add(json_export_vrfs, | |
13146 | json_object_new_string(vname)); | |
13147 | json_object_object_add(json, "exportToVrfs", | |
13148 | json_export_vrfs); | |
13149 | json_object_string_add(json, "routeDistinguisher", | |
13150 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13151 | buf1, RD_ADDRSTRLEN)); | |
13152 | ||
13153 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13154 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13155 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13156 | bgp->vpn_policy[afi].rtlist[dir], |
13157 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13158 | json_object_string_add(json, "exportRts", |
13159 | ecom_str); | |
13160 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13161 | } else | |
13162 | json_object_string_add(json, "exportRts", | |
13163 | "none"); | |
b46dfd20 DS |
13164 | } |
13165 | ||
03915806 CS |
13166 | if (use_json) { |
13167 | vty_out(vty, "%s\n", | |
13168 | json_object_to_json_string_ext(json, | |
b46dfd20 | 13169 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
13170 | json_object_free(json); |
13171 | } | |
53089bec | 13172 | } else { |
b46dfd20 DS |
13173 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13174 | ||
53089bec | 13175 | if (!bgp) { |
b46dfd20 | 13176 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 13177 | return CMD_WARNING; |
13178 | } | |
53089bec | 13179 | |
b46dfd20 DS |
13180 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13181 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
13182 | vty_out(vty, | |
13183 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 13184 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13185 | else { |
13186 | vty_out(vty, | |
13187 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 13188 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13189 | |
13190 | for (ALL_LIST_ELEMENTS_RO( | |
13191 | bgp->vpn_policy[afi].import_vrf, | |
13192 | node, vname)) | |
13193 | vty_out(vty, " %s\n", vname); | |
13194 | ||
13195 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
13196 | ecom_str = NULL; |
13197 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
13198 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13199 | bgp->vpn_policy[afi].rtlist[dir], |
13200 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 13201 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 13202 | |
b20875ea CS |
13203 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
13204 | } else | |
13205 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13206 | } |
53089bec | 13207 | |
b46dfd20 DS |
13208 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13209 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
13210 | vty_out(vty, | |
13211 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 13212 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13213 | else { |
13214 | vty_out(vty, | |
04c9077f | 13215 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 13216 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13217 | |
13218 | for (ALL_LIST_ELEMENTS_RO( | |
13219 | bgp->vpn_policy[afi].export_vrf, | |
13220 | node, vname)) | |
13221 | vty_out(vty, " %s\n", vname); | |
13222 | ||
13223 | vty_out(vty, "RD: %s\n", | |
13224 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13225 | buf1, RD_ADDRSTRLEN)); | |
13226 | ||
13227 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13228 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13229 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13230 | bgp->vpn_policy[afi].rtlist[dir], |
13231 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13232 | vty_out(vty, "Export RT: %s\n", ecom_str); |
13233 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13234 | } else | |
13235 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13236 | } |
53089bec | 13237 | } |
13238 | ||
13239 | return CMD_SUCCESS; | |
13240 | } | |
13241 | ||
03915806 CS |
13242 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
13243 | safi_t safi, bool use_json) | |
13244 | { | |
13245 | struct listnode *node, *nnode; | |
13246 | struct bgp *bgp; | |
13247 | char *vrf_name = NULL; | |
13248 | json_object *json = NULL; | |
13249 | json_object *json_vrf = NULL; | |
13250 | json_object *json_vrfs = NULL; | |
13251 | ||
13252 | if (use_json) { | |
13253 | json = json_object_new_object(); | |
13254 | json_vrfs = json_object_new_object(); | |
13255 | } | |
13256 | ||
13257 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
13258 | ||
13259 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
13260 | vrf_name = bgp->name; | |
13261 | ||
13262 | if (use_json) { | |
13263 | json_vrf = json_object_new_object(); | |
13264 | } else { | |
13265 | vty_out(vty, "\nInstance %s:\n", | |
13266 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13267 | ? VRF_DEFAULT_NAME : bgp->name); | |
13268 | } | |
13269 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
13270 | if (use_json) { | |
13271 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13272 | json_object_object_add(json_vrfs, | |
13273 | VRF_DEFAULT_NAME, json_vrf); | |
13274 | else | |
13275 | json_object_object_add(json_vrfs, vrf_name, | |
13276 | json_vrf); | |
13277 | } | |
13278 | } | |
13279 | ||
13280 | if (use_json) { | |
13281 | json_object_object_add(json, "vrfs", json_vrfs); | |
13282 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
13283 | JSON_C_TO_STRING_PRETTY)); | |
13284 | json_object_free(json); | |
13285 | } | |
13286 | ||
13287 | return CMD_SUCCESS; | |
13288 | } | |
13289 | ||
53089bec | 13290 | /* "show [ip] bgp route-leak" command. */ |
13291 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
13292 | show_ip_bgp_route_leak_cmd, |
13293 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
13294 | SHOW_STR |
13295 | IP_STR | |
13296 | BGP_STR | |
13297 | BGP_INSTANCE_HELP_STR | |
13298 | BGP_AFI_HELP_STR | |
13299 | BGP_SAFI_HELP_STR | |
13300 | "Route leaking information\n" | |
13301 | JSON_STR) | |
53089bec | 13302 | { |
13303 | char *vrf = NULL; | |
13304 | afi_t afi = AFI_MAX; | |
13305 | safi_t safi = SAFI_MAX; | |
13306 | ||
9f049418 | 13307 | bool uj = use_json(argc, argv); |
53089bec | 13308 | int idx = 0; |
03915806 | 13309 | json_object *json = NULL; |
53089bec | 13310 | |
13311 | /* show [ip] bgp */ | |
13312 | if (argv_find(argv, argc, "ip", &idx)) { | |
13313 | afi = AFI_IP; | |
13314 | safi = SAFI_UNICAST; | |
13315 | } | |
13316 | /* [vrf VIEWVRFNAME] */ | |
13317 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
13318 | vty_out(vty, |
13319 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 13320 | return CMD_WARNING; |
13321 | } | |
13322 | ||
9a8bdf1c PG |
13323 | if (argv_find(argv, argc, "vrf", &idx)) { |
13324 | vrf = argv[idx + 1]->arg; | |
13325 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13326 | vrf = NULL; | |
13327 | } | |
53089bec | 13328 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13329 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13330 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13331 | } | |
13332 | ||
13333 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
13334 | vty_out(vty, |
13335 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 13336 | return CMD_WARNING; |
13337 | } | |
13338 | ||
03915806 CS |
13339 | if (vrf && strmatch(vrf, "all")) |
13340 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
13341 | ||
13342 | if (uj) | |
13343 | json = json_object_new_object(); | |
13344 | ||
13345 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 13346 | } |
13347 | ||
d62a17ae | 13348 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
13349 | safi_t safi) | |
f186de26 | 13350 | { |
d62a17ae | 13351 | struct listnode *node, *nnode; |
13352 | struct bgp *bgp; | |
f186de26 | 13353 | |
d62a17ae | 13354 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
13355 | vty_out(vty, "\nInstance %s:\n", | |
13356 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13357 | ? VRF_DEFAULT_NAME |
d62a17ae | 13358 | : bgp->name); |
13359 | update_group_show(bgp, afi, safi, vty, 0); | |
13360 | } | |
f186de26 | 13361 | } |
13362 | ||
d62a17ae | 13363 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
13364 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 13365 | { |
d62a17ae | 13366 | struct bgp *bgp; |
4fb25c53 | 13367 | |
d62a17ae | 13368 | if (name) { |
13369 | if (strmatch(name, "all")) { | |
13370 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
13371 | return CMD_SUCCESS; | |
13372 | } else { | |
13373 | bgp = bgp_lookup_by_name(name); | |
13374 | } | |
13375 | } else { | |
13376 | bgp = bgp_get_default(); | |
13377 | } | |
4fb25c53 | 13378 | |
d62a17ae | 13379 | if (bgp) |
13380 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
13381 | return CMD_SUCCESS; | |
4fb25c53 DW |
13382 | } |
13383 | ||
8fe8a7f6 DS |
13384 | DEFUN (show_ip_bgp_updgrps, |
13385 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 13386 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 13387 | SHOW_STR |
13388 | IP_STR | |
13389 | BGP_STR | |
13390 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 13391 | BGP_AFI_HELP_STR |
9bedbb1e | 13392 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
13393 | "Detailed info about dynamic update groups\n" |
13394 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 13395 | { |
d62a17ae | 13396 | char *vrf = NULL; |
13397 | afi_t afi = AFI_IP6; | |
13398 | safi_t safi = SAFI_UNICAST; | |
13399 | uint64_t subgrp_id = 0; | |
13400 | ||
13401 | int idx = 0; | |
13402 | ||
13403 | /* show [ip] bgp */ | |
13404 | if (argv_find(argv, argc, "ip", &idx)) | |
13405 | afi = AFI_IP; | |
9a8bdf1c PG |
13406 | /* [<vrf> VIEWVRFNAME] */ |
13407 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13408 | vrf = argv[idx + 1]->arg; | |
13409 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13410 | vrf = NULL; | |
13411 | } else if (argv_find(argv, argc, "view", &idx)) | |
13412 | /* [<view> VIEWVRFNAME] */ | |
13413 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 13414 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13415 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13416 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13417 | } | |
5bf15956 | 13418 | |
d62a17ae | 13419 | /* get subgroup id, if provided */ |
13420 | idx = argc - 1; | |
13421 | if (argv[idx]->type == VARIABLE_TKN) | |
13422 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13423 | |
d62a17ae | 13424 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13425 | } |
13426 | ||
f186de26 | 13427 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13428 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13429 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13430 | SHOW_STR |
716b2d8a | 13431 | IP_STR |
f186de26 | 13432 | BGP_STR |
13433 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13434 | "Detailed info about dynamic update groups\n") |
f186de26 | 13435 | { |
d62a17ae | 13436 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13437 | return CMD_SUCCESS; | |
f186de26 | 13438 | } |
13439 | ||
43d3f4fc DS |
13440 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13441 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13442 | "show [ip] bgp l2vpn evpn update-groups", | |
13443 | SHOW_STR | |
13444 | IP_STR | |
13445 | BGP_STR | |
13446 | "l2vpn address family\n" | |
13447 | "evpn sub-address family\n" | |
13448 | "Detailed info about dynamic update groups\n") | |
13449 | { | |
13450 | char *vrf = NULL; | |
13451 | uint64_t subgrp_id = 0; | |
13452 | ||
13453 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13454 | return CMD_SUCCESS; | |
13455 | } | |
13456 | ||
5bf15956 DW |
13457 | DEFUN (show_bgp_updgrps_stats, |
13458 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13459 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13460 | SHOW_STR |
716b2d8a | 13461 | IP_STR |
3f9c7369 | 13462 | BGP_STR |
0c7b1b01 | 13463 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13464 | "Statistics\n") |
13465 | { | |
d62a17ae | 13466 | struct bgp *bgp; |
3f9c7369 | 13467 | |
d62a17ae | 13468 | bgp = bgp_get_default(); |
13469 | if (bgp) | |
13470 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13471 | |
d62a17ae | 13472 | return CMD_SUCCESS; |
3f9c7369 DS |
13473 | } |
13474 | ||
8386ac43 | 13475 | DEFUN (show_bgp_instance_updgrps_stats, |
13476 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13477 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13478 | SHOW_STR |
716b2d8a | 13479 | IP_STR |
8386ac43 | 13480 | BGP_STR |
13481 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13482 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13483 | "Statistics\n") |
13484 | { | |
d62a17ae | 13485 | int idx_word = 3; |
13486 | struct bgp *bgp; | |
8386ac43 | 13487 | |
d62a17ae | 13488 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13489 | if (bgp) | |
13490 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13491 | |
d62a17ae | 13492 | return CMD_SUCCESS; |
8386ac43 | 13493 | } |
13494 | ||
d62a17ae | 13495 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13496 | afi_t afi, safi_t safi, | |
13497 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13498 | { |
d62a17ae | 13499 | struct bgp *bgp; |
8386ac43 | 13500 | |
d62a17ae | 13501 | if (name) |
13502 | bgp = bgp_lookup_by_name(name); | |
13503 | else | |
13504 | bgp = bgp_get_default(); | |
8386ac43 | 13505 | |
d62a17ae | 13506 | if (bgp) { |
13507 | if (!strcmp(what, "advertise-queue")) | |
13508 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13509 | subgrp_id); | |
13510 | else if (!strcmp(what, "advertised-routes")) | |
13511 | update_group_show_advertised(bgp, afi, safi, vty, | |
13512 | subgrp_id); | |
13513 | else if (!strcmp(what, "packet-queue")) | |
13514 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13515 | subgrp_id); | |
13516 | } | |
3f9c7369 DS |
13517 | } |
13518 | ||
dc64bdec QY |
13519 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13520 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13521 | "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", | |
13522 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13523 | BGP_SAFI_HELP_STR | |
13524 | "Detailed info about dynamic update groups\n" | |
13525 | "Specific subgroup to display info for\n" | |
13526 | "Advertisement queue\n" | |
13527 | "Announced routes\n" | |
13528 | "Packet queue\n") | |
3f9c7369 | 13529 | { |
dc64bdec QY |
13530 | uint64_t subgrp_id = 0; |
13531 | afi_t afiz; | |
13532 | safi_t safiz; | |
13533 | if (sgid) | |
13534 | subgrp_id = strtoull(sgid, NULL, 10); | |
13535 | ||
13536 | if (!ip && !afi) | |
13537 | afiz = AFI_IP6; | |
13538 | if (!ip && afi) | |
13539 | afiz = bgp_vty_afi_from_str(afi); | |
13540 | if (ip && !afi) | |
13541 | afiz = AFI_IP; | |
13542 | if (ip && afi) { | |
13543 | afiz = bgp_vty_afi_from_str(afi); | |
13544 | if (afiz != AFI_IP) | |
13545 | vty_out(vty, | |
13546 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13547 | return CMD_WARNING; | |
13548 | } | |
d62a17ae | 13549 | |
dc64bdec | 13550 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13551 | |
dc64bdec | 13552 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13553 | return CMD_SUCCESS; |
13554 | } | |
13555 | ||
d62a17ae | 13556 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13557 | { | |
13558 | struct listnode *node, *nnode; | |
13559 | struct prefix *range; | |
13560 | struct peer *conf; | |
13561 | struct peer *peer; | |
13562 | char buf[PREFIX2STR_BUFFER]; | |
13563 | afi_t afi; | |
13564 | safi_t safi; | |
13565 | const char *peer_status; | |
13566 | const char *af_str; | |
13567 | int lr_count; | |
13568 | int dynamic; | |
13569 | int af_cfgd; | |
13570 | ||
13571 | conf = group->conf; | |
13572 | ||
13573 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
6cde4b45 | 13574 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 13575 | group->name, conf->as); |
d62a17ae | 13576 | } else if (conf->as_type == AS_INTERNAL) { |
6cde4b45 | 13577 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 13578 | group->name, group->bgp->as); |
d62a17ae | 13579 | } else { |
13580 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13581 | } | |
f14e6fdb | 13582 | |
d62a17ae | 13583 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13584 | vty_out(vty, " Peer-group type is internal\n"); | |
13585 | else | |
13586 | vty_out(vty, " Peer-group type is external\n"); | |
13587 | ||
13588 | /* Display AFs configured. */ | |
13589 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13590 | FOREACH_AFI_SAFI (afi, safi) { |
13591 | if (conf->afc[afi][safi]) { | |
13592 | af_cfgd = 1; | |
5cb5f4d0 | 13593 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13594 | } |
05c7a1cc | 13595 | } |
d62a17ae | 13596 | if (!af_cfgd) |
13597 | vty_out(vty, " none\n"); | |
13598 | else | |
13599 | vty_out(vty, "\n"); | |
13600 | ||
13601 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13602 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13603 | if (afi == AFI_IP) | |
13604 | af_str = "IPv4"; | |
13605 | else if (afi == AFI_IP6) | |
13606 | af_str = "IPv6"; | |
13607 | else | |
13608 | af_str = "???"; | |
13609 | lr_count = listcount(group->listen_range[afi]); | |
13610 | if (lr_count) { | |
13611 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13612 | af_str); | |
13613 | ||
13614 | ||
13615 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13616 | nnode, range)) { | |
13617 | prefix2str(range, buf, sizeof(buf)); | |
13618 | vty_out(vty, " %s\n", buf); | |
13619 | } | |
13620 | } | |
13621 | } | |
f14e6fdb | 13622 | |
d62a17ae | 13623 | /* Display group members and their status */ |
13624 | if (listcount(group->peer)) { | |
13625 | vty_out(vty, " Peer-group members:\n"); | |
13626 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
13627 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
13628 | peer_status = "Idle (Admin)"; | |
13629 | else if (CHECK_FLAG(peer->sflags, | |
13630 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13631 | peer_status = "Idle (PfxCt)"; | |
13632 | else | |
13633 | peer_status = lookup_msg(bgp_status_msg, | |
13634 | peer->status, NULL); | |
13635 | ||
13636 | dynamic = peer_dynamic_neighbor(peer); | |
13637 | vty_out(vty, " %s %s %s \n", peer->host, | |
13638 | dynamic ? "(dynamic)" : "", peer_status); | |
13639 | } | |
13640 | } | |
f14e6fdb | 13641 | |
d62a17ae | 13642 | return CMD_SUCCESS; |
13643 | } | |
13644 | ||
ff9959b0 QY |
13645 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13646 | const char *group_name) | |
d62a17ae | 13647 | { |
ff9959b0 | 13648 | struct bgp *bgp; |
d62a17ae | 13649 | struct listnode *node, *nnode; |
13650 | struct peer_group *group; | |
ff9959b0 QY |
13651 | bool found = false; |
13652 | ||
13653 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13654 | ||
13655 | if (!bgp) { | |
9f049418 | 13656 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13657 | return CMD_WARNING; |
13658 | } | |
d62a17ae | 13659 | |
13660 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13661 | if (group_name) { |
13662 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13663 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13664 | found = true; |
13665 | break; | |
d62a17ae | 13666 | } |
ff9959b0 QY |
13667 | } else { |
13668 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13669 | } |
f14e6fdb | 13670 | } |
f14e6fdb | 13671 | |
ff9959b0 | 13672 | if (group_name && !found) |
d62a17ae | 13673 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13674 | |
d62a17ae | 13675 | return CMD_SUCCESS; |
f14e6fdb DS |
13676 | } |
13677 | ||
f14e6fdb DS |
13678 | DEFUN (show_ip_bgp_peer_groups, |
13679 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13680 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13681 | SHOW_STR |
13682 | IP_STR | |
13683 | BGP_STR | |
8386ac43 | 13684 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13685 | "Detailed information on BGP peer groups\n" |
13686 | "Peer group name\n") | |
f14e6fdb | 13687 | { |
d62a17ae | 13688 | char *vrf, *pg; |
d62a17ae | 13689 | int idx = 0; |
f14e6fdb | 13690 | |
a4d82a8a PZ |
13691 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13692 | : NULL; | |
d62a17ae | 13693 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13694 | |
ff9959b0 | 13695 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13696 | } |
3f9c7369 | 13697 | |
d6e3c605 | 13698 | |
718e3744 | 13699 | /* Redistribute VTY commands. */ |
13700 | ||
718e3744 | 13701 | DEFUN (bgp_redistribute_ipv4, |
13702 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13703 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13704 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13705 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13706 | { |
d62a17ae | 13707 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13708 | int idx_protocol = 1; | |
13709 | int type; | |
718e3744 | 13710 | |
d62a17ae | 13711 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13712 | if (type < 0) { | |
13713 | vty_out(vty, "%% Invalid route type\n"); | |
13714 | return CMD_WARNING_CONFIG_FAILED; | |
13715 | } | |
7f323236 | 13716 | |
d62a17ae | 13717 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13718 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13719 | } |
13720 | ||
d62a17ae | 13721 | ALIAS_HIDDEN( |
13722 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13723 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13724 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13725 | |
718e3744 | 13726 | DEFUN (bgp_redistribute_ipv4_rmap, |
13727 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13728 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13729 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13730 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13731 | "Route map reference\n" |
13732 | "Pointer to route-map entries\n") | |
13733 | { | |
d62a17ae | 13734 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13735 | int idx_protocol = 1; | |
13736 | int idx_word = 3; | |
13737 | int type; | |
13738 | struct bgp_redist *red; | |
e923dd62 | 13739 | bool changed; |
1de27621 DA |
13740 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13741 | vty, argv[idx_word]->arg); | |
718e3744 | 13742 | |
d62a17ae | 13743 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13744 | if (type < 0) { | |
13745 | vty_out(vty, "%% Invalid route type\n"); | |
13746 | return CMD_WARNING_CONFIG_FAILED; | |
13747 | } | |
718e3744 | 13748 | |
d62a17ae | 13749 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13750 | changed = |
13751 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13752 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13753 | } |
13754 | ||
d62a17ae | 13755 | ALIAS_HIDDEN( |
13756 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13757 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13758 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13759 | "Route map reference\n" | |
13760 | "Pointer to route-map entries\n") | |
596c17ba | 13761 | |
718e3744 | 13762 | DEFUN (bgp_redistribute_ipv4_metric, |
13763 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13764 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13765 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13766 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13767 | "Metric for redistributed routes\n" |
13768 | "Default metric\n") | |
13769 | { | |
d62a17ae | 13770 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13771 | int idx_protocol = 1; | |
13772 | int idx_number = 3; | |
13773 | int type; | |
d7c0a89a | 13774 | uint32_t metric; |
d62a17ae | 13775 | struct bgp_redist *red; |
e923dd62 | 13776 | bool changed; |
d62a17ae | 13777 | |
13778 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13779 | if (type < 0) { | |
13780 | vty_out(vty, "%% Invalid route type\n"); | |
13781 | return CMD_WARNING_CONFIG_FAILED; | |
13782 | } | |
13783 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13784 | ||
13785 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13786 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13787 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13788 | } |
13789 | ||
13790 | ALIAS_HIDDEN( | |
13791 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13792 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13793 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13794 | "Metric for redistributed routes\n" | |
13795 | "Default metric\n") | |
596c17ba | 13796 | |
718e3744 | 13797 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13798 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13799 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13800 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13801 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13802 | "Route map reference\n" |
13803 | "Pointer to route-map entries\n" | |
13804 | "Metric for redistributed routes\n" | |
13805 | "Default metric\n") | |
13806 | { | |
d62a17ae | 13807 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13808 | int idx_protocol = 1; | |
13809 | int idx_word = 3; | |
13810 | int idx_number = 5; | |
13811 | int type; | |
d7c0a89a | 13812 | uint32_t metric; |
d62a17ae | 13813 | struct bgp_redist *red; |
e923dd62 | 13814 | bool changed; |
1de27621 DA |
13815 | struct route_map *route_map = |
13816 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13817 | |
13818 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13819 | if (type < 0) { | |
13820 | vty_out(vty, "%% Invalid route type\n"); | |
13821 | return CMD_WARNING_CONFIG_FAILED; | |
13822 | } | |
13823 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13824 | ||
13825 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13826 | changed = |
13827 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13828 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13829 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13830 | } |
13831 | ||
13832 | ALIAS_HIDDEN( | |
13833 | bgp_redistribute_ipv4_rmap_metric, | |
13834 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13835 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13836 | " route-map WORD metric (0-4294967295)", | |
13837 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13838 | "Route map reference\n" | |
13839 | "Pointer to route-map entries\n" | |
13840 | "Metric for redistributed routes\n" | |
13841 | "Default metric\n") | |
596c17ba | 13842 | |
718e3744 | 13843 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13844 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13845 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13846 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13847 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13848 | "Metric for redistributed routes\n" |
13849 | "Default metric\n" | |
13850 | "Route map reference\n" | |
13851 | "Pointer to route-map entries\n") | |
13852 | { | |
d62a17ae | 13853 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13854 | int idx_protocol = 1; | |
13855 | int idx_number = 3; | |
13856 | int idx_word = 5; | |
13857 | int type; | |
d7c0a89a | 13858 | uint32_t metric; |
d62a17ae | 13859 | struct bgp_redist *red; |
e923dd62 | 13860 | bool changed; |
1de27621 DA |
13861 | struct route_map *route_map = |
13862 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13863 | |
13864 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13865 | if (type < 0) { | |
13866 | vty_out(vty, "%% Invalid route type\n"); | |
13867 | return CMD_WARNING_CONFIG_FAILED; | |
13868 | } | |
13869 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13870 | ||
13871 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13872 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13873 | changed |= |
13874 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13875 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13876 | } |
13877 | ||
13878 | ALIAS_HIDDEN( | |
13879 | bgp_redistribute_ipv4_metric_rmap, | |
13880 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13881 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13882 | " metric (0-4294967295) route-map WORD", | |
13883 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13884 | "Metric for redistributed routes\n" | |
13885 | "Default metric\n" | |
13886 | "Route map reference\n" | |
13887 | "Pointer to route-map entries\n") | |
596c17ba | 13888 | |
7c8ff89e DS |
13889 | DEFUN (bgp_redistribute_ipv4_ospf, |
13890 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13891 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13892 | "Redistribute information from another routing protocol\n" |
13893 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13894 | "Non-main Kernel Routing Table\n" |
13895 | "Instance ID/Table ID\n") | |
7c8ff89e | 13896 | { |
d62a17ae | 13897 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13898 | int idx_ospf_table = 1; | |
13899 | int idx_number = 2; | |
d7c0a89a QY |
13900 | unsigned short instance; |
13901 | unsigned short protocol; | |
7c8ff89e | 13902 | |
d62a17ae | 13903 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13904 | |
d62a17ae | 13905 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13906 | protocol = ZEBRA_ROUTE_OSPF; | |
13907 | else | |
13908 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13909 | |
d62a17ae | 13910 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13911 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13912 | } |
13913 | ||
d62a17ae | 13914 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13915 | "redistribute <ospf|table> (1-65535)", | |
13916 | "Redistribute information from another routing protocol\n" | |
13917 | "Open Shortest Path First (OSPFv2)\n" | |
13918 | "Non-main Kernel Routing Table\n" | |
13919 | "Instance ID/Table ID\n") | |
596c17ba | 13920 | |
7c8ff89e DS |
13921 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13922 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13923 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13924 | "Redistribute information from another routing protocol\n" |
13925 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13926 | "Non-main Kernel Routing Table\n" |
13927 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13928 | "Route map reference\n" |
13929 | "Pointer to route-map entries\n") | |
13930 | { | |
d62a17ae | 13931 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13932 | int idx_ospf_table = 1; | |
13933 | int idx_number = 2; | |
13934 | int idx_word = 4; | |
13935 | struct bgp_redist *red; | |
d7c0a89a | 13936 | unsigned short instance; |
d62a17ae | 13937 | int protocol; |
e923dd62 | 13938 | bool changed; |
1de27621 DA |
13939 | struct route_map *route_map = |
13940 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13941 | |
13942 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13943 | protocol = ZEBRA_ROUTE_OSPF; | |
13944 | else | |
13945 | protocol = ZEBRA_ROUTE_TABLE; | |
13946 | ||
13947 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13948 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13949 | changed = |
13950 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13951 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13952 | } |
13953 | ||
13954 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
13955 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
13956 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
13957 | "Redistribute information from another routing protocol\n" | |
13958 | "Open Shortest Path First (OSPFv2)\n" | |
13959 | "Non-main Kernel Routing Table\n" | |
13960 | "Instance ID/Table ID\n" | |
13961 | "Route map reference\n" | |
13962 | "Pointer to route-map entries\n") | |
596c17ba | 13963 | |
7c8ff89e DS |
13964 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
13965 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 13966 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
13967 | "Redistribute information from another routing protocol\n" |
13968 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13969 | "Non-main Kernel Routing Table\n" |
13970 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13971 | "Metric for redistributed routes\n" |
13972 | "Default metric\n") | |
13973 | { | |
d62a17ae | 13974 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13975 | int idx_ospf_table = 1; | |
13976 | int idx_number = 2; | |
13977 | int idx_number_2 = 4; | |
d7c0a89a | 13978 | uint32_t metric; |
d62a17ae | 13979 | struct bgp_redist *red; |
d7c0a89a | 13980 | unsigned short instance; |
d62a17ae | 13981 | int protocol; |
e923dd62 | 13982 | bool changed; |
d62a17ae | 13983 | |
13984 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13985 | protocol = ZEBRA_ROUTE_OSPF; | |
13986 | else | |
13987 | protocol = ZEBRA_ROUTE_TABLE; | |
13988 | ||
13989 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13990 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13991 | ||
13992 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13993 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13994 | metric); | |
13995 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13996 | } |
13997 | ||
13998 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
13999 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
14000 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
14001 | "Redistribute information from another routing protocol\n" | |
14002 | "Open Shortest Path First (OSPFv2)\n" | |
14003 | "Non-main Kernel Routing Table\n" | |
14004 | "Instance ID/Table ID\n" | |
14005 | "Metric for redistributed routes\n" | |
14006 | "Default metric\n") | |
596c17ba | 14007 | |
7c8ff89e DS |
14008 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
14009 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 14010 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
14011 | "Redistribute information from another routing protocol\n" |
14012 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14013 | "Non-main Kernel Routing Table\n" |
14014 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14015 | "Route map reference\n" |
14016 | "Pointer to route-map entries\n" | |
14017 | "Metric for redistributed routes\n" | |
14018 | "Default metric\n") | |
14019 | { | |
d62a17ae | 14020 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14021 | int idx_ospf_table = 1; | |
14022 | int idx_number = 2; | |
14023 | int idx_word = 4; | |
14024 | int idx_number_2 = 6; | |
d7c0a89a | 14025 | uint32_t metric; |
d62a17ae | 14026 | struct bgp_redist *red; |
d7c0a89a | 14027 | unsigned short instance; |
d62a17ae | 14028 | int protocol; |
e923dd62 | 14029 | bool changed; |
1de27621 DA |
14030 | struct route_map *route_map = |
14031 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14032 | |
14033 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14034 | protocol = ZEBRA_ROUTE_OSPF; | |
14035 | else | |
14036 | protocol = ZEBRA_ROUTE_TABLE; | |
14037 | ||
14038 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14039 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14040 | ||
14041 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
14042 | changed = |
14043 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14044 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14045 | metric); | |
14046 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 14047 | } |
14048 | ||
14049 | ALIAS_HIDDEN( | |
14050 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
14051 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
14052 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
14053 | "Redistribute information from another routing protocol\n" | |
14054 | "Open Shortest Path First (OSPFv2)\n" | |
14055 | "Non-main Kernel Routing Table\n" | |
14056 | "Instance ID/Table ID\n" | |
14057 | "Route map reference\n" | |
14058 | "Pointer to route-map entries\n" | |
14059 | "Metric for redistributed routes\n" | |
14060 | "Default metric\n") | |
596c17ba | 14061 | |
7c8ff89e DS |
14062 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
14063 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 14064 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
14065 | "Redistribute information from another routing protocol\n" |
14066 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14067 | "Non-main Kernel Routing Table\n" |
14068 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14069 | "Metric for redistributed routes\n" |
14070 | "Default metric\n" | |
14071 | "Route map reference\n" | |
14072 | "Pointer to route-map entries\n") | |
14073 | { | |
d62a17ae | 14074 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14075 | int idx_ospf_table = 1; | |
14076 | int idx_number = 2; | |
14077 | int idx_number_2 = 4; | |
14078 | int idx_word = 6; | |
d7c0a89a | 14079 | uint32_t metric; |
d62a17ae | 14080 | struct bgp_redist *red; |
d7c0a89a | 14081 | unsigned short instance; |
d62a17ae | 14082 | int protocol; |
e923dd62 | 14083 | bool changed; |
1de27621 DA |
14084 | struct route_map *route_map = |
14085 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14086 | |
14087 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14088 | protocol = ZEBRA_ROUTE_OSPF; | |
14089 | else | |
14090 | protocol = ZEBRA_ROUTE_TABLE; | |
14091 | ||
14092 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14093 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14094 | ||
14095 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 14096 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14097 | metric); | |
1de27621 DA |
14098 | changed |= |
14099 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14100 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 14101 | } |
14102 | ||
14103 | ALIAS_HIDDEN( | |
14104 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
14105 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
14106 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
14107 | "Redistribute information from another routing protocol\n" | |
14108 | "Open Shortest Path First (OSPFv2)\n" | |
14109 | "Non-main Kernel Routing Table\n" | |
14110 | "Instance ID/Table ID\n" | |
14111 | "Metric for redistributed routes\n" | |
14112 | "Default metric\n" | |
14113 | "Route map reference\n" | |
14114 | "Pointer to route-map entries\n") | |
596c17ba | 14115 | |
7c8ff89e DS |
14116 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
14117 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 14118 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
14119 | NO_STR |
14120 | "Redistribute information from another routing protocol\n" | |
14121 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 14122 | "Non-main Kernel Routing Table\n" |
31500417 DW |
14123 | "Instance ID/Table ID\n" |
14124 | "Metric for redistributed routes\n" | |
14125 | "Default metric\n" | |
14126 | "Route map reference\n" | |
14127 | "Pointer to route-map entries\n") | |
7c8ff89e | 14128 | { |
d62a17ae | 14129 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14130 | int idx_ospf_table = 2; | |
14131 | int idx_number = 3; | |
d7c0a89a | 14132 | unsigned short instance; |
d62a17ae | 14133 | int protocol; |
14134 | ||
14135 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14136 | protocol = ZEBRA_ROUTE_OSPF; | |
14137 | else | |
14138 | protocol = ZEBRA_ROUTE_TABLE; | |
14139 | ||
14140 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14141 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
14142 | } | |
14143 | ||
14144 | ALIAS_HIDDEN( | |
14145 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 14146 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14147 | NO_STR |
14148 | "Redistribute information from another routing protocol\n" | |
14149 | "Open Shortest Path First (OSPFv2)\n" | |
14150 | "Non-main Kernel Routing Table\n" | |
14151 | "Instance ID/Table ID\n" | |
14152 | "Metric for redistributed routes\n" | |
14153 | "Default metric\n" | |
14154 | "Route map reference\n" | |
14155 | "Pointer to route-map entries\n") | |
596c17ba | 14156 | |
718e3744 | 14157 | DEFUN (no_bgp_redistribute_ipv4, |
14158 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 14159 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14160 | NO_STR |
14161 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14162 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
14163 | "Metric for redistributed routes\n" |
14164 | "Default metric\n" | |
14165 | "Route map reference\n" | |
14166 | "Pointer to route-map entries\n") | |
718e3744 | 14167 | { |
d62a17ae | 14168 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14169 | int idx_protocol = 2; | |
14170 | int type; | |
14171 | ||
14172 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14173 | if (type < 0) { | |
14174 | vty_out(vty, "%% Invalid route type\n"); | |
14175 | return CMD_WARNING_CONFIG_FAILED; | |
14176 | } | |
14177 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
14178 | } | |
14179 | ||
14180 | ALIAS_HIDDEN( | |
14181 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
14182 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 14183 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14184 | NO_STR |
14185 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14186 | "Metric for redistributed routes\n" | |
14187 | "Default metric\n" | |
14188 | "Route map reference\n" | |
14189 | "Pointer to route-map entries\n") | |
596c17ba | 14190 | |
718e3744 | 14191 | DEFUN (bgp_redistribute_ipv6, |
14192 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 14193 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 14194 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14195 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 14196 | { |
d62a17ae | 14197 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14198 | int idx_protocol = 1; | |
14199 | int type; | |
718e3744 | 14200 | |
d62a17ae | 14201 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14202 | if (type < 0) { | |
14203 | vty_out(vty, "%% Invalid route type\n"); | |
14204 | return CMD_WARNING_CONFIG_FAILED; | |
14205 | } | |
718e3744 | 14206 | |
d62a17ae | 14207 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14208 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 14209 | } |
14210 | ||
14211 | DEFUN (bgp_redistribute_ipv6_rmap, | |
14212 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 14213 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 14214 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14215 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14216 | "Route map reference\n" |
14217 | "Pointer to route-map entries\n") | |
14218 | { | |
d62a17ae | 14219 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14220 | int idx_protocol = 1; | |
14221 | int idx_word = 3; | |
14222 | int type; | |
14223 | struct bgp_redist *red; | |
e923dd62 | 14224 | bool changed; |
1de27621 DA |
14225 | struct route_map *route_map = |
14226 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 14227 | |
d62a17ae | 14228 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14229 | if (type < 0) { | |
14230 | vty_out(vty, "%% Invalid route type\n"); | |
14231 | return CMD_WARNING_CONFIG_FAILED; | |
14232 | } | |
718e3744 | 14233 | |
d62a17ae | 14234 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14235 | changed = |
14236 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14237 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14238 | } |
14239 | ||
14240 | DEFUN (bgp_redistribute_ipv6_metric, | |
14241 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 14242 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 14243 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14244 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14245 | "Metric for redistributed routes\n" |
14246 | "Default metric\n") | |
14247 | { | |
d62a17ae | 14248 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14249 | int idx_protocol = 1; | |
14250 | int idx_number = 3; | |
14251 | int type; | |
d7c0a89a | 14252 | uint32_t metric; |
d62a17ae | 14253 | struct bgp_redist *red; |
e923dd62 | 14254 | bool changed; |
d62a17ae | 14255 | |
14256 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14257 | if (type < 0) { | |
14258 | vty_out(vty, "%% Invalid route type\n"); | |
14259 | return CMD_WARNING_CONFIG_FAILED; | |
14260 | } | |
14261 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14262 | |
d62a17ae | 14263 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14264 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
14265 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14266 | } |
14267 | ||
14268 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
14269 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 14270 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 14271 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14272 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14273 | "Route map reference\n" |
14274 | "Pointer to route-map entries\n" | |
14275 | "Metric for redistributed routes\n" | |
14276 | "Default metric\n") | |
14277 | { | |
d62a17ae | 14278 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14279 | int idx_protocol = 1; | |
14280 | int idx_word = 3; | |
14281 | int idx_number = 5; | |
14282 | int type; | |
d7c0a89a | 14283 | uint32_t metric; |
d62a17ae | 14284 | struct bgp_redist *red; |
e923dd62 | 14285 | bool changed; |
1de27621 DA |
14286 | struct route_map *route_map = |
14287 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14288 | |
14289 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14290 | if (type < 0) { | |
14291 | vty_out(vty, "%% Invalid route type\n"); | |
14292 | return CMD_WARNING_CONFIG_FAILED; | |
14293 | } | |
14294 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14295 | |
d62a17ae | 14296 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14297 | changed = |
14298 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14299 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
14300 | metric); | |
14301 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14302 | } |
14303 | ||
14304 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
14305 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 14306 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14307 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14308 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14309 | "Metric for redistributed routes\n" |
14310 | "Default metric\n" | |
14311 | "Route map reference\n" | |
14312 | "Pointer to route-map entries\n") | |
14313 | { | |
d62a17ae | 14314 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14315 | int idx_protocol = 1; | |
14316 | int idx_number = 3; | |
14317 | int idx_word = 5; | |
14318 | int type; | |
d7c0a89a | 14319 | uint32_t metric; |
d62a17ae | 14320 | struct bgp_redist *red; |
e923dd62 | 14321 | bool changed; |
1de27621 DA |
14322 | struct route_map *route_map = |
14323 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14324 | |
14325 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14326 | if (type < 0) { | |
14327 | vty_out(vty, "%% Invalid route type\n"); | |
14328 | return CMD_WARNING_CONFIG_FAILED; | |
14329 | } | |
14330 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14331 | |
d62a17ae | 14332 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14333 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
14334 | metric); | |
1de27621 DA |
14335 | changed |= |
14336 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14337 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14338 | } |
14339 | ||
14340 | DEFUN (no_bgp_redistribute_ipv6, | |
14341 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 14342 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14343 | NO_STR |
14344 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14345 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
14346 | "Metric for redistributed routes\n" |
14347 | "Default metric\n" | |
14348 | "Route map reference\n" | |
14349 | "Pointer to route-map entries\n") | |
718e3744 | 14350 | { |
d62a17ae | 14351 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14352 | int idx_protocol = 2; | |
14353 | int type; | |
718e3744 | 14354 | |
d62a17ae | 14355 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14356 | if (type < 0) { | |
14357 | vty_out(vty, "%% Invalid route type\n"); | |
14358 | return CMD_WARNING_CONFIG_FAILED; | |
14359 | } | |
718e3744 | 14360 | |
d62a17ae | 14361 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
14362 | } | |
14363 | ||
dd65f45e DL |
14364 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
14365 | afi_t afi, safi_t safi) | |
d62a17ae | 14366 | { |
14367 | int i; | |
14368 | ||
14369 | /* Unicast redistribution only. */ | |
14370 | if (safi != SAFI_UNICAST) | |
2b791107 | 14371 | return; |
d62a17ae | 14372 | |
14373 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
14374 | /* Redistribute BGP does not make sense. */ | |
14375 | if (i != ZEBRA_ROUTE_BGP) { | |
14376 | struct list *red_list; | |
14377 | struct listnode *node; | |
14378 | struct bgp_redist *red; | |
14379 | ||
14380 | red_list = bgp->redist[afi][i]; | |
14381 | if (!red_list) | |
14382 | continue; | |
14383 | ||
14384 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 14385 | /* "redistribute" configuration. */ |
14386 | vty_out(vty, " redistribute %s", | |
14387 | zebra_route_string(i)); | |
14388 | if (red->instance) | |
14389 | vty_out(vty, " %d", red->instance); | |
14390 | if (red->redist_metric_flag) | |
14391 | vty_out(vty, " metric %u", | |
14392 | red->redist_metric); | |
14393 | if (red->rmap.name) | |
14394 | vty_out(vty, " route-map %s", | |
14395 | red->rmap.name); | |
14396 | vty_out(vty, "\n"); | |
14397 | } | |
14398 | } | |
14399 | } | |
718e3744 | 14400 | } |
6b0655a2 | 14401 | |
dd65f45e DL |
14402 | /* peer-group helpers for config-write */ |
14403 | ||
14404 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
14405 | { | |
14406 | if (!peer_group_active(peer)) { | |
14407 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
14408 | return !CHECK_FLAG(peer->flags, flag); | |
14409 | else | |
14410 | return !!CHECK_FLAG(peer->flags, flag); | |
14411 | } | |
14412 | ||
14413 | return !!CHECK_FLAG(peer->flags_override, flag); | |
14414 | } | |
14415 | ||
14416 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
14417 | uint32_t flag) | |
14418 | { | |
14419 | if (!peer_group_active(peer)) { | |
14420 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14421 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14422 | else | |
14423 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14424 | } | |
14425 | ||
14426 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14427 | } | |
14428 | ||
14429 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14430 | uint8_t type, int direct) | |
14431 | { | |
14432 | struct bgp_filter *filter; | |
14433 | ||
14434 | if (peer_group_active(peer)) | |
14435 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14436 | type); | |
14437 | ||
14438 | filter = &peer->filter[afi][safi]; | |
14439 | switch (type) { | |
14440 | case PEER_FT_DISTRIBUTE_LIST: | |
14441 | return !!(filter->dlist[direct].name); | |
14442 | case PEER_FT_FILTER_LIST: | |
14443 | return !!(filter->aslist[direct].name); | |
14444 | case PEER_FT_PREFIX_LIST: | |
14445 | return !!(filter->plist[direct].name); | |
14446 | case PEER_FT_ROUTE_MAP: | |
14447 | return !!(filter->map[direct].name); | |
14448 | case PEER_FT_UNSUPPRESS_MAP: | |
14449 | return !!(filter->usmap.name); | |
14450 | default: | |
14451 | return false; | |
14452 | } | |
14453 | } | |
14454 | ||
14455 | /* Return true if the addpath type is set for peer and different from | |
14456 | * peer-group. | |
14457 | */ | |
3dc339cd DA |
14458 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
14459 | safi_t safi) | |
dd65f45e DL |
14460 | { |
14461 | enum bgp_addpath_strat type, g_type; | |
14462 | ||
14463 | type = peer->addpath_type[afi][safi]; | |
14464 | ||
14465 | if (type != BGP_ADDPATH_NONE) { | |
14466 | if (peer_group_active(peer)) { | |
14467 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14468 | ||
14469 | if (type != g_type) | |
3dc339cd | 14470 | return true; |
dd65f45e | 14471 | else |
3dc339cd | 14472 | return false; |
dd65f45e DL |
14473 | } |
14474 | ||
3dc339cd | 14475 | return true; |
dd65f45e DL |
14476 | } |
14477 | ||
3dc339cd | 14478 | return false; |
dd65f45e DL |
14479 | } |
14480 | ||
b9c7bc5a | 14481 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14482 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14483 | afi_t afi) |
14484 | { | |
b9c7bc5a | 14485 | int indent = 2; |
ddb5b488 | 14486 | |
8a066a70 | 14487 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
14488 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14489 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
14490 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
14491 | bgp->vpn_policy[afi] | |
bb4f6190 | 14492 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14493 | else |
14494 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14495 | bgp->vpn_policy[afi] | |
14496 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14497 | } | |
12a844a5 DS |
14498 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14499 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14500 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14501 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14502 | return; | |
14503 | ||
e70e9f8e PZ |
14504 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14505 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14506 | ||
14507 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14508 | ||
14509 | } else { | |
14510 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14511 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14512 | bgp->vpn_policy[afi].tovpn_label); | |
14513 | } | |
ddb5b488 PZ |
14514 | } |
14515 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14516 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14517 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14518 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14519 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14520 | sizeof(buf))); | |
14521 | } | |
14522 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14523 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14524 | ||
14525 | char buf[PREFIX_STRLEN]; | |
14526 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14527 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14528 | sizeof(buf))) { | |
14529 | ||
b9c7bc5a PZ |
14530 | vty_out(vty, "%*snexthop vpn export %s\n", |
14531 | indent, "", buf); | |
ddb5b488 PZ |
14532 | } |
14533 | } | |
14534 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14535 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14536 | && ecommunity_cmp( | |
14537 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14538 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14539 | ||
14540 | char *b = ecommunity_ecom2str( | |
14541 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14542 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14543 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14544 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14545 | } else { | |
14546 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14547 | char *b = ecommunity_ecom2str( | |
14548 | bgp->vpn_policy[afi] | |
14549 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14550 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14551 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14552 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14553 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14554 | } | |
14555 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14556 | char *b = ecommunity_ecom2str( | |
14557 | bgp->vpn_policy[afi] | |
14558 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14559 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14560 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14561 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14562 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14563 | } | |
14564 | } | |
bb4f6190 DS |
14565 | |
14566 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14567 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14568 | bgp->vpn_policy[afi] |
14569 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14570 | |
301ad80a PG |
14571 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14572 | char *b = ecommunity_ecom2str( | |
14573 | bgp->vpn_policy[afi] | |
14574 | .import_redirect_rtlist, | |
14575 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14576 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14577 | |
301ad80a PG |
14578 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14579 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14580 | } | |
ddb5b488 PZ |
14581 | } |
14582 | ||
dd65f45e DL |
14583 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14584 | afi_t afi, safi_t safi) | |
14585 | { | |
14586 | struct bgp_filter *filter; | |
14587 | char *addr; | |
14588 | ||
14589 | addr = peer->host; | |
14590 | filter = &peer->filter[afi][safi]; | |
14591 | ||
14592 | /* distribute-list. */ | |
14593 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14594 | FILTER_IN)) | |
14595 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14596 | filter->dlist[FILTER_IN].name); | |
14597 | ||
14598 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14599 | FILTER_OUT)) | |
14600 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14601 | filter->dlist[FILTER_OUT].name); | |
14602 | ||
14603 | /* prefix-list. */ | |
14604 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14605 | FILTER_IN)) | |
14606 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14607 | filter->plist[FILTER_IN].name); | |
14608 | ||
14609 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14610 | FILTER_OUT)) | |
14611 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14612 | filter->plist[FILTER_OUT].name); | |
14613 | ||
14614 | /* route-map. */ | |
14615 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14616 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14617 | filter->map[RMAP_IN].name); | |
14618 | ||
14619 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14620 | RMAP_OUT)) | |
14621 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14622 | filter->map[RMAP_OUT].name); | |
14623 | ||
14624 | /* unsuppress-map */ | |
14625 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14626 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14627 | filter->usmap.name); | |
14628 | ||
14629 | /* filter-list. */ | |
14630 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14631 | FILTER_IN)) | |
14632 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14633 | filter->aslist[FILTER_IN].name); | |
14634 | ||
14635 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14636 | FILTER_OUT)) | |
14637 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14638 | filter->aslist[FILTER_OUT].name); | |
14639 | } | |
14640 | ||
14641 | /* BGP peer configuration display function. */ | |
14642 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14643 | struct peer *peer) | |
14644 | { | |
14645 | struct peer *g_peer = NULL; | |
14646 | char buf[SU_ADDRSTRLEN]; | |
14647 | char *addr; | |
14648 | int if_pg_printed = false; | |
14649 | int if_ras_printed = false; | |
14650 | ||
14651 | /* Skip dynamic neighbors. */ | |
14652 | if (peer_dynamic_neighbor(peer)) | |
14653 | return; | |
14654 | ||
14655 | if (peer->conf_if) | |
14656 | addr = peer->conf_if; | |
14657 | else | |
14658 | addr = peer->host; | |
14659 | ||
14660 | /************************************ | |
14661 | ****** Global to the neighbor ****** | |
14662 | ************************************/ | |
14663 | if (peer->conf_if) { | |
14664 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14665 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14666 | else | |
14667 | vty_out(vty, " neighbor %s interface", addr); | |
14668 | ||
14669 | if (peer_group_active(peer)) { | |
14670 | vty_out(vty, " peer-group %s", peer->group->name); | |
14671 | if_pg_printed = true; | |
14672 | } else if (peer->as_type == AS_SPECIFIED) { | |
14673 | vty_out(vty, " remote-as %u", peer->as); | |
14674 | if_ras_printed = true; | |
14675 | } else if (peer->as_type == AS_INTERNAL) { | |
14676 | vty_out(vty, " remote-as internal"); | |
14677 | if_ras_printed = true; | |
14678 | } else if (peer->as_type == AS_EXTERNAL) { | |
14679 | vty_out(vty, " remote-as external"); | |
14680 | if_ras_printed = true; | |
14681 | } | |
14682 | ||
14683 | vty_out(vty, "\n"); | |
14684 | } | |
14685 | ||
14686 | /* remote-as and peer-group */ | |
14687 | /* peer is a member of a peer-group */ | |
14688 | if (peer_group_active(peer)) { | |
14689 | g_peer = peer->group->conf; | |
14690 | ||
14691 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14692 | if (peer->as_type == AS_SPECIFIED) { | |
14693 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14694 | addr, peer->as); | |
14695 | } else if (peer->as_type == AS_INTERNAL) { | |
14696 | vty_out(vty, | |
14697 | " neighbor %s remote-as internal\n", | |
14698 | addr); | |
14699 | } else if (peer->as_type == AS_EXTERNAL) { | |
14700 | vty_out(vty, | |
14701 | " neighbor %s remote-as external\n", | |
14702 | addr); | |
14703 | } | |
14704 | } | |
14705 | ||
14706 | /* For swpX peers we displayed the peer-group | |
14707 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14708 | if (!if_pg_printed) | |
14709 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14710 | peer->group->name); | |
14711 | } | |
14712 | ||
14713 | /* peer is NOT a member of a peer-group */ | |
14714 | else { | |
14715 | /* peer is a peer-group, declare the peer-group */ | |
14716 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14717 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14718 | } | |
14719 | ||
14720 | if (!if_ras_printed) { | |
14721 | if (peer->as_type == AS_SPECIFIED) { | |
14722 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14723 | addr, peer->as); | |
14724 | } else if (peer->as_type == AS_INTERNAL) { | |
14725 | vty_out(vty, | |
14726 | " neighbor %s remote-as internal\n", | |
14727 | addr); | |
14728 | } else if (peer->as_type == AS_EXTERNAL) { | |
14729 | vty_out(vty, | |
14730 | " neighbor %s remote-as external\n", | |
14731 | addr); | |
14732 | } | |
14733 | } | |
14734 | } | |
14735 | ||
14736 | /* local-as */ | |
14737 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14738 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14739 | peer->change_local_as); | |
14740 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14741 | vty_out(vty, " no-prepend"); | |
14742 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14743 | vty_out(vty, " replace-as"); | |
14744 | vty_out(vty, "\n"); | |
14745 | } | |
14746 | ||
14747 | /* description */ | |
14748 | if (peer->desc) { | |
14749 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14750 | } | |
14751 | ||
14752 | /* shutdown */ | |
14753 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14754 | if (peer->tx_shutdown_message) | |
14755 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14756 | peer->tx_shutdown_message); | |
14757 | else | |
14758 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14759 | } | |
14760 | ||
14761 | /* bfd */ | |
14762 | if (peer->bfd_info) { | |
14763 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14764 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14765 | } | |
14766 | } | |
14767 | ||
14768 | /* password */ | |
14769 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14770 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14771 | peer->password); | |
14772 | ||
14773 | /* neighbor solo */ | |
14774 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14775 | if (!peer_group_active(peer)) { | |
14776 | vty_out(vty, " neighbor %s solo\n", addr); | |
14777 | } | |
14778 | } | |
14779 | ||
14780 | /* BGP port */ | |
14781 | if (peer->port != BGP_PORT_DEFAULT) { | |
14782 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14783 | } | |
14784 | ||
14785 | /* Local interface name */ | |
14786 | if (peer->ifname) { | |
14787 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14788 | } | |
14789 | ||
14790 | /* passive */ | |
14791 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14792 | vty_out(vty, " neighbor %s passive\n", addr); | |
14793 | ||
14794 | /* ebgp-multihop */ | |
14795 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
14796 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
14797 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
14798 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
14799 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14800 | peer->ttl); | |
14801 | } | |
14802 | } | |
14803 | ||
14804 | /* ttl-security hops */ | |
e2521429 | 14805 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
14806 | if (!peer_group_active(peer) |
14807 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14808 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14809 | addr, peer->gtsm_hops); | |
14810 | } | |
14811 | } | |
14812 | ||
14813 | /* disable-connected-check */ | |
14814 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14815 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14816 | ||
14817 | /* enforce-first-as */ | |
14818 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14819 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14820 | ||
14821 | /* update-source */ | |
14822 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14823 | if (peer->update_source) | |
14824 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14825 | sockunion2str(peer->update_source, buf, | |
14826 | SU_ADDRSTRLEN)); | |
14827 | else if (peer->update_if) | |
14828 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14829 | peer->update_if); | |
14830 | } | |
14831 | ||
14832 | /* advertisement-interval */ | |
14833 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14834 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14835 | peer->routeadv); | |
14836 | ||
14837 | /* timers */ | |
14838 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14839 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14840 | peer->keepalive, peer->holdtime); | |
14841 | ||
14842 | /* timers connect */ | |
14843 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14844 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14845 | peer->connect); | |
5d5393b9 DL |
14846 | /* need special-case handling for changed default values due to |
14847 | * config profile / version (because there is no "timers bgp connect" | |
14848 | * command, we need to save this per-peer :/) | |
14849 | */ | |
14850 | else if (!peer_group_active(peer) && !peer->connect && | |
14851 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14852 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14853 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14854 | |
14855 | /* capability dynamic */ | |
14856 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14857 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14858 | ||
14859 | /* capability extended-nexthop */ | |
14860 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14861 | if (!peer->conf_if) { | |
14862 | if (CHECK_FLAG(peer->flags_invert, | |
14863 | PEER_FLAG_CAPABILITY_ENHE)) | |
14864 | vty_out(vty, | |
14865 | " no neighbor %s capability extended-nexthop\n", | |
14866 | addr); | |
14867 | else | |
14868 | vty_out(vty, | |
14869 | " neighbor %s capability extended-nexthop\n", | |
14870 | addr); | |
14871 | } | |
14872 | } | |
14873 | ||
14874 | /* dont-capability-negotiation */ | |
14875 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14876 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14877 | ||
14878 | /* override-capability */ | |
14879 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14880 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14881 | ||
14882 | /* strict-capability-match */ | |
14883 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14884 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14885 | ||
14886 | /* Sender side AS path loop detection. */ | |
14887 | if (peer->as_path_loop_detection) | |
14888 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14889 | addr); | |
cfd47646 | 14890 | |
14891 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14892 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 14893 | |
14894 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14895 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 14896 | vty_out(vty, |
14897 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
14898 | } else if (CHECK_FLAG( |
14899 | peer->peer_gr_new_status_flag, | |
14900 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 14901 | vty_out(vty, |
14902 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
14903 | } else if ( |
14904 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14905 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14906 | && !(CHECK_FLAG( | |
14907 | peer->peer_gr_new_status_flag, | |
14908 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14909 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
14910 | addr); | |
cfd47646 | 14911 | } |
14912 | } | |
dd65f45e DL |
14913 | } |
14914 | ||
14915 | /* BGP peer configuration display function. */ | |
14916 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14917 | struct peer *peer, afi_t afi, safi_t safi) | |
14918 | { | |
14919 | struct peer *g_peer = NULL; | |
14920 | char *addr; | |
14921 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14922 | ||
14923 | /* Skip dynamic neighbors. */ | |
14924 | if (peer_dynamic_neighbor(peer)) | |
14925 | return; | |
14926 | ||
14927 | if (peer->conf_if) | |
14928 | addr = peer->conf_if; | |
14929 | else | |
14930 | addr = peer->host; | |
14931 | ||
14932 | /************************************ | |
14933 | ****** Per AF to the neighbor ****** | |
14934 | ************************************/ | |
14935 | if (peer_group_active(peer)) { | |
14936 | g_peer = peer->group->conf; | |
14937 | ||
14938 | /* If the peer-group is active but peer is not, print a 'no | |
14939 | * activate' */ | |
14940 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14941 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14942 | } | |
14943 | ||
14944 | /* If the peer-group is not active but peer is, print an | |
14945 | 'activate' */ | |
14946 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14947 | vty_out(vty, " neighbor %s activate\n", addr); | |
14948 | } | |
14949 | } else { | |
14950 | if (peer->afc[afi][safi]) { | |
14951 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14952 | if (CHECK_FLAG(bgp->flags, |
14953 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14954 | vty_out(vty, " neighbor %s activate\n", |
14955 | addr); | |
14956 | } | |
14957 | } else | |
14958 | vty_out(vty, " neighbor %s activate\n", addr); | |
14959 | } else { | |
14960 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14961 | if (!CHECK_FLAG(bgp->flags, |
14962 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14963 | vty_out(vty, |
14964 | " no neighbor %s activate\n", | |
14965 | addr); | |
14966 | } | |
14967 | } | |
14968 | } | |
14969 | } | |
14970 | ||
14971 | /* addpath TX knobs */ | |
14972 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
14973 | switch (peer->addpath_type[afi][safi]) { | |
14974 | case BGP_ADDPATH_ALL: | |
14975 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
14976 | addr); | |
14977 | break; | |
14978 | case BGP_ADDPATH_BEST_PER_AS: | |
14979 | vty_out(vty, | |
14980 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
14981 | addr); | |
14982 | break; | |
14983 | case BGP_ADDPATH_MAX: | |
14984 | case BGP_ADDPATH_NONE: | |
14985 | break; | |
14986 | } | |
14987 | } | |
14988 | ||
14989 | /* ORF capability. */ | |
14990 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
14991 | || peergroup_af_flag_check(peer, afi, safi, | |
14992 | PEER_FLAG_ORF_PREFIX_RM)) { | |
14993 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
14994 | ||
14995 | if (peergroup_af_flag_check(peer, afi, safi, | |
14996 | PEER_FLAG_ORF_PREFIX_SM) | |
14997 | && peergroup_af_flag_check(peer, afi, safi, | |
14998 | PEER_FLAG_ORF_PREFIX_RM)) | |
14999 | vty_out(vty, " both"); | |
15000 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15001 | PEER_FLAG_ORF_PREFIX_SM)) | |
15002 | vty_out(vty, " send"); | |
15003 | else | |
15004 | vty_out(vty, " receive"); | |
15005 | vty_out(vty, "\n"); | |
15006 | } | |
15007 | ||
dd65f45e DL |
15008 | /* Route reflector client. */ |
15009 | if (peergroup_af_flag_check(peer, afi, safi, | |
15010 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
15011 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
15012 | } | |
15013 | ||
15014 | /* next-hop-self force */ | |
15015 | if (peergroup_af_flag_check(peer, afi, safi, | |
15016 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
15017 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
15018 | } | |
15019 | ||
15020 | /* next-hop-self */ | |
15021 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
15022 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
15023 | } | |
15024 | ||
15025 | /* remove-private-AS */ | |
15026 | if (peergroup_af_flag_check(peer, afi, safi, | |
15027 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
15028 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
15029 | addr); | |
15030 | } | |
15031 | ||
15032 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15033 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
15034 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
15035 | addr); | |
15036 | } | |
15037 | ||
15038 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15039 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
15040 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
15041 | } | |
15042 | ||
15043 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15044 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
15045 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
15046 | } | |
15047 | ||
15048 | /* as-override */ | |
15049 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
15050 | vty_out(vty, " neighbor %s as-override\n", addr); | |
15051 | } | |
15052 | ||
15053 | /* send-community print. */ | |
15054 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
15055 | PEER_FLAG_SEND_COMMUNITY); | |
15056 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
15057 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
15058 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
15059 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
15060 | ||
15061 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
15062 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
15063 | } else { | |
15064 | if (flag_scomm) | |
15065 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
15066 | if (flag_secomm) | |
15067 | vty_out(vty, | |
15068 | " no neighbor %s send-community extended\n", | |
15069 | addr); | |
15070 | ||
15071 | if (flag_slcomm) | |
15072 | vty_out(vty, " no neighbor %s send-community large\n", | |
15073 | addr); | |
15074 | } | |
15075 | ||
15076 | /* Default information */ | |
15077 | if (peergroup_af_flag_check(peer, afi, safi, | |
15078 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
15079 | vty_out(vty, " neighbor %s default-originate", addr); | |
15080 | ||
15081 | if (peer->default_rmap[afi][safi].name) | |
15082 | vty_out(vty, " route-map %s", | |
15083 | peer->default_rmap[afi][safi].name); | |
15084 | ||
15085 | vty_out(vty, "\n"); | |
15086 | } | |
15087 | ||
15088 | /* Soft reconfiguration inbound. */ | |
15089 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
15090 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
15091 | addr); | |
15092 | } | |
15093 | ||
15094 | /* maximum-prefix. */ | |
15095 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 15096 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
15097 | peer->pmax[afi][safi]); |
15098 | ||
15099 | if (peer->pmax_threshold[afi][safi] | |
15100 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
15101 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
15102 | if (peer_af_flag_check(peer, afi, safi, | |
15103 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
15104 | vty_out(vty, " warning-only"); | |
15105 | if (peer->pmax_restart[afi][safi]) | |
15106 | vty_out(vty, " restart %u", | |
15107 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
15108 | if (peer_af_flag_check(peer, afi, safi, |
15109 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
15110 | vty_out(vty, " force"); | |
dd65f45e DL |
15111 | |
15112 | vty_out(vty, "\n"); | |
15113 | } | |
15114 | ||
fde246e8 DA |
15115 | /* maximum-prefix-out */ |
15116 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 15117 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
15118 | addr, peer->pmax_out[afi][safi]); |
15119 | ||
dd65f45e DL |
15120 | /* Route server client. */ |
15121 | if (peergroup_af_flag_check(peer, afi, safi, | |
15122 | PEER_FLAG_RSERVER_CLIENT)) { | |
15123 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
15124 | } | |
15125 | ||
15126 | /* Nexthop-local unchanged. */ | |
15127 | if (peergroup_af_flag_check(peer, afi, safi, | |
15128 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
15129 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
15130 | } | |
15131 | ||
15132 | /* allowas-in <1-10> */ | |
15133 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
15134 | if (peer_af_flag_check(peer, afi, safi, | |
15135 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
15136 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
15137 | } else if (peer->allowas_in[afi][safi] == 3) { | |
15138 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
15139 | } else { | |
15140 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
15141 | peer->allowas_in[afi][safi]); | |
15142 | } | |
15143 | } | |
15144 | ||
15145 | /* weight */ | |
15146 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
15147 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
15148 | peer->weight[afi][safi]); | |
15149 | ||
15150 | /* Filter. */ | |
15151 | bgp_config_write_filter(vty, peer, afi, safi); | |
15152 | ||
15153 | /* atribute-unchanged. */ | |
15154 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
15155 | || (safi != SAFI_EVPN | |
15156 | && peer_af_flag_check(peer, afi, safi, | |
15157 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
15158 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
15159 | ||
15160 | if (!peer_group_active(peer) | |
15161 | || peergroup_af_flag_check(peer, afi, safi, | |
15162 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15163 | || peergroup_af_flag_check(peer, afi, safi, | |
15164 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15165 | || peergroup_af_flag_check(peer, afi, safi, | |
15166 | PEER_FLAG_MED_UNCHANGED)) { | |
15167 | ||
15168 | vty_out(vty, | |
15169 | " neighbor %s attribute-unchanged%s%s%s\n", | |
15170 | addr, | |
15171 | peer_af_flag_check(peer, afi, safi, | |
15172 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15173 | ? " as-path" | |
15174 | : "", | |
15175 | peer_af_flag_check(peer, afi, safi, | |
15176 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15177 | ? " next-hop" | |
15178 | : "", | |
15179 | peer_af_flag_check(peer, afi, safi, | |
15180 | PEER_FLAG_MED_UNCHANGED) | |
15181 | ? " med" | |
15182 | : ""); | |
15183 | } | |
15184 | } | |
15185 | } | |
15186 | ||
15187 | /* Address family based peer configuration display. */ | |
15188 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
15189 | safi_t safi) | |
15190 | { | |
15191 | struct peer *peer; | |
15192 | struct peer_group *group; | |
15193 | struct listnode *node, *nnode; | |
15194 | ||
15195 | ||
15196 | vty_frame(vty, " !\n address-family "); | |
15197 | if (afi == AFI_IP) { | |
15198 | if (safi == SAFI_UNICAST) | |
15199 | vty_frame(vty, "ipv4 unicast"); | |
15200 | else if (safi == SAFI_LABELED_UNICAST) | |
15201 | vty_frame(vty, "ipv4 labeled-unicast"); | |
15202 | else if (safi == SAFI_MULTICAST) | |
15203 | vty_frame(vty, "ipv4 multicast"); | |
15204 | else if (safi == SAFI_MPLS_VPN) | |
15205 | vty_frame(vty, "ipv4 vpn"); | |
15206 | else if (safi == SAFI_ENCAP) | |
15207 | vty_frame(vty, "ipv4 encap"); | |
15208 | else if (safi == SAFI_FLOWSPEC) | |
15209 | vty_frame(vty, "ipv4 flowspec"); | |
15210 | } else if (afi == AFI_IP6) { | |
15211 | if (safi == SAFI_UNICAST) | |
15212 | vty_frame(vty, "ipv6 unicast"); | |
15213 | else if (safi == SAFI_LABELED_UNICAST) | |
15214 | vty_frame(vty, "ipv6 labeled-unicast"); | |
15215 | else if (safi == SAFI_MULTICAST) | |
15216 | vty_frame(vty, "ipv6 multicast"); | |
15217 | else if (safi == SAFI_MPLS_VPN) | |
15218 | vty_frame(vty, "ipv6 vpn"); | |
15219 | else if (safi == SAFI_ENCAP) | |
15220 | vty_frame(vty, "ipv6 encap"); | |
15221 | else if (safi == SAFI_FLOWSPEC) | |
15222 | vty_frame(vty, "ipv6 flowspec"); | |
15223 | } else if (afi == AFI_L2VPN) { | |
15224 | if (safi == SAFI_EVPN) | |
15225 | vty_frame(vty, "l2vpn evpn"); | |
15226 | } | |
15227 | vty_frame(vty, "\n"); | |
15228 | ||
15229 | bgp_config_write_distance(vty, bgp, afi, safi); | |
15230 | ||
15231 | bgp_config_write_network(vty, bgp, afi, safi); | |
15232 | ||
15233 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
15234 | ||
8a4e7fe6 DA |
15235 | /* BGP flag dampening. */ |
15236 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
15237 | bgp_config_write_damp(vty, afi, safi); | |
15238 | ||
dd65f45e DL |
15239 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
15240 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
15241 | ||
15242 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15243 | /* Skip dynamic neighbors. */ | |
15244 | if (peer_dynamic_neighbor(peer)) | |
15245 | continue; | |
15246 | ||
15247 | /* Do not display doppelganger peers */ | |
15248 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15249 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
15250 | } | |
15251 | ||
15252 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
15253 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
15254 | ||
15255 | if (safi == SAFI_EVPN) | |
15256 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
15257 | ||
15258 | if (safi == SAFI_FLOWSPEC) | |
15259 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
15260 | ||
15261 | if (safi == SAFI_UNICAST) { | |
15262 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
15263 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15264 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
15265 | ||
15266 | vty_out(vty, " export vpn\n"); | |
15267 | } | |
15268 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15269 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
15270 | ||
15271 | vty_out(vty, " import vpn\n"); | |
15272 | } | |
15273 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15274 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15275 | char *name; | |
15276 | ||
15277 | for (ALL_LIST_ELEMENTS_RO( | |
15278 | bgp->vpn_policy[afi].import_vrf, node, | |
15279 | name)) | |
15280 | vty_out(vty, " import vrf %s\n", name); | |
15281 | } | |
15282 | } | |
15283 | ||
15284 | vty_endframe(vty, " exit-address-family\n"); | |
15285 | } | |
15286 | ||
15287 | int bgp_config_write(struct vty *vty) | |
15288 | { | |
15289 | struct bgp *bgp; | |
15290 | struct peer_group *group; | |
15291 | struct peer *peer; | |
15292 | struct listnode *node, *nnode; | |
15293 | struct listnode *mnode, *mnnode; | |
15294 | ||
15295 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
15296 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
15297 | bm->rmap_update_timer); | |
15298 | ||
15299 | /* BGP configuration. */ | |
15300 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
15301 | ||
15302 | /* skip all auto created vrf as they dont have user config */ | |
15303 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
15304 | continue; | |
15305 | ||
15306 | /* Router bgp ASN */ | |
15307 | vty_out(vty, "router bgp %u", bgp->as); | |
15308 | ||
15309 | if (bgp->name) | |
15310 | vty_out(vty, " %s %s", | |
15311 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
15312 | ? "view" : "vrf", bgp->name); | |
15313 | vty_out(vty, "\n"); | |
15314 | ||
15315 | /* BGP fast-external-failover. */ | |
15316 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
15317 | vty_out(vty, " no bgp fast-external-failover\n"); | |
15318 | ||
15319 | /* BGP router ID. */ | |
15320 | if (bgp->router_id_static.s_addr != 0) | |
15321 | vty_out(vty, " bgp router-id %s\n", | |
15322 | inet_ntoa(bgp->router_id_static)); | |
15323 | ||
15324 | /* BGP log-neighbor-changes. */ | |
892fedb6 | 15325 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 15326 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 15327 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
15328 | CHECK_FLAG(bgp->flags, |
15329 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
15330 | ? "" |
15331 | : "no "); | |
15332 | ||
15333 | /* BGP configuration. */ | |
892fedb6 | 15334 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
15335 | vty_out(vty, " bgp always-compare-med\n"); |
15336 | ||
15337 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
15338 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
15339 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
15340 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
15341 | CHECK_FLAG(bgp->flags, | |
15342 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
15343 | ? "" | |
15344 | : "no "); | |
dd65f45e DL |
15345 | |
15346 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 15347 | if (bgp->reject_as_sets) |
dd65f45e DL |
15348 | vty_out(vty, " bgp reject-as-sets\n"); |
15349 | ||
15350 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 15351 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
15352 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
15353 | ||
15354 | /* BGP default local-preference. */ | |
15355 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
15356 | vty_out(vty, " bgp default local-preference %u\n", | |
15357 | bgp->default_local_pref); | |
15358 | ||
15359 | /* BGP default show-hostname */ | |
892fedb6 | 15360 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 15361 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 15362 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 15363 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
15364 | ? "" |
15365 | : "no "); | |
15366 | ||
aef999a2 DA |
15367 | /* BGP default show-nexthop-hostname */ |
15368 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
15369 | != SAVE_BGP_SHOW_HOSTNAME) | |
15370 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
15371 | CHECK_FLAG(bgp->flags, | |
15372 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
15373 | ? "" | |
15374 | : "no "); | |
15375 | ||
dd65f45e DL |
15376 | /* BGP default subgroup-pkt-queue-max. */ |
15377 | if (bgp->default_subgroup_pkt_queue_max | |
15378 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
15379 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
15380 | bgp->default_subgroup_pkt_queue_max); | |
15381 | ||
15382 | /* BGP client-to-client reflection. */ | |
892fedb6 | 15383 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
15384 | vty_out(vty, " no bgp client-to-client reflection\n"); |
15385 | ||
15386 | /* BGP cluster ID. */ | |
15387 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
15388 | vty_out(vty, " bgp cluster-id %s\n", | |
15389 | inet_ntoa(bgp->cluster_id)); | |
15390 | ||
15391 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 15392 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
15393 | vty_out(vty, |
15394 | " bgp disable-ebgp-connected-route-check\n"); | |
15395 | ||
15396 | /* Confederation identifier*/ | |
15397 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
15398 | vty_out(vty, " bgp confederation identifier %u\n", | |
15399 | bgp->confed_id); | |
15400 | ||
15401 | /* Confederation peer */ | |
15402 | if (bgp->confed_peers_cnt > 0) { | |
15403 | int i; | |
15404 | ||
15405 | vty_out(vty, " bgp confederation peers"); | |
15406 | ||
15407 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
15408 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
15409 | ||
15410 | vty_out(vty, "\n"); | |
15411 | } | |
15412 | ||
15413 | /* BGP deterministic-med. */ | |
892fedb6 | 15414 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 15415 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 15416 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
15417 | CHECK_FLAG(bgp->flags, |
15418 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
15419 | ? "" |
15420 | : "no "); | |
15421 | ||
15422 | /* BGP update-delay. */ | |
15423 | bgp_config_write_update_delay(vty, bgp); | |
15424 | ||
15425 | if (bgp->v_maxmed_onstartup | |
15426 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
15427 | vty_out(vty, " bgp max-med on-startup %u", | |
15428 | bgp->v_maxmed_onstartup); | |
15429 | if (bgp->maxmed_onstartup_value | |
15430 | != BGP_MAXMED_VALUE_DEFAULT) | |
15431 | vty_out(vty, " %u", | |
15432 | bgp->maxmed_onstartup_value); | |
15433 | vty_out(vty, "\n"); | |
15434 | } | |
15435 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
15436 | vty_out(vty, " bgp max-med administrative"); | |
15437 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
15438 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15439 | vty_out(vty, "\n"); | |
15440 | } | |
15441 | ||
15442 | /* write quanta */ | |
15443 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15444 | /* read quanta */ | |
15445 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15446 | ||
15447 | /* coalesce time */ | |
15448 | bgp_config_write_coalesce_time(vty, bgp); | |
15449 | ||
15450 | /* BGP graceful-restart. */ | |
15451 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15452 | vty_out(vty, | |
15453 | " bgp graceful-restart stalepath-time %u\n", | |
15454 | bgp->stalepath_time); | |
cfd47646 | 15455 | |
dd65f45e DL |
15456 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15457 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15458 | bgp->restart_time); | |
cfd47646 | 15459 | |
15460 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15461 | vty_out(vty, | |
15462 | " bgp graceful-restart select-defer-time %u\n", | |
15463 | bgp->select_defer_time); | |
15464 | ||
15465 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15466 | vty_out(vty, " bgp graceful-restart\n"); |
15467 | ||
cfd47646 | 15468 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15469 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15470 | ||
dd65f45e | 15471 | /* BGP graceful-shutdown */ |
892fedb6 | 15472 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) |
dd65f45e DL |
15473 | vty_out(vty, " bgp graceful-shutdown\n"); |
15474 | ||
15475 | /* BGP graceful-restart Preserve State F bit. */ | |
892fedb6 | 15476 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
15477 | vty_out(vty, |
15478 | " bgp graceful-restart preserve-fw-state\n"); | |
15479 | ||
dc95985f | 15480 | /* Stale timer for RIB */ |
15481 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
15482 | vty_out(vty, | |
15483 | " bgp graceful-restart rib-stale-time %u\n", | |
15484 | bgp->rib_stale_time); | |
15485 | ||
dd65f45e | 15486 | /* BGP bestpath method. */ |
892fedb6 | 15487 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 15488 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 15489 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
15490 | vty_out(vty, " bgp bestpath as-path confed\n"); |
15491 | ||
892fedb6 DA |
15492 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
15493 | if (CHECK_FLAG(bgp->flags, | |
15494 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
15495 | vty_out(vty, |
15496 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15497 | } else { | |
15498 | vty_out(vty, | |
15499 | " bgp bestpath as-path multipath-relax\n"); | |
15500 | } | |
15501 | } | |
15502 | ||
892fedb6 | 15503 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
15504 | vty_out(vty, |
15505 | " bgp route-reflector allow-outbound-policy\n"); | |
15506 | } | |
892fedb6 | 15507 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 15508 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
15509 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
15510 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 15511 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 15512 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 15513 | vty_out(vty, " confed"); |
892fedb6 DA |
15514 | if (CHECK_FLAG(bgp->flags, |
15515 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
15516 | vty_out(vty, " missing-as-worst"); |
15517 | vty_out(vty, "\n"); | |
15518 | } | |
15519 | ||
f7e1c681 | 15520 | /* Link bandwidth handling. */ |
15521 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
15522 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
15523 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
15524 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
15525 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
15526 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
15527 | ||
dd65f45e | 15528 | /* BGP network import check. */ |
892fedb6 | 15529 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 15530 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 15531 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 15532 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
15533 | ? "" |
15534 | : "no "); | |
15535 | ||
15536 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15537 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15538 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15539 | vty_out(vty, " timers bgp %u %u\n", |
15540 | bgp->default_keepalive, bgp->default_holdtime); | |
15541 | ||
15542 | /* peer-group */ | |
15543 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15544 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15545 | } | |
15546 | ||
15547 | /* Normal neighbor configuration. */ | |
15548 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15549 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15550 | bgp_config_write_peer_global(vty, bgp, peer); | |
15551 | } | |
15552 | ||
15553 | /* listen range and limit for dynamic BGP neighbors */ | |
15554 | bgp_config_write_listen(vty, bgp); | |
15555 | ||
15556 | /* | |
15557 | * BGP default autoshutdown neighbors | |
15558 | * | |
15559 | * This must be placed after any peer and peer-group | |
15560 | * configuration, to avoid setting all peers to shutdown after | |
15561 | * a daemon restart, which is undesired behavior. (see #2286) | |
15562 | */ | |
15563 | if (bgp->autoshutdown) | |
15564 | vty_out(vty, " bgp default shutdown\n"); | |
15565 | ||
15566 | /* IPv4 unicast configuration. */ | |
15567 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15568 | ||
15569 | /* IPv4 multicast configuration. */ | |
15570 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15571 | ||
15572 | /* IPv4 labeled-unicast configuration. */ | |
15573 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15574 | ||
15575 | /* IPv4 VPN configuration. */ | |
15576 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15577 | ||
15578 | /* ENCAPv4 configuration. */ | |
15579 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15580 | ||
15581 | /* FLOWSPEC v4 configuration. */ | |
15582 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15583 | ||
15584 | /* IPv6 unicast configuration. */ | |
15585 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15586 | ||
15587 | /* IPv6 multicast configuration. */ | |
15588 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15589 | ||
15590 | /* IPv6 labeled-unicast configuration. */ | |
15591 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15592 | SAFI_LABELED_UNICAST); | |
15593 | ||
15594 | /* IPv6 VPN configuration. */ | |
15595 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15596 | ||
15597 | /* ENCAPv6 configuration. */ | |
15598 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15599 | ||
15600 | /* FLOWSPEC v6 configuration. */ | |
15601 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15602 | ||
15603 | /* EVPN configuration. */ | |
15604 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15605 | ||
15606 | hook_call(bgp_inst_config_write, bgp, vty); | |
15607 | ||
49e5a4a0 | 15608 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
15609 | bgp_rfapi_cfg_write(vty, bgp); |
15610 | #endif | |
15611 | ||
15612 | vty_out(vty, "!\n"); | |
15613 | } | |
15614 | return 0; | |
15615 | } | |
15616 | ||
ddb5b488 | 15617 | |
718e3744 | 15618 | /* BGP node structure. */ |
d62a17ae | 15619 | static struct cmd_node bgp_node = { |
f4b8291f | 15620 | .name = "bgp", |
62b346ee | 15621 | .node = BGP_NODE, |
24389580 | 15622 | .parent_node = CONFIG_NODE, |
62b346ee | 15623 | .prompt = "%s(config-router)# ", |
612c2c15 | 15624 | .config_write = bgp_config_write, |
718e3744 | 15625 | }; |
15626 | ||
d62a17ae | 15627 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 15628 | .name = "bgp ipv4 unicast", |
62b346ee | 15629 | .node = BGP_IPV4_NODE, |
24389580 | 15630 | .parent_node = BGP_NODE, |
62b346ee | 15631 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15632 | }; |
15633 | ||
d62a17ae | 15634 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 15635 | .name = "bgp ipv4 multicast", |
62b346ee | 15636 | .node = BGP_IPV4M_NODE, |
24389580 | 15637 | .parent_node = BGP_NODE, |
62b346ee | 15638 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15639 | }; |
15640 | ||
d62a17ae | 15641 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 15642 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 15643 | .node = BGP_IPV4L_NODE, |
24389580 | 15644 | .parent_node = BGP_NODE, |
62b346ee | 15645 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15646 | }; |
15647 | ||
d62a17ae | 15648 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 15649 | .name = "bgp ipv6", |
62b346ee | 15650 | .node = BGP_IPV6_NODE, |
24389580 | 15651 | .parent_node = BGP_NODE, |
62b346ee | 15652 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15653 | }; |
15654 | ||
d62a17ae | 15655 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 15656 | .name = "bgp ipv6 multicast", |
62b346ee | 15657 | .node = BGP_IPV6M_NODE, |
24389580 | 15658 | .parent_node = BGP_NODE, |
62b346ee | 15659 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 15660 | }; |
15661 | ||
d62a17ae | 15662 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 15663 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 15664 | .node = BGP_IPV6L_NODE, |
24389580 | 15665 | .parent_node = BGP_NODE, |
62b346ee | 15666 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15667 | }; |
15668 | ||
62b346ee | 15669 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 15670 | .name = "bgp vpnv4", |
62b346ee | 15671 | .node = BGP_VPNV4_NODE, |
24389580 | 15672 | .parent_node = BGP_NODE, |
62b346ee | 15673 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15674 | }; |
6b0655a2 | 15675 | |
62b346ee | 15676 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 15677 | .name = "bgp vpnv6", |
62b346ee | 15678 | .node = BGP_VPNV6_NODE, |
24389580 | 15679 | .parent_node = BGP_NODE, |
62b346ee | 15680 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15681 | }; |
8ecd3266 | 15682 | |
62b346ee | 15683 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 15684 | .name = "bgp evpn", |
62b346ee | 15685 | .node = BGP_EVPN_NODE, |
24389580 | 15686 | .parent_node = BGP_NODE, |
62b346ee | 15687 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 15688 | }; |
4e0b7b6d | 15689 | |
62b346ee | 15690 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 15691 | .name = "bgp evpn vni", |
62b346ee | 15692 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 15693 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 15694 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 15695 | }; |
90e60aa7 | 15696 | |
62b346ee | 15697 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 15698 | .name = "bgp ipv4 flowspec", |
62b346ee | 15699 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 15700 | .parent_node = BGP_NODE, |
62b346ee | 15701 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15702 | }; |
7c40bf39 | 15703 | |
62b346ee | 15704 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 15705 | .name = "bgp ipv6 flowspec", |
62b346ee | 15706 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 15707 | .parent_node = BGP_NODE, |
62b346ee | 15708 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15709 | }; |
7c40bf39 | 15710 | |
d62a17ae | 15711 | static void community_list_vty(void); |
1f8ae70b | 15712 | |
d62a17ae | 15713 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15714 | { |
d62a17ae | 15715 | struct bgp *bgp; |
15716 | struct peer *peer; | |
d62a17ae | 15717 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15718 | |
d62a17ae | 15719 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15720 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15721 | /* only provide suggestions on the appropriate input | |
15722 | * token type, | |
15723 | * they'll otherwise show up multiple times */ | |
15724 | enum cmd_token_type match_type; | |
15725 | char *name = peer->host; | |
d48ed3e0 | 15726 | |
d62a17ae | 15727 | if (peer->conf_if) { |
15728 | match_type = VARIABLE_TKN; | |
15729 | name = peer->conf_if; | |
15730 | } else if (strchr(peer->host, ':')) | |
15731 | match_type = IPV6_TKN; | |
15732 | else | |
15733 | match_type = IPV4_TKN; | |
d48ed3e0 | 15734 | |
d62a17ae | 15735 | if (token->type != match_type) |
15736 | continue; | |
d48ed3e0 | 15737 | |
d62a17ae | 15738 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15739 | } | |
d62a17ae | 15740 | } |
b8a815e5 DL |
15741 | } |
15742 | ||
15743 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15744 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15745 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15746 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15747 | {.completions = NULL}}; |
15748 | ||
47a306a0 DS |
15749 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15750 | { | |
15751 | struct bgp *bgp; | |
15752 | struct peer_group *group; | |
15753 | struct listnode *lnbgp, *lnpeer; | |
15754 | ||
15755 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15756 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15757 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15758 | group->name)); | |
15759 | } | |
15760 | } | |
15761 | ||
15762 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15763 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15764 | {.completions = NULL} }; | |
15765 | ||
d62a17ae | 15766 | void bgp_vty_init(void) |
15767 | { | |
15768 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15769 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15770 | |
15771 | /* Install bgp top node. */ | |
612c2c15 DL |
15772 | install_node(&bgp_node); |
15773 | install_node(&bgp_ipv4_unicast_node); | |
15774 | install_node(&bgp_ipv4_multicast_node); | |
15775 | install_node(&bgp_ipv4_labeled_unicast_node); | |
15776 | install_node(&bgp_ipv6_unicast_node); | |
15777 | install_node(&bgp_ipv6_multicast_node); | |
15778 | install_node(&bgp_ipv6_labeled_unicast_node); | |
15779 | install_node(&bgp_vpnv4_node); | |
15780 | install_node(&bgp_vpnv6_node); | |
15781 | install_node(&bgp_evpn_node); | |
15782 | install_node(&bgp_evpn_vni_node); | |
15783 | install_node(&bgp_flowspecv4_node); | |
15784 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 15785 | |
15786 | /* Install default VTY commands to new nodes. */ | |
15787 | install_default(BGP_NODE); | |
15788 | install_default(BGP_IPV4_NODE); | |
15789 | install_default(BGP_IPV4M_NODE); | |
15790 | install_default(BGP_IPV4L_NODE); | |
15791 | install_default(BGP_IPV6_NODE); | |
15792 | install_default(BGP_IPV6M_NODE); | |
15793 | install_default(BGP_IPV6L_NODE); | |
15794 | install_default(BGP_VPNV4_NODE); | |
15795 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15796 | install_default(BGP_FLOWSPECV4_NODE); |
15797 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15798 | install_default(BGP_EVPN_NODE); |
15799 | install_default(BGP_EVPN_VNI_NODE); | |
15800 | ||
8029b216 AK |
15801 | /* "bgp local-mac" hidden commands. */ |
15802 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15803 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15804 | ||
d62a17ae | 15805 | /* bgp route-map delay-timer commands. */ |
15806 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15807 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15808 | ||
15809 | /* Dummy commands (Currently not supported) */ | |
15810 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15811 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15812 | ||
15813 | /* "router bgp" commands. */ | |
15814 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15815 | ||
15816 | /* "no router bgp" commands. */ | |
15817 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15818 | ||
15819 | /* "bgp router-id" commands. */ | |
15820 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15821 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15822 | ||
15823 | /* "bgp cluster-id" commands. */ | |
15824 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15825 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15826 | ||
15827 | /* "bgp confederation" commands. */ | |
15828 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15829 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15830 | ||
15831 | /* "bgp confederation peers" commands. */ | |
15832 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15833 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15834 | ||
15835 | /* bgp max-med command */ | |
15836 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15837 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15838 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15839 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15840 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15841 | ||
15842 | /* bgp disable-ebgp-connected-nh-check */ | |
15843 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15844 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15845 | ||
15846 | /* bgp update-delay command */ | |
15847 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15848 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15849 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15850 | ||
15851 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15852 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15853 | |
15854 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15855 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15856 | ||
15857 | /* "maximum-paths" commands. */ | |
15858 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15859 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15860 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15861 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15862 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15863 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15864 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15865 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15866 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15867 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15868 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15869 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15870 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15871 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15872 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15873 | ||
39edabac PG |
15874 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
15875 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
15876 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15877 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15878 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 15879 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
15880 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15881 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15882 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15883 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15884 | ||
15885 | /* "timers bgp" commands. */ | |
15886 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15887 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15888 | ||
15889 | /* route-map delay-timer commands - per instance for backwards compat. | |
15890 | */ | |
15891 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15892 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15893 | ||
15894 | /* "bgp client-to-client reflection" commands */ | |
15895 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15896 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15897 | ||
15898 | /* "bgp always-compare-med" commands */ | |
15899 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15900 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15901 | ||
9dac9fc8 DA |
15902 | /* bgp ebgp-requires-policy */ |
15903 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15904 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15905 | ||
fb29348a DA |
15906 | /* bgp reject-as-sets */ |
15907 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15908 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15909 | ||
d62a17ae | 15910 | /* "bgp deterministic-med" commands */ |
15911 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15912 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15913 | ||
055679e9 | 15914 | /* "bgp graceful-restart" command */ |
36235319 QY |
15915 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
15916 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 15917 | |
15918 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
15919 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
15920 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 15921 | |
15922 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
15923 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
15924 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 15925 | |
15926 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15927 | install_element(BGP_NODE, | |
15928 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15929 | install_element(BGP_NODE, | |
15930 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15931 | ||
15932 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15933 | install_element(BGP_NODE, | |
15934 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15935 | install_element(BGP_NODE, | |
15936 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15937 | ||
d62a17ae | 15938 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15939 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15940 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15941 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15942 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15943 | install_element(BGP_NODE, |
15944 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15945 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15946 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15947 | ||
d6e3c15b | 15948 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
15949 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 15950 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
15951 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 15952 | |
7f323236 DW |
15953 | /* "bgp graceful-shutdown" commands */ |
15954 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
15955 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
15956 | ||
d62a17ae | 15957 | /* "bgp fast-external-failover" commands */ |
15958 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
15959 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
15960 | ||
d62a17ae | 15961 | /* "bgp bestpath compare-routerid" commands */ |
15962 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
15963 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
15964 | ||
15965 | /* "bgp bestpath as-path ignore" commands */ | |
15966 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
15967 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
15968 | ||
15969 | /* "bgp bestpath as-path confed" commands */ | |
15970 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
15971 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
15972 | ||
15973 | /* "bgp bestpath as-path multipath-relax" commands */ | |
15974 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
15975 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
15976 | ||
15977 | /* "bgp log-neighbor-changes" commands */ | |
15978 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
15979 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
15980 | ||
15981 | /* "bgp bestpath med" commands */ | |
15982 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
15983 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
15984 | ||
f7e1c681 | 15985 | /* "bgp bestpath bandwidth" commands */ |
15986 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 15987 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 15988 | |
d62a17ae | 15989 | /* "no bgp default ipv4-unicast" commands. */ |
15990 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
15991 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
15992 | ||
15993 | /* "bgp network import-check" commands. */ | |
15994 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
15995 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
15996 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
15997 | ||
15998 | /* "bgp default local-preference" commands. */ | |
15999 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
16000 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
16001 | ||
16002 | /* bgp default show-hostname */ | |
16003 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
16004 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
16005 | ||
aef999a2 DA |
16006 | /* bgp default show-nexthop-hostname */ |
16007 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
16008 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
16009 | ||
d62a17ae | 16010 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
16011 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
16012 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
16013 | ||
16014 | /* bgp ibgp-allow-policy-mods command */ | |
16015 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
16016 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
16017 | ||
16018 | /* "bgp listen limit" commands. */ | |
16019 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
16020 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
16021 | ||
16022 | /* "bgp listen range" commands. */ | |
16023 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
16024 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
16025 | ||
8175f54a | 16026 | /* "bgp default shutdown" command */ |
f26845f9 QY |
16027 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
16028 | ||
d62a17ae | 16029 | /* "neighbor remote-as" commands. */ |
16030 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
16031 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
16032 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
16033 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
16034 | install_element(BGP_NODE, | |
16035 | &neighbor_interface_v6only_config_remote_as_cmd); | |
16036 | install_element(BGP_NODE, &no_neighbor_cmd); | |
16037 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
16038 | ||
16039 | /* "neighbor peer-group" commands. */ | |
16040 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
16041 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
16042 | install_element(BGP_NODE, | |
16043 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
16044 | ||
16045 | /* "neighbor local-as" commands. */ | |
16046 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
16047 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
16048 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
16049 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
16050 | ||
16051 | /* "neighbor solo" commands. */ | |
16052 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
16053 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
16054 | ||
16055 | /* "neighbor password" commands. */ | |
16056 | install_element(BGP_NODE, &neighbor_password_cmd); | |
16057 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
16058 | ||
16059 | /* "neighbor activate" commands. */ | |
16060 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
16061 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
16062 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
16063 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
16064 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
16065 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
16066 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
16067 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
16068 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 16069 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
16070 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 16071 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
16072 | ||
16073 | /* "no neighbor activate" commands. */ | |
16074 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
16075 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
16076 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
16077 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
16078 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
16079 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
16080 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
16081 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
16082 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 16083 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
16084 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 16085 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
16086 | ||
16087 | /* "neighbor peer-group" set commands. */ | |
16088 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
16089 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16090 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16091 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16092 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16093 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16094 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16095 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 16096 | install_element(BGP_FLOWSPECV4_NODE, |
16097 | &neighbor_set_peer_group_hidden_cmd); | |
16098 | install_element(BGP_FLOWSPECV6_NODE, | |
16099 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16100 | |
16101 | /* "no neighbor peer-group unset" commands. */ | |
16102 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
16103 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16104 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16105 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16106 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16107 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16108 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16109 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 16110 | install_element(BGP_FLOWSPECV4_NODE, |
16111 | &no_neighbor_set_peer_group_hidden_cmd); | |
16112 | install_element(BGP_FLOWSPECV6_NODE, | |
16113 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16114 | |
16115 | /* "neighbor softreconfiguration inbound" commands.*/ | |
16116 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
16117 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
16118 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16119 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16120 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16121 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16122 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16123 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16124 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16125 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16126 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16127 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16128 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16129 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16130 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16131 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16132 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16133 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 16134 | install_element(BGP_FLOWSPECV4_NODE, |
16135 | &neighbor_soft_reconfiguration_cmd); | |
16136 | install_element(BGP_FLOWSPECV4_NODE, | |
16137 | &no_neighbor_soft_reconfiguration_cmd); | |
16138 | install_element(BGP_FLOWSPECV6_NODE, | |
16139 | &neighbor_soft_reconfiguration_cmd); | |
16140 | install_element(BGP_FLOWSPECV6_NODE, | |
16141 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
16142 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
16143 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 16144 | |
16145 | /* "neighbor attribute-unchanged" commands. */ | |
16146 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
16147 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
16148 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
16149 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16150 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
16151 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16152 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
16153 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16154 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
16155 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16156 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
16157 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16158 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
16159 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16160 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
16161 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16162 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
16163 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16164 | ||
16165 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
16166 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
16167 | ||
16168 | /* "nexthop-local unchanged" commands */ | |
16169 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
16170 | install_element(BGP_IPV6_NODE, | |
16171 | &no_neighbor_nexthop_local_unchanged_cmd); | |
16172 | ||
16173 | /* "neighbor next-hop-self" commands. */ | |
16174 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
16175 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
16176 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
16177 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16178 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
16179 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
16180 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
16181 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
16182 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
16183 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
16184 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
16185 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
16186 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
16187 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
16188 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
16189 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16190 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
16191 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
16192 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
16193 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 16194 | |
16195 | /* "neighbor next-hop-self force" commands. */ | |
16196 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
16197 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
16198 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16199 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16200 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
16201 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16202 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16203 | install_element(BGP_IPV4_NODE, | |
16204 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16205 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
16206 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16207 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16208 | install_element(BGP_IPV4M_NODE, | |
16209 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16210 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
16211 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16212 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16213 | install_element(BGP_IPV4L_NODE, | |
16214 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16215 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
16216 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16217 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16218 | install_element(BGP_IPV6_NODE, | |
16219 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16220 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
16221 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16222 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16223 | install_element(BGP_IPV6M_NODE, | |
16224 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16225 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
16226 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16227 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16228 | install_element(BGP_IPV6L_NODE, | |
16229 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16230 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
16231 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16232 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16233 | install_element(BGP_VPNV4_NODE, | |
16234 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16235 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
16236 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16237 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16238 | install_element(BGP_VPNV6_NODE, | |
16239 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
16240 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
16241 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 16242 | |
16243 | /* "neighbor as-override" commands. */ | |
16244 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
16245 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
16246 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
16247 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
16248 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
16249 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
16250 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
16251 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
16252 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
16253 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
16254 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
16255 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
16256 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
16257 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
16258 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
16259 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
16260 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
16261 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
16262 | ||
16263 | /* "neighbor remove-private-AS" commands. */ | |
16264 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
16265 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
16266 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
16267 | install_element(BGP_NODE, | |
16268 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
16269 | install_element(BGP_NODE, | |
16270 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
16271 | install_element(BGP_NODE, | |
16272 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
16273 | install_element(BGP_NODE, | |
16274 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16275 | install_element( | |
16276 | BGP_NODE, | |
16277 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16278 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
16279 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16280 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16281 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16282 | install_element(BGP_IPV4_NODE, | |
16283 | &neighbor_remove_private_as_replace_as_cmd); | |
16284 | install_element(BGP_IPV4_NODE, | |
16285 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16286 | install_element(BGP_IPV4_NODE, | |
16287 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16288 | install_element(BGP_IPV4_NODE, | |
16289 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16290 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
16291 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
16292 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
16293 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16294 | install_element(BGP_IPV4M_NODE, | |
16295 | &neighbor_remove_private_as_replace_as_cmd); | |
16296 | install_element(BGP_IPV4M_NODE, | |
16297 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16298 | install_element(BGP_IPV4M_NODE, | |
16299 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16300 | install_element(BGP_IPV4M_NODE, | |
16301 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16302 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
16303 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
16304 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
16305 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16306 | install_element(BGP_IPV4L_NODE, | |
16307 | &neighbor_remove_private_as_replace_as_cmd); | |
16308 | install_element(BGP_IPV4L_NODE, | |
16309 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16310 | install_element(BGP_IPV4L_NODE, | |
16311 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16312 | install_element(BGP_IPV4L_NODE, | |
16313 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16314 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
16315 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16316 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16317 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16318 | install_element(BGP_IPV6_NODE, | |
16319 | &neighbor_remove_private_as_replace_as_cmd); | |
16320 | install_element(BGP_IPV6_NODE, | |
16321 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16322 | install_element(BGP_IPV6_NODE, | |
16323 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16324 | install_element(BGP_IPV6_NODE, | |
16325 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16326 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
16327 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
16328 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
16329 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16330 | install_element(BGP_IPV6M_NODE, | |
16331 | &neighbor_remove_private_as_replace_as_cmd); | |
16332 | install_element(BGP_IPV6M_NODE, | |
16333 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16334 | install_element(BGP_IPV6M_NODE, | |
16335 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16336 | install_element(BGP_IPV6M_NODE, | |
16337 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16338 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
16339 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
16340 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
16341 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16342 | install_element(BGP_IPV6L_NODE, | |
16343 | &neighbor_remove_private_as_replace_as_cmd); | |
16344 | install_element(BGP_IPV6L_NODE, | |
16345 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16346 | install_element(BGP_IPV6L_NODE, | |
16347 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16348 | install_element(BGP_IPV6L_NODE, | |
16349 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16350 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
16351 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16352 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16353 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16354 | install_element(BGP_VPNV4_NODE, | |
16355 | &neighbor_remove_private_as_replace_as_cmd); | |
16356 | install_element(BGP_VPNV4_NODE, | |
16357 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16358 | install_element(BGP_VPNV4_NODE, | |
16359 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16360 | install_element(BGP_VPNV4_NODE, | |
16361 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16362 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
16363 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16364 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16365 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16366 | install_element(BGP_VPNV6_NODE, | |
16367 | &neighbor_remove_private_as_replace_as_cmd); | |
16368 | install_element(BGP_VPNV6_NODE, | |
16369 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16370 | install_element(BGP_VPNV6_NODE, | |
16371 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16372 | install_element(BGP_VPNV6_NODE, | |
16373 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16374 | ||
16375 | /* "neighbor send-community" commands.*/ | |
16376 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
16377 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
16378 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
16379 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
16380 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
16381 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
16382 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
16383 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
16384 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
16385 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
16386 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
16387 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
16388 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
16389 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
16390 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
16391 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
16392 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
16393 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
16394 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
16395 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
16396 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
16397 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
16398 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
16399 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
16400 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
16401 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
16402 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
16403 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
16404 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
16405 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
16406 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
16407 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
16408 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
16409 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
16410 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
16411 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
16412 | ||
16413 | /* "neighbor route-reflector" commands.*/ | |
16414 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
16415 | install_element(BGP_NODE, | |
16416 | &no_neighbor_route_reflector_client_hidden_cmd); | |
16417 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
16418 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
16419 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
16420 | install_element(BGP_IPV4M_NODE, | |
16421 | &no_neighbor_route_reflector_client_cmd); | |
16422 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
16423 | install_element(BGP_IPV4L_NODE, | |
16424 | &no_neighbor_route_reflector_client_cmd); | |
16425 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
16426 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
16427 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
16428 | install_element(BGP_IPV6M_NODE, | |
16429 | &no_neighbor_route_reflector_client_cmd); | |
16430 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
16431 | install_element(BGP_IPV6L_NODE, | |
16432 | &no_neighbor_route_reflector_client_cmd); | |
16433 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
16434 | install_element(BGP_VPNV4_NODE, | |
16435 | &no_neighbor_route_reflector_client_cmd); | |
16436 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
16437 | install_element(BGP_VPNV6_NODE, | |
16438 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 16439 | install_element(BGP_FLOWSPECV4_NODE, |
16440 | &neighbor_route_reflector_client_cmd); | |
16441 | install_element(BGP_FLOWSPECV4_NODE, | |
16442 | &no_neighbor_route_reflector_client_cmd); | |
16443 | install_element(BGP_FLOWSPECV6_NODE, | |
16444 | &neighbor_route_reflector_client_cmd); | |
16445 | install_element(BGP_FLOWSPECV6_NODE, | |
16446 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 16447 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
16448 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
16449 | ||
16450 | /* "neighbor route-server" commands.*/ | |
16451 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
16452 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
16453 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
16454 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
16455 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
16456 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
16457 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
16458 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
16459 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
16460 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
16461 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
16462 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
16463 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
16464 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
16465 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
16466 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
16467 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
16468 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
16469 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
16470 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 16471 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
16472 | install_element(BGP_FLOWSPECV4_NODE, | |
16473 | &no_neighbor_route_server_client_cmd); | |
16474 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
16475 | install_element(BGP_FLOWSPECV6_NODE, | |
16476 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 16477 | |
16478 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
16479 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
16480 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
16481 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16482 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16483 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16484 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16485 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16486 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16487 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16488 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16489 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16490 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16491 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16492 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16493 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16494 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16495 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16496 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16497 | ||
16498 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
16499 | install_element(BGP_NODE, | |
16500 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16501 | install_element(BGP_NODE, | |
16502 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16503 | install_element(BGP_IPV4_NODE, | |
16504 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16505 | install_element(BGP_IPV4_NODE, | |
16506 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16507 | install_element(BGP_IPV4M_NODE, | |
16508 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16509 | install_element(BGP_IPV4M_NODE, | |
16510 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16511 | install_element(BGP_IPV4L_NODE, | |
16512 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16513 | install_element(BGP_IPV4L_NODE, | |
16514 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16515 | install_element(BGP_IPV6_NODE, | |
16516 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16517 | install_element(BGP_IPV6_NODE, | |
16518 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16519 | install_element(BGP_IPV6M_NODE, | |
16520 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16521 | install_element(BGP_IPV6M_NODE, | |
16522 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16523 | install_element(BGP_IPV6L_NODE, | |
16524 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16525 | install_element(BGP_IPV6L_NODE, | |
16526 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16527 | install_element(BGP_VPNV4_NODE, | |
16528 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16529 | install_element(BGP_VPNV4_NODE, | |
16530 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16531 | install_element(BGP_VPNV6_NODE, | |
16532 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16533 | install_element(BGP_VPNV6_NODE, | |
16534 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16535 | ||
2b31007c RZ |
16536 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16537 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16538 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16539 | ||
d62a17ae | 16540 | /* "neighbor passive" commands. */ |
16541 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16542 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16543 | ||
16544 | ||
16545 | /* "neighbor shutdown" commands. */ | |
16546 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16547 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16548 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16549 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16550 | ||
16551 | /* "neighbor capability extended-nexthop" commands.*/ | |
16552 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16553 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16554 | ||
16555 | /* "neighbor capability orf prefix-list" commands.*/ | |
16556 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16557 | install_element(BGP_NODE, | |
16558 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16559 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16560 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16561 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16562 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16563 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16564 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16565 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16566 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16567 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16568 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16569 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16570 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16571 | ||
16572 | /* "neighbor capability dynamic" commands.*/ | |
16573 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16574 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16575 | ||
16576 | /* "neighbor dont-capability-negotiate" commands. */ | |
16577 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16578 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16579 | ||
16580 | /* "neighbor ebgp-multihop" commands. */ | |
16581 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16582 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16583 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16584 | ||
16585 | /* "neighbor disable-connected-check" commands. */ | |
16586 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16587 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16588 | ||
47cbc09b PM |
16589 | /* "neighbor enforce-first-as" commands. */ |
16590 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16591 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16592 | ||
d62a17ae | 16593 | /* "neighbor description" commands. */ |
16594 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16595 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16596 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16597 | |
16598 | /* "neighbor update-source" commands. "*/ | |
16599 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16600 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16601 | ||
16602 | /* "neighbor default-originate" commands. */ | |
16603 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16604 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16605 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16606 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16607 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16608 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16609 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16610 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16611 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16612 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16613 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16614 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16615 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16616 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16617 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16618 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16619 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16620 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16621 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16622 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16623 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16624 | ||
16625 | /* "neighbor port" commands. */ | |
16626 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16627 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16628 | ||
16629 | /* "neighbor weight" commands. */ | |
16630 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16631 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16632 | ||
16633 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16634 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16635 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16636 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16637 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16638 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16639 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16640 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16641 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16642 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16643 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16644 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16645 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16646 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16647 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16648 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16649 | ||
16650 | /* "neighbor override-capability" commands. */ | |
16651 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16652 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16653 | ||
16654 | /* "neighbor strict-capability-match" commands. */ | |
16655 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16656 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16657 | ||
16658 | /* "neighbor timers" commands. */ | |
16659 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16660 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16661 | ||
16662 | /* "neighbor timers connect" commands. */ | |
16663 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16664 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16665 | ||
16666 | /* "neighbor advertisement-interval" commands. */ | |
16667 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16668 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16669 | ||
16670 | /* "neighbor interface" commands. */ | |
16671 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16672 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16673 | ||
16674 | /* "neighbor distribute" commands. */ | |
16675 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16676 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16677 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16678 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16679 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16680 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16681 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16682 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16683 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16684 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16685 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16686 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16687 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16688 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16689 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16690 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16691 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16692 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16693 | ||
16694 | /* "neighbor prefix-list" commands. */ | |
16695 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16696 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16697 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16698 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16699 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16700 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16701 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16702 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16703 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16704 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16705 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16706 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16707 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16708 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16709 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16710 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16711 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16712 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16713 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16714 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16715 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16716 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16717 | |
16718 | /* "neighbor filter-list" commands. */ | |
16719 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16720 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16721 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16722 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16723 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16724 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16725 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16726 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16727 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16728 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16729 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16730 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16731 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16732 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16733 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16734 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16735 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16736 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16737 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16738 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16739 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16740 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16741 | |
16742 | /* "neighbor route-map" commands. */ | |
16743 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16744 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16745 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16746 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16747 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16748 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16749 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16750 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16751 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16752 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16753 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16754 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16755 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16756 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16757 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16758 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16759 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16760 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16761 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16762 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16763 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16764 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16765 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16766 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16767 | |
16768 | /* "neighbor unsuppress-map" commands. */ | |
16769 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16770 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16771 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16772 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16773 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16774 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16775 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16776 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16777 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16778 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16779 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16780 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16781 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16782 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16783 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16784 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16785 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16786 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16787 | ||
fde246e8 DA |
16788 | /* neighbor maximum-prefix-out commands. */ |
16789 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16790 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16791 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16792 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16793 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16794 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16795 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16796 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16797 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16798 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16799 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16800 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16801 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16802 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16803 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16804 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16805 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16806 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16807 | ||
d62a17ae | 16808 | /* "neighbor maximum-prefix" commands. */ |
16809 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16810 | install_element(BGP_NODE, | |
16811 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16812 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16813 | install_element(BGP_NODE, | |
16814 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16815 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16816 | install_element(BGP_NODE, | |
16817 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16818 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16819 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16820 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16821 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16822 | install_element(BGP_IPV4_NODE, | |
16823 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16824 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16825 | install_element(BGP_IPV4_NODE, | |
16826 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16827 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16828 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16829 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16830 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16831 | install_element(BGP_IPV4M_NODE, | |
16832 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16833 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16834 | install_element(BGP_IPV4M_NODE, | |
16835 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16836 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16837 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16838 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16839 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16840 | install_element(BGP_IPV4L_NODE, | |
16841 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16842 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16843 | install_element(BGP_IPV4L_NODE, | |
16844 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16845 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16846 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16847 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16848 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16849 | install_element(BGP_IPV6_NODE, | |
16850 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16851 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16852 | install_element(BGP_IPV6_NODE, | |
16853 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16854 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16855 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16856 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16857 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16858 | install_element(BGP_IPV6M_NODE, | |
16859 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16860 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16861 | install_element(BGP_IPV6M_NODE, | |
16862 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16863 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16864 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16865 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16866 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16867 | install_element(BGP_IPV6L_NODE, | |
16868 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16869 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16870 | install_element(BGP_IPV6L_NODE, | |
16871 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16872 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16873 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16874 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16875 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16876 | install_element(BGP_VPNV4_NODE, | |
16877 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16878 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16879 | install_element(BGP_VPNV4_NODE, | |
16880 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16881 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16882 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16883 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16884 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16885 | install_element(BGP_VPNV6_NODE, | |
16886 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16887 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16888 | install_element(BGP_VPNV6_NODE, | |
16889 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16890 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16891 | ||
16892 | /* "neighbor allowas-in" */ | |
16893 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16894 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16895 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16896 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16897 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16898 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16899 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16900 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16901 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16902 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16903 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16904 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16905 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16906 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16907 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16908 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16909 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16910 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16911 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16912 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16913 | ||
16914 | /* address-family commands. */ | |
16915 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16916 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16917 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16918 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16919 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16920 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16921 | |
d62a17ae | 16922 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16923 | ||
16924 | /* "exit-address-family" command. */ | |
16925 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16926 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16927 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16928 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16929 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16930 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16931 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16932 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16933 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16934 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16935 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16936 | ||
16937 | /* "clear ip bgp commands" */ | |
16938 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16939 | ||
16940 | /* clear ip bgp prefix */ | |
16941 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16942 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16943 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16944 | ||
16945 | /* "show [ip] bgp summary" commands. */ | |
16946 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 16947 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 16948 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 16949 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 16950 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
16951 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 16952 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
16953 | ||
16954 | /* "show [ip] bgp neighbors" commands. */ | |
16955 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
16956 | ||
36235319 | 16957 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 16958 | |
d62a17ae | 16959 | /* "show [ip] bgp peer-group" commands. */ |
16960 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
16961 | ||
16962 | /* "show [ip] bgp paths" commands. */ | |
16963 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
16964 | ||
16965 | /* "show [ip] bgp community" commands. */ | |
16966 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
16967 | ||
16968 | /* "show ip bgp large-community" commands. */ | |
16969 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
16970 | /* "show [ip] bgp attribute-info" commands. */ | |
16971 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 16972 | /* "show [ip] bgp route-leak" command */ |
16973 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 16974 | |
16975 | /* "redistribute" commands. */ | |
16976 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
16977 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
16978 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
16979 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
16980 | install_element(BGP_NODE, | |
16981 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
16982 | install_element(BGP_NODE, | |
16983 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
16984 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16985 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16986 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
16987 | install_element(BGP_NODE, | |
16988 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
16989 | install_element(BGP_NODE, | |
16990 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
16991 | install_element(BGP_NODE, | |
16992 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
16993 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
16994 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
16995 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
16996 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
16997 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
16998 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
16999 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
17000 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
17001 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
17002 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
17003 | install_element(BGP_IPV4_NODE, | |
17004 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
17005 | install_element(BGP_IPV4_NODE, | |
17006 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
17007 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
17008 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
17009 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
17010 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
17011 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
17012 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
17013 | ||
b9c7bc5a PZ |
17014 | /* import|export vpn [route-map WORD] */ |
17015 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
17016 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 17017 | |
12a844a5 DS |
17018 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
17019 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
17020 | ||
d62a17ae | 17021 | /* ttl_security commands */ |
17022 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
17023 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
17024 | ||
17025 | /* "show [ip] bgp memory" commands. */ | |
17026 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
17027 | ||
acf71666 MK |
17028 | /* "show bgp martian next-hop" */ |
17029 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
17030 | ||
48ecf8f5 DS |
17031 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
17032 | ||
d62a17ae | 17033 | /* "show [ip] bgp views" commands. */ |
17034 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
17035 | ||
17036 | /* "show [ip] bgp vrfs" commands. */ | |
17037 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
17038 | ||
17039 | /* Community-list. */ | |
17040 | community_list_vty(); | |
ddb5b488 PZ |
17041 | |
17042 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
17043 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
17044 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
17045 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
17046 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
17047 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
17048 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
17049 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
17050 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
17051 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
17052 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
17053 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
17054 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 17055 | |
301ad80a PG |
17056 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
17057 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
17058 | ||
b9c7bc5a PZ |
17059 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
17060 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
17061 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
17062 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
17063 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
17064 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
17065 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
17066 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
17067 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
17068 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 17069 | } |
6b0655a2 | 17070 | |
718e3744 | 17071 | #include "memory.h" |
17072 | #include "bgp_regex.h" | |
17073 | #include "bgp_clist.h" | |
17074 | #include "bgp_ecommunity.h" | |
17075 | ||
17076 | /* VTY functions. */ | |
17077 | ||
17078 | /* Direction value to string conversion. */ | |
d62a17ae | 17079 | static const char *community_direct_str(int direct) |
17080 | { | |
17081 | switch (direct) { | |
17082 | case COMMUNITY_DENY: | |
17083 | return "deny"; | |
17084 | case COMMUNITY_PERMIT: | |
17085 | return "permit"; | |
17086 | default: | |
17087 | return "unknown"; | |
17088 | } | |
718e3744 | 17089 | } |
17090 | ||
17091 | /* Display error string. */ | |
d62a17ae | 17092 | static void community_list_perror(struct vty *vty, int ret) |
17093 | { | |
17094 | switch (ret) { | |
17095 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
17096 | vty_out(vty, "%% Can't find community-list\n"); | |
17097 | break; | |
17098 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
17099 | vty_out(vty, "%% Malformed community-list value\n"); | |
17100 | break; | |
17101 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
17102 | vty_out(vty, | |
17103 | "%% Community name conflict, previously defined as standard community\n"); | |
17104 | break; | |
17105 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
17106 | vty_out(vty, | |
17107 | "%% Community name conflict, previously defined as expanded community\n"); | |
17108 | break; | |
17109 | } | |
718e3744 | 17110 | } |
17111 | ||
5bf15956 DW |
17112 | /* "community-list" keyword help string. */ |
17113 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
17114 | ||
7336e101 SP |
17115 | /*community-list standard */ |
17116 | DEFUN (community_list_standard, | |
17117 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 17118 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17119 | BGP_STR |
718e3744 | 17120 | COMMUNITY_LIST_STR |
17121 | "Community list number (standard)\n" | |
5bf15956 | 17122 | "Add an standard community-list entry\n" |
718e3744 | 17123 | "Community list name\n" |
2f8cc0e5 DA |
17124 | "Sequence number of an entry\n" |
17125 | "Sequence number\n" | |
718e3744 | 17126 | "Specify community to reject\n" |
17127 | "Specify community to accept\n" | |
17128 | COMMUNITY_VAL_STR) | |
17129 | { | |
d62a17ae | 17130 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17131 | char *seq = NULL; |
d62a17ae | 17132 | int direct = 0; |
17133 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 17134 | int idx = 0; |
7336e101 | 17135 | |
2f8cc0e5 DA |
17136 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17137 | if (idx) | |
17138 | seq = argv[idx]->arg; | |
17139 | ||
17140 | idx = 0; | |
d62a17ae | 17141 | argv_find(argv, argc, "(1-99)", &idx); |
17142 | argv_find(argv, argc, "WORD", &idx); | |
17143 | cl_name_or_number = argv[idx]->arg; | |
17144 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17145 | : COMMUNITY_DENY; | |
17146 | argv_find(argv, argc, "AA:NN", &idx); | |
17147 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17148 | |
2f8cc0e5 DA |
17149 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
17150 | direct, style); | |
42f914d4 | 17151 | |
d62a17ae | 17152 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17153 | |
d62a17ae | 17154 | if (ret < 0) { |
17155 | /* Display error string. */ | |
17156 | community_list_perror(vty, ret); | |
17157 | return CMD_WARNING_CONFIG_FAILED; | |
17158 | } | |
42f914d4 | 17159 | |
d62a17ae | 17160 | return CMD_SUCCESS; |
718e3744 | 17161 | } |
17162 | ||
7336e101 SP |
17163 | DEFUN (no_community_list_standard_all, |
17164 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 17165 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17166 | NO_STR |
17167 | BGP_STR | |
17168 | COMMUNITY_LIST_STR | |
17169 | "Community list number (standard)\n" | |
17170 | "Add an standard community-list entry\n" | |
17171 | "Community list name\n" | |
2f8cc0e5 DA |
17172 | "Sequence number of an entry\n" |
17173 | "Sequence number\n" | |
7336e101 SP |
17174 | "Specify community to reject\n" |
17175 | "Specify community to accept\n" | |
17176 | COMMUNITY_VAL_STR) | |
718e3744 | 17177 | { |
d62a17ae | 17178 | char *cl_name_or_number = NULL; |
174b5cb9 | 17179 | char *str = NULL; |
d62a17ae | 17180 | int direct = 0; |
17181 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 17182 | char *seq = NULL; |
d62a17ae | 17183 | int idx = 0; |
7336e101 | 17184 | |
2f8cc0e5 DA |
17185 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17186 | if (idx) | |
17187 | seq = argv[idx]->arg; | |
17188 | ||
17189 | idx = 0; | |
174b5cb9 DA |
17190 | argv_find(argv, argc, "permit", &idx); |
17191 | argv_find(argv, argc, "deny", &idx); | |
17192 | ||
17193 | if (idx) { | |
17194 | direct = argv_find(argv, argc, "permit", &idx) | |
17195 | ? COMMUNITY_PERMIT | |
17196 | : COMMUNITY_DENY; | |
17197 | ||
17198 | idx = 0; | |
17199 | argv_find(argv, argc, "AA:NN", &idx); | |
17200 | str = argv_concat(argv, argc, idx); | |
17201 | } | |
17202 | ||
17203 | idx = 0; | |
d62a17ae | 17204 | argv_find(argv, argc, "(1-99)", &idx); |
17205 | argv_find(argv, argc, "WORD", &idx); | |
17206 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 17207 | |
2f8cc0e5 | 17208 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 17209 | direct, style); |
42f914d4 | 17210 | |
d62a17ae | 17211 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17212 | |
d62a17ae | 17213 | if (ret < 0) { |
17214 | community_list_perror(vty, ret); | |
17215 | return CMD_WARNING_CONFIG_FAILED; | |
17216 | } | |
42f914d4 | 17217 | |
d62a17ae | 17218 | return CMD_SUCCESS; |
718e3744 | 17219 | } |
7336e101 | 17220 | |
174b5cb9 DA |
17221 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
17222 | "no bgp community-list <(1-99)|standard WORD>", | |
17223 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
17224 | "Community list number (standard)\n" | |
17225 | "Add an standard community-list entry\n" | |
17226 | "Community list name\n") | |
17227 | ||
7336e101 SP |
17228 | /*community-list expanded */ |
17229 | DEFUN (community_list_expanded_all, | |
17230 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17231 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17232 | BGP_STR |
17233 | COMMUNITY_LIST_STR | |
718e3744 | 17234 | "Community list number (expanded)\n" |
5bf15956 | 17235 | "Add an expanded community-list entry\n" |
718e3744 | 17236 | "Community list name\n" |
2f8cc0e5 DA |
17237 | "Sequence number of an entry\n" |
17238 | "Sequence number\n" | |
718e3744 | 17239 | "Specify community to reject\n" |
17240 | "Specify community to accept\n" | |
17241 | COMMUNITY_VAL_STR) | |
17242 | { | |
d62a17ae | 17243 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17244 | char *seq = NULL; |
d62a17ae | 17245 | int direct = 0; |
17246 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17247 | int idx = 0; |
7b9a4750 | 17248 | |
2f8cc0e5 DA |
17249 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17250 | if (idx) | |
17251 | seq = argv[idx]->arg; | |
17252 | ||
17253 | idx = 0; | |
17254 | ||
d62a17ae | 17255 | argv_find(argv, argc, "(100-500)", &idx); |
17256 | argv_find(argv, argc, "WORD", &idx); | |
17257 | cl_name_or_number = argv[idx]->arg; | |
17258 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17259 | : COMMUNITY_DENY; | |
17260 | argv_find(argv, argc, "AA:NN", &idx); | |
17261 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17262 | |
2f8cc0e5 DA |
17263 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
17264 | direct, style); | |
42f914d4 | 17265 | |
d62a17ae | 17266 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17267 | |
d62a17ae | 17268 | if (ret < 0) { |
17269 | /* Display error string. */ | |
17270 | community_list_perror(vty, ret); | |
17271 | return CMD_WARNING_CONFIG_FAILED; | |
17272 | } | |
42f914d4 | 17273 | |
d62a17ae | 17274 | return CMD_SUCCESS; |
718e3744 | 17275 | } |
17276 | ||
7336e101 SP |
17277 | DEFUN (no_community_list_expanded_all, |
17278 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17279 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17280 | NO_STR |
17281 | BGP_STR | |
17282 | COMMUNITY_LIST_STR | |
17283 | "Community list number (expanded)\n" | |
17284 | "Add an expanded community-list entry\n" | |
17285 | "Community list name\n" | |
2f8cc0e5 DA |
17286 | "Sequence number of an entry\n" |
17287 | "Sequence number\n" | |
7336e101 SP |
17288 | "Specify community to reject\n" |
17289 | "Specify community to accept\n" | |
17290 | COMMUNITY_VAL_STR) | |
718e3744 | 17291 | { |
d62a17ae | 17292 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17293 | char *seq = NULL; |
174b5cb9 | 17294 | char *str = NULL; |
d62a17ae | 17295 | int direct = 0; |
17296 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17297 | int idx = 0; |
174b5cb9 | 17298 | |
2f8cc0e5 DA |
17299 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17300 | if (idx) | |
17301 | seq = argv[idx]->arg; | |
17302 | ||
17303 | idx = 0; | |
174b5cb9 DA |
17304 | argv_find(argv, argc, "permit", &idx); |
17305 | argv_find(argv, argc, "deny", &idx); | |
17306 | ||
17307 | if (idx) { | |
17308 | direct = argv_find(argv, argc, "permit", &idx) | |
17309 | ? COMMUNITY_PERMIT | |
17310 | : COMMUNITY_DENY; | |
17311 | ||
17312 | idx = 0; | |
17313 | argv_find(argv, argc, "AA:NN", &idx); | |
17314 | str = argv_concat(argv, argc, idx); | |
7336e101 | 17315 | } |
174b5cb9 DA |
17316 | |
17317 | idx = 0; | |
d62a17ae | 17318 | argv_find(argv, argc, "(100-500)", &idx); |
17319 | argv_find(argv, argc, "WORD", &idx); | |
17320 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 17321 | |
2f8cc0e5 | 17322 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 17323 | direct, style); |
42f914d4 | 17324 | |
d62a17ae | 17325 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17326 | |
d62a17ae | 17327 | if (ret < 0) { |
17328 | community_list_perror(vty, ret); | |
17329 | return CMD_WARNING_CONFIG_FAILED; | |
17330 | } | |
42f914d4 | 17331 | |
d62a17ae | 17332 | return CMD_SUCCESS; |
718e3744 | 17333 | } |
17334 | ||
174b5cb9 DA |
17335 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
17336 | "no bgp community-list <(100-500)|expanded WORD>", | |
17337 | NO_STR IP_STR COMMUNITY_LIST_STR | |
17338 | "Community list number (expanded)\n" | |
17339 | "Add an expanded community-list entry\n" | |
17340 | "Community list name\n") | |
17341 | ||
8d9b8ed9 PM |
17342 | /* Return configuration string of community-list entry. */ |
17343 | static const char *community_list_config_str(struct community_entry *entry) | |
17344 | { | |
17345 | const char *str; | |
17346 | ||
17347 | if (entry->any) | |
17348 | str = ""; | |
17349 | else { | |
17350 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
17351 | str = community_str(entry->u.com, false); | |
17352 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
17353 | str = lcommunity_str(entry->u.lcom, false); | |
17354 | else | |
17355 | str = entry->config; | |
17356 | } | |
17357 | return str; | |
17358 | } | |
17359 | ||
d62a17ae | 17360 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17361 | { |
d62a17ae | 17362 | struct community_entry *entry; |
718e3744 | 17363 | |
d62a17ae | 17364 | for (entry = list->head; entry; entry = entry->next) { |
17365 | if (entry == list->head) { | |
17366 | if (all_digit(list->name)) | |
17367 | vty_out(vty, "Community %s list %s\n", | |
17368 | entry->style == COMMUNITY_LIST_STANDARD | |
17369 | ? "standard" | |
17370 | : "(expanded) access", | |
17371 | list->name); | |
17372 | else | |
17373 | vty_out(vty, "Named Community %s list %s\n", | |
17374 | entry->style == COMMUNITY_LIST_STANDARD | |
17375 | ? "standard" | |
17376 | : "expanded", | |
17377 | list->name); | |
17378 | } | |
17379 | if (entry->any) | |
17380 | vty_out(vty, " %s\n", | |
17381 | community_direct_str(entry->direct)); | |
17382 | else | |
17383 | vty_out(vty, " %s %s\n", | |
17384 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17385 | community_list_config_str(entry)); |
d62a17ae | 17386 | } |
718e3744 | 17387 | } |
17388 | ||
7336e101 SP |
17389 | DEFUN (show_community_list, |
17390 | show_bgp_community_list_cmd, | |
17391 | "show bgp community-list", | |
718e3744 | 17392 | SHOW_STR |
7336e101 | 17393 | BGP_STR |
718e3744 | 17394 | "List community-list\n") |
17395 | { | |
d62a17ae | 17396 | struct community_list *list; |
17397 | struct community_list_master *cm; | |
718e3744 | 17398 | |
d62a17ae | 17399 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
17400 | if (!cm) | |
17401 | return CMD_SUCCESS; | |
718e3744 | 17402 | |
d62a17ae | 17403 | for (list = cm->num.head; list; list = list->next) |
17404 | community_list_show(vty, list); | |
718e3744 | 17405 | |
d62a17ae | 17406 | for (list = cm->str.head; list; list = list->next) |
17407 | community_list_show(vty, list); | |
718e3744 | 17408 | |
d62a17ae | 17409 | return CMD_SUCCESS; |
718e3744 | 17410 | } |
17411 | ||
7336e101 SP |
17412 | DEFUN (show_community_list_arg, |
17413 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 17414 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
17415 | SHOW_STR |
17416 | BGP_STR | |
718e3744 | 17417 | "List community-list\n" |
17418 | "Community-list number\n" | |
960b69b9 | 17419 | "Community-list name\n" |
17420 | "Detailed information on community-list\n") | |
718e3744 | 17421 | { |
d62a17ae | 17422 | int idx_comm_list = 3; |
17423 | struct community_list *list; | |
718e3744 | 17424 | |
e237b0d2 | 17425 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17426 | COMMUNITY_LIST_MASTER); |
17427 | if (!list) { | |
17428 | vty_out(vty, "%% Can't find community-list\n"); | |
17429 | return CMD_WARNING; | |
17430 | } | |
718e3744 | 17431 | |
d62a17ae | 17432 | community_list_show(vty, list); |
718e3744 | 17433 | |
d62a17ae | 17434 | return CMD_SUCCESS; |
718e3744 | 17435 | } |
6b0655a2 | 17436 | |
57d187bc JS |
17437 | /* |
17438 | * Large Community code. | |
17439 | */ | |
d62a17ae | 17440 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
17441 | struct cmd_token **argv, int style, | |
17442 | int reject_all_digit_name) | |
17443 | { | |
17444 | int ret; | |
17445 | int direct; | |
17446 | char *str; | |
17447 | int idx = 0; | |
17448 | char *cl_name; | |
2f8cc0e5 DA |
17449 | char *seq = NULL; |
17450 | ||
947073e3 | 17451 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 17452 | seq = argv[idx]->arg; |
d62a17ae | 17453 | |
2f8cc0e5 | 17454 | idx = 0; |
d62a17ae | 17455 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17456 | : COMMUNITY_DENY; | |
17457 | ||
17458 | /* All digit name check. */ | |
17459 | idx = 0; | |
17460 | argv_find(argv, argc, "WORD", &idx); | |
17461 | argv_find(argv, argc, "(1-99)", &idx); | |
17462 | argv_find(argv, argc, "(100-500)", &idx); | |
17463 | cl_name = argv[idx]->arg; | |
17464 | if (reject_all_digit_name && all_digit(cl_name)) { | |
17465 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
17466 | return CMD_WARNING_CONFIG_FAILED; | |
17467 | } | |
17468 | ||
17469 | idx = 0; | |
17470 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
17471 | argv_find(argv, argc, "LINE", &idx); | |
17472 | /* Concat community string argument. */ | |
17473 | if (idx) | |
17474 | str = argv_concat(argv, argc, idx); | |
17475 | else | |
17476 | str = NULL; | |
17477 | ||
2f8cc0e5 | 17478 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 17479 | |
17480 | /* Free temporary community list string allocated by | |
17481 | argv_concat(). */ | |
0a22ddfb | 17482 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17483 | |
17484 | if (ret < 0) { | |
17485 | community_list_perror(vty, ret); | |
17486 | return CMD_WARNING_CONFIG_FAILED; | |
17487 | } | |
17488 | return CMD_SUCCESS; | |
17489 | } | |
17490 | ||
17491 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
17492 | struct cmd_token **argv, int style) | |
17493 | { | |
17494 | int ret; | |
17495 | int direct = 0; | |
17496 | char *str = NULL; | |
17497 | int idx = 0; | |
2f8cc0e5 | 17498 | char *seq = NULL; |
d62a17ae | 17499 | |
947073e3 | 17500 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 17501 | seq = argv[idx]->arg; |
d62a17ae | 17502 | |
2f8cc0e5 | 17503 | idx = 0; |
d62a17ae | 17504 | argv_find(argv, argc, "permit", &idx); |
17505 | argv_find(argv, argc, "deny", &idx); | |
17506 | ||
17507 | if (idx) { | |
17508 | /* Check the list direct. */ | |
17509 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
17510 | direct = COMMUNITY_PERMIT; | |
17511 | else | |
17512 | direct = COMMUNITY_DENY; | |
17513 | ||
17514 | idx = 0; | |
17515 | argv_find(argv, argc, "LINE", &idx); | |
17516 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
17517 | /* Concat community string argument. */ | |
17518 | str = argv_concat(argv, argc, idx); | |
17519 | } | |
17520 | ||
17521 | idx = 0; | |
17522 | argv_find(argv, argc, "(1-99)", &idx); | |
17523 | argv_find(argv, argc, "(100-500)", &idx); | |
17524 | argv_find(argv, argc, "WORD", &idx); | |
17525 | ||
17526 | /* Unset community list. */ | |
2f8cc0e5 | 17527 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 17528 | style); |
17529 | ||
17530 | /* Free temporary community list string allocated by | |
17531 | argv_concat(). */ | |
0a22ddfb | 17532 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17533 | |
17534 | if (ret < 0) { | |
17535 | community_list_perror(vty, ret); | |
17536 | return CMD_WARNING_CONFIG_FAILED; | |
17537 | } | |
17538 | ||
17539 | return CMD_SUCCESS; | |
57d187bc JS |
17540 | } |
17541 | ||
17542 | /* "large-community-list" keyword help string. */ | |
17543 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
17544 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
17545 | ||
7336e101 SP |
17546 | DEFUN (lcommunity_list_standard, |
17547 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17548 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17549 | BGP_STR |
17550 | LCOMMUNITY_LIST_STR | |
17551 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17552 | "Sequence number of an entry\n" |
17553 | "Sequence number\n" | |
7336e101 SP |
17554 | "Specify large community to reject\n" |
17555 | "Specify large community to accept\n" | |
17556 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17557 | { |
d62a17ae | 17558 | return lcommunity_list_set_vty(vty, argc, argv, |
17559 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17560 | } |
17561 | ||
7336e101 SP |
17562 | DEFUN (lcommunity_list_expanded, |
17563 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17564 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17565 | BGP_STR |
17566 | LCOMMUNITY_LIST_STR | |
17567 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17568 | "Sequence number of an entry\n" |
17569 | "Sequence number\n" | |
7336e101 SP |
17570 | "Specify large community to reject\n" |
17571 | "Specify large community to accept\n" | |
17572 | "An ordered list as a regular-expression\n") | |
57d187bc | 17573 | { |
d62a17ae | 17574 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17575 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17576 | } |
17577 | ||
7336e101 SP |
17578 | DEFUN (lcommunity_list_name_standard, |
17579 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17580 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17581 | BGP_STR |
17582 | LCOMMUNITY_LIST_STR | |
17583 | "Specify standard large-community-list\n" | |
17584 | "Large Community list name\n" | |
2f8cc0e5 DA |
17585 | "Sequence number of an entry\n" |
17586 | "Sequence number\n" | |
7336e101 SP |
17587 | "Specify large community to reject\n" |
17588 | "Specify large community to accept\n" | |
17589 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17590 | { |
d62a17ae | 17591 | return lcommunity_list_set_vty(vty, argc, argv, |
17592 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17593 | } |
17594 | ||
7336e101 SP |
17595 | DEFUN (lcommunity_list_name_expanded, |
17596 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17597 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17598 | BGP_STR |
17599 | LCOMMUNITY_LIST_STR | |
17600 | "Specify expanded large-community-list\n" | |
17601 | "Large Community list name\n" | |
2f8cc0e5 DA |
17602 | "Sequence number of an entry\n" |
17603 | "Sequence number\n" | |
7336e101 SP |
17604 | "Specify large community to reject\n" |
17605 | "Specify large community to accept\n" | |
17606 | "An ordered list as a regular-expression\n") | |
57d187bc | 17607 | { |
d62a17ae | 17608 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17609 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17610 | } |
17611 | ||
4378f57c DA |
17612 | DEFUN (no_lcommunity_list_all, |
17613 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
17614 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
17615 | NO_STR | |
17616 | BGP_STR | |
17617 | LCOMMUNITY_LIST_STR | |
17618 | "Large Community list number (standard)\n" | |
17619 | "Large Community list number (expanded)\n" | |
17620 | "Large Community list name\n") | |
57d187bc | 17621 | { |
7336e101 SP |
17622 | return lcommunity_list_unset_vty(vty, argc, argv, |
17623 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17624 | } |
17625 | ||
4378f57c DA |
17626 | DEFUN (no_lcommunity_list_name_standard_all, |
17627 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
17628 | "no bgp large-community-list standard WORD", | |
17629 | NO_STR | |
17630 | BGP_STR | |
17631 | LCOMMUNITY_LIST_STR | |
17632 | "Specify standard large-community-list\n" | |
17633 | "Large Community list name\n") | |
17634 | { | |
17635 | return lcommunity_list_unset_vty(vty, argc, argv, | |
17636 | LARGE_COMMUNITY_LIST_STANDARD); | |
17637 | } | |
17638 | ||
7336e101 SP |
17639 | DEFUN (no_lcommunity_list_name_expanded_all, |
17640 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17641 | "no bgp large-community-list expanded WORD", | |
17642 | NO_STR | |
17643 | BGP_STR | |
17644 | LCOMMUNITY_LIST_STR | |
17645 | "Specify expanded large-community-list\n" | |
17646 | "Large Community list name\n") | |
57d187bc | 17647 | { |
d62a17ae | 17648 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17649 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17650 | } |
17651 | ||
7336e101 SP |
17652 | DEFUN (no_lcommunity_list_standard, |
17653 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17654 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17655 | NO_STR |
17656 | BGP_STR | |
17657 | LCOMMUNITY_LIST_STR | |
17658 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17659 | "Sequence number of an entry\n" |
17660 | "Sequence number\n" | |
7336e101 SP |
17661 | "Specify large community to reject\n" |
17662 | "Specify large community to accept\n" | |
17663 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17664 | { |
d62a17ae | 17665 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17666 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17667 | } |
17668 | ||
7336e101 SP |
17669 | DEFUN (no_lcommunity_list_expanded, |
17670 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17671 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17672 | NO_STR |
17673 | BGP_STR | |
17674 | LCOMMUNITY_LIST_STR | |
17675 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17676 | "Sequence number of an entry\n" |
17677 | "Sequence number\n" | |
7336e101 SP |
17678 | "Specify large community to reject\n" |
17679 | "Specify large community to accept\n" | |
17680 | "An ordered list as a regular-expression\n") | |
57d187bc | 17681 | { |
d62a17ae | 17682 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17683 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17684 | } |
17685 | ||
7336e101 SP |
17686 | DEFUN (no_lcommunity_list_name_standard, |
17687 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17688 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17689 | NO_STR |
17690 | BGP_STR | |
17691 | LCOMMUNITY_LIST_STR | |
17692 | "Specify standard large-community-list\n" | |
17693 | "Large Community list name\n" | |
2f8cc0e5 DA |
17694 | "Sequence number of an entry\n" |
17695 | "Sequence number\n" | |
7336e101 SP |
17696 | "Specify large community to reject\n" |
17697 | "Specify large community to accept\n" | |
17698 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17699 | { |
d62a17ae | 17700 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17701 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17702 | } |
17703 | ||
7336e101 SP |
17704 | DEFUN (no_lcommunity_list_name_expanded, |
17705 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17706 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17707 | NO_STR |
17708 | BGP_STR | |
17709 | LCOMMUNITY_LIST_STR | |
17710 | "Specify expanded large-community-list\n" | |
17711 | "Large community list name\n" | |
2f8cc0e5 DA |
17712 | "Sequence number of an entry\n" |
17713 | "Sequence number\n" | |
7336e101 SP |
17714 | "Specify large community to reject\n" |
17715 | "Specify large community to accept\n" | |
17716 | "An ordered list as a regular-expression\n") | |
57d187bc | 17717 | { |
d62a17ae | 17718 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17719 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17720 | } |
17721 | ||
d62a17ae | 17722 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17723 | { | |
17724 | struct community_entry *entry; | |
17725 | ||
17726 | for (entry = list->head; entry; entry = entry->next) { | |
17727 | if (entry == list->head) { | |
17728 | if (all_digit(list->name)) | |
17729 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17730 | entry->style == |
17731 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17732 | ? "standard" |
17733 | : "(expanded) access", | |
17734 | list->name); | |
17735 | else | |
17736 | vty_out(vty, | |
17737 | "Named large community %s list %s\n", | |
169b72c8 | 17738 | entry->style == |
17739 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17740 | ? "standard" |
17741 | : "expanded", | |
17742 | list->name); | |
17743 | } | |
17744 | if (entry->any) | |
17745 | vty_out(vty, " %s\n", | |
17746 | community_direct_str(entry->direct)); | |
17747 | else | |
17748 | vty_out(vty, " %s %s\n", | |
17749 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17750 | community_list_config_str(entry)); |
d62a17ae | 17751 | } |
57d187bc JS |
17752 | } |
17753 | ||
7336e101 SP |
17754 | DEFUN (show_lcommunity_list, |
17755 | show_bgp_lcommunity_list_cmd, | |
17756 | "show bgp large-community-list", | |
57d187bc | 17757 | SHOW_STR |
7336e101 | 17758 | BGP_STR |
57d187bc JS |
17759 | "List large-community list\n") |
17760 | { | |
d62a17ae | 17761 | struct community_list *list; |
17762 | struct community_list_master *cm; | |
57d187bc | 17763 | |
d62a17ae | 17764 | cm = community_list_master_lookup(bgp_clist, |
17765 | LARGE_COMMUNITY_LIST_MASTER); | |
17766 | if (!cm) | |
17767 | return CMD_SUCCESS; | |
57d187bc | 17768 | |
d62a17ae | 17769 | for (list = cm->num.head; list; list = list->next) |
17770 | lcommunity_list_show(vty, list); | |
57d187bc | 17771 | |
d62a17ae | 17772 | for (list = cm->str.head; list; list = list->next) |
17773 | lcommunity_list_show(vty, list); | |
57d187bc | 17774 | |
d62a17ae | 17775 | return CMD_SUCCESS; |
57d187bc JS |
17776 | } |
17777 | ||
7336e101 SP |
17778 | DEFUN (show_lcommunity_list_arg, |
17779 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17780 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17781 | SHOW_STR |
17782 | BGP_STR | |
57d187bc | 17783 | "List large-community list\n" |
960b69b9 | 17784 | "Large-community-list number\n" |
17785 | "Large-community-list name\n" | |
17786 | "Detailed information on large-community-list\n") | |
57d187bc | 17787 | { |
d62a17ae | 17788 | struct community_list *list; |
57d187bc | 17789 | |
e237b0d2 | 17790 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17791 | LARGE_COMMUNITY_LIST_MASTER); |
17792 | if (!list) { | |
960b69b9 | 17793 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17794 | return CMD_WARNING; |
17795 | } | |
57d187bc | 17796 | |
d62a17ae | 17797 | lcommunity_list_show(vty, list); |
57d187bc | 17798 | |
d62a17ae | 17799 | return CMD_SUCCESS; |
57d187bc JS |
17800 | } |
17801 | ||
718e3744 | 17802 | /* "extcommunity-list" keyword help string. */ |
17803 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17804 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17805 | ||
7336e101 SP |
17806 | DEFUN (extcommunity_list_standard, |
17807 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 17808 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17809 | BGP_STR |
718e3744 | 17810 | EXTCOMMUNITY_LIST_STR |
17811 | "Extended Community list number (standard)\n" | |
718e3744 | 17812 | "Specify standard extcommunity-list\n" |
5bf15956 | 17813 | "Community list name\n" |
2f8cc0e5 DA |
17814 | "Sequence number of an entry\n" |
17815 | "Sequence number\n" | |
718e3744 | 17816 | "Specify community to reject\n" |
17817 | "Specify community to accept\n" | |
17818 | EXTCOMMUNITY_VAL_STR) | |
17819 | { | |
d62a17ae | 17820 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17821 | int direct = 0; | |
17822 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17823 | char *seq = NULL; |
42f914d4 | 17824 | |
d62a17ae | 17825 | int idx = 0; |
7b9a4750 | 17826 | |
d62a17ae | 17827 | argv_find(argv, argc, "(1-99)", &idx); |
17828 | argv_find(argv, argc, "WORD", &idx); | |
17829 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 17830 | |
409148f6 | 17831 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17832 | seq = argv[idx]->arg; |
17833 | ||
d62a17ae | 17834 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17835 | : COMMUNITY_DENY; | |
17836 | argv_find(argv, argc, "AA:NN", &idx); | |
17837 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17838 | |
2f8cc0e5 | 17839 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17840 | direct, style); |
42f914d4 | 17841 | |
d62a17ae | 17842 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17843 | |
d62a17ae | 17844 | if (ret < 0) { |
17845 | community_list_perror(vty, ret); | |
17846 | return CMD_WARNING_CONFIG_FAILED; | |
17847 | } | |
42f914d4 | 17848 | |
d62a17ae | 17849 | return CMD_SUCCESS; |
718e3744 | 17850 | } |
17851 | ||
7336e101 SP |
17852 | DEFUN (extcommunity_list_name_expanded, |
17853 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17854 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17855 | BGP_STR |
17856 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17857 | "Extended Community list number (expanded)\n" |
718e3744 | 17858 | "Specify expanded extcommunity-list\n" |
17859 | "Extended Community list name\n" | |
2f8cc0e5 DA |
17860 | "Sequence number of an entry\n" |
17861 | "Sequence number\n" | |
718e3744 | 17862 | "Specify community to reject\n" |
17863 | "Specify community to accept\n" | |
17864 | "An ordered list as a regular-expression\n") | |
17865 | { | |
d62a17ae | 17866 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17867 | int direct = 0; | |
17868 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17869 | char *seq = NULL; |
d62a17ae | 17870 | int idx = 0; |
7336e101 | 17871 | |
d62a17ae | 17872 | argv_find(argv, argc, "(100-500)", &idx); |
17873 | argv_find(argv, argc, "WORD", &idx); | |
17874 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 17875 | |
409148f6 | 17876 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17877 | seq = argv[idx]->arg; |
17878 | ||
d62a17ae | 17879 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17880 | : COMMUNITY_DENY; | |
17881 | argv_find(argv, argc, "LINE", &idx); | |
17882 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17883 | |
2f8cc0e5 | 17884 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17885 | direct, style); |
42f914d4 | 17886 | |
d62a17ae | 17887 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17888 | |
d62a17ae | 17889 | if (ret < 0) { |
17890 | community_list_perror(vty, ret); | |
17891 | return CMD_WARNING_CONFIG_FAILED; | |
17892 | } | |
42f914d4 | 17893 | |
d62a17ae | 17894 | return CMD_SUCCESS; |
718e3744 | 17895 | } |
17896 | ||
7336e101 SP |
17897 | DEFUN (no_extcommunity_list_standard_all, |
17898 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 17899 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17900 | NO_STR |
17901 | BGP_STR | |
17902 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17903 | "Extended Community list number (standard)\n" |
718e3744 | 17904 | "Specify standard extcommunity-list\n" |
5bf15956 | 17905 | "Community list name\n" |
2f8cc0e5 DA |
17906 | "Sequence number of an entry\n" |
17907 | "Sequence number\n" | |
718e3744 | 17908 | "Specify community to reject\n" |
17909 | "Specify community to accept\n" | |
17910 | EXTCOMMUNITY_VAL_STR) | |
17911 | { | |
d62a17ae | 17912 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17913 | int direct = 0; | |
17914 | char *cl_number_or_name = NULL; | |
d4455c89 | 17915 | char *str = NULL; |
2f8cc0e5 | 17916 | char *seq = NULL; |
d62a17ae | 17917 | int idx = 0; |
d4455c89 | 17918 | |
409148f6 | 17919 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17920 | seq = argv[idx]->arg; |
17921 | ||
17922 | idx = 0; | |
d4455c89 DA |
17923 | argv_find(argv, argc, "permit", &idx); |
17924 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
17925 | if (idx) { |
17926 | direct = argv_find(argv, argc, "permit", &idx) | |
17927 | ? COMMUNITY_PERMIT | |
17928 | : COMMUNITY_DENY; | |
17929 | ||
17930 | idx = 0; | |
17931 | argv_find(argv, argc, "AA:NN", &idx); | |
17932 | str = argv_concat(argv, argc, idx); | |
17933 | } | |
17934 | ||
17935 | idx = 0; | |
d62a17ae | 17936 | argv_find(argv, argc, "(1-99)", &idx); |
17937 | argv_find(argv, argc, "WORD", &idx); | |
17938 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17939 | |
d62a17ae | 17940 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17941 | seq, direct, style); |
42f914d4 | 17942 | |
d62a17ae | 17943 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17944 | |
d62a17ae | 17945 | if (ret < 0) { |
17946 | community_list_perror(vty, ret); | |
17947 | return CMD_WARNING_CONFIG_FAILED; | |
17948 | } | |
42f914d4 | 17949 | |
d62a17ae | 17950 | return CMD_SUCCESS; |
718e3744 | 17951 | } |
17952 | ||
d4455c89 DA |
17953 | ALIAS(no_extcommunity_list_standard_all, |
17954 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
17955 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
17956 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17957 | "Extended Community list number (standard)\n" | |
17958 | "Specify standard extcommunity-list\n" | |
17959 | "Community list name\n") | |
17960 | ||
7336e101 SP |
17961 | DEFUN (no_extcommunity_list_expanded_all, |
17962 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 17963 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17964 | NO_STR |
17965 | BGP_STR | |
17966 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 17967 | "Extended Community list number (expanded)\n" |
718e3744 | 17968 | "Specify expanded extcommunity-list\n" |
5bf15956 | 17969 | "Extended Community list name\n" |
2f8cc0e5 DA |
17970 | "Sequence number of an entry\n" |
17971 | "Sequence number\n" | |
718e3744 | 17972 | "Specify community to reject\n" |
17973 | "Specify community to accept\n" | |
17974 | "An ordered list as a regular-expression\n") | |
17975 | { | |
d62a17ae | 17976 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17977 | int direct = 0; | |
17978 | char *cl_number_or_name = NULL; | |
d4455c89 | 17979 | char *str = NULL; |
2f8cc0e5 | 17980 | char *seq = NULL; |
d62a17ae | 17981 | int idx = 0; |
d4455c89 | 17982 | |
409148f6 | 17983 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17984 | seq = argv[idx]->arg; |
17985 | ||
17986 | idx = 0; | |
d4455c89 DA |
17987 | argv_find(argv, argc, "permit", &idx); |
17988 | argv_find(argv, argc, "deny", &idx); | |
17989 | ||
17990 | if (idx) { | |
17991 | direct = argv_find(argv, argc, "permit", &idx) | |
17992 | ? COMMUNITY_PERMIT | |
17993 | : COMMUNITY_DENY; | |
17994 | ||
17995 | idx = 0; | |
17996 | argv_find(argv, argc, "LINE", &idx); | |
17997 | str = argv_concat(argv, argc, idx); | |
17998 | } | |
17999 | ||
18000 | idx = 0; | |
d62a17ae | 18001 | argv_find(argv, argc, "(100-500)", &idx); |
18002 | argv_find(argv, argc, "WORD", &idx); | |
18003 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 18004 | |
d62a17ae | 18005 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 18006 | seq, direct, style); |
42f914d4 | 18007 | |
d62a17ae | 18008 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18009 | |
d62a17ae | 18010 | if (ret < 0) { |
18011 | community_list_perror(vty, ret); | |
18012 | return CMD_WARNING_CONFIG_FAILED; | |
18013 | } | |
42f914d4 | 18014 | |
d62a17ae | 18015 | return CMD_SUCCESS; |
718e3744 | 18016 | } |
18017 | ||
d4455c89 DA |
18018 | ALIAS(no_extcommunity_list_expanded_all, |
18019 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
18020 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
18021 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
18022 | "Extended Community list number (expanded)\n" | |
18023 | "Specify expanded extcommunity-list\n" | |
18024 | "Extended Community list name\n") | |
18025 | ||
d62a17ae | 18026 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 18027 | { |
d62a17ae | 18028 | struct community_entry *entry; |
718e3744 | 18029 | |
d62a17ae | 18030 | for (entry = list->head; entry; entry = entry->next) { |
18031 | if (entry == list->head) { | |
18032 | if (all_digit(list->name)) | |
18033 | vty_out(vty, "Extended community %s list %s\n", | |
18034 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
18035 | ? "standard" | |
18036 | : "(expanded) access", | |
18037 | list->name); | |
18038 | else | |
18039 | vty_out(vty, | |
18040 | "Named extended community %s list %s\n", | |
18041 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
18042 | ? "standard" | |
18043 | : "expanded", | |
18044 | list->name); | |
18045 | } | |
18046 | if (entry->any) | |
18047 | vty_out(vty, " %s\n", | |
18048 | community_direct_str(entry->direct)); | |
18049 | else | |
18050 | vty_out(vty, " %s %s\n", | |
18051 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18052 | community_list_config_str(entry)); |
d62a17ae | 18053 | } |
718e3744 | 18054 | } |
18055 | ||
7336e101 SP |
18056 | DEFUN (show_extcommunity_list, |
18057 | show_bgp_extcommunity_list_cmd, | |
18058 | "show bgp extcommunity-list", | |
718e3744 | 18059 | SHOW_STR |
7336e101 | 18060 | BGP_STR |
718e3744 | 18061 | "List extended-community list\n") |
18062 | { | |
d62a17ae | 18063 | struct community_list *list; |
18064 | struct community_list_master *cm; | |
718e3744 | 18065 | |
d62a17ae | 18066 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
18067 | if (!cm) | |
18068 | return CMD_SUCCESS; | |
718e3744 | 18069 | |
d62a17ae | 18070 | for (list = cm->num.head; list; list = list->next) |
18071 | extcommunity_list_show(vty, list); | |
718e3744 | 18072 | |
d62a17ae | 18073 | for (list = cm->str.head; list; list = list->next) |
18074 | extcommunity_list_show(vty, list); | |
718e3744 | 18075 | |
d62a17ae | 18076 | return CMD_SUCCESS; |
718e3744 | 18077 | } |
18078 | ||
7336e101 SP |
18079 | DEFUN (show_extcommunity_list_arg, |
18080 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 18081 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
18082 | SHOW_STR |
18083 | BGP_STR | |
718e3744 | 18084 | "List extended-community list\n" |
18085 | "Extcommunity-list number\n" | |
960b69b9 | 18086 | "Extcommunity-list name\n" |
18087 | "Detailed information on extcommunity-list\n") | |
718e3744 | 18088 | { |
d62a17ae | 18089 | int idx_comm_list = 3; |
18090 | struct community_list *list; | |
718e3744 | 18091 | |
e237b0d2 | 18092 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 18093 | EXTCOMMUNITY_LIST_MASTER); |
18094 | if (!list) { | |
18095 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
18096 | return CMD_WARNING; | |
18097 | } | |
718e3744 | 18098 | |
d62a17ae | 18099 | extcommunity_list_show(vty, list); |
718e3744 | 18100 | |
d62a17ae | 18101 | return CMD_SUCCESS; |
718e3744 | 18102 | } |
6b0655a2 | 18103 | |
718e3744 | 18104 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 18105 | static int community_list_config_write(struct vty *vty) |
18106 | { | |
18107 | struct community_list *list; | |
18108 | struct community_entry *entry; | |
18109 | struct community_list_master *cm; | |
18110 | int write = 0; | |
18111 | ||
18112 | /* Community-list. */ | |
18113 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
18114 | ||
18115 | for (list = cm->num.head; list; list = list->next) | |
18116 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18117 | vty_out(vty, |
18118 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
18119 | list->name, entry->seq, | |
d62a17ae | 18120 | community_direct_str(entry->direct), |
18121 | community_list_config_str(entry)); | |
18122 | write++; | |
18123 | } | |
18124 | for (list = cm->str.head; list; list = list->next) | |
18125 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18126 | vty_out(vty, |
18127 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 18128 | entry->style == COMMUNITY_LIST_STANDARD |
18129 | ? "standard" | |
18130 | : "expanded", | |
2f8cc0e5 DA |
18131 | list->name, entry->seq, |
18132 | community_direct_str(entry->direct), | |
d62a17ae | 18133 | community_list_config_str(entry)); |
18134 | write++; | |
18135 | } | |
18136 | ||
18137 | /* Extcommunity-list. */ | |
18138 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
18139 | ||
18140 | for (list = cm->num.head; list; list = list->next) | |
18141 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18142 | vty_out(vty, |
18143 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
18144 | list->name, entry->seq, | |
18145 | community_direct_str(entry->direct), | |
d62a17ae | 18146 | community_list_config_str(entry)); |
18147 | write++; | |
18148 | } | |
18149 | for (list = cm->str.head; list; list = list->next) | |
18150 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18151 | vty_out(vty, |
6cde4b45 | 18152 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 18153 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
18154 | ? "standard" | |
18155 | : "expanded", | |
2f8cc0e5 DA |
18156 | list->name, entry->seq, |
18157 | community_direct_str(entry->direct), | |
d62a17ae | 18158 | community_list_config_str(entry)); |
18159 | write++; | |
18160 | } | |
18161 | ||
18162 | ||
18163 | /* lcommunity-list. */ | |
18164 | cm = community_list_master_lookup(bgp_clist, | |
18165 | LARGE_COMMUNITY_LIST_MASTER); | |
18166 | ||
18167 | for (list = cm->num.head; list; list = list->next) | |
18168 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18169 | vty_out(vty, |
6cde4b45 | 18170 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
18171 | list->name, entry->seq, |
18172 | community_direct_str(entry->direct), | |
d62a17ae | 18173 | community_list_config_str(entry)); |
18174 | write++; | |
18175 | } | |
18176 | for (list = cm->str.head; list; list = list->next) | |
18177 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18178 | vty_out(vty, |
6cde4b45 | 18179 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 18180 | |
d62a17ae | 18181 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
18182 | ? "standard" | |
18183 | : "expanded", | |
2f8cc0e5 | 18184 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 18185 | community_list_config_str(entry)); |
18186 | write++; | |
18187 | } | |
18188 | ||
18189 | return write; | |
18190 | } | |
18191 | ||
612c2c15 | 18192 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 18193 | static struct cmd_node community_list_node = { |
f4b8291f | 18194 | .name = "community list", |
62b346ee DL |
18195 | .node = COMMUNITY_LIST_NODE, |
18196 | .prompt = "", | |
612c2c15 | 18197 | .config_write = community_list_config_write, |
718e3744 | 18198 | }; |
18199 | ||
d62a17ae | 18200 | static void community_list_vty(void) |
18201 | { | |
612c2c15 | 18202 | install_node(&community_list_node); |
d62a17ae | 18203 | |
18204 | /* Community-list. */ | |
7336e101 SP |
18205 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
18206 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
18207 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 18208 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 18209 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 18210 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
18211 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
18212 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 18213 | |
18214 | /* Extcommunity-list. */ | |
7336e101 SP |
18215 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
18216 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
18217 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
18218 | install_element(CONFIG_NODE, |
18219 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 18220 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
18221 | install_element(CONFIG_NODE, |
18222 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
18223 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
18224 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 18225 | |
18226 | /* Large Community List */ | |
7336e101 | 18227 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
18228 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
18229 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 18230 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
18231 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
18232 | install_element(CONFIG_NODE, | |
18233 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
18234 | install_element(CONFIG_NODE, |
18235 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
18236 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
18237 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
18238 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
18239 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
18240 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
18241 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 18242 | } |