]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
5cb5f4d0 | 25 | #include "lib_errors.h" |
ec0ab544 | 26 | #include "lib/zclient.h" |
718e3744 | 27 | #include "prefix.h" |
28 | #include "plist.h" | |
29 | #include "buffer.h" | |
30 | #include "linklist.h" | |
31 | #include "stream.h" | |
32 | #include "thread.h" | |
33 | #include "log.h" | |
3b8b1855 | 34 | #include "memory.h" |
1c0d8808 | 35 | #include "lib_vty.h" |
4bf6a362 | 36 | #include "hash.h" |
3f9c7369 | 37 | #include "queue.h" |
039f3a34 | 38 | #include "filter.h" |
5d5ba018 | 39 | #include "frrstr.h" |
718e3744 | 40 | |
41 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 42 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 43 | #include "bgpd/bgp_advertise.h" |
718e3744 | 44 | #include "bgpd/bgp_attr.h" |
45 | #include "bgpd/bgp_aspath.h" | |
46 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 47 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 48 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 49 | #include "bgpd/bgp_damp.h" |
718e3744 | 50 | #include "bgpd/bgp_debug.h" |
14454c9f | 51 | #include "bgpd/bgp_errors.h" |
e0701b79 | 52 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 53 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 54 | #include "bgpd/bgp_open.h" |
4bf6a362 | 55 | #include "bgpd/bgp_regex.h" |
718e3744 | 56 | #include "bgpd/bgp_route.h" |
c016b6c7 | 57 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 58 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 59 | #include "bgpd/bgp_table.h" |
94f2b392 | 60 | #include "bgpd/bgp_vty.h" |
165b5fff | 61 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 62 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 63 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 64 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 65 | #include "bgpd/bgp_io.h" |
94c2f693 | 66 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 67 | #include "bgpd/bgp_evpn_vty.h" |
b5e140c8 | 68 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 69 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 70 | #include "bgpd/bgp_mac.h" |
dd65f45e | 71 | #include "bgpd/bgp_flowspec.h" |
49e5a4a0 | 72 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
73 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
74 | #endif | |
75 | ||
ff8a8a7a CS |
76 | #include "northbound.h" |
77 | #include "northbound_cli.h" | |
78 | #include "bgpd/bgp_nb.h" | |
79 | ||
80 | ||
5d5393b9 | 81 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
82 | { |
83 | .val_bool = false, | |
84 | .match_profile = "traditional", | |
85 | .match_version = "< 7.4", | |
86 | }, | |
87 | { .val_bool = true }, | |
5d5393b9 DL |
88 | ) |
89 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
4c1458b5 DL |
90 | { .val_bool = true, .match_profile = "datacenter", }, |
91 | { .val_bool = false }, | |
5d5393b9 | 92 | ) |
aef999a2 DA |
93 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
94 | { .val_bool = true, .match_profile = "datacenter", }, | |
95 | { .val_bool = false }, | |
96 | ) | |
5d5393b9 | 97 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
98 | { .val_bool = true, .match_profile = "datacenter", }, |
99 | { .val_bool = false }, | |
5d5393b9 DL |
100 | ) |
101 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
4c1458b5 DL |
102 | { .val_bool = true, .match_profile = "datacenter", }, |
103 | { .val_bool = false }, | |
5d5393b9 DL |
104 | ) |
105 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
106 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
107 | { .val_ulong = 120 }, | |
108 | ) | |
109 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
110 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
111 | { .val_ulong = 180 }, | |
112 | ) | |
113 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
114 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
115 | { .val_ulong = 60 }, | |
116 | ) | |
1d3fdccf DA |
117 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
118 | { .val_bool = false, .match_profile = "datacenter", }, | |
119 | { .val_bool = false, .match_version = "< 7.4", }, | |
120 | { .val_bool = true }, | |
121 | ) | |
5d5393b9 | 122 | |
dd65f45e DL |
123 | DEFINE_HOOK(bgp_inst_config_write, |
124 | (struct bgp *bgp, struct vty *vty), | |
125 | (bgp, vty)) | |
718e3744 | 126 | |
36235319 QY |
127 | #define GR_NO_OPER \ |
128 | "The Graceful Restart No Operation was executed as cmd same as previous one." | |
129 | #define GR_INVALID \ | |
130 | "The Graceful Restart command used is not valid at this moment." | |
d62a17ae | 131 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
132 | struct prefix *range, int exact); | |
133 | ||
055679e9 | 134 | /* Show BGP peer's information. */ |
135 | enum show_type { | |
136 | show_all, | |
137 | show_peer, | |
138 | show_ipv4_all, | |
139 | show_ipv6_all, | |
140 | show_ipv4_peer, | |
141 | show_ipv6_peer | |
142 | }; | |
143 | ||
36235319 QY |
144 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
145 | struct prefix *range, int exact); | |
2986cac2 | 146 | |
36235319 QY |
147 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
148 | struct bgp *bgp, | |
149 | bool use_json, | |
150 | json_object *json); | |
2986cac2 | 151 | |
36235319 QY |
152 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
153 | enum show_type type, | |
154 | const char *ip_str, | |
155 | afi_t afi, bool use_json); | |
2986cac2 | 156 | |
f4b8ec07 CS |
157 | static int peer_and_group_lookup_nb(struct vty *vty, const char *peer_str, |
158 | char *base_xpath, int xpath_len, | |
159 | char *abs_xpath); | |
160 | ||
d62a17ae | 161 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
162 | { | |
163 | switch (afi) { | |
164 | case AFI_IP: | |
165 | switch (safi) { | |
166 | case SAFI_UNICAST: | |
167 | return BGP_IPV4_NODE; | |
d62a17ae | 168 | case SAFI_MULTICAST: |
169 | return BGP_IPV4M_NODE; | |
d62a17ae | 170 | case SAFI_LABELED_UNICAST: |
171 | return BGP_IPV4L_NODE; | |
d62a17ae | 172 | case SAFI_MPLS_VPN: |
173 | return BGP_VPNV4_NODE; | |
7c40bf39 | 174 | case SAFI_FLOWSPEC: |
175 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
176 | default: |
177 | /* not expected */ | |
178 | return BGP_IPV4_NODE; | |
d62a17ae | 179 | } |
180 | break; | |
181 | case AFI_IP6: | |
182 | switch (safi) { | |
183 | case SAFI_UNICAST: | |
184 | return BGP_IPV6_NODE; | |
d62a17ae | 185 | case SAFI_MULTICAST: |
186 | return BGP_IPV6M_NODE; | |
d62a17ae | 187 | case SAFI_LABELED_UNICAST: |
188 | return BGP_IPV6L_NODE; | |
d62a17ae | 189 | case SAFI_MPLS_VPN: |
190 | return BGP_VPNV6_NODE; | |
7c40bf39 | 191 | case SAFI_FLOWSPEC: |
192 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
193 | default: |
194 | /* not expected */ | |
195 | return BGP_IPV4_NODE; | |
d62a17ae | 196 | } |
197 | break; | |
198 | case AFI_L2VPN: | |
199 | return BGP_EVPN_NODE; | |
b26f891d | 200 | case AFI_UNSPEC: |
d62a17ae | 201 | case AFI_MAX: |
202 | // We should never be here but to clarify the switch statement.. | |
203 | return BGP_IPV4_NODE; | |
d62a17ae | 204 | } |
205 | ||
206 | // Impossible to happen | |
207 | return BGP_IPV4_NODE; | |
f51bae9c | 208 | } |
20eb8864 | 209 | |
5cb5f4d0 DD |
210 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
211 | { | |
212 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
213 | return "IPv4 Unicast"; | |
214 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
215 | return "IPv4 Multicast"; | |
216 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
217 | return "IPv4 Labeled Unicast"; | |
218 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
219 | return "IPv4 VPN"; | |
220 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
221 | return "IPv4 Encap"; | |
222 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
223 | return "IPv4 Flowspec"; | |
224 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
225 | return "IPv6 Unicast"; | |
226 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
227 | return "IPv6 Multicast"; | |
228 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
229 | return "IPv6 Labeled Unicast"; | |
230 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
231 | return "IPv6 VPN"; | |
232 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
233 | return "IPv6 Encap"; | |
234 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
235 | return "IPv6 Flowspec"; | |
236 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
237 | return "L2VPN EVPN"; | |
8e5509b0 | 238 | else |
5cb5f4d0 | 239 | return "Unknown"; |
5cb5f4d0 DD |
240 | } |
241 | ||
242 | /* | |
243 | * Please note that we have intentionally camelCased | |
244 | * the return strings here. So if you want | |
245 | * to use this function, please ensure you | |
246 | * are doing this within json output | |
247 | */ | |
248 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
249 | { | |
250 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
251 | return "ipv4Unicast"; | |
252 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
253 | return "ipv4Multicast"; | |
254 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
255 | return "ipv4LabeledUnicast"; | |
256 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
257 | return "ipv4Vpn"; | |
258 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
259 | return "ipv4Encap"; | |
260 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
261 | return "ipv4Flowspec"; | |
262 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
263 | return "ipv6Unicast"; | |
264 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
265 | return "ipv6Multicast"; | |
266 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
267 | return "ipv6LabeledUnicast"; | |
268 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
269 | return "ipv6Vpn"; | |
270 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
271 | return "ipv6Encap"; | |
272 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
273 | return "ipv6Flowspec"; | |
274 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
275 | return "l2VpnEvpn"; | |
8e5509b0 | 276 | else |
5cb5f4d0 | 277 | return "Unknown"; |
5cb5f4d0 DD |
278 | } |
279 | ||
37a87b8f CS |
280 | /* return string maps to afi-safi specific container names |
281 | * defined in bgp yang file. | |
282 | */ | |
283 | const char *bgp_afi_safi_get_container_str(afi_t afi, safi_t safi) | |
284 | { | |
285 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
286 | return "ipv4-unicast"; | |
287 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
288 | return "ipv4-multicast"; | |
289 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
290 | return "ipv4-labeled-unicast"; | |
291 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
292 | return "l3vpn-ipv4-unicast"; | |
293 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
294 | return "ipv4-flowspec"; | |
295 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
296 | return "ipv6-unicast"; | |
297 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
298 | return "ipv6-multicast"; | |
299 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
300 | return "ipv6-labeled-unicast"; | |
301 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
302 | return "l3vpn-ipv6-unicast"; | |
303 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
304 | return "ipv6-flowspec"; | |
305 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
306 | return "l2vpn-evpn"; | |
307 | else | |
308 | return "Unknown"; | |
309 | } | |
310 | ||
718e3744 | 311 | /* Utility function to get address family from current node. */ |
d62a17ae | 312 | afi_t bgp_node_afi(struct vty *vty) |
313 | { | |
314 | afi_t afi; | |
315 | switch (vty->node) { | |
316 | case BGP_IPV6_NODE: | |
317 | case BGP_IPV6M_NODE: | |
318 | case BGP_IPV6L_NODE: | |
319 | case BGP_VPNV6_NODE: | |
7c40bf39 | 320 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 321 | afi = AFI_IP6; |
322 | break; | |
323 | case BGP_EVPN_NODE: | |
324 | afi = AFI_L2VPN; | |
325 | break; | |
326 | default: | |
327 | afi = AFI_IP; | |
328 | break; | |
329 | } | |
330 | return afi; | |
718e3744 | 331 | } |
332 | ||
333 | /* Utility function to get subsequent address family from current | |
334 | node. */ | |
d62a17ae | 335 | safi_t bgp_node_safi(struct vty *vty) |
336 | { | |
337 | safi_t safi; | |
338 | switch (vty->node) { | |
339 | case BGP_VPNV4_NODE: | |
340 | case BGP_VPNV6_NODE: | |
341 | safi = SAFI_MPLS_VPN; | |
342 | break; | |
343 | case BGP_IPV4M_NODE: | |
344 | case BGP_IPV6M_NODE: | |
345 | safi = SAFI_MULTICAST; | |
346 | break; | |
347 | case BGP_EVPN_NODE: | |
348 | safi = SAFI_EVPN; | |
349 | break; | |
350 | case BGP_IPV4L_NODE: | |
351 | case BGP_IPV6L_NODE: | |
352 | safi = SAFI_LABELED_UNICAST; | |
353 | break; | |
7c40bf39 | 354 | case BGP_FLOWSPECV4_NODE: |
355 | case BGP_FLOWSPECV6_NODE: | |
356 | safi = SAFI_FLOWSPEC; | |
357 | break; | |
d62a17ae | 358 | default: |
359 | safi = SAFI_UNICAST; | |
360 | break; | |
361 | } | |
362 | return safi; | |
718e3744 | 363 | } |
364 | ||
55f91488 QY |
365 | /** |
366 | * Converts an AFI in string form to afi_t | |
367 | * | |
368 | * @param afi string, one of | |
369 | * - "ipv4" | |
370 | * - "ipv6" | |
81cf0de5 | 371 | * - "l2vpn" |
55f91488 QY |
372 | * @return the corresponding afi_t |
373 | */ | |
d62a17ae | 374 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
375 | { | |
376 | afi_t afi = AFI_MAX; /* unknown */ | |
377 | if (strmatch(afi_str, "ipv4")) | |
378 | afi = AFI_IP; | |
379 | else if (strmatch(afi_str, "ipv6")) | |
380 | afi = AFI_IP6; | |
81cf0de5 CS |
381 | else if (strmatch(afi_str, "l2vpn")) |
382 | afi = AFI_L2VPN; | |
d62a17ae | 383 | return afi; |
384 | } | |
385 | ||
386 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
387 | afi_t *afi) | |
388 | { | |
389 | int ret = 0; | |
390 | if (argv_find(argv, argc, "ipv4", index)) { | |
391 | ret = 1; | |
392 | if (afi) | |
393 | *afi = AFI_IP; | |
394 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
395 | ret = 1; | |
396 | if (afi) | |
397 | *afi = AFI_IP6; | |
8688b3e7 DS |
398 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
399 | ret = 1; | |
400 | if (afi) | |
401 | *afi = AFI_L2VPN; | |
d62a17ae | 402 | } |
403 | return ret; | |
46f296b4 LB |
404 | } |
405 | ||
375a2e67 | 406 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 407 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
408 | { | |
409 | safi_t safi = SAFI_MAX; /* unknown */ | |
410 | if (strmatch(safi_str, "multicast")) | |
411 | safi = SAFI_MULTICAST; | |
412 | else if (strmatch(safi_str, "unicast")) | |
413 | safi = SAFI_UNICAST; | |
414 | else if (strmatch(safi_str, "vpn")) | |
415 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
416 | else if (strmatch(safi_str, "evpn")) |
417 | safi = SAFI_EVPN; | |
d62a17ae | 418 | else if (strmatch(safi_str, "labeled-unicast")) |
419 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 420 | else if (strmatch(safi_str, "flowspec")) |
421 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 422 | return safi; |
423 | } | |
424 | ||
425 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
426 | safi_t *safi) | |
427 | { | |
428 | int ret = 0; | |
429 | if (argv_find(argv, argc, "unicast", index)) { | |
430 | ret = 1; | |
431 | if (safi) | |
432 | *safi = SAFI_UNICAST; | |
433 | } else if (argv_find(argv, argc, "multicast", index)) { | |
434 | ret = 1; | |
435 | if (safi) | |
436 | *safi = SAFI_MULTICAST; | |
437 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
438 | ret = 1; | |
439 | if (safi) | |
440 | *safi = SAFI_LABELED_UNICAST; | |
441 | } else if (argv_find(argv, argc, "vpn", index)) { | |
442 | ret = 1; | |
443 | if (safi) | |
444 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
445 | } else if (argv_find(argv, argc, "evpn", index)) { |
446 | ret = 1; | |
447 | if (safi) | |
448 | *safi = SAFI_EVPN; | |
7c40bf39 | 449 | } else if (argv_find(argv, argc, "flowspec", index)) { |
450 | ret = 1; | |
451 | if (safi) | |
452 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 453 | } |
454 | return ret; | |
46f296b4 LB |
455 | } |
456 | ||
5d5393b9 DL |
457 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
458 | enum bgp_instance_type inst_type) | |
459 | { | |
460 | int ret = bgp_get(bgp, as, name, inst_type); | |
461 | ||
462 | if (ret == BGP_CREATED) { | |
463 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
464 | DFLT_BGP_CONNECT_RETRY); | |
465 | ||
466 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 467 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 468 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 469 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
470 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
471 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 472 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 473 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 474 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 475 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
476 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
477 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
5d5393b9 DL |
478 | |
479 | ret = BGP_SUCCESS; | |
480 | } | |
481 | return ret; | |
482 | } | |
483 | ||
7eeee51e | 484 | /* |
f212a857 | 485 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 486 | * |
f212a857 DS |
487 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
488 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
489 | * to appropriate values for the calling function. This is to allow the |
490 | * calling function to make decisions appropriate for the show command | |
491 | * that is being parsed. | |
492 | * | |
493 | * The show commands are generally of the form: | |
d62a17ae | 494 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
495 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
496 | * |
497 | * Since we use argv_find if the show command in particular doesn't have: | |
498 | * [ip] | |
18c57037 | 499 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 500 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
501 | * The command parsing should still be ok. |
502 | * | |
503 | * vty -> The vty for the command so we can output some useful data in | |
504 | * the event of a parse error in the vrf. | |
505 | * argv -> The command tokens | |
506 | * argc -> How many command tokens we have | |
d62a17ae | 507 | * idx -> The current place in the command, generally should be 0 for this |
508 | * function | |
7eeee51e DS |
509 | * afi -> The parsed afi if it was included in the show command, returned here |
510 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 511 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 512 | * use_json -> json is configured or not |
7eeee51e DS |
513 | * |
514 | * The function returns the correct location in the parse tree for the | |
515 | * last token found. | |
0e37c258 DS |
516 | * |
517 | * Returns 0 for failure to parse correctly, else the idx position of where | |
518 | * it found the last token. | |
7eeee51e | 519 | */ |
d62a17ae | 520 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
521 | struct cmd_token **argv, int argc, | |
522 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 523 | struct bgp **bgp, bool use_json) |
d62a17ae | 524 | { |
525 | char *vrf_name = NULL; | |
526 | ||
527 | assert(afi); | |
528 | assert(safi); | |
529 | assert(bgp); | |
530 | ||
531 | if (argv_find(argv, argc, "ip", idx)) | |
532 | *afi = AFI_IP; | |
533 | ||
9a8bdf1c | 534 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 535 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
536 | else if (argv_find(argv, argc, "vrf", idx)) { |
537 | vrf_name = argv[*idx + 1]->arg; | |
538 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
539 | vrf_name = NULL; | |
540 | } | |
541 | if (vrf_name) { | |
d62a17ae | 542 | if (strmatch(vrf_name, "all")) |
543 | *bgp = NULL; | |
544 | else { | |
545 | *bgp = bgp_lookup_by_name(vrf_name); | |
546 | if (!*bgp) { | |
52e5b8c4 SP |
547 | if (use_json) { |
548 | json_object *json = NULL; | |
549 | json = json_object_new_object(); | |
550 | json_object_string_add( | |
551 | json, "warning", | |
552 | "View/Vrf is unknown"); | |
553 | vty_out(vty, "%s\n", | |
554 | json_object_to_json_string_ext(json, | |
555 | JSON_C_TO_STRING_PRETTY)); | |
556 | json_object_free(json); | |
557 | } | |
ca61fd25 DS |
558 | else |
559 | vty_out(vty, "View/Vrf %s is unknown\n", | |
560 | vrf_name); | |
d62a17ae | 561 | *idx = 0; |
562 | return 0; | |
563 | } | |
564 | } | |
565 | } else { | |
566 | *bgp = bgp_get_default(); | |
567 | if (!*bgp) { | |
52e5b8c4 SP |
568 | if (use_json) { |
569 | json_object *json = NULL; | |
570 | json = json_object_new_object(); | |
571 | json_object_string_add( | |
572 | json, "warning", | |
573 | "Default BGP instance not found"); | |
574 | vty_out(vty, "%s\n", | |
575 | json_object_to_json_string_ext(json, | |
576 | JSON_C_TO_STRING_PRETTY)); | |
577 | json_object_free(json); | |
578 | } | |
ca61fd25 DS |
579 | else |
580 | vty_out(vty, | |
581 | "Default BGP instance not found\n"); | |
d62a17ae | 582 | *idx = 0; |
583 | return 0; | |
584 | } | |
585 | } | |
586 | ||
587 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
588 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
589 | ||
590 | *idx += 1; | |
591 | return *idx; | |
592 | } | |
593 | ||
f4b8ec07 | 594 | bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 595 | { |
596 | struct interface *ifp = NULL; | |
597 | ||
598 | if (su->sa.sa_family == AF_INET) | |
599 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
600 | else if (su->sa.sa_family == AF_INET6) | |
601 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
602 | su->sin6.sin6_scope_id, | |
603 | bgp->vrf_id); | |
604 | ||
605 | if (ifp) | |
3dc339cd | 606 | return true; |
d62a17ae | 607 | |
3dc339cd | 608 | return false; |
718e3744 | 609 | } |
610 | ||
718e3744 | 611 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
612 | /* This is used only for configuration, so disallow if attempted on |
613 | * a dynamic neighbor. | |
614 | */ | |
d62a17ae | 615 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
616 | { | |
617 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
618 | int ret; | |
619 | union sockunion su; | |
620 | struct peer *peer = NULL; | |
621 | struct peer_group *group = NULL; | |
622 | ||
623 | if (!bgp) { | |
624 | return NULL; | |
625 | } | |
626 | ||
627 | ret = str2sockunion(peer_str, &su); | |
628 | if (ret == 0) { | |
629 | /* IP address, locate peer. */ | |
630 | peer = peer_lookup(bgp, &su); | |
631 | } else { | |
632 | /* Not IP, could match either peer configured on interface or a | |
633 | * group. */ | |
634 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
635 | if (!peer) | |
636 | group = peer_group_lookup(bgp, peer_str); | |
637 | } | |
638 | ||
639 | if (peer) { | |
640 | if (peer_dynamic_neighbor(peer)) { | |
641 | vty_out(vty, | |
642 | "%% Operation not allowed on a dynamic neighbor\n"); | |
643 | return NULL; | |
644 | } | |
645 | ||
646 | return peer; | |
647 | } | |
648 | ||
649 | if (group) | |
650 | return group->conf; | |
651 | ||
652 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
653 | ||
654 | return NULL; | |
655 | } | |
656 | ||
f4b8ec07 CS |
657 | int bgp_nb_errmsg_return(char *errmsg, size_t errmsg_len, int ret) |
658 | { | |
659 | const char *str = NULL; | |
660 | ||
661 | switch (ret) { | |
662 | case BGP_ERR_INVALID_VALUE: | |
663 | str = "Invalid value"; | |
664 | break; | |
665 | case BGP_ERR_INVALID_FLAG: | |
666 | str = "Invalid flag"; | |
667 | break; | |
668 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
669 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
670 | break; | |
671 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
672 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
673 | break; | |
674 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
675 | str = "Specify remote-as or peer-group remote AS first"; | |
676 | break; | |
677 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
678 | str = "Cannot change the peer-group. Deconfigure first"; | |
679 | break; | |
680 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
681 | str = "Peer is not a member of this peer-group"; | |
682 | break; | |
683 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
684 | str = "Prefix/distribute list can not co-exist"; | |
685 | break; | |
686 | case BGP_ERR_NOT_INTERNAL_PEER: | |
687 | str = "Invalid command. Not an internal neighbor"; | |
688 | break; | |
689 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
690 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
691 | break; | |
692 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
693 | str = "Local-AS allowed only for EBGP peers"; | |
694 | break; | |
695 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
696 | str = "Cannot have local-as same as BGP AS number"; | |
697 | break; | |
698 | case BGP_ERR_TCPSIG_FAILED: | |
699 | str = "Error while applying TCP-Sig to session(s)"; | |
700 | break; | |
701 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
702 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
703 | break; | |
704 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
705 | str = "ttl-security only allowed for EBGP peers"; | |
706 | break; | |
707 | case BGP_ERR_AS_OVERRIDE: | |
708 | str = "as-override cannot be configured for IBGP peers"; | |
709 | break; | |
710 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
711 | str = "Invalid limit for number of dynamic neighbors"; | |
712 | break; | |
713 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
714 | str = "Dynamic neighbor listen range already exists"; | |
715 | break; | |
716 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
717 | str = "Operation not allowed on a dynamic neighbor"; | |
718 | break; | |
719 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
720 | str = "Operation not allowed on a directly connected neighbor"; | |
721 | break; | |
722 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
723 | str = GR_INVALID; | |
724 | break; | |
725 | case BGP_ERR_GR_INVALID_CMD: | |
726 | str = "The Graceful Restart command used is not valid at this moment."; | |
727 | break; | |
728 | case BGP_ERR_GR_OPERATION_FAILED: | |
729 | str = "The Graceful Restart Operation failed due to an err."; | |
730 | break; | |
731 | case BGP_GR_NO_OPERATION: | |
732 | str = GR_NO_OPER; | |
733 | break; | |
734 | case BGP_ERR_PEER_GROUP_MEMBER: | |
735 | str = "Peer-group member cannot override remote-as of peer-group"; | |
736 | break; | |
737 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
738 | str = "Peer-group members must be all internal or all external"; | |
739 | break; | |
740 | } | |
741 | if (str) { | |
742 | snprintf(errmsg, errmsg_len, "%s", str); | |
743 | return -1; | |
744 | } | |
745 | ||
746 | return 0; | |
747 | } | |
748 | ||
d62a17ae | 749 | int bgp_vty_return(struct vty *vty, int ret) |
750 | { | |
751 | const char *str = NULL; | |
752 | ||
753 | switch (ret) { | |
754 | case BGP_ERR_INVALID_VALUE: | |
755 | str = "Invalid value"; | |
756 | break; | |
757 | case BGP_ERR_INVALID_FLAG: | |
758 | str = "Invalid flag"; | |
759 | break; | |
760 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
761 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
762 | break; | |
763 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
764 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
765 | break; | |
766 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
767 | str = "Specify remote-as or peer-group remote AS first"; | |
768 | break; | |
769 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
770 | str = "Cannot change the peer-group. Deconfigure first"; | |
771 | break; | |
772 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
773 | str = "Peer is not a member of this peer-group"; | |
774 | break; | |
775 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
776 | str = "Prefix/distribute list can not co-exist"; | |
777 | break; | |
778 | case BGP_ERR_NOT_INTERNAL_PEER: | |
779 | str = "Invalid command. Not an internal neighbor"; | |
780 | break; | |
781 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
782 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
783 | break; | |
784 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
785 | str = "Local-AS allowed only for EBGP peers"; | |
786 | break; | |
787 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
788 | str = "Cannot have local-as same as BGP AS number"; | |
789 | break; | |
790 | case BGP_ERR_TCPSIG_FAILED: | |
791 | str = "Error while applying TCP-Sig to session(s)"; | |
792 | break; | |
793 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
794 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
795 | break; | |
796 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
797 | str = "ttl-security only allowed for EBGP peers"; | |
798 | break; | |
799 | case BGP_ERR_AS_OVERRIDE: | |
800 | str = "as-override cannot be configured for IBGP peers"; | |
801 | break; | |
802 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
803 | str = "Invalid limit for number of dynamic neighbors"; | |
804 | break; | |
805 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
806 | str = "Dynamic neighbor listen range already exists"; | |
807 | break; | |
808 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
809 | str = "Operation not allowed on a dynamic neighbor"; | |
810 | break; | |
811 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
812 | str = "Operation not allowed on a directly connected neighbor"; | |
813 | break; | |
814 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 815 | str = GR_INVALID; |
816 | break; | |
817 | case BGP_ERR_GR_INVALID_CMD: | |
818 | str = "The Graceful Restart command used is not valid at this moment."; | |
819 | break; | |
820 | case BGP_ERR_GR_OPERATION_FAILED: | |
821 | str = "The Graceful Restart Operation failed due to an err."; | |
822 | break; | |
823 | case BGP_GR_NO_OPERATION: | |
824 | str = GR_NO_OPER; | |
d62a17ae | 825 | break; |
826 | } | |
827 | if (str) { | |
828 | vty_out(vty, "%% %s\n", str); | |
829 | return CMD_WARNING_CONFIG_FAILED; | |
830 | } | |
831 | return CMD_SUCCESS; | |
718e3744 | 832 | } |
833 | ||
7aafcaca | 834 | /* BGP clear sort. */ |
d62a17ae | 835 | enum clear_sort { |
836 | clear_all, | |
837 | clear_peer, | |
838 | clear_group, | |
839 | clear_external, | |
840 | clear_as | |
7aafcaca DS |
841 | }; |
842 | ||
ff8a8a7a CS |
843 | static void bgp_clear_vty_error(struct peer *peer, afi_t afi, safi_t safi, |
844 | int error, char *errmsg, size_t errmsg_len) | |
d62a17ae | 845 | { |
846 | switch (error) { | |
847 | case BGP_ERR_AF_UNCONFIGURED: | |
ff8a8a7a CS |
848 | snprintf(errmsg, errmsg_len, |
849 | "%%BGP: Enable %s address family for the neighbor %s", | |
850 | get_afi_safi_str(afi, safi, false), peer->host); | |
d62a17ae | 851 | break; |
852 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
ff8a8a7a CS |
853 | snprintf( |
854 | errmsg, errmsg_len, | |
855 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig", | |
d62a17ae | 856 | peer->host); |
857 | break; | |
858 | default: | |
859 | break; | |
860 | } | |
7aafcaca DS |
861 | } |
862 | ||
dc912615 | 863 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 864 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
865 | { |
866 | int ret = 0; | |
867 | ||
868 | /* if afi/.safi not specified, spin thru all of them */ | |
869 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
870 | afi_t tmp_afi; | |
871 | safi_t tmp_safi; | |
872 | ||
873 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
874 | if (!peer->afc[tmp_afi][tmp_safi]) | |
875 | continue; | |
876 | ||
877 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 878 | ret = peer_clear(peer, nnode); |
dc912615 DS |
879 | else |
880 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
881 | stype); | |
882 | } | |
883 | /* if afi specified and safi not, spin thru safis on this afi */ | |
884 | } else if (safi == SAFI_UNSPEC) { | |
885 | safi_t tmp_safi; | |
886 | ||
887 | for (tmp_safi = SAFI_UNICAST; | |
888 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
889 | if (!peer->afc[afi][tmp_safi]) | |
890 | continue; | |
891 | ||
892 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 893 | ret = peer_clear(peer, nnode); |
dc912615 DS |
894 | else |
895 | ret = peer_clear_soft(peer, afi, | |
896 | tmp_safi, stype); | |
897 | } | |
898 | /* both afi/safi specified, let the caller know if not defined */ | |
899 | } else { | |
900 | if (!peer->afc[afi][safi]) | |
901 | return 1; | |
902 | ||
903 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 904 | ret = peer_clear(peer, nnode); |
dc912615 DS |
905 | else |
906 | ret = peer_clear_soft(peer, afi, safi, stype); | |
907 | } | |
908 | ||
909 | return ret; | |
910 | } | |
911 | ||
7aafcaca | 912 | /* `clear ip bgp' functions. */ |
ff8a8a7a | 913 | static int bgp_clear(struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 914 | enum clear_sort sort, enum bgp_clear_type stype, |
ff8a8a7a | 915 | const char *arg, char *errmsg, size_t errmsg_len) |
d62a17ae | 916 | { |
dc912615 | 917 | int ret = 0; |
3ae8bfa5 | 918 | bool found = false; |
d62a17ae | 919 | struct peer *peer; |
dc95985f | 920 | |
921 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 922 | |
923 | /* Clear all neighbors. */ | |
924 | /* | |
925 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
926 | * nodes on the BGP instance as that may get freed if it is a |
927 | * doppelganger | |
d62a17ae | 928 | */ |
929 | if (sort == clear_all) { | |
930 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 931 | |
932 | bgp_peer_gr_flags_update(peer); | |
933 | ||
36235319 | 934 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 935 | gr_router_detected = true; |
936 | ||
c368171c | 937 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 938 | stype); |
d62a17ae | 939 | |
940 | if (ret < 0) | |
ff8a8a7a CS |
941 | bgp_clear_vty_error(peer, afi, safi, ret, |
942 | errmsg, errmsg_len); | |
dc95985f | 943 | } |
944 | ||
36235319 QY |
945 | if (gr_router_detected |
946 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 947 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
948 | } else if (!gr_router_detected |
949 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 950 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 951 | } |
d62a17ae | 952 | |
953 | /* This is to apply read-only mode on this clear. */ | |
954 | if (stype == BGP_CLEAR_SOFT_NONE) | |
955 | bgp->update_delay_over = 0; | |
956 | ||
957 | return CMD_SUCCESS; | |
7aafcaca DS |
958 | } |
959 | ||
3ae8bfa5 | 960 | /* Clear specified neighbor. */ |
d62a17ae | 961 | if (sort == clear_peer) { |
962 | union sockunion su; | |
d62a17ae | 963 | |
964 | /* Make sockunion for lookup. */ | |
965 | ret = str2sockunion(arg, &su); | |
966 | if (ret < 0) { | |
967 | peer = peer_lookup_by_conf_if(bgp, arg); | |
968 | if (!peer) { | |
969 | peer = peer_lookup_by_hostname(bgp, arg); | |
970 | if (!peer) { | |
ff8a8a7a CS |
971 | snprintf( |
972 | errmsg, errmsg_len, | |
973 | "Malformed address or name: %s", | |
d62a17ae | 974 | arg); |
975 | return CMD_WARNING; | |
976 | } | |
977 | } | |
978 | } else { | |
979 | peer = peer_lookup(bgp, &su); | |
980 | if (!peer) { | |
ff8a8a7a CS |
981 | snprintf(errmsg, errmsg_len, |
982 | "%%BGP: Unknown neighbor - \"%s\"", | |
983 | arg); | |
d62a17ae | 984 | return CMD_WARNING; |
985 | } | |
986 | } | |
7aafcaca | 987 | |
dc95985f | 988 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
989 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
990 | ||
dc912615 DS |
991 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
992 | ||
993 | /* if afi/safi not defined for this peer, let caller know */ | |
994 | if (ret == 1) | |
3ae8bfa5 | 995 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 996 | |
d62a17ae | 997 | if (ret < 0) |
ff8a8a7a CS |
998 | bgp_clear_vty_error(peer, afi, safi, ret, errmsg, |
999 | errmsg_len); | |
7aafcaca | 1000 | |
d62a17ae | 1001 | return CMD_SUCCESS; |
7aafcaca | 1002 | } |
7aafcaca | 1003 | |
3ae8bfa5 | 1004 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1005 | if (sort == clear_group) { |
1006 | struct peer_group *group; | |
7aafcaca | 1007 | |
d62a17ae | 1008 | group = peer_group_lookup(bgp, arg); |
1009 | if (!group) { | |
ff8a8a7a CS |
1010 | snprintf(errmsg, errmsg_len, |
1011 | "%%BGP: No such peer-group %s", arg); | |
d62a17ae | 1012 | return CMD_WARNING; |
1013 | } | |
1014 | ||
1015 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1016 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1017 | |
d62a17ae | 1018 | if (ret < 0) |
ff8a8a7a CS |
1019 | bgp_clear_vty_error(peer, afi, safi, ret, |
1020 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1021 | else |
1022 | found = true; | |
d62a17ae | 1023 | } |
3ae8bfa5 PM |
1024 | |
1025 | if (!found) | |
ff8a8a7a CS |
1026 | snprintf( |
1027 | errmsg, errmsg_len, | |
1028 | "%%BGP: No %s peer belonging to peer-group %s is configured", | |
5cb5f4d0 | 1029 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1030 | |
d62a17ae | 1031 | return CMD_SUCCESS; |
7aafcaca | 1032 | } |
7aafcaca | 1033 | |
3ae8bfa5 | 1034 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1035 | if (sort == clear_external) { |
1036 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1037 | if (peer->sort == BGP_PEER_IBGP) | |
1038 | continue; | |
7aafcaca | 1039 | |
dc95985f | 1040 | bgp_peer_gr_flags_update(peer); |
1041 | ||
36235319 | 1042 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1043 | gr_router_detected = true; |
dc95985f | 1044 | |
c368171c | 1045 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1046 | |
d62a17ae | 1047 | if (ret < 0) |
ff8a8a7a CS |
1048 | bgp_clear_vty_error(peer, afi, safi, ret, |
1049 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1050 | else |
1051 | found = true; | |
d62a17ae | 1052 | } |
3ae8bfa5 | 1053 | |
36235319 QY |
1054 | if (gr_router_detected |
1055 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1056 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1057 | } else if (!gr_router_detected |
1058 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1059 | bgp_zebra_send_capabilities(bgp, true); |
1060 | } | |
1061 | ||
3ae8bfa5 | 1062 | if (!found) |
ff8a8a7a CS |
1063 | snprintf(errmsg, errmsg_len, |
1064 | "%%BGP: No external %s peer is configured", | |
1065 | get_afi_safi_str(afi, safi, false)); | |
3ae8bfa5 | 1066 | |
d62a17ae | 1067 | return CMD_SUCCESS; |
1068 | } | |
1069 | ||
3ae8bfa5 | 1070 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1071 | if (sort == clear_as) { |
3ae8bfa5 | 1072 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 1073 | |
1074 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1075 | if (peer->as != as) | |
1076 | continue; | |
1077 | ||
dc95985f | 1078 | bgp_peer_gr_flags_update(peer); |
1079 | ||
36235319 | 1080 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1081 | gr_router_detected = true; |
dc95985f | 1082 | |
c368171c | 1083 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1084 | |
1085 | if (ret < 0) | |
ff8a8a7a CS |
1086 | bgp_clear_vty_error(peer, afi, safi, ret, |
1087 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1088 | else |
1089 | found = true; | |
d62a17ae | 1090 | } |
3ae8bfa5 | 1091 | |
36235319 QY |
1092 | if (gr_router_detected |
1093 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1094 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1095 | } else if (!gr_router_detected |
1096 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1097 | bgp_zebra_send_capabilities(bgp, true); |
1098 | } | |
1099 | ||
3ae8bfa5 | 1100 | if (!found) |
ff8a8a7a CS |
1101 | snprintf(errmsg, errmsg_len, |
1102 | "%%BGP: No %s peer is configured with AS %s", | |
1103 | get_afi_safi_str(afi, safi, false), arg); | |
3ae8bfa5 | 1104 | |
d62a17ae | 1105 | return CMD_SUCCESS; |
1106 | } | |
1107 | ||
1108 | return CMD_SUCCESS; | |
1109 | } | |
1110 | ||
ff8a8a7a CS |
1111 | static int bgp_clear_vty(const char *name, afi_t afi, safi_t safi, |
1112 | enum clear_sort sort, enum bgp_clear_type stype, | |
1113 | const char *arg, char *errmsg, size_t errmsg_len) | |
d62a17ae | 1114 | { |
1115 | struct bgp *bgp; | |
1116 | ||
1117 | /* BGP structure lookup. */ | |
1118 | if (name) { | |
1119 | bgp = bgp_lookup_by_name(name); | |
1120 | if (bgp == NULL) { | |
ff8a8a7a CS |
1121 | snprintf(errmsg, errmsg_len, |
1122 | "Can't find BGP instance %s", name); | |
d62a17ae | 1123 | return CMD_WARNING; |
1124 | } | |
1125 | } else { | |
1126 | bgp = bgp_get_default(); | |
1127 | if (bgp == NULL) { | |
ff8a8a7a CS |
1128 | snprintf(errmsg, errmsg_len, |
1129 | "No BGP process is configured"); | |
d62a17ae | 1130 | return CMD_WARNING; |
1131 | } | |
1132 | } | |
1133 | ||
ff8a8a7a | 1134 | return bgp_clear(bgp, afi, safi, sort, stype, arg, errmsg, errmsg_len); |
7aafcaca DS |
1135 | } |
1136 | ||
1137 | /* clear soft inbound */ | |
ff8a8a7a | 1138 | int bgp_clear_star_soft_in(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1139 | { |
99b3ebd3 NS |
1140 | afi_t afi; |
1141 | safi_t safi; | |
ff8a8a7a CS |
1142 | int ret; |
1143 | ||
1144 | FOREACH_AFI_SAFI (afi, safi) { | |
1145 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1146 | BGP_CLEAR_SOFT_IN, NULL, errmsg, | |
1147 | errmsg_len); | |
1148 | if (ret != CMD_SUCCESS) | |
1149 | return -1; | |
1150 | } | |
99b3ebd3 | 1151 | |
ff8a8a7a | 1152 | return 0; |
7aafcaca DS |
1153 | } |
1154 | ||
1155 | /* clear soft outbound */ | |
ff8a8a7a | 1156 | int bgp_clear_star_soft_out(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1157 | { |
99b3ebd3 NS |
1158 | afi_t afi; |
1159 | safi_t safi; | |
ff8a8a7a | 1160 | int ret; |
99b3ebd3 | 1161 | |
ff8a8a7a CS |
1162 | FOREACH_AFI_SAFI (afi, safi) { |
1163 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1164 | BGP_CLEAR_SOFT_OUT, NULL, errmsg, | |
1165 | errmsg_len); | |
1166 | if (ret != CMD_SUCCESS) | |
1167 | return -1; | |
1168 | } | |
1169 | ||
1170 | return 0; | |
7aafcaca DS |
1171 | } |
1172 | ||
1173 | ||
f787d7a0 | 1174 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1175 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1176 | #endif |
1177 | ||
8029b216 AK |
1178 | DEFUN_HIDDEN (bgp_local_mac, |
1179 | bgp_local_mac_cmd, | |
093e3f23 | 1180 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1181 | BGP_STR |
1182 | "Local MAC config\n" | |
1183 | "VxLAN Network Identifier\n" | |
1184 | "VNI number\n" | |
1185 | "local mac\n" | |
1186 | "mac address\n" | |
1187 | "mac-mobility sequence\n" | |
1188 | "seq number\n") | |
1189 | { | |
1190 | int rv; | |
1191 | vni_t vni; | |
1192 | struct ethaddr mac; | |
1193 | struct ipaddr ip; | |
1194 | uint32_t seq; | |
1195 | struct bgp *bgp; | |
1196 | ||
1197 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1198 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1199 | vty_out(vty, "%% Malformed MAC address\n"); | |
1200 | return CMD_WARNING; | |
1201 | } | |
1202 | memset(&ip, 0, sizeof(ip)); | |
1203 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1204 | ||
1205 | bgp = bgp_get_default(); | |
1206 | if (!bgp) { | |
1207 | vty_out(vty, "Default BGP instance is not there\n"); | |
1208 | return CMD_WARNING; | |
1209 | } | |
1210 | ||
b5e140c8 AK |
1211 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1212 | zero_esi); | |
8029b216 AK |
1213 | if (rv < 0) { |
1214 | vty_out(vty, "Internal error\n"); | |
1215 | return CMD_WARNING; | |
1216 | } | |
1217 | ||
1218 | return CMD_SUCCESS; | |
1219 | } | |
1220 | ||
1221 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1222 | no_bgp_local_mac_cmd, | |
093e3f23 | 1223 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1224 | NO_STR |
1225 | BGP_STR | |
1226 | "Local MAC config\n" | |
1227 | "VxLAN Network Identifier\n" | |
1228 | "VNI number\n" | |
1229 | "local mac\n" | |
1230 | "mac address\n") | |
1231 | { | |
1232 | int rv; | |
1233 | vni_t vni; | |
1234 | struct ethaddr mac; | |
1235 | struct ipaddr ip; | |
1236 | struct bgp *bgp; | |
1237 | ||
1238 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1239 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1240 | vty_out(vty, "%% Malformed MAC address\n"); | |
1241 | return CMD_WARNING; | |
1242 | } | |
1243 | memset(&ip, 0, sizeof(ip)); | |
1244 | ||
1245 | bgp = bgp_get_default(); | |
1246 | if (!bgp) { | |
1247 | vty_out(vty, "Default BGP instance is not there\n"); | |
1248 | return CMD_WARNING; | |
1249 | } | |
1250 | ||
ec0ab544 | 1251 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1252 | if (rv < 0) { |
1253 | vty_out(vty, "Internal error\n"); | |
1254 | return CMD_WARNING; | |
1255 | } | |
1256 | ||
1257 | return CMD_SUCCESS; | |
1258 | } | |
1259 | ||
718e3744 | 1260 | DEFUN (no_synchronization, |
1261 | no_synchronization_cmd, | |
1262 | "no synchronization", | |
1263 | NO_STR | |
1264 | "Perform IGP synchronization\n") | |
1265 | { | |
d62a17ae | 1266 | return CMD_SUCCESS; |
718e3744 | 1267 | } |
1268 | ||
1269 | DEFUN (no_auto_summary, | |
1270 | no_auto_summary_cmd, | |
1271 | "no auto-summary", | |
1272 | NO_STR | |
1273 | "Enable automatic network number summarization\n") | |
1274 | { | |
d62a17ae | 1275 | return CMD_SUCCESS; |
718e3744 | 1276 | } |
3d515fd9 | 1277 | |
718e3744 | 1278 | /* "router bgp" commands. */ |
ff8a8a7a CS |
1279 | DEFUN_YANG_NOSH(router_bgp, |
1280 | router_bgp_cmd, | |
1281 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1282 | ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1283 | { |
d62a17ae | 1284 | int idx_asn = 2; |
1285 | int idx_view_vrf = 3; | |
1286 | int idx_vrf = 4; | |
ff8a8a7a | 1287 | int ret = CMD_SUCCESS; |
d62a17ae | 1288 | as_t as; |
1289 | struct bgp *bgp; | |
1290 | const char *name = NULL; | |
ff8a8a7a | 1291 | char as_str[12] = {'\0'}; |
d62a17ae | 1292 | enum bgp_instance_type inst_type; |
ff8a8a7a | 1293 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 1294 | |
1295 | // "router bgp" without an ASN | |
1296 | if (argc == 2) { | |
1297 | // Pending: Make VRF option available for ASN less config | |
1298 | bgp = bgp_get_default(); | |
1299 | ||
1300 | if (bgp == NULL) { | |
1301 | vty_out(vty, "%% No BGP process is configured\n"); | |
1302 | return CMD_WARNING_CONFIG_FAILED; | |
1303 | } | |
1304 | ||
1305 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1306 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1307 | return CMD_WARNING_CONFIG_FAILED; |
1308 | } | |
ff8a8a7a CS |
1309 | |
1310 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, | |
5ce106b7 | 1311 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); |
ff8a8a7a CS |
1312 | |
1313 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
1314 | snprintf(as_str, 12, "%d", bgp->as); | |
87ce2564 CS |
1315 | nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY, |
1316 | as_str); | |
ff8a8a7a | 1317 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) { |
87ce2564 CS |
1318 | nb_cli_enqueue_change(vty, |
1319 | "./global/instance-type-view", | |
ff8a8a7a CS |
1320 | NB_OP_MODIFY, "true"); |
1321 | } | |
1322 | ||
a5ab756f | 1323 | nb_cli_pending_commit_check(vty); |
ff8a8a7a CS |
1324 | ret = nb_cli_apply_changes(vty, base_xpath); |
1325 | if (ret == CMD_SUCCESS) { | |
1326 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); | |
1327 | ||
1328 | /* | |
1329 | * For backward compatibility with old commands we still | |
1330 | * need to use the qobj infrastructure. | |
1331 | */ | |
1332 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1333 | } | |
1334 | return ret; | |
d62a17ae | 1335 | } |
1336 | ||
1337 | // "router bgp X" | |
1338 | else { | |
d62a17ae | 1339 | |
ff8a8a7a | 1340 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
d62a17ae | 1341 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1342 | if (argc > 3) { | |
1343 | name = argv[idx_vrf]->arg; | |
1344 | ||
9a8bdf1c PG |
1345 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1346 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1347 | name = NULL; | |
1348 | else | |
1349 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
ff8a8a7a | 1350 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) { |
d62a17ae | 1351 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
ff8a8a7a | 1352 | } |
d62a17ae | 1353 | } |
ff8a8a7a CS |
1354 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1355 | "frr-bgp:bgp", "bgp", name ? name : VRF_DEFAULT_NAME); | |
1356 | ||
1357 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
87ce2564 | 1358 | nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY, |
ff8a8a7a CS |
1359 | argv[idx_asn]->arg); |
1360 | if (inst_type == BGP_INSTANCE_TYPE_VIEW) { | |
87ce2564 CS |
1361 | nb_cli_enqueue_change(vty, |
1362 | "./global/instance-type-view", | |
ff8a8a7a | 1363 | NB_OP_MODIFY, "true"); |
d62a17ae | 1364 | } |
1365 | ||
ff8a8a7a CS |
1366 | nb_cli_pending_commit_check(vty); |
1367 | ret = nb_cli_apply_changes(vty, base_xpath); | |
1368 | if (ret == CMD_SUCCESS) { | |
1369 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); | |
3bd70bf8 | 1370 | |
ff8a8a7a CS |
1371 | /* |
1372 | * For backward compatibility with old commands we still | |
1373 | * need to use the qobj infrastructure. | |
1374 | */ | |
1375 | bgp = bgp_lookup(as, name); | |
1376 | if (bgp) | |
1377 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1378 | } | |
d62a17ae | 1379 | } |
1380 | ||
ff8a8a7a | 1381 | return ret; |
718e3744 | 1382 | } |
1383 | ||
718e3744 | 1384 | /* "no router bgp" commands. */ |
ff8a8a7a CS |
1385 | DEFUN_YANG(no_router_bgp, |
1386 | no_router_bgp_cmd, | |
1387 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1388 | NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1389 | { |
d62a17ae | 1390 | int idx_asn = 3; |
1391 | int idx_vrf = 5; | |
ff8a8a7a | 1392 | as_t as = 0; |
d62a17ae | 1393 | struct bgp *bgp; |
1394 | const char *name = NULL; | |
ff8a8a7a | 1395 | char base_xpath[XPATH_MAXLEN]; |
4b63e358 | 1396 | const struct lyd_node *bgp_glb_dnode; |
718e3744 | 1397 | |
d62a17ae | 1398 | // "no router bgp" without an ASN |
1399 | if (argc == 3) { | |
1400 | // Pending: Make VRF option available for ASN less config | |
4b63e358 CS |
1401 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1402 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); | |
718e3744 | 1403 | |
4b63e358 CS |
1404 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, |
1405 | base_xpath); | |
1406 | if (!bgp_glb_dnode) { | |
d62a17ae | 1407 | vty_out(vty, "%% No BGP process is configured\n"); |
1408 | return CMD_WARNING_CONFIG_FAILED; | |
1409 | } | |
7fb21a9f | 1410 | |
d62a17ae | 1411 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1412 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1413 | return CMD_WARNING_CONFIG_FAILED; |
1414 | } | |
0b5131c9 | 1415 | |
4b63e358 CS |
1416 | /* tcli mode bgp would not be set until apply stage. */ |
1417 | bgp = nb_running_get_entry(bgp_glb_dnode, NULL, false); | |
1418 | if (!bgp) | |
1419 | return CMD_SUCCESS; | |
1420 | ||
0b5131c9 MK |
1421 | if (bgp->l3vni) { |
1422 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1423 | bgp->l3vni); | |
1424 | return CMD_WARNING_CONFIG_FAILED; | |
1425 | } | |
d62a17ae | 1426 | } else { |
1427 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1428 | |
d62a17ae | 1429 | if (argc > 4) |
1430 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1431 | |
d62a17ae | 1432 | /* Lookup bgp structure. */ |
1433 | bgp = bgp_lookup(as, name); | |
1434 | if (!bgp) { | |
1435 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1436 | return CMD_WARNING_CONFIG_FAILED; | |
1437 | } | |
0b5131c9 MK |
1438 | |
1439 | if (bgp->l3vni) { | |
dd5868c2 | 1440 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1441 | bgp->l3vni); |
1442 | return CMD_WARNING_CONFIG_FAILED; | |
1443 | } | |
dd5868c2 DS |
1444 | |
1445 | /* Cannot delete default instance if vrf instances exist */ | |
1446 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1447 | struct listnode *node; | |
1448 | struct bgp *tmp_bgp; | |
1449 | ||
1450 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1451 | if (tmp_bgp->inst_type | |
1452 | == BGP_INSTANCE_TYPE_VRF) { | |
1453 | vty_out(vty, | |
1454 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1455 | return CMD_WARNING_CONFIG_FAILED; | |
1456 | } | |
1457 | } | |
1458 | } | |
d62a17ae | 1459 | } |
ff8a8a7a CS |
1460 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1461 | "frr-bgp:bgp", "bgp", | |
1462 | bgp->name ? bgp->name : VRF_DEFAULT_NAME); | |
718e3744 | 1463 | |
ff8a8a7a | 1464 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); |
718e3744 | 1465 | |
ff8a8a7a | 1466 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 1467 | } |
1468 | ||
ff8a8a7a CS |
1469 | void cli_show_router_bgp(struct vty *vty, struct lyd_node *dnode, |
1470 | bool show_defaults) | |
1471 | { | |
1472 | const struct lyd_node *vrf_dnode; | |
1473 | const char *vrf_name; | |
1474 | as_t as; | |
6b0655a2 | 1475 | |
ff8a8a7a CS |
1476 | vrf_dnode = yang_dnode_get_parent(dnode, "control-plane-protocol"); |
1477 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
5e42cb2f | 1478 | as = yang_dnode_get_uint32(dnode, "./global/local-as"); |
718e3744 | 1479 | |
ff8a8a7a CS |
1480 | vty_out(vty, "!\n"); |
1481 | vty_out(vty, "router bgp %u", as); | |
1482 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
1483 | vty_out(vty, " vrf %s", vrf_name); | |
1484 | vty_out(vty, "\n"); | |
718e3744 | 1485 | } |
1486 | ||
ff8a8a7a CS |
1487 | /* BGP router-id. */ |
1488 | ||
1489 | DEFPY_YANG(bgp_router_id, bgp_router_id_cmd, "bgp router-id A.B.C.D", | |
1490 | BGP_STR | |
1491 | "Override configured router identifier\n" | |
1492 | "Manually configured router identifier\n") | |
718e3744 | 1493 | { |
87ce2564 CS |
1494 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_MODIFY, |
1495 | router_id_str); | |
718e3744 | 1496 | |
ff8a8a7a CS |
1497 | return nb_cli_apply_changes(vty, NULL); |
1498 | } | |
718e3744 | 1499 | |
ff8a8a7a CS |
1500 | DEFPY_YANG(no_bgp_router_id, no_bgp_router_id_cmd, "no bgp router-id [A.B.C.D]", |
1501 | NO_STR BGP_STR | |
1502 | "Override configured router identifier\n" | |
1503 | "Manually configured router identifier\n") | |
1504 | { | |
87ce2564 | 1505 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_DESTROY, |
ff8a8a7a | 1506 | router_id_str ? router_id_str : NULL); |
718e3744 | 1507 | |
ff8a8a7a | 1508 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1509 | } |
1510 | ||
ff8a8a7a CS |
1511 | void cli_show_router_bgp_router_id(struct vty *vty, struct lyd_node *dnode, |
1512 | bool show_defaults) | |
1513 | { | |
1514 | vty_out(vty, " bgp router-id %s\n", yang_dnode_get_string(dnode, NULL)); | |
1515 | } | |
6b0655a2 | 1516 | |
c208c586 S |
1517 | DEFPY (bgp_suppress_fib_pending, |
1518 | bgp_suppress_fib_pending_cmd, | |
1519 | "[no] bgp suppress-fib-pending", | |
1520 | NO_STR | |
1521 | BGP_STR | |
1522 | "Advertise only routes that are programmed in kernel to peers\n") | |
1523 | { | |
1524 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1525 | ||
1526 | bgp_suppress_fib_pending_set(bgp, !no); | |
1527 | return CMD_SUCCESS; | |
1528 | } | |
1529 | ||
1530 | ||
718e3744 | 1531 | /* BGP Cluster ID. */ |
ff8a8a7a CS |
1532 | DEFUN_YANG(bgp_cluster_id, |
1533 | bgp_cluster_id_cmd, | |
1534 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1535 | BGP_STR | |
1536 | "Configure Route-Reflector Cluster-id\n" | |
1537 | "Route-Reflector Cluster-id in IP address format\n" | |
1538 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1539 | { |
d62a17ae | 1540 | int idx_ipv4 = 2; |
718e3744 | 1541 | |
87ce2564 CS |
1542 | nb_cli_enqueue_change( |
1543 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1544 | NB_OP_MODIFY, argv[idx_ipv4]->arg); | |
718e3744 | 1545 | |
ff8a8a7a | 1546 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1547 | } |
1548 | ||
ff8a8a7a CS |
1549 | DEFUN_YANG(no_bgp_cluster_id, |
1550 | no_bgp_cluster_id_cmd, | |
1551 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1552 | NO_STR BGP_STR | |
1553 | "Configure Route-Reflector Cluster-id\n" | |
1554 | "Route-Reflector Cluster-id in IP address format\n" | |
1555 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1556 | { |
87ce2564 CS |
1557 | nb_cli_enqueue_change( |
1558 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1559 | NB_OP_DESTROY, NULL); | |
718e3744 | 1560 | |
ff8a8a7a | 1561 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1562 | } |
1563 | ||
c163f297 DS |
1564 | DEFPY (bgp_norib, |
1565 | bgp_norib_cmd, | |
1566 | "bgp no-rib", | |
1567 | BGP_STR | |
1568 | "Disable BGP route installation to RIB (Zebra)\n") | |
1569 | { | |
1570 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1571 | vty_out(vty, | |
1572 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1573 | return CMD_SUCCESS; | |
1574 | } | |
1575 | ||
1576 | bgp_option_norib_set_runtime(); | |
1577 | ||
1578 | return CMD_SUCCESS; | |
1579 | } | |
1580 | ||
1581 | DEFPY (no_bgp_norib, | |
1582 | no_bgp_norib_cmd, | |
1583 | "no bgp no-rib", | |
1584 | NO_STR | |
1585 | BGP_STR | |
1586 | "Disable BGP route installation to RIB (Zebra)\n") | |
1587 | { | |
1588 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1589 | vty_out(vty, | |
1590 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1591 | return CMD_SUCCESS; | |
1592 | } | |
1593 | ||
1594 | bgp_option_norib_unset_runtime(); | |
1595 | ||
1596 | return CMD_SUCCESS; | |
1597 | } | |
1598 | ||
ff8a8a7a CS |
1599 | DEFUN_YANG(bgp_confederation_identifier, |
1600 | bgp_confederation_identifier_cmd, | |
1601 | "bgp confederation identifier (1-4294967295)", | |
1602 | "BGP specific commands\n" | |
1603 | "AS confederation parameters\n" | |
1604 | "AS number\n" | |
1605 | "Set routing domain confederation AS\n") | |
718e3744 | 1606 | { |
d62a17ae | 1607 | int idx_number = 3; |
718e3744 | 1608 | |
87ce2564 CS |
1609 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1610 | NB_OP_MODIFY, argv[idx_number]->arg); | |
718e3744 | 1611 | |
ff8a8a7a | 1612 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1613 | } |
1614 | ||
ff8a8a7a CS |
1615 | DEFUN_YANG(no_bgp_confederation_identifier, |
1616 | no_bgp_confederation_identifier_cmd, | |
1617 | "no bgp confederation identifier [(1-4294967295)]", | |
1618 | NO_STR | |
1619 | "BGP specific commands\n" | |
1620 | "AS confederation parameters\n" | |
1621 | "AS number\n" | |
1622 | "Set routing domain confederation AS\n") | |
718e3744 | 1623 | { |
87ce2564 CS |
1624 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1625 | NB_OP_DESTROY, NULL); | |
718e3744 | 1626 | |
ff8a8a7a | 1627 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1628 | } |
1629 | ||
ff8a8a7a CS |
1630 | void cli_show_router_bgp_confederation_identifier(struct vty *vty, |
1631 | struct lyd_node *dnode, | |
1632 | bool show_defaults) | |
1633 | { | |
1634 | vty_out(vty, " bgp confederation identifier %u\n", | |
1635 | yang_dnode_get_uint32(dnode, NULL)); | |
1636 | } | |
1637 | ||
1638 | DEFUN_YANG(bgp_confederation_peers, | |
1639 | bgp_confederation_peers_cmd, | |
1640 | "bgp confederation peers (1-4294967295)...", | |
1641 | "BGP specific commands\n" | |
1642 | "AS confederation parameters\n" | |
1643 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1644 | { |
d62a17ae | 1645 | int idx_asn = 3; |
d62a17ae | 1646 | int i; |
718e3744 | 1647 | |
ff8a8a7a | 1648 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1649 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1650 | NB_OP_CREATE, argv[i]->arg); |
718e3744 | 1651 | |
ff8a8a7a | 1652 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1653 | } |
1654 | ||
ff8a8a7a CS |
1655 | DEFUN_YANG(no_bgp_confederation_peers, |
1656 | no_bgp_confederation_peers_cmd, | |
1657 | "no bgp confederation peers (1-4294967295)...", | |
1658 | NO_STR | |
1659 | "BGP specific commands\n" | |
1660 | "AS confederation parameters\n" | |
1661 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1662 | { |
d62a17ae | 1663 | int idx_asn = 4; |
d62a17ae | 1664 | int i; |
718e3744 | 1665 | |
ff8a8a7a | 1666 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1667 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1668 | NB_OP_DESTROY, argv[i]->arg); |
0b2aa3a0 | 1669 | |
ff8a8a7a CS |
1670 | return nb_cli_apply_changes(vty, NULL); |
1671 | } | |
1672 | ||
1673 | void cli_show_router_bgp_confederation_member_as(struct vty *vty, | |
1674 | struct lyd_node *dnode, | |
1675 | bool show_defaults) | |
1676 | { | |
1677 | vty_out(vty, " bgp confederation peers %u \n", | |
1678 | yang_dnode_get_uint32(dnode, NULL)); | |
718e3744 | 1679 | } |
6b0655a2 | 1680 | |
5e242b0d DS |
1681 | /** |
1682 | * Central routine for maximum-paths configuration. | |
1683 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1684 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1685 | */ | |
37a87b8f CS |
1686 | int bgp_maxpaths_config_vty(struct bgp *bgp, afi_t afi, safi_t safi, |
1687 | int peer_type, uint16_t maxpaths, uint16_t options, | |
1688 | int set, char *errmsg, size_t errmsg_len) | |
d62a17ae | 1689 | { |
d62a17ae | 1690 | int ret; |
d62a17ae | 1691 | |
1692 | if (set) { | |
d62a17ae | 1693 | if (maxpaths > multipath_num) { |
37a87b8f CS |
1694 | snprintf( |
1695 | errmsg, errmsg_len, | |
d62a17ae | 1696 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
1697 | maxpaths, multipath_num); | |
1698 | return CMD_WARNING_CONFIG_FAILED; | |
1699 | } | |
1700 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1701 | options); | |
1702 | } else | |
1703 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1704 | ||
1705 | if (ret < 0) { | |
37a87b8f CS |
1706 | snprintf( |
1707 | errmsg, errmsg_len, | |
d62a17ae | 1708 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
1709 | (set == 1) ? "" : "un", | |
1710 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1711 | maxpaths, afi, safi); | |
1712 | return CMD_WARNING_CONFIG_FAILED; | |
1713 | } | |
1714 | ||
1715 | bgp_recalculate_all_bestpaths(bgp); | |
1716 | ||
1717 | return CMD_SUCCESS; | |
165b5fff JB |
1718 | } |
1719 | ||
ff8a8a7a CS |
1720 | void cli_show_router_bgp_med_config(struct vty *vty, struct lyd_node *dnode, |
1721 | bool show_defaults) | |
abc920f8 | 1722 | { |
ff8a8a7a CS |
1723 | if (yang_dnode_get_bool(dnode, "./enable-med-admin")) { |
1724 | uint32_t med_admin_val; | |
abc920f8 | 1725 | |
ff8a8a7a CS |
1726 | vty_out(vty, " bgp max-med administrative"); |
1727 | if ((med_admin_val = | |
1728 | yang_dnode_get_uint32(dnode, "./max-med-admin")) | |
1729 | != BGP_MAXMED_VALUE_DEFAULT) | |
1730 | vty_out(vty, " %u", med_admin_val); | |
1731 | vty_out(vty, "\n"); | |
1732 | } | |
abc920f8 | 1733 | |
ff8a8a7a CS |
1734 | if (yang_dnode_exists(dnode, "./max-med-onstart-up-time")) { |
1735 | uint32_t onstartup_val; | |
abc920f8 | 1736 | |
ff8a8a7a CS |
1737 | vty_out(vty, " bgp max-med on-startup %u", |
1738 | yang_dnode_get_uint32(dnode, | |
1739 | "./max-med-onstart-up-time")); | |
1740 | onstartup_val = yang_dnode_get_uint32( | |
1741 | dnode, "./max-med-onstart-up-value"); | |
1742 | if (onstartup_val != BGP_MAXMED_VALUE_DEFAULT) | |
1743 | vty_out(vty, " %u", onstartup_val); | |
1744 | ||
1745 | vty_out(vty, "\n"); | |
1746 | } | |
abc920f8 DS |
1747 | } |
1748 | ||
ff8a8a7a CS |
1749 | DEFUN_YANG(bgp_maxmed_admin, |
1750 | bgp_maxmed_admin_cmd, | |
1751 | "bgp max-med administrative ", | |
1752 | BGP_STR | |
1753 | "Advertise routes with max-med\n" | |
1754 | "Administratively applied, for an indefinite period\n") | |
1755 | { | |
87ce2564 | 1756 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a CS |
1757 | NB_OP_MODIFY, "true"); |
1758 | ||
1759 | return nb_cli_apply_changes(vty, NULL); | |
1760 | } | |
1761 | ||
1762 | DEFUN_YANG(bgp_maxmed_admin_medv, | |
1763 | bgp_maxmed_admin_medv_cmd, | |
1764 | "bgp max-med administrative (0-4294967295)", | |
1765 | BGP_STR | |
1766 | "Advertise routes with max-med\n" | |
1767 | "Administratively applied, for an indefinite period\n" | |
1768 | "Max MED value to be used\n") | |
abc920f8 | 1769 | { |
d62a17ae | 1770 | int idx_number = 3; |
abc920f8 | 1771 | |
87ce2564 | 1772 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1773 | NB_OP_MODIFY, "true"); |
abc920f8 | 1774 | |
87ce2564 CS |
1775 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1776 | NB_OP_MODIFY, argv[idx_number]->arg); | |
abc920f8 | 1777 | |
ff8a8a7a | 1778 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1779 | } |
1780 | ||
ff8a8a7a CS |
1781 | DEFUN_YANG(no_bgp_maxmed_admin, |
1782 | no_bgp_maxmed_admin_cmd, | |
1783 | "no bgp max-med administrative [(0-4294967295)]", | |
1784 | NO_STR BGP_STR | |
1785 | "Advertise routes with max-med\n" | |
1786 | "Administratively applied, for an indefinite period\n" | |
1787 | "Max MED value to be used\n") | |
abc920f8 | 1788 | { |
87ce2564 | 1789 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1790 | NB_OP_MODIFY, "false"); |
abc920f8 | 1791 | |
87ce2564 CS |
1792 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1793 | NB_OP_MODIFY, NULL); | |
ff8a8a7a CS |
1794 | |
1795 | return nb_cli_apply_changes(vty, NULL); | |
abc920f8 DS |
1796 | } |
1797 | ||
37a87b8f CS |
1798 | DEFUN_YANG (bgp_maxmed_onstartup, |
1799 | bgp_maxmed_onstartup_cmd, | |
1800 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
1801 | BGP_STR | |
1802 | "Advertise routes with max-med\n" | |
1803 | "Effective on a startup\n" | |
1804 | "Time (seconds) period for max-med\n" | |
1805 | "Max MED value to be used\n") | |
abc920f8 | 1806 | { |
d62a17ae | 1807 | int idx = 0; |
4668a151 | 1808 | |
d62a17ae | 1809 | argv_find(argv, argc, "(5-86400)", &idx); |
87ce2564 CS |
1810 | nb_cli_enqueue_change(vty, |
1811 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a CS |
1812 | NB_OP_MODIFY, argv[idx]->arg); |
1813 | ||
d62a17ae | 1814 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
87ce2564 CS |
1815 | nb_cli_enqueue_change( |
1816 | vty, "./global/med-config/max-med-onstart-up-value", | |
1817 | NB_OP_MODIFY, argv[idx]->arg); | |
d62a17ae | 1818 | else |
87ce2564 CS |
1819 | nb_cli_enqueue_change( |
1820 | vty, "./global/med-config/max-med-onstart-up-value", | |
1821 | NB_OP_MODIFY, NULL); | |
abc920f8 | 1822 | |
ff8a8a7a | 1823 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1824 | } |
1825 | ||
37a87b8f CS |
1826 | DEFUN_YANG (no_bgp_maxmed_onstartup, |
1827 | no_bgp_maxmed_onstartup_cmd, | |
1828 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
1829 | NO_STR BGP_STR | |
1830 | "Advertise routes with max-med\n" | |
1831 | "Effective on a startup\n" | |
1832 | "Time (seconds) period for max-med\n" | |
1833 | "Max MED value to be used\n") | |
abc920f8 | 1834 | { |
87ce2564 CS |
1835 | nb_cli_enqueue_change(vty, |
1836 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a | 1837 | NB_OP_DESTROY, NULL); |
abc920f8 | 1838 | |
87ce2564 CS |
1839 | nb_cli_enqueue_change(vty, |
1840 | "./global/med-config/max-med-onstart-up-value", | |
ff8a8a7a | 1841 | NB_OP_MODIFY, NULL); |
abc920f8 | 1842 | |
ff8a8a7a | 1843 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1844 | } |
1845 | ||
d70583f7 D |
1846 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
1847 | uint16_t update_delay, | |
1848 | uint16_t establish_wait) | |
1849 | { | |
1850 | struct listnode *node, *nnode; | |
1851 | struct bgp *bgp; | |
1852 | bool vrf_cfg = false; | |
1853 | ||
1854 | /* | |
1855 | * See if update-delay is set per-vrf and warn user to delete it | |
1856 | * Note that we only need to check this if this is the first time | |
1857 | * setting the global config. | |
1858 | */ | |
1859 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
1860 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1861 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
1862 | vty_out(vty, | |
1863 | "%% update-delay configuration found in vrf %s\n", | |
1864 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
1865 | ? VRF_DEFAULT_NAME | |
1866 | : bgp->name); | |
1867 | vrf_cfg = true; | |
1868 | } | |
1869 | } | |
1870 | } | |
1871 | ||
1872 | if (vrf_cfg) { | |
1873 | vty_out(vty, | |
1874 | "%%Failed: global update-delay config not permitted\n"); | |
1875 | return CMD_WARNING; | |
1876 | } | |
1877 | ||
1878 | if (!establish_wait) { /* update-delay <delay> */ | |
1879 | bm->v_update_delay = update_delay; | |
1880 | bm->v_establish_wait = bm->v_update_delay; | |
1881 | } else { | |
1882 | /* update-delay <delay> <establish-wait> */ | |
1883 | if (update_delay < establish_wait) { | |
1884 | vty_out(vty, | |
1885 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1886 | return CMD_WARNING_CONFIG_FAILED; | |
1887 | } | |
1888 | ||
1889 | bm->v_update_delay = update_delay; | |
1890 | bm->v_establish_wait = establish_wait; | |
1891 | } | |
1892 | ||
1893 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1894 | bgp->v_update_delay = bm->v_update_delay; | |
1895 | bgp->v_establish_wait = bm->v_establish_wait; | |
1896 | } | |
1897 | ||
1898 | return CMD_SUCCESS; | |
1899 | } | |
1900 | ||
1901 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
1902 | { | |
1903 | struct listnode *node, *nnode; | |
1904 | struct bgp *bgp; | |
1905 | ||
1906 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1907 | bm->v_establish_wait = bm->v_update_delay; | |
1908 | ||
1909 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1910 | bgp->v_update_delay = bm->v_update_delay; | |
1911 | bgp->v_establish_wait = bm->v_establish_wait; | |
1912 | } | |
1913 | ||
1914 | return CMD_SUCCESS; | |
1915 | } | |
1916 | ||
1917 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
1918 | uint16_t establish_wait) | |
f188f2c4 | 1919 | { |
d62a17ae | 1920 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1921 | |
d70583f7 D |
1922 | /* if configured globally, per-instance config is not allowed */ |
1923 | if (bm->v_update_delay) { | |
1924 | vty_out(vty, | |
1925 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
1926 | return CMD_WARNING_CONFIG_FAILED; | |
1927 | } | |
1928 | ||
f188f2c4 | 1929 | |
d70583f7 | 1930 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 1931 | { |
1932 | bgp->v_update_delay = update_delay; | |
1933 | bgp->v_establish_wait = bgp->v_update_delay; | |
1934 | return CMD_SUCCESS; | |
1935 | } | |
f188f2c4 | 1936 | |
d62a17ae | 1937 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 1938 | if (update_delay < establish_wait) { |
1939 | vty_out(vty, | |
1940 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1941 | return CMD_WARNING_CONFIG_FAILED; | |
1942 | } | |
f188f2c4 | 1943 | |
d62a17ae | 1944 | bgp->v_update_delay = update_delay; |
1945 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1946 | |
d62a17ae | 1947 | return CMD_SUCCESS; |
f188f2c4 DS |
1948 | } |
1949 | ||
d62a17ae | 1950 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1951 | { |
d62a17ae | 1952 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1953 | |
d70583f7 D |
1954 | /* If configured globally, cannot remove from one bgp instance */ |
1955 | if (bm->v_update_delay) { | |
1956 | vty_out(vty, | |
1957 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
1958 | return CMD_WARNING_CONFIG_FAILED; | |
1959 | } | |
d62a17ae | 1960 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1961 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1962 | |
d62a17ae | 1963 | return CMD_SUCCESS; |
f188f2c4 DS |
1964 | } |
1965 | ||
2b791107 | 1966 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1967 | { |
d70583f7 D |
1968 | /* If configured globally, no need to display per-instance value */ |
1969 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 1970 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
1971 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1972 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1973 | vty_out(vty, "\n"); | |
1974 | } | |
f188f2c4 DS |
1975 | } |
1976 | ||
d70583f7 D |
1977 | /* Global update-delay configuration */ |
1978 | DEFPY (bgp_global_update_delay, | |
1979 | bgp_global_update_delay_cmd, | |
1980 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
1981 | BGP_STR | |
1982 | "Force initial delay for best-path and updates for all bgp instances\n" | |
1983 | "Max delay in seconds\n" | |
1984 | "Establish wait in seconds\n") | |
1985 | { | |
1986 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
1987 | } | |
f188f2c4 | 1988 | |
d70583f7 D |
1989 | /* Global update-delay deconfiguration */ |
1990 | DEFPY (no_bgp_global_update_delay, | |
1991 | no_bgp_global_update_delay_cmd, | |
1992 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
1993 | NO_STR | |
1994 | BGP_STR | |
f188f2c4 | 1995 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
1996 | "Max delay in seconds\n" |
1997 | "Establish wait in seconds\n") | |
f188f2c4 | 1998 | { |
d70583f7 | 1999 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2000 | } |
2001 | ||
d70583f7 D |
2002 | /* Update-delay configuration */ |
2003 | ||
2004 | DEFPY (bgp_update_delay, | |
2005 | bgp_update_delay_cmd, | |
2006 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2007 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2008 | "Max delay in seconds\n" |
2009 | "Establish wait in seconds\n") | |
f188f2c4 | 2010 | { |
d70583f7 | 2011 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2012 | } |
2013 | ||
2014 | /* Update-delay deconfiguration */ | |
d70583f7 | 2015 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2016 | no_bgp_update_delay_cmd, |
838758ac DW |
2017 | "no update-delay [(0-3600) [(1-3600)]]", |
2018 | NO_STR | |
f188f2c4 | 2019 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2020 | "Max delay in seconds\n" |
2021 | "Establish wait in seconds\n") | |
f188f2c4 | 2022 | { |
d62a17ae | 2023 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2024 | } |
2025 | ||
5e242b0d | 2026 | |
ff8a8a7a | 2027 | int bgp_wpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
cb1faec9 | 2028 | { |
8fa7732f QY |
2029 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2030 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2031 | |
2032 | return CMD_SUCCESS; | |
2033 | } | |
2034 | ||
ff8a8a7a | 2035 | int bgp_rpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
555e09d4 | 2036 | { |
8fa7732f QY |
2037 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2038 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2039 | |
d62a17ae | 2040 | return CMD_SUCCESS; |
cb1faec9 DS |
2041 | } |
2042 | ||
2b791107 | 2043 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2044 | { |
555e09d4 QY |
2045 | uint32_t quanta = |
2046 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2047 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2048 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2049 | } |
2050 | ||
555e09d4 QY |
2051 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2052 | { | |
2053 | uint32_t quanta = | |
2054 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2055 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2056 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2057 | } |
cb1faec9 | 2058 | |
8fa7732f QY |
2059 | /* Packet quanta configuration |
2060 | * | |
2061 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2062 | * thread. When changing these limits be careful to prevent stack overflow. | |
2063 | * | |
2064 | * Furthermore, the maximums used here should correspond to | |
2065 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2066 | */ | |
37a87b8f CS |
2067 | DEFPY_YANG (bgp_wpkt_quanta, |
2068 | bgp_wpkt_quanta_cmd, | |
2069 | "[no] write-quanta (1-64)$quanta", | |
2070 | NO_STR | |
2071 | "How many packets to write to peer socket per run\n" | |
2072 | "Number of packets\n") | |
ff8a8a7a CS |
2073 | { |
2074 | if (!no) | |
2075 | nb_cli_enqueue_change( | |
2076 | vty, | |
87ce2564 | 2077 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
2078 | NB_OP_MODIFY, quanta_str); |
2079 | else | |
2080 | nb_cli_enqueue_change( | |
2081 | vty, | |
87ce2564 | 2082 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
2083 | NB_OP_MODIFY, NULL); |
2084 | ||
2085 | return nb_cli_apply_changes(vty, NULL); | |
2086 | } | |
2087 | ||
37a87b8f CS |
2088 | DEFPY_YANG (bgp_rpkt_quanta, |
2089 | bgp_rpkt_quanta_cmd, | |
2090 | "[no] read-quanta (1-10)$quanta", | |
2091 | NO_STR | |
2092 | "How many packets to read from peer socket per I/O cycle\n" | |
2093 | "Number of packets\n") | |
ff8a8a7a CS |
2094 | { |
2095 | if (!no) | |
2096 | nb_cli_enqueue_change( | |
2097 | vty, | |
87ce2564 | 2098 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a CS |
2099 | NB_OP_MODIFY, quanta_str); |
2100 | else | |
2101 | nb_cli_enqueue_change( | |
2102 | vty, | |
87ce2564 | 2103 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a | 2104 | NB_OP_MODIFY, NULL); |
cb1faec9 | 2105 | |
ff8a8a7a | 2106 | return nb_cli_apply_changes(vty, NULL); |
555e09d4 QY |
2107 | } |
2108 | ||
2b791107 | 2109 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2110 | { |
37a333fe | 2111 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2112 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2113 | } |
2114 | ||
ff8a8a7a CS |
2115 | void cli_show_router_global_update_group_config_coalesce_time( |
2116 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3f9c7369 | 2117 | { |
ff8a8a7a CS |
2118 | vty_out(vty, " coalesce-time %u\n", yang_dnode_get_uint32(dnode, NULL)); |
2119 | } | |
2120 | ||
4668a151 | 2121 | |
37a87b8f CS |
2122 | DEFUN_YANG (bgp_coalesce_time, |
2123 | bgp_coalesce_time_cmd, | |
2124 | "coalesce-time (0-4294967295)", | |
2125 | "Subgroup coalesce timer\n" | |
2126 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2127 | { |
d62a17ae | 2128 | int idx = 0; |
ff8a8a7a | 2129 | |
d62a17ae | 2130 | argv_find(argv, argc, "(0-4294967295)", &idx); |
87ce2564 CS |
2131 | nb_cli_enqueue_change( |
2132 | vty, "./global/global-update-group-config/coalesce-time", | |
2133 | NB_OP_MODIFY, argv[idx]->arg); | |
ff8a8a7a CS |
2134 | |
2135 | return nb_cli_apply_changes(vty, NULL); | |
3f9c7369 DS |
2136 | } |
2137 | ||
ff8a8a7a CS |
2138 | DEFUN_YANG(no_bgp_coalesce_time, |
2139 | no_bgp_coalesce_time_cmd, | |
2140 | "no coalesce-time (0-4294967295)", | |
2141 | NO_STR | |
2142 | "Subgroup coalesce timer\n" | |
2143 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2144 | { |
87ce2564 CS |
2145 | nb_cli_enqueue_change( |
2146 | vty, "./global/global-update-group-config/coalesce-time", | |
2147 | NB_OP_MODIFY, NULL); | |
4668a151 | 2148 | |
ff8a8a7a | 2149 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
2150 | } |
2151 | ||
5e242b0d | 2152 | /* Maximum-paths configuration */ |
37a87b8f CS |
2153 | DEFUN_YANG (bgp_maxpaths, |
2154 | bgp_maxpaths_cmd, | |
2155 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2156 | "Forward packets over multiple paths\n" | |
2157 | "Number of paths\n") | |
5e242b0d | 2158 | { |
d62a17ae | 2159 | int idx_number = 1; |
37a87b8f CS |
2160 | char base_xpath[XPATH_MAXLEN]; |
2161 | afi_t afi; | |
2162 | safi_t safi; | |
2163 | ||
2164 | afi = bgp_node_afi(vty); | |
2165 | safi = bgp_node_safi(vty); | |
2166 | ||
2167 | snprintf( | |
2168 | base_xpath, sizeof(base_xpath), | |
2169 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths", | |
2170 | yang_afi_safi_value2identity(afi, safi), | |
2171 | bgp_afi_safi_get_container_str(afi, safi)); | |
2172 | ||
2173 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, | |
2174 | argv[idx_number]->arg); | |
2175 | ||
2176 | return nb_cli_apply_changes(vty, NULL); | |
2177 | } | |
2178 | ||
2179 | void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths( | |
2180 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
2181 | { | |
2182 | vty_out(vty, " maximum-paths %d\n", | |
2183 | yang_dnode_get_uint16(dnode, NULL)); | |
5e242b0d DS |
2184 | } |
2185 | ||
d62a17ae | 2186 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2187 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2188 | "Forward packets over multiple paths\n" | |
2189 | "Number of paths\n") | |
596c17ba | 2190 | |
37a87b8f CS |
2191 | DEFUN_YANG (bgp_maxpaths_ibgp, |
2192 | bgp_maxpaths_ibgp_cmd, | |
2193 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2194 | "Forward packets over multiple paths\n" | |
2195 | "iBGP-multipath\n" | |
2196 | "Number of paths\n") | |
165b5fff | 2197 | { |
d62a17ae | 2198 | int idx_number = 2; |
37a87b8f CS |
2199 | char base_xpath[XPATH_MAXLEN]; |
2200 | afi_t afi; | |
2201 | safi_t safi; | |
2202 | ||
2203 | afi = bgp_node_afi(vty); | |
2204 | safi = bgp_node_safi(vty); | |
2205 | ||
2206 | snprintf( | |
2207 | base_xpath, sizeof(base_xpath), | |
2208 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths", | |
2209 | yang_afi_safi_value2identity(afi, safi), | |
2210 | bgp_afi_safi_get_container_str(afi, safi)); | |
2211 | ||
2212 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, | |
2213 | argv[idx_number]->arg); | |
2214 | ||
2215 | return nb_cli_apply_changes(vty, NULL); | |
5e242b0d | 2216 | } |
165b5fff | 2217 | |
d62a17ae | 2218 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2219 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2220 | "Forward packets over multiple paths\n" | |
2221 | "iBGP-multipath\n" | |
2222 | "Number of paths\n") | |
596c17ba | 2223 | |
37a87b8f CS |
2224 | DEFUN_YANG (bgp_maxpaths_ibgp_cluster, |
2225 | bgp_maxpaths_ibgp_cluster_cmd, | |
2226 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2227 | "Forward packets over multiple paths\n" | |
2228 | "iBGP-multipath\n" | |
2229 | "Number of paths\n" | |
2230 | "Match the cluster length\n") | |
5e242b0d | 2231 | { |
d62a17ae | 2232 | int idx_number = 2; |
37a87b8f CS |
2233 | char base_xpath[XPATH_MAXLEN]; |
2234 | afi_t afi; | |
2235 | safi_t safi; | |
2236 | ||
2237 | afi = bgp_node_afi(vty); | |
2238 | safi = bgp_node_safi(vty); | |
2239 | ||
2240 | snprintf( | |
2241 | base_xpath, sizeof(base_xpath), | |
2242 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths", | |
2243 | yang_afi_safi_value2identity(afi, safi), | |
2244 | bgp_afi_safi_get_container_str(afi, safi)); | |
2245 | ||
2246 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, | |
2247 | argv[idx_number]->arg); | |
2248 | ||
2249 | snprintf( | |
2250 | base_xpath, sizeof(base_xpath), | |
2251 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list", | |
2252 | yang_afi_safi_value2identity(afi, safi), | |
2253 | bgp_afi_safi_get_container_str(afi, safi)); | |
2254 | ||
2255 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, "true"); | |
2256 | ||
2257 | return nb_cli_apply_changes(vty, NULL); | |
2258 | } | |
2259 | ||
2260 | void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths( | |
2261 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
2262 | { | |
2263 | vty_out(vty, " maximum-paths ibgp %d", | |
2264 | yang_dnode_get_uint16(dnode, "./maximum-paths")); | |
2265 | if (yang_dnode_get_bool(dnode, "./cluster-length-list")) | |
2266 | vty_out(vty, " equal-cluster-length"); | |
2267 | vty_out(vty, "\n"); | |
165b5fff JB |
2268 | } |
2269 | ||
d62a17ae | 2270 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2271 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2272 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2273 | "Forward packets over multiple paths\n" | |
2274 | "iBGP-multipath\n" | |
2275 | "Number of paths\n" | |
2276 | "Match the cluster length\n") | |
596c17ba | 2277 | |
37a87b8f CS |
2278 | DEFUN_YANG (no_bgp_maxpaths, |
2279 | no_bgp_maxpaths_cmd, | |
2280 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2281 | NO_STR | |
2282 | "Forward packets over multiple paths\n" | |
2283 | "Number of paths\n") | |
165b5fff | 2284 | { |
37a87b8f CS |
2285 | char base_xpath[XPATH_MAXLEN]; |
2286 | afi_t afi; | |
2287 | safi_t safi; | |
2288 | ||
2289 | afi = bgp_node_afi(vty); | |
2290 | safi = bgp_node_safi(vty); | |
2291 | ||
2292 | snprintf( | |
2293 | base_xpath, sizeof(base_xpath), | |
2294 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths", | |
2295 | yang_afi_safi_value2identity(afi, safi), | |
2296 | bgp_afi_safi_get_container_str(afi, safi)); | |
2297 | ||
2298 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, NULL); | |
2299 | ||
2300 | return nb_cli_apply_changes(vty, NULL); | |
165b5fff JB |
2301 | } |
2302 | ||
d62a17ae | 2303 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2304 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2305 | "Forward packets over multiple paths\n" |
2306 | "Number of paths\n") | |
596c17ba | 2307 | |
37a87b8f CS |
2308 | DEFUN_YANG (no_bgp_maxpaths_ibgp, |
2309 | no_bgp_maxpaths_ibgp_cmd, | |
2310 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2311 | NO_STR | |
2312 | "Forward packets over multiple paths\n" | |
2313 | "iBGP-multipath\n" | |
2314 | "Number of paths\n" | |
2315 | "Match the cluster length\n") | |
165b5fff | 2316 | { |
37a87b8f CS |
2317 | char base_xpath[XPATH_MAXLEN]; |
2318 | afi_t afi; | |
2319 | safi_t safi; | |
2320 | ||
2321 | afi = bgp_node_afi(vty); | |
2322 | safi = bgp_node_safi(vty); | |
2323 | ||
2324 | snprintf( | |
2325 | base_xpath, sizeof(base_xpath), | |
2326 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths", | |
2327 | yang_afi_safi_value2identity(afi, safi), | |
2328 | bgp_afi_safi_get_container_str(afi, safi)); | |
2329 | ||
2330 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, NULL); | |
2331 | ||
2332 | snprintf( | |
2333 | base_xpath, sizeof(base_xpath), | |
2334 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list", | |
2335 | yang_afi_safi_value2identity(afi, safi), | |
2336 | bgp_afi_safi_get_container_str(afi, safi)); | |
2337 | ||
2338 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, "false"); | |
2339 | ||
2340 | return nb_cli_apply_changes(vty, NULL); | |
165b5fff JB |
2341 | } |
2342 | ||
d62a17ae | 2343 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2344 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2345 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2346 | NO_STR | |
2347 | "Forward packets over multiple paths\n" | |
2348 | "iBGP-multipath\n" | |
2349 | "Number of paths\n" | |
2350 | "Match the cluster length\n") | |
596c17ba | 2351 | |
dd65f45e DL |
2352 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2353 | afi_t afi, safi_t safi) | |
165b5fff | 2354 | { |
d62a17ae | 2355 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 2356 | vty_out(vty, " maximum-paths %d\n", |
2357 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2358 | } | |
165b5fff | 2359 | |
d62a17ae | 2360 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 2361 | vty_out(vty, " maximum-paths ibgp %d", |
2362 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
2363 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
2364 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
2365 | vty_out(vty, " equal-cluster-length"); | |
2366 | vty_out(vty, "\n"); | |
2367 | } | |
165b5fff | 2368 | } |
6b0655a2 | 2369 | |
718e3744 | 2370 | /* BGP timers. */ |
2371 | ||
37a87b8f CS |
2372 | DEFUN_YANG (bgp_timers, |
2373 | bgp_timers_cmd, | |
2374 | "timers bgp (0-65535) (0-65535)", | |
2375 | "Adjust routing timers\n" | |
2376 | "BGP timers\n" | |
2377 | "Keepalive interval\n" | |
2378 | "Holdtime\n") | |
718e3744 | 2379 | { |
d62a17ae | 2380 | int idx_number = 2; |
2381 | int idx_number_2 = 3; | |
718e3744 | 2382 | |
87ce2564 | 2383 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2384 | NB_OP_MODIFY, argv[idx_number]->arg); |
87ce2564 | 2385 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2386 | NB_OP_MODIFY, argv[idx_number_2]->arg); |
718e3744 | 2387 | |
ff8a8a7a CS |
2388 | return nb_cli_apply_changes(vty, NULL); |
2389 | } | |
718e3744 | 2390 | |
37a87b8f CS |
2391 | DEFUN_YANG (no_bgp_timers, |
2392 | no_bgp_timers_cmd, | |
2393 | "no timers bgp [(0-65535) (0-65535)]", | |
2394 | NO_STR | |
2395 | "Adjust routing timers\n" | |
2396 | "BGP timers\n" | |
2397 | "Keepalive interval\n" | |
2398 | "Holdtime\n") | |
ff8a8a7a | 2399 | { |
87ce2564 | 2400 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2401 | NB_OP_DESTROY, NULL); |
87ce2564 | 2402 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2403 | NB_OP_DESTROY, NULL); |
718e3744 | 2404 | |
ff8a8a7a | 2405 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2406 | } |
2407 | ||
ff8a8a7a CS |
2408 | void cli_show_router_bgp_route_reflector(struct vty *vty, |
2409 | struct lyd_node *dnode, | |
2410 | bool show_defaults) | |
718e3744 | 2411 | { |
ff8a8a7a CS |
2412 | if (yang_dnode_get_bool(dnode, "./no-client-reflect")) |
2413 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
718e3744 | 2414 | |
ff8a8a7a CS |
2415 | if (yang_dnode_get_bool(dnode, "./allow-outbound-policy")) |
2416 | vty_out(vty, " bgp route-reflector allow-outbound-policy\n"); | |
2417 | ||
2418 | if (yang_dnode_exists(dnode, "./route-reflector-cluster-id")) | |
2419 | vty_out(vty, " bgp cluster-id %s\n", | |
2420 | yang_dnode_get_string(dnode, | |
2421 | "./route-reflector-cluster-id")); | |
718e3744 | 2422 | } |
2423 | ||
ff8a8a7a CS |
2424 | DEFUN_YANG(bgp_client_to_client_reflection, |
2425 | bgp_client_to_client_reflection_cmd, | |
2426 | "bgp client-to-client reflection", | |
2427 | "BGP specific commands\n" | |
2428 | "Configure client to client route reflection\n" | |
2429 | "reflection of routes allowed\n") | |
2430 | { | |
87ce2564 | 2431 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2432 | NB_OP_MODIFY, "false"); |
6b0655a2 | 2433 | |
ff8a8a7a CS |
2434 | return nb_cli_apply_changes(vty, NULL); |
2435 | } | |
2436 | ||
2437 | DEFUN_YANG(no_bgp_client_to_client_reflection, | |
2438 | no_bgp_client_to_client_reflection_cmd, | |
2439 | "no bgp client-to-client reflection", | |
2440 | NO_STR | |
2441 | "BGP specific commands\n" | |
2442 | "Configure client to client route reflection\n" | |
2443 | "reflection of routes allowed\n") | |
718e3744 | 2444 | { |
87ce2564 | 2445 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2446 | NB_OP_MODIFY, "true"); |
7aafcaca | 2447 | |
ff8a8a7a | 2448 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2449 | } |
2450 | ||
ff8a8a7a CS |
2451 | void cli_show_router_bgp_route_selection(struct vty *vty, |
2452 | struct lyd_node *dnode, | |
2453 | bool show_defaults) | |
718e3744 | 2454 | { |
7aafcaca | 2455 | |
ff8a8a7a CS |
2456 | if (yang_dnode_get_bool(dnode, "./always-compare-med")) |
2457 | vty_out(vty, " bgp always-compare-med\n"); | |
2458 | ||
2459 | if (yang_dnode_get_bool(dnode, "./ignore-as-path-length")) | |
2460 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
2461 | ||
2462 | if (yang_dnode_get_bool(dnode, "./aspath-confed")) | |
2463 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
2464 | ||
2465 | if (yang_dnode_get_bool(dnode, "./external-compare-router-id")) | |
2466 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
2467 | ||
2468 | if (yang_dnode_get_bool(dnode, "./allow-multiple-as")) { | |
2469 | if (yang_dnode_get_bool(dnode, "./multi-path-as-set")) | |
2470 | vty_out(vty, | |
2471 | " bgp bestpath as-path multipath-relax as-set\n"); | |
2472 | else | |
2473 | vty_out(vty, " bgp bestpath as-path multipath-relax\n"); | |
2474 | } | |
2475 | ||
2476 | if (yang_dnode_get_bool(dnode, "./deterministic-med")) | |
2477 | vty_out(vty, " bgp deterministic-med\n"); | |
2478 | ||
2479 | if (yang_dnode_get_bool(dnode, "./confed-med") | |
2480 | || yang_dnode_get_bool(dnode, "./missing-as-worst-med")) { | |
2481 | vty_out(vty, " bgp bestpath med"); | |
2482 | if (yang_dnode_get_bool(dnode, "./confed-med")) | |
2483 | vty_out(vty, " confed"); | |
2484 | if (yang_dnode_get_bool(dnode, "./missing-as-worst-med")) | |
2485 | vty_out(vty, " missing-as-worst"); | |
2486 | vty_out(vty, "\n"); | |
2487 | } | |
718e3744 | 2488 | } |
2489 | ||
2490 | /* "bgp always-compare-med" configuration. */ | |
ff8a8a7a CS |
2491 | DEFUN_YANG(bgp_always_compare_med, |
2492 | bgp_always_compare_med_cmd, | |
2493 | "bgp always-compare-med", | |
2494 | "BGP specific commands\n" | |
2495 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2496 | { |
87ce2564 CS |
2497 | nb_cli_enqueue_change( |
2498 | vty, "./global/route-selection-options/always-compare-med", | |
2499 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2500 | |
ff8a8a7a | 2501 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2502 | } |
2503 | ||
ff8a8a7a CS |
2504 | DEFUN_YANG(no_bgp_always_compare_med, |
2505 | no_bgp_always_compare_med_cmd, | |
2506 | "no bgp always-compare-med", | |
2507 | NO_STR | |
2508 | "BGP specific commands\n" | |
2509 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2510 | { |
87ce2564 CS |
2511 | nb_cli_enqueue_change( |
2512 | vty, "./global/route-selection-options/always-compare-med", | |
2513 | NB_OP_MODIFY, "false"); | |
7aafcaca | 2514 | |
ff8a8a7a | 2515 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2516 | } |
6b0655a2 | 2517 | |
ff8a8a7a CS |
2518 | DEFUN_YANG(bgp_ebgp_requires_policy, |
2519 | bgp_ebgp_requires_policy_cmd, | |
2520 | "bgp ebgp-requires-policy", | |
2521 | "BGP specific commands\n" | |
2522 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2523 | { | |
87ce2564 CS |
2524 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2525 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
2526 | return nb_cli_apply_changes(vty, NULL); |
2527 | } | |
9dac9fc8 | 2528 | |
ff8a8a7a CS |
2529 | DEFUN_YANG(no_bgp_ebgp_requires_policy, |
2530 | no_bgp_ebgp_requires_policy_cmd, | |
2531 | "no bgp ebgp-requires-policy", | |
2532 | NO_STR | |
2533 | "BGP specific commands\n" | |
2534 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
9dac9fc8 | 2535 | { |
87ce2564 CS |
2536 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2537 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 2538 | return nb_cli_apply_changes(vty, NULL); |
9dac9fc8 DA |
2539 | } |
2540 | ||
ff8a8a7a CS |
2541 | void cli_show_router_bgp_ebgp_requires_policy(struct vty *vty, |
2542 | struct lyd_node *dnode, | |
2543 | bool show_defaults) | |
9dac9fc8 | 2544 | { |
ff8a8a7a CS |
2545 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_EBGP_REQUIRES_POLICY) |
2546 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
9dac9fc8 DA |
2547 | } |
2548 | ||
fb29348a DA |
2549 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2550 | "bgp reject-as-sets", | |
2551 | "BGP specific commands\n" | |
2552 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2553 | { | |
2554 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2555 | struct listnode *node, *nnode; | |
2556 | struct peer *peer; | |
2557 | ||
7f972cd8 | 2558 | bgp->reject_as_sets = true; |
fb29348a DA |
2559 | |
2560 | /* Reset existing BGP sessions to reject routes | |
2561 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2562 | */ | |
2563 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2564 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2565 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2566 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2567 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2568 | } | |
2569 | } | |
2570 | ||
2571 | return CMD_SUCCESS; | |
2572 | } | |
2573 | ||
2574 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2575 | "no bgp reject-as-sets", | |
2576 | NO_STR | |
2577 | "BGP specific commands\n" | |
2578 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2579 | { | |
2580 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2581 | struct listnode *node, *nnode; | |
2582 | struct peer *peer; | |
2583 | ||
7f972cd8 | 2584 | bgp->reject_as_sets = false; |
fb29348a DA |
2585 | |
2586 | /* Reset existing BGP sessions to reject routes | |
2587 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2588 | */ | |
2589 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2590 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2591 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2592 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2593 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2594 | } | |
2595 | } | |
2596 | ||
2597 | return CMD_SUCCESS; | |
2598 | } | |
9dac9fc8 | 2599 | |
718e3744 | 2600 | /* "bgp deterministic-med" configuration. */ |
ff8a8a7a | 2601 | DEFUN_YANG (bgp_deterministic_med, |
718e3744 | 2602 | bgp_deterministic_med_cmd, |
2603 | "bgp deterministic-med", | |
2604 | "BGP specific commands\n" | |
2605 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2606 | { | |
87ce2564 CS |
2607 | nb_cli_enqueue_change( |
2608 | vty, "./global/route-selection-options/deterministic-med", | |
2609 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2610 | |
ff8a8a7a | 2611 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2612 | } |
2613 | ||
ff8a8a7a | 2614 | DEFUN_YANG (no_bgp_deterministic_med, |
718e3744 | 2615 | no_bgp_deterministic_med_cmd, |
2616 | "no bgp deterministic-med", | |
2617 | NO_STR | |
2618 | "BGP specific commands\n" | |
2619 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2620 | { | |
87ce2564 CS |
2621 | nb_cli_enqueue_change( |
2622 | vty, "./global/route-selection-options/deterministic-med", | |
2623 | NB_OP_MODIFY, "false"); | |
d62a17ae | 2624 | |
ff8a8a7a | 2625 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2626 | } |
538621f2 | 2627 | |
055679e9 | 2628 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2629 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2630 | bgp_graceful_restart_cmd, |
2631 | "bgp graceful-restart", | |
2632 | "BGP specific commands\n" | |
2633 | GR_CMD | |
055679e9 | 2634 | ) |
538621f2 | 2635 | { |
055679e9 | 2636 | int ret = BGP_GR_FAILURE; |
2637 | ||
2638 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2639 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2640 | |
d62a17ae | 2641 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2642 | |
2643 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2644 | ||
36235319 QY |
2645 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2646 | ret); | |
5cce3f05 | 2647 | |
055679e9 | 2648 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2649 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2650 | vty_out(vty, |
2651 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2652 | return bgp_vty_return(vty, ret); |
538621f2 | 2653 | } |
2654 | ||
2655 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2656 | no_bgp_graceful_restart_cmd, |
2657 | "no bgp graceful-restart", | |
2658 | NO_STR | |
2659 | "BGP specific commands\n" | |
2660 | NO_GR_CMD | |
055679e9 | 2661 | ) |
538621f2 | 2662 | { |
d62a17ae | 2663 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2664 | |
2665 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2666 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2667 | |
2668 | int ret = BGP_GR_FAILURE; | |
2669 | ||
2670 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2671 | ||
36235319 QY |
2672 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2673 | ret); | |
5cce3f05 | 2674 | |
055679e9 | 2675 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2676 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2677 | vty_out(vty, |
2678 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2679 | |
2680 | return bgp_vty_return(vty, ret); | |
538621f2 | 2681 | } |
2682 | ||
93406d87 | 2683 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2684 | bgp_graceful_restart_stalepath_time_cmd, |
2685 | "bgp graceful-restart stalepath-time (1-4095)", | |
2686 | "BGP specific commands\n" | |
2687 | "Graceful restart capability parameters\n" | |
2688 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2689 | "Delay value (seconds)\n") | |
93406d87 | 2690 | { |
d62a17ae | 2691 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2692 | int idx_number = 3; | |
d7c0a89a | 2693 | uint32_t stalepath; |
93406d87 | 2694 | |
d62a17ae | 2695 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2696 | bgp->stalepath_time = stalepath; | |
2697 | return CMD_SUCCESS; | |
93406d87 | 2698 | } |
2699 | ||
eb6f1b41 | 2700 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2701 | bgp_graceful_restart_restart_time_cmd, |
2702 | "bgp graceful-restart restart-time (1-4095)", | |
2703 | "BGP specific commands\n" | |
2704 | "Graceful restart capability parameters\n" | |
2705 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2706 | "Delay value (seconds)\n") | |
eb6f1b41 | 2707 | { |
d62a17ae | 2708 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2709 | int idx_number = 3; | |
d7c0a89a | 2710 | uint32_t restart; |
eb6f1b41 | 2711 | |
d62a17ae | 2712 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2713 | bgp->restart_time = restart; | |
2714 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2715 | } |
2716 | ||
cfd47646 | 2717 | DEFUN (bgp_graceful_restart_select_defer_time, |
2718 | bgp_graceful_restart_select_defer_time_cmd, | |
2719 | "bgp graceful-restart select-defer-time (0-3600)", | |
2720 | "BGP specific commands\n" | |
2721 | "Graceful restart capability parameters\n" | |
2722 | "Set the time to defer the BGP route selection after restart\n" | |
2723 | "Delay value (seconds, 0 - disable)\n") | |
2724 | { | |
2725 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2726 | int idx_number = 3; | |
2727 | uint32_t defer_time; | |
2728 | ||
2729 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2730 | bgp->select_defer_time = defer_time; | |
2731 | if (defer_time == 0) | |
892fedb6 | 2732 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2733 | else |
892fedb6 | 2734 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2735 | |
2736 | return CMD_SUCCESS; | |
2737 | } | |
2738 | ||
93406d87 | 2739 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2740 | no_bgp_graceful_restart_stalepath_time_cmd, |
2741 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2742 | NO_STR | |
2743 | "BGP specific commands\n" | |
2744 | "Graceful restart capability parameters\n" | |
2745 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2746 | "Delay value (seconds)\n") | |
93406d87 | 2747 | { |
d62a17ae | 2748 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2749 | |
d62a17ae | 2750 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2751 | return CMD_SUCCESS; | |
93406d87 | 2752 | } |
2753 | ||
eb6f1b41 | 2754 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2755 | no_bgp_graceful_restart_restart_time_cmd, |
2756 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2757 | NO_STR | |
2758 | "BGP specific commands\n" | |
2759 | "Graceful restart capability parameters\n" | |
2760 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2761 | "Delay value (seconds)\n") | |
eb6f1b41 | 2762 | { |
d62a17ae | 2763 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2764 | |
d62a17ae | 2765 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2766 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2767 | } |
2768 | ||
cfd47646 | 2769 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2770 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2771 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2772 | NO_STR | |
2773 | "BGP specific commands\n" | |
2774 | "Graceful restart capability parameters\n" | |
2775 | "Set the time to defer the BGP route selection after restart\n" | |
2776 | "Delay value (seconds)\n") | |
2777 | { | |
2778 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2779 | ||
2780 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2781 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2782 | |
2783 | return CMD_SUCCESS; | |
2784 | } | |
2785 | ||
43fc21b3 | 2786 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2787 | bgp_graceful_restart_preserve_fw_cmd, |
2788 | "bgp graceful-restart preserve-fw-state", | |
2789 | "BGP specific commands\n" | |
2790 | "Graceful restart capability parameters\n" | |
2791 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2792 | { |
d62a17ae | 2793 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2794 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2795 | return CMD_SUCCESS; |
43fc21b3 JC |
2796 | } |
2797 | ||
2798 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2799 | no_bgp_graceful_restart_preserve_fw_cmd, |
2800 | "no bgp graceful-restart preserve-fw-state", | |
2801 | NO_STR | |
2802 | "BGP specific commands\n" | |
2803 | "Graceful restart capability parameters\n" | |
2804 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2805 | { |
d62a17ae | 2806 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2807 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2808 | return CMD_SUCCESS; |
43fc21b3 JC |
2809 | } |
2810 | ||
055679e9 | 2811 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2812 | bgp_graceful_restart_disable_cmd, |
2813 | "bgp graceful-restart-disable", | |
2814 | "BGP specific commands\n" | |
2815 | GR_DISABLE) | |
055679e9 | 2816 | { |
2817 | int ret = BGP_GR_FAILURE; | |
2818 | ||
2819 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2820 | zlog_debug( | |
2ba1fe69 | 2821 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2822 | |
055679e9 | 2823 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2824 | ||
2825 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2826 | ||
dc95985f | 2827 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2828 | bgp->peer, ret); | |
5cce3f05 | 2829 | |
055679e9 | 2830 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2831 | zlog_debug( | |
2ba1fe69 | 2832 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2833 | vty_out(vty, |
2834 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2835 | ||
055679e9 | 2836 | return bgp_vty_return(vty, ret); |
2837 | } | |
2838 | ||
2839 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2840 | no_bgp_graceful_restart_disable_cmd, |
2841 | "no bgp graceful-restart-disable", | |
2842 | NO_STR | |
2843 | "BGP specific commands\n" | |
2844 | NO_GR_DISABLE | |
055679e9 | 2845 | ) |
2846 | { | |
2847 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2848 | ||
2849 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2850 | zlog_debug( | |
2ba1fe69 | 2851 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2852 | |
2853 | int ret = BGP_GR_FAILURE; | |
2854 | ||
2855 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2856 | ||
36235319 QY |
2857 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2858 | ret); | |
5cce3f05 | 2859 | |
055679e9 | 2860 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2861 | zlog_debug( | |
2ba1fe69 | 2862 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2863 | vty_out(vty, |
2864 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2865 | |
2866 | return bgp_vty_return(vty, ret); | |
2867 | } | |
2868 | ||
2869 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2870 | bgp_neighbor_graceful_restart_set_cmd, |
2871 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2872 | NEIGHBOR_STR | |
2873 | NEIGHBOR_ADDR_STR2 | |
2874 | GR_NEIGHBOR_CMD | |
055679e9 | 2875 | ) |
2876 | { | |
2877 | int idx_peer = 1; | |
2878 | struct peer *peer; | |
2879 | int ret = BGP_GR_FAILURE; | |
2880 | ||
dc95985f | 2881 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2882 | ||
055679e9 | 2883 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2884 | zlog_debug( | |
2ba1fe69 | 2885 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2886 | |
055679e9 | 2887 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2888 | if (!peer) | |
2889 | return CMD_WARNING_CONFIG_FAILED; | |
2890 | ||
2891 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2892 | ||
dc95985f | 2893 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2894 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2895 | |
2896 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2897 | zlog_debug( | |
2ba1fe69 | 2898 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2899 | vty_out(vty, |
2900 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2901 | |
2902 | return bgp_vty_return(vty, ret); | |
2903 | } | |
2904 | ||
2905 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2906 | no_bgp_neighbor_graceful_restart_set_cmd, |
2907 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2908 | NO_STR | |
2909 | NEIGHBOR_STR | |
2910 | NEIGHBOR_ADDR_STR2 | |
2911 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2912 | ) |
2913 | { | |
2914 | int idx_peer = 2; | |
2915 | int ret = BGP_GR_FAILURE; | |
2916 | struct peer *peer; | |
2917 | ||
dc95985f | 2918 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2919 | ||
055679e9 | 2920 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2921 | if (!peer) | |
2922 | return CMD_WARNING_CONFIG_FAILED; | |
2923 | ||
2924 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2925 | zlog_debug( | |
2ba1fe69 | 2926 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2927 | |
2928 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2929 | ||
dc95985f | 2930 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2931 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2932 | |
2933 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2934 | zlog_debug( | |
2ba1fe69 | 2935 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2936 | vty_out(vty, |
2937 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2938 | |
2939 | return bgp_vty_return(vty, ret); | |
2940 | } | |
2941 | ||
2942 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2943 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2944 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2945 | NEIGHBOR_STR | |
2946 | NEIGHBOR_ADDR_STR2 | |
2947 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2948 | ) |
2949 | { | |
2950 | int idx_peer = 1; | |
2951 | struct peer *peer; | |
2952 | int ret = BGP_GR_FAILURE; | |
2953 | ||
dc95985f | 2954 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2955 | ||
055679e9 | 2956 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2957 | zlog_debug( | |
2ba1fe69 | 2958 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2959 | |
055679e9 | 2960 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2961 | ||
055679e9 | 2962 | if (!peer) |
2963 | return CMD_WARNING_CONFIG_FAILED; | |
2964 | ||
2965 | ||
2966 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2967 | |
dc95985f | 2968 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2969 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2970 | |
055679e9 | 2971 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2972 | zlog_debug( | |
2ba1fe69 | 2973 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2974 | vty_out(vty, |
2975 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2976 | |
2977 | return bgp_vty_return(vty, ret); | |
2978 | } | |
2979 | ||
2980 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2981 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2982 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2983 | NO_STR | |
2984 | NEIGHBOR_STR | |
2985 | NEIGHBOR_ADDR_STR2 | |
2986 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2987 | ) |
2988 | { | |
2989 | int idx_peer = 2; | |
2990 | int ret = BGP_GR_FAILURE; | |
2991 | struct peer *peer; | |
2992 | ||
dc95985f | 2993 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2994 | ||
055679e9 | 2995 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2996 | if (!peer) | |
2997 | return CMD_WARNING_CONFIG_FAILED; | |
2998 | ||
2999 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3000 | zlog_debug( | |
2ba1fe69 | 3001 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 3002 | |
36235319 | 3003 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 3004 | |
dc95985f | 3005 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3006 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3007 | |
3008 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3009 | zlog_debug( | |
2ba1fe69 | 3010 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3011 | vty_out(vty, |
3012 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3013 | |
3014 | return bgp_vty_return(vty, ret); | |
3015 | } | |
3016 | ||
3017 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 3018 | bgp_neighbor_graceful_restart_disable_set_cmd, |
3019 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3020 | NEIGHBOR_STR | |
3021 | NEIGHBOR_ADDR_STR2 | |
3022 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3023 | ) |
3024 | { | |
3025 | int idx_peer = 1; | |
3026 | struct peer *peer; | |
3027 | int ret = BGP_GR_FAILURE; | |
3028 | ||
dc95985f | 3029 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3030 | ||
055679e9 | 3031 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3032 | zlog_debug( | |
2ba1fe69 | 3033 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3034 | |
3035 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3036 | if (!peer) | |
3037 | return CMD_WARNING_CONFIG_FAILED; | |
3038 | ||
36235319 | 3039 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 3040 | |
3041 | if (peer->bgp->t_startup) | |
3042 | bgp_peer_gr_flags_update(peer); | |
3043 | ||
dc95985f | 3044 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3045 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3046 | ||
055679e9 | 3047 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3048 | zlog_debug( | |
2ba1fe69 | 3049 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3050 | vty_out(vty, |
3051 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3052 | |
3053 | return bgp_vty_return(vty, ret); | |
3054 | } | |
3055 | ||
3056 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3057 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3058 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3059 | NO_STR | |
3060 | NEIGHBOR_STR | |
3061 | NEIGHBOR_ADDR_STR2 | |
3062 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3063 | ) |
3064 | { | |
3065 | int idx_peer = 2; | |
3066 | int ret = BGP_GR_FAILURE; | |
3067 | struct peer *peer; | |
3068 | ||
dc95985f | 3069 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3070 | ||
055679e9 | 3071 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3072 | if (!peer) | |
3073 | return CMD_WARNING_CONFIG_FAILED; | |
3074 | ||
3075 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3076 | zlog_debug( | |
2ba1fe69 | 3077 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3078 | |
3079 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3080 | ||
dc95985f | 3081 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3082 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3083 | |
3084 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3085 | zlog_debug( | |
2ba1fe69 | 3086 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3087 | vty_out(vty, |
3088 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3089 | |
3090 | return bgp_vty_return(vty, ret); | |
3091 | } | |
3092 | ||
d6e3c15b | 3093 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3094 | bgp_graceful_restart_disable_eor_cmd, | |
3095 | "bgp graceful-restart disable-eor", | |
3096 | "BGP specific commands\n" | |
3097 | "Graceful restart configuration parameters\n" | |
3098 | "Disable EOR Check\n") | |
3099 | { | |
3100 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3101 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3102 | |
d6e3c15b | 3103 | return CMD_SUCCESS; |
3104 | } | |
3105 | ||
3106 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3107 | no_bgp_graceful_restart_disable_eor_cmd, | |
3108 | "no bgp graceful-restart disable-eor", | |
3109 | NO_STR | |
3110 | "BGP specific commands\n" | |
3111 | "Graceful restart configuration parameters\n" | |
3112 | "Disable EOR Check\n") | |
3113 | { | |
3114 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3115 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3116 | |
3117 | return CMD_SUCCESS; | |
3118 | } | |
3119 | ||
3120 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3121 | bgp_graceful_restart_rib_stale_time_cmd, | |
3122 | "bgp graceful-restart rib-stale-time (1-3600)", | |
3123 | "BGP specific commands\n" | |
3124 | "Graceful restart configuration parameters\n" | |
3125 | "Specify the stale route removal timer in rib\n" | |
3126 | "Delay value (seconds)\n") | |
3127 | { | |
3128 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3129 | int idx_number = 3; | |
3130 | uint32_t stale_time; | |
3131 | ||
3132 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3133 | bgp->rib_stale_time = stale_time; | |
3134 | /* Send the stale timer update message to RIB */ | |
3135 | if (bgp_zebra_stale_timer_update(bgp)) | |
3136 | return CMD_WARNING; | |
3137 | ||
3138 | return CMD_SUCCESS; | |
3139 | } | |
3140 | ||
3141 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3142 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3143 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3144 | NO_STR | |
3145 | "BGP specific commands\n" | |
3146 | "Graceful restart configuration parameters\n" | |
3147 | "Specify the stale route removal timer in rib\n" | |
3148 | "Delay value (seconds)\n") | |
3149 | { | |
3150 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3151 | ||
3152 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3153 | /* Send the stale timer update message to RIB */ | |
3154 | if (bgp_zebra_stale_timer_update(bgp)) | |
3155 | return CMD_WARNING; | |
3156 | ||
d6e3c15b | 3157 | return CMD_SUCCESS; |
3158 | } | |
3159 | ||
ff8a8a7a CS |
3160 | static inline int bgp_initiate_graceful_shut_unshut(struct bgp *bgp, |
3161 | char *errmsg, | |
3162 | size_t errmsg_len) | |
05bd726c | 3163 | { |
3164 | bgp_static_redo_import_check(bgp); | |
3165 | bgp_redistribute_redo(bgp); | |
ff8a8a7a CS |
3166 | if (bgp_clear_star_soft_out(bgp->name, errmsg, errmsg_len) < 0) |
3167 | return -1; | |
3168 | if (bgp_clear_star_soft_in(bgp->name, errmsg, errmsg_len) < 0) | |
3169 | return -1; | |
3170 | ||
3171 | return 0; | |
05bd726c | 3172 | } |
3173 | ||
3174 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3175 | { | |
3176 | struct listnode *node, *nnode; | |
3177 | struct bgp *bgp; | |
3178 | bool vrf_cfg = false; | |
ff8a8a7a | 3179 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 3180 | |
3181 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3182 | return CMD_SUCCESS; | |
3183 | ||
3184 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3185 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3186 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3187 | vty_out(vty, | |
3188 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3189 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3190 | VRF_DEFAULT_NAME : bgp->name); | |
3191 | vrf_cfg = true; | |
3192 | } | |
3193 | } | |
3194 | ||
3195 | if (vrf_cfg) { | |
3196 | vty_out(vty, | |
3197 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3198 | return CMD_WARNING; | |
3199 | } | |
3200 | ||
3201 | /* Set flag globally */ | |
3202 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3203 | ||
3204 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3205 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3206 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3207 | sizeof(errmsg)) | |
3208 | < 0) | |
3209 | if (strlen(errmsg)) | |
3210 | vty_out(vty, "%s\n", errmsg); | |
3211 | } | |
05bd726c | 3212 | |
3213 | return CMD_SUCCESS; | |
3214 | } | |
3215 | ||
3216 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3217 | { | |
3218 | struct listnode *node, *nnode; | |
3219 | struct bgp *bgp; | |
ff8a8a7a | 3220 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 3221 | |
3222 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3223 | return CMD_SUCCESS; | |
3224 | ||
3225 | /* Unset flag globally */ | |
3226 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3227 | ||
3228 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3229 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3230 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3231 | sizeof(errmsg)) | |
3232 | < 0) | |
3233 | if (strlen(errmsg)) | |
3234 | vty_out(vty, "%s\n", errmsg); | |
3235 | } | |
05bd726c | 3236 | |
3237 | return CMD_SUCCESS; | |
3238 | } | |
3239 | ||
7f323236 DW |
3240 | /* "bgp graceful-shutdown" configuration */ |
3241 | DEFUN (bgp_graceful_shutdown, | |
3242 | bgp_graceful_shutdown_cmd, | |
3243 | "bgp graceful-shutdown", | |
3244 | BGP_STR | |
3245 | "Graceful shutdown parameters\n") | |
3246 | { | |
05bd726c | 3247 | if (vty->node == CONFIG_NODE) |
3248 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3249 | ||
87ce2564 CS |
3250 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3251 | NB_OP_MODIFY, "true"); | |
7f323236 | 3252 | |
ff8a8a7a | 3253 | return nb_cli_apply_changes(vty, NULL); |
7f323236 DW |
3254 | } |
3255 | ||
ff8a8a7a | 3256 | DEFUN_YANG (no_bgp_graceful_shutdown, |
7f323236 DW |
3257 | no_bgp_graceful_shutdown_cmd, |
3258 | "no bgp graceful-shutdown", | |
3259 | NO_STR | |
3260 | BGP_STR | |
3261 | "Graceful shutdown parameters\n") | |
3262 | { | |
05bd726c | 3263 | if (vty->node == CONFIG_NODE) |
3264 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3265 | ||
87ce2564 CS |
3266 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3267 | NB_OP_MODIFY, "false"); | |
05bd726c | 3268 | |
ff8a8a7a CS |
3269 | return nb_cli_apply_changes(vty, NULL); |
3270 | } | |
7f323236 | 3271 | |
ff8a8a7a CS |
3272 | void cli_show_router_bgp_graceful_shutdown(struct vty *vty, |
3273 | struct lyd_node *dnode, | |
3274 | bool show_defaults) | |
3275 | { | |
3276 | if (yang_dnode_get_bool(dnode, NULL)) | |
3277 | vty_out(vty, " bgp graceful-shutdown\n"); | |
7f323236 DW |
3278 | } |
3279 | ||
718e3744 | 3280 | /* "bgp fast-external-failover" configuration. */ |
ff8a8a7a | 3281 | DEFUN_YANG (bgp_fast_external_failover, |
718e3744 | 3282 | bgp_fast_external_failover_cmd, |
3283 | "bgp fast-external-failover", | |
3284 | BGP_STR | |
3285 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3286 | { | |
87ce2564 CS |
3287 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3288 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3289 | |
3290 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 3291 | } |
3292 | ||
ff8a8a7a | 3293 | DEFUN_YANG (no_bgp_fast_external_failover, |
718e3744 | 3294 | no_bgp_fast_external_failover_cmd, |
3295 | "no bgp fast-external-failover", | |
3296 | NO_STR | |
3297 | BGP_STR | |
3298 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3299 | { | |
87ce2564 CS |
3300 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3301 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3302 | |
3303 | return nb_cli_apply_changes(vty, NULL); | |
3304 | } | |
3305 | ||
3306 | void cli_show_router_bgp_fast_external_failover(struct vty *vty, | |
3307 | struct lyd_node *dnode, | |
3308 | bool show_defaults) | |
3309 | { | |
3310 | if (!yang_dnode_get_bool(dnode, NULL)) | |
3311 | vty_out(vty, " no bgp fast-external-failover\n"); | |
718e3744 | 3312 | } |
6b0655a2 | 3313 | |
718e3744 | 3314 | /* "bgp bestpath compare-routerid" configuration. */ |
ff8a8a7a CS |
3315 | DEFUN_YANG(bgp_bestpath_compare_router_id, |
3316 | bgp_bestpath_compare_router_id_cmd, | |
3317 | "bgp bestpath compare-routerid", | |
3318 | "BGP specific commands\n" | |
3319 | "Change the default bestpath selection\n" | |
3320 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3321 | { |
ff8a8a7a | 3322 | nb_cli_enqueue_change( |
87ce2564 CS |
3323 | vty, |
3324 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3325 | NB_OP_MODIFY, "true"); |
7aafcaca | 3326 | |
ff8a8a7a | 3327 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3328 | } |
3329 | ||
ff8a8a7a CS |
3330 | DEFUN_YANG(no_bgp_bestpath_compare_router_id, |
3331 | no_bgp_bestpath_compare_router_id_cmd, | |
3332 | "no bgp bestpath compare-routerid", | |
3333 | NO_STR | |
3334 | "BGP specific commands\n" | |
3335 | "Change the default bestpath selection\n" | |
3336 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3337 | { |
ff8a8a7a | 3338 | nb_cli_enqueue_change( |
87ce2564 CS |
3339 | vty, |
3340 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3341 | NB_OP_MODIFY, "false"); |
7aafcaca | 3342 | |
ff8a8a7a | 3343 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3344 | } |
6b0655a2 | 3345 | |
718e3744 | 3346 | /* "bgp bestpath as-path ignore" configuration. */ |
ff8a8a7a CS |
3347 | DEFUN_YANG(bgp_bestpath_aspath_ignore, |
3348 | bgp_bestpath_aspath_ignore_cmd, | |
3349 | "bgp bestpath as-path ignore", | |
3350 | "BGP specific commands\n" | |
3351 | "Change the default bestpath selection\n" | |
3352 | "AS-path attribute\n" | |
3353 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3354 | { |
87ce2564 CS |
3355 | nb_cli_enqueue_change( |
3356 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3357 | NB_OP_MODIFY, "true"); | |
7aafcaca | 3358 | |
ff8a8a7a | 3359 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3360 | } |
3361 | ||
ff8a8a7a CS |
3362 | DEFUN_YANG(no_bgp_bestpath_aspath_ignore, |
3363 | no_bgp_bestpath_aspath_ignore_cmd, | |
3364 | "no bgp bestpath as-path ignore", | |
3365 | NO_STR | |
3366 | "BGP specific commands\n" | |
3367 | "Change the default bestpath selection\n" | |
3368 | "AS-path attribute\n" | |
3369 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3370 | { |
87ce2564 CS |
3371 | nb_cli_enqueue_change( |
3372 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3373 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3374 | |
ff8a8a7a | 3375 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3376 | } |
6b0655a2 | 3377 | |
6811845b | 3378 | /* "bgp bestpath as-path confed" configuration. */ |
ff8a8a7a | 3379 | DEFUN_YANG (bgp_bestpath_aspath_confed, |
6811845b | 3380 | bgp_bestpath_aspath_confed_cmd, |
3381 | "bgp bestpath as-path confed", | |
3382 | "BGP specific commands\n" | |
3383 | "Change the default bestpath selection\n" | |
3384 | "AS-path attribute\n" | |
3385 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3386 | { | |
87ce2564 CS |
3387 | nb_cli_enqueue_change(vty, |
3388 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3389 | NB_OP_MODIFY, "true"); |
7aafcaca | 3390 | |
ff8a8a7a | 3391 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3392 | } |
3393 | ||
ff8a8a7a | 3394 | DEFUN_YANG (no_bgp_bestpath_aspath_confed, |
6811845b | 3395 | no_bgp_bestpath_aspath_confed_cmd, |
3396 | "no bgp bestpath as-path confed", | |
3397 | NO_STR | |
3398 | "BGP specific commands\n" | |
3399 | "Change the default bestpath selection\n" | |
3400 | "AS-path attribute\n" | |
3401 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3402 | { | |
87ce2564 CS |
3403 | nb_cli_enqueue_change(vty, |
3404 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3405 | NB_OP_MODIFY, "false"); |
7aafcaca | 3406 | |
ff8a8a7a | 3407 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3408 | } |
6b0655a2 | 3409 | |
2fdd455c | 3410 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
ff8a8a7a | 3411 | DEFUN_YANG (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3412 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3413 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3414 | "BGP specific commands\n" |
3415 | "Change the default bestpath selection\n" | |
3416 | "AS-path attribute\n" | |
3417 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3418 | "Generate an AS_SET\n" |
16fc1eec DS |
3419 | "Do not generate an AS_SET\n") |
3420 | { | |
d62a17ae | 3421 | int idx = 0; |
219178b6 | 3422 | |
87ce2564 CS |
3423 | nb_cli_enqueue_change( |
3424 | vty, "./global/route-selection-options/allow-multiple-as", | |
3425 | NB_OP_MODIFY, "true"); | |
d62a17ae | 3426 | if (argv_find(argv, argc, "as-set", &idx)) |
ff8a8a7a | 3427 | nb_cli_enqueue_change( |
87ce2564 CS |
3428 | vty, |
3429 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3430 | NB_OP_MODIFY, "true"); |
d62a17ae | 3431 | else |
ff8a8a7a | 3432 | nb_cli_enqueue_change( |
87ce2564 CS |
3433 | vty, |
3434 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3435 | NB_OP_MODIFY, "false"); |
7aafcaca | 3436 | |
ff8a8a7a | 3437 | return nb_cli_apply_changes(vty, NULL); |
16fc1eec DS |
3438 | } |
3439 | ||
ff8a8a7a | 3440 | DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3441 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3442 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3443 | NO_STR |
3444 | "BGP specific commands\n" | |
3445 | "Change the default bestpath selection\n" | |
3446 | "AS-path attribute\n" | |
3447 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3448 | "Generate an AS_SET\n" |
16fc1eec DS |
3449 | "Do not generate an AS_SET\n") |
3450 | { | |
87ce2564 CS |
3451 | nb_cli_enqueue_change( |
3452 | vty, "./global/route-selection-options/allow-multiple-as", | |
3453 | NB_OP_MODIFY, "false"); | |
3454 | nb_cli_enqueue_change( | |
3455 | vty, "./global/route-selection-options/multi-path-as-set", | |
3456 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3457 | |
ff8a8a7a | 3458 | return nb_cli_apply_changes(vty, NULL); |
2fdd455c | 3459 | } |
6b0655a2 | 3460 | |
848973c7 | 3461 | /* "bgp log-neighbor-changes" configuration. */ |
ff8a8a7a CS |
3462 | DEFUN_YANG(bgp_log_neighbor_changes, |
3463 | bgp_log_neighbor_changes_cmd, | |
3464 | "bgp log-neighbor-changes", | |
3465 | "BGP specific commands\n" | |
3466 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3467 | { |
87ce2564 CS |
3468 | nb_cli_enqueue_change( |
3469 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3470 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3471 | |
3472 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3473 | } |
3474 | ||
ff8a8a7a CS |
3475 | DEFUN_YANG(no_bgp_log_neighbor_changes, |
3476 | no_bgp_log_neighbor_changes_cmd, | |
3477 | "no bgp log-neighbor-changes", | |
3478 | NO_STR | |
3479 | "BGP specific commands\n" | |
3480 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3481 | { |
87ce2564 CS |
3482 | nb_cli_enqueue_change( |
3483 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3484 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3485 | |
3486 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3487 | } |
6b0655a2 | 3488 | |
718e3744 | 3489 | /* "bgp bestpath med" configuration. */ |
ff8a8a7a | 3490 | DEFUN_YANG (bgp_bestpath_med, |
718e3744 | 3491 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3492 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3493 | "BGP specific commands\n" |
3494 | "Change the default bestpath selection\n" | |
3495 | "MED attribute\n" | |
3496 | "Compare MED among confederation paths\n" | |
838758ac DW |
3497 | "Treat missing MED as the least preferred one\n" |
3498 | "Treat missing MED as the least preferred one\n" | |
3499 | "Compare MED among confederation paths\n") | |
718e3744 | 3500 | { |
d62a17ae | 3501 | int idx = 0; |
ff8a8a7a CS |
3502 | bool confed = false; |
3503 | bool worst_med = false; | |
3504 | ||
3505 | ||
d62a17ae | 3506 | if (argv_find(argv, argc, "confed", &idx)) |
ff8a8a7a CS |
3507 | confed = true; |
3508 | ||
87ce2564 CS |
3509 | nb_cli_enqueue_change(vty, |
3510 | "./global/route-selection-options/confed-med", | |
ff8a8a7a CS |
3511 | NB_OP_MODIFY, confed ? "true" : "false"); |
3512 | ||
d62a17ae | 3513 | idx = 0; |
3514 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3515 | worst_med = true; |
e52702f2 | 3516 | |
87ce2564 CS |
3517 | nb_cli_enqueue_change( |
3518 | vty, "./global/route-selection-options/missing-as-worst-med", | |
3519 | NB_OP_MODIFY, worst_med ? "true" : "false"); | |
7aafcaca | 3520 | |
ff8a8a7a | 3521 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3522 | } |
3523 | ||
ff8a8a7a | 3524 | DEFUN_YANG (no_bgp_bestpath_med, |
718e3744 | 3525 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3526 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3527 | NO_STR |
3528 | "BGP specific commands\n" | |
3529 | "Change the default bestpath selection\n" | |
3530 | "MED attribute\n" | |
3531 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3532 | "Treat missing MED as the least preferred one\n" |
3533 | "Treat missing MED as the least preferred one\n" | |
3534 | "Compare MED among confederation paths\n") | |
718e3744 | 3535 | { |
d62a17ae | 3536 | int idx = 0; |
ff8a8a7a | 3537 | |
d62a17ae | 3538 | if (argv_find(argv, argc, "confed", &idx)) |
87ce2564 CS |
3539 | nb_cli_enqueue_change( |
3540 | vty, "./global/route-selection-options/confed-med", | |
3541 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 3542 | |
d62a17ae | 3543 | idx = 0; |
3544 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3545 | nb_cli_enqueue_change( |
87ce2564 CS |
3546 | vty, |
3547 | "./global/route-selection-options/missing-as-worst-med", | |
ff8a8a7a | 3548 | NB_OP_MODIFY, "false"); |
718e3744 | 3549 | |
ff8a8a7a | 3550 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3551 | } |
3552 | ||
f7e1c681 | 3553 | /* "bgp bestpath bandwidth" configuration. */ |
3554 | DEFPY (bgp_bestpath_bw, | |
3555 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3556 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
f7e1c681 | 3557 | "BGP specific commands\n" |
3558 | "Change the default bestpath selection\n" | |
3559 | "Link Bandwidth attribute\n" | |
3560 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3561 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3562 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3563 | { | |
3564 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3565 | afi_t afi; | |
3566 | safi_t safi; | |
3567 | ||
ad36d216 DS |
3568 | if (!bw_cfg) { |
3569 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3570 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3571 | } |
ad36d216 DS |
3572 | if (!strcmp(bw_cfg, "ignore")) |
3573 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3574 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3575 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3576 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3577 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3578 | else | |
3579 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3580 | |
3581 | /* This config is used in route install, so redo that. */ | |
3582 | FOREACH_AFI_SAFI (afi, safi) { | |
3583 | if (!bgp_fibupd_safi(safi)) | |
3584 | continue; | |
3585 | bgp_zebra_announce_table(bgp, afi, safi); | |
3586 | } | |
3587 | ||
3588 | return CMD_SUCCESS; | |
3589 | } | |
3590 | ||
ad36d216 DS |
3591 | DEFPY (no_bgp_bestpath_bw, |
3592 | no_bgp_bestpath_bw_cmd, | |
3593 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3594 | NO_STR | |
3595 | "BGP specific commands\n" | |
3596 | "Change the default bestpath selection\n" | |
3597 | "Link Bandwidth attribute\n" | |
3598 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3599 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3600 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3601 | { | |
3602 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3603 | afi_t afi; | |
3604 | safi_t safi; | |
3605 | ||
3606 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3607 | ||
3608 | /* This config is used in route install, so redo that. */ | |
3609 | FOREACH_AFI_SAFI (afi, safi) { | |
3610 | if (!bgp_fibupd_safi(safi)) | |
3611 | continue; | |
3612 | bgp_zebra_announce_table(bgp, afi, safi); | |
3613 | } | |
3614 | return CMD_SUCCESS; | |
3615 | } | |
3616 | ||
718e3744 | 3617 | /* "no bgp default ipv4-unicast". */ |
3618 | DEFUN (no_bgp_default_ipv4_unicast, | |
3619 | no_bgp_default_ipv4_unicast_cmd, | |
3620 | "no bgp default ipv4-unicast", | |
3621 | NO_STR | |
3622 | "BGP specific commands\n" | |
3623 | "Configure BGP defaults\n" | |
3624 | "Activate ipv4-unicast for a peer by default\n") | |
3625 | { | |
d62a17ae | 3626 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3627 | SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3628 | return CMD_SUCCESS; |
718e3744 | 3629 | } |
3630 | ||
3631 | DEFUN (bgp_default_ipv4_unicast, | |
3632 | bgp_default_ipv4_unicast_cmd, | |
3633 | "bgp default ipv4-unicast", | |
3634 | "BGP specific commands\n" | |
3635 | "Configure BGP defaults\n" | |
3636 | "Activate ipv4-unicast for a peer by default\n") | |
3637 | { | |
d62a17ae | 3638 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3639 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3640 | return CMD_SUCCESS; |
718e3744 | 3641 | } |
6b0655a2 | 3642 | |
04b6bdc0 | 3643 | /* Display hostname in certain command outputs */ |
ff8a8a7a | 3644 | DEFUN_YANG (bgp_default_show_hostname, |
04b6bdc0 DW |
3645 | bgp_default_show_hostname_cmd, |
3646 | "bgp default show-hostname", | |
3647 | "BGP specific commands\n" | |
3648 | "Configure BGP defaults\n" | |
0437e105 | 3649 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3650 | { |
87ce2564 CS |
3651 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3652 | "true"); | |
ff8a8a7a CS |
3653 | |
3654 | return nb_cli_apply_changes(vty, NULL); | |
04b6bdc0 DW |
3655 | } |
3656 | ||
ff8a8a7a CS |
3657 | DEFUN_YANG(no_bgp_default_show_hostname, |
3658 | no_bgp_default_show_hostname_cmd, | |
3659 | "no bgp default show-hostname", | |
3660 | NO_STR | |
3661 | "BGP specific commands\n" | |
3662 | "Configure BGP defaults\n" | |
3663 | "Show hostname in certain command outputs\n") | |
04b6bdc0 | 3664 | { |
87ce2564 CS |
3665 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3666 | "false"); | |
ff8a8a7a CS |
3667 | |
3668 | return nb_cli_apply_changes(vty, NULL); | |
3669 | } | |
3670 | ||
3671 | void cli_show_router_bgp_show_hostname(struct vty *vty, struct lyd_node *dnode, | |
3672 | bool show_defaults) | |
3673 | { | |
3674 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3675 | vty_out(vty, " bgp default show-hostname\n"); | |
04b6bdc0 DW |
3676 | } |
3677 | ||
aef999a2 DA |
3678 | /* Display hostname in certain command outputs */ |
3679 | DEFUN (bgp_default_show_nexthop_hostname, | |
3680 | bgp_default_show_nexthop_hostname_cmd, | |
3681 | "bgp default show-nexthop-hostname", | |
3682 | "BGP specific commands\n" | |
3683 | "Configure BGP defaults\n" | |
3684 | "Show hostname for nexthop in certain command outputs\n") | |
3685 | { | |
87ce2564 CS |
3686 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3687 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3688 | |
3689 | return nb_cli_apply_changes(vty, NULL); | |
aef999a2 DA |
3690 | } |
3691 | ||
3692 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3693 | no_bgp_default_show_nexthop_hostname_cmd, | |
3694 | "no bgp default show-nexthop-hostname", | |
3695 | NO_STR | |
3696 | "BGP specific commands\n" | |
3697 | "Configure BGP defaults\n" | |
3698 | "Show hostname for nexthop in certain command outputs\n") | |
3699 | { | |
87ce2564 CS |
3700 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3701 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3702 | |
3703 | return nb_cli_apply_changes(vty, NULL); | |
3704 | } | |
3705 | ||
3706 | void cli_show_router_bgp_show_nexthop_hostname(struct vty *vty, | |
3707 | struct lyd_node *dnode, | |
3708 | bool show_defaults) | |
3709 | { | |
3710 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3711 | vty_out(vty, " bgp default show-nexthop-hostname\n"); | |
aef999a2 DA |
3712 | } |
3713 | ||
8233ef81 | 3714 | /* "bgp network import-check" configuration. */ |
ff8a8a7a CS |
3715 | DEFUN_YANG(bgp_network_import_check, |
3716 | bgp_network_import_check_cmd, | |
3717 | "bgp network import-check", | |
3718 | "BGP specific commands\n" | |
3719 | "BGP network command\n" | |
3720 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3721 | { |
87ce2564 CS |
3722 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3723 | "true"); | |
078430f6 | 3724 | |
ff8a8a7a | 3725 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3726 | } |
3727 | ||
d62a17ae | 3728 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3729 | "bgp network import-check exact", | |
3730 | "BGP specific commands\n" | |
3731 | "BGP network command\n" | |
3732 | "Check BGP network route exists in IGP\n" | |
3733 | "Match route precisely\n") | |
8233ef81 | 3734 | |
ff8a8a7a CS |
3735 | DEFUN_YANG(no_bgp_network_import_check, |
3736 | no_bgp_network_import_check_cmd, | |
3737 | "no bgp network import-check", | |
3738 | NO_STR | |
3739 | "BGP specific commands\n" | |
3740 | "BGP network command\n" | |
3741 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3742 | { |
87ce2564 CS |
3743 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3744 | "false"); | |
5623e905 | 3745 | |
ff8a8a7a | 3746 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3747 | } |
6b0655a2 | 3748 | |
ff8a8a7a CS |
3749 | void cli_show_router_bgp_import_check(struct vty *vty, struct lyd_node *dnode, |
3750 | bool show_defaults) | |
718e3744 | 3751 | { |
ff8a8a7a CS |
3752 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_IMPORT_CHECK) |
3753 | vty_out(vty, " bgp network import-check\n"); | |
3754 | } | |
718e3744 | 3755 | |
ff8a8a7a CS |
3756 | DEFUN_YANG(bgp_default_local_preference, |
3757 | bgp_default_local_preference_cmd, | |
3758 | "bgp default local-preference (0-4294967295)", | |
3759 | "BGP specific commands\n" | |
3760 | "Configure BGP defaults\n" | |
3761 | "local preference (higher=more preferred)\n" | |
3762 | "Configure default local preference value\n") | |
3763 | { | |
3764 | int idx_number = 3; | |
718e3744 | 3765 | |
87ce2564 | 3766 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, |
ff8a8a7a | 3767 | argv[idx_number]->arg); |
718e3744 | 3768 | |
ff8a8a7a | 3769 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3770 | } |
3771 | ||
ff8a8a7a CS |
3772 | DEFUN_YANG(no_bgp_default_local_preference, |
3773 | no_bgp_default_local_preference_cmd, | |
3774 | "no bgp default local-preference [(0-4294967295)]", | |
3775 | NO_STR | |
3776 | "BGP specific commands\n" | |
3777 | "Configure BGP defaults\n" | |
3778 | "local preference (higher=more preferred)\n" | |
3779 | "Configure default local preference value\n") | |
718e3744 | 3780 | { |
87ce2564 | 3781 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, NULL); |
7aafcaca | 3782 | |
ff8a8a7a | 3783 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3784 | } |
3785 | ||
ff8a8a7a CS |
3786 | void cli_show_router_bgp_local_pref(struct vty *vty, struct lyd_node *dnode, |
3787 | bool show_defaults) | |
3788 | { | |
3789 | vty_out(vty, " bgp default local-preference %u\n", | |
3790 | yang_dnode_get_uint32(dnode, NULL)); | |
3791 | } | |
6b0655a2 | 3792 | |
ff8a8a7a CS |
3793 | |
3794 | DEFUN_YANG(bgp_default_subgroup_pkt_queue_max, | |
3795 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3796 | "bgp default subgroup-pkt-queue-max (20-100)", | |
3797 | "BGP specific commands\n" | |
3798 | "Configure BGP defaults\n" | |
3799 | "subgroup-pkt-queue-max\n" | |
3800 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3801 | { |
d62a17ae | 3802 | int idx_number = 3; |
3f9c7369 | 3803 | |
ff8a8a7a | 3804 | nb_cli_enqueue_change( |
87ce2564 CS |
3805 | vty, |
3806 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a | 3807 | NB_OP_MODIFY, argv[idx_number]->arg); |
3f9c7369 | 3808 | |
ff8a8a7a | 3809 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
3810 | } |
3811 | ||
ff8a8a7a CS |
3812 | DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max, |
3813 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
3814 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
3815 | NO_STR | |
3816 | "BGP specific commands\n" | |
3817 | "Configure BGP defaults\n" | |
3818 | "subgroup-pkt-queue-max\n" | |
3819 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3820 | { |
ff8a8a7a | 3821 | nb_cli_enqueue_change( |
87ce2564 CS |
3822 | vty, |
3823 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a CS |
3824 | NB_OP_MODIFY, NULL); |
3825 | ||
3826 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
3827 | } |
3828 | ||
ff8a8a7a CS |
3829 | void cli_show_router_global_update_group_config_subgroup_pkt_queue_size( |
3830 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3831 | { | |
3832 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
3833 | yang_dnode_get_uint32(dnode, NULL)); | |
3834 | } | |
813d4307 | 3835 | |
ff8a8a7a CS |
3836 | DEFUN_YANG(bgp_rr_allow_outbound_policy, |
3837 | bgp_rr_allow_outbound_policy_cmd, | |
3838 | "bgp route-reflector allow-outbound-policy", | |
3839 | "BGP specific commands\n" | |
3840 | "Allow modifications made by out route-map\n" | |
3841 | "on ibgp neighbors\n") | |
8bd9d948 | 3842 | { |
87ce2564 CS |
3843 | nb_cli_enqueue_change(vty, |
3844 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a | 3845 | NB_OP_MODIFY, "true"); |
8bd9d948 | 3846 | |
ff8a8a7a CS |
3847 | return nb_cli_apply_changes(vty, NULL); |
3848 | } | |
8bd9d948 | 3849 | |
ff8a8a7a CS |
3850 | DEFUN_YANG(no_bgp_rr_allow_outbound_policy, |
3851 | no_bgp_rr_allow_outbound_policy_cmd, | |
3852 | "no bgp route-reflector allow-outbound-policy", | |
3853 | NO_STR | |
3854 | "BGP specific commands\n" | |
3855 | "Allow modifications made by out route-map\n" | |
3856 | "on ibgp neighbors\n") | |
3857 | { | |
87ce2564 CS |
3858 | nb_cli_enqueue_change(vty, |
3859 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a CS |
3860 | NB_OP_MODIFY, "false"); |
3861 | ||
3862 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
3863 | } |
3864 | ||
ff8a8a7a CS |
3865 | |
3866 | void cli_show_router_global_neighbor_config(struct vty *vty, | |
3867 | struct lyd_node *dnode, | |
3868 | bool show_defaults) | |
8bd9d948 | 3869 | { |
ff8a8a7a CS |
3870 | uint32_t write_quanta, read_quanta; |
3871 | ||
3872 | if (yang_dnode_get_bool(dnode, "./log-neighbor-changes")) | |
3873 | vty_out(vty, " bgp log-neighbor-changes\n"); | |
8bd9d948 | 3874 | |
ff8a8a7a CS |
3875 | if (yang_dnode_exists(dnode, "./dynamic-neighbors-limit")) { |
3876 | uint32_t listen_limit = yang_dnode_get_uint32( | |
3877 | dnode, "./dynamic-neighbors-limit"); | |
3878 | vty_out(vty, " bgp listen limit %u\n", listen_limit); | |
d62a17ae | 3879 | } |
8bd9d948 | 3880 | |
ff8a8a7a CS |
3881 | write_quanta = yang_dnode_get_uint32( |
3882 | dnode, "./packet-quanta-config/wpkt-quanta"); | |
3883 | if (write_quanta != BGP_WRITE_PACKET_MAX) | |
3884 | vty_out(vty, " write-quanta %d\n", write_quanta); | |
3885 | ||
3886 | read_quanta = yang_dnode_get_uint32( | |
3887 | dnode, "./packet-quanta-config/rpkt-quanta"); | |
3888 | ||
3889 | if (read_quanta != BGP_READ_PACKET_MAX) | |
3890 | vty_out(vty, " read-quanta %d\n", read_quanta); | |
8bd9d948 DS |
3891 | } |
3892 | ||
ff8a8a7a CS |
3893 | DEFUN_YANG(bgp_listen_limit, |
3894 | bgp_listen_limit_cmd, | |
3895 | "bgp listen limit (1-5000)", | |
3896 | "BGP specific commands\n" | |
3897 | "BGP Dynamic Neighbors listen commands\n" | |
3898 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3899 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3900 | { |
d62a17ae | 3901 | int idx_number = 3; |
f14e6fdb | 3902 | |
ff8a8a7a | 3903 | nb_cli_enqueue_change( |
87ce2564 | 3904 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a | 3905 | NB_OP_MODIFY, argv[idx_number]->arg); |
f14e6fdb | 3906 | |
ff8a8a7a | 3907 | return nb_cli_apply_changes(vty, NULL); |
f14e6fdb DS |
3908 | } |
3909 | ||
ff8a8a7a CS |
3910 | DEFUN_YANG(no_bgp_listen_limit, |
3911 | no_bgp_listen_limit_cmd, | |
3912 | "no bgp listen limit [(1-5000)]", | |
3913 | NO_STR | |
3914 | "BGP specific commands\n" | |
3915 | "BGP Dynamic Neighbors listen commands\n" | |
3916 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3917 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3918 | { |
ff8a8a7a | 3919 | nb_cli_enqueue_change( |
87ce2564 | 3920 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a CS |
3921 | NB_OP_DESTROY, NULL); |
3922 | ||
3923 | return nb_cli_apply_changes(vty, NULL); | |
f14e6fdb DS |
3924 | } |
3925 | ||
3926 | ||
20eb8864 | 3927 | /* |
3928 | * Check if this listen range is already configured. Check for exact | |
3929 | * match or overlap based on input. | |
3930 | */ | |
d62a17ae | 3931 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3932 | struct prefix *range, int exact) | |
3933 | { | |
3934 | struct listnode *node, *nnode; | |
3935 | struct listnode *node1, *nnode1; | |
3936 | struct peer_group *group; | |
3937 | struct prefix *lr; | |
3938 | afi_t afi; | |
3939 | int match; | |
3940 | ||
3941 | afi = family2afi(range->family); | |
3942 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3943 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3944 | lr)) { | |
3945 | if (exact) | |
3946 | match = prefix_same(range, lr); | |
3947 | else | |
3948 | match = (prefix_match(range, lr) | |
3949 | || prefix_match(lr, range)); | |
3950 | if (match) | |
3951 | return group; | |
3952 | } | |
3953 | } | |
3954 | ||
3955 | return NULL; | |
20eb8864 | 3956 | } |
3957 | ||
f14e6fdb DS |
3958 | DEFUN (bgp_listen_range, |
3959 | bgp_listen_range_cmd, | |
d7b9898c | 3960 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3961 | "BGP specific commands\n" |
d7fa34c1 QY |
3962 | "Configure BGP dynamic neighbors listen range\n" |
3963 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3964 | NEIGHBOR_ADDR_STR |
3965 | "Member of the peer-group\n" | |
3966 | "Peer-group name\n") | |
f14e6fdb | 3967 | { |
d62a17ae | 3968 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3969 | struct prefix range; | |
3970 | struct peer_group *group, *existing_group; | |
3971 | afi_t afi; | |
3972 | int ret; | |
3973 | int idx = 0; | |
3974 | ||
3975 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3976 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3977 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3978 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3979 | char *peergroup = argv[idx]->arg; |
3980 | ||
3981 | /* Convert IP prefix string to struct prefix. */ | |
3982 | ret = str2prefix(prefix, &range); | |
3983 | if (!ret) { | |
3984 | vty_out(vty, "%% Malformed listen range\n"); | |
3985 | return CMD_WARNING_CONFIG_FAILED; | |
3986 | } | |
3987 | ||
3988 | afi = family2afi(range.family); | |
3989 | ||
3990 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3991 | vty_out(vty, | |
3992 | "%% Malformed listen range (link-local address)\n"); | |
3993 | return CMD_WARNING_CONFIG_FAILED; | |
3994 | } | |
3995 | ||
3996 | apply_mask(&range); | |
3997 | ||
3998 | /* Check if same listen range is already configured. */ | |
3999 | existing_group = listen_range_exists(bgp, &range, 1); | |
4000 | if (existing_group) { | |
4001 | if (strcmp(existing_group->name, peergroup) == 0) | |
4002 | return CMD_SUCCESS; | |
4003 | else { | |
4004 | vty_out(vty, | |
4005 | "%% Same listen range is attached to peer-group %s\n", | |
4006 | existing_group->name); | |
4007 | return CMD_WARNING_CONFIG_FAILED; | |
4008 | } | |
4009 | } | |
4010 | ||
4011 | /* Check if an overlapping listen range exists. */ | |
4012 | if (listen_range_exists(bgp, &range, 0)) { | |
4013 | vty_out(vty, | |
4014 | "%% Listen range overlaps with existing listen range\n"); | |
4015 | return CMD_WARNING_CONFIG_FAILED; | |
4016 | } | |
4017 | ||
4018 | group = peer_group_lookup(bgp, peergroup); | |
4019 | if (!group) { | |
4020 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4021 | return CMD_WARNING_CONFIG_FAILED; | |
4022 | } | |
4023 | ||
4024 | ret = peer_group_listen_range_add(group, &range); | |
4025 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4026 | } |
4027 | ||
4028 | DEFUN (no_bgp_listen_range, | |
4029 | no_bgp_listen_range_cmd, | |
d7b9898c | 4030 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4031 | NO_STR |
f14e6fdb | 4032 | "BGP specific commands\n" |
d7fa34c1 QY |
4033 | "Unconfigure BGP dynamic neighbors listen range\n" |
4034 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4035 | NEIGHBOR_ADDR_STR | |
4036 | "Member of the peer-group\n" | |
4037 | "Peer-group name\n") | |
f14e6fdb | 4038 | { |
d62a17ae | 4039 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4040 | struct prefix range; | |
4041 | struct peer_group *group; | |
4042 | afi_t afi; | |
4043 | int ret; | |
4044 | int idx = 0; | |
4045 | ||
4046 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4047 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4048 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4049 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4050 | char *peergroup = argv[idx]->arg; |
4051 | ||
4052 | /* Convert IP prefix string to struct prefix. */ | |
4053 | ret = str2prefix(prefix, &range); | |
4054 | if (!ret) { | |
4055 | vty_out(vty, "%% Malformed listen range\n"); | |
4056 | return CMD_WARNING_CONFIG_FAILED; | |
4057 | } | |
4058 | ||
4059 | afi = family2afi(range.family); | |
4060 | ||
4061 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4062 | vty_out(vty, | |
4063 | "%% Malformed listen range (link-local address)\n"); | |
4064 | return CMD_WARNING_CONFIG_FAILED; | |
4065 | } | |
4066 | ||
4067 | apply_mask(&range); | |
4068 | ||
4069 | group = peer_group_lookup(bgp, peergroup); | |
4070 | if (!group) { | |
4071 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4072 | return CMD_WARNING_CONFIG_FAILED; | |
4073 | } | |
4074 | ||
4075 | ret = peer_group_listen_range_del(group, &range); | |
4076 | return bgp_vty_return(vty, ret); | |
4077 | } | |
4078 | ||
2b791107 | 4079 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4080 | { |
4081 | struct peer_group *group; | |
4082 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4083 | struct prefix *range; | |
4084 | afi_t afi; | |
d62a17ae | 4085 | |
4086 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4087 | vty_out(vty, " bgp listen limit %d\n", | |
4088 | bgp->dynamic_neighbors_limit); | |
4089 | ||
4090 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4091 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4092 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4093 | nrnode, range)) { | |
d62a17ae | 4094 | vty_out(vty, |
2dbe669b DA |
4095 | " bgp listen range %pFX peer-group %s\n", |
4096 | range, group->name); | |
d62a17ae | 4097 | } |
4098 | } | |
4099 | } | |
f14e6fdb DS |
4100 | } |
4101 | ||
4102 | ||
ff8a8a7a CS |
4103 | DEFUN_YANG(bgp_disable_connected_route_check, |
4104 | bgp_disable_connected_route_check_cmd, | |
4105 | "bgp disable-ebgp-connected-route-check", | |
4106 | "BGP specific commands\n" | |
4107 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 4108 | { |
87ce2564 CS |
4109 | nb_cli_enqueue_change(vty, |
4110 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 4111 | NB_OP_MODIFY, "true"); |
7aafcaca | 4112 | |
ff8a8a7a | 4113 | return nb_cli_apply_changes(vty, NULL); |
907f92c8 DS |
4114 | } |
4115 | ||
ff8a8a7a CS |
4116 | DEFUN_YANG(no_bgp_disable_connected_route_check, |
4117 | no_bgp_disable_connected_route_check_cmd, | |
4118 | "no bgp disable-ebgp-connected-route-check", | |
4119 | NO_STR | |
4120 | "BGP specific commands\n" | |
4121 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 4122 | { |
87ce2564 CS |
4123 | nb_cli_enqueue_change(vty, |
4124 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 4125 | NB_OP_MODIFY, "false"); |
d62a17ae | 4126 | |
ff8a8a7a | 4127 | return nb_cli_apply_changes(vty, NULL); |
d62a17ae | 4128 | } |
4129 | ||
ff8a8a7a CS |
4130 | void cli_show_router_global_ebgp_multihop_connected_route_check( |
4131 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
4132 | { | |
4133 | if (yang_dnode_get_bool(dnode, NULL)) | |
4134 | vty_out(vty, " bgp disable-ebgp-connected-route-check\n"); | |
4135 | } | |
d62a17ae | 4136 | |
ff8a8a7a CS |
4137 | DEFUN_YANG(bgp_default_shutdown, |
4138 | bgp_default_shutdown_cmd, | |
4139 | "[no] bgp default shutdown", | |
4140 | NO_STR BGP_STR | |
4141 | "Configure BGP defaults\n" | |
4142 | "Apply administrative shutdown to newly configured peers\n") | |
f26845f9 | 4143 | { |
87ce2564 | 4144 | nb_cli_enqueue_change(vty, "./global/default-shutdown", NB_OP_MODIFY, |
ff8a8a7a CS |
4145 | strmatch(argv[0]->text, "no") ? "false" : "true"); |
4146 | ||
4147 | return nb_cli_apply_changes(vty, NULL); | |
4148 | } | |
4149 | ||
4150 | void cli_show_router_bgp_default_shutdown(struct vty *vty, | |
4151 | struct lyd_node *dnode, | |
4152 | bool show_defaults) | |
4153 | { | |
4154 | if (yang_dnode_get_bool(dnode, NULL)) | |
4155 | vty_out(vty, " bgp default shutdown\n"); | |
f26845f9 QY |
4156 | } |
4157 | ||
736b68f3 DS |
4158 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4159 | BGP_STR | |
9ddf4b81 | 4160 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4161 | "Add a shutdown message (RFC 8203)\n" |
4162 | "Shutdown message\n") | |
9cf59432 | 4163 | { |
736b68f3 | 4164 | char *msgstr = NULL; |
8389c83a | 4165 | |
9cf59432 DS |
4166 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4167 | ||
8389c83a | 4168 | if (argc > 3) |
f80e35b6 | 4169 | msgstr = argv_concat(argv, argc, 3); |
8389c83a DS |
4170 | |
4171 | bgp_shutdown_enable(bgp, msgstr); | |
4172 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4173 | |
4174 | return CMD_SUCCESS; | |
4175 | } | |
4176 | ||
736b68f3 | 4177 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4178 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4179 | { |
4180 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4181 | ||
4182 | bgp_shutdown_enable(bgp, NULL); | |
4183 | ||
4184 | return CMD_SUCCESS; | |
4185 | } | |
8389c83a | 4186 | |
736b68f3 | 4187 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4188 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4189 | { |
4190 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4191 | ||
4192 | bgp_shutdown_disable(bgp); | |
4193 | ||
4194 | return CMD_SUCCESS; | |
4195 | } | |
4196 | ||
9ddf4b81 | 4197 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4198 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4199 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4200 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4201 | |
f4b8ec07 CS |
4202 | DEFUN_YANG(neighbor_remote_as, |
4203 | neighbor_remote_as_cmd, | |
4204 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4205 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4206 | "Specify a BGP neighbor\n" AS_STR | |
4207 | "Internal BGP peer\n" | |
4208 | "External BGP peer\n") | |
718e3744 | 4209 | { |
d62a17ae | 4210 | int idx_peer = 1; |
4211 | int idx_remote_as = 3; | |
f4b8ec07 CS |
4212 | char base_xpath[XPATH_MAXLEN]; |
4213 | char unnbr_xpath[XPATH_MAXLEN]; | |
4214 | char prgrp_xpath[XPATH_MAXLEN]; | |
4215 | union sockunion su; | |
4216 | const char *as_type_str = "as-specified"; | |
4217 | ||
4218 | if (str2sockunion(argv[idx_peer]->arg, &su) < 0) { | |
4219 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
4220 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, argv[idx_peer]->arg, ""); | |
4221 | ||
4222 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
4223 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, ""); | |
4224 | ||
4225 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4226 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
4227 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); | |
4228 | } else if (yang_dnode_exists(vty->candidate_config->dnode, | |
4229 | "%s%s", VTY_CURR_XPATH, | |
4230 | prgrp_xpath + 1)) { | |
4231 | snprintf(base_xpath, sizeof(base_xpath), | |
4232 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, | |
4233 | ""); | |
4234 | } else { | |
4235 | vty_out(vty, | |
4236 | "%% Create the peer-group or interface first\n"); | |
4237 | return CMD_WARNING_CONFIG_FAILED; | |
4238 | } | |
4239 | } else { | |
4240 | snprintf(base_xpath, sizeof(base_xpath), | |
4241 | FRR_BGP_NEIGHBOR_NUM_XPATH, argv[idx_peer]->arg, ""); | |
4242 | } | |
4243 | ||
4244 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4245 | as_type_str = "internal"; | |
4246 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4247 | as_type_str = "external"; | |
4248 | } else { | |
4249 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4250 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4251 | } | |
4252 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4253 | NB_OP_MODIFY, as_type_str); | |
4254 | ||
4255 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 4256 | } |
4257 | ||
f4b8ec07 CS |
4258 | int peer_conf_interface_create(struct bgp *bgp, const char *conf_if, afi_t afi, |
4259 | safi_t safi, bool v6only, | |
4260 | const char *peer_group_name, int as_type, | |
4261 | as_t as, char *errmsg, size_t errmsg_len) | |
d62a17ae | 4262 | { |
d62a17ae | 4263 | struct peer *peer; |
4264 | struct peer_group *group; | |
4265 | int ret = 0; | |
4266 | union sockunion su; | |
4267 | ||
4268 | group = peer_group_lookup(bgp, conf_if); | |
4269 | ||
4270 | if (group) { | |
f4b8ec07 CS |
4271 | snprintf(errmsg, errmsg_len, |
4272 | "Name conflict with peer-group \n"); | |
4273 | return -1; | |
d62a17ae | 4274 | } |
4275 | ||
4276 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4277 | if (peer) { | |
f4b8ec07 | 4278 | if (as_type != AS_UNSPECIFIED) |
cc4d4ce8 | 4279 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 4280 | afi, safi); |
4281 | } else { | |
892fedb6 | 4282 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4) |
d62a17ae | 4283 | && afi == AFI_IP && safi == SAFI_UNICAST) |
4284 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
4285 | as_type, 0, 0, NULL); | |
4286 | else | |
4287 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
4288 | as_type, afi, safi, NULL); | |
4289 | ||
4290 | if (!peer) { | |
f4b8ec07 CS |
4291 | snprintf(errmsg, errmsg_len, |
4292 | "BGP failed to create peer\n"); | |
4293 | return -1; | |
d62a17ae | 4294 | } |
4295 | ||
4296 | if (v6only) | |
527de3dc | 4297 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4298 | |
4299 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4300 | * this | |
4301 | * any unnumbered peer in order to not worry about run-time | |
4302 | * transitions | |
4303 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4304 | * address | |
4305 | * gets deleted later etc.) | |
4306 | */ | |
4307 | if (peer->ifp) | |
4308 | bgp_zebra_initiate_radv(bgp, peer); | |
4309 | } | |
4310 | ||
4311 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4312 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4313 | if (v6only) | |
527de3dc | 4314 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4315 | else |
527de3dc | 4316 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4317 | |
4318 | /* v6only flag changed. Reset bgp seesion */ | |
4319 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4320 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4321 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4322 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4323 | } else | |
4324 | bgp_session_reset(peer); | |
4325 | } | |
4326 | ||
9fb964de PM |
4327 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4328 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4329 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4330 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4331 | } |
d62a17ae | 4332 | |
4333 | if (peer_group_name) { | |
4334 | group = peer_group_lookup(bgp, peer_group_name); | |
4335 | if (!group) { | |
f4b8ec07 CS |
4336 | snprintf(errmsg, errmsg_len, |
4337 | "Configure the peer-group first\n"); | |
4338 | return -1; | |
d62a17ae | 4339 | } |
4340 | ||
4341 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4342 | } | |
4343 | ||
f4b8ec07 | 4344 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); |
a80beece DS |
4345 | } |
4346 | ||
f4b8ec07 CS |
4347 | DEFUN_YANG(neighbor_interface_config, neighbor_interface_config_cmd, |
4348 | "neighbor WORD interface [peer-group PGNAME]", | |
4349 | NEIGHBOR_STR | |
4350 | "Interface name or neighbor tag\n" | |
4351 | "Enable BGP on interface\n" | |
4352 | "Member of the peer-group\n" | |
4353 | "Peer-group name\n") | |
4c48cf63 | 4354 | { |
d62a17ae | 4355 | int idx_word = 1; |
4356 | int idx_peer_group_word = 4; | |
f4b8ec07 CS |
4357 | char base_xpath[XPATH_MAXLEN]; |
4358 | ||
4359 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4360 | argv[idx_word]->arg, ""); | |
31500417 | 4361 | |
f4b8ec07 | 4362 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
d62a17ae | 4363 | if (argc > idx_peer_group_word) |
f4b8ec07 CS |
4364 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4365 | argv[idx_peer_group_word]->arg); | |
4366 | ||
4367 | return nb_cli_apply_changes(vty, base_xpath); | |
4c48cf63 DW |
4368 | } |
4369 | ||
f4b8ec07 CS |
4370 | DEFUN_YANG(neighbor_interface_config_v6only, |
4371 | neighbor_interface_config_v6only_cmd, | |
4372 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4373 | NEIGHBOR_STR | |
4374 | "Interface name or neighbor tag\n" | |
4375 | "Enable BGP on interface\n" | |
4376 | "Enable BGP with v6 link-local only\n" | |
4377 | "Member of the peer-group\n" | |
4378 | "Peer-group name\n") | |
4c48cf63 | 4379 | { |
d62a17ae | 4380 | int idx_word = 1; |
4381 | int idx_peer_group_word = 5; | |
f4b8ec07 CS |
4382 | char base_xpath[XPATH_MAXLEN]; |
4383 | ||
4384 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4385 | argv[idx_word]->arg, ""); | |
31500417 | 4386 | |
f4b8ec07 | 4387 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
d62a17ae | 4388 | if (argc > idx_peer_group_word) |
f4b8ec07 CS |
4389 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4390 | argv[idx_peer_group_word]->arg); | |
31500417 | 4391 | |
f4b8ec07 CS |
4392 | nb_cli_enqueue_change(vty, "./v6only", NB_OP_MODIFY, "true"); |
4393 | ||
4394 | return nb_cli_apply_changes(vty, base_xpath); | |
4c48cf63 DW |
4395 | } |
4396 | ||
a80beece | 4397 | |
f4b8ec07 CS |
4398 | DEFUN_YANG( |
4399 | neighbor_interface_config_remote_as, | |
4400 | neighbor_interface_config_remote_as_cmd, | |
4401 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4402 | NEIGHBOR_STR | |
4403 | "Interface name or neighbor tag\n" | |
4404 | "Enable BGP on interface\n" | |
4405 | "Specify a BGP neighbor\n" AS_STR | |
4406 | "Internal BGP peer\n" | |
4407 | "External BGP peer\n") | |
b3a39dc5 | 4408 | { |
d62a17ae | 4409 | int idx_word = 1; |
4410 | int idx_remote_as = 4; | |
f4b8ec07 CS |
4411 | char base_xpath[XPATH_MAXLEN]; |
4412 | const char *as_type_str = "as-specified"; | |
4413 | ||
4414 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4415 | argv[idx_word]->arg, ""); | |
4416 | ||
4417 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
4418 | ||
4419 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4420 | as_type_str = "internal"; | |
4421 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4422 | as_type_str = "external"; | |
4423 | } else { | |
4424 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4425 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4426 | } | |
4427 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4428 | NB_OP_MODIFY, as_type_str); | |
4429 | ||
4430 | return nb_cli_apply_changes(vty, base_xpath); | |
b3a39dc5 DD |
4431 | } |
4432 | ||
f4b8ec07 CS |
4433 | DEFUN_YANG( |
4434 | neighbor_interface_v6only_config_remote_as, | |
4435 | neighbor_interface_v6only_config_remote_as_cmd, | |
4436 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4437 | NEIGHBOR_STR | |
4438 | "Interface name or neighbor tag\n" | |
4439 | "Enable BGP with v6 link-local only\n" | |
4440 | "Enable BGP on interface\n" | |
4441 | "Specify a BGP neighbor\n" AS_STR | |
4442 | "Internal BGP peer\n" | |
4443 | "External BGP peer\n") | |
b3a39dc5 | 4444 | { |
d62a17ae | 4445 | int idx_word = 1; |
4446 | int idx_remote_as = 5; | |
f4b8ec07 CS |
4447 | char base_xpath[XPATH_MAXLEN]; |
4448 | const char *as_type_str = "as-specified"; | |
4449 | ||
4450 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4451 | argv[idx_word]->arg, ""); | |
4452 | ||
4453 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
4454 | ||
4455 | nb_cli_enqueue_change(vty, "./v6only", NB_OP_MODIFY, "true"); | |
4456 | ||
4457 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4458 | as_type_str = "internal"; | |
4459 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4460 | as_type_str = "external"; | |
4461 | } else { | |
4462 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4463 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4464 | } | |
4465 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4466 | NB_OP_MODIFY, as_type_str); | |
4467 | ||
4468 | return nb_cli_apply_changes(vty, base_xpath); | |
b3a39dc5 DD |
4469 | } |
4470 | ||
f4b8ec07 CS |
4471 | DEFUN_YANG(neighbor_peer_group, neighbor_peer_group_cmd, |
4472 | "neighbor WORD peer-group", | |
4473 | NEIGHBOR_STR | |
4474 | "Interface name or neighbor tag\n" | |
4475 | "Configure peer-group\n") | |
718e3744 | 4476 | { |
f4b8ec07 | 4477 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4478 | int idx_word = 1; |
718e3744 | 4479 | |
f4b8ec07 CS |
4480 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4481 | argv[idx_word]->arg, ""); | |
718e3744 | 4482 | |
f4b8ec07 | 4483 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
718e3744 | 4484 | |
f4b8ec07 | 4485 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 4486 | } |
4487 | ||
4488 | DEFUN (no_neighbor, | |
4489 | no_neighbor_cmd, | |
dab8cd00 | 4490 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 4491 | NO_STR |
4492 | NEIGHBOR_STR | |
3a2d747c QY |
4493 | NEIGHBOR_ADDR_STR2 |
4494 | "Specify a BGP neighbor\n" | |
4495 | AS_STR | |
4496 | "Internal BGP peer\n" | |
4497 | "External BGP peer\n") | |
718e3744 | 4498 | { |
d62a17ae | 4499 | int idx_peer = 2; |
f4b8ec07 CS |
4500 | char base_xpath[XPATH_MAXLEN]; |
4501 | char num_xpath[XPATH_MAXLEN]; | |
4502 | char unnbr_xpath[XPATH_MAXLEN]; | |
4503 | char prgrp_xpath[XPATH_MAXLEN]; | |
d62a17ae | 4504 | union sockunion su; |
d62a17ae | 4505 | |
f4b8ec07 CS |
4506 | if (str2sockunion(argv[idx_peer]->arg, &su) == 0) { |
4507 | snprintf(num_xpath, sizeof(num_xpath), | |
4508 | FRR_BGP_NEIGHBOR_NUM_XPATH, argv[idx_peer]->arg, ""); | |
4509 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4510 | VTY_CURR_XPATH, num_xpath + 1)) { | |
4511 | strlcpy(base_xpath, num_xpath, sizeof(base_xpath)); | |
d62a17ae | 4512 | } |
f4b8ec07 CS |
4513 | } else { |
4514 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
4515 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, argv[idx_peer]->arg, ""); | |
4516 | ||
4517 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
4518 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, ""); | |
4519 | ||
4520 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4521 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
4522 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); | |
4523 | } else if (yang_dnode_exists(vty->candidate_config->dnode, | |
4524 | "%s%s", VTY_CURR_XPATH, | |
4525 | prgrp_xpath + 1)) { | |
4526 | strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath)); | |
4e2786df | 4527 | } else { |
f4b8ec07 CS |
4528 | vty_out(vty, |
4529 | "%% Create the peer-group or interface first\n"); | |
d62a17ae | 4530 | return CMD_WARNING_CONFIG_FAILED; |
4531 | } | |
1ff9a340 | 4532 | } |
718e3744 | 4533 | |
f4b8ec07 CS |
4534 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_DESTROY, NULL); |
4535 | ||
4536 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 4537 | } |
4538 | ||
f4b8ec07 CS |
4539 | DEFUN_YANG(no_neighbor_interface_config, |
4540 | no_neighbor_interface_config_cmd, | |
4541 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4542 | NO_STR NEIGHBOR_STR | |
4543 | "Interface name\n" | |
4544 | "Configure BGP on interface\n" | |
4545 | "Enable BGP with v6 link-local only\n" | |
4546 | "Member of the peer-group\n" | |
4547 | "Peer-group name\n" | |
4548 | "Specify a BGP neighbor\n" AS_STR | |
4549 | "Internal BGP peer\n" | |
4550 | "External BGP peer\n") | |
a80beece | 4551 | { |
d62a17ae | 4552 | int idx_word = 2; |
f4b8ec07 | 4553 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4554 | |
f4b8ec07 CS |
4555 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, |
4556 | argv[idx_word]->arg, ""); | |
4557 | ||
4558 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
4559 | ||
4560 | return nb_cli_apply_changes(vty, base_xpath); | |
a80beece DS |
4561 | } |
4562 | ||
f4b8ec07 CS |
4563 | DEFUN_YANG(no_neighbor_peer_group, |
4564 | no_neighbor_peer_group_cmd, | |
4565 | "no neighbor WORD peer-group", | |
4566 | NO_STR NEIGHBOR_STR | |
4567 | "Neighbor tag\n" | |
4568 | "Configure peer-group\n") | |
718e3744 | 4569 | { |
f4b8ec07 | 4570 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4571 | int idx_word = 2; |
718e3744 | 4572 | |
f4b8ec07 CS |
4573 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4574 | argv[idx_word]->arg, ""); | |
4575 | ||
4576 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
4577 | ||
4578 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4579 | } |
4580 | ||
f4b8ec07 CS |
4581 | DEFUN_YANG(no_neighbor_interface_peer_group_remote_as, |
4582 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4583 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4584 | NO_STR NEIGHBOR_STR | |
4585 | "Interface name or neighbor tag\n" | |
4586 | "Specify a BGP neighbor\n" AS_STR | |
4587 | "Internal BGP peer\n" | |
4588 | "External BGP peer\n") | |
718e3744 | 4589 | { |
f4b8ec07 CS |
4590 | int idx_peer = 2; |
4591 | char base_xpath[XPATH_MAXLEN]; | |
4592 | char unnbr_xpath[XPATH_MAXLEN]; | |
4593 | char prgrp_xpath[XPATH_MAXLEN]; | |
d62a17ae | 4594 | |
f4b8ec07 CS |
4595 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, |
4596 | argv[idx_peer]->arg, ""); | |
d62a17ae | 4597 | |
f4b8ec07 CS |
4598 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4599 | argv[idx_peer]->arg, ""); | |
4600 | ||
4601 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4602 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
4603 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); | |
4604 | } else if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4605 | VTY_CURR_XPATH, prgrp_xpath + 1)) { | |
4606 | strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath)); | |
4607 | } else { | |
d62a17ae | 4608 | vty_out(vty, "%% Create the peer-group or interface first\n"); |
4609 | return CMD_WARNING_CONFIG_FAILED; | |
4610 | } | |
f4b8ec07 CS |
4611 | |
4612 | strlcat(base_xpath, "/neighbor-remote-as/remote-as-type", | |
4613 | sizeof(base_xpath)); | |
4614 | ||
4615 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_DESTROY, NULL); | |
4616 | ||
4617 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 4618 | } |
6b0655a2 | 4619 | |
f4b8ec07 CS |
4620 | DEFUN_YANG(neighbor_local_as, |
4621 | neighbor_local_as_cmd, | |
4622 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4623 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4624 | "Specify a local-as number\n" | |
4625 | "AS number used as local AS\n") | |
718e3744 | 4626 | { |
d62a17ae | 4627 | int idx_peer = 1; |
4628 | int idx_number = 3; | |
f4b8ec07 | 4629 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4630 | |
f4b8ec07 CS |
4631 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4632 | sizeof(base_xpath), NULL) | |
4633 | < 0) | |
d62a17ae | 4634 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4635 | |
f4b8ec07 CS |
4636 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4637 | argv[idx_number]->arg); | |
4638 | ||
4639 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4640 | } |
4641 | ||
f4b8ec07 CS |
4642 | DEFUN_YANG( |
4643 | neighbor_local_as_no_prepend, neighbor_local_as_no_prepend_cmd, | |
4644 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4645 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4646 | "Specify a local-as number\n" | |
4647 | "AS number used as local AS\n" | |
4648 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4649 | { |
d62a17ae | 4650 | int idx_peer = 1; |
4651 | int idx_number = 3; | |
f4b8ec07 | 4652 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4653 | |
f4b8ec07 CS |
4654 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4655 | sizeof(base_xpath), NULL) | |
4656 | < 0) | |
d62a17ae | 4657 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4658 | |
f4b8ec07 CS |
4659 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4660 | argv[idx_number]->arg); | |
4661 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4662 | "true"); | |
4663 | ||
4664 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4665 | } |
4666 | ||
f4b8ec07 CS |
4667 | DEFUN_YANG( |
4668 | neighbor_local_as_no_prepend_replace_as, | |
4669 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4670 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4671 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4672 | "Specify a local-as number\n" | |
4673 | "AS number used as local AS\n" | |
4674 | "Do not prepend local-as to updates from ebgp peers\n" | |
4675 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4676 | { |
d62a17ae | 4677 | int idx_peer = 1; |
4678 | int idx_number = 3; | |
f4b8ec07 | 4679 | char base_xpath[XPATH_MAXLEN]; |
9d3f9705 | 4680 | |
f4b8ec07 CS |
4681 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4682 | sizeof(base_xpath), NULL) | |
4683 | < 0) | |
d62a17ae | 4684 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4685 | |
f4b8ec07 CS |
4686 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4687 | argv[idx_number]->arg); | |
4688 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4689 | "true"); | |
4690 | nb_cli_enqueue_change(vty, "./local-as/no-replace-as", NB_OP_MODIFY, | |
4691 | "true"); | |
4692 | ||
4693 | return nb_cli_apply_changes(vty, base_xpath); | |
9d3f9705 AC |
4694 | } |
4695 | ||
f4b8ec07 CS |
4696 | DEFUN_YANG(no_neighbor_local_as, |
4697 | no_neighbor_local_as_cmd, | |
4698 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4699 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4700 | "Specify a local-as number\n" | |
4701 | "AS number used as local AS\n" | |
4702 | "Do not prepend local-as to updates from ebgp peers\n" | |
4703 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4704 | { |
d62a17ae | 4705 | int idx_peer = 2; |
f4b8ec07 | 4706 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4707 | |
f4b8ec07 CS |
4708 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4709 | sizeof(base_xpath), NULL) | |
4710 | < 0) | |
d62a17ae | 4711 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4712 | |
f4b8ec07 CS |
4713 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_DESTROY, NULL); |
4714 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4715 | "false"); | |
4716 | nb_cli_enqueue_change(vty, "./local-as/no-replace-as", NB_OP_MODIFY, | |
4717 | "false"); | |
4718 | ||
4719 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4720 | } |
4721 | ||
718e3744 | 4722 | |
3f9c7369 DS |
4723 | DEFUN (neighbor_solo, |
4724 | neighbor_solo_cmd, | |
9ccf14f7 | 4725 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4726 | NEIGHBOR_STR |
4727 | NEIGHBOR_ADDR_STR2 | |
4728 | "Solo peer - part of its own update group\n") | |
4729 | { | |
d62a17ae | 4730 | int idx_peer = 1; |
4731 | struct peer *peer; | |
4732 | int ret; | |
3f9c7369 | 4733 | |
d62a17ae | 4734 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4735 | if (!peer) | |
4736 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4737 | |
d62a17ae | 4738 | ret = update_group_adjust_soloness(peer, 1); |
4739 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4740 | } |
4741 | ||
4742 | DEFUN (no_neighbor_solo, | |
4743 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4744 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4745 | NO_STR |
4746 | NEIGHBOR_STR | |
4747 | NEIGHBOR_ADDR_STR2 | |
4748 | "Solo peer - part of its own update group\n") | |
4749 | { | |
d62a17ae | 4750 | int idx_peer = 2; |
4751 | struct peer *peer; | |
4752 | int ret; | |
3f9c7369 | 4753 | |
d62a17ae | 4754 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4755 | if (!peer) | |
4756 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4757 | |
d62a17ae | 4758 | ret = update_group_adjust_soloness(peer, 0); |
4759 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4760 | } |
4761 | ||
f4b8ec07 CS |
4762 | DEFUN_YANG(neighbor_password, |
4763 | neighbor_password_cmd, | |
4764 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4765 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4766 | "Set a password\n" | |
4767 | "The password\n") | |
0df7c91f | 4768 | { |
d62a17ae | 4769 | int idx_peer = 1; |
4770 | int idx_line = 3; | |
f4b8ec07 | 4771 | char base_xpath[XPATH_MAXLEN]; |
0df7c91f | 4772 | |
f4b8ec07 CS |
4773 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4774 | sizeof(base_xpath), NULL) | |
4775 | < 0) | |
d62a17ae | 4776 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4777 | |
f4b8ec07 CS |
4778 | nb_cli_enqueue_change(vty, "./password", NB_OP_MODIFY, |
4779 | argv[idx_line]->arg); | |
4780 | ||
4781 | return nb_cli_apply_changes(vty, base_xpath); | |
0df7c91f PJ |
4782 | } |
4783 | ||
f4b8ec07 CS |
4784 | DEFUN_YANG(no_neighbor_password, |
4785 | no_neighbor_password_cmd, | |
4786 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
4787 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4788 | "Set a password\n" | |
4789 | "The password\n") | |
0df7c91f | 4790 | { |
d62a17ae | 4791 | int idx_peer = 2; |
f4b8ec07 | 4792 | char base_xpath[XPATH_MAXLEN]; |
0df7c91f | 4793 | |
f4b8ec07 CS |
4794 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4795 | sizeof(base_xpath), NULL) | |
4796 | < 0) | |
d62a17ae | 4797 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4798 | |
f4b8ec07 CS |
4799 | nb_cli_enqueue_change(vty, "./password", NB_OP_DESTROY, NULL); |
4800 | ||
4801 | return nb_cli_apply_changes(vty, base_xpath); | |
0df7c91f | 4802 | } |
6b0655a2 | 4803 | |
f4b8ec07 CS |
4804 | DEFUN_YANG(neighbor_activate, |
4805 | neighbor_activate_cmd, | |
4806 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4807 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4808 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4809 | { |
d62a17ae | 4810 | int idx_peer = 1; |
f4b8ec07 | 4811 | char base_xpath[XPATH_MAXLEN]; |
f4b8ec07 CS |
4812 | char af_xpath[XPATH_MAXLEN]; |
4813 | afi_t afi = bgp_node_afi(vty); | |
4814 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 4815 | |
f4b8ec07 CS |
4816 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
4817 | yang_afi_safi_value2identity(afi, safi)); | |
555c8ab7 CS |
4818 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4819 | sizeof(base_xpath), af_xpath) | |
f4b8ec07 | 4820 | < 0) |
d62a17ae | 4821 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4822 | |
555c8ab7 | 4823 | nb_cli_enqueue_change(vty, "./enabled", NB_OP_MODIFY, "true"); |
f4b8ec07 CS |
4824 | |
4825 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4826 | } |
4827 | ||
d62a17ae | 4828 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4829 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4830 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4831 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4832 | |
f4b8ec07 CS |
4833 | DEFUN_YANG(no_neighbor_activate, |
4834 | no_neighbor_activate_cmd, | |
4835 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4836 | NO_STR NEIGHBOR_STR | |
4837 | NEIGHBOR_ADDR_STR2 | |
4838 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4839 | { |
d62a17ae | 4840 | int idx_peer = 2; |
f4b8ec07 CS |
4841 | char base_xpath[XPATH_MAXLEN]; |
4842 | char af_xpath[XPATH_MAXLEN]; | |
4843 | afi_t afi = bgp_node_afi(vty); | |
4844 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 4845 | |
f4b8ec07 CS |
4846 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
4847 | yang_afi_safi_value2identity(afi, safi)); | |
4848 | ||
4849 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
4850 | sizeof(base_xpath), af_xpath) | |
4851 | < 0) | |
d62a17ae | 4852 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4853 | |
f4b8ec07 CS |
4854 | nb_cli_enqueue_change(vty, "./enabled", NB_OP_MODIFY, "false"); |
4855 | ||
4856 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4857 | } |
6b0655a2 | 4858 | |
d62a17ae | 4859 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4860 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4861 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4862 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4863 | |
f4b8ec07 CS |
4864 | DEFUN_YANG (neighbor_set_peer_group, |
4865 | neighbor_set_peer_group_cmd, | |
4866 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4867 | NEIGHBOR_STR | |
4868 | NEIGHBOR_ADDR_STR2 | |
4869 | "Member of the peer-group\n" | |
4870 | "Peer-group name\n") | |
718e3744 | 4871 | { |
d62a17ae | 4872 | int idx_peer = 1; |
4873 | int idx_word = 3; | |
f4b8ec07 | 4874 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4875 | |
f4b8ec07 CS |
4876 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4877 | sizeof(base_xpath), NULL) | |
4878 | < 0) | |
d62a17ae | 4879 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 4880 | |
f4b8ec07 CS |
4881 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4882 | argv[idx_word]->arg); | |
d62a17ae | 4883 | |
f4b8ec07 | 4884 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 4885 | } |
4886 | ||
4887 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4888 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4889 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4890 | "Member of the peer-group\n" | |
4891 | "Peer-group name\n") | |
596c17ba | 4892 | |
f4b8ec07 CS |
4893 | DEFUN_YANG (no_neighbor_set_peer_group, |
4894 | no_neighbor_set_peer_group_cmd, | |
4895 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4896 | NO_STR | |
4897 | NEIGHBOR_STR | |
4898 | NEIGHBOR_ADDR_STR2 | |
4899 | "Member of the peer-group\n" | |
4900 | "Peer-group name\n") | |
718e3744 | 4901 | { |
d62a17ae | 4902 | int idx_peer = 2; |
f4b8ec07 | 4903 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4904 | |
f4b8ec07 CS |
4905 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4906 | sizeof(base_xpath), NULL) | |
4907 | < 0) | |
d62a17ae | 4908 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 4909 | |
f4b8ec07 | 4910 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_DESTROY, NULL); |
718e3744 | 4911 | |
f4b8ec07 | 4912 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 4913 | } |
6b0655a2 | 4914 | |
d62a17ae | 4915 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4916 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4917 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4918 | "Member of the peer-group\n" | |
4919 | "Peer-group name\n") | |
596c17ba | 4920 | |
d62a17ae | 4921 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4922 | uint32_t flag, int set) |
718e3744 | 4923 | { |
d62a17ae | 4924 | int ret; |
4925 | struct peer *peer; | |
718e3744 | 4926 | |
d62a17ae | 4927 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4928 | if (!peer) | |
4929 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4930 | |
7ebe625c QY |
4931 | /* |
4932 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4933 | * we should not accept disable-connected-check. | |
4934 | */ | |
4935 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4936 | vty_out(vty, | |
3efd0893 | 4937 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
4938 | ip_str); |
4939 | return CMD_WARNING_CONFIG_FAILED; | |
4940 | } | |
4941 | ||
d62a17ae | 4942 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4943 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4944 | |
d62a17ae | 4945 | if (set) |
4946 | ret = peer_flag_set(peer, flag); | |
4947 | else | |
4948 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4949 | |
d62a17ae | 4950 | return bgp_vty_return(vty, ret); |
718e3744 | 4951 | } |
4952 | ||
47cbc09b | 4953 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4954 | { |
d62a17ae | 4955 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4956 | } |
4957 | ||
d62a17ae | 4958 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4959 | uint32_t flag) |
718e3744 | 4960 | { |
d62a17ae | 4961 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4962 | } |
4963 | ||
f4b8ec07 CS |
4964 | int peer_flag_modify_nb(struct bgp *bgp, const char *ip_str, struct peer *peer, |
4965 | uint32_t flag, bool set, char *errmsg, | |
4966 | size_t errmsg_len) | |
4967 | { | |
4968 | int ret; | |
4969 | ||
4970 | /* | |
4971 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4972 | * we should not accept disable-connected-check. | |
4973 | */ | |
4974 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4975 | snprintf( | |
4976 | errmsg, errmsg_len, | |
4977 | "%s is directly connected peer, cannot accept disable-connected-check\n", | |
4978 | ip_str); | |
4979 | return -1; | |
4980 | } | |
4981 | ||
4982 | if (!set && flag == PEER_FLAG_SHUTDOWN) | |
4983 | peer_tx_shutdown_message_unset(peer); | |
4984 | ||
4985 | if (set) | |
4986 | ret = peer_flag_set(peer, flag); | |
4987 | else | |
4988 | ret = peer_flag_unset(peer, flag); | |
4989 | ||
4990 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); | |
4991 | } | |
4992 | ||
718e3744 | 4993 | /* neighbor passive. */ |
f4b8ec07 CS |
4994 | DEFUN_YANG(neighbor_passive, |
4995 | neighbor_passive_cmd, | |
4996 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
4997 | NEIGHBOR_STR | |
4998 | NEIGHBOR_ADDR_STR2 | |
4999 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5000 | { |
d62a17ae | 5001 | int idx_peer = 1; |
f4b8ec07 CS |
5002 | char base_xpath[XPATH_MAXLEN]; |
5003 | ||
5004 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5005 | sizeof(base_xpath), NULL) | |
5006 | < 0) | |
5007 | return CMD_WARNING_CONFIG_FAILED; | |
5008 | ||
5009 | nb_cli_enqueue_change(vty, "./passive-mode", NB_OP_MODIFY, "true"); | |
5010 | ||
5011 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5012 | } |
5013 | ||
f4b8ec07 CS |
5014 | DEFUN_YANG(no_neighbor_passive, |
5015 | no_neighbor_passive_cmd, | |
5016 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5017 | NO_STR NEIGHBOR_STR | |
5018 | NEIGHBOR_ADDR_STR2 | |
5019 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5020 | { |
d62a17ae | 5021 | int idx_peer = 2; |
f4b8ec07 CS |
5022 | char base_xpath[XPATH_MAXLEN]; |
5023 | ||
5024 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5025 | sizeof(base_xpath), NULL) | |
5026 | < 0) | |
5027 | return CMD_WARNING_CONFIG_FAILED; | |
5028 | ||
5029 | nb_cli_enqueue_change(vty, "./passive-mode", NB_OP_MODIFY, "false"); | |
5030 | ||
5031 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5032 | } |
6b0655a2 | 5033 | |
718e3744 | 5034 | /* neighbor shutdown. */ |
f4b8ec07 CS |
5035 | DEFUN_YANG(neighbor_shutdown_msg, |
5036 | neighbor_shutdown_msg_cmd, | |
5037 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5038 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5039 | "Administratively shut down this neighbor\n" | |
5040 | "Add a shutdown message (RFC 8203)\n" | |
5041 | "Shutdown message\n") | |
718e3744 | 5042 | { |
d62a17ae | 5043 | int idx_peer = 1; |
f4b8ec07 CS |
5044 | char base_xpath[XPATH_MAXLEN]; |
5045 | ||
5046 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5047 | sizeof(base_xpath), NULL) | |
5048 | < 0) | |
5049 | return CMD_WARNING_CONFIG_FAILED; | |
73d70fa6 | 5050 | |
d62a17ae | 5051 | if (argc >= 5) { |
d62a17ae | 5052 | char *message; |
73d70fa6 | 5053 | |
d62a17ae | 5054 | message = argv_concat(argv, argc, 4); |
f4b8ec07 CS |
5055 | nb_cli_enqueue_change(vty, "./admin-shutdown/message", |
5056 | NB_OP_MODIFY, message); | |
d62a17ae | 5057 | } |
73d70fa6 | 5058 | |
f4b8ec07 CS |
5059 | nb_cli_enqueue_change(vty, "./admin-shutdown/enable", NB_OP_MODIFY, |
5060 | "true"); | |
5061 | ||
5062 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5063 | } |
5064 | ||
d62a17ae | 5065 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
5066 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
5067 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5068 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5069 | |
f4b8ec07 CS |
5070 | DEFUN_YANG(no_neighbor_shutdown_msg, |
5071 | no_neighbor_shutdown_msg_cmd, | |
5072 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5073 | NO_STR NEIGHBOR_STR | |
5074 | NEIGHBOR_ADDR_STR2 | |
5075 | "Administratively shut down this neighbor\n" | |
5076 | "Remove a shutdown message (RFC 8203)\n" | |
5077 | "Shutdown message\n") | |
718e3744 | 5078 | { |
d62a17ae | 5079 | int idx_peer = 2; |
f4b8ec07 | 5080 | char base_xpath[XPATH_MAXLEN]; |
73d70fa6 | 5081 | |
f4b8ec07 CS |
5082 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
5083 | sizeof(base_xpath), NULL) | |
5084 | < 0) | |
5085 | return CMD_WARNING_CONFIG_FAILED; | |
5086 | ||
5087 | nb_cli_enqueue_change(vty, "./admin-shutdown/enable", NB_OP_MODIFY, | |
5088 | "false"); | |
5089 | ||
5090 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5091 | } |
6b0655a2 | 5092 | |
d62a17ae | 5093 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
5094 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
5095 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5096 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5097 | |
8336c896 DA |
5098 | DEFUN(neighbor_shutdown_rtt, |
5099 | neighbor_shutdown_rtt_cmd, | |
5100 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5101 | NEIGHBOR_STR | |
5102 | NEIGHBOR_ADDR_STR2 | |
5103 | "Administratively shut down this neighbor\n" | |
5104 | "Shutdown if round-trip-time is higher than expected\n" | |
5105 | "Round-trip-time in milliseconds\n" | |
5106 | "Specify the number of keepalives before shutdown\n" | |
5107 | "The number of keepalives with higher RTT to shutdown\n") | |
5108 | { | |
5109 | int idx_peer = 1; | |
5110 | int idx_rtt = 4; | |
5111 | int idx_count = 0; | |
5112 | struct peer *peer; | |
5113 | ||
5114 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5115 | ||
5116 | if (!peer) | |
5117 | return CMD_WARNING_CONFIG_FAILED; | |
5118 | ||
5119 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5120 | ||
5121 | if (argv_find(argv, argc, "count", &idx_count)) | |
5122 | peer->rtt_keepalive_conf = | |
5123 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5124 | ||
5125 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5126 | PEER_FLAG_RTT_SHUTDOWN); | |
5127 | } | |
5128 | ||
5129 | DEFUN(no_neighbor_shutdown_rtt, | |
5130 | no_neighbor_shutdown_rtt_cmd, | |
5131 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5132 | NO_STR | |
5133 | NEIGHBOR_STR | |
5134 | NEIGHBOR_ADDR_STR2 | |
5135 | "Administratively shut down this neighbor\n" | |
5136 | "Shutdown if round-trip-time is higher than expected\n" | |
5137 | "Round-trip-time in milliseconds\n" | |
5138 | "Specify the number of keepalives before shutdown\n" | |
5139 | "The number of keepalives with higher RTT to shutdown\n") | |
5140 | { | |
5141 | int idx_peer = 2; | |
5142 | struct peer *peer; | |
5143 | ||
5144 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5145 | ||
5146 | if (!peer) | |
5147 | return CMD_WARNING_CONFIG_FAILED; | |
5148 | ||
5149 | peer->rtt_expected = 0; | |
5150 | peer->rtt_keepalive_conf = 1; | |
5151 | ||
5152 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5153 | PEER_FLAG_RTT_SHUTDOWN); | |
5154 | } | |
5155 | ||
718e3744 | 5156 | /* neighbor capability dynamic. */ |
f4b8ec07 CS |
5157 | DEFUN_YANG (neighbor_capability_dynamic, |
5158 | neighbor_capability_dynamic_cmd, | |
5159 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5160 | NEIGHBOR_STR | |
5161 | NEIGHBOR_ADDR_STR2 | |
5162 | "Advertise capability to the peer\n" | |
5163 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5164 | { |
d62a17ae | 5165 | int idx_peer = 1; |
f4b8ec07 CS |
5166 | char base_xpath[XPATH_MAXLEN]; |
5167 | ||
5168 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5169 | sizeof(base_xpath), NULL) | |
5170 | < 0) | |
5171 | return CMD_WARNING_CONFIG_FAILED; | |
5172 | ||
5173 | nb_cli_enqueue_change(vty, "./capability-options/dynamic-capability", | |
5174 | NB_OP_MODIFY, "true"); | |
5175 | ||
5176 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5177 | } |
5178 | ||
f4b8ec07 CS |
5179 | DEFUN_YANG (no_neighbor_capability_dynamic, |
5180 | no_neighbor_capability_dynamic_cmd, | |
5181 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5182 | NO_STR | |
5183 | NEIGHBOR_STR | |
5184 | NEIGHBOR_ADDR_STR2 | |
5185 | "Advertise capability to the peer\n" | |
5186 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5187 | { |
d62a17ae | 5188 | int idx_peer = 2; |
f4b8ec07 CS |
5189 | char base_xpath[XPATH_MAXLEN]; |
5190 | ||
5191 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5192 | sizeof(base_xpath), NULL) | |
5193 | < 0) | |
5194 | return CMD_WARNING_CONFIG_FAILED; | |
5195 | ||
5196 | nb_cli_enqueue_change(vty, "./capability-options/dynamic-capability", | |
5197 | NB_OP_MODIFY, "false"); | |
5198 | ||
5199 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5200 | } |
6b0655a2 | 5201 | |
718e3744 | 5202 | /* neighbor dont-capability-negotiate */ |
5203 | DEFUN (neighbor_dont_capability_negotiate, | |
5204 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5205 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5206 | NEIGHBOR_STR |
5207 | NEIGHBOR_ADDR_STR2 | |
5208 | "Do not perform capability negotiation\n") | |
5209 | { | |
d62a17ae | 5210 | int idx_peer = 1; |
5211 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5212 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5213 | } |
5214 | ||
5215 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5216 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5217 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5218 | NO_STR |
5219 | NEIGHBOR_STR | |
5220 | NEIGHBOR_ADDR_STR2 | |
5221 | "Do not perform capability negotiation\n") | |
5222 | { | |
d62a17ae | 5223 | int idx_peer = 2; |
5224 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5225 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5226 | } |
6b0655a2 | 5227 | |
8a92a8a0 | 5228 | /* neighbor capability extended next hop encoding */ |
f4b8ec07 CS |
5229 | DEFUN_YANG (neighbor_capability_enhe, |
5230 | neighbor_capability_enhe_cmd, | |
5231 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5232 | NEIGHBOR_STR | |
5233 | NEIGHBOR_ADDR_STR2 | |
5234 | "Advertise capability to the peer\n" | |
5235 | "Advertise extended next-hop capability to the peer\n") | |
8a92a8a0 | 5236 | { |
d62a17ae | 5237 | int idx_peer = 1; |
f4b8ec07 CS |
5238 | char base_xpath[XPATH_MAXLEN]; |
5239 | ||
5240 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5241 | sizeof(base_xpath), NULL) | |
5242 | < 0) | |
5243 | return CMD_WARNING_CONFIG_FAILED; | |
5244 | ||
5245 | nb_cli_enqueue_change( | |
5246 | vty, "./capability-options/extended-nexthop-capability", | |
5247 | NB_OP_MODIFY, "true"); | |
5248 | ||
5249 | return nb_cli_apply_changes(vty, base_xpath); | |
8a92a8a0 DS |
5250 | } |
5251 | ||
f4b8ec07 CS |
5252 | DEFUN_YANG (no_neighbor_capability_enhe, |
5253 | no_neighbor_capability_enhe_cmd, | |
5254 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5255 | NO_STR | |
5256 | NEIGHBOR_STR | |
5257 | NEIGHBOR_ADDR_STR2 | |
5258 | "Advertise capability to the peer\n" | |
5259 | "Advertise extended next-hop capability to the peer\n") | |
8a92a8a0 | 5260 | { |
d62a17ae | 5261 | int idx_peer = 2; |
f4b8ec07 CS |
5262 | char base_xpath[XPATH_MAXLEN]; |
5263 | ||
5264 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5265 | sizeof(base_xpath), NULL) | |
5266 | < 0) | |
5267 | return CMD_WARNING_CONFIG_FAILED; | |
5268 | ||
5269 | nb_cli_enqueue_change( | |
5270 | vty, "./capability-options/extended-nexthop-capability", | |
5271 | NB_OP_MODIFY, "false"); | |
5272 | ||
5273 | return nb_cli_apply_changes(vty, base_xpath); | |
5274 | } | |
5275 | ||
5276 | int peer_af_flag_modify_nb(struct peer *peer, afi_t afi, safi_t safi, | |
5277 | uint32_t flag, int set, char *errmsg, | |
5278 | size_t errmsg_len) | |
5279 | { | |
5280 | int ret; | |
5281 | ||
5282 | if (set) | |
5283 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5284 | else | |
5285 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
5286 | ||
5287 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); | |
8a92a8a0 DS |
5288 | } |
5289 | ||
d62a17ae | 5290 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5291 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5292 | int set) |
718e3744 | 5293 | { |
d62a17ae | 5294 | int ret; |
5295 | struct peer *peer; | |
718e3744 | 5296 | |
d62a17ae | 5297 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5298 | if (!peer) | |
5299 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5300 | |
d62a17ae | 5301 | if (set) |
5302 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5303 | else | |
5304 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5305 | |
d62a17ae | 5306 | return bgp_vty_return(vty, ret); |
718e3744 | 5307 | } |
5308 | ||
d62a17ae | 5309 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5310 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5311 | { |
d62a17ae | 5312 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5313 | } |
5314 | ||
d62a17ae | 5315 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5316 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5317 | { |
d62a17ae | 5318 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5319 | } |
6b0655a2 | 5320 | |
718e3744 | 5321 | /* neighbor capability orf prefix-list. */ |
5322 | DEFUN (neighbor_capability_orf_prefix, | |
5323 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5324 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5325 | NEIGHBOR_STR |
5326 | NEIGHBOR_ADDR_STR2 | |
5327 | "Advertise capability to the peer\n" | |
5328 | "Advertise ORF capability to the peer\n" | |
5329 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5330 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5331 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5332 | "Capability to SEND the ORF to this neighbor\n") | |
5333 | { | |
d62a17ae | 5334 | int idx_send_recv = 5; |
db45f64d DS |
5335 | char *peer_str = argv[1]->arg; |
5336 | struct peer *peer; | |
5337 | afi_t afi = bgp_node_afi(vty); | |
5338 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5339 | |
db45f64d DS |
5340 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5341 | if (!peer) | |
d62a17ae | 5342 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5343 | |
db45f64d DS |
5344 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5345 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5346 | PEER_FLAG_ORF_PREFIX_SM); | |
5347 | ||
5348 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5349 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5350 | PEER_FLAG_ORF_PREFIX_RM); | |
5351 | ||
5352 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5353 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5354 | PEER_FLAG_ORF_PREFIX_SM) | |
5355 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5356 | PEER_FLAG_ORF_PREFIX_RM); | |
5357 | ||
5358 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5359 | } |
5360 | ||
5361 | ALIAS_HIDDEN( | |
5362 | neighbor_capability_orf_prefix, | |
5363 | neighbor_capability_orf_prefix_hidden_cmd, | |
5364 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5365 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5366 | "Advertise capability to the peer\n" | |
5367 | "Advertise ORF capability to the peer\n" | |
5368 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5369 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5370 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5371 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5372 | |
718e3744 | 5373 | DEFUN (no_neighbor_capability_orf_prefix, |
5374 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5375 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5376 | NO_STR |
5377 | NEIGHBOR_STR | |
5378 | NEIGHBOR_ADDR_STR2 | |
5379 | "Advertise capability to the peer\n" | |
5380 | "Advertise ORF capability to the peer\n" | |
5381 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5382 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5383 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5384 | "Capability to SEND the ORF to this neighbor\n") | |
5385 | { | |
d62a17ae | 5386 | int idx_send_recv = 6; |
db45f64d DS |
5387 | char *peer_str = argv[2]->arg; |
5388 | struct peer *peer; | |
5389 | afi_t afi = bgp_node_afi(vty); | |
5390 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5391 | |
db45f64d DS |
5392 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5393 | if (!peer) | |
d62a17ae | 5394 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5395 | |
db45f64d DS |
5396 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5397 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5398 | PEER_FLAG_ORF_PREFIX_SM); | |
5399 | ||
5400 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5401 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5402 | PEER_FLAG_ORF_PREFIX_RM); | |
5403 | ||
5404 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5405 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5406 | PEER_FLAG_ORF_PREFIX_SM) | |
5407 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5408 | PEER_FLAG_ORF_PREFIX_RM); | |
5409 | ||
5410 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5411 | } |
5412 | ||
5413 | ALIAS_HIDDEN( | |
5414 | no_neighbor_capability_orf_prefix, | |
5415 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5416 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5417 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5418 | "Advertise capability to the peer\n" | |
5419 | "Advertise ORF capability to the peer\n" | |
5420 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5421 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5422 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5423 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5424 | |
718e3744 | 5425 | /* neighbor next-hop-self. */ |
f4b8ec07 CS |
5426 | DEFUN_YANG (neighbor_nexthop_self, |
5427 | neighbor_nexthop_self_cmd, | |
5428 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5429 | NEIGHBOR_STR | |
5430 | NEIGHBOR_ADDR_STR2 | |
5431 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5432 | { |
d62a17ae | 5433 | int idx_peer = 1; |
f4b8ec07 CS |
5434 | char base_xpath[XPATH_MAXLEN]; |
5435 | char af_xpath[XPATH_MAXLEN]; | |
5436 | char attr_xpath[XPATH_MAXLEN]; | |
5437 | afi_t afi = bgp_node_afi(vty); | |
5438 | safi_t safi = bgp_node_safi(vty); | |
5439 | ||
5440 | ||
5441 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5442 | yang_afi_safi_value2identity(afi, safi)); | |
5443 | ||
5444 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5445 | sizeof(base_xpath), af_xpath) | |
5446 | < 0) | |
5447 | return CMD_WARNING_CONFIG_FAILED; | |
5448 | ||
5449 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5450 | "./%s/nexthop-self/next-hop-self", | |
5451 | bgp_afi_safi_get_container_str(afi, safi)); | |
5452 | ||
5453 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5454 | ||
5455 | return nb_cli_apply_changes(vty, base_xpath); | |
a538debe | 5456 | } |
9e7a53c1 | 5457 | |
d62a17ae | 5458 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5459 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5460 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5461 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5462 | |
f4b8ec07 CS |
5463 | /* neighbor next-hop-self. */ |
5464 | DEFUN_YANG(neighbor_nexthop_self_force, | |
5465 | neighbor_nexthop_self_force_cmd, | |
5466 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5467 | NEIGHBOR_STR | |
5468 | NEIGHBOR_ADDR_STR2 | |
5469 | "Disable the next hop calculation for this neighbor\n" | |
5470 | "Set the next hop to self for reflected routes\n") | |
5471 | { | |
5472 | int idx_peer = 1; | |
5473 | char base_xpath[XPATH_MAXLEN]; | |
5474 | char af_xpath[XPATH_MAXLEN]; | |
5475 | char attr_xpath[XPATH_MAXLEN]; | |
5476 | afi_t afi = bgp_node_afi(vty); | |
5477 | safi_t safi = bgp_node_safi(vty); | |
5478 | ||
5479 | ||
5480 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5481 | yang_afi_safi_value2identity(afi, safi)); | |
5482 | ||
5483 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5484 | sizeof(base_xpath), af_xpath) | |
5485 | < 0) | |
5486 | return CMD_WARNING_CONFIG_FAILED; | |
5487 | ||
5488 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5489 | "./%s/nexthop-self/next-hop-self-force", | |
5490 | bgp_afi_safi_get_container_str(afi, safi)); | |
5491 | ||
5492 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5493 | ||
5494 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5495 | } |
5496 | ||
d62a17ae | 5497 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5498 | neighbor_nexthop_self_force_hidden_cmd, | |
5499 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5500 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5501 | "Disable the next hop calculation for this neighbor\n" | |
5502 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5503 | |
1bc4e531 DA |
5504 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5505 | neighbor_nexthop_self_all_hidden_cmd, | |
5506 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5507 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5508 | "Disable the next hop calculation for this neighbor\n" | |
5509 | "Set the next hop to self for reflected routes\n") | |
5510 | ||
f4b8ec07 CS |
5511 | DEFUN_YANG (no_neighbor_nexthop_self, |
5512 | no_neighbor_nexthop_self_cmd, | |
5513 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5514 | NO_STR | |
5515 | NEIGHBOR_STR | |
5516 | NEIGHBOR_ADDR_STR2 | |
5517 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5518 | { |
d62a17ae | 5519 | int idx_peer = 2; |
f4b8ec07 CS |
5520 | char base_xpath[XPATH_MAXLEN]; |
5521 | char af_xpath[XPATH_MAXLEN]; | |
5522 | char attr_xpath[XPATH_MAXLEN]; | |
5523 | afi_t afi = bgp_node_afi(vty); | |
5524 | safi_t safi = bgp_node_safi(vty); | |
5525 | ||
5526 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5527 | yang_afi_safi_value2identity(afi, safi)); | |
5528 | ||
5529 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5530 | sizeof(base_xpath), af_xpath) | |
5531 | < 0) | |
5532 | return CMD_WARNING_CONFIG_FAILED; | |
5533 | ||
5534 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5535 | "./%s/nexthop-self/next-hop-self", | |
5536 | bgp_afi_safi_get_container_str(afi, safi)); | |
5537 | ||
5538 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5539 | ||
5540 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5541 | } |
6b0655a2 | 5542 | |
d62a17ae | 5543 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5544 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5545 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5546 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5547 | |
f4b8ec07 CS |
5548 | DEFUN_YANG (no_neighbor_nexthop_self_force, |
5549 | no_neighbor_nexthop_self_force_cmd, | |
5550 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5551 | NO_STR | |
5552 | NEIGHBOR_STR | |
5553 | NEIGHBOR_ADDR_STR2 | |
5554 | "Disable the next hop calculation for this neighbor\n" | |
5555 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5556 | { |
d62a17ae | 5557 | int idx_peer = 2; |
f4b8ec07 CS |
5558 | char base_xpath[XPATH_MAXLEN]; |
5559 | char af_xpath[XPATH_MAXLEN]; | |
5560 | char attr_xpath[XPATH_MAXLEN]; | |
5561 | afi_t afi = bgp_node_afi(vty); | |
5562 | safi_t safi = bgp_node_safi(vty); | |
5563 | ||
5564 | ||
5565 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5566 | yang_afi_safi_value2identity(afi, safi)); | |
5567 | ||
5568 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5569 | sizeof(base_xpath), af_xpath) | |
5570 | < 0) | |
5571 | return CMD_WARNING_CONFIG_FAILED; | |
5572 | ||
5573 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5574 | "./%s/nexthop-self/next-hop-self-force", | |
5575 | bgp_afi_safi_get_container_str(afi, safi)); | |
5576 | ||
5577 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5578 | ||
5579 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5580 | } |
a538debe | 5581 | |
d62a17ae | 5582 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5583 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5584 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5585 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5586 | "Disable the next hop calculation for this neighbor\n" | |
5587 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5588 | |
1bc4e531 DA |
5589 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5590 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5591 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5592 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5593 | "Disable the next hop calculation for this neighbor\n" | |
5594 | "Set the next hop to self for reflected routes\n") | |
5595 | ||
c7122e14 | 5596 | /* neighbor as-override */ |
f4b8ec07 CS |
5597 | DEFUN_YANG (neighbor_as_override, |
5598 | neighbor_as_override_cmd, | |
5599 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5600 | NEIGHBOR_STR | |
5601 | NEIGHBOR_ADDR_STR2 | |
5602 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5603 | { |
d62a17ae | 5604 | int idx_peer = 1; |
f4b8ec07 CS |
5605 | char base_xpath[XPATH_MAXLEN]; |
5606 | char af_xpath[XPATH_MAXLEN]; | |
5607 | char attr_xpath[XPATH_MAXLEN]; | |
5608 | afi_t afi = bgp_node_afi(vty); | |
5609 | safi_t safi = bgp_node_safi(vty); | |
5610 | ||
5611 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5612 | yang_afi_safi_value2identity(afi, safi)); | |
5613 | ||
5614 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5615 | sizeof(base_xpath), af_xpath) | |
5616 | < 0) | |
5617 | return CMD_WARNING_CONFIG_FAILED; | |
5618 | ||
5619 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5620 | "./%s/as-path-options/replace-peer-as", | |
5621 | bgp_afi_safi_get_container_str(afi, safi)); | |
5622 | ||
5623 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5624 | ||
5625 | return nb_cli_apply_changes(vty, base_xpath); | |
c7122e14 DS |
5626 | } |
5627 | ||
d62a17ae | 5628 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5629 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5630 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5631 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5632 | |
f4b8ec07 CS |
5633 | DEFUN_YANG (no_neighbor_as_override, |
5634 | no_neighbor_as_override_cmd, | |
5635 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5636 | NO_STR | |
5637 | NEIGHBOR_STR | |
5638 | NEIGHBOR_ADDR_STR2 | |
5639 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5640 | { |
d62a17ae | 5641 | int idx_peer = 2; |
f4b8ec07 CS |
5642 | char base_xpath[XPATH_MAXLEN]; |
5643 | char af_xpath[XPATH_MAXLEN]; | |
5644 | char attr_xpath[XPATH_MAXLEN]; | |
5645 | afi_t afi = bgp_node_afi(vty); | |
5646 | safi_t safi = bgp_node_safi(vty); | |
5647 | ||
5648 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5649 | yang_afi_safi_value2identity(afi, safi)); | |
5650 | ||
5651 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5652 | sizeof(base_xpath), af_xpath) | |
5653 | < 0) | |
5654 | return CMD_WARNING_CONFIG_FAILED; | |
5655 | ||
5656 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5657 | "./%s/as-path-options/replace-peer-as", | |
5658 | bgp_afi_safi_get_container_str(afi, safi)); | |
5659 | ||
5660 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5661 | ||
5662 | return nb_cli_apply_changes(vty, base_xpath); | |
c7122e14 DS |
5663 | } |
5664 | ||
d62a17ae | 5665 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5666 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5667 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5668 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5669 | |
718e3744 | 5670 | /* neighbor remove-private-AS. */ |
f4b8ec07 CS |
5671 | DEFUN_YANG (neighbor_remove_private_as, |
5672 | neighbor_remove_private_as_cmd, | |
5673 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5674 | NEIGHBOR_STR | |
5675 | NEIGHBOR_ADDR_STR2 | |
5676 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5677 | { |
d62a17ae | 5678 | int idx_peer = 1; |
f4b8ec07 CS |
5679 | char base_xpath[XPATH_MAXLEN]; |
5680 | char af_xpath[XPATH_MAXLEN]; | |
5681 | char attr_xpath[XPATH_MAXLEN]; | |
5682 | afi_t afi = bgp_node_afi(vty); | |
5683 | safi_t safi = bgp_node_safi(vty); | |
5684 | ||
5685 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5686 | yang_afi_safi_value2identity(afi, safi)); | |
5687 | ||
5688 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5689 | sizeof(base_xpath), af_xpath) | |
5690 | < 0) | |
5691 | return CMD_WARNING_CONFIG_FAILED; | |
5692 | ||
5693 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5694 | "./%s/private-as/remove-private-as", | |
5695 | bgp_afi_safi_get_container_str(afi, safi)); | |
5696 | ||
5697 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5698 | ||
5699 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5700 | } |
5701 | ||
d62a17ae | 5702 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5703 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5704 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5705 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5706 | |
f4b8ec07 CS |
5707 | DEFUN_YANG (neighbor_remove_private_as_all, |
5708 | neighbor_remove_private_as_all_cmd, | |
5709 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5710 | NEIGHBOR_STR | |
5711 | NEIGHBOR_ADDR_STR2 | |
5712 | "Remove private ASNs in outbound updates\n" | |
5713 | "Apply to all AS numbers\n") | |
5000f21c | 5714 | { |
d62a17ae | 5715 | int idx_peer = 1; |
f4b8ec07 CS |
5716 | char base_xpath[XPATH_MAXLEN]; |
5717 | char af_xpath[XPATH_MAXLEN]; | |
5718 | char attr_xpath[XPATH_MAXLEN]; | |
5719 | afi_t afi = bgp_node_afi(vty); | |
5720 | safi_t safi = bgp_node_safi(vty); | |
5721 | ||
5722 | ||
5723 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5724 | yang_afi_safi_value2identity(afi, safi)); | |
5725 | ||
5726 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5727 | sizeof(base_xpath), af_xpath) | |
5728 | < 0) | |
5729 | return CMD_WARNING_CONFIG_FAILED; | |
5730 | ||
5731 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5732 | "./%s/private-as/remove-private-as-all", | |
5733 | bgp_afi_safi_get_container_str(afi, safi)); | |
5734 | ||
5735 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5736 | ||
5737 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
5738 | } |
5739 | ||
d62a17ae | 5740 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5741 | neighbor_remove_private_as_all_hidden_cmd, | |
5742 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5743 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5744 | "Remove private ASNs in outbound updates\n" | |
5745 | "Apply to all AS numbers") | |
596c17ba | 5746 | |
f4b8ec07 CS |
5747 | DEFUN_YANG (neighbor_remove_private_as_replace_as, |
5748 | neighbor_remove_private_as_replace_as_cmd, | |
5749 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5750 | NEIGHBOR_STR | |
5751 | NEIGHBOR_ADDR_STR2 | |
5752 | "Remove private ASNs in outbound updates\n" | |
5753 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5754 | { |
d62a17ae | 5755 | int idx_peer = 1; |
f4b8ec07 CS |
5756 | char base_xpath[XPATH_MAXLEN]; |
5757 | char af_xpath[XPATH_MAXLEN]; | |
5758 | char attr_xpath[XPATH_MAXLEN]; | |
5759 | afi_t afi = bgp_node_afi(vty); | |
5760 | safi_t safi = bgp_node_safi(vty); | |
5761 | ||
5762 | ||
5763 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5764 | yang_afi_safi_value2identity(afi, safi)); | |
5765 | ||
5766 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5767 | sizeof(base_xpath), af_xpath) | |
5768 | < 0) | |
5769 | return CMD_WARNING_CONFIG_FAILED; | |
5770 | ||
5771 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5772 | "./%s/private-as/remove-private-as-replace", | |
5773 | bgp_afi_safi_get_container_str(afi, safi)); | |
5774 | ||
5775 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5776 | ||
5777 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
5778 | } |
5779 | ||
d62a17ae | 5780 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5781 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5782 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5783 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5784 | "Remove private ASNs in outbound updates\n" | |
5785 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5786 | |
f4b8ec07 CS |
5787 | DEFUN_YANG (neighbor_remove_private_as_all_replace_as, |
5788 | neighbor_remove_private_as_all_replace_as_cmd, | |
5789 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5790 | NEIGHBOR_STR | |
5791 | NEIGHBOR_ADDR_STR2 | |
5792 | "Remove private ASNs in outbound updates\n" | |
5793 | "Apply to all AS numbers\n" | |
5794 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5795 | { |
d62a17ae | 5796 | int idx_peer = 1; |
f4b8ec07 CS |
5797 | char base_xpath[XPATH_MAXLEN]; |
5798 | char af_xpath[XPATH_MAXLEN]; | |
5799 | char attr_xpath[XPATH_MAXLEN]; | |
5800 | afi_t afi = bgp_node_afi(vty); | |
5801 | safi_t safi = bgp_node_safi(vty); | |
5802 | ||
5803 | ||
5804 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5805 | yang_afi_safi_value2identity(afi, safi)); | |
5806 | ||
5807 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5808 | sizeof(base_xpath), af_xpath) | |
5809 | < 0) | |
5810 | return CMD_WARNING_CONFIG_FAILED; | |
5811 | ||
5812 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5813 | "./%s/private-as/remove-private-as-all-replace", | |
5814 | bgp_afi_safi_get_container_str(afi, safi)); | |
5815 | ||
5816 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5817 | ||
5818 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
5819 | } |
5820 | ||
d62a17ae | 5821 | ALIAS_HIDDEN( |
5822 | neighbor_remove_private_as_all_replace_as, | |
5823 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5824 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5825 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5826 | "Remove private ASNs in outbound updates\n" | |
5827 | "Apply to all AS numbers\n" | |
5828 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5829 | |
f4b8ec07 CS |
5830 | DEFUN_YANG (no_neighbor_remove_private_as, |
5831 | no_neighbor_remove_private_as_cmd, | |
5832 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5833 | NO_STR | |
5834 | NEIGHBOR_STR | |
5835 | NEIGHBOR_ADDR_STR2 | |
5836 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5837 | { |
d62a17ae | 5838 | int idx_peer = 2; |
f4b8ec07 CS |
5839 | char base_xpath[XPATH_MAXLEN]; |
5840 | char af_xpath[XPATH_MAXLEN]; | |
5841 | char attr_xpath[XPATH_MAXLEN]; | |
5842 | afi_t afi = bgp_node_afi(vty); | |
5843 | safi_t safi = bgp_node_safi(vty); | |
5844 | ||
5845 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5846 | yang_afi_safi_value2identity(afi, safi)); | |
5847 | ||
5848 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5849 | sizeof(base_xpath), af_xpath) | |
5850 | < 0) | |
5851 | return CMD_WARNING_CONFIG_FAILED; | |
5852 | ||
5853 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5854 | "./%s/private-as/remove-private-as", | |
5855 | bgp_afi_safi_get_container_str(afi, safi)); | |
5856 | ||
5857 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5858 | ||
5859 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5860 | } |
6b0655a2 | 5861 | |
d62a17ae | 5862 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5863 | no_neighbor_remove_private_as_hidden_cmd, | |
5864 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5865 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5866 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5867 | |
f4b8ec07 CS |
5868 | DEFUN_YANG (no_neighbor_remove_private_as_all, |
5869 | no_neighbor_remove_private_as_all_cmd, | |
5870 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5871 | NO_STR | |
5872 | NEIGHBOR_STR | |
5873 | NEIGHBOR_ADDR_STR2 | |
5874 | "Remove private ASNs in outbound updates\n" | |
5875 | "Apply to all AS numbers\n") | |
88b8ed8d | 5876 | { |
d62a17ae | 5877 | int idx_peer = 2; |
f4b8ec07 CS |
5878 | char base_xpath[XPATH_MAXLEN]; |
5879 | char af_xpath[XPATH_MAXLEN]; | |
5880 | char attr_xpath[XPATH_MAXLEN]; | |
5881 | afi_t afi = bgp_node_afi(vty); | |
5882 | safi_t safi = bgp_node_safi(vty); | |
5883 | ||
5884 | ||
5885 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5886 | yang_afi_safi_value2identity(afi, safi)); | |
5887 | ||
5888 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5889 | sizeof(base_xpath), af_xpath) | |
5890 | < 0) | |
5891 | return CMD_WARNING_CONFIG_FAILED; | |
5892 | ||
5893 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5894 | "./%s/private-as/remove-private-as-all", | |
5895 | bgp_afi_safi_get_container_str(afi, safi)); | |
5896 | ||
5897 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5898 | ||
5899 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5900 | } |
5000f21c | 5901 | |
d62a17ae | 5902 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5903 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5904 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5905 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5906 | "Remove private ASNs in outbound updates\n" | |
5907 | "Apply to all AS numbers\n") | |
596c17ba | 5908 | |
f4b8ec07 CS |
5909 | DEFUN_YANG (no_neighbor_remove_private_as_replace_as, |
5910 | no_neighbor_remove_private_as_replace_as_cmd, | |
5911 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5912 | NO_STR | |
5913 | NEIGHBOR_STR | |
5914 | NEIGHBOR_ADDR_STR2 | |
5915 | "Remove private ASNs in outbound updates\n" | |
5916 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5917 | { |
d62a17ae | 5918 | int idx_peer = 2; |
f4b8ec07 CS |
5919 | char base_xpath[XPATH_MAXLEN]; |
5920 | char af_xpath[XPATH_MAXLEN]; | |
5921 | char attr_xpath[XPATH_MAXLEN]; | |
5922 | afi_t afi = bgp_node_afi(vty); | |
5923 | safi_t safi = bgp_node_safi(vty); | |
5924 | ||
5925 | ||
5926 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5927 | yang_afi_safi_value2identity(afi, safi)); | |
5928 | ||
5929 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5930 | sizeof(base_xpath), af_xpath) | |
5931 | < 0) | |
5932 | return CMD_WARNING_CONFIG_FAILED; | |
5933 | ||
5934 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5935 | "./%s/private-as/remove-private-as-replace", | |
5936 | bgp_afi_safi_get_container_str(afi, safi)); | |
5937 | ||
5938 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5939 | ||
5940 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5941 | } |
5000f21c | 5942 | |
d62a17ae | 5943 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5944 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5945 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5946 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5947 | "Remove private ASNs in outbound updates\n" | |
5948 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5949 | |
f4b8ec07 CS |
5950 | DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as, |
5951 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5952 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5953 | NO_STR | |
5954 | NEIGHBOR_STR | |
5955 | NEIGHBOR_ADDR_STR2 | |
5956 | "Remove private ASNs in outbound updates\n" | |
5957 | "Apply to all AS numbers\n" | |
5958 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5959 | { |
d62a17ae | 5960 | int idx_peer = 2; |
f4b8ec07 CS |
5961 | char base_xpath[XPATH_MAXLEN]; |
5962 | char af_xpath[XPATH_MAXLEN]; | |
5963 | char attr_xpath[XPATH_MAXLEN]; | |
5964 | afi_t afi = bgp_node_afi(vty); | |
5965 | safi_t safi = bgp_node_safi(vty); | |
5966 | ||
5967 | ||
5968 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5969 | yang_afi_safi_value2identity(afi, safi)); | |
5970 | ||
5971 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5972 | sizeof(base_xpath), af_xpath) | |
5973 | < 0) | |
5974 | return CMD_WARNING_CONFIG_FAILED; | |
5975 | ||
5976 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5977 | "./%s/private-as/remove-private-as-all-replace", | |
5978 | bgp_afi_safi_get_container_str(afi, safi)); | |
5979 | ||
5980 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5981 | ||
5982 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5983 | } |
5000f21c | 5984 | |
d62a17ae | 5985 | ALIAS_HIDDEN( |
5986 | no_neighbor_remove_private_as_all_replace_as, | |
5987 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5988 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5989 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5990 | "Remove private ASNs in outbound updates\n" | |
5991 | "Apply to all AS numbers\n" | |
5992 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5993 | |
5000f21c | 5994 | |
718e3744 | 5995 | /* neighbor send-community. */ |
f4b8ec07 CS |
5996 | DEFUN_YANG (neighbor_send_community, |
5997 | neighbor_send_community_cmd, | |
5998 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5999 | NEIGHBOR_STR | |
6000 | NEIGHBOR_ADDR_STR2 | |
6001 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6002 | { |
d62a17ae | 6003 | int idx_peer = 1; |
27c05d4d | 6004 | |
d62a17ae | 6005 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6006 | bgp_node_safi(vty), | |
6007 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6008 | } |
6009 | ||
d62a17ae | 6010 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
6011 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6012 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6013 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6014 | |
f4b8ec07 CS |
6015 | DEFUN_YANG (no_neighbor_send_community, |
6016 | no_neighbor_send_community_cmd, | |
6017 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6018 | NO_STR | |
6019 | NEIGHBOR_STR | |
6020 | NEIGHBOR_ADDR_STR2 | |
6021 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6022 | { |
d62a17ae | 6023 | int idx_peer = 2; |
27c05d4d | 6024 | |
d62a17ae | 6025 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6026 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6027 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6028 | } |
6b0655a2 | 6029 | |
d62a17ae | 6030 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
6031 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6032 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6033 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6034 | |
718e3744 | 6035 | /* neighbor send-community extended. */ |
f4b8ec07 CS |
6036 | DEFUN_YANG (neighbor_send_community_type, |
6037 | neighbor_send_community_type_cmd, | |
6038 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6039 | NEIGHBOR_STR | |
6040 | NEIGHBOR_ADDR_STR2 | |
6041 | "Send Community attribute to this neighbor\n" | |
6042 | "Send Standard and Extended Community attributes\n" | |
6043 | "Send Standard, Large and Extended Community attributes\n" | |
6044 | "Send Extended Community attributes\n" | |
6045 | "Send Standard Community attributes\n" | |
6046 | "Send Large Community attributes\n") | |
718e3744 | 6047 | { |
27c05d4d | 6048 | const char *type = argv[argc - 1]->text; |
db45f64d | 6049 | char *peer_str = argv[1]->arg; |
f4b8ec07 CS |
6050 | char base_xpath[XPATH_MAXLEN]; |
6051 | char af_xpath[XPATH_MAXLEN]; | |
6052 | char std_xpath[XPATH_MAXLEN]; | |
6053 | char ext_xpath[XPATH_MAXLEN]; | |
6054 | char lrg_xpath[XPATH_MAXLEN]; | |
db45f64d DS |
6055 | afi_t afi = bgp_node_afi(vty); |
6056 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 6057 | |
f4b8ec07 CS |
6058 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6059 | yang_afi_safi_value2identity(afi, safi)); | |
6060 | ||
6061 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6062 | sizeof(base_xpath), af_xpath) | |
6063 | < 0) | |
db45f64d | 6064 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6065 | |
f4b8ec07 CS |
6066 | if (strmatch(type, "standard")) { |
6067 | snprintf(std_xpath, sizeof(std_xpath), | |
6068 | "./%s/send-community/send-community", | |
6069 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6070 | |
f4b8ec07 CS |
6071 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); |
6072 | } | |
db45f64d | 6073 | |
f4b8ec07 CS |
6074 | if (strmatch(type, "extended")) { |
6075 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6076 | "./%s/send-community/send-ext-community", | |
6077 | bgp_afi_safi_get_container_str(afi, safi)); | |
6078 | ||
6079 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
6080 | } | |
6081 | ||
6082 | if (strmatch(type, "large")) { | |
6083 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6084 | "./%s/send-community/send-large-community", | |
6085 | bgp_afi_safi_get_container_str(afi, safi)); | |
6086 | ||
6087 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "true"); | |
6088 | } | |
db45f64d DS |
6089 | |
6090 | if (strmatch(type, "both")) { | |
f4b8ec07 CS |
6091 | snprintf(std_xpath, sizeof(std_xpath), |
6092 | "./%s/send-community/send-community", | |
6093 | bgp_afi_safi_get_container_str(afi, safi)); | |
6094 | ||
6095 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); | |
6096 | ||
6097 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6098 | "./%s/send-community/send-ext-community", | |
6099 | bgp_afi_safi_get_container_str(afi, safi)); | |
6100 | ||
6101 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
db45f64d | 6102 | } |
f4b8ec07 CS |
6103 | |
6104 | if (strmatch(type, "all")) { | |
6105 | snprintf(std_xpath, sizeof(std_xpath), | |
6106 | "./%s/send-community/send-community", | |
6107 | bgp_afi_safi_get_container_str(afi, safi)); | |
6108 | ||
6109 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); | |
6110 | ||
6111 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6112 | "./%s/send-community/send-ext-community", | |
6113 | bgp_afi_safi_get_container_str(afi, safi)); | |
6114 | ||
6115 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
6116 | ||
6117 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6118 | "./%s/send-community/send-large-community", | |
6119 | bgp_afi_safi_get_container_str(afi, safi)); | |
6120 | ||
6121 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "true"); | |
6122 | } | |
6123 | ||
6124 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 6125 | } |
6126 | ||
6127 | ALIAS_HIDDEN( | |
6128 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
6129 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6130 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6131 | "Send Community attribute to this neighbor\n" | |
6132 | "Send Standard and Extended Community attributes\n" | |
6133 | "Send Standard, Large and Extended Community attributes\n" | |
6134 | "Send Extended Community attributes\n" | |
6135 | "Send Standard Community attributes\n" | |
6136 | "Send Large Community attributes\n") | |
596c17ba | 6137 | |
f4b8ec07 CS |
6138 | DEFUN_YANG (no_neighbor_send_community_type, |
6139 | no_neighbor_send_community_type_cmd, | |
6140 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6141 | NO_STR | |
6142 | NEIGHBOR_STR | |
6143 | NEIGHBOR_ADDR_STR2 | |
6144 | "Send Community attribute to this neighbor\n" | |
6145 | "Send Standard and Extended Community attributes\n" | |
6146 | "Send Standard, Large and Extended Community attributes\n" | |
6147 | "Send Extended Community attributes\n" | |
6148 | "Send Standard Community attributes\n" | |
6149 | "Send Large Community attributes\n") | |
718e3744 | 6150 | { |
d62a17ae | 6151 | const char *type = argv[argc - 1]->text; |
db45f64d | 6152 | char *peer_str = argv[2]->arg; |
f4b8ec07 CS |
6153 | char base_xpath[XPATH_MAXLEN]; |
6154 | char af_xpath[XPATH_MAXLEN]; | |
6155 | char std_xpath[XPATH_MAXLEN]; | |
6156 | char ext_xpath[XPATH_MAXLEN]; | |
6157 | char lrg_xpath[XPATH_MAXLEN]; | |
db45f64d DS |
6158 | afi_t afi = bgp_node_afi(vty); |
6159 | safi_t safi = bgp_node_safi(vty); | |
6160 | ||
f4b8ec07 CS |
6161 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6162 | yang_afi_safi_value2identity(afi, safi)); | |
6163 | ||
6164 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6165 | sizeof(base_xpath), af_xpath) | |
6166 | < 0) | |
6167 | return CMD_WARNING_CONFIG_FAILED; | |
6168 | ||
6169 | if (strmatch(type, "standard")) { | |
6170 | snprintf(std_xpath, sizeof(std_xpath), | |
6171 | "./%s/send-community/send-community", | |
6172 | bgp_afi_safi_get_container_str(afi, safi)); | |
6173 | ||
6174 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); | |
6175 | } | |
6176 | ||
6177 | if (strmatch(type, "extended")) { | |
6178 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6179 | "./%s/send-community/send-ext-community", | |
6180 | bgp_afi_safi_get_container_str(afi, safi)); | |
6181 | ||
6182 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); | |
6183 | } | |
6184 | ||
6185 | if (strmatch(type, "large")) { | |
6186 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6187 | "./%s/send-community/send-large-community", | |
6188 | bgp_afi_safi_get_container_str(afi, safi)); | |
6189 | ||
6190 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "false"); | |
6191 | } | |
6192 | ||
6193 | if (strmatch(type, "both")) { | |
6194 | snprintf(std_xpath, sizeof(std_xpath), | |
6195 | "./%s/send-community/send-community", | |
6196 | bgp_afi_safi_get_container_str(afi, safi)); | |
6197 | ||
6198 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); | |
6199 | ||
6200 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6201 | "./%s/send-community/send-ext-community", | |
6202 | bgp_afi_safi_get_container_str(afi, safi)); | |
6203 | ||
6204 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); | |
6205 | } | |
6206 | ||
6207 | if (strmatch(type, "all")) { | |
6208 | snprintf(std_xpath, sizeof(std_xpath), | |
6209 | "./%s/send-community/send-community", | |
6210 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6211 | |
f4b8ec07 | 6212 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6213 | |
f4b8ec07 CS |
6214 | snprintf(ext_xpath, sizeof(ext_xpath), |
6215 | "./%s/send-community/send-ext-community", | |
6216 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6217 | |
f4b8ec07 | 6218 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6219 | |
f4b8ec07 CS |
6220 | snprintf(lrg_xpath, sizeof(lrg_xpath), |
6221 | "./%s/send-community/send-large-community", | |
6222 | bgp_afi_safi_get_container_str(afi, safi)); | |
d62a17ae | 6223 | |
f4b8ec07 | 6224 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "false"); |
27c05d4d PM |
6225 | } |
6226 | ||
f4b8ec07 | 6227 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6228 | } |
6229 | ||
6230 | ALIAS_HIDDEN( | |
6231 | no_neighbor_send_community_type, | |
6232 | no_neighbor_send_community_type_hidden_cmd, | |
6233 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6234 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6235 | "Send Community attribute to this neighbor\n" | |
6236 | "Send Standard and Extended Community attributes\n" | |
6237 | "Send Standard, Large and Extended Community attributes\n" | |
6238 | "Send Extended Community attributes\n" | |
6239 | "Send Standard Community attributes\n" | |
6240 | "Send Large Community attributes\n") | |
596c17ba | 6241 | |
718e3744 | 6242 | /* neighbor soft-reconfig. */ |
f4b8ec07 CS |
6243 | DEFUN_YANG (neighbor_soft_reconfiguration, |
6244 | neighbor_soft_reconfiguration_cmd, | |
6245 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6246 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6247 | "Per neighbor soft reconfiguration\n" | |
6248 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6249 | { |
d62a17ae | 6250 | int idx_peer = 1; |
f4b8ec07 CS |
6251 | char base_xpath[XPATH_MAXLEN]; |
6252 | char af_xpath[XPATH_MAXLEN]; | |
6253 | char soft_xpath[XPATH_MAXLEN]; | |
6254 | afi_t afi = bgp_node_afi(vty); | |
6255 | safi_t safi = bgp_node_safi(vty); | |
6256 | ||
6257 | ||
6258 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6259 | yang_afi_safi_value2identity(afi, safi)); | |
6260 | ||
6261 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6262 | sizeof(base_xpath), af_xpath) | |
6263 | < 0) | |
6264 | return CMD_WARNING_CONFIG_FAILED; | |
6265 | ||
6266 | snprintf(soft_xpath, sizeof(soft_xpath), "./%s/soft-reconfiguration", | |
6267 | bgp_afi_safi_get_container_str(afi, safi)); | |
6268 | ||
6269 | nb_cli_enqueue_change(vty, soft_xpath, NB_OP_MODIFY, "true"); | |
6270 | ||
6271 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6272 | } |
6273 | ||
d62a17ae | 6274 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
6275 | neighbor_soft_reconfiguration_hidden_cmd, | |
6276 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6277 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6278 | "Per neighbor soft reconfiguration\n" | |
6279 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6280 | |
f4b8ec07 CS |
6281 | DEFUN_YANG (no_neighbor_soft_reconfiguration, |
6282 | no_neighbor_soft_reconfiguration_cmd, | |
6283 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6284 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6285 | "Per neighbor soft reconfiguration\n" | |
6286 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6287 | { |
d62a17ae | 6288 | int idx_peer = 2; |
f4b8ec07 CS |
6289 | char base_xpath[XPATH_MAXLEN]; |
6290 | char af_xpath[XPATH_MAXLEN]; | |
6291 | char soft_xpath[XPATH_MAXLEN]; | |
6292 | afi_t afi = bgp_node_afi(vty); | |
6293 | safi_t safi = bgp_node_safi(vty); | |
6294 | ||
6295 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6296 | yang_afi_safi_value2identity(afi, safi)); | |
6297 | ||
6298 | snprintf(soft_xpath, sizeof(soft_xpath), "./%s/soft-reconfiguration", | |
6299 | bgp_afi_safi_get_container_str(afi, safi)); | |
6300 | ||
6301 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6302 | sizeof(base_xpath), af_xpath) | |
6303 | < 0) | |
6304 | return CMD_WARNING_CONFIG_FAILED; | |
6305 | ||
6306 | nb_cli_enqueue_change(vty, soft_xpath, NB_OP_MODIFY, "false"); | |
6307 | ||
6308 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6309 | } |
6b0655a2 | 6310 | |
d62a17ae | 6311 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
6312 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
6313 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6314 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6315 | "Per neighbor soft reconfiguration\n" | |
6316 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6317 | |
f4b8ec07 CS |
6318 | DEFUN_YANG (neighbor_route_reflector_client, |
6319 | neighbor_route_reflector_client_cmd, | |
6320 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6321 | NEIGHBOR_STR | |
6322 | NEIGHBOR_ADDR_STR2 | |
6323 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6324 | { |
d62a17ae | 6325 | int idx_peer = 1; |
f4b8ec07 CS |
6326 | char base_xpath[XPATH_MAXLEN]; |
6327 | char af_xpath[XPATH_MAXLEN]; | |
6328 | char attr_xpath[XPATH_MAXLEN]; | |
6329 | afi_t afi = bgp_node_afi(vty); | |
6330 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 6331 | |
f4b8ec07 CS |
6332 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6333 | yang_afi_safi_value2identity(afi, safi)); | |
718e3744 | 6334 | |
f4b8ec07 CS |
6335 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6336 | sizeof(base_xpath), af_xpath) | |
6337 | < 0) | |
d62a17ae | 6338 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6339 | |
f4b8ec07 CS |
6340 | snprintf(attr_xpath, sizeof(attr_xpath), |
6341 | "./%s/route-reflector/route-reflector-client", | |
6342 | bgp_afi_safi_get_container_str(afi, safi)); | |
6343 | ||
6344 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6345 | ||
6346 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6347 | } |
6348 | ||
d62a17ae | 6349 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
6350 | neighbor_route_reflector_client_hidden_cmd, | |
6351 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6352 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6353 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6354 | |
f4b8ec07 CS |
6355 | DEFUN_YANG (no_neighbor_route_reflector_client, |
6356 | no_neighbor_route_reflector_client_cmd, | |
6357 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6358 | NO_STR | |
6359 | NEIGHBOR_STR | |
6360 | NEIGHBOR_ADDR_STR2 | |
6361 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6362 | { |
d62a17ae | 6363 | int idx_peer = 2; |
f4b8ec07 CS |
6364 | char base_xpath[XPATH_MAXLEN]; |
6365 | char af_xpath[XPATH_MAXLEN]; | |
6366 | char attr_xpath[XPATH_MAXLEN]; | |
6367 | afi_t afi = bgp_node_afi(vty); | |
6368 | safi_t safi = bgp_node_safi(vty); | |
6369 | ||
6370 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6371 | yang_afi_safi_value2identity(afi, safi)); | |
6372 | ||
6373 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6374 | sizeof(base_xpath), af_xpath) | |
6375 | < 0) | |
6376 | return CMD_WARNING_CONFIG_FAILED; | |
6377 | ||
6378 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6379 | "./%s/route-reflector/route-reflector-client", | |
6380 | bgp_afi_safi_get_container_str(afi, safi)); | |
6381 | ||
6382 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6383 | ||
6384 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6385 | } |
6b0655a2 | 6386 | |
d62a17ae | 6387 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
6388 | no_neighbor_route_reflector_client_hidden_cmd, | |
6389 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6390 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6391 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6392 | |
718e3744 | 6393 | /* neighbor route-server-client. */ |
f4b8ec07 CS |
6394 | DEFUN_YANG (neighbor_route_server_client, |
6395 | neighbor_route_server_client_cmd, | |
6396 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6397 | NEIGHBOR_STR | |
6398 | NEIGHBOR_ADDR_STR2 | |
6399 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 6400 | { |
d62a17ae | 6401 | int idx_peer = 1; |
f4b8ec07 CS |
6402 | char base_xpath[XPATH_MAXLEN]; |
6403 | char af_xpath[XPATH_MAXLEN]; | |
6404 | char attr_xpath[XPATH_MAXLEN]; | |
6405 | afi_t afi = bgp_node_afi(vty); | |
6406 | safi_t safi = bgp_node_safi(vty); | |
2a3d5731 | 6407 | |
f4b8ec07 CS |
6408 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6409 | yang_afi_safi_value2identity(afi, safi)); | |
6410 | ||
6411 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6412 | sizeof(base_xpath), af_xpath) | |
6413 | < 0) | |
d62a17ae | 6414 | return CMD_WARNING_CONFIG_FAILED; |
f4b8ec07 CS |
6415 | |
6416 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6417 | "./%s/route-server/route-server-client", | |
6418 | bgp_afi_safi_get_container_str(afi, safi)); | |
6419 | ||
6420 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6421 | ||
6422 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6423 | } |
6424 | ||
d62a17ae | 6425 | ALIAS_HIDDEN(neighbor_route_server_client, |
6426 | neighbor_route_server_client_hidden_cmd, | |
6427 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6428 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6429 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6430 | |
f4b8ec07 CS |
6431 | DEFUN_YANG (no_neighbor_route_server_client, |
6432 | no_neighbor_route_server_client_cmd, | |
6433 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6434 | NO_STR | |
6435 | NEIGHBOR_STR | |
6436 | NEIGHBOR_ADDR_STR2 | |
6437 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 6438 | { |
d62a17ae | 6439 | int idx_peer = 2; |
f4b8ec07 CS |
6440 | char base_xpath[XPATH_MAXLEN]; |
6441 | char af_xpath[XPATH_MAXLEN]; | |
6442 | char attr_xpath[XPATH_MAXLEN]; | |
6443 | afi_t afi = bgp_node_afi(vty); | |
6444 | safi_t safi = bgp_node_safi(vty); | |
6445 | ||
6446 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6447 | yang_afi_safi_value2identity(afi, safi)); | |
6448 | ||
6449 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6450 | sizeof(base_xpath), af_xpath) | |
6451 | < 0) | |
6452 | return CMD_WARNING_CONFIG_FAILED; | |
6453 | ||
6454 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6455 | "./%s/route-server/route-server-client", | |
6456 | bgp_afi_safi_get_container_str(afi, safi)); | |
6457 | ||
6458 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6459 | ||
6460 | return nb_cli_apply_changes(vty, base_xpath); | |
fee0f4c6 | 6461 | } |
6b0655a2 | 6462 | |
d62a17ae | 6463 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
6464 | no_neighbor_route_server_client_hidden_cmd, | |
6465 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6466 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6467 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6468 | |
fee0f4c6 | 6469 | DEFUN (neighbor_nexthop_local_unchanged, |
6470 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6471 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6472 | NEIGHBOR_STR |
6473 | NEIGHBOR_ADDR_STR2 | |
6474 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6475 | "Leave link-local nexthop unchanged for this peer\n") | |
6476 | { | |
d62a17ae | 6477 | int idx_peer = 1; |
6478 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6479 | bgp_node_safi(vty), | |
6480 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6481 | } |
6b0655a2 | 6482 | |
fee0f4c6 | 6483 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6484 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6485 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6486 | NO_STR |
6487 | NEIGHBOR_STR | |
6488 | NEIGHBOR_ADDR_STR2 | |
6489 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6490 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6491 | { |
d62a17ae | 6492 | int idx_peer = 2; |
6493 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6494 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6495 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6496 | } |
6b0655a2 | 6497 | |
f4b8ec07 CS |
6498 | DEFUN_YANG (neighbor_attr_unchanged, |
6499 | neighbor_attr_unchanged_cmd, | |
6500 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6501 | NEIGHBOR_STR | |
6502 | NEIGHBOR_ADDR_STR2 | |
6503 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6504 | "As-path attribute\n" | |
6505 | "Nexthop attribute\n" | |
6506 | "Med attribute\n") | |
718e3744 | 6507 | { |
d62a17ae | 6508 | int idx = 0; |
8eeb0335 | 6509 | char *peer_str = argv[1]->arg; |
db45f64d DS |
6510 | bool aspath = false; |
6511 | bool nexthop = false; | |
6512 | bool med = false; | |
8eeb0335 DW |
6513 | afi_t afi = bgp_node_afi(vty); |
6514 | safi_t safi = bgp_node_safi(vty); | |
f4b8ec07 CS |
6515 | char base_xpath[XPATH_MAXLEN]; |
6516 | char af_xpath[XPATH_MAXLEN]; | |
6517 | char as_xpath[XPATH_MAXLEN]; | |
6518 | char nxthop_xpath[XPATH_MAXLEN]; | |
6519 | char med_xpath[XPATH_MAXLEN]; | |
8eeb0335 | 6520 | |
f4b8ec07 CS |
6521 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6522 | yang_afi_safi_value2identity(afi, safi)); | |
6523 | ||
6524 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6525 | sizeof(base_xpath), af_xpath) | |
6526 | < 0) | |
8eeb0335 | 6527 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6528 | |
6529 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6530 | aspath = true; |
6531 | ||
d62a17ae | 6532 | idx = 0; |
6533 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6534 | nexthop = true; |
6535 | ||
d62a17ae | 6536 | idx = 0; |
6537 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6538 | med = true; |
d62a17ae | 6539 | |
f4b8ec07 CS |
6540 | snprintf(as_xpath, sizeof(as_xpath), |
6541 | "./%s/attr-unchanged/as-path-unchanged", | |
6542 | bgp_afi_safi_get_container_str(afi, safi)); | |
6543 | snprintf(nxthop_xpath, sizeof(nxthop_xpath), | |
6544 | "./%s/attr-unchanged/next-hop-unchanged", | |
6545 | bgp_afi_safi_get_container_str(afi, safi)); | |
6546 | snprintf(med_xpath, sizeof(med_xpath), | |
6547 | "./%s/attr-unchanged/med-unchanged", | |
6548 | bgp_afi_safi_get_container_str(afi, safi)); | |
6549 | ||
8eeb0335 | 6550 | /* no flags means all of them! */ |
db45f64d | 6551 | if (!aspath && !nexthop && !med) { |
f4b8ec07 CS |
6552 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "true"); |
6553 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "true"); | |
6554 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "true"); | |
8eeb0335 | 6555 | } else { |
f4b8ec07 CS |
6556 | if (!aspath) |
6557 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, | |
6558 | "false"); | |
6559 | else | |
6560 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, | |
6561 | "true"); | |
6562 | ||
6563 | if (!nexthop) | |
6564 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, | |
6565 | "false"); | |
6566 | else | |
6567 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, | |
6568 | "true"); | |
6569 | ||
6570 | if (!med) | |
6571 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, | |
6572 | "false"); | |
6573 | else | |
6574 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, | |
6575 | "true"); | |
d62a17ae | 6576 | } |
6577 | ||
f4b8ec07 | 6578 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6579 | } |
6580 | ||
6581 | ALIAS_HIDDEN( | |
6582 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6583 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6584 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6585 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6586 | "As-path attribute\n" | |
6587 | "Nexthop attribute\n" | |
6588 | "Med attribute\n") | |
596c17ba | 6589 | |
f4b8ec07 CS |
6590 | DEFUN_YANG (no_neighbor_attr_unchanged, |
6591 | no_neighbor_attr_unchanged_cmd, | |
6592 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6593 | NO_STR | |
6594 | NEIGHBOR_STR | |
6595 | NEIGHBOR_ADDR_STR2 | |
6596 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6597 | "As-path attribute\n" | |
6598 | "Nexthop attribute\n" | |
6599 | "Med attribute\n") | |
718e3744 | 6600 | { |
d62a17ae | 6601 | int idx = 0; |
db45f64d | 6602 | char *peer_str = argv[2]->arg; |
db45f64d DS |
6603 | bool aspath = false; |
6604 | bool nexthop = false; | |
6605 | bool med = false; | |
6606 | afi_t afi = bgp_node_afi(vty); | |
6607 | safi_t safi = bgp_node_safi(vty); | |
f4b8ec07 CS |
6608 | char base_xpath[XPATH_MAXLEN]; |
6609 | char af_xpath[XPATH_MAXLEN]; | |
6610 | char as_xpath[XPATH_MAXLEN]; | |
6611 | char nxthop_xpath[XPATH_MAXLEN]; | |
6612 | char med_xpath[XPATH_MAXLEN]; | |
db45f64d | 6613 | |
f4b8ec07 CS |
6614 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6615 | yang_afi_safi_value2identity(afi, safi)); | |
6616 | ||
6617 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6618 | sizeof(base_xpath), af_xpath) | |
6619 | < 0) | |
db45f64d | 6620 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6621 | |
6622 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6623 | aspath = true; |
6624 | ||
d62a17ae | 6625 | idx = 0; |
6626 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6627 | nexthop = true; |
6628 | ||
d62a17ae | 6629 | idx = 0; |
6630 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6631 | med = true; |
d62a17ae | 6632 | |
f4b8ec07 CS |
6633 | snprintf(as_xpath, sizeof(as_xpath), |
6634 | "./%s/attr-unchanged/as-path-unchanged", | |
6635 | bgp_afi_safi_get_container_str(afi, safi)); | |
6636 | snprintf(nxthop_xpath, sizeof(nxthop_xpath), | |
6637 | "./%s/attr-unchanged/next-hop-unchanged", | |
6638 | bgp_afi_safi_get_container_str(afi, safi)); | |
6639 | snprintf(med_xpath, sizeof(med_xpath), | |
6640 | "./%s/attr-unchanged/med-unchanged", | |
6641 | bgp_afi_safi_get_container_str(afi, safi)); | |
6642 | ||
6643 | /* no flags means all of them! */ | |
6644 | if (!aspath && !nexthop && !med) { | |
6645 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "false"); | |
6646 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "false"); | |
6647 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "false"); | |
6648 | } | |
db45f64d DS |
6649 | |
6650 | if (aspath) | |
f4b8ec07 | 6651 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "false"); |
db45f64d DS |
6652 | |
6653 | if (nexthop) | |
f4b8ec07 | 6654 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "false"); |
d62a17ae | 6655 | |
db45f64d | 6656 | if (med) |
f4b8ec07 | 6657 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6658 | |
f4b8ec07 | 6659 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6660 | } |
6661 | ||
6662 | ALIAS_HIDDEN( | |
6663 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6664 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6665 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6666 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6667 | "As-path attribute\n" | |
6668 | "Nexthop attribute\n" | |
6669 | "Med attribute\n") | |
718e3744 | 6670 | |
f4b8ec07 CS |
6671 | /* neighbor ebgp-multihop. */ |
6672 | DEFUN_YANG (neighbor_ebgp_multihop, | |
6673 | neighbor_ebgp_multihop_cmd, | |
6674 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6675 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6676 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6677 | { |
f4b8ec07 CS |
6678 | int idx_peer = 1; |
6679 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 6680 | |
f4b8ec07 CS |
6681 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6682 | sizeof(base_xpath), NULL) | |
6683 | < 0) | |
d62a17ae | 6684 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6685 | |
f4b8ec07 CS |
6686 | nb_cli_enqueue_change(vty, "./ebgp-multihop/enabled", NB_OP_MODIFY, |
6687 | "true"); | |
718e3744 | 6688 | |
f4b8ec07 | 6689 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 6690 | } |
6691 | ||
f4b8ec07 CS |
6692 | DEFUN_YANG (neighbor_ebgp_multihop_ttl, |
6693 | neighbor_ebgp_multihop_ttl_cmd, | |
6694 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6695 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6696 | "Allow EBGP neighbors not on directly connected networks\n" | |
6697 | "maximum hop count\n") | |
718e3744 | 6698 | { |
f4b8ec07 CS |
6699 | int idx_peer = 1; |
6700 | int idx_number = 3; | |
6701 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 6702 | |
f4b8ec07 CS |
6703 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6704 | sizeof(base_xpath), NULL) | |
6705 | < 0) | |
d62a17ae | 6706 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6707 | |
f4b8ec07 CS |
6708 | nb_cli_enqueue_change(vty, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY, |
6709 | argv[idx_number]->arg); | |
718e3744 | 6710 | |
f4b8ec07 | 6711 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 6712 | } |
6713 | ||
f4b8ec07 CS |
6714 | DEFUN_YANG (no_neighbor_ebgp_multihop, |
6715 | no_neighbor_ebgp_multihop_cmd, | |
6716 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6717 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6718 | "Allow EBGP neighbors not on directly connected networks\n" | |
6719 | "maximum hop count\n") | |
718e3744 | 6720 | { |
d62a17ae | 6721 | int idx_peer = 2; |
f4b8ec07 CS |
6722 | char base_xpath[XPATH_MAXLEN]; |
6723 | ||
6724 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6725 | sizeof(base_xpath), NULL) | |
6726 | < 0) | |
6727 | return CMD_WARNING_CONFIG_FAILED; | |
6728 | ||
6729 | if (argc > 4) | |
6730 | nb_cli_enqueue_change(vty, "./ebgp-multihop/multihop-ttl", | |
6731 | NB_OP_DESTROY, NULL); | |
6732 | else | |
6733 | nb_cli_enqueue_change(vty, "./ebgp-multihop/enabled", | |
6734 | NB_OP_MODIFY, "false"); | |
6735 | ||
6736 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6737 | } |
6738 | ||
6b0655a2 | 6739 | |
6ffd2079 | 6740 | /* disable-connected-check */ |
f4b8ec07 CS |
6741 | DEFUN_YANG (neighbor_disable_connected_check, |
6742 | neighbor_disable_connected_check_cmd, | |
6743 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6744 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6745 | "one-hop away EBGP peer using loopback address\n" | |
6746 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6747 | { |
d62a17ae | 6748 | int idx_peer = 1; |
f4b8ec07 CS |
6749 | char base_xpath[XPATH_MAXLEN]; |
6750 | ||
6751 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6752 | sizeof(base_xpath), NULL) | |
6753 | < 0) | |
6754 | return CMD_WARNING_CONFIG_FAILED; | |
6755 | ||
6756 | nb_cli_enqueue_change(vty, "./ebgp-multihop/disable-connected-check", | |
6757 | NB_OP_MODIFY, "true"); | |
6758 | ||
6759 | return nb_cli_apply_changes(vty, base_xpath); | |
6ffd2079 | 6760 | } |
6761 | ||
f4b8ec07 CS |
6762 | DEFUN_YANG (no_neighbor_disable_connected_check, |
6763 | no_neighbor_disable_connected_check_cmd, | |
6764 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6765 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6766 | "one-hop away EBGP peer using loopback address\n" | |
6767 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6768 | { |
d62a17ae | 6769 | int idx_peer = 2; |
f4b8ec07 CS |
6770 | char base_xpath[XPATH_MAXLEN]; |
6771 | ||
6772 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6773 | sizeof(base_xpath), NULL) | |
6774 | < 0) | |
6775 | return CMD_WARNING_CONFIG_FAILED; | |
6776 | ||
6777 | nb_cli_enqueue_change(vty, "./ebgp-multihop/disable-connected-check", | |
6778 | NB_OP_MODIFY, "false"); | |
6779 | ||
6780 | return nb_cli_apply_changes(vty, base_xpath); | |
6ffd2079 | 6781 | } |
6782 | ||
47cbc09b PM |
6783 | |
6784 | /* enforce-first-as */ | |
f4b8ec07 CS |
6785 | DEFUN_YANG (neighbor_enforce_first_as, |
6786 | neighbor_enforce_first_as_cmd, | |
6787 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6788 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6789 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6790 | { |
6791 | int idx_peer = 1; | |
f4b8ec07 | 6792 | char base_xpath[XPATH_MAXLEN]; |
47cbc09b | 6793 | |
f4b8ec07 CS |
6794 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6795 | sizeof(base_xpath), NULL) | |
6796 | < 0) | |
6797 | return CMD_WARNING_CONFIG_FAILED; | |
6798 | ||
6799 | nb_cli_enqueue_change(vty, "./enforce-first-as", NB_OP_MODIFY, "true"); | |
6800 | ||
6801 | return nb_cli_apply_changes(vty, base_xpath); | |
47cbc09b PM |
6802 | } |
6803 | ||
f4b8ec07 CS |
6804 | DEFUN_YANG (no_neighbor_enforce_first_as, |
6805 | no_neighbor_enforce_first_as_cmd, | |
6806 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6807 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6808 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6809 | { |
6810 | int idx_peer = 2; | |
f4b8ec07 | 6811 | char base_xpath[XPATH_MAXLEN]; |
47cbc09b | 6812 | |
f4b8ec07 CS |
6813 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6814 | sizeof(base_xpath), NULL) | |
6815 | < 0) | |
6816 | return CMD_WARNING_CONFIG_FAILED; | |
6817 | ||
6818 | nb_cli_enqueue_change(vty, "./enforce-first-as", NB_OP_MODIFY, "false"); | |
6819 | ||
6820 | return nb_cli_apply_changes(vty, base_xpath); | |
47cbc09b PM |
6821 | } |
6822 | ||
f4b8ec07 CS |
6823 | static int peer_and_group_lookup_nb(struct vty *vty, const char *peer_str, |
6824 | char *base_xpath, int xpath_len, | |
6825 | char *xpath) | |
6826 | { | |
6827 | union sockunion su; | |
6828 | char num_xpath[XPATH_MAXLEN]; | |
6829 | char unnbr_xpath[XPATH_MAXLEN]; | |
6830 | char prgrp_xpath[XPATH_MAXLEN]; | |
6831 | ||
6832 | if (str2sockunion(peer_str, &su) == 0) { | |
6833 | snprintf(num_xpath, sizeof(num_xpath), | |
6834 | "/neighbors/neighbor[remote-address='%s']", peer_str); | |
6835 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
6836 | VTY_CURR_XPATH, num_xpath)) { | |
6837 | snprintf(base_xpath, xpath_len, | |
6838 | FRR_BGP_NEIGHBOR_NUM_XPATH, peer_str, | |
6839 | xpath ? xpath : ""); | |
6840 | } else { | |
6841 | vty_out(vty, | |
6842 | "%% Specify remote-as or peer-group commands first\n"); | |
6843 | return -1; | |
6844 | } | |
6845 | ||
6846 | } else { | |
6847 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
6848 | "/neighbors/unnumbered-neighbor[interface='%s']", | |
6849 | peer_str); | |
6850 | ||
6851 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
6852 | "/peer-groups/peer-group[peer-group-name='%s']", | |
6853 | peer_str); | |
6854 | ||
6855 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
6856 | VTY_CURR_XPATH, unnbr_xpath)) { | |
6857 | snprintf(base_xpath, xpath_len, | |
6858 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, peer_str, | |
6859 | xpath ? xpath : ""); | |
6860 | } else if (yang_dnode_exists(vty->candidate_config->dnode, | |
6861 | "%s%s", VTY_CURR_XPATH, | |
6862 | prgrp_xpath)) { | |
6863 | snprintf(base_xpath, xpath_len, | |
6864 | FRR_BGP_PEER_GROUP_XPATH, peer_str, | |
6865 | xpath ? xpath : ""); | |
6866 | } else { | |
6867 | vty_out(vty, | |
6868 | "%% Create the peer-group or interface first\n"); | |
6869 | return -1; | |
6870 | } | |
6871 | } | |
6872 | ||
6873 | return 0; | |
6874 | } | |
47cbc09b | 6875 | |
f4b8ec07 CS |
6876 | DEFUN_YANG (neighbor_description, |
6877 | neighbor_description_cmd, | |
6878 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6879 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6880 | "Neighbor specific description\n" | |
6881 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6882 | { |
d62a17ae | 6883 | int idx_peer = 1; |
6884 | int idx_line = 3; | |
f4b8ec07 CS |
6885 | int ret; |
6886 | char base_xpath[XPATH_MAXLEN]; | |
d62a17ae | 6887 | char *str; |
718e3744 | 6888 | |
f4b8ec07 CS |
6889 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6890 | sizeof(base_xpath), NULL) | |
6891 | < 0) | |
d62a17ae | 6892 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6893 | |
d62a17ae | 6894 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6895 | |
f4b8ec07 CS |
6896 | nb_cli_enqueue_change(vty, "./description", NB_OP_MODIFY, str); |
6897 | ||
6898 | ret = nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6899 | |
d62a17ae | 6900 | XFREE(MTYPE_TMP, str); |
718e3744 | 6901 | |
f4b8ec07 | 6902 | return ret; |
718e3744 | 6903 | } |
6904 | ||
f4b8ec07 CS |
6905 | DEFUN_YANG (no_neighbor_description, |
6906 | no_neighbor_description_cmd, | |
6907 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6908 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6909 | "Neighbor specific description\n") | |
718e3744 | 6910 | { |
d62a17ae | 6911 | int idx_peer = 2; |
f4b8ec07 CS |
6912 | char base_xpath[XPATH_MAXLEN]; |
6913 | ||
6914 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6915 | sizeof(base_xpath), NULL) | |
6916 | < 0) | |
d62a17ae | 6917 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6918 | |
f4b8ec07 | 6919 | nb_cli_enqueue_change(vty, "./description", NB_OP_DESTROY, NULL); |
718e3744 | 6920 | |
f4b8ec07 | 6921 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 6922 | } |
6923 | ||
a14810f4 PM |
6924 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
6925 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6926 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6927 | "Neighbor specific description\n" | |
6928 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6929 | |
d62a17ae | 6930 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6931 | "IPv4 address\n" \ | |
6932 | "IPv6 address\n" \ | |
6933 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6934 | |
f4b8ec07 CS |
6935 | DEFUN_YANG (neighbor_update_source, |
6936 | neighbor_update_source_cmd, | |
6937 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6938 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6939 | "Source of routing updates\n" | |
6940 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6941 | { |
d62a17ae | 6942 | int idx_peer = 1; |
6943 | int idx_peer_2 = 3; | |
f4b8ec07 CS |
6944 | union sockunion su; |
6945 | char base_xpath[XPATH_MAXLEN]; | |
6946 | ||
6947 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6948 | sizeof(base_xpath), NULL) | |
6949 | < 0) | |
6950 | return CMD_WARNING_CONFIG_FAILED; | |
6951 | ||
f4b8ec07 CS |
6952 | if (str2sockunion(argv[idx_peer_2]->arg, &su) == 0) |
6953 | nb_cli_enqueue_change(vty, "./update-source/ip", NB_OP_MODIFY, | |
d62a17ae | 6954 | argv[idx_peer_2]->arg); |
f4b8ec07 CS |
6955 | else |
6956 | nb_cli_enqueue_change(vty, "./update-source/interface", | |
6957 | NB_OP_MODIFY, argv[idx_peer_2]->arg); | |
6958 | ||
6959 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6960 | } |
6961 | ||
f4b8ec07 CS |
6962 | DEFUN_YANG (no_neighbor_update_source, |
6963 | no_neighbor_update_source_cmd, | |
6964 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6965 | NO_STR NEIGHBOR_STR | |
6966 | NEIGHBOR_ADDR_STR2 | |
6967 | "Source of routing updates\n" | |
6968 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6969 | { |
d62a17ae | 6970 | int idx_peer = 2; |
f4b8ec07 | 6971 | char base_xpath[XPATH_MAXLEN]; |
f4b8ec07 CS |
6972 | |
6973 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6974 | sizeof(base_xpath), NULL) | |
6975 | < 0) | |
6976 | return CMD_WARNING_CONFIG_FAILED; | |
6977 | ||
555c8ab7 CS |
6978 | nb_cli_enqueue_change(vty, "./update-source/ip", NB_OP_DESTROY, NULL); |
6979 | nb_cli_enqueue_change(vty, "./update-source/interface", NB_OP_DESTROY, | |
6980 | NULL); | |
f4b8ec07 CS |
6981 | |
6982 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6983 | } |
6b0655a2 | 6984 | |
d62a17ae | 6985 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6986 | afi_t afi, safi_t safi, | |
6987 | const char *rmap, int set) | |
718e3744 | 6988 | { |
d62a17ae | 6989 | int ret; |
6990 | struct peer *peer; | |
80912664 | 6991 | struct route_map *route_map = NULL; |
718e3744 | 6992 | |
d62a17ae | 6993 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6994 | if (!peer) | |
6995 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6996 | |
1de27621 | 6997 | if (set) { |
80912664 DS |
6998 | if (rmap) |
6999 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
7000 | ret = peer_default_originate_set(peer, afi, safi, |
7001 | rmap, route_map); | |
7002 | } else | |
d62a17ae | 7003 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 7004 | |
d62a17ae | 7005 | return bgp_vty_return(vty, ret); |
718e3744 | 7006 | } |
7007 | ||
7008 | /* neighbor default-originate. */ | |
7009 | DEFUN (neighbor_default_originate, | |
7010 | neighbor_default_originate_cmd, | |
9ccf14f7 | 7011 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 7012 | NEIGHBOR_STR |
7013 | NEIGHBOR_ADDR_STR2 | |
7014 | "Originate default route to this neighbor\n") | |
7015 | { | |
d62a17ae | 7016 | int idx_peer = 1; |
7017 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7018 | bgp_node_afi(vty), | |
7019 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 7020 | } |
7021 | ||
d62a17ae | 7022 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
7023 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
7024 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7025 | "Originate default route to this neighbor\n") | |
596c17ba | 7026 | |
718e3744 | 7027 | DEFUN (neighbor_default_originate_rmap, |
7028 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 7029 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 7030 | NEIGHBOR_STR |
7031 | NEIGHBOR_ADDR_STR2 | |
7032 | "Originate default route to this neighbor\n" | |
7033 | "Route-map to specify criteria to originate default\n" | |
7034 | "route-map name\n") | |
7035 | { | |
d62a17ae | 7036 | int idx_peer = 1; |
7037 | int idx_word = 4; | |
7038 | return peer_default_originate_set_vty( | |
7039 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7040 | argv[idx_word]->arg, 1); | |
718e3744 | 7041 | } |
7042 | ||
d62a17ae | 7043 | ALIAS_HIDDEN( |
7044 | neighbor_default_originate_rmap, | |
7045 | neighbor_default_originate_rmap_hidden_cmd, | |
7046 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
7047 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7048 | "Originate default route to this neighbor\n" | |
7049 | "Route-map to specify criteria to originate default\n" | |
7050 | "route-map name\n") | |
596c17ba | 7051 | |
718e3744 | 7052 | DEFUN (no_neighbor_default_originate, |
7053 | no_neighbor_default_originate_cmd, | |
a636c635 | 7054 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 7055 | NO_STR |
7056 | NEIGHBOR_STR | |
7057 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
7058 | "Originate default route to this neighbor\n" |
7059 | "Route-map to specify criteria to originate default\n" | |
7060 | "route-map name\n") | |
718e3744 | 7061 | { |
d62a17ae | 7062 | int idx_peer = 2; |
7063 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7064 | bgp_node_afi(vty), | |
7065 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 7066 | } |
7067 | ||
d62a17ae | 7068 | ALIAS_HIDDEN( |
7069 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
7070 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
7071 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7072 | "Originate default route to this neighbor\n" | |
7073 | "Route-map to specify criteria to originate default\n" | |
7074 | "route-map name\n") | |
596c17ba | 7075 | |
6b0655a2 | 7076 | |
f418446b | 7077 | /* Set specified peer's BGP port. */ |
f4b8ec07 CS |
7078 | DEFUN_YANG (neighbor_port, |
7079 | neighbor_port_cmd, | |
7080 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
7081 | NEIGHBOR_STR | |
7082 | NEIGHBOR_ADDR_STR | |
7083 | "Neighbor's BGP port\n" | |
7084 | "TCP port number\n") | |
718e3744 | 7085 | { |
d62a17ae | 7086 | int idx_ip = 1; |
7087 | int idx_number = 3; | |
f4b8ec07 | 7088 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 7089 | |
f4b8ec07 CS |
7090 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7091 | argv[idx_ip]->arg, ""); | |
718e3744 | 7092 | |
f4b8ec07 CS |
7093 | nb_cli_enqueue_change(vty, "./local-port", NB_OP_MODIFY, |
7094 | argv[idx_number]->arg); | |
7095 | ||
7096 | return nb_cli_apply_changes(vty, base_xpath); | |
7097 | } | |
6b0655a2 | 7098 | |
f4b8ec07 CS |
7099 | DEFUN_YANG (no_neighbor_port, |
7100 | no_neighbor_port_cmd, | |
7101 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
7102 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR | |
7103 | "Neighbor's BGP port\n" | |
7104 | "TCP port number\n") | |
718e3744 | 7105 | { |
f4b8ec07 CS |
7106 | int idx_ip = 2; |
7107 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7108 | |
f4b8ec07 CS |
7109 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7110 | argv[idx_ip]->arg, ""); | |
718e3744 | 7111 | |
f4b8ec07 | 7112 | nb_cli_enqueue_change(vty, "./local-port", NB_OP_DESTROY, NULL); |
718e3744 | 7113 | |
f4b8ec07 | 7114 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7115 | } |
7116 | ||
f4b8ec07 CS |
7117 | DEFUN_YANG (neighbor_weight, |
7118 | neighbor_weight_cmd, | |
7119 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7120 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7121 | "Set default weight for routes from this neighbor\n" | |
7122 | "default weight\n") | |
718e3744 | 7123 | { |
f4b8ec07 CS |
7124 | int idx_peer = 1; |
7125 | int idx_number = 3; | |
7126 | char base_xpath[XPATH_MAXLEN]; | |
7127 | char af_xpath[XPATH_MAXLEN]; | |
7128 | char attr_xpath[XPATH_MAXLEN]; | |
7129 | afi_t afi = bgp_node_afi(vty); | |
7130 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 7131 | |
f4b8ec07 CS |
7132 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
7133 | yang_afi_safi_value2identity(afi, safi)); | |
7134 | ||
7135 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7136 | sizeof(base_xpath), af_xpath) | |
7137 | < 0) | |
d62a17ae | 7138 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7139 | |
f4b8ec07 CS |
7140 | snprintf(attr_xpath, sizeof(attr_xpath), "./%s/weight/weight-attribute", |
7141 | bgp_afi_safi_get_container_str(afi, safi)); | |
718e3744 | 7142 | |
f4b8ec07 CS |
7143 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, |
7144 | argv[idx_number]->arg); | |
7145 | ||
7146 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7147 | } |
7148 | ||
d62a17ae | 7149 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
7150 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7151 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7152 | "Set default weight for routes from this neighbor\n" | |
7153 | "default weight\n") | |
596c17ba | 7154 | |
f4b8ec07 CS |
7155 | DEFUN_YANG (no_neighbor_weight, |
7156 | no_neighbor_weight_cmd, | |
7157 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7158 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7159 | "Set default weight for routes from this neighbor\n" | |
7160 | "default weight\n") | |
718e3744 | 7161 | { |
d62a17ae | 7162 | int idx_peer = 2; |
f4b8ec07 CS |
7163 | char base_xpath[XPATH_MAXLEN]; |
7164 | char af_xpath[XPATH_MAXLEN]; | |
7165 | char attr_xpath[XPATH_MAXLEN]; | |
7166 | afi_t afi = bgp_node_afi(vty); | |
7167 | safi_t safi = bgp_node_safi(vty); | |
7168 | ||
7169 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
7170 | yang_afi_safi_value2identity(afi, safi)); | |
7171 | ||
7172 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7173 | sizeof(base_xpath), af_xpath) | |
7174 | < 0) | |
7175 | return CMD_WARNING_CONFIG_FAILED; | |
7176 | ||
7177 | snprintf(attr_xpath, sizeof(attr_xpath), "./%s/weight/weight-attribute", | |
7178 | bgp_afi_safi_get_container_str(afi, safi)); | |
7179 | ||
7180 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_DESTROY, NULL); | |
7181 | ||
7182 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7183 | } |
7184 | ||
d62a17ae | 7185 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
7186 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7187 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7188 | "Set default weight for routes from this neighbor\n" | |
7189 | "default weight\n") | |
596c17ba | 7190 | |
6b0655a2 | 7191 | |
718e3744 | 7192 | /* Override capability negotiation. */ |
8611c7f3 CS |
7193 | DEFUN_YANG (neighbor_override_capability, |
7194 | neighbor_override_capability_cmd, | |
7195 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7196 | NEIGHBOR_STR | |
7197 | NEIGHBOR_ADDR_STR2 | |
7198 | "Override capability negotiation result\n") | |
718e3744 | 7199 | { |
d62a17ae | 7200 | int idx_peer = 1; |
8611c7f3 CS |
7201 | char base_xpath[XPATH_MAXLEN]; |
7202 | ||
7203 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7204 | sizeof(base_xpath), NULL) | |
7205 | < 0) | |
7206 | return CMD_WARNING_CONFIG_FAILED; | |
7207 | ||
7208 | nb_cli_enqueue_change( | |
7209 | vty, "./capability-options/override-capability", | |
7210 | NB_OP_MODIFY, "true"); | |
7211 | ||
7212 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7213 | } |
7214 | ||
8611c7f3 CS |
7215 | DEFUN_YANG (no_neighbor_override_capability, |
7216 | no_neighbor_override_capability_cmd, | |
7217 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7218 | NO_STR | |
7219 | NEIGHBOR_STR | |
7220 | NEIGHBOR_ADDR_STR2 | |
7221 | "Override capability negotiation result\n") | |
718e3744 | 7222 | { |
d62a17ae | 7223 | int idx_peer = 2; |
8611c7f3 CS |
7224 | char base_xpath[XPATH_MAXLEN]; |
7225 | ||
7226 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7227 | sizeof(base_xpath), NULL) | |
7228 | < 0) | |
7229 | return CMD_WARNING_CONFIG_FAILED; | |
7230 | ||
7231 | nb_cli_enqueue_change( | |
7232 | vty, "./capability-options/override-capability", | |
7233 | NB_OP_MODIFY, "false"); | |
7234 | ||
7235 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7236 | } |
6b0655a2 | 7237 | |
8611c7f3 CS |
7238 | DEFUN_YANG (neighbor_strict_capability, |
7239 | neighbor_strict_capability_cmd, | |
7240 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7241 | NEIGHBOR_STR | |
7242 | NEIGHBOR_ADDR_STR2 | |
7243 | "Strict capability negotiation match\n") | |
718e3744 | 7244 | { |
9fb964de | 7245 | int idx_peer = 1; |
8611c7f3 | 7246 | char base_xpath[XPATH_MAXLEN]; |
9fb964de | 7247 | |
8611c7f3 CS |
7248 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7249 | sizeof(base_xpath), NULL) | |
7250 | < 0) | |
7251 | return CMD_WARNING_CONFIG_FAILED; | |
7252 | ||
7253 | nb_cli_enqueue_change( | |
7254 | vty, "./capability-options/strict-capability", | |
7255 | NB_OP_MODIFY, "true"); | |
7256 | ||
7257 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7258 | } |
7259 | ||
8611c7f3 CS |
7260 | DEFUN_YANG (no_neighbor_strict_capability, |
7261 | no_neighbor_strict_capability_cmd, | |
7262 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7263 | NO_STR | |
7264 | NEIGHBOR_STR | |
7265 | NEIGHBOR_ADDR_STR2 | |
7266 | "Strict capability negotiation match\n") | |
718e3744 | 7267 | { |
9fb964de | 7268 | int idx_peer = 2; |
8611c7f3 | 7269 | char base_xpath[XPATH_MAXLEN]; |
9fb964de | 7270 | |
8611c7f3 CS |
7271 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7272 | sizeof(base_xpath), NULL) | |
7273 | < 0) | |
7274 | return CMD_WARNING_CONFIG_FAILED; | |
7275 | ||
7276 | nb_cli_enqueue_change( | |
7277 | vty, "./capability-options/strict-capability", | |
7278 | NB_OP_MODIFY, "false"); | |
7279 | ||
7280 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7281 | } |
6b0655a2 | 7282 | |
f4b8ec07 CS |
7283 | DEFUN_YANG (neighbor_timers, |
7284 | neighbor_timers_cmd, | |
7285 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
7286 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7287 | "BGP per neighbor timers\n" | |
7288 | "Keepalive interval\n" | |
7289 | "Holdtime\n") | |
718e3744 | 7290 | { |
f4b8ec07 CS |
7291 | int idx_peer = 1; |
7292 | int idx_number = 3; | |
7293 | int idx_number_2 = 4; | |
7294 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7295 | |
f4b8ec07 CS |
7296 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7297 | sizeof(base_xpath), NULL) | |
7298 | < 0) | |
d62a17ae | 7299 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7300 | |
f4b8ec07 CS |
7301 | nb_cli_enqueue_change(vty, "./timers/keepalive", NB_OP_MODIFY, |
7302 | argv[idx_number]->arg); | |
718e3744 | 7303 | |
f4b8ec07 CS |
7304 | nb_cli_enqueue_change(vty, "./timers/hold-time", NB_OP_MODIFY, |
7305 | argv[idx_number_2]->arg); | |
718e3744 | 7306 | |
f4b8ec07 | 7307 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7308 | } |
6b0655a2 | 7309 | |
f4b8ec07 CS |
7310 | DEFUN_YANG (no_neighbor_timers, |
7311 | no_neighbor_timers_cmd, | |
7312 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
7313 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7314 | "BGP per neighbor timers\n" | |
7315 | "Keepalive interval\n" | |
7316 | "Holdtime\n") | |
718e3744 | 7317 | { |
f4b8ec07 CS |
7318 | int idx_peer = 2; |
7319 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7320 | |
f4b8ec07 CS |
7321 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7322 | sizeof(base_xpath), NULL) | |
7323 | < 0) | |
d62a17ae | 7324 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7325 | |
f4b8ec07 | 7326 | nb_cli_enqueue_change(vty, "./timers/hold-time", NB_OP_DESTROY, NULL); |
718e3744 | 7327 | |
f4b8ec07 | 7328 | nb_cli_enqueue_change(vty, "./timers/keepalive", NB_OP_DESTROY, NULL); |
718e3744 | 7329 | |
f4b8ec07 | 7330 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7331 | } |
6b0655a2 | 7332 | |
f4b8ec07 CS |
7333 | DEFUN_YANG (neighbor_timers_connect, |
7334 | neighbor_timers_connect_cmd, | |
7335 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
7336 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7337 | "BGP per neighbor timers\n" | |
7338 | "BGP connect timer\n" | |
7339 | "Connect timer\n") | |
718e3744 | 7340 | { |
f4b8ec07 CS |
7341 | int idx_peer = 1; |
7342 | int idx_number = 4; | |
7343 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7344 | |
f4b8ec07 CS |
7345 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7346 | sizeof(base_xpath), NULL) | |
7347 | < 0) | |
d62a17ae | 7348 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7349 | |
f4b8ec07 CS |
7350 | nb_cli_enqueue_change(vty, "./timers/connect-time", NB_OP_MODIFY, |
7351 | argv[idx_number]->arg); | |
718e3744 | 7352 | |
f4b8ec07 | 7353 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7354 | } |
7355 | ||
f4b8ec07 CS |
7356 | DEFUN_YANG (no_neighbor_timers_connect, |
7357 | no_neighbor_timers_connect_cmd, | |
7358 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
7359 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7360 | "BGP per neighbor timers\n" | |
7361 | "BGP connect timer\n" | |
7362 | "Connect timer\n") | |
718e3744 | 7363 | { |
f4b8ec07 CS |
7364 | int idx_peer = 2; |
7365 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7366 | |
f4b8ec07 CS |
7367 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7368 | sizeof(base_xpath), NULL) | |
7369 | < 0) | |
d62a17ae | 7370 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7371 | |
f4b8ec07 CS |
7372 | nb_cli_enqueue_change(vty, "./timers/connect-time", NB_OP_DESTROY, |
7373 | NULL); | |
718e3744 | 7374 | |
f4b8ec07 | 7375 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7376 | } |
7377 | ||
f4b8ec07 CS |
7378 | DEFUN_YANG (neighbor_advertise_interval, |
7379 | neighbor_advertise_interval_cmd, | |
7380 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
7381 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7382 | "Minimum interval between sending BGP routing updates\n" | |
7383 | "time in seconds\n") | |
718e3744 | 7384 | { |
d62a17ae | 7385 | int idx_peer = 1; |
f4b8ec07 CS |
7386 | int idx_number = 3; |
7387 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7388 | |
f4b8ec07 CS |
7389 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7390 | sizeof(base_xpath), NULL) | |
7391 | < 0) | |
d62a17ae | 7392 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7393 | |
f4b8ec07 CS |
7394 | nb_cli_enqueue_change(vty, "./timers/advertise-interval", NB_OP_MODIFY, |
7395 | argv[idx_number]->arg); | |
718e3744 | 7396 | |
f4b8ec07 | 7397 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7398 | } |
7399 | ||
f4b8ec07 CS |
7400 | DEFUN_YANG (no_neighbor_advertise_interval, |
7401 | no_neighbor_advertise_interval_cmd, | |
7402 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7403 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7404 | "Minimum interval between sending BGP routing updates\n" | |
7405 | "time in seconds\n") | |
718e3744 | 7406 | { |
d62a17ae | 7407 | int idx_peer = 2; |
f4b8ec07 CS |
7408 | char base_xpath[XPATH_MAXLEN]; |
7409 | ||
7410 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7411 | sizeof(base_xpath), NULL) | |
7412 | < 0) | |
7413 | return CMD_WARNING_CONFIG_FAILED; | |
7414 | ||
7415 | nb_cli_enqueue_change(vty, "./timers/advertise-interval", NB_OP_DESTROY, | |
7416 | NULL); | |
7417 | ||
7418 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7419 | } |
7420 | ||
6b0655a2 | 7421 | |
518f0eb1 DS |
7422 | /* Time to wait before processing route-map updates */ |
7423 | DEFUN (bgp_set_route_map_delay_timer, | |
7424 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 7425 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
7426 | SET_STR |
7427 | "BGP route-map delay timer\n" | |
7428 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 7429 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 7430 | { |
d62a17ae | 7431 | int idx_number = 3; |
d7c0a89a | 7432 | uint32_t rmap_delay_timer; |
d62a17ae | 7433 | |
7434 | if (argv[idx_number]->arg) { | |
7435 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7436 | bm->rmap_update_timer = rmap_delay_timer; | |
7437 | ||
7438 | /* if the dynamic update handling is being disabled, and a timer | |
7439 | * is | |
7440 | * running, stop the timer and act as if the timer has already | |
7441 | * fired. | |
7442 | */ | |
7443 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
7444 | BGP_TIMER_OFF(bm->t_rmap_update); | |
7445 | thread_execute(bm->master, bgp_route_map_update_timer, | |
7446 | NULL, 0); | |
7447 | } | |
7448 | return CMD_SUCCESS; | |
7449 | } else { | |
7450 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7451 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7452 | } |
518f0eb1 DS |
7453 | } |
7454 | ||
7455 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7456 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7457 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7458 | NO_STR |
3a2d747c | 7459 | BGP_STR |
518f0eb1 | 7460 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7461 | "Reset to default time to wait for processing route-map changes\n" |
7462 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7463 | { |
518f0eb1 | 7464 | |
d62a17ae | 7465 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7466 | |
d62a17ae | 7467 | return CMD_SUCCESS; |
518f0eb1 DS |
7468 | } |
7469 | ||
f4b8ec07 CS |
7470 | DEFUN_YANG (neighbor_interface, |
7471 | neighbor_interface_cmd, | |
7472 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7473 | NEIGHBOR_STR NEIGHBOR_ADDR_STR | |
7474 | "Interface\n" | |
7475 | "Interface name\n") | |
718e3744 | 7476 | { |
f4b8ec07 CS |
7477 | int idx_ip = 1; |
7478 | int idx_word = 3; | |
7479 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7480 | |
f4b8ec07 CS |
7481 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7482 | argv[idx_ip]->arg, ""); | |
718e3744 | 7483 | |
f4b8ec07 CS |
7484 | nb_cli_enqueue_change(vty, "./local-interface", NB_OP_MODIFY, |
7485 | argv[idx_word]->arg); | |
718e3744 | 7486 | |
f4b8ec07 | 7487 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7488 | } |
7489 | ||
f4b8ec07 CS |
7490 | DEFUN_YANG (no_neighbor_interface, |
7491 | no_neighbor_interface_cmd, | |
7492 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", | |
7493 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7494 | "Interface\n" | |
7495 | "Interface name\n") | |
718e3744 | 7496 | { |
d62a17ae | 7497 | int idx_peer = 2; |
f4b8ec07 CS |
7498 | char base_xpath[XPATH_MAXLEN]; |
7499 | ||
7500 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, | |
7501 | argv[idx_peer]->arg, ""); | |
7502 | ||
7503 | nb_cli_enqueue_change(vty, "./local-interface", NB_OP_DESTROY, NULL); | |
7504 | ||
7505 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7506 | } |
6b0655a2 | 7507 | |
718e3744 | 7508 | DEFUN (neighbor_distribute_list, |
7509 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 7510 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 7511 | NEIGHBOR_STR |
7512 | NEIGHBOR_ADDR_STR2 | |
7513 | "Filter updates to/from this neighbor\n" | |
7514 | "IP access-list number\n" | |
7515 | "IP access-list number (expanded range)\n" | |
7516 | "IP Access-list name\n" | |
7517 | "Filter incoming updates\n" | |
7518 | "Filter outgoing updates\n") | |
7519 | { | |
d62a17ae | 7520 | int idx_peer = 1; |
7521 | int idx_acl = 3; | |
7522 | int direct, ret; | |
7523 | struct peer *peer; | |
a8206004 | 7524 | |
d62a17ae | 7525 | const char *pstr = argv[idx_peer]->arg; |
7526 | const char *acl = argv[idx_acl]->arg; | |
7527 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7528 | |
d62a17ae | 7529 | peer = peer_and_group_lookup_vty(vty, pstr); |
7530 | if (!peer) | |
7531 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7532 | |
d62a17ae | 7533 | /* Check filter direction. */ |
7534 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7535 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7536 | direct, acl); | |
a8206004 | 7537 | |
d62a17ae | 7538 | return bgp_vty_return(vty, ret); |
718e3744 | 7539 | } |
7540 | ||
d62a17ae | 7541 | ALIAS_HIDDEN( |
7542 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
7543 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
7544 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7545 | "Filter updates to/from this neighbor\n" | |
7546 | "IP access-list number\n" | |
7547 | "IP access-list number (expanded range)\n" | |
7548 | "IP Access-list name\n" | |
7549 | "Filter incoming updates\n" | |
7550 | "Filter outgoing updates\n") | |
596c17ba | 7551 | |
718e3744 | 7552 | DEFUN (no_neighbor_distribute_list, |
7553 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 7554 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 7555 | NO_STR |
7556 | NEIGHBOR_STR | |
7557 | NEIGHBOR_ADDR_STR2 | |
7558 | "Filter updates to/from this neighbor\n" | |
7559 | "IP access-list number\n" | |
7560 | "IP access-list number (expanded range)\n" | |
7561 | "IP Access-list name\n" | |
7562 | "Filter incoming updates\n" | |
7563 | "Filter outgoing updates\n") | |
7564 | { | |
d62a17ae | 7565 | int idx_peer = 2; |
7566 | int direct, ret; | |
7567 | struct peer *peer; | |
a8206004 | 7568 | |
d62a17ae | 7569 | const char *pstr = argv[idx_peer]->arg; |
7570 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7571 | |
d62a17ae | 7572 | peer = peer_and_group_lookup_vty(vty, pstr); |
7573 | if (!peer) | |
7574 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7575 | |
d62a17ae | 7576 | /* Check filter direction. */ |
7577 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7578 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7579 | direct); | |
a8206004 | 7580 | |
d62a17ae | 7581 | return bgp_vty_return(vty, ret); |
718e3744 | 7582 | } |
6b0655a2 | 7583 | |
d62a17ae | 7584 | ALIAS_HIDDEN( |
7585 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
7586 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
7587 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7588 | "Filter updates to/from this neighbor\n" | |
7589 | "IP access-list number\n" | |
7590 | "IP access-list number (expanded range)\n" | |
7591 | "IP Access-list name\n" | |
7592 | "Filter incoming updates\n" | |
7593 | "Filter outgoing updates\n") | |
596c17ba | 7594 | |
718e3744 | 7595 | /* Set prefix list to the peer. */ |
d62a17ae | 7596 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7597 | afi_t afi, safi_t safi, | |
7598 | const char *name_str, | |
7599 | const char *direct_str) | |
718e3744 | 7600 | { |
d62a17ae | 7601 | int ret; |
d62a17ae | 7602 | int direct = FILTER_IN; |
cf9ac8bf | 7603 | struct peer *peer; |
718e3744 | 7604 | |
d62a17ae | 7605 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7606 | if (!peer) | |
7607 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7608 | |
d62a17ae | 7609 | /* Check filter direction. */ |
7610 | if (strncmp(direct_str, "i", 1) == 0) | |
7611 | direct = FILTER_IN; | |
7612 | else if (strncmp(direct_str, "o", 1) == 0) | |
7613 | direct = FILTER_OUT; | |
718e3744 | 7614 | |
d62a17ae | 7615 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7616 | |
d62a17ae | 7617 | return bgp_vty_return(vty, ret); |
718e3744 | 7618 | } |
7619 | ||
d62a17ae | 7620 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
7621 | afi_t afi, safi_t safi, | |
7622 | const char *direct_str) | |
718e3744 | 7623 | { |
d62a17ae | 7624 | int ret; |
7625 | struct peer *peer; | |
7626 | int direct = FILTER_IN; | |
718e3744 | 7627 | |
d62a17ae | 7628 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7629 | if (!peer) | |
7630 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 7631 | |
d62a17ae | 7632 | /* Check filter direction. */ |
7633 | if (strncmp(direct_str, "i", 1) == 0) | |
7634 | direct = FILTER_IN; | |
7635 | else if (strncmp(direct_str, "o", 1) == 0) | |
7636 | direct = FILTER_OUT; | |
718e3744 | 7637 | |
d62a17ae | 7638 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 7639 | |
d62a17ae | 7640 | return bgp_vty_return(vty, ret); |
718e3744 | 7641 | } |
7642 | ||
7643 | DEFUN (neighbor_prefix_list, | |
7644 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 7645 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 7646 | NEIGHBOR_STR |
7647 | NEIGHBOR_ADDR_STR2 | |
7648 | "Filter updates to/from this neighbor\n" | |
7649 | "Name of a prefix list\n" | |
7650 | "Filter incoming updates\n" | |
7651 | "Filter outgoing updates\n") | |
7652 | { | |
d62a17ae | 7653 | int idx_peer = 1; |
7654 | int idx_word = 3; | |
7655 | int idx_in_out = 4; | |
7656 | return peer_prefix_list_set_vty( | |
7657 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7658 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7659 | } |
7660 | ||
d62a17ae | 7661 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7662 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7663 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7664 | "Filter updates to/from this neighbor\n" | |
7665 | "Name of a prefix list\n" | |
7666 | "Filter incoming updates\n" | |
7667 | "Filter outgoing updates\n") | |
596c17ba | 7668 | |
718e3744 | 7669 | DEFUN (no_neighbor_prefix_list, |
7670 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 7671 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 7672 | NO_STR |
7673 | NEIGHBOR_STR | |
7674 | NEIGHBOR_ADDR_STR2 | |
7675 | "Filter updates to/from this neighbor\n" | |
7676 | "Name of a prefix list\n" | |
7677 | "Filter incoming updates\n" | |
7678 | "Filter outgoing updates\n") | |
7679 | { | |
d62a17ae | 7680 | int idx_peer = 2; |
7681 | int idx_in_out = 5; | |
7682 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7683 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7684 | argv[idx_in_out]->arg); | |
718e3744 | 7685 | } |
6b0655a2 | 7686 | |
d62a17ae | 7687 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
7688 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7689 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7690 | "Filter updates to/from this neighbor\n" | |
7691 | "Name of a prefix list\n" | |
7692 | "Filter incoming updates\n" | |
7693 | "Filter outgoing updates\n") | |
596c17ba | 7694 | |
d62a17ae | 7695 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7696 | safi_t safi, const char *name_str, | |
7697 | const char *direct_str) | |
718e3744 | 7698 | { |
d62a17ae | 7699 | int ret; |
7700 | struct peer *peer; | |
7701 | int direct = FILTER_IN; | |
718e3744 | 7702 | |
d62a17ae | 7703 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7704 | if (!peer) | |
7705 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7706 | |
d62a17ae | 7707 | /* Check filter direction. */ |
7708 | if (strncmp(direct_str, "i", 1) == 0) | |
7709 | direct = FILTER_IN; | |
7710 | else if (strncmp(direct_str, "o", 1) == 0) | |
7711 | direct = FILTER_OUT; | |
718e3744 | 7712 | |
d62a17ae | 7713 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7714 | |
d62a17ae | 7715 | return bgp_vty_return(vty, ret); |
718e3744 | 7716 | } |
7717 | ||
d62a17ae | 7718 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7719 | safi_t safi, const char *direct_str) | |
718e3744 | 7720 | { |
d62a17ae | 7721 | int ret; |
7722 | struct peer *peer; | |
7723 | int direct = FILTER_IN; | |
718e3744 | 7724 | |
d62a17ae | 7725 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7726 | if (!peer) | |
7727 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7728 | |
d62a17ae | 7729 | /* Check filter direction. */ |
7730 | if (strncmp(direct_str, "i", 1) == 0) | |
7731 | direct = FILTER_IN; | |
7732 | else if (strncmp(direct_str, "o", 1) == 0) | |
7733 | direct = FILTER_OUT; | |
718e3744 | 7734 | |
d62a17ae | 7735 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7736 | |
d62a17ae | 7737 | return bgp_vty_return(vty, ret); |
718e3744 | 7738 | } |
7739 | ||
7740 | DEFUN (neighbor_filter_list, | |
7741 | neighbor_filter_list_cmd, | |
9ccf14f7 | 7742 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7743 | NEIGHBOR_STR |
7744 | NEIGHBOR_ADDR_STR2 | |
7745 | "Establish BGP filters\n" | |
7746 | "AS path access-list name\n" | |
7747 | "Filter incoming routes\n" | |
7748 | "Filter outgoing routes\n") | |
7749 | { | |
d62a17ae | 7750 | int idx_peer = 1; |
7751 | int idx_word = 3; | |
7752 | int idx_in_out = 4; | |
7753 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7754 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7755 | argv[idx_in_out]->arg); | |
718e3744 | 7756 | } |
7757 | ||
d62a17ae | 7758 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
7759 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7760 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7761 | "Establish BGP filters\n" | |
7762 | "AS path access-list name\n" | |
7763 | "Filter incoming routes\n" | |
7764 | "Filter outgoing routes\n") | |
596c17ba | 7765 | |
718e3744 | 7766 | DEFUN (no_neighbor_filter_list, |
7767 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 7768 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7769 | NO_STR |
7770 | NEIGHBOR_STR | |
7771 | NEIGHBOR_ADDR_STR2 | |
7772 | "Establish BGP filters\n" | |
7773 | "AS path access-list name\n" | |
7774 | "Filter incoming routes\n" | |
7775 | "Filter outgoing routes\n") | |
7776 | { | |
d62a17ae | 7777 | int idx_peer = 2; |
7778 | int idx_in_out = 5; | |
7779 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7780 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7781 | argv[idx_in_out]->arg); | |
718e3744 | 7782 | } |
6b0655a2 | 7783 | |
d62a17ae | 7784 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
7785 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7786 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7787 | "Establish BGP filters\n" | |
7788 | "AS path access-list name\n" | |
7789 | "Filter incoming routes\n" | |
7790 | "Filter outgoing routes\n") | |
596c17ba | 7791 | |
7f7940e6 MK |
7792 | /* Set advertise-map to the peer. */ |
7793 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7794 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7795 | const char *advertise_str, |
7796 | const char *condition_str, bool condition, | |
7797 | bool set) | |
7f7940e6 MK |
7798 | { |
7799 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7800 | struct peer *peer; | |
7801 | struct route_map *advertise_map; | |
7802 | struct route_map *condition_map; | |
7803 | ||
7804 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7805 | if (!peer) | |
7806 | return ret; | |
7807 | ||
7808 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7809 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7810 | ||
cf2ad4d8 MK |
7811 | if (set) |
7812 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7813 | advertise_map, condition_str, | |
7814 | condition_map, condition); | |
7815 | else | |
7816 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7817 | advertise_map, condition_str, | |
7818 | condition_map, condition); | |
7f7940e6 MK |
7819 | |
7820 | return bgp_vty_return(vty, ret); | |
7821 | } | |
7822 | ||
cf2ad4d8 | 7823 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7824 | neighbor_advertise_map_cmd, |
52b84062 | 7825 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str", |
cf2ad4d8 | 7826 | NO_STR |
7f7940e6 MK |
7827 | NEIGHBOR_STR |
7828 | NEIGHBOR_ADDR_STR2 | |
7829 | "Route-map to conditionally advertise routes\n" | |
7830 | "Name of advertise map\n" | |
7831 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7832 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7833 | "Name of the exist or non exist map\n") |
7f7940e6 | 7834 | { |
7f7940e6 MK |
7835 | bool condition = CONDITION_EXIST; |
7836 | ||
52b84062 | 7837 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7838 | condition = CONDITION_NON_EXIST; |
7839 | ||
52b84062 MK |
7840 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7841 | bgp_node_safi(vty), advertise_str, | |
7842 | condition_str, condition, !no); | |
7f7940e6 MK |
7843 | } |
7844 | ||
7845 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
52b84062 | 7846 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str", |
7f7940e6 MK |
7847 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7848 | "Route-map to conditionally advertise routes\n" | |
7849 | "Name of advertise map\n" | |
7850 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7851 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7852 | "Name of the exist or non exist map\n") |
7f7940e6 | 7853 | |
718e3744 | 7854 | /* Set route-map to the peer. */ |
d62a17ae | 7855 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7856 | afi_t afi, safi_t safi, const char *name_str, | |
7857 | const char *direct_str) | |
718e3744 | 7858 | { |
d62a17ae | 7859 | int ret; |
7860 | struct peer *peer; | |
7861 | int direct = RMAP_IN; | |
1de27621 | 7862 | struct route_map *route_map; |
718e3744 | 7863 | |
d62a17ae | 7864 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7865 | if (!peer) | |
7866 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7867 | |
d62a17ae | 7868 | /* Check filter direction. */ |
7869 | if (strncmp(direct_str, "in", 2) == 0) | |
7870 | direct = RMAP_IN; | |
7871 | else if (strncmp(direct_str, "o", 1) == 0) | |
7872 | direct = RMAP_OUT; | |
718e3744 | 7873 | |
1de27621 DA |
7874 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7875 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7876 | |
d62a17ae | 7877 | return bgp_vty_return(vty, ret); |
718e3744 | 7878 | } |
7879 | ||
d62a17ae | 7880 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
7881 | afi_t afi, safi_t safi, | |
7882 | const char *direct_str) | |
718e3744 | 7883 | { |
d62a17ae | 7884 | int ret; |
7885 | struct peer *peer; | |
7886 | int direct = RMAP_IN; | |
718e3744 | 7887 | |
d62a17ae | 7888 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7889 | if (!peer) | |
7890 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7891 | |
d62a17ae | 7892 | /* Check filter direction. */ |
7893 | if (strncmp(direct_str, "in", 2) == 0) | |
7894 | direct = RMAP_IN; | |
7895 | else if (strncmp(direct_str, "o", 1) == 0) | |
7896 | direct = RMAP_OUT; | |
718e3744 | 7897 | |
d62a17ae | 7898 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 7899 | |
d62a17ae | 7900 | return bgp_vty_return(vty, ret); |
718e3744 | 7901 | } |
7902 | ||
7903 | DEFUN (neighbor_route_map, | |
7904 | neighbor_route_map_cmd, | |
9ccf14f7 | 7905 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 7906 | NEIGHBOR_STR |
7907 | NEIGHBOR_ADDR_STR2 | |
7908 | "Apply route map to neighbor\n" | |
7909 | "Name of route map\n" | |
7910 | "Apply map to incoming routes\n" | |
2a3d5731 | 7911 | "Apply map to outbound routes\n") |
718e3744 | 7912 | { |
d62a17ae | 7913 | int idx_peer = 1; |
7914 | int idx_word = 3; | |
7915 | int idx_in_out = 4; | |
7916 | return peer_route_map_set_vty( | |
7917 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7918 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7919 | } |
7920 | ||
d62a17ae | 7921 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
7922 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7923 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7924 | "Apply route map to neighbor\n" | |
7925 | "Name of route map\n" | |
7926 | "Apply map to incoming routes\n" | |
7927 | "Apply map to outbound routes\n") | |
596c17ba | 7928 | |
718e3744 | 7929 | DEFUN (no_neighbor_route_map, |
7930 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 7931 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 7932 | NO_STR |
7933 | NEIGHBOR_STR | |
7934 | NEIGHBOR_ADDR_STR2 | |
7935 | "Apply route map to neighbor\n" | |
7936 | "Name of route map\n" | |
7937 | "Apply map to incoming routes\n" | |
2a3d5731 | 7938 | "Apply map to outbound routes\n") |
718e3744 | 7939 | { |
d62a17ae | 7940 | int idx_peer = 2; |
7941 | int idx_in_out = 5; | |
7942 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7943 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7944 | argv[idx_in_out]->arg); | |
718e3744 | 7945 | } |
6b0655a2 | 7946 | |
d62a17ae | 7947 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
7948 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7949 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7950 | "Apply route map to neighbor\n" | |
7951 | "Name of route map\n" | |
7952 | "Apply map to incoming routes\n" | |
7953 | "Apply map to outbound routes\n") | |
596c17ba | 7954 | |
718e3744 | 7955 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7956 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7957 | afi_t afi, safi_t safi, | |
7958 | const char *name_str) | |
718e3744 | 7959 | { |
d62a17ae | 7960 | int ret; |
7961 | struct peer *peer; | |
1de27621 | 7962 | struct route_map *route_map; |
718e3744 | 7963 | |
d62a17ae | 7964 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7965 | if (!peer) | |
7966 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7967 | |
1de27621 DA |
7968 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7969 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7970 | |
d62a17ae | 7971 | return bgp_vty_return(vty, ret); |
718e3744 | 7972 | } |
7973 | ||
7974 | /* Unset route-map from the peer. */ | |
d62a17ae | 7975 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7976 | afi_t afi, safi_t safi) | |
718e3744 | 7977 | { |
d62a17ae | 7978 | int ret; |
7979 | struct peer *peer; | |
718e3744 | 7980 | |
d62a17ae | 7981 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7982 | if (!peer) | |
7983 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7984 | |
d62a17ae | 7985 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7986 | |
d62a17ae | 7987 | return bgp_vty_return(vty, ret); |
718e3744 | 7988 | } |
7989 | ||
7990 | DEFUN (neighbor_unsuppress_map, | |
7991 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7992 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7993 | NEIGHBOR_STR |
7994 | NEIGHBOR_ADDR_STR2 | |
7995 | "Route-map to selectively unsuppress suppressed routes\n" | |
7996 | "Name of route map\n") | |
7997 | { | |
d62a17ae | 7998 | int idx_peer = 1; |
7999 | int idx_word = 3; | |
8000 | return peer_unsuppress_map_set_vty( | |
8001 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8002 | argv[idx_word]->arg); | |
718e3744 | 8003 | } |
8004 | ||
d62a17ae | 8005 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
8006 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8007 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8008 | "Route-map to selectively unsuppress suppressed routes\n" | |
8009 | "Name of route map\n") | |
596c17ba | 8010 | |
718e3744 | 8011 | DEFUN (no_neighbor_unsuppress_map, |
8012 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8013 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8014 | NO_STR |
8015 | NEIGHBOR_STR | |
8016 | NEIGHBOR_ADDR_STR2 | |
8017 | "Route-map to selectively unsuppress suppressed routes\n" | |
8018 | "Name of route map\n") | |
8019 | { | |
d62a17ae | 8020 | int idx_peer = 2; |
8021 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
8022 | bgp_node_afi(vty), | |
8023 | bgp_node_safi(vty)); | |
718e3744 | 8024 | } |
6b0655a2 | 8025 | |
d62a17ae | 8026 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
8027 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8028 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8029 | "Route-map to selectively unsuppress suppressed routes\n" | |
8030 | "Name of route map\n") | |
596c17ba | 8031 | |
fde246e8 DA |
8032 | /* Maximum number of prefix to be sent to the neighbor. */ |
8033 | DEFUN(neighbor_maximum_prefix_out, | |
8034 | neighbor_maximum_prefix_out_cmd, | |
8035 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
8036 | NEIGHBOR_STR | |
8037 | NEIGHBOR_ADDR_STR2 | |
8038 | "Maximum number of prefixes to be sent to this peer\n" | |
8039 | "Maximum no. of prefix limit\n") | |
8040 | { | |
04261dec CS |
8041 | char base_xpath[XPATH_MAXLEN]; |
8042 | char af_xpath[XPATH_MAXLEN]; | |
8043 | char attr_xpath[XPATH_MAXLEN]; | |
fde246e8 DA |
8044 | int idx_peer = 1; |
8045 | int idx_number = 3; | |
fde246e8 DA |
8046 | afi_t afi = bgp_node_afi(vty); |
8047 | safi_t safi = bgp_node_safi(vty); | |
8048 | ||
04261dec CS |
8049 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8050 | yang_afi_safi_value2identity(afi, safi)); | |
8051 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8052 | sizeof(base_xpath), af_xpath) | |
8053 | < 0) | |
fde246e8 DA |
8054 | return CMD_WARNING_CONFIG_FAILED; |
8055 | ||
04261dec CS |
8056 | snprintf(attr_xpath, sizeof(attr_xpath), |
8057 | "/%s/prefix-limit/direction-list[direction='out']", | |
8058 | bgp_afi_safi_get_container_str(afi, safi)); | |
8059 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
fde246e8 | 8060 | |
04261dec | 8061 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
fde246e8 | 8062 | |
04261dec CS |
8063 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, |
8064 | argv[idx_number]->arg); | |
8065 | ||
8066 | return nb_cli_apply_changes(vty, base_xpath); | |
fde246e8 DA |
8067 | } |
8068 | ||
8069 | DEFUN(no_neighbor_maximum_prefix_out, | |
8070 | no_neighbor_maximum_prefix_out_cmd, | |
8071 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
8072 | NO_STR | |
8073 | NEIGHBOR_STR | |
8074 | NEIGHBOR_ADDR_STR2 | |
8075 | "Maximum number of prefixes to be sent to this peer\n") | |
8076 | { | |
04261dec CS |
8077 | char base_xpath[XPATH_MAXLEN]; |
8078 | char af_xpath[XPATH_MAXLEN]; | |
8079 | char attr_xpath[XPATH_MAXLEN]; | |
fde246e8 | 8080 | int idx_peer = 2; |
fde246e8 DA |
8081 | afi_t afi = bgp_node_afi(vty); |
8082 | safi_t safi = bgp_node_safi(vty); | |
8083 | ||
04261dec CS |
8084 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8085 | yang_afi_safi_value2identity(afi, safi)); | |
8086 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8087 | sizeof(base_xpath), af_xpath) | |
8088 | < 0) | |
fde246e8 DA |
8089 | return CMD_WARNING_CONFIG_FAILED; |
8090 | ||
04261dec CS |
8091 | snprintf(attr_xpath, sizeof(attr_xpath), |
8092 | "/%s/prefix-limit/direction-list[direction='out']", | |
8093 | bgp_afi_safi_get_container_str(afi, safi)); | |
8094 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8095 | ||
8096 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
fde246e8 | 8097 | |
04261dec | 8098 | return nb_cli_apply_changes(vty, base_xpath); |
fde246e8 DA |
8099 | } |
8100 | ||
9cbd06e0 DA |
8101 | /* Maximum number of prefix configuration. Prefix count is different |
8102 | for each peer configuration. So this configuration can be set for | |
718e3744 | 8103 | each peer configuration. */ |
8104 | DEFUN (neighbor_maximum_prefix, | |
8105 | neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 8106 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
718e3744 | 8107 | NEIGHBOR_STR |
8108 | NEIGHBOR_ADDR_STR2 | |
8109 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
8110 | "maximum no. of prefix limit\n" |
8111 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8112 | { |
d62a17ae | 8113 | int idx_peer = 1; |
8114 | int idx_number = 3; | |
9cbd06e0 | 8115 | int idx_force = 0; |
04261dec CS |
8116 | char base_xpath[XPATH_MAXLEN]; |
8117 | char af_xpath[XPATH_MAXLEN]; | |
8118 | char attr_xpath[XPATH_MAXLEN]; | |
8119 | afi_t afi = bgp_node_afi(vty); | |
8120 | safi_t safi = bgp_node_safi(vty); | |
8121 | ||
8122 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8123 | yang_afi_safi_value2identity(afi, safi)); | |
8124 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8125 | sizeof(base_xpath), af_xpath) | |
8126 | < 0) | |
8127 | return CMD_WARNING_CONFIG_FAILED; | |
8128 | ||
8129 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8130 | "/%s/prefix-limit/direction-list[direction='in']", | |
8131 | bgp_afi_safi_get_container_str(afi, safi)); | |
8132 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8133 | ||
8134 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
9cbd06e0 | 8135 | |
04261dec CS |
8136 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, |
8137 | argv[idx_number]->arg); | |
9cbd06e0 | 8138 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8139 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8140 | "true"); | |
9cbd06e0 | 8141 | |
04261dec | 8142 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8143 | } |
8144 | ||
d62a17ae | 8145 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 8146 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 8147 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8148 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
8149 | "maximum no. of prefix limit\n" |
8150 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8151 | |
e0701b79 | 8152 | DEFUN (neighbor_maximum_prefix_threshold, |
8153 | neighbor_maximum_prefix_threshold_cmd, | |
9cbd06e0 | 8154 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
e0701b79 | 8155 | NEIGHBOR_STR |
8156 | NEIGHBOR_ADDR_STR2 | |
8157 | "Maximum number of prefix accept from this peer\n" | |
8158 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8159 | "Threshold value (%) at which to generate a warning msg\n" |
8160 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8161 | { |
d62a17ae | 8162 | int idx_peer = 1; |
8163 | int idx_number = 3; | |
8164 | int idx_number_2 = 4; | |
9cbd06e0 | 8165 | int idx_force = 0; |
04261dec CS |
8166 | char base_xpath[XPATH_MAXLEN]; |
8167 | char af_xpath[XPATH_MAXLEN]; | |
8168 | char attr_xpath[XPATH_MAXLEN]; | |
8169 | afi_t afi = bgp_node_afi(vty); | |
8170 | safi_t safi = bgp_node_safi(vty); | |
8171 | ||
8172 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8173 | yang_afi_safi_value2identity(afi, safi)); | |
8174 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8175 | sizeof(base_xpath), af_xpath) | |
8176 | < 0) | |
8177 | return CMD_WARNING_CONFIG_FAILED; | |
8178 | ||
8179 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8180 | "/%s/prefix-limit/direction-list[direction='in']", | |
8181 | bgp_afi_safi_get_container_str(afi, safi)); | |
8182 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8183 | ||
8184 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8185 | ||
8186 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8187 | argv[idx_number]->arg); | |
8188 | ||
8189 | nb_cli_enqueue_change(vty, "./options/shutdown-threshold-pct", | |
8190 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
9cbd06e0 DA |
8191 | |
8192 | if (argv_find(argv, argc, "force", &idx_force)) | |
04261dec CS |
8193 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8194 | "true"); | |
9cbd06e0 | 8195 | |
04261dec | 8196 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8197 | } |
e0701b79 | 8198 | |
d62a17ae | 8199 | ALIAS_HIDDEN( |
8200 | neighbor_maximum_prefix_threshold, | |
8201 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 8202 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 8203 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8204 | "Maximum number of prefix accept from this peer\n" | |
8205 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8206 | "Threshold value (%) at which to generate a warning msg\n" |
8207 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8208 | |
718e3744 | 8209 | DEFUN (neighbor_maximum_prefix_warning, |
8210 | neighbor_maximum_prefix_warning_cmd, | |
9cbd06e0 | 8211 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
718e3744 | 8212 | NEIGHBOR_STR |
8213 | NEIGHBOR_ADDR_STR2 | |
8214 | "Maximum number of prefix accept from this peer\n" | |
8215 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8216 | "Only give warning message when limit is exceeded\n" |
8217 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8218 | { |
d62a17ae | 8219 | int idx_peer = 1; |
8220 | int idx_number = 3; | |
9cbd06e0 | 8221 | int idx_force = 0; |
04261dec CS |
8222 | char base_xpath[XPATH_MAXLEN]; |
8223 | char af_xpath[XPATH_MAXLEN]; | |
8224 | char attr_xpath[XPATH_MAXLEN]; | |
8225 | afi_t afi = bgp_node_afi(vty); | |
8226 | safi_t safi = bgp_node_safi(vty); | |
8227 | ||
8228 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8229 | yang_afi_safi_value2identity(afi, safi)); | |
8230 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8231 | sizeof(base_xpath), af_xpath) | |
8232 | < 0) | |
8233 | return CMD_WARNING_CONFIG_FAILED; | |
9cbd06e0 | 8234 | |
04261dec CS |
8235 | snprintf(attr_xpath, sizeof(attr_xpath), |
8236 | "/%s/prefix-limit/direction-list[direction='in']", | |
8237 | bgp_afi_safi_get_container_str(afi, safi)); | |
8238 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8239 | ||
8240 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8241 | ||
8242 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8243 | argv[idx_number]->arg); | |
8244 | ||
8245 | nb_cli_enqueue_change(vty, "./options/warning-only", NB_OP_MODIFY, | |
8246 | "true"); | |
9cbd06e0 | 8247 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8248 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8249 | "true"); | |
9cbd06e0 | 8250 | |
04261dec | 8251 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8252 | } |
8253 | ||
d62a17ae | 8254 | ALIAS_HIDDEN( |
8255 | neighbor_maximum_prefix_warning, | |
8256 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 8257 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 8258 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8259 | "Maximum number of prefix accept from this peer\n" | |
8260 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8261 | "Only give warning message when limit is exceeded\n" |
8262 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8263 | |
e0701b79 | 8264 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
8265 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9cbd06e0 | 8266 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
e0701b79 | 8267 | NEIGHBOR_STR |
8268 | NEIGHBOR_ADDR_STR2 | |
8269 | "Maximum number of prefix accept from this peer\n" | |
8270 | "maximum no. of prefix limit\n" | |
8271 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
8272 | "Only give warning message when limit is exceeded\n" |
8273 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8274 | { |
d62a17ae | 8275 | int idx_peer = 1; |
8276 | int idx_number = 3; | |
8277 | int idx_number_2 = 4; | |
9cbd06e0 | 8278 | int idx_force = 0; |
04261dec CS |
8279 | char base_xpath[XPATH_MAXLEN]; |
8280 | char af_xpath[XPATH_MAXLEN]; | |
8281 | char attr_xpath[XPATH_MAXLEN]; | |
8282 | afi_t afi = bgp_node_afi(vty); | |
8283 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8284 | |
04261dec CS |
8285 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8286 | yang_afi_safi_value2identity(afi, safi)); | |
8287 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8288 | sizeof(base_xpath), af_xpath) | |
8289 | < 0) | |
8290 | return CMD_WARNING_CONFIG_FAILED; | |
8291 | ||
8292 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8293 | "/%s/prefix-limit/direction-list[direction='in']", | |
8294 | bgp_afi_safi_get_container_str(afi, safi)); | |
8295 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8296 | ||
8297 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8298 | ||
8299 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8300 | argv[idx_number]->arg); | |
8301 | nb_cli_enqueue_change(vty, "./options/tw-shutdown-threshold-pct", | |
8302 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
8303 | nb_cli_enqueue_change(vty, "./options/tw-warning-only", NB_OP_MODIFY, | |
8304 | "true"); | |
9cbd06e0 | 8305 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8306 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8307 | "true"); | |
9cbd06e0 | 8308 | |
04261dec | 8309 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8310 | } |
8311 | ||
d62a17ae | 8312 | ALIAS_HIDDEN( |
8313 | neighbor_maximum_prefix_threshold_warning, | |
8314 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 8315 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 8316 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8317 | "Maximum number of prefix accept from this peer\n" | |
8318 | "maximum no. of prefix limit\n" | |
8319 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
8320 | "Only give warning message when limit is exceeded\n" |
8321 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8322 | |
0a486e5f | 8323 | DEFUN (neighbor_maximum_prefix_restart, |
8324 | neighbor_maximum_prefix_restart_cmd, | |
9cbd06e0 | 8325 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
0a486e5f | 8326 | NEIGHBOR_STR |
8327 | NEIGHBOR_ADDR_STR2 | |
8328 | "Maximum number of prefix accept from this peer\n" | |
8329 | "maximum no. of prefix limit\n" | |
8330 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8331 | "Restart interval in minutes\n" |
8332 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8333 | { |
d62a17ae | 8334 | int idx_peer = 1; |
8335 | int idx_number = 3; | |
8336 | int idx_number_2 = 5; | |
9cbd06e0 | 8337 | int idx_force = 0; |
04261dec CS |
8338 | char base_xpath[XPATH_MAXLEN]; |
8339 | char af_xpath[XPATH_MAXLEN]; | |
8340 | char attr_xpath[XPATH_MAXLEN]; | |
8341 | afi_t afi = bgp_node_afi(vty); | |
8342 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8343 | |
04261dec CS |
8344 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8345 | yang_afi_safi_value2identity(afi, safi)); | |
8346 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8347 | sizeof(base_xpath), af_xpath) | |
8348 | < 0) | |
8349 | return CMD_WARNING_CONFIG_FAILED; | |
8350 | ||
8351 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8352 | "/%s/prefix-limit/direction-list[direction='in']", | |
8353 | bgp_afi_safi_get_container_str(afi, safi)); | |
8354 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8355 | ||
8356 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8357 | ||
8358 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8359 | argv[idx_number]->arg); | |
8360 | nb_cli_enqueue_change(vty, "./options/restart-timer", NB_OP_MODIFY, | |
8361 | argv[idx_number_2]->arg); | |
9cbd06e0 | 8362 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8363 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8364 | "true"); | |
9cbd06e0 | 8365 | |
04261dec | 8366 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8367 | } |
8368 | ||
d62a17ae | 8369 | ALIAS_HIDDEN( |
8370 | neighbor_maximum_prefix_restart, | |
8371 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 8372 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 8373 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8374 | "Maximum number of prefix accept from this peer\n" | |
8375 | "maximum no. of prefix limit\n" | |
8376 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8377 | "Restart interval in minutes\n" |
8378 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8379 | |
0a486e5f | 8380 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
8381 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9cbd06e0 | 8382 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
0a486e5f | 8383 | NEIGHBOR_STR |
8384 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 8385 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 8386 | "maximum no. of prefix limit\n" |
8387 | "Threshold value (%) at which to generate a warning msg\n" | |
8388 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8389 | "Restart interval in minutes\n" |
8390 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8391 | { |
d62a17ae | 8392 | int idx_peer = 1; |
8393 | int idx_number = 3; | |
8394 | int idx_number_2 = 4; | |
8395 | int idx_number_3 = 6; | |
9cbd06e0 | 8396 | int idx_force = 0; |
04261dec CS |
8397 | char base_xpath[XPATH_MAXLEN]; |
8398 | char af_xpath[XPATH_MAXLEN]; | |
8399 | char attr_xpath[XPATH_MAXLEN]; | |
8400 | afi_t afi = bgp_node_afi(vty); | |
8401 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8402 | |
04261dec CS |
8403 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8404 | yang_afi_safi_value2identity(afi, safi)); | |
8405 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8406 | sizeof(base_xpath), af_xpath) | |
8407 | < 0) | |
8408 | return CMD_WARNING_CONFIG_FAILED; | |
8409 | ||
8410 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8411 | "/%s/prefix-limit/direction-list[direction='in']", | |
8412 | bgp_afi_safi_get_container_str(afi, safi)); | |
8413 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8414 | ||
8415 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8416 | ||
8417 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8418 | argv[idx_number]->arg); | |
8419 | nb_cli_enqueue_change(vty, "./options/tr-shutdown-threshold-pct", | |
8420 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
8421 | nb_cli_enqueue_change(vty, "./options/tr-restart-timer", NB_OP_MODIFY, | |
8422 | argv[idx_number_3]->arg); | |
9cbd06e0 | 8423 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8424 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8425 | "true"); | |
9cbd06e0 | 8426 | |
04261dec | 8427 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 8428 | } |
8429 | ||
8430 | ALIAS_HIDDEN( | |
8431 | neighbor_maximum_prefix_threshold_restart, | |
8432 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 8433 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 8434 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8435 | "Maximum number of prefixes to accept from this peer\n" | |
8436 | "maximum no. of prefix limit\n" | |
8437 | "Threshold value (%) at which to generate a warning msg\n" | |
8438 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8439 | "Restart interval in minutes\n" |
8440 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8441 | |
718e3744 | 8442 | DEFUN (no_neighbor_maximum_prefix, |
8443 | no_neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 8444 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
718e3744 | 8445 | NO_STR |
8446 | NEIGHBOR_STR | |
8447 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 8448 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
8449 | "maximum no. of prefix limit\n" |
8450 | "Threshold value (%) at which to generate a warning msg\n" | |
8451 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 8452 | "Restart interval in minutes\n" |
9cbd06e0 DA |
8453 | "Only give warning message when limit is exceeded\n" |
8454 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8455 | { |
d62a17ae | 8456 | int idx_peer = 2; |
04261dec CS |
8457 | char base_xpath[XPATH_MAXLEN]; |
8458 | char af_xpath[XPATH_MAXLEN]; | |
8459 | char attr_xpath[XPATH_MAXLEN]; | |
8460 | afi_t afi = bgp_node_afi(vty); | |
8461 | safi_t safi = bgp_node_safi(vty); | |
8462 | ||
8463 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8464 | yang_afi_safi_value2identity(afi, safi)); | |
8465 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8466 | sizeof(base_xpath), af_xpath) | |
8467 | < 0) | |
8468 | return CMD_WARNING_CONFIG_FAILED; | |
8469 | ||
8470 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8471 | "/%s/prefix-limit/direction-list[direction='in']", | |
8472 | bgp_afi_safi_get_container_str(afi, safi)); | |
8473 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8474 | ||
8475 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
8476 | ||
8477 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 8478 | } |
e52702f2 | 8479 | |
d62a17ae | 8480 | ALIAS_HIDDEN( |
8481 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 8482 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 8483 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8484 | "Maximum number of prefixes to accept from this peer\n" | |
8485 | "maximum no. of prefix limit\n" | |
8486 | "Threshold value (%) at which to generate a warning msg\n" | |
8487 | "Restart bgp connection after limit is exceeded\n" | |
8488 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
8489 | "Only give warning message when limit is exceeded\n" |
8490 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8491 | |
718e3744 | 8492 | |
718e3744 | 8493 | /* "neighbor allowas-in" */ |
8494 | DEFUN (neighbor_allowas_in, | |
8495 | neighbor_allowas_in_cmd, | |
fd8503f5 | 8496 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8497 | NEIGHBOR_STR |
8498 | NEIGHBOR_ADDR_STR2 | |
31500417 | 8499 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 8500 | "Number of occurrences of AS number\n" |
fd8503f5 | 8501 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8502 | { |
d62a17ae | 8503 | int idx_peer = 1; |
8504 | int idx_number_origin = 3; | |
8505 | int ret; | |
8506 | int origin = 0; | |
8507 | struct peer *peer; | |
8508 | int allow_num = 0; | |
8509 | ||
8510 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8511 | if (!peer) | |
8512 | return CMD_WARNING_CONFIG_FAILED; | |
8513 | ||
8514 | if (argc <= idx_number_origin) | |
8515 | allow_num = 3; | |
8516 | else { | |
8517 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8518 | origin = 1; | |
8519 | else | |
8520 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8521 | } | |
8522 | ||
8523 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8524 | allow_num, origin); | |
8525 | ||
8526 | return bgp_vty_return(vty, ret); | |
8527 | } | |
8528 | ||
8529 | ALIAS_HIDDEN( | |
8530 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8531 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8532 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8533 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 8534 | "Number of occurrences of AS number\n" |
d62a17ae | 8535 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8536 | |
718e3744 | 8537 | DEFUN (no_neighbor_allowas_in, |
8538 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8539 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8540 | NO_STR |
8541 | NEIGHBOR_STR | |
8542 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8543 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8544 | "Number of occurrences of AS number\n" |
fd8503f5 | 8545 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8546 | { |
d62a17ae | 8547 | int idx_peer = 2; |
8548 | int ret; | |
8549 | struct peer *peer; | |
718e3744 | 8550 | |
d62a17ae | 8551 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8552 | if (!peer) | |
8553 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8554 | |
d62a17ae | 8555 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8556 | bgp_node_safi(vty)); | |
718e3744 | 8557 | |
d62a17ae | 8558 | return bgp_vty_return(vty, ret); |
718e3744 | 8559 | } |
6b0655a2 | 8560 | |
d62a17ae | 8561 | ALIAS_HIDDEN( |
8562 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8563 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8564 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8565 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8566 | "Number of occurrences of AS number\n" |
d62a17ae | 8567 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8568 | |
f4b8ec07 CS |
8569 | DEFUN_YANG (neighbor_ttl_security, |
8570 | neighbor_ttl_security_cmd, | |
8571 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8572 | NEIGHBOR_STR | |
8573 | NEIGHBOR_ADDR_STR2 | |
8574 | "BGP ttl-security parameters\n" | |
8575 | "Specify the maximum number of hops to the BGP peer\n" | |
8576 | "Number of hops to BGP peer\n") | |
fa411a21 | 8577 | { |
d62a17ae | 8578 | int idx_peer = 1; |
8579 | int idx_number = 4; | |
f4b8ec07 | 8580 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 8581 | |
f4b8ec07 CS |
8582 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
8583 | sizeof(base_xpath), NULL) | |
8584 | < 0) | |
d62a17ae | 8585 | return CMD_WARNING_CONFIG_FAILED; |
8586 | ||
f4b8ec07 CS |
8587 | nb_cli_enqueue_change(vty, "./ttl-security", NB_OP_MODIFY, |
8588 | argv[idx_number]->arg); | |
7ebe625c | 8589 | |
f4b8ec07 | 8590 | return nb_cli_apply_changes(vty, base_xpath); |
fa411a21 NH |
8591 | } |
8592 | ||
8593 | DEFUN (no_neighbor_ttl_security, | |
8594 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 8595 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
8596 | NO_STR |
8597 | NEIGHBOR_STR | |
7ebe625c | 8598 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 8599 | "BGP ttl-security parameters\n" |
3a2d747c QY |
8600 | "Specify the maximum number of hops to the BGP peer\n" |
8601 | "Number of hops to BGP peer\n") | |
fa411a21 | 8602 | { |
d62a17ae | 8603 | int idx_peer = 2; |
f4b8ec07 | 8604 | char base_xpath[XPATH_MAXLEN]; |
fa411a21 | 8605 | |
f4b8ec07 CS |
8606 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
8607 | sizeof(base_xpath), NULL) | |
8608 | < 0) | |
d62a17ae | 8609 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8610 | |
f4b8ec07 CS |
8611 | nb_cli_enqueue_change(vty, "./ttl-security", NB_OP_DESTROY, NULL); |
8612 | ||
8613 | return nb_cli_apply_changes(vty, base_xpath); | |
fa411a21 | 8614 | } |
6b0655a2 | 8615 | |
adbac85e DW |
8616 | DEFUN (neighbor_addpath_tx_all_paths, |
8617 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8618 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8619 | NEIGHBOR_STR |
8620 | NEIGHBOR_ADDR_STR2 | |
8621 | "Use addpath to advertise all paths to a neighbor\n") | |
8622 | { | |
d62a17ae | 8623 | int idx_peer = 1; |
8624 | struct peer *peer; | |
adbac85e | 8625 | |
d62a17ae | 8626 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8627 | if (!peer) | |
8628 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8629 | |
dcc68b5e MS |
8630 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8631 | BGP_ADDPATH_ALL); | |
8632 | return CMD_SUCCESS; | |
adbac85e DW |
8633 | } |
8634 | ||
d62a17ae | 8635 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8636 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8637 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8638 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8639 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8640 | |
adbac85e DW |
8641 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8642 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8643 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8644 | NO_STR |
8645 | NEIGHBOR_STR | |
8646 | NEIGHBOR_ADDR_STR2 | |
8647 | "Use addpath to advertise all paths to a neighbor\n") | |
8648 | { | |
d62a17ae | 8649 | int idx_peer = 2; |
dcc68b5e MS |
8650 | struct peer *peer; |
8651 | ||
8652 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8653 | if (!peer) | |
8654 | return CMD_WARNING_CONFIG_FAILED; | |
8655 | ||
8656 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8657 | != BGP_ADDPATH_ALL) { | |
8658 | vty_out(vty, | |
8659 | "%% Peer not currently configured to transmit all paths."); | |
8660 | return CMD_WARNING_CONFIG_FAILED; | |
8661 | } | |
8662 | ||
8663 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8664 | BGP_ADDPATH_NONE); | |
8665 | ||
8666 | return CMD_SUCCESS; | |
adbac85e DW |
8667 | } |
8668 | ||
d62a17ae | 8669 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8670 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8671 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8672 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8673 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8674 | |
06370dac DW |
8675 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8676 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8677 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8678 | NEIGHBOR_STR |
8679 | NEIGHBOR_ADDR_STR2 | |
8680 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8681 | { | |
d62a17ae | 8682 | int idx_peer = 1; |
8683 | struct peer *peer; | |
06370dac | 8684 | |
d62a17ae | 8685 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8686 | if (!peer) | |
8687 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8688 | |
dcc68b5e MS |
8689 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8690 | BGP_ADDPATH_BEST_PER_AS); | |
8691 | ||
8692 | return CMD_SUCCESS; | |
06370dac DW |
8693 | } |
8694 | ||
d62a17ae | 8695 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8696 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8697 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8698 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8699 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8700 | |
06370dac DW |
8701 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8702 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8703 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8704 | NO_STR |
8705 | NEIGHBOR_STR | |
8706 | NEIGHBOR_ADDR_STR2 | |
8707 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8708 | { | |
d62a17ae | 8709 | int idx_peer = 2; |
dcc68b5e MS |
8710 | struct peer *peer; |
8711 | ||
8712 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8713 | if (!peer) | |
8714 | return CMD_WARNING_CONFIG_FAILED; | |
8715 | ||
8716 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8717 | != BGP_ADDPATH_BEST_PER_AS) { | |
8718 | vty_out(vty, | |
8719 | "%% Peer not currently configured to transmit all best path per as."); | |
8720 | return CMD_WARNING_CONFIG_FAILED; | |
8721 | } | |
8722 | ||
8723 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8724 | BGP_ADDPATH_NONE); | |
8725 | ||
8726 | return CMD_SUCCESS; | |
06370dac DW |
8727 | } |
8728 | ||
d62a17ae | 8729 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8730 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8731 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8732 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8733 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8734 | |
2b31007c RZ |
8735 | DEFPY( |
8736 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8737 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8738 | NEIGHBOR_STR | |
8739 | NEIGHBOR_ADDR_STR2 | |
8740 | "Detect AS loops before sending to neighbor\n") | |
8741 | { | |
8742 | struct peer *peer; | |
8743 | ||
8744 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8745 | if (!peer) | |
8746 | return CMD_WARNING_CONFIG_FAILED; | |
8747 | ||
8748 | peer->as_path_loop_detection = true; | |
8749 | ||
8750 | return CMD_SUCCESS; | |
8751 | } | |
8752 | ||
8753 | DEFPY( | |
8754 | no_neighbor_aspath_loop_detection, | |
8755 | no_neighbor_aspath_loop_detection_cmd, | |
8756 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8757 | NO_STR | |
8758 | NEIGHBOR_STR | |
8759 | NEIGHBOR_ADDR_STR2 | |
8760 | "Detect AS loops before sending to neighbor\n") | |
8761 | { | |
8762 | struct peer *peer; | |
8763 | ||
8764 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8765 | if (!peer) | |
8766 | return CMD_WARNING_CONFIG_FAILED; | |
8767 | ||
8768 | peer->as_path_loop_detection = false; | |
8769 | ||
8770 | return CMD_SUCCESS; | |
8771 | } | |
8772 | ||
b9c7bc5a | 8773 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8774 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8775 | { |
b9c7bc5a PZ |
8776 | struct ecommunity *ecom = NULL; |
8777 | struct ecommunity *ecomadd; | |
ddb5b488 | 8778 | |
b9c7bc5a | 8779 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8780 | if (is_rt6) |
8781 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8782 | ECOMMUNITY_ROUTE_TARGET, | |
8783 | 0); | |
8784 | else | |
8785 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8786 | ECOMMUNITY_ROUTE_TARGET, | |
8787 | 0); | |
b9c7bc5a PZ |
8788 | if (!ecomadd) { |
8789 | vty_out(vty, "Malformed community-list value\n"); | |
8790 | if (ecom) | |
8791 | ecommunity_free(&ecom); | |
8792 | return CMD_WARNING_CONFIG_FAILED; | |
8793 | } | |
ddb5b488 | 8794 | |
b9c7bc5a PZ |
8795 | if (ecom) { |
8796 | ecommunity_merge(ecom, ecomadd); | |
8797 | ecommunity_free(&ecomadd); | |
8798 | } else { | |
8799 | ecom = ecomadd; | |
8800 | } | |
8801 | } | |
8802 | ||
8803 | if (*list) { | |
8804 | ecommunity_free(&*list); | |
ddb5b488 | 8805 | } |
b9c7bc5a PZ |
8806 | *list = ecom; |
8807 | ||
8808 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8809 | } |
8810 | ||
37a87b8f CS |
8811 | bool vpn_policy_check_import(struct bgp *bgp, afi_t afi, safi_t safi, |
8812 | bool v2vimport, char *errmsg, size_t errmsg_len) | |
8813 | { | |
8814 | if (!v2vimport) { | |
8815 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8816 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8817 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8818 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8819 | snprintf( | |
8820 | errmsg, errmsg_len, "%s", | |
8821 | "%% error: Please unconfigure import vrf commands before using vpn commands"); | |
8822 | return false; | |
8823 | } | |
8824 | } else { | |
8825 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8826 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8827 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8828 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8829 | snprintf( | |
8830 | errmsg, errmsg_len, "%s", | |
8831 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands"); | |
8832 | return false; | |
8833 | } | |
8834 | } | |
8835 | return true; | |
8836 | } | |
8837 | ||
0ca70ba5 DS |
8838 | /* |
8839 | * v2vimport is true if we are handling a `import vrf ...` command | |
8840 | */ | |
8841 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8842 | { |
0ca70ba5 DS |
8843 | afi_t afi; |
8844 | ||
ddb5b488 | 8845 | switch (vty->node) { |
b9c7bc5a | 8846 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8847 | afi = AFI_IP; |
8848 | break; | |
b9c7bc5a | 8849 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8850 | afi = AFI_IP6; |
8851 | break; | |
ddb5b488 PZ |
8852 | default: |
8853 | vty_out(vty, | |
b9c7bc5a | 8854 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8855 | return AFI_MAX; |
ddb5b488 | 8856 | } |
69b07479 | 8857 | |
0ca70ba5 DS |
8858 | if (!v2vimport) { |
8859 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8860 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8861 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8862 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8863 | vty_out(vty, | |
8864 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8865 | return AFI_MAX; | |
8866 | } | |
8867 | } else { | |
8868 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8869 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8870 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8871 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8872 | vty_out(vty, | |
8873 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8874 | return AFI_MAX; | |
8875 | } | |
8876 | } | |
8877 | return afi; | |
ddb5b488 PZ |
8878 | } |
8879 | ||
37a87b8f CS |
8880 | DEFPY_YANG( |
8881 | af_rd_vpn_export, | |
8882 | af_rd_vpn_export_cmd, | |
8883 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8884 | NO_STR | |
8885 | "Specify route distinguisher\n" | |
8886 | "Between current address-family and vpn\n" | |
8887 | "For routes leaked from current address-family to vpn\n" | |
8888 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8889 | { |
37a87b8f | 8890 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 8891 | afi_t afi; |
37a87b8f | 8892 | safi_t safi; |
b9c7bc5a | 8893 | int idx = 0; |
b9c7bc5a | 8894 | |
37a87b8f CS |
8895 | afi = bgp_node_afi(vty); |
8896 | safi = bgp_node_safi(vty); | |
ddb5b488 | 8897 | |
37a87b8f CS |
8898 | snprintf( |
8899 | base_xpath, sizeof(base_xpath), | |
8900 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
8901 | yang_afi_safi_value2identity(afi, safi), | |
8902 | bgp_afi_safi_get_container_str(afi, safi)); | |
ddb5b488 | 8903 | |
37a87b8f CS |
8904 | if (argv_find(argv, argc, "no", &idx)) |
8905 | nb_cli_enqueue_change(vty, "./rd", NB_OP_DESTROY, NULL); | |
8906 | else | |
8907 | nb_cli_enqueue_change(vty, "./rd", NB_OP_MODIFY, rd_str); | |
ddb5b488 | 8908 | |
37a87b8f CS |
8909 | return nb_cli_apply_changes(vty, base_xpath); |
8910 | } | |
ddb5b488 | 8911 | |
37a87b8f CS |
8912 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd( |
8913 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
8914 | { | |
8915 | int indent = 2; | |
69b07479 | 8916 | |
37a87b8f CS |
8917 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
8918 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
8919 | } |
8920 | ||
b9c7bc5a PZ |
8921 | ALIAS (af_rd_vpn_export, |
8922 | af_no_rd_vpn_export_cmd, | |
8923 | "no rd vpn export", | |
ddb5b488 | 8924 | NO_STR |
b9c7bc5a PZ |
8925 | "Specify route distinguisher\n" |
8926 | "Between current address-family and vpn\n" | |
8927 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8928 | |
b9c7bc5a PZ |
8929 | DEFPY (af_label_vpn_export, |
8930 | af_label_vpn_export_cmd, | |
e70e9f8e | 8931 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8932 | NO_STR |
ddb5b488 | 8933 | "label value for VRF\n" |
b9c7bc5a PZ |
8934 | "Between current address-family and vpn\n" |
8935 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8936 | "Label Value <0-1048575>\n" |
8937 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8938 | { |
8939 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8940 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8941 | afi_t afi; |
b9c7bc5a | 8942 | int idx = 0; |
c6423c31 | 8943 | bool yes = true; |
b9c7bc5a PZ |
8944 | |
8945 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8946 | yes = false; |
ddb5b488 | 8947 | |
21a16cc2 PZ |
8948 | /* If "no ...", squash trailing parameter */ |
8949 | if (!yes) | |
8950 | label_auto = NULL; | |
8951 | ||
e70e9f8e PZ |
8952 | if (yes) { |
8953 | if (!label_auto) | |
8954 | label = label_val; /* parser should force unsigned */ | |
8955 | } | |
ddb5b488 | 8956 | |
0ca70ba5 | 8957 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8958 | if (afi == AFI_MAX) |
8959 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8960 | |
e70e9f8e | 8961 | |
69b07479 DS |
8962 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8963 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8964 | /* no change */ | |
8965 | return CMD_SUCCESS; | |
e70e9f8e | 8966 | |
69b07479 DS |
8967 | /* |
8968 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8969 | */ | |
8970 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8971 | bgp_get_default(), bgp); | |
8972 | ||
8973 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8974 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8975 | ||
8976 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8977 | ||
8978 | /* | |
8979 | * label has previously been automatically | |
8980 | * assigned by labelpool: release it | |
8981 | * | |
8982 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8983 | * means the automatic assignment is in flight | |
8984 | * and therefore the labelpool callback must | |
8985 | * detect that the auto label is not needed. | |
8986 | */ | |
8987 | ||
8988 | bgp_lp_release(LP_TYPE_VRF, | |
8989 | &bgp->vpn_policy[afi], | |
8990 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8991 | } |
69b07479 DS |
8992 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8993 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8994 | } | |
ddb5b488 | 8995 | |
69b07479 DS |
8996 | bgp->vpn_policy[afi].tovpn_label = label; |
8997 | if (label_auto) { | |
8998 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8999 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9000 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
9001 | vpn_leak_label_callback); | |
ddb5b488 PZ |
9002 | } |
9003 | ||
69b07479 DS |
9004 | /* post-change: re-export vpn routes */ |
9005 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9006 | bgp_get_default(), bgp); | |
9007 | ||
ddb5b488 PZ |
9008 | return CMD_SUCCESS; |
9009 | } | |
9010 | ||
b9c7bc5a PZ |
9011 | ALIAS (af_label_vpn_export, |
9012 | af_no_label_vpn_export_cmd, | |
9013 | "no label vpn export", | |
9014 | NO_STR | |
9015 | "label value for VRF\n" | |
9016 | "Between current address-family and vpn\n" | |
9017 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9018 | |
37a87b8f | 9019 | DEFPY_YANG (af_nexthop_vpn_export, |
b9c7bc5a | 9020 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 9021 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 9022 | NO_STR |
ddb5b488 | 9023 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
9024 | "Between current address-family and vpn\n" |
9025 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9026 | "IPv4 prefix\n" |
9027 | "IPv6 prefix\n") | |
9028 | { | |
37a87b8f | 9029 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9030 | afi_t afi; |
37a87b8f CS |
9031 | safi_t safi; |
9032 | int idx = 0; | |
ddb5b488 PZ |
9033 | struct prefix p; |
9034 | ||
8c85ca28 QY |
9035 | if (!no) { |
9036 | if (!nexthop_su) { | |
9037 | vty_out(vty, "%% Nexthop required\n"); | |
9038 | return CMD_WARNING_CONFIG_FAILED; | |
9039 | } | |
8c85ca28 | 9040 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
9041 | return CMD_WARNING_CONFIG_FAILED; |
9042 | } | |
ddb5b488 | 9043 | |
37a87b8f CS |
9044 | afi = bgp_node_afi(vty); |
9045 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9046 | |
37a87b8f CS |
9047 | snprintf( |
9048 | base_xpath, sizeof(base_xpath), | |
9049 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9050 | yang_afi_safi_value2identity(afi, safi), | |
9051 | bgp_afi_safi_get_container_str(afi, safi)); | |
ddb5b488 | 9052 | |
37a87b8f CS |
9053 | if (argv_find(argv, argc, "no", &idx)) |
9054 | nb_cli_enqueue_change(vty, "./nexthop", NB_OP_DESTROY, NULL); | |
9055 | else | |
9056 | nb_cli_enqueue_change(vty, "./nexthop", NB_OP_MODIFY, | |
9057 | nexthop_su_str); | |
ddb5b488 | 9058 | |
37a87b8f CS |
9059 | return nb_cli_apply_changes(vty, base_xpath); |
9060 | } | |
69b07479 | 9061 | |
37a87b8f CS |
9062 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop( |
9063 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9064 | { | |
9065 | int indent = 2; | |
9066 | ||
9067 | vty_out(vty, "%*snexthop vpn export %s\n", indent, "", | |
9068 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9069 | } |
9070 | ||
b9c7bc5a | 9071 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 9072 | { |
b9c7bc5a PZ |
9073 | if (!strcmp(dstr, "import")) { |
9074 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9075 | } else if (!strcmp(dstr, "export")) { | |
9076 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9077 | } else if (!strcmp(dstr, "both")) { | |
9078 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9079 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9080 | } else { | |
9081 | vty_out(vty, "%% direction parse error\n"); | |
9082 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9083 | } |
ddb5b488 PZ |
9084 | return CMD_SUCCESS; |
9085 | } | |
9086 | ||
b9c7bc5a PZ |
9087 | DEFPY (af_rt_vpn_imexport, |
9088 | af_rt_vpn_imexport_cmd, | |
9089 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
9090 | NO_STR | |
9091 | "Specify route target list\n" | |
ddb5b488 | 9092 | "Specify route target list\n" |
b9c7bc5a PZ |
9093 | "Between current address-family and vpn\n" |
9094 | "For routes leaked from vpn to current address-family: match any\n" | |
9095 | "For routes leaked from current address-family to vpn: set\n" | |
9096 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
9097 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
9098 | { | |
9099 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9100 | int ret; | |
9101 | struct ecommunity *ecom = NULL; | |
9102 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
9103 | vpn_policy_direction_t dir; |
9104 | afi_t afi; | |
9105 | int idx = 0; | |
c6423c31 | 9106 | bool yes = true; |
ddb5b488 | 9107 | |
b9c7bc5a | 9108 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 9109 | yes = false; |
b9c7bc5a | 9110 | |
0ca70ba5 | 9111 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9112 | if (afi == AFI_MAX) |
9113 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9114 | |
b9c7bc5a | 9115 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
9116 | if (ret != CMD_SUCCESS) |
9117 | return ret; | |
9118 | ||
b9c7bc5a PZ |
9119 | if (yes) { |
9120 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9121 | vty_out(vty, "%% Missing RTLIST\n"); | |
9122 | return CMD_WARNING_CONFIG_FAILED; | |
9123 | } | |
c6423c31 | 9124 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
9125 | if (ret != CMD_SUCCESS) { |
9126 | return ret; | |
9127 | } | |
ddb5b488 PZ |
9128 | } |
9129 | ||
69b07479 DS |
9130 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9131 | if (!dodir[dir]) | |
ddb5b488 | 9132 | continue; |
ddb5b488 | 9133 | |
69b07479 | 9134 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 9135 | |
69b07479 DS |
9136 | if (yes) { |
9137 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9138 | ecommunity_free( | |
9139 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9140 | bgp->vpn_policy[afi].rtlist[dir] = | |
9141 | ecommunity_dup(ecom); | |
9142 | } else { | |
9143 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9144 | ecommunity_free( | |
9145 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9146 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 9147 | } |
69b07479 DS |
9148 | |
9149 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 9150 | } |
69b07479 | 9151 | |
d555f3e9 PZ |
9152 | if (ecom) |
9153 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
9154 | |
9155 | return CMD_SUCCESS; | |
9156 | } | |
9157 | ||
b9c7bc5a PZ |
9158 | ALIAS (af_rt_vpn_imexport, |
9159 | af_no_rt_vpn_imexport_cmd, | |
9160 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
9161 | NO_STR |
9162 | "Specify route target list\n" | |
b9c7bc5a PZ |
9163 | "Specify route target list\n" |
9164 | "Between current address-family and vpn\n" | |
9165 | "For routes leaked from vpn to current address-family\n" | |
9166 | "For routes leaked from current address-family to vpn\n" | |
9167 | "both import and export\n") | |
9168 | ||
37a87b8f | 9169 | DEFPY_YANG (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
9170 | af_route_map_vpn_imexport_cmd, |
9171 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
9172 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
9173 | NO_STR | |
ddb5b488 | 9174 | "Specify route map\n" |
b9c7bc5a PZ |
9175 | "Between current address-family and vpn\n" |
9176 | "For routes leaked from vpn to current address-family\n" | |
9177 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9178 | "name of route-map\n") |
9179 | { | |
37a87b8f | 9180 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9181 | afi_t afi; |
37a87b8f | 9182 | safi_t safi; |
ddb5b488 | 9183 | int idx = 0; |
ddb5b488 | 9184 | |
37a87b8f CS |
9185 | afi = bgp_node_afi(vty); |
9186 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9187 | |
37a87b8f CS |
9188 | snprintf( |
9189 | base_xpath, sizeof(base_xpath), | |
9190 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9191 | yang_afi_safi_value2identity(afi, safi), | |
9192 | bgp_afi_safi_get_container_str(afi, safi)); | |
9193 | ||
9194 | if (argv_find(argv, argc, "no", &idx)) { | |
9195 | if (!strcmp(direction_str, "import")) | |
9196 | nb_cli_enqueue_change(vty, "./rmap-import", | |
9197 | NB_OP_DESTROY, NULL); | |
9198 | else if (!strcmp(direction_str, "export")) | |
9199 | nb_cli_enqueue_change(vty, "./rmap-export", | |
9200 | NB_OP_DESTROY, NULL); | |
9201 | } else { | |
9202 | if (!strcmp(direction_str, "import")) | |
9203 | nb_cli_enqueue_change(vty, "./rmap-import", | |
9204 | NB_OP_MODIFY, rmap_str); | |
9205 | if (!strcmp(direction_str, "export")) | |
9206 | nb_cli_enqueue_change(vty, "./rmap-export", | |
9207 | NB_OP_MODIFY, rmap_str); | |
9208 | } | |
9209 | return nb_cli_apply_changes(vty, base_xpath); | |
9210 | } | |
ddb5b488 | 9211 | |
37a87b8f CS |
9212 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import( |
9213 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9214 | { | |
9215 | int indent = 2; | |
ddb5b488 | 9216 | |
37a87b8f CS |
9217 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", |
9218 | yang_dnode_get_string(dnode, NULL)); | |
9219 | } | |
69b07479 | 9220 | |
37a87b8f CS |
9221 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export( |
9222 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9223 | { | |
9224 | int indent = 2; | |
ddb5b488 | 9225 | |
37a87b8f CS |
9226 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", |
9227 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9228 | } |
9229 | ||
b9c7bc5a PZ |
9230 | ALIAS (af_route_map_vpn_imexport, |
9231 | af_no_route_map_vpn_imexport_cmd, | |
9232 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
9233 | NO_STR |
9234 | "Specify route map\n" | |
b9c7bc5a PZ |
9235 | "Between current address-family and vpn\n" |
9236 | "For routes leaked from vpn to current address-family\n" | |
9237 | "For routes leaked from current address-family to vpn\n") | |
9238 | ||
bb4f6190 | 9239 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 9240 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
9241 | "Import routes from another VRF\n" |
9242 | "Vrf routes being filtered\n" | |
9243 | "Specify route map\n" | |
9244 | "name of route-map\n") | |
9245 | { | |
9246 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
9247 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
9248 | afi_t afi; | |
bb4f6190 DS |
9249 | struct bgp *bgp_default; |
9250 | ||
0ca70ba5 | 9251 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
9252 | if (afi == AFI_MAX) |
9253 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
9254 | |
9255 | bgp_default = bgp_get_default(); | |
9256 | if (!bgp_default) { | |
9257 | int32_t ret; | |
9258 | as_t as = bgp->as; | |
9259 | ||
9260 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
9261 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
9262 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
9263 | |
9264 | if (ret) { | |
9265 | vty_out(vty, | |
9266 | "VRF default is not configured as a bgp instance\n"); | |
9267 | return CMD_WARNING; | |
9268 | } | |
9269 | } | |
9270 | ||
69b07479 | 9271 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 9272 | |
ae6a6fb4 DS |
9273 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
9274 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9275 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9276 | bgp->vpn_policy[afi].rmap_name[dir] = | |
9277 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9278 | bgp->vpn_policy[afi].rmap[dir] = | |
9279 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9280 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9281 | return CMD_SUCCESS; | |
9282 | ||
9283 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9284 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 9285 | |
69b07479 DS |
9286 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
9287 | ||
bb4f6190 DS |
9288 | return CMD_SUCCESS; |
9289 | } | |
9290 | ||
ae6a6fb4 DS |
9291 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
9292 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
9293 | NO_STR |
9294 | "Import routes from another VRF\n" | |
9295 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
9296 | "Specify route map\n" |
9297 | "name of route-map\n") | |
9298 | { | |
9299 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9300 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
9301 | afi_t afi; | |
9302 | ||
9303 | afi = vpn_policy_getafi(vty, bgp, true); | |
9304 | if (afi == AFI_MAX) | |
9305 | return CMD_WARNING_CONFIG_FAILED; | |
9306 | ||
9307 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9308 | ||
9309 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9310 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9311 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9312 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9313 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9314 | ||
9315 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
9316 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9317 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
9318 | ||
9319 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9320 | ||
9321 | return CMD_SUCCESS; | |
9322 | } | |
bb4f6190 | 9323 | |
37a87b8f CS |
9324 | DEFPY_YANG(bgp_imexport_vrf, |
9325 | bgp_imexport_vrf_cmd, | |
9326 | "[no] import vrf VIEWVRFNAME$import_name", | |
9327 | NO_STR | |
9328 | "Import routes from another VRF\n" | |
9329 | "VRF to import from\n" | |
9330 | "The name of the VRF\n") | |
12a844a5 | 9331 | { |
37a87b8f | 9332 | char base_xpath[XPATH_MAXLEN]; |
12a844a5 DS |
9333 | safi_t safi; |
9334 | afi_t afi; | |
37a87b8f | 9335 | int32_t idx = 0; |
12a844a5 | 9336 | |
867f0cca | 9337 | if (import_name == NULL) { |
9338 | vty_out(vty, "%% Missing import name\n"); | |
9339 | return CMD_WARNING; | |
9340 | } | |
9341 | ||
ae6a6fb4 DS |
9342 | if (strcmp(import_name, "route-map") == 0) { |
9343 | vty_out(vty, "%% Must include route-map name\n"); | |
9344 | return CMD_WARNING; | |
9345 | } | |
9346 | ||
37a87b8f | 9347 | afi = bgp_node_afi(vty); |
12a844a5 DS |
9348 | safi = bgp_node_safi(vty); |
9349 | ||
37a87b8f CS |
9350 | snprintf( |
9351 | base_xpath, sizeof(base_xpath), | |
9352 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']", | |
9353 | yang_afi_safi_value2identity(afi, safi), | |
9354 | bgp_afi_safi_get_container_str(afi, safi), import_name); | |
25679caa | 9355 | |
37a87b8f CS |
9356 | if (argv_find(argv, argc, "no", &idx)) |
9357 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
9358 | else | |
9359 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
12a844a5 | 9360 | |
37a87b8f CS |
9361 | return nb_cli_apply_changes(vty, base_xpath); |
9362 | } | |
12a844a5 | 9363 | |
37a87b8f CS |
9364 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs( |
9365 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9366 | { | |
9367 | vty_out(vty, " import vrf %s\n", | |
9368 | yang_dnode_get_string(dnode, "./vrf")); | |
12a844a5 DS |
9369 | } |
9370 | ||
b9c7bc5a | 9371 | /* This command is valid only in a bgp vrf instance or the default instance */ |
37a87b8f | 9372 | DEFPY_YANG (bgp_imexport_vpn, |
b9c7bc5a PZ |
9373 | bgp_imexport_vpn_cmd, |
9374 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
9375 | NO_STR |
9376 | "Import routes to this address-family\n" | |
9377 | "Export routes from this address-family\n" | |
9378 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 9379 | { |
37a87b8f | 9380 | char base_xpath[XPATH_MAXLEN]; |
b9c7bc5a | 9381 | safi_t safi; |
37a87b8f CS |
9382 | afi_t afi; |
9383 | int32_t idx = 0; | |
ddb5b488 | 9384 | |
b9c7bc5a PZ |
9385 | afi = bgp_node_afi(vty); |
9386 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9387 | |
b9c7bc5a | 9388 | if (!strcmp(direction_str, "import")) { |
37a87b8f CS |
9389 | snprintf( |
9390 | base_xpath, sizeof(base_xpath), | |
9391 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn", | |
9392 | yang_afi_safi_value2identity(afi, safi), | |
9393 | bgp_afi_safi_get_container_str(afi, safi)); | |
b9c7bc5a | 9394 | } else if (!strcmp(direction_str, "export")) { |
37a87b8f CS |
9395 | snprintf( |
9396 | base_xpath, sizeof(base_xpath), | |
9397 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn", | |
9398 | yang_afi_safi_value2identity(afi, safi), | |
9399 | bgp_afi_safi_get_container_str(afi, safi)); | |
b9c7bc5a PZ |
9400 | } else { |
9401 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9402 | return CMD_WARNING_CONFIG_FAILED; | |
9403 | } | |
9404 | ||
37a87b8f CS |
9405 | if (argv_find(argv, argc, "no", &idx)) |
9406 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
9407 | else | |
9408 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, "true"); | |
ddb5b488 | 9409 | |
37a87b8f CS |
9410 | return nb_cli_apply_changes(vty, base_xpath); |
9411 | } | |
ddb5b488 | 9412 | |
37a87b8f CS |
9413 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn( |
9414 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9415 | { | |
9416 | if (yang_dnode_get_bool(dnode, NULL)) | |
9417 | vty_out(vty, " import vpn\n"); | |
9418 | } | |
9419 | ||
9420 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn( | |
9421 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9422 | { | |
9423 | if (yang_dnode_get_bool(dnode, NULL)) | |
9424 | vty_out(vty, " export vpn\n"); | |
ddb5b488 PZ |
9425 | } |
9426 | ||
301ad80a PG |
9427 | DEFPY (af_routetarget_import, |
9428 | af_routetarget_import_cmd, | |
9a659715 | 9429 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9430 | NO_STR |
9431 | "Specify route target list\n" | |
9432 | "Specify route target list\n" | |
9a659715 PG |
9433 | "Specify route target list\n" |
9434 | "Specify route target list\n" | |
301ad80a PG |
9435 | "Flow-spec redirect type route target\n" |
9436 | "Import routes to this address-family\n" | |
9a659715 | 9437 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9438 | { |
9439 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9440 | int ret; | |
9441 | struct ecommunity *ecom = NULL; | |
301ad80a | 9442 | afi_t afi; |
9a659715 | 9443 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9444 | bool yes = true; |
9445 | bool rt6 = false; | |
301ad80a PG |
9446 | |
9447 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9448 | yes = false; |
301ad80a | 9449 | |
9a659715 PG |
9450 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9451 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9452 | rt6 = true; |
301ad80a | 9453 | |
0ca70ba5 | 9454 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9455 | if (afi == AFI_MAX) |
9456 | return CMD_WARNING_CONFIG_FAILED; | |
9457 | ||
9a659715 PG |
9458 | if (rt6 && afi != AFI_IP6) |
9459 | return CMD_WARNING_CONFIG_FAILED; | |
9460 | ||
301ad80a PG |
9461 | if (yes) { |
9462 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9463 | vty_out(vty, "%% Missing RTLIST\n"); | |
9464 | return CMD_WARNING_CONFIG_FAILED; | |
9465 | } | |
9a659715 | 9466 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9467 | if (ret != CMD_SUCCESS) |
9468 | return ret; | |
9469 | } | |
69b07479 DS |
9470 | |
9471 | if (yes) { | |
9472 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9473 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9474 | .import_redirect_rtlist); |
69b07479 DS |
9475 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9476 | ecommunity_dup(ecom); | |
9477 | } else { | |
9478 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9479 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9480 | .import_redirect_rtlist); |
69b07479 | 9481 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9482 | } |
69b07479 | 9483 | |
301ad80a PG |
9484 | if (ecom) |
9485 | ecommunity_free(&ecom); | |
9486 | ||
9487 | return CMD_SUCCESS; | |
9488 | } | |
9489 | ||
37a87b8f CS |
9490 | void cli_show_bgp_global_afi_safi_header(struct vty *vty, |
9491 | struct lyd_node *dnode, | |
9492 | bool show_defaults) | |
9493 | { | |
9494 | const char *af_name; | |
9495 | afi_t afi; | |
9496 | safi_t safi; | |
9497 | ||
9498 | af_name = yang_dnode_get_string(dnode, "./afi-safi-name"); | |
9499 | yang_afi_safi_identity2value(af_name, &afi, &safi); | |
9500 | ||
9501 | vty_out(vty, " !\n address-family "); | |
9502 | if (afi == AFI_IP) { | |
9503 | if (safi == SAFI_UNICAST) | |
9504 | vty_out(vty, "ipv4 unicast"); | |
9505 | else if (safi == SAFI_LABELED_UNICAST) | |
9506 | vty_out(vty, "ipv4 labeled-unicast"); | |
9507 | else if (safi == SAFI_MULTICAST) | |
9508 | vty_out(vty, "ipv4 multicast"); | |
9509 | else if (safi == SAFI_MPLS_VPN) | |
9510 | vty_out(vty, "ipv4 vpn"); | |
9511 | else if (safi == SAFI_ENCAP) | |
9512 | vty_out(vty, "ipv4 encap"); | |
9513 | else if (safi == SAFI_FLOWSPEC) | |
9514 | vty_out(vty, "ipv4 flowspec"); | |
9515 | } else if (afi == AFI_IP6) { | |
9516 | if (safi == SAFI_UNICAST) | |
9517 | vty_out(vty, "ipv6 unicast"); | |
9518 | else if (safi == SAFI_LABELED_UNICAST) | |
9519 | vty_out(vty, "ipv6 labeled-unicast"); | |
9520 | else if (safi == SAFI_MULTICAST) | |
9521 | vty_out(vty, "ipv6 multicast"); | |
9522 | else if (safi == SAFI_MPLS_VPN) | |
9523 | vty_out(vty, "ipv6 vpn"); | |
9524 | else if (safi == SAFI_ENCAP) | |
9525 | vty_out(vty, "ipv6 encap"); | |
9526 | else if (safi == SAFI_FLOWSPEC) | |
9527 | vty_out(vty, "ipv6 flowspec"); | |
9528 | } else if (afi == AFI_L2VPN) { | |
9529 | if (safi == SAFI_EVPN) | |
9530 | vty_out(vty, "l2vpn evpn"); | |
9531 | } | |
9532 | vty_out(vty, "\n"); | |
9533 | } | |
9534 | ||
505e5056 | 9535 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9536 | address_family_ipv4_safi_cmd, |
9537 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9538 | "Enter Address Family command mode\n" | |
9539 | "Address Family\n" | |
9540 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 9541 | { |
f51bae9c | 9542 | |
37a87b8f CS |
9543 | safi_t safi = SAFI_UNICAST; |
9544 | const struct lyd_node *vrf_dnode, *bgp_glb_dnode; | |
9545 | const char *vrf_name = NULL; | |
9546 | ||
d62a17ae | 9547 | if (argc == 3) { |
37a87b8f CS |
9548 | safi = bgp_vty_safi_from_str(argv[2]->text); |
9549 | ||
9550 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, | |
9551 | VTY_CURR_XPATH); | |
9552 | vrf_dnode = yang_dnode_get_parent(bgp_glb_dnode, | |
9553 | "control-plane-protocol"); | |
9554 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
9555 | ||
9556 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME) | |
a4d82a8a | 9557 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9558 | && safi != SAFI_EVPN) { |
31947174 MK |
9559 | vty_out(vty, |
9560 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9561 | return CMD_WARNING_CONFIG_FAILED; |
9562 | } | |
37a87b8f CS |
9563 | } |
9564 | vty->node = bgp_node_type(AFI_IP, safi); | |
718e3744 | 9565 | |
d62a17ae | 9566 | return CMD_SUCCESS; |
718e3744 | 9567 | } |
9568 | ||
505e5056 | 9569 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9570 | address_family_ipv6_safi_cmd, |
9571 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9572 | "Enter Address Family command mode\n" | |
9573 | "Address Family\n" | |
9574 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 9575 | { |
37a87b8f CS |
9576 | safi_t safi = SAFI_UNICAST; |
9577 | const struct lyd_node *vrf_dnode, *bgp_glb_dnode; | |
9578 | const char *vrf_name = NULL; | |
9579 | ||
d62a17ae | 9580 | if (argc == 3) { |
37a87b8f CS |
9581 | safi = bgp_vty_safi_from_str(argv[2]->text); |
9582 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, | |
9583 | VTY_CURR_XPATH); | |
9584 | vrf_dnode = yang_dnode_get_parent(bgp_glb_dnode, | |
9585 | "control-plane-protocol"); | |
9586 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
9587 | ||
9588 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME) | |
a4d82a8a | 9589 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9590 | && safi != SAFI_EVPN) { |
31947174 MK |
9591 | vty_out(vty, |
9592 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9593 | return CMD_WARNING_CONFIG_FAILED; |
9594 | } | |
37a87b8f CS |
9595 | } |
9596 | vty->node = bgp_node_type(AFI_IP6, safi); | |
25ffbdc1 | 9597 | |
d62a17ae | 9598 | return CMD_SUCCESS; |
25ffbdc1 | 9599 | } |
718e3744 | 9600 | |
d6902373 | 9601 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9602 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9603 | address_family_vpnv4_cmd, |
8334fd5a | 9604 | "address-family vpnv4 [unicast]", |
718e3744 | 9605 | "Enter Address Family command mode\n" |
8c3deaae | 9606 | "Address Family\n" |
3a2d747c | 9607 | "Address Family modifier\n") |
718e3744 | 9608 | { |
d62a17ae | 9609 | vty->node = BGP_VPNV4_NODE; |
9610 | return CMD_SUCCESS; | |
718e3744 | 9611 | } |
9612 | ||
505e5056 | 9613 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9614 | address_family_vpnv6_cmd, |
8334fd5a | 9615 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9616 | "Enter Address Family command mode\n" |
8c3deaae | 9617 | "Address Family\n" |
3a2d747c | 9618 | "Address Family modifier\n") |
8ecd3266 | 9619 | { |
d62a17ae | 9620 | vty->node = BGP_VPNV6_NODE; |
9621 | return CMD_SUCCESS; | |
8ecd3266 | 9622 | } |
64e4a6c5 | 9623 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9624 | |
505e5056 | 9625 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9626 | address_family_evpn_cmd, |
7111c1a0 | 9627 | "address-family l2vpn evpn", |
4e0b7b6d | 9628 | "Enter Address Family command mode\n" |
7111c1a0 QY |
9629 | "Address Family\n" |
9630 | "Address Family modifier\n") | |
4e0b7b6d | 9631 | { |
2131d5cf | 9632 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9633 | vty->node = BGP_EVPN_NODE; |
9634 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9635 | } |
9636 | ||
505e5056 | 9637 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9638 | exit_address_family_cmd, |
9639 | "exit-address-family", | |
9640 | "Exit from Address Family configuration mode\n") | |
9641 | { | |
d62a17ae | 9642 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9643 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9644 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9645 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9646 | || vty->node == BGP_EVPN_NODE |
9647 | || vty->node == BGP_FLOWSPECV4_NODE | |
9648 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9649 | vty->node = BGP_NODE; |
9650 | return CMD_SUCCESS; | |
718e3744 | 9651 | } |
6b0655a2 | 9652 | |
37a87b8f CS |
9653 | void cli_show_bgp_global_afi_safi_header_end(struct vty *vty, |
9654 | struct lyd_node *dnode | |
9655 | __attribute__((__unused__))) | |
9656 | { | |
9657 | vty_out(vty, " exit-address-family\n"); | |
9658 | } | |
9659 | ||
8ad7271d | 9660 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9661 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9662 | const char *ip_str, afi_t afi, safi_t safi, | |
9663 | struct prefix_rd *prd) | |
9664 | { | |
9665 | int ret; | |
9666 | struct prefix match; | |
9bcb3eef DS |
9667 | struct bgp_dest *dest; |
9668 | struct bgp_dest *rm; | |
d62a17ae | 9669 | struct bgp *bgp; |
9670 | struct bgp_table *table; | |
9671 | struct bgp_table *rib; | |
9672 | ||
9673 | /* BGP structure lookup. */ | |
9674 | if (view_name) { | |
9675 | bgp = bgp_lookup_by_name(view_name); | |
9676 | if (bgp == NULL) { | |
9677 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9678 | view_name); | |
9679 | return CMD_WARNING; | |
9680 | } | |
9681 | } else { | |
9682 | bgp = bgp_get_default(); | |
9683 | if (bgp == NULL) { | |
9684 | vty_out(vty, "%% No BGP process is configured\n"); | |
9685 | return CMD_WARNING; | |
9686 | } | |
9687 | } | |
9688 | ||
9689 | /* Check IP address argument. */ | |
9690 | ret = str2prefix(ip_str, &match); | |
9691 | if (!ret) { | |
9692 | vty_out(vty, "%% address is malformed\n"); | |
9693 | return CMD_WARNING; | |
9694 | } | |
9695 | ||
9696 | match.family = afi2family(afi); | |
9697 | rib = bgp->rib[afi][safi]; | |
9698 | ||
9699 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
9700 | for (dest = bgp_table_top(rib); dest; |
9701 | dest = bgp_route_next(dest)) { | |
9702 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9703 | |
9bcb3eef | 9704 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 9705 | continue; |
9706 | ||
9bcb3eef | 9707 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
9708 | if (table == NULL) |
9709 | continue; | |
9710 | ||
9711 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
9712 | const struct prefix *rm_p = | |
9bcb3eef | 9713 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
9714 | |
9715 | if (rm_p->prefixlen == match.prefixlen) { | |
9716 | SET_FLAG(rm->flags, | |
9717 | BGP_NODE_USER_CLEAR); | |
9718 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 9719 | } |
9bcb3eef | 9720 | bgp_dest_unlock_node(rm); |
d62a17ae | 9721 | } |
9722 | } | |
9723 | } else { | |
9bcb3eef DS |
9724 | if ((dest = bgp_node_match(rib, &match)) != NULL) { |
9725 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9726 | |
9bcb3eef DS |
9727 | if (dest_p->prefixlen == match.prefixlen) { |
9728 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
9729 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 9730 | } |
9bcb3eef | 9731 | bgp_dest_unlock_node(dest); |
d62a17ae | 9732 | } |
9733 | } | |
9734 | ||
9735 | return CMD_SUCCESS; | |
8ad7271d DS |
9736 | } |
9737 | ||
b09b5ae0 | 9738 | /* one clear bgp command to rule them all */ |
718e3744 | 9739 | DEFUN (clear_ip_bgp_all, |
9740 | clear_ip_bgp_all_cmd, | |
453c92f6 | 9741 | "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 | 9742 | CLEAR_STR |
9743 | IP_STR | |
9744 | BGP_STR | |
838758ac | 9745 | BGP_INSTANCE_HELP_STR |
510afcd6 | 9746 | BGP_AFI_HELP_STR |
fd5e7b70 | 9747 | "Address Family\n" |
510afcd6 | 9748 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 9749 | "Address Family modifier\n" |
b09b5ae0 | 9750 | "Clear all peers\n" |
453c92f6 | 9751 | "BGP IPv4 neighbor to clear\n" |
a80beece | 9752 | "BGP IPv6 neighbor to clear\n" |
838758ac | 9753 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
9754 | "Clear peers with the AS number\n" |
9755 | "Clear all external peers\n" | |
718e3744 | 9756 | "Clear all members of peer-group\n" |
b09b5ae0 | 9757 | "BGP peer-group name\n" |
b09b5ae0 DW |
9758 | BGP_SOFT_STR |
9759 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
9760 | BGP_SOFT_OUT_STR |
9761 | BGP_SOFT_IN_STR | |
9762 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 9763 | BGP_SOFT_OUT_STR) |
718e3744 | 9764 | { |
d62a17ae | 9765 | char *vrf = NULL; |
9766 | ||
dc912615 DS |
9767 | afi_t afi = AFI_UNSPEC; |
9768 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 9769 | enum clear_sort clr_sort = clear_peer; |
9770 | enum bgp_clear_type clr_type; | |
9771 | char *clr_arg = NULL; | |
9772 | ||
9773 | int idx = 0; | |
ff8a8a7a CS |
9774 | char errmsg[BUFSIZ] = {'\0'}; |
9775 | int ret; | |
d62a17ae | 9776 | |
9777 | /* clear [ip] bgp */ | |
9778 | if (argv_find(argv, argc, "ip", &idx)) | |
9779 | afi = AFI_IP; | |
9780 | ||
9a8bdf1c PG |
9781 | /* [<vrf> VIEWVRFNAME] */ |
9782 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9783 | vrf = argv[idx + 1]->arg; | |
9784 | idx += 2; | |
9785 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9786 | vrf = NULL; | |
9787 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9788 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 9789 | vrf = argv[idx + 1]->arg; |
9790 | idx += 2; | |
9791 | } | |
d62a17ae | 9792 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9793 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
9794 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9795 | ||
d7b9898c | 9796 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 9797 | if (argv_find(argv, argc, "*", &idx)) { |
9798 | clr_sort = clear_all; | |
9799 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
9800 | clr_sort = clear_peer; | |
9801 | clr_arg = argv[idx]->arg; | |
9802 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
9803 | clr_sort = clear_peer; | |
9804 | clr_arg = argv[idx]->arg; | |
9805 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
9806 | clr_sort = clear_group; | |
9807 | idx++; | |
9808 | clr_arg = argv[idx]->arg; | |
d7b9898c | 9809 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 9810 | clr_sort = clear_peer; |
9811 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
9812 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
9813 | clr_sort = clear_peer; | |
9814 | clr_arg = argv[idx]->arg; | |
d62a17ae | 9815 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
9816 | clr_sort = clear_as; | |
9817 | clr_arg = argv[idx]->arg; | |
9818 | } else if (argv_find(argv, argc, "external", &idx)) { | |
9819 | clr_sort = clear_external; | |
9820 | } | |
9821 | ||
9822 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
9823 | if (argv_find(argv, argc, "soft", &idx)) { | |
9824 | if (argv_find(argv, argc, "in", &idx) | |
9825 | || argv_find(argv, argc, "out", &idx)) | |
9826 | clr_type = strmatch(argv[idx]->text, "in") | |
9827 | ? BGP_CLEAR_SOFT_IN | |
9828 | : BGP_CLEAR_SOFT_OUT; | |
9829 | else | |
9830 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9831 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9832 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9833 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9834 | : BGP_CLEAR_SOFT_IN; | |
9835 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9836 | clr_type = BGP_CLEAR_SOFT_OUT; | |
9837 | } else | |
9838 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9839 | ||
ff8a8a7a CS |
9840 | ret = bgp_clear_vty(vrf, afi, safi, clr_sort, clr_type, clr_arg, errmsg, |
9841 | sizeof(errmsg)); | |
9842 | if (ret != NB_OK) | |
9843 | vty_out(vty, "Error description: %s\n", errmsg); | |
9844 | ||
9845 | return ret; | |
838758ac | 9846 | } |
01080f7c | 9847 | |
8ad7271d DS |
9848 | DEFUN (clear_ip_bgp_prefix, |
9849 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 9850 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
9851 | CLEAR_STR |
9852 | IP_STR | |
9853 | BGP_STR | |
838758ac | 9854 | BGP_INSTANCE_HELP_STR |
8ad7271d | 9855 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9856 | "IPv4 prefix\n") |
8ad7271d | 9857 | { |
d62a17ae | 9858 | char *vrf = NULL; |
9859 | char *prefix = NULL; | |
8ad7271d | 9860 | |
d62a17ae | 9861 | int idx = 0; |
01080f7c | 9862 | |
d62a17ae | 9863 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
9864 | if (argv_find(argv, argc, "vrf", &idx)) { |
9865 | vrf = argv[idx + 1]->arg; | |
9866 | idx += 2; | |
9867 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9868 | vrf = NULL; | |
9869 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9870 | /* [<view> VIEWVRFNAME] */ | |
9871 | vrf = argv[idx + 1]->arg; | |
9872 | idx += 2; | |
9873 | } | |
0c7b1b01 | 9874 | |
d62a17ae | 9875 | prefix = argv[argc - 1]->arg; |
8ad7271d | 9876 | |
d62a17ae | 9877 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 9878 | } |
8ad7271d | 9879 | |
b09b5ae0 DW |
9880 | DEFUN (clear_bgp_ipv6_safi_prefix, |
9881 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 9882 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9883 | CLEAR_STR |
3a2d747c | 9884 | IP_STR |
718e3744 | 9885 | BGP_STR |
8c3deaae | 9886 | "Address Family\n" |
46f296b4 | 9887 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9888 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9889 | "IPv6 prefix\n") |
718e3744 | 9890 | { |
9b475e76 PG |
9891 | int idx_safi = 0; |
9892 | int idx_ipv6_prefix = 0; | |
9893 | safi_t safi = SAFI_UNICAST; | |
9894 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9895 | argv[idx_ipv6_prefix]->arg : NULL; | |
9896 | ||
9897 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 9898 | return bgp_clear_prefix( |
9b475e76 PG |
9899 | vty, NULL, prefix, AFI_IP6, |
9900 | safi, NULL); | |
838758ac | 9901 | } |
01080f7c | 9902 | |
b09b5ae0 DW |
9903 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
9904 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 9905 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9906 | CLEAR_STR |
3a2d747c | 9907 | IP_STR |
718e3744 | 9908 | BGP_STR |
838758ac | 9909 | BGP_INSTANCE_HELP_STR |
8c3deaae | 9910 | "Address Family\n" |
46f296b4 | 9911 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9912 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9913 | "IPv6 prefix\n") |
718e3744 | 9914 | { |
9b475e76 | 9915 | int idx_safi = 0; |
9a8bdf1c | 9916 | int idx_vrfview = 0; |
9b475e76 PG |
9917 | int idx_ipv6_prefix = 0; |
9918 | safi_t safi = SAFI_UNICAST; | |
9919 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9920 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 9921 | char *vrfview = NULL; |
9b475e76 | 9922 | |
9a8bdf1c PG |
9923 | /* [<view|vrf> VIEWVRFNAME] */ |
9924 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9925 | vrfview = argv[idx_vrfview + 1]->arg; | |
9926 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9927 | vrfview = NULL; | |
9928 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9929 | /* [<view> VIEWVRFNAME] */ | |
9930 | vrfview = argv[idx_vrfview + 1]->arg; | |
9931 | } | |
9b475e76 PG |
9932 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
9933 | ||
d62a17ae | 9934 | return bgp_clear_prefix( |
9b475e76 PG |
9935 | vty, vrfview, prefix, |
9936 | AFI_IP6, safi, NULL); | |
718e3744 | 9937 | } |
9938 | ||
b09b5ae0 DW |
9939 | DEFUN (show_bgp_views, |
9940 | show_bgp_views_cmd, | |
d6e3c605 | 9941 | "show [ip] bgp views", |
b09b5ae0 | 9942 | SHOW_STR |
d6e3c605 | 9943 | IP_STR |
01080f7c | 9944 | BGP_STR |
b09b5ae0 | 9945 | "Show the defined BGP views\n") |
01080f7c | 9946 | { |
d62a17ae | 9947 | struct list *inst = bm->bgp; |
9948 | struct listnode *node; | |
9949 | struct bgp *bgp; | |
01080f7c | 9950 | |
d62a17ae | 9951 | vty_out(vty, "Defined BGP views:\n"); |
9952 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9953 | /* Skip VRFs. */ | |
9954 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9955 | continue; | |
9956 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9957 | bgp->as); | |
9958 | } | |
e52702f2 | 9959 | |
d62a17ae | 9960 | return CMD_SUCCESS; |
e0081f70 ML |
9961 | } |
9962 | ||
8386ac43 | 9963 | DEFUN (show_bgp_vrfs, |
9964 | show_bgp_vrfs_cmd, | |
d6e3c605 | 9965 | "show [ip] bgp vrfs [json]", |
8386ac43 | 9966 | SHOW_STR |
d6e3c605 | 9967 | IP_STR |
8386ac43 | 9968 | BGP_STR |
9969 | "Show BGP VRFs\n" | |
9973d184 | 9970 | JSON_STR) |
8386ac43 | 9971 | { |
fe1dc5a3 | 9972 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 9973 | struct list *inst = bm->bgp; |
9974 | struct listnode *node; | |
9975 | struct bgp *bgp; | |
9f049418 | 9976 | bool uj = use_json(argc, argv); |
d62a17ae | 9977 | json_object *json = NULL; |
9978 | json_object *json_vrfs = NULL; | |
9979 | int count = 0; | |
d62a17ae | 9980 | |
d62a17ae | 9981 | if (uj) { |
9982 | json = json_object_new_object(); | |
9983 | json_vrfs = json_object_new_object(); | |
9984 | } | |
9985 | ||
9986 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9987 | const char *name, *type; | |
9988 | struct peer *peer; | |
7fe96307 | 9989 | struct listnode *node2, *nnode2; |
d62a17ae | 9990 | int peers_cfg, peers_estb; |
9991 | json_object *json_vrf = NULL; | |
d62a17ae | 9992 | |
9993 | /* Skip Views. */ | |
9994 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9995 | continue; | |
9996 | ||
9997 | count++; | |
efb4077a | 9998 | if (!uj && count == 1) { |
fe1dc5a3 | 9999 | vty_out(vty, |
efb4077a | 10000 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 10001 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
10002 | "#PeersEstb", "Name"); |
10003 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
10004 | "L3-VNI", "RouterMAC", "Interface"); | |
10005 | } | |
d62a17ae | 10006 | |
10007 | peers_cfg = peers_estb = 0; | |
10008 | if (uj) | |
10009 | json_vrf = json_object_new_object(); | |
10010 | ||
10011 | ||
7fe96307 | 10012 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 10013 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10014 | continue; | |
10015 | peers_cfg++; | |
10016 | if (peer->status == Established) | |
10017 | peers_estb++; | |
10018 | } | |
10019 | ||
10020 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 10021 | name = VRF_DEFAULT_NAME; |
d62a17ae | 10022 | type = "DFLT"; |
10023 | } else { | |
10024 | name = bgp->name; | |
10025 | type = "VRF"; | |
10026 | } | |
10027 | ||
a8bf7d9c | 10028 | |
d62a17ae | 10029 | if (uj) { |
a4d82a8a PZ |
10030 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10031 | ? -1 | |
10032 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
10033 | char buf[BUFSIZ] = {0}; |
10034 | ||
d62a17ae | 10035 | json_object_string_add(json_vrf, "type", type); |
10036 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
10037 | json_object_string_add(json_vrf, "routerId", | |
23d0a753 DA |
10038 | inet_ntop(AF_INET, |
10039 | &bgp->router_id, buf, | |
10040 | sizeof(buf))); | |
d62a17ae | 10041 | json_object_int_add(json_vrf, "numConfiguredPeers", |
10042 | peers_cfg); | |
10043 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
10044 | peers_estb); | |
10045 | ||
fe1dc5a3 | 10046 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
10047 | json_object_string_add( |
10048 | json_vrf, "rmac", | |
10049 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
10050 | json_object_string_add(json_vrf, "interface", |
10051 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10052 | bgp->vrf_id)); | |
d62a17ae | 10053 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 10054 | } else { |
23d0a753 | 10055 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
10056 | type, |
10057 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10058 | : (int)bgp->vrf_id, | |
23d0a753 | 10059 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
10060 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
10061 | bgp->l3vni, | |
10062 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
10063 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10064 | bgp->vrf_id)); | |
10065 | } | |
d62a17ae | 10066 | } |
10067 | ||
10068 | if (uj) { | |
10069 | json_object_object_add(json, "vrfs", json_vrfs); | |
10070 | ||
10071 | json_object_int_add(json, "totalVrfs", count); | |
10072 | ||
996c9314 LB |
10073 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10074 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10075 | json_object_free(json); |
10076 | } else { | |
10077 | if (count) | |
10078 | vty_out(vty, | |
10079 | "\nTotal number of VRFs (including default): %d\n", | |
10080 | count); | |
10081 | } | |
10082 | ||
10083 | return CMD_SUCCESS; | |
8386ac43 | 10084 | } |
10085 | ||
48ecf8f5 DS |
10086 | DEFUN (show_bgp_mac_hash, |
10087 | show_bgp_mac_hash_cmd, | |
10088 | "show bgp mac hash", | |
10089 | SHOW_STR | |
10090 | BGP_STR | |
10091 | "Mac Address\n" | |
10092 | "Mac Address database\n") | |
10093 | { | |
10094 | bgp_mac_dump_table(vty); | |
10095 | ||
10096 | return CMD_SUCCESS; | |
10097 | } | |
acf71666 | 10098 | |
e3b78da8 | 10099 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 10100 | { |
0291c246 | 10101 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 10102 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 10103 | |
23d0a753 | 10104 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
10105 | } |
10106 | ||
10107 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
10108 | { | |
10109 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 10110 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
10111 | |
10112 | vty_out(vty, "Tunnel-ip database:\n"); | |
10113 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 10114 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
10115 | vty); |
10116 | } | |
10117 | ||
15c81ca4 DS |
10118 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
10119 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
10120 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
10121 | "martian next-hops\n" |
10122 | "martian next-hop database\n") | |
acf71666 | 10123 | { |
0291c246 | 10124 | struct bgp *bgp = NULL; |
15c81ca4 | 10125 | int idx = 0; |
9a8bdf1c PG |
10126 | char *name = NULL; |
10127 | ||
10128 | /* [<vrf> VIEWVRFNAME] */ | |
10129 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10130 | name = argv[idx + 1]->arg; | |
10131 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
10132 | name = NULL; | |
10133 | } else if (argv_find(argv, argc, "view", &idx)) | |
10134 | /* [<view> VIEWVRFNAME] */ | |
10135 | name = argv[idx + 1]->arg; | |
10136 | if (name) | |
10137 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
10138 | else |
10139 | bgp = bgp_get_default(); | |
acf71666 | 10140 | |
acf71666 MK |
10141 | if (!bgp) { |
10142 | vty_out(vty, "%% No BGP process is configured\n"); | |
10143 | return CMD_WARNING; | |
10144 | } | |
10145 | bgp_show_martian_nexthops(vty, bgp); | |
10146 | ||
10147 | return CMD_SUCCESS; | |
10148 | } | |
10149 | ||
f412b39a | 10150 | DEFUN (show_bgp_memory, |
4bf6a362 | 10151 | show_bgp_memory_cmd, |
7fa12b13 | 10152 | "show [ip] bgp memory", |
4bf6a362 | 10153 | SHOW_STR |
3a2d747c | 10154 | IP_STR |
4bf6a362 PJ |
10155 | BGP_STR |
10156 | "Global BGP memory statistics\n") | |
10157 | { | |
d62a17ae | 10158 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
10159 | unsigned long count; | |
10160 | ||
10161 | /* RIB related usage stats */ | |
10162 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
10163 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
10164 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 10165 | count * sizeof(struct bgp_dest))); |
d62a17ae | 10166 | |
10167 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
10168 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
10169 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 10170 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 10171 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
10172 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
10173 | count, | |
4b7e6066 DS |
10174 | mtype_memstr( |
10175 | memstrbuf, sizeof(memstrbuf), | |
10176 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 10177 | |
10178 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
10179 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
10180 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10181 | count * sizeof(struct bgp_static))); | |
10182 | ||
10183 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
10184 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
10185 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10186 | count * sizeof(struct bpacket))); | |
10187 | ||
10188 | /* Adj-In/Out */ | |
10189 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
10190 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
10191 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10192 | count * sizeof(struct bgp_adj_in))); | |
10193 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
10194 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
10195 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10196 | count * sizeof(struct bgp_adj_out))); | |
10197 | ||
10198 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
10199 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
10200 | count, | |
10201 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10202 | count * sizeof(struct bgp_nexthop_cache))); | |
10203 | ||
10204 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
10205 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
10206 | count, | |
10207 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10208 | count * sizeof(struct bgp_damp_info))); | |
10209 | ||
10210 | /* Attributes */ | |
10211 | count = attr_count(); | |
10212 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
10213 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10214 | count * sizeof(struct attr))); | |
10215 | ||
10216 | if ((count = attr_unknown_count())) | |
10217 | vty_out(vty, "%ld unknown attributes\n", count); | |
10218 | ||
10219 | /* AS_PATH attributes */ | |
10220 | count = aspath_count(); | |
10221 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
10222 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10223 | count * sizeof(struct aspath))); | |
10224 | ||
10225 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
10226 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
10227 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10228 | count * sizeof(struct assegment))); | |
10229 | ||
10230 | /* Other attributes */ | |
10231 | if ((count = community_count())) | |
10232 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10233 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10234 | count * sizeof(struct community))); | |
d62a17ae | 10235 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
10236 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10237 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10238 | count * sizeof(struct ecommunity))); | |
d62a17ae | 10239 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
10240 | vty_out(vty, | |
10241 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
10242 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10243 | count * sizeof(struct lcommunity))); | |
d62a17ae | 10244 | |
10245 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
10246 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
10247 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10248 | count * sizeof(struct cluster_list))); | |
10249 | ||
10250 | /* Peer related usage */ | |
10251 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
10252 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
10253 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10254 | count * sizeof(struct peer))); | |
10255 | ||
10256 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
10257 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
10258 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10259 | count * sizeof(struct peer_group))); | |
10260 | ||
10261 | /* Other */ | |
d62a17ae | 10262 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
10263 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
10264 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10265 | count * sizeof(regex_t))); | |
d62a17ae | 10266 | return CMD_SUCCESS; |
4bf6a362 | 10267 | } |
fee0f4c6 | 10268 | |
57a9c8a8 DS |
10269 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
10270 | { | |
10271 | json_object *bestpath = json_object_new_object(); | |
10272 | ||
892fedb6 | 10273 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
10274 | json_object_string_add(bestpath, "asPath", "ignore"); |
10275 | ||
892fedb6 | 10276 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
10277 | json_object_string_add(bestpath, "asPath", "confed"); |
10278 | ||
892fedb6 DA |
10279 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
10280 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 10281 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10282 | "as-set"); |
10283 | else | |
a4d82a8a | 10284 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10285 | "true"); |
10286 | } else | |
a4d82a8a | 10287 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 10288 | |
892fedb6 | 10289 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 10290 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
10291 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
10292 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10293 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 10294 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 10295 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
10296 | json_object_string_add(bestpath, "med", |
10297 | "missing-as-worst"); | |
10298 | else | |
10299 | json_object_string_add(bestpath, "med", "true"); | |
10300 | } | |
10301 | ||
10302 | json_object_object_add(json, "bestPath", bestpath); | |
10303 | } | |
10304 | ||
3577f1c5 DD |
10305 | /* Print the error code/subcode for why the peer is down */ |
10306 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10307 | json_object *json_peer, bool use_json) | |
10308 | { | |
10309 | const char *code_str; | |
10310 | const char *subcode_str; | |
10311 | ||
10312 | if (use_json) { | |
10313 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10314 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10315 | char errorcodesubcode_hexstr[5]; | |
10316 | char errorcodesubcode_str[256]; | |
10317 | ||
10318 | code_str = bgp_notify_code_str(peer->notify.code); | |
10319 | subcode_str = bgp_notify_subcode_str( | |
10320 | peer->notify.code, | |
10321 | peer->notify.subcode); | |
10322 | ||
772270f3 QY |
10323 | snprintf(errorcodesubcode_hexstr, |
10324 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10325 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10326 | json_object_string_add(json_peer, |
10327 | "lastErrorCodeSubcode", | |
10328 | errorcodesubcode_hexstr); | |
10329 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10330 | code_str, subcode_str); | |
10331 | json_object_string_add(json_peer, | |
10332 | "lastNotificationReason", | |
10333 | errorcodesubcode_str); | |
10334 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10335 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10336 | && (peer->notify.subcode | |
10337 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10338 | || peer->notify.subcode | |
10339 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10340 | && peer->notify.length) { | |
10341 | char msgbuf[1024]; | |
10342 | const char *msg_str; | |
10343 | ||
10344 | msg_str = bgp_notify_admin_message( | |
10345 | msgbuf, sizeof(msgbuf), | |
10346 | (uint8_t *)peer->notify.data, | |
10347 | peer->notify.length); | |
10348 | if (msg_str) | |
10349 | json_object_string_add( | |
10350 | json_peer, | |
10351 | "lastShutdownDescription", | |
10352 | msg_str); | |
10353 | } | |
10354 | ||
c258527b | 10355 | } |
3577f1c5 DD |
10356 | json_object_string_add(json_peer, "lastResetDueTo", |
10357 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10358 | json_object_int_add(json_peer, "lastResetCode", |
10359 | peer->last_reset); | |
3577f1c5 DD |
10360 | } else { |
10361 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10362 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10363 | code_str = bgp_notify_code_str(peer->notify.code); | |
10364 | subcode_str = | |
10365 | bgp_notify_subcode_str(peer->notify.code, | |
10366 | peer->notify.subcode); | |
10367 | vty_out(vty, " Notification %s (%s%s)\n", | |
10368 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10369 | ? "sent" | |
10370 | : "received", | |
10371 | code_str, subcode_str); | |
10372 | } else { | |
e91c24c8 | 10373 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10374 | peer_down_str[(int)peer->last_reset]); |
10375 | } | |
10376 | } | |
10377 | } | |
10378 | ||
10379 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10380 | safi_t safi) | |
10381 | { | |
10382 | return ((peer->status != Established) || | |
10383 | !peer->afc_recv[afi][safi]); | |
10384 | } | |
10385 | ||
10386 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10387 | struct peer *peer, json_object *json_peer, | |
10388 | int max_neighbor_width, bool use_json) | |
10389 | { | |
10390 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10391 | int len; | |
10392 | ||
10393 | if (use_json) { | |
10394 | if (peer_dynamic_neighbor(peer)) | |
10395 | json_object_boolean_true_add(json_peer, | |
10396 | "dynamicPeer"); | |
10397 | if (peer->hostname) | |
10398 | json_object_string_add(json_peer, "hostname", | |
10399 | peer->hostname); | |
10400 | ||
10401 | if (peer->domainname) | |
10402 | json_object_string_add(json_peer, "domainname", | |
10403 | peer->domainname); | |
10404 | json_object_int_add(json_peer, "connectionsEstablished", | |
10405 | peer->established); | |
10406 | json_object_int_add(json_peer, "connectionsDropped", | |
10407 | peer->dropped); | |
10408 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10409 | use_json, json_peer); | |
10410 | if (peer->status == Established) | |
10411 | json_object_string_add(json_peer, "lastResetDueTo", | |
10412 | "AFI/SAFI Not Negotiated"); | |
10413 | else | |
10414 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10415 | } else { | |
10416 | dn_flag[1] = '\0'; | |
10417 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10418 | if (peer->hostname | |
892fedb6 | 10419 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10420 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10421 | peer->hostname, peer->host); | |
10422 | else | |
10423 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10424 | ||
10425 | /* pad the neighbor column with spaces */ | |
10426 | if (len < max_neighbor_width) | |
10427 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10428 | " "); | |
e91c24c8 | 10429 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10430 | peer->dropped, |
10431 | peer_uptime(peer->uptime, timebuf, | |
10432 | BGP_UPTIME_LEN, 0, NULL)); | |
10433 | if (peer->status == Established) | |
10434 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
10435 | else | |
10436 | bgp_show_peer_reset(vty, peer, NULL, | |
10437 | false); | |
10438 | } | |
10439 | } | |
c258527b | 10440 | |
3577f1c5 | 10441 | |
718e3744 | 10442 | /* Show BGP peer's summary information. */ |
d62a17ae | 10443 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
10b49f14 DA |
10444 | bool show_failed, bool show_established, |
10445 | bool use_json) | |
d62a17ae | 10446 | { |
10447 | struct peer *peer; | |
10448 | struct listnode *node, *nnode; | |
10449 | unsigned int count = 0, dn_count = 0; | |
10450 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10451 | char neighbor_buf[VTY_BUFSIZ]; | |
10452 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10453 | int len, failed_count = 0; |
d62a17ae | 10454 | int max_neighbor_width = 0; |
10455 | int pfx_rcd_safi; | |
3c13337d | 10456 | json_object *json = NULL; |
d62a17ae | 10457 | json_object *json_peer = NULL; |
10458 | json_object *json_peers = NULL; | |
50e05855 | 10459 | struct peer_af *paf; |
d3ada366 | 10460 | struct bgp_filter *filter; |
d62a17ae | 10461 | |
10462 | /* labeled-unicast routes are installed in the unicast table so in order | |
10463 | * to | |
10464 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10465 | */ | |
3577f1c5 | 10466 | |
d62a17ae | 10467 | if (safi == SAFI_LABELED_UNICAST) |
10468 | pfx_rcd_safi = SAFI_UNICAST; | |
10469 | else | |
10470 | pfx_rcd_safi = safi; | |
10471 | ||
10472 | if (use_json) { | |
3c13337d | 10473 | json = json_object_new_object(); |
d62a17ae | 10474 | json_peers = json_object_new_object(); |
3577f1c5 DD |
10475 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10476 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10477 | continue; | |
10478 | ||
10479 | if (peer->afc[afi][safi]) { | |
10480 | /* See if we have at least a single failed peer */ | |
10481 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10482 | failed_count++; | |
10483 | count++; | |
10484 | } | |
10485 | if (peer_dynamic_neighbor(peer)) | |
10486 | dn_count++; | |
10487 | } | |
c258527b | 10488 | |
d62a17ae | 10489 | } else { |
10490 | /* Loop over all neighbors that will be displayed to determine | |
10491 | * how many | |
10492 | * characters are needed for the Neighbor column | |
10493 | */ | |
10494 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10495 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10496 | continue; | |
10497 | ||
10498 | if (peer->afc[afi][safi]) { | |
10499 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10500 | if (peer_dynamic_neighbor(peer)) | |
10501 | dn_flag[0] = '*'; | |
10502 | ||
10503 | if (peer->hostname | |
892fedb6 DA |
10504 | && CHECK_FLAG(bgp->flags, |
10505 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10506 | snprintf(neighbor_buf, |
10507 | sizeof(neighbor_buf), | |
10508 | "%s%s(%s) ", dn_flag, | |
10509 | peer->hostname, peer->host); | |
d62a17ae | 10510 | else |
772270f3 QY |
10511 | snprintf(neighbor_buf, |
10512 | sizeof(neighbor_buf), "%s%s ", | |
10513 | dn_flag, peer->host); | |
d62a17ae | 10514 | |
10515 | len = strlen(neighbor_buf); | |
10516 | ||
10517 | if (len > max_neighbor_width) | |
10518 | max_neighbor_width = len; | |
c258527b | 10519 | |
3577f1c5 DD |
10520 | /* See if we have at least a single failed peer */ |
10521 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10522 | failed_count++; | |
10523 | count++; | |
d62a17ae | 10524 | } |
10525 | } | |
f933309e | 10526 | |
d62a17ae | 10527 | /* Originally we displayed the Neighbor column as 16 |
10528 | * characters wide so make that the default | |
10529 | */ | |
10530 | if (max_neighbor_width < neighbor_col_default_width) | |
10531 | max_neighbor_width = neighbor_col_default_width; | |
10532 | } | |
f933309e | 10533 | |
3577f1c5 DD |
10534 | if (show_failed && !failed_count) { |
10535 | if (use_json) { | |
10536 | json_object_int_add(json, "failedPeersCount", 0); | |
10537 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10538 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
10539 | |
10540 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
10541 | json, JSON_C_TO_STRING_PRETTY)); | |
10542 | json_object_free(json); | |
10543 | } else { | |
10544 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
10545 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
10546 | } | |
10547 | return CMD_SUCCESS; | |
10548 | } | |
c258527b | 10549 | |
3577f1c5 | 10550 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 10551 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10552 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10553 | continue; | |
10554 | ||
ea47320b DL |
10555 | if (!peer->afc[afi][safi]) |
10556 | continue; | |
d62a17ae | 10557 | |
ea47320b DL |
10558 | if (!count) { |
10559 | unsigned long ents; | |
10560 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10561 | int64_t vrf_id_ui; |
d62a17ae | 10562 | |
a4d82a8a PZ |
10563 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10564 | ? -1 | |
10565 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10566 | |
10567 | /* Usage summary and header */ | |
10568 | if (use_json) { | |
23d0a753 DA |
10569 | char buf[BUFSIZ] = {0}; |
10570 | ||
ea47320b DL |
10571 | json_object_string_add( |
10572 | json, "routerId", | |
23d0a753 DA |
10573 | inet_ntop(AF_INET, &bgp->router_id, buf, |
10574 | sizeof(buf))); | |
60466a63 QY |
10575 | json_object_int_add(json, "as", bgp->as); |
10576 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10577 | json_object_string_add( |
10578 | json, "vrfName", | |
10579 | (bgp->inst_type | |
10580 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10581 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10582 | : bgp->name); |
10583 | } else { | |
10584 | vty_out(vty, | |
23d0a753 DA |
10585 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10586 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10587 | bgp->vrf_id == VRF_UNKNOWN |
10588 | ? -1 | |
10589 | : (int)bgp->vrf_id); | |
ea47320b DL |
10590 | vty_out(vty, "\n"); |
10591 | } | |
d62a17ae | 10592 | |
ea47320b | 10593 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10594 | if (use_json) { |
ea47320b | 10595 | json_object_int_add( |
60466a63 | 10596 | json, "updateDelayLimit", |
ea47320b | 10597 | bgp->v_update_delay); |
d62a17ae | 10598 | |
ea47320b DL |
10599 | if (bgp->v_update_delay |
10600 | != bgp->v_establish_wait) | |
d62a17ae | 10601 | json_object_int_add( |
10602 | json, | |
ea47320b DL |
10603 | "updateDelayEstablishWait", |
10604 | bgp->v_establish_wait); | |
d62a17ae | 10605 | |
60466a63 | 10606 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10607 | json_object_string_add( |
10608 | json, | |
10609 | "updateDelayFirstNeighbor", | |
10610 | bgp->update_delay_begin_time); | |
10611 | json_object_boolean_true_add( | |
10612 | json, | |
10613 | "updateDelayInProgress"); | |
10614 | } else { | |
10615 | if (bgp->update_delay_over) { | |
d62a17ae | 10616 | json_object_string_add( |
10617 | json, | |
10618 | "updateDelayFirstNeighbor", | |
10619 | bgp->update_delay_begin_time); | |
ea47320b | 10620 | json_object_string_add( |
d62a17ae | 10621 | json, |
ea47320b DL |
10622 | "updateDelayBestpathResumed", |
10623 | bgp->update_delay_end_time); | |
10624 | json_object_string_add( | |
d62a17ae | 10625 | json, |
ea47320b DL |
10626 | "updateDelayZebraUpdateResume", |
10627 | bgp->update_delay_zebra_resume_time); | |
10628 | json_object_string_add( | |
10629 | json, | |
10630 | "updateDelayPeerUpdateResume", | |
10631 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10632 | } |
ea47320b DL |
10633 | } |
10634 | } else { | |
10635 | vty_out(vty, | |
10636 | "Read-only mode update-delay limit: %d seconds\n", | |
10637 | bgp->v_update_delay); | |
10638 | if (bgp->v_update_delay | |
10639 | != bgp->v_establish_wait) | |
d62a17ae | 10640 | vty_out(vty, |
ea47320b DL |
10641 | " Establish wait: %d seconds\n", |
10642 | bgp->v_establish_wait); | |
d62a17ae | 10643 | |
60466a63 | 10644 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10645 | vty_out(vty, |
10646 | " First neighbor established: %s\n", | |
10647 | bgp->update_delay_begin_time); | |
10648 | vty_out(vty, | |
10649 | " Delay in progress\n"); | |
10650 | } else { | |
10651 | if (bgp->update_delay_over) { | |
d62a17ae | 10652 | vty_out(vty, |
10653 | " First neighbor established: %s\n", | |
10654 | bgp->update_delay_begin_time); | |
10655 | vty_out(vty, | |
ea47320b DL |
10656 | " Best-paths resumed: %s\n", |
10657 | bgp->update_delay_end_time); | |
10658 | vty_out(vty, | |
10659 | " zebra update resumed: %s\n", | |
10660 | bgp->update_delay_zebra_resume_time); | |
10661 | vty_out(vty, | |
10662 | " peers update resumed: %s\n", | |
10663 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10664 | } |
10665 | } | |
10666 | } | |
ea47320b | 10667 | } |
d62a17ae | 10668 | |
ea47320b DL |
10669 | if (use_json) { |
10670 | if (bgp_maxmed_onstartup_configured(bgp) | |
10671 | && bgp->maxmed_active) | |
10672 | json_object_boolean_true_add( | |
60466a63 | 10673 | json, "maxMedOnStartup"); |
ea47320b DL |
10674 | if (bgp->v_maxmed_admin) |
10675 | json_object_boolean_true_add( | |
60466a63 | 10676 | json, "maxMedAdministrative"); |
d62a17ae | 10677 | |
ea47320b DL |
10678 | json_object_int_add( |
10679 | json, "tableVersion", | |
60466a63 | 10680 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 10681 | |
60466a63 QY |
10682 | ents = bgp_table_count(bgp->rib[afi][safi]); |
10683 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
10684 | json_object_int_add( |
10685 | json, "ribMemory", | |
9bcb3eef | 10686 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 10687 | |
210ec2a0 | 10688 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
10689 | json_object_int_add(json, "peerCount", ents); |
10690 | json_object_int_add(json, "peerMemory", | |
10691 | ents * sizeof(struct peer)); | |
d62a17ae | 10692 | |
ea47320b DL |
10693 | if ((ents = listcount(bgp->group))) { |
10694 | json_object_int_add( | |
60466a63 | 10695 | json, "peerGroupCount", ents); |
ea47320b DL |
10696 | json_object_int_add( |
10697 | json, "peerGroupMemory", | |
996c9314 LB |
10698 | ents * sizeof(struct |
10699 | peer_group)); | |
ea47320b | 10700 | } |
d62a17ae | 10701 | |
ea47320b DL |
10702 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10703 | BGP_CONFIG_DAMPENING)) | |
10704 | json_object_boolean_true_add( | |
60466a63 | 10705 | json, "dampeningEnabled"); |
ea47320b DL |
10706 | } else { |
10707 | if (bgp_maxmed_onstartup_configured(bgp) | |
10708 | && bgp->maxmed_active) | |
d62a17ae | 10709 | vty_out(vty, |
ea47320b DL |
10710 | "Max-med on-startup active\n"); |
10711 | if (bgp->v_maxmed_admin) | |
d62a17ae | 10712 | vty_out(vty, |
ea47320b | 10713 | "Max-med administrative active\n"); |
d62a17ae | 10714 | |
60466a63 QY |
10715 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
10716 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 10717 | |
60466a63 | 10718 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
10719 | vty_out(vty, |
10720 | "RIB entries %ld, using %s of memory\n", | |
10721 | ents, | |
9bcb3eef DS |
10722 | mtype_memstr( |
10723 | memstrbuf, sizeof(memstrbuf), | |
10724 | ents | |
10725 | * sizeof(struct | |
10726 | bgp_dest))); | |
ea47320b DL |
10727 | |
10728 | /* Peer related usage */ | |
210ec2a0 | 10729 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 10730 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
10731 | ents, |
10732 | mtype_memstr( | |
60466a63 QY |
10733 | memstrbuf, sizeof(memstrbuf), |
10734 | ents * sizeof(struct peer))); | |
ea47320b DL |
10735 | |
10736 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 10737 | vty_out(vty, |
ea47320b | 10738 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 10739 | ents, |
10740 | mtype_memstr( | |
10741 | memstrbuf, | |
10742 | sizeof(memstrbuf), | |
996c9314 LB |
10743 | ents * sizeof(struct |
10744 | peer_group))); | |
d62a17ae | 10745 | |
ea47320b DL |
10746 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10747 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 10748 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 10749 | vty_out(vty, "\n"); |
d62a17ae | 10750 | |
ea47320b DL |
10751 | /* Subtract 8 here because 'Neighbor' is |
10752 | * 8 characters */ | |
10753 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
10754 | vty_out(vty, "%*s", max_neighbor_width - 8, |
10755 | " "); | |
3577f1c5 DD |
10756 | if (show_failed) |
10757 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
10758 | else | |
10759 | vty_out(vty, | |
db92d226 | 10760 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n"); |
d62a17ae | 10761 | } |
ea47320b | 10762 | } |
d62a17ae | 10763 | |
d55811cc | 10764 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 10765 | filter = &peer->filter[afi][safi]; |
db92d226 | 10766 | |
ea47320b | 10767 | count++; |
3577f1c5 DD |
10768 | /* Works for both failed & successful cases */ |
10769 | if (peer_dynamic_neighbor(peer)) | |
10770 | dn_count++; | |
d62a17ae | 10771 | |
ea47320b | 10772 | if (use_json) { |
3577f1c5 DD |
10773 | json_peer = NULL; |
10774 | ||
10775 | if (show_failed && | |
10776 | bgp_has_peer_failed(peer, afi, safi)) { | |
10777 | json_peer = json_object_new_object(); | |
10778 | bgp_show_failed_summary(vty, bgp, peer, | |
10779 | json_peer, 0, use_json); | |
10780 | } else if (!show_failed) { | |
10b49f14 DA |
10781 | if (show_established |
10782 | && bgp_has_peer_failed(peer, afi, safi)) | |
10783 | continue; | |
10784 | ||
3577f1c5 DD |
10785 | json_peer = json_object_new_object(); |
10786 | if (peer_dynamic_neighbor(peer)) { | |
10787 | json_object_boolean_true_add(json_peer, | |
10788 | "dynamicPeer"); | |
10789 | } | |
d62a17ae | 10790 | |
3577f1c5 DD |
10791 | if (peer->hostname) |
10792 | json_object_string_add(json_peer, "hostname", | |
10793 | peer->hostname); | |
10794 | ||
10795 | if (peer->domainname) | |
10796 | json_object_string_add(json_peer, "domainname", | |
10797 | peer->domainname); | |
10798 | ||
10799 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
10800 | json_object_int_add(json_peer, "version", 4); | |
10801 | json_object_int_add(json_peer, "msgRcvd", | |
10802 | PEER_TOTAL_RX(peer)); | |
10803 | json_object_int_add(json_peer, "msgSent", | |
10804 | PEER_TOTAL_TX(peer)); | |
10805 | ||
43aa5965 QY |
10806 | atomic_size_t outq_count, inq_count; |
10807 | outq_count = atomic_load_explicit( | |
10808 | &peer->obuf->count, | |
10809 | memory_order_relaxed); | |
10810 | inq_count = atomic_load_explicit( | |
10811 | &peer->ibuf->count, | |
10812 | memory_order_relaxed); | |
10813 | ||
3577f1c5 DD |
10814 | json_object_int_add(json_peer, "tableVersion", |
10815 | peer->version[afi][safi]); | |
10816 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
10817 | outq_count); |
10818 | json_object_int_add(json_peer, "inq", | |
10819 | inq_count); | |
3577f1c5 DD |
10820 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
10821 | use_json, json_peer); | |
10822 | ||
3577f1c5 DD |
10823 | json_object_int_add(json_peer, "pfxRcd", |
10824 | peer->pcount[afi][pfx_rcd_safi]); | |
10825 | ||
3577f1c5 DD |
10826 | if (paf && PAF_SUBGRP(paf)) |
10827 | json_object_int_add(json_peer, | |
10828 | "pfxSnt", | |
10829 | (PAF_SUBGRP(paf))->scount); | |
cb9196e7 | 10830 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
10831 | || CHECK_FLAG(peer->bgp->flags, |
10832 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10833 | json_object_string_add(json_peer, "state", |
10834 | "Idle (Admin)"); | |
10835 | else if (peer->afc_recv[afi][safi]) | |
10836 | json_object_string_add( | |
10837 | json_peer, "state", | |
10838 | lookup_msg(bgp_status_msg, peer->status, | |
10839 | NULL)); | |
10840 | else if (CHECK_FLAG(peer->sflags, | |
10841 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10842 | json_object_string_add(json_peer, "state", | |
10843 | "Idle (PfxCt)"); | |
10844 | else | |
10845 | json_object_string_add( | |
10846 | json_peer, "state", | |
10847 | lookup_msg(bgp_status_msg, peer->status, | |
10848 | NULL)); | |
200116db DD |
10849 | json_object_int_add(json_peer, "connectionsEstablished", |
10850 | peer->established); | |
10851 | json_object_int_add(json_peer, "connectionsDropped", | |
10852 | peer->dropped); | |
b4e9dcba | 10853 | } |
3577f1c5 DD |
10854 | /* Avoid creating empty peer dicts in JSON */ |
10855 | if (json_peer == NULL) | |
10856 | continue; | |
ea47320b DL |
10857 | |
10858 | if (peer->conf_if) | |
60466a63 | 10859 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
10860 | "interface"); |
10861 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
10862 | json_object_string_add(json_peer, "idType", |
10863 | "ipv4"); | |
ea47320b | 10864 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
10865 | json_object_string_add(json_peer, "idType", |
10866 | "ipv6"); | |
ea47320b DL |
10867 | json_object_object_add(json_peers, peer->host, |
10868 | json_peer); | |
10869 | } else { | |
3577f1c5 DD |
10870 | if (show_failed && |
10871 | bgp_has_peer_failed(peer, afi, safi)) { | |
10872 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10873 | max_neighbor_width, | |
10874 | use_json); | |
10875 | } else if (!show_failed) { | |
10b49f14 DA |
10876 | if (show_established |
10877 | && bgp_has_peer_failed(peer, afi, safi)) | |
10878 | continue; | |
10879 | ||
3577f1c5 DD |
10880 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10881 | if (peer_dynamic_neighbor(peer)) { | |
10882 | dn_flag[0] = '*'; | |
10883 | } | |
d62a17ae | 10884 | |
3577f1c5 | 10885 | if (peer->hostname |
892fedb6 DA |
10886 | && CHECK_FLAG(bgp->flags, |
10887 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10888 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10889 | peer->hostname, |
10890 | peer->host); | |
d62a17ae | 10891 | else |
3577f1c5 DD |
10892 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10893 | ||
10894 | /* pad the neighbor column with spaces */ | |
10895 | if (len < max_neighbor_width) | |
10896 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10897 | " "); | |
10898 | ||
43aa5965 QY |
10899 | atomic_size_t outq_count, inq_count; |
10900 | outq_count = atomic_load_explicit( | |
10901 | &peer->obuf->count, | |
10902 | memory_order_relaxed); | |
10903 | inq_count = atomic_load_explicit( | |
10904 | &peer->ibuf->count, | |
10905 | memory_order_relaxed); | |
10906 | ||
566bdaf6 | 10907 | vty_out(vty, |
6cde4b45 | 10908 | "4 %10u %9u %9u %8" PRIu64" %4zu %4zu %8s", |
3577f1c5 | 10909 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 10910 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
10911 | peer->version[afi][safi], inq_count, |
10912 | outq_count, | |
3577f1c5 DD |
10913 | peer_uptime(peer->uptime, timebuf, |
10914 | BGP_UPTIME_LEN, 0, NULL)); | |
10915 | ||
db92d226 | 10916 | if (peer->status == Established) { |
d3ada366 DA |
10917 | if (peer->afc_recv[afi][safi]) { |
10918 | if (CHECK_FLAG( | |
10919 | bgp->flags, | |
10920 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10921 | && !bgp_inbound_policy_exists( | |
10922 | peer, filter)) | |
10923 | vty_out(vty, " %12s", | |
10924 | "(Policy)"); | |
10925 | else | |
10926 | vty_out(vty, | |
6cde4b45 | 10927 | " %12u", |
d3ada366 DA |
10928 | peer->pcount |
10929 | [afi] | |
10930 | [pfx_rcd_safi]); | |
10931 | } else { | |
3577f1c5 | 10932 | vty_out(vty, " NoNeg"); |
d3ada366 | 10933 | } |
db92d226 | 10934 | |
d3ada366 DA |
10935 | if (paf && PAF_SUBGRP(paf)) { |
10936 | if (CHECK_FLAG( | |
10937 | bgp->flags, | |
10938 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10939 | && !bgp_outbound_policy_exists( | |
10940 | peer, filter)) | |
10941 | vty_out(vty, " %8s", | |
10942 | "(Policy)"); | |
10943 | else | |
10944 | vty_out(vty, | |
6cde4b45 | 10945 | " %8u", |
d3ada366 DA |
10946 | (PAF_SUBGRP( |
10947 | paf)) | |
10948 | ->scount); | |
10949 | } | |
db92d226 | 10950 | } else { |
736b68f3 DS |
10951 | if (CHECK_FLAG(peer->flags, |
10952 | PEER_FLAG_SHUTDOWN) | |
10953 | || CHECK_FLAG(peer->bgp->flags, | |
10954 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10955 | vty_out(vty, " Idle (Admin)"); |
10956 | else if (CHECK_FLAG( | |
10957 | peer->sflags, | |
10958 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10959 | vty_out(vty, " Idle (PfxCt)"); | |
10960 | else | |
10961 | vty_out(vty, " %12s", | |
10962 | lookup_msg(bgp_status_msg, | |
10963 | peer->status, NULL)); | |
db92d226 | 10964 | |
6cde4b45 | 10965 | vty_out(vty, " %8u", 0); |
3577f1c5 DD |
10966 | } |
10967 | vty_out(vty, "\n"); | |
d62a17ae | 10968 | } |
3577f1c5 | 10969 | |
d62a17ae | 10970 | } |
10971 | } | |
f933309e | 10972 | |
d62a17ae | 10973 | if (use_json) { |
10974 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 10975 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 10976 | json_object_int_add(json, "totalPeers", count); |
10977 | json_object_int_add(json, "dynamicPeers", dn_count); | |
10978 | ||
3577f1c5 DD |
10979 | if (!show_failed) |
10980 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 10981 | |
996c9314 LB |
10982 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10983 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10984 | json_object_free(json); |
10985 | } else { | |
10986 | if (count) | |
10987 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
10988 | else { | |
d6ceaca3 | 10989 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 10990 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10991 | } |
b05a1c8b | 10992 | |
d6ceaca3 | 10993 | if (dn_count) { |
d62a17ae | 10994 | vty_out(vty, "* - dynamic neighbor\n"); |
10995 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
10996 | dn_count, bgp->dynamic_neighbors_limit); | |
10997 | } | |
10998 | } | |
1ff9a340 | 10999 | |
d62a17ae | 11000 | return CMD_SUCCESS; |
718e3744 | 11001 | } |
11002 | ||
d62a17ae | 11003 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
10b49f14 DA |
11004 | int safi, bool show_failed, |
11005 | bool show_established, bool use_json) | |
d62a17ae | 11006 | { |
11007 | int is_first = 1; | |
11008 | int afi_wildcard = (afi == AFI_MAX); | |
11009 | int safi_wildcard = (safi == SAFI_MAX); | |
11010 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11011 | bool nbr_output = false; |
d62a17ae | 11012 | |
11013 | if (use_json && is_wildcard) | |
11014 | vty_out(vty, "{\n"); | |
11015 | if (afi_wildcard) | |
11016 | afi = 1; /* AFI_IP */ | |
11017 | while (afi < AFI_MAX) { | |
11018 | if (safi_wildcard) | |
11019 | safi = 1; /* SAFI_UNICAST */ | |
11020 | while (safi < SAFI_MAX) { | |
318cac96 | 11021 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11022 | nbr_output = true; |
f86897b9 | 11023 | |
d62a17ae | 11024 | if (is_wildcard) { |
11025 | /* | |
11026 | * So limit output to those afi/safi | |
11027 | * pairs that | |
11028 | * actualy have something interesting in | |
11029 | * them | |
11030 | */ | |
11031 | if (use_json) { | |
d62a17ae | 11032 | if (!is_first) |
11033 | vty_out(vty, ",\n"); | |
11034 | else | |
11035 | is_first = 0; | |
11036 | ||
11037 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11038 | get_afi_safi_str(afi, |
11039 | safi, | |
11040 | true)); | |
d62a17ae | 11041 | } else { |
11042 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
11043 | get_afi_safi_str(afi, |
11044 | safi, | |
11045 | false)); | |
d62a17ae | 11046 | } |
11047 | } | |
10b49f14 DA |
11048 | bgp_show_summary(vty, bgp, afi, safi, |
11049 | show_failed, show_established, | |
3577f1c5 | 11050 | use_json); |
d62a17ae | 11051 | } |
11052 | safi++; | |
d62a17ae | 11053 | if (!safi_wildcard) |
11054 | safi = SAFI_MAX; | |
11055 | } | |
11056 | afi++; | |
ee851c8c | 11057 | if (!afi_wildcard) |
d62a17ae | 11058 | afi = AFI_MAX; |
11059 | } | |
11060 | ||
11061 | if (use_json && is_wildcard) | |
11062 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11063 | else if (!nbr_output) { |
11064 | if (use_json) | |
11065 | vty_out(vty, "{}\n"); | |
11066 | else | |
11067 | vty_out(vty, "%% No BGP neighbors found\n"); | |
11068 | } | |
d62a17ae | 11069 | } |
11070 | ||
11071 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 | 11072 | safi_t safi, bool show_failed, |
10b49f14 | 11073 | bool show_established, |
3577f1c5 | 11074 | bool use_json) |
d62a17ae | 11075 | { |
11076 | struct listnode *node, *nnode; | |
11077 | struct bgp *bgp; | |
d62a17ae | 11078 | int is_first = 1; |
9f049418 | 11079 | bool nbr_output = false; |
d62a17ae | 11080 | |
11081 | if (use_json) | |
11082 | vty_out(vty, "{\n"); | |
11083 | ||
11084 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11085 | nbr_output = true; |
d62a17ae | 11086 | if (use_json) { |
d62a17ae | 11087 | if (!is_first) |
11088 | vty_out(vty, ",\n"); | |
11089 | else | |
11090 | is_first = 0; | |
11091 | ||
11092 | vty_out(vty, "\"%s\":", | |
11093 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11094 | ? VRF_DEFAULT_NAME |
d62a17ae | 11095 | : bgp->name); |
11096 | } else { | |
11097 | vty_out(vty, "\nInstance %s:\n", | |
11098 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11099 | ? VRF_DEFAULT_NAME |
d62a17ae | 11100 | : bgp->name); |
11101 | } | |
3577f1c5 | 11102 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 11103 | show_established, use_json); |
d62a17ae | 11104 | } |
11105 | ||
11106 | if (use_json) | |
11107 | vty_out(vty, "}\n"); | |
9f049418 DS |
11108 | else if (!nbr_output) |
11109 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11110 | } |
11111 | ||
11112 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
10b49f14 DA |
11113 | safi_t safi, bool show_failed, bool show_established, |
11114 | bool use_json) | |
d62a17ae | 11115 | { |
11116 | struct bgp *bgp; | |
11117 | ||
11118 | if (name) { | |
11119 | if (strmatch(name, "all")) { | |
10b49f14 DA |
11120 | bgp_show_all_instances_summary_vty( |
11121 | vty, afi, safi, show_failed, show_established, | |
11122 | use_json); | |
d62a17ae | 11123 | return CMD_SUCCESS; |
11124 | } else { | |
11125 | bgp = bgp_lookup_by_name(name); | |
11126 | ||
11127 | if (!bgp) { | |
11128 | if (use_json) | |
11129 | vty_out(vty, "{}\n"); | |
11130 | else | |
11131 | vty_out(vty, | |
ca61fd25 | 11132 | "%% BGP instance not found\n"); |
d62a17ae | 11133 | return CMD_WARNING; |
11134 | } | |
11135 | ||
f86897b9 | 11136 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
10b49f14 DA |
11137 | show_failed, show_established, |
11138 | use_json); | |
d62a17ae | 11139 | return CMD_SUCCESS; |
11140 | } | |
11141 | } | |
11142 | ||
11143 | bgp = bgp_get_default(); | |
11144 | ||
11145 | if (bgp) | |
3577f1c5 | 11146 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 11147 | show_established, use_json); |
9f049418 | 11148 | else { |
ca61fd25 DS |
11149 | if (use_json) |
11150 | vty_out(vty, "{}\n"); | |
11151 | else | |
11152 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11153 | return CMD_WARNING; |
11154 | } | |
d62a17ae | 11155 | |
11156 | return CMD_SUCCESS; | |
4fb25c53 DW |
11157 | } |
11158 | ||
716b2d8a | 11159 | /* `show [ip] bgp summary' commands. */ |
96f3485c | 11160 | DEFPY (show_ip_bgp_summary, |
718e3744 | 11161 | show_ip_bgp_summary_cmd, |
96f3485c | 11162 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] summary [established|failed] [json$uj]", |
718e3744 | 11163 | SHOW_STR |
11164 | IP_STR | |
11165 | BGP_STR | |
8386ac43 | 11166 | BGP_INSTANCE_HELP_STR |
46f296b4 | 11167 | BGP_AFI_HELP_STR |
dd6bd0f1 | 11168 | BGP_SAFI_WITH_LABEL_HELP_STR |
96f3485c | 11169 | "Display the entries for all address families\n" |
b05a1c8b | 11170 | "Summary of BGP neighbor status\n" |
10b49f14 | 11171 | "Show only sessions in Established state\n" |
3577f1c5 | 11172 | "Show only sessions not in Established state\n" |
9973d184 | 11173 | JSON_STR) |
718e3744 | 11174 | { |
d62a17ae | 11175 | char *vrf = NULL; |
11176 | afi_t afi = AFI_MAX; | |
11177 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 11178 | bool show_failed = false; |
10b49f14 | 11179 | bool show_established = false; |
d62a17ae | 11180 | |
11181 | int idx = 0; | |
11182 | ||
11183 | /* show [ip] bgp */ | |
96f3485c | 11184 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11185 | afi = AFI_IP; |
9a8bdf1c PG |
11186 | /* [<vrf> VIEWVRFNAME] */ |
11187 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11188 | vrf = argv[idx + 1]->arg; | |
11189 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11190 | vrf = NULL; | |
11191 | } else if (argv_find(argv, argc, "view", &idx)) | |
11192 | /* [<view> VIEWVRFNAME] */ | |
11193 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11194 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11195 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11196 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11197 | } | |
11198 | ||
3577f1c5 DD |
11199 | if (argv_find(argv, argc, "failed", &idx)) |
11200 | show_failed = true; | |
10b49f14 DA |
11201 | if (argv_find(argv, argc, "established", &idx)) |
11202 | show_established = true; | |
3577f1c5 | 11203 | |
10b49f14 DA |
11204 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, |
11205 | show_established, uj); | |
d62a17ae | 11206 | } |
11207 | ||
5cb5f4d0 | 11208 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11209 | { |
5cb5f4d0 DD |
11210 | if (for_json) |
11211 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11212 | else |
5cb5f4d0 | 11213 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11214 | } |
11215 | ||
d62a17ae | 11216 | |
11217 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11218 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11219 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11220 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11221 | bool use_json, json_object *json_pref) |
d62a17ae | 11222 | { |
11223 | /* Send-Mode */ | |
11224 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11225 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11226 | if (use_json) { | |
11227 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11228 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11229 | json_object_string_add(json_pref, "sendMode", | |
11230 | "advertisedAndReceived"); | |
11231 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11232 | json_object_string_add(json_pref, "sendMode", | |
11233 | "advertised"); | |
11234 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11235 | json_object_string_add(json_pref, "sendMode", | |
11236 | "received"); | |
11237 | } else { | |
11238 | vty_out(vty, " Send-mode: "); | |
11239 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11240 | vty_out(vty, "advertised"); | |
11241 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11242 | vty_out(vty, "%sreceived", | |
11243 | CHECK_FLAG(p->af_cap[afi][safi], | |
11244 | adv_smcap) | |
11245 | ? ", " | |
11246 | : ""); | |
11247 | vty_out(vty, "\n"); | |
11248 | } | |
11249 | } | |
11250 | ||
11251 | /* Receive-Mode */ | |
11252 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11253 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11254 | if (use_json) { | |
11255 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11256 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11257 | json_object_string_add(json_pref, "recvMode", | |
11258 | "advertisedAndReceived"); | |
11259 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11260 | json_object_string_add(json_pref, "recvMode", | |
11261 | "advertised"); | |
11262 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11263 | json_object_string_add(json_pref, "recvMode", | |
11264 | "received"); | |
11265 | } else { | |
11266 | vty_out(vty, " Receive-mode: "); | |
11267 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11268 | vty_out(vty, "advertised"); | |
11269 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11270 | vty_out(vty, "%sreceived", | |
11271 | CHECK_FLAG(p->af_cap[afi][safi], | |
11272 | adv_rmcap) | |
11273 | ? ", " | |
11274 | : ""); | |
11275 | vty_out(vty, "\n"); | |
11276 | } | |
11277 | } | |
11278 | } | |
11279 | ||
13909c4f DS |
11280 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
11281 | struct peer *p, | |
11282 | bool use_json, | |
11283 | json_object *json) | |
2986cac2 | 11284 | { |
08c2d52a | 11285 | bool rbit_status = false; |
2986cac2 | 11286 | |
11287 | if (!use_json) | |
a53ca37b | 11288 | vty_out(vty, "\n R bit: "); |
2986cac2 | 11289 | |
13909c4f DS |
11290 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11291 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
11292 | && (p->status == Established)) { | |
2986cac2 | 11293 | |
11294 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 11295 | rbit_status = true; |
2986cac2 | 11296 | else |
08c2d52a | 11297 | rbit_status = false; |
2986cac2 | 11298 | } |
11299 | ||
11300 | if (rbit_status) { | |
11301 | if (use_json) | |
13909c4f | 11302 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 11303 | else |
11304 | vty_out(vty, "True\n"); | |
11305 | } else { | |
11306 | if (use_json) | |
13909c4f | 11307 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 11308 | else |
11309 | vty_out(vty, "False\n"); | |
11310 | } | |
11311 | } | |
11312 | ||
13909c4f DS |
11313 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11314 | struct peer *peer, | |
11315 | bool use_json, | |
11316 | json_object *json) | |
2986cac2 | 11317 | { |
2bb5d39b | 11318 | const char *mode = "NotApplicable"; |
2986cac2 | 11319 | |
11320 | if (!use_json) | |
a53ca37b | 11321 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11322 | |
13909c4f DS |
11323 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11324 | && (peer->status == Established)) { | |
2986cac2 | 11325 | |
13909c4f DS |
11326 | if ((peer->nsf_af_count == 0) |
11327 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11328 | |
2986cac2 | 11329 | mode = "Disable"; |
11330 | ||
13909c4f DS |
11331 | } else if (peer->nsf_af_count == 0 |
11332 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11333 | |
2986cac2 | 11334 | mode = "Helper"; |
11335 | ||
13909c4f DS |
11336 | } else if (peer->nsf_af_count != 0 |
11337 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11338 | |
2986cac2 | 11339 | mode = "Restart"; |
2986cac2 | 11340 | } |
11341 | } | |
11342 | ||
11343 | if (use_json) { | |
13909c4f | 11344 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11345 | } else |
11346 | vty_out(vty, mode, "\n"); | |
11347 | } | |
11348 | ||
13909c4f DS |
11349 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11350 | struct peer *p, | |
11351 | bool use_json, | |
11352 | json_object *json) | |
2986cac2 | 11353 | { |
11354 | const char *mode = "Invalid"; | |
11355 | ||
11356 | if (!use_json) | |
a53ca37b | 11357 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11358 | |
11359 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11360 | mode = "Helper"; | |
11361 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11362 | mode = "Restart"; | |
11363 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11364 | mode = "Disable"; | |
2ba1fe69 | 11365 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11366 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11367 | mode = "Helper*"; | |
11368 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11369 | mode = "Restart*"; | |
11370 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11371 | mode = "Disable*"; | |
11372 | else | |
11373 | mode = "Invalid*"; | |
2ba1fe69 | 11374 | } |
2986cac2 | 11375 | |
11376 | if (use_json) { | |
13909c4f | 11377 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11378 | } else { |
11379 | vty_out(vty, mode, "\n"); | |
11380 | } | |
11381 | } | |
11382 | ||
13909c4f DS |
11383 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11384 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11385 | { |
2ba1fe69 | 11386 | afi_t afi; |
11387 | safi_t safi; | |
2986cac2 | 11388 | json_object *json_afi_safi = NULL; |
11389 | json_object *json_timer = NULL; | |
11390 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11391 | bool eor_flag = false; |
2986cac2 | 11392 | |
11393 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11394 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
11395 | if (!peer->afc[afi][safi]) |
11396 | continue; | |
2986cac2 | 11397 | |
13909c4f DS |
11398 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11399 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11400 | continue; | |
9e3b51a7 | 11401 | |
13909c4f DS |
11402 | if (use_json) { |
11403 | json_afi_safi = json_object_new_object(); | |
11404 | json_endofrib_status = json_object_new_object(); | |
11405 | json_timer = json_object_new_object(); | |
11406 | } | |
2986cac2 | 11407 | |
13909c4f DS |
11408 | if (peer->eor_stime[afi][safi] |
11409 | >= peer->pkt_stime[afi][safi]) | |
11410 | eor_flag = true; | |
11411 | else | |
11412 | eor_flag = false; | |
2986cac2 | 11413 | |
13909c4f | 11414 | if (!use_json) { |
a53ca37b | 11415 | vty_out(vty, " %s:\n", |
13909c4f | 11416 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 11417 | |
a53ca37b | 11418 | vty_out(vty, " F bit: "); |
698ba8d0 | 11419 | } |
2986cac2 | 11420 | |
13909c4f DS |
11421 | if (peer->nsf[afi][safi] |
11422 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
11423 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11424 | |
13909c4f DS |
11425 | if (use_json) { |
11426 | json_object_boolean_true_add( | |
2986cac2 | 11427 | json_afi_safi, "fBit"); |
13909c4f DS |
11428 | } else |
11429 | vty_out(vty, "True\n"); | |
11430 | } else { | |
11431 | if (use_json) | |
11432 | json_object_boolean_false_add( | |
11433 | json_afi_safi, "fBit"); | |
11434 | else | |
11435 | vty_out(vty, "False\n"); | |
11436 | } | |
2986cac2 | 11437 | |
13909c4f | 11438 | if (!use_json) |
a53ca37b | 11439 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 11440 | |
13909c4f DS |
11441 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11442 | PEER_STATUS_EOR_SEND)) { | |
11443 | if (use_json) { | |
11444 | json_object_boolean_true_add( | |
2986cac2 | 11445 | json_endofrib_status, |
13909c4f | 11446 | "endOfRibSend"); |
9e3b51a7 | 11447 | |
13909c4f DS |
11448 | PRINT_EOR_JSON(eor_flag); |
11449 | } else { | |
11450 | vty_out(vty, "Yes\n"); | |
11451 | vty_out(vty, | |
a53ca37b | 11452 | " End-of-RIB sent after update: "); |
2986cac2 | 11453 | |
13909c4f DS |
11454 | PRINT_EOR(eor_flag); |
11455 | } | |
11456 | } else { | |
11457 | if (use_json) { | |
11458 | json_object_boolean_false_add( | |
2986cac2 | 11459 | json_endofrib_status, |
13909c4f DS |
11460 | "endOfRibSend"); |
11461 | json_object_boolean_false_add( | |
9e3b51a7 | 11462 | json_endofrib_status, |
13909c4f DS |
11463 | "endOfRibSentAfterUpdate"); |
11464 | } else { | |
11465 | vty_out(vty, "No\n"); | |
11466 | vty_out(vty, | |
a53ca37b | 11467 | " End-of-RIB sent after update: "); |
13909c4f | 11468 | vty_out(vty, "No\n"); |
2986cac2 | 11469 | } |
13909c4f | 11470 | } |
2986cac2 | 11471 | |
a53ca37b DA |
11472 | if (!use_json) |
11473 | vty_out(vty, " End-of-RIB received: "); | |
11474 | ||
11475 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
11476 | PEER_STATUS_EOR_RECEIVED)) { | |
11477 | if (use_json) | |
11478 | json_object_boolean_true_add( | |
11479 | json_endofrib_status, | |
11480 | "endOfRibRecv"); | |
11481 | else | |
11482 | vty_out(vty, "Yes\n"); | |
11483 | } else { | |
11484 | if (use_json) | |
11485 | json_object_boolean_false_add( | |
11486 | json_endofrib_status, | |
11487 | "endOfRibRecv"); | |
11488 | else | |
11489 | vty_out(vty, "No\n"); | |
11490 | } | |
11491 | ||
13909c4f DS |
11492 | if (use_json) { |
11493 | json_object_int_add(json_timer, | |
11494 | "stalePathTimer", | |
11495 | peer->bgp->stalepath_time); | |
2986cac2 | 11496 | |
13909c4f DS |
11497 | if (peer->t_gr_stale != NULL) { |
11498 | json_object_int_add( | |
2986cac2 | 11499 | json_timer, |
11500 | "stalePathTimerRemaining", | |
11501 | thread_timer_remain_second( | |
13909c4f DS |
11502 | peer->t_gr_stale)); |
11503 | } | |
3a75afa4 | 11504 | |
13909c4f DS |
11505 | /* Display Configured Selection |
11506 | * Deferral only when when | |
11507 | * Gr mode is enabled. | |
11508 | */ | |
11509 | if (CHECK_FLAG(peer->flags, | |
11510 | PEER_FLAG_GRACEFUL_RESTART)) { | |
11511 | json_object_int_add( | |
3a75afa4 | 11512 | json_timer, |
2986cac2 | 11513 | "selectionDeferralTimer", |
11514 | peer->bgp->stalepath_time); | |
13909c4f | 11515 | } |
2986cac2 | 11516 | |
13909c4f DS |
11517 | if (peer->bgp->gr_info[afi][safi] |
11518 | .t_select_deferral | |
11519 | != NULL) { | |
2986cac2 | 11520 | |
13909c4f | 11521 | json_object_int_add( |
2986cac2 | 11522 | json_timer, |
11523 | "selectionDeferralTimerRemaining", | |
11524 | thread_timer_remain_second( | |
13909c4f DS |
11525 | peer->bgp |
11526 | ->gr_info[afi] | |
11527 | [safi] | |
11528 | .t_select_deferral)); | |
11529 | } | |
11530 | } else { | |
a53ca37b | 11531 | vty_out(vty, " Timers:\n"); |
13909c4f | 11532 | vty_out(vty, |
a53ca37b DA |
11533 | " Configured Stale Path Time(sec): %u\n", |
11534 | peer->bgp->stalepath_time); | |
2986cac2 | 11535 | |
a53ca37b | 11536 | if (peer->t_gr_stale != NULL) |
2986cac2 | 11537 | vty_out(vty, |
a53ca37b | 11538 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 11539 | thread_timer_remain_second( |
13909c4f | 11540 | peer->t_gr_stale)); |
13909c4f DS |
11541 | /* Display Configured Selection |
11542 | * Deferral only when when | |
11543 | * Gr mode is enabled. | |
11544 | */ | |
11545 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 11546 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 11547 | vty_out(vty, |
a53ca37b | 11548 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 11549 | peer->bgp->select_defer_time); |
2986cac2 | 11550 | |
13909c4f DS |
11551 | if (peer->bgp->gr_info[afi][safi] |
11552 | .t_select_deferral | |
a53ca37b | 11553 | != NULL) |
13909c4f | 11554 | vty_out(vty, |
a53ca37b | 11555 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 11556 | thread_timer_remain_second( |
13909c4f DS |
11557 | peer->bgp |
11558 | ->gr_info[afi] | |
11559 | [safi] | |
11560 | .t_select_deferral)); | |
2986cac2 | 11561 | } |
13909c4f DS |
11562 | if (use_json) { |
11563 | json_object_object_add(json_afi_safi, | |
11564 | "endOfRibStatus", | |
11565 | json_endofrib_status); | |
11566 | json_object_object_add(json_afi_safi, "timers", | |
11567 | json_timer); | |
11568 | json_object_object_add( | |
11569 | json, get_afi_safi_str(afi, safi, true), | |
11570 | json_afi_safi); | |
11571 | } | |
2986cac2 | 11572 | } |
11573 | } | |
11574 | } | |
11575 | ||
36235319 QY |
11576 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
11577 | struct peer *p, | |
11578 | bool use_json, | |
11579 | json_object *json) | |
2986cac2 | 11580 | { |
11581 | if (use_json) { | |
11582 | json_object *json_timer = NULL; | |
11583 | ||
11584 | json_timer = json_object_new_object(); | |
11585 | ||
13909c4f DS |
11586 | json_object_int_add(json_timer, "configuredRestartTimer", |
11587 | p->bgp->restart_time); | |
2986cac2 | 11588 | |
13909c4f DS |
11589 | json_object_int_add(json_timer, "receivedRestartTimer", |
11590 | p->v_gr_restart); | |
2986cac2 | 11591 | |
13909c4f DS |
11592 | if (p->t_gr_restart != NULL) |
11593 | json_object_int_add( | |
11594 | json_timer, "restartTimerRemaining", | |
11595 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 11596 | |
11597 | json_object_object_add(json, "timers", json_timer); | |
11598 | } else { | |
11599 | ||
a53ca37b DA |
11600 | vty_out(vty, " Timers:\n"); |
11601 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 11602 | p->bgp->restart_time); |
2986cac2 | 11603 | |
a53ca37b | 11604 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
11605 | p->v_gr_restart); |
11606 | if (p->t_gr_restart != NULL) | |
a53ca37b | 11607 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 11608 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 11609 | if (p->t_gr_restart != NULL) { |
a53ca37b | 11610 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
11611 | thread_timer_remain_second(p->t_gr_restart)); |
11612 | } | |
2986cac2 | 11613 | } |
11614 | } | |
11615 | ||
11616 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 11617 | bool use_json, json_object *json) |
2986cac2 | 11618 | { |
11619 | char buf[SU_ADDRSTRLEN] = {0}; | |
11620 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
11621 | /* '*' + v6 address of neighbor */ |
11622 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 11623 | |
2986cac2 | 11624 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
11625 | dn_flag[0] = '*'; | |
11626 | ||
11627 | if (p->conf_if) { | |
11628 | if (use_json) | |
13909c4f DS |
11629 | json_object_string_add( |
11630 | json, "neighborAddr", | |
2986cac2 | 11631 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
11632 | ? "none" |
11633 | : sockunion2str(&p->su, buf, | |
11634 | SU_ADDRSTRLEN)); | |
2986cac2 | 11635 | else |
13909c4f | 11636 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 11637 | BGP_PEER_SU_UNSPEC(p) |
11638 | ? "none" | |
11639 | : sockunion2str(&p->su, buf, | |
11640 | SU_ADDRSTRLEN)); | |
11641 | } else { | |
772270f3 QY |
11642 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
11643 | p->host); | |
2986cac2 | 11644 | |
11645 | if (use_json) | |
36235319 QY |
11646 | json_object_string_add(json, "neighborAddr", |
11647 | neighborAddr); | |
2986cac2 | 11648 | else |
36235319 | 11649 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 11650 | } |
11651 | ||
11652 | /* more gr info in new format */ | |
11653 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11654 | } | |
11655 | ||
d62a17ae | 11656 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 11657 | safi_t safi, bool use_json, |
d62a17ae | 11658 | json_object *json_neigh) |
11659 | { | |
0291c246 MK |
11660 | struct bgp_filter *filter; |
11661 | struct peer_af *paf; | |
11662 | char orf_pfx_name[BUFSIZ]; | |
11663 | int orf_pfx_count; | |
11664 | json_object *json_af = NULL; | |
11665 | json_object *json_prefA = NULL; | |
11666 | json_object *json_prefB = NULL; | |
11667 | json_object *json_addr = NULL; | |
fa36596c | 11668 | json_object *json_advmap = NULL; |
d62a17ae | 11669 | |
11670 | if (use_json) { | |
11671 | json_addr = json_object_new_object(); | |
11672 | json_af = json_object_new_object(); | |
11673 | filter = &p->filter[afi][safi]; | |
11674 | ||
11675 | if (peer_group_active(p)) | |
11676 | json_object_string_add(json_addr, "peerGroupMember", | |
11677 | p->group->name); | |
11678 | ||
11679 | paf = peer_af_find(p, afi, safi); | |
11680 | if (paf && PAF_SUBGRP(paf)) { | |
11681 | json_object_int_add(json_addr, "updateGroupId", | |
11682 | PAF_UPDGRP(paf)->id); | |
11683 | json_object_int_add(json_addr, "subGroupId", | |
11684 | PAF_SUBGRP(paf)->id); | |
11685 | json_object_int_add(json_addr, "packetQueueLength", | |
11686 | bpacket_queue_virtual_length(paf)); | |
11687 | } | |
11688 | ||
11689 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11690 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11691 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11692 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11693 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11694 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11695 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11696 | json_object_int_add(json_af, "orfType", | |
11697 | ORF_TYPE_PREFIX); | |
11698 | json_prefA = json_object_new_object(); | |
11699 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11700 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11701 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11702 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11703 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11704 | use_json, json_prefA); | |
11705 | json_object_object_add(json_af, "orfPrefixList", | |
11706 | json_prefA); | |
11707 | } | |
11708 | ||
11709 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11710 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11711 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11712 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11713 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11714 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11715 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11716 | json_object_int_add(json_af, "orfOldType", | |
11717 | ORF_TYPE_PREFIX_OLD); | |
11718 | json_prefB = json_object_new_object(); | |
11719 | bgp_show_peer_afi_orf_cap( | |
11720 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11721 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11722 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11723 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11724 | json_prefB); | |
11725 | json_object_object_add(json_af, "orfOldPrefixList", | |
11726 | json_prefB); | |
11727 | } | |
11728 | ||
11729 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11730 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11731 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11732 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11733 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11734 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11735 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11736 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11737 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11738 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11739 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11740 | json_object_object_add(json_addr, "afDependentCap", | |
11741 | json_af); | |
11742 | else | |
11743 | json_object_free(json_af); | |
11744 | ||
772270f3 QY |
11745 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11746 | p->host, afi, safi); | |
d62a17ae | 11747 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11748 | NULL, afi, orf_pfx_name, use_json); | |
11749 | ||
11750 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11751 | PEER_STATUS_ORF_PREFIX_SEND) | |
11752 | || orf_pfx_count) { | |
11753 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11754 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11755 | json_object_boolean_true_add(json_neigh, | |
11756 | "orfSent"); | |
11757 | if (orf_pfx_count) | |
11758 | json_object_int_add(json_addr, "orfRecvCounter", | |
11759 | orf_pfx_count); | |
11760 | } | |
11761 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11762 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11763 | json_object_string_add( | |
11764 | json_addr, "orfFirstUpdate", | |
11765 | "deferredUntilORFOrRouteRefreshRecvd"); | |
11766 | ||
11767 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11768 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11769 | json_object_boolean_true_add(json_addr, | |
11770 | "routeReflectorClient"); | |
11771 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11772 | PEER_FLAG_RSERVER_CLIENT)) | |
11773 | json_object_boolean_true_add(json_addr, | |
11774 | "routeServerClient"); | |
11775 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11776 | json_object_boolean_true_add(json_addr, | |
11777 | "inboundSoftConfigPermit"); | |
11778 | ||
11779 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11780 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11781 | json_object_boolean_true_add( | |
11782 | json_addr, | |
11783 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
11784 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11785 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11786 | json_object_boolean_true_add( | |
11787 | json_addr, | |
11788 | "privateAsNumsReplacedInUpdatesToNbr"); | |
11789 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11790 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11791 | json_object_boolean_true_add( | |
11792 | json_addr, | |
11793 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
11794 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11795 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11796 | json_object_boolean_true_add( | |
11797 | json_addr, | |
11798 | "privateAsNumsRemovedInUpdatesToNbr"); | |
11799 | ||
dcc68b5e MS |
11800 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11801 | json_object_boolean_true_add( | |
11802 | json_addr, | |
11803 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11804 | ->type_json_name); | |
d62a17ae | 11805 | |
11806 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11807 | json_object_string_add(json_addr, | |
11808 | "overrideASNsInOutboundUpdates", | |
11809 | "ifAspathEqualRemoteAs"); | |
11810 | ||
11811 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11812 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11813 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11814 | json_object_boolean_true_add(json_addr, | |
11815 | "routerAlwaysNextHop"); | |
11816 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11817 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11818 | json_object_boolean_true_add( | |
11819 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
11820 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11821 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11822 | json_object_boolean_true_add( | |
11823 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
11824 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11825 | json_object_boolean_true_add( | |
11826 | json_addr, "unchangedMedPropogatedToNbr"); | |
11827 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11828 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11829 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11830 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11831 | PEER_FLAG_SEND_COMMUNITY) | |
11832 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11833 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11834 | json_object_string_add(json_addr, | |
11835 | "commAttriSentToNbr", | |
11836 | "extendedAndStandard"); | |
11837 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11838 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11839 | json_object_string_add(json_addr, | |
11840 | "commAttriSentToNbr", | |
11841 | "extended"); | |
11842 | else | |
11843 | json_object_string_add(json_addr, | |
11844 | "commAttriSentToNbr", | |
11845 | "standard"); | |
11846 | } | |
11847 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11848 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11849 | if (p->default_rmap[afi][safi].name) | |
11850 | json_object_string_add( | |
11851 | json_addr, "defaultRouteMap", | |
11852 | p->default_rmap[afi][safi].name); | |
11853 | ||
11854 | if (paf && PAF_SUBGRP(paf) | |
11855 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11856 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11857 | json_object_boolean_true_add(json_addr, | |
11858 | "defaultSent"); | |
11859 | else | |
11860 | json_object_boolean_true_add(json_addr, | |
11861 | "defaultNotSent"); | |
11862 | } | |
11863 | ||
dff8f48d | 11864 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 11865 | if (is_evpn_enabled()) |
60466a63 QY |
11866 | json_object_boolean_true_add( |
11867 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
11868 | } |
11869 | ||
d62a17ae | 11870 | if (filter->plist[FILTER_IN].name |
11871 | || filter->dlist[FILTER_IN].name | |
11872 | || filter->aslist[FILTER_IN].name | |
11873 | || filter->map[RMAP_IN].name) | |
11874 | json_object_boolean_true_add(json_addr, | |
11875 | "inboundPathPolicyConfig"); | |
11876 | if (filter->plist[FILTER_OUT].name | |
11877 | || filter->dlist[FILTER_OUT].name | |
11878 | || filter->aslist[FILTER_OUT].name | |
11879 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11880 | json_object_boolean_true_add( | |
11881 | json_addr, "outboundPathPolicyConfig"); | |
11882 | ||
11883 | /* prefix-list */ | |
11884 | if (filter->plist[FILTER_IN].name) | |
11885 | json_object_string_add(json_addr, | |
11886 | "incomingUpdatePrefixFilterList", | |
11887 | filter->plist[FILTER_IN].name); | |
11888 | if (filter->plist[FILTER_OUT].name) | |
11889 | json_object_string_add(json_addr, | |
11890 | "outgoingUpdatePrefixFilterList", | |
11891 | filter->plist[FILTER_OUT].name); | |
11892 | ||
11893 | /* distribute-list */ | |
11894 | if (filter->dlist[FILTER_IN].name) | |
11895 | json_object_string_add( | |
11896 | json_addr, "incomingUpdateNetworkFilterList", | |
11897 | filter->dlist[FILTER_IN].name); | |
11898 | if (filter->dlist[FILTER_OUT].name) | |
11899 | json_object_string_add( | |
11900 | json_addr, "outgoingUpdateNetworkFilterList", | |
11901 | filter->dlist[FILTER_OUT].name); | |
11902 | ||
11903 | /* filter-list. */ | |
11904 | if (filter->aslist[FILTER_IN].name) | |
11905 | json_object_string_add(json_addr, | |
11906 | "incomingUpdateAsPathFilterList", | |
11907 | filter->aslist[FILTER_IN].name); | |
11908 | if (filter->aslist[FILTER_OUT].name) | |
11909 | json_object_string_add(json_addr, | |
11910 | "outgoingUpdateAsPathFilterList", | |
11911 | filter->aslist[FILTER_OUT].name); | |
11912 | ||
11913 | /* route-map. */ | |
11914 | if (filter->map[RMAP_IN].name) | |
11915 | json_object_string_add( | |
11916 | json_addr, "routeMapForIncomingAdvertisements", | |
11917 | filter->map[RMAP_IN].name); | |
11918 | if (filter->map[RMAP_OUT].name) | |
11919 | json_object_string_add( | |
11920 | json_addr, "routeMapForOutgoingAdvertisements", | |
11921 | filter->map[RMAP_OUT].name); | |
11922 | ||
9dac9fc8 | 11923 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11924 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11925 | && !bgp_inbound_policy_exists(p, filter)) |
11926 | json_object_string_add( | |
11927 | json_addr, "inboundEbgpRequiresPolicy", | |
11928 | "Inbound updates discarded due to missing policy"); | |
11929 | ||
11930 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11931 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11932 | && (!bgp_outbound_policy_exists(p, filter))) |
11933 | json_object_string_add( | |
11934 | json_addr, "outboundEbgpRequiresPolicy", | |
11935 | "Outbound updates discarded due to missing policy"); | |
11936 | ||
d62a17ae | 11937 | /* unsuppress-map */ |
11938 | if (filter->usmap.name) | |
11939 | json_object_string_add(json_addr, | |
11940 | "selectiveUnsuppressRouteMap", | |
11941 | filter->usmap.name); | |
11942 | ||
fa36596c MK |
11943 | /* advertise-map */ |
11944 | if (filter->advmap.aname) { | |
11945 | json_advmap = json_object_new_object(); | |
11946 | json_object_string_add(json_advmap, "condition", | |
11947 | filter->advmap.condition | |
11948 | ? "EXIST" | |
11949 | : "NON_EXIST"); | |
11950 | json_object_string_add(json_advmap, "conditionMap", | |
11951 | filter->advmap.cname); | |
11952 | json_object_string_add(json_advmap, "advertiseMap", | |
11953 | filter->advmap.aname); | |
11954 | json_object_string_add(json_advmap, "advertiseStatus", | |
11955 | filter->advmap.update_type | |
11956 | == ADVERTISE | |
11957 | ? "Advertise" | |
11958 | : "Withdraw"); | |
11959 | json_object_object_add(json_addr, "advertiseMap", | |
11960 | json_advmap); | |
11961 | } | |
11962 | ||
d62a17ae | 11963 | /* Receive prefix count */ |
11964 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11965 | p->pcount[afi][safi]); | |
50e05855 AD |
11966 | if (paf && PAF_SUBGRP(paf)) |
11967 | json_object_int_add(json_addr, "sentPrefixCounter", | |
11968 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 11969 | |
fde246e8 DA |
11970 | /* Maximum prefix */ |
11971 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
11972 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
11973 | p->pmax_out[afi][safi]); | |
11974 | ||
d62a17ae | 11975 | /* Maximum prefix */ |
11976 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
11977 | json_object_int_add(json_addr, "prefixAllowedMax", | |
11978 | p->pmax[afi][safi]); | |
11979 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11980 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
11981 | json_object_boolean_true_add( | |
11982 | json_addr, "prefixAllowedMaxWarning"); | |
11983 | json_object_int_add(json_addr, | |
11984 | "prefixAllowedWarningThresh", | |
11985 | p->pmax_threshold[afi][safi]); | |
11986 | if (p->pmax_restart[afi][safi]) | |
11987 | json_object_int_add( | |
11988 | json_addr, | |
11989 | "prefixAllowedRestartIntervalMsecs", | |
11990 | p->pmax_restart[afi][safi] * 60000); | |
11991 | } | |
2986cac2 | 11992 | json_object_object_add(json_neigh, |
36235319 | 11993 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 11994 | json_addr); |
11995 | ||
11996 | } else { | |
11997 | filter = &p->filter[afi][safi]; | |
11998 | ||
11999 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12000 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12001 | |
12002 | if (peer_group_active(p)) | |
12003 | vty_out(vty, " %s peer-group member\n", | |
12004 | p->group->name); | |
12005 | ||
12006 | paf = peer_af_find(p, afi, safi); | |
12007 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12008 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12009 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12010 | vty_out(vty, " Packet Queue length %d\n", | |
12011 | bpacket_queue_virtual_length(paf)); | |
12012 | } else { | |
12013 | vty_out(vty, " Not part of any update group\n"); | |
12014 | } | |
12015 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12016 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12017 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12018 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12019 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12020 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12021 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12022 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12023 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12024 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12025 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12026 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12027 | ||
12028 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12029 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12030 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12031 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12032 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12033 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12034 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12035 | vty_out(vty, | |
12036 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12037 | ORF_TYPE_PREFIX); | |
12038 | bgp_show_peer_afi_orf_cap( | |
12039 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12040 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12041 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12042 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12043 | } | |
12044 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12045 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12046 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12047 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12048 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12049 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12050 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12051 | vty_out(vty, | |
12052 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12053 | ORF_TYPE_PREFIX_OLD); | |
12054 | bgp_show_peer_afi_orf_cap( | |
12055 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12056 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12057 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12058 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12059 | } | |
12060 | ||
772270f3 QY |
12061 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12062 | p->host, afi, safi); | |
d62a17ae | 12063 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12064 | NULL, afi, orf_pfx_name, use_json); | |
12065 | ||
12066 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12067 | PEER_STATUS_ORF_PREFIX_SEND) | |
12068 | || orf_pfx_count) { | |
12069 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12070 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12071 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12072 | vty_out(vty, " sent;"); | |
12073 | if (orf_pfx_count) | |
12074 | vty_out(vty, " received (%d entries)", | |
12075 | orf_pfx_count); | |
12076 | vty_out(vty, "\n"); | |
12077 | } | |
12078 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12079 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12080 | vty_out(vty, | |
12081 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12082 | ||
12083 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12084 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12085 | vty_out(vty, " Route-Reflector Client\n"); | |
12086 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12087 | PEER_FLAG_RSERVER_CLIENT)) | |
12088 | vty_out(vty, " Route-Server Client\n"); | |
12089 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12090 | vty_out(vty, | |
12091 | " Inbound soft reconfiguration allowed\n"); | |
12092 | ||
12093 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12094 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12095 | vty_out(vty, | |
12096 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12097 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12098 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12099 | vty_out(vty, | |
12100 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12101 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12102 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12103 | vty_out(vty, | |
12104 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12105 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12106 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12107 | vty_out(vty, | |
12108 | " Private AS numbers removed in updates to this neighbor\n"); | |
12109 | ||
dcc68b5e MS |
12110 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12111 | vty_out(vty, " %s\n", | |
12112 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12113 | ->human_description); | |
d62a17ae | 12114 | |
12115 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12116 | vty_out(vty, | |
12117 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12118 | ||
12119 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12120 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12121 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12122 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12123 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12124 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12125 | vty_out(vty, | |
12126 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12127 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12128 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12129 | vty_out(vty, | |
12130 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12131 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12132 | vty_out(vty, | |
12133 | " MED is propagated unchanged to this neighbor\n"); | |
12134 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12135 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12136 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12137 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12138 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12139 | vty_out(vty, | |
12140 | " Community attribute sent to this neighbor"); | |
12141 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12142 | PEER_FLAG_SEND_COMMUNITY) | |
12143 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12144 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12145 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12146 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12147 | vty_out(vty, "(all)\n"); | |
12148 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12149 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12150 | vty_out(vty, "(large)\n"); | |
12151 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12152 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12153 | vty_out(vty, "(extended)\n"); | |
12154 | else | |
12155 | vty_out(vty, "(standard)\n"); | |
12156 | } | |
12157 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12158 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12159 | vty_out(vty, " Default information originate,"); | |
12160 | ||
12161 | if (p->default_rmap[afi][safi].name) | |
12162 | vty_out(vty, " default route-map %s%s,", | |
12163 | p->default_rmap[afi][safi].map ? "*" | |
12164 | : "", | |
12165 | p->default_rmap[afi][safi].name); | |
12166 | if (paf && PAF_SUBGRP(paf) | |
12167 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12168 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12169 | vty_out(vty, " default sent\n"); | |
12170 | else | |
12171 | vty_out(vty, " default not sent\n"); | |
12172 | } | |
12173 | ||
dff8f48d MK |
12174 | /* advertise-vni-all */ |
12175 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12176 | if (is_evpn_enabled()) |
dff8f48d MK |
12177 | vty_out(vty, " advertise-all-vni\n"); |
12178 | } | |
12179 | ||
d62a17ae | 12180 | if (filter->plist[FILTER_IN].name |
12181 | || filter->dlist[FILTER_IN].name | |
12182 | || filter->aslist[FILTER_IN].name | |
12183 | || filter->map[RMAP_IN].name) | |
12184 | vty_out(vty, " Inbound path policy configured\n"); | |
12185 | if (filter->plist[FILTER_OUT].name | |
12186 | || filter->dlist[FILTER_OUT].name | |
12187 | || filter->aslist[FILTER_OUT].name | |
12188 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12189 | vty_out(vty, " Outbound path policy configured\n"); | |
12190 | ||
12191 | /* prefix-list */ | |
12192 | if (filter->plist[FILTER_IN].name) | |
12193 | vty_out(vty, | |
12194 | " Incoming update prefix filter list is %s%s\n", | |
12195 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12196 | filter->plist[FILTER_IN].name); | |
12197 | if (filter->plist[FILTER_OUT].name) | |
12198 | vty_out(vty, | |
12199 | " Outgoing update prefix filter list is %s%s\n", | |
12200 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12201 | filter->plist[FILTER_OUT].name); | |
12202 | ||
12203 | /* distribute-list */ | |
12204 | if (filter->dlist[FILTER_IN].name) | |
12205 | vty_out(vty, | |
12206 | " Incoming update network filter list is %s%s\n", | |
12207 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12208 | filter->dlist[FILTER_IN].name); | |
12209 | if (filter->dlist[FILTER_OUT].name) | |
12210 | vty_out(vty, | |
12211 | " Outgoing update network filter list is %s%s\n", | |
12212 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12213 | filter->dlist[FILTER_OUT].name); | |
12214 | ||
12215 | /* filter-list. */ | |
12216 | if (filter->aslist[FILTER_IN].name) | |
12217 | vty_out(vty, | |
12218 | " Incoming update AS path filter list is %s%s\n", | |
12219 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12220 | filter->aslist[FILTER_IN].name); | |
12221 | if (filter->aslist[FILTER_OUT].name) | |
12222 | vty_out(vty, | |
12223 | " Outgoing update AS path filter list is %s%s\n", | |
12224 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12225 | filter->aslist[FILTER_OUT].name); | |
12226 | ||
12227 | /* route-map. */ | |
12228 | if (filter->map[RMAP_IN].name) | |
12229 | vty_out(vty, | |
12230 | " Route map for incoming advertisements is %s%s\n", | |
12231 | filter->map[RMAP_IN].map ? "*" : "", | |
12232 | filter->map[RMAP_IN].name); | |
12233 | if (filter->map[RMAP_OUT].name) | |
12234 | vty_out(vty, | |
12235 | " Route map for outgoing advertisements is %s%s\n", | |
12236 | filter->map[RMAP_OUT].map ? "*" : "", | |
12237 | filter->map[RMAP_OUT].name); | |
12238 | ||
9dac9fc8 | 12239 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12240 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12241 | && !bgp_inbound_policy_exists(p, filter)) |
12242 | vty_out(vty, | |
12243 | " Inbound updates discarded due to missing policy\n"); | |
12244 | ||
12245 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12246 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12247 | && !bgp_outbound_policy_exists(p, filter)) |
12248 | vty_out(vty, | |
12249 | " Outbound updates discarded due to missing policy\n"); | |
12250 | ||
d62a17ae | 12251 | /* unsuppress-map */ |
12252 | if (filter->usmap.name) | |
12253 | vty_out(vty, | |
12254 | " Route map for selective unsuppress is %s%s\n", | |
12255 | filter->usmap.map ? "*" : "", | |
12256 | filter->usmap.name); | |
12257 | ||
7f7940e6 MK |
12258 | /* advertise-map */ |
12259 | if (filter->advmap.aname && filter->advmap.cname) | |
12260 | vty_out(vty, | |
12261 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12262 | filter->advmap.condition ? "EXIST" | |
12263 | : "NON_EXIST", | |
12264 | filter->advmap.cmap ? "*" : "", | |
12265 | filter->advmap.cname, | |
12266 | filter->advmap.amap ? "*" : "", | |
12267 | filter->advmap.aname, | |
fa36596c | 12268 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
12269 | ? "Advertise" |
12270 | : "Withdraw"); | |
7f7940e6 | 12271 | |
d62a17ae | 12272 | /* Receive prefix count */ |
6cde4b45 | 12273 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12274 | p->pcount[afi][safi]); |
d62a17ae | 12275 | |
fde246e8 DA |
12276 | /* maximum-prefix-out */ |
12277 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12278 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12279 | vty_out(vty, | |
6cde4b45 | 12280 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12281 | p->pmax_out[afi][safi]); |
12282 | ||
d62a17ae | 12283 | /* Maximum prefix */ |
12284 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12285 | vty_out(vty, |
6cde4b45 | 12286 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12287 | p->pmax[afi][safi], |
12288 | CHECK_FLAG(p->af_flags[afi][safi], | |
12289 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12290 | ? " (warning-only)" | |
12291 | : ""); | |
12292 | vty_out(vty, " Threshold for warning message %d%%", | |
12293 | p->pmax_threshold[afi][safi]); | |
12294 | if (p->pmax_restart[afi][safi]) | |
12295 | vty_out(vty, ", restart interval %d min", | |
12296 | p->pmax_restart[afi][safi]); | |
12297 | vty_out(vty, "\n"); | |
12298 | } | |
12299 | ||
12300 | vty_out(vty, "\n"); | |
12301 | } | |
12302 | } | |
12303 | ||
9f049418 | 12304 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12305 | json_object *json) |
718e3744 | 12306 | { |
d62a17ae | 12307 | struct bgp *bgp; |
12308 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12309 | char timebuf[BGP_UPTIME_LEN]; | |
12310 | char dn_flag[2]; | |
d62a17ae | 12311 | afi_t afi; |
12312 | safi_t safi; | |
d7c0a89a QY |
12313 | uint16_t i; |
12314 | uint8_t *msg; | |
d62a17ae | 12315 | json_object *json_neigh = NULL; |
12316 | time_t epoch_tbuf; | |
718e3744 | 12317 | |
d62a17ae | 12318 | bgp = p->bgp; |
12319 | ||
12320 | if (use_json) | |
12321 | json_neigh = json_object_new_object(); | |
12322 | ||
12323 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12324 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12325 | dn_flag[0] = '*'; | |
12326 | ||
12327 | if (!use_json) { | |
12328 | if (p->conf_if) /* Configured interface name. */ | |
12329 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12330 | BGP_PEER_SU_UNSPEC(p) | |
12331 | ? "None" | |
12332 | : sockunion2str(&p->su, buf, | |
12333 | SU_ADDRSTRLEN)); | |
12334 | else /* Configured IP address. */ | |
12335 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12336 | p->host); | |
12337 | } | |
12338 | ||
12339 | if (use_json) { | |
12340 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12341 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12342 | "none"); | |
12343 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12344 | json_object_string_add( | |
12345 | json_neigh, "bgpNeighborAddr", | |
12346 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12347 | ||
12348 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12349 | ||
12350 | if (p->change_local_as) | |
12351 | json_object_int_add(json_neigh, "localAs", | |
12352 | p->change_local_as); | |
12353 | else | |
12354 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12355 | ||
12356 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12357 | json_object_boolean_true_add(json_neigh, | |
12358 | "localAsNoPrepend"); | |
12359 | ||
12360 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12361 | json_object_boolean_true_add(json_neigh, | |
12362 | "localAsReplaceAs"); | |
12363 | } else { | |
12364 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12365 | || (p->as_type == AS_INTERNAL)) | |
12366 | vty_out(vty, "remote AS %u, ", p->as); | |
12367 | else | |
12368 | vty_out(vty, "remote AS Unspecified, "); | |
12369 | vty_out(vty, "local AS %u%s%s, ", | |
12370 | p->change_local_as ? p->change_local_as : p->local_as, | |
12371 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12372 | ? " no-prepend" | |
12373 | : "", | |
12374 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12375 | ? " replace-as" | |
12376 | : ""); | |
12377 | } | |
faa16034 DS |
12378 | /* peer type internal or confed-internal */ |
12379 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12380 | if (use_json) { |
12381 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12382 | json_object_boolean_true_add( | |
12383 | json_neigh, "nbrConfedInternalLink"); | |
12384 | else | |
12385 | json_object_boolean_true_add(json_neigh, | |
12386 | "nbrInternalLink"); | |
12387 | } else { | |
12388 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12389 | vty_out(vty, "confed-internal link\n"); | |
12390 | else | |
12391 | vty_out(vty, "internal link\n"); | |
12392 | } | |
faa16034 DS |
12393 | /* peer type external or confed-external */ |
12394 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12395 | if (use_json) { |
12396 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12397 | json_object_boolean_true_add( | |
12398 | json_neigh, "nbrConfedExternalLink"); | |
12399 | else | |
12400 | json_object_boolean_true_add(json_neigh, | |
12401 | "nbrExternalLink"); | |
12402 | } else { | |
12403 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12404 | vty_out(vty, "confed-external link\n"); | |
12405 | else | |
12406 | vty_out(vty, "external link\n"); | |
12407 | } | |
faa16034 DS |
12408 | } else { |
12409 | if (use_json) | |
12410 | json_object_boolean_true_add(json_neigh, | |
12411 | "nbrUnspecifiedLink"); | |
12412 | else | |
12413 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12414 | } |
12415 | ||
12416 | /* Description. */ | |
12417 | if (p->desc) { | |
12418 | if (use_json) | |
12419 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12420 | else | |
12421 | vty_out(vty, " Description: %s\n", p->desc); | |
12422 | } | |
12423 | ||
12424 | if (p->hostname) { | |
12425 | if (use_json) { | |
12426 | if (p->hostname) | |
12427 | json_object_string_add(json_neigh, "hostname", | |
12428 | p->hostname); | |
12429 | ||
12430 | if (p->domainname) | |
12431 | json_object_string_add(json_neigh, "domainname", | |
12432 | p->domainname); | |
12433 | } else { | |
12434 | if (p->domainname && (p->domainname[0] != '\0')) | |
12435 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12436 | p->domainname); | |
12437 | else | |
12438 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12439 | } | |
12440 | } | |
12441 | ||
12442 | /* Peer-group */ | |
12443 | if (p->group) { | |
12444 | if (use_json) { | |
12445 | json_object_string_add(json_neigh, "peerGroup", | |
12446 | p->group->name); | |
12447 | ||
12448 | if (dn_flag[0]) { | |
12449 | struct prefix prefix, *range = NULL; | |
12450 | ||
12451 | sockunion2hostprefix(&(p->su), &prefix); | |
12452 | range = peer_group_lookup_dynamic_neighbor_range( | |
12453 | p->group, &prefix); | |
12454 | ||
12455 | if (range) { | |
12456 | prefix2str(range, buf1, sizeof(buf1)); | |
12457 | json_object_string_add( | |
12458 | json_neigh, | |
12459 | "peerSubnetRangeGroup", buf1); | |
12460 | } | |
12461 | } | |
12462 | } else { | |
12463 | vty_out(vty, | |
12464 | " Member of peer-group %s for session parameters\n", | |
12465 | p->group->name); | |
12466 | ||
12467 | if (dn_flag[0]) { | |
12468 | struct prefix prefix, *range = NULL; | |
12469 | ||
12470 | sockunion2hostprefix(&(p->su), &prefix); | |
12471 | range = peer_group_lookup_dynamic_neighbor_range( | |
12472 | p->group, &prefix); | |
12473 | ||
12474 | if (range) { | |
d62a17ae | 12475 | vty_out(vty, |
1b78780b DL |
12476 | " Belongs to the subnet range group: %pFX\n", |
12477 | range); | |
d62a17ae | 12478 | } |
12479 | } | |
12480 | } | |
12481 | } | |
12482 | ||
12483 | if (use_json) { | |
12484 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12485 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12486 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12487 | json_object_boolean_true_add(json_neigh, |
12488 | "adminShutDown"); | |
12489 | ||
12490 | /* BGP Version. */ | |
12491 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
12492 | json_object_string_add( | |
12493 | json_neigh, "remoteRouterId", | |
12494 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
12495 | json_object_string_add( |
12496 | json_neigh, "localRouterId", | |
12497 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12498 | sizeof(buf1))); | |
d62a17ae | 12499 | |
12500 | /* Confederation */ | |
12501 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12502 | && bgp_confederation_peers_check(bgp, p->as)) | |
12503 | json_object_boolean_true_add(json_neigh, | |
12504 | "nbrCommonAdmin"); | |
12505 | ||
12506 | /* Status. */ | |
12507 | json_object_string_add( | |
12508 | json_neigh, "bgpState", | |
12509 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12510 | ||
12511 | if (p->status == Established) { | |
12512 | time_t uptime; | |
d62a17ae | 12513 | |
12514 | uptime = bgp_clock(); | |
12515 | uptime -= p->uptime; | |
d62a17ae | 12516 | epoch_tbuf = time(NULL) - uptime; |
12517 | ||
d3c7efed DS |
12518 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
12519 | uptime * 1000); | |
d62a17ae | 12520 | json_object_string_add(json_neigh, "bgpTimerUpString", |
12521 | peer_uptime(p->uptime, timebuf, | |
12522 | BGP_UPTIME_LEN, 0, | |
12523 | NULL)); | |
12524 | json_object_int_add(json_neigh, | |
12525 | "bgpTimerUpEstablishedEpoch", | |
12526 | epoch_tbuf); | |
12527 | } | |
12528 | ||
12529 | else if (p->status == Active) { | |
12530 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12531 | json_object_string_add(json_neigh, "bgpStateIs", | |
12532 | "passive"); | |
12533 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12534 | json_object_string_add(json_neigh, "bgpStateIs", | |
12535 | "passiveNSF"); | |
12536 | } | |
12537 | ||
12538 | /* read timer */ | |
12539 | time_t uptime; | |
a2700b50 | 12540 | struct tm tm; |
d62a17ae | 12541 | |
12542 | uptime = bgp_clock(); | |
12543 | uptime -= p->readtime; | |
a2700b50 MS |
12544 | gmtime_r(&uptime, &tm); |
12545 | ||
d62a17ae | 12546 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
12547 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12548 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12549 | |
12550 | uptime = bgp_clock(); | |
12551 | uptime -= p->last_write; | |
a2700b50 MS |
12552 | gmtime_r(&uptime, &tm); |
12553 | ||
d62a17ae | 12554 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
12555 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12556 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12557 | |
12558 | uptime = bgp_clock(); | |
12559 | uptime -= p->update_time; | |
a2700b50 MS |
12560 | gmtime_r(&uptime, &tm); |
12561 | ||
d62a17ae | 12562 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
12563 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12564 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12565 | |
12566 | /* Configured timer values. */ | |
12567 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12568 | p->v_holdtime * 1000); | |
12569 | json_object_int_add(json_neigh, | |
12570 | "bgpTimerKeepAliveIntervalMsecs", | |
12571 | p->v_keepalive * 1000); | |
b90a8e13 | 12572 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12573 | json_object_int_add(json_neigh, |
12574 | "bgpTimerConfiguredHoldTimeMsecs", | |
12575 | p->holdtime * 1000); | |
12576 | json_object_int_add( | |
12577 | json_neigh, | |
12578 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12579 | p->keepalive * 1000); | |
5d5393b9 DL |
12580 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12581 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12582 | json_object_int_add(json_neigh, |
12583 | "bgpTimerConfiguredHoldTimeMsecs", | |
12584 | bgp->default_holdtime); | |
12585 | json_object_int_add( | |
12586 | json_neigh, | |
12587 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12588 | bgp->default_keepalive); | |
d62a17ae | 12589 | } |
12590 | } else { | |
12591 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12592 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12593 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12594 | vty_out(vty, " Administratively shut down\n"); |
12595 | ||
12596 | /* BGP Version. */ | |
12597 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 12598 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 12599 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
12600 | vty_out(vty, ", local router ID %s\n", |
12601 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12602 | sizeof(buf1))); | |
d62a17ae | 12603 | |
12604 | /* Confederation */ | |
12605 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12606 | && bgp_confederation_peers_check(bgp, p->as)) | |
12607 | vty_out(vty, | |
12608 | " Neighbor under common administration\n"); | |
12609 | ||
12610 | /* Status. */ | |
12611 | vty_out(vty, " BGP state = %s", | |
12612 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12613 | ||
12614 | if (p->status == Established) | |
12615 | vty_out(vty, ", up for %8s", | |
12616 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12617 | 0, NULL)); | |
12618 | ||
12619 | else if (p->status == Active) { | |
12620 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12621 | vty_out(vty, " (passive)"); | |
12622 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12623 | vty_out(vty, " (NSF passive)"); | |
12624 | } | |
12625 | vty_out(vty, "\n"); | |
12626 | ||
12627 | /* read timer */ | |
12628 | vty_out(vty, " Last read %s", | |
12629 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12630 | NULL)); | |
12631 | vty_out(vty, ", Last write %s\n", | |
12632 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12633 | NULL)); | |
12634 | ||
12635 | /* Configured timer values. */ | |
12636 | vty_out(vty, | |
12637 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12638 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 12639 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12640 | vty_out(vty, " Configured hold time is %d", |
12641 | p->holdtime); | |
12642 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12643 | p->keepalive); | |
5d5393b9 DL |
12644 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12645 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12646 | vty_out(vty, " Configured hold time is %d", |
12647 | bgp->default_holdtime); | |
12648 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12649 | bgp->default_keepalive); | |
d62a17ae | 12650 | } |
12651 | } | |
12652 | /* Capability. */ | |
12653 | if (p->status == Established) { | |
12654 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
12655 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
12656 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
12657 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
12658 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
12659 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
12660 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
12661 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
12662 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
12663 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
12664 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
12665 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 12666 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
12667 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 12668 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
12669 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 12670 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
12671 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 12672 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
12673 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
12674 | if (use_json) { | |
12675 | json_object *json_cap = NULL; | |
12676 | ||
12677 | json_cap = json_object_new_object(); | |
12678 | ||
12679 | /* AS4 */ | |
12680 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
12681 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12682 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
12683 | && CHECK_FLAG(p->cap, | |
12684 | PEER_CAP_AS4_RCV)) | |
12685 | json_object_string_add( | |
12686 | json_cap, "4byteAs", | |
12687 | "advertisedAndReceived"); | |
12688 | else if (CHECK_FLAG(p->cap, | |
12689 | PEER_CAP_AS4_ADV)) | |
12690 | json_object_string_add( | |
12691 | json_cap, "4byteAs", | |
12692 | "advertised"); | |
12693 | else if (CHECK_FLAG(p->cap, | |
12694 | PEER_CAP_AS4_RCV)) | |
12695 | json_object_string_add( | |
12696 | json_cap, "4byteAs", | |
12697 | "received"); | |
12698 | } | |
12699 | ||
12700 | /* AddPath */ | |
12701 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
12702 | || CHECK_FLAG(p->cap, | |
12703 | PEER_CAP_ADDPATH_ADV)) { | |
12704 | json_object *json_add = NULL; | |
12705 | const char *print_store; | |
12706 | ||
12707 | json_add = json_object_new_object(); | |
12708 | ||
05c7a1cc QY |
12709 | FOREACH_AFI_SAFI (afi, safi) { |
12710 | json_object *json_sub = NULL; | |
12711 | json_sub = | |
12712 | json_object_new_object(); | |
5cb5f4d0 DD |
12713 | print_store = get_afi_safi_str( |
12714 | afi, safi, true); | |
d62a17ae | 12715 | |
05c7a1cc QY |
12716 | if (CHECK_FLAG( |
12717 | p->af_cap[afi] | |
12718 | [safi], | |
12719 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12720 | || CHECK_FLAG( | |
12721 | p->af_cap[afi] | |
12722 | [safi], | |
12723 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 12724 | if (CHECK_FLAG( |
12725 | p->af_cap | |
12726 | [afi] | |
12727 | [safi], | |
12728 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 12729 | && CHECK_FLAG( |
d62a17ae | 12730 | p->af_cap |
12731 | [afi] | |
12732 | [safi], | |
05c7a1cc QY |
12733 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
12734 | json_object_boolean_true_add( | |
12735 | json_sub, | |
12736 | "txAdvertisedAndReceived"); | |
12737 | else if ( | |
12738 | CHECK_FLAG( | |
12739 | p->af_cap | |
12740 | [afi] | |
12741 | [safi], | |
12742 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
12743 | json_object_boolean_true_add( | |
12744 | json_sub, | |
12745 | "txAdvertised"); | |
12746 | else if ( | |
12747 | CHECK_FLAG( | |
12748 | p->af_cap | |
12749 | [afi] | |
12750 | [safi], | |
12751 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12752 | json_object_boolean_true_add( | |
12753 | json_sub, | |
12754 | "txReceived"); | |
12755 | } | |
d62a17ae | 12756 | |
05c7a1cc QY |
12757 | if (CHECK_FLAG( |
12758 | p->af_cap[afi] | |
12759 | [safi], | |
12760 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12761 | || CHECK_FLAG( | |
12762 | p->af_cap[afi] | |
12763 | [safi], | |
12764 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 12765 | if (CHECK_FLAG( |
12766 | p->af_cap | |
12767 | [afi] | |
12768 | [safi], | |
12769 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 12770 | && CHECK_FLAG( |
d62a17ae | 12771 | p->af_cap |
12772 | [afi] | |
12773 | [safi], | |
12774 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
12775 | json_object_boolean_true_add( |
12776 | json_sub, | |
12777 | "rxAdvertisedAndReceived"); | |
12778 | else if ( | |
12779 | CHECK_FLAG( | |
12780 | p->af_cap | |
12781 | [afi] | |
12782 | [safi], | |
12783 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
12784 | json_object_boolean_true_add( | |
12785 | json_sub, | |
12786 | "rxAdvertised"); | |
12787 | else if ( | |
12788 | CHECK_FLAG( | |
12789 | p->af_cap | |
12790 | [afi] | |
12791 | [safi], | |
12792 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12793 | json_object_boolean_true_add( | |
12794 | json_sub, | |
12795 | "rxReceived"); | |
d62a17ae | 12796 | } |
12797 | ||
05c7a1cc QY |
12798 | if (CHECK_FLAG( |
12799 | p->af_cap[afi] | |
12800 | [safi], | |
12801 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12802 | || CHECK_FLAG( | |
12803 | p->af_cap[afi] | |
12804 | [safi], | |
12805 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
12806 | || CHECK_FLAG( | |
12807 | p->af_cap[afi] | |
12808 | [safi], | |
12809 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12810 | || CHECK_FLAG( | |
12811 | p->af_cap[afi] | |
12812 | [safi], | |
12813 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12814 | json_object_object_add( | |
12815 | json_add, | |
12816 | print_store, | |
12817 | json_sub); | |
12818 | else | |
12819 | json_object_free( | |
12820 | json_sub); | |
12821 | } | |
12822 | ||
d62a17ae | 12823 | json_object_object_add( |
12824 | json_cap, "addPath", json_add); | |
12825 | } | |
12826 | ||
12827 | /* Dynamic */ | |
12828 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
12829 | || CHECK_FLAG(p->cap, | |
12830 | PEER_CAP_DYNAMIC_ADV)) { | |
12831 | if (CHECK_FLAG(p->cap, | |
12832 | PEER_CAP_DYNAMIC_ADV) | |
12833 | && CHECK_FLAG(p->cap, | |
12834 | PEER_CAP_DYNAMIC_RCV)) | |
12835 | json_object_string_add( | |
12836 | json_cap, "dynamic", | |
12837 | "advertisedAndReceived"); | |
12838 | else if (CHECK_FLAG( | |
12839 | p->cap, | |
12840 | PEER_CAP_DYNAMIC_ADV)) | |
12841 | json_object_string_add( | |
12842 | json_cap, "dynamic", | |
12843 | "advertised"); | |
12844 | else if (CHECK_FLAG( | |
12845 | p->cap, | |
12846 | PEER_CAP_DYNAMIC_RCV)) | |
12847 | json_object_string_add( | |
12848 | json_cap, "dynamic", | |
12849 | "received"); | |
12850 | } | |
12851 | ||
12852 | /* Extended nexthop */ | |
12853 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
12854 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12855 | json_object *json_nxt = NULL; | |
12856 | const char *print_store; | |
12857 | ||
12858 | ||
12859 | if (CHECK_FLAG(p->cap, | |
12860 | PEER_CAP_ENHE_ADV) | |
12861 | && CHECK_FLAG(p->cap, | |
12862 | PEER_CAP_ENHE_RCV)) | |
12863 | json_object_string_add( | |
12864 | json_cap, | |
12865 | "extendedNexthop", | |
12866 | "advertisedAndReceived"); | |
12867 | else if (CHECK_FLAG(p->cap, | |
12868 | PEER_CAP_ENHE_ADV)) | |
12869 | json_object_string_add( | |
12870 | json_cap, | |
12871 | "extendedNexthop", | |
12872 | "advertised"); | |
12873 | else if (CHECK_FLAG(p->cap, | |
12874 | PEER_CAP_ENHE_RCV)) | |
12875 | json_object_string_add( | |
12876 | json_cap, | |
12877 | "extendedNexthop", | |
12878 | "received"); | |
12879 | ||
12880 | if (CHECK_FLAG(p->cap, | |
12881 | PEER_CAP_ENHE_RCV)) { | |
12882 | json_nxt = | |
12883 | json_object_new_object(); | |
12884 | ||
12885 | for (safi = SAFI_UNICAST; | |
12886 | safi < SAFI_MAX; safi++) { | |
12887 | if (CHECK_FLAG( | |
12888 | p->af_cap | |
12889 | [AFI_IP] | |
12890 | [safi], | |
12891 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 12892 | print_store = get_afi_safi_str( |
d62a17ae | 12893 | AFI_IP, |
5cb5f4d0 | 12894 | safi, true); |
d62a17ae | 12895 | json_object_string_add( |
12896 | json_nxt, | |
12897 | print_store, | |
54f29523 | 12898 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 12899 | } |
12900 | } | |
12901 | json_object_object_add( | |
12902 | json_cap, | |
12903 | "extendedNexthopFamililesByPeer", | |
12904 | json_nxt); | |
12905 | } | |
12906 | } | |
12907 | ||
12908 | /* Route Refresh */ | |
12909 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12910 | || CHECK_FLAG(p->cap, | |
12911 | PEER_CAP_REFRESH_NEW_RCV) | |
12912 | || CHECK_FLAG(p->cap, | |
12913 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12914 | if (CHECK_FLAG(p->cap, | |
12915 | PEER_CAP_REFRESH_ADV) | |
12916 | && (CHECK_FLAG( | |
12917 | p->cap, | |
12918 | PEER_CAP_REFRESH_NEW_RCV) | |
12919 | || CHECK_FLAG( | |
12920 | p->cap, | |
12921 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12922 | if (CHECK_FLAG( | |
12923 | p->cap, | |
12924 | PEER_CAP_REFRESH_OLD_RCV) | |
12925 | && CHECK_FLAG( | |
12926 | p->cap, | |
12927 | PEER_CAP_REFRESH_NEW_RCV)) | |
12928 | json_object_string_add( | |
12929 | json_cap, | |
12930 | "routeRefresh", | |
12931 | "advertisedAndReceivedOldNew"); | |
12932 | else { | |
12933 | if (CHECK_FLAG( | |
12934 | p->cap, | |
12935 | PEER_CAP_REFRESH_OLD_RCV)) | |
12936 | json_object_string_add( | |
12937 | json_cap, | |
12938 | "routeRefresh", | |
12939 | "advertisedAndReceivedOld"); | |
12940 | else | |
12941 | json_object_string_add( | |
12942 | json_cap, | |
12943 | "routeRefresh", | |
12944 | "advertisedAndReceivedNew"); | |
12945 | } | |
12946 | } else if ( | |
12947 | CHECK_FLAG( | |
12948 | p->cap, | |
12949 | PEER_CAP_REFRESH_ADV)) | |
12950 | json_object_string_add( | |
12951 | json_cap, | |
12952 | "routeRefresh", | |
12953 | "advertised"); | |
12954 | else if ( | |
12955 | CHECK_FLAG( | |
12956 | p->cap, | |
12957 | PEER_CAP_REFRESH_NEW_RCV) | |
12958 | || CHECK_FLAG( | |
12959 | p->cap, | |
12960 | PEER_CAP_REFRESH_OLD_RCV)) | |
12961 | json_object_string_add( | |
12962 | json_cap, | |
12963 | "routeRefresh", | |
12964 | "received"); | |
12965 | } | |
12966 | ||
12967 | /* Multiprotocol Extensions */ | |
12968 | json_object *json_multi = NULL; | |
12969 | json_multi = json_object_new_object(); | |
12970 | ||
05c7a1cc QY |
12971 | FOREACH_AFI_SAFI (afi, safi) { |
12972 | if (p->afc_adv[afi][safi] | |
12973 | || p->afc_recv[afi][safi]) { | |
12974 | json_object *json_exten = NULL; | |
12975 | json_exten = | |
12976 | json_object_new_object(); | |
12977 | ||
d62a17ae | 12978 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
12979 | && p->afc_recv[afi][safi]) |
12980 | json_object_boolean_true_add( | |
12981 | json_exten, | |
12982 | "advertisedAndReceived"); | |
12983 | else if (p->afc_adv[afi][safi]) | |
12984 | json_object_boolean_true_add( | |
12985 | json_exten, | |
12986 | "advertised"); | |
12987 | else if (p->afc_recv[afi][safi]) | |
12988 | json_object_boolean_true_add( | |
12989 | json_exten, | |
12990 | "received"); | |
d62a17ae | 12991 | |
05c7a1cc QY |
12992 | json_object_object_add( |
12993 | json_multi, | |
5cb5f4d0 DD |
12994 | get_afi_safi_str(afi, |
12995 | safi, | |
12996 | true), | |
05c7a1cc | 12997 | json_exten); |
d62a17ae | 12998 | } |
12999 | } | |
13000 | json_object_object_add( | |
13001 | json_cap, "multiprotocolExtensions", | |
13002 | json_multi); | |
13003 | ||
d77114b7 | 13004 | /* Hostname capabilities */ |
60466a63 | 13005 | json_object *json_hname = NULL; |
d77114b7 MK |
13006 | |
13007 | json_hname = json_object_new_object(); | |
13008 | ||
13009 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
13010 | json_object_string_add( | |
60466a63 QY |
13011 | json_hname, "advHostName", |
13012 | bgp->peer_self->hostname | |
13013 | ? bgp->peer_self | |
13014 | ->hostname | |
d77114b7 MK |
13015 | : "n/a"); |
13016 | json_object_string_add( | |
60466a63 QY |
13017 | json_hname, "advDomainName", |
13018 | bgp->peer_self->domainname | |
13019 | ? bgp->peer_self | |
13020 | ->domainname | |
d77114b7 MK |
13021 | : "n/a"); |
13022 | } | |
13023 | ||
13024 | ||
13025 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
13026 | json_object_string_add( | |
60466a63 QY |
13027 | json_hname, "rcvHostName", |
13028 | p->hostname ? p->hostname | |
13029 | : "n/a"); | |
d77114b7 | 13030 | json_object_string_add( |
60466a63 QY |
13031 | json_hname, "rcvDomainName", |
13032 | p->domainname ? p->domainname | |
13033 | : "n/a"); | |
d77114b7 MK |
13034 | } |
13035 | ||
60466a63 | 13036 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
13037 | json_hname); |
13038 | ||
d62a17ae | 13039 | /* Gracefull Restart */ |
13040 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
13041 | || CHECK_FLAG(p->cap, | |
13042 | PEER_CAP_RESTART_ADV)) { | |
13043 | if (CHECK_FLAG(p->cap, | |
13044 | PEER_CAP_RESTART_ADV) | |
13045 | && CHECK_FLAG(p->cap, | |
13046 | PEER_CAP_RESTART_RCV)) | |
13047 | json_object_string_add( | |
13048 | json_cap, | |
13049 | "gracefulRestart", | |
13050 | "advertisedAndReceived"); | |
13051 | else if (CHECK_FLAG( | |
13052 | p->cap, | |
13053 | PEER_CAP_RESTART_ADV)) | |
13054 | json_object_string_add( | |
13055 | json_cap, | |
13056 | "gracefulRestartCapability", | |
13057 | "advertised"); | |
13058 | else if (CHECK_FLAG( | |
13059 | p->cap, | |
13060 | PEER_CAP_RESTART_RCV)) | |
13061 | json_object_string_add( | |
13062 | json_cap, | |
13063 | "gracefulRestartCapability", | |
13064 | "received"); | |
13065 | ||
13066 | if (CHECK_FLAG(p->cap, | |
13067 | PEER_CAP_RESTART_RCV)) { | |
13068 | int restart_af_count = 0; | |
13069 | json_object *json_restart = | |
13070 | NULL; | |
13071 | json_restart = | |
13072 | json_object_new_object(); | |
13073 | ||
13074 | json_object_int_add( | |
13075 | json_cap, | |
13076 | "gracefulRestartRemoteTimerMsecs", | |
13077 | p->v_gr_restart * 1000); | |
13078 | ||
05c7a1cc QY |
13079 | FOREACH_AFI_SAFI (afi, safi) { |
13080 | if (CHECK_FLAG( | |
13081 | p->af_cap | |
13082 | [afi] | |
13083 | [safi], | |
13084 | PEER_CAP_RESTART_AF_RCV)) { | |
13085 | json_object * | |
13086 | json_sub = | |
13087 | NULL; | |
13088 | json_sub = | |
13089 | json_object_new_object(); | |
13090 | ||
d62a17ae | 13091 | if (CHECK_FLAG( |
13092 | p->af_cap | |
13093 | [afi] | |
13094 | [safi], | |
05c7a1cc QY |
13095 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13096 | json_object_boolean_true_add( | |
13097 | json_sub, | |
13098 | "preserved"); | |
13099 | restart_af_count++; | |
13100 | json_object_object_add( | |
13101 | json_restart, | |
5cb5f4d0 | 13102 | get_afi_safi_str( |
05c7a1cc | 13103 | afi, |
5cb5f4d0 DD |
13104 | safi, |
13105 | true), | |
05c7a1cc | 13106 | json_sub); |
d62a17ae | 13107 | } |
13108 | } | |
13109 | if (!restart_af_count) { | |
13110 | json_object_string_add( | |
13111 | json_cap, | |
13112 | "addressFamiliesByPeer", | |
13113 | "none"); | |
13114 | json_object_free( | |
13115 | json_restart); | |
13116 | } else | |
13117 | json_object_object_add( | |
13118 | json_cap, | |
13119 | "addressFamiliesByPeer", | |
13120 | json_restart); | |
13121 | } | |
13122 | } | |
13123 | json_object_object_add(json_neigh, | |
13124 | "neighborCapabilities", | |
13125 | json_cap); | |
13126 | } else { | |
13127 | vty_out(vty, " Neighbor capabilities:\n"); | |
13128 | ||
13129 | /* AS4 */ | |
13130 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
13131 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13132 | vty_out(vty, " 4 Byte AS:"); | |
13133 | if (CHECK_FLAG(p->cap, | |
13134 | PEER_CAP_AS4_ADV)) | |
13135 | vty_out(vty, " advertised"); | |
13136 | if (CHECK_FLAG(p->cap, | |
13137 | PEER_CAP_AS4_RCV)) | |
13138 | vty_out(vty, " %sreceived", | |
13139 | CHECK_FLAG( | |
13140 | p->cap, | |
13141 | PEER_CAP_AS4_ADV) | |
13142 | ? "and " | |
13143 | : ""); | |
13144 | vty_out(vty, "\n"); | |
13145 | } | |
13146 | ||
13147 | /* AddPath */ | |
13148 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
13149 | || CHECK_FLAG(p->cap, | |
13150 | PEER_CAP_ADDPATH_ADV)) { | |
13151 | vty_out(vty, " AddPath:\n"); | |
13152 | ||
05c7a1cc QY |
13153 | FOREACH_AFI_SAFI (afi, safi) { |
13154 | if (CHECK_FLAG( | |
13155 | p->af_cap[afi] | |
13156 | [safi], | |
13157 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13158 | || CHECK_FLAG( | |
13159 | p->af_cap[afi] | |
13160 | [safi], | |
13161 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13162 | vty_out(vty, | |
13163 | " %s: TX ", | |
5cb5f4d0 | 13164 | get_afi_safi_str( |
05c7a1cc | 13165 | afi, |
5cb5f4d0 DD |
13166 | safi, |
13167 | false)); | |
05c7a1cc | 13168 | |
d62a17ae | 13169 | if (CHECK_FLAG( |
13170 | p->af_cap | |
13171 | [afi] | |
13172 | [safi], | |
05c7a1cc | 13173 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 13174 | vty_out(vty, |
05c7a1cc | 13175 | "advertised %s", |
5cb5f4d0 | 13176 | get_afi_safi_str( |
d62a17ae | 13177 | afi, |
5cb5f4d0 DD |
13178 | safi, |
13179 | false)); | |
d62a17ae | 13180 | |
05c7a1cc QY |
13181 | if (CHECK_FLAG( |
13182 | p->af_cap | |
13183 | [afi] | |
13184 | [safi], | |
13185 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13186 | vty_out(vty, | |
13187 | "%sreceived", | |
13188 | CHECK_FLAG( | |
13189 | p->af_cap | |
13190 | [afi] | |
13191 | [safi], | |
13192 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13193 | ? " and " | |
13194 | : ""); | |
d62a17ae | 13195 | |
05c7a1cc QY |
13196 | vty_out(vty, "\n"); |
13197 | } | |
d62a17ae | 13198 | |
05c7a1cc QY |
13199 | if (CHECK_FLAG( |
13200 | p->af_cap[afi] | |
13201 | [safi], | |
13202 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13203 | || CHECK_FLAG( | |
13204 | p->af_cap[afi] | |
13205 | [safi], | |
13206 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13207 | vty_out(vty, | |
13208 | " %s: RX ", | |
5cb5f4d0 | 13209 | get_afi_safi_str( |
05c7a1cc | 13210 | afi, |
5cb5f4d0 DD |
13211 | safi, |
13212 | false)); | |
d62a17ae | 13213 | |
13214 | if (CHECK_FLAG( | |
13215 | p->af_cap | |
13216 | [afi] | |
13217 | [safi], | |
05c7a1cc | 13218 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 13219 | vty_out(vty, |
05c7a1cc | 13220 | "advertised %s", |
5cb5f4d0 | 13221 | get_afi_safi_str( |
d62a17ae | 13222 | afi, |
5cb5f4d0 DD |
13223 | safi, |
13224 | false)); | |
d62a17ae | 13225 | |
05c7a1cc QY |
13226 | if (CHECK_FLAG( |
13227 | p->af_cap | |
13228 | [afi] | |
13229 | [safi], | |
13230 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 13231 | vty_out(vty, |
05c7a1cc QY |
13232 | "%sreceived", |
13233 | CHECK_FLAG( | |
13234 | p->af_cap | |
13235 | [afi] | |
13236 | [safi], | |
13237 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13238 | ? " and " | |
13239 | : ""); | |
13240 | ||
13241 | vty_out(vty, "\n"); | |
d62a17ae | 13242 | } |
05c7a1cc | 13243 | } |
d62a17ae | 13244 | } |
13245 | ||
13246 | /* Dynamic */ | |
13247 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
13248 | || CHECK_FLAG(p->cap, | |
13249 | PEER_CAP_DYNAMIC_ADV)) { | |
13250 | vty_out(vty, " Dynamic:"); | |
13251 | if (CHECK_FLAG(p->cap, | |
13252 | PEER_CAP_DYNAMIC_ADV)) | |
13253 | vty_out(vty, " advertised"); | |
13254 | if (CHECK_FLAG(p->cap, | |
13255 | PEER_CAP_DYNAMIC_RCV)) | |
13256 | vty_out(vty, " %sreceived", | |
13257 | CHECK_FLAG( | |
13258 | p->cap, | |
13259 | PEER_CAP_DYNAMIC_ADV) | |
13260 | ? "and " | |
13261 | : ""); | |
13262 | vty_out(vty, "\n"); | |
13263 | } | |
13264 | ||
13265 | /* Extended nexthop */ | |
13266 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
13267 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13268 | vty_out(vty, " Extended nexthop:"); | |
13269 | if (CHECK_FLAG(p->cap, | |
13270 | PEER_CAP_ENHE_ADV)) | |
13271 | vty_out(vty, " advertised"); | |
13272 | if (CHECK_FLAG(p->cap, | |
13273 | PEER_CAP_ENHE_RCV)) | |
13274 | vty_out(vty, " %sreceived", | |
13275 | CHECK_FLAG( | |
13276 | p->cap, | |
13277 | PEER_CAP_ENHE_ADV) | |
13278 | ? "and " | |
13279 | : ""); | |
13280 | vty_out(vty, "\n"); | |
13281 | ||
13282 | if (CHECK_FLAG(p->cap, | |
13283 | PEER_CAP_ENHE_RCV)) { | |
13284 | vty_out(vty, | |
13285 | " Address families by peer:\n "); | |
13286 | for (safi = SAFI_UNICAST; | |
13287 | safi < SAFI_MAX; safi++) | |
13288 | if (CHECK_FLAG( | |
13289 | p->af_cap | |
13290 | [AFI_IP] | |
13291 | [safi], | |
13292 | PEER_CAP_ENHE_AF_RCV)) | |
13293 | vty_out(vty, | |
13294 | " %s\n", | |
5cb5f4d0 | 13295 | get_afi_safi_str( |
d62a17ae | 13296 | AFI_IP, |
5cb5f4d0 DD |
13297 | safi, |
13298 | false)); | |
d62a17ae | 13299 | } |
13300 | } | |
13301 | ||
13302 | /* Route Refresh */ | |
13303 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
13304 | || CHECK_FLAG(p->cap, | |
13305 | PEER_CAP_REFRESH_NEW_RCV) | |
13306 | || CHECK_FLAG(p->cap, | |
13307 | PEER_CAP_REFRESH_OLD_RCV)) { | |
13308 | vty_out(vty, " Route refresh:"); | |
13309 | if (CHECK_FLAG(p->cap, | |
13310 | PEER_CAP_REFRESH_ADV)) | |
13311 | vty_out(vty, " advertised"); | |
13312 | if (CHECK_FLAG(p->cap, | |
13313 | PEER_CAP_REFRESH_NEW_RCV) | |
13314 | || CHECK_FLAG( | |
13315 | p->cap, | |
13316 | PEER_CAP_REFRESH_OLD_RCV)) | |
13317 | vty_out(vty, " %sreceived(%s)", | |
13318 | CHECK_FLAG( | |
13319 | p->cap, | |
13320 | PEER_CAP_REFRESH_ADV) | |
13321 | ? "and " | |
13322 | : "", | |
13323 | (CHECK_FLAG( | |
13324 | p->cap, | |
13325 | PEER_CAP_REFRESH_OLD_RCV) | |
13326 | && CHECK_FLAG( | |
13327 | p->cap, | |
13328 | PEER_CAP_REFRESH_NEW_RCV)) | |
13329 | ? "old & new" | |
13330 | : CHECK_FLAG( | |
13331 | p->cap, | |
13332 | PEER_CAP_REFRESH_OLD_RCV) | |
13333 | ? "old" | |
13334 | : "new"); | |
13335 | ||
13336 | vty_out(vty, "\n"); | |
13337 | } | |
13338 | ||
13339 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
13340 | FOREACH_AFI_SAFI (afi, safi) |
13341 | if (p->afc_adv[afi][safi] | |
13342 | || p->afc_recv[afi][safi]) { | |
13343 | vty_out(vty, | |
13344 | " Address Family %s:", | |
5cb5f4d0 DD |
13345 | get_afi_safi_str( |
13346 | afi, | |
13347 | safi, | |
13348 | false)); | |
05c7a1cc | 13349 | if (p->afc_adv[afi][safi]) |
d62a17ae | 13350 | vty_out(vty, |
05c7a1cc QY |
13351 | " advertised"); |
13352 | if (p->afc_recv[afi][safi]) | |
13353 | vty_out(vty, | |
13354 | " %sreceived", | |
13355 | p->afc_adv[afi] | |
13356 | [safi] | |
13357 | ? "and " | |
13358 | : ""); | |
13359 | vty_out(vty, "\n"); | |
13360 | } | |
d62a17ae | 13361 | |
13362 | /* Hostname capability */ | |
60466a63 | 13363 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
13364 | |
13365 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
13366 | vty_out(vty, |
13367 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
13368 | bgp->peer_self->hostname |
13369 | ? bgp->peer_self | |
13370 | ->hostname | |
d77114b7 | 13371 | : "n/a", |
60466a63 QY |
13372 | bgp->peer_self->domainname |
13373 | ? bgp->peer_self | |
13374 | ->domainname | |
d77114b7 MK |
13375 | : "n/a"); |
13376 | } else { | |
13377 | vty_out(vty, " not advertised"); | |
d62a17ae | 13378 | } |
13379 | ||
d77114b7 | 13380 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
13381 | vty_out(vty, |
13382 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
13383 | p->hostname ? p->hostname |
13384 | : "n/a", | |
13385 | p->domainname ? p->domainname | |
13386 | : "n/a"); | |
d77114b7 MK |
13387 | } else { |
13388 | vty_out(vty, " not received"); | |
13389 | } | |
13390 | ||
13391 | vty_out(vty, "\n"); | |
13392 | ||
61bfbd51 | 13393 | /* Graceful Restart */ |
d62a17ae | 13394 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
13395 | || CHECK_FLAG(p->cap, | |
13396 | PEER_CAP_RESTART_ADV)) { | |
13397 | vty_out(vty, | |
61bfbd51 | 13398 | " Graceful Restart Capability:"); |
d62a17ae | 13399 | if (CHECK_FLAG(p->cap, |
13400 | PEER_CAP_RESTART_ADV)) | |
13401 | vty_out(vty, " advertised"); | |
13402 | if (CHECK_FLAG(p->cap, | |
13403 | PEER_CAP_RESTART_RCV)) | |
13404 | vty_out(vty, " %sreceived", | |
13405 | CHECK_FLAG( | |
13406 | p->cap, | |
13407 | PEER_CAP_RESTART_ADV) | |
13408 | ? "and " | |
13409 | : ""); | |
13410 | vty_out(vty, "\n"); | |
13411 | ||
13412 | if (CHECK_FLAG(p->cap, | |
13413 | PEER_CAP_RESTART_RCV)) { | |
13414 | int restart_af_count = 0; | |
13415 | ||
13416 | vty_out(vty, | |
13417 | " Remote Restart timer is %d seconds\n", | |
13418 | p->v_gr_restart); | |
13419 | vty_out(vty, | |
13420 | " Address families by peer:\n "); | |
13421 | ||
05c7a1cc QY |
13422 | FOREACH_AFI_SAFI (afi, safi) |
13423 | if (CHECK_FLAG( | |
13424 | p->af_cap | |
13425 | [afi] | |
13426 | [safi], | |
13427 | PEER_CAP_RESTART_AF_RCV)) { | |
13428 | vty_out(vty, | |
13429 | "%s%s(%s)", | |
13430 | restart_af_count | |
13431 | ? ", " | |
13432 | : "", | |
5cb5f4d0 | 13433 | get_afi_safi_str( |
05c7a1cc | 13434 | afi, |
5cb5f4d0 DD |
13435 | safi, |
13436 | false), | |
05c7a1cc QY |
13437 | CHECK_FLAG( |
13438 | p->af_cap | |
13439 | [afi] | |
13440 | [safi], | |
13441 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13442 | ? "preserved" | |
13443 | : "not preserved"); | |
13444 | restart_af_count++; | |
13445 | } | |
d62a17ae | 13446 | if (!restart_af_count) |
13447 | vty_out(vty, "none"); | |
13448 | vty_out(vty, "\n"); | |
13449 | } | |
2986cac2 | 13450 | } /* Gracefull Restart */ |
d62a17ae | 13451 | } |
13452 | } | |
13453 | } | |
13454 | ||
13455 | /* graceful restart information */ | |
d62a17ae | 13456 | json_object *json_grace = NULL; |
13457 | json_object *json_grace_send = NULL; | |
13458 | json_object *json_grace_recv = NULL; | |
13459 | int eor_send_af_count = 0; | |
13460 | int eor_receive_af_count = 0; | |
13461 | ||
13462 | if (use_json) { | |
13463 | json_grace = json_object_new_object(); | |
13464 | json_grace_send = json_object_new_object(); | |
13465 | json_grace_recv = json_object_new_object(); | |
13466 | ||
36235319 QY |
13467 | if ((p->status == Established) |
13468 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
13469 | FOREACH_AFI_SAFI (afi, safi) { |
13470 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 13471 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
13472 | json_object_boolean_true_add( |
13473 | json_grace_send, | |
5cb5f4d0 DD |
13474 | get_afi_safi_str(afi, |
13475 | safi, | |
13476 | true)); | |
05c7a1cc | 13477 | eor_send_af_count++; |
d62a17ae | 13478 | } |
13479 | } | |
05c7a1cc QY |
13480 | FOREACH_AFI_SAFI (afi, safi) { |
13481 | if (CHECK_FLAG( | |
36235319 QY |
13482 | p->af_sflags[afi][safi], |
13483 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
13484 | json_object_boolean_true_add( |
13485 | json_grace_recv, | |
5cb5f4d0 DD |
13486 | get_afi_safi_str(afi, |
13487 | safi, | |
13488 | true)); | |
05c7a1cc | 13489 | eor_receive_af_count++; |
d62a17ae | 13490 | } |
13491 | } | |
13492 | } | |
36235319 QY |
13493 | json_object_object_add(json_grace, "endOfRibSend", |
13494 | json_grace_send); | |
13495 | json_object_object_add(json_grace, "endOfRibRecv", | |
13496 | json_grace_recv); | |
d62a17ae | 13497 | |
d62a17ae | 13498 | |
13499 | if (p->t_gr_restart) | |
13500 | json_object_int_add(json_grace, | |
13501 | "gracefulRestartTimerMsecs", | |
13502 | thread_timer_remain_second( | |
13503 | p->t_gr_restart) | |
13504 | * 1000); | |
13505 | ||
13506 | if (p->t_gr_stale) | |
13507 | json_object_int_add( | |
13508 | json_grace, | |
13509 | "gracefulStalepathTimerMsecs", | |
13510 | thread_timer_remain_second( | |
13511 | p->t_gr_stale) | |
13512 | * 1000); | |
2986cac2 | 13513 | /* more gr info in new format */ |
13514 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 13515 | json_grace); |
d62a17ae | 13516 | json_object_object_add( |
13517 | json_neigh, "gracefulRestartInfo", json_grace); | |
13518 | } else { | |
2089dd80 | 13519 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
13520 | if ((p->status == Established) |
13521 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 13522 | |
d62a17ae | 13523 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
13524 | FOREACH_AFI_SAFI (afi, safi) { |
13525 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13526 | PEER_STATUS_EOR_SEND)) { | |
13527 | vty_out(vty, "%s%s", | |
13528 | eor_send_af_count ? ", " | |
13529 | : "", | |
36235319 QY |
13530 | get_afi_safi_str( |
13531 | afi, safi, | |
13532 | false)); | |
05c7a1cc | 13533 | eor_send_af_count++; |
d62a17ae | 13534 | } |
13535 | } | |
13536 | vty_out(vty, "\n"); | |
13537 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
13538 | FOREACH_AFI_SAFI (afi, safi) { |
13539 | if (CHECK_FLAG( | |
13540 | p->af_sflags[afi][safi], | |
13541 | PEER_STATUS_EOR_RECEIVED)) { | |
13542 | vty_out(vty, "%s%s", | |
13543 | eor_receive_af_count | |
13544 | ? ", " | |
13545 | : "", | |
5cb5f4d0 DD |
13546 | get_afi_safi_str(afi, |
13547 | safi, | |
13548 | false)); | |
05c7a1cc | 13549 | eor_receive_af_count++; |
d62a17ae | 13550 | } |
13551 | } | |
13552 | vty_out(vty, "\n"); | |
13553 | } | |
13554 | ||
13555 | if (p->t_gr_restart) | |
13556 | vty_out(vty, | |
13557 | " The remaining time of restart timer is %ld\n", | |
13558 | thread_timer_remain_second( | |
13559 | p->t_gr_restart)); | |
13560 | ||
13561 | if (p->t_gr_stale) | |
13562 | vty_out(vty, | |
13563 | " The remaining time of stalepath timer is %ld\n", | |
13564 | thread_timer_remain_second( | |
13565 | p->t_gr_stale)); | |
2986cac2 | 13566 | |
13567 | /* more gr info in new format */ | |
13568 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 13569 | } |
2986cac2 | 13570 | |
d62a17ae | 13571 | if (use_json) { |
13572 | json_object *json_stat = NULL; | |
13573 | json_stat = json_object_new_object(); | |
13574 | /* Packet counts. */ | |
43aa5965 QY |
13575 | |
13576 | atomic_size_t outq_count, inq_count; | |
13577 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13578 | memory_order_relaxed); | |
13579 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13580 | memory_order_relaxed); | |
13581 | ||
13582 | json_object_int_add(json_stat, "depthInq", | |
13583 | (unsigned long)inq_count); | |
d62a17ae | 13584 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 13585 | (unsigned long)outq_count); |
0112e9e0 QY |
13586 | json_object_int_add(json_stat, "opensSent", |
13587 | atomic_load_explicit(&p->open_out, | |
13588 | memory_order_relaxed)); | |
13589 | json_object_int_add(json_stat, "opensRecv", | |
13590 | atomic_load_explicit(&p->open_in, | |
13591 | memory_order_relaxed)); | |
d62a17ae | 13592 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
13593 | atomic_load_explicit(&p->notify_out, |
13594 | memory_order_relaxed)); | |
d62a17ae | 13595 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
13596 | atomic_load_explicit(&p->notify_in, |
13597 | memory_order_relaxed)); | |
13598 | json_object_int_add(json_stat, "updatesSent", | |
13599 | atomic_load_explicit(&p->update_out, | |
13600 | memory_order_relaxed)); | |
13601 | json_object_int_add(json_stat, "updatesRecv", | |
13602 | atomic_load_explicit(&p->update_in, | |
13603 | memory_order_relaxed)); | |
d62a17ae | 13604 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
13605 | atomic_load_explicit(&p->keepalive_out, |
13606 | memory_order_relaxed)); | |
d62a17ae | 13607 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
13608 | atomic_load_explicit(&p->keepalive_in, |
13609 | memory_order_relaxed)); | |
d62a17ae | 13610 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
13611 | atomic_load_explicit(&p->refresh_out, |
13612 | memory_order_relaxed)); | |
d62a17ae | 13613 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
13614 | atomic_load_explicit(&p->refresh_in, |
13615 | memory_order_relaxed)); | |
d62a17ae | 13616 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
13617 | atomic_load_explicit(&p->dynamic_cap_out, |
13618 | memory_order_relaxed)); | |
d62a17ae | 13619 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
13620 | atomic_load_explicit(&p->dynamic_cap_in, |
13621 | memory_order_relaxed)); | |
13622 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13623 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 13624 | json_object_object_add(json_neigh, "messageStats", json_stat); |
13625 | } else { | |
43aa5965 QY |
13626 | atomic_size_t outq_count, inq_count; |
13627 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13628 | memory_order_relaxed); | |
13629 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13630 | memory_order_relaxed); | |
13631 | ||
d62a17ae | 13632 | /* Packet counts. */ |
13633 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
13634 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
13635 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 13636 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
13637 | vty_out(vty, " Opens: %10d %10d\n", |
13638 | atomic_load_explicit(&p->open_out, | |
13639 | memory_order_relaxed), | |
13640 | atomic_load_explicit(&p->open_in, | |
13641 | memory_order_relaxed)); | |
13642 | vty_out(vty, " Notifications: %10d %10d\n", | |
13643 | atomic_load_explicit(&p->notify_out, | |
13644 | memory_order_relaxed), | |
13645 | atomic_load_explicit(&p->notify_in, | |
13646 | memory_order_relaxed)); | |
13647 | vty_out(vty, " Updates: %10d %10d\n", | |
13648 | atomic_load_explicit(&p->update_out, | |
13649 | memory_order_relaxed), | |
13650 | atomic_load_explicit(&p->update_in, | |
13651 | memory_order_relaxed)); | |
13652 | vty_out(vty, " Keepalives: %10d %10d\n", | |
13653 | atomic_load_explicit(&p->keepalive_out, | |
13654 | memory_order_relaxed), | |
13655 | atomic_load_explicit(&p->keepalive_in, | |
13656 | memory_order_relaxed)); | |
13657 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
13658 | atomic_load_explicit(&p->refresh_out, | |
13659 | memory_order_relaxed), | |
13660 | atomic_load_explicit(&p->refresh_in, | |
13661 | memory_order_relaxed)); | |
d62a17ae | 13662 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
13663 | atomic_load_explicit(&p->dynamic_cap_out, |
13664 | memory_order_relaxed), | |
13665 | atomic_load_explicit(&p->dynamic_cap_in, | |
13666 | memory_order_relaxed)); | |
13667 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
13668 | PEER_TOTAL_RX(p)); | |
d62a17ae | 13669 | } |
13670 | ||
13671 | if (use_json) { | |
13672 | /* advertisement-interval */ | |
13673 | json_object_int_add(json_neigh, | |
13674 | "minBtwnAdvertisementRunsTimerMsecs", | |
13675 | p->v_routeadv * 1000); | |
13676 | ||
13677 | /* Update-source. */ | |
13678 | if (p->update_if || p->update_source) { | |
13679 | if (p->update_if) | |
13680 | json_object_string_add(json_neigh, | |
13681 | "updateSource", | |
13682 | p->update_if); | |
13683 | else if (p->update_source) | |
13684 | json_object_string_add( | |
13685 | json_neigh, "updateSource", | |
13686 | sockunion2str(p->update_source, buf1, | |
13687 | SU_ADDRSTRLEN)); | |
13688 | } | |
13689 | } else { | |
13690 | /* advertisement-interval */ | |
13691 | vty_out(vty, | |
13692 | " Minimum time between advertisement runs is %d seconds\n", | |
13693 | p->v_routeadv); | |
13694 | ||
13695 | /* Update-source. */ | |
13696 | if (p->update_if || p->update_source) { | |
13697 | vty_out(vty, " Update source is "); | |
13698 | if (p->update_if) | |
13699 | vty_out(vty, "%s", p->update_if); | |
13700 | else if (p->update_source) | |
13701 | vty_out(vty, "%s", | |
13702 | sockunion2str(p->update_source, buf1, | |
13703 | SU_ADDRSTRLEN)); | |
13704 | vty_out(vty, "\n"); | |
13705 | } | |
13706 | ||
13707 | vty_out(vty, "\n"); | |
13708 | } | |
13709 | ||
13710 | /* Address Family Information */ | |
13711 | json_object *json_hold = NULL; | |
13712 | ||
13713 | if (use_json) | |
13714 | json_hold = json_object_new_object(); | |
13715 | ||
05c7a1cc QY |
13716 | FOREACH_AFI_SAFI (afi, safi) |
13717 | if (p->afc[afi][safi]) | |
13718 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
13719 | json_hold); | |
d62a17ae | 13720 | |
13721 | if (use_json) { | |
13722 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
13723 | json_hold); | |
13724 | json_object_int_add(json_neigh, "connectionsEstablished", | |
13725 | p->established); | |
13726 | json_object_int_add(json_neigh, "connectionsDropped", | |
13727 | p->dropped); | |
13728 | } else | |
13729 | vty_out(vty, " Connections established %d; dropped %d\n", | |
13730 | p->established, p->dropped); | |
13731 | ||
13732 | if (!p->last_reset) { | |
13733 | if (use_json) | |
13734 | json_object_string_add(json_neigh, "lastReset", | |
13735 | "never"); | |
13736 | else | |
13737 | vty_out(vty, " Last reset never\n"); | |
13738 | } else { | |
13739 | if (use_json) { | |
13740 | time_t uptime; | |
a2700b50 | 13741 | struct tm tm; |
d62a17ae | 13742 | |
13743 | uptime = bgp_clock(); | |
13744 | uptime -= p->resettime; | |
a2700b50 MS |
13745 | gmtime_r(&uptime, &tm); |
13746 | ||
d62a17ae | 13747 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
13748 | (tm.tm_sec * 1000) |
13749 | + (tm.tm_min * 60000) | |
13750 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 13751 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 13752 | } else { |
13753 | vty_out(vty, " Last reset %s, ", | |
13754 | peer_uptime(p->resettime, timebuf, | |
13755 | BGP_UPTIME_LEN, 0, NULL)); | |
13756 | ||
3577f1c5 | 13757 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 13758 | if (p->last_reset_cause_size) { |
13759 | msg = p->last_reset_cause; | |
13760 | vty_out(vty, | |
13761 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
13762 | for (i = 1; i <= p->last_reset_cause_size; | |
13763 | i++) { | |
13764 | vty_out(vty, "%02X", *msg++); | |
13765 | ||
13766 | if (i != p->last_reset_cause_size) { | |
13767 | if (i % 16 == 0) { | |
13768 | vty_out(vty, "\n "); | |
13769 | } else if (i % 4 == 0) { | |
13770 | vty_out(vty, " "); | |
13771 | } | |
13772 | } | |
13773 | } | |
13774 | vty_out(vty, "\n"); | |
13775 | } | |
13776 | } | |
13777 | } | |
13778 | ||
13779 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
13780 | if (use_json) | |
13781 | json_object_boolean_true_add(json_neigh, | |
13782 | "prefixesConfigExceedMax"); | |
13783 | else | |
13784 | vty_out(vty, | |
13785 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
13786 | ||
13787 | if (p->t_pmax_restart) { | |
13788 | if (use_json) { | |
13789 | json_object_boolean_true_add( | |
13790 | json_neigh, "reducePrefixNumFrom"); | |
13791 | json_object_int_add(json_neigh, | |
13792 | "restartInTimerMsec", | |
13793 | thread_timer_remain_second( | |
13794 | p->t_pmax_restart) | |
13795 | * 1000); | |
13796 | } else | |
13797 | vty_out(vty, | |
13798 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
13799 | p->host, thread_timer_remain_second( |
13800 | p->t_pmax_restart)); | |
d62a17ae | 13801 | } else { |
13802 | if (use_json) | |
13803 | json_object_boolean_true_add( | |
13804 | json_neigh, | |
13805 | "reducePrefixNumAndClearIpBgp"); | |
13806 | else | |
13807 | vty_out(vty, | |
13808 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
13809 | p->host); | |
13810 | } | |
13811 | } | |
13812 | ||
13813 | /* EBGP Multihop and GTSM */ | |
13814 | if (p->sort != BGP_PEER_IBGP) { | |
13815 | if (use_json) { | |
e2521429 | 13816 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13817 | json_object_int_add(json_neigh, |
13818 | "externalBgpNbrMaxHopsAway", | |
13819 | p->gtsm_hops); | |
c8d6f0d6 | 13820 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13821 | json_object_int_add(json_neigh, |
13822 | "externalBgpNbrMaxHopsAway", | |
13823 | p->ttl); | |
13824 | } else { | |
e2521429 | 13825 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13826 | vty_out(vty, |
13827 | " External BGP neighbor may be up to %d hops away.\n", | |
13828 | p->gtsm_hops); | |
c8d6f0d6 | 13829 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13830 | vty_out(vty, |
13831 | " External BGP neighbor may be up to %d hops away.\n", | |
13832 | p->ttl); | |
13833 | } | |
13834 | } else { | |
e2521429 | 13835 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 13836 | if (use_json) |
13837 | json_object_int_add(json_neigh, | |
13838 | "internalBgpNbrMaxHopsAway", | |
13839 | p->gtsm_hops); | |
13840 | else | |
13841 | vty_out(vty, | |
13842 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13843 | p->gtsm_hops); | |
13844 | } | |
13845 | } | |
13846 | ||
13847 | /* Local address. */ | |
13848 | if (p->su_local) { | |
13849 | if (use_json) { | |
13850 | json_object_string_add(json_neigh, "hostLocal", | |
13851 | sockunion2str(p->su_local, buf1, | |
13852 | SU_ADDRSTRLEN)); | |
13853 | json_object_int_add(json_neigh, "portLocal", | |
13854 | ntohs(p->su_local->sin.sin_port)); | |
13855 | } else | |
13856 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13857 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
13858 | ntohs(p->su_local->sin.sin_port)); | |
13859 | } | |
13860 | ||
13861 | /* Remote address. */ | |
13862 | if (p->su_remote) { | |
13863 | if (use_json) { | |
13864 | json_object_string_add(json_neigh, "hostForeign", | |
13865 | sockunion2str(p->su_remote, buf1, | |
13866 | SU_ADDRSTRLEN)); | |
13867 | json_object_int_add(json_neigh, "portForeign", | |
13868 | ntohs(p->su_remote->sin.sin_port)); | |
13869 | } else | |
13870 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
13871 | sockunion2str(p->su_remote, buf1, | |
13872 | SU_ADDRSTRLEN), | |
13873 | ntohs(p->su_remote->sin.sin_port)); | |
13874 | } | |
13875 | ||
13876 | /* Nexthop display. */ | |
13877 | if (p->su_local) { | |
13878 | if (use_json) { | |
13879 | json_object_string_add(json_neigh, "nexthop", | |
13880 | inet_ntop(AF_INET, | |
13881 | &p->nexthop.v4, buf1, | |
13882 | sizeof(buf1))); | |
13883 | json_object_string_add(json_neigh, "nexthopGlobal", | |
13884 | inet_ntop(AF_INET6, | |
13885 | &p->nexthop.v6_global, | |
13886 | buf1, sizeof(buf1))); | |
13887 | json_object_string_add(json_neigh, "nexthopLocal", | |
13888 | inet_ntop(AF_INET6, | |
13889 | &p->nexthop.v6_local, | |
13890 | buf1, sizeof(buf1))); | |
13891 | if (p->shared_network) | |
13892 | json_object_string_add(json_neigh, | |
13893 | "bgpConnection", | |
13894 | "sharedNetwork"); | |
13895 | else | |
13896 | json_object_string_add(json_neigh, | |
13897 | "bgpConnection", | |
13898 | "nonSharedNetwork"); | |
13899 | } else { | |
13900 | vty_out(vty, "Nexthop: %s\n", | |
13901 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
13902 | sizeof(buf1))); | |
13903 | vty_out(vty, "Nexthop global: %s\n", | |
13904 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
13905 | sizeof(buf1))); | |
13906 | vty_out(vty, "Nexthop local: %s\n", | |
13907 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
13908 | sizeof(buf1))); | |
13909 | vty_out(vty, "BGP connection: %s\n", | |
13910 | p->shared_network ? "shared network" | |
13911 | : "non shared network"); | |
13912 | } | |
13913 | } | |
13914 | ||
13915 | /* Timer information. */ | |
13916 | if (use_json) { | |
13917 | json_object_int_add(json_neigh, "connectRetryTimer", | |
13918 | p->v_connect); | |
13919 | if (p->status == Established && p->rtt) | |
13920 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
13921 | p->rtt); | |
13922 | if (p->t_start) | |
13923 | json_object_int_add( | |
13924 | json_neigh, "nextStartTimerDueInMsecs", | |
13925 | thread_timer_remain_second(p->t_start) * 1000); | |
13926 | if (p->t_connect) | |
13927 | json_object_int_add( | |
13928 | json_neigh, "nextConnectTimerDueInMsecs", | |
13929 | thread_timer_remain_second(p->t_connect) | |
13930 | * 1000); | |
13931 | if (p->t_routeadv) { | |
13932 | json_object_int_add(json_neigh, "mraiInterval", | |
13933 | p->v_routeadv); | |
13934 | json_object_int_add( | |
13935 | json_neigh, "mraiTimerExpireInMsecs", | |
13936 | thread_timer_remain_second(p->t_routeadv) | |
13937 | * 1000); | |
13938 | } | |
13939 | if (p->password) | |
13940 | json_object_int_add(json_neigh, "authenticationEnabled", | |
13941 | 1); | |
13942 | ||
13943 | if (p->t_read) | |
13944 | json_object_string_add(json_neigh, "readThread", "on"); | |
13945 | else | |
13946 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
13947 | |
13948 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 13949 | json_object_string_add(json_neigh, "writeThread", "on"); |
13950 | else | |
13951 | json_object_string_add(json_neigh, "writeThread", | |
13952 | "off"); | |
13953 | } else { | |
13954 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
13955 | p->v_connect); | |
13956 | if (p->status == Established && p->rtt) | |
13957 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
13958 | p->rtt); | |
13959 | if (p->t_start) | |
13960 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
13961 | thread_timer_remain_second(p->t_start)); | |
13962 | if (p->t_connect) | |
13963 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
13964 | thread_timer_remain_second(p->t_connect)); | |
13965 | if (p->t_routeadv) | |
13966 | vty_out(vty, | |
13967 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
13968 | p->v_routeadv, | |
13969 | thread_timer_remain_second(p->t_routeadv)); | |
13970 | if (p->password) | |
13971 | vty_out(vty, "Peer Authentication Enabled\n"); | |
13972 | ||
cac9e917 | 13973 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
13974 | p->t_read ? "on" : "off", |
13975 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
13976 | ? "on" | |
cac9e917 | 13977 | : "off", p->fd); |
d62a17ae | 13978 | } |
13979 | ||
13980 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
13981 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
13982 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
13983 | ||
13984 | if (!use_json) | |
13985 | vty_out(vty, "\n"); | |
13986 | ||
13987 | /* BFD information. */ | |
13988 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
13989 | ||
13990 | if (use_json) { | |
13991 | if (p->conf_if) /* Configured interface name. */ | |
13992 | json_object_object_add(json, p->conf_if, json_neigh); | |
13993 | else /* Configured IP address. */ | |
13994 | json_object_object_add(json, p->host, json_neigh); | |
13995 | } | |
13996 | } | |
13997 | ||
36235319 QY |
13998 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
13999 | enum show_type type, | |
14000 | union sockunion *su, | |
14001 | const char *conf_if, afi_t afi, | |
74a630b6 | 14002 | bool use_json) |
2986cac2 | 14003 | { |
14004 | struct listnode *node, *nnode; | |
14005 | struct peer *peer; | |
14006 | int find = 0; | |
14007 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 14008 | json_object *json = NULL; |
2986cac2 | 14009 | json_object *json_neighbor = NULL; |
14010 | ||
74a630b6 NT |
14011 | if (use_json) { |
14012 | json = json_object_new_object(); | |
14013 | json_neighbor = json_object_new_object(); | |
14014 | } | |
14015 | ||
2986cac2 | 14016 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
14017 | ||
14018 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14019 | continue; | |
14020 | ||
14021 | if ((peer->afc[afi][safi]) == 0) | |
14022 | continue; | |
14023 | ||
2ba1fe69 | 14024 | if (type == show_all) { |
2986cac2 | 14025 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 14026 | json_neighbor); |
2986cac2 | 14027 | |
74a630b6 | 14028 | if (use_json) { |
13909c4f DS |
14029 | json_object_object_add(json, peer->host, |
14030 | json_neighbor); | |
74a630b6 NT |
14031 | json_neighbor = NULL; |
14032 | } | |
2986cac2 | 14033 | |
2ba1fe69 | 14034 | } else if (type == show_peer) { |
2986cac2 | 14035 | if (conf_if) { |
14036 | if ((peer->conf_if | |
13909c4f DS |
14037 | && !strcmp(peer->conf_if, conf_if)) |
14038 | || (peer->hostname | |
2986cac2 | 14039 | && !strcmp(peer->hostname, conf_if))) { |
14040 | find = 1; | |
13909c4f DS |
14041 | bgp_show_peer_gr_status(vty, peer, |
14042 | use_json, | |
14043 | json_neighbor); | |
2986cac2 | 14044 | } |
14045 | } else { | |
14046 | if (sockunion_same(&peer->su, su)) { | |
14047 | find = 1; | |
13909c4f DS |
14048 | bgp_show_peer_gr_status(vty, peer, |
14049 | use_json, | |
14050 | json_neighbor); | |
2986cac2 | 14051 | } |
14052 | } | |
13909c4f DS |
14053 | if (use_json && find) |
14054 | json_object_object_add(json, peer->host, | |
14055 | json_neighbor); | |
2986cac2 | 14056 | } |
14057 | ||
74a630b6 NT |
14058 | if (find) { |
14059 | json_neighbor = NULL; | |
2986cac2 | 14060 | break; |
74a630b6 | 14061 | } |
2986cac2 | 14062 | } |
14063 | ||
14064 | if (type == show_peer && !find) { | |
14065 | if (use_json) | |
13909c4f | 14066 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14067 | else |
14068 | vty_out(vty, "%% No such neighbor\n"); | |
14069 | } | |
14070 | if (use_json) { | |
13909c4f DS |
14071 | vty_out(vty, "%s\n", |
14072 | json_object_to_json_string_ext( | |
14073 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
14074 | |
14075 | if (json_neighbor) | |
14076 | json_object_free(json_neighbor); | |
14077 | json_object_free(json); | |
2986cac2 | 14078 | } else { |
14079 | vty_out(vty, "\n"); | |
14080 | } | |
14081 | ||
14082 | return CMD_SUCCESS; | |
14083 | } | |
14084 | ||
d62a17ae | 14085 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14086 | enum show_type type, union sockunion *su, | |
9f049418 | 14087 | const char *conf_if, bool use_json, |
d62a17ae | 14088 | json_object *json) |
14089 | { | |
14090 | struct listnode *node, *nnode; | |
14091 | struct peer *peer; | |
14092 | int find = 0; | |
9f049418 | 14093 | bool nbr_output = false; |
d1927ebe AS |
14094 | afi_t afi = AFI_MAX; |
14095 | safi_t safi = SAFI_MAX; | |
14096 | ||
14097 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14098 | afi = AFI_IP; | |
14099 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14100 | afi = AFI_IP6; | |
14101 | } | |
d62a17ae | 14102 | |
14103 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14104 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14105 | continue; | |
14106 | ||
14107 | switch (type) { | |
14108 | case show_all: | |
14109 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14110 | nbr_output = true; |
d62a17ae | 14111 | break; |
14112 | case show_peer: | |
14113 | if (conf_if) { | |
14114 | if ((peer->conf_if | |
14115 | && !strcmp(peer->conf_if, conf_if)) | |
14116 | || (peer->hostname | |
14117 | && !strcmp(peer->hostname, conf_if))) { | |
14118 | find = 1; | |
14119 | bgp_show_peer(vty, peer, use_json, | |
14120 | json); | |
14121 | } | |
14122 | } else { | |
14123 | if (sockunion_same(&peer->su, su)) { | |
14124 | find = 1; | |
14125 | bgp_show_peer(vty, peer, use_json, | |
14126 | json); | |
14127 | } | |
14128 | } | |
14129 | break; | |
d1927ebe AS |
14130 | case show_ipv4_peer: |
14131 | case show_ipv6_peer: | |
14132 | FOREACH_SAFI (safi) { | |
14133 | if (peer->afc[afi][safi]) { | |
14134 | if (conf_if) { | |
14135 | if ((peer->conf_if | |
14136 | && !strcmp(peer->conf_if, conf_if)) | |
14137 | || (peer->hostname | |
14138 | && !strcmp(peer->hostname, conf_if))) { | |
14139 | find = 1; | |
14140 | bgp_show_peer(vty, peer, use_json, | |
14141 | json); | |
14142 | break; | |
14143 | } | |
14144 | } else { | |
14145 | if (sockunion_same(&peer->su, su)) { | |
14146 | find = 1; | |
14147 | bgp_show_peer(vty, peer, use_json, | |
14148 | json); | |
14149 | break; | |
14150 | } | |
14151 | } | |
14152 | } | |
14153 | } | |
14154 | break; | |
14155 | case show_ipv4_all: | |
14156 | case show_ipv6_all: | |
14157 | FOREACH_SAFI (safi) { | |
14158 | if (peer->afc[afi][safi]) { | |
14159 | bgp_show_peer(vty, peer, use_json, json); | |
14160 | nbr_output = true; | |
14161 | break; | |
14162 | } | |
14163 | } | |
14164 | break; | |
d62a17ae | 14165 | } |
14166 | } | |
14167 | ||
d1927ebe AS |
14168 | if ((type == show_peer || type == show_ipv4_peer || |
14169 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14170 | if (use_json) |
14171 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14172 | else | |
88b7d255 | 14173 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14174 | } |
14175 | ||
d1927ebe AS |
14176 | if (type != show_peer && type != show_ipv4_peer && |
14177 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14178 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14179 | |
d62a17ae | 14180 | if (use_json) { |
996c9314 LB |
14181 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14182 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14183 | } else { |
14184 | vty_out(vty, "\n"); | |
14185 | } | |
14186 | ||
14187 | return CMD_SUCCESS; | |
14188 | } | |
14189 | ||
36235319 QY |
14190 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14191 | enum show_type type, | |
14192 | const char *ip_str, | |
14193 | afi_t afi, bool use_json) | |
2986cac2 | 14194 | { |
14195 | ||
14196 | int ret; | |
14197 | struct bgp *bgp; | |
14198 | union sockunion su; | |
2986cac2 | 14199 | |
14200 | bgp = bgp_get_default(); | |
14201 | ||
13909c4f DS |
14202 | if (!bgp) |
14203 | return; | |
2986cac2 | 14204 | |
13909c4f DS |
14205 | if (!use_json) |
14206 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14207 | NULL); | |
2986cac2 | 14208 | |
13909c4f DS |
14209 | if (ip_str) { |
14210 | ret = str2sockunion(ip_str, &su); | |
14211 | if (ret < 0) | |
13909c4f | 14212 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14213 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14214 | else | |
14215 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14216 | NULL, afi, use_json); | |
13909c4f DS |
14217 | } else |
14218 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14219 | afi, use_json); |
2986cac2 | 14220 | } |
14221 | ||
d62a17ae | 14222 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14223 | enum show_type type, |
14224 | const char *ip_str, | |
9f049418 | 14225 | bool use_json) |
d62a17ae | 14226 | { |
0291c246 MK |
14227 | struct listnode *node, *nnode; |
14228 | struct bgp *bgp; | |
71aedaa3 | 14229 | union sockunion su; |
0291c246 | 14230 | json_object *json = NULL; |
71aedaa3 | 14231 | int ret, is_first = 1; |
9f049418 | 14232 | bool nbr_output = false; |
d62a17ae | 14233 | |
14234 | if (use_json) | |
14235 | vty_out(vty, "{\n"); | |
14236 | ||
14237 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14238 | nbr_output = true; |
d62a17ae | 14239 | if (use_json) { |
14240 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14241 | flog_err( |
e50f7cfd | 14242 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14243 | "Unable to allocate memory for JSON object"); |
14244 | vty_out(vty, | |
14245 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14246 | return; | |
14247 | } | |
14248 | ||
14249 | json_object_int_add(json, "vrfId", | |
14250 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14251 | ? -1 |
14252 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14253 | json_object_string_add( |
14254 | json, "vrfName", | |
14255 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14256 | ? VRF_DEFAULT_NAME |
d62a17ae | 14257 | : bgp->name); |
14258 | ||
14259 | if (!is_first) | |
14260 | vty_out(vty, ",\n"); | |
14261 | else | |
14262 | is_first = 0; | |
14263 | ||
14264 | vty_out(vty, "\"%s\":", | |
14265 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14266 | ? VRF_DEFAULT_NAME |
d62a17ae | 14267 | : bgp->name); |
14268 | } else { | |
14269 | vty_out(vty, "\nInstance %s:\n", | |
14270 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14271 | ? VRF_DEFAULT_NAME |
d62a17ae | 14272 | : bgp->name); |
14273 | } | |
71aedaa3 | 14274 | |
d1927ebe AS |
14275 | if (type == show_peer || type == show_ipv4_peer || |
14276 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14277 | ret = str2sockunion(ip_str, &su); |
14278 | if (ret < 0) | |
14279 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14280 | use_json, json); | |
14281 | else | |
14282 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14283 | use_json, json); | |
14284 | } else { | |
d1927ebe | 14285 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14286 | use_json, json); |
14287 | } | |
b77004d6 | 14288 | json_object_free(json); |
121067e9 | 14289 | json = NULL; |
d62a17ae | 14290 | } |
14291 | ||
3e78a6ce | 14292 | if (use_json) |
d62a17ae | 14293 | vty_out(vty, "}\n"); |
9f049418 DS |
14294 | else if (!nbr_output) |
14295 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14296 | } |
14297 | ||
14298 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14299 | enum show_type type, const char *ip_str, | |
9f049418 | 14300 | bool use_json) |
d62a17ae | 14301 | { |
14302 | int ret; | |
14303 | struct bgp *bgp; | |
14304 | union sockunion su; | |
14305 | json_object *json = NULL; | |
14306 | ||
14307 | if (name) { | |
14308 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14309 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14310 | use_json); | |
d62a17ae | 14311 | return CMD_SUCCESS; |
14312 | } else { | |
14313 | bgp = bgp_lookup_by_name(name); | |
14314 | if (!bgp) { | |
14315 | if (use_json) { | |
14316 | json = json_object_new_object(); | |
d62a17ae | 14317 | vty_out(vty, "%s\n", |
14318 | json_object_to_json_string_ext( | |
14319 | json, | |
14320 | JSON_C_TO_STRING_PRETTY)); | |
14321 | json_object_free(json); | |
14322 | } else | |
14323 | vty_out(vty, | |
9f049418 | 14324 | "%% BGP instance not found\n"); |
d62a17ae | 14325 | |
14326 | return CMD_WARNING; | |
14327 | } | |
14328 | } | |
14329 | } else { | |
14330 | bgp = bgp_get_default(); | |
14331 | } | |
14332 | ||
14333 | if (bgp) { | |
14334 | json = json_object_new_object(); | |
14335 | if (ip_str) { | |
14336 | ret = str2sockunion(ip_str, &su); | |
14337 | if (ret < 0) | |
14338 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14339 | use_json, json); | |
14340 | else | |
14341 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14342 | use_json, json); | |
14343 | } else { | |
14344 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14345 | json); | |
14346 | } | |
14347 | json_object_free(json); | |
ca61fd25 DS |
14348 | } else { |
14349 | if (use_json) | |
14350 | vty_out(vty, "{}\n"); | |
14351 | else | |
14352 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14353 | } |
14354 | ||
14355 | return CMD_SUCCESS; | |
4fb25c53 DW |
14356 | } |
14357 | ||
2986cac2 | 14358 | |
14359 | ||
14360 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14361 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14362 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14363 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14364 | SHOW_STR | |
14365 | BGP_STR | |
14366 | IP_STR | |
14367 | IPV6_STR | |
14368 | NEIGHBOR_STR | |
14369 | "Neighbor to display information about\n" | |
14370 | "Neighbor to display information about\n" | |
14371 | "Neighbor on BGP configured interface\n" | |
14372 | GR_SHOW | |
14373 | JSON_STR) | |
14374 | { | |
14375 | char *sh_arg = NULL; | |
14376 | enum show_type sh_type; | |
14377 | int idx = 0; | |
14378 | afi_t afi = AFI_MAX; | |
2986cac2 | 14379 | bool uj = use_json(argc, argv); |
14380 | ||
36235319 | 14381 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 14382 | afi = AFI_MAX; |
14383 | ||
14384 | idx++; | |
14385 | ||
14386 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14387 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14388 | || argv_find(argv, argc, "WORD", &idx)) { | |
14389 | sh_type = show_peer; | |
14390 | sh_arg = argv[idx]->arg; | |
14391 | } else | |
14392 | sh_type = show_all; | |
14393 | ||
14394 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14395 | return CMD_SUCCESS; | |
14396 | ||
14397 | ||
36235319 QY |
14398 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
14399 | afi, uj); | |
2986cac2 | 14400 | } |
14401 | ||
716b2d8a | 14402 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 14403 | DEFUN (show_ip_bgp_neighbors, |
14404 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 14405 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 14406 | SHOW_STR |
14407 | IP_STR | |
14408 | BGP_STR | |
f2a8972b | 14409 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
14410 | "Address Family\n" |
14411 | "Address Family\n" | |
718e3744 | 14412 | "Detailed information on TCP and BGP neighbor connections\n" |
14413 | "Neighbor to display information about\n" | |
a80beece | 14414 | "Neighbor to display information about\n" |
91d37724 | 14415 | "Neighbor on BGP configured interface\n" |
9973d184 | 14416 | JSON_STR) |
718e3744 | 14417 | { |
d62a17ae | 14418 | char *vrf = NULL; |
14419 | char *sh_arg = NULL; | |
14420 | enum show_type sh_type; | |
d1927ebe | 14421 | afi_t afi = AFI_MAX; |
718e3744 | 14422 | |
9f049418 | 14423 | bool uj = use_json(argc, argv); |
718e3744 | 14424 | |
d62a17ae | 14425 | int idx = 0; |
718e3744 | 14426 | |
9a8bdf1c PG |
14427 | /* [<vrf> VIEWVRFNAME] */ |
14428 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14429 | vrf = argv[idx + 1]->arg; | |
14430 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14431 | vrf = NULL; | |
14432 | } else if (argv_find(argv, argc, "view", &idx)) | |
14433 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 14434 | vrf = argv[idx + 1]->arg; |
718e3744 | 14435 | |
d62a17ae | 14436 | idx++; |
d1927ebe AS |
14437 | |
14438 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14439 | sh_type = show_ipv4_all; | |
14440 | afi = AFI_IP; | |
14441 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14442 | sh_type = show_ipv6_all; | |
14443 | afi = AFI_IP6; | |
14444 | } else { | |
14445 | sh_type = show_all; | |
14446 | } | |
14447 | ||
d62a17ae | 14448 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
14449 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14450 | || argv_find(argv, argc, "WORD", &idx)) { | |
14451 | sh_type = show_peer; | |
14452 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
14453 | } |
14454 | ||
14455 | if (sh_type == show_peer && afi == AFI_IP) { | |
14456 | sh_type = show_ipv4_peer; | |
14457 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14458 | sh_type = show_ipv6_peer; | |
14459 | } | |
856ca177 | 14460 | |
d62a17ae | 14461 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 14462 | } |
14463 | ||
716b2d8a | 14464 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 14465 | paths' and `show ip mbgp paths'. Those functions results are the |
14466 | same.*/ | |
f412b39a | 14467 | DEFUN (show_ip_bgp_paths, |
718e3744 | 14468 | show_ip_bgp_paths_cmd, |
46f296b4 | 14469 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 14470 | SHOW_STR |
14471 | IP_STR | |
14472 | BGP_STR | |
46f296b4 | 14473 | BGP_SAFI_HELP_STR |
718e3744 | 14474 | "Path information\n") |
14475 | { | |
d62a17ae | 14476 | vty_out(vty, "Address Refcnt Path\n"); |
14477 | aspath_print_all_vty(vty); | |
14478 | return CMD_SUCCESS; | |
718e3744 | 14479 | } |
14480 | ||
718e3744 | 14481 | #include "hash.h" |
14482 | ||
e3b78da8 | 14483 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14484 | struct vty *vty) |
718e3744 | 14485 | { |
d62a17ae | 14486 | struct community *com; |
718e3744 | 14487 | |
e3b78da8 | 14488 | com = (struct community *)bucket->data; |
3f65c5b1 | 14489 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 14490 | community_str(com, false)); |
718e3744 | 14491 | } |
14492 | ||
14493 | /* Show BGP's community internal data. */ | |
f412b39a | 14494 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 14495 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 14496 | "show [ip] bgp community-info", |
718e3744 | 14497 | SHOW_STR |
14498 | IP_STR | |
14499 | BGP_STR | |
14500 | "List all bgp community information\n") | |
14501 | { | |
d62a17ae | 14502 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 14503 | |
d62a17ae | 14504 | hash_iterate(community_hash(), |
e3b78da8 | 14505 | (void (*)(struct hash_bucket *, |
d62a17ae | 14506 | void *))community_show_all_iterator, |
14507 | vty); | |
718e3744 | 14508 | |
d62a17ae | 14509 | return CMD_SUCCESS; |
718e3744 | 14510 | } |
14511 | ||
e3b78da8 | 14512 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14513 | struct vty *vty) |
57d187bc | 14514 | { |
d62a17ae | 14515 | struct lcommunity *lcom; |
57d187bc | 14516 | |
e3b78da8 | 14517 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 14518 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 14519 | lcommunity_str(lcom, false)); |
57d187bc JS |
14520 | } |
14521 | ||
14522 | /* Show BGP's community internal data. */ | |
14523 | DEFUN (show_ip_bgp_lcommunity_info, | |
14524 | show_ip_bgp_lcommunity_info_cmd, | |
14525 | "show ip bgp large-community-info", | |
14526 | SHOW_STR | |
14527 | IP_STR | |
14528 | BGP_STR | |
14529 | "List all bgp large-community information\n") | |
14530 | { | |
d62a17ae | 14531 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 14532 | |
d62a17ae | 14533 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 14534 | (void (*)(struct hash_bucket *, |
d62a17ae | 14535 | void *))lcommunity_show_all_iterator, |
14536 | vty); | |
57d187bc | 14537 | |
d62a17ae | 14538 | return CMD_SUCCESS; |
57d187bc | 14539 | } |
2986cac2 | 14540 | /* Graceful Restart */ |
14541 | ||
14542 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
14543 | struct bgp *bgp, |
14544 | bool use_json, | |
14545 | json_object *json) | |
2986cac2 | 14546 | { |
57d187bc JS |
14547 | |
14548 | ||
2986cac2 | 14549 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
14550 | ||
7318ae88 | 14551 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 14552 | |
14553 | switch (bgp_global_gr_mode) { | |
14554 | ||
14555 | case GLOBAL_HELPER: | |
13909c4f | 14556 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 14557 | break; |
14558 | ||
14559 | case GLOBAL_GR: | |
13909c4f | 14560 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 14561 | break; |
14562 | ||
14563 | case GLOBAL_DISABLE: | |
13909c4f | 14564 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 14565 | break; |
14566 | ||
14567 | case GLOBAL_INVALID: | |
2986cac2 | 14568 | vty_out(vty, |
2ba1fe69 | 14569 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 14570 | break; |
14571 | } | |
14572 | vty_out(vty, "\n"); | |
14573 | } | |
14574 | ||
36235319 QY |
14575 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
14576 | enum show_type type, | |
14577 | const char *ip_str, | |
14578 | afi_t afi, bool use_json) | |
2986cac2 | 14579 | { |
14580 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14581 | afi = AFI_IP; | |
14582 | ||
14583 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14584 | ||
36235319 QY |
14585 | bgp_show_neighbor_graceful_restart_vty( |
14586 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 14587 | afi++; |
14588 | } | |
14589 | } else if (afi != AFI_MAX) { | |
36235319 QY |
14590 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
14591 | use_json); | |
2986cac2 | 14592 | } else { |
14593 | return CMD_ERR_INCOMPLETE; | |
14594 | } | |
14595 | ||
14596 | return CMD_SUCCESS; | |
14597 | } | |
14598 | /* Graceful Restart */ | |
14599 | ||
f412b39a | 14600 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 14601 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 14602 | "show [ip] bgp attribute-info", |
718e3744 | 14603 | SHOW_STR |
14604 | IP_STR | |
14605 | BGP_STR | |
14606 | "List all bgp attribute information\n") | |
14607 | { | |
d62a17ae | 14608 | attr_show_all(vty); |
14609 | return CMD_SUCCESS; | |
718e3744 | 14610 | } |
6b0655a2 | 14611 | |
03915806 CS |
14612 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
14613 | afi_t afi, safi_t safi, | |
14614 | bool use_json, json_object *json) | |
53089bec | 14615 | { |
14616 | struct bgp *bgp; | |
14617 | struct listnode *node; | |
14618 | char *vname; | |
14619 | char buf1[INET6_ADDRSTRLEN]; | |
14620 | char *ecom_str; | |
14621 | vpn_policy_direction_t dir; | |
14622 | ||
03915806 | 14623 | if (json) { |
b46dfd20 DS |
14624 | json_object *json_import_vrfs = NULL; |
14625 | json_object *json_export_vrfs = NULL; | |
14626 | ||
b46dfd20 DS |
14627 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14628 | ||
53089bec | 14629 | if (!bgp) { |
b46dfd20 DS |
14630 | vty_out(vty, "%s\n", |
14631 | json_object_to_json_string_ext( | |
14632 | json, | |
14633 | JSON_C_TO_STRING_PRETTY)); | |
14634 | json_object_free(json); | |
14635 | ||
53089bec | 14636 | return CMD_WARNING; |
14637 | } | |
b46dfd20 | 14638 | |
94d4c685 DS |
14639 | /* Provide context for the block */ |
14640 | json_object_string_add(json, "vrf", name ? name : "default"); | |
14641 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 14642 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 14643 | |
b46dfd20 DS |
14644 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14645 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14646 | json_object_string_add(json, "importFromVrfs", "none"); | |
14647 | json_object_string_add(json, "importRts", "none"); | |
14648 | } else { | |
6ce24e52 DS |
14649 | json_import_vrfs = json_object_new_array(); |
14650 | ||
b46dfd20 DS |
14651 | for (ALL_LIST_ELEMENTS_RO( |
14652 | bgp->vpn_policy[afi].import_vrf, | |
14653 | node, vname)) | |
14654 | json_object_array_add(json_import_vrfs, | |
14655 | json_object_new_string(vname)); | |
14656 | ||
b20875ea CS |
14657 | json_object_object_add(json, "importFromVrfs", |
14658 | json_import_vrfs); | |
b46dfd20 | 14659 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
14660 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14661 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14662 | bgp->vpn_policy[afi].rtlist[dir], |
14663 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14664 | json_object_string_add(json, "importRts", |
14665 | ecom_str); | |
14666 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14667 | } else | |
14668 | json_object_string_add(json, "importRts", | |
14669 | "none"); | |
b46dfd20 DS |
14670 | } |
14671 | ||
14672 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14673 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
14674 | json_object_string_add(json, "exportToVrfs", "none"); | |
14675 | json_object_string_add(json, "routeDistinguisher", | |
14676 | "none"); | |
14677 | json_object_string_add(json, "exportRts", "none"); | |
14678 | } else { | |
6ce24e52 DS |
14679 | json_export_vrfs = json_object_new_array(); |
14680 | ||
b46dfd20 DS |
14681 | for (ALL_LIST_ELEMENTS_RO( |
14682 | bgp->vpn_policy[afi].export_vrf, | |
14683 | node, vname)) | |
14684 | json_object_array_add(json_export_vrfs, | |
14685 | json_object_new_string(vname)); | |
14686 | json_object_object_add(json, "exportToVrfs", | |
14687 | json_export_vrfs); | |
14688 | json_object_string_add(json, "routeDistinguisher", | |
14689 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14690 | buf1, RD_ADDRSTRLEN)); | |
14691 | ||
14692 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14693 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14694 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14695 | bgp->vpn_policy[afi].rtlist[dir], |
14696 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14697 | json_object_string_add(json, "exportRts", |
14698 | ecom_str); | |
14699 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14700 | } else | |
14701 | json_object_string_add(json, "exportRts", | |
14702 | "none"); | |
b46dfd20 DS |
14703 | } |
14704 | ||
03915806 CS |
14705 | if (use_json) { |
14706 | vty_out(vty, "%s\n", | |
14707 | json_object_to_json_string_ext(json, | |
b46dfd20 | 14708 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
14709 | json_object_free(json); |
14710 | } | |
53089bec | 14711 | } else { |
b46dfd20 DS |
14712 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14713 | ||
53089bec | 14714 | if (!bgp) { |
b46dfd20 | 14715 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 14716 | return CMD_WARNING; |
14717 | } | |
53089bec | 14718 | |
b46dfd20 DS |
14719 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14720 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
14721 | vty_out(vty, | |
14722 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 14723 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14724 | else { |
14725 | vty_out(vty, | |
14726 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 14727 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14728 | |
14729 | for (ALL_LIST_ELEMENTS_RO( | |
14730 | bgp->vpn_policy[afi].import_vrf, | |
14731 | node, vname)) | |
14732 | vty_out(vty, " %s\n", vname); | |
14733 | ||
14734 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
14735 | ecom_str = NULL; |
14736 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14737 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14738 | bgp->vpn_policy[afi].rtlist[dir], |
14739 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 14740 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 14741 | |
b20875ea CS |
14742 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
14743 | } else | |
14744 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14745 | } |
53089bec | 14746 | |
b46dfd20 DS |
14747 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14748 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14749 | vty_out(vty, | |
14750 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 14751 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14752 | else { |
14753 | vty_out(vty, | |
04c9077f | 14754 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 14755 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14756 | |
14757 | for (ALL_LIST_ELEMENTS_RO( | |
14758 | bgp->vpn_policy[afi].export_vrf, | |
14759 | node, vname)) | |
14760 | vty_out(vty, " %s\n", vname); | |
14761 | ||
14762 | vty_out(vty, "RD: %s\n", | |
14763 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14764 | buf1, RD_ADDRSTRLEN)); | |
14765 | ||
14766 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14767 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14768 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14769 | bgp->vpn_policy[afi].rtlist[dir], |
14770 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14771 | vty_out(vty, "Export RT: %s\n", ecom_str); |
14772 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14773 | } else | |
14774 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14775 | } |
53089bec | 14776 | } |
14777 | ||
14778 | return CMD_SUCCESS; | |
14779 | } | |
14780 | ||
03915806 CS |
14781 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
14782 | safi_t safi, bool use_json) | |
14783 | { | |
14784 | struct listnode *node, *nnode; | |
14785 | struct bgp *bgp; | |
14786 | char *vrf_name = NULL; | |
14787 | json_object *json = NULL; | |
14788 | json_object *json_vrf = NULL; | |
14789 | json_object *json_vrfs = NULL; | |
14790 | ||
14791 | if (use_json) { | |
14792 | json = json_object_new_object(); | |
14793 | json_vrfs = json_object_new_object(); | |
14794 | } | |
14795 | ||
14796 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14797 | ||
14798 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
14799 | vrf_name = bgp->name; | |
14800 | ||
14801 | if (use_json) { | |
14802 | json_vrf = json_object_new_object(); | |
14803 | } else { | |
14804 | vty_out(vty, "\nInstance %s:\n", | |
14805 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14806 | ? VRF_DEFAULT_NAME : bgp->name); | |
14807 | } | |
14808 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
14809 | if (use_json) { | |
14810 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14811 | json_object_object_add(json_vrfs, | |
14812 | VRF_DEFAULT_NAME, json_vrf); | |
14813 | else | |
14814 | json_object_object_add(json_vrfs, vrf_name, | |
14815 | json_vrf); | |
14816 | } | |
14817 | } | |
14818 | ||
14819 | if (use_json) { | |
14820 | json_object_object_add(json, "vrfs", json_vrfs); | |
14821 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
14822 | JSON_C_TO_STRING_PRETTY)); | |
14823 | json_object_free(json); | |
14824 | } | |
14825 | ||
14826 | return CMD_SUCCESS; | |
14827 | } | |
14828 | ||
53089bec | 14829 | /* "show [ip] bgp route-leak" command. */ |
14830 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
14831 | show_ip_bgp_route_leak_cmd, |
14832 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
14833 | SHOW_STR |
14834 | IP_STR | |
14835 | BGP_STR | |
14836 | BGP_INSTANCE_HELP_STR | |
14837 | BGP_AFI_HELP_STR | |
14838 | BGP_SAFI_HELP_STR | |
14839 | "Route leaking information\n" | |
14840 | JSON_STR) | |
53089bec | 14841 | { |
14842 | char *vrf = NULL; | |
14843 | afi_t afi = AFI_MAX; | |
14844 | safi_t safi = SAFI_MAX; | |
14845 | ||
9f049418 | 14846 | bool uj = use_json(argc, argv); |
53089bec | 14847 | int idx = 0; |
03915806 | 14848 | json_object *json = NULL; |
53089bec | 14849 | |
14850 | /* show [ip] bgp */ | |
14851 | if (argv_find(argv, argc, "ip", &idx)) { | |
14852 | afi = AFI_IP; | |
14853 | safi = SAFI_UNICAST; | |
14854 | } | |
14855 | /* [vrf VIEWVRFNAME] */ | |
14856 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
14857 | vty_out(vty, |
14858 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 14859 | return CMD_WARNING; |
14860 | } | |
14861 | ||
9a8bdf1c PG |
14862 | if (argv_find(argv, argc, "vrf", &idx)) { |
14863 | vrf = argv[idx + 1]->arg; | |
14864 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14865 | vrf = NULL; | |
14866 | } | |
53089bec | 14867 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14868 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14869 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14870 | } | |
14871 | ||
14872 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
14873 | vty_out(vty, |
14874 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 14875 | return CMD_WARNING; |
14876 | } | |
14877 | ||
03915806 CS |
14878 | if (vrf && strmatch(vrf, "all")) |
14879 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14880 | ||
14881 | if (uj) | |
14882 | json = json_object_new_object(); | |
14883 | ||
14884 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 14885 | } |
14886 | ||
d62a17ae | 14887 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
14888 | safi_t safi) | |
f186de26 | 14889 | { |
d62a17ae | 14890 | struct listnode *node, *nnode; |
14891 | struct bgp *bgp; | |
f186de26 | 14892 | |
d62a17ae | 14893 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
14894 | vty_out(vty, "\nInstance %s:\n", | |
14895 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14896 | ? VRF_DEFAULT_NAME |
d62a17ae | 14897 | : bgp->name); |
14898 | update_group_show(bgp, afi, safi, vty, 0); | |
14899 | } | |
f186de26 | 14900 | } |
14901 | ||
d62a17ae | 14902 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
14903 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 14904 | { |
d62a17ae | 14905 | struct bgp *bgp; |
4fb25c53 | 14906 | |
d62a17ae | 14907 | if (name) { |
14908 | if (strmatch(name, "all")) { | |
14909 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
14910 | return CMD_SUCCESS; | |
14911 | } else { | |
14912 | bgp = bgp_lookup_by_name(name); | |
14913 | } | |
14914 | } else { | |
14915 | bgp = bgp_get_default(); | |
14916 | } | |
4fb25c53 | 14917 | |
d62a17ae | 14918 | if (bgp) |
14919 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
14920 | return CMD_SUCCESS; | |
4fb25c53 DW |
14921 | } |
14922 | ||
8fe8a7f6 DS |
14923 | DEFUN (show_ip_bgp_updgrps, |
14924 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 14925 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 14926 | SHOW_STR |
14927 | IP_STR | |
14928 | BGP_STR | |
14929 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 14930 | BGP_AFI_HELP_STR |
9bedbb1e | 14931 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
14932 | "Detailed info about dynamic update groups\n" |
14933 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 14934 | { |
d62a17ae | 14935 | char *vrf = NULL; |
14936 | afi_t afi = AFI_IP6; | |
14937 | safi_t safi = SAFI_UNICAST; | |
14938 | uint64_t subgrp_id = 0; | |
14939 | ||
14940 | int idx = 0; | |
14941 | ||
14942 | /* show [ip] bgp */ | |
14943 | if (argv_find(argv, argc, "ip", &idx)) | |
14944 | afi = AFI_IP; | |
9a8bdf1c PG |
14945 | /* [<vrf> VIEWVRFNAME] */ |
14946 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14947 | vrf = argv[idx + 1]->arg; | |
14948 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14949 | vrf = NULL; | |
14950 | } else if (argv_find(argv, argc, "view", &idx)) | |
14951 | /* [<view> VIEWVRFNAME] */ | |
14952 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 14953 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14954 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14955 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14956 | } | |
5bf15956 | 14957 | |
d62a17ae | 14958 | /* get subgroup id, if provided */ |
14959 | idx = argc - 1; | |
14960 | if (argv[idx]->type == VARIABLE_TKN) | |
14961 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 14962 | |
d62a17ae | 14963 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
14964 | } |
14965 | ||
f186de26 | 14966 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
14967 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 14968 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 14969 | SHOW_STR |
716b2d8a | 14970 | IP_STR |
f186de26 | 14971 | BGP_STR |
14972 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 14973 | "Detailed info about dynamic update groups\n") |
f186de26 | 14974 | { |
d62a17ae | 14975 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
14976 | return CMD_SUCCESS; | |
f186de26 | 14977 | } |
14978 | ||
43d3f4fc DS |
14979 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
14980 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
14981 | "show [ip] bgp l2vpn evpn update-groups", | |
14982 | SHOW_STR | |
14983 | IP_STR | |
14984 | BGP_STR | |
14985 | "l2vpn address family\n" | |
14986 | "evpn sub-address family\n" | |
14987 | "Detailed info about dynamic update groups\n") | |
14988 | { | |
14989 | char *vrf = NULL; | |
14990 | uint64_t subgrp_id = 0; | |
14991 | ||
14992 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
14993 | return CMD_SUCCESS; | |
14994 | } | |
14995 | ||
5bf15956 DW |
14996 | DEFUN (show_bgp_updgrps_stats, |
14997 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 14998 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 14999 | SHOW_STR |
716b2d8a | 15000 | IP_STR |
3f9c7369 | 15001 | BGP_STR |
0c7b1b01 | 15002 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15003 | "Statistics\n") |
15004 | { | |
d62a17ae | 15005 | struct bgp *bgp; |
3f9c7369 | 15006 | |
d62a17ae | 15007 | bgp = bgp_get_default(); |
15008 | if (bgp) | |
15009 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15010 | |
d62a17ae | 15011 | return CMD_SUCCESS; |
3f9c7369 DS |
15012 | } |
15013 | ||
8386ac43 | 15014 | DEFUN (show_bgp_instance_updgrps_stats, |
15015 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15016 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15017 | SHOW_STR |
716b2d8a | 15018 | IP_STR |
8386ac43 | 15019 | BGP_STR |
15020 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15021 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15022 | "Statistics\n") |
15023 | { | |
d62a17ae | 15024 | int idx_word = 3; |
15025 | struct bgp *bgp; | |
8386ac43 | 15026 | |
d62a17ae | 15027 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15028 | if (bgp) | |
15029 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15030 | |
d62a17ae | 15031 | return CMD_SUCCESS; |
8386ac43 | 15032 | } |
15033 | ||
d62a17ae | 15034 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15035 | afi_t afi, safi_t safi, | |
15036 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15037 | { |
d62a17ae | 15038 | struct bgp *bgp; |
8386ac43 | 15039 | |
d62a17ae | 15040 | if (name) |
15041 | bgp = bgp_lookup_by_name(name); | |
15042 | else | |
15043 | bgp = bgp_get_default(); | |
8386ac43 | 15044 | |
d62a17ae | 15045 | if (bgp) { |
15046 | if (!strcmp(what, "advertise-queue")) | |
15047 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15048 | subgrp_id); | |
15049 | else if (!strcmp(what, "advertised-routes")) | |
15050 | update_group_show_advertised(bgp, afi, safi, vty, | |
15051 | subgrp_id); | |
15052 | else if (!strcmp(what, "packet-queue")) | |
15053 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15054 | subgrp_id); | |
15055 | } | |
3f9c7369 DS |
15056 | } |
15057 | ||
dc64bdec QY |
15058 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15059 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15060 | "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", | |
15061 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15062 | BGP_SAFI_HELP_STR | |
15063 | "Detailed info about dynamic update groups\n" | |
15064 | "Specific subgroup to display info for\n" | |
15065 | "Advertisement queue\n" | |
15066 | "Announced routes\n" | |
15067 | "Packet queue\n") | |
3f9c7369 | 15068 | { |
dc64bdec QY |
15069 | uint64_t subgrp_id = 0; |
15070 | afi_t afiz; | |
15071 | safi_t safiz; | |
15072 | if (sgid) | |
15073 | subgrp_id = strtoull(sgid, NULL, 10); | |
15074 | ||
15075 | if (!ip && !afi) | |
15076 | afiz = AFI_IP6; | |
15077 | if (!ip && afi) | |
15078 | afiz = bgp_vty_afi_from_str(afi); | |
15079 | if (ip && !afi) | |
15080 | afiz = AFI_IP; | |
15081 | if (ip && afi) { | |
15082 | afiz = bgp_vty_afi_from_str(afi); | |
15083 | if (afiz != AFI_IP) | |
15084 | vty_out(vty, | |
15085 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15086 | return CMD_WARNING; | |
15087 | } | |
d62a17ae | 15088 | |
dc64bdec | 15089 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15090 | |
dc64bdec | 15091 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15092 | return CMD_SUCCESS; |
15093 | } | |
15094 | ||
d62a17ae | 15095 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
15096 | { | |
15097 | struct listnode *node, *nnode; | |
15098 | struct prefix *range; | |
15099 | struct peer *conf; | |
15100 | struct peer *peer; | |
d62a17ae | 15101 | afi_t afi; |
15102 | safi_t safi; | |
15103 | const char *peer_status; | |
15104 | const char *af_str; | |
15105 | int lr_count; | |
15106 | int dynamic; | |
15107 | int af_cfgd; | |
15108 | ||
15109 | conf = group->conf; | |
15110 | ||
15111 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
6cde4b45 | 15112 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 15113 | group->name, conf->as); |
d62a17ae | 15114 | } else if (conf->as_type == AS_INTERNAL) { |
6cde4b45 | 15115 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 15116 | group->name, group->bgp->as); |
d62a17ae | 15117 | } else { |
15118 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
15119 | } | |
f14e6fdb | 15120 | |
d62a17ae | 15121 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
15122 | vty_out(vty, " Peer-group type is internal\n"); | |
15123 | else | |
15124 | vty_out(vty, " Peer-group type is external\n"); | |
15125 | ||
15126 | /* Display AFs configured. */ | |
15127 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
15128 | FOREACH_AFI_SAFI (afi, safi) { |
15129 | if (conf->afc[afi][safi]) { | |
15130 | af_cfgd = 1; | |
5cb5f4d0 | 15131 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 15132 | } |
05c7a1cc | 15133 | } |
d62a17ae | 15134 | if (!af_cfgd) |
15135 | vty_out(vty, " none\n"); | |
15136 | else | |
15137 | vty_out(vty, "\n"); | |
15138 | ||
15139 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15140 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
15141 | if (afi == AFI_IP) | |
15142 | af_str = "IPv4"; | |
15143 | else if (afi == AFI_IP6) | |
15144 | af_str = "IPv6"; | |
15145 | else | |
15146 | af_str = "???"; | |
15147 | lr_count = listcount(group->listen_range[afi]); | |
15148 | if (lr_count) { | |
15149 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
15150 | af_str); | |
15151 | ||
15152 | ||
15153 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
2dbe669b DA |
15154 | nnode, range)) |
15155 | vty_out(vty, " %pFX\n", range); | |
d62a17ae | 15156 | } |
15157 | } | |
f14e6fdb | 15158 | |
d62a17ae | 15159 | /* Display group members and their status */ |
15160 | if (listcount(group->peer)) { | |
15161 | vty_out(vty, " Peer-group members:\n"); | |
15162 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
cb9196e7 DS |
15163 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15164 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15165 | peer_status = "Idle (Admin)"; |
15166 | else if (CHECK_FLAG(peer->sflags, | |
15167 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15168 | peer_status = "Idle (PfxCt)"; | |
15169 | else | |
15170 | peer_status = lookup_msg(bgp_status_msg, | |
15171 | peer->status, NULL); | |
15172 | ||
15173 | dynamic = peer_dynamic_neighbor(peer); | |
15174 | vty_out(vty, " %s %s %s \n", peer->host, | |
15175 | dynamic ? "(dynamic)" : "", peer_status); | |
15176 | } | |
15177 | } | |
f14e6fdb | 15178 | |
d62a17ae | 15179 | return CMD_SUCCESS; |
15180 | } | |
15181 | ||
ff9959b0 QY |
15182 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
15183 | const char *group_name) | |
d62a17ae | 15184 | { |
ff9959b0 | 15185 | struct bgp *bgp; |
d62a17ae | 15186 | struct listnode *node, *nnode; |
15187 | struct peer_group *group; | |
ff9959b0 QY |
15188 | bool found = false; |
15189 | ||
15190 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15191 | ||
15192 | if (!bgp) { | |
9f049418 | 15193 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
15194 | return CMD_WARNING; |
15195 | } | |
d62a17ae | 15196 | |
15197 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15198 | if (group_name) { |
15199 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 15200 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
15201 | found = true; |
15202 | break; | |
d62a17ae | 15203 | } |
ff9959b0 QY |
15204 | } else { |
15205 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 15206 | } |
f14e6fdb | 15207 | } |
f14e6fdb | 15208 | |
ff9959b0 | 15209 | if (group_name && !found) |
d62a17ae | 15210 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15211 | |
d62a17ae | 15212 | return CMD_SUCCESS; |
f14e6fdb DS |
15213 | } |
15214 | ||
f14e6fdb DS |
15215 | DEFUN (show_ip_bgp_peer_groups, |
15216 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 15217 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
15218 | SHOW_STR |
15219 | IP_STR | |
15220 | BGP_STR | |
8386ac43 | 15221 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
15222 | "Detailed information on BGP peer groups\n" |
15223 | "Peer group name\n") | |
f14e6fdb | 15224 | { |
d62a17ae | 15225 | char *vrf, *pg; |
d62a17ae | 15226 | int idx = 0; |
f14e6fdb | 15227 | |
a4d82a8a PZ |
15228 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15229 | : NULL; | |
d62a17ae | 15230 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15231 | |
ff9959b0 | 15232 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 15233 | } |
3f9c7369 | 15234 | |
d6e3c605 | 15235 | |
718e3744 | 15236 | /* Redistribute VTY commands. */ |
15237 | ||
37a87b8f CS |
15238 | DEFUN_YANG (bgp_redistribute_ipv4, |
15239 | bgp_redistribute_ipv4_cmd, | |
15240 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15241 | "Redistribute information from another routing protocol\n" | |
15242 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15243 | { |
d62a17ae | 15244 | int idx_protocol = 1; |
37a87b8f | 15245 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15246 | |
37a87b8f CS |
15247 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15248 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15249 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15250 | argv[idx_protocol]->text, "0"); | |
15251 | ||
15252 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
7f323236 | 15253 | |
37a87b8f | 15254 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 15255 | } |
15256 | ||
d62a17ae | 15257 | ALIAS_HIDDEN( |
15258 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15259 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15260 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 15261 | |
37a87b8f CS |
15262 | DEFUN_YANG (bgp_redistribute_ipv4_rmap, |
15263 | bgp_redistribute_ipv4_rmap_cmd, | |
15264 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15265 | "Redistribute information from another routing protocol\n" | |
15266 | FRR_IP_REDIST_HELP_STR_BGPD | |
15267 | "Route map reference\n" | |
15268 | "Pointer to route-map entries\n") | |
718e3744 | 15269 | { |
d62a17ae | 15270 | int idx_protocol = 1; |
15271 | int idx_word = 3; | |
37a87b8f CS |
15272 | char base_xpath[XPATH_MAXLEN]; |
15273 | ||
15274 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15275 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15276 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15277 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15278 | |
37a87b8f CS |
15279 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15280 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15281 | argv[idx_word]->arg); | |
15282 | ||
15283 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15284 | } |
15285 | ||
d62a17ae | 15286 | ALIAS_HIDDEN( |
15287 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
15288 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15289 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15290 | "Route map reference\n" | |
15291 | "Pointer to route-map entries\n") | |
596c17ba | 15292 | |
37a87b8f CS |
15293 | DEFUN_YANG (bgp_redistribute_ipv4_metric, |
15294 | bgp_redistribute_ipv4_metric_cmd, | |
15295 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15296 | "Redistribute information from another routing protocol\n" | |
15297 | FRR_IP_REDIST_HELP_STR_BGPD | |
15298 | "Metric for redistributed routes\n" | |
15299 | "Default metric\n") | |
718e3744 | 15300 | { |
d62a17ae | 15301 | int idx_protocol = 1; |
15302 | int idx_number = 3; | |
37a87b8f CS |
15303 | char base_xpath[XPATH_MAXLEN]; |
15304 | ||
15305 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15306 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15307 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15308 | argv[idx_protocol]->text, "0"); | |
d62a17ae | 15309 | |
37a87b8f CS |
15310 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15311 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15312 | argv[idx_number]->arg); | |
15313 | ||
15314 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 15315 | } |
15316 | ||
15317 | ALIAS_HIDDEN( | |
15318 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15319 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15320 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15321 | "Metric for redistributed routes\n" | |
15322 | "Default metric\n") | |
596c17ba | 15323 | |
37a87b8f CS |
15324 | DEFUN_YANG( |
15325 | bgp_redistribute_ipv4_rmap_metric, | |
15326 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
15327 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15328 | " route-map WORD metric (0-4294967295)", | |
15329 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15330 | "Route map reference\n" | |
15331 | "Pointer to route-map entries\n" | |
15332 | "Metric for redistributed routes\n" | |
15333 | "Default metric\n") | |
718e3744 | 15334 | { |
d62a17ae | 15335 | int idx_protocol = 1; |
15336 | int idx_word = 3; | |
15337 | int idx_number = 5; | |
37a87b8f CS |
15338 | char base_xpath[XPATH_MAXLEN]; |
15339 | ||
15340 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15341 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15342 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15343 | argv[idx_protocol]->text, "0"); | |
15344 | ||
15345 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15346 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15347 | argv[idx_word]->arg); | |
15348 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15349 | argv[idx_number]->arg); | |
d62a17ae | 15350 | |
37a87b8f | 15351 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15352 | } |
15353 | ||
15354 | ALIAS_HIDDEN( | |
15355 | bgp_redistribute_ipv4_rmap_metric, | |
15356 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15357 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15358 | " route-map WORD metric (0-4294967295)", | |
15359 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15360 | "Route map reference\n" | |
15361 | "Pointer to route-map entries\n" | |
15362 | "Metric for redistributed routes\n" | |
15363 | "Default metric\n") | |
596c17ba | 15364 | |
37a87b8f CS |
15365 | DEFUN_YANG( |
15366 | bgp_redistribute_ipv4_metric_rmap, | |
15367 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
15368 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15369 | " metric (0-4294967295) route-map WORD", | |
15370 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15371 | "Metric for redistributed routes\n" | |
15372 | "Default metric\n" | |
15373 | "Route map reference\n" | |
15374 | "Pointer to route-map entries\n") | |
718e3744 | 15375 | { |
d62a17ae | 15376 | int idx_protocol = 1; |
d62a17ae | 15377 | int idx_word = 5; |
37a87b8f CS |
15378 | int idx_number = 3; |
15379 | char base_xpath[XPATH_MAXLEN]; | |
15380 | ||
15381 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15382 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15383 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15384 | argv[idx_protocol]->text, "0"); | |
15385 | ||
15386 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15387 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15388 | argv[idx_number]->arg); | |
15389 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15390 | argv[idx_word]->arg); | |
d62a17ae | 15391 | |
37a87b8f | 15392 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15393 | } |
15394 | ||
15395 | ALIAS_HIDDEN( | |
15396 | bgp_redistribute_ipv4_metric_rmap, | |
15397 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15398 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15399 | " metric (0-4294967295) route-map WORD", | |
15400 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15401 | "Metric for redistributed routes\n" | |
15402 | "Default metric\n" | |
15403 | "Route map reference\n" | |
15404 | "Pointer to route-map entries\n") | |
596c17ba | 15405 | |
37a87b8f CS |
15406 | DEFUN_YANG (bgp_redistribute_ipv4_ospf, |
15407 | bgp_redistribute_ipv4_ospf_cmd, | |
15408 | "redistribute <ospf|table> (1-65535)", | |
15409 | "Redistribute information from another routing protocol\n" | |
15410 | "Open Shortest Path First (OSPFv2)\n" | |
15411 | "Non-main Kernel Routing Table\n" | |
15412 | "Instance ID/Table ID\n") | |
7c8ff89e | 15413 | { |
37a87b8f | 15414 | int idx_protocol = 1; |
d62a17ae | 15415 | int idx_number = 2; |
37a87b8f | 15416 | char base_xpath[XPATH_MAXLEN]; |
7c8ff89e | 15417 | |
37a87b8f CS |
15418 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15419 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15420 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15421 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
7a4bb9c5 | 15422 | |
37a87b8f | 15423 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
7a4bb9c5 | 15424 | |
37a87b8f | 15425 | return nb_cli_apply_changes(vty, base_xpath); |
7c8ff89e DS |
15426 | } |
15427 | ||
d62a17ae | 15428 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
15429 | "redistribute <ospf|table> (1-65535)", | |
15430 | "Redistribute information from another routing protocol\n" | |
15431 | "Open Shortest Path First (OSPFv2)\n" | |
15432 | "Non-main Kernel Routing Table\n" | |
15433 | "Instance ID/Table ID\n") | |
596c17ba | 15434 | |
37a87b8f CS |
15435 | DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap, |
15436 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
15437 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15438 | "Redistribute information from another routing protocol\n" | |
15439 | "Open Shortest Path First (OSPFv2)\n" | |
15440 | "Non-main Kernel Routing Table\n" | |
15441 | "Instance ID/Table ID\n" | |
15442 | "Route map reference\n" | |
15443 | "Pointer to route-map entries\n") | |
7c8ff89e | 15444 | { |
37a87b8f | 15445 | int idx_protocol = 1; |
d62a17ae | 15446 | int idx_number = 2; |
15447 | int idx_word = 4; | |
37a87b8f CS |
15448 | char base_xpath[XPATH_MAXLEN]; |
15449 | ||
15450 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15451 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15452 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15453 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15454 | ||
15455 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15456 | ||
15457 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15458 | argv[idx_word]->arg); | |
d62a17ae | 15459 | |
37a87b8f | 15460 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15461 | } |
15462 | ||
15463 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15464 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
15465 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15466 | "Redistribute information from another routing protocol\n" | |
15467 | "Open Shortest Path First (OSPFv2)\n" | |
15468 | "Non-main Kernel Routing Table\n" | |
15469 | "Instance ID/Table ID\n" | |
15470 | "Route map reference\n" | |
15471 | "Pointer to route-map entries\n") | |
596c17ba | 15472 | |
37a87b8f CS |
15473 | DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric, |
15474 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15475 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15476 | "Redistribute information from another routing protocol\n" | |
15477 | "Open Shortest Path First (OSPFv2)\n" | |
15478 | "Non-main Kernel Routing Table\n" | |
15479 | "Instance ID/Table ID\n" | |
15480 | "Metric for redistributed routes\n" | |
15481 | "Default metric\n") | |
7c8ff89e | 15482 | { |
37a87b8f | 15483 | int idx_protocol = 1; |
d62a17ae | 15484 | int idx_number = 2; |
15485 | int idx_number_2 = 4; | |
37a87b8f CS |
15486 | char base_xpath[XPATH_MAXLEN]; |
15487 | ||
15488 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15489 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15490 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15491 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15492 | ||
15493 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15494 | |
37a87b8f CS |
15495 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
15496 | argv[idx_number_2]->arg); | |
d62a17ae | 15497 | |
37a87b8f | 15498 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15499 | } |
15500 | ||
15501 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15502 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15503 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15504 | "Redistribute information from another routing protocol\n" | |
15505 | "Open Shortest Path First (OSPFv2)\n" | |
15506 | "Non-main Kernel Routing Table\n" | |
15507 | "Instance ID/Table ID\n" | |
15508 | "Metric for redistributed routes\n" | |
15509 | "Default metric\n") | |
596c17ba | 15510 | |
37a87b8f CS |
15511 | DEFUN_YANG( |
15512 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15513 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
15514 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15515 | "Redistribute information from another routing protocol\n" | |
15516 | "Open Shortest Path First (OSPFv2)\n" | |
15517 | "Non-main Kernel Routing Table\n" | |
15518 | "Instance ID/Table ID\n" | |
15519 | "Route map reference\n" | |
15520 | "Pointer to route-map entries\n" | |
15521 | "Metric for redistributed routes\n" | |
15522 | "Default metric\n") | |
7c8ff89e | 15523 | { |
37a87b8f | 15524 | int idx_protocol = 1; |
d62a17ae | 15525 | int idx_number = 2; |
15526 | int idx_word = 4; | |
15527 | int idx_number_2 = 6; | |
37a87b8f CS |
15528 | char base_xpath[XPATH_MAXLEN]; |
15529 | ||
15530 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15531 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15532 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15533 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15534 | ||
15535 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15536 | |
37a87b8f CS |
15537 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, |
15538 | argv[idx_word]->arg); | |
15539 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15540 | argv[idx_number_2]->arg); | |
d62a17ae | 15541 | |
37a87b8f | 15542 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15543 | } |
15544 | ||
15545 | ALIAS_HIDDEN( | |
15546 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15547 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
15548 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15549 | "Redistribute information from another routing protocol\n" | |
15550 | "Open Shortest Path First (OSPFv2)\n" | |
15551 | "Non-main Kernel Routing Table\n" | |
15552 | "Instance ID/Table ID\n" | |
15553 | "Route map reference\n" | |
15554 | "Pointer to route-map entries\n" | |
15555 | "Metric for redistributed routes\n" | |
15556 | "Default metric\n") | |
596c17ba | 15557 | |
37a87b8f CS |
15558 | DEFUN_YANG( |
15559 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15560 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
15561 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15562 | "Redistribute information from another routing protocol\n" | |
15563 | "Open Shortest Path First (OSPFv2)\n" | |
15564 | "Non-main Kernel Routing Table\n" | |
15565 | "Instance ID/Table ID\n" | |
15566 | "Metric for redistributed routes\n" | |
15567 | "Default metric\n" | |
15568 | "Route map reference\n" | |
15569 | "Pointer to route-map entries\n") | |
7c8ff89e | 15570 | { |
37a87b8f | 15571 | int idx_protocol = 1; |
d62a17ae | 15572 | int idx_number = 2; |
15573 | int idx_number_2 = 4; | |
15574 | int idx_word = 6; | |
37a87b8f CS |
15575 | char base_xpath[XPATH_MAXLEN]; |
15576 | ||
15577 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15578 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15579 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15580 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15581 | ||
15582 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15583 | |
37a87b8f CS |
15584 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
15585 | argv[idx_number_2]->arg); | |
15586 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15587 | argv[idx_word]->arg); | |
d62a17ae | 15588 | |
37a87b8f | 15589 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15590 | } |
15591 | ||
15592 | ALIAS_HIDDEN( | |
15593 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15594 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
15595 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15596 | "Redistribute information from another routing protocol\n" | |
15597 | "Open Shortest Path First (OSPFv2)\n" | |
15598 | "Non-main Kernel Routing Table\n" | |
15599 | "Instance ID/Table ID\n" | |
15600 | "Metric for redistributed routes\n" | |
15601 | "Default metric\n" | |
15602 | "Route map reference\n" | |
15603 | "Pointer to route-map entries\n") | |
596c17ba | 15604 | |
37a87b8f CS |
15605 | DEFUN_YANG (no_bgp_redistribute_ipv4_ospf, |
15606 | no_bgp_redistribute_ipv4_ospf_cmd, | |
15607 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15608 | NO_STR | |
15609 | "Redistribute information from another routing protocol\n" | |
15610 | "Open Shortest Path First (OSPFv2)\n" | |
15611 | "Non-main Kernel Routing Table\n" | |
15612 | "Instance ID/Table ID\n" | |
15613 | "Metric for redistributed routes\n" | |
15614 | "Default metric\n" | |
15615 | "Route map reference\n" | |
15616 | "Pointer to route-map entries\n") | |
7c8ff89e | 15617 | { |
37a87b8f | 15618 | int idx_protocol = 2; |
d62a17ae | 15619 | int idx_number = 3; |
37a87b8f | 15620 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 15621 | |
37a87b8f CS |
15622 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15623 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15624 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15625 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15626 | ||
15627 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
d62a17ae | 15628 | |
37a87b8f | 15629 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15630 | } |
15631 | ||
15632 | ALIAS_HIDDEN( | |
15633 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 15634 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15635 | NO_STR |
15636 | "Redistribute information from another routing protocol\n" | |
15637 | "Open Shortest Path First (OSPFv2)\n" | |
15638 | "Non-main Kernel Routing Table\n" | |
15639 | "Instance ID/Table ID\n" | |
15640 | "Metric for redistributed routes\n" | |
15641 | "Default metric\n" | |
15642 | "Route map reference\n" | |
15643 | "Pointer to route-map entries\n") | |
596c17ba | 15644 | |
37a87b8f CS |
15645 | DEFUN_YANG (no_bgp_redistribute_ipv4, |
15646 | no_bgp_redistribute_ipv4_cmd, | |
15647 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15648 | NO_STR | |
15649 | "Redistribute information from another routing protocol\n" | |
15650 | FRR_IP_REDIST_HELP_STR_BGPD | |
15651 | "Metric for redistributed routes\n" | |
15652 | "Default metric\n" | |
15653 | "Route map reference\n" | |
15654 | "Pointer to route-map entries\n") | |
718e3744 | 15655 | { |
d62a17ae | 15656 | int idx_protocol = 2; |
37a87b8f | 15657 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 15658 | |
37a87b8f CS |
15659 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15660 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15661 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15662 | argv[idx_protocol]->text, "0"); | |
15663 | ||
15664 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
15665 | ||
15666 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 15667 | } |
15668 | ||
15669 | ALIAS_HIDDEN( | |
15670 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
15671 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 15672 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15673 | NO_STR |
15674 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15675 | "Metric for redistributed routes\n" | |
15676 | "Default metric\n" | |
15677 | "Route map reference\n" | |
15678 | "Pointer to route-map entries\n") | |
596c17ba | 15679 | |
37a87b8f CS |
15680 | DEFUN_YANG (bgp_redistribute_ipv6, |
15681 | bgp_redistribute_ipv6_cmd, | |
15682 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
15683 | "Redistribute information from another routing protocol\n" | |
15684 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 15685 | { |
d62a17ae | 15686 | int idx_protocol = 1; |
37a87b8f | 15687 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15688 | |
37a87b8f CS |
15689 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15690 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15691 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15692 | argv[idx_protocol]->text, "0"); | |
15693 | ||
15694 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
718e3744 | 15695 | |
37a87b8f | 15696 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 15697 | } |
15698 | ||
37a87b8f CS |
15699 | DEFUN_YANG (bgp_redistribute_ipv6_rmap, |
15700 | bgp_redistribute_ipv6_rmap_cmd, | |
15701 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
15702 | "Redistribute information from another routing protocol\n" | |
15703 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15704 | "Route map reference\n" | |
15705 | "Pointer to route-map entries\n") | |
718e3744 | 15706 | { |
d62a17ae | 15707 | int idx_protocol = 1; |
15708 | int idx_word = 3; | |
37a87b8f CS |
15709 | char base_xpath[XPATH_MAXLEN]; |
15710 | ||
15711 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15712 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15713 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15714 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15715 | |
37a87b8f CS |
15716 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15717 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15718 | argv[idx_word]->arg); | |
15719 | ||
15720 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15721 | } |
15722 | ||
37a87b8f | 15723 | DEFUN_YANG (bgp_redistribute_ipv6_metric, |
718e3744 | 15724 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 15725 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 15726 | "Redistribute information from another routing protocol\n" |
ab0181ee | 15727 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 15728 | "Metric for redistributed routes\n" |
15729 | "Default metric\n") | |
15730 | { | |
d62a17ae | 15731 | int idx_protocol = 1; |
15732 | int idx_number = 3; | |
37a87b8f CS |
15733 | char base_xpath[XPATH_MAXLEN]; |
15734 | ||
15735 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15736 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15737 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15738 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15739 | |
37a87b8f CS |
15740 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15741 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15742 | argv[idx_number]->arg); | |
15743 | ||
15744 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15745 | } |
15746 | ||
37a87b8f CS |
15747 | DEFUN_YANG( |
15748 | bgp_redistribute_ipv6_rmap_metric, | |
15749 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
15750 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
15751 | " route-map WORD metric (0-4294967295)", | |
15752 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
15753 | "Route map reference\n" | |
15754 | "Pointer to route-map entries\n" | |
15755 | "Metric for redistributed routes\n" | |
15756 | "Default metric\n") | |
718e3744 | 15757 | { |
d62a17ae | 15758 | int idx_protocol = 1; |
15759 | int idx_word = 3; | |
15760 | int idx_number = 5; | |
37a87b8f CS |
15761 | char base_xpath[XPATH_MAXLEN]; |
15762 | ||
15763 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15764 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15765 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15766 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15767 | |
37a87b8f CS |
15768 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15769 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15770 | argv[idx_word]->arg); | |
15771 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15772 | argv[idx_number]->arg); | |
15773 | ||
15774 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15775 | } |
15776 | ||
37a87b8f CS |
15777 | DEFUN_YANG( |
15778 | bgp_redistribute_ipv6_metric_rmap, | |
15779 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
15780 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
15781 | " metric (0-4294967295) route-map WORD", | |
15782 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
15783 | "Metric for redistributed routes\n" | |
15784 | "Default metric\n" | |
15785 | "Route map reference\n" | |
15786 | "Pointer to route-map entries\n") | |
718e3744 | 15787 | { |
d62a17ae | 15788 | int idx_protocol = 1; |
d62a17ae | 15789 | int idx_word = 5; |
37a87b8f CS |
15790 | int idx_number = 3; |
15791 | char base_xpath[XPATH_MAXLEN]; | |
15792 | ||
15793 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15794 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15795 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15796 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15797 | |
37a87b8f CS |
15798 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15799 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15800 | argv[idx_number]->arg); | |
15801 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15802 | argv[idx_word]->arg); | |
15803 | ||
15804 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15805 | } |
15806 | ||
37a87b8f CS |
15807 | DEFUN_YANG( |
15808 | no_bgp_redistribute_ipv6, | |
15809 | no_bgp_redistribute_ipv6_cmd, | |
15810 | "no redistribute " FRR_IP6_REDIST_STR_BGPD | |
15811 | " [{metric (0-4294967295)|route-map WORD}]", | |
15812 | NO_STR | |
15813 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
15814 | "Metric for redistributed routes\n" | |
15815 | "Default metric\n" | |
15816 | "Route map reference\n" | |
15817 | "Pointer to route-map entries\n") | |
718e3744 | 15818 | { |
d62a17ae | 15819 | int idx_protocol = 2; |
37a87b8f | 15820 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15821 | |
37a87b8f CS |
15822 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15823 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15824 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15825 | argv[idx_protocol]->text, "0"); | |
15826 | ||
15827 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
15828 | ||
15829 | return nb_cli_apply_changes(vty, base_xpath); | |
15830 | } | |
718e3744 | 15831 | |
37a87b8f CS |
15832 | void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list( |
15833 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
15834 | { | |
15835 | uint32_t instance = 0; | |
15836 | ||
15837 | vty_out(vty, " redistribute %s", | |
15838 | yang_dnode_get_string(dnode, "./route-type")); | |
15839 | if ((instance = yang_dnode_get_uint16(dnode, "./route-instance"))) | |
15840 | vty_out(vty, " %d", instance); | |
15841 | if (yang_dnode_exists(dnode, "./metric")) | |
15842 | vty_out(vty, " metric %u", | |
15843 | yang_dnode_get_uint32(dnode, "./metric")); | |
15844 | if (yang_dnode_exists(dnode, "./rmap-policy-import")) | |
15845 | vty_out(vty, " route-map %s", | |
15846 | yang_dnode_get_string(dnode, "./rmap-policy-import")); | |
15847 | vty_out(vty, "\n"); | |
d62a17ae | 15848 | } |
15849 | ||
dd65f45e DL |
15850 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
15851 | afi_t afi, safi_t safi) | |
d62a17ae | 15852 | { |
15853 | int i; | |
15854 | ||
15855 | /* Unicast redistribution only. */ | |
15856 | if (safi != SAFI_UNICAST) | |
2b791107 | 15857 | return; |
d62a17ae | 15858 | |
15859 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
15860 | /* Redistribute BGP does not make sense. */ | |
15861 | if (i != ZEBRA_ROUTE_BGP) { | |
15862 | struct list *red_list; | |
15863 | struct listnode *node; | |
15864 | struct bgp_redist *red; | |
15865 | ||
15866 | red_list = bgp->redist[afi][i]; | |
15867 | if (!red_list) | |
15868 | continue; | |
15869 | ||
15870 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 15871 | /* "redistribute" configuration. */ |
15872 | vty_out(vty, " redistribute %s", | |
15873 | zebra_route_string(i)); | |
15874 | if (red->instance) | |
15875 | vty_out(vty, " %d", red->instance); | |
15876 | if (red->redist_metric_flag) | |
15877 | vty_out(vty, " metric %u", | |
15878 | red->redist_metric); | |
15879 | if (red->rmap.name) | |
15880 | vty_out(vty, " route-map %s", | |
15881 | red->rmap.name); | |
15882 | vty_out(vty, "\n"); | |
15883 | } | |
15884 | } | |
15885 | } | |
718e3744 | 15886 | } |
6b0655a2 | 15887 | |
dd65f45e DL |
15888 | /* peer-group helpers for config-write */ |
15889 | ||
15890 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
15891 | { | |
15892 | if (!peer_group_active(peer)) { | |
15893 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
15894 | return !CHECK_FLAG(peer->flags, flag); | |
15895 | else | |
15896 | return !!CHECK_FLAG(peer->flags, flag); | |
15897 | } | |
15898 | ||
15899 | return !!CHECK_FLAG(peer->flags_override, flag); | |
15900 | } | |
15901 | ||
15902 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
15903 | uint32_t flag) | |
15904 | { | |
15905 | if (!peer_group_active(peer)) { | |
15906 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
15907 | return !peer_af_flag_check(peer, afi, safi, flag); | |
15908 | else | |
15909 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
15910 | } | |
15911 | ||
15912 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
15913 | } | |
15914 | ||
15915 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
15916 | uint8_t type, int direct) | |
15917 | { | |
15918 | struct bgp_filter *filter; | |
15919 | ||
15920 | if (peer_group_active(peer)) | |
15921 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
15922 | type); | |
15923 | ||
15924 | filter = &peer->filter[afi][safi]; | |
15925 | switch (type) { | |
15926 | case PEER_FT_DISTRIBUTE_LIST: | |
15927 | return !!(filter->dlist[direct].name); | |
15928 | case PEER_FT_FILTER_LIST: | |
15929 | return !!(filter->aslist[direct].name); | |
15930 | case PEER_FT_PREFIX_LIST: | |
15931 | return !!(filter->plist[direct].name); | |
15932 | case PEER_FT_ROUTE_MAP: | |
15933 | return !!(filter->map[direct].name); | |
15934 | case PEER_FT_UNSUPPRESS_MAP: | |
15935 | return !!(filter->usmap.name); | |
7f7940e6 MK |
15936 | case PEER_FT_ADVERTISE_MAP: |
15937 | return !!(filter->advmap.aname | |
15938 | && ((filter->advmap.condition == direct) | |
15939 | && filter->advmap.cname)); | |
dd65f45e DL |
15940 | default: |
15941 | return false; | |
15942 | } | |
15943 | } | |
15944 | ||
15945 | /* Return true if the addpath type is set for peer and different from | |
15946 | * peer-group. | |
15947 | */ | |
3dc339cd DA |
15948 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
15949 | safi_t safi) | |
dd65f45e DL |
15950 | { |
15951 | enum bgp_addpath_strat type, g_type; | |
15952 | ||
15953 | type = peer->addpath_type[afi][safi]; | |
15954 | ||
15955 | if (type != BGP_ADDPATH_NONE) { | |
15956 | if (peer_group_active(peer)) { | |
15957 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
15958 | ||
15959 | if (type != g_type) | |
3dc339cd | 15960 | return true; |
dd65f45e | 15961 | else |
3dc339cd | 15962 | return false; |
dd65f45e DL |
15963 | } |
15964 | ||
3dc339cd | 15965 | return true; |
dd65f45e DL |
15966 | } |
15967 | ||
3dc339cd | 15968 | return false; |
dd65f45e DL |
15969 | } |
15970 | ||
b9c7bc5a | 15971 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 15972 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
15973 | afi_t afi) |
15974 | { | |
b9c7bc5a | 15975 | int indent = 2; |
ddb5b488 | 15976 | |
8a066a70 | 15977 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
15978 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
15979 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
15980 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
15981 | bgp->vpn_policy[afi] | |
bb4f6190 | 15982 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
15983 | else |
15984 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
15985 | bgp->vpn_policy[afi] | |
15986 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
15987 | } | |
12a844a5 DS |
15988 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
15989 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
15990 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
15991 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
15992 | return; | |
15993 | ||
e70e9f8e PZ |
15994 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
15995 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
15996 | ||
15997 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
15998 | ||
15999 | } else { | |
16000 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16001 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16002 | bgp->vpn_policy[afi].tovpn_label); | |
16003 | } | |
ddb5b488 PZ |
16004 | } |
16005 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16006 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16007 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 16008 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
16009 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
16010 | sizeof(buf))); | |
16011 | } | |
16012 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16013 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16014 | ||
16015 | char buf[PREFIX_STRLEN]; | |
16016 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16017 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16018 | sizeof(buf))) { | |
16019 | ||
b9c7bc5a PZ |
16020 | vty_out(vty, "%*snexthop vpn export %s\n", |
16021 | indent, "", buf); | |
ddb5b488 PZ |
16022 | } |
16023 | } | |
16024 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16025 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16026 | && ecommunity_cmp( | |
16027 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16028 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16029 | ||
16030 | char *b = ecommunity_ecom2str( | |
16031 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16032 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16033 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16034 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16035 | } else { | |
16036 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16037 | char *b = ecommunity_ecom2str( | |
16038 | bgp->vpn_policy[afi] | |
16039 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16040 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16041 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16042 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16043 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16044 | } | |
16045 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16046 | char *b = ecommunity_ecom2str( | |
16047 | bgp->vpn_policy[afi] | |
16048 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16049 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16050 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16051 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16052 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16053 | } | |
16054 | } | |
bb4f6190 DS |
16055 | |
16056 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16057 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16058 | bgp->vpn_policy[afi] |
16059 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16060 | |
301ad80a PG |
16061 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16062 | char *b = ecommunity_ecom2str( | |
16063 | bgp->vpn_policy[afi] | |
16064 | .import_redirect_rtlist, | |
16065 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16066 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16067 | |
9a659715 PG |
16068 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16069 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16070 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16071 | indent, "", b); |
16072 | else | |
16073 | vty_out(vty, "%*srt redirect import %s\n", | |
16074 | indent, "", b); | |
301ad80a PG |
16075 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16076 | } | |
ddb5b488 PZ |
16077 | } |
16078 | ||
dd65f45e DL |
16079 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16080 | afi_t afi, safi_t safi) | |
16081 | { | |
16082 | struct bgp_filter *filter; | |
16083 | char *addr; | |
16084 | ||
16085 | addr = peer->host; | |
16086 | filter = &peer->filter[afi][safi]; | |
16087 | ||
16088 | /* distribute-list. */ | |
16089 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16090 | FILTER_IN)) | |
16091 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16092 | filter->dlist[FILTER_IN].name); | |
16093 | ||
16094 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16095 | FILTER_OUT)) | |
16096 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16097 | filter->dlist[FILTER_OUT].name); | |
16098 | ||
16099 | /* prefix-list. */ | |
16100 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16101 | FILTER_IN)) | |
16102 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16103 | filter->plist[FILTER_IN].name); | |
16104 | ||
16105 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16106 | FILTER_OUT)) | |
16107 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16108 | filter->plist[FILTER_OUT].name); | |
16109 | ||
16110 | /* route-map. */ | |
16111 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16112 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16113 | filter->map[RMAP_IN].name); | |
16114 | ||
16115 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16116 | RMAP_OUT)) | |
16117 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16118 | filter->map[RMAP_OUT].name); | |
16119 | ||
16120 | /* unsuppress-map */ | |
16121 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16122 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16123 | filter->usmap.name); | |
16124 | ||
7f7940e6 MK |
16125 | /* advertise-map : always applied in OUT direction*/ |
16126 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16127 | CONDITION_NON_EXIST)) | |
16128 | vty_out(vty, | |
16129 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16130 | addr, filter->advmap.aname, filter->advmap.cname); | |
16131 | ||
16132 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16133 | CONDITION_EXIST)) | |
16134 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16135 | addr, filter->advmap.aname, filter->advmap.cname); | |
16136 | ||
dd65f45e DL |
16137 | /* filter-list. */ |
16138 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16139 | FILTER_IN)) | |
16140 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16141 | filter->aslist[FILTER_IN].name); | |
16142 | ||
16143 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16144 | FILTER_OUT)) | |
16145 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16146 | filter->aslist[FILTER_OUT].name); | |
16147 | } | |
16148 | ||
16149 | /* BGP peer configuration display function. */ | |
16150 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16151 | struct peer *peer) | |
16152 | { | |
16153 | struct peer *g_peer = NULL; | |
16154 | char buf[SU_ADDRSTRLEN]; | |
16155 | char *addr; | |
16156 | int if_pg_printed = false; | |
16157 | int if_ras_printed = false; | |
16158 | ||
16159 | /* Skip dynamic neighbors. */ | |
16160 | if (peer_dynamic_neighbor(peer)) | |
16161 | return; | |
16162 | ||
16163 | if (peer->conf_if) | |
16164 | addr = peer->conf_if; | |
16165 | else | |
16166 | addr = peer->host; | |
16167 | ||
16168 | /************************************ | |
16169 | ****** Global to the neighbor ****** | |
16170 | ************************************/ | |
16171 | if (peer->conf_if) { | |
16172 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16173 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16174 | else | |
16175 | vty_out(vty, " neighbor %s interface", addr); | |
16176 | ||
16177 | if (peer_group_active(peer)) { | |
16178 | vty_out(vty, " peer-group %s", peer->group->name); | |
16179 | if_pg_printed = true; | |
16180 | } else if (peer->as_type == AS_SPECIFIED) { | |
16181 | vty_out(vty, " remote-as %u", peer->as); | |
16182 | if_ras_printed = true; | |
16183 | } else if (peer->as_type == AS_INTERNAL) { | |
16184 | vty_out(vty, " remote-as internal"); | |
16185 | if_ras_printed = true; | |
16186 | } else if (peer->as_type == AS_EXTERNAL) { | |
16187 | vty_out(vty, " remote-as external"); | |
16188 | if_ras_printed = true; | |
16189 | } | |
16190 | ||
16191 | vty_out(vty, "\n"); | |
16192 | } | |
16193 | ||
16194 | /* remote-as and peer-group */ | |
16195 | /* peer is a member of a peer-group */ | |
16196 | if (peer_group_active(peer)) { | |
16197 | g_peer = peer->group->conf; | |
16198 | ||
16199 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16200 | if (peer->as_type == AS_SPECIFIED) { | |
16201 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16202 | addr, peer->as); | |
16203 | } else if (peer->as_type == AS_INTERNAL) { | |
16204 | vty_out(vty, | |
16205 | " neighbor %s remote-as internal\n", | |
16206 | addr); | |
16207 | } else if (peer->as_type == AS_EXTERNAL) { | |
16208 | vty_out(vty, | |
16209 | " neighbor %s remote-as external\n", | |
16210 | addr); | |
16211 | } | |
16212 | } | |
16213 | ||
16214 | /* For swpX peers we displayed the peer-group | |
16215 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16216 | if (!if_pg_printed) | |
16217 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16218 | peer->group->name); | |
16219 | } | |
16220 | ||
16221 | /* peer is NOT a member of a peer-group */ | |
16222 | else { | |
16223 | /* peer is a peer-group, declare the peer-group */ | |
16224 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16225 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16226 | } | |
16227 | ||
16228 | if (!if_ras_printed) { | |
16229 | if (peer->as_type == AS_SPECIFIED) { | |
16230 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16231 | addr, peer->as); | |
16232 | } else if (peer->as_type == AS_INTERNAL) { | |
16233 | vty_out(vty, | |
16234 | " neighbor %s remote-as internal\n", | |
16235 | addr); | |
16236 | } else if (peer->as_type == AS_EXTERNAL) { | |
16237 | vty_out(vty, | |
16238 | " neighbor %s remote-as external\n", | |
16239 | addr); | |
16240 | } | |
16241 | } | |
16242 | } | |
16243 | ||
16244 | /* local-as */ | |
16245 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16246 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16247 | peer->change_local_as); | |
16248 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16249 | vty_out(vty, " no-prepend"); | |
16250 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16251 | vty_out(vty, " replace-as"); | |
16252 | vty_out(vty, "\n"); | |
16253 | } | |
16254 | ||
16255 | /* description */ | |
16256 | if (peer->desc) { | |
16257 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16258 | } | |
16259 | ||
16260 | /* shutdown */ | |
16261 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16262 | if (peer->tx_shutdown_message) | |
16263 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16264 | peer->tx_shutdown_message); | |
16265 | else | |
16266 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16267 | } | |
16268 | ||
8336c896 DA |
16269 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
16270 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16271 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16272 | ||
dd65f45e DL |
16273 | /* bfd */ |
16274 | if (peer->bfd_info) { | |
16275 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
16276 | bgp_bfd_peer_config_write(vty, peer, addr); | |
16277 | } | |
16278 | } | |
16279 | ||
16280 | /* password */ | |
16281 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16282 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16283 | peer->password); | |
16284 | ||
16285 | /* neighbor solo */ | |
16286 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16287 | if (!peer_group_active(peer)) { | |
16288 | vty_out(vty, " neighbor %s solo\n", addr); | |
16289 | } | |
16290 | } | |
16291 | ||
16292 | /* BGP port */ | |
16293 | if (peer->port != BGP_PORT_DEFAULT) { | |
16294 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16295 | } | |
16296 | ||
16297 | /* Local interface name */ | |
16298 | if (peer->ifname) { | |
16299 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16300 | } | |
16301 | ||
16302 | /* passive */ | |
16303 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16304 | vty_out(vty, " neighbor %s passive\n", addr); | |
16305 | ||
16306 | /* ebgp-multihop */ | |
16307 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
16308 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
16309 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
16310 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
16311 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16312 | peer->ttl); | |
16313 | } | |
16314 | } | |
16315 | ||
16316 | /* ttl-security hops */ | |
e2521429 | 16317 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
16318 | if (!peer_group_active(peer) |
16319 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16320 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16321 | addr, peer->gtsm_hops); | |
16322 | } | |
16323 | } | |
16324 | ||
16325 | /* disable-connected-check */ | |
16326 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16327 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16328 | ||
16329 | /* enforce-first-as */ | |
16330 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16331 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16332 | ||
16333 | /* update-source */ | |
16334 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16335 | if (peer->update_source) | |
16336 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16337 | sockunion2str(peer->update_source, buf, | |
16338 | SU_ADDRSTRLEN)); | |
16339 | else if (peer->update_if) | |
16340 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16341 | peer->update_if); | |
16342 | } | |
16343 | ||
16344 | /* advertisement-interval */ | |
16345 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16346 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16347 | peer->routeadv); | |
16348 | ||
16349 | /* timers */ | |
16350 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16351 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16352 | peer->keepalive, peer->holdtime); | |
16353 | ||
16354 | /* timers connect */ | |
16355 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16356 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16357 | peer->connect); | |
5d5393b9 DL |
16358 | /* need special-case handling for changed default values due to |
16359 | * config profile / version (because there is no "timers bgp connect" | |
16360 | * command, we need to save this per-peer :/) | |
16361 | */ | |
16362 | else if (!peer_group_active(peer) && !peer->connect && | |
16363 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16364 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16365 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
16366 | |
16367 | /* capability dynamic */ | |
16368 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16369 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16370 | ||
16371 | /* capability extended-nexthop */ | |
16372 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
16373 | if (!peer->conf_if) { | |
16374 | if (CHECK_FLAG(peer->flags_invert, | |
16375 | PEER_FLAG_CAPABILITY_ENHE)) | |
16376 | vty_out(vty, | |
16377 | " no neighbor %s capability extended-nexthop\n", | |
16378 | addr); | |
16379 | else | |
16380 | vty_out(vty, | |
16381 | " neighbor %s capability extended-nexthop\n", | |
16382 | addr); | |
16383 | } | |
16384 | } | |
16385 | ||
16386 | /* dont-capability-negotiation */ | |
16387 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16388 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16389 | ||
16390 | /* override-capability */ | |
16391 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16392 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16393 | ||
16394 | /* strict-capability-match */ | |
16395 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16396 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16397 | ||
16398 | /* Sender side AS path loop detection. */ | |
16399 | if (peer->as_path_loop_detection) | |
16400 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16401 | addr); | |
cfd47646 | 16402 | |
16403 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16404 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 16405 | |
16406 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16407 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 16408 | vty_out(vty, |
16409 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
16410 | } else if (CHECK_FLAG( |
16411 | peer->peer_gr_new_status_flag, | |
16412 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 16413 | vty_out(vty, |
16414 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
16415 | } else if ( |
16416 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16417 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16418 | && !(CHECK_FLAG( | |
16419 | peer->peer_gr_new_status_flag, | |
16420 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16421 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16422 | addr); | |
cfd47646 | 16423 | } |
16424 | } | |
dd65f45e DL |
16425 | } |
16426 | ||
16427 | /* BGP peer configuration display function. */ | |
16428 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16429 | struct peer *peer, afi_t afi, safi_t safi) | |
16430 | { | |
16431 | struct peer *g_peer = NULL; | |
16432 | char *addr; | |
16433 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16434 | ||
16435 | /* Skip dynamic neighbors. */ | |
16436 | if (peer_dynamic_neighbor(peer)) | |
16437 | return; | |
16438 | ||
16439 | if (peer->conf_if) | |
16440 | addr = peer->conf_if; | |
16441 | else | |
16442 | addr = peer->host; | |
16443 | ||
16444 | /************************************ | |
16445 | ****** Per AF to the neighbor ****** | |
16446 | ************************************/ | |
16447 | if (peer_group_active(peer)) { | |
16448 | g_peer = peer->group->conf; | |
16449 | ||
16450 | /* If the peer-group is active but peer is not, print a 'no | |
16451 | * activate' */ | |
16452 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16453 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16454 | } | |
16455 | ||
16456 | /* If the peer-group is not active but peer is, print an | |
16457 | 'activate' */ | |
16458 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16459 | vty_out(vty, " neighbor %s activate\n", addr); | |
16460 | } | |
16461 | } else { | |
16462 | if (peer->afc[afi][safi]) { | |
16463 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
16464 | if (CHECK_FLAG(bgp->flags, |
16465 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
16466 | vty_out(vty, " neighbor %s activate\n", |
16467 | addr); | |
16468 | } | |
16469 | } else | |
16470 | vty_out(vty, " neighbor %s activate\n", addr); | |
16471 | } else { | |
16472 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
16473 | if (!CHECK_FLAG(bgp->flags, |
16474 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
16475 | vty_out(vty, |
16476 | " no neighbor %s activate\n", | |
16477 | addr); | |
16478 | } | |
16479 | } | |
16480 | } | |
16481 | } | |
16482 | ||
16483 | /* addpath TX knobs */ | |
16484 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16485 | switch (peer->addpath_type[afi][safi]) { | |
16486 | case BGP_ADDPATH_ALL: | |
16487 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16488 | addr); | |
16489 | break; | |
16490 | case BGP_ADDPATH_BEST_PER_AS: | |
16491 | vty_out(vty, | |
16492 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16493 | addr); | |
16494 | break; | |
16495 | case BGP_ADDPATH_MAX: | |
16496 | case BGP_ADDPATH_NONE: | |
16497 | break; | |
16498 | } | |
16499 | } | |
16500 | ||
16501 | /* ORF capability. */ | |
16502 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16503 | || peergroup_af_flag_check(peer, afi, safi, | |
16504 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16505 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16506 | ||
16507 | if (peergroup_af_flag_check(peer, afi, safi, | |
16508 | PEER_FLAG_ORF_PREFIX_SM) | |
16509 | && peergroup_af_flag_check(peer, afi, safi, | |
16510 | PEER_FLAG_ORF_PREFIX_RM)) | |
16511 | vty_out(vty, " both"); | |
16512 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16513 | PEER_FLAG_ORF_PREFIX_SM)) | |
16514 | vty_out(vty, " send"); | |
16515 | else | |
16516 | vty_out(vty, " receive"); | |
16517 | vty_out(vty, "\n"); | |
16518 | } | |
16519 | ||
dd65f45e DL |
16520 | /* Route reflector client. */ |
16521 | if (peergroup_af_flag_check(peer, afi, safi, | |
16522 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16523 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16524 | } | |
16525 | ||
16526 | /* next-hop-self force */ | |
16527 | if (peergroup_af_flag_check(peer, afi, safi, | |
16528 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16529 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16530 | } | |
16531 | ||
16532 | /* next-hop-self */ | |
16533 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16534 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16535 | } | |
16536 | ||
16537 | /* remove-private-AS */ | |
16538 | if (peergroup_af_flag_check(peer, afi, safi, | |
16539 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16540 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16541 | addr); | |
16542 | } | |
16543 | ||
16544 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16545 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16546 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16547 | addr); | |
16548 | } | |
16549 | ||
16550 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16551 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16552 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16553 | } | |
16554 | ||
16555 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16556 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16557 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16558 | } | |
16559 | ||
16560 | /* as-override */ | |
16561 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16562 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16563 | } | |
16564 | ||
16565 | /* send-community print. */ | |
16566 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16567 | PEER_FLAG_SEND_COMMUNITY); | |
16568 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16569 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16570 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16571 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16572 | ||
16573 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16574 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16575 | } else { | |
16576 | if (flag_scomm) | |
16577 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16578 | if (flag_secomm) | |
16579 | vty_out(vty, | |
16580 | " no neighbor %s send-community extended\n", | |
16581 | addr); | |
16582 | ||
16583 | if (flag_slcomm) | |
16584 | vty_out(vty, " no neighbor %s send-community large\n", | |
16585 | addr); | |
16586 | } | |
16587 | ||
16588 | /* Default information */ | |
16589 | if (peergroup_af_flag_check(peer, afi, safi, | |
16590 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16591 | vty_out(vty, " neighbor %s default-originate", addr); | |
16592 | ||
16593 | if (peer->default_rmap[afi][safi].name) | |
16594 | vty_out(vty, " route-map %s", | |
16595 | peer->default_rmap[afi][safi].name); | |
16596 | ||
16597 | vty_out(vty, "\n"); | |
16598 | } | |
16599 | ||
16600 | /* Soft reconfiguration inbound. */ | |
16601 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16602 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16603 | addr); | |
16604 | } | |
16605 | ||
16606 | /* maximum-prefix. */ | |
16607 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 16608 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
16609 | peer->pmax[afi][safi]); |
16610 | ||
16611 | if (peer->pmax_threshold[afi][safi] | |
16612 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16613 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16614 | if (peer_af_flag_check(peer, afi, safi, | |
16615 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
16616 | vty_out(vty, " warning-only"); | |
16617 | if (peer->pmax_restart[afi][safi]) | |
16618 | vty_out(vty, " restart %u", | |
16619 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
16620 | if (peer_af_flag_check(peer, afi, safi, |
16621 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
16622 | vty_out(vty, " force"); | |
dd65f45e DL |
16623 | |
16624 | vty_out(vty, "\n"); | |
16625 | } | |
16626 | ||
fde246e8 DA |
16627 | /* maximum-prefix-out */ |
16628 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 16629 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
16630 | addr, peer->pmax_out[afi][safi]); |
16631 | ||
dd65f45e DL |
16632 | /* Route server client. */ |
16633 | if (peergroup_af_flag_check(peer, afi, safi, | |
16634 | PEER_FLAG_RSERVER_CLIENT)) { | |
16635 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
16636 | } | |
16637 | ||
16638 | /* Nexthop-local unchanged. */ | |
16639 | if (peergroup_af_flag_check(peer, afi, safi, | |
16640 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
16641 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
16642 | } | |
16643 | ||
16644 | /* allowas-in <1-10> */ | |
16645 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
16646 | if (peer_af_flag_check(peer, afi, safi, | |
16647 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
16648 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
16649 | } else if (peer->allowas_in[afi][safi] == 3) { | |
16650 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
16651 | } else { | |
16652 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
16653 | peer->allowas_in[afi][safi]); | |
16654 | } | |
16655 | } | |
16656 | ||
16657 | /* weight */ | |
16658 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
16659 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
16660 | peer->weight[afi][safi]); | |
16661 | ||
16662 | /* Filter. */ | |
16663 | bgp_config_write_filter(vty, peer, afi, safi); | |
16664 | ||
16665 | /* atribute-unchanged. */ | |
16666 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
16667 | || (safi != SAFI_EVPN | |
16668 | && peer_af_flag_check(peer, afi, safi, | |
16669 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
16670 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
16671 | ||
16672 | if (!peer_group_active(peer) | |
16673 | || peergroup_af_flag_check(peer, afi, safi, | |
16674 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16675 | || peergroup_af_flag_check(peer, afi, safi, | |
16676 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16677 | || peergroup_af_flag_check(peer, afi, safi, | |
16678 | PEER_FLAG_MED_UNCHANGED)) { | |
16679 | ||
16680 | vty_out(vty, | |
16681 | " neighbor %s attribute-unchanged%s%s%s\n", | |
16682 | addr, | |
16683 | peer_af_flag_check(peer, afi, safi, | |
16684 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16685 | ? " as-path" | |
16686 | : "", | |
16687 | peer_af_flag_check(peer, afi, safi, | |
16688 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16689 | ? " next-hop" | |
16690 | : "", | |
16691 | peer_af_flag_check(peer, afi, safi, | |
16692 | PEER_FLAG_MED_UNCHANGED) | |
16693 | ? " med" | |
16694 | : ""); | |
16695 | } | |
16696 | } | |
16697 | } | |
16698 | ||
16699 | /* Address family based peer configuration display. */ | |
16700 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
16701 | safi_t safi) | |
16702 | { | |
16703 | struct peer *peer; | |
16704 | struct peer_group *group; | |
16705 | struct listnode *node, *nnode; | |
16706 | ||
16707 | ||
16708 | vty_frame(vty, " !\n address-family "); | |
16709 | if (afi == AFI_IP) { | |
16710 | if (safi == SAFI_UNICAST) | |
16711 | vty_frame(vty, "ipv4 unicast"); | |
16712 | else if (safi == SAFI_LABELED_UNICAST) | |
16713 | vty_frame(vty, "ipv4 labeled-unicast"); | |
16714 | else if (safi == SAFI_MULTICAST) | |
16715 | vty_frame(vty, "ipv4 multicast"); | |
16716 | else if (safi == SAFI_MPLS_VPN) | |
16717 | vty_frame(vty, "ipv4 vpn"); | |
16718 | else if (safi == SAFI_ENCAP) | |
16719 | vty_frame(vty, "ipv4 encap"); | |
16720 | else if (safi == SAFI_FLOWSPEC) | |
16721 | vty_frame(vty, "ipv4 flowspec"); | |
16722 | } else if (afi == AFI_IP6) { | |
16723 | if (safi == SAFI_UNICAST) | |
16724 | vty_frame(vty, "ipv6 unicast"); | |
16725 | else if (safi == SAFI_LABELED_UNICAST) | |
16726 | vty_frame(vty, "ipv6 labeled-unicast"); | |
16727 | else if (safi == SAFI_MULTICAST) | |
16728 | vty_frame(vty, "ipv6 multicast"); | |
16729 | else if (safi == SAFI_MPLS_VPN) | |
16730 | vty_frame(vty, "ipv6 vpn"); | |
16731 | else if (safi == SAFI_ENCAP) | |
16732 | vty_frame(vty, "ipv6 encap"); | |
16733 | else if (safi == SAFI_FLOWSPEC) | |
16734 | vty_frame(vty, "ipv6 flowspec"); | |
16735 | } else if (afi == AFI_L2VPN) { | |
16736 | if (safi == SAFI_EVPN) | |
16737 | vty_frame(vty, "l2vpn evpn"); | |
16738 | } | |
16739 | vty_frame(vty, "\n"); | |
16740 | ||
16741 | bgp_config_write_distance(vty, bgp, afi, safi); | |
16742 | ||
16743 | bgp_config_write_network(vty, bgp, afi, safi); | |
16744 | ||
16745 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
16746 | ||
8a4e7fe6 DA |
16747 | /* BGP flag dampening. */ |
16748 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
16749 | bgp_config_write_damp(vty, afi, safi); | |
16750 | ||
dd65f45e DL |
16751 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
16752 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
16753 | ||
16754 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
16755 | /* Skip dynamic neighbors. */ | |
16756 | if (peer_dynamic_neighbor(peer)) | |
16757 | continue; | |
16758 | ||
16759 | /* Do not display doppelganger peers */ | |
16760 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
16761 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
16762 | } | |
16763 | ||
16764 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
16765 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
16766 | ||
16767 | if (safi == SAFI_EVPN) | |
16768 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
16769 | ||
16770 | if (safi == SAFI_FLOWSPEC) | |
16771 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
16772 | ||
16773 | if (safi == SAFI_UNICAST) { | |
16774 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
16775 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16776 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
16777 | ||
16778 | vty_out(vty, " export vpn\n"); | |
16779 | } | |
16780 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16781 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
16782 | ||
16783 | vty_out(vty, " import vpn\n"); | |
16784 | } | |
16785 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16786 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
16787 | char *name; | |
16788 | ||
16789 | for (ALL_LIST_ELEMENTS_RO( | |
16790 | bgp->vpn_policy[afi].import_vrf, node, | |
16791 | name)) | |
16792 | vty_out(vty, " import vrf %s\n", name); | |
16793 | } | |
16794 | } | |
16795 | ||
16796 | vty_endframe(vty, " exit-address-family\n"); | |
16797 | } | |
16798 | ||
16799 | int bgp_config_write(struct vty *vty) | |
16800 | { | |
16801 | struct bgp *bgp; | |
16802 | struct peer_group *group; | |
16803 | struct peer *peer; | |
16804 | struct listnode *node, *nnode; | |
16805 | struct listnode *mnode, *mnnode; | |
16806 | ||
16807 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
16808 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
16809 | bm->rmap_update_timer); | |
16810 | ||
d70583f7 D |
16811 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
16812 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
16813 | if (bm->v_update_delay != bm->v_establish_wait) | |
16814 | vty_out(vty, " %d", bm->v_establish_wait); | |
16815 | vty_out(vty, "\n"); | |
16816 | } | |
16817 | ||
05bd726c | 16818 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
16819 | vty_out(vty, "bgp graceful-shutdown\n"); | |
16820 | ||
c163f297 DS |
16821 | /* No-RIB (Zebra) option flag configuration */ |
16822 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
16823 | vty_out(vty, "bgp no-rib\n"); | |
16824 | ||
dd65f45e DL |
16825 | /* BGP configuration. */ |
16826 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
16827 | ||
16828 | /* skip all auto created vrf as they dont have user config */ | |
16829 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
16830 | continue; | |
16831 | ||
16832 | /* Router bgp ASN */ | |
16833 | vty_out(vty, "router bgp %u", bgp->as); | |
16834 | ||
16835 | if (bgp->name) | |
16836 | vty_out(vty, " %s %s", | |
16837 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
16838 | ? "view" : "vrf", bgp->name); | |
16839 | vty_out(vty, "\n"); | |
16840 | ||
16841 | /* BGP fast-external-failover. */ | |
16842 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
16843 | vty_out(vty, " no bgp fast-external-failover\n"); | |
16844 | ||
16845 | /* BGP router ID. */ | |
16846 | if (bgp->router_id_static.s_addr != 0) | |
23d0a753 DA |
16847 | vty_out(vty, " bgp router-id %pI4\n", |
16848 | &bgp->router_id_static); | |
dd65f45e | 16849 | |
c208c586 S |
16850 | /* Suppress fib pending */ |
16851 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
16852 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
16853 | ||
dd65f45e | 16854 | /* BGP log-neighbor-changes. */ |
892fedb6 | 16855 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 16856 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 16857 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
16858 | CHECK_FLAG(bgp->flags, |
16859 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
16860 | ? "" |
16861 | : "no "); | |
16862 | ||
16863 | /* BGP configuration. */ | |
892fedb6 | 16864 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
16865 | vty_out(vty, " bgp always-compare-med\n"); |
16866 | ||
16867 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
16868 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
16869 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
16870 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
16871 | CHECK_FLAG(bgp->flags, | |
16872 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
16873 | ? "" | |
16874 | : "no "); | |
dd65f45e DL |
16875 | |
16876 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 16877 | if (bgp->reject_as_sets) |
dd65f45e DL |
16878 | vty_out(vty, " bgp reject-as-sets\n"); |
16879 | ||
16880 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 16881 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
16882 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
16883 | ||
16884 | /* BGP default local-preference. */ | |
16885 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
16886 | vty_out(vty, " bgp default local-preference %u\n", | |
16887 | bgp->default_local_pref); | |
16888 | ||
16889 | /* BGP default show-hostname */ | |
892fedb6 | 16890 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 16891 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 16892 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 16893 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
16894 | ? "" |
16895 | : "no "); | |
16896 | ||
aef999a2 DA |
16897 | /* BGP default show-nexthop-hostname */ |
16898 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16899 | != SAVE_BGP_SHOW_HOSTNAME) | |
16900 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
16901 | CHECK_FLAG(bgp->flags, | |
16902 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16903 | ? "" | |
16904 | : "no "); | |
16905 | ||
dd65f45e DL |
16906 | /* BGP default subgroup-pkt-queue-max. */ |
16907 | if (bgp->default_subgroup_pkt_queue_max | |
16908 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
16909 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
16910 | bgp->default_subgroup_pkt_queue_max); | |
16911 | ||
16912 | /* BGP client-to-client reflection. */ | |
892fedb6 | 16913 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
16914 | vty_out(vty, " no bgp client-to-client reflection\n"); |
16915 | ||
16916 | /* BGP cluster ID. */ | |
16917 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
16918 | vty_out(vty, " bgp cluster-id %pI4\n", |
16919 | &bgp->cluster_id); | |
dd65f45e DL |
16920 | |
16921 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 16922 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
16923 | vty_out(vty, |
16924 | " bgp disable-ebgp-connected-route-check\n"); | |
16925 | ||
16926 | /* Confederation identifier*/ | |
16927 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
16928 | vty_out(vty, " bgp confederation identifier %u\n", | |
16929 | bgp->confed_id); | |
16930 | ||
16931 | /* Confederation peer */ | |
16932 | if (bgp->confed_peers_cnt > 0) { | |
16933 | int i; | |
16934 | ||
16935 | vty_out(vty, " bgp confederation peers"); | |
16936 | ||
16937 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
16938 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
16939 | ||
16940 | vty_out(vty, "\n"); | |
16941 | } | |
16942 | ||
16943 | /* BGP deterministic-med. */ | |
892fedb6 | 16944 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 16945 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 16946 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
16947 | CHECK_FLAG(bgp->flags, |
16948 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
16949 | ? "" |
16950 | : "no "); | |
16951 | ||
16952 | /* BGP update-delay. */ | |
16953 | bgp_config_write_update_delay(vty, bgp); | |
16954 | ||
16955 | if (bgp->v_maxmed_onstartup | |
16956 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
16957 | vty_out(vty, " bgp max-med on-startup %u", | |
16958 | bgp->v_maxmed_onstartup); | |
16959 | if (bgp->maxmed_onstartup_value | |
16960 | != BGP_MAXMED_VALUE_DEFAULT) | |
16961 | vty_out(vty, " %u", | |
16962 | bgp->maxmed_onstartup_value); | |
16963 | vty_out(vty, "\n"); | |
16964 | } | |
16965 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
16966 | vty_out(vty, " bgp max-med administrative"); | |
16967 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
16968 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
16969 | vty_out(vty, "\n"); | |
16970 | } | |
16971 | ||
16972 | /* write quanta */ | |
16973 | bgp_config_write_wpkt_quanta(vty, bgp); | |
16974 | /* read quanta */ | |
16975 | bgp_config_write_rpkt_quanta(vty, bgp); | |
16976 | ||
16977 | /* coalesce time */ | |
16978 | bgp_config_write_coalesce_time(vty, bgp); | |
16979 | ||
05bd726c | 16980 | /* BGP per-instance graceful-shutdown */ |
16981 | /* BGP-wide settings and per-instance settings are mutually | |
16982 | * exclusive. | |
16983 | */ | |
16984 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
16985 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
16986 | vty_out(vty, " bgp graceful-shutdown\n"); | |
16987 | ||
dd65f45e DL |
16988 | /* BGP graceful-restart. */ |
16989 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
16990 | vty_out(vty, | |
16991 | " bgp graceful-restart stalepath-time %u\n", | |
16992 | bgp->stalepath_time); | |
cfd47646 | 16993 | |
dd65f45e DL |
16994 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
16995 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
16996 | bgp->restart_time); | |
cfd47646 | 16997 | |
16998 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
16999 | vty_out(vty, | |
17000 | " bgp graceful-restart select-defer-time %u\n", | |
17001 | bgp->select_defer_time); | |
17002 | ||
17003 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17004 | vty_out(vty, " bgp graceful-restart\n"); |
17005 | ||
cfd47646 | 17006 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17007 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17008 | ||
dd65f45e | 17009 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 17010 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
17011 | vty_out(vty, |
17012 | " bgp graceful-restart preserve-fw-state\n"); | |
17013 | ||
dc95985f | 17014 | /* Stale timer for RIB */ |
17015 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17016 | vty_out(vty, | |
17017 | " bgp graceful-restart rib-stale-time %u\n", | |
17018 | bgp->rib_stale_time); | |
17019 | ||
dd65f45e | 17020 | /* BGP bestpath method. */ |
892fedb6 | 17021 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 17022 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 17023 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
17024 | vty_out(vty, " bgp bestpath as-path confed\n"); |
17025 | ||
892fedb6 DA |
17026 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
17027 | if (CHECK_FLAG(bgp->flags, | |
17028 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
17029 | vty_out(vty, |
17030 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17031 | } else { | |
17032 | vty_out(vty, | |
17033 | " bgp bestpath as-path multipath-relax\n"); | |
17034 | } | |
17035 | } | |
17036 | ||
892fedb6 | 17037 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
17038 | vty_out(vty, |
17039 | " bgp route-reflector allow-outbound-policy\n"); | |
17040 | } | |
892fedb6 | 17041 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 17042 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
17043 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
17044 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 17045 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 17046 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 17047 | vty_out(vty, " confed"); |
892fedb6 DA |
17048 | if (CHECK_FLAG(bgp->flags, |
17049 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
17050 | vty_out(vty, " missing-as-worst"); |
17051 | vty_out(vty, "\n"); | |
17052 | } | |
17053 | ||
f7e1c681 | 17054 | /* Link bandwidth handling. */ |
17055 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17056 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17057 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17058 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17059 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17060 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17061 | ||
dd65f45e | 17062 | /* BGP network import check. */ |
892fedb6 | 17063 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 17064 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 17065 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 17066 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
17067 | ? "" |
17068 | : "no "); | |
17069 | ||
17070 | /* BGP timers configuration. */ | |
5d5393b9 DL |
17071 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
17072 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
17073 | vty_out(vty, " timers bgp %u %u\n", |
17074 | bgp->default_keepalive, bgp->default_holdtime); | |
17075 | ||
17076 | /* peer-group */ | |
17077 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17078 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17079 | } | |
17080 | ||
17081 | /* Normal neighbor configuration. */ | |
17082 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17083 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17084 | bgp_config_write_peer_global(vty, bgp, peer); | |
17085 | } | |
17086 | ||
17087 | /* listen range and limit for dynamic BGP neighbors */ | |
17088 | bgp_config_write_listen(vty, bgp); | |
17089 | ||
17090 | /* | |
17091 | * BGP default autoshutdown neighbors | |
17092 | * | |
17093 | * This must be placed after any peer and peer-group | |
17094 | * configuration, to avoid setting all peers to shutdown after | |
17095 | * a daemon restart, which is undesired behavior. (see #2286) | |
17096 | */ | |
17097 | if (bgp->autoshutdown) | |
17098 | vty_out(vty, " bgp default shutdown\n"); | |
17099 | ||
9cf59432 DS |
17100 | /* BGP instance administrative shutdown */ |
17101 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17102 | vty_out(vty, " bgp shutdown\n"); | |
17103 | ||
dd65f45e DL |
17104 | /* IPv4 unicast configuration. */ |
17105 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17106 | ||
17107 | /* IPv4 multicast configuration. */ | |
17108 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17109 | ||
17110 | /* IPv4 labeled-unicast configuration. */ | |
17111 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17112 | ||
17113 | /* IPv4 VPN configuration. */ | |
17114 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17115 | ||
17116 | /* ENCAPv4 configuration. */ | |
17117 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17118 | ||
17119 | /* FLOWSPEC v4 configuration. */ | |
17120 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17121 | ||
17122 | /* IPv6 unicast configuration. */ | |
17123 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17124 | ||
17125 | /* IPv6 multicast configuration. */ | |
17126 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17127 | ||
17128 | /* IPv6 labeled-unicast configuration. */ | |
17129 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17130 | SAFI_LABELED_UNICAST); | |
17131 | ||
17132 | /* IPv6 VPN configuration. */ | |
17133 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17134 | ||
17135 | /* ENCAPv6 configuration. */ | |
17136 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17137 | ||
17138 | /* FLOWSPEC v6 configuration. */ | |
17139 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17140 | ||
17141 | /* EVPN configuration. */ | |
17142 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17143 | ||
17144 | hook_call(bgp_inst_config_write, bgp, vty); | |
17145 | ||
49e5a4a0 | 17146 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
17147 | bgp_rfapi_cfg_write(vty, bgp); |
17148 | #endif | |
17149 | ||
17150 | vty_out(vty, "!\n"); | |
17151 | } | |
17152 | return 0; | |
17153 | } | |
17154 | ||
ddb5b488 | 17155 | |
718e3744 | 17156 | /* BGP node structure. */ |
d62a17ae | 17157 | static struct cmd_node bgp_node = { |
f4b8291f | 17158 | .name = "bgp", |
62b346ee | 17159 | .node = BGP_NODE, |
24389580 | 17160 | .parent_node = CONFIG_NODE, |
62b346ee | 17161 | .prompt = "%s(config-router)# ", |
612c2c15 | 17162 | .config_write = bgp_config_write, |
718e3744 | 17163 | }; |
17164 | ||
d62a17ae | 17165 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 17166 | .name = "bgp ipv4 unicast", |
62b346ee | 17167 | .node = BGP_IPV4_NODE, |
24389580 | 17168 | .parent_node = BGP_NODE, |
62b346ee | 17169 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17170 | }; |
17171 | ||
d62a17ae | 17172 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 17173 | .name = "bgp ipv4 multicast", |
62b346ee | 17174 | .node = BGP_IPV4M_NODE, |
24389580 | 17175 | .parent_node = BGP_NODE, |
62b346ee | 17176 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17177 | }; |
17178 | ||
d62a17ae | 17179 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 17180 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 17181 | .node = BGP_IPV4L_NODE, |
24389580 | 17182 | .parent_node = BGP_NODE, |
62b346ee | 17183 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17184 | }; |
17185 | ||
d62a17ae | 17186 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 17187 | .name = "bgp ipv6", |
62b346ee | 17188 | .node = BGP_IPV6_NODE, |
24389580 | 17189 | .parent_node = BGP_NODE, |
62b346ee | 17190 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17191 | }; |
17192 | ||
d62a17ae | 17193 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 17194 | .name = "bgp ipv6 multicast", |
62b346ee | 17195 | .node = BGP_IPV6M_NODE, |
24389580 | 17196 | .parent_node = BGP_NODE, |
62b346ee | 17197 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 17198 | }; |
17199 | ||
d62a17ae | 17200 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 17201 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 17202 | .node = BGP_IPV6L_NODE, |
24389580 | 17203 | .parent_node = BGP_NODE, |
62b346ee | 17204 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17205 | }; |
17206 | ||
62b346ee | 17207 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 17208 | .name = "bgp vpnv4", |
62b346ee | 17209 | .node = BGP_VPNV4_NODE, |
24389580 | 17210 | .parent_node = BGP_NODE, |
62b346ee | 17211 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17212 | }; |
6b0655a2 | 17213 | |
62b346ee | 17214 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 17215 | .name = "bgp vpnv6", |
62b346ee | 17216 | .node = BGP_VPNV6_NODE, |
24389580 | 17217 | .parent_node = BGP_NODE, |
62b346ee | 17218 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17219 | }; |
8ecd3266 | 17220 | |
62b346ee | 17221 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 17222 | .name = "bgp evpn", |
62b346ee | 17223 | .node = BGP_EVPN_NODE, |
24389580 | 17224 | .parent_node = BGP_NODE, |
62b346ee | 17225 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 17226 | }; |
4e0b7b6d | 17227 | |
62b346ee | 17228 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 17229 | .name = "bgp evpn vni", |
62b346ee | 17230 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 17231 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 17232 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 17233 | }; |
90e60aa7 | 17234 | |
62b346ee | 17235 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 17236 | .name = "bgp ipv4 flowspec", |
62b346ee | 17237 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 17238 | .parent_node = BGP_NODE, |
62b346ee | 17239 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17240 | }; |
7c40bf39 | 17241 | |
62b346ee | 17242 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 17243 | .name = "bgp ipv6 flowspec", |
62b346ee | 17244 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 17245 | .parent_node = BGP_NODE, |
62b346ee | 17246 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17247 | }; |
7c40bf39 | 17248 | |
d62a17ae | 17249 | static void community_list_vty(void); |
1f8ae70b | 17250 | |
d62a17ae | 17251 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 17252 | { |
d62a17ae | 17253 | struct bgp *bgp; |
17254 | struct peer *peer; | |
d62a17ae | 17255 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 17256 | |
d62a17ae | 17257 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
17258 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17259 | /* only provide suggestions on the appropriate input | |
17260 | * token type, | |
17261 | * they'll otherwise show up multiple times */ | |
17262 | enum cmd_token_type match_type; | |
17263 | char *name = peer->host; | |
d48ed3e0 | 17264 | |
d62a17ae | 17265 | if (peer->conf_if) { |
17266 | match_type = VARIABLE_TKN; | |
17267 | name = peer->conf_if; | |
17268 | } else if (strchr(peer->host, ':')) | |
17269 | match_type = IPV6_TKN; | |
17270 | else | |
17271 | match_type = IPV4_TKN; | |
d48ed3e0 | 17272 | |
d62a17ae | 17273 | if (token->type != match_type) |
17274 | continue; | |
d48ed3e0 | 17275 | |
d62a17ae | 17276 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
17277 | } | |
d62a17ae | 17278 | } |
b8a815e5 DL |
17279 | } |
17280 | ||
17281 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 17282 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
17283 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 17284 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 17285 | {.completions = NULL}}; |
17286 | ||
47a306a0 DS |
17287 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
17288 | { | |
17289 | struct bgp *bgp; | |
17290 | struct peer_group *group; | |
17291 | struct listnode *lnbgp, *lnpeer; | |
17292 | ||
17293 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17294 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17295 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
17296 | group->name)); | |
17297 | } | |
17298 | } | |
17299 | ||
17300 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
17301 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17302 | {.completions = NULL} }; | |
17303 | ||
d62a17ae | 17304 | void bgp_vty_init(void) |
17305 | { | |
17306 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 17307 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 17308 | |
17309 | /* Install bgp top node. */ | |
612c2c15 DL |
17310 | install_node(&bgp_node); |
17311 | install_node(&bgp_ipv4_unicast_node); | |
17312 | install_node(&bgp_ipv4_multicast_node); | |
17313 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17314 | install_node(&bgp_ipv6_unicast_node); | |
17315 | install_node(&bgp_ipv6_multicast_node); | |
17316 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17317 | install_node(&bgp_vpnv4_node); | |
17318 | install_node(&bgp_vpnv6_node); | |
17319 | install_node(&bgp_evpn_node); | |
17320 | install_node(&bgp_evpn_vni_node); | |
17321 | install_node(&bgp_flowspecv4_node); | |
17322 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 17323 | |
17324 | /* Install default VTY commands to new nodes. */ | |
17325 | install_default(BGP_NODE); | |
17326 | install_default(BGP_IPV4_NODE); | |
17327 | install_default(BGP_IPV4M_NODE); | |
17328 | install_default(BGP_IPV4L_NODE); | |
17329 | install_default(BGP_IPV6_NODE); | |
17330 | install_default(BGP_IPV6M_NODE); | |
17331 | install_default(BGP_IPV6L_NODE); | |
17332 | install_default(BGP_VPNV4_NODE); | |
17333 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 17334 | install_default(BGP_FLOWSPECV4_NODE); |
17335 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 17336 | install_default(BGP_EVPN_NODE); |
17337 | install_default(BGP_EVPN_VNI_NODE); | |
17338 | ||
8029b216 AK |
17339 | /* "bgp local-mac" hidden commands. */ |
17340 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17341 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17342 | ||
d62a17ae | 17343 | /* bgp route-map delay-timer commands. */ |
17344 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17345 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17346 | ||
d70583f7 D |
17347 | /* global bgp update-delay command */ |
17348 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17349 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17350 | ||
05bd726c | 17351 | /* global bgp graceful-shutdown command */ |
17352 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17353 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17354 | ||
d62a17ae | 17355 | /* Dummy commands (Currently not supported) */ |
17356 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17357 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17358 | ||
17359 | /* "router bgp" commands. */ | |
17360 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17361 | ||
17362 | /* "no router bgp" commands. */ | |
17363 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17364 | ||
17365 | /* "bgp router-id" commands. */ | |
17366 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17367 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17368 | ||
c208c586 S |
17369 | /* "bgp suppress-fib-pending" command */ |
17370 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17371 | ||
d62a17ae | 17372 | /* "bgp cluster-id" commands. */ |
17373 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17374 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17375 | ||
c163f297 DS |
17376 | /* "bgp no-rib" commands. */ |
17377 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17378 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17379 | ||
d62a17ae | 17380 | /* "bgp confederation" commands. */ |
17381 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17382 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17383 | ||
17384 | /* "bgp confederation peers" commands. */ | |
17385 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17386 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17387 | ||
17388 | /* bgp max-med command */ | |
17389 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17390 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17391 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17392 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17393 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17394 | ||
17395 | /* bgp disable-ebgp-connected-nh-check */ | |
17396 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17397 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17398 | ||
17399 | /* bgp update-delay command */ | |
17400 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17401 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 17402 | |
17403 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 17404 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 17405 | |
17406 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17407 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17408 | ||
17409 | /* "maximum-paths" commands. */ | |
17410 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17411 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17412 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17413 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17414 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17415 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17416 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17417 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17418 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17419 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17420 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17421 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17422 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17423 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17424 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17425 | ||
39edabac PG |
17426 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
17427 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17428 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17429 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17430 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 17431 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
17432 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17433 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17434 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17435 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17436 | ||
17437 | /* "timers bgp" commands. */ | |
17438 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17439 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17440 | ||
17441 | /* route-map delay-timer commands - per instance for backwards compat. | |
17442 | */ | |
17443 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17444 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17445 | ||
17446 | /* "bgp client-to-client reflection" commands */ | |
17447 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17448 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17449 | ||
17450 | /* "bgp always-compare-med" commands */ | |
17451 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17452 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17453 | ||
9dac9fc8 DA |
17454 | /* bgp ebgp-requires-policy */ |
17455 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17456 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17457 | ||
fb29348a DA |
17458 | /* bgp reject-as-sets */ |
17459 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
17460 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
17461 | ||
d62a17ae | 17462 | /* "bgp deterministic-med" commands */ |
17463 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
17464 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
17465 | ||
055679e9 | 17466 | /* "bgp graceful-restart" command */ |
36235319 QY |
17467 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
17468 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 17469 | |
17470 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
17471 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
17472 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 17473 | |
17474 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
17475 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
17476 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 17477 | |
17478 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
17479 | install_element(BGP_NODE, | |
17480 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
17481 | install_element(BGP_NODE, | |
17482 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
17483 | ||
17484 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
17485 | install_element(BGP_NODE, | |
17486 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
17487 | install_element(BGP_NODE, | |
17488 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
17489 | ||
d62a17ae | 17490 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
17491 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
17492 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
17493 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 17494 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 17495 | install_element(BGP_NODE, |
17496 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 17497 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
17498 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
17499 | ||
d6e3c15b | 17500 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
17501 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 17502 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
17503 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 17504 | |
7f323236 DW |
17505 | /* "bgp graceful-shutdown" commands */ |
17506 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
17507 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
17508 | ||
d62a17ae | 17509 | /* "bgp fast-external-failover" commands */ |
17510 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
17511 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
17512 | ||
d62a17ae | 17513 | /* "bgp bestpath compare-routerid" commands */ |
17514 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
17515 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
17516 | ||
17517 | /* "bgp bestpath as-path ignore" commands */ | |
17518 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
17519 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
17520 | ||
17521 | /* "bgp bestpath as-path confed" commands */ | |
17522 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
17523 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
17524 | ||
17525 | /* "bgp bestpath as-path multipath-relax" commands */ | |
17526 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
17527 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
17528 | ||
17529 | /* "bgp log-neighbor-changes" commands */ | |
17530 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
17531 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
17532 | ||
17533 | /* "bgp bestpath med" commands */ | |
17534 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
17535 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
17536 | ||
f7e1c681 | 17537 | /* "bgp bestpath bandwidth" commands */ |
17538 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 17539 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 17540 | |
d62a17ae | 17541 | /* "no bgp default ipv4-unicast" commands. */ |
17542 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
17543 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
17544 | ||
17545 | /* "bgp network import-check" commands. */ | |
17546 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
17547 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
17548 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
17549 | ||
17550 | /* "bgp default local-preference" commands. */ | |
17551 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
17552 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
17553 | ||
17554 | /* bgp default show-hostname */ | |
17555 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
17556 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
17557 | ||
aef999a2 DA |
17558 | /* bgp default show-nexthop-hostname */ |
17559 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
17560 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
17561 | ||
d62a17ae | 17562 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
17563 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
17564 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
17565 | ||
17566 | /* bgp ibgp-allow-policy-mods command */ | |
17567 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
17568 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
17569 | ||
17570 | /* "bgp listen limit" commands. */ | |
17571 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
17572 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
17573 | ||
17574 | /* "bgp listen range" commands. */ | |
17575 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
17576 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
17577 | ||
8175f54a | 17578 | /* "bgp default shutdown" command */ |
f26845f9 | 17579 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
17580 | |
17581 | /* "bgp shutdown" commands */ | |
17582 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 17583 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 17584 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 17585 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 17586 | |
d62a17ae | 17587 | /* "neighbor remote-as" commands. */ |
17588 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
17589 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
17590 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
17591 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
17592 | install_element(BGP_NODE, | |
17593 | &neighbor_interface_v6only_config_remote_as_cmd); | |
17594 | install_element(BGP_NODE, &no_neighbor_cmd); | |
17595 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
17596 | ||
17597 | /* "neighbor peer-group" commands. */ | |
17598 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
17599 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
17600 | install_element(BGP_NODE, | |
17601 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
17602 | ||
17603 | /* "neighbor local-as" commands. */ | |
17604 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
17605 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
17606 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
17607 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
17608 | ||
17609 | /* "neighbor solo" commands. */ | |
17610 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
17611 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
17612 | ||
17613 | /* "neighbor password" commands. */ | |
17614 | install_element(BGP_NODE, &neighbor_password_cmd); | |
17615 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
17616 | ||
17617 | /* "neighbor activate" commands. */ | |
17618 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
17619 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
17620 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
17621 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
17622 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
17623 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
17624 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
17625 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
17626 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 17627 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
17628 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 17629 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
17630 | ||
17631 | /* "no neighbor activate" commands. */ | |
17632 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
17633 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
17634 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
17635 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
17636 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
17637 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
17638 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
17639 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
17640 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 17641 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
17642 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 17643 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
17644 | ||
17645 | /* "neighbor peer-group" set commands. */ | |
17646 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
17647 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17648 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17649 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17650 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17651 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17652 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17653 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17654 | install_element(BGP_FLOWSPECV4_NODE, |
17655 | &neighbor_set_peer_group_hidden_cmd); | |
17656 | install_element(BGP_FLOWSPECV6_NODE, | |
17657 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17658 | |
17659 | /* "no neighbor peer-group unset" commands. */ | |
17660 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
17661 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17662 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17663 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17664 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17665 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17666 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17667 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17668 | install_element(BGP_FLOWSPECV4_NODE, |
17669 | &no_neighbor_set_peer_group_hidden_cmd); | |
17670 | install_element(BGP_FLOWSPECV6_NODE, | |
17671 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17672 | |
17673 | /* "neighbor softreconfiguration inbound" commands.*/ | |
17674 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
17675 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
17676 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17677 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17678 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17679 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17680 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17681 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17682 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17683 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17684 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17685 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17686 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17687 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17688 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17689 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17690 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17691 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 17692 | install_element(BGP_FLOWSPECV4_NODE, |
17693 | &neighbor_soft_reconfiguration_cmd); | |
17694 | install_element(BGP_FLOWSPECV4_NODE, | |
17695 | &no_neighbor_soft_reconfiguration_cmd); | |
17696 | install_element(BGP_FLOWSPECV6_NODE, | |
17697 | &neighbor_soft_reconfiguration_cmd); | |
17698 | install_element(BGP_FLOWSPECV6_NODE, | |
17699 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
17700 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
17701 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 17702 | |
17703 | /* "neighbor attribute-unchanged" commands. */ | |
17704 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
17705 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
17706 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
17707 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17708 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
17709 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17710 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
17711 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
17712 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
17713 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17714 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
17715 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17716 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
17717 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
17718 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
17719 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17720 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
17721 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17722 | ||
17723 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
17724 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
17725 | ||
17726 | /* "nexthop-local unchanged" commands */ | |
17727 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
17728 | install_element(BGP_IPV6_NODE, | |
17729 | &no_neighbor_nexthop_local_unchanged_cmd); | |
17730 | ||
17731 | /* "neighbor next-hop-self" commands. */ | |
17732 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
17733 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
17734 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
17735 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
17736 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
17737 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
17738 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
17739 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
17740 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
17741 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
17742 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
17743 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
17744 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
17745 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
17746 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
17747 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
17748 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
17749 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
17750 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
17751 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 17752 | |
17753 | /* "neighbor next-hop-self force" commands. */ | |
17754 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
17755 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
17756 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17757 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17758 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
17759 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17760 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17761 | install_element(BGP_IPV4_NODE, | |
17762 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17763 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
17764 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17765 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17766 | install_element(BGP_IPV4M_NODE, | |
17767 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17768 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
17769 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17770 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17771 | install_element(BGP_IPV4L_NODE, | |
17772 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17773 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
17774 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17775 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17776 | install_element(BGP_IPV6_NODE, | |
17777 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17778 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
17779 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17780 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17781 | install_element(BGP_IPV6M_NODE, | |
17782 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17783 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
17784 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17785 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17786 | install_element(BGP_IPV6L_NODE, | |
17787 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17788 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
17789 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17790 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17791 | install_element(BGP_VPNV4_NODE, | |
17792 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17793 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
17794 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17795 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17796 | install_element(BGP_VPNV6_NODE, | |
17797 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
17798 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
17799 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 17800 | |
17801 | /* "neighbor as-override" commands. */ | |
17802 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
17803 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
17804 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
17805 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
17806 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
17807 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
17808 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
17809 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
17810 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
17811 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
17812 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
17813 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
17814 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
17815 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
17816 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
17817 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
17818 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
17819 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
17820 | ||
17821 | /* "neighbor remove-private-AS" commands. */ | |
17822 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
17823 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
17824 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
17825 | install_element(BGP_NODE, | |
17826 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
17827 | install_element(BGP_NODE, | |
17828 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
17829 | install_element(BGP_NODE, | |
17830 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
17831 | install_element(BGP_NODE, | |
17832 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
17833 | install_element( | |
17834 | BGP_NODE, | |
17835 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
17836 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
17837 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
17838 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
17839 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17840 | install_element(BGP_IPV4_NODE, | |
17841 | &neighbor_remove_private_as_replace_as_cmd); | |
17842 | install_element(BGP_IPV4_NODE, | |
17843 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17844 | install_element(BGP_IPV4_NODE, | |
17845 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17846 | install_element(BGP_IPV4_NODE, | |
17847 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17848 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
17849 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
17850 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
17851 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17852 | install_element(BGP_IPV4M_NODE, | |
17853 | &neighbor_remove_private_as_replace_as_cmd); | |
17854 | install_element(BGP_IPV4M_NODE, | |
17855 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17856 | install_element(BGP_IPV4M_NODE, | |
17857 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17858 | install_element(BGP_IPV4M_NODE, | |
17859 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17860 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
17861 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
17862 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
17863 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17864 | install_element(BGP_IPV4L_NODE, | |
17865 | &neighbor_remove_private_as_replace_as_cmd); | |
17866 | install_element(BGP_IPV4L_NODE, | |
17867 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17868 | install_element(BGP_IPV4L_NODE, | |
17869 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17870 | install_element(BGP_IPV4L_NODE, | |
17871 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17872 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
17873 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17874 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17875 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17876 | install_element(BGP_IPV6_NODE, | |
17877 | &neighbor_remove_private_as_replace_as_cmd); | |
17878 | install_element(BGP_IPV6_NODE, | |
17879 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17880 | install_element(BGP_IPV6_NODE, | |
17881 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17882 | install_element(BGP_IPV6_NODE, | |
17883 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17884 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
17885 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
17886 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
17887 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17888 | install_element(BGP_IPV6M_NODE, | |
17889 | &neighbor_remove_private_as_replace_as_cmd); | |
17890 | install_element(BGP_IPV6M_NODE, | |
17891 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17892 | install_element(BGP_IPV6M_NODE, | |
17893 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17894 | install_element(BGP_IPV6M_NODE, | |
17895 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17896 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
17897 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
17898 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
17899 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17900 | install_element(BGP_IPV6L_NODE, | |
17901 | &neighbor_remove_private_as_replace_as_cmd); | |
17902 | install_element(BGP_IPV6L_NODE, | |
17903 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17904 | install_element(BGP_IPV6L_NODE, | |
17905 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17906 | install_element(BGP_IPV6L_NODE, | |
17907 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17908 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
17909 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
17910 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
17911 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17912 | install_element(BGP_VPNV4_NODE, | |
17913 | &neighbor_remove_private_as_replace_as_cmd); | |
17914 | install_element(BGP_VPNV4_NODE, | |
17915 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17916 | install_element(BGP_VPNV4_NODE, | |
17917 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17918 | install_element(BGP_VPNV4_NODE, | |
17919 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17920 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
17921 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17922 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17923 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17924 | install_element(BGP_VPNV6_NODE, | |
17925 | &neighbor_remove_private_as_replace_as_cmd); | |
17926 | install_element(BGP_VPNV6_NODE, | |
17927 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17928 | install_element(BGP_VPNV6_NODE, | |
17929 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17930 | install_element(BGP_VPNV6_NODE, | |
17931 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17932 | ||
17933 | /* "neighbor send-community" commands.*/ | |
17934 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
17935 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
17936 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
17937 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
17938 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
17939 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
17940 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
17941 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
17942 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
17943 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
17944 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
17945 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
17946 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
17947 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
17948 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
17949 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
17950 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
17951 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
17952 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
17953 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
17954 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
17955 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
17956 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
17957 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
17958 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
17959 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
17960 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
17961 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
17962 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
17963 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
17964 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
17965 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
17966 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
17967 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
17968 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
17969 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
17970 | ||
17971 | /* "neighbor route-reflector" commands.*/ | |
17972 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
17973 | install_element(BGP_NODE, | |
17974 | &no_neighbor_route_reflector_client_hidden_cmd); | |
17975 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
17976 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
17977 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
17978 | install_element(BGP_IPV4M_NODE, | |
17979 | &no_neighbor_route_reflector_client_cmd); | |
17980 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
17981 | install_element(BGP_IPV4L_NODE, | |
17982 | &no_neighbor_route_reflector_client_cmd); | |
17983 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
17984 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
17985 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
17986 | install_element(BGP_IPV6M_NODE, | |
17987 | &no_neighbor_route_reflector_client_cmd); | |
17988 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
17989 | install_element(BGP_IPV6L_NODE, | |
17990 | &no_neighbor_route_reflector_client_cmd); | |
17991 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
17992 | install_element(BGP_VPNV4_NODE, | |
17993 | &no_neighbor_route_reflector_client_cmd); | |
17994 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
17995 | install_element(BGP_VPNV6_NODE, | |
17996 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 17997 | install_element(BGP_FLOWSPECV4_NODE, |
17998 | &neighbor_route_reflector_client_cmd); | |
17999 | install_element(BGP_FLOWSPECV4_NODE, | |
18000 | &no_neighbor_route_reflector_client_cmd); | |
18001 | install_element(BGP_FLOWSPECV6_NODE, | |
18002 | &neighbor_route_reflector_client_cmd); | |
18003 | install_element(BGP_FLOWSPECV6_NODE, | |
18004 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 18005 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
18006 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18007 | ||
18008 | /* "neighbor route-server" commands.*/ | |
18009 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18010 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18011 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18012 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18013 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18014 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18015 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18016 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18017 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18018 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18019 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18020 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18021 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18022 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18023 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18024 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18025 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18026 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
18027 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
18028 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 18029 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
18030 | install_element(BGP_FLOWSPECV4_NODE, | |
18031 | &no_neighbor_route_server_client_cmd); | |
18032 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18033 | install_element(BGP_FLOWSPECV6_NODE, | |
18034 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 18035 | |
18036 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
18037 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18038 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18039 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18040 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18041 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18042 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18043 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18044 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18045 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18046 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18047 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18048 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18049 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18050 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18051 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18052 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18053 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18054 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18055 | ||
18056 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18057 | install_element(BGP_NODE, | |
18058 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18059 | install_element(BGP_NODE, | |
18060 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18061 | install_element(BGP_IPV4_NODE, | |
18062 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18063 | install_element(BGP_IPV4_NODE, | |
18064 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18065 | install_element(BGP_IPV4M_NODE, | |
18066 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18067 | install_element(BGP_IPV4M_NODE, | |
18068 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18069 | install_element(BGP_IPV4L_NODE, | |
18070 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18071 | install_element(BGP_IPV4L_NODE, | |
18072 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18073 | install_element(BGP_IPV6_NODE, | |
18074 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18075 | install_element(BGP_IPV6_NODE, | |
18076 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18077 | install_element(BGP_IPV6M_NODE, | |
18078 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18079 | install_element(BGP_IPV6M_NODE, | |
18080 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18081 | install_element(BGP_IPV6L_NODE, | |
18082 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18083 | install_element(BGP_IPV6L_NODE, | |
18084 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18085 | install_element(BGP_VPNV4_NODE, | |
18086 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18087 | install_element(BGP_VPNV4_NODE, | |
18088 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18089 | install_element(BGP_VPNV6_NODE, | |
18090 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18091 | install_element(BGP_VPNV6_NODE, | |
18092 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18093 | ||
2b31007c RZ |
18094 | /* "neighbor sender-as-path-loop-detection" commands. */ |
18095 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18096 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18097 | ||
d62a17ae | 18098 | /* "neighbor passive" commands. */ |
18099 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18100 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18101 | ||
18102 | ||
18103 | /* "neighbor shutdown" commands. */ | |
18104 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18105 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18106 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18107 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
18108 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
18109 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 18110 | |
18111 | /* "neighbor capability extended-nexthop" commands.*/ | |
18112 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18113 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18114 | ||
18115 | /* "neighbor capability orf prefix-list" commands.*/ | |
18116 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18117 | install_element(BGP_NODE, | |
18118 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18119 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18120 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18121 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18122 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18123 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18124 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18125 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18126 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18127 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18128 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18129 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18130 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18131 | ||
18132 | /* "neighbor capability dynamic" commands.*/ | |
18133 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18134 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18135 | ||
18136 | /* "neighbor dont-capability-negotiate" commands. */ | |
18137 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18138 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18139 | ||
18140 | /* "neighbor ebgp-multihop" commands. */ | |
18141 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18142 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18143 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18144 | ||
18145 | /* "neighbor disable-connected-check" commands. */ | |
18146 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18147 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18148 | ||
47cbc09b PM |
18149 | /* "neighbor enforce-first-as" commands. */ |
18150 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18151 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18152 | ||
d62a17ae | 18153 | /* "neighbor description" commands. */ |
18154 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18155 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 18156 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 18157 | |
18158 | /* "neighbor update-source" commands. "*/ | |
18159 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18160 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18161 | ||
18162 | /* "neighbor default-originate" commands. */ | |
18163 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18164 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18165 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18166 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18167 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18168 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18169 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18170 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18171 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18172 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18173 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18174 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18175 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18176 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18177 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18178 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18179 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18180 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18181 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18182 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18183 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18184 | ||
18185 | /* "neighbor port" commands. */ | |
18186 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18187 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18188 | ||
18189 | /* "neighbor weight" commands. */ | |
18190 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18191 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18192 | ||
18193 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18194 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18195 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18196 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18197 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18198 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18199 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18200 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18201 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18202 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18203 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18204 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18205 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18206 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18207 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18208 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18209 | ||
18210 | /* "neighbor override-capability" commands. */ | |
18211 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18212 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18213 | ||
18214 | /* "neighbor strict-capability-match" commands. */ | |
18215 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18216 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18217 | ||
18218 | /* "neighbor timers" commands. */ | |
18219 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18220 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18221 | ||
18222 | /* "neighbor timers connect" commands. */ | |
18223 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18224 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18225 | ||
18226 | /* "neighbor advertisement-interval" commands. */ | |
18227 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18228 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18229 | ||
18230 | /* "neighbor interface" commands. */ | |
18231 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18232 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18233 | ||
18234 | /* "neighbor distribute" commands. */ | |
18235 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18236 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18237 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18238 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18239 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18240 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18241 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18242 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18243 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18244 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18245 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18246 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18247 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18248 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18249 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18250 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18251 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18252 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18253 | ||
18254 | /* "neighbor prefix-list" commands. */ | |
18255 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
18256 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
18257 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
18258 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
18259 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
18260 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
18261 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
18262 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
18263 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
18264 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
18265 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
18266 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
18267 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
18268 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
18269 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
18270 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
18271 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
18272 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 18273 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
18274 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
18275 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
18276 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 18277 | |
18278 | /* "neighbor filter-list" commands. */ | |
18279 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18280 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18281 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18282 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18283 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18284 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18285 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18286 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18287 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18288 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18289 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18290 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18291 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18292 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18293 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18294 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18295 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18296 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 18297 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
18298 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18299 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18300 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 18301 | |
18302 | /* "neighbor route-map" commands. */ | |
18303 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
18304 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
18305 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
18306 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
18307 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
18308 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
18309 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
18310 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
18311 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
18312 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
18313 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
18314 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
18315 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
18316 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
18317 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
18318 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
18319 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
18320 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 18321 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
18322 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
18323 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
18324 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
18325 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
18326 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 18327 | |
18328 | /* "neighbor unsuppress-map" commands. */ | |
18329 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18330 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18331 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18332 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18333 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18334 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18335 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18336 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18337 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18338 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18339 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18340 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18341 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18342 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18343 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18344 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18345 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18346 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18347 | ||
7f7940e6 MK |
18348 | /* "neighbor advertise-map" commands. */ |
18349 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); | |
7f7940e6 | 18350 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18351 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18352 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18353 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18354 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18355 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18356 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18357 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18358 | |
fde246e8 DA |
18359 | /* neighbor maximum-prefix-out commands. */ |
18360 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18361 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18362 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18363 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18364 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18365 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18366 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18367 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18368 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18369 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18370 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18371 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18372 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18373 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18374 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18375 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18376 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18377 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18378 | ||
d62a17ae | 18379 | /* "neighbor maximum-prefix" commands. */ |
18380 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18381 | install_element(BGP_NODE, | |
18382 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18383 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18384 | install_element(BGP_NODE, | |
18385 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18386 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18387 | install_element(BGP_NODE, | |
18388 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18389 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18390 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18391 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18392 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18393 | install_element(BGP_IPV4_NODE, | |
18394 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18395 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18396 | install_element(BGP_IPV4_NODE, | |
18397 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18398 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18399 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18400 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18401 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18402 | install_element(BGP_IPV4M_NODE, | |
18403 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18404 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18405 | install_element(BGP_IPV4M_NODE, | |
18406 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18407 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18408 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
18409 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18410 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18411 | install_element(BGP_IPV4L_NODE, | |
18412 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18413 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18414 | install_element(BGP_IPV4L_NODE, | |
18415 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18416 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18417 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
18418 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18419 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18420 | install_element(BGP_IPV6_NODE, | |
18421 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18422 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18423 | install_element(BGP_IPV6_NODE, | |
18424 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18425 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18426 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
18427 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18428 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18429 | install_element(BGP_IPV6M_NODE, | |
18430 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18431 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18432 | install_element(BGP_IPV6M_NODE, | |
18433 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18434 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18435 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
18436 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18437 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18438 | install_element(BGP_IPV6L_NODE, | |
18439 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18440 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18441 | install_element(BGP_IPV6L_NODE, | |
18442 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18443 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18444 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
18445 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18446 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18447 | install_element(BGP_VPNV4_NODE, | |
18448 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18449 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18450 | install_element(BGP_VPNV4_NODE, | |
18451 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18452 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18453 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
18454 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18455 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18456 | install_element(BGP_VPNV6_NODE, | |
18457 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18458 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18459 | install_element(BGP_VPNV6_NODE, | |
18460 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18461 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18462 | ||
18463 | /* "neighbor allowas-in" */ | |
18464 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
18465 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
18466 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
18467 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
18468 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
18469 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
18470 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
18471 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
18472 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
18473 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
18474 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
18475 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
18476 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
18477 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
18478 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
18479 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
18480 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
18481 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
18482 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
18483 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
18484 | ||
18485 | /* address-family commands. */ | |
18486 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
18487 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 18488 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 18489 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
18490 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 18491 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 18492 | |
d62a17ae | 18493 | install_element(BGP_NODE, &address_family_evpn_cmd); |
18494 | ||
18495 | /* "exit-address-family" command. */ | |
18496 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
18497 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
18498 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
18499 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
18500 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
18501 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
18502 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
18503 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 18504 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
18505 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 18506 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
18507 | ||
18508 | /* "clear ip bgp commands" */ | |
18509 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
18510 | ||
18511 | /* clear ip bgp prefix */ | |
18512 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
18513 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
18514 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
18515 | ||
18516 | /* "show [ip] bgp summary" commands. */ | |
18517 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 18518 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 18519 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 18520 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 18521 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
18522 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 18523 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
18524 | ||
18525 | /* "show [ip] bgp neighbors" commands. */ | |
18526 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
18527 | ||
36235319 | 18528 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 18529 | |
d62a17ae | 18530 | /* "show [ip] bgp peer-group" commands. */ |
18531 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
18532 | ||
18533 | /* "show [ip] bgp paths" commands. */ | |
18534 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
18535 | ||
18536 | /* "show [ip] bgp community" commands. */ | |
18537 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
18538 | ||
18539 | /* "show ip bgp large-community" commands. */ | |
18540 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
18541 | /* "show [ip] bgp attribute-info" commands. */ | |
18542 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 18543 | /* "show [ip] bgp route-leak" command */ |
18544 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 18545 | |
18546 | /* "redistribute" commands. */ | |
18547 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
18548 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
18549 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
18550 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
18551 | install_element(BGP_NODE, | |
18552 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
18553 | install_element(BGP_NODE, | |
18554 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
18555 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18556 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18557 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
18558 | install_element(BGP_NODE, | |
18559 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
18560 | install_element(BGP_NODE, | |
18561 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
18562 | install_element(BGP_NODE, | |
18563 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
18564 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
18565 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
18566 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
18567 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
18568 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
18569 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
18570 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
18571 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
18572 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
18573 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
18574 | install_element(BGP_IPV4_NODE, | |
18575 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
18576 | install_element(BGP_IPV4_NODE, | |
18577 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
18578 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
18579 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
18580 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
18581 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
18582 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
18583 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
18584 | ||
b9c7bc5a PZ |
18585 | /* import|export vpn [route-map WORD] */ |
18586 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
18587 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 18588 | |
12a844a5 DS |
18589 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
18590 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
18591 | ||
d62a17ae | 18592 | /* ttl_security commands */ |
18593 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
18594 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
18595 | ||
18596 | /* "show [ip] bgp memory" commands. */ | |
18597 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
18598 | ||
acf71666 MK |
18599 | /* "show bgp martian next-hop" */ |
18600 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
18601 | ||
48ecf8f5 DS |
18602 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
18603 | ||
d62a17ae | 18604 | /* "show [ip] bgp views" commands. */ |
18605 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
18606 | ||
18607 | /* "show [ip] bgp vrfs" commands. */ | |
18608 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
18609 | ||
18610 | /* Community-list. */ | |
18611 | community_list_vty(); | |
ddb5b488 PZ |
18612 | |
18613 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
18614 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
18615 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
18616 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
18617 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
18618 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
18619 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
18620 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
18621 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
18622 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
18623 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18624 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
18625 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 18626 | |
301ad80a PG |
18627 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
18628 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
18629 | ||
b9c7bc5a PZ |
18630 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
18631 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
18632 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
18633 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
18634 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
18635 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
18636 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
18637 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18638 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
18639 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 18640 | } |
6b0655a2 | 18641 | |
718e3744 | 18642 | #include "memory.h" |
18643 | #include "bgp_regex.h" | |
18644 | #include "bgp_clist.h" | |
18645 | #include "bgp_ecommunity.h" | |
18646 | ||
18647 | /* VTY functions. */ | |
18648 | ||
18649 | /* Direction value to string conversion. */ | |
d62a17ae | 18650 | static const char *community_direct_str(int direct) |
18651 | { | |
18652 | switch (direct) { | |
18653 | case COMMUNITY_DENY: | |
18654 | return "deny"; | |
18655 | case COMMUNITY_PERMIT: | |
18656 | return "permit"; | |
18657 | default: | |
18658 | return "unknown"; | |
18659 | } | |
718e3744 | 18660 | } |
18661 | ||
18662 | /* Display error string. */ | |
d62a17ae | 18663 | static void community_list_perror(struct vty *vty, int ret) |
18664 | { | |
18665 | switch (ret) { | |
18666 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
18667 | vty_out(vty, "%% Can't find community-list\n"); | |
18668 | break; | |
18669 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
18670 | vty_out(vty, "%% Malformed community-list value\n"); | |
18671 | break; | |
18672 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
18673 | vty_out(vty, | |
18674 | "%% Community name conflict, previously defined as standard community\n"); | |
18675 | break; | |
18676 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
18677 | vty_out(vty, | |
18678 | "%% Community name conflict, previously defined as expanded community\n"); | |
18679 | break; | |
18680 | } | |
718e3744 | 18681 | } |
18682 | ||
5bf15956 DW |
18683 | /* "community-list" keyword help string. */ |
18684 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
18685 | ||
7336e101 SP |
18686 | /*community-list standard */ |
18687 | DEFUN (community_list_standard, | |
18688 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 18689 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 18690 | BGP_STR |
718e3744 | 18691 | COMMUNITY_LIST_STR |
18692 | "Community list number (standard)\n" | |
5bf15956 | 18693 | "Add an standard community-list entry\n" |
718e3744 | 18694 | "Community list name\n" |
2f8cc0e5 DA |
18695 | "Sequence number of an entry\n" |
18696 | "Sequence number\n" | |
718e3744 | 18697 | "Specify community to reject\n" |
18698 | "Specify community to accept\n" | |
18699 | COMMUNITY_VAL_STR) | |
18700 | { | |
d62a17ae | 18701 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18702 | char *seq = NULL; |
d62a17ae | 18703 | int direct = 0; |
18704 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 18705 | int idx = 0; |
7336e101 | 18706 | |
2f8cc0e5 DA |
18707 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18708 | if (idx) | |
18709 | seq = argv[idx]->arg; | |
18710 | ||
18711 | idx = 0; | |
d62a17ae | 18712 | argv_find(argv, argc, "(1-99)", &idx); |
18713 | argv_find(argv, argc, "WORD", &idx); | |
18714 | cl_name_or_number = argv[idx]->arg; | |
18715 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
18716 | : COMMUNITY_DENY; | |
18717 | argv_find(argv, argc, "AA:NN", &idx); | |
18718 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18719 | |
2f8cc0e5 DA |
18720 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
18721 | direct, style); | |
42f914d4 | 18722 | |
d62a17ae | 18723 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18724 | |
d62a17ae | 18725 | if (ret < 0) { |
18726 | /* Display error string. */ | |
18727 | community_list_perror(vty, ret); | |
18728 | return CMD_WARNING_CONFIG_FAILED; | |
18729 | } | |
42f914d4 | 18730 | |
d62a17ae | 18731 | return CMD_SUCCESS; |
718e3744 | 18732 | } |
18733 | ||
7336e101 SP |
18734 | DEFUN (no_community_list_standard_all, |
18735 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 18736 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18737 | NO_STR |
18738 | BGP_STR | |
18739 | COMMUNITY_LIST_STR | |
18740 | "Community list number (standard)\n" | |
18741 | "Add an standard community-list entry\n" | |
18742 | "Community list name\n" | |
2f8cc0e5 DA |
18743 | "Sequence number of an entry\n" |
18744 | "Sequence number\n" | |
7336e101 SP |
18745 | "Specify community to reject\n" |
18746 | "Specify community to accept\n" | |
18747 | COMMUNITY_VAL_STR) | |
718e3744 | 18748 | { |
d62a17ae | 18749 | char *cl_name_or_number = NULL; |
174b5cb9 | 18750 | char *str = NULL; |
d62a17ae | 18751 | int direct = 0; |
18752 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 18753 | char *seq = NULL; |
d62a17ae | 18754 | int idx = 0; |
7336e101 | 18755 | |
2f8cc0e5 DA |
18756 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18757 | if (idx) | |
18758 | seq = argv[idx]->arg; | |
18759 | ||
18760 | idx = 0; | |
174b5cb9 DA |
18761 | argv_find(argv, argc, "permit", &idx); |
18762 | argv_find(argv, argc, "deny", &idx); | |
18763 | ||
18764 | if (idx) { | |
18765 | direct = argv_find(argv, argc, "permit", &idx) | |
18766 | ? COMMUNITY_PERMIT | |
18767 | : COMMUNITY_DENY; | |
18768 | ||
18769 | idx = 0; | |
18770 | argv_find(argv, argc, "AA:NN", &idx); | |
18771 | str = argv_concat(argv, argc, idx); | |
18772 | } | |
18773 | ||
18774 | idx = 0; | |
d62a17ae | 18775 | argv_find(argv, argc, "(1-99)", &idx); |
18776 | argv_find(argv, argc, "WORD", &idx); | |
18777 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 18778 | |
2f8cc0e5 | 18779 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 18780 | direct, style); |
42f914d4 | 18781 | |
d62a17ae | 18782 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 18783 | |
d62a17ae | 18784 | if (ret < 0) { |
18785 | community_list_perror(vty, ret); | |
18786 | return CMD_WARNING_CONFIG_FAILED; | |
18787 | } | |
42f914d4 | 18788 | |
d62a17ae | 18789 | return CMD_SUCCESS; |
718e3744 | 18790 | } |
7336e101 | 18791 | |
174b5cb9 DA |
18792 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
18793 | "no bgp community-list <(1-99)|standard WORD>", | |
18794 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
18795 | "Community list number (standard)\n" | |
18796 | "Add an standard community-list entry\n" | |
18797 | "Community list name\n") | |
18798 | ||
7336e101 SP |
18799 | /*community-list expanded */ |
18800 | DEFUN (community_list_expanded_all, | |
18801 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 18802 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18803 | BGP_STR |
18804 | COMMUNITY_LIST_STR | |
718e3744 | 18805 | "Community list number (expanded)\n" |
5bf15956 | 18806 | "Add an expanded community-list entry\n" |
718e3744 | 18807 | "Community list name\n" |
2f8cc0e5 DA |
18808 | "Sequence number of an entry\n" |
18809 | "Sequence number\n" | |
718e3744 | 18810 | "Specify community to reject\n" |
18811 | "Specify community to accept\n" | |
18812 | COMMUNITY_VAL_STR) | |
18813 | { | |
d62a17ae | 18814 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18815 | char *seq = NULL; |
d62a17ae | 18816 | int direct = 0; |
18817 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 18818 | int idx = 0; |
7b9a4750 | 18819 | |
2f8cc0e5 DA |
18820 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18821 | if (idx) | |
18822 | seq = argv[idx]->arg; | |
18823 | ||
18824 | idx = 0; | |
18825 | ||
d62a17ae | 18826 | argv_find(argv, argc, "(100-500)", &idx); |
18827 | argv_find(argv, argc, "WORD", &idx); | |
18828 | cl_name_or_number = argv[idx]->arg; | |
18829 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
18830 | : COMMUNITY_DENY; | |
18831 | argv_find(argv, argc, "AA:NN", &idx); | |
18832 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18833 | |
2f8cc0e5 DA |
18834 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
18835 | direct, style); | |
42f914d4 | 18836 | |
d62a17ae | 18837 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18838 | |
d62a17ae | 18839 | if (ret < 0) { |
18840 | /* Display error string. */ | |
18841 | community_list_perror(vty, ret); | |
18842 | return CMD_WARNING_CONFIG_FAILED; | |
18843 | } | |
42f914d4 | 18844 | |
d62a17ae | 18845 | return CMD_SUCCESS; |
718e3744 | 18846 | } |
18847 | ||
7336e101 SP |
18848 | DEFUN (no_community_list_expanded_all, |
18849 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 18850 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18851 | NO_STR |
18852 | BGP_STR | |
18853 | COMMUNITY_LIST_STR | |
18854 | "Community list number (expanded)\n" | |
18855 | "Add an expanded community-list entry\n" | |
18856 | "Community list name\n" | |
2f8cc0e5 DA |
18857 | "Sequence number of an entry\n" |
18858 | "Sequence number\n" | |
7336e101 SP |
18859 | "Specify community to reject\n" |
18860 | "Specify community to accept\n" | |
18861 | COMMUNITY_VAL_STR) | |
718e3744 | 18862 | { |
d62a17ae | 18863 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18864 | char *seq = NULL; |
174b5cb9 | 18865 | char *str = NULL; |
d62a17ae | 18866 | int direct = 0; |
18867 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 18868 | int idx = 0; |
174b5cb9 | 18869 | |
2f8cc0e5 DA |
18870 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18871 | if (idx) | |
18872 | seq = argv[idx]->arg; | |
18873 | ||
18874 | idx = 0; | |
174b5cb9 DA |
18875 | argv_find(argv, argc, "permit", &idx); |
18876 | argv_find(argv, argc, "deny", &idx); | |
18877 | ||
18878 | if (idx) { | |
18879 | direct = argv_find(argv, argc, "permit", &idx) | |
18880 | ? COMMUNITY_PERMIT | |
18881 | : COMMUNITY_DENY; | |
18882 | ||
18883 | idx = 0; | |
18884 | argv_find(argv, argc, "AA:NN", &idx); | |
18885 | str = argv_concat(argv, argc, idx); | |
7336e101 | 18886 | } |
174b5cb9 DA |
18887 | |
18888 | idx = 0; | |
d62a17ae | 18889 | argv_find(argv, argc, "(100-500)", &idx); |
18890 | argv_find(argv, argc, "WORD", &idx); | |
18891 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 18892 | |
2f8cc0e5 | 18893 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 18894 | direct, style); |
42f914d4 | 18895 | |
d62a17ae | 18896 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 18897 | |
d62a17ae | 18898 | if (ret < 0) { |
18899 | community_list_perror(vty, ret); | |
18900 | return CMD_WARNING_CONFIG_FAILED; | |
18901 | } | |
42f914d4 | 18902 | |
d62a17ae | 18903 | return CMD_SUCCESS; |
718e3744 | 18904 | } |
18905 | ||
36d4bb44 EB |
18906 | ALIAS(no_community_list_expanded_all, |
18907 | no_bgp_community_list_expanded_all_list_cmd, | |
174b5cb9 | 18908 | "no bgp community-list <(100-500)|expanded WORD>", |
36d4bb44 | 18909 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
18910 | "Community list number (expanded)\n" |
18911 | "Add an expanded community-list entry\n" | |
18912 | "Community list name\n") | |
18913 | ||
8d9b8ed9 PM |
18914 | /* Return configuration string of community-list entry. */ |
18915 | static const char *community_list_config_str(struct community_entry *entry) | |
18916 | { | |
18917 | const char *str; | |
18918 | ||
18919 | if (entry->any) | |
18920 | str = ""; | |
18921 | else { | |
18922 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
18923 | str = community_str(entry->u.com, false); | |
18924 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
18925 | str = lcommunity_str(entry->u.lcom, false); | |
18926 | else | |
18927 | str = entry->config; | |
18928 | } | |
18929 | return str; | |
18930 | } | |
18931 | ||
d62a17ae | 18932 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 18933 | { |
d62a17ae | 18934 | struct community_entry *entry; |
718e3744 | 18935 | |
d62a17ae | 18936 | for (entry = list->head; entry; entry = entry->next) { |
18937 | if (entry == list->head) { | |
18938 | if (all_digit(list->name)) | |
18939 | vty_out(vty, "Community %s list %s\n", | |
18940 | entry->style == COMMUNITY_LIST_STANDARD | |
18941 | ? "standard" | |
18942 | : "(expanded) access", | |
18943 | list->name); | |
18944 | else | |
18945 | vty_out(vty, "Named Community %s list %s\n", | |
18946 | entry->style == COMMUNITY_LIST_STANDARD | |
18947 | ? "standard" | |
18948 | : "expanded", | |
18949 | list->name); | |
18950 | } | |
18951 | if (entry->any) | |
18952 | vty_out(vty, " %s\n", | |
18953 | community_direct_str(entry->direct)); | |
18954 | else | |
18955 | vty_out(vty, " %s %s\n", | |
18956 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18957 | community_list_config_str(entry)); |
d62a17ae | 18958 | } |
718e3744 | 18959 | } |
18960 | ||
7336e101 SP |
18961 | DEFUN (show_community_list, |
18962 | show_bgp_community_list_cmd, | |
18963 | "show bgp community-list", | |
718e3744 | 18964 | SHOW_STR |
7336e101 | 18965 | BGP_STR |
718e3744 | 18966 | "List community-list\n") |
18967 | { | |
d62a17ae | 18968 | struct community_list *list; |
18969 | struct community_list_master *cm; | |
718e3744 | 18970 | |
d62a17ae | 18971 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
18972 | if (!cm) | |
18973 | return CMD_SUCCESS; | |
718e3744 | 18974 | |
d62a17ae | 18975 | for (list = cm->num.head; list; list = list->next) |
18976 | community_list_show(vty, list); | |
718e3744 | 18977 | |
d62a17ae | 18978 | for (list = cm->str.head; list; list = list->next) |
18979 | community_list_show(vty, list); | |
718e3744 | 18980 | |
d62a17ae | 18981 | return CMD_SUCCESS; |
718e3744 | 18982 | } |
18983 | ||
7336e101 SP |
18984 | DEFUN (show_community_list_arg, |
18985 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 18986 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
18987 | SHOW_STR |
18988 | BGP_STR | |
718e3744 | 18989 | "List community-list\n" |
18990 | "Community-list number\n" | |
960b69b9 | 18991 | "Community-list name\n" |
18992 | "Detailed information on community-list\n") | |
718e3744 | 18993 | { |
d62a17ae | 18994 | int idx_comm_list = 3; |
18995 | struct community_list *list; | |
718e3744 | 18996 | |
e237b0d2 | 18997 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 18998 | COMMUNITY_LIST_MASTER); |
18999 | if (!list) { | |
19000 | vty_out(vty, "%% Can't find community-list\n"); | |
19001 | return CMD_WARNING; | |
19002 | } | |
718e3744 | 19003 | |
d62a17ae | 19004 | community_list_show(vty, list); |
718e3744 | 19005 | |
d62a17ae | 19006 | return CMD_SUCCESS; |
718e3744 | 19007 | } |
6b0655a2 | 19008 | |
57d187bc JS |
19009 | /* |
19010 | * Large Community code. | |
19011 | */ | |
d62a17ae | 19012 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
19013 | struct cmd_token **argv, int style, | |
19014 | int reject_all_digit_name) | |
19015 | { | |
19016 | int ret; | |
19017 | int direct; | |
19018 | char *str; | |
19019 | int idx = 0; | |
19020 | char *cl_name; | |
2f8cc0e5 DA |
19021 | char *seq = NULL; |
19022 | ||
947073e3 | 19023 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 19024 | seq = argv[idx]->arg; |
d62a17ae | 19025 | |
2f8cc0e5 | 19026 | idx = 0; |
d62a17ae | 19027 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19028 | : COMMUNITY_DENY; | |
19029 | ||
19030 | /* All digit name check. */ | |
19031 | idx = 0; | |
19032 | argv_find(argv, argc, "WORD", &idx); | |
19033 | argv_find(argv, argc, "(1-99)", &idx); | |
19034 | argv_find(argv, argc, "(100-500)", &idx); | |
19035 | cl_name = argv[idx]->arg; | |
19036 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19037 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19038 | return CMD_WARNING_CONFIG_FAILED; | |
19039 | } | |
19040 | ||
19041 | idx = 0; | |
19042 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19043 | argv_find(argv, argc, "LINE", &idx); | |
19044 | /* Concat community string argument. */ | |
19045 | if (idx) | |
19046 | str = argv_concat(argv, argc, idx); | |
19047 | else | |
19048 | str = NULL; | |
19049 | ||
2f8cc0e5 | 19050 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 19051 | |
19052 | /* Free temporary community list string allocated by | |
19053 | argv_concat(). */ | |
0a22ddfb | 19054 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19055 | |
19056 | if (ret < 0) { | |
19057 | community_list_perror(vty, ret); | |
19058 | return CMD_WARNING_CONFIG_FAILED; | |
19059 | } | |
19060 | return CMD_SUCCESS; | |
19061 | } | |
19062 | ||
19063 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19064 | struct cmd_token **argv, int style) | |
19065 | { | |
19066 | int ret; | |
19067 | int direct = 0; | |
19068 | char *str = NULL; | |
19069 | int idx = 0; | |
2f8cc0e5 | 19070 | char *seq = NULL; |
d62a17ae | 19071 | |
947073e3 | 19072 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 19073 | seq = argv[idx]->arg; |
d62a17ae | 19074 | |
2f8cc0e5 | 19075 | idx = 0; |
d62a17ae | 19076 | argv_find(argv, argc, "permit", &idx); |
19077 | argv_find(argv, argc, "deny", &idx); | |
19078 | ||
19079 | if (idx) { | |
19080 | /* Check the list direct. */ | |
19081 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19082 | direct = COMMUNITY_PERMIT; | |
19083 | else | |
19084 | direct = COMMUNITY_DENY; | |
19085 | ||
19086 | idx = 0; | |
19087 | argv_find(argv, argc, "LINE", &idx); | |
19088 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19089 | /* Concat community string argument. */ | |
19090 | str = argv_concat(argv, argc, idx); | |
19091 | } | |
19092 | ||
19093 | idx = 0; | |
19094 | argv_find(argv, argc, "(1-99)", &idx); | |
19095 | argv_find(argv, argc, "(100-500)", &idx); | |
19096 | argv_find(argv, argc, "WORD", &idx); | |
19097 | ||
19098 | /* Unset community list. */ | |
2f8cc0e5 | 19099 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 19100 | style); |
19101 | ||
19102 | /* Free temporary community list string allocated by | |
19103 | argv_concat(). */ | |
0a22ddfb | 19104 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19105 | |
19106 | if (ret < 0) { | |
19107 | community_list_perror(vty, ret); | |
19108 | return CMD_WARNING_CONFIG_FAILED; | |
19109 | } | |
19110 | ||
19111 | return CMD_SUCCESS; | |
57d187bc JS |
19112 | } |
19113 | ||
19114 | /* "large-community-list" keyword help string. */ | |
19115 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19116 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19117 | ||
7336e101 SP |
19118 | DEFUN (lcommunity_list_standard, |
19119 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 19120 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19121 | BGP_STR |
19122 | LCOMMUNITY_LIST_STR | |
19123 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19124 | "Sequence number of an entry\n" |
19125 | "Sequence number\n" | |
7336e101 SP |
19126 | "Specify large community to reject\n" |
19127 | "Specify large community to accept\n" | |
19128 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19129 | { |
d62a17ae | 19130 | return lcommunity_list_set_vty(vty, argc, argv, |
19131 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
19132 | } |
19133 | ||
7336e101 SP |
19134 | DEFUN (lcommunity_list_expanded, |
19135 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 19136 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19137 | BGP_STR |
19138 | LCOMMUNITY_LIST_STR | |
19139 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19140 | "Sequence number of an entry\n" |
19141 | "Sequence number\n" | |
7336e101 SP |
19142 | "Specify large community to reject\n" |
19143 | "Specify large community to accept\n" | |
19144 | "An ordered list as a regular-expression\n") | |
57d187bc | 19145 | { |
d62a17ae | 19146 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19147 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
19148 | } |
19149 | ||
7336e101 SP |
19150 | DEFUN (lcommunity_list_name_standard, |
19151 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 19152 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19153 | BGP_STR |
19154 | LCOMMUNITY_LIST_STR | |
19155 | "Specify standard large-community-list\n" | |
19156 | "Large Community list name\n" | |
2f8cc0e5 DA |
19157 | "Sequence number of an entry\n" |
19158 | "Sequence number\n" | |
7336e101 SP |
19159 | "Specify large community to reject\n" |
19160 | "Specify large community to accept\n" | |
19161 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19162 | { |
d62a17ae | 19163 | return lcommunity_list_set_vty(vty, argc, argv, |
19164 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
19165 | } |
19166 | ||
7336e101 SP |
19167 | DEFUN (lcommunity_list_name_expanded, |
19168 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 19169 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19170 | BGP_STR |
19171 | LCOMMUNITY_LIST_STR | |
19172 | "Specify expanded large-community-list\n" | |
19173 | "Large Community list name\n" | |
2f8cc0e5 DA |
19174 | "Sequence number of an entry\n" |
19175 | "Sequence number\n" | |
7336e101 SP |
19176 | "Specify large community to reject\n" |
19177 | "Specify large community to accept\n" | |
19178 | "An ordered list as a regular-expression\n") | |
57d187bc | 19179 | { |
d62a17ae | 19180 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19181 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
19182 | } |
19183 | ||
4378f57c DA |
19184 | DEFUN (no_lcommunity_list_all, |
19185 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
19186 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
19187 | NO_STR | |
19188 | BGP_STR | |
19189 | LCOMMUNITY_LIST_STR | |
19190 | "Large Community list number (standard)\n" | |
19191 | "Large Community list number (expanded)\n" | |
19192 | "Large Community list name\n") | |
57d187bc | 19193 | { |
7336e101 SP |
19194 | return lcommunity_list_unset_vty(vty, argc, argv, |
19195 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
19196 | } |
19197 | ||
4378f57c DA |
19198 | DEFUN (no_lcommunity_list_name_standard_all, |
19199 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
19200 | "no bgp large-community-list standard WORD", | |
19201 | NO_STR | |
19202 | BGP_STR | |
19203 | LCOMMUNITY_LIST_STR | |
19204 | "Specify standard large-community-list\n" | |
19205 | "Large Community list name\n") | |
19206 | { | |
19207 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19208 | LARGE_COMMUNITY_LIST_STANDARD); | |
19209 | } | |
19210 | ||
7336e101 SP |
19211 | DEFUN (no_lcommunity_list_name_expanded_all, |
19212 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
19213 | "no bgp large-community-list expanded WORD", | |
19214 | NO_STR | |
19215 | BGP_STR | |
19216 | LCOMMUNITY_LIST_STR | |
19217 | "Specify expanded large-community-list\n" | |
19218 | "Large Community list name\n") | |
57d187bc | 19219 | { |
d62a17ae | 19220 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19221 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19222 | } |
19223 | ||
7336e101 SP |
19224 | DEFUN (no_lcommunity_list_standard, |
19225 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 19226 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19227 | NO_STR |
19228 | BGP_STR | |
19229 | LCOMMUNITY_LIST_STR | |
19230 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19231 | "Sequence number of an entry\n" |
19232 | "Sequence number\n" | |
7336e101 SP |
19233 | "Specify large community to reject\n" |
19234 | "Specify large community to accept\n" | |
19235 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19236 | { |
d62a17ae | 19237 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19238 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19239 | } |
19240 | ||
7336e101 SP |
19241 | DEFUN (no_lcommunity_list_expanded, |
19242 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 19243 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19244 | NO_STR |
19245 | BGP_STR | |
19246 | LCOMMUNITY_LIST_STR | |
19247 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19248 | "Sequence number of an entry\n" |
19249 | "Sequence number\n" | |
7336e101 SP |
19250 | "Specify large community to reject\n" |
19251 | "Specify large community to accept\n" | |
19252 | "An ordered list as a regular-expression\n") | |
57d187bc | 19253 | { |
d62a17ae | 19254 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19255 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19256 | } |
19257 | ||
7336e101 SP |
19258 | DEFUN (no_lcommunity_list_name_standard, |
19259 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 19260 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19261 | NO_STR |
19262 | BGP_STR | |
19263 | LCOMMUNITY_LIST_STR | |
19264 | "Specify standard large-community-list\n" | |
19265 | "Large Community list name\n" | |
2f8cc0e5 DA |
19266 | "Sequence number of an entry\n" |
19267 | "Sequence number\n" | |
7336e101 SP |
19268 | "Specify large community to reject\n" |
19269 | "Specify large community to accept\n" | |
19270 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19271 | { |
d62a17ae | 19272 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19273 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19274 | } |
19275 | ||
7336e101 SP |
19276 | DEFUN (no_lcommunity_list_name_expanded, |
19277 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 19278 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19279 | NO_STR |
19280 | BGP_STR | |
19281 | LCOMMUNITY_LIST_STR | |
19282 | "Specify expanded large-community-list\n" | |
19283 | "Large community list name\n" | |
2f8cc0e5 DA |
19284 | "Sequence number of an entry\n" |
19285 | "Sequence number\n" | |
7336e101 SP |
19286 | "Specify large community to reject\n" |
19287 | "Specify large community to accept\n" | |
19288 | "An ordered list as a regular-expression\n") | |
57d187bc | 19289 | { |
d62a17ae | 19290 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19291 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19292 | } |
19293 | ||
d62a17ae | 19294 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
19295 | { | |
19296 | struct community_entry *entry; | |
19297 | ||
19298 | for (entry = list->head; entry; entry = entry->next) { | |
19299 | if (entry == list->head) { | |
19300 | if (all_digit(list->name)) | |
19301 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 19302 | entry->style == |
19303 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19304 | ? "standard" |
19305 | : "(expanded) access", | |
19306 | list->name); | |
19307 | else | |
19308 | vty_out(vty, | |
19309 | "Named large community %s list %s\n", | |
169b72c8 | 19310 | entry->style == |
19311 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19312 | ? "standard" |
19313 | : "expanded", | |
19314 | list->name); | |
19315 | } | |
19316 | if (entry->any) | |
19317 | vty_out(vty, " %s\n", | |
19318 | community_direct_str(entry->direct)); | |
19319 | else | |
19320 | vty_out(vty, " %s %s\n", | |
19321 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19322 | community_list_config_str(entry)); |
d62a17ae | 19323 | } |
57d187bc JS |
19324 | } |
19325 | ||
7336e101 SP |
19326 | DEFUN (show_lcommunity_list, |
19327 | show_bgp_lcommunity_list_cmd, | |
19328 | "show bgp large-community-list", | |
57d187bc | 19329 | SHOW_STR |
7336e101 | 19330 | BGP_STR |
57d187bc JS |
19331 | "List large-community list\n") |
19332 | { | |
d62a17ae | 19333 | struct community_list *list; |
19334 | struct community_list_master *cm; | |
57d187bc | 19335 | |
d62a17ae | 19336 | cm = community_list_master_lookup(bgp_clist, |
19337 | LARGE_COMMUNITY_LIST_MASTER); | |
19338 | if (!cm) | |
19339 | return CMD_SUCCESS; | |
57d187bc | 19340 | |
d62a17ae | 19341 | for (list = cm->num.head; list; list = list->next) |
19342 | lcommunity_list_show(vty, list); | |
57d187bc | 19343 | |
d62a17ae | 19344 | for (list = cm->str.head; list; list = list->next) |
19345 | lcommunity_list_show(vty, list); | |
57d187bc | 19346 | |
d62a17ae | 19347 | return CMD_SUCCESS; |
57d187bc JS |
19348 | } |
19349 | ||
7336e101 SP |
19350 | DEFUN (show_lcommunity_list_arg, |
19351 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 19352 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
19353 | SHOW_STR |
19354 | BGP_STR | |
57d187bc | 19355 | "List large-community list\n" |
960b69b9 | 19356 | "Large-community-list number\n" |
19357 | "Large-community-list name\n" | |
19358 | "Detailed information on large-community-list\n") | |
57d187bc | 19359 | { |
d62a17ae | 19360 | struct community_list *list; |
57d187bc | 19361 | |
e237b0d2 | 19362 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 19363 | LARGE_COMMUNITY_LIST_MASTER); |
19364 | if (!list) { | |
960b69b9 | 19365 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 19366 | return CMD_WARNING; |
19367 | } | |
57d187bc | 19368 | |
d62a17ae | 19369 | lcommunity_list_show(vty, list); |
57d187bc | 19370 | |
d62a17ae | 19371 | return CMD_SUCCESS; |
57d187bc JS |
19372 | } |
19373 | ||
718e3744 | 19374 | /* "extcommunity-list" keyword help string. */ |
19375 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19376 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19377 | ||
7336e101 SP |
19378 | DEFUN (extcommunity_list_standard, |
19379 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 19380 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19381 | BGP_STR |
718e3744 | 19382 | EXTCOMMUNITY_LIST_STR |
19383 | "Extended Community list number (standard)\n" | |
718e3744 | 19384 | "Specify standard extcommunity-list\n" |
5bf15956 | 19385 | "Community list name\n" |
2f8cc0e5 DA |
19386 | "Sequence number of an entry\n" |
19387 | "Sequence number\n" | |
718e3744 | 19388 | "Specify community to reject\n" |
19389 | "Specify community to accept\n" | |
19390 | EXTCOMMUNITY_VAL_STR) | |
19391 | { | |
d62a17ae | 19392 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19393 | int direct = 0; | |
19394 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19395 | char *seq = NULL; |
42f914d4 | 19396 | |
d62a17ae | 19397 | int idx = 0; |
7b9a4750 | 19398 | |
d62a17ae | 19399 | argv_find(argv, argc, "(1-99)", &idx); |
19400 | argv_find(argv, argc, "WORD", &idx); | |
19401 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19402 | |
409148f6 | 19403 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19404 | seq = argv[idx]->arg; |
19405 | ||
d62a17ae | 19406 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19407 | : COMMUNITY_DENY; | |
19408 | argv_find(argv, argc, "AA:NN", &idx); | |
19409 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19410 | |
2f8cc0e5 | 19411 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19412 | direct, style); |
42f914d4 | 19413 | |
d62a17ae | 19414 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19415 | |
d62a17ae | 19416 | if (ret < 0) { |
19417 | community_list_perror(vty, ret); | |
19418 | return CMD_WARNING_CONFIG_FAILED; | |
19419 | } | |
42f914d4 | 19420 | |
d62a17ae | 19421 | return CMD_SUCCESS; |
718e3744 | 19422 | } |
19423 | ||
7336e101 SP |
19424 | DEFUN (extcommunity_list_name_expanded, |
19425 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 19426 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19427 | BGP_STR |
19428 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 19429 | "Extended Community list number (expanded)\n" |
718e3744 | 19430 | "Specify expanded extcommunity-list\n" |
19431 | "Extended Community list name\n" | |
2f8cc0e5 DA |
19432 | "Sequence number of an entry\n" |
19433 | "Sequence number\n" | |
718e3744 | 19434 | "Specify community to reject\n" |
19435 | "Specify community to accept\n" | |
19436 | "An ordered list as a regular-expression\n") | |
19437 | { | |
d62a17ae | 19438 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19439 | int direct = 0; | |
19440 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19441 | char *seq = NULL; |
d62a17ae | 19442 | int idx = 0; |
7336e101 | 19443 | |
d62a17ae | 19444 | argv_find(argv, argc, "(100-500)", &idx); |
19445 | argv_find(argv, argc, "WORD", &idx); | |
19446 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19447 | |
409148f6 | 19448 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19449 | seq = argv[idx]->arg; |
19450 | ||
d62a17ae | 19451 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19452 | : COMMUNITY_DENY; | |
19453 | argv_find(argv, argc, "LINE", &idx); | |
19454 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19455 | |
2f8cc0e5 | 19456 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19457 | direct, style); |
42f914d4 | 19458 | |
d62a17ae | 19459 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19460 | |
d62a17ae | 19461 | if (ret < 0) { |
19462 | community_list_perror(vty, ret); | |
19463 | return CMD_WARNING_CONFIG_FAILED; | |
19464 | } | |
42f914d4 | 19465 | |
d62a17ae | 19466 | return CMD_SUCCESS; |
718e3744 | 19467 | } |
19468 | ||
7336e101 SP |
19469 | DEFUN (no_extcommunity_list_standard_all, |
19470 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 19471 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19472 | NO_STR |
19473 | BGP_STR | |
19474 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 19475 | "Extended Community list number (standard)\n" |
718e3744 | 19476 | "Specify standard extcommunity-list\n" |
5bf15956 | 19477 | "Community list name\n" |
2f8cc0e5 DA |
19478 | "Sequence number of an entry\n" |
19479 | "Sequence number\n" | |
718e3744 | 19480 | "Specify community to reject\n" |
19481 | "Specify community to accept\n" | |
19482 | EXTCOMMUNITY_VAL_STR) | |
19483 | { | |
d62a17ae | 19484 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19485 | int direct = 0; | |
19486 | char *cl_number_or_name = NULL; | |
d4455c89 | 19487 | char *str = NULL; |
2f8cc0e5 | 19488 | char *seq = NULL; |
d62a17ae | 19489 | int idx = 0; |
d4455c89 | 19490 | |
409148f6 | 19491 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19492 | seq = argv[idx]->arg; |
19493 | ||
19494 | idx = 0; | |
d4455c89 DA |
19495 | argv_find(argv, argc, "permit", &idx); |
19496 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
19497 | if (idx) { |
19498 | direct = argv_find(argv, argc, "permit", &idx) | |
19499 | ? COMMUNITY_PERMIT | |
19500 | : COMMUNITY_DENY; | |
19501 | ||
19502 | idx = 0; | |
19503 | argv_find(argv, argc, "AA:NN", &idx); | |
19504 | str = argv_concat(argv, argc, idx); | |
19505 | } | |
19506 | ||
19507 | idx = 0; | |
d62a17ae | 19508 | argv_find(argv, argc, "(1-99)", &idx); |
19509 | argv_find(argv, argc, "WORD", &idx); | |
19510 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19511 | |
d62a17ae | 19512 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19513 | seq, direct, style); |
42f914d4 | 19514 | |
d62a17ae | 19515 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19516 | |
d62a17ae | 19517 | if (ret < 0) { |
19518 | community_list_perror(vty, ret); | |
19519 | return CMD_WARNING_CONFIG_FAILED; | |
19520 | } | |
42f914d4 | 19521 | |
d62a17ae | 19522 | return CMD_SUCCESS; |
718e3744 | 19523 | } |
19524 | ||
d4455c89 DA |
19525 | ALIAS(no_extcommunity_list_standard_all, |
19526 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
19527 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
36d4bb44 | 19528 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19529 | "Extended Community list number (standard)\n" |
19530 | "Specify standard extcommunity-list\n" | |
19531 | "Community list name\n") | |
19532 | ||
7336e101 SP |
19533 | DEFUN (no_extcommunity_list_expanded_all, |
19534 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 19535 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19536 | NO_STR |
19537 | BGP_STR | |
19538 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 19539 | "Extended Community list number (expanded)\n" |
718e3744 | 19540 | "Specify expanded extcommunity-list\n" |
5bf15956 | 19541 | "Extended Community list name\n" |
2f8cc0e5 DA |
19542 | "Sequence number of an entry\n" |
19543 | "Sequence number\n" | |
718e3744 | 19544 | "Specify community to reject\n" |
19545 | "Specify community to accept\n" | |
19546 | "An ordered list as a regular-expression\n") | |
19547 | { | |
d62a17ae | 19548 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19549 | int direct = 0; | |
19550 | char *cl_number_or_name = NULL; | |
d4455c89 | 19551 | char *str = NULL; |
2f8cc0e5 | 19552 | char *seq = NULL; |
d62a17ae | 19553 | int idx = 0; |
d4455c89 | 19554 | |
409148f6 | 19555 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19556 | seq = argv[idx]->arg; |
19557 | ||
19558 | idx = 0; | |
d4455c89 DA |
19559 | argv_find(argv, argc, "permit", &idx); |
19560 | argv_find(argv, argc, "deny", &idx); | |
19561 | ||
19562 | if (idx) { | |
19563 | direct = argv_find(argv, argc, "permit", &idx) | |
19564 | ? COMMUNITY_PERMIT | |
19565 | : COMMUNITY_DENY; | |
19566 | ||
19567 | idx = 0; | |
19568 | argv_find(argv, argc, "LINE", &idx); | |
19569 | str = argv_concat(argv, argc, idx); | |
19570 | } | |
19571 | ||
19572 | idx = 0; | |
d62a17ae | 19573 | argv_find(argv, argc, "(100-500)", &idx); |
19574 | argv_find(argv, argc, "WORD", &idx); | |
19575 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19576 | |
d62a17ae | 19577 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19578 | seq, direct, style); |
42f914d4 | 19579 | |
d62a17ae | 19580 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19581 | |
d62a17ae | 19582 | if (ret < 0) { |
19583 | community_list_perror(vty, ret); | |
19584 | return CMD_WARNING_CONFIG_FAILED; | |
19585 | } | |
42f914d4 | 19586 | |
d62a17ae | 19587 | return CMD_SUCCESS; |
718e3744 | 19588 | } |
19589 | ||
d4455c89 DA |
19590 | ALIAS(no_extcommunity_list_expanded_all, |
19591 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
19592 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
36d4bb44 | 19593 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19594 | "Extended Community list number (expanded)\n" |
19595 | "Specify expanded extcommunity-list\n" | |
19596 | "Extended Community list name\n") | |
19597 | ||
d62a17ae | 19598 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19599 | { |
d62a17ae | 19600 | struct community_entry *entry; |
718e3744 | 19601 | |
d62a17ae | 19602 | for (entry = list->head; entry; entry = entry->next) { |
19603 | if (entry == list->head) { | |
19604 | if (all_digit(list->name)) | |
19605 | vty_out(vty, "Extended community %s list %s\n", | |
19606 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19607 | ? "standard" | |
19608 | : "(expanded) access", | |
19609 | list->name); | |
19610 | else | |
19611 | vty_out(vty, | |
19612 | "Named extended community %s list %s\n", | |
19613 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19614 | ? "standard" | |
19615 | : "expanded", | |
19616 | list->name); | |
19617 | } | |
19618 | if (entry->any) | |
19619 | vty_out(vty, " %s\n", | |
19620 | community_direct_str(entry->direct)); | |
19621 | else | |
19622 | vty_out(vty, " %s %s\n", | |
19623 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19624 | community_list_config_str(entry)); |
d62a17ae | 19625 | } |
718e3744 | 19626 | } |
19627 | ||
7336e101 SP |
19628 | DEFUN (show_extcommunity_list, |
19629 | show_bgp_extcommunity_list_cmd, | |
19630 | "show bgp extcommunity-list", | |
718e3744 | 19631 | SHOW_STR |
7336e101 | 19632 | BGP_STR |
718e3744 | 19633 | "List extended-community list\n") |
19634 | { | |
d62a17ae | 19635 | struct community_list *list; |
19636 | struct community_list_master *cm; | |
718e3744 | 19637 | |
d62a17ae | 19638 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
19639 | if (!cm) | |
19640 | return CMD_SUCCESS; | |
718e3744 | 19641 | |
d62a17ae | 19642 | for (list = cm->num.head; list; list = list->next) |
19643 | extcommunity_list_show(vty, list); | |
718e3744 | 19644 | |
d62a17ae | 19645 | for (list = cm->str.head; list; list = list->next) |
19646 | extcommunity_list_show(vty, list); | |
718e3744 | 19647 | |
d62a17ae | 19648 | return CMD_SUCCESS; |
718e3744 | 19649 | } |
19650 | ||
7336e101 SP |
19651 | DEFUN (show_extcommunity_list_arg, |
19652 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 19653 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
19654 | SHOW_STR |
19655 | BGP_STR | |
718e3744 | 19656 | "List extended-community list\n" |
19657 | "Extcommunity-list number\n" | |
960b69b9 | 19658 | "Extcommunity-list name\n" |
19659 | "Detailed information on extcommunity-list\n") | |
718e3744 | 19660 | { |
d62a17ae | 19661 | int idx_comm_list = 3; |
19662 | struct community_list *list; | |
718e3744 | 19663 | |
e237b0d2 | 19664 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19665 | EXTCOMMUNITY_LIST_MASTER); |
19666 | if (!list) { | |
19667 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
19668 | return CMD_WARNING; | |
19669 | } | |
718e3744 | 19670 | |
d62a17ae | 19671 | extcommunity_list_show(vty, list); |
718e3744 | 19672 | |
d62a17ae | 19673 | return CMD_SUCCESS; |
718e3744 | 19674 | } |
6b0655a2 | 19675 | |
718e3744 | 19676 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 19677 | static int community_list_config_write(struct vty *vty) |
19678 | { | |
19679 | struct community_list *list; | |
19680 | struct community_entry *entry; | |
19681 | struct community_list_master *cm; | |
19682 | int write = 0; | |
19683 | ||
19684 | /* Community-list. */ | |
19685 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
19686 | ||
19687 | for (list = cm->num.head; list; list = list->next) | |
19688 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19689 | vty_out(vty, |
19690 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
19691 | list->name, entry->seq, | |
d62a17ae | 19692 | community_direct_str(entry->direct), |
19693 | community_list_config_str(entry)); | |
19694 | write++; | |
19695 | } | |
19696 | for (list = cm->str.head; list; list = list->next) | |
19697 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19698 | vty_out(vty, |
19699 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 19700 | entry->style == COMMUNITY_LIST_STANDARD |
19701 | ? "standard" | |
19702 | : "expanded", | |
2f8cc0e5 DA |
19703 | list->name, entry->seq, |
19704 | community_direct_str(entry->direct), | |
d62a17ae | 19705 | community_list_config_str(entry)); |
19706 | write++; | |
19707 | } | |
19708 | ||
19709 | /* Extcommunity-list. */ | |
19710 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
19711 | ||
19712 | for (list = cm->num.head; list; list = list->next) | |
19713 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19714 | vty_out(vty, |
19715 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
19716 | list->name, entry->seq, | |
19717 | community_direct_str(entry->direct), | |
d62a17ae | 19718 | community_list_config_str(entry)); |
19719 | write++; | |
19720 | } | |
19721 | for (list = cm->str.head; list; list = list->next) | |
19722 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 19723 | vty_out(vty, |
6cde4b45 | 19724 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 19725 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
19726 | ? "standard" | |
19727 | : "expanded", | |
2f8cc0e5 DA |
19728 | list->name, entry->seq, |
19729 | community_direct_str(entry->direct), | |
d62a17ae | 19730 | community_list_config_str(entry)); |
19731 | write++; | |
19732 | } | |
19733 | ||
19734 | ||
19735 | /* lcommunity-list. */ | |
19736 | cm = community_list_master_lookup(bgp_clist, | |
19737 | LARGE_COMMUNITY_LIST_MASTER); | |
19738 | ||
19739 | for (list = cm->num.head; list; list = list->next) | |
19740 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 19741 | vty_out(vty, |
6cde4b45 | 19742 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
19743 | list->name, entry->seq, |
19744 | community_direct_str(entry->direct), | |
d62a17ae | 19745 | community_list_config_str(entry)); |
19746 | write++; | |
19747 | } | |
19748 | for (list = cm->str.head; list; list = list->next) | |
19749 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 19750 | vty_out(vty, |
6cde4b45 | 19751 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 19752 | |
d62a17ae | 19753 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
19754 | ? "standard" | |
19755 | : "expanded", | |
2f8cc0e5 | 19756 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 19757 | community_list_config_str(entry)); |
19758 | write++; | |
19759 | } | |
19760 | ||
19761 | return write; | |
19762 | } | |
19763 | ||
612c2c15 | 19764 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 19765 | static struct cmd_node community_list_node = { |
f4b8291f | 19766 | .name = "community list", |
62b346ee DL |
19767 | .node = COMMUNITY_LIST_NODE, |
19768 | .prompt = "", | |
612c2c15 | 19769 | .config_write = community_list_config_write, |
718e3744 | 19770 | }; |
19771 | ||
d62a17ae | 19772 | static void community_list_vty(void) |
19773 | { | |
612c2c15 | 19774 | install_node(&community_list_node); |
d62a17ae | 19775 | |
19776 | /* Community-list. */ | |
7336e101 SP |
19777 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
19778 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
19779 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 19780 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 19781 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 19782 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
19783 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
19784 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 19785 | |
19786 | /* Extcommunity-list. */ | |
7336e101 SP |
19787 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
19788 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
19789 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
19790 | install_element(CONFIG_NODE, |
19791 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 19792 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
19793 | install_element(CONFIG_NODE, |
19794 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
19795 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
19796 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 19797 | |
19798 | /* Large Community List */ | |
7336e101 | 19799 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
19800 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
19801 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 19802 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
19803 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
19804 | install_element(CONFIG_NODE, | |
19805 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
19806 | install_element(CONFIG_NODE, |
19807 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
19808 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
19809 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
19810 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
19811 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
19812 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
19813 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 19814 | } |