]>
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 | { |
00908b7a | 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 | |
00908b7a | 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 | 3678 | /* Display hostname in certain command outputs */ |
232c75cd CS |
3679 | DEFUN_YANG(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") | |
aef999a2 | 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 | ||
232c75cd CS |
4347 | DEFUN_YANG(neighbor_interface_config, |
4348 | neighbor_interface_config_cmd, | |
f4b8ec07 CS |
4349 | "neighbor WORD interface [peer-group PGNAME]", |
4350 | NEIGHBOR_STR | |
4351 | "Interface name or neighbor tag\n" | |
4352 | "Enable BGP on interface\n" | |
4353 | "Member of the peer-group\n" | |
4354 | "Peer-group name\n") | |
4c48cf63 | 4355 | { |
d62a17ae | 4356 | int idx_word = 1; |
4357 | int idx_peer_group_word = 4; | |
f4b8ec07 CS |
4358 | char base_xpath[XPATH_MAXLEN]; |
4359 | ||
4360 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4361 | argv[idx_word]->arg, ""); | |
31500417 | 4362 | |
f4b8ec07 | 4363 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
d62a17ae | 4364 | if (argc > idx_peer_group_word) |
f4b8ec07 CS |
4365 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4366 | argv[idx_peer_group_word]->arg); | |
4367 | ||
4368 | return nb_cli_apply_changes(vty, base_xpath); | |
4c48cf63 DW |
4369 | } |
4370 | ||
f4b8ec07 CS |
4371 | DEFUN_YANG(neighbor_interface_config_v6only, |
4372 | neighbor_interface_config_v6only_cmd, | |
4373 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4374 | NEIGHBOR_STR | |
4375 | "Interface name or neighbor tag\n" | |
4376 | "Enable BGP on interface\n" | |
4377 | "Enable BGP with v6 link-local only\n" | |
4378 | "Member of the peer-group\n" | |
4379 | "Peer-group name\n") | |
4c48cf63 | 4380 | { |
d62a17ae | 4381 | int idx_word = 1; |
4382 | int idx_peer_group_word = 5; | |
f4b8ec07 CS |
4383 | char base_xpath[XPATH_MAXLEN]; |
4384 | ||
4385 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4386 | argv[idx_word]->arg, ""); | |
31500417 | 4387 | |
f4b8ec07 | 4388 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
d62a17ae | 4389 | if (argc > idx_peer_group_word) |
f4b8ec07 CS |
4390 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4391 | argv[idx_peer_group_word]->arg); | |
31500417 | 4392 | |
f4b8ec07 CS |
4393 | nb_cli_enqueue_change(vty, "./v6only", NB_OP_MODIFY, "true"); |
4394 | ||
4395 | return nb_cli_apply_changes(vty, base_xpath); | |
4c48cf63 DW |
4396 | } |
4397 | ||
a80beece | 4398 | |
f4b8ec07 CS |
4399 | DEFUN_YANG( |
4400 | neighbor_interface_config_remote_as, | |
4401 | neighbor_interface_config_remote_as_cmd, | |
4402 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4403 | NEIGHBOR_STR | |
4404 | "Interface name or neighbor tag\n" | |
4405 | "Enable BGP on interface\n" | |
4406 | "Specify a BGP neighbor\n" AS_STR | |
4407 | "Internal BGP peer\n" | |
4408 | "External BGP peer\n") | |
b3a39dc5 | 4409 | { |
d62a17ae | 4410 | int idx_word = 1; |
4411 | int idx_remote_as = 4; | |
f4b8ec07 CS |
4412 | char base_xpath[XPATH_MAXLEN]; |
4413 | const char *as_type_str = "as-specified"; | |
4414 | ||
4415 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4416 | argv[idx_word]->arg, ""); | |
4417 | ||
4418 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
4419 | ||
4420 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4421 | as_type_str = "internal"; | |
4422 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4423 | as_type_str = "external"; | |
4424 | } else { | |
4425 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4426 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4427 | } | |
4428 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4429 | NB_OP_MODIFY, as_type_str); | |
4430 | ||
4431 | return nb_cli_apply_changes(vty, base_xpath); | |
b3a39dc5 DD |
4432 | } |
4433 | ||
f4b8ec07 CS |
4434 | DEFUN_YANG( |
4435 | neighbor_interface_v6only_config_remote_as, | |
4436 | neighbor_interface_v6only_config_remote_as_cmd, | |
4437 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4438 | NEIGHBOR_STR | |
4439 | "Interface name or neighbor tag\n" | |
4440 | "Enable BGP with v6 link-local only\n" | |
4441 | "Enable BGP on interface\n" | |
4442 | "Specify a BGP neighbor\n" AS_STR | |
4443 | "Internal BGP peer\n" | |
4444 | "External BGP peer\n") | |
b3a39dc5 | 4445 | { |
d62a17ae | 4446 | int idx_word = 1; |
4447 | int idx_remote_as = 5; | |
f4b8ec07 CS |
4448 | char base_xpath[XPATH_MAXLEN]; |
4449 | const char *as_type_str = "as-specified"; | |
4450 | ||
4451 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4452 | argv[idx_word]->arg, ""); | |
4453 | ||
4454 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
4455 | ||
4456 | nb_cli_enqueue_change(vty, "./v6only", NB_OP_MODIFY, "true"); | |
4457 | ||
4458 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4459 | as_type_str = "internal"; | |
4460 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4461 | as_type_str = "external"; | |
4462 | } else { | |
4463 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4464 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4465 | } | |
4466 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4467 | NB_OP_MODIFY, as_type_str); | |
4468 | ||
4469 | return nb_cli_apply_changes(vty, base_xpath); | |
b3a39dc5 DD |
4470 | } |
4471 | ||
f4b8ec07 CS |
4472 | DEFUN_YANG(neighbor_peer_group, neighbor_peer_group_cmd, |
4473 | "neighbor WORD peer-group", | |
4474 | NEIGHBOR_STR | |
4475 | "Interface name or neighbor tag\n" | |
4476 | "Configure peer-group\n") | |
718e3744 | 4477 | { |
f4b8ec07 | 4478 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4479 | int idx_word = 1; |
718e3744 | 4480 | |
f4b8ec07 CS |
4481 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4482 | argv[idx_word]->arg, ""); | |
718e3744 | 4483 | |
f4b8ec07 | 4484 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
718e3744 | 4485 | |
f4b8ec07 | 4486 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 4487 | } |
4488 | ||
232c75cd CS |
4489 | DEFUN_YANG(no_neighbor, |
4490 | no_neighbor_cmd, | |
4491 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4492 | NO_STR NEIGHBOR_STR | |
4493 | NEIGHBOR_ADDR_STR2 | |
4494 | "Specify a BGP neighbor\n" AS_STR | |
4495 | "Internal BGP peer\n" | |
4496 | "External BGP peer\n") | |
718e3744 | 4497 | { |
d62a17ae | 4498 | int idx_peer = 2; |
f4b8ec07 CS |
4499 | char base_xpath[XPATH_MAXLEN]; |
4500 | char num_xpath[XPATH_MAXLEN]; | |
4501 | char unnbr_xpath[XPATH_MAXLEN]; | |
4502 | char prgrp_xpath[XPATH_MAXLEN]; | |
d62a17ae | 4503 | union sockunion su; |
d62a17ae | 4504 | |
f4b8ec07 CS |
4505 | if (str2sockunion(argv[idx_peer]->arg, &su) == 0) { |
4506 | snprintf(num_xpath, sizeof(num_xpath), | |
4507 | FRR_BGP_NEIGHBOR_NUM_XPATH, argv[idx_peer]->arg, ""); | |
4508 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4509 | VTY_CURR_XPATH, num_xpath + 1)) { | |
4510 | strlcpy(base_xpath, num_xpath, sizeof(base_xpath)); | |
d62a17ae | 4511 | } |
f4b8ec07 CS |
4512 | } else { |
4513 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
4514 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, argv[idx_peer]->arg, ""); | |
4515 | ||
4516 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
4517 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, ""); | |
4518 | ||
4519 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4520 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
4521 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); | |
4522 | } else if (yang_dnode_exists(vty->candidate_config->dnode, | |
4523 | "%s%s", VTY_CURR_XPATH, | |
4524 | prgrp_xpath + 1)) { | |
4525 | strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath)); | |
4e2786df | 4526 | } else { |
f4b8ec07 CS |
4527 | vty_out(vty, |
4528 | "%% Create the peer-group or interface first\n"); | |
d62a17ae | 4529 | return CMD_WARNING_CONFIG_FAILED; |
4530 | } | |
1ff9a340 | 4531 | } |
718e3744 | 4532 | |
f4b8ec07 CS |
4533 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_DESTROY, NULL); |
4534 | ||
4535 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 4536 | } |
4537 | ||
f4b8ec07 CS |
4538 | DEFUN_YANG(no_neighbor_interface_config, |
4539 | no_neighbor_interface_config_cmd, | |
4540 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4541 | NO_STR NEIGHBOR_STR | |
4542 | "Interface name\n" | |
4543 | "Configure BGP on interface\n" | |
4544 | "Enable BGP with v6 link-local only\n" | |
4545 | "Member of the peer-group\n" | |
4546 | "Peer-group name\n" | |
4547 | "Specify a BGP neighbor\n" AS_STR | |
4548 | "Internal BGP peer\n" | |
4549 | "External BGP peer\n") | |
a80beece | 4550 | { |
d62a17ae | 4551 | int idx_word = 2; |
f4b8ec07 | 4552 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4553 | |
f4b8ec07 CS |
4554 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, |
4555 | argv[idx_word]->arg, ""); | |
4556 | ||
4557 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
4558 | ||
4559 | return nb_cli_apply_changes(vty, base_xpath); | |
a80beece DS |
4560 | } |
4561 | ||
f4b8ec07 CS |
4562 | DEFUN_YANG(no_neighbor_peer_group, |
4563 | no_neighbor_peer_group_cmd, | |
4564 | "no neighbor WORD peer-group", | |
4565 | NO_STR NEIGHBOR_STR | |
4566 | "Neighbor tag\n" | |
4567 | "Configure peer-group\n") | |
718e3744 | 4568 | { |
f4b8ec07 | 4569 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4570 | int idx_word = 2; |
718e3744 | 4571 | |
f4b8ec07 CS |
4572 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4573 | argv[idx_word]->arg, ""); | |
4574 | ||
4575 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
4576 | ||
4577 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4578 | } |
4579 | ||
f4b8ec07 CS |
4580 | DEFUN_YANG(no_neighbor_interface_peer_group_remote_as, |
4581 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4582 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4583 | NO_STR NEIGHBOR_STR | |
4584 | "Interface name or neighbor tag\n" | |
4585 | "Specify a BGP neighbor\n" AS_STR | |
4586 | "Internal BGP peer\n" | |
4587 | "External BGP peer\n") | |
718e3744 | 4588 | { |
f4b8ec07 CS |
4589 | int idx_peer = 2; |
4590 | char base_xpath[XPATH_MAXLEN]; | |
4591 | char unnbr_xpath[XPATH_MAXLEN]; | |
4592 | char prgrp_xpath[XPATH_MAXLEN]; | |
d62a17ae | 4593 | |
f4b8ec07 CS |
4594 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, |
4595 | argv[idx_peer]->arg, ""); | |
d62a17ae | 4596 | |
f4b8ec07 CS |
4597 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4598 | argv[idx_peer]->arg, ""); | |
4599 | ||
4600 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4601 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
4602 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); | |
4603 | } else if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4604 | VTY_CURR_XPATH, prgrp_xpath + 1)) { | |
4605 | strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath)); | |
4606 | } else { | |
d62a17ae | 4607 | vty_out(vty, "%% Create the peer-group or interface first\n"); |
4608 | return CMD_WARNING_CONFIG_FAILED; | |
4609 | } | |
f4b8ec07 CS |
4610 | |
4611 | strlcat(base_xpath, "/neighbor-remote-as/remote-as-type", | |
4612 | sizeof(base_xpath)); | |
4613 | ||
4614 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_DESTROY, NULL); | |
4615 | ||
4616 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 4617 | } |
6b0655a2 | 4618 | |
f4b8ec07 CS |
4619 | DEFUN_YANG(neighbor_local_as, |
4620 | neighbor_local_as_cmd, | |
4621 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4622 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4623 | "Specify a local-as number\n" | |
4624 | "AS number used as local AS\n") | |
718e3744 | 4625 | { |
d62a17ae | 4626 | int idx_peer = 1; |
4627 | int idx_number = 3; | |
f4b8ec07 | 4628 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4629 | |
f4b8ec07 CS |
4630 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4631 | sizeof(base_xpath), NULL) | |
4632 | < 0) | |
d62a17ae | 4633 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4634 | |
f4b8ec07 CS |
4635 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4636 | argv[idx_number]->arg); | |
4637 | ||
4638 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4639 | } |
4640 | ||
f4b8ec07 CS |
4641 | DEFUN_YANG( |
4642 | neighbor_local_as_no_prepend, neighbor_local_as_no_prepend_cmd, | |
4643 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4644 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4645 | "Specify a local-as number\n" | |
4646 | "AS number used as local AS\n" | |
4647 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4648 | { |
d62a17ae | 4649 | int idx_peer = 1; |
4650 | int idx_number = 3; | |
f4b8ec07 | 4651 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4652 | |
f4b8ec07 CS |
4653 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4654 | sizeof(base_xpath), NULL) | |
4655 | < 0) | |
d62a17ae | 4656 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4657 | |
f4b8ec07 CS |
4658 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4659 | argv[idx_number]->arg); | |
4660 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4661 | "true"); | |
4662 | ||
4663 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4664 | } |
4665 | ||
f4b8ec07 CS |
4666 | DEFUN_YANG( |
4667 | neighbor_local_as_no_prepend_replace_as, | |
4668 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4669 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4670 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4671 | "Specify a local-as number\n" | |
4672 | "AS number used as local AS\n" | |
4673 | "Do not prepend local-as to updates from ebgp peers\n" | |
4674 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4675 | { |
d62a17ae | 4676 | int idx_peer = 1; |
4677 | int idx_number = 3; | |
f4b8ec07 | 4678 | char base_xpath[XPATH_MAXLEN]; |
9d3f9705 | 4679 | |
f4b8ec07 CS |
4680 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4681 | sizeof(base_xpath), NULL) | |
4682 | < 0) | |
d62a17ae | 4683 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4684 | |
f4b8ec07 CS |
4685 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4686 | argv[idx_number]->arg); | |
4687 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4688 | "true"); | |
4689 | nb_cli_enqueue_change(vty, "./local-as/no-replace-as", NB_OP_MODIFY, | |
4690 | "true"); | |
4691 | ||
4692 | return nb_cli_apply_changes(vty, base_xpath); | |
9d3f9705 AC |
4693 | } |
4694 | ||
f4b8ec07 CS |
4695 | DEFUN_YANG(no_neighbor_local_as, |
4696 | no_neighbor_local_as_cmd, | |
4697 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4698 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4699 | "Specify a local-as number\n" | |
4700 | "AS number used as local AS\n" | |
4701 | "Do not prepend local-as to updates from ebgp peers\n" | |
4702 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4703 | { |
d62a17ae | 4704 | int idx_peer = 2; |
f4b8ec07 | 4705 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4706 | |
f4b8ec07 CS |
4707 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4708 | sizeof(base_xpath), NULL) | |
4709 | < 0) | |
d62a17ae | 4710 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4711 | |
f4b8ec07 CS |
4712 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_DESTROY, NULL); |
4713 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4714 | "false"); | |
4715 | nb_cli_enqueue_change(vty, "./local-as/no-replace-as", NB_OP_MODIFY, | |
4716 | "false"); | |
4717 | ||
4718 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4719 | } |
4720 | ||
718e3744 | 4721 | |
3f9c7369 DS |
4722 | DEFUN (neighbor_solo, |
4723 | neighbor_solo_cmd, | |
9ccf14f7 | 4724 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4725 | NEIGHBOR_STR |
4726 | NEIGHBOR_ADDR_STR2 | |
4727 | "Solo peer - part of its own update group\n") | |
4728 | { | |
d62a17ae | 4729 | int idx_peer = 1; |
4730 | struct peer *peer; | |
4731 | int ret; | |
3f9c7369 | 4732 | |
d62a17ae | 4733 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4734 | if (!peer) | |
4735 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4736 | |
d62a17ae | 4737 | ret = update_group_adjust_soloness(peer, 1); |
4738 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4739 | } |
4740 | ||
4741 | DEFUN (no_neighbor_solo, | |
4742 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4743 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4744 | NO_STR |
4745 | NEIGHBOR_STR | |
4746 | NEIGHBOR_ADDR_STR2 | |
4747 | "Solo peer - part of its own update group\n") | |
4748 | { | |
d62a17ae | 4749 | int idx_peer = 2; |
4750 | struct peer *peer; | |
4751 | int ret; | |
3f9c7369 | 4752 | |
d62a17ae | 4753 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4754 | if (!peer) | |
4755 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4756 | |
d62a17ae | 4757 | ret = update_group_adjust_soloness(peer, 0); |
4758 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4759 | } |
4760 | ||
f4b8ec07 CS |
4761 | DEFUN_YANG(neighbor_password, |
4762 | neighbor_password_cmd, | |
4763 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4764 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4765 | "Set a password\n" | |
4766 | "The password\n") | |
0df7c91f | 4767 | { |
d62a17ae | 4768 | int idx_peer = 1; |
4769 | int idx_line = 3; | |
f4b8ec07 | 4770 | char base_xpath[XPATH_MAXLEN]; |
0df7c91f | 4771 | |
f4b8ec07 CS |
4772 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4773 | sizeof(base_xpath), NULL) | |
4774 | < 0) | |
d62a17ae | 4775 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4776 | |
f4b8ec07 CS |
4777 | nb_cli_enqueue_change(vty, "./password", NB_OP_MODIFY, |
4778 | argv[idx_line]->arg); | |
4779 | ||
4780 | return nb_cli_apply_changes(vty, base_xpath); | |
0df7c91f PJ |
4781 | } |
4782 | ||
f4b8ec07 CS |
4783 | DEFUN_YANG(no_neighbor_password, |
4784 | no_neighbor_password_cmd, | |
4785 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
4786 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4787 | "Set a password\n" | |
4788 | "The password\n") | |
0df7c91f | 4789 | { |
d62a17ae | 4790 | int idx_peer = 2; |
f4b8ec07 | 4791 | char base_xpath[XPATH_MAXLEN]; |
0df7c91f | 4792 | |
f4b8ec07 CS |
4793 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4794 | sizeof(base_xpath), NULL) | |
4795 | < 0) | |
d62a17ae | 4796 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4797 | |
f4b8ec07 CS |
4798 | nb_cli_enqueue_change(vty, "./password", NB_OP_DESTROY, NULL); |
4799 | ||
4800 | return nb_cli_apply_changes(vty, base_xpath); | |
0df7c91f | 4801 | } |
6b0655a2 | 4802 | |
f4b8ec07 CS |
4803 | DEFUN_YANG(neighbor_activate, |
4804 | neighbor_activate_cmd, | |
4805 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4806 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4807 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4808 | { |
d62a17ae | 4809 | int idx_peer = 1; |
f4b8ec07 | 4810 | char base_xpath[XPATH_MAXLEN]; |
f4b8ec07 CS |
4811 | char af_xpath[XPATH_MAXLEN]; |
4812 | afi_t afi = bgp_node_afi(vty); | |
4813 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 4814 | |
f4b8ec07 CS |
4815 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
4816 | yang_afi_safi_value2identity(afi, safi)); | |
555c8ab7 CS |
4817 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4818 | sizeof(base_xpath), af_xpath) | |
f4b8ec07 | 4819 | < 0) |
d62a17ae | 4820 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4821 | |
555c8ab7 | 4822 | nb_cli_enqueue_change(vty, "./enabled", NB_OP_MODIFY, "true"); |
f4b8ec07 CS |
4823 | |
4824 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4825 | } |
4826 | ||
d62a17ae | 4827 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4828 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4829 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4830 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4831 | |
f4b8ec07 CS |
4832 | DEFUN_YANG(no_neighbor_activate, |
4833 | no_neighbor_activate_cmd, | |
4834 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4835 | NO_STR NEIGHBOR_STR | |
4836 | NEIGHBOR_ADDR_STR2 | |
4837 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4838 | { |
d62a17ae | 4839 | int idx_peer = 2; |
f4b8ec07 CS |
4840 | char base_xpath[XPATH_MAXLEN]; |
4841 | char af_xpath[XPATH_MAXLEN]; | |
4842 | afi_t afi = bgp_node_afi(vty); | |
4843 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 4844 | |
f4b8ec07 CS |
4845 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
4846 | yang_afi_safi_value2identity(afi, safi)); | |
4847 | ||
4848 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
4849 | sizeof(base_xpath), af_xpath) | |
4850 | < 0) | |
d62a17ae | 4851 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4852 | |
f4b8ec07 CS |
4853 | nb_cli_enqueue_change(vty, "./enabled", NB_OP_MODIFY, "false"); |
4854 | ||
4855 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4856 | } |
6b0655a2 | 4857 | |
d62a17ae | 4858 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4859 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4860 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4861 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4862 | |
f4b8ec07 CS |
4863 | DEFUN_YANG (neighbor_set_peer_group, |
4864 | neighbor_set_peer_group_cmd, | |
4865 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4866 | NEIGHBOR_STR | |
4867 | NEIGHBOR_ADDR_STR2 | |
4868 | "Member of the peer-group\n" | |
4869 | "Peer-group name\n") | |
718e3744 | 4870 | { |
d62a17ae | 4871 | int idx_peer = 1; |
4872 | int idx_word = 3; | |
f4b8ec07 | 4873 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4874 | |
f4b8ec07 CS |
4875 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4876 | sizeof(base_xpath), NULL) | |
4877 | < 0) | |
d62a17ae | 4878 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 4879 | |
f4b8ec07 CS |
4880 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4881 | argv[idx_word]->arg); | |
d62a17ae | 4882 | |
f4b8ec07 | 4883 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 4884 | } |
4885 | ||
4886 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4887 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4888 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4889 | "Member of the peer-group\n" | |
4890 | "Peer-group name\n") | |
596c17ba | 4891 | |
f4b8ec07 CS |
4892 | DEFUN_YANG (no_neighbor_set_peer_group, |
4893 | no_neighbor_set_peer_group_cmd, | |
4894 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4895 | NO_STR | |
4896 | NEIGHBOR_STR | |
4897 | NEIGHBOR_ADDR_STR2 | |
4898 | "Member of the peer-group\n" | |
4899 | "Peer-group name\n") | |
718e3744 | 4900 | { |
d62a17ae | 4901 | int idx_peer = 2; |
f4b8ec07 | 4902 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4903 | |
f4b8ec07 CS |
4904 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4905 | sizeof(base_xpath), NULL) | |
4906 | < 0) | |
d62a17ae | 4907 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 4908 | |
f4b8ec07 | 4909 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_DESTROY, NULL); |
718e3744 | 4910 | |
f4b8ec07 | 4911 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 4912 | } |
6b0655a2 | 4913 | |
d62a17ae | 4914 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4915 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4916 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4917 | "Member of the peer-group\n" | |
4918 | "Peer-group name\n") | |
596c17ba | 4919 | |
d62a17ae | 4920 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4921 | uint32_t flag, int set) |
718e3744 | 4922 | { |
d62a17ae | 4923 | int ret; |
4924 | struct peer *peer; | |
718e3744 | 4925 | |
d62a17ae | 4926 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4927 | if (!peer) | |
4928 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4929 | |
7ebe625c QY |
4930 | /* |
4931 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4932 | * we should not accept disable-connected-check. | |
4933 | */ | |
4934 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4935 | vty_out(vty, | |
3efd0893 | 4936 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
4937 | ip_str); |
4938 | return CMD_WARNING_CONFIG_FAILED; | |
4939 | } | |
4940 | ||
d62a17ae | 4941 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4942 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4943 | |
d62a17ae | 4944 | if (set) |
4945 | ret = peer_flag_set(peer, flag); | |
4946 | else | |
4947 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4948 | |
d62a17ae | 4949 | return bgp_vty_return(vty, ret); |
718e3744 | 4950 | } |
4951 | ||
47cbc09b | 4952 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4953 | { |
d62a17ae | 4954 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4955 | } |
4956 | ||
d62a17ae | 4957 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4958 | uint32_t flag) |
718e3744 | 4959 | { |
d62a17ae | 4960 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4961 | } |
4962 | ||
f4b8ec07 CS |
4963 | int peer_flag_modify_nb(struct bgp *bgp, const char *ip_str, struct peer *peer, |
4964 | uint32_t flag, bool set, char *errmsg, | |
4965 | size_t errmsg_len) | |
4966 | { | |
4967 | int ret; | |
4968 | ||
4969 | /* | |
4970 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4971 | * we should not accept disable-connected-check. | |
4972 | */ | |
4973 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4974 | snprintf( | |
4975 | errmsg, errmsg_len, | |
4976 | "%s is directly connected peer, cannot accept disable-connected-check\n", | |
4977 | ip_str); | |
4978 | return -1; | |
4979 | } | |
4980 | ||
4981 | if (!set && flag == PEER_FLAG_SHUTDOWN) | |
4982 | peer_tx_shutdown_message_unset(peer); | |
4983 | ||
4984 | if (set) | |
4985 | ret = peer_flag_set(peer, flag); | |
4986 | else | |
4987 | ret = peer_flag_unset(peer, flag); | |
4988 | ||
4989 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); | |
4990 | } | |
4991 | ||
718e3744 | 4992 | /* neighbor passive. */ |
f4b8ec07 CS |
4993 | DEFUN_YANG(neighbor_passive, |
4994 | neighbor_passive_cmd, | |
4995 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
4996 | NEIGHBOR_STR | |
4997 | NEIGHBOR_ADDR_STR2 | |
4998 | "Don't send open messages to this neighbor\n") | |
718e3744 | 4999 | { |
d62a17ae | 5000 | int idx_peer = 1; |
f4b8ec07 CS |
5001 | char base_xpath[XPATH_MAXLEN]; |
5002 | ||
5003 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5004 | sizeof(base_xpath), NULL) | |
5005 | < 0) | |
5006 | return CMD_WARNING_CONFIG_FAILED; | |
5007 | ||
5008 | nb_cli_enqueue_change(vty, "./passive-mode", NB_OP_MODIFY, "true"); | |
5009 | ||
5010 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5011 | } |
5012 | ||
f4b8ec07 CS |
5013 | DEFUN_YANG(no_neighbor_passive, |
5014 | no_neighbor_passive_cmd, | |
5015 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5016 | NO_STR NEIGHBOR_STR | |
5017 | NEIGHBOR_ADDR_STR2 | |
5018 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5019 | { |
d62a17ae | 5020 | int idx_peer = 2; |
f4b8ec07 CS |
5021 | char base_xpath[XPATH_MAXLEN]; |
5022 | ||
5023 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5024 | sizeof(base_xpath), NULL) | |
5025 | < 0) | |
5026 | return CMD_WARNING_CONFIG_FAILED; | |
5027 | ||
5028 | nb_cli_enqueue_change(vty, "./passive-mode", NB_OP_MODIFY, "false"); | |
5029 | ||
5030 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5031 | } |
6b0655a2 | 5032 | |
718e3744 | 5033 | /* neighbor shutdown. */ |
f4b8ec07 CS |
5034 | DEFUN_YANG(neighbor_shutdown_msg, |
5035 | neighbor_shutdown_msg_cmd, | |
5036 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5037 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5038 | "Administratively shut down this neighbor\n" | |
5039 | "Add a shutdown message (RFC 8203)\n" | |
5040 | "Shutdown message\n") | |
718e3744 | 5041 | { |
d62a17ae | 5042 | int idx_peer = 1; |
f4b8ec07 CS |
5043 | char base_xpath[XPATH_MAXLEN]; |
5044 | ||
5045 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5046 | sizeof(base_xpath), NULL) | |
5047 | < 0) | |
5048 | return CMD_WARNING_CONFIG_FAILED; | |
73d70fa6 | 5049 | |
d62a17ae | 5050 | if (argc >= 5) { |
d62a17ae | 5051 | char *message; |
73d70fa6 | 5052 | |
d62a17ae | 5053 | message = argv_concat(argv, argc, 4); |
f4b8ec07 CS |
5054 | nb_cli_enqueue_change(vty, "./admin-shutdown/message", |
5055 | NB_OP_MODIFY, message); | |
d62a17ae | 5056 | } |
73d70fa6 | 5057 | |
f4b8ec07 CS |
5058 | nb_cli_enqueue_change(vty, "./admin-shutdown/enable", NB_OP_MODIFY, |
5059 | "true"); | |
5060 | ||
5061 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5062 | } |
5063 | ||
232c75cd | 5064 | ALIAS_YANG(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5065 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5066 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5067 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5068 | |
f4b8ec07 CS |
5069 | DEFUN_YANG(no_neighbor_shutdown_msg, |
5070 | no_neighbor_shutdown_msg_cmd, | |
5071 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5072 | NO_STR NEIGHBOR_STR | |
5073 | NEIGHBOR_ADDR_STR2 | |
5074 | "Administratively shut down this neighbor\n" | |
5075 | "Remove a shutdown message (RFC 8203)\n" | |
5076 | "Shutdown message\n") | |
718e3744 | 5077 | { |
d62a17ae | 5078 | int idx_peer = 2; |
f4b8ec07 | 5079 | char base_xpath[XPATH_MAXLEN]; |
73d70fa6 | 5080 | |
f4b8ec07 CS |
5081 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
5082 | sizeof(base_xpath), NULL) | |
5083 | < 0) | |
5084 | return CMD_WARNING_CONFIG_FAILED; | |
5085 | ||
5086 | nb_cli_enqueue_change(vty, "./admin-shutdown/enable", NB_OP_MODIFY, | |
5087 | "false"); | |
5088 | ||
5089 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5090 | } |
6b0655a2 | 5091 | |
232c75cd | 5092 | ALIAS_YANG(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5093 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5094 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5095 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5096 | |
8336c896 DA |
5097 | DEFUN(neighbor_shutdown_rtt, |
5098 | neighbor_shutdown_rtt_cmd, | |
5099 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5100 | NEIGHBOR_STR | |
5101 | NEIGHBOR_ADDR_STR2 | |
5102 | "Administratively shut down this neighbor\n" | |
5103 | "Shutdown if round-trip-time is higher than expected\n" | |
5104 | "Round-trip-time in milliseconds\n" | |
5105 | "Specify the number of keepalives before shutdown\n" | |
5106 | "The number of keepalives with higher RTT to shutdown\n") | |
5107 | { | |
5108 | int idx_peer = 1; | |
5109 | int idx_rtt = 4; | |
5110 | int idx_count = 0; | |
5111 | struct peer *peer; | |
5112 | ||
5113 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5114 | ||
5115 | if (!peer) | |
5116 | return CMD_WARNING_CONFIG_FAILED; | |
5117 | ||
5118 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5119 | ||
5120 | if (argv_find(argv, argc, "count", &idx_count)) | |
5121 | peer->rtt_keepalive_conf = | |
5122 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5123 | ||
5124 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5125 | PEER_FLAG_RTT_SHUTDOWN); | |
5126 | } | |
5127 | ||
5128 | DEFUN(no_neighbor_shutdown_rtt, | |
5129 | no_neighbor_shutdown_rtt_cmd, | |
5130 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5131 | NO_STR | |
5132 | NEIGHBOR_STR | |
5133 | NEIGHBOR_ADDR_STR2 | |
5134 | "Administratively shut down this neighbor\n" | |
5135 | "Shutdown if round-trip-time is higher than expected\n" | |
5136 | "Round-trip-time in milliseconds\n" | |
5137 | "Specify the number of keepalives before shutdown\n" | |
5138 | "The number of keepalives with higher RTT to shutdown\n") | |
5139 | { | |
5140 | int idx_peer = 2; | |
5141 | struct peer *peer; | |
5142 | ||
5143 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5144 | ||
5145 | if (!peer) | |
5146 | return CMD_WARNING_CONFIG_FAILED; | |
5147 | ||
5148 | peer->rtt_expected = 0; | |
5149 | peer->rtt_keepalive_conf = 1; | |
5150 | ||
5151 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5152 | PEER_FLAG_RTT_SHUTDOWN); | |
5153 | } | |
5154 | ||
718e3744 | 5155 | /* neighbor capability dynamic. */ |
f4b8ec07 CS |
5156 | DEFUN_YANG (neighbor_capability_dynamic, |
5157 | neighbor_capability_dynamic_cmd, | |
5158 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5159 | NEIGHBOR_STR | |
5160 | NEIGHBOR_ADDR_STR2 | |
5161 | "Advertise capability to the peer\n" | |
5162 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5163 | { |
d62a17ae | 5164 | int idx_peer = 1; |
f4b8ec07 CS |
5165 | char base_xpath[XPATH_MAXLEN]; |
5166 | ||
5167 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5168 | sizeof(base_xpath), NULL) | |
5169 | < 0) | |
5170 | return CMD_WARNING_CONFIG_FAILED; | |
5171 | ||
5172 | nb_cli_enqueue_change(vty, "./capability-options/dynamic-capability", | |
5173 | NB_OP_MODIFY, "true"); | |
5174 | ||
5175 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5176 | } |
5177 | ||
f4b8ec07 CS |
5178 | DEFUN_YANG (no_neighbor_capability_dynamic, |
5179 | no_neighbor_capability_dynamic_cmd, | |
5180 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5181 | NO_STR | |
5182 | NEIGHBOR_STR | |
5183 | NEIGHBOR_ADDR_STR2 | |
5184 | "Advertise capability to the peer\n" | |
5185 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5186 | { |
d62a17ae | 5187 | int idx_peer = 2; |
f4b8ec07 CS |
5188 | char base_xpath[XPATH_MAXLEN]; |
5189 | ||
5190 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5191 | sizeof(base_xpath), NULL) | |
5192 | < 0) | |
5193 | return CMD_WARNING_CONFIG_FAILED; | |
5194 | ||
5195 | nb_cli_enqueue_change(vty, "./capability-options/dynamic-capability", | |
5196 | NB_OP_MODIFY, "false"); | |
5197 | ||
5198 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5199 | } |
6b0655a2 | 5200 | |
718e3744 | 5201 | /* neighbor dont-capability-negotiate */ |
5202 | DEFUN (neighbor_dont_capability_negotiate, | |
5203 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5204 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5205 | NEIGHBOR_STR |
5206 | NEIGHBOR_ADDR_STR2 | |
5207 | "Do not perform capability negotiation\n") | |
5208 | { | |
d62a17ae | 5209 | int idx_peer = 1; |
5210 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5211 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5212 | } |
5213 | ||
5214 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5215 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5216 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5217 | NO_STR |
5218 | NEIGHBOR_STR | |
5219 | NEIGHBOR_ADDR_STR2 | |
5220 | "Do not perform capability negotiation\n") | |
5221 | { | |
d62a17ae | 5222 | int idx_peer = 2; |
5223 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5224 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5225 | } |
6b0655a2 | 5226 | |
8a92a8a0 | 5227 | /* neighbor capability extended next hop encoding */ |
f4b8ec07 CS |
5228 | DEFUN_YANG (neighbor_capability_enhe, |
5229 | neighbor_capability_enhe_cmd, | |
5230 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5231 | NEIGHBOR_STR | |
5232 | NEIGHBOR_ADDR_STR2 | |
5233 | "Advertise capability to the peer\n" | |
5234 | "Advertise extended next-hop capability to the peer\n") | |
8a92a8a0 | 5235 | { |
d62a17ae | 5236 | int idx_peer = 1; |
f4b8ec07 CS |
5237 | char base_xpath[XPATH_MAXLEN]; |
5238 | ||
5239 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5240 | sizeof(base_xpath), NULL) | |
5241 | < 0) | |
5242 | return CMD_WARNING_CONFIG_FAILED; | |
5243 | ||
5244 | nb_cli_enqueue_change( | |
5245 | vty, "./capability-options/extended-nexthop-capability", | |
5246 | NB_OP_MODIFY, "true"); | |
5247 | ||
5248 | return nb_cli_apply_changes(vty, base_xpath); | |
8a92a8a0 DS |
5249 | } |
5250 | ||
f4b8ec07 CS |
5251 | DEFUN_YANG (no_neighbor_capability_enhe, |
5252 | no_neighbor_capability_enhe_cmd, | |
5253 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5254 | NO_STR | |
5255 | NEIGHBOR_STR | |
5256 | NEIGHBOR_ADDR_STR2 | |
5257 | "Advertise capability to the peer\n" | |
5258 | "Advertise extended next-hop capability to the peer\n") | |
8a92a8a0 | 5259 | { |
d62a17ae | 5260 | int idx_peer = 2; |
f4b8ec07 CS |
5261 | char base_xpath[XPATH_MAXLEN]; |
5262 | ||
5263 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5264 | sizeof(base_xpath), NULL) | |
5265 | < 0) | |
5266 | return CMD_WARNING_CONFIG_FAILED; | |
5267 | ||
5268 | nb_cli_enqueue_change( | |
5269 | vty, "./capability-options/extended-nexthop-capability", | |
5270 | NB_OP_MODIFY, "false"); | |
5271 | ||
5272 | return nb_cli_apply_changes(vty, base_xpath); | |
5273 | } | |
5274 | ||
5275 | int peer_af_flag_modify_nb(struct peer *peer, afi_t afi, safi_t safi, | |
5276 | uint32_t flag, int set, char *errmsg, | |
5277 | size_t errmsg_len) | |
5278 | { | |
5279 | int ret; | |
5280 | ||
5281 | if (set) | |
5282 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5283 | else | |
5284 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
5285 | ||
5286 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); | |
8a92a8a0 DS |
5287 | } |
5288 | ||
d62a17ae | 5289 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5290 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5291 | int set) |
718e3744 | 5292 | { |
d62a17ae | 5293 | int ret; |
5294 | struct peer *peer; | |
718e3744 | 5295 | |
d62a17ae | 5296 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5297 | if (!peer) | |
5298 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5299 | |
d62a17ae | 5300 | if (set) |
5301 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5302 | else | |
5303 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5304 | |
d62a17ae | 5305 | return bgp_vty_return(vty, ret); |
718e3744 | 5306 | } |
5307 | ||
d62a17ae | 5308 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5309 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5310 | { |
d62a17ae | 5311 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5312 | } |
5313 | ||
d62a17ae | 5314 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5315 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5316 | { |
d62a17ae | 5317 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5318 | } |
6b0655a2 | 5319 | |
718e3744 | 5320 | /* neighbor capability orf prefix-list. */ |
5321 | DEFUN (neighbor_capability_orf_prefix, | |
5322 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5323 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5324 | NEIGHBOR_STR |
5325 | NEIGHBOR_ADDR_STR2 | |
5326 | "Advertise capability to the peer\n" | |
5327 | "Advertise ORF capability to the peer\n" | |
5328 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5329 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5330 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5331 | "Capability to SEND the ORF to this neighbor\n") | |
5332 | { | |
d62a17ae | 5333 | int idx_send_recv = 5; |
db45f64d DS |
5334 | char *peer_str = argv[1]->arg; |
5335 | struct peer *peer; | |
5336 | afi_t afi = bgp_node_afi(vty); | |
5337 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5338 | |
db45f64d DS |
5339 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5340 | if (!peer) | |
d62a17ae | 5341 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5342 | |
db45f64d DS |
5343 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5344 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5345 | PEER_FLAG_ORF_PREFIX_SM); | |
5346 | ||
5347 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5348 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5349 | PEER_FLAG_ORF_PREFIX_RM); | |
5350 | ||
5351 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5352 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5353 | PEER_FLAG_ORF_PREFIX_SM) | |
5354 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5355 | PEER_FLAG_ORF_PREFIX_RM); | |
5356 | ||
5357 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5358 | } |
5359 | ||
5360 | ALIAS_HIDDEN( | |
5361 | neighbor_capability_orf_prefix, | |
5362 | neighbor_capability_orf_prefix_hidden_cmd, | |
5363 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5364 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5365 | "Advertise capability to the peer\n" | |
5366 | "Advertise ORF capability to the peer\n" | |
5367 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5368 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5369 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5370 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5371 | |
718e3744 | 5372 | DEFUN (no_neighbor_capability_orf_prefix, |
5373 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5374 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5375 | NO_STR |
5376 | NEIGHBOR_STR | |
5377 | NEIGHBOR_ADDR_STR2 | |
5378 | "Advertise capability to the peer\n" | |
5379 | "Advertise ORF capability to the peer\n" | |
5380 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5381 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5382 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5383 | "Capability to SEND the ORF to this neighbor\n") | |
5384 | { | |
d62a17ae | 5385 | int idx_send_recv = 6; |
db45f64d DS |
5386 | char *peer_str = argv[2]->arg; |
5387 | struct peer *peer; | |
5388 | afi_t afi = bgp_node_afi(vty); | |
5389 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5390 | |
db45f64d DS |
5391 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5392 | if (!peer) | |
d62a17ae | 5393 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5394 | |
db45f64d DS |
5395 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5396 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5397 | PEER_FLAG_ORF_PREFIX_SM); | |
5398 | ||
5399 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5400 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5401 | PEER_FLAG_ORF_PREFIX_RM); | |
5402 | ||
5403 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5404 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5405 | PEER_FLAG_ORF_PREFIX_SM) | |
5406 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5407 | PEER_FLAG_ORF_PREFIX_RM); | |
5408 | ||
5409 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5410 | } |
5411 | ||
5412 | ALIAS_HIDDEN( | |
5413 | no_neighbor_capability_orf_prefix, | |
5414 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5415 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5416 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5417 | "Advertise capability to the peer\n" | |
5418 | "Advertise ORF capability to the peer\n" | |
5419 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5420 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5421 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5422 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5423 | |
718e3744 | 5424 | /* neighbor next-hop-self. */ |
f4b8ec07 CS |
5425 | DEFUN_YANG (neighbor_nexthop_self, |
5426 | neighbor_nexthop_self_cmd, | |
5427 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5428 | NEIGHBOR_STR | |
5429 | NEIGHBOR_ADDR_STR2 | |
5430 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5431 | { |
d62a17ae | 5432 | int idx_peer = 1; |
f4b8ec07 CS |
5433 | char base_xpath[XPATH_MAXLEN]; |
5434 | char af_xpath[XPATH_MAXLEN]; | |
5435 | char attr_xpath[XPATH_MAXLEN]; | |
5436 | afi_t afi = bgp_node_afi(vty); | |
5437 | safi_t safi = bgp_node_safi(vty); | |
5438 | ||
5439 | ||
5440 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5441 | yang_afi_safi_value2identity(afi, safi)); | |
5442 | ||
5443 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5444 | sizeof(base_xpath), af_xpath) | |
5445 | < 0) | |
5446 | return CMD_WARNING_CONFIG_FAILED; | |
5447 | ||
5448 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5449 | "./%s/nexthop-self/next-hop-self", | |
5450 | bgp_afi_safi_get_container_str(afi, safi)); | |
5451 | ||
5452 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5453 | ||
5454 | return nb_cli_apply_changes(vty, base_xpath); | |
a538debe | 5455 | } |
9e7a53c1 | 5456 | |
d62a17ae | 5457 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5458 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5459 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5460 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5461 | |
f4b8ec07 CS |
5462 | /* neighbor next-hop-self. */ |
5463 | DEFUN_YANG(neighbor_nexthop_self_force, | |
5464 | neighbor_nexthop_self_force_cmd, | |
5465 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5466 | NEIGHBOR_STR | |
5467 | NEIGHBOR_ADDR_STR2 | |
5468 | "Disable the next hop calculation for this neighbor\n" | |
5469 | "Set the next hop to self for reflected routes\n") | |
5470 | { | |
5471 | int idx_peer = 1; | |
5472 | char base_xpath[XPATH_MAXLEN]; | |
5473 | char af_xpath[XPATH_MAXLEN]; | |
5474 | char attr_xpath[XPATH_MAXLEN]; | |
5475 | afi_t afi = bgp_node_afi(vty); | |
5476 | safi_t safi = bgp_node_safi(vty); | |
5477 | ||
5478 | ||
5479 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5480 | yang_afi_safi_value2identity(afi, safi)); | |
5481 | ||
5482 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5483 | sizeof(base_xpath), af_xpath) | |
5484 | < 0) | |
5485 | return CMD_WARNING_CONFIG_FAILED; | |
5486 | ||
5487 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5488 | "./%s/nexthop-self/next-hop-self-force", | |
5489 | bgp_afi_safi_get_container_str(afi, safi)); | |
5490 | ||
5491 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5492 | ||
5493 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5494 | } |
5495 | ||
d62a17ae | 5496 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5497 | neighbor_nexthop_self_force_hidden_cmd, | |
5498 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5499 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5500 | "Disable the next hop calculation for this neighbor\n" | |
5501 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5502 | |
1bc4e531 DA |
5503 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5504 | neighbor_nexthop_self_all_hidden_cmd, | |
5505 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5506 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5507 | "Disable the next hop calculation for this neighbor\n" | |
5508 | "Set the next hop to self for reflected routes\n") | |
5509 | ||
f4b8ec07 CS |
5510 | DEFUN_YANG (no_neighbor_nexthop_self, |
5511 | no_neighbor_nexthop_self_cmd, | |
5512 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5513 | NO_STR | |
5514 | NEIGHBOR_STR | |
5515 | NEIGHBOR_ADDR_STR2 | |
5516 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5517 | { |
d62a17ae | 5518 | int idx_peer = 2; |
f4b8ec07 CS |
5519 | char base_xpath[XPATH_MAXLEN]; |
5520 | char af_xpath[XPATH_MAXLEN]; | |
5521 | char attr_xpath[XPATH_MAXLEN]; | |
5522 | afi_t afi = bgp_node_afi(vty); | |
5523 | safi_t safi = bgp_node_safi(vty); | |
5524 | ||
5525 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5526 | yang_afi_safi_value2identity(afi, safi)); | |
5527 | ||
5528 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5529 | sizeof(base_xpath), af_xpath) | |
5530 | < 0) | |
5531 | return CMD_WARNING_CONFIG_FAILED; | |
5532 | ||
5533 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5534 | "./%s/nexthop-self/next-hop-self", | |
5535 | bgp_afi_safi_get_container_str(afi, safi)); | |
5536 | ||
5537 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5538 | ||
5539 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5540 | } |
6b0655a2 | 5541 | |
d62a17ae | 5542 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5543 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5544 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5545 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5546 | |
f4b8ec07 CS |
5547 | DEFUN_YANG (no_neighbor_nexthop_self_force, |
5548 | no_neighbor_nexthop_self_force_cmd, | |
5549 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5550 | NO_STR | |
5551 | NEIGHBOR_STR | |
5552 | NEIGHBOR_ADDR_STR2 | |
5553 | "Disable the next hop calculation for this neighbor\n" | |
5554 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5555 | { |
d62a17ae | 5556 | int idx_peer = 2; |
f4b8ec07 CS |
5557 | char base_xpath[XPATH_MAXLEN]; |
5558 | char af_xpath[XPATH_MAXLEN]; | |
5559 | char attr_xpath[XPATH_MAXLEN]; | |
5560 | afi_t afi = bgp_node_afi(vty); | |
5561 | safi_t safi = bgp_node_safi(vty); | |
5562 | ||
5563 | ||
5564 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5565 | yang_afi_safi_value2identity(afi, safi)); | |
5566 | ||
5567 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5568 | sizeof(base_xpath), af_xpath) | |
5569 | < 0) | |
5570 | return CMD_WARNING_CONFIG_FAILED; | |
5571 | ||
5572 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5573 | "./%s/nexthop-self/next-hop-self-force", | |
5574 | bgp_afi_safi_get_container_str(afi, safi)); | |
5575 | ||
5576 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5577 | ||
5578 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5579 | } |
a538debe | 5580 | |
d62a17ae | 5581 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5582 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5583 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5584 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5585 | "Disable the next hop calculation for this neighbor\n" | |
5586 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5587 | |
1bc4e531 DA |
5588 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5589 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5590 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5591 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5592 | "Disable the next hop calculation for this neighbor\n" | |
5593 | "Set the next hop to self for reflected routes\n") | |
5594 | ||
c7122e14 | 5595 | /* neighbor as-override */ |
f4b8ec07 CS |
5596 | DEFUN_YANG (neighbor_as_override, |
5597 | neighbor_as_override_cmd, | |
5598 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5599 | NEIGHBOR_STR | |
5600 | NEIGHBOR_ADDR_STR2 | |
5601 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5602 | { |
d62a17ae | 5603 | int idx_peer = 1; |
f4b8ec07 CS |
5604 | char base_xpath[XPATH_MAXLEN]; |
5605 | char af_xpath[XPATH_MAXLEN]; | |
5606 | char attr_xpath[XPATH_MAXLEN]; | |
5607 | afi_t afi = bgp_node_afi(vty); | |
5608 | safi_t safi = bgp_node_safi(vty); | |
5609 | ||
5610 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5611 | yang_afi_safi_value2identity(afi, safi)); | |
5612 | ||
5613 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5614 | sizeof(base_xpath), af_xpath) | |
5615 | < 0) | |
5616 | return CMD_WARNING_CONFIG_FAILED; | |
5617 | ||
5618 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5619 | "./%s/as-path-options/replace-peer-as", | |
5620 | bgp_afi_safi_get_container_str(afi, safi)); | |
5621 | ||
5622 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5623 | ||
5624 | return nb_cli_apply_changes(vty, base_xpath); | |
c7122e14 DS |
5625 | } |
5626 | ||
d62a17ae | 5627 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5628 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5629 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5630 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5631 | |
f4b8ec07 CS |
5632 | DEFUN_YANG (no_neighbor_as_override, |
5633 | no_neighbor_as_override_cmd, | |
5634 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5635 | NO_STR | |
5636 | NEIGHBOR_STR | |
5637 | NEIGHBOR_ADDR_STR2 | |
5638 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5639 | { |
d62a17ae | 5640 | int idx_peer = 2; |
f4b8ec07 CS |
5641 | char base_xpath[XPATH_MAXLEN]; |
5642 | char af_xpath[XPATH_MAXLEN]; | |
5643 | char attr_xpath[XPATH_MAXLEN]; | |
5644 | afi_t afi = bgp_node_afi(vty); | |
5645 | safi_t safi = bgp_node_safi(vty); | |
5646 | ||
5647 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5648 | yang_afi_safi_value2identity(afi, safi)); | |
5649 | ||
5650 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5651 | sizeof(base_xpath), af_xpath) | |
5652 | < 0) | |
5653 | return CMD_WARNING_CONFIG_FAILED; | |
5654 | ||
5655 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5656 | "./%s/as-path-options/replace-peer-as", | |
5657 | bgp_afi_safi_get_container_str(afi, safi)); | |
5658 | ||
5659 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5660 | ||
5661 | return nb_cli_apply_changes(vty, base_xpath); | |
c7122e14 DS |
5662 | } |
5663 | ||
d62a17ae | 5664 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5665 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5666 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5667 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5668 | |
718e3744 | 5669 | /* neighbor remove-private-AS. */ |
f4b8ec07 CS |
5670 | DEFUN_YANG (neighbor_remove_private_as, |
5671 | neighbor_remove_private_as_cmd, | |
5672 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5673 | NEIGHBOR_STR | |
5674 | NEIGHBOR_ADDR_STR2 | |
5675 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5676 | { |
d62a17ae | 5677 | int idx_peer = 1; |
f4b8ec07 CS |
5678 | char base_xpath[XPATH_MAXLEN]; |
5679 | char af_xpath[XPATH_MAXLEN]; | |
5680 | char attr_xpath[XPATH_MAXLEN]; | |
5681 | afi_t afi = bgp_node_afi(vty); | |
5682 | safi_t safi = bgp_node_safi(vty); | |
5683 | ||
5684 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5685 | yang_afi_safi_value2identity(afi, safi)); | |
5686 | ||
5687 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5688 | sizeof(base_xpath), af_xpath) | |
5689 | < 0) | |
5690 | return CMD_WARNING_CONFIG_FAILED; | |
5691 | ||
5692 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5693 | "./%s/private-as/remove-private-as", | |
5694 | bgp_afi_safi_get_container_str(afi, safi)); | |
5695 | ||
5696 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5697 | ||
5698 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5699 | } |
5700 | ||
d62a17ae | 5701 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5702 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5703 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5704 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5705 | |
f4b8ec07 CS |
5706 | DEFUN_YANG (neighbor_remove_private_as_all, |
5707 | neighbor_remove_private_as_all_cmd, | |
5708 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5709 | NEIGHBOR_STR | |
5710 | NEIGHBOR_ADDR_STR2 | |
5711 | "Remove private ASNs in outbound updates\n" | |
5712 | "Apply to all AS numbers\n") | |
5000f21c | 5713 | { |
d62a17ae | 5714 | int idx_peer = 1; |
f4b8ec07 CS |
5715 | char base_xpath[XPATH_MAXLEN]; |
5716 | char af_xpath[XPATH_MAXLEN]; | |
5717 | char attr_xpath[XPATH_MAXLEN]; | |
5718 | afi_t afi = bgp_node_afi(vty); | |
5719 | safi_t safi = bgp_node_safi(vty); | |
5720 | ||
5721 | ||
5722 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5723 | yang_afi_safi_value2identity(afi, safi)); | |
5724 | ||
5725 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5726 | sizeof(base_xpath), af_xpath) | |
5727 | < 0) | |
5728 | return CMD_WARNING_CONFIG_FAILED; | |
5729 | ||
5730 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5731 | "./%s/private-as/remove-private-as-all", | |
5732 | bgp_afi_safi_get_container_str(afi, safi)); | |
5733 | ||
5734 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5735 | ||
5736 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
5737 | } |
5738 | ||
d62a17ae | 5739 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5740 | neighbor_remove_private_as_all_hidden_cmd, | |
5741 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5742 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5743 | "Remove private ASNs in outbound updates\n" | |
5744 | "Apply to all AS numbers") | |
596c17ba | 5745 | |
f4b8ec07 CS |
5746 | DEFUN_YANG (neighbor_remove_private_as_replace_as, |
5747 | neighbor_remove_private_as_replace_as_cmd, | |
5748 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5749 | NEIGHBOR_STR | |
5750 | NEIGHBOR_ADDR_STR2 | |
5751 | "Remove private ASNs in outbound updates\n" | |
5752 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5753 | { |
d62a17ae | 5754 | int idx_peer = 1; |
f4b8ec07 CS |
5755 | char base_xpath[XPATH_MAXLEN]; |
5756 | char af_xpath[XPATH_MAXLEN]; | |
5757 | char attr_xpath[XPATH_MAXLEN]; | |
5758 | afi_t afi = bgp_node_afi(vty); | |
5759 | safi_t safi = bgp_node_safi(vty); | |
5760 | ||
5761 | ||
5762 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5763 | yang_afi_safi_value2identity(afi, safi)); | |
5764 | ||
5765 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5766 | sizeof(base_xpath), af_xpath) | |
5767 | < 0) | |
5768 | return CMD_WARNING_CONFIG_FAILED; | |
5769 | ||
5770 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5771 | "./%s/private-as/remove-private-as-replace", | |
5772 | bgp_afi_safi_get_container_str(afi, safi)); | |
5773 | ||
5774 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5775 | ||
5776 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
5777 | } |
5778 | ||
d62a17ae | 5779 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5780 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5781 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5782 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5783 | "Remove private ASNs in outbound updates\n" | |
5784 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5785 | |
f4b8ec07 CS |
5786 | DEFUN_YANG (neighbor_remove_private_as_all_replace_as, |
5787 | neighbor_remove_private_as_all_replace_as_cmd, | |
5788 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5789 | NEIGHBOR_STR | |
5790 | NEIGHBOR_ADDR_STR2 | |
5791 | "Remove private ASNs in outbound updates\n" | |
5792 | "Apply to all AS numbers\n" | |
5793 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5794 | { |
d62a17ae | 5795 | int idx_peer = 1; |
f4b8ec07 CS |
5796 | char base_xpath[XPATH_MAXLEN]; |
5797 | char af_xpath[XPATH_MAXLEN]; | |
5798 | char attr_xpath[XPATH_MAXLEN]; | |
5799 | afi_t afi = bgp_node_afi(vty); | |
5800 | safi_t safi = bgp_node_safi(vty); | |
5801 | ||
5802 | ||
5803 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5804 | yang_afi_safi_value2identity(afi, safi)); | |
5805 | ||
5806 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5807 | sizeof(base_xpath), af_xpath) | |
5808 | < 0) | |
5809 | return CMD_WARNING_CONFIG_FAILED; | |
5810 | ||
5811 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5812 | "./%s/private-as/remove-private-as-all-replace", | |
5813 | bgp_afi_safi_get_container_str(afi, safi)); | |
5814 | ||
5815 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5816 | ||
5817 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
5818 | } |
5819 | ||
d62a17ae | 5820 | ALIAS_HIDDEN( |
5821 | neighbor_remove_private_as_all_replace_as, | |
5822 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5823 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5824 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5825 | "Remove private ASNs in outbound updates\n" | |
5826 | "Apply to all AS numbers\n" | |
5827 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5828 | |
f4b8ec07 CS |
5829 | DEFUN_YANG (no_neighbor_remove_private_as, |
5830 | no_neighbor_remove_private_as_cmd, | |
5831 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5832 | NO_STR | |
5833 | NEIGHBOR_STR | |
5834 | NEIGHBOR_ADDR_STR2 | |
5835 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5836 | { |
d62a17ae | 5837 | int idx_peer = 2; |
f4b8ec07 CS |
5838 | char base_xpath[XPATH_MAXLEN]; |
5839 | char af_xpath[XPATH_MAXLEN]; | |
5840 | char attr_xpath[XPATH_MAXLEN]; | |
5841 | afi_t afi = bgp_node_afi(vty); | |
5842 | safi_t safi = bgp_node_safi(vty); | |
5843 | ||
5844 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5845 | yang_afi_safi_value2identity(afi, safi)); | |
5846 | ||
5847 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5848 | sizeof(base_xpath), af_xpath) | |
5849 | < 0) | |
5850 | return CMD_WARNING_CONFIG_FAILED; | |
5851 | ||
5852 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5853 | "./%s/private-as/remove-private-as", | |
5854 | bgp_afi_safi_get_container_str(afi, safi)); | |
5855 | ||
5856 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5857 | ||
5858 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5859 | } |
6b0655a2 | 5860 | |
d62a17ae | 5861 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5862 | no_neighbor_remove_private_as_hidden_cmd, | |
5863 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5864 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5865 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5866 | |
f4b8ec07 CS |
5867 | DEFUN_YANG (no_neighbor_remove_private_as_all, |
5868 | no_neighbor_remove_private_as_all_cmd, | |
5869 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5870 | NO_STR | |
5871 | NEIGHBOR_STR | |
5872 | NEIGHBOR_ADDR_STR2 | |
5873 | "Remove private ASNs in outbound updates\n" | |
5874 | "Apply to all AS numbers\n") | |
88b8ed8d | 5875 | { |
d62a17ae | 5876 | int idx_peer = 2; |
f4b8ec07 CS |
5877 | char base_xpath[XPATH_MAXLEN]; |
5878 | char af_xpath[XPATH_MAXLEN]; | |
5879 | char attr_xpath[XPATH_MAXLEN]; | |
5880 | afi_t afi = bgp_node_afi(vty); | |
5881 | safi_t safi = bgp_node_safi(vty); | |
5882 | ||
5883 | ||
5884 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5885 | yang_afi_safi_value2identity(afi, safi)); | |
5886 | ||
5887 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5888 | sizeof(base_xpath), af_xpath) | |
5889 | < 0) | |
5890 | return CMD_WARNING_CONFIG_FAILED; | |
5891 | ||
5892 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5893 | "./%s/private-as/remove-private-as-all", | |
5894 | bgp_afi_safi_get_container_str(afi, safi)); | |
5895 | ||
5896 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5897 | ||
5898 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5899 | } |
5000f21c | 5900 | |
d62a17ae | 5901 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5902 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5903 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5904 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5905 | "Remove private ASNs in outbound updates\n" | |
5906 | "Apply to all AS numbers\n") | |
596c17ba | 5907 | |
f4b8ec07 CS |
5908 | DEFUN_YANG (no_neighbor_remove_private_as_replace_as, |
5909 | no_neighbor_remove_private_as_replace_as_cmd, | |
5910 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5911 | NO_STR | |
5912 | NEIGHBOR_STR | |
5913 | NEIGHBOR_ADDR_STR2 | |
5914 | "Remove private ASNs in outbound updates\n" | |
5915 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5916 | { |
d62a17ae | 5917 | int idx_peer = 2; |
f4b8ec07 CS |
5918 | char base_xpath[XPATH_MAXLEN]; |
5919 | char af_xpath[XPATH_MAXLEN]; | |
5920 | char attr_xpath[XPATH_MAXLEN]; | |
5921 | afi_t afi = bgp_node_afi(vty); | |
5922 | safi_t safi = bgp_node_safi(vty); | |
5923 | ||
5924 | ||
5925 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5926 | yang_afi_safi_value2identity(afi, safi)); | |
5927 | ||
5928 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5929 | sizeof(base_xpath), af_xpath) | |
5930 | < 0) | |
5931 | return CMD_WARNING_CONFIG_FAILED; | |
5932 | ||
5933 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5934 | "./%s/private-as/remove-private-as-replace", | |
5935 | bgp_afi_safi_get_container_str(afi, safi)); | |
5936 | ||
5937 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5938 | ||
5939 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5940 | } |
5000f21c | 5941 | |
d62a17ae | 5942 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5943 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5944 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5945 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5946 | "Remove private ASNs in outbound updates\n" | |
5947 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5948 | |
f4b8ec07 CS |
5949 | DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as, |
5950 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5951 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5952 | NO_STR | |
5953 | NEIGHBOR_STR | |
5954 | NEIGHBOR_ADDR_STR2 | |
5955 | "Remove private ASNs in outbound updates\n" | |
5956 | "Apply to all AS numbers\n" | |
5957 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5958 | { |
d62a17ae | 5959 | int idx_peer = 2; |
f4b8ec07 CS |
5960 | char base_xpath[XPATH_MAXLEN]; |
5961 | char af_xpath[XPATH_MAXLEN]; | |
5962 | char attr_xpath[XPATH_MAXLEN]; | |
5963 | afi_t afi = bgp_node_afi(vty); | |
5964 | safi_t safi = bgp_node_safi(vty); | |
5965 | ||
5966 | ||
5967 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5968 | yang_afi_safi_value2identity(afi, safi)); | |
5969 | ||
5970 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5971 | sizeof(base_xpath), af_xpath) | |
5972 | < 0) | |
5973 | return CMD_WARNING_CONFIG_FAILED; | |
5974 | ||
5975 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5976 | "./%s/private-as/remove-private-as-all-replace", | |
5977 | bgp_afi_safi_get_container_str(afi, safi)); | |
5978 | ||
5979 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5980 | ||
5981 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5982 | } |
5000f21c | 5983 | |
d62a17ae | 5984 | ALIAS_HIDDEN( |
5985 | no_neighbor_remove_private_as_all_replace_as, | |
5986 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5987 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5988 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5989 | "Remove private ASNs in outbound updates\n" | |
5990 | "Apply to all AS numbers\n" | |
5991 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5992 | |
5000f21c | 5993 | |
718e3744 | 5994 | /* neighbor send-community. */ |
f4b8ec07 CS |
5995 | DEFUN_YANG (neighbor_send_community, |
5996 | neighbor_send_community_cmd, | |
5997 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5998 | NEIGHBOR_STR | |
5999 | NEIGHBOR_ADDR_STR2 | |
6000 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6001 | { |
d62a17ae | 6002 | int idx_peer = 1; |
27c05d4d | 6003 | |
d62a17ae | 6004 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6005 | bgp_node_safi(vty), | |
6006 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6007 | } |
6008 | ||
d62a17ae | 6009 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
6010 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6011 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6012 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6013 | |
f4b8ec07 CS |
6014 | DEFUN_YANG (no_neighbor_send_community, |
6015 | no_neighbor_send_community_cmd, | |
6016 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6017 | NO_STR | |
6018 | NEIGHBOR_STR | |
6019 | NEIGHBOR_ADDR_STR2 | |
6020 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6021 | { |
d62a17ae | 6022 | int idx_peer = 2; |
27c05d4d | 6023 | |
d62a17ae | 6024 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6025 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6026 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6027 | } |
6b0655a2 | 6028 | |
d62a17ae | 6029 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
6030 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6031 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6032 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6033 | |
718e3744 | 6034 | /* neighbor send-community extended. */ |
f4b8ec07 CS |
6035 | DEFUN_YANG (neighbor_send_community_type, |
6036 | neighbor_send_community_type_cmd, | |
6037 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6038 | NEIGHBOR_STR | |
6039 | NEIGHBOR_ADDR_STR2 | |
6040 | "Send Community attribute to this neighbor\n" | |
6041 | "Send Standard and Extended Community attributes\n" | |
6042 | "Send Standard, Large and Extended Community attributes\n" | |
6043 | "Send Extended Community attributes\n" | |
6044 | "Send Standard Community attributes\n" | |
6045 | "Send Large Community attributes\n") | |
718e3744 | 6046 | { |
27c05d4d | 6047 | const char *type = argv[argc - 1]->text; |
db45f64d | 6048 | char *peer_str = argv[1]->arg; |
f4b8ec07 CS |
6049 | char base_xpath[XPATH_MAXLEN]; |
6050 | char af_xpath[XPATH_MAXLEN]; | |
6051 | char std_xpath[XPATH_MAXLEN]; | |
6052 | char ext_xpath[XPATH_MAXLEN]; | |
6053 | char lrg_xpath[XPATH_MAXLEN]; | |
db45f64d DS |
6054 | afi_t afi = bgp_node_afi(vty); |
6055 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 6056 | |
f4b8ec07 CS |
6057 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6058 | yang_afi_safi_value2identity(afi, safi)); | |
6059 | ||
6060 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6061 | sizeof(base_xpath), af_xpath) | |
6062 | < 0) | |
db45f64d | 6063 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6064 | |
f4b8ec07 CS |
6065 | if (strmatch(type, "standard")) { |
6066 | snprintf(std_xpath, sizeof(std_xpath), | |
6067 | "./%s/send-community/send-community", | |
6068 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6069 | |
f4b8ec07 CS |
6070 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); |
6071 | } | |
db45f64d | 6072 | |
f4b8ec07 CS |
6073 | if (strmatch(type, "extended")) { |
6074 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6075 | "./%s/send-community/send-ext-community", | |
6076 | bgp_afi_safi_get_container_str(afi, safi)); | |
6077 | ||
6078 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
6079 | } | |
6080 | ||
6081 | if (strmatch(type, "large")) { | |
6082 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6083 | "./%s/send-community/send-large-community", | |
6084 | bgp_afi_safi_get_container_str(afi, safi)); | |
6085 | ||
6086 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "true"); | |
6087 | } | |
db45f64d DS |
6088 | |
6089 | if (strmatch(type, "both")) { | |
f4b8ec07 CS |
6090 | snprintf(std_xpath, sizeof(std_xpath), |
6091 | "./%s/send-community/send-community", | |
6092 | bgp_afi_safi_get_container_str(afi, safi)); | |
6093 | ||
6094 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); | |
6095 | ||
6096 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6097 | "./%s/send-community/send-ext-community", | |
6098 | bgp_afi_safi_get_container_str(afi, safi)); | |
6099 | ||
6100 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
db45f64d | 6101 | } |
f4b8ec07 CS |
6102 | |
6103 | if (strmatch(type, "all")) { | |
6104 | snprintf(std_xpath, sizeof(std_xpath), | |
6105 | "./%s/send-community/send-community", | |
6106 | bgp_afi_safi_get_container_str(afi, safi)); | |
6107 | ||
6108 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); | |
6109 | ||
6110 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6111 | "./%s/send-community/send-ext-community", | |
6112 | bgp_afi_safi_get_container_str(afi, safi)); | |
6113 | ||
6114 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
6115 | ||
6116 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6117 | "./%s/send-community/send-large-community", | |
6118 | bgp_afi_safi_get_container_str(afi, safi)); | |
6119 | ||
6120 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "true"); | |
6121 | } | |
6122 | ||
6123 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 6124 | } |
6125 | ||
6126 | ALIAS_HIDDEN( | |
6127 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
6128 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6129 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6130 | "Send Community attribute to this neighbor\n" | |
6131 | "Send Standard and Extended Community attributes\n" | |
6132 | "Send Standard, Large and Extended Community attributes\n" | |
6133 | "Send Extended Community attributes\n" | |
6134 | "Send Standard Community attributes\n" | |
6135 | "Send Large Community attributes\n") | |
596c17ba | 6136 | |
f4b8ec07 CS |
6137 | DEFUN_YANG (no_neighbor_send_community_type, |
6138 | no_neighbor_send_community_type_cmd, | |
6139 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6140 | NO_STR | |
6141 | NEIGHBOR_STR | |
6142 | NEIGHBOR_ADDR_STR2 | |
6143 | "Send Community attribute to this neighbor\n" | |
6144 | "Send Standard and Extended Community attributes\n" | |
6145 | "Send Standard, Large and Extended Community attributes\n" | |
6146 | "Send Extended Community attributes\n" | |
6147 | "Send Standard Community attributes\n" | |
6148 | "Send Large Community attributes\n") | |
718e3744 | 6149 | { |
d62a17ae | 6150 | const char *type = argv[argc - 1]->text; |
db45f64d | 6151 | char *peer_str = argv[2]->arg; |
f4b8ec07 CS |
6152 | char base_xpath[XPATH_MAXLEN]; |
6153 | char af_xpath[XPATH_MAXLEN]; | |
6154 | char std_xpath[XPATH_MAXLEN]; | |
6155 | char ext_xpath[XPATH_MAXLEN]; | |
6156 | char lrg_xpath[XPATH_MAXLEN]; | |
db45f64d DS |
6157 | afi_t afi = bgp_node_afi(vty); |
6158 | safi_t safi = bgp_node_safi(vty); | |
6159 | ||
f4b8ec07 CS |
6160 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6161 | yang_afi_safi_value2identity(afi, safi)); | |
6162 | ||
6163 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6164 | sizeof(base_xpath), af_xpath) | |
6165 | < 0) | |
6166 | return CMD_WARNING_CONFIG_FAILED; | |
6167 | ||
6168 | if (strmatch(type, "standard")) { | |
6169 | snprintf(std_xpath, sizeof(std_xpath), | |
6170 | "./%s/send-community/send-community", | |
6171 | bgp_afi_safi_get_container_str(afi, safi)); | |
6172 | ||
6173 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); | |
6174 | } | |
6175 | ||
6176 | if (strmatch(type, "extended")) { | |
6177 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6178 | "./%s/send-community/send-ext-community", | |
6179 | bgp_afi_safi_get_container_str(afi, safi)); | |
6180 | ||
6181 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); | |
6182 | } | |
6183 | ||
6184 | if (strmatch(type, "large")) { | |
6185 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6186 | "./%s/send-community/send-large-community", | |
6187 | bgp_afi_safi_get_container_str(afi, safi)); | |
6188 | ||
6189 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "false"); | |
6190 | } | |
6191 | ||
6192 | if (strmatch(type, "both")) { | |
6193 | snprintf(std_xpath, sizeof(std_xpath), | |
6194 | "./%s/send-community/send-community", | |
6195 | bgp_afi_safi_get_container_str(afi, safi)); | |
6196 | ||
6197 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); | |
6198 | ||
6199 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6200 | "./%s/send-community/send-ext-community", | |
6201 | bgp_afi_safi_get_container_str(afi, safi)); | |
6202 | ||
6203 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); | |
6204 | } | |
6205 | ||
6206 | if (strmatch(type, "all")) { | |
6207 | snprintf(std_xpath, sizeof(std_xpath), | |
6208 | "./%s/send-community/send-community", | |
6209 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6210 | |
f4b8ec07 | 6211 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6212 | |
f4b8ec07 CS |
6213 | snprintf(ext_xpath, sizeof(ext_xpath), |
6214 | "./%s/send-community/send-ext-community", | |
6215 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6216 | |
f4b8ec07 | 6217 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6218 | |
f4b8ec07 CS |
6219 | snprintf(lrg_xpath, sizeof(lrg_xpath), |
6220 | "./%s/send-community/send-large-community", | |
6221 | bgp_afi_safi_get_container_str(afi, safi)); | |
d62a17ae | 6222 | |
f4b8ec07 | 6223 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "false"); |
27c05d4d PM |
6224 | } |
6225 | ||
f4b8ec07 | 6226 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6227 | } |
6228 | ||
6229 | ALIAS_HIDDEN( | |
6230 | no_neighbor_send_community_type, | |
6231 | no_neighbor_send_community_type_hidden_cmd, | |
6232 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6233 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6234 | "Send Community attribute to this neighbor\n" | |
6235 | "Send Standard and Extended Community attributes\n" | |
6236 | "Send Standard, Large and Extended Community attributes\n" | |
6237 | "Send Extended Community attributes\n" | |
6238 | "Send Standard Community attributes\n" | |
6239 | "Send Large Community attributes\n") | |
596c17ba | 6240 | |
718e3744 | 6241 | /* neighbor soft-reconfig. */ |
f4b8ec07 CS |
6242 | DEFUN_YANG (neighbor_soft_reconfiguration, |
6243 | neighbor_soft_reconfiguration_cmd, | |
6244 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6245 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6246 | "Per neighbor soft reconfiguration\n" | |
6247 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6248 | { |
d62a17ae | 6249 | int idx_peer = 1; |
f4b8ec07 CS |
6250 | char base_xpath[XPATH_MAXLEN]; |
6251 | char af_xpath[XPATH_MAXLEN]; | |
6252 | char soft_xpath[XPATH_MAXLEN]; | |
6253 | afi_t afi = bgp_node_afi(vty); | |
6254 | safi_t safi = bgp_node_safi(vty); | |
6255 | ||
6256 | ||
6257 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6258 | yang_afi_safi_value2identity(afi, safi)); | |
6259 | ||
6260 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6261 | sizeof(base_xpath), af_xpath) | |
6262 | < 0) | |
6263 | return CMD_WARNING_CONFIG_FAILED; | |
6264 | ||
6265 | snprintf(soft_xpath, sizeof(soft_xpath), "./%s/soft-reconfiguration", | |
6266 | bgp_afi_safi_get_container_str(afi, safi)); | |
6267 | ||
6268 | nb_cli_enqueue_change(vty, soft_xpath, NB_OP_MODIFY, "true"); | |
6269 | ||
6270 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6271 | } |
6272 | ||
d62a17ae | 6273 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
6274 | neighbor_soft_reconfiguration_hidden_cmd, | |
6275 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6276 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6277 | "Per neighbor soft reconfiguration\n" | |
6278 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6279 | |
f4b8ec07 CS |
6280 | DEFUN_YANG (no_neighbor_soft_reconfiguration, |
6281 | no_neighbor_soft_reconfiguration_cmd, | |
6282 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6283 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6284 | "Per neighbor soft reconfiguration\n" | |
6285 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6286 | { |
d62a17ae | 6287 | int idx_peer = 2; |
f4b8ec07 CS |
6288 | char base_xpath[XPATH_MAXLEN]; |
6289 | char af_xpath[XPATH_MAXLEN]; | |
6290 | char soft_xpath[XPATH_MAXLEN]; | |
6291 | afi_t afi = bgp_node_afi(vty); | |
6292 | safi_t safi = bgp_node_safi(vty); | |
6293 | ||
6294 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6295 | yang_afi_safi_value2identity(afi, safi)); | |
6296 | ||
6297 | snprintf(soft_xpath, sizeof(soft_xpath), "./%s/soft-reconfiguration", | |
6298 | bgp_afi_safi_get_container_str(afi, safi)); | |
6299 | ||
6300 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6301 | sizeof(base_xpath), af_xpath) | |
6302 | < 0) | |
6303 | return CMD_WARNING_CONFIG_FAILED; | |
6304 | ||
6305 | nb_cli_enqueue_change(vty, soft_xpath, NB_OP_MODIFY, "false"); | |
6306 | ||
6307 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6308 | } |
6b0655a2 | 6309 | |
d62a17ae | 6310 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
6311 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
6312 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6313 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6314 | "Per neighbor soft reconfiguration\n" | |
6315 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6316 | |
f4b8ec07 CS |
6317 | DEFUN_YANG (neighbor_route_reflector_client, |
6318 | neighbor_route_reflector_client_cmd, | |
6319 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6320 | NEIGHBOR_STR | |
6321 | NEIGHBOR_ADDR_STR2 | |
6322 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6323 | { |
d62a17ae | 6324 | int idx_peer = 1; |
f4b8ec07 CS |
6325 | char base_xpath[XPATH_MAXLEN]; |
6326 | char af_xpath[XPATH_MAXLEN]; | |
6327 | char attr_xpath[XPATH_MAXLEN]; | |
6328 | afi_t afi = bgp_node_afi(vty); | |
6329 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 6330 | |
f4b8ec07 CS |
6331 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6332 | yang_afi_safi_value2identity(afi, safi)); | |
718e3744 | 6333 | |
f4b8ec07 CS |
6334 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6335 | sizeof(base_xpath), af_xpath) | |
6336 | < 0) | |
d62a17ae | 6337 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6338 | |
f4b8ec07 CS |
6339 | snprintf(attr_xpath, sizeof(attr_xpath), |
6340 | "./%s/route-reflector/route-reflector-client", | |
6341 | bgp_afi_safi_get_container_str(afi, safi)); | |
6342 | ||
6343 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6344 | ||
6345 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6346 | } |
6347 | ||
d62a17ae | 6348 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
6349 | neighbor_route_reflector_client_hidden_cmd, | |
6350 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6351 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6352 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6353 | |
f4b8ec07 CS |
6354 | DEFUN_YANG (no_neighbor_route_reflector_client, |
6355 | no_neighbor_route_reflector_client_cmd, | |
6356 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6357 | NO_STR | |
6358 | NEIGHBOR_STR | |
6359 | NEIGHBOR_ADDR_STR2 | |
6360 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6361 | { |
d62a17ae | 6362 | int idx_peer = 2; |
f4b8ec07 CS |
6363 | char base_xpath[XPATH_MAXLEN]; |
6364 | char af_xpath[XPATH_MAXLEN]; | |
6365 | char attr_xpath[XPATH_MAXLEN]; | |
6366 | afi_t afi = bgp_node_afi(vty); | |
6367 | safi_t safi = bgp_node_safi(vty); | |
6368 | ||
6369 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6370 | yang_afi_safi_value2identity(afi, safi)); | |
6371 | ||
6372 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6373 | sizeof(base_xpath), af_xpath) | |
6374 | < 0) | |
6375 | return CMD_WARNING_CONFIG_FAILED; | |
6376 | ||
6377 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6378 | "./%s/route-reflector/route-reflector-client", | |
6379 | bgp_afi_safi_get_container_str(afi, safi)); | |
6380 | ||
6381 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6382 | ||
6383 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6384 | } |
6b0655a2 | 6385 | |
d62a17ae | 6386 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
6387 | no_neighbor_route_reflector_client_hidden_cmd, | |
6388 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6389 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6390 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6391 | |
718e3744 | 6392 | /* neighbor route-server-client. */ |
f4b8ec07 CS |
6393 | DEFUN_YANG (neighbor_route_server_client, |
6394 | neighbor_route_server_client_cmd, | |
6395 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6396 | NEIGHBOR_STR | |
6397 | NEIGHBOR_ADDR_STR2 | |
6398 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 6399 | { |
d62a17ae | 6400 | int idx_peer = 1; |
f4b8ec07 CS |
6401 | char base_xpath[XPATH_MAXLEN]; |
6402 | char af_xpath[XPATH_MAXLEN]; | |
6403 | char attr_xpath[XPATH_MAXLEN]; | |
6404 | afi_t afi = bgp_node_afi(vty); | |
6405 | safi_t safi = bgp_node_safi(vty); | |
2a3d5731 | 6406 | |
f4b8ec07 CS |
6407 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6408 | yang_afi_safi_value2identity(afi, safi)); | |
6409 | ||
6410 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6411 | sizeof(base_xpath), af_xpath) | |
6412 | < 0) | |
d62a17ae | 6413 | return CMD_WARNING_CONFIG_FAILED; |
f4b8ec07 CS |
6414 | |
6415 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6416 | "./%s/route-server/route-server-client", | |
6417 | bgp_afi_safi_get_container_str(afi, safi)); | |
6418 | ||
6419 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6420 | ||
6421 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6422 | } |
6423 | ||
d62a17ae | 6424 | ALIAS_HIDDEN(neighbor_route_server_client, |
6425 | neighbor_route_server_client_hidden_cmd, | |
6426 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6427 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6428 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6429 | |
f4b8ec07 CS |
6430 | DEFUN_YANG (no_neighbor_route_server_client, |
6431 | no_neighbor_route_server_client_cmd, | |
6432 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6433 | NO_STR | |
6434 | NEIGHBOR_STR | |
6435 | NEIGHBOR_ADDR_STR2 | |
6436 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 6437 | { |
d62a17ae | 6438 | int idx_peer = 2; |
f4b8ec07 CS |
6439 | char base_xpath[XPATH_MAXLEN]; |
6440 | char af_xpath[XPATH_MAXLEN]; | |
6441 | char attr_xpath[XPATH_MAXLEN]; | |
6442 | afi_t afi = bgp_node_afi(vty); | |
6443 | safi_t safi = bgp_node_safi(vty); | |
6444 | ||
6445 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6446 | yang_afi_safi_value2identity(afi, safi)); | |
6447 | ||
6448 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6449 | sizeof(base_xpath), af_xpath) | |
6450 | < 0) | |
6451 | return CMD_WARNING_CONFIG_FAILED; | |
6452 | ||
6453 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6454 | "./%s/route-server/route-server-client", | |
6455 | bgp_afi_safi_get_container_str(afi, safi)); | |
6456 | ||
6457 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6458 | ||
6459 | return nb_cli_apply_changes(vty, base_xpath); | |
fee0f4c6 | 6460 | } |
6b0655a2 | 6461 | |
d62a17ae | 6462 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
6463 | no_neighbor_route_server_client_hidden_cmd, | |
6464 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6465 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6466 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6467 | |
fee0f4c6 | 6468 | DEFUN (neighbor_nexthop_local_unchanged, |
6469 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6470 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6471 | NEIGHBOR_STR |
6472 | NEIGHBOR_ADDR_STR2 | |
6473 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6474 | "Leave link-local nexthop unchanged for this peer\n") | |
6475 | { | |
d62a17ae | 6476 | int idx_peer = 1; |
6477 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6478 | bgp_node_safi(vty), | |
6479 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6480 | } |
6b0655a2 | 6481 | |
fee0f4c6 | 6482 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6483 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6484 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6485 | NO_STR |
6486 | NEIGHBOR_STR | |
6487 | NEIGHBOR_ADDR_STR2 | |
6488 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6489 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6490 | { |
d62a17ae | 6491 | int idx_peer = 2; |
6492 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6493 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6494 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6495 | } |
6b0655a2 | 6496 | |
f4b8ec07 CS |
6497 | DEFUN_YANG (neighbor_attr_unchanged, |
6498 | neighbor_attr_unchanged_cmd, | |
6499 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6500 | NEIGHBOR_STR | |
6501 | NEIGHBOR_ADDR_STR2 | |
6502 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6503 | "As-path attribute\n" | |
6504 | "Nexthop attribute\n" | |
6505 | "Med attribute\n") | |
718e3744 | 6506 | { |
d62a17ae | 6507 | int idx = 0; |
8eeb0335 | 6508 | char *peer_str = argv[1]->arg; |
db45f64d DS |
6509 | bool aspath = false; |
6510 | bool nexthop = false; | |
6511 | bool med = false; | |
8eeb0335 DW |
6512 | afi_t afi = bgp_node_afi(vty); |
6513 | safi_t safi = bgp_node_safi(vty); | |
f4b8ec07 CS |
6514 | char base_xpath[XPATH_MAXLEN]; |
6515 | char af_xpath[XPATH_MAXLEN]; | |
6516 | char as_xpath[XPATH_MAXLEN]; | |
6517 | char nxthop_xpath[XPATH_MAXLEN]; | |
6518 | char med_xpath[XPATH_MAXLEN]; | |
8eeb0335 | 6519 | |
f4b8ec07 CS |
6520 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6521 | yang_afi_safi_value2identity(afi, safi)); | |
6522 | ||
6523 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6524 | sizeof(base_xpath), af_xpath) | |
6525 | < 0) | |
8eeb0335 | 6526 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6527 | |
6528 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6529 | aspath = true; |
6530 | ||
d62a17ae | 6531 | idx = 0; |
6532 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6533 | nexthop = true; |
6534 | ||
d62a17ae | 6535 | idx = 0; |
6536 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6537 | med = true; |
d62a17ae | 6538 | |
f4b8ec07 CS |
6539 | snprintf(as_xpath, sizeof(as_xpath), |
6540 | "./%s/attr-unchanged/as-path-unchanged", | |
6541 | bgp_afi_safi_get_container_str(afi, safi)); | |
6542 | snprintf(nxthop_xpath, sizeof(nxthop_xpath), | |
6543 | "./%s/attr-unchanged/next-hop-unchanged", | |
6544 | bgp_afi_safi_get_container_str(afi, safi)); | |
6545 | snprintf(med_xpath, sizeof(med_xpath), | |
6546 | "./%s/attr-unchanged/med-unchanged", | |
6547 | bgp_afi_safi_get_container_str(afi, safi)); | |
6548 | ||
8eeb0335 | 6549 | /* no flags means all of them! */ |
db45f64d | 6550 | if (!aspath && !nexthop && !med) { |
f4b8ec07 CS |
6551 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "true"); |
6552 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "true"); | |
6553 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "true"); | |
8eeb0335 | 6554 | } else { |
f4b8ec07 CS |
6555 | if (!aspath) |
6556 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, | |
6557 | "false"); | |
6558 | else | |
6559 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, | |
6560 | "true"); | |
6561 | ||
6562 | if (!nexthop) | |
6563 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, | |
6564 | "false"); | |
6565 | else | |
6566 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, | |
6567 | "true"); | |
6568 | ||
6569 | if (!med) | |
6570 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, | |
6571 | "false"); | |
6572 | else | |
6573 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, | |
6574 | "true"); | |
d62a17ae | 6575 | } |
6576 | ||
f4b8ec07 | 6577 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6578 | } |
6579 | ||
6580 | ALIAS_HIDDEN( | |
6581 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6582 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6583 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6584 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6585 | "As-path attribute\n" | |
6586 | "Nexthop attribute\n" | |
6587 | "Med attribute\n") | |
596c17ba | 6588 | |
f4b8ec07 CS |
6589 | DEFUN_YANG (no_neighbor_attr_unchanged, |
6590 | no_neighbor_attr_unchanged_cmd, | |
6591 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6592 | NO_STR | |
6593 | NEIGHBOR_STR | |
6594 | NEIGHBOR_ADDR_STR2 | |
6595 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6596 | "As-path attribute\n" | |
6597 | "Nexthop attribute\n" | |
6598 | "Med attribute\n") | |
718e3744 | 6599 | { |
d62a17ae | 6600 | int idx = 0; |
db45f64d | 6601 | char *peer_str = argv[2]->arg; |
db45f64d DS |
6602 | bool aspath = false; |
6603 | bool nexthop = false; | |
6604 | bool med = false; | |
6605 | afi_t afi = bgp_node_afi(vty); | |
6606 | safi_t safi = bgp_node_safi(vty); | |
f4b8ec07 CS |
6607 | char base_xpath[XPATH_MAXLEN]; |
6608 | char af_xpath[XPATH_MAXLEN]; | |
6609 | char as_xpath[XPATH_MAXLEN]; | |
6610 | char nxthop_xpath[XPATH_MAXLEN]; | |
6611 | char med_xpath[XPATH_MAXLEN]; | |
db45f64d | 6612 | |
f4b8ec07 CS |
6613 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6614 | yang_afi_safi_value2identity(afi, safi)); | |
6615 | ||
6616 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6617 | sizeof(base_xpath), af_xpath) | |
6618 | < 0) | |
db45f64d | 6619 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6620 | |
6621 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6622 | aspath = true; |
6623 | ||
d62a17ae | 6624 | idx = 0; |
6625 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6626 | nexthop = true; |
6627 | ||
d62a17ae | 6628 | idx = 0; |
6629 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6630 | med = true; |
d62a17ae | 6631 | |
f4b8ec07 CS |
6632 | snprintf(as_xpath, sizeof(as_xpath), |
6633 | "./%s/attr-unchanged/as-path-unchanged", | |
6634 | bgp_afi_safi_get_container_str(afi, safi)); | |
6635 | snprintf(nxthop_xpath, sizeof(nxthop_xpath), | |
6636 | "./%s/attr-unchanged/next-hop-unchanged", | |
6637 | bgp_afi_safi_get_container_str(afi, safi)); | |
6638 | snprintf(med_xpath, sizeof(med_xpath), | |
6639 | "./%s/attr-unchanged/med-unchanged", | |
6640 | bgp_afi_safi_get_container_str(afi, safi)); | |
6641 | ||
6642 | /* no flags means all of them! */ | |
6643 | if (!aspath && !nexthop && !med) { | |
6644 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "false"); | |
6645 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "false"); | |
6646 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "false"); | |
6647 | } | |
db45f64d DS |
6648 | |
6649 | if (aspath) | |
f4b8ec07 | 6650 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "false"); |
db45f64d DS |
6651 | |
6652 | if (nexthop) | |
f4b8ec07 | 6653 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "false"); |
d62a17ae | 6654 | |
db45f64d | 6655 | if (med) |
f4b8ec07 | 6656 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6657 | |
f4b8ec07 | 6658 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6659 | } |
6660 | ||
6661 | ALIAS_HIDDEN( | |
6662 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6663 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6664 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6665 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6666 | "As-path attribute\n" | |
6667 | "Nexthop attribute\n" | |
6668 | "Med attribute\n") | |
718e3744 | 6669 | |
f4b8ec07 CS |
6670 | /* neighbor ebgp-multihop. */ |
6671 | DEFUN_YANG (neighbor_ebgp_multihop, | |
6672 | neighbor_ebgp_multihop_cmd, | |
6673 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6674 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6675 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6676 | { |
f4b8ec07 CS |
6677 | int idx_peer = 1; |
6678 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 6679 | |
f4b8ec07 CS |
6680 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6681 | sizeof(base_xpath), NULL) | |
6682 | < 0) | |
d62a17ae | 6683 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6684 | |
f4b8ec07 CS |
6685 | nb_cli_enqueue_change(vty, "./ebgp-multihop/enabled", NB_OP_MODIFY, |
6686 | "true"); | |
718e3744 | 6687 | |
f4b8ec07 | 6688 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 6689 | } |
6690 | ||
f4b8ec07 CS |
6691 | DEFUN_YANG (neighbor_ebgp_multihop_ttl, |
6692 | neighbor_ebgp_multihop_ttl_cmd, | |
6693 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6694 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6695 | "Allow EBGP neighbors not on directly connected networks\n" | |
6696 | "maximum hop count\n") | |
718e3744 | 6697 | { |
f4b8ec07 CS |
6698 | int idx_peer = 1; |
6699 | int idx_number = 3; | |
6700 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 6701 | |
f4b8ec07 CS |
6702 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6703 | sizeof(base_xpath), NULL) | |
6704 | < 0) | |
d62a17ae | 6705 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6706 | |
f4b8ec07 CS |
6707 | nb_cli_enqueue_change(vty, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY, |
6708 | argv[idx_number]->arg); | |
718e3744 | 6709 | |
f4b8ec07 | 6710 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 6711 | } |
6712 | ||
f4b8ec07 CS |
6713 | DEFUN_YANG (no_neighbor_ebgp_multihop, |
6714 | no_neighbor_ebgp_multihop_cmd, | |
6715 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6716 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6717 | "Allow EBGP neighbors not on directly connected networks\n" | |
6718 | "maximum hop count\n") | |
718e3744 | 6719 | { |
d62a17ae | 6720 | int idx_peer = 2; |
f4b8ec07 CS |
6721 | char base_xpath[XPATH_MAXLEN]; |
6722 | ||
6723 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6724 | sizeof(base_xpath), NULL) | |
6725 | < 0) | |
6726 | return CMD_WARNING_CONFIG_FAILED; | |
6727 | ||
6728 | if (argc > 4) | |
6729 | nb_cli_enqueue_change(vty, "./ebgp-multihop/multihop-ttl", | |
6730 | NB_OP_DESTROY, NULL); | |
6731 | else | |
6732 | nb_cli_enqueue_change(vty, "./ebgp-multihop/enabled", | |
6733 | NB_OP_MODIFY, "false"); | |
6734 | ||
6735 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6736 | } |
6737 | ||
6b0655a2 | 6738 | |
6ffd2079 | 6739 | /* disable-connected-check */ |
f4b8ec07 CS |
6740 | DEFUN_YANG (neighbor_disable_connected_check, |
6741 | neighbor_disable_connected_check_cmd, | |
6742 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6743 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6744 | "one-hop away EBGP peer using loopback address\n" | |
6745 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6746 | { |
d62a17ae | 6747 | int idx_peer = 1; |
f4b8ec07 CS |
6748 | char base_xpath[XPATH_MAXLEN]; |
6749 | ||
6750 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6751 | sizeof(base_xpath), NULL) | |
6752 | < 0) | |
6753 | return CMD_WARNING_CONFIG_FAILED; | |
6754 | ||
6755 | nb_cli_enqueue_change(vty, "./ebgp-multihop/disable-connected-check", | |
6756 | NB_OP_MODIFY, "true"); | |
6757 | ||
6758 | return nb_cli_apply_changes(vty, base_xpath); | |
6ffd2079 | 6759 | } |
6760 | ||
f4b8ec07 CS |
6761 | DEFUN_YANG (no_neighbor_disable_connected_check, |
6762 | no_neighbor_disable_connected_check_cmd, | |
6763 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6764 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6765 | "one-hop away EBGP peer using loopback address\n" | |
6766 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6767 | { |
d62a17ae | 6768 | int idx_peer = 2; |
f4b8ec07 CS |
6769 | char base_xpath[XPATH_MAXLEN]; |
6770 | ||
6771 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6772 | sizeof(base_xpath), NULL) | |
6773 | < 0) | |
6774 | return CMD_WARNING_CONFIG_FAILED; | |
6775 | ||
6776 | nb_cli_enqueue_change(vty, "./ebgp-multihop/disable-connected-check", | |
6777 | NB_OP_MODIFY, "false"); | |
6778 | ||
6779 | return nb_cli_apply_changes(vty, base_xpath); | |
6ffd2079 | 6780 | } |
6781 | ||
47cbc09b PM |
6782 | |
6783 | /* enforce-first-as */ | |
f4b8ec07 CS |
6784 | DEFUN_YANG (neighbor_enforce_first_as, |
6785 | neighbor_enforce_first_as_cmd, | |
6786 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6787 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6788 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6789 | { |
6790 | int idx_peer = 1; | |
f4b8ec07 | 6791 | char base_xpath[XPATH_MAXLEN]; |
47cbc09b | 6792 | |
f4b8ec07 CS |
6793 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6794 | sizeof(base_xpath), NULL) | |
6795 | < 0) | |
6796 | return CMD_WARNING_CONFIG_FAILED; | |
6797 | ||
6798 | nb_cli_enqueue_change(vty, "./enforce-first-as", NB_OP_MODIFY, "true"); | |
6799 | ||
6800 | return nb_cli_apply_changes(vty, base_xpath); | |
47cbc09b PM |
6801 | } |
6802 | ||
f4b8ec07 CS |
6803 | DEFUN_YANG (no_neighbor_enforce_first_as, |
6804 | no_neighbor_enforce_first_as_cmd, | |
6805 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6806 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6807 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6808 | { |
6809 | int idx_peer = 2; | |
f4b8ec07 | 6810 | char base_xpath[XPATH_MAXLEN]; |
47cbc09b | 6811 | |
f4b8ec07 CS |
6812 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6813 | sizeof(base_xpath), NULL) | |
6814 | < 0) | |
6815 | return CMD_WARNING_CONFIG_FAILED; | |
6816 | ||
6817 | nb_cli_enqueue_change(vty, "./enforce-first-as", NB_OP_MODIFY, "false"); | |
6818 | ||
6819 | return nb_cli_apply_changes(vty, base_xpath); | |
47cbc09b PM |
6820 | } |
6821 | ||
f4b8ec07 CS |
6822 | static int peer_and_group_lookup_nb(struct vty *vty, const char *peer_str, |
6823 | char *base_xpath, int xpath_len, | |
6824 | char *xpath) | |
6825 | { | |
6826 | union sockunion su; | |
6827 | char num_xpath[XPATH_MAXLEN]; | |
6828 | char unnbr_xpath[XPATH_MAXLEN]; | |
6829 | char prgrp_xpath[XPATH_MAXLEN]; | |
6830 | ||
6831 | if (str2sockunion(peer_str, &su) == 0) { | |
6832 | snprintf(num_xpath, sizeof(num_xpath), | |
6833 | "/neighbors/neighbor[remote-address='%s']", peer_str); | |
6834 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
6835 | VTY_CURR_XPATH, num_xpath)) { | |
6836 | snprintf(base_xpath, xpath_len, | |
6837 | FRR_BGP_NEIGHBOR_NUM_XPATH, peer_str, | |
6838 | xpath ? xpath : ""); | |
6839 | } else { | |
6840 | vty_out(vty, | |
6841 | "%% Specify remote-as or peer-group commands first\n"); | |
6842 | return -1; | |
6843 | } | |
6844 | ||
6845 | } else { | |
6846 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
6847 | "/neighbors/unnumbered-neighbor[interface='%s']", | |
6848 | peer_str); | |
6849 | ||
6850 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
6851 | "/peer-groups/peer-group[peer-group-name='%s']", | |
6852 | peer_str); | |
6853 | ||
6854 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
6855 | VTY_CURR_XPATH, unnbr_xpath)) { | |
6856 | snprintf(base_xpath, xpath_len, | |
6857 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, peer_str, | |
6858 | xpath ? xpath : ""); | |
6859 | } else if (yang_dnode_exists(vty->candidate_config->dnode, | |
6860 | "%s%s", VTY_CURR_XPATH, | |
6861 | prgrp_xpath)) { | |
6862 | snprintf(base_xpath, xpath_len, | |
6863 | FRR_BGP_PEER_GROUP_XPATH, peer_str, | |
6864 | xpath ? xpath : ""); | |
6865 | } else { | |
6866 | vty_out(vty, | |
6867 | "%% Create the peer-group or interface first\n"); | |
6868 | return -1; | |
6869 | } | |
6870 | } | |
6871 | ||
6872 | return 0; | |
6873 | } | |
47cbc09b | 6874 | |
f4b8ec07 CS |
6875 | DEFUN_YANG (neighbor_description, |
6876 | neighbor_description_cmd, | |
6877 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6878 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6879 | "Neighbor specific description\n" | |
6880 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6881 | { |
d62a17ae | 6882 | int idx_peer = 1; |
6883 | int idx_line = 3; | |
f4b8ec07 CS |
6884 | int ret; |
6885 | char base_xpath[XPATH_MAXLEN]; | |
d62a17ae | 6886 | char *str; |
718e3744 | 6887 | |
f4b8ec07 CS |
6888 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6889 | sizeof(base_xpath), NULL) | |
6890 | < 0) | |
d62a17ae | 6891 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6892 | |
d62a17ae | 6893 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6894 | |
f4b8ec07 CS |
6895 | nb_cli_enqueue_change(vty, "./description", NB_OP_MODIFY, str); |
6896 | ||
6897 | ret = nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6898 | |
d62a17ae | 6899 | XFREE(MTYPE_TMP, str); |
718e3744 | 6900 | |
f4b8ec07 | 6901 | return ret; |
718e3744 | 6902 | } |
6903 | ||
f4b8ec07 CS |
6904 | DEFUN_YANG (no_neighbor_description, |
6905 | no_neighbor_description_cmd, | |
6906 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6907 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6908 | "Neighbor specific description\n") | |
718e3744 | 6909 | { |
d62a17ae | 6910 | int idx_peer = 2; |
f4b8ec07 CS |
6911 | char base_xpath[XPATH_MAXLEN]; |
6912 | ||
6913 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6914 | sizeof(base_xpath), NULL) | |
6915 | < 0) | |
d62a17ae | 6916 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6917 | |
f4b8ec07 | 6918 | nb_cli_enqueue_change(vty, "./description", NB_OP_DESTROY, NULL); |
718e3744 | 6919 | |
f4b8ec07 | 6920 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 6921 | } |
6922 | ||
232c75cd | 6923 | ALIAS_YANG(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6924 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6925 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6926 | "Neighbor specific description\n" | |
6927 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6928 | |
d62a17ae | 6929 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6930 | "IPv4 address\n" \ | |
6931 | "IPv6 address\n" \ | |
6932 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6933 | |
f4b8ec07 CS |
6934 | DEFUN_YANG (neighbor_update_source, |
6935 | neighbor_update_source_cmd, | |
6936 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6937 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6938 | "Source of routing updates\n" | |
6939 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6940 | { |
d62a17ae | 6941 | int idx_peer = 1; |
6942 | int idx_peer_2 = 3; | |
f4b8ec07 CS |
6943 | union sockunion su; |
6944 | char base_xpath[XPATH_MAXLEN]; | |
6945 | ||
6946 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6947 | sizeof(base_xpath), NULL) | |
6948 | < 0) | |
6949 | return CMD_WARNING_CONFIG_FAILED; | |
6950 | ||
f4b8ec07 CS |
6951 | if (str2sockunion(argv[idx_peer_2]->arg, &su) == 0) |
6952 | nb_cli_enqueue_change(vty, "./update-source/ip", NB_OP_MODIFY, | |
d62a17ae | 6953 | argv[idx_peer_2]->arg); |
f4b8ec07 CS |
6954 | else |
6955 | nb_cli_enqueue_change(vty, "./update-source/interface", | |
6956 | NB_OP_MODIFY, argv[idx_peer_2]->arg); | |
6957 | ||
6958 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6959 | } |
6960 | ||
f4b8ec07 CS |
6961 | DEFUN_YANG (no_neighbor_update_source, |
6962 | no_neighbor_update_source_cmd, | |
6963 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6964 | NO_STR NEIGHBOR_STR | |
6965 | NEIGHBOR_ADDR_STR2 | |
6966 | "Source of routing updates\n" | |
6967 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6968 | { |
d62a17ae | 6969 | int idx_peer = 2; |
f4b8ec07 | 6970 | char base_xpath[XPATH_MAXLEN]; |
f4b8ec07 CS |
6971 | |
6972 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6973 | sizeof(base_xpath), NULL) | |
6974 | < 0) | |
6975 | return CMD_WARNING_CONFIG_FAILED; | |
6976 | ||
555c8ab7 CS |
6977 | nb_cli_enqueue_change(vty, "./update-source/ip", NB_OP_DESTROY, NULL); |
6978 | nb_cli_enqueue_change(vty, "./update-source/interface", NB_OP_DESTROY, | |
6979 | NULL); | |
f4b8ec07 CS |
6980 | |
6981 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6982 | } |
6b0655a2 | 6983 | |
d62a17ae | 6984 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6985 | afi_t afi, safi_t safi, | |
6986 | const char *rmap, int set) | |
718e3744 | 6987 | { |
d62a17ae | 6988 | int ret; |
6989 | struct peer *peer; | |
80912664 | 6990 | struct route_map *route_map = NULL; |
718e3744 | 6991 | |
d62a17ae | 6992 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6993 | if (!peer) | |
6994 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6995 | |
1de27621 | 6996 | if (set) { |
80912664 DS |
6997 | if (rmap) |
6998 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6999 | ret = peer_default_originate_set(peer, afi, safi, |
7000 | rmap, route_map); | |
7001 | } else | |
d62a17ae | 7002 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 7003 | |
d62a17ae | 7004 | return bgp_vty_return(vty, ret); |
718e3744 | 7005 | } |
7006 | ||
7007 | /* neighbor default-originate. */ | |
7008 | DEFUN (neighbor_default_originate, | |
7009 | neighbor_default_originate_cmd, | |
9ccf14f7 | 7010 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 7011 | NEIGHBOR_STR |
7012 | NEIGHBOR_ADDR_STR2 | |
7013 | "Originate default route to this neighbor\n") | |
7014 | { | |
d62a17ae | 7015 | int idx_peer = 1; |
7016 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7017 | bgp_node_afi(vty), | |
7018 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 7019 | } |
7020 | ||
d62a17ae | 7021 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
7022 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
7023 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7024 | "Originate default route to this neighbor\n") | |
596c17ba | 7025 | |
718e3744 | 7026 | DEFUN (neighbor_default_originate_rmap, |
7027 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 7028 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 7029 | NEIGHBOR_STR |
7030 | NEIGHBOR_ADDR_STR2 | |
7031 | "Originate default route to this neighbor\n" | |
7032 | "Route-map to specify criteria to originate default\n" | |
7033 | "route-map name\n") | |
7034 | { | |
d62a17ae | 7035 | int idx_peer = 1; |
7036 | int idx_word = 4; | |
7037 | return peer_default_originate_set_vty( | |
7038 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7039 | argv[idx_word]->arg, 1); | |
718e3744 | 7040 | } |
7041 | ||
d62a17ae | 7042 | ALIAS_HIDDEN( |
7043 | neighbor_default_originate_rmap, | |
7044 | neighbor_default_originate_rmap_hidden_cmd, | |
7045 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
7046 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7047 | "Originate default route to this neighbor\n" | |
7048 | "Route-map to specify criteria to originate default\n" | |
7049 | "route-map name\n") | |
596c17ba | 7050 | |
718e3744 | 7051 | DEFUN (no_neighbor_default_originate, |
7052 | no_neighbor_default_originate_cmd, | |
a636c635 | 7053 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 7054 | NO_STR |
7055 | NEIGHBOR_STR | |
7056 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
7057 | "Originate default route to this neighbor\n" |
7058 | "Route-map to specify criteria to originate default\n" | |
7059 | "route-map name\n") | |
718e3744 | 7060 | { |
d62a17ae | 7061 | int idx_peer = 2; |
7062 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7063 | bgp_node_afi(vty), | |
7064 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 7065 | } |
7066 | ||
d62a17ae | 7067 | ALIAS_HIDDEN( |
7068 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
7069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
7070 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7071 | "Originate default route to this neighbor\n" | |
7072 | "Route-map to specify criteria to originate default\n" | |
7073 | "route-map name\n") | |
596c17ba | 7074 | |
6b0655a2 | 7075 | |
f418446b | 7076 | /* Set specified peer's BGP port. */ |
f4b8ec07 CS |
7077 | DEFUN_YANG (neighbor_port, |
7078 | neighbor_port_cmd, | |
7079 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
7080 | NEIGHBOR_STR | |
7081 | NEIGHBOR_ADDR_STR | |
7082 | "Neighbor's BGP port\n" | |
7083 | "TCP port number\n") | |
718e3744 | 7084 | { |
d62a17ae | 7085 | int idx_ip = 1; |
7086 | int idx_number = 3; | |
f4b8ec07 | 7087 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 7088 | |
f4b8ec07 CS |
7089 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7090 | argv[idx_ip]->arg, ""); | |
718e3744 | 7091 | |
f4b8ec07 CS |
7092 | nb_cli_enqueue_change(vty, "./local-port", NB_OP_MODIFY, |
7093 | argv[idx_number]->arg); | |
7094 | ||
7095 | return nb_cli_apply_changes(vty, base_xpath); | |
7096 | } | |
6b0655a2 | 7097 | |
f4b8ec07 CS |
7098 | DEFUN_YANG (no_neighbor_port, |
7099 | no_neighbor_port_cmd, | |
7100 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
7101 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR | |
7102 | "Neighbor's BGP port\n" | |
7103 | "TCP port number\n") | |
718e3744 | 7104 | { |
f4b8ec07 CS |
7105 | int idx_ip = 2; |
7106 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7107 | |
f4b8ec07 CS |
7108 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7109 | argv[idx_ip]->arg, ""); | |
718e3744 | 7110 | |
f4b8ec07 | 7111 | nb_cli_enqueue_change(vty, "./local-port", NB_OP_DESTROY, NULL); |
718e3744 | 7112 | |
f4b8ec07 | 7113 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7114 | } |
7115 | ||
f4b8ec07 CS |
7116 | DEFUN_YANG (neighbor_weight, |
7117 | neighbor_weight_cmd, | |
7118 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7119 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7120 | "Set default weight for routes from this neighbor\n" | |
7121 | "default weight\n") | |
718e3744 | 7122 | { |
f4b8ec07 CS |
7123 | int idx_peer = 1; |
7124 | int idx_number = 3; | |
7125 | char base_xpath[XPATH_MAXLEN]; | |
7126 | char af_xpath[XPATH_MAXLEN]; | |
7127 | char attr_xpath[XPATH_MAXLEN]; | |
7128 | afi_t afi = bgp_node_afi(vty); | |
7129 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 7130 | |
f4b8ec07 CS |
7131 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
7132 | yang_afi_safi_value2identity(afi, safi)); | |
7133 | ||
7134 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7135 | sizeof(base_xpath), af_xpath) | |
7136 | < 0) | |
d62a17ae | 7137 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7138 | |
f4b8ec07 CS |
7139 | snprintf(attr_xpath, sizeof(attr_xpath), "./%s/weight/weight-attribute", |
7140 | bgp_afi_safi_get_container_str(afi, safi)); | |
718e3744 | 7141 | |
f4b8ec07 CS |
7142 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, |
7143 | argv[idx_number]->arg); | |
7144 | ||
7145 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7146 | } |
7147 | ||
d62a17ae | 7148 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
7149 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7150 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7151 | "Set default weight for routes from this neighbor\n" | |
7152 | "default weight\n") | |
596c17ba | 7153 | |
f4b8ec07 CS |
7154 | DEFUN_YANG (no_neighbor_weight, |
7155 | no_neighbor_weight_cmd, | |
7156 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7157 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7158 | "Set default weight for routes from this neighbor\n" | |
7159 | "default weight\n") | |
718e3744 | 7160 | { |
d62a17ae | 7161 | int idx_peer = 2; |
f4b8ec07 CS |
7162 | char base_xpath[XPATH_MAXLEN]; |
7163 | char af_xpath[XPATH_MAXLEN]; | |
7164 | char attr_xpath[XPATH_MAXLEN]; | |
7165 | afi_t afi = bgp_node_afi(vty); | |
7166 | safi_t safi = bgp_node_safi(vty); | |
7167 | ||
7168 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
7169 | yang_afi_safi_value2identity(afi, safi)); | |
7170 | ||
7171 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7172 | sizeof(base_xpath), af_xpath) | |
7173 | < 0) | |
7174 | return CMD_WARNING_CONFIG_FAILED; | |
7175 | ||
7176 | snprintf(attr_xpath, sizeof(attr_xpath), "./%s/weight/weight-attribute", | |
7177 | bgp_afi_safi_get_container_str(afi, safi)); | |
7178 | ||
7179 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_DESTROY, NULL); | |
7180 | ||
7181 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7182 | } |
7183 | ||
d62a17ae | 7184 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
7185 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7186 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7187 | "Set default weight for routes from this neighbor\n" | |
7188 | "default weight\n") | |
596c17ba | 7189 | |
6b0655a2 | 7190 | |
718e3744 | 7191 | /* Override capability negotiation. */ |
8611c7f3 CS |
7192 | DEFUN_YANG (neighbor_override_capability, |
7193 | neighbor_override_capability_cmd, | |
7194 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7195 | NEIGHBOR_STR | |
7196 | NEIGHBOR_ADDR_STR2 | |
7197 | "Override capability negotiation result\n") | |
718e3744 | 7198 | { |
d62a17ae | 7199 | int idx_peer = 1; |
8611c7f3 CS |
7200 | char base_xpath[XPATH_MAXLEN]; |
7201 | ||
7202 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7203 | sizeof(base_xpath), NULL) | |
7204 | < 0) | |
7205 | return CMD_WARNING_CONFIG_FAILED; | |
7206 | ||
7207 | nb_cli_enqueue_change( | |
7208 | vty, "./capability-options/override-capability", | |
7209 | NB_OP_MODIFY, "true"); | |
7210 | ||
7211 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7212 | } |
7213 | ||
8611c7f3 CS |
7214 | DEFUN_YANG (no_neighbor_override_capability, |
7215 | no_neighbor_override_capability_cmd, | |
7216 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7217 | NO_STR | |
7218 | NEIGHBOR_STR | |
7219 | NEIGHBOR_ADDR_STR2 | |
7220 | "Override capability negotiation result\n") | |
718e3744 | 7221 | { |
d62a17ae | 7222 | int idx_peer = 2; |
8611c7f3 CS |
7223 | char base_xpath[XPATH_MAXLEN]; |
7224 | ||
7225 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7226 | sizeof(base_xpath), NULL) | |
7227 | < 0) | |
7228 | return CMD_WARNING_CONFIG_FAILED; | |
7229 | ||
7230 | nb_cli_enqueue_change( | |
7231 | vty, "./capability-options/override-capability", | |
7232 | NB_OP_MODIFY, "false"); | |
7233 | ||
7234 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7235 | } |
6b0655a2 | 7236 | |
8611c7f3 CS |
7237 | DEFUN_YANG (neighbor_strict_capability, |
7238 | neighbor_strict_capability_cmd, | |
7239 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7240 | NEIGHBOR_STR | |
7241 | NEIGHBOR_ADDR_STR2 | |
7242 | "Strict capability negotiation match\n") | |
718e3744 | 7243 | { |
9fb964de | 7244 | int idx_peer = 1; |
8611c7f3 | 7245 | char base_xpath[XPATH_MAXLEN]; |
9fb964de | 7246 | |
8611c7f3 CS |
7247 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7248 | sizeof(base_xpath), NULL) | |
7249 | < 0) | |
7250 | return CMD_WARNING_CONFIG_FAILED; | |
7251 | ||
7252 | nb_cli_enqueue_change( | |
7253 | vty, "./capability-options/strict-capability", | |
7254 | NB_OP_MODIFY, "true"); | |
7255 | ||
7256 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7257 | } |
7258 | ||
8611c7f3 CS |
7259 | DEFUN_YANG (no_neighbor_strict_capability, |
7260 | no_neighbor_strict_capability_cmd, | |
7261 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7262 | NO_STR | |
7263 | NEIGHBOR_STR | |
7264 | NEIGHBOR_ADDR_STR2 | |
7265 | "Strict capability negotiation match\n") | |
718e3744 | 7266 | { |
9fb964de | 7267 | int idx_peer = 2; |
8611c7f3 | 7268 | char base_xpath[XPATH_MAXLEN]; |
9fb964de | 7269 | |
8611c7f3 CS |
7270 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7271 | sizeof(base_xpath), NULL) | |
7272 | < 0) | |
7273 | return CMD_WARNING_CONFIG_FAILED; | |
7274 | ||
7275 | nb_cli_enqueue_change( | |
7276 | vty, "./capability-options/strict-capability", | |
7277 | NB_OP_MODIFY, "false"); | |
7278 | ||
7279 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7280 | } |
6b0655a2 | 7281 | |
f4b8ec07 CS |
7282 | DEFUN_YANG (neighbor_timers, |
7283 | neighbor_timers_cmd, | |
7284 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
7285 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7286 | "BGP per neighbor timers\n" | |
7287 | "Keepalive interval\n" | |
7288 | "Holdtime\n") | |
718e3744 | 7289 | { |
f4b8ec07 CS |
7290 | int idx_peer = 1; |
7291 | int idx_number = 3; | |
7292 | int idx_number_2 = 4; | |
7293 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7294 | |
f4b8ec07 CS |
7295 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7296 | sizeof(base_xpath), NULL) | |
7297 | < 0) | |
d62a17ae | 7298 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7299 | |
f4b8ec07 CS |
7300 | nb_cli_enqueue_change(vty, "./timers/keepalive", NB_OP_MODIFY, |
7301 | argv[idx_number]->arg); | |
718e3744 | 7302 | |
f4b8ec07 CS |
7303 | nb_cli_enqueue_change(vty, "./timers/hold-time", NB_OP_MODIFY, |
7304 | argv[idx_number_2]->arg); | |
718e3744 | 7305 | |
f4b8ec07 | 7306 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7307 | } |
6b0655a2 | 7308 | |
f4b8ec07 CS |
7309 | DEFUN_YANG (no_neighbor_timers, |
7310 | no_neighbor_timers_cmd, | |
7311 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
7312 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7313 | "BGP per neighbor timers\n" | |
7314 | "Keepalive interval\n" | |
7315 | "Holdtime\n") | |
718e3744 | 7316 | { |
f4b8ec07 CS |
7317 | int idx_peer = 2; |
7318 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7319 | |
f4b8ec07 CS |
7320 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7321 | sizeof(base_xpath), NULL) | |
7322 | < 0) | |
d62a17ae | 7323 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7324 | |
f4b8ec07 | 7325 | nb_cli_enqueue_change(vty, "./timers/hold-time", NB_OP_DESTROY, NULL); |
718e3744 | 7326 | |
f4b8ec07 | 7327 | nb_cli_enqueue_change(vty, "./timers/keepalive", NB_OP_DESTROY, NULL); |
718e3744 | 7328 | |
f4b8ec07 | 7329 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7330 | } |
6b0655a2 | 7331 | |
f4b8ec07 CS |
7332 | DEFUN_YANG (neighbor_timers_connect, |
7333 | neighbor_timers_connect_cmd, | |
7334 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
7335 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7336 | "BGP per neighbor timers\n" | |
7337 | "BGP connect timer\n" | |
7338 | "Connect timer\n") | |
718e3744 | 7339 | { |
f4b8ec07 CS |
7340 | int idx_peer = 1; |
7341 | int idx_number = 4; | |
7342 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7343 | |
f4b8ec07 CS |
7344 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7345 | sizeof(base_xpath), NULL) | |
7346 | < 0) | |
d62a17ae | 7347 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7348 | |
f4b8ec07 CS |
7349 | nb_cli_enqueue_change(vty, "./timers/connect-time", NB_OP_MODIFY, |
7350 | argv[idx_number]->arg); | |
718e3744 | 7351 | |
f4b8ec07 | 7352 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7353 | } |
7354 | ||
f4b8ec07 CS |
7355 | DEFUN_YANG (no_neighbor_timers_connect, |
7356 | no_neighbor_timers_connect_cmd, | |
7357 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
7358 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7359 | "BGP per neighbor timers\n" | |
7360 | "BGP connect timer\n" | |
7361 | "Connect timer\n") | |
718e3744 | 7362 | { |
f4b8ec07 CS |
7363 | int idx_peer = 2; |
7364 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7365 | |
f4b8ec07 CS |
7366 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7367 | sizeof(base_xpath), NULL) | |
7368 | < 0) | |
d62a17ae | 7369 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7370 | |
f4b8ec07 CS |
7371 | nb_cli_enqueue_change(vty, "./timers/connect-time", NB_OP_DESTROY, |
7372 | NULL); | |
718e3744 | 7373 | |
f4b8ec07 | 7374 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7375 | } |
7376 | ||
f4b8ec07 CS |
7377 | DEFUN_YANG (neighbor_advertise_interval, |
7378 | neighbor_advertise_interval_cmd, | |
7379 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
7380 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7381 | "Minimum interval between sending BGP routing updates\n" | |
7382 | "time in seconds\n") | |
718e3744 | 7383 | { |
d62a17ae | 7384 | int idx_peer = 1; |
f4b8ec07 CS |
7385 | int idx_number = 3; |
7386 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7387 | |
f4b8ec07 CS |
7388 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7389 | sizeof(base_xpath), NULL) | |
7390 | < 0) | |
d62a17ae | 7391 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7392 | |
f4b8ec07 CS |
7393 | nb_cli_enqueue_change(vty, "./timers/advertise-interval", NB_OP_MODIFY, |
7394 | argv[idx_number]->arg); | |
718e3744 | 7395 | |
f4b8ec07 | 7396 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7397 | } |
7398 | ||
f4b8ec07 CS |
7399 | DEFUN_YANG (no_neighbor_advertise_interval, |
7400 | no_neighbor_advertise_interval_cmd, | |
7401 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7402 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7403 | "Minimum interval between sending BGP routing updates\n" | |
7404 | "time in seconds\n") | |
718e3744 | 7405 | { |
d62a17ae | 7406 | int idx_peer = 2; |
f4b8ec07 CS |
7407 | char base_xpath[XPATH_MAXLEN]; |
7408 | ||
7409 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7410 | sizeof(base_xpath), NULL) | |
7411 | < 0) | |
7412 | return CMD_WARNING_CONFIG_FAILED; | |
7413 | ||
7414 | nb_cli_enqueue_change(vty, "./timers/advertise-interval", NB_OP_DESTROY, | |
7415 | NULL); | |
7416 | ||
7417 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7418 | } |
7419 | ||
6b0655a2 | 7420 | |
518f0eb1 DS |
7421 | /* Time to wait before processing route-map updates */ |
7422 | DEFUN (bgp_set_route_map_delay_timer, | |
7423 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 7424 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
7425 | SET_STR |
7426 | "BGP route-map delay timer\n" | |
7427 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 7428 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 7429 | { |
d62a17ae | 7430 | int idx_number = 3; |
d7c0a89a | 7431 | uint32_t rmap_delay_timer; |
d62a17ae | 7432 | |
7433 | if (argv[idx_number]->arg) { | |
7434 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7435 | bm->rmap_update_timer = rmap_delay_timer; | |
7436 | ||
7437 | /* if the dynamic update handling is being disabled, and a timer | |
7438 | * is | |
7439 | * running, stop the timer and act as if the timer has already | |
7440 | * fired. | |
7441 | */ | |
7442 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
7443 | BGP_TIMER_OFF(bm->t_rmap_update); | |
7444 | thread_execute(bm->master, bgp_route_map_update_timer, | |
7445 | NULL, 0); | |
7446 | } | |
7447 | return CMD_SUCCESS; | |
7448 | } else { | |
7449 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7450 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7451 | } |
518f0eb1 DS |
7452 | } |
7453 | ||
7454 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7455 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7456 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7457 | NO_STR |
3a2d747c | 7458 | BGP_STR |
518f0eb1 | 7459 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7460 | "Reset to default time to wait for processing route-map changes\n" |
7461 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7462 | { |
518f0eb1 | 7463 | |
d62a17ae | 7464 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7465 | |
d62a17ae | 7466 | return CMD_SUCCESS; |
518f0eb1 DS |
7467 | } |
7468 | ||
f4b8ec07 CS |
7469 | DEFUN_YANG (neighbor_interface, |
7470 | neighbor_interface_cmd, | |
7471 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7472 | NEIGHBOR_STR NEIGHBOR_ADDR_STR | |
7473 | "Interface\n" | |
7474 | "Interface name\n") | |
718e3744 | 7475 | { |
f4b8ec07 CS |
7476 | int idx_ip = 1; |
7477 | int idx_word = 3; | |
7478 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7479 | |
f4b8ec07 CS |
7480 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7481 | argv[idx_ip]->arg, ""); | |
718e3744 | 7482 | |
f4b8ec07 CS |
7483 | nb_cli_enqueue_change(vty, "./local-interface", NB_OP_MODIFY, |
7484 | argv[idx_word]->arg); | |
718e3744 | 7485 | |
f4b8ec07 | 7486 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7487 | } |
7488 | ||
f4b8ec07 CS |
7489 | DEFUN_YANG (no_neighbor_interface, |
7490 | no_neighbor_interface_cmd, | |
7491 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", | |
7492 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7493 | "Interface\n" | |
7494 | "Interface name\n") | |
718e3744 | 7495 | { |
d62a17ae | 7496 | int idx_peer = 2; |
f4b8ec07 CS |
7497 | char base_xpath[XPATH_MAXLEN]; |
7498 | ||
7499 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, | |
7500 | argv[idx_peer]->arg, ""); | |
7501 | ||
7502 | nb_cli_enqueue_change(vty, "./local-interface", NB_OP_DESTROY, NULL); | |
7503 | ||
7504 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7505 | } |
6b0655a2 | 7506 | |
718e3744 | 7507 | DEFUN (neighbor_distribute_list, |
7508 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 7509 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 7510 | NEIGHBOR_STR |
7511 | NEIGHBOR_ADDR_STR2 | |
7512 | "Filter updates to/from this neighbor\n" | |
7513 | "IP access-list number\n" | |
7514 | "IP access-list number (expanded range)\n" | |
7515 | "IP Access-list name\n" | |
7516 | "Filter incoming updates\n" | |
7517 | "Filter outgoing updates\n") | |
7518 | { | |
d62a17ae | 7519 | int idx_peer = 1; |
7520 | int idx_acl = 3; | |
7521 | int direct, ret; | |
7522 | struct peer *peer; | |
a8206004 | 7523 | |
d62a17ae | 7524 | const char *pstr = argv[idx_peer]->arg; |
7525 | const char *acl = argv[idx_acl]->arg; | |
7526 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7527 | |
d62a17ae | 7528 | peer = peer_and_group_lookup_vty(vty, pstr); |
7529 | if (!peer) | |
7530 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7531 | |
d62a17ae | 7532 | /* Check filter direction. */ |
7533 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7534 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7535 | direct, acl); | |
a8206004 | 7536 | |
d62a17ae | 7537 | return bgp_vty_return(vty, ret); |
718e3744 | 7538 | } |
7539 | ||
d62a17ae | 7540 | ALIAS_HIDDEN( |
7541 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
7542 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
7543 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7544 | "Filter updates to/from this neighbor\n" | |
7545 | "IP access-list number\n" | |
7546 | "IP access-list number (expanded range)\n" | |
7547 | "IP Access-list name\n" | |
7548 | "Filter incoming updates\n" | |
7549 | "Filter outgoing updates\n") | |
596c17ba | 7550 | |
718e3744 | 7551 | DEFUN (no_neighbor_distribute_list, |
7552 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 7553 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 7554 | NO_STR |
7555 | NEIGHBOR_STR | |
7556 | NEIGHBOR_ADDR_STR2 | |
7557 | "Filter updates to/from this neighbor\n" | |
7558 | "IP access-list number\n" | |
7559 | "IP access-list number (expanded range)\n" | |
7560 | "IP Access-list name\n" | |
7561 | "Filter incoming updates\n" | |
7562 | "Filter outgoing updates\n") | |
7563 | { | |
d62a17ae | 7564 | int idx_peer = 2; |
7565 | int direct, ret; | |
7566 | struct peer *peer; | |
a8206004 | 7567 | |
d62a17ae | 7568 | const char *pstr = argv[idx_peer]->arg; |
7569 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7570 | |
d62a17ae | 7571 | peer = peer_and_group_lookup_vty(vty, pstr); |
7572 | if (!peer) | |
7573 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7574 | |
d62a17ae | 7575 | /* Check filter direction. */ |
7576 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7577 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7578 | direct); | |
a8206004 | 7579 | |
d62a17ae | 7580 | return bgp_vty_return(vty, ret); |
718e3744 | 7581 | } |
6b0655a2 | 7582 | |
d62a17ae | 7583 | ALIAS_HIDDEN( |
7584 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
7585 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
7586 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7587 | "Filter updates to/from this neighbor\n" | |
7588 | "IP access-list number\n" | |
7589 | "IP access-list number (expanded range)\n" | |
7590 | "IP Access-list name\n" | |
7591 | "Filter incoming updates\n" | |
7592 | "Filter outgoing updates\n") | |
596c17ba | 7593 | |
718e3744 | 7594 | /* Set prefix list to the peer. */ |
d62a17ae | 7595 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7596 | afi_t afi, safi_t safi, | |
7597 | const char *name_str, | |
7598 | const char *direct_str) | |
718e3744 | 7599 | { |
d62a17ae | 7600 | int ret; |
d62a17ae | 7601 | int direct = FILTER_IN; |
cf9ac8bf | 7602 | struct peer *peer; |
718e3744 | 7603 | |
d62a17ae | 7604 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7605 | if (!peer) | |
7606 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7607 | |
d62a17ae | 7608 | /* Check filter direction. */ |
7609 | if (strncmp(direct_str, "i", 1) == 0) | |
7610 | direct = FILTER_IN; | |
7611 | else if (strncmp(direct_str, "o", 1) == 0) | |
7612 | direct = FILTER_OUT; | |
718e3744 | 7613 | |
d62a17ae | 7614 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7615 | |
d62a17ae | 7616 | return bgp_vty_return(vty, ret); |
718e3744 | 7617 | } |
7618 | ||
d62a17ae | 7619 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
7620 | afi_t afi, safi_t safi, | |
7621 | const char *direct_str) | |
718e3744 | 7622 | { |
d62a17ae | 7623 | int ret; |
7624 | struct peer *peer; | |
7625 | int direct = FILTER_IN; | |
718e3744 | 7626 | |
d62a17ae | 7627 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7628 | if (!peer) | |
7629 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 7630 | |
d62a17ae | 7631 | /* Check filter direction. */ |
7632 | if (strncmp(direct_str, "i", 1) == 0) | |
7633 | direct = FILTER_IN; | |
7634 | else if (strncmp(direct_str, "o", 1) == 0) | |
7635 | direct = FILTER_OUT; | |
718e3744 | 7636 | |
d62a17ae | 7637 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 7638 | |
d62a17ae | 7639 | return bgp_vty_return(vty, ret); |
718e3744 | 7640 | } |
7641 | ||
7642 | DEFUN (neighbor_prefix_list, | |
7643 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 7644 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 7645 | NEIGHBOR_STR |
7646 | NEIGHBOR_ADDR_STR2 | |
7647 | "Filter updates to/from this neighbor\n" | |
7648 | "Name of a prefix list\n" | |
7649 | "Filter incoming updates\n" | |
7650 | "Filter outgoing updates\n") | |
7651 | { | |
d62a17ae | 7652 | int idx_peer = 1; |
7653 | int idx_word = 3; | |
7654 | int idx_in_out = 4; | |
7655 | return peer_prefix_list_set_vty( | |
7656 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7657 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7658 | } |
7659 | ||
d62a17ae | 7660 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7661 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7662 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7663 | "Filter updates to/from this neighbor\n" | |
7664 | "Name of a prefix list\n" | |
7665 | "Filter incoming updates\n" | |
7666 | "Filter outgoing updates\n") | |
596c17ba | 7667 | |
718e3744 | 7668 | DEFUN (no_neighbor_prefix_list, |
7669 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 7670 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 7671 | NO_STR |
7672 | NEIGHBOR_STR | |
7673 | NEIGHBOR_ADDR_STR2 | |
7674 | "Filter updates to/from this neighbor\n" | |
7675 | "Name of a prefix list\n" | |
7676 | "Filter incoming updates\n" | |
7677 | "Filter outgoing updates\n") | |
7678 | { | |
d62a17ae | 7679 | int idx_peer = 2; |
7680 | int idx_in_out = 5; | |
7681 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7682 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7683 | argv[idx_in_out]->arg); | |
718e3744 | 7684 | } |
6b0655a2 | 7685 | |
d62a17ae | 7686 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
7687 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7688 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7689 | "Filter updates to/from this neighbor\n" | |
7690 | "Name of a prefix list\n" | |
7691 | "Filter incoming updates\n" | |
7692 | "Filter outgoing updates\n") | |
596c17ba | 7693 | |
d62a17ae | 7694 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7695 | safi_t safi, const char *name_str, | |
7696 | const char *direct_str) | |
718e3744 | 7697 | { |
d62a17ae | 7698 | int ret; |
7699 | struct peer *peer; | |
7700 | int direct = FILTER_IN; | |
718e3744 | 7701 | |
d62a17ae | 7702 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7703 | if (!peer) | |
7704 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7705 | |
d62a17ae | 7706 | /* Check filter direction. */ |
7707 | if (strncmp(direct_str, "i", 1) == 0) | |
7708 | direct = FILTER_IN; | |
7709 | else if (strncmp(direct_str, "o", 1) == 0) | |
7710 | direct = FILTER_OUT; | |
718e3744 | 7711 | |
d62a17ae | 7712 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7713 | |
d62a17ae | 7714 | return bgp_vty_return(vty, ret); |
718e3744 | 7715 | } |
7716 | ||
d62a17ae | 7717 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7718 | safi_t safi, const char *direct_str) | |
718e3744 | 7719 | { |
d62a17ae | 7720 | int ret; |
7721 | struct peer *peer; | |
7722 | int direct = FILTER_IN; | |
718e3744 | 7723 | |
d62a17ae | 7724 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7725 | if (!peer) | |
7726 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7727 | |
d62a17ae | 7728 | /* Check filter direction. */ |
7729 | if (strncmp(direct_str, "i", 1) == 0) | |
7730 | direct = FILTER_IN; | |
7731 | else if (strncmp(direct_str, "o", 1) == 0) | |
7732 | direct = FILTER_OUT; | |
718e3744 | 7733 | |
d62a17ae | 7734 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7735 | |
d62a17ae | 7736 | return bgp_vty_return(vty, ret); |
718e3744 | 7737 | } |
7738 | ||
7739 | DEFUN (neighbor_filter_list, | |
7740 | neighbor_filter_list_cmd, | |
9ccf14f7 | 7741 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7742 | NEIGHBOR_STR |
7743 | NEIGHBOR_ADDR_STR2 | |
7744 | "Establish BGP filters\n" | |
7745 | "AS path access-list name\n" | |
7746 | "Filter incoming routes\n" | |
7747 | "Filter outgoing routes\n") | |
7748 | { | |
d62a17ae | 7749 | int idx_peer = 1; |
7750 | int idx_word = 3; | |
7751 | int idx_in_out = 4; | |
7752 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7753 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7754 | argv[idx_in_out]->arg); | |
718e3744 | 7755 | } |
7756 | ||
d62a17ae | 7757 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
7758 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7759 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7760 | "Establish BGP filters\n" | |
7761 | "AS path access-list name\n" | |
7762 | "Filter incoming routes\n" | |
7763 | "Filter outgoing routes\n") | |
596c17ba | 7764 | |
718e3744 | 7765 | DEFUN (no_neighbor_filter_list, |
7766 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 7767 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7768 | NO_STR |
7769 | NEIGHBOR_STR | |
7770 | NEIGHBOR_ADDR_STR2 | |
7771 | "Establish BGP filters\n" | |
7772 | "AS path access-list name\n" | |
7773 | "Filter incoming routes\n" | |
7774 | "Filter outgoing routes\n") | |
7775 | { | |
d62a17ae | 7776 | int idx_peer = 2; |
7777 | int idx_in_out = 5; | |
7778 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7779 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7780 | argv[idx_in_out]->arg); | |
718e3744 | 7781 | } |
6b0655a2 | 7782 | |
d62a17ae | 7783 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
7784 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7785 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7786 | "Establish BGP filters\n" | |
7787 | "AS path access-list name\n" | |
7788 | "Filter incoming routes\n" | |
7789 | "Filter outgoing routes\n") | |
596c17ba | 7790 | |
7f7940e6 MK |
7791 | /* Set advertise-map to the peer. */ |
7792 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7793 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7794 | const char *advertise_str, |
7795 | const char *condition_str, bool condition, | |
7796 | bool set) | |
7f7940e6 MK |
7797 | { |
7798 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7799 | struct peer *peer; | |
7800 | struct route_map *advertise_map; | |
7801 | struct route_map *condition_map; | |
7802 | ||
7803 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7804 | if (!peer) | |
7805 | return ret; | |
7806 | ||
7807 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7808 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7809 | ||
cf2ad4d8 MK |
7810 | if (set) |
7811 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7812 | advertise_map, condition_str, | |
7813 | condition_map, condition); | |
7814 | else | |
7815 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7816 | advertise_map, condition_str, | |
7817 | condition_map, condition); | |
7f7940e6 MK |
7818 | |
7819 | return bgp_vty_return(vty, ret); | |
7820 | } | |
7821 | ||
cf2ad4d8 | 7822 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7823 | neighbor_advertise_map_cmd, |
52b84062 | 7824 | "[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 | 7825 | NO_STR |
7f7940e6 MK |
7826 | NEIGHBOR_STR |
7827 | NEIGHBOR_ADDR_STR2 | |
7828 | "Route-map to conditionally advertise routes\n" | |
7829 | "Name of advertise map\n" | |
7830 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7831 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7832 | "Name of the exist or non exist map\n") |
7f7940e6 | 7833 | { |
7f7940e6 MK |
7834 | bool condition = CONDITION_EXIST; |
7835 | ||
52b84062 | 7836 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7837 | condition = CONDITION_NON_EXIST; |
7838 | ||
52b84062 MK |
7839 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7840 | bgp_node_safi(vty), advertise_str, | |
7841 | condition_str, condition, !no); | |
7f7940e6 MK |
7842 | } |
7843 | ||
7844 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
52b84062 | 7845 | "[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 |
7846 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7847 | "Route-map to conditionally advertise routes\n" | |
7848 | "Name of advertise map\n" | |
7849 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7850 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7851 | "Name of the exist or non exist map\n") |
7f7940e6 | 7852 | |
718e3744 | 7853 | /* Set route-map to the peer. */ |
d62a17ae | 7854 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7855 | afi_t afi, safi_t safi, const char *name_str, | |
7856 | const char *direct_str) | |
718e3744 | 7857 | { |
d62a17ae | 7858 | int ret; |
7859 | struct peer *peer; | |
7860 | int direct = RMAP_IN; | |
1de27621 | 7861 | struct route_map *route_map; |
718e3744 | 7862 | |
d62a17ae | 7863 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7864 | if (!peer) | |
7865 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7866 | |
d62a17ae | 7867 | /* Check filter direction. */ |
7868 | if (strncmp(direct_str, "in", 2) == 0) | |
7869 | direct = RMAP_IN; | |
7870 | else if (strncmp(direct_str, "o", 1) == 0) | |
7871 | direct = RMAP_OUT; | |
718e3744 | 7872 | |
1de27621 DA |
7873 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7874 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7875 | |
d62a17ae | 7876 | return bgp_vty_return(vty, ret); |
718e3744 | 7877 | } |
7878 | ||
d62a17ae | 7879 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
7880 | afi_t afi, safi_t safi, | |
7881 | const char *direct_str) | |
718e3744 | 7882 | { |
d62a17ae | 7883 | int ret; |
7884 | struct peer *peer; | |
7885 | int direct = RMAP_IN; | |
718e3744 | 7886 | |
d62a17ae | 7887 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7888 | if (!peer) | |
7889 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7890 | |
d62a17ae | 7891 | /* Check filter direction. */ |
7892 | if (strncmp(direct_str, "in", 2) == 0) | |
7893 | direct = RMAP_IN; | |
7894 | else if (strncmp(direct_str, "o", 1) == 0) | |
7895 | direct = RMAP_OUT; | |
718e3744 | 7896 | |
d62a17ae | 7897 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 7898 | |
d62a17ae | 7899 | return bgp_vty_return(vty, ret); |
718e3744 | 7900 | } |
7901 | ||
7902 | DEFUN (neighbor_route_map, | |
7903 | neighbor_route_map_cmd, | |
9ccf14f7 | 7904 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 7905 | NEIGHBOR_STR |
7906 | NEIGHBOR_ADDR_STR2 | |
7907 | "Apply route map to neighbor\n" | |
7908 | "Name of route map\n" | |
7909 | "Apply map to incoming routes\n" | |
2a3d5731 | 7910 | "Apply map to outbound routes\n") |
718e3744 | 7911 | { |
d62a17ae | 7912 | int idx_peer = 1; |
7913 | int idx_word = 3; | |
7914 | int idx_in_out = 4; | |
7915 | return peer_route_map_set_vty( | |
7916 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7917 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7918 | } |
7919 | ||
d62a17ae | 7920 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
7921 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7922 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7923 | "Apply route map to neighbor\n" | |
7924 | "Name of route map\n" | |
7925 | "Apply map to incoming routes\n" | |
7926 | "Apply map to outbound routes\n") | |
596c17ba | 7927 | |
718e3744 | 7928 | DEFUN (no_neighbor_route_map, |
7929 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 7930 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 7931 | NO_STR |
7932 | NEIGHBOR_STR | |
7933 | NEIGHBOR_ADDR_STR2 | |
7934 | "Apply route map to neighbor\n" | |
7935 | "Name of route map\n" | |
7936 | "Apply map to incoming routes\n" | |
2a3d5731 | 7937 | "Apply map to outbound routes\n") |
718e3744 | 7938 | { |
d62a17ae | 7939 | int idx_peer = 2; |
7940 | int idx_in_out = 5; | |
7941 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7942 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7943 | argv[idx_in_out]->arg); | |
718e3744 | 7944 | } |
6b0655a2 | 7945 | |
d62a17ae | 7946 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
7947 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7948 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7949 | "Apply route map to neighbor\n" | |
7950 | "Name of route map\n" | |
7951 | "Apply map to incoming routes\n" | |
7952 | "Apply map to outbound routes\n") | |
596c17ba | 7953 | |
718e3744 | 7954 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7955 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7956 | afi_t afi, safi_t safi, | |
7957 | const char *name_str) | |
718e3744 | 7958 | { |
d62a17ae | 7959 | int ret; |
7960 | struct peer *peer; | |
1de27621 | 7961 | struct route_map *route_map; |
718e3744 | 7962 | |
d62a17ae | 7963 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7964 | if (!peer) | |
7965 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7966 | |
1de27621 DA |
7967 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7968 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7969 | |
d62a17ae | 7970 | return bgp_vty_return(vty, ret); |
718e3744 | 7971 | } |
7972 | ||
7973 | /* Unset route-map from the peer. */ | |
d62a17ae | 7974 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7975 | afi_t afi, safi_t safi) | |
718e3744 | 7976 | { |
d62a17ae | 7977 | int ret; |
7978 | struct peer *peer; | |
718e3744 | 7979 | |
d62a17ae | 7980 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7981 | if (!peer) | |
7982 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7983 | |
d62a17ae | 7984 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7985 | |
d62a17ae | 7986 | return bgp_vty_return(vty, ret); |
718e3744 | 7987 | } |
7988 | ||
7989 | DEFUN (neighbor_unsuppress_map, | |
7990 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7991 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7992 | NEIGHBOR_STR |
7993 | NEIGHBOR_ADDR_STR2 | |
7994 | "Route-map to selectively unsuppress suppressed routes\n" | |
7995 | "Name of route map\n") | |
7996 | { | |
d62a17ae | 7997 | int idx_peer = 1; |
7998 | int idx_word = 3; | |
7999 | return peer_unsuppress_map_set_vty( | |
8000 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8001 | argv[idx_word]->arg); | |
718e3744 | 8002 | } |
8003 | ||
d62a17ae | 8004 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
8005 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8006 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8007 | "Route-map to selectively unsuppress suppressed routes\n" | |
8008 | "Name of route map\n") | |
596c17ba | 8009 | |
718e3744 | 8010 | DEFUN (no_neighbor_unsuppress_map, |
8011 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8012 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8013 | NO_STR |
8014 | NEIGHBOR_STR | |
8015 | NEIGHBOR_ADDR_STR2 | |
8016 | "Route-map to selectively unsuppress suppressed routes\n" | |
8017 | "Name of route map\n") | |
8018 | { | |
d62a17ae | 8019 | int idx_peer = 2; |
8020 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
8021 | bgp_node_afi(vty), | |
8022 | bgp_node_safi(vty)); | |
718e3744 | 8023 | } |
6b0655a2 | 8024 | |
d62a17ae | 8025 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
8026 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8027 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8028 | "Route-map to selectively unsuppress suppressed routes\n" | |
8029 | "Name of route map\n") | |
596c17ba | 8030 | |
fde246e8 | 8031 | /* Maximum number of prefix to be sent to the neighbor. */ |
232c75cd CS |
8032 | DEFUN_YANG(neighbor_maximum_prefix_out, |
8033 | neighbor_maximum_prefix_out_cmd, | |
8034 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
8035 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8036 | "Maximum number of prefixes to be sent to this peer\n" | |
8037 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8038 | { |
04261dec CS |
8039 | char base_xpath[XPATH_MAXLEN]; |
8040 | char af_xpath[XPATH_MAXLEN]; | |
8041 | char attr_xpath[XPATH_MAXLEN]; | |
fde246e8 DA |
8042 | int idx_peer = 1; |
8043 | int idx_number = 3; | |
fde246e8 DA |
8044 | afi_t afi = bgp_node_afi(vty); |
8045 | safi_t safi = bgp_node_safi(vty); | |
8046 | ||
04261dec CS |
8047 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8048 | yang_afi_safi_value2identity(afi, safi)); | |
8049 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8050 | sizeof(base_xpath), af_xpath) | |
8051 | < 0) | |
fde246e8 DA |
8052 | return CMD_WARNING_CONFIG_FAILED; |
8053 | ||
04261dec CS |
8054 | snprintf(attr_xpath, sizeof(attr_xpath), |
8055 | "/%s/prefix-limit/direction-list[direction='out']", | |
8056 | bgp_afi_safi_get_container_str(afi, safi)); | |
8057 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
fde246e8 | 8058 | |
04261dec | 8059 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
fde246e8 | 8060 | |
04261dec CS |
8061 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, |
8062 | argv[idx_number]->arg); | |
8063 | ||
8064 | return nb_cli_apply_changes(vty, base_xpath); | |
fde246e8 DA |
8065 | } |
8066 | ||
232c75cd CS |
8067 | DEFUN_YANG(no_neighbor_maximum_prefix_out, |
8068 | no_neighbor_maximum_prefix_out_cmd, | |
8069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
8070 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8071 | "Maximum number of prefixes to be sent to this peer\n") | |
fde246e8 | 8072 | { |
04261dec CS |
8073 | char base_xpath[XPATH_MAXLEN]; |
8074 | char af_xpath[XPATH_MAXLEN]; | |
8075 | char attr_xpath[XPATH_MAXLEN]; | |
fde246e8 | 8076 | int idx_peer = 2; |
fde246e8 DA |
8077 | afi_t afi = bgp_node_afi(vty); |
8078 | safi_t safi = bgp_node_safi(vty); | |
8079 | ||
04261dec CS |
8080 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8081 | yang_afi_safi_value2identity(afi, safi)); | |
8082 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8083 | sizeof(base_xpath), af_xpath) | |
8084 | < 0) | |
fde246e8 DA |
8085 | return CMD_WARNING_CONFIG_FAILED; |
8086 | ||
04261dec CS |
8087 | snprintf(attr_xpath, sizeof(attr_xpath), |
8088 | "/%s/prefix-limit/direction-list[direction='out']", | |
8089 | bgp_afi_safi_get_container_str(afi, safi)); | |
8090 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8091 | ||
8092 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
fde246e8 | 8093 | |
04261dec | 8094 | return nb_cli_apply_changes(vty, base_xpath); |
fde246e8 DA |
8095 | } |
8096 | ||
9cbd06e0 DA |
8097 | /* Maximum number of prefix configuration. Prefix count is different |
8098 | for each peer configuration. So this configuration can be set for | |
718e3744 | 8099 | each peer configuration. */ |
232c75cd CS |
8100 | DEFUN_YANG(neighbor_maximum_prefix, |
8101 | neighbor_maximum_prefix_cmd, | |
8102 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
8103 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8104 | "Maximum number of prefix accept from this peer\n" | |
8105 | "maximum no. of prefix limit\n" | |
8106 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8107 | { |
d62a17ae | 8108 | int idx_peer = 1; |
8109 | int idx_number = 3; | |
9cbd06e0 | 8110 | int idx_force = 0; |
04261dec CS |
8111 | char base_xpath[XPATH_MAXLEN]; |
8112 | char af_xpath[XPATH_MAXLEN]; | |
8113 | char attr_xpath[XPATH_MAXLEN]; | |
8114 | afi_t afi = bgp_node_afi(vty); | |
8115 | safi_t safi = bgp_node_safi(vty); | |
8116 | ||
8117 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8118 | yang_afi_safi_value2identity(afi, safi)); | |
8119 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8120 | sizeof(base_xpath), af_xpath) | |
8121 | < 0) | |
8122 | return CMD_WARNING_CONFIG_FAILED; | |
8123 | ||
8124 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8125 | "/%s/prefix-limit/direction-list[direction='in']", | |
8126 | bgp_afi_safi_get_container_str(afi, safi)); | |
8127 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8128 | ||
8129 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
9cbd06e0 | 8130 | |
04261dec CS |
8131 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, |
8132 | argv[idx_number]->arg); | |
9cbd06e0 | 8133 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8134 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8135 | "true"); | |
9cbd06e0 | 8136 | |
04261dec | 8137 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8138 | } |
8139 | ||
d62a17ae | 8140 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 8141 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 8142 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8143 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
8144 | "maximum no. of prefix limit\n" |
8145 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8146 | |
232c75cd CS |
8147 | DEFUN_YANG(neighbor_maximum_prefix_threshold, |
8148 | neighbor_maximum_prefix_threshold_cmd, | |
8149 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
8150 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8151 | "Maximum number of prefix accept from this peer\n" | |
8152 | "maximum no. of prefix limit\n" | |
8153 | "Threshold value (%) at which to generate a warning msg\n" | |
8154 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8155 | { |
d62a17ae | 8156 | int idx_peer = 1; |
8157 | int idx_number = 3; | |
8158 | int idx_number_2 = 4; | |
9cbd06e0 | 8159 | int idx_force = 0; |
04261dec CS |
8160 | char base_xpath[XPATH_MAXLEN]; |
8161 | char af_xpath[XPATH_MAXLEN]; | |
8162 | char attr_xpath[XPATH_MAXLEN]; | |
8163 | afi_t afi = bgp_node_afi(vty); | |
8164 | safi_t safi = bgp_node_safi(vty); | |
8165 | ||
8166 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8167 | yang_afi_safi_value2identity(afi, safi)); | |
8168 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8169 | sizeof(base_xpath), af_xpath) | |
8170 | < 0) | |
8171 | return CMD_WARNING_CONFIG_FAILED; | |
8172 | ||
8173 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8174 | "/%s/prefix-limit/direction-list[direction='in']", | |
8175 | bgp_afi_safi_get_container_str(afi, safi)); | |
8176 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8177 | ||
8178 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8179 | ||
8180 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8181 | argv[idx_number]->arg); | |
8182 | ||
8183 | nb_cli_enqueue_change(vty, "./options/shutdown-threshold-pct", | |
8184 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
9cbd06e0 DA |
8185 | |
8186 | if (argv_find(argv, argc, "force", &idx_force)) | |
04261dec CS |
8187 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8188 | "true"); | |
9cbd06e0 | 8189 | |
04261dec | 8190 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8191 | } |
e0701b79 | 8192 | |
d62a17ae | 8193 | ALIAS_HIDDEN( |
8194 | neighbor_maximum_prefix_threshold, | |
8195 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 8196 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 8197 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8198 | "Maximum number of prefix accept from this peer\n" | |
8199 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8200 | "Threshold value (%) at which to generate a warning msg\n" |
8201 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8202 | |
232c75cd CS |
8203 | DEFUN_YANG(neighbor_maximum_prefix_warning, |
8204 | neighbor_maximum_prefix_warning_cmd, | |
8205 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
8206 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8207 | "Maximum number of prefix accept from this peer\n" | |
8208 | "maximum no. of prefix limit\n" | |
8209 | "Only give warning message when limit is exceeded\n" | |
8210 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8211 | { |
d62a17ae | 8212 | int idx_peer = 1; |
8213 | int idx_number = 3; | |
9cbd06e0 | 8214 | int idx_force = 0; |
04261dec CS |
8215 | char base_xpath[XPATH_MAXLEN]; |
8216 | char af_xpath[XPATH_MAXLEN]; | |
8217 | char attr_xpath[XPATH_MAXLEN]; | |
8218 | afi_t afi = bgp_node_afi(vty); | |
8219 | safi_t safi = bgp_node_safi(vty); | |
8220 | ||
8221 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8222 | yang_afi_safi_value2identity(afi, safi)); | |
8223 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8224 | sizeof(base_xpath), af_xpath) | |
8225 | < 0) | |
8226 | return CMD_WARNING_CONFIG_FAILED; | |
9cbd06e0 | 8227 | |
04261dec CS |
8228 | snprintf(attr_xpath, sizeof(attr_xpath), |
8229 | "/%s/prefix-limit/direction-list[direction='in']", | |
8230 | bgp_afi_safi_get_container_str(afi, safi)); | |
8231 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8232 | ||
8233 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8234 | ||
8235 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8236 | argv[idx_number]->arg); | |
8237 | ||
8238 | nb_cli_enqueue_change(vty, "./options/warning-only", NB_OP_MODIFY, | |
8239 | "true"); | |
9cbd06e0 | 8240 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8241 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8242 | "true"); | |
9cbd06e0 | 8243 | |
04261dec | 8244 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8245 | } |
8246 | ||
d62a17ae | 8247 | ALIAS_HIDDEN( |
8248 | neighbor_maximum_prefix_warning, | |
8249 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 8250 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 8251 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8252 | "Maximum number of prefix accept from this peer\n" | |
8253 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8254 | "Only give warning message when limit is exceeded\n" |
8255 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8256 | |
232c75cd CS |
8257 | DEFUN_YANG(neighbor_maximum_prefix_threshold_warning, |
8258 | neighbor_maximum_prefix_threshold_warning_cmd, | |
8259 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
8260 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8261 | "Maximum number of prefix accept from this peer\n" | |
8262 | "maximum no. of prefix limit\n" | |
8263 | "Threshold value (%) at which to generate a warning msg\n" | |
8264 | "Only give warning message when limit is exceeded\n" | |
8265 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8266 | { |
d62a17ae | 8267 | int idx_peer = 1; |
8268 | int idx_number = 3; | |
8269 | int idx_number_2 = 4; | |
9cbd06e0 | 8270 | int idx_force = 0; |
04261dec CS |
8271 | char base_xpath[XPATH_MAXLEN]; |
8272 | char af_xpath[XPATH_MAXLEN]; | |
8273 | char attr_xpath[XPATH_MAXLEN]; | |
8274 | afi_t afi = bgp_node_afi(vty); | |
8275 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8276 | |
04261dec CS |
8277 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8278 | yang_afi_safi_value2identity(afi, safi)); | |
8279 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8280 | sizeof(base_xpath), af_xpath) | |
8281 | < 0) | |
8282 | return CMD_WARNING_CONFIG_FAILED; | |
8283 | ||
8284 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8285 | "/%s/prefix-limit/direction-list[direction='in']", | |
8286 | bgp_afi_safi_get_container_str(afi, safi)); | |
8287 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8288 | ||
8289 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8290 | ||
8291 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8292 | argv[idx_number]->arg); | |
8293 | nb_cli_enqueue_change(vty, "./options/tw-shutdown-threshold-pct", | |
8294 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
8295 | nb_cli_enqueue_change(vty, "./options/tw-warning-only", NB_OP_MODIFY, | |
8296 | "true"); | |
9cbd06e0 | 8297 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8298 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8299 | "true"); | |
9cbd06e0 | 8300 | |
04261dec | 8301 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8302 | } |
8303 | ||
d62a17ae | 8304 | ALIAS_HIDDEN( |
8305 | neighbor_maximum_prefix_threshold_warning, | |
8306 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 8307 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 8308 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8309 | "Maximum number of prefix accept from this peer\n" | |
8310 | "maximum no. of prefix limit\n" | |
8311 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
8312 | "Only give warning message when limit is exceeded\n" |
8313 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8314 | |
232c75cd CS |
8315 | DEFUN_YANG(neighbor_maximum_prefix_restart, |
8316 | neighbor_maximum_prefix_restart_cmd, | |
8317 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
8318 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8319 | "Maximum number of prefix accept from this peer\n" | |
8320 | "maximum no. of prefix limit\n" | |
8321 | "Restart bgp connection after limit is exceeded\n" | |
8322 | "Restart interval in minutes\n" | |
8323 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8324 | { |
d62a17ae | 8325 | int idx_peer = 1; |
8326 | int idx_number = 3; | |
8327 | int idx_number_2 = 5; | |
9cbd06e0 | 8328 | int idx_force = 0; |
04261dec CS |
8329 | char base_xpath[XPATH_MAXLEN]; |
8330 | char af_xpath[XPATH_MAXLEN]; | |
8331 | char attr_xpath[XPATH_MAXLEN]; | |
8332 | afi_t afi = bgp_node_afi(vty); | |
8333 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8334 | |
04261dec CS |
8335 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8336 | yang_afi_safi_value2identity(afi, safi)); | |
8337 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8338 | sizeof(base_xpath), af_xpath) | |
8339 | < 0) | |
8340 | return CMD_WARNING_CONFIG_FAILED; | |
8341 | ||
8342 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8343 | "/%s/prefix-limit/direction-list[direction='in']", | |
8344 | bgp_afi_safi_get_container_str(afi, safi)); | |
8345 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8346 | ||
8347 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8348 | ||
8349 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8350 | argv[idx_number]->arg); | |
8351 | nb_cli_enqueue_change(vty, "./options/restart-timer", NB_OP_MODIFY, | |
8352 | argv[idx_number_2]->arg); | |
9cbd06e0 | 8353 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8354 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8355 | "true"); | |
9cbd06e0 | 8356 | |
04261dec | 8357 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8358 | } |
8359 | ||
d62a17ae | 8360 | ALIAS_HIDDEN( |
8361 | neighbor_maximum_prefix_restart, | |
8362 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 8363 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 8364 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8365 | "Maximum number of prefix accept from this peer\n" | |
8366 | "maximum no. of prefix limit\n" | |
8367 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8368 | "Restart interval in minutes\n" |
8369 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8370 | |
232c75cd CS |
8371 | DEFUN_YANG(neighbor_maximum_prefix_threshold_restart, |
8372 | neighbor_maximum_prefix_threshold_restart_cmd, | |
8373 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
8374 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8375 | "Maximum number of prefixes to accept from this peer\n" | |
8376 | "maximum no. of prefix limit\n" | |
8377 | "Threshold value (%) at which to generate a warning msg\n" | |
8378 | "Restart bgp connection after limit is exceeded\n" | |
8379 | "Restart interval in minutes\n" | |
8380 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8381 | { |
d62a17ae | 8382 | int idx_peer = 1; |
8383 | int idx_number = 3; | |
8384 | int idx_number_2 = 4; | |
8385 | int idx_number_3 = 6; | |
9cbd06e0 | 8386 | int idx_force = 0; |
04261dec CS |
8387 | char base_xpath[XPATH_MAXLEN]; |
8388 | char af_xpath[XPATH_MAXLEN]; | |
8389 | char attr_xpath[XPATH_MAXLEN]; | |
8390 | afi_t afi = bgp_node_afi(vty); | |
8391 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8392 | |
04261dec CS |
8393 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8394 | yang_afi_safi_value2identity(afi, safi)); | |
8395 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8396 | sizeof(base_xpath), af_xpath) | |
8397 | < 0) | |
8398 | return CMD_WARNING_CONFIG_FAILED; | |
8399 | ||
8400 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8401 | "/%s/prefix-limit/direction-list[direction='in']", | |
8402 | bgp_afi_safi_get_container_str(afi, safi)); | |
8403 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8404 | ||
8405 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8406 | ||
8407 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8408 | argv[idx_number]->arg); | |
8409 | nb_cli_enqueue_change(vty, "./options/tr-shutdown-threshold-pct", | |
8410 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
8411 | nb_cli_enqueue_change(vty, "./options/tr-restart-timer", NB_OP_MODIFY, | |
8412 | argv[idx_number_3]->arg); | |
9cbd06e0 | 8413 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8414 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8415 | "true"); | |
9cbd06e0 | 8416 | |
04261dec | 8417 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 8418 | } |
8419 | ||
8420 | ALIAS_HIDDEN( | |
8421 | neighbor_maximum_prefix_threshold_restart, | |
8422 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 8423 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 8424 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8425 | "Maximum number of prefixes to accept from this peer\n" | |
8426 | "maximum no. of prefix limit\n" | |
8427 | "Threshold value (%) at which to generate a warning msg\n" | |
8428 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8429 | "Restart interval in minutes\n" |
8430 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8431 | |
232c75cd CS |
8432 | DEFUN_YANG(no_neighbor_maximum_prefix, |
8433 | no_neighbor_maximum_prefix_cmd, | |
8434 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
8435 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8436 | "Maximum number of prefixes to accept from this peer\n" | |
8437 | "maximum no. of prefix limit\n" | |
8438 | "Threshold value (%) at which to generate a warning msg\n" | |
8439 | "Restart bgp connection after limit is exceeded\n" | |
8440 | "Restart interval in minutes\n" | |
8441 | "Only give warning message when limit is exceeded\n" | |
8442 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8443 | { |
d62a17ae | 8444 | int idx_peer = 2; |
04261dec CS |
8445 | char base_xpath[XPATH_MAXLEN]; |
8446 | char af_xpath[XPATH_MAXLEN]; | |
8447 | char attr_xpath[XPATH_MAXLEN]; | |
8448 | afi_t afi = bgp_node_afi(vty); | |
8449 | safi_t safi = bgp_node_safi(vty); | |
8450 | ||
8451 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8452 | yang_afi_safi_value2identity(afi, safi)); | |
8453 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8454 | sizeof(base_xpath), af_xpath) | |
8455 | < 0) | |
8456 | return CMD_WARNING_CONFIG_FAILED; | |
8457 | ||
8458 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8459 | "/%s/prefix-limit/direction-list[direction='in']", | |
8460 | bgp_afi_safi_get_container_str(afi, safi)); | |
8461 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8462 | ||
8463 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
8464 | ||
8465 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 8466 | } |
e52702f2 | 8467 | |
d62a17ae | 8468 | ALIAS_HIDDEN( |
8469 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 8470 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 8471 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8472 | "Maximum number of prefixes to accept from this peer\n" | |
8473 | "maximum no. of prefix limit\n" | |
8474 | "Threshold value (%) at which to generate a warning msg\n" | |
8475 | "Restart bgp connection after limit is exceeded\n" | |
8476 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
8477 | "Only give warning message when limit is exceeded\n" |
8478 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8479 | |
718e3744 | 8480 | |
718e3744 | 8481 | /* "neighbor allowas-in" */ |
8482 | DEFUN (neighbor_allowas_in, | |
8483 | neighbor_allowas_in_cmd, | |
fd8503f5 | 8484 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8485 | NEIGHBOR_STR |
8486 | NEIGHBOR_ADDR_STR2 | |
31500417 | 8487 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 8488 | "Number of occurrences of AS number\n" |
fd8503f5 | 8489 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8490 | { |
d62a17ae | 8491 | int idx_peer = 1; |
8492 | int idx_number_origin = 3; | |
8493 | int ret; | |
8494 | int origin = 0; | |
8495 | struct peer *peer; | |
8496 | int allow_num = 0; | |
8497 | ||
8498 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8499 | if (!peer) | |
8500 | return CMD_WARNING_CONFIG_FAILED; | |
8501 | ||
8502 | if (argc <= idx_number_origin) | |
8503 | allow_num = 3; | |
8504 | else { | |
8505 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8506 | origin = 1; | |
8507 | else | |
8508 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8509 | } | |
8510 | ||
8511 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8512 | allow_num, origin); | |
8513 | ||
8514 | return bgp_vty_return(vty, ret); | |
8515 | } | |
8516 | ||
8517 | ALIAS_HIDDEN( | |
8518 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8519 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8520 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8521 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 8522 | "Number of occurrences of AS number\n" |
d62a17ae | 8523 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8524 | |
718e3744 | 8525 | DEFUN (no_neighbor_allowas_in, |
8526 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8527 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8528 | NO_STR |
8529 | NEIGHBOR_STR | |
8530 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8531 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8532 | "Number of occurrences of AS number\n" |
fd8503f5 | 8533 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8534 | { |
d62a17ae | 8535 | int idx_peer = 2; |
8536 | int ret; | |
8537 | struct peer *peer; | |
718e3744 | 8538 | |
d62a17ae | 8539 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8540 | if (!peer) | |
8541 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8542 | |
d62a17ae | 8543 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8544 | bgp_node_safi(vty)); | |
718e3744 | 8545 | |
d62a17ae | 8546 | return bgp_vty_return(vty, ret); |
718e3744 | 8547 | } |
6b0655a2 | 8548 | |
d62a17ae | 8549 | ALIAS_HIDDEN( |
8550 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8551 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8552 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8553 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8554 | "Number of occurrences of AS number\n" |
d62a17ae | 8555 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8556 | |
f4b8ec07 CS |
8557 | DEFUN_YANG (neighbor_ttl_security, |
8558 | neighbor_ttl_security_cmd, | |
8559 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8560 | NEIGHBOR_STR | |
8561 | NEIGHBOR_ADDR_STR2 | |
8562 | "BGP ttl-security parameters\n" | |
8563 | "Specify the maximum number of hops to the BGP peer\n" | |
8564 | "Number of hops to BGP peer\n") | |
fa411a21 | 8565 | { |
d62a17ae | 8566 | int idx_peer = 1; |
8567 | int idx_number = 4; | |
f4b8ec07 | 8568 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 8569 | |
f4b8ec07 CS |
8570 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
8571 | sizeof(base_xpath), NULL) | |
8572 | < 0) | |
d62a17ae | 8573 | return CMD_WARNING_CONFIG_FAILED; |
8574 | ||
f4b8ec07 CS |
8575 | nb_cli_enqueue_change(vty, "./ttl-security", NB_OP_MODIFY, |
8576 | argv[idx_number]->arg); | |
7ebe625c | 8577 | |
f4b8ec07 | 8578 | return nb_cli_apply_changes(vty, base_xpath); |
fa411a21 NH |
8579 | } |
8580 | ||
232c75cd CS |
8581 | DEFUN_YANG(no_neighbor_ttl_security, |
8582 | no_neighbor_ttl_security_cmd, | |
8583 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8584 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8585 | "BGP ttl-security parameters\n" | |
8586 | "Specify the maximum number of hops to the BGP peer\n" | |
8587 | "Number of hops to BGP peer\n") | |
fa411a21 | 8588 | { |
d62a17ae | 8589 | int idx_peer = 2; |
f4b8ec07 | 8590 | char base_xpath[XPATH_MAXLEN]; |
fa411a21 | 8591 | |
f4b8ec07 CS |
8592 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
8593 | sizeof(base_xpath), NULL) | |
8594 | < 0) | |
d62a17ae | 8595 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8596 | |
f4b8ec07 CS |
8597 | nb_cli_enqueue_change(vty, "./ttl-security", NB_OP_DESTROY, NULL); |
8598 | ||
8599 | return nb_cli_apply_changes(vty, base_xpath); | |
fa411a21 | 8600 | } |
6b0655a2 | 8601 | |
adbac85e DW |
8602 | DEFUN (neighbor_addpath_tx_all_paths, |
8603 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8604 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8605 | NEIGHBOR_STR |
8606 | NEIGHBOR_ADDR_STR2 | |
8607 | "Use addpath to advertise all paths to a neighbor\n") | |
8608 | { | |
d62a17ae | 8609 | int idx_peer = 1; |
8610 | struct peer *peer; | |
adbac85e | 8611 | |
d62a17ae | 8612 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8613 | if (!peer) | |
8614 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8615 | |
dcc68b5e MS |
8616 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8617 | BGP_ADDPATH_ALL); | |
8618 | return CMD_SUCCESS; | |
adbac85e DW |
8619 | } |
8620 | ||
d62a17ae | 8621 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8622 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8623 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8624 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8625 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8626 | |
adbac85e DW |
8627 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8628 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8629 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8630 | NO_STR |
8631 | NEIGHBOR_STR | |
8632 | NEIGHBOR_ADDR_STR2 | |
8633 | "Use addpath to advertise all paths to a neighbor\n") | |
8634 | { | |
d62a17ae | 8635 | int idx_peer = 2; |
dcc68b5e MS |
8636 | struct peer *peer; |
8637 | ||
8638 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8639 | if (!peer) | |
8640 | return CMD_WARNING_CONFIG_FAILED; | |
8641 | ||
8642 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8643 | != BGP_ADDPATH_ALL) { | |
8644 | vty_out(vty, | |
8645 | "%% Peer not currently configured to transmit all paths."); | |
8646 | return CMD_WARNING_CONFIG_FAILED; | |
8647 | } | |
8648 | ||
8649 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8650 | BGP_ADDPATH_NONE); | |
8651 | ||
8652 | return CMD_SUCCESS; | |
adbac85e DW |
8653 | } |
8654 | ||
d62a17ae | 8655 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8656 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8657 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8658 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8659 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8660 | |
06370dac DW |
8661 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8662 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8663 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8664 | NEIGHBOR_STR |
8665 | NEIGHBOR_ADDR_STR2 | |
8666 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8667 | { | |
d62a17ae | 8668 | int idx_peer = 1; |
8669 | struct peer *peer; | |
06370dac | 8670 | |
d62a17ae | 8671 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8672 | if (!peer) | |
8673 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8674 | |
dcc68b5e MS |
8675 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8676 | BGP_ADDPATH_BEST_PER_AS); | |
8677 | ||
8678 | return CMD_SUCCESS; | |
06370dac DW |
8679 | } |
8680 | ||
d62a17ae | 8681 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8682 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8683 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8684 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8685 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8686 | |
06370dac DW |
8687 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8688 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8689 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8690 | NO_STR |
8691 | NEIGHBOR_STR | |
8692 | NEIGHBOR_ADDR_STR2 | |
8693 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8694 | { | |
d62a17ae | 8695 | int idx_peer = 2; |
dcc68b5e MS |
8696 | struct peer *peer; |
8697 | ||
8698 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8699 | if (!peer) | |
8700 | return CMD_WARNING_CONFIG_FAILED; | |
8701 | ||
8702 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8703 | != BGP_ADDPATH_BEST_PER_AS) { | |
8704 | vty_out(vty, | |
8705 | "%% Peer not currently configured to transmit all best path per as."); | |
8706 | return CMD_WARNING_CONFIG_FAILED; | |
8707 | } | |
8708 | ||
8709 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8710 | BGP_ADDPATH_NONE); | |
8711 | ||
8712 | return CMD_SUCCESS; | |
06370dac DW |
8713 | } |
8714 | ||
d62a17ae | 8715 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8716 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8717 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8718 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8719 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8720 | |
2b31007c RZ |
8721 | DEFPY( |
8722 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8723 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8724 | NEIGHBOR_STR | |
8725 | NEIGHBOR_ADDR_STR2 | |
8726 | "Detect AS loops before sending to neighbor\n") | |
8727 | { | |
8728 | struct peer *peer; | |
8729 | ||
8730 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8731 | if (!peer) | |
8732 | return CMD_WARNING_CONFIG_FAILED; | |
8733 | ||
8734 | peer->as_path_loop_detection = true; | |
8735 | ||
8736 | return CMD_SUCCESS; | |
8737 | } | |
8738 | ||
8739 | DEFPY( | |
8740 | no_neighbor_aspath_loop_detection, | |
8741 | no_neighbor_aspath_loop_detection_cmd, | |
8742 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8743 | NO_STR | |
8744 | NEIGHBOR_STR | |
8745 | NEIGHBOR_ADDR_STR2 | |
8746 | "Detect AS loops before sending to neighbor\n") | |
8747 | { | |
8748 | struct peer *peer; | |
8749 | ||
8750 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8751 | if (!peer) | |
8752 | return CMD_WARNING_CONFIG_FAILED; | |
8753 | ||
8754 | peer->as_path_loop_detection = false; | |
8755 | ||
8756 | return CMD_SUCCESS; | |
8757 | } | |
8758 | ||
b9c7bc5a | 8759 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8760 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8761 | { |
b9c7bc5a PZ |
8762 | struct ecommunity *ecom = NULL; |
8763 | struct ecommunity *ecomadd; | |
ddb5b488 | 8764 | |
b9c7bc5a | 8765 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8766 | if (is_rt6) |
8767 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8768 | ECOMMUNITY_ROUTE_TARGET, | |
8769 | 0); | |
8770 | else | |
8771 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8772 | ECOMMUNITY_ROUTE_TARGET, | |
8773 | 0); | |
b9c7bc5a PZ |
8774 | if (!ecomadd) { |
8775 | vty_out(vty, "Malformed community-list value\n"); | |
8776 | if (ecom) | |
8777 | ecommunity_free(&ecom); | |
8778 | return CMD_WARNING_CONFIG_FAILED; | |
8779 | } | |
ddb5b488 | 8780 | |
b9c7bc5a PZ |
8781 | if (ecom) { |
8782 | ecommunity_merge(ecom, ecomadd); | |
8783 | ecommunity_free(&ecomadd); | |
8784 | } else { | |
8785 | ecom = ecomadd; | |
8786 | } | |
8787 | } | |
8788 | ||
8789 | if (*list) { | |
8790 | ecommunity_free(&*list); | |
ddb5b488 | 8791 | } |
b9c7bc5a PZ |
8792 | *list = ecom; |
8793 | ||
8794 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8795 | } |
8796 | ||
37a87b8f CS |
8797 | bool vpn_policy_check_import(struct bgp *bgp, afi_t afi, safi_t safi, |
8798 | bool v2vimport, char *errmsg, size_t errmsg_len) | |
8799 | { | |
8800 | if (!v2vimport) { | |
8801 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8802 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8803 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8804 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8805 | snprintf( | |
8806 | errmsg, errmsg_len, "%s", | |
8807 | "%% error: Please unconfigure import vrf commands before using vpn commands"); | |
8808 | return false; | |
8809 | } | |
8810 | } else { | |
8811 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8812 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8813 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8814 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8815 | snprintf( | |
8816 | errmsg, errmsg_len, "%s", | |
8817 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands"); | |
8818 | return false; | |
8819 | } | |
8820 | } | |
8821 | return true; | |
8822 | } | |
8823 | ||
0ca70ba5 DS |
8824 | /* |
8825 | * v2vimport is true if we are handling a `import vrf ...` command | |
8826 | */ | |
8827 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8828 | { |
0ca70ba5 DS |
8829 | afi_t afi; |
8830 | ||
ddb5b488 | 8831 | switch (vty->node) { |
b9c7bc5a | 8832 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8833 | afi = AFI_IP; |
8834 | break; | |
b9c7bc5a | 8835 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8836 | afi = AFI_IP6; |
8837 | break; | |
ddb5b488 PZ |
8838 | default: |
8839 | vty_out(vty, | |
b9c7bc5a | 8840 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8841 | return AFI_MAX; |
ddb5b488 | 8842 | } |
69b07479 | 8843 | |
0ca70ba5 DS |
8844 | if (!v2vimport) { |
8845 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8846 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8847 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8848 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8849 | vty_out(vty, | |
8850 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8851 | return AFI_MAX; | |
8852 | } | |
8853 | } else { | |
8854 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8855 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8856 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8857 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8858 | vty_out(vty, | |
8859 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8860 | return AFI_MAX; | |
8861 | } | |
8862 | } | |
8863 | return afi; | |
ddb5b488 PZ |
8864 | } |
8865 | ||
37a87b8f CS |
8866 | DEFPY_YANG( |
8867 | af_rd_vpn_export, | |
8868 | af_rd_vpn_export_cmd, | |
8869 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8870 | NO_STR | |
8871 | "Specify route distinguisher\n" | |
8872 | "Between current address-family and vpn\n" | |
8873 | "For routes leaked from current address-family to vpn\n" | |
8874 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8875 | { |
37a87b8f | 8876 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 8877 | afi_t afi; |
37a87b8f | 8878 | safi_t safi; |
b9c7bc5a | 8879 | int idx = 0; |
b9c7bc5a | 8880 | |
37a87b8f CS |
8881 | afi = bgp_node_afi(vty); |
8882 | safi = bgp_node_safi(vty); | |
ddb5b488 | 8883 | |
37a87b8f CS |
8884 | snprintf( |
8885 | base_xpath, sizeof(base_xpath), | |
8886 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
8887 | yang_afi_safi_value2identity(afi, safi), | |
8888 | bgp_afi_safi_get_container_str(afi, safi)); | |
ddb5b488 | 8889 | |
37a87b8f CS |
8890 | if (argv_find(argv, argc, "no", &idx)) |
8891 | nb_cli_enqueue_change(vty, "./rd", NB_OP_DESTROY, NULL); | |
8892 | else | |
8893 | nb_cli_enqueue_change(vty, "./rd", NB_OP_MODIFY, rd_str); | |
ddb5b488 | 8894 | |
37a87b8f CS |
8895 | return nb_cli_apply_changes(vty, base_xpath); |
8896 | } | |
ddb5b488 | 8897 | |
37a87b8f CS |
8898 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd( |
8899 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
8900 | { | |
8901 | int indent = 2; | |
69b07479 | 8902 | |
37a87b8f CS |
8903 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
8904 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
8905 | } |
8906 | ||
b9c7bc5a PZ |
8907 | ALIAS (af_rd_vpn_export, |
8908 | af_no_rd_vpn_export_cmd, | |
8909 | "no rd vpn export", | |
ddb5b488 | 8910 | NO_STR |
b9c7bc5a PZ |
8911 | "Specify route distinguisher\n" |
8912 | "Between current address-family and vpn\n" | |
8913 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8914 | |
b9c7bc5a PZ |
8915 | DEFPY (af_label_vpn_export, |
8916 | af_label_vpn_export_cmd, | |
e70e9f8e | 8917 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8918 | NO_STR |
ddb5b488 | 8919 | "label value for VRF\n" |
b9c7bc5a PZ |
8920 | "Between current address-family and vpn\n" |
8921 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8922 | "Label Value <0-1048575>\n" |
8923 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8924 | { |
8925 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8926 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8927 | afi_t afi; |
b9c7bc5a | 8928 | int idx = 0; |
c6423c31 | 8929 | bool yes = true; |
b9c7bc5a PZ |
8930 | |
8931 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8932 | yes = false; |
ddb5b488 | 8933 | |
21a16cc2 PZ |
8934 | /* If "no ...", squash trailing parameter */ |
8935 | if (!yes) | |
8936 | label_auto = NULL; | |
8937 | ||
e70e9f8e PZ |
8938 | if (yes) { |
8939 | if (!label_auto) | |
8940 | label = label_val; /* parser should force unsigned */ | |
8941 | } | |
ddb5b488 | 8942 | |
0ca70ba5 | 8943 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8944 | if (afi == AFI_MAX) |
8945 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8946 | |
e70e9f8e | 8947 | |
69b07479 DS |
8948 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8949 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8950 | /* no change */ | |
8951 | return CMD_SUCCESS; | |
e70e9f8e | 8952 | |
69b07479 DS |
8953 | /* |
8954 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8955 | */ | |
8956 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8957 | bgp_get_default(), bgp); | |
8958 | ||
8959 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8960 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8961 | ||
8962 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8963 | ||
8964 | /* | |
8965 | * label has previously been automatically | |
8966 | * assigned by labelpool: release it | |
8967 | * | |
8968 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8969 | * means the automatic assignment is in flight | |
8970 | * and therefore the labelpool callback must | |
8971 | * detect that the auto label is not needed. | |
8972 | */ | |
8973 | ||
8974 | bgp_lp_release(LP_TYPE_VRF, | |
8975 | &bgp->vpn_policy[afi], | |
8976 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8977 | } |
69b07479 DS |
8978 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8979 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8980 | } | |
ddb5b488 | 8981 | |
69b07479 DS |
8982 | bgp->vpn_policy[afi].tovpn_label = label; |
8983 | if (label_auto) { | |
8984 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8985 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8986 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8987 | vpn_leak_label_callback); | |
ddb5b488 PZ |
8988 | } |
8989 | ||
69b07479 DS |
8990 | /* post-change: re-export vpn routes */ |
8991 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8992 | bgp_get_default(), bgp); | |
8993 | ||
ddb5b488 PZ |
8994 | return CMD_SUCCESS; |
8995 | } | |
8996 | ||
b9c7bc5a PZ |
8997 | ALIAS (af_label_vpn_export, |
8998 | af_no_label_vpn_export_cmd, | |
8999 | "no label vpn export", | |
9000 | NO_STR | |
9001 | "label value for VRF\n" | |
9002 | "Between current address-family and vpn\n" | |
9003 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9004 | |
37a87b8f | 9005 | DEFPY_YANG (af_nexthop_vpn_export, |
b9c7bc5a | 9006 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 9007 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 9008 | NO_STR |
ddb5b488 | 9009 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
9010 | "Between current address-family and vpn\n" |
9011 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9012 | "IPv4 prefix\n" |
9013 | "IPv6 prefix\n") | |
9014 | { | |
37a87b8f | 9015 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9016 | afi_t afi; |
37a87b8f CS |
9017 | safi_t safi; |
9018 | int idx = 0; | |
ddb5b488 PZ |
9019 | struct prefix p; |
9020 | ||
8c85ca28 QY |
9021 | if (!no) { |
9022 | if (!nexthop_su) { | |
9023 | vty_out(vty, "%% Nexthop required\n"); | |
9024 | return CMD_WARNING_CONFIG_FAILED; | |
9025 | } | |
8c85ca28 | 9026 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
9027 | return CMD_WARNING_CONFIG_FAILED; |
9028 | } | |
ddb5b488 | 9029 | |
37a87b8f CS |
9030 | afi = bgp_node_afi(vty); |
9031 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9032 | |
37a87b8f CS |
9033 | snprintf( |
9034 | base_xpath, sizeof(base_xpath), | |
9035 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9036 | yang_afi_safi_value2identity(afi, safi), | |
9037 | bgp_afi_safi_get_container_str(afi, safi)); | |
ddb5b488 | 9038 | |
37a87b8f CS |
9039 | if (argv_find(argv, argc, "no", &idx)) |
9040 | nb_cli_enqueue_change(vty, "./nexthop", NB_OP_DESTROY, NULL); | |
9041 | else | |
9042 | nb_cli_enqueue_change(vty, "./nexthop", NB_OP_MODIFY, | |
9043 | nexthop_su_str); | |
ddb5b488 | 9044 | |
37a87b8f CS |
9045 | return nb_cli_apply_changes(vty, base_xpath); |
9046 | } | |
69b07479 | 9047 | |
37a87b8f CS |
9048 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop( |
9049 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9050 | { | |
9051 | int indent = 2; | |
9052 | ||
9053 | vty_out(vty, "%*snexthop vpn export %s\n", indent, "", | |
9054 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9055 | } |
9056 | ||
b9c7bc5a | 9057 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 9058 | { |
b9c7bc5a PZ |
9059 | if (!strcmp(dstr, "import")) { |
9060 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9061 | } else if (!strcmp(dstr, "export")) { | |
9062 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9063 | } else if (!strcmp(dstr, "both")) { | |
9064 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9065 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9066 | } else { | |
9067 | vty_out(vty, "%% direction parse error\n"); | |
9068 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9069 | } |
ddb5b488 PZ |
9070 | return CMD_SUCCESS; |
9071 | } | |
9072 | ||
b9c7bc5a PZ |
9073 | DEFPY (af_rt_vpn_imexport, |
9074 | af_rt_vpn_imexport_cmd, | |
9075 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
9076 | NO_STR | |
9077 | "Specify route target list\n" | |
ddb5b488 | 9078 | "Specify route target list\n" |
b9c7bc5a PZ |
9079 | "Between current address-family and vpn\n" |
9080 | "For routes leaked from vpn to current address-family: match any\n" | |
9081 | "For routes leaked from current address-family to vpn: set\n" | |
9082 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
9083 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
9084 | { | |
9085 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9086 | int ret; | |
9087 | struct ecommunity *ecom = NULL; | |
9088 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
9089 | vpn_policy_direction_t dir; |
9090 | afi_t afi; | |
9091 | int idx = 0; | |
c6423c31 | 9092 | bool yes = true; |
ddb5b488 | 9093 | |
b9c7bc5a | 9094 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 9095 | yes = false; |
b9c7bc5a | 9096 | |
0ca70ba5 | 9097 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9098 | if (afi == AFI_MAX) |
9099 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9100 | |
b9c7bc5a | 9101 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
9102 | if (ret != CMD_SUCCESS) |
9103 | return ret; | |
9104 | ||
b9c7bc5a PZ |
9105 | if (yes) { |
9106 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9107 | vty_out(vty, "%% Missing RTLIST\n"); | |
9108 | return CMD_WARNING_CONFIG_FAILED; | |
9109 | } | |
c6423c31 | 9110 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
9111 | if (ret != CMD_SUCCESS) { |
9112 | return ret; | |
9113 | } | |
ddb5b488 PZ |
9114 | } |
9115 | ||
69b07479 DS |
9116 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9117 | if (!dodir[dir]) | |
ddb5b488 | 9118 | continue; |
ddb5b488 | 9119 | |
69b07479 | 9120 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 9121 | |
69b07479 DS |
9122 | if (yes) { |
9123 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9124 | ecommunity_free( | |
9125 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9126 | bgp->vpn_policy[afi].rtlist[dir] = | |
9127 | ecommunity_dup(ecom); | |
9128 | } else { | |
9129 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9130 | ecommunity_free( | |
9131 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9132 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 9133 | } |
69b07479 DS |
9134 | |
9135 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 9136 | } |
69b07479 | 9137 | |
d555f3e9 PZ |
9138 | if (ecom) |
9139 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
9140 | |
9141 | return CMD_SUCCESS; | |
9142 | } | |
9143 | ||
b9c7bc5a PZ |
9144 | ALIAS (af_rt_vpn_imexport, |
9145 | af_no_rt_vpn_imexport_cmd, | |
9146 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
9147 | NO_STR |
9148 | "Specify route target list\n" | |
b9c7bc5a PZ |
9149 | "Specify route target list\n" |
9150 | "Between current address-family and vpn\n" | |
9151 | "For routes leaked from vpn to current address-family\n" | |
9152 | "For routes leaked from current address-family to vpn\n" | |
9153 | "both import and export\n") | |
9154 | ||
37a87b8f | 9155 | DEFPY_YANG (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
9156 | af_route_map_vpn_imexport_cmd, |
9157 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
9158 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
9159 | NO_STR | |
ddb5b488 | 9160 | "Specify route map\n" |
b9c7bc5a PZ |
9161 | "Between current address-family and vpn\n" |
9162 | "For routes leaked from vpn to current address-family\n" | |
9163 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9164 | "name of route-map\n") |
9165 | { | |
37a87b8f | 9166 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9167 | afi_t afi; |
37a87b8f | 9168 | safi_t safi; |
ddb5b488 | 9169 | int idx = 0; |
ddb5b488 | 9170 | |
37a87b8f CS |
9171 | afi = bgp_node_afi(vty); |
9172 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9173 | |
37a87b8f CS |
9174 | snprintf( |
9175 | base_xpath, sizeof(base_xpath), | |
9176 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9177 | yang_afi_safi_value2identity(afi, safi), | |
9178 | bgp_afi_safi_get_container_str(afi, safi)); | |
9179 | ||
9180 | if (argv_find(argv, argc, "no", &idx)) { | |
9181 | if (!strcmp(direction_str, "import")) | |
9182 | nb_cli_enqueue_change(vty, "./rmap-import", | |
9183 | NB_OP_DESTROY, NULL); | |
9184 | else if (!strcmp(direction_str, "export")) | |
9185 | nb_cli_enqueue_change(vty, "./rmap-export", | |
9186 | NB_OP_DESTROY, NULL); | |
9187 | } else { | |
9188 | if (!strcmp(direction_str, "import")) | |
9189 | nb_cli_enqueue_change(vty, "./rmap-import", | |
9190 | NB_OP_MODIFY, rmap_str); | |
9191 | if (!strcmp(direction_str, "export")) | |
9192 | nb_cli_enqueue_change(vty, "./rmap-export", | |
9193 | NB_OP_MODIFY, rmap_str); | |
9194 | } | |
9195 | return nb_cli_apply_changes(vty, base_xpath); | |
9196 | } | |
ddb5b488 | 9197 | |
37a87b8f CS |
9198 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import( |
9199 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9200 | { | |
9201 | int indent = 2; | |
ddb5b488 | 9202 | |
37a87b8f CS |
9203 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", |
9204 | yang_dnode_get_string(dnode, NULL)); | |
9205 | } | |
69b07479 | 9206 | |
37a87b8f CS |
9207 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export( |
9208 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9209 | { | |
9210 | int indent = 2; | |
ddb5b488 | 9211 | |
37a87b8f CS |
9212 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", |
9213 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9214 | } |
9215 | ||
b9c7bc5a PZ |
9216 | ALIAS (af_route_map_vpn_imexport, |
9217 | af_no_route_map_vpn_imexport_cmd, | |
9218 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
9219 | NO_STR |
9220 | "Specify route map\n" | |
b9c7bc5a PZ |
9221 | "Between current address-family and vpn\n" |
9222 | "For routes leaked from vpn to current address-family\n" | |
9223 | "For routes leaked from current address-family to vpn\n") | |
9224 | ||
bb4f6190 | 9225 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 9226 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
9227 | "Import routes from another VRF\n" |
9228 | "Vrf routes being filtered\n" | |
9229 | "Specify route map\n" | |
9230 | "name of route-map\n") | |
9231 | { | |
9232 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
9233 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
9234 | afi_t afi; | |
bb4f6190 DS |
9235 | struct bgp *bgp_default; |
9236 | ||
0ca70ba5 | 9237 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
9238 | if (afi == AFI_MAX) |
9239 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
9240 | |
9241 | bgp_default = bgp_get_default(); | |
9242 | if (!bgp_default) { | |
9243 | int32_t ret; | |
9244 | as_t as = bgp->as; | |
9245 | ||
9246 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
9247 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
9248 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
9249 | |
9250 | if (ret) { | |
9251 | vty_out(vty, | |
9252 | "VRF default is not configured as a bgp instance\n"); | |
9253 | return CMD_WARNING; | |
9254 | } | |
9255 | } | |
9256 | ||
69b07479 | 9257 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 9258 | |
ae6a6fb4 DS |
9259 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
9260 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9261 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9262 | bgp->vpn_policy[afi].rmap_name[dir] = | |
9263 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9264 | bgp->vpn_policy[afi].rmap[dir] = | |
9265 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9266 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9267 | return CMD_SUCCESS; | |
9268 | ||
9269 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9270 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 9271 | |
69b07479 DS |
9272 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
9273 | ||
bb4f6190 DS |
9274 | return CMD_SUCCESS; |
9275 | } | |
9276 | ||
ae6a6fb4 DS |
9277 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
9278 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
9279 | NO_STR |
9280 | "Import routes from another VRF\n" | |
9281 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
9282 | "Specify route map\n" |
9283 | "name of route-map\n") | |
9284 | { | |
9285 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9286 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
9287 | afi_t afi; | |
9288 | ||
9289 | afi = vpn_policy_getafi(vty, bgp, true); | |
9290 | if (afi == AFI_MAX) | |
9291 | return CMD_WARNING_CONFIG_FAILED; | |
9292 | ||
9293 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9294 | ||
9295 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9296 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9297 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9298 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9299 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9300 | ||
9301 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
9302 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9303 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
9304 | ||
9305 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9306 | ||
9307 | return CMD_SUCCESS; | |
9308 | } | |
bb4f6190 | 9309 | |
37a87b8f CS |
9310 | DEFPY_YANG(bgp_imexport_vrf, |
9311 | bgp_imexport_vrf_cmd, | |
9312 | "[no] import vrf VIEWVRFNAME$import_name", | |
9313 | NO_STR | |
9314 | "Import routes from another VRF\n" | |
9315 | "VRF to import from\n" | |
9316 | "The name of the VRF\n") | |
12a844a5 | 9317 | { |
37a87b8f | 9318 | char base_xpath[XPATH_MAXLEN]; |
12a844a5 DS |
9319 | safi_t safi; |
9320 | afi_t afi; | |
37a87b8f | 9321 | int32_t idx = 0; |
12a844a5 | 9322 | |
867f0cca | 9323 | if (import_name == NULL) { |
9324 | vty_out(vty, "%% Missing import name\n"); | |
9325 | return CMD_WARNING; | |
9326 | } | |
9327 | ||
ae6a6fb4 DS |
9328 | if (strcmp(import_name, "route-map") == 0) { |
9329 | vty_out(vty, "%% Must include route-map name\n"); | |
9330 | return CMD_WARNING; | |
9331 | } | |
9332 | ||
37a87b8f | 9333 | afi = bgp_node_afi(vty); |
12a844a5 DS |
9334 | safi = bgp_node_safi(vty); |
9335 | ||
37a87b8f CS |
9336 | snprintf( |
9337 | base_xpath, sizeof(base_xpath), | |
9338 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']", | |
9339 | yang_afi_safi_value2identity(afi, safi), | |
9340 | bgp_afi_safi_get_container_str(afi, safi), import_name); | |
25679caa | 9341 | |
37a87b8f CS |
9342 | if (argv_find(argv, argc, "no", &idx)) |
9343 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
9344 | else | |
9345 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
12a844a5 | 9346 | |
37a87b8f CS |
9347 | return nb_cli_apply_changes(vty, base_xpath); |
9348 | } | |
12a844a5 | 9349 | |
37a87b8f CS |
9350 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs( |
9351 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9352 | { | |
9353 | vty_out(vty, " import vrf %s\n", | |
9354 | yang_dnode_get_string(dnode, "./vrf")); | |
12a844a5 DS |
9355 | } |
9356 | ||
b9c7bc5a | 9357 | /* This command is valid only in a bgp vrf instance or the default instance */ |
37a87b8f | 9358 | DEFPY_YANG (bgp_imexport_vpn, |
b9c7bc5a PZ |
9359 | bgp_imexport_vpn_cmd, |
9360 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
9361 | NO_STR |
9362 | "Import routes to this address-family\n" | |
9363 | "Export routes from this address-family\n" | |
9364 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 9365 | { |
37a87b8f | 9366 | char base_xpath[XPATH_MAXLEN]; |
b9c7bc5a | 9367 | safi_t safi; |
37a87b8f CS |
9368 | afi_t afi; |
9369 | int32_t idx = 0; | |
ddb5b488 | 9370 | |
b9c7bc5a PZ |
9371 | afi = bgp_node_afi(vty); |
9372 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9373 | |
b9c7bc5a | 9374 | if (!strcmp(direction_str, "import")) { |
37a87b8f CS |
9375 | snprintf( |
9376 | base_xpath, sizeof(base_xpath), | |
9377 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn", | |
9378 | yang_afi_safi_value2identity(afi, safi), | |
9379 | bgp_afi_safi_get_container_str(afi, safi)); | |
b9c7bc5a | 9380 | } else if (!strcmp(direction_str, "export")) { |
37a87b8f CS |
9381 | snprintf( |
9382 | base_xpath, sizeof(base_xpath), | |
9383 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn", | |
9384 | yang_afi_safi_value2identity(afi, safi), | |
9385 | bgp_afi_safi_get_container_str(afi, safi)); | |
b9c7bc5a PZ |
9386 | } else { |
9387 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9388 | return CMD_WARNING_CONFIG_FAILED; | |
9389 | } | |
9390 | ||
37a87b8f CS |
9391 | if (argv_find(argv, argc, "no", &idx)) |
9392 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
9393 | else | |
9394 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, "true"); | |
ddb5b488 | 9395 | |
37a87b8f CS |
9396 | return nb_cli_apply_changes(vty, base_xpath); |
9397 | } | |
ddb5b488 | 9398 | |
37a87b8f CS |
9399 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn( |
9400 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9401 | { | |
9402 | if (yang_dnode_get_bool(dnode, NULL)) | |
9403 | vty_out(vty, " import vpn\n"); | |
9404 | } | |
9405 | ||
9406 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn( | |
9407 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9408 | { | |
9409 | if (yang_dnode_get_bool(dnode, NULL)) | |
9410 | vty_out(vty, " export vpn\n"); | |
ddb5b488 PZ |
9411 | } |
9412 | ||
301ad80a PG |
9413 | DEFPY (af_routetarget_import, |
9414 | af_routetarget_import_cmd, | |
9a659715 | 9415 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9416 | NO_STR |
9417 | "Specify route target list\n" | |
9418 | "Specify route target list\n" | |
9a659715 PG |
9419 | "Specify route target list\n" |
9420 | "Specify route target list\n" | |
301ad80a PG |
9421 | "Flow-spec redirect type route target\n" |
9422 | "Import routes to this address-family\n" | |
9a659715 | 9423 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9424 | { |
9425 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9426 | int ret; | |
9427 | struct ecommunity *ecom = NULL; | |
301ad80a | 9428 | afi_t afi; |
9a659715 | 9429 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9430 | bool yes = true; |
9431 | bool rt6 = false; | |
301ad80a PG |
9432 | |
9433 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9434 | yes = false; |
301ad80a | 9435 | |
9a659715 PG |
9436 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9437 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9438 | rt6 = true; |
301ad80a | 9439 | |
0ca70ba5 | 9440 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9441 | if (afi == AFI_MAX) |
9442 | return CMD_WARNING_CONFIG_FAILED; | |
9443 | ||
9a659715 PG |
9444 | if (rt6 && afi != AFI_IP6) |
9445 | return CMD_WARNING_CONFIG_FAILED; | |
9446 | ||
301ad80a PG |
9447 | if (yes) { |
9448 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9449 | vty_out(vty, "%% Missing RTLIST\n"); | |
9450 | return CMD_WARNING_CONFIG_FAILED; | |
9451 | } | |
9a659715 | 9452 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9453 | if (ret != CMD_SUCCESS) |
9454 | return ret; | |
9455 | } | |
69b07479 DS |
9456 | |
9457 | if (yes) { | |
9458 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9459 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9460 | .import_redirect_rtlist); |
69b07479 DS |
9461 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9462 | ecommunity_dup(ecom); | |
9463 | } else { | |
9464 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9465 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9466 | .import_redirect_rtlist); |
69b07479 | 9467 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9468 | } |
69b07479 | 9469 | |
301ad80a PG |
9470 | if (ecom) |
9471 | ecommunity_free(&ecom); | |
9472 | ||
9473 | return CMD_SUCCESS; | |
9474 | } | |
9475 | ||
37a87b8f CS |
9476 | void cli_show_bgp_global_afi_safi_header(struct vty *vty, |
9477 | struct lyd_node *dnode, | |
9478 | bool show_defaults) | |
9479 | { | |
9480 | const char *af_name; | |
9481 | afi_t afi; | |
9482 | safi_t safi; | |
9483 | ||
9484 | af_name = yang_dnode_get_string(dnode, "./afi-safi-name"); | |
9485 | yang_afi_safi_identity2value(af_name, &afi, &safi); | |
9486 | ||
9487 | vty_out(vty, " !\n address-family "); | |
9488 | if (afi == AFI_IP) { | |
9489 | if (safi == SAFI_UNICAST) | |
9490 | vty_out(vty, "ipv4 unicast"); | |
9491 | else if (safi == SAFI_LABELED_UNICAST) | |
9492 | vty_out(vty, "ipv4 labeled-unicast"); | |
9493 | else if (safi == SAFI_MULTICAST) | |
9494 | vty_out(vty, "ipv4 multicast"); | |
9495 | else if (safi == SAFI_MPLS_VPN) | |
9496 | vty_out(vty, "ipv4 vpn"); | |
9497 | else if (safi == SAFI_ENCAP) | |
9498 | vty_out(vty, "ipv4 encap"); | |
9499 | else if (safi == SAFI_FLOWSPEC) | |
9500 | vty_out(vty, "ipv4 flowspec"); | |
9501 | } else if (afi == AFI_IP6) { | |
9502 | if (safi == SAFI_UNICAST) | |
9503 | vty_out(vty, "ipv6 unicast"); | |
9504 | else if (safi == SAFI_LABELED_UNICAST) | |
9505 | vty_out(vty, "ipv6 labeled-unicast"); | |
9506 | else if (safi == SAFI_MULTICAST) | |
9507 | vty_out(vty, "ipv6 multicast"); | |
9508 | else if (safi == SAFI_MPLS_VPN) | |
9509 | vty_out(vty, "ipv6 vpn"); | |
9510 | else if (safi == SAFI_ENCAP) | |
9511 | vty_out(vty, "ipv6 encap"); | |
9512 | else if (safi == SAFI_FLOWSPEC) | |
9513 | vty_out(vty, "ipv6 flowspec"); | |
9514 | } else if (afi == AFI_L2VPN) { | |
9515 | if (safi == SAFI_EVPN) | |
9516 | vty_out(vty, "l2vpn evpn"); | |
9517 | } | |
9518 | vty_out(vty, "\n"); | |
9519 | } | |
9520 | ||
505e5056 | 9521 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9522 | address_family_ipv4_safi_cmd, |
9523 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9524 | "Enter Address Family command mode\n" | |
9525 | "Address Family\n" | |
9526 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 9527 | { |
f51bae9c | 9528 | |
37a87b8f CS |
9529 | safi_t safi = SAFI_UNICAST; |
9530 | const struct lyd_node *vrf_dnode, *bgp_glb_dnode; | |
9531 | const char *vrf_name = NULL; | |
9532 | ||
d62a17ae | 9533 | if (argc == 3) { |
37a87b8f CS |
9534 | safi = bgp_vty_safi_from_str(argv[2]->text); |
9535 | ||
9536 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, | |
9537 | VTY_CURR_XPATH); | |
9538 | vrf_dnode = yang_dnode_get_parent(bgp_glb_dnode, | |
9539 | "control-plane-protocol"); | |
9540 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
9541 | ||
9542 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME) | |
a4d82a8a | 9543 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9544 | && safi != SAFI_EVPN) { |
31947174 MK |
9545 | vty_out(vty, |
9546 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9547 | return CMD_WARNING_CONFIG_FAILED; |
9548 | } | |
37a87b8f CS |
9549 | } |
9550 | vty->node = bgp_node_type(AFI_IP, safi); | |
718e3744 | 9551 | |
d62a17ae | 9552 | return CMD_SUCCESS; |
718e3744 | 9553 | } |
9554 | ||
505e5056 | 9555 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9556 | address_family_ipv6_safi_cmd, |
9557 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9558 | "Enter Address Family command mode\n" | |
9559 | "Address Family\n" | |
9560 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 9561 | { |
37a87b8f CS |
9562 | safi_t safi = SAFI_UNICAST; |
9563 | const struct lyd_node *vrf_dnode, *bgp_glb_dnode; | |
9564 | const char *vrf_name = NULL; | |
9565 | ||
d62a17ae | 9566 | if (argc == 3) { |
37a87b8f CS |
9567 | safi = bgp_vty_safi_from_str(argv[2]->text); |
9568 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, | |
9569 | VTY_CURR_XPATH); | |
9570 | vrf_dnode = yang_dnode_get_parent(bgp_glb_dnode, | |
9571 | "control-plane-protocol"); | |
9572 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
9573 | ||
9574 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME) | |
a4d82a8a | 9575 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9576 | && safi != SAFI_EVPN) { |
31947174 MK |
9577 | vty_out(vty, |
9578 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9579 | return CMD_WARNING_CONFIG_FAILED; |
9580 | } | |
37a87b8f CS |
9581 | } |
9582 | vty->node = bgp_node_type(AFI_IP6, safi); | |
25ffbdc1 | 9583 | |
d62a17ae | 9584 | return CMD_SUCCESS; |
25ffbdc1 | 9585 | } |
718e3744 | 9586 | |
d6902373 | 9587 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9588 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9589 | address_family_vpnv4_cmd, |
8334fd5a | 9590 | "address-family vpnv4 [unicast]", |
718e3744 | 9591 | "Enter Address Family command mode\n" |
8c3deaae | 9592 | "Address Family\n" |
3a2d747c | 9593 | "Address Family modifier\n") |
718e3744 | 9594 | { |
d62a17ae | 9595 | vty->node = BGP_VPNV4_NODE; |
9596 | return CMD_SUCCESS; | |
718e3744 | 9597 | } |
9598 | ||
505e5056 | 9599 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9600 | address_family_vpnv6_cmd, |
8334fd5a | 9601 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9602 | "Enter Address Family command mode\n" |
8c3deaae | 9603 | "Address Family\n" |
3a2d747c | 9604 | "Address Family modifier\n") |
8ecd3266 | 9605 | { |
d62a17ae | 9606 | vty->node = BGP_VPNV6_NODE; |
9607 | return CMD_SUCCESS; | |
8ecd3266 | 9608 | } |
64e4a6c5 | 9609 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9610 | |
505e5056 | 9611 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9612 | address_family_evpn_cmd, |
7111c1a0 | 9613 | "address-family l2vpn evpn", |
4e0b7b6d | 9614 | "Enter Address Family command mode\n" |
7111c1a0 QY |
9615 | "Address Family\n" |
9616 | "Address Family modifier\n") | |
4e0b7b6d | 9617 | { |
2131d5cf | 9618 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9619 | vty->node = BGP_EVPN_NODE; |
9620 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9621 | } |
9622 | ||
505e5056 | 9623 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9624 | exit_address_family_cmd, |
9625 | "exit-address-family", | |
9626 | "Exit from Address Family configuration mode\n") | |
9627 | { | |
d62a17ae | 9628 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9629 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9630 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9631 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9632 | || vty->node == BGP_EVPN_NODE |
9633 | || vty->node == BGP_FLOWSPECV4_NODE | |
9634 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9635 | vty->node = BGP_NODE; |
9636 | return CMD_SUCCESS; | |
718e3744 | 9637 | } |
6b0655a2 | 9638 | |
37a87b8f CS |
9639 | void cli_show_bgp_global_afi_safi_header_end(struct vty *vty, |
9640 | struct lyd_node *dnode | |
9641 | __attribute__((__unused__))) | |
9642 | { | |
9643 | vty_out(vty, " exit-address-family\n"); | |
9644 | } | |
9645 | ||
8ad7271d | 9646 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9647 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9648 | const char *ip_str, afi_t afi, safi_t safi, | |
9649 | struct prefix_rd *prd) | |
9650 | { | |
9651 | int ret; | |
9652 | struct prefix match; | |
9bcb3eef DS |
9653 | struct bgp_dest *dest; |
9654 | struct bgp_dest *rm; | |
d62a17ae | 9655 | struct bgp *bgp; |
9656 | struct bgp_table *table; | |
9657 | struct bgp_table *rib; | |
9658 | ||
9659 | /* BGP structure lookup. */ | |
9660 | if (view_name) { | |
9661 | bgp = bgp_lookup_by_name(view_name); | |
9662 | if (bgp == NULL) { | |
9663 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9664 | view_name); | |
9665 | return CMD_WARNING; | |
9666 | } | |
9667 | } else { | |
9668 | bgp = bgp_get_default(); | |
9669 | if (bgp == NULL) { | |
9670 | vty_out(vty, "%% No BGP process is configured\n"); | |
9671 | return CMD_WARNING; | |
9672 | } | |
9673 | } | |
9674 | ||
9675 | /* Check IP address argument. */ | |
9676 | ret = str2prefix(ip_str, &match); | |
9677 | if (!ret) { | |
9678 | vty_out(vty, "%% address is malformed\n"); | |
9679 | return CMD_WARNING; | |
9680 | } | |
9681 | ||
9682 | match.family = afi2family(afi); | |
9683 | rib = bgp->rib[afi][safi]; | |
9684 | ||
9685 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
9686 | for (dest = bgp_table_top(rib); dest; |
9687 | dest = bgp_route_next(dest)) { | |
9688 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9689 | |
9bcb3eef | 9690 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 9691 | continue; |
9692 | ||
9bcb3eef | 9693 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
9694 | if (table == NULL) |
9695 | continue; | |
9696 | ||
9697 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
9698 | const struct prefix *rm_p = | |
9bcb3eef | 9699 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
9700 | |
9701 | if (rm_p->prefixlen == match.prefixlen) { | |
9702 | SET_FLAG(rm->flags, | |
9703 | BGP_NODE_USER_CLEAR); | |
9704 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 9705 | } |
9bcb3eef | 9706 | bgp_dest_unlock_node(rm); |
d62a17ae | 9707 | } |
9708 | } | |
9709 | } else { | |
9bcb3eef DS |
9710 | if ((dest = bgp_node_match(rib, &match)) != NULL) { |
9711 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9712 | |
9bcb3eef DS |
9713 | if (dest_p->prefixlen == match.prefixlen) { |
9714 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
9715 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 9716 | } |
9bcb3eef | 9717 | bgp_dest_unlock_node(dest); |
d62a17ae | 9718 | } |
9719 | } | |
9720 | ||
9721 | return CMD_SUCCESS; | |
8ad7271d DS |
9722 | } |
9723 | ||
b09b5ae0 | 9724 | /* one clear bgp command to rule them all */ |
718e3744 | 9725 | DEFUN (clear_ip_bgp_all, |
9726 | clear_ip_bgp_all_cmd, | |
453c92f6 | 9727 | "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 | 9728 | CLEAR_STR |
9729 | IP_STR | |
9730 | BGP_STR | |
838758ac | 9731 | BGP_INSTANCE_HELP_STR |
510afcd6 | 9732 | BGP_AFI_HELP_STR |
fd5e7b70 | 9733 | "Address Family\n" |
510afcd6 | 9734 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 9735 | "Address Family modifier\n" |
b09b5ae0 | 9736 | "Clear all peers\n" |
453c92f6 | 9737 | "BGP IPv4 neighbor to clear\n" |
a80beece | 9738 | "BGP IPv6 neighbor to clear\n" |
838758ac | 9739 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
9740 | "Clear peers with the AS number\n" |
9741 | "Clear all external peers\n" | |
718e3744 | 9742 | "Clear all members of peer-group\n" |
b09b5ae0 | 9743 | "BGP peer-group name\n" |
b09b5ae0 DW |
9744 | BGP_SOFT_STR |
9745 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
9746 | BGP_SOFT_OUT_STR |
9747 | BGP_SOFT_IN_STR | |
9748 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 9749 | BGP_SOFT_OUT_STR) |
718e3744 | 9750 | { |
d62a17ae | 9751 | char *vrf = NULL; |
9752 | ||
dc912615 DS |
9753 | afi_t afi = AFI_UNSPEC; |
9754 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 9755 | enum clear_sort clr_sort = clear_peer; |
9756 | enum bgp_clear_type clr_type; | |
9757 | char *clr_arg = NULL; | |
9758 | ||
9759 | int idx = 0; | |
ff8a8a7a CS |
9760 | char errmsg[BUFSIZ] = {'\0'}; |
9761 | int ret; | |
d62a17ae | 9762 | |
9763 | /* clear [ip] bgp */ | |
9764 | if (argv_find(argv, argc, "ip", &idx)) | |
9765 | afi = AFI_IP; | |
9766 | ||
9a8bdf1c PG |
9767 | /* [<vrf> VIEWVRFNAME] */ |
9768 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9769 | vrf = argv[idx + 1]->arg; | |
9770 | idx += 2; | |
9771 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9772 | vrf = NULL; | |
9773 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9774 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 9775 | vrf = argv[idx + 1]->arg; |
9776 | idx += 2; | |
9777 | } | |
d62a17ae | 9778 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9779 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
9780 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9781 | ||
d7b9898c | 9782 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 9783 | if (argv_find(argv, argc, "*", &idx)) { |
9784 | clr_sort = clear_all; | |
9785 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
9786 | clr_sort = clear_peer; | |
9787 | clr_arg = argv[idx]->arg; | |
9788 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
9789 | clr_sort = clear_peer; | |
9790 | clr_arg = argv[idx]->arg; | |
9791 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
9792 | clr_sort = clear_group; | |
9793 | idx++; | |
9794 | clr_arg = argv[idx]->arg; | |
d7b9898c | 9795 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 9796 | clr_sort = clear_peer; |
9797 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
9798 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
9799 | clr_sort = clear_peer; | |
9800 | clr_arg = argv[idx]->arg; | |
d62a17ae | 9801 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
9802 | clr_sort = clear_as; | |
9803 | clr_arg = argv[idx]->arg; | |
9804 | } else if (argv_find(argv, argc, "external", &idx)) { | |
9805 | clr_sort = clear_external; | |
9806 | } | |
9807 | ||
9808 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
9809 | if (argv_find(argv, argc, "soft", &idx)) { | |
9810 | if (argv_find(argv, argc, "in", &idx) | |
9811 | || argv_find(argv, argc, "out", &idx)) | |
9812 | clr_type = strmatch(argv[idx]->text, "in") | |
9813 | ? BGP_CLEAR_SOFT_IN | |
9814 | : BGP_CLEAR_SOFT_OUT; | |
9815 | else | |
9816 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9817 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9818 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9819 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9820 | : BGP_CLEAR_SOFT_IN; | |
9821 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9822 | clr_type = BGP_CLEAR_SOFT_OUT; | |
9823 | } else | |
9824 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9825 | ||
ff8a8a7a CS |
9826 | ret = bgp_clear_vty(vrf, afi, safi, clr_sort, clr_type, clr_arg, errmsg, |
9827 | sizeof(errmsg)); | |
9828 | if (ret != NB_OK) | |
9829 | vty_out(vty, "Error description: %s\n", errmsg); | |
9830 | ||
9831 | return ret; | |
838758ac | 9832 | } |
01080f7c | 9833 | |
8ad7271d DS |
9834 | DEFUN (clear_ip_bgp_prefix, |
9835 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 9836 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
9837 | CLEAR_STR |
9838 | IP_STR | |
9839 | BGP_STR | |
838758ac | 9840 | BGP_INSTANCE_HELP_STR |
8ad7271d | 9841 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9842 | "IPv4 prefix\n") |
8ad7271d | 9843 | { |
d62a17ae | 9844 | char *vrf = NULL; |
9845 | char *prefix = NULL; | |
8ad7271d | 9846 | |
d62a17ae | 9847 | int idx = 0; |
01080f7c | 9848 | |
d62a17ae | 9849 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
9850 | if (argv_find(argv, argc, "vrf", &idx)) { |
9851 | vrf = argv[idx + 1]->arg; | |
9852 | idx += 2; | |
9853 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9854 | vrf = NULL; | |
9855 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9856 | /* [<view> VIEWVRFNAME] */ | |
9857 | vrf = argv[idx + 1]->arg; | |
9858 | idx += 2; | |
9859 | } | |
0c7b1b01 | 9860 | |
d62a17ae | 9861 | prefix = argv[argc - 1]->arg; |
8ad7271d | 9862 | |
d62a17ae | 9863 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 9864 | } |
8ad7271d | 9865 | |
b09b5ae0 DW |
9866 | DEFUN (clear_bgp_ipv6_safi_prefix, |
9867 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 9868 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9869 | CLEAR_STR |
3a2d747c | 9870 | IP_STR |
718e3744 | 9871 | BGP_STR |
8c3deaae | 9872 | "Address Family\n" |
46f296b4 | 9873 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9874 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9875 | "IPv6 prefix\n") |
718e3744 | 9876 | { |
9b475e76 PG |
9877 | int idx_safi = 0; |
9878 | int idx_ipv6_prefix = 0; | |
9879 | safi_t safi = SAFI_UNICAST; | |
9880 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9881 | argv[idx_ipv6_prefix]->arg : NULL; | |
9882 | ||
9883 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 9884 | return bgp_clear_prefix( |
9b475e76 PG |
9885 | vty, NULL, prefix, AFI_IP6, |
9886 | safi, NULL); | |
838758ac | 9887 | } |
01080f7c | 9888 | |
b09b5ae0 DW |
9889 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
9890 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 9891 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9892 | CLEAR_STR |
3a2d747c | 9893 | IP_STR |
718e3744 | 9894 | BGP_STR |
838758ac | 9895 | BGP_INSTANCE_HELP_STR |
8c3deaae | 9896 | "Address Family\n" |
46f296b4 | 9897 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9898 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9899 | "IPv6 prefix\n") |
718e3744 | 9900 | { |
9b475e76 | 9901 | int idx_safi = 0; |
9a8bdf1c | 9902 | int idx_vrfview = 0; |
9b475e76 PG |
9903 | int idx_ipv6_prefix = 0; |
9904 | safi_t safi = SAFI_UNICAST; | |
9905 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9906 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 9907 | char *vrfview = NULL; |
9b475e76 | 9908 | |
9a8bdf1c PG |
9909 | /* [<view|vrf> VIEWVRFNAME] */ |
9910 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9911 | vrfview = argv[idx_vrfview + 1]->arg; | |
9912 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9913 | vrfview = NULL; | |
9914 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9915 | /* [<view> VIEWVRFNAME] */ | |
9916 | vrfview = argv[idx_vrfview + 1]->arg; | |
9917 | } | |
9b475e76 PG |
9918 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
9919 | ||
d62a17ae | 9920 | return bgp_clear_prefix( |
9b475e76 PG |
9921 | vty, vrfview, prefix, |
9922 | AFI_IP6, safi, NULL); | |
718e3744 | 9923 | } |
9924 | ||
b09b5ae0 DW |
9925 | DEFUN (show_bgp_views, |
9926 | show_bgp_views_cmd, | |
d6e3c605 | 9927 | "show [ip] bgp views", |
b09b5ae0 | 9928 | SHOW_STR |
d6e3c605 | 9929 | IP_STR |
01080f7c | 9930 | BGP_STR |
b09b5ae0 | 9931 | "Show the defined BGP views\n") |
01080f7c | 9932 | { |
d62a17ae | 9933 | struct list *inst = bm->bgp; |
9934 | struct listnode *node; | |
9935 | struct bgp *bgp; | |
01080f7c | 9936 | |
d62a17ae | 9937 | vty_out(vty, "Defined BGP views:\n"); |
9938 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9939 | /* Skip VRFs. */ | |
9940 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9941 | continue; | |
9942 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9943 | bgp->as); | |
9944 | } | |
e52702f2 | 9945 | |
d62a17ae | 9946 | return CMD_SUCCESS; |
e0081f70 ML |
9947 | } |
9948 | ||
8386ac43 | 9949 | DEFUN (show_bgp_vrfs, |
9950 | show_bgp_vrfs_cmd, | |
d6e3c605 | 9951 | "show [ip] bgp vrfs [json]", |
8386ac43 | 9952 | SHOW_STR |
d6e3c605 | 9953 | IP_STR |
8386ac43 | 9954 | BGP_STR |
9955 | "Show BGP VRFs\n" | |
9973d184 | 9956 | JSON_STR) |
8386ac43 | 9957 | { |
fe1dc5a3 | 9958 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 9959 | struct list *inst = bm->bgp; |
9960 | struct listnode *node; | |
9961 | struct bgp *bgp; | |
9f049418 | 9962 | bool uj = use_json(argc, argv); |
d62a17ae | 9963 | json_object *json = NULL; |
9964 | json_object *json_vrfs = NULL; | |
9965 | int count = 0; | |
d62a17ae | 9966 | |
d62a17ae | 9967 | if (uj) { |
9968 | json = json_object_new_object(); | |
9969 | json_vrfs = json_object_new_object(); | |
9970 | } | |
9971 | ||
9972 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9973 | const char *name, *type; | |
9974 | struct peer *peer; | |
7fe96307 | 9975 | struct listnode *node2, *nnode2; |
d62a17ae | 9976 | int peers_cfg, peers_estb; |
9977 | json_object *json_vrf = NULL; | |
d62a17ae | 9978 | |
9979 | /* Skip Views. */ | |
9980 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9981 | continue; | |
9982 | ||
9983 | count++; | |
efb4077a | 9984 | if (!uj && count == 1) { |
fe1dc5a3 | 9985 | vty_out(vty, |
efb4077a | 9986 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 9987 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
9988 | "#PeersEstb", "Name"); |
9989 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
9990 | "L3-VNI", "RouterMAC", "Interface"); | |
9991 | } | |
d62a17ae | 9992 | |
9993 | peers_cfg = peers_estb = 0; | |
9994 | if (uj) | |
9995 | json_vrf = json_object_new_object(); | |
9996 | ||
9997 | ||
7fe96307 | 9998 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 9999 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10000 | continue; | |
10001 | peers_cfg++; | |
10002 | if (peer->status == Established) | |
10003 | peers_estb++; | |
10004 | } | |
10005 | ||
10006 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 10007 | name = VRF_DEFAULT_NAME; |
d62a17ae | 10008 | type = "DFLT"; |
10009 | } else { | |
10010 | name = bgp->name; | |
10011 | type = "VRF"; | |
10012 | } | |
10013 | ||
a8bf7d9c | 10014 | |
d62a17ae | 10015 | if (uj) { |
a4d82a8a PZ |
10016 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10017 | ? -1 | |
10018 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
10019 | char buf[BUFSIZ] = {0}; |
10020 | ||
d62a17ae | 10021 | json_object_string_add(json_vrf, "type", type); |
10022 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
10023 | json_object_string_add(json_vrf, "routerId", | |
23d0a753 DA |
10024 | inet_ntop(AF_INET, |
10025 | &bgp->router_id, buf, | |
10026 | sizeof(buf))); | |
d62a17ae | 10027 | json_object_int_add(json_vrf, "numConfiguredPeers", |
10028 | peers_cfg); | |
10029 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
10030 | peers_estb); | |
10031 | ||
fe1dc5a3 | 10032 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
10033 | json_object_string_add( |
10034 | json_vrf, "rmac", | |
10035 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
10036 | json_object_string_add(json_vrf, "interface", |
10037 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10038 | bgp->vrf_id)); | |
d62a17ae | 10039 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 10040 | } else { |
23d0a753 | 10041 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
10042 | type, |
10043 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10044 | : (int)bgp->vrf_id, | |
23d0a753 | 10045 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
10046 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
10047 | bgp->l3vni, | |
10048 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
10049 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10050 | bgp->vrf_id)); | |
10051 | } | |
d62a17ae | 10052 | } |
10053 | ||
10054 | if (uj) { | |
10055 | json_object_object_add(json, "vrfs", json_vrfs); | |
10056 | ||
10057 | json_object_int_add(json, "totalVrfs", count); | |
10058 | ||
996c9314 LB |
10059 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10060 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10061 | json_object_free(json); |
10062 | } else { | |
10063 | if (count) | |
10064 | vty_out(vty, | |
10065 | "\nTotal number of VRFs (including default): %d\n", | |
10066 | count); | |
10067 | } | |
10068 | ||
10069 | return CMD_SUCCESS; | |
8386ac43 | 10070 | } |
10071 | ||
48ecf8f5 DS |
10072 | DEFUN (show_bgp_mac_hash, |
10073 | show_bgp_mac_hash_cmd, | |
10074 | "show bgp mac hash", | |
10075 | SHOW_STR | |
10076 | BGP_STR | |
10077 | "Mac Address\n" | |
10078 | "Mac Address database\n") | |
10079 | { | |
10080 | bgp_mac_dump_table(vty); | |
10081 | ||
10082 | return CMD_SUCCESS; | |
10083 | } | |
acf71666 | 10084 | |
e3b78da8 | 10085 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 10086 | { |
0291c246 | 10087 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 10088 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 10089 | |
23d0a753 | 10090 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
10091 | } |
10092 | ||
10093 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
10094 | { | |
10095 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 10096 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
10097 | |
10098 | vty_out(vty, "Tunnel-ip database:\n"); | |
10099 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 10100 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
10101 | vty); |
10102 | } | |
10103 | ||
15c81ca4 DS |
10104 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
10105 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
10106 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
10107 | "martian next-hops\n" |
10108 | "martian next-hop database\n") | |
acf71666 | 10109 | { |
0291c246 | 10110 | struct bgp *bgp = NULL; |
15c81ca4 | 10111 | int idx = 0; |
9a8bdf1c PG |
10112 | char *name = NULL; |
10113 | ||
10114 | /* [<vrf> VIEWVRFNAME] */ | |
10115 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10116 | name = argv[idx + 1]->arg; | |
10117 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
10118 | name = NULL; | |
10119 | } else if (argv_find(argv, argc, "view", &idx)) | |
10120 | /* [<view> VIEWVRFNAME] */ | |
10121 | name = argv[idx + 1]->arg; | |
10122 | if (name) | |
10123 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
10124 | else |
10125 | bgp = bgp_get_default(); | |
acf71666 | 10126 | |
acf71666 MK |
10127 | if (!bgp) { |
10128 | vty_out(vty, "%% No BGP process is configured\n"); | |
10129 | return CMD_WARNING; | |
10130 | } | |
10131 | bgp_show_martian_nexthops(vty, bgp); | |
10132 | ||
10133 | return CMD_SUCCESS; | |
10134 | } | |
10135 | ||
f412b39a | 10136 | DEFUN (show_bgp_memory, |
4bf6a362 | 10137 | show_bgp_memory_cmd, |
7fa12b13 | 10138 | "show [ip] bgp memory", |
4bf6a362 | 10139 | SHOW_STR |
3a2d747c | 10140 | IP_STR |
4bf6a362 PJ |
10141 | BGP_STR |
10142 | "Global BGP memory statistics\n") | |
10143 | { | |
d62a17ae | 10144 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
10145 | unsigned long count; | |
10146 | ||
10147 | /* RIB related usage stats */ | |
10148 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
10149 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
10150 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 10151 | count * sizeof(struct bgp_dest))); |
d62a17ae | 10152 | |
10153 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
10154 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
10155 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 10156 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 10157 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
10158 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
10159 | count, | |
4b7e6066 DS |
10160 | mtype_memstr( |
10161 | memstrbuf, sizeof(memstrbuf), | |
10162 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 10163 | |
10164 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
10165 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
10166 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10167 | count * sizeof(struct bgp_static))); | |
10168 | ||
10169 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
10170 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
10171 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10172 | count * sizeof(struct bpacket))); | |
10173 | ||
10174 | /* Adj-In/Out */ | |
10175 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
10176 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
10177 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10178 | count * sizeof(struct bgp_adj_in))); | |
10179 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
10180 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
10181 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10182 | count * sizeof(struct bgp_adj_out))); | |
10183 | ||
10184 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
10185 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
10186 | count, | |
10187 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10188 | count * sizeof(struct bgp_nexthop_cache))); | |
10189 | ||
10190 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
10191 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
10192 | count, | |
10193 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10194 | count * sizeof(struct bgp_damp_info))); | |
10195 | ||
10196 | /* Attributes */ | |
10197 | count = attr_count(); | |
10198 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
10199 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10200 | count * sizeof(struct attr))); | |
10201 | ||
10202 | if ((count = attr_unknown_count())) | |
10203 | vty_out(vty, "%ld unknown attributes\n", count); | |
10204 | ||
10205 | /* AS_PATH attributes */ | |
10206 | count = aspath_count(); | |
10207 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
10208 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10209 | count * sizeof(struct aspath))); | |
10210 | ||
10211 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
10212 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
10213 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10214 | count * sizeof(struct assegment))); | |
10215 | ||
10216 | /* Other attributes */ | |
10217 | if ((count = community_count())) | |
10218 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10219 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10220 | count * sizeof(struct community))); | |
d62a17ae | 10221 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
10222 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10223 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10224 | count * sizeof(struct ecommunity))); | |
d62a17ae | 10225 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
10226 | vty_out(vty, | |
10227 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
10228 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10229 | count * sizeof(struct lcommunity))); | |
d62a17ae | 10230 | |
10231 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
10232 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
10233 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10234 | count * sizeof(struct cluster_list))); | |
10235 | ||
10236 | /* Peer related usage */ | |
10237 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
10238 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
10239 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10240 | count * sizeof(struct peer))); | |
10241 | ||
10242 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
10243 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
10244 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10245 | count * sizeof(struct peer_group))); | |
10246 | ||
10247 | /* Other */ | |
d62a17ae | 10248 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
10249 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
10250 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10251 | count * sizeof(regex_t))); | |
d62a17ae | 10252 | return CMD_SUCCESS; |
4bf6a362 | 10253 | } |
fee0f4c6 | 10254 | |
57a9c8a8 DS |
10255 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
10256 | { | |
10257 | json_object *bestpath = json_object_new_object(); | |
10258 | ||
892fedb6 | 10259 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
10260 | json_object_string_add(bestpath, "asPath", "ignore"); |
10261 | ||
892fedb6 | 10262 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
10263 | json_object_string_add(bestpath, "asPath", "confed"); |
10264 | ||
892fedb6 DA |
10265 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
10266 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 10267 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10268 | "as-set"); |
10269 | else | |
a4d82a8a | 10270 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10271 | "true"); |
10272 | } else | |
a4d82a8a | 10273 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 10274 | |
892fedb6 | 10275 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 10276 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
10277 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
10278 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10279 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 10280 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 10281 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
10282 | json_object_string_add(bestpath, "med", |
10283 | "missing-as-worst"); | |
10284 | else | |
10285 | json_object_string_add(bestpath, "med", "true"); | |
10286 | } | |
10287 | ||
10288 | json_object_object_add(json, "bestPath", bestpath); | |
10289 | } | |
10290 | ||
3577f1c5 DD |
10291 | /* Print the error code/subcode for why the peer is down */ |
10292 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10293 | json_object *json_peer, bool use_json) | |
10294 | { | |
10295 | const char *code_str; | |
10296 | const char *subcode_str; | |
10297 | ||
10298 | if (use_json) { | |
10299 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10300 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10301 | char errorcodesubcode_hexstr[5]; | |
10302 | char errorcodesubcode_str[256]; | |
10303 | ||
10304 | code_str = bgp_notify_code_str(peer->notify.code); | |
10305 | subcode_str = bgp_notify_subcode_str( | |
10306 | peer->notify.code, | |
10307 | peer->notify.subcode); | |
10308 | ||
772270f3 QY |
10309 | snprintf(errorcodesubcode_hexstr, |
10310 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10311 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10312 | json_object_string_add(json_peer, |
10313 | "lastErrorCodeSubcode", | |
10314 | errorcodesubcode_hexstr); | |
10315 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10316 | code_str, subcode_str); | |
10317 | json_object_string_add(json_peer, | |
10318 | "lastNotificationReason", | |
10319 | errorcodesubcode_str); | |
10320 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10321 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10322 | && (peer->notify.subcode | |
10323 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10324 | || peer->notify.subcode | |
10325 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10326 | && peer->notify.length) { | |
10327 | char msgbuf[1024]; | |
10328 | const char *msg_str; | |
10329 | ||
10330 | msg_str = bgp_notify_admin_message( | |
10331 | msgbuf, sizeof(msgbuf), | |
10332 | (uint8_t *)peer->notify.data, | |
10333 | peer->notify.length); | |
10334 | if (msg_str) | |
10335 | json_object_string_add( | |
10336 | json_peer, | |
10337 | "lastShutdownDescription", | |
10338 | msg_str); | |
10339 | } | |
10340 | ||
c258527b | 10341 | } |
3577f1c5 DD |
10342 | json_object_string_add(json_peer, "lastResetDueTo", |
10343 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10344 | json_object_int_add(json_peer, "lastResetCode", |
10345 | peer->last_reset); | |
3577f1c5 DD |
10346 | } else { |
10347 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10348 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10349 | code_str = bgp_notify_code_str(peer->notify.code); | |
10350 | subcode_str = | |
10351 | bgp_notify_subcode_str(peer->notify.code, | |
10352 | peer->notify.subcode); | |
10353 | vty_out(vty, " Notification %s (%s%s)\n", | |
10354 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10355 | ? "sent" | |
10356 | : "received", | |
10357 | code_str, subcode_str); | |
10358 | } else { | |
e91c24c8 | 10359 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10360 | peer_down_str[(int)peer->last_reset]); |
10361 | } | |
10362 | } | |
10363 | } | |
10364 | ||
10365 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10366 | safi_t safi) | |
10367 | { | |
10368 | return ((peer->status != Established) || | |
10369 | !peer->afc_recv[afi][safi]); | |
10370 | } | |
10371 | ||
10372 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10373 | struct peer *peer, json_object *json_peer, | |
10374 | int max_neighbor_width, bool use_json) | |
10375 | { | |
10376 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10377 | int len; | |
10378 | ||
10379 | if (use_json) { | |
10380 | if (peer_dynamic_neighbor(peer)) | |
10381 | json_object_boolean_true_add(json_peer, | |
10382 | "dynamicPeer"); | |
10383 | if (peer->hostname) | |
10384 | json_object_string_add(json_peer, "hostname", | |
10385 | peer->hostname); | |
10386 | ||
10387 | if (peer->domainname) | |
10388 | json_object_string_add(json_peer, "domainname", | |
10389 | peer->domainname); | |
10390 | json_object_int_add(json_peer, "connectionsEstablished", | |
10391 | peer->established); | |
10392 | json_object_int_add(json_peer, "connectionsDropped", | |
10393 | peer->dropped); | |
10394 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10395 | use_json, json_peer); | |
10396 | if (peer->status == Established) | |
10397 | json_object_string_add(json_peer, "lastResetDueTo", | |
10398 | "AFI/SAFI Not Negotiated"); | |
10399 | else | |
10400 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10401 | } else { | |
10402 | dn_flag[1] = '\0'; | |
10403 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10404 | if (peer->hostname | |
892fedb6 | 10405 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10406 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10407 | peer->hostname, peer->host); | |
10408 | else | |
10409 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10410 | ||
10411 | /* pad the neighbor column with spaces */ | |
10412 | if (len < max_neighbor_width) | |
10413 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10414 | " "); | |
e91c24c8 | 10415 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10416 | peer->dropped, |
10417 | peer_uptime(peer->uptime, timebuf, | |
10418 | BGP_UPTIME_LEN, 0, NULL)); | |
10419 | if (peer->status == Established) | |
10420 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
10421 | else | |
10422 | bgp_show_peer_reset(vty, peer, NULL, | |
10423 | false); | |
10424 | } | |
10425 | } | |
c258527b | 10426 | |
3577f1c5 | 10427 | |
718e3744 | 10428 | /* Show BGP peer's summary information. */ |
d62a17ae | 10429 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
10b49f14 DA |
10430 | bool show_failed, bool show_established, |
10431 | bool use_json) | |
d62a17ae | 10432 | { |
10433 | struct peer *peer; | |
10434 | struct listnode *node, *nnode; | |
10435 | unsigned int count = 0, dn_count = 0; | |
10436 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10437 | char neighbor_buf[VTY_BUFSIZ]; | |
10438 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10439 | int len, failed_count = 0; |
d62a17ae | 10440 | int max_neighbor_width = 0; |
10441 | int pfx_rcd_safi; | |
3c13337d | 10442 | json_object *json = NULL; |
d62a17ae | 10443 | json_object *json_peer = NULL; |
10444 | json_object *json_peers = NULL; | |
50e05855 | 10445 | struct peer_af *paf; |
d3ada366 | 10446 | struct bgp_filter *filter; |
d62a17ae | 10447 | |
10448 | /* labeled-unicast routes are installed in the unicast table so in order | |
10449 | * to | |
10450 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10451 | */ | |
3577f1c5 | 10452 | |
d62a17ae | 10453 | if (safi == SAFI_LABELED_UNICAST) |
10454 | pfx_rcd_safi = SAFI_UNICAST; | |
10455 | else | |
10456 | pfx_rcd_safi = safi; | |
10457 | ||
10458 | if (use_json) { | |
3c13337d | 10459 | json = json_object_new_object(); |
d62a17ae | 10460 | json_peers = json_object_new_object(); |
3577f1c5 DD |
10461 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10462 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10463 | continue; | |
10464 | ||
10465 | if (peer->afc[afi][safi]) { | |
10466 | /* See if we have at least a single failed peer */ | |
10467 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10468 | failed_count++; | |
10469 | count++; | |
10470 | } | |
10471 | if (peer_dynamic_neighbor(peer)) | |
10472 | dn_count++; | |
10473 | } | |
c258527b | 10474 | |
d62a17ae | 10475 | } else { |
10476 | /* Loop over all neighbors that will be displayed to determine | |
10477 | * how many | |
10478 | * characters are needed for the Neighbor column | |
10479 | */ | |
10480 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10481 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10482 | continue; | |
10483 | ||
10484 | if (peer->afc[afi][safi]) { | |
10485 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10486 | if (peer_dynamic_neighbor(peer)) | |
10487 | dn_flag[0] = '*'; | |
10488 | ||
10489 | if (peer->hostname | |
892fedb6 DA |
10490 | && CHECK_FLAG(bgp->flags, |
10491 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10492 | snprintf(neighbor_buf, |
10493 | sizeof(neighbor_buf), | |
10494 | "%s%s(%s) ", dn_flag, | |
10495 | peer->hostname, peer->host); | |
d62a17ae | 10496 | else |
772270f3 QY |
10497 | snprintf(neighbor_buf, |
10498 | sizeof(neighbor_buf), "%s%s ", | |
10499 | dn_flag, peer->host); | |
d62a17ae | 10500 | |
10501 | len = strlen(neighbor_buf); | |
10502 | ||
10503 | if (len > max_neighbor_width) | |
10504 | max_neighbor_width = len; | |
c258527b | 10505 | |
3577f1c5 DD |
10506 | /* See if we have at least a single failed peer */ |
10507 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10508 | failed_count++; | |
10509 | count++; | |
d62a17ae | 10510 | } |
10511 | } | |
f933309e | 10512 | |
d62a17ae | 10513 | /* Originally we displayed the Neighbor column as 16 |
10514 | * characters wide so make that the default | |
10515 | */ | |
10516 | if (max_neighbor_width < neighbor_col_default_width) | |
10517 | max_neighbor_width = neighbor_col_default_width; | |
10518 | } | |
f933309e | 10519 | |
3577f1c5 DD |
10520 | if (show_failed && !failed_count) { |
10521 | if (use_json) { | |
10522 | json_object_int_add(json, "failedPeersCount", 0); | |
10523 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10524 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
10525 | |
10526 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
10527 | json, JSON_C_TO_STRING_PRETTY)); | |
10528 | json_object_free(json); | |
10529 | } else { | |
10530 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
10531 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
10532 | } | |
10533 | return CMD_SUCCESS; | |
10534 | } | |
c258527b | 10535 | |
3577f1c5 | 10536 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 10537 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10538 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10539 | continue; | |
10540 | ||
ea47320b DL |
10541 | if (!peer->afc[afi][safi]) |
10542 | continue; | |
d62a17ae | 10543 | |
ea47320b DL |
10544 | if (!count) { |
10545 | unsigned long ents; | |
10546 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10547 | int64_t vrf_id_ui; |
d62a17ae | 10548 | |
a4d82a8a PZ |
10549 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10550 | ? -1 | |
10551 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10552 | |
10553 | /* Usage summary and header */ | |
10554 | if (use_json) { | |
23d0a753 DA |
10555 | char buf[BUFSIZ] = {0}; |
10556 | ||
ea47320b DL |
10557 | json_object_string_add( |
10558 | json, "routerId", | |
23d0a753 DA |
10559 | inet_ntop(AF_INET, &bgp->router_id, buf, |
10560 | sizeof(buf))); | |
60466a63 QY |
10561 | json_object_int_add(json, "as", bgp->as); |
10562 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10563 | json_object_string_add( |
10564 | json, "vrfName", | |
10565 | (bgp->inst_type | |
10566 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10567 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10568 | : bgp->name); |
10569 | } else { | |
10570 | vty_out(vty, | |
23d0a753 DA |
10571 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10572 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10573 | bgp->vrf_id == VRF_UNKNOWN |
10574 | ? -1 | |
10575 | : (int)bgp->vrf_id); | |
ea47320b DL |
10576 | vty_out(vty, "\n"); |
10577 | } | |
d62a17ae | 10578 | |
ea47320b | 10579 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10580 | if (use_json) { |
ea47320b | 10581 | json_object_int_add( |
60466a63 | 10582 | json, "updateDelayLimit", |
ea47320b | 10583 | bgp->v_update_delay); |
d62a17ae | 10584 | |
ea47320b DL |
10585 | if (bgp->v_update_delay |
10586 | != bgp->v_establish_wait) | |
d62a17ae | 10587 | json_object_int_add( |
10588 | json, | |
ea47320b DL |
10589 | "updateDelayEstablishWait", |
10590 | bgp->v_establish_wait); | |
d62a17ae | 10591 | |
60466a63 | 10592 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10593 | json_object_string_add( |
10594 | json, | |
10595 | "updateDelayFirstNeighbor", | |
10596 | bgp->update_delay_begin_time); | |
10597 | json_object_boolean_true_add( | |
10598 | json, | |
10599 | "updateDelayInProgress"); | |
10600 | } else { | |
10601 | if (bgp->update_delay_over) { | |
d62a17ae | 10602 | json_object_string_add( |
10603 | json, | |
10604 | "updateDelayFirstNeighbor", | |
10605 | bgp->update_delay_begin_time); | |
ea47320b | 10606 | json_object_string_add( |
d62a17ae | 10607 | json, |
ea47320b DL |
10608 | "updateDelayBestpathResumed", |
10609 | bgp->update_delay_end_time); | |
10610 | json_object_string_add( | |
d62a17ae | 10611 | json, |
ea47320b DL |
10612 | "updateDelayZebraUpdateResume", |
10613 | bgp->update_delay_zebra_resume_time); | |
10614 | json_object_string_add( | |
10615 | json, | |
10616 | "updateDelayPeerUpdateResume", | |
10617 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10618 | } |
ea47320b DL |
10619 | } |
10620 | } else { | |
10621 | vty_out(vty, | |
10622 | "Read-only mode update-delay limit: %d seconds\n", | |
10623 | bgp->v_update_delay); | |
10624 | if (bgp->v_update_delay | |
10625 | != bgp->v_establish_wait) | |
d62a17ae | 10626 | vty_out(vty, |
ea47320b DL |
10627 | " Establish wait: %d seconds\n", |
10628 | bgp->v_establish_wait); | |
d62a17ae | 10629 | |
60466a63 | 10630 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10631 | vty_out(vty, |
10632 | " First neighbor established: %s\n", | |
10633 | bgp->update_delay_begin_time); | |
10634 | vty_out(vty, | |
10635 | " Delay in progress\n"); | |
10636 | } else { | |
10637 | if (bgp->update_delay_over) { | |
d62a17ae | 10638 | vty_out(vty, |
10639 | " First neighbor established: %s\n", | |
10640 | bgp->update_delay_begin_time); | |
10641 | vty_out(vty, | |
ea47320b DL |
10642 | " Best-paths resumed: %s\n", |
10643 | bgp->update_delay_end_time); | |
10644 | vty_out(vty, | |
10645 | " zebra update resumed: %s\n", | |
10646 | bgp->update_delay_zebra_resume_time); | |
10647 | vty_out(vty, | |
10648 | " peers update resumed: %s\n", | |
10649 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10650 | } |
10651 | } | |
10652 | } | |
ea47320b | 10653 | } |
d62a17ae | 10654 | |
ea47320b DL |
10655 | if (use_json) { |
10656 | if (bgp_maxmed_onstartup_configured(bgp) | |
10657 | && bgp->maxmed_active) | |
10658 | json_object_boolean_true_add( | |
60466a63 | 10659 | json, "maxMedOnStartup"); |
ea47320b DL |
10660 | if (bgp->v_maxmed_admin) |
10661 | json_object_boolean_true_add( | |
60466a63 | 10662 | json, "maxMedAdministrative"); |
d62a17ae | 10663 | |
ea47320b DL |
10664 | json_object_int_add( |
10665 | json, "tableVersion", | |
60466a63 | 10666 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 10667 | |
60466a63 QY |
10668 | ents = bgp_table_count(bgp->rib[afi][safi]); |
10669 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
10670 | json_object_int_add( |
10671 | json, "ribMemory", | |
9bcb3eef | 10672 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 10673 | |
210ec2a0 | 10674 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
10675 | json_object_int_add(json, "peerCount", ents); |
10676 | json_object_int_add(json, "peerMemory", | |
10677 | ents * sizeof(struct peer)); | |
d62a17ae | 10678 | |
ea47320b DL |
10679 | if ((ents = listcount(bgp->group))) { |
10680 | json_object_int_add( | |
60466a63 | 10681 | json, "peerGroupCount", ents); |
ea47320b DL |
10682 | json_object_int_add( |
10683 | json, "peerGroupMemory", | |
996c9314 LB |
10684 | ents * sizeof(struct |
10685 | peer_group)); | |
ea47320b | 10686 | } |
d62a17ae | 10687 | |
ea47320b DL |
10688 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10689 | BGP_CONFIG_DAMPENING)) | |
10690 | json_object_boolean_true_add( | |
60466a63 | 10691 | json, "dampeningEnabled"); |
ea47320b DL |
10692 | } else { |
10693 | if (bgp_maxmed_onstartup_configured(bgp) | |
10694 | && bgp->maxmed_active) | |
d62a17ae | 10695 | vty_out(vty, |
ea47320b DL |
10696 | "Max-med on-startup active\n"); |
10697 | if (bgp->v_maxmed_admin) | |
d62a17ae | 10698 | vty_out(vty, |
ea47320b | 10699 | "Max-med administrative active\n"); |
d62a17ae | 10700 | |
60466a63 QY |
10701 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
10702 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 10703 | |
60466a63 | 10704 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
10705 | vty_out(vty, |
10706 | "RIB entries %ld, using %s of memory\n", | |
10707 | ents, | |
9bcb3eef DS |
10708 | mtype_memstr( |
10709 | memstrbuf, sizeof(memstrbuf), | |
10710 | ents | |
10711 | * sizeof(struct | |
10712 | bgp_dest))); | |
ea47320b DL |
10713 | |
10714 | /* Peer related usage */ | |
210ec2a0 | 10715 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 10716 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
10717 | ents, |
10718 | mtype_memstr( | |
60466a63 QY |
10719 | memstrbuf, sizeof(memstrbuf), |
10720 | ents * sizeof(struct peer))); | |
ea47320b DL |
10721 | |
10722 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 10723 | vty_out(vty, |
ea47320b | 10724 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 10725 | ents, |
10726 | mtype_memstr( | |
10727 | memstrbuf, | |
10728 | sizeof(memstrbuf), | |
996c9314 LB |
10729 | ents * sizeof(struct |
10730 | peer_group))); | |
d62a17ae | 10731 | |
ea47320b DL |
10732 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10733 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 10734 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 10735 | vty_out(vty, "\n"); |
d62a17ae | 10736 | |
ea47320b DL |
10737 | /* Subtract 8 here because 'Neighbor' is |
10738 | * 8 characters */ | |
10739 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
10740 | vty_out(vty, "%*s", max_neighbor_width - 8, |
10741 | " "); | |
3577f1c5 DD |
10742 | if (show_failed) |
10743 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
10744 | else | |
10745 | vty_out(vty, | |
db92d226 | 10746 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n"); |
d62a17ae | 10747 | } |
ea47320b | 10748 | } |
d62a17ae | 10749 | |
d55811cc | 10750 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 10751 | filter = &peer->filter[afi][safi]; |
db92d226 | 10752 | |
ea47320b | 10753 | count++; |
3577f1c5 DD |
10754 | /* Works for both failed & successful cases */ |
10755 | if (peer_dynamic_neighbor(peer)) | |
10756 | dn_count++; | |
d62a17ae | 10757 | |
ea47320b | 10758 | if (use_json) { |
3577f1c5 DD |
10759 | json_peer = NULL; |
10760 | ||
10761 | if (show_failed && | |
10762 | bgp_has_peer_failed(peer, afi, safi)) { | |
10763 | json_peer = json_object_new_object(); | |
10764 | bgp_show_failed_summary(vty, bgp, peer, | |
10765 | json_peer, 0, use_json); | |
10766 | } else if (!show_failed) { | |
10b49f14 DA |
10767 | if (show_established |
10768 | && bgp_has_peer_failed(peer, afi, safi)) | |
10769 | continue; | |
10770 | ||
3577f1c5 DD |
10771 | json_peer = json_object_new_object(); |
10772 | if (peer_dynamic_neighbor(peer)) { | |
10773 | json_object_boolean_true_add(json_peer, | |
10774 | "dynamicPeer"); | |
10775 | } | |
d62a17ae | 10776 | |
3577f1c5 DD |
10777 | if (peer->hostname) |
10778 | json_object_string_add(json_peer, "hostname", | |
10779 | peer->hostname); | |
10780 | ||
10781 | if (peer->domainname) | |
10782 | json_object_string_add(json_peer, "domainname", | |
10783 | peer->domainname); | |
10784 | ||
10785 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
10786 | json_object_int_add(json_peer, "version", 4); | |
10787 | json_object_int_add(json_peer, "msgRcvd", | |
10788 | PEER_TOTAL_RX(peer)); | |
10789 | json_object_int_add(json_peer, "msgSent", | |
10790 | PEER_TOTAL_TX(peer)); | |
10791 | ||
43aa5965 QY |
10792 | atomic_size_t outq_count, inq_count; |
10793 | outq_count = atomic_load_explicit( | |
10794 | &peer->obuf->count, | |
10795 | memory_order_relaxed); | |
10796 | inq_count = atomic_load_explicit( | |
10797 | &peer->ibuf->count, | |
10798 | memory_order_relaxed); | |
10799 | ||
3577f1c5 DD |
10800 | json_object_int_add(json_peer, "tableVersion", |
10801 | peer->version[afi][safi]); | |
10802 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
10803 | outq_count); |
10804 | json_object_int_add(json_peer, "inq", | |
10805 | inq_count); | |
3577f1c5 DD |
10806 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
10807 | use_json, json_peer); | |
10808 | ||
3577f1c5 DD |
10809 | json_object_int_add(json_peer, "pfxRcd", |
10810 | peer->pcount[afi][pfx_rcd_safi]); | |
10811 | ||
3577f1c5 | 10812 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
10813 | json_object_int_add( |
10814 | json_peer, "pfxSnt", | |
10815 | (PAF_SUBGRP(paf))->scount); | |
10816 | else | |
10817 | json_object_int_add(json_peer, "pfxSnt", | |
10818 | 0); | |
0e1f8ab5 DA |
10819 | |
10820 | /* BGP FSM state */ | |
cb9196e7 | 10821 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
10822 | || CHECK_FLAG(peer->bgp->flags, |
10823 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
10824 | json_object_string_add(json_peer, |
10825 | "state", | |
3577f1c5 DD |
10826 | "Idle (Admin)"); |
10827 | else if (peer->afc_recv[afi][safi]) | |
10828 | json_object_string_add( | |
0e1f8ab5 DA |
10829 | json_peer, "state", |
10830 | lookup_msg(bgp_status_msg, | |
10831 | peer->status, NULL)); | |
10832 | else if (CHECK_FLAG( | |
10833 | peer->sflags, | |
10834 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10835 | json_object_string_add(json_peer, | |
10836 | "state", | |
3577f1c5 DD |
10837 | "Idle (PfxCt)"); |
10838 | else | |
10839 | json_object_string_add( | |
0e1f8ab5 DA |
10840 | json_peer, "state", |
10841 | lookup_msg(bgp_status_msg, | |
10842 | peer->status, NULL)); | |
10843 | ||
10844 | /* BGP peer state */ | |
10845 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
10846 | || CHECK_FLAG(peer->bgp->flags, | |
10847 | BGP_FLAG_SHUTDOWN)) | |
10848 | json_object_string_add(json_peer, | |
10849 | "peerState", | |
10850 | "Admin"); | |
10851 | else if (CHECK_FLAG( | |
10852 | peer->sflags, | |
10853 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10854 | json_object_string_add(json_peer, | |
10855 | "peerState", | |
10856 | "PfxCt"); | |
10857 | else if (CHECK_FLAG(peer->flags, | |
10858 | PEER_FLAG_PASSIVE)) | |
10859 | json_object_string_add(json_peer, | |
10860 | "peerState", | |
10861 | "Passive"); | |
10862 | else if (CHECK_FLAG(peer->sflags, | |
10863 | PEER_STATUS_NSF_WAIT)) | |
10864 | json_object_string_add(json_peer, | |
10865 | "peerState", | |
10866 | "NSF passive"); | |
10867 | else if (CHECK_FLAG( | |
10868 | peer->bgp->flags, | |
10869 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10870 | && (!bgp_inbound_policy_exists(peer, | |
10871 | filter) | |
10872 | || !bgp_outbound_policy_exists( | |
10873 | peer, filter))) | |
10874 | json_object_string_add(json_peer, | |
10875 | "peerState", | |
10876 | "Policy"); | |
10877 | else | |
10878 | json_object_string_add( | |
10879 | json_peer, "peerState", "OK"); | |
10880 | ||
200116db DD |
10881 | json_object_int_add(json_peer, "connectionsEstablished", |
10882 | peer->established); | |
10883 | json_object_int_add(json_peer, "connectionsDropped", | |
10884 | peer->dropped); | |
b4e9dcba | 10885 | } |
3577f1c5 DD |
10886 | /* Avoid creating empty peer dicts in JSON */ |
10887 | if (json_peer == NULL) | |
10888 | continue; | |
ea47320b DL |
10889 | |
10890 | if (peer->conf_if) | |
60466a63 | 10891 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
10892 | "interface"); |
10893 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
10894 | json_object_string_add(json_peer, "idType", |
10895 | "ipv4"); | |
ea47320b | 10896 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
10897 | json_object_string_add(json_peer, "idType", |
10898 | "ipv6"); | |
ea47320b DL |
10899 | json_object_object_add(json_peers, peer->host, |
10900 | json_peer); | |
10901 | } else { | |
3577f1c5 DD |
10902 | if (show_failed && |
10903 | bgp_has_peer_failed(peer, afi, safi)) { | |
10904 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10905 | max_neighbor_width, | |
10906 | use_json); | |
10907 | } else if (!show_failed) { | |
10b49f14 DA |
10908 | if (show_established |
10909 | && bgp_has_peer_failed(peer, afi, safi)) | |
10910 | continue; | |
10911 | ||
3577f1c5 DD |
10912 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10913 | if (peer_dynamic_neighbor(peer)) { | |
10914 | dn_flag[0] = '*'; | |
10915 | } | |
d62a17ae | 10916 | |
3577f1c5 | 10917 | if (peer->hostname |
892fedb6 DA |
10918 | && CHECK_FLAG(bgp->flags, |
10919 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10920 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10921 | peer->hostname, |
10922 | peer->host); | |
d62a17ae | 10923 | else |
3577f1c5 DD |
10924 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10925 | ||
10926 | /* pad the neighbor column with spaces */ | |
10927 | if (len < max_neighbor_width) | |
10928 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10929 | " "); | |
10930 | ||
43aa5965 QY |
10931 | atomic_size_t outq_count, inq_count; |
10932 | outq_count = atomic_load_explicit( | |
10933 | &peer->obuf->count, | |
10934 | memory_order_relaxed); | |
10935 | inq_count = atomic_load_explicit( | |
10936 | &peer->ibuf->count, | |
10937 | memory_order_relaxed); | |
10938 | ||
566bdaf6 | 10939 | vty_out(vty, |
6cde4b45 | 10940 | "4 %10u %9u %9u %8" PRIu64" %4zu %4zu %8s", |
3577f1c5 | 10941 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 10942 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
10943 | peer->version[afi][safi], inq_count, |
10944 | outq_count, | |
3577f1c5 DD |
10945 | peer_uptime(peer->uptime, timebuf, |
10946 | BGP_UPTIME_LEN, 0, NULL)); | |
10947 | ||
db92d226 | 10948 | if (peer->status == Established) { |
d3ada366 DA |
10949 | if (peer->afc_recv[afi][safi]) { |
10950 | if (CHECK_FLAG( | |
10951 | bgp->flags, | |
10952 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10953 | && !bgp_inbound_policy_exists( | |
10954 | peer, filter)) | |
10955 | vty_out(vty, " %12s", | |
10956 | "(Policy)"); | |
10957 | else | |
10958 | vty_out(vty, | |
6cde4b45 | 10959 | " %12u", |
d3ada366 DA |
10960 | peer->pcount |
10961 | [afi] | |
10962 | [pfx_rcd_safi]); | |
10963 | } else { | |
3577f1c5 | 10964 | vty_out(vty, " NoNeg"); |
d3ada366 | 10965 | } |
db92d226 | 10966 | |
d3ada366 DA |
10967 | if (paf && PAF_SUBGRP(paf)) { |
10968 | if (CHECK_FLAG( | |
10969 | bgp->flags, | |
10970 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10971 | && !bgp_outbound_policy_exists( | |
10972 | peer, filter)) | |
10973 | vty_out(vty, " %8s", | |
10974 | "(Policy)"); | |
10975 | else | |
10976 | vty_out(vty, | |
6cde4b45 | 10977 | " %8u", |
d3ada366 DA |
10978 | (PAF_SUBGRP( |
10979 | paf)) | |
10980 | ->scount); | |
10981 | } | |
db92d226 | 10982 | } else { |
736b68f3 DS |
10983 | if (CHECK_FLAG(peer->flags, |
10984 | PEER_FLAG_SHUTDOWN) | |
10985 | || CHECK_FLAG(peer->bgp->flags, | |
10986 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10987 | vty_out(vty, " Idle (Admin)"); |
10988 | else if (CHECK_FLAG( | |
10989 | peer->sflags, | |
10990 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10991 | vty_out(vty, " Idle (PfxCt)"); | |
10992 | else | |
10993 | vty_out(vty, " %12s", | |
10994 | lookup_msg(bgp_status_msg, | |
10995 | peer->status, NULL)); | |
db92d226 | 10996 | |
6cde4b45 | 10997 | vty_out(vty, " %8u", 0); |
3577f1c5 DD |
10998 | } |
10999 | vty_out(vty, "\n"); | |
d62a17ae | 11000 | } |
3577f1c5 | 11001 | |
d62a17ae | 11002 | } |
11003 | } | |
f933309e | 11004 | |
d62a17ae | 11005 | if (use_json) { |
11006 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 11007 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 11008 | json_object_int_add(json, "totalPeers", count); |
11009 | json_object_int_add(json, "dynamicPeers", dn_count); | |
11010 | ||
3577f1c5 DD |
11011 | if (!show_failed) |
11012 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 11013 | |
996c9314 LB |
11014 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
11015 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 11016 | json_object_free(json); |
11017 | } else { | |
11018 | if (count) | |
11019 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
11020 | else { | |
d6ceaca3 | 11021 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 11022 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11023 | } |
b05a1c8b | 11024 | |
d6ceaca3 | 11025 | if (dn_count) { |
d62a17ae | 11026 | vty_out(vty, "* - dynamic neighbor\n"); |
11027 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
11028 | dn_count, bgp->dynamic_neighbors_limit); | |
11029 | } | |
11030 | } | |
1ff9a340 | 11031 | |
d62a17ae | 11032 | return CMD_SUCCESS; |
718e3744 | 11033 | } |
11034 | ||
d62a17ae | 11035 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
10b49f14 DA |
11036 | int safi, bool show_failed, |
11037 | bool show_established, bool use_json) | |
d62a17ae | 11038 | { |
11039 | int is_first = 1; | |
11040 | int afi_wildcard = (afi == AFI_MAX); | |
11041 | int safi_wildcard = (safi == SAFI_MAX); | |
11042 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11043 | bool nbr_output = false; |
d62a17ae | 11044 | |
11045 | if (use_json && is_wildcard) | |
11046 | vty_out(vty, "{\n"); | |
11047 | if (afi_wildcard) | |
11048 | afi = 1; /* AFI_IP */ | |
11049 | while (afi < AFI_MAX) { | |
11050 | if (safi_wildcard) | |
11051 | safi = 1; /* SAFI_UNICAST */ | |
11052 | while (safi < SAFI_MAX) { | |
318cac96 | 11053 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11054 | nbr_output = true; |
f86897b9 | 11055 | |
d62a17ae | 11056 | if (is_wildcard) { |
11057 | /* | |
11058 | * So limit output to those afi/safi | |
11059 | * pairs that | |
11060 | * actualy have something interesting in | |
11061 | * them | |
11062 | */ | |
11063 | if (use_json) { | |
d62a17ae | 11064 | if (!is_first) |
11065 | vty_out(vty, ",\n"); | |
11066 | else | |
11067 | is_first = 0; | |
11068 | ||
11069 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11070 | get_afi_safi_str(afi, |
11071 | safi, | |
11072 | true)); | |
d62a17ae | 11073 | } else { |
11074 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
11075 | get_afi_safi_str(afi, |
11076 | safi, | |
11077 | false)); | |
d62a17ae | 11078 | } |
11079 | } | |
10b49f14 DA |
11080 | bgp_show_summary(vty, bgp, afi, safi, |
11081 | show_failed, show_established, | |
3577f1c5 | 11082 | use_json); |
d62a17ae | 11083 | } |
11084 | safi++; | |
d62a17ae | 11085 | if (!safi_wildcard) |
11086 | safi = SAFI_MAX; | |
11087 | } | |
11088 | afi++; | |
ee851c8c | 11089 | if (!afi_wildcard) |
d62a17ae | 11090 | afi = AFI_MAX; |
11091 | } | |
11092 | ||
11093 | if (use_json && is_wildcard) | |
11094 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11095 | else if (!nbr_output) { |
11096 | if (use_json) | |
11097 | vty_out(vty, "{}\n"); | |
11098 | else | |
11099 | vty_out(vty, "%% No BGP neighbors found\n"); | |
11100 | } | |
d62a17ae | 11101 | } |
11102 | ||
11103 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 | 11104 | safi_t safi, bool show_failed, |
10b49f14 | 11105 | bool show_established, |
3577f1c5 | 11106 | bool use_json) |
d62a17ae | 11107 | { |
11108 | struct listnode *node, *nnode; | |
11109 | struct bgp *bgp; | |
d62a17ae | 11110 | int is_first = 1; |
9f049418 | 11111 | bool nbr_output = false; |
d62a17ae | 11112 | |
11113 | if (use_json) | |
11114 | vty_out(vty, "{\n"); | |
11115 | ||
11116 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11117 | nbr_output = true; |
d62a17ae | 11118 | if (use_json) { |
d62a17ae | 11119 | if (!is_first) |
11120 | vty_out(vty, ",\n"); | |
11121 | else | |
11122 | is_first = 0; | |
11123 | ||
11124 | vty_out(vty, "\"%s\":", | |
11125 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11126 | ? VRF_DEFAULT_NAME |
d62a17ae | 11127 | : bgp->name); |
11128 | } else { | |
11129 | vty_out(vty, "\nInstance %s:\n", | |
11130 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11131 | ? VRF_DEFAULT_NAME |
d62a17ae | 11132 | : bgp->name); |
11133 | } | |
3577f1c5 | 11134 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 11135 | show_established, use_json); |
d62a17ae | 11136 | } |
11137 | ||
11138 | if (use_json) | |
11139 | vty_out(vty, "}\n"); | |
9f049418 DS |
11140 | else if (!nbr_output) |
11141 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11142 | } |
11143 | ||
11144 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
10b49f14 DA |
11145 | safi_t safi, bool show_failed, bool show_established, |
11146 | bool use_json) | |
d62a17ae | 11147 | { |
11148 | struct bgp *bgp; | |
11149 | ||
11150 | if (name) { | |
11151 | if (strmatch(name, "all")) { | |
10b49f14 DA |
11152 | bgp_show_all_instances_summary_vty( |
11153 | vty, afi, safi, show_failed, show_established, | |
11154 | use_json); | |
d62a17ae | 11155 | return CMD_SUCCESS; |
11156 | } else { | |
11157 | bgp = bgp_lookup_by_name(name); | |
11158 | ||
11159 | if (!bgp) { | |
11160 | if (use_json) | |
11161 | vty_out(vty, "{}\n"); | |
11162 | else | |
11163 | vty_out(vty, | |
ca61fd25 | 11164 | "%% BGP instance not found\n"); |
d62a17ae | 11165 | return CMD_WARNING; |
11166 | } | |
11167 | ||
f86897b9 | 11168 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
10b49f14 DA |
11169 | show_failed, show_established, |
11170 | use_json); | |
d62a17ae | 11171 | return CMD_SUCCESS; |
11172 | } | |
11173 | } | |
11174 | ||
11175 | bgp = bgp_get_default(); | |
11176 | ||
11177 | if (bgp) | |
3577f1c5 | 11178 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 11179 | show_established, use_json); |
9f049418 | 11180 | else { |
ca61fd25 DS |
11181 | if (use_json) |
11182 | vty_out(vty, "{}\n"); | |
11183 | else | |
11184 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11185 | return CMD_WARNING; |
11186 | } | |
d62a17ae | 11187 | |
11188 | return CMD_SUCCESS; | |
4fb25c53 DW |
11189 | } |
11190 | ||
716b2d8a | 11191 | /* `show [ip] bgp summary' commands. */ |
96f3485c | 11192 | DEFPY (show_ip_bgp_summary, |
718e3744 | 11193 | show_ip_bgp_summary_cmd, |
96f3485c | 11194 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] summary [established|failed] [json$uj]", |
718e3744 | 11195 | SHOW_STR |
11196 | IP_STR | |
11197 | BGP_STR | |
8386ac43 | 11198 | BGP_INSTANCE_HELP_STR |
46f296b4 | 11199 | BGP_AFI_HELP_STR |
dd6bd0f1 | 11200 | BGP_SAFI_WITH_LABEL_HELP_STR |
96f3485c | 11201 | "Display the entries for all address families\n" |
b05a1c8b | 11202 | "Summary of BGP neighbor status\n" |
10b49f14 | 11203 | "Show only sessions in Established state\n" |
3577f1c5 | 11204 | "Show only sessions not in Established state\n" |
9973d184 | 11205 | JSON_STR) |
718e3744 | 11206 | { |
d62a17ae | 11207 | char *vrf = NULL; |
11208 | afi_t afi = AFI_MAX; | |
11209 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 11210 | bool show_failed = false; |
10b49f14 | 11211 | bool show_established = false; |
d62a17ae | 11212 | |
11213 | int idx = 0; | |
11214 | ||
11215 | /* show [ip] bgp */ | |
96f3485c | 11216 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11217 | afi = AFI_IP; |
9a8bdf1c PG |
11218 | /* [<vrf> VIEWVRFNAME] */ |
11219 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11220 | vrf = argv[idx + 1]->arg; | |
11221 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11222 | vrf = NULL; | |
11223 | } else if (argv_find(argv, argc, "view", &idx)) | |
11224 | /* [<view> VIEWVRFNAME] */ | |
11225 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11226 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11227 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11228 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11229 | } | |
11230 | ||
3577f1c5 DD |
11231 | if (argv_find(argv, argc, "failed", &idx)) |
11232 | show_failed = true; | |
10b49f14 DA |
11233 | if (argv_find(argv, argc, "established", &idx)) |
11234 | show_established = true; | |
3577f1c5 | 11235 | |
10b49f14 DA |
11236 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, |
11237 | show_established, uj); | |
d62a17ae | 11238 | } |
11239 | ||
5cb5f4d0 | 11240 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11241 | { |
5cb5f4d0 DD |
11242 | if (for_json) |
11243 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11244 | else |
5cb5f4d0 | 11245 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11246 | } |
11247 | ||
d62a17ae | 11248 | |
11249 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11250 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11251 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11252 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11253 | bool use_json, json_object *json_pref) |
d62a17ae | 11254 | { |
11255 | /* Send-Mode */ | |
11256 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11257 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11258 | if (use_json) { | |
11259 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11260 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11261 | json_object_string_add(json_pref, "sendMode", | |
11262 | "advertisedAndReceived"); | |
11263 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11264 | json_object_string_add(json_pref, "sendMode", | |
11265 | "advertised"); | |
11266 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11267 | json_object_string_add(json_pref, "sendMode", | |
11268 | "received"); | |
11269 | } else { | |
11270 | vty_out(vty, " Send-mode: "); | |
11271 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11272 | vty_out(vty, "advertised"); | |
11273 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11274 | vty_out(vty, "%sreceived", | |
11275 | CHECK_FLAG(p->af_cap[afi][safi], | |
11276 | adv_smcap) | |
11277 | ? ", " | |
11278 | : ""); | |
11279 | vty_out(vty, "\n"); | |
11280 | } | |
11281 | } | |
11282 | ||
11283 | /* Receive-Mode */ | |
11284 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11285 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11286 | if (use_json) { | |
11287 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11288 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11289 | json_object_string_add(json_pref, "recvMode", | |
11290 | "advertisedAndReceived"); | |
11291 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11292 | json_object_string_add(json_pref, "recvMode", | |
11293 | "advertised"); | |
11294 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11295 | json_object_string_add(json_pref, "recvMode", | |
11296 | "received"); | |
11297 | } else { | |
11298 | vty_out(vty, " Receive-mode: "); | |
11299 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11300 | vty_out(vty, "advertised"); | |
11301 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11302 | vty_out(vty, "%sreceived", | |
11303 | CHECK_FLAG(p->af_cap[afi][safi], | |
11304 | adv_rmcap) | |
11305 | ? ", " | |
11306 | : ""); | |
11307 | vty_out(vty, "\n"); | |
11308 | } | |
11309 | } | |
11310 | } | |
11311 | ||
13909c4f DS |
11312 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
11313 | struct peer *p, | |
11314 | bool use_json, | |
11315 | json_object *json) | |
2986cac2 | 11316 | { |
08c2d52a | 11317 | bool rbit_status = false; |
2986cac2 | 11318 | |
11319 | if (!use_json) | |
a53ca37b | 11320 | vty_out(vty, "\n R bit: "); |
2986cac2 | 11321 | |
13909c4f DS |
11322 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11323 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
11324 | && (p->status == Established)) { | |
2986cac2 | 11325 | |
11326 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 11327 | rbit_status = true; |
2986cac2 | 11328 | else |
08c2d52a | 11329 | rbit_status = false; |
2986cac2 | 11330 | } |
11331 | ||
11332 | if (rbit_status) { | |
11333 | if (use_json) | |
13909c4f | 11334 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 11335 | else |
11336 | vty_out(vty, "True\n"); | |
11337 | } else { | |
11338 | if (use_json) | |
13909c4f | 11339 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 11340 | else |
11341 | vty_out(vty, "False\n"); | |
11342 | } | |
11343 | } | |
11344 | ||
13909c4f DS |
11345 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11346 | struct peer *peer, | |
11347 | bool use_json, | |
11348 | json_object *json) | |
2986cac2 | 11349 | { |
2bb5d39b | 11350 | const char *mode = "NotApplicable"; |
2986cac2 | 11351 | |
11352 | if (!use_json) | |
a53ca37b | 11353 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11354 | |
13909c4f DS |
11355 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11356 | && (peer->status == Established)) { | |
2986cac2 | 11357 | |
13909c4f DS |
11358 | if ((peer->nsf_af_count == 0) |
11359 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11360 | |
2986cac2 | 11361 | mode = "Disable"; |
11362 | ||
13909c4f DS |
11363 | } else if (peer->nsf_af_count == 0 |
11364 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11365 | |
2986cac2 | 11366 | mode = "Helper"; |
11367 | ||
13909c4f DS |
11368 | } else if (peer->nsf_af_count != 0 |
11369 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11370 | |
2986cac2 | 11371 | mode = "Restart"; |
2986cac2 | 11372 | } |
11373 | } | |
11374 | ||
11375 | if (use_json) { | |
13909c4f | 11376 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11377 | } else |
11378 | vty_out(vty, mode, "\n"); | |
11379 | } | |
11380 | ||
13909c4f DS |
11381 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11382 | struct peer *p, | |
11383 | bool use_json, | |
11384 | json_object *json) | |
2986cac2 | 11385 | { |
11386 | const char *mode = "Invalid"; | |
11387 | ||
11388 | if (!use_json) | |
a53ca37b | 11389 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11390 | |
11391 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11392 | mode = "Helper"; | |
11393 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11394 | mode = "Restart"; | |
11395 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11396 | mode = "Disable"; | |
2ba1fe69 | 11397 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11398 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11399 | mode = "Helper*"; | |
11400 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11401 | mode = "Restart*"; | |
11402 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11403 | mode = "Disable*"; | |
11404 | else | |
11405 | mode = "Invalid*"; | |
2ba1fe69 | 11406 | } |
2986cac2 | 11407 | |
11408 | if (use_json) { | |
13909c4f | 11409 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11410 | } else { |
11411 | vty_out(vty, mode, "\n"); | |
11412 | } | |
11413 | } | |
11414 | ||
13909c4f DS |
11415 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11416 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11417 | { |
2ba1fe69 | 11418 | afi_t afi; |
11419 | safi_t safi; | |
2986cac2 | 11420 | json_object *json_afi_safi = NULL; |
11421 | json_object *json_timer = NULL; | |
11422 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11423 | bool eor_flag = false; |
2986cac2 | 11424 | |
11425 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11426 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
11427 | if (!peer->afc[afi][safi]) |
11428 | continue; | |
2986cac2 | 11429 | |
13909c4f DS |
11430 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11431 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11432 | continue; | |
9e3b51a7 | 11433 | |
13909c4f DS |
11434 | if (use_json) { |
11435 | json_afi_safi = json_object_new_object(); | |
11436 | json_endofrib_status = json_object_new_object(); | |
11437 | json_timer = json_object_new_object(); | |
11438 | } | |
2986cac2 | 11439 | |
13909c4f DS |
11440 | if (peer->eor_stime[afi][safi] |
11441 | >= peer->pkt_stime[afi][safi]) | |
11442 | eor_flag = true; | |
11443 | else | |
11444 | eor_flag = false; | |
2986cac2 | 11445 | |
13909c4f | 11446 | if (!use_json) { |
a53ca37b | 11447 | vty_out(vty, " %s:\n", |
13909c4f | 11448 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 11449 | |
a53ca37b | 11450 | vty_out(vty, " F bit: "); |
698ba8d0 | 11451 | } |
2986cac2 | 11452 | |
13909c4f DS |
11453 | if (peer->nsf[afi][safi] |
11454 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
11455 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11456 | |
13909c4f DS |
11457 | if (use_json) { |
11458 | json_object_boolean_true_add( | |
2986cac2 | 11459 | json_afi_safi, "fBit"); |
13909c4f DS |
11460 | } else |
11461 | vty_out(vty, "True\n"); | |
11462 | } else { | |
11463 | if (use_json) | |
11464 | json_object_boolean_false_add( | |
11465 | json_afi_safi, "fBit"); | |
11466 | else | |
11467 | vty_out(vty, "False\n"); | |
11468 | } | |
2986cac2 | 11469 | |
13909c4f | 11470 | if (!use_json) |
a53ca37b | 11471 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 11472 | |
13909c4f DS |
11473 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11474 | PEER_STATUS_EOR_SEND)) { | |
11475 | if (use_json) { | |
11476 | json_object_boolean_true_add( | |
2986cac2 | 11477 | json_endofrib_status, |
13909c4f | 11478 | "endOfRibSend"); |
9e3b51a7 | 11479 | |
13909c4f DS |
11480 | PRINT_EOR_JSON(eor_flag); |
11481 | } else { | |
11482 | vty_out(vty, "Yes\n"); | |
11483 | vty_out(vty, | |
a53ca37b | 11484 | " End-of-RIB sent after update: "); |
2986cac2 | 11485 | |
13909c4f DS |
11486 | PRINT_EOR(eor_flag); |
11487 | } | |
11488 | } else { | |
11489 | if (use_json) { | |
11490 | json_object_boolean_false_add( | |
2986cac2 | 11491 | json_endofrib_status, |
13909c4f DS |
11492 | "endOfRibSend"); |
11493 | json_object_boolean_false_add( | |
9e3b51a7 | 11494 | json_endofrib_status, |
13909c4f DS |
11495 | "endOfRibSentAfterUpdate"); |
11496 | } else { | |
11497 | vty_out(vty, "No\n"); | |
11498 | vty_out(vty, | |
a53ca37b | 11499 | " End-of-RIB sent after update: "); |
13909c4f | 11500 | vty_out(vty, "No\n"); |
2986cac2 | 11501 | } |
13909c4f | 11502 | } |
2986cac2 | 11503 | |
a53ca37b DA |
11504 | if (!use_json) |
11505 | vty_out(vty, " End-of-RIB received: "); | |
11506 | ||
11507 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
11508 | PEER_STATUS_EOR_RECEIVED)) { | |
11509 | if (use_json) | |
11510 | json_object_boolean_true_add( | |
11511 | json_endofrib_status, | |
11512 | "endOfRibRecv"); | |
11513 | else | |
11514 | vty_out(vty, "Yes\n"); | |
11515 | } else { | |
11516 | if (use_json) | |
11517 | json_object_boolean_false_add( | |
11518 | json_endofrib_status, | |
11519 | "endOfRibRecv"); | |
11520 | else | |
11521 | vty_out(vty, "No\n"); | |
11522 | } | |
11523 | ||
13909c4f DS |
11524 | if (use_json) { |
11525 | json_object_int_add(json_timer, | |
11526 | "stalePathTimer", | |
11527 | peer->bgp->stalepath_time); | |
2986cac2 | 11528 | |
13909c4f DS |
11529 | if (peer->t_gr_stale != NULL) { |
11530 | json_object_int_add( | |
2986cac2 | 11531 | json_timer, |
11532 | "stalePathTimerRemaining", | |
11533 | thread_timer_remain_second( | |
13909c4f DS |
11534 | peer->t_gr_stale)); |
11535 | } | |
3a75afa4 | 11536 | |
13909c4f DS |
11537 | /* Display Configured Selection |
11538 | * Deferral only when when | |
11539 | * Gr mode is enabled. | |
11540 | */ | |
11541 | if (CHECK_FLAG(peer->flags, | |
11542 | PEER_FLAG_GRACEFUL_RESTART)) { | |
11543 | json_object_int_add( | |
3a75afa4 | 11544 | json_timer, |
2986cac2 | 11545 | "selectionDeferralTimer", |
11546 | peer->bgp->stalepath_time); | |
13909c4f | 11547 | } |
2986cac2 | 11548 | |
13909c4f DS |
11549 | if (peer->bgp->gr_info[afi][safi] |
11550 | .t_select_deferral | |
11551 | != NULL) { | |
2986cac2 | 11552 | |
13909c4f | 11553 | json_object_int_add( |
2986cac2 | 11554 | json_timer, |
11555 | "selectionDeferralTimerRemaining", | |
11556 | thread_timer_remain_second( | |
13909c4f DS |
11557 | peer->bgp |
11558 | ->gr_info[afi] | |
11559 | [safi] | |
11560 | .t_select_deferral)); | |
11561 | } | |
11562 | } else { | |
a53ca37b | 11563 | vty_out(vty, " Timers:\n"); |
13909c4f | 11564 | vty_out(vty, |
a53ca37b DA |
11565 | " Configured Stale Path Time(sec): %u\n", |
11566 | peer->bgp->stalepath_time); | |
2986cac2 | 11567 | |
a53ca37b | 11568 | if (peer->t_gr_stale != NULL) |
2986cac2 | 11569 | vty_out(vty, |
a53ca37b | 11570 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 11571 | thread_timer_remain_second( |
13909c4f | 11572 | peer->t_gr_stale)); |
13909c4f DS |
11573 | /* Display Configured Selection |
11574 | * Deferral only when when | |
11575 | * Gr mode is enabled. | |
11576 | */ | |
11577 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 11578 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 11579 | vty_out(vty, |
a53ca37b | 11580 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 11581 | peer->bgp->select_defer_time); |
2986cac2 | 11582 | |
13909c4f DS |
11583 | if (peer->bgp->gr_info[afi][safi] |
11584 | .t_select_deferral | |
a53ca37b | 11585 | != NULL) |
13909c4f | 11586 | vty_out(vty, |
a53ca37b | 11587 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 11588 | thread_timer_remain_second( |
13909c4f DS |
11589 | peer->bgp |
11590 | ->gr_info[afi] | |
11591 | [safi] | |
11592 | .t_select_deferral)); | |
2986cac2 | 11593 | } |
13909c4f DS |
11594 | if (use_json) { |
11595 | json_object_object_add(json_afi_safi, | |
11596 | "endOfRibStatus", | |
11597 | json_endofrib_status); | |
11598 | json_object_object_add(json_afi_safi, "timers", | |
11599 | json_timer); | |
11600 | json_object_object_add( | |
11601 | json, get_afi_safi_str(afi, safi, true), | |
11602 | json_afi_safi); | |
11603 | } | |
2986cac2 | 11604 | } |
11605 | } | |
11606 | } | |
11607 | ||
36235319 QY |
11608 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
11609 | struct peer *p, | |
11610 | bool use_json, | |
11611 | json_object *json) | |
2986cac2 | 11612 | { |
11613 | if (use_json) { | |
11614 | json_object *json_timer = NULL; | |
11615 | ||
11616 | json_timer = json_object_new_object(); | |
11617 | ||
13909c4f DS |
11618 | json_object_int_add(json_timer, "configuredRestartTimer", |
11619 | p->bgp->restart_time); | |
2986cac2 | 11620 | |
13909c4f DS |
11621 | json_object_int_add(json_timer, "receivedRestartTimer", |
11622 | p->v_gr_restart); | |
2986cac2 | 11623 | |
13909c4f DS |
11624 | if (p->t_gr_restart != NULL) |
11625 | json_object_int_add( | |
11626 | json_timer, "restartTimerRemaining", | |
11627 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 11628 | |
11629 | json_object_object_add(json, "timers", json_timer); | |
11630 | } else { | |
11631 | ||
a53ca37b DA |
11632 | vty_out(vty, " Timers:\n"); |
11633 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 11634 | p->bgp->restart_time); |
2986cac2 | 11635 | |
a53ca37b | 11636 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
11637 | p->v_gr_restart); |
11638 | if (p->t_gr_restart != NULL) | |
a53ca37b | 11639 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 11640 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 11641 | if (p->t_gr_restart != NULL) { |
a53ca37b | 11642 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
11643 | thread_timer_remain_second(p->t_gr_restart)); |
11644 | } | |
2986cac2 | 11645 | } |
11646 | } | |
11647 | ||
11648 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 11649 | bool use_json, json_object *json) |
2986cac2 | 11650 | { |
11651 | char buf[SU_ADDRSTRLEN] = {0}; | |
11652 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
11653 | /* '*' + v6 address of neighbor */ |
11654 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 11655 | |
2986cac2 | 11656 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
11657 | dn_flag[0] = '*'; | |
11658 | ||
11659 | if (p->conf_if) { | |
11660 | if (use_json) | |
13909c4f DS |
11661 | json_object_string_add( |
11662 | json, "neighborAddr", | |
2986cac2 | 11663 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
11664 | ? "none" |
11665 | : sockunion2str(&p->su, buf, | |
11666 | SU_ADDRSTRLEN)); | |
2986cac2 | 11667 | else |
13909c4f | 11668 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 11669 | BGP_PEER_SU_UNSPEC(p) |
11670 | ? "none" | |
11671 | : sockunion2str(&p->su, buf, | |
11672 | SU_ADDRSTRLEN)); | |
11673 | } else { | |
772270f3 QY |
11674 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
11675 | p->host); | |
2986cac2 | 11676 | |
11677 | if (use_json) | |
36235319 QY |
11678 | json_object_string_add(json, "neighborAddr", |
11679 | neighborAddr); | |
2986cac2 | 11680 | else |
36235319 | 11681 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 11682 | } |
11683 | ||
11684 | /* more gr info in new format */ | |
11685 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11686 | } | |
11687 | ||
d62a17ae | 11688 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 11689 | safi_t safi, bool use_json, |
d62a17ae | 11690 | json_object *json_neigh) |
11691 | { | |
0291c246 MK |
11692 | struct bgp_filter *filter; |
11693 | struct peer_af *paf; | |
11694 | char orf_pfx_name[BUFSIZ]; | |
11695 | int orf_pfx_count; | |
11696 | json_object *json_af = NULL; | |
11697 | json_object *json_prefA = NULL; | |
11698 | json_object *json_prefB = NULL; | |
11699 | json_object *json_addr = NULL; | |
fa36596c | 11700 | json_object *json_advmap = NULL; |
d62a17ae | 11701 | |
11702 | if (use_json) { | |
11703 | json_addr = json_object_new_object(); | |
11704 | json_af = json_object_new_object(); | |
11705 | filter = &p->filter[afi][safi]; | |
11706 | ||
11707 | if (peer_group_active(p)) | |
11708 | json_object_string_add(json_addr, "peerGroupMember", | |
11709 | p->group->name); | |
11710 | ||
11711 | paf = peer_af_find(p, afi, safi); | |
11712 | if (paf && PAF_SUBGRP(paf)) { | |
11713 | json_object_int_add(json_addr, "updateGroupId", | |
11714 | PAF_UPDGRP(paf)->id); | |
11715 | json_object_int_add(json_addr, "subGroupId", | |
11716 | PAF_SUBGRP(paf)->id); | |
11717 | json_object_int_add(json_addr, "packetQueueLength", | |
11718 | bpacket_queue_virtual_length(paf)); | |
11719 | } | |
11720 | ||
11721 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11722 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11723 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11724 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11725 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11726 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11727 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11728 | json_object_int_add(json_af, "orfType", | |
11729 | ORF_TYPE_PREFIX); | |
11730 | json_prefA = json_object_new_object(); | |
11731 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11732 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11733 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11734 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11735 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11736 | use_json, json_prefA); | |
11737 | json_object_object_add(json_af, "orfPrefixList", | |
11738 | json_prefA); | |
11739 | } | |
11740 | ||
11741 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11742 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11743 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11744 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11745 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11746 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11747 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11748 | json_object_int_add(json_af, "orfOldType", | |
11749 | ORF_TYPE_PREFIX_OLD); | |
11750 | json_prefB = json_object_new_object(); | |
11751 | bgp_show_peer_afi_orf_cap( | |
11752 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11753 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11754 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11755 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11756 | json_prefB); | |
11757 | json_object_object_add(json_af, "orfOldPrefixList", | |
11758 | json_prefB); | |
11759 | } | |
11760 | ||
11761 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11762 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11763 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11764 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11765 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11766 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11767 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11768 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11769 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11770 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11771 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11772 | json_object_object_add(json_addr, "afDependentCap", | |
11773 | json_af); | |
11774 | else | |
11775 | json_object_free(json_af); | |
11776 | ||
772270f3 QY |
11777 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11778 | p->host, afi, safi); | |
d62a17ae | 11779 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11780 | NULL, afi, orf_pfx_name, use_json); | |
11781 | ||
11782 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11783 | PEER_STATUS_ORF_PREFIX_SEND) | |
11784 | || orf_pfx_count) { | |
11785 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11786 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11787 | json_object_boolean_true_add(json_neigh, | |
11788 | "orfSent"); | |
11789 | if (orf_pfx_count) | |
11790 | json_object_int_add(json_addr, "orfRecvCounter", | |
11791 | orf_pfx_count); | |
11792 | } | |
11793 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11794 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11795 | json_object_string_add( | |
11796 | json_addr, "orfFirstUpdate", | |
11797 | "deferredUntilORFOrRouteRefreshRecvd"); | |
11798 | ||
11799 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11800 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11801 | json_object_boolean_true_add(json_addr, | |
11802 | "routeReflectorClient"); | |
11803 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11804 | PEER_FLAG_RSERVER_CLIENT)) | |
11805 | json_object_boolean_true_add(json_addr, | |
11806 | "routeServerClient"); | |
11807 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11808 | json_object_boolean_true_add(json_addr, | |
11809 | "inboundSoftConfigPermit"); | |
11810 | ||
11811 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11812 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11813 | json_object_boolean_true_add( | |
11814 | json_addr, | |
11815 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
11816 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11817 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11818 | json_object_boolean_true_add( | |
11819 | json_addr, | |
11820 | "privateAsNumsReplacedInUpdatesToNbr"); | |
11821 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11822 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11823 | json_object_boolean_true_add( | |
11824 | json_addr, | |
11825 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
11826 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11827 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11828 | json_object_boolean_true_add( | |
11829 | json_addr, | |
11830 | "privateAsNumsRemovedInUpdatesToNbr"); | |
11831 | ||
dcc68b5e MS |
11832 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11833 | json_object_boolean_true_add( | |
11834 | json_addr, | |
11835 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11836 | ->type_json_name); | |
d62a17ae | 11837 | |
11838 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11839 | json_object_string_add(json_addr, | |
11840 | "overrideASNsInOutboundUpdates", | |
11841 | "ifAspathEqualRemoteAs"); | |
11842 | ||
11843 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11844 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11845 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11846 | json_object_boolean_true_add(json_addr, | |
11847 | "routerAlwaysNextHop"); | |
11848 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11849 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11850 | json_object_boolean_true_add( | |
11851 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
11852 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11853 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11854 | json_object_boolean_true_add( | |
11855 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
11856 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11857 | json_object_boolean_true_add( | |
11858 | json_addr, "unchangedMedPropogatedToNbr"); | |
11859 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11860 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11861 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11862 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11863 | PEER_FLAG_SEND_COMMUNITY) | |
11864 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11865 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11866 | json_object_string_add(json_addr, | |
11867 | "commAttriSentToNbr", | |
11868 | "extendedAndStandard"); | |
11869 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11870 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11871 | json_object_string_add(json_addr, | |
11872 | "commAttriSentToNbr", | |
11873 | "extended"); | |
11874 | else | |
11875 | json_object_string_add(json_addr, | |
11876 | "commAttriSentToNbr", | |
11877 | "standard"); | |
11878 | } | |
11879 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11880 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11881 | if (p->default_rmap[afi][safi].name) | |
11882 | json_object_string_add( | |
11883 | json_addr, "defaultRouteMap", | |
11884 | p->default_rmap[afi][safi].name); | |
11885 | ||
11886 | if (paf && PAF_SUBGRP(paf) | |
11887 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11888 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11889 | json_object_boolean_true_add(json_addr, | |
11890 | "defaultSent"); | |
11891 | else | |
11892 | json_object_boolean_true_add(json_addr, | |
11893 | "defaultNotSent"); | |
11894 | } | |
11895 | ||
dff8f48d | 11896 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 11897 | if (is_evpn_enabled()) |
60466a63 QY |
11898 | json_object_boolean_true_add( |
11899 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
11900 | } |
11901 | ||
d62a17ae | 11902 | if (filter->plist[FILTER_IN].name |
11903 | || filter->dlist[FILTER_IN].name | |
11904 | || filter->aslist[FILTER_IN].name | |
11905 | || filter->map[RMAP_IN].name) | |
11906 | json_object_boolean_true_add(json_addr, | |
11907 | "inboundPathPolicyConfig"); | |
11908 | if (filter->plist[FILTER_OUT].name | |
11909 | || filter->dlist[FILTER_OUT].name | |
11910 | || filter->aslist[FILTER_OUT].name | |
11911 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11912 | json_object_boolean_true_add( | |
11913 | json_addr, "outboundPathPolicyConfig"); | |
11914 | ||
11915 | /* prefix-list */ | |
11916 | if (filter->plist[FILTER_IN].name) | |
11917 | json_object_string_add(json_addr, | |
11918 | "incomingUpdatePrefixFilterList", | |
11919 | filter->plist[FILTER_IN].name); | |
11920 | if (filter->plist[FILTER_OUT].name) | |
11921 | json_object_string_add(json_addr, | |
11922 | "outgoingUpdatePrefixFilterList", | |
11923 | filter->plist[FILTER_OUT].name); | |
11924 | ||
11925 | /* distribute-list */ | |
11926 | if (filter->dlist[FILTER_IN].name) | |
11927 | json_object_string_add( | |
11928 | json_addr, "incomingUpdateNetworkFilterList", | |
11929 | filter->dlist[FILTER_IN].name); | |
11930 | if (filter->dlist[FILTER_OUT].name) | |
11931 | json_object_string_add( | |
11932 | json_addr, "outgoingUpdateNetworkFilterList", | |
11933 | filter->dlist[FILTER_OUT].name); | |
11934 | ||
11935 | /* filter-list. */ | |
11936 | if (filter->aslist[FILTER_IN].name) | |
11937 | json_object_string_add(json_addr, | |
11938 | "incomingUpdateAsPathFilterList", | |
11939 | filter->aslist[FILTER_IN].name); | |
11940 | if (filter->aslist[FILTER_OUT].name) | |
11941 | json_object_string_add(json_addr, | |
11942 | "outgoingUpdateAsPathFilterList", | |
11943 | filter->aslist[FILTER_OUT].name); | |
11944 | ||
11945 | /* route-map. */ | |
11946 | if (filter->map[RMAP_IN].name) | |
11947 | json_object_string_add( | |
11948 | json_addr, "routeMapForIncomingAdvertisements", | |
11949 | filter->map[RMAP_IN].name); | |
11950 | if (filter->map[RMAP_OUT].name) | |
11951 | json_object_string_add( | |
11952 | json_addr, "routeMapForOutgoingAdvertisements", | |
11953 | filter->map[RMAP_OUT].name); | |
11954 | ||
9dac9fc8 | 11955 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11956 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11957 | && !bgp_inbound_policy_exists(p, filter)) |
11958 | json_object_string_add( | |
11959 | json_addr, "inboundEbgpRequiresPolicy", | |
11960 | "Inbound updates discarded due to missing policy"); | |
11961 | ||
11962 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11963 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11964 | && (!bgp_outbound_policy_exists(p, filter))) |
11965 | json_object_string_add( | |
11966 | json_addr, "outboundEbgpRequiresPolicy", | |
11967 | "Outbound updates discarded due to missing policy"); | |
11968 | ||
d62a17ae | 11969 | /* unsuppress-map */ |
11970 | if (filter->usmap.name) | |
11971 | json_object_string_add(json_addr, | |
11972 | "selectiveUnsuppressRouteMap", | |
11973 | filter->usmap.name); | |
11974 | ||
fa36596c MK |
11975 | /* advertise-map */ |
11976 | if (filter->advmap.aname) { | |
11977 | json_advmap = json_object_new_object(); | |
11978 | json_object_string_add(json_advmap, "condition", | |
11979 | filter->advmap.condition | |
11980 | ? "EXIST" | |
11981 | : "NON_EXIST"); | |
11982 | json_object_string_add(json_advmap, "conditionMap", | |
11983 | filter->advmap.cname); | |
11984 | json_object_string_add(json_advmap, "advertiseMap", | |
11985 | filter->advmap.aname); | |
11986 | json_object_string_add(json_advmap, "advertiseStatus", | |
11987 | filter->advmap.update_type | |
11988 | == ADVERTISE | |
11989 | ? "Advertise" | |
11990 | : "Withdraw"); | |
11991 | json_object_object_add(json_addr, "advertiseMap", | |
11992 | json_advmap); | |
11993 | } | |
11994 | ||
d62a17ae | 11995 | /* Receive prefix count */ |
11996 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11997 | p->pcount[afi][safi]); | |
50e05855 AD |
11998 | if (paf && PAF_SUBGRP(paf)) |
11999 | json_object_int_add(json_addr, "sentPrefixCounter", | |
12000 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 12001 | |
fde246e8 DA |
12002 | /* Maximum prefix */ |
12003 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
12004 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
12005 | p->pmax_out[afi][safi]); | |
12006 | ||
d62a17ae | 12007 | /* Maximum prefix */ |
12008 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12009 | json_object_int_add(json_addr, "prefixAllowedMax", | |
12010 | p->pmax[afi][safi]); | |
12011 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12012 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
12013 | json_object_boolean_true_add( | |
12014 | json_addr, "prefixAllowedMaxWarning"); | |
12015 | json_object_int_add(json_addr, | |
12016 | "prefixAllowedWarningThresh", | |
12017 | p->pmax_threshold[afi][safi]); | |
12018 | if (p->pmax_restart[afi][safi]) | |
12019 | json_object_int_add( | |
12020 | json_addr, | |
12021 | "prefixAllowedRestartIntervalMsecs", | |
12022 | p->pmax_restart[afi][safi] * 60000); | |
12023 | } | |
2986cac2 | 12024 | json_object_object_add(json_neigh, |
36235319 | 12025 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 12026 | json_addr); |
12027 | ||
12028 | } else { | |
12029 | filter = &p->filter[afi][safi]; | |
12030 | ||
12031 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12032 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12033 | |
12034 | if (peer_group_active(p)) | |
12035 | vty_out(vty, " %s peer-group member\n", | |
12036 | p->group->name); | |
12037 | ||
12038 | paf = peer_af_find(p, afi, safi); | |
12039 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12040 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12041 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12042 | vty_out(vty, " Packet Queue length %d\n", | |
12043 | bpacket_queue_virtual_length(paf)); | |
12044 | } else { | |
12045 | vty_out(vty, " Not part of any update group\n"); | |
12046 | } | |
12047 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12048 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12049 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12050 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12051 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12052 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12053 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12054 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12055 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12056 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12057 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12058 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12059 | ||
12060 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12061 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12062 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12063 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12064 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12065 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12066 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12067 | vty_out(vty, | |
12068 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12069 | ORF_TYPE_PREFIX); | |
12070 | bgp_show_peer_afi_orf_cap( | |
12071 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12072 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12073 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12074 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12075 | } | |
12076 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12077 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12078 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12079 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12080 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12081 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12082 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12083 | vty_out(vty, | |
12084 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12085 | ORF_TYPE_PREFIX_OLD); | |
12086 | bgp_show_peer_afi_orf_cap( | |
12087 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12088 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12089 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12090 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12091 | } | |
12092 | ||
772270f3 QY |
12093 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12094 | p->host, afi, safi); | |
d62a17ae | 12095 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12096 | NULL, afi, orf_pfx_name, use_json); | |
12097 | ||
12098 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12099 | PEER_STATUS_ORF_PREFIX_SEND) | |
12100 | || orf_pfx_count) { | |
12101 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12102 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12103 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12104 | vty_out(vty, " sent;"); | |
12105 | if (orf_pfx_count) | |
12106 | vty_out(vty, " received (%d entries)", | |
12107 | orf_pfx_count); | |
12108 | vty_out(vty, "\n"); | |
12109 | } | |
12110 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12111 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12112 | vty_out(vty, | |
12113 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12114 | ||
12115 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12116 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12117 | vty_out(vty, " Route-Reflector Client\n"); | |
12118 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12119 | PEER_FLAG_RSERVER_CLIENT)) | |
12120 | vty_out(vty, " Route-Server Client\n"); | |
12121 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12122 | vty_out(vty, | |
12123 | " Inbound soft reconfiguration allowed\n"); | |
12124 | ||
12125 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12126 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12127 | vty_out(vty, | |
12128 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12129 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12130 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12131 | vty_out(vty, | |
12132 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12133 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12134 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12135 | vty_out(vty, | |
12136 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12137 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12138 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12139 | vty_out(vty, | |
12140 | " Private AS numbers removed in updates to this neighbor\n"); | |
12141 | ||
dcc68b5e MS |
12142 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12143 | vty_out(vty, " %s\n", | |
12144 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12145 | ->human_description); | |
d62a17ae | 12146 | |
12147 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12148 | vty_out(vty, | |
12149 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12150 | ||
12151 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12152 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12153 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12154 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12155 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12156 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12157 | vty_out(vty, | |
12158 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12159 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12160 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12161 | vty_out(vty, | |
12162 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12163 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12164 | vty_out(vty, | |
12165 | " MED is propagated unchanged to this neighbor\n"); | |
12166 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12167 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12168 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12169 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12170 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12171 | vty_out(vty, | |
12172 | " Community attribute sent to this neighbor"); | |
12173 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12174 | PEER_FLAG_SEND_COMMUNITY) | |
12175 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12176 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12177 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12178 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12179 | vty_out(vty, "(all)\n"); | |
12180 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12181 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12182 | vty_out(vty, "(large)\n"); | |
12183 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12184 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12185 | vty_out(vty, "(extended)\n"); | |
12186 | else | |
12187 | vty_out(vty, "(standard)\n"); | |
12188 | } | |
12189 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12190 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12191 | vty_out(vty, " Default information originate,"); | |
12192 | ||
12193 | if (p->default_rmap[afi][safi].name) | |
12194 | vty_out(vty, " default route-map %s%s,", | |
12195 | p->default_rmap[afi][safi].map ? "*" | |
12196 | : "", | |
12197 | p->default_rmap[afi][safi].name); | |
12198 | if (paf && PAF_SUBGRP(paf) | |
12199 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12200 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12201 | vty_out(vty, " default sent\n"); | |
12202 | else | |
12203 | vty_out(vty, " default not sent\n"); | |
12204 | } | |
12205 | ||
dff8f48d MK |
12206 | /* advertise-vni-all */ |
12207 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12208 | if (is_evpn_enabled()) |
dff8f48d MK |
12209 | vty_out(vty, " advertise-all-vni\n"); |
12210 | } | |
12211 | ||
d62a17ae | 12212 | if (filter->plist[FILTER_IN].name |
12213 | || filter->dlist[FILTER_IN].name | |
12214 | || filter->aslist[FILTER_IN].name | |
12215 | || filter->map[RMAP_IN].name) | |
12216 | vty_out(vty, " Inbound path policy configured\n"); | |
12217 | if (filter->plist[FILTER_OUT].name | |
12218 | || filter->dlist[FILTER_OUT].name | |
12219 | || filter->aslist[FILTER_OUT].name | |
12220 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12221 | vty_out(vty, " Outbound path policy configured\n"); | |
12222 | ||
12223 | /* prefix-list */ | |
12224 | if (filter->plist[FILTER_IN].name) | |
12225 | vty_out(vty, | |
12226 | " Incoming update prefix filter list is %s%s\n", | |
12227 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12228 | filter->plist[FILTER_IN].name); | |
12229 | if (filter->plist[FILTER_OUT].name) | |
12230 | vty_out(vty, | |
12231 | " Outgoing update prefix filter list is %s%s\n", | |
12232 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12233 | filter->plist[FILTER_OUT].name); | |
12234 | ||
12235 | /* distribute-list */ | |
12236 | if (filter->dlist[FILTER_IN].name) | |
12237 | vty_out(vty, | |
12238 | " Incoming update network filter list is %s%s\n", | |
12239 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12240 | filter->dlist[FILTER_IN].name); | |
12241 | if (filter->dlist[FILTER_OUT].name) | |
12242 | vty_out(vty, | |
12243 | " Outgoing update network filter list is %s%s\n", | |
12244 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12245 | filter->dlist[FILTER_OUT].name); | |
12246 | ||
12247 | /* filter-list. */ | |
12248 | if (filter->aslist[FILTER_IN].name) | |
12249 | vty_out(vty, | |
12250 | " Incoming update AS path filter list is %s%s\n", | |
12251 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12252 | filter->aslist[FILTER_IN].name); | |
12253 | if (filter->aslist[FILTER_OUT].name) | |
12254 | vty_out(vty, | |
12255 | " Outgoing update AS path filter list is %s%s\n", | |
12256 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12257 | filter->aslist[FILTER_OUT].name); | |
12258 | ||
12259 | /* route-map. */ | |
12260 | if (filter->map[RMAP_IN].name) | |
12261 | vty_out(vty, | |
12262 | " Route map for incoming advertisements is %s%s\n", | |
12263 | filter->map[RMAP_IN].map ? "*" : "", | |
12264 | filter->map[RMAP_IN].name); | |
12265 | if (filter->map[RMAP_OUT].name) | |
12266 | vty_out(vty, | |
12267 | " Route map for outgoing advertisements is %s%s\n", | |
12268 | filter->map[RMAP_OUT].map ? "*" : "", | |
12269 | filter->map[RMAP_OUT].name); | |
12270 | ||
9dac9fc8 | 12271 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12272 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12273 | && !bgp_inbound_policy_exists(p, filter)) |
12274 | vty_out(vty, | |
12275 | " Inbound updates discarded due to missing policy\n"); | |
12276 | ||
12277 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12278 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12279 | && !bgp_outbound_policy_exists(p, filter)) |
12280 | vty_out(vty, | |
12281 | " Outbound updates discarded due to missing policy\n"); | |
12282 | ||
d62a17ae | 12283 | /* unsuppress-map */ |
12284 | if (filter->usmap.name) | |
12285 | vty_out(vty, | |
12286 | " Route map for selective unsuppress is %s%s\n", | |
12287 | filter->usmap.map ? "*" : "", | |
12288 | filter->usmap.name); | |
12289 | ||
7f7940e6 MK |
12290 | /* advertise-map */ |
12291 | if (filter->advmap.aname && filter->advmap.cname) | |
12292 | vty_out(vty, | |
12293 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12294 | filter->advmap.condition ? "EXIST" | |
12295 | : "NON_EXIST", | |
12296 | filter->advmap.cmap ? "*" : "", | |
12297 | filter->advmap.cname, | |
12298 | filter->advmap.amap ? "*" : "", | |
12299 | filter->advmap.aname, | |
fa36596c | 12300 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
12301 | ? "Advertise" |
12302 | : "Withdraw"); | |
7f7940e6 | 12303 | |
d62a17ae | 12304 | /* Receive prefix count */ |
6cde4b45 | 12305 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12306 | p->pcount[afi][safi]); |
d62a17ae | 12307 | |
fde246e8 DA |
12308 | /* maximum-prefix-out */ |
12309 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12310 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12311 | vty_out(vty, | |
6cde4b45 | 12312 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12313 | p->pmax_out[afi][safi]); |
12314 | ||
d62a17ae | 12315 | /* Maximum prefix */ |
12316 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12317 | vty_out(vty, |
6cde4b45 | 12318 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12319 | p->pmax[afi][safi], |
12320 | CHECK_FLAG(p->af_flags[afi][safi], | |
12321 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12322 | ? " (warning-only)" | |
12323 | : ""); | |
12324 | vty_out(vty, " Threshold for warning message %d%%", | |
12325 | p->pmax_threshold[afi][safi]); | |
12326 | if (p->pmax_restart[afi][safi]) | |
12327 | vty_out(vty, ", restart interval %d min", | |
12328 | p->pmax_restart[afi][safi]); | |
12329 | vty_out(vty, "\n"); | |
12330 | } | |
12331 | ||
12332 | vty_out(vty, "\n"); | |
12333 | } | |
12334 | } | |
12335 | ||
9f049418 | 12336 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12337 | json_object *json) |
718e3744 | 12338 | { |
d62a17ae | 12339 | struct bgp *bgp; |
12340 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12341 | char timebuf[BGP_UPTIME_LEN]; | |
12342 | char dn_flag[2]; | |
d62a17ae | 12343 | afi_t afi; |
12344 | safi_t safi; | |
d7c0a89a QY |
12345 | uint16_t i; |
12346 | uint8_t *msg; | |
d62a17ae | 12347 | json_object *json_neigh = NULL; |
12348 | time_t epoch_tbuf; | |
718e3744 | 12349 | |
d62a17ae | 12350 | bgp = p->bgp; |
12351 | ||
12352 | if (use_json) | |
12353 | json_neigh = json_object_new_object(); | |
12354 | ||
12355 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12356 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12357 | dn_flag[0] = '*'; | |
12358 | ||
12359 | if (!use_json) { | |
12360 | if (p->conf_if) /* Configured interface name. */ | |
12361 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12362 | BGP_PEER_SU_UNSPEC(p) | |
12363 | ? "None" | |
12364 | : sockunion2str(&p->su, buf, | |
12365 | SU_ADDRSTRLEN)); | |
12366 | else /* Configured IP address. */ | |
12367 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12368 | p->host); | |
12369 | } | |
12370 | ||
12371 | if (use_json) { | |
12372 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12373 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12374 | "none"); | |
12375 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12376 | json_object_string_add( | |
12377 | json_neigh, "bgpNeighborAddr", | |
12378 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12379 | ||
12380 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12381 | ||
12382 | if (p->change_local_as) | |
12383 | json_object_int_add(json_neigh, "localAs", | |
12384 | p->change_local_as); | |
12385 | else | |
12386 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12387 | ||
12388 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12389 | json_object_boolean_true_add(json_neigh, | |
12390 | "localAsNoPrepend"); | |
12391 | ||
12392 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12393 | json_object_boolean_true_add(json_neigh, | |
12394 | "localAsReplaceAs"); | |
12395 | } else { | |
12396 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12397 | || (p->as_type == AS_INTERNAL)) | |
12398 | vty_out(vty, "remote AS %u, ", p->as); | |
12399 | else | |
12400 | vty_out(vty, "remote AS Unspecified, "); | |
12401 | vty_out(vty, "local AS %u%s%s, ", | |
12402 | p->change_local_as ? p->change_local_as : p->local_as, | |
12403 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12404 | ? " no-prepend" | |
12405 | : "", | |
12406 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12407 | ? " replace-as" | |
12408 | : ""); | |
12409 | } | |
faa16034 DS |
12410 | /* peer type internal or confed-internal */ |
12411 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12412 | if (use_json) { |
12413 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12414 | json_object_boolean_true_add( | |
12415 | json_neigh, "nbrConfedInternalLink"); | |
12416 | else | |
12417 | json_object_boolean_true_add(json_neigh, | |
12418 | "nbrInternalLink"); | |
12419 | } else { | |
12420 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12421 | vty_out(vty, "confed-internal link\n"); | |
12422 | else | |
12423 | vty_out(vty, "internal link\n"); | |
12424 | } | |
faa16034 DS |
12425 | /* peer type external or confed-external */ |
12426 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12427 | if (use_json) { |
12428 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12429 | json_object_boolean_true_add( | |
12430 | json_neigh, "nbrConfedExternalLink"); | |
12431 | else | |
12432 | json_object_boolean_true_add(json_neigh, | |
12433 | "nbrExternalLink"); | |
12434 | } else { | |
12435 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12436 | vty_out(vty, "confed-external link\n"); | |
12437 | else | |
12438 | vty_out(vty, "external link\n"); | |
12439 | } | |
faa16034 DS |
12440 | } else { |
12441 | if (use_json) | |
12442 | json_object_boolean_true_add(json_neigh, | |
12443 | "nbrUnspecifiedLink"); | |
12444 | else | |
12445 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12446 | } |
12447 | ||
12448 | /* Description. */ | |
12449 | if (p->desc) { | |
12450 | if (use_json) | |
12451 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12452 | else | |
12453 | vty_out(vty, " Description: %s\n", p->desc); | |
12454 | } | |
12455 | ||
12456 | if (p->hostname) { | |
12457 | if (use_json) { | |
12458 | if (p->hostname) | |
12459 | json_object_string_add(json_neigh, "hostname", | |
12460 | p->hostname); | |
12461 | ||
12462 | if (p->domainname) | |
12463 | json_object_string_add(json_neigh, "domainname", | |
12464 | p->domainname); | |
12465 | } else { | |
12466 | if (p->domainname && (p->domainname[0] != '\0')) | |
12467 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12468 | p->domainname); | |
12469 | else | |
12470 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12471 | } | |
12472 | } | |
12473 | ||
12474 | /* Peer-group */ | |
12475 | if (p->group) { | |
12476 | if (use_json) { | |
12477 | json_object_string_add(json_neigh, "peerGroup", | |
12478 | p->group->name); | |
12479 | ||
12480 | if (dn_flag[0]) { | |
12481 | struct prefix prefix, *range = NULL; | |
12482 | ||
0154d8ce DS |
12483 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12484 | range = peer_group_lookup_dynamic_neighbor_range( | |
12485 | p->group, &prefix); | |
d62a17ae | 12486 | |
12487 | if (range) { | |
12488 | prefix2str(range, buf1, sizeof(buf1)); | |
12489 | json_object_string_add( | |
12490 | json_neigh, | |
12491 | "peerSubnetRangeGroup", buf1); | |
12492 | } | |
12493 | } | |
12494 | } else { | |
12495 | vty_out(vty, | |
12496 | " Member of peer-group %s for session parameters\n", | |
12497 | p->group->name); | |
12498 | ||
12499 | if (dn_flag[0]) { | |
12500 | struct prefix prefix, *range = NULL; | |
12501 | ||
0154d8ce DS |
12502 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12503 | range = peer_group_lookup_dynamic_neighbor_range( | |
12504 | p->group, &prefix); | |
d62a17ae | 12505 | |
12506 | if (range) { | |
d62a17ae | 12507 | vty_out(vty, |
1b78780b DL |
12508 | " Belongs to the subnet range group: %pFX\n", |
12509 | range); | |
d62a17ae | 12510 | } |
12511 | } | |
12512 | } | |
12513 | } | |
12514 | ||
12515 | if (use_json) { | |
12516 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12517 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12518 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12519 | json_object_boolean_true_add(json_neigh, |
12520 | "adminShutDown"); | |
12521 | ||
12522 | /* BGP Version. */ | |
12523 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
12524 | json_object_string_add( | |
12525 | json_neigh, "remoteRouterId", | |
12526 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
12527 | json_object_string_add( |
12528 | json_neigh, "localRouterId", | |
12529 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12530 | sizeof(buf1))); | |
d62a17ae | 12531 | |
12532 | /* Confederation */ | |
12533 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12534 | && bgp_confederation_peers_check(bgp, p->as)) | |
12535 | json_object_boolean_true_add(json_neigh, | |
12536 | "nbrCommonAdmin"); | |
12537 | ||
12538 | /* Status. */ | |
12539 | json_object_string_add( | |
12540 | json_neigh, "bgpState", | |
12541 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12542 | ||
12543 | if (p->status == Established) { | |
12544 | time_t uptime; | |
d62a17ae | 12545 | |
12546 | uptime = bgp_clock(); | |
12547 | uptime -= p->uptime; | |
d62a17ae | 12548 | epoch_tbuf = time(NULL) - uptime; |
12549 | ||
d3c7efed DS |
12550 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
12551 | uptime * 1000); | |
d62a17ae | 12552 | json_object_string_add(json_neigh, "bgpTimerUpString", |
12553 | peer_uptime(p->uptime, timebuf, | |
12554 | BGP_UPTIME_LEN, 0, | |
12555 | NULL)); | |
12556 | json_object_int_add(json_neigh, | |
12557 | "bgpTimerUpEstablishedEpoch", | |
12558 | epoch_tbuf); | |
12559 | } | |
12560 | ||
12561 | else if (p->status == Active) { | |
12562 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12563 | json_object_string_add(json_neigh, "bgpStateIs", | |
12564 | "passive"); | |
12565 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12566 | json_object_string_add(json_neigh, "bgpStateIs", | |
12567 | "passiveNSF"); | |
12568 | } | |
12569 | ||
12570 | /* read timer */ | |
12571 | time_t uptime; | |
a2700b50 | 12572 | struct tm tm; |
d62a17ae | 12573 | |
12574 | uptime = bgp_clock(); | |
12575 | uptime -= p->readtime; | |
a2700b50 MS |
12576 | gmtime_r(&uptime, &tm); |
12577 | ||
d62a17ae | 12578 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
12579 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12580 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12581 | |
12582 | uptime = bgp_clock(); | |
12583 | uptime -= p->last_write; | |
a2700b50 MS |
12584 | gmtime_r(&uptime, &tm); |
12585 | ||
d62a17ae | 12586 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
12587 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12588 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12589 | |
12590 | uptime = bgp_clock(); | |
12591 | uptime -= p->update_time; | |
a2700b50 MS |
12592 | gmtime_r(&uptime, &tm); |
12593 | ||
d62a17ae | 12594 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
12595 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12596 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12597 | |
12598 | /* Configured timer values. */ | |
12599 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12600 | p->v_holdtime * 1000); | |
12601 | json_object_int_add(json_neigh, | |
12602 | "bgpTimerKeepAliveIntervalMsecs", | |
12603 | p->v_keepalive * 1000); | |
b90a8e13 | 12604 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12605 | json_object_int_add(json_neigh, |
12606 | "bgpTimerConfiguredHoldTimeMsecs", | |
12607 | p->holdtime * 1000); | |
12608 | json_object_int_add( | |
12609 | json_neigh, | |
12610 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12611 | p->keepalive * 1000); | |
5d5393b9 DL |
12612 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12613 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12614 | json_object_int_add(json_neigh, |
12615 | "bgpTimerConfiguredHoldTimeMsecs", | |
12616 | bgp->default_holdtime); | |
12617 | json_object_int_add( | |
12618 | json_neigh, | |
12619 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12620 | bgp->default_keepalive); | |
d62a17ae | 12621 | } |
12622 | } else { | |
12623 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12624 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12625 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12626 | vty_out(vty, " Administratively shut down\n"); |
12627 | ||
12628 | /* BGP Version. */ | |
12629 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 12630 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 12631 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
12632 | vty_out(vty, ", local router ID %s\n", |
12633 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12634 | sizeof(buf1))); | |
d62a17ae | 12635 | |
12636 | /* Confederation */ | |
12637 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12638 | && bgp_confederation_peers_check(bgp, p->as)) | |
12639 | vty_out(vty, | |
12640 | " Neighbor under common administration\n"); | |
12641 | ||
12642 | /* Status. */ | |
12643 | vty_out(vty, " BGP state = %s", | |
12644 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12645 | ||
12646 | if (p->status == Established) | |
12647 | vty_out(vty, ", up for %8s", | |
12648 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12649 | 0, NULL)); | |
12650 | ||
12651 | else if (p->status == Active) { | |
12652 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12653 | vty_out(vty, " (passive)"); | |
12654 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12655 | vty_out(vty, " (NSF passive)"); | |
12656 | } | |
12657 | vty_out(vty, "\n"); | |
12658 | ||
12659 | /* read timer */ | |
12660 | vty_out(vty, " Last read %s", | |
12661 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12662 | NULL)); | |
12663 | vty_out(vty, ", Last write %s\n", | |
12664 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12665 | NULL)); | |
12666 | ||
12667 | /* Configured timer values. */ | |
12668 | vty_out(vty, | |
12669 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12670 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 12671 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12672 | vty_out(vty, " Configured hold time is %d", |
12673 | p->holdtime); | |
12674 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12675 | p->keepalive); | |
5d5393b9 DL |
12676 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12677 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12678 | vty_out(vty, " Configured hold time is %d", |
12679 | bgp->default_holdtime); | |
12680 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12681 | bgp->default_keepalive); | |
d62a17ae | 12682 | } |
12683 | } | |
12684 | /* Capability. */ | |
12685 | if (p->status == Established) { | |
12686 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
12687 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
12688 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
12689 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
12690 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
12691 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
12692 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
12693 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
12694 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
12695 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
12696 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
12697 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 12698 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
12699 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 12700 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
12701 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 12702 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
12703 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 12704 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
12705 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
12706 | if (use_json) { | |
12707 | json_object *json_cap = NULL; | |
12708 | ||
12709 | json_cap = json_object_new_object(); | |
12710 | ||
12711 | /* AS4 */ | |
12712 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
12713 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12714 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
12715 | && CHECK_FLAG(p->cap, | |
12716 | PEER_CAP_AS4_RCV)) | |
12717 | json_object_string_add( | |
12718 | json_cap, "4byteAs", | |
12719 | "advertisedAndReceived"); | |
12720 | else if (CHECK_FLAG(p->cap, | |
12721 | PEER_CAP_AS4_ADV)) | |
12722 | json_object_string_add( | |
12723 | json_cap, "4byteAs", | |
12724 | "advertised"); | |
12725 | else if (CHECK_FLAG(p->cap, | |
12726 | PEER_CAP_AS4_RCV)) | |
12727 | json_object_string_add( | |
12728 | json_cap, "4byteAs", | |
12729 | "received"); | |
12730 | } | |
12731 | ||
12732 | /* AddPath */ | |
12733 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
12734 | || CHECK_FLAG(p->cap, | |
12735 | PEER_CAP_ADDPATH_ADV)) { | |
12736 | json_object *json_add = NULL; | |
12737 | const char *print_store; | |
12738 | ||
12739 | json_add = json_object_new_object(); | |
12740 | ||
05c7a1cc QY |
12741 | FOREACH_AFI_SAFI (afi, safi) { |
12742 | json_object *json_sub = NULL; | |
12743 | json_sub = | |
12744 | json_object_new_object(); | |
5cb5f4d0 DD |
12745 | print_store = get_afi_safi_str( |
12746 | afi, safi, true); | |
d62a17ae | 12747 | |
05c7a1cc QY |
12748 | if (CHECK_FLAG( |
12749 | p->af_cap[afi] | |
12750 | [safi], | |
12751 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12752 | || CHECK_FLAG( | |
12753 | p->af_cap[afi] | |
12754 | [safi], | |
12755 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 12756 | if (CHECK_FLAG( |
12757 | p->af_cap | |
12758 | [afi] | |
12759 | [safi], | |
12760 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 12761 | && CHECK_FLAG( |
d62a17ae | 12762 | p->af_cap |
12763 | [afi] | |
12764 | [safi], | |
05c7a1cc QY |
12765 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
12766 | json_object_boolean_true_add( | |
12767 | json_sub, | |
12768 | "txAdvertisedAndReceived"); | |
12769 | else if ( | |
12770 | CHECK_FLAG( | |
12771 | p->af_cap | |
12772 | [afi] | |
12773 | [safi], | |
12774 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
12775 | json_object_boolean_true_add( | |
12776 | json_sub, | |
12777 | "txAdvertised"); | |
12778 | else if ( | |
12779 | CHECK_FLAG( | |
12780 | p->af_cap | |
12781 | [afi] | |
12782 | [safi], | |
12783 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12784 | json_object_boolean_true_add( | |
12785 | json_sub, | |
12786 | "txReceived"); | |
12787 | } | |
d62a17ae | 12788 | |
05c7a1cc QY |
12789 | if (CHECK_FLAG( |
12790 | p->af_cap[afi] | |
12791 | [safi], | |
12792 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12793 | || CHECK_FLAG( | |
12794 | p->af_cap[afi] | |
12795 | [safi], | |
12796 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 12797 | if (CHECK_FLAG( |
12798 | p->af_cap | |
12799 | [afi] | |
12800 | [safi], | |
12801 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 12802 | && CHECK_FLAG( |
d62a17ae | 12803 | p->af_cap |
12804 | [afi] | |
12805 | [safi], | |
12806 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
12807 | json_object_boolean_true_add( |
12808 | json_sub, | |
12809 | "rxAdvertisedAndReceived"); | |
12810 | else if ( | |
12811 | CHECK_FLAG( | |
12812 | p->af_cap | |
12813 | [afi] | |
12814 | [safi], | |
12815 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
12816 | json_object_boolean_true_add( | |
12817 | json_sub, | |
12818 | "rxAdvertised"); | |
12819 | else if ( | |
12820 | CHECK_FLAG( | |
12821 | p->af_cap | |
12822 | [afi] | |
12823 | [safi], | |
12824 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12825 | json_object_boolean_true_add( | |
12826 | json_sub, | |
12827 | "rxReceived"); | |
d62a17ae | 12828 | } |
12829 | ||
05c7a1cc QY |
12830 | if (CHECK_FLAG( |
12831 | p->af_cap[afi] | |
12832 | [safi], | |
12833 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12834 | || CHECK_FLAG( | |
12835 | p->af_cap[afi] | |
12836 | [safi], | |
12837 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
12838 | || CHECK_FLAG( | |
12839 | p->af_cap[afi] | |
12840 | [safi], | |
12841 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12842 | || CHECK_FLAG( | |
12843 | p->af_cap[afi] | |
12844 | [safi], | |
12845 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12846 | json_object_object_add( | |
12847 | json_add, | |
12848 | print_store, | |
12849 | json_sub); | |
12850 | else | |
12851 | json_object_free( | |
12852 | json_sub); | |
12853 | } | |
12854 | ||
d62a17ae | 12855 | json_object_object_add( |
12856 | json_cap, "addPath", json_add); | |
12857 | } | |
12858 | ||
12859 | /* Dynamic */ | |
12860 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
12861 | || CHECK_FLAG(p->cap, | |
12862 | PEER_CAP_DYNAMIC_ADV)) { | |
12863 | if (CHECK_FLAG(p->cap, | |
12864 | PEER_CAP_DYNAMIC_ADV) | |
12865 | && CHECK_FLAG(p->cap, | |
12866 | PEER_CAP_DYNAMIC_RCV)) | |
12867 | json_object_string_add( | |
12868 | json_cap, "dynamic", | |
12869 | "advertisedAndReceived"); | |
12870 | else if (CHECK_FLAG( | |
12871 | p->cap, | |
12872 | PEER_CAP_DYNAMIC_ADV)) | |
12873 | json_object_string_add( | |
12874 | json_cap, "dynamic", | |
12875 | "advertised"); | |
12876 | else if (CHECK_FLAG( | |
12877 | p->cap, | |
12878 | PEER_CAP_DYNAMIC_RCV)) | |
12879 | json_object_string_add( | |
12880 | json_cap, "dynamic", | |
12881 | "received"); | |
12882 | } | |
12883 | ||
12884 | /* Extended nexthop */ | |
12885 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
12886 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12887 | json_object *json_nxt = NULL; | |
12888 | const char *print_store; | |
12889 | ||
12890 | ||
12891 | if (CHECK_FLAG(p->cap, | |
12892 | PEER_CAP_ENHE_ADV) | |
12893 | && CHECK_FLAG(p->cap, | |
12894 | PEER_CAP_ENHE_RCV)) | |
12895 | json_object_string_add( | |
12896 | json_cap, | |
12897 | "extendedNexthop", | |
12898 | "advertisedAndReceived"); | |
12899 | else if (CHECK_FLAG(p->cap, | |
12900 | PEER_CAP_ENHE_ADV)) | |
12901 | json_object_string_add( | |
12902 | json_cap, | |
12903 | "extendedNexthop", | |
12904 | "advertised"); | |
12905 | else if (CHECK_FLAG(p->cap, | |
12906 | PEER_CAP_ENHE_RCV)) | |
12907 | json_object_string_add( | |
12908 | json_cap, | |
12909 | "extendedNexthop", | |
12910 | "received"); | |
12911 | ||
12912 | if (CHECK_FLAG(p->cap, | |
12913 | PEER_CAP_ENHE_RCV)) { | |
12914 | json_nxt = | |
12915 | json_object_new_object(); | |
12916 | ||
12917 | for (safi = SAFI_UNICAST; | |
12918 | safi < SAFI_MAX; safi++) { | |
12919 | if (CHECK_FLAG( | |
12920 | p->af_cap | |
12921 | [AFI_IP] | |
12922 | [safi], | |
12923 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 12924 | print_store = get_afi_safi_str( |
d62a17ae | 12925 | AFI_IP, |
5cb5f4d0 | 12926 | safi, true); |
d62a17ae | 12927 | json_object_string_add( |
12928 | json_nxt, | |
12929 | print_store, | |
54f29523 | 12930 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 12931 | } |
12932 | } | |
12933 | json_object_object_add( | |
12934 | json_cap, | |
12935 | "extendedNexthopFamililesByPeer", | |
12936 | json_nxt); | |
12937 | } | |
12938 | } | |
12939 | ||
12940 | /* Route Refresh */ | |
12941 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12942 | || CHECK_FLAG(p->cap, | |
12943 | PEER_CAP_REFRESH_NEW_RCV) | |
12944 | || CHECK_FLAG(p->cap, | |
12945 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12946 | if (CHECK_FLAG(p->cap, | |
12947 | PEER_CAP_REFRESH_ADV) | |
12948 | && (CHECK_FLAG( | |
12949 | p->cap, | |
12950 | PEER_CAP_REFRESH_NEW_RCV) | |
12951 | || CHECK_FLAG( | |
12952 | p->cap, | |
12953 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12954 | if (CHECK_FLAG( | |
12955 | p->cap, | |
12956 | PEER_CAP_REFRESH_OLD_RCV) | |
12957 | && CHECK_FLAG( | |
12958 | p->cap, | |
12959 | PEER_CAP_REFRESH_NEW_RCV)) | |
12960 | json_object_string_add( | |
12961 | json_cap, | |
12962 | "routeRefresh", | |
12963 | "advertisedAndReceivedOldNew"); | |
12964 | else { | |
12965 | if (CHECK_FLAG( | |
12966 | p->cap, | |
12967 | PEER_CAP_REFRESH_OLD_RCV)) | |
12968 | json_object_string_add( | |
12969 | json_cap, | |
12970 | "routeRefresh", | |
12971 | "advertisedAndReceivedOld"); | |
12972 | else | |
12973 | json_object_string_add( | |
12974 | json_cap, | |
12975 | "routeRefresh", | |
12976 | "advertisedAndReceivedNew"); | |
12977 | } | |
12978 | } else if ( | |
12979 | CHECK_FLAG( | |
12980 | p->cap, | |
12981 | PEER_CAP_REFRESH_ADV)) | |
12982 | json_object_string_add( | |
12983 | json_cap, | |
12984 | "routeRefresh", | |
12985 | "advertised"); | |
12986 | else if ( | |
12987 | CHECK_FLAG( | |
12988 | p->cap, | |
12989 | PEER_CAP_REFRESH_NEW_RCV) | |
12990 | || CHECK_FLAG( | |
12991 | p->cap, | |
12992 | PEER_CAP_REFRESH_OLD_RCV)) | |
12993 | json_object_string_add( | |
12994 | json_cap, | |
12995 | "routeRefresh", | |
12996 | "received"); | |
12997 | } | |
12998 | ||
12999 | /* Multiprotocol Extensions */ | |
13000 | json_object *json_multi = NULL; | |
13001 | json_multi = json_object_new_object(); | |
13002 | ||
05c7a1cc QY |
13003 | FOREACH_AFI_SAFI (afi, safi) { |
13004 | if (p->afc_adv[afi][safi] | |
13005 | || p->afc_recv[afi][safi]) { | |
13006 | json_object *json_exten = NULL; | |
13007 | json_exten = | |
13008 | json_object_new_object(); | |
13009 | ||
d62a17ae | 13010 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
13011 | && p->afc_recv[afi][safi]) |
13012 | json_object_boolean_true_add( | |
13013 | json_exten, | |
13014 | "advertisedAndReceived"); | |
13015 | else if (p->afc_adv[afi][safi]) | |
13016 | json_object_boolean_true_add( | |
13017 | json_exten, | |
13018 | "advertised"); | |
13019 | else if (p->afc_recv[afi][safi]) | |
13020 | json_object_boolean_true_add( | |
13021 | json_exten, | |
13022 | "received"); | |
d62a17ae | 13023 | |
05c7a1cc QY |
13024 | json_object_object_add( |
13025 | json_multi, | |
5cb5f4d0 DD |
13026 | get_afi_safi_str(afi, |
13027 | safi, | |
13028 | true), | |
05c7a1cc | 13029 | json_exten); |
d62a17ae | 13030 | } |
13031 | } | |
13032 | json_object_object_add( | |
13033 | json_cap, "multiprotocolExtensions", | |
13034 | json_multi); | |
13035 | ||
d77114b7 | 13036 | /* Hostname capabilities */ |
60466a63 | 13037 | json_object *json_hname = NULL; |
d77114b7 MK |
13038 | |
13039 | json_hname = json_object_new_object(); | |
13040 | ||
13041 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
13042 | json_object_string_add( | |
60466a63 QY |
13043 | json_hname, "advHostName", |
13044 | bgp->peer_self->hostname | |
13045 | ? bgp->peer_self | |
13046 | ->hostname | |
d77114b7 MK |
13047 | : "n/a"); |
13048 | json_object_string_add( | |
60466a63 QY |
13049 | json_hname, "advDomainName", |
13050 | bgp->peer_self->domainname | |
13051 | ? bgp->peer_self | |
13052 | ->domainname | |
d77114b7 MK |
13053 | : "n/a"); |
13054 | } | |
13055 | ||
13056 | ||
13057 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
13058 | json_object_string_add( | |
60466a63 QY |
13059 | json_hname, "rcvHostName", |
13060 | p->hostname ? p->hostname | |
13061 | : "n/a"); | |
d77114b7 | 13062 | json_object_string_add( |
60466a63 QY |
13063 | json_hname, "rcvDomainName", |
13064 | p->domainname ? p->domainname | |
13065 | : "n/a"); | |
d77114b7 MK |
13066 | } |
13067 | ||
60466a63 | 13068 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
13069 | json_hname); |
13070 | ||
d62a17ae | 13071 | /* Gracefull Restart */ |
13072 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
13073 | || CHECK_FLAG(p->cap, | |
13074 | PEER_CAP_RESTART_ADV)) { | |
13075 | if (CHECK_FLAG(p->cap, | |
13076 | PEER_CAP_RESTART_ADV) | |
13077 | && CHECK_FLAG(p->cap, | |
13078 | PEER_CAP_RESTART_RCV)) | |
13079 | json_object_string_add( | |
13080 | json_cap, | |
13081 | "gracefulRestart", | |
13082 | "advertisedAndReceived"); | |
13083 | else if (CHECK_FLAG( | |
13084 | p->cap, | |
13085 | PEER_CAP_RESTART_ADV)) | |
13086 | json_object_string_add( | |
13087 | json_cap, | |
13088 | "gracefulRestartCapability", | |
13089 | "advertised"); | |
13090 | else if (CHECK_FLAG( | |
13091 | p->cap, | |
13092 | PEER_CAP_RESTART_RCV)) | |
13093 | json_object_string_add( | |
13094 | json_cap, | |
13095 | "gracefulRestartCapability", | |
13096 | "received"); | |
13097 | ||
13098 | if (CHECK_FLAG(p->cap, | |
13099 | PEER_CAP_RESTART_RCV)) { | |
13100 | int restart_af_count = 0; | |
13101 | json_object *json_restart = | |
13102 | NULL; | |
13103 | json_restart = | |
13104 | json_object_new_object(); | |
13105 | ||
13106 | json_object_int_add( | |
13107 | json_cap, | |
13108 | "gracefulRestartRemoteTimerMsecs", | |
13109 | p->v_gr_restart * 1000); | |
13110 | ||
05c7a1cc QY |
13111 | FOREACH_AFI_SAFI (afi, safi) { |
13112 | if (CHECK_FLAG( | |
13113 | p->af_cap | |
13114 | [afi] | |
13115 | [safi], | |
13116 | PEER_CAP_RESTART_AF_RCV)) { | |
13117 | json_object * | |
13118 | json_sub = | |
13119 | NULL; | |
13120 | json_sub = | |
13121 | json_object_new_object(); | |
13122 | ||
d62a17ae | 13123 | if (CHECK_FLAG( |
13124 | p->af_cap | |
13125 | [afi] | |
13126 | [safi], | |
05c7a1cc QY |
13127 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13128 | json_object_boolean_true_add( | |
13129 | json_sub, | |
13130 | "preserved"); | |
13131 | restart_af_count++; | |
13132 | json_object_object_add( | |
13133 | json_restart, | |
5cb5f4d0 | 13134 | get_afi_safi_str( |
05c7a1cc | 13135 | afi, |
5cb5f4d0 DD |
13136 | safi, |
13137 | true), | |
05c7a1cc | 13138 | json_sub); |
d62a17ae | 13139 | } |
13140 | } | |
13141 | if (!restart_af_count) { | |
13142 | json_object_string_add( | |
13143 | json_cap, | |
13144 | "addressFamiliesByPeer", | |
13145 | "none"); | |
13146 | json_object_free( | |
13147 | json_restart); | |
13148 | } else | |
13149 | json_object_object_add( | |
13150 | json_cap, | |
13151 | "addressFamiliesByPeer", | |
13152 | json_restart); | |
13153 | } | |
13154 | } | |
13155 | json_object_object_add(json_neigh, | |
13156 | "neighborCapabilities", | |
13157 | json_cap); | |
13158 | } else { | |
13159 | vty_out(vty, " Neighbor capabilities:\n"); | |
13160 | ||
13161 | /* AS4 */ | |
13162 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
13163 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13164 | vty_out(vty, " 4 Byte AS:"); | |
13165 | if (CHECK_FLAG(p->cap, | |
13166 | PEER_CAP_AS4_ADV)) | |
13167 | vty_out(vty, " advertised"); | |
13168 | if (CHECK_FLAG(p->cap, | |
13169 | PEER_CAP_AS4_RCV)) | |
13170 | vty_out(vty, " %sreceived", | |
13171 | CHECK_FLAG( | |
13172 | p->cap, | |
13173 | PEER_CAP_AS4_ADV) | |
13174 | ? "and " | |
13175 | : ""); | |
13176 | vty_out(vty, "\n"); | |
13177 | } | |
13178 | ||
13179 | /* AddPath */ | |
13180 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
13181 | || CHECK_FLAG(p->cap, | |
13182 | PEER_CAP_ADDPATH_ADV)) { | |
13183 | vty_out(vty, " AddPath:\n"); | |
13184 | ||
05c7a1cc QY |
13185 | FOREACH_AFI_SAFI (afi, safi) { |
13186 | if (CHECK_FLAG( | |
13187 | p->af_cap[afi] | |
13188 | [safi], | |
13189 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13190 | || CHECK_FLAG( | |
13191 | p->af_cap[afi] | |
13192 | [safi], | |
13193 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13194 | vty_out(vty, | |
13195 | " %s: TX ", | |
5cb5f4d0 | 13196 | get_afi_safi_str( |
05c7a1cc | 13197 | afi, |
5cb5f4d0 DD |
13198 | safi, |
13199 | false)); | |
05c7a1cc | 13200 | |
d62a17ae | 13201 | if (CHECK_FLAG( |
13202 | p->af_cap | |
13203 | [afi] | |
13204 | [safi], | |
05c7a1cc | 13205 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 13206 | vty_out(vty, |
05c7a1cc | 13207 | "advertised %s", |
5cb5f4d0 | 13208 | get_afi_safi_str( |
d62a17ae | 13209 | afi, |
5cb5f4d0 DD |
13210 | safi, |
13211 | false)); | |
d62a17ae | 13212 | |
05c7a1cc QY |
13213 | if (CHECK_FLAG( |
13214 | p->af_cap | |
13215 | [afi] | |
13216 | [safi], | |
13217 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13218 | vty_out(vty, | |
13219 | "%sreceived", | |
13220 | CHECK_FLAG( | |
13221 | p->af_cap | |
13222 | [afi] | |
13223 | [safi], | |
13224 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13225 | ? " and " | |
13226 | : ""); | |
d62a17ae | 13227 | |
05c7a1cc QY |
13228 | vty_out(vty, "\n"); |
13229 | } | |
d62a17ae | 13230 | |
05c7a1cc QY |
13231 | if (CHECK_FLAG( |
13232 | p->af_cap[afi] | |
13233 | [safi], | |
13234 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13235 | || CHECK_FLAG( | |
13236 | p->af_cap[afi] | |
13237 | [safi], | |
13238 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13239 | vty_out(vty, | |
13240 | " %s: RX ", | |
5cb5f4d0 | 13241 | get_afi_safi_str( |
05c7a1cc | 13242 | afi, |
5cb5f4d0 DD |
13243 | safi, |
13244 | false)); | |
d62a17ae | 13245 | |
13246 | if (CHECK_FLAG( | |
13247 | p->af_cap | |
13248 | [afi] | |
13249 | [safi], | |
05c7a1cc | 13250 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 13251 | vty_out(vty, |
05c7a1cc | 13252 | "advertised %s", |
5cb5f4d0 | 13253 | get_afi_safi_str( |
d62a17ae | 13254 | afi, |
5cb5f4d0 DD |
13255 | safi, |
13256 | false)); | |
d62a17ae | 13257 | |
05c7a1cc QY |
13258 | if (CHECK_FLAG( |
13259 | p->af_cap | |
13260 | [afi] | |
13261 | [safi], | |
13262 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 13263 | vty_out(vty, |
05c7a1cc QY |
13264 | "%sreceived", |
13265 | CHECK_FLAG( | |
13266 | p->af_cap | |
13267 | [afi] | |
13268 | [safi], | |
13269 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13270 | ? " and " | |
13271 | : ""); | |
13272 | ||
13273 | vty_out(vty, "\n"); | |
d62a17ae | 13274 | } |
05c7a1cc | 13275 | } |
d62a17ae | 13276 | } |
13277 | ||
13278 | /* Dynamic */ | |
13279 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
13280 | || CHECK_FLAG(p->cap, | |
13281 | PEER_CAP_DYNAMIC_ADV)) { | |
13282 | vty_out(vty, " Dynamic:"); | |
13283 | if (CHECK_FLAG(p->cap, | |
13284 | PEER_CAP_DYNAMIC_ADV)) | |
13285 | vty_out(vty, " advertised"); | |
13286 | if (CHECK_FLAG(p->cap, | |
13287 | PEER_CAP_DYNAMIC_RCV)) | |
13288 | vty_out(vty, " %sreceived", | |
13289 | CHECK_FLAG( | |
13290 | p->cap, | |
13291 | PEER_CAP_DYNAMIC_ADV) | |
13292 | ? "and " | |
13293 | : ""); | |
13294 | vty_out(vty, "\n"); | |
13295 | } | |
13296 | ||
13297 | /* Extended nexthop */ | |
13298 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
13299 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13300 | vty_out(vty, " Extended nexthop:"); | |
13301 | if (CHECK_FLAG(p->cap, | |
13302 | PEER_CAP_ENHE_ADV)) | |
13303 | vty_out(vty, " advertised"); | |
13304 | if (CHECK_FLAG(p->cap, | |
13305 | PEER_CAP_ENHE_RCV)) | |
13306 | vty_out(vty, " %sreceived", | |
13307 | CHECK_FLAG( | |
13308 | p->cap, | |
13309 | PEER_CAP_ENHE_ADV) | |
13310 | ? "and " | |
13311 | : ""); | |
13312 | vty_out(vty, "\n"); | |
13313 | ||
13314 | if (CHECK_FLAG(p->cap, | |
13315 | PEER_CAP_ENHE_RCV)) { | |
13316 | vty_out(vty, | |
13317 | " Address families by peer:\n "); | |
13318 | for (safi = SAFI_UNICAST; | |
13319 | safi < SAFI_MAX; safi++) | |
13320 | if (CHECK_FLAG( | |
13321 | p->af_cap | |
13322 | [AFI_IP] | |
13323 | [safi], | |
13324 | PEER_CAP_ENHE_AF_RCV)) | |
13325 | vty_out(vty, | |
13326 | " %s\n", | |
5cb5f4d0 | 13327 | get_afi_safi_str( |
d62a17ae | 13328 | AFI_IP, |
5cb5f4d0 DD |
13329 | safi, |
13330 | false)); | |
d62a17ae | 13331 | } |
13332 | } | |
13333 | ||
13334 | /* Route Refresh */ | |
13335 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
13336 | || CHECK_FLAG(p->cap, | |
13337 | PEER_CAP_REFRESH_NEW_RCV) | |
13338 | || CHECK_FLAG(p->cap, | |
13339 | PEER_CAP_REFRESH_OLD_RCV)) { | |
13340 | vty_out(vty, " Route refresh:"); | |
13341 | if (CHECK_FLAG(p->cap, | |
13342 | PEER_CAP_REFRESH_ADV)) | |
13343 | vty_out(vty, " advertised"); | |
13344 | if (CHECK_FLAG(p->cap, | |
13345 | PEER_CAP_REFRESH_NEW_RCV) | |
13346 | || CHECK_FLAG( | |
13347 | p->cap, | |
13348 | PEER_CAP_REFRESH_OLD_RCV)) | |
13349 | vty_out(vty, " %sreceived(%s)", | |
13350 | CHECK_FLAG( | |
13351 | p->cap, | |
13352 | PEER_CAP_REFRESH_ADV) | |
13353 | ? "and " | |
13354 | : "", | |
13355 | (CHECK_FLAG( | |
13356 | p->cap, | |
13357 | PEER_CAP_REFRESH_OLD_RCV) | |
13358 | && CHECK_FLAG( | |
13359 | p->cap, | |
13360 | PEER_CAP_REFRESH_NEW_RCV)) | |
13361 | ? "old & new" | |
13362 | : CHECK_FLAG( | |
13363 | p->cap, | |
13364 | PEER_CAP_REFRESH_OLD_RCV) | |
13365 | ? "old" | |
13366 | : "new"); | |
13367 | ||
13368 | vty_out(vty, "\n"); | |
13369 | } | |
13370 | ||
13371 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
13372 | FOREACH_AFI_SAFI (afi, safi) |
13373 | if (p->afc_adv[afi][safi] | |
13374 | || p->afc_recv[afi][safi]) { | |
13375 | vty_out(vty, | |
13376 | " Address Family %s:", | |
5cb5f4d0 DD |
13377 | get_afi_safi_str( |
13378 | afi, | |
13379 | safi, | |
13380 | false)); | |
05c7a1cc | 13381 | if (p->afc_adv[afi][safi]) |
d62a17ae | 13382 | vty_out(vty, |
05c7a1cc QY |
13383 | " advertised"); |
13384 | if (p->afc_recv[afi][safi]) | |
13385 | vty_out(vty, | |
13386 | " %sreceived", | |
13387 | p->afc_adv[afi] | |
13388 | [safi] | |
13389 | ? "and " | |
13390 | : ""); | |
13391 | vty_out(vty, "\n"); | |
13392 | } | |
d62a17ae | 13393 | |
13394 | /* Hostname capability */ | |
60466a63 | 13395 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
13396 | |
13397 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
13398 | vty_out(vty, |
13399 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
13400 | bgp->peer_self->hostname |
13401 | ? bgp->peer_self | |
13402 | ->hostname | |
d77114b7 | 13403 | : "n/a", |
60466a63 QY |
13404 | bgp->peer_self->domainname |
13405 | ? bgp->peer_self | |
13406 | ->domainname | |
d77114b7 MK |
13407 | : "n/a"); |
13408 | } else { | |
13409 | vty_out(vty, " not advertised"); | |
d62a17ae | 13410 | } |
13411 | ||
d77114b7 | 13412 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
13413 | vty_out(vty, |
13414 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
13415 | p->hostname ? p->hostname |
13416 | : "n/a", | |
13417 | p->domainname ? p->domainname | |
13418 | : "n/a"); | |
d77114b7 MK |
13419 | } else { |
13420 | vty_out(vty, " not received"); | |
13421 | } | |
13422 | ||
13423 | vty_out(vty, "\n"); | |
13424 | ||
61bfbd51 | 13425 | /* Graceful Restart */ |
d62a17ae | 13426 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
13427 | || CHECK_FLAG(p->cap, | |
13428 | PEER_CAP_RESTART_ADV)) { | |
13429 | vty_out(vty, | |
61bfbd51 | 13430 | " Graceful Restart Capability:"); |
d62a17ae | 13431 | if (CHECK_FLAG(p->cap, |
13432 | PEER_CAP_RESTART_ADV)) | |
13433 | vty_out(vty, " advertised"); | |
13434 | if (CHECK_FLAG(p->cap, | |
13435 | PEER_CAP_RESTART_RCV)) | |
13436 | vty_out(vty, " %sreceived", | |
13437 | CHECK_FLAG( | |
13438 | p->cap, | |
13439 | PEER_CAP_RESTART_ADV) | |
13440 | ? "and " | |
13441 | : ""); | |
13442 | vty_out(vty, "\n"); | |
13443 | ||
13444 | if (CHECK_FLAG(p->cap, | |
13445 | PEER_CAP_RESTART_RCV)) { | |
13446 | int restart_af_count = 0; | |
13447 | ||
13448 | vty_out(vty, | |
13449 | " Remote Restart timer is %d seconds\n", | |
13450 | p->v_gr_restart); | |
13451 | vty_out(vty, | |
13452 | " Address families by peer:\n "); | |
13453 | ||
05c7a1cc QY |
13454 | FOREACH_AFI_SAFI (afi, safi) |
13455 | if (CHECK_FLAG( | |
13456 | p->af_cap | |
13457 | [afi] | |
13458 | [safi], | |
13459 | PEER_CAP_RESTART_AF_RCV)) { | |
13460 | vty_out(vty, | |
13461 | "%s%s(%s)", | |
13462 | restart_af_count | |
13463 | ? ", " | |
13464 | : "", | |
5cb5f4d0 | 13465 | get_afi_safi_str( |
05c7a1cc | 13466 | afi, |
5cb5f4d0 DD |
13467 | safi, |
13468 | false), | |
05c7a1cc QY |
13469 | CHECK_FLAG( |
13470 | p->af_cap | |
13471 | [afi] | |
13472 | [safi], | |
13473 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13474 | ? "preserved" | |
13475 | : "not preserved"); | |
13476 | restart_af_count++; | |
13477 | } | |
d62a17ae | 13478 | if (!restart_af_count) |
13479 | vty_out(vty, "none"); | |
13480 | vty_out(vty, "\n"); | |
13481 | } | |
2986cac2 | 13482 | } /* Gracefull Restart */ |
d62a17ae | 13483 | } |
13484 | } | |
13485 | } | |
13486 | ||
13487 | /* graceful restart information */ | |
d62a17ae | 13488 | json_object *json_grace = NULL; |
13489 | json_object *json_grace_send = NULL; | |
13490 | json_object *json_grace_recv = NULL; | |
13491 | int eor_send_af_count = 0; | |
13492 | int eor_receive_af_count = 0; | |
13493 | ||
13494 | if (use_json) { | |
13495 | json_grace = json_object_new_object(); | |
13496 | json_grace_send = json_object_new_object(); | |
13497 | json_grace_recv = json_object_new_object(); | |
13498 | ||
36235319 QY |
13499 | if ((p->status == Established) |
13500 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
13501 | FOREACH_AFI_SAFI (afi, safi) { |
13502 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 13503 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
13504 | json_object_boolean_true_add( |
13505 | json_grace_send, | |
5cb5f4d0 DD |
13506 | get_afi_safi_str(afi, |
13507 | safi, | |
13508 | true)); | |
05c7a1cc | 13509 | eor_send_af_count++; |
d62a17ae | 13510 | } |
13511 | } | |
05c7a1cc QY |
13512 | FOREACH_AFI_SAFI (afi, safi) { |
13513 | if (CHECK_FLAG( | |
36235319 QY |
13514 | p->af_sflags[afi][safi], |
13515 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
13516 | json_object_boolean_true_add( |
13517 | json_grace_recv, | |
5cb5f4d0 DD |
13518 | get_afi_safi_str(afi, |
13519 | safi, | |
13520 | true)); | |
05c7a1cc | 13521 | eor_receive_af_count++; |
d62a17ae | 13522 | } |
13523 | } | |
13524 | } | |
36235319 QY |
13525 | json_object_object_add(json_grace, "endOfRibSend", |
13526 | json_grace_send); | |
13527 | json_object_object_add(json_grace, "endOfRibRecv", | |
13528 | json_grace_recv); | |
d62a17ae | 13529 | |
d62a17ae | 13530 | |
13531 | if (p->t_gr_restart) | |
13532 | json_object_int_add(json_grace, | |
13533 | "gracefulRestartTimerMsecs", | |
13534 | thread_timer_remain_second( | |
13535 | p->t_gr_restart) | |
13536 | * 1000); | |
13537 | ||
13538 | if (p->t_gr_stale) | |
13539 | json_object_int_add( | |
13540 | json_grace, | |
13541 | "gracefulStalepathTimerMsecs", | |
13542 | thread_timer_remain_second( | |
13543 | p->t_gr_stale) | |
13544 | * 1000); | |
2986cac2 | 13545 | /* more gr info in new format */ |
13546 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 13547 | json_grace); |
d62a17ae | 13548 | json_object_object_add( |
13549 | json_neigh, "gracefulRestartInfo", json_grace); | |
13550 | } else { | |
2089dd80 | 13551 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
13552 | if ((p->status == Established) |
13553 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 13554 | |
d62a17ae | 13555 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
13556 | FOREACH_AFI_SAFI (afi, safi) { |
13557 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13558 | PEER_STATUS_EOR_SEND)) { | |
13559 | vty_out(vty, "%s%s", | |
13560 | eor_send_af_count ? ", " | |
13561 | : "", | |
36235319 QY |
13562 | get_afi_safi_str( |
13563 | afi, safi, | |
13564 | false)); | |
05c7a1cc | 13565 | eor_send_af_count++; |
d62a17ae | 13566 | } |
13567 | } | |
13568 | vty_out(vty, "\n"); | |
13569 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
13570 | FOREACH_AFI_SAFI (afi, safi) { |
13571 | if (CHECK_FLAG( | |
13572 | p->af_sflags[afi][safi], | |
13573 | PEER_STATUS_EOR_RECEIVED)) { | |
13574 | vty_out(vty, "%s%s", | |
13575 | eor_receive_af_count | |
13576 | ? ", " | |
13577 | : "", | |
5cb5f4d0 DD |
13578 | get_afi_safi_str(afi, |
13579 | safi, | |
13580 | false)); | |
05c7a1cc | 13581 | eor_receive_af_count++; |
d62a17ae | 13582 | } |
13583 | } | |
13584 | vty_out(vty, "\n"); | |
13585 | } | |
13586 | ||
13587 | if (p->t_gr_restart) | |
13588 | vty_out(vty, | |
13589 | " The remaining time of restart timer is %ld\n", | |
13590 | thread_timer_remain_second( | |
13591 | p->t_gr_restart)); | |
13592 | ||
13593 | if (p->t_gr_stale) | |
13594 | vty_out(vty, | |
13595 | " The remaining time of stalepath timer is %ld\n", | |
13596 | thread_timer_remain_second( | |
13597 | p->t_gr_stale)); | |
2986cac2 | 13598 | |
13599 | /* more gr info in new format */ | |
13600 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 13601 | } |
2986cac2 | 13602 | |
d62a17ae | 13603 | if (use_json) { |
13604 | json_object *json_stat = NULL; | |
13605 | json_stat = json_object_new_object(); | |
13606 | /* Packet counts. */ | |
43aa5965 QY |
13607 | |
13608 | atomic_size_t outq_count, inq_count; | |
13609 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13610 | memory_order_relaxed); | |
13611 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13612 | memory_order_relaxed); | |
13613 | ||
13614 | json_object_int_add(json_stat, "depthInq", | |
13615 | (unsigned long)inq_count); | |
d62a17ae | 13616 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 13617 | (unsigned long)outq_count); |
0112e9e0 QY |
13618 | json_object_int_add(json_stat, "opensSent", |
13619 | atomic_load_explicit(&p->open_out, | |
13620 | memory_order_relaxed)); | |
13621 | json_object_int_add(json_stat, "opensRecv", | |
13622 | atomic_load_explicit(&p->open_in, | |
13623 | memory_order_relaxed)); | |
d62a17ae | 13624 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
13625 | atomic_load_explicit(&p->notify_out, |
13626 | memory_order_relaxed)); | |
d62a17ae | 13627 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
13628 | atomic_load_explicit(&p->notify_in, |
13629 | memory_order_relaxed)); | |
13630 | json_object_int_add(json_stat, "updatesSent", | |
13631 | atomic_load_explicit(&p->update_out, | |
13632 | memory_order_relaxed)); | |
13633 | json_object_int_add(json_stat, "updatesRecv", | |
13634 | atomic_load_explicit(&p->update_in, | |
13635 | memory_order_relaxed)); | |
d62a17ae | 13636 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
13637 | atomic_load_explicit(&p->keepalive_out, |
13638 | memory_order_relaxed)); | |
d62a17ae | 13639 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
13640 | atomic_load_explicit(&p->keepalive_in, |
13641 | memory_order_relaxed)); | |
d62a17ae | 13642 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
13643 | atomic_load_explicit(&p->refresh_out, |
13644 | memory_order_relaxed)); | |
d62a17ae | 13645 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
13646 | atomic_load_explicit(&p->refresh_in, |
13647 | memory_order_relaxed)); | |
d62a17ae | 13648 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
13649 | atomic_load_explicit(&p->dynamic_cap_out, |
13650 | memory_order_relaxed)); | |
d62a17ae | 13651 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
13652 | atomic_load_explicit(&p->dynamic_cap_in, |
13653 | memory_order_relaxed)); | |
13654 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13655 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 13656 | json_object_object_add(json_neigh, "messageStats", json_stat); |
13657 | } else { | |
43aa5965 QY |
13658 | atomic_size_t outq_count, inq_count; |
13659 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13660 | memory_order_relaxed); | |
13661 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13662 | memory_order_relaxed); | |
13663 | ||
d62a17ae | 13664 | /* Packet counts. */ |
13665 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
13666 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
13667 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 13668 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
13669 | vty_out(vty, " Opens: %10d %10d\n", |
13670 | atomic_load_explicit(&p->open_out, | |
13671 | memory_order_relaxed), | |
13672 | atomic_load_explicit(&p->open_in, | |
13673 | memory_order_relaxed)); | |
13674 | vty_out(vty, " Notifications: %10d %10d\n", | |
13675 | atomic_load_explicit(&p->notify_out, | |
13676 | memory_order_relaxed), | |
13677 | atomic_load_explicit(&p->notify_in, | |
13678 | memory_order_relaxed)); | |
13679 | vty_out(vty, " Updates: %10d %10d\n", | |
13680 | atomic_load_explicit(&p->update_out, | |
13681 | memory_order_relaxed), | |
13682 | atomic_load_explicit(&p->update_in, | |
13683 | memory_order_relaxed)); | |
13684 | vty_out(vty, " Keepalives: %10d %10d\n", | |
13685 | atomic_load_explicit(&p->keepalive_out, | |
13686 | memory_order_relaxed), | |
13687 | atomic_load_explicit(&p->keepalive_in, | |
13688 | memory_order_relaxed)); | |
13689 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
13690 | atomic_load_explicit(&p->refresh_out, | |
13691 | memory_order_relaxed), | |
13692 | atomic_load_explicit(&p->refresh_in, | |
13693 | memory_order_relaxed)); | |
d62a17ae | 13694 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
13695 | atomic_load_explicit(&p->dynamic_cap_out, |
13696 | memory_order_relaxed), | |
13697 | atomic_load_explicit(&p->dynamic_cap_in, | |
13698 | memory_order_relaxed)); | |
13699 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
13700 | PEER_TOTAL_RX(p)); | |
d62a17ae | 13701 | } |
13702 | ||
13703 | if (use_json) { | |
13704 | /* advertisement-interval */ | |
13705 | json_object_int_add(json_neigh, | |
13706 | "minBtwnAdvertisementRunsTimerMsecs", | |
13707 | p->v_routeadv * 1000); | |
13708 | ||
13709 | /* Update-source. */ | |
13710 | if (p->update_if || p->update_source) { | |
13711 | if (p->update_if) | |
13712 | json_object_string_add(json_neigh, | |
13713 | "updateSource", | |
13714 | p->update_if); | |
13715 | else if (p->update_source) | |
13716 | json_object_string_add( | |
13717 | json_neigh, "updateSource", | |
13718 | sockunion2str(p->update_source, buf1, | |
13719 | SU_ADDRSTRLEN)); | |
13720 | } | |
13721 | } else { | |
13722 | /* advertisement-interval */ | |
13723 | vty_out(vty, | |
13724 | " Minimum time between advertisement runs is %d seconds\n", | |
13725 | p->v_routeadv); | |
13726 | ||
13727 | /* Update-source. */ | |
13728 | if (p->update_if || p->update_source) { | |
13729 | vty_out(vty, " Update source is "); | |
13730 | if (p->update_if) | |
13731 | vty_out(vty, "%s", p->update_if); | |
13732 | else if (p->update_source) | |
13733 | vty_out(vty, "%s", | |
13734 | sockunion2str(p->update_source, buf1, | |
13735 | SU_ADDRSTRLEN)); | |
13736 | vty_out(vty, "\n"); | |
13737 | } | |
13738 | ||
13739 | vty_out(vty, "\n"); | |
13740 | } | |
13741 | ||
13742 | /* Address Family Information */ | |
13743 | json_object *json_hold = NULL; | |
13744 | ||
13745 | if (use_json) | |
13746 | json_hold = json_object_new_object(); | |
13747 | ||
05c7a1cc QY |
13748 | FOREACH_AFI_SAFI (afi, safi) |
13749 | if (p->afc[afi][safi]) | |
13750 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
13751 | json_hold); | |
d62a17ae | 13752 | |
13753 | if (use_json) { | |
13754 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
13755 | json_hold); | |
13756 | json_object_int_add(json_neigh, "connectionsEstablished", | |
13757 | p->established); | |
13758 | json_object_int_add(json_neigh, "connectionsDropped", | |
13759 | p->dropped); | |
13760 | } else | |
13761 | vty_out(vty, " Connections established %d; dropped %d\n", | |
13762 | p->established, p->dropped); | |
13763 | ||
13764 | if (!p->last_reset) { | |
13765 | if (use_json) | |
13766 | json_object_string_add(json_neigh, "lastReset", | |
13767 | "never"); | |
13768 | else | |
13769 | vty_out(vty, " Last reset never\n"); | |
13770 | } else { | |
13771 | if (use_json) { | |
13772 | time_t uptime; | |
a2700b50 | 13773 | struct tm tm; |
d62a17ae | 13774 | |
13775 | uptime = bgp_clock(); | |
13776 | uptime -= p->resettime; | |
a2700b50 MS |
13777 | gmtime_r(&uptime, &tm); |
13778 | ||
d62a17ae | 13779 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
13780 | (tm.tm_sec * 1000) |
13781 | + (tm.tm_min * 60000) | |
13782 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 13783 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 13784 | } else { |
13785 | vty_out(vty, " Last reset %s, ", | |
13786 | peer_uptime(p->resettime, timebuf, | |
13787 | BGP_UPTIME_LEN, 0, NULL)); | |
13788 | ||
3577f1c5 | 13789 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 13790 | if (p->last_reset_cause_size) { |
13791 | msg = p->last_reset_cause; | |
13792 | vty_out(vty, | |
13793 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
13794 | for (i = 1; i <= p->last_reset_cause_size; | |
13795 | i++) { | |
13796 | vty_out(vty, "%02X", *msg++); | |
13797 | ||
13798 | if (i != p->last_reset_cause_size) { | |
13799 | if (i % 16 == 0) { | |
13800 | vty_out(vty, "\n "); | |
13801 | } else if (i % 4 == 0) { | |
13802 | vty_out(vty, " "); | |
13803 | } | |
13804 | } | |
13805 | } | |
13806 | vty_out(vty, "\n"); | |
13807 | } | |
13808 | } | |
13809 | } | |
13810 | ||
13811 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
13812 | if (use_json) | |
13813 | json_object_boolean_true_add(json_neigh, | |
13814 | "prefixesConfigExceedMax"); | |
13815 | else | |
13816 | vty_out(vty, | |
13817 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
13818 | ||
13819 | if (p->t_pmax_restart) { | |
13820 | if (use_json) { | |
13821 | json_object_boolean_true_add( | |
13822 | json_neigh, "reducePrefixNumFrom"); | |
13823 | json_object_int_add(json_neigh, | |
13824 | "restartInTimerMsec", | |
13825 | thread_timer_remain_second( | |
13826 | p->t_pmax_restart) | |
13827 | * 1000); | |
13828 | } else | |
13829 | vty_out(vty, | |
13830 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
13831 | p->host, thread_timer_remain_second( |
13832 | p->t_pmax_restart)); | |
d62a17ae | 13833 | } else { |
13834 | if (use_json) | |
13835 | json_object_boolean_true_add( | |
13836 | json_neigh, | |
13837 | "reducePrefixNumAndClearIpBgp"); | |
13838 | else | |
13839 | vty_out(vty, | |
13840 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
13841 | p->host); | |
13842 | } | |
13843 | } | |
13844 | ||
13845 | /* EBGP Multihop and GTSM */ | |
13846 | if (p->sort != BGP_PEER_IBGP) { | |
13847 | if (use_json) { | |
e2521429 | 13848 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13849 | json_object_int_add(json_neigh, |
13850 | "externalBgpNbrMaxHopsAway", | |
13851 | p->gtsm_hops); | |
c8d6f0d6 | 13852 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13853 | json_object_int_add(json_neigh, |
13854 | "externalBgpNbrMaxHopsAway", | |
13855 | p->ttl); | |
13856 | } else { | |
e2521429 | 13857 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13858 | vty_out(vty, |
13859 | " External BGP neighbor may be up to %d hops away.\n", | |
13860 | p->gtsm_hops); | |
c8d6f0d6 | 13861 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13862 | vty_out(vty, |
13863 | " External BGP neighbor may be up to %d hops away.\n", | |
13864 | p->ttl); | |
13865 | } | |
13866 | } else { | |
e2521429 | 13867 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 13868 | if (use_json) |
13869 | json_object_int_add(json_neigh, | |
13870 | "internalBgpNbrMaxHopsAway", | |
13871 | p->gtsm_hops); | |
13872 | else | |
13873 | vty_out(vty, | |
13874 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13875 | p->gtsm_hops); | |
13876 | } | |
13877 | } | |
13878 | ||
13879 | /* Local address. */ | |
13880 | if (p->su_local) { | |
13881 | if (use_json) { | |
13882 | json_object_string_add(json_neigh, "hostLocal", | |
13883 | sockunion2str(p->su_local, buf1, | |
13884 | SU_ADDRSTRLEN)); | |
13885 | json_object_int_add(json_neigh, "portLocal", | |
13886 | ntohs(p->su_local->sin.sin_port)); | |
13887 | } else | |
13888 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13889 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
13890 | ntohs(p->su_local->sin.sin_port)); | |
13891 | } | |
13892 | ||
13893 | /* Remote address. */ | |
13894 | if (p->su_remote) { | |
13895 | if (use_json) { | |
13896 | json_object_string_add(json_neigh, "hostForeign", | |
13897 | sockunion2str(p->su_remote, buf1, | |
13898 | SU_ADDRSTRLEN)); | |
13899 | json_object_int_add(json_neigh, "portForeign", | |
13900 | ntohs(p->su_remote->sin.sin_port)); | |
13901 | } else | |
13902 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
13903 | sockunion2str(p->su_remote, buf1, | |
13904 | SU_ADDRSTRLEN), | |
13905 | ntohs(p->su_remote->sin.sin_port)); | |
13906 | } | |
13907 | ||
13908 | /* Nexthop display. */ | |
13909 | if (p->su_local) { | |
13910 | if (use_json) { | |
13911 | json_object_string_add(json_neigh, "nexthop", | |
13912 | inet_ntop(AF_INET, | |
13913 | &p->nexthop.v4, buf1, | |
13914 | sizeof(buf1))); | |
13915 | json_object_string_add(json_neigh, "nexthopGlobal", | |
13916 | inet_ntop(AF_INET6, | |
13917 | &p->nexthop.v6_global, | |
13918 | buf1, sizeof(buf1))); | |
13919 | json_object_string_add(json_neigh, "nexthopLocal", | |
13920 | inet_ntop(AF_INET6, | |
13921 | &p->nexthop.v6_local, | |
13922 | buf1, sizeof(buf1))); | |
13923 | if (p->shared_network) | |
13924 | json_object_string_add(json_neigh, | |
13925 | "bgpConnection", | |
13926 | "sharedNetwork"); | |
13927 | else | |
13928 | json_object_string_add(json_neigh, | |
13929 | "bgpConnection", | |
13930 | "nonSharedNetwork"); | |
13931 | } else { | |
13932 | vty_out(vty, "Nexthop: %s\n", | |
13933 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
13934 | sizeof(buf1))); | |
13935 | vty_out(vty, "Nexthop global: %s\n", | |
13936 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
13937 | sizeof(buf1))); | |
13938 | vty_out(vty, "Nexthop local: %s\n", | |
13939 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
13940 | sizeof(buf1))); | |
13941 | vty_out(vty, "BGP connection: %s\n", | |
13942 | p->shared_network ? "shared network" | |
13943 | : "non shared network"); | |
13944 | } | |
13945 | } | |
13946 | ||
13947 | /* Timer information. */ | |
13948 | if (use_json) { | |
13949 | json_object_int_add(json_neigh, "connectRetryTimer", | |
13950 | p->v_connect); | |
13951 | if (p->status == Established && p->rtt) | |
13952 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
13953 | p->rtt); | |
13954 | if (p->t_start) | |
13955 | json_object_int_add( | |
13956 | json_neigh, "nextStartTimerDueInMsecs", | |
13957 | thread_timer_remain_second(p->t_start) * 1000); | |
13958 | if (p->t_connect) | |
13959 | json_object_int_add( | |
13960 | json_neigh, "nextConnectTimerDueInMsecs", | |
13961 | thread_timer_remain_second(p->t_connect) | |
13962 | * 1000); | |
13963 | if (p->t_routeadv) { | |
13964 | json_object_int_add(json_neigh, "mraiInterval", | |
13965 | p->v_routeadv); | |
13966 | json_object_int_add( | |
13967 | json_neigh, "mraiTimerExpireInMsecs", | |
13968 | thread_timer_remain_second(p->t_routeadv) | |
13969 | * 1000); | |
13970 | } | |
13971 | if (p->password) | |
13972 | json_object_int_add(json_neigh, "authenticationEnabled", | |
13973 | 1); | |
13974 | ||
13975 | if (p->t_read) | |
13976 | json_object_string_add(json_neigh, "readThread", "on"); | |
13977 | else | |
13978 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
13979 | |
13980 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 13981 | json_object_string_add(json_neigh, "writeThread", "on"); |
13982 | else | |
13983 | json_object_string_add(json_neigh, "writeThread", | |
13984 | "off"); | |
13985 | } else { | |
13986 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
13987 | p->v_connect); | |
13988 | if (p->status == Established && p->rtt) | |
13989 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
13990 | p->rtt); | |
13991 | if (p->t_start) | |
13992 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
13993 | thread_timer_remain_second(p->t_start)); | |
13994 | if (p->t_connect) | |
13995 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
13996 | thread_timer_remain_second(p->t_connect)); | |
13997 | if (p->t_routeadv) | |
13998 | vty_out(vty, | |
13999 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
14000 | p->v_routeadv, | |
14001 | thread_timer_remain_second(p->t_routeadv)); | |
14002 | if (p->password) | |
14003 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14004 | ||
cac9e917 | 14005 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14006 | p->t_read ? "on" : "off", |
14007 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14008 | ? "on" | |
cac9e917 | 14009 | : "off", p->fd); |
d62a17ae | 14010 | } |
14011 | ||
14012 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14013 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14014 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14015 | ||
14016 | if (!use_json) | |
14017 | vty_out(vty, "\n"); | |
14018 | ||
14019 | /* BFD information. */ | |
14020 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
14021 | ||
14022 | if (use_json) { | |
14023 | if (p->conf_if) /* Configured interface name. */ | |
14024 | json_object_object_add(json, p->conf_if, json_neigh); | |
14025 | else /* Configured IP address. */ | |
14026 | json_object_object_add(json, p->host, json_neigh); | |
14027 | } | |
14028 | } | |
14029 | ||
36235319 QY |
14030 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14031 | enum show_type type, | |
14032 | union sockunion *su, | |
14033 | const char *conf_if, afi_t afi, | |
74a630b6 | 14034 | bool use_json) |
2986cac2 | 14035 | { |
14036 | struct listnode *node, *nnode; | |
14037 | struct peer *peer; | |
14038 | int find = 0; | |
14039 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 14040 | json_object *json = NULL; |
2986cac2 | 14041 | json_object *json_neighbor = NULL; |
14042 | ||
74a630b6 NT |
14043 | if (use_json) { |
14044 | json = json_object_new_object(); | |
14045 | json_neighbor = json_object_new_object(); | |
14046 | } | |
14047 | ||
2986cac2 | 14048 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
14049 | ||
14050 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14051 | continue; | |
14052 | ||
14053 | if ((peer->afc[afi][safi]) == 0) | |
14054 | continue; | |
14055 | ||
2ba1fe69 | 14056 | if (type == show_all) { |
2986cac2 | 14057 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 14058 | json_neighbor); |
2986cac2 | 14059 | |
74a630b6 | 14060 | if (use_json) { |
13909c4f DS |
14061 | json_object_object_add(json, peer->host, |
14062 | json_neighbor); | |
74a630b6 NT |
14063 | json_neighbor = NULL; |
14064 | } | |
2986cac2 | 14065 | |
2ba1fe69 | 14066 | } else if (type == show_peer) { |
2986cac2 | 14067 | if (conf_if) { |
14068 | if ((peer->conf_if | |
13909c4f DS |
14069 | && !strcmp(peer->conf_if, conf_if)) |
14070 | || (peer->hostname | |
2986cac2 | 14071 | && !strcmp(peer->hostname, conf_if))) { |
14072 | find = 1; | |
13909c4f DS |
14073 | bgp_show_peer_gr_status(vty, peer, |
14074 | use_json, | |
14075 | json_neighbor); | |
2986cac2 | 14076 | } |
14077 | } else { | |
14078 | if (sockunion_same(&peer->su, su)) { | |
14079 | find = 1; | |
13909c4f DS |
14080 | bgp_show_peer_gr_status(vty, peer, |
14081 | use_json, | |
14082 | json_neighbor); | |
2986cac2 | 14083 | } |
14084 | } | |
13909c4f DS |
14085 | if (use_json && find) |
14086 | json_object_object_add(json, peer->host, | |
14087 | json_neighbor); | |
2986cac2 | 14088 | } |
14089 | ||
74a630b6 NT |
14090 | if (find) { |
14091 | json_neighbor = NULL; | |
2986cac2 | 14092 | break; |
74a630b6 | 14093 | } |
2986cac2 | 14094 | } |
14095 | ||
14096 | if (type == show_peer && !find) { | |
14097 | if (use_json) | |
13909c4f | 14098 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14099 | else |
14100 | vty_out(vty, "%% No such neighbor\n"); | |
14101 | } | |
14102 | if (use_json) { | |
13909c4f DS |
14103 | vty_out(vty, "%s\n", |
14104 | json_object_to_json_string_ext( | |
14105 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
14106 | |
14107 | if (json_neighbor) | |
14108 | json_object_free(json_neighbor); | |
14109 | json_object_free(json); | |
2986cac2 | 14110 | } else { |
14111 | vty_out(vty, "\n"); | |
14112 | } | |
14113 | ||
14114 | return CMD_SUCCESS; | |
14115 | } | |
14116 | ||
d62a17ae | 14117 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14118 | enum show_type type, union sockunion *su, | |
9f049418 | 14119 | const char *conf_if, bool use_json, |
d62a17ae | 14120 | json_object *json) |
14121 | { | |
14122 | struct listnode *node, *nnode; | |
14123 | struct peer *peer; | |
14124 | int find = 0; | |
9f049418 | 14125 | bool nbr_output = false; |
d1927ebe AS |
14126 | afi_t afi = AFI_MAX; |
14127 | safi_t safi = SAFI_MAX; | |
14128 | ||
14129 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14130 | afi = AFI_IP; | |
14131 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14132 | afi = AFI_IP6; | |
14133 | } | |
d62a17ae | 14134 | |
14135 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14136 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14137 | continue; | |
14138 | ||
14139 | switch (type) { | |
14140 | case show_all: | |
14141 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14142 | nbr_output = true; |
d62a17ae | 14143 | break; |
14144 | case show_peer: | |
14145 | if (conf_if) { | |
14146 | if ((peer->conf_if | |
14147 | && !strcmp(peer->conf_if, conf_if)) | |
14148 | || (peer->hostname | |
14149 | && !strcmp(peer->hostname, conf_if))) { | |
14150 | find = 1; | |
14151 | bgp_show_peer(vty, peer, use_json, | |
14152 | json); | |
14153 | } | |
14154 | } else { | |
14155 | if (sockunion_same(&peer->su, su)) { | |
14156 | find = 1; | |
14157 | bgp_show_peer(vty, peer, use_json, | |
14158 | json); | |
14159 | } | |
14160 | } | |
14161 | break; | |
d1927ebe AS |
14162 | case show_ipv4_peer: |
14163 | case show_ipv6_peer: | |
14164 | FOREACH_SAFI (safi) { | |
14165 | if (peer->afc[afi][safi]) { | |
14166 | if (conf_if) { | |
14167 | if ((peer->conf_if | |
14168 | && !strcmp(peer->conf_if, conf_if)) | |
14169 | || (peer->hostname | |
14170 | && !strcmp(peer->hostname, conf_if))) { | |
14171 | find = 1; | |
14172 | bgp_show_peer(vty, peer, use_json, | |
14173 | json); | |
14174 | break; | |
14175 | } | |
14176 | } else { | |
14177 | if (sockunion_same(&peer->su, su)) { | |
14178 | find = 1; | |
14179 | bgp_show_peer(vty, peer, use_json, | |
14180 | json); | |
14181 | break; | |
14182 | } | |
14183 | } | |
14184 | } | |
14185 | } | |
14186 | break; | |
14187 | case show_ipv4_all: | |
14188 | case show_ipv6_all: | |
14189 | FOREACH_SAFI (safi) { | |
14190 | if (peer->afc[afi][safi]) { | |
14191 | bgp_show_peer(vty, peer, use_json, json); | |
14192 | nbr_output = true; | |
14193 | break; | |
14194 | } | |
14195 | } | |
14196 | break; | |
d62a17ae | 14197 | } |
14198 | } | |
14199 | ||
d1927ebe AS |
14200 | if ((type == show_peer || type == show_ipv4_peer || |
14201 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14202 | if (use_json) |
14203 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14204 | else | |
88b7d255 | 14205 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14206 | } |
14207 | ||
d1927ebe AS |
14208 | if (type != show_peer && type != show_ipv4_peer && |
14209 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14210 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14211 | |
d62a17ae | 14212 | if (use_json) { |
996c9314 LB |
14213 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14214 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14215 | } else { |
14216 | vty_out(vty, "\n"); | |
14217 | } | |
14218 | ||
14219 | return CMD_SUCCESS; | |
14220 | } | |
14221 | ||
36235319 QY |
14222 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14223 | enum show_type type, | |
14224 | const char *ip_str, | |
14225 | afi_t afi, bool use_json) | |
2986cac2 | 14226 | { |
14227 | ||
14228 | int ret; | |
14229 | struct bgp *bgp; | |
14230 | union sockunion su; | |
2986cac2 | 14231 | |
14232 | bgp = bgp_get_default(); | |
14233 | ||
13909c4f DS |
14234 | if (!bgp) |
14235 | return; | |
2986cac2 | 14236 | |
13909c4f DS |
14237 | if (!use_json) |
14238 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14239 | NULL); | |
2986cac2 | 14240 | |
13909c4f DS |
14241 | if (ip_str) { |
14242 | ret = str2sockunion(ip_str, &su); | |
14243 | if (ret < 0) | |
13909c4f | 14244 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14245 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14246 | else | |
14247 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14248 | NULL, afi, use_json); | |
13909c4f DS |
14249 | } else |
14250 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14251 | afi, use_json); |
2986cac2 | 14252 | } |
14253 | ||
d62a17ae | 14254 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14255 | enum show_type type, |
14256 | const char *ip_str, | |
9f049418 | 14257 | bool use_json) |
d62a17ae | 14258 | { |
0291c246 MK |
14259 | struct listnode *node, *nnode; |
14260 | struct bgp *bgp; | |
71aedaa3 | 14261 | union sockunion su; |
0291c246 | 14262 | json_object *json = NULL; |
71aedaa3 | 14263 | int ret, is_first = 1; |
9f049418 | 14264 | bool nbr_output = false; |
d62a17ae | 14265 | |
14266 | if (use_json) | |
14267 | vty_out(vty, "{\n"); | |
14268 | ||
14269 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14270 | nbr_output = true; |
d62a17ae | 14271 | if (use_json) { |
14272 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14273 | flog_err( |
e50f7cfd | 14274 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14275 | "Unable to allocate memory for JSON object"); |
14276 | vty_out(vty, | |
14277 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14278 | return; | |
14279 | } | |
14280 | ||
14281 | json_object_int_add(json, "vrfId", | |
14282 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14283 | ? -1 |
14284 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14285 | json_object_string_add( |
14286 | json, "vrfName", | |
14287 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14288 | ? VRF_DEFAULT_NAME |
d62a17ae | 14289 | : bgp->name); |
14290 | ||
14291 | if (!is_first) | |
14292 | vty_out(vty, ",\n"); | |
14293 | else | |
14294 | is_first = 0; | |
14295 | ||
14296 | vty_out(vty, "\"%s\":", | |
14297 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14298 | ? VRF_DEFAULT_NAME |
d62a17ae | 14299 | : bgp->name); |
14300 | } else { | |
14301 | vty_out(vty, "\nInstance %s:\n", | |
14302 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14303 | ? VRF_DEFAULT_NAME |
d62a17ae | 14304 | : bgp->name); |
14305 | } | |
71aedaa3 | 14306 | |
d1927ebe AS |
14307 | if (type == show_peer || type == show_ipv4_peer || |
14308 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14309 | ret = str2sockunion(ip_str, &su); |
14310 | if (ret < 0) | |
14311 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14312 | use_json, json); | |
14313 | else | |
14314 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14315 | use_json, json); | |
14316 | } else { | |
d1927ebe | 14317 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14318 | use_json, json); |
14319 | } | |
b77004d6 | 14320 | json_object_free(json); |
121067e9 | 14321 | json = NULL; |
d62a17ae | 14322 | } |
14323 | ||
3e78a6ce | 14324 | if (use_json) |
d62a17ae | 14325 | vty_out(vty, "}\n"); |
9f049418 DS |
14326 | else if (!nbr_output) |
14327 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14328 | } |
14329 | ||
14330 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14331 | enum show_type type, const char *ip_str, | |
9f049418 | 14332 | bool use_json) |
d62a17ae | 14333 | { |
14334 | int ret; | |
14335 | struct bgp *bgp; | |
14336 | union sockunion su; | |
14337 | json_object *json = NULL; | |
14338 | ||
14339 | if (name) { | |
14340 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14341 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14342 | use_json); | |
d62a17ae | 14343 | return CMD_SUCCESS; |
14344 | } else { | |
14345 | bgp = bgp_lookup_by_name(name); | |
14346 | if (!bgp) { | |
14347 | if (use_json) { | |
14348 | json = json_object_new_object(); | |
d62a17ae | 14349 | vty_out(vty, "%s\n", |
14350 | json_object_to_json_string_ext( | |
14351 | json, | |
14352 | JSON_C_TO_STRING_PRETTY)); | |
14353 | json_object_free(json); | |
14354 | } else | |
14355 | vty_out(vty, | |
9f049418 | 14356 | "%% BGP instance not found\n"); |
d62a17ae | 14357 | |
14358 | return CMD_WARNING; | |
14359 | } | |
14360 | } | |
14361 | } else { | |
14362 | bgp = bgp_get_default(); | |
14363 | } | |
14364 | ||
14365 | if (bgp) { | |
14366 | json = json_object_new_object(); | |
14367 | if (ip_str) { | |
14368 | ret = str2sockunion(ip_str, &su); | |
14369 | if (ret < 0) | |
14370 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14371 | use_json, json); | |
14372 | else | |
14373 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14374 | use_json, json); | |
14375 | } else { | |
14376 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14377 | json); | |
14378 | } | |
14379 | json_object_free(json); | |
ca61fd25 DS |
14380 | } else { |
14381 | if (use_json) | |
14382 | vty_out(vty, "{}\n"); | |
14383 | else | |
14384 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14385 | } |
14386 | ||
14387 | return CMD_SUCCESS; | |
4fb25c53 DW |
14388 | } |
14389 | ||
2986cac2 | 14390 | |
14391 | ||
14392 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14393 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14394 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14395 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14396 | SHOW_STR | |
14397 | BGP_STR | |
14398 | IP_STR | |
14399 | IPV6_STR | |
14400 | NEIGHBOR_STR | |
14401 | "Neighbor to display information about\n" | |
14402 | "Neighbor to display information about\n" | |
14403 | "Neighbor on BGP configured interface\n" | |
14404 | GR_SHOW | |
14405 | JSON_STR) | |
14406 | { | |
14407 | char *sh_arg = NULL; | |
14408 | enum show_type sh_type; | |
14409 | int idx = 0; | |
14410 | afi_t afi = AFI_MAX; | |
2986cac2 | 14411 | bool uj = use_json(argc, argv); |
14412 | ||
36235319 | 14413 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 14414 | afi = AFI_MAX; |
14415 | ||
14416 | idx++; | |
14417 | ||
14418 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14419 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14420 | || argv_find(argv, argc, "WORD", &idx)) { | |
14421 | sh_type = show_peer; | |
14422 | sh_arg = argv[idx]->arg; | |
14423 | } else | |
14424 | sh_type = show_all; | |
14425 | ||
14426 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14427 | return CMD_SUCCESS; | |
14428 | ||
14429 | ||
36235319 QY |
14430 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
14431 | afi, uj); | |
2986cac2 | 14432 | } |
14433 | ||
716b2d8a | 14434 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 14435 | DEFUN (show_ip_bgp_neighbors, |
14436 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 14437 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 14438 | SHOW_STR |
14439 | IP_STR | |
14440 | BGP_STR | |
f2a8972b | 14441 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
14442 | "Address Family\n" |
14443 | "Address Family\n" | |
718e3744 | 14444 | "Detailed information on TCP and BGP neighbor connections\n" |
14445 | "Neighbor to display information about\n" | |
a80beece | 14446 | "Neighbor to display information about\n" |
91d37724 | 14447 | "Neighbor on BGP configured interface\n" |
9973d184 | 14448 | JSON_STR) |
718e3744 | 14449 | { |
d62a17ae | 14450 | char *vrf = NULL; |
14451 | char *sh_arg = NULL; | |
14452 | enum show_type sh_type; | |
d1927ebe | 14453 | afi_t afi = AFI_MAX; |
718e3744 | 14454 | |
9f049418 | 14455 | bool uj = use_json(argc, argv); |
718e3744 | 14456 | |
d62a17ae | 14457 | int idx = 0; |
718e3744 | 14458 | |
9a8bdf1c PG |
14459 | /* [<vrf> VIEWVRFNAME] */ |
14460 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14461 | vrf = argv[idx + 1]->arg; | |
14462 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14463 | vrf = NULL; | |
14464 | } else if (argv_find(argv, argc, "view", &idx)) | |
14465 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 14466 | vrf = argv[idx + 1]->arg; |
718e3744 | 14467 | |
d62a17ae | 14468 | idx++; |
d1927ebe AS |
14469 | |
14470 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14471 | sh_type = show_ipv4_all; | |
14472 | afi = AFI_IP; | |
14473 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14474 | sh_type = show_ipv6_all; | |
14475 | afi = AFI_IP6; | |
14476 | } else { | |
14477 | sh_type = show_all; | |
14478 | } | |
14479 | ||
d62a17ae | 14480 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
14481 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14482 | || argv_find(argv, argc, "WORD", &idx)) { | |
14483 | sh_type = show_peer; | |
14484 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
14485 | } |
14486 | ||
14487 | if (sh_type == show_peer && afi == AFI_IP) { | |
14488 | sh_type = show_ipv4_peer; | |
14489 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14490 | sh_type = show_ipv6_peer; | |
14491 | } | |
856ca177 | 14492 | |
d62a17ae | 14493 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 14494 | } |
14495 | ||
716b2d8a | 14496 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 14497 | paths' and `show ip mbgp paths'. Those functions results are the |
14498 | same.*/ | |
f412b39a | 14499 | DEFUN (show_ip_bgp_paths, |
718e3744 | 14500 | show_ip_bgp_paths_cmd, |
46f296b4 | 14501 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 14502 | SHOW_STR |
14503 | IP_STR | |
14504 | BGP_STR | |
46f296b4 | 14505 | BGP_SAFI_HELP_STR |
718e3744 | 14506 | "Path information\n") |
14507 | { | |
d62a17ae | 14508 | vty_out(vty, "Address Refcnt Path\n"); |
14509 | aspath_print_all_vty(vty); | |
14510 | return CMD_SUCCESS; | |
718e3744 | 14511 | } |
14512 | ||
718e3744 | 14513 | #include "hash.h" |
14514 | ||
e3b78da8 | 14515 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14516 | struct vty *vty) |
718e3744 | 14517 | { |
d62a17ae | 14518 | struct community *com; |
718e3744 | 14519 | |
e3b78da8 | 14520 | com = (struct community *)bucket->data; |
3f65c5b1 | 14521 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 14522 | community_str(com, false)); |
718e3744 | 14523 | } |
14524 | ||
14525 | /* Show BGP's community internal data. */ | |
f412b39a | 14526 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 14527 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 14528 | "show [ip] bgp community-info", |
718e3744 | 14529 | SHOW_STR |
14530 | IP_STR | |
14531 | BGP_STR | |
14532 | "List all bgp community information\n") | |
14533 | { | |
d62a17ae | 14534 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 14535 | |
d62a17ae | 14536 | hash_iterate(community_hash(), |
e3b78da8 | 14537 | (void (*)(struct hash_bucket *, |
d62a17ae | 14538 | void *))community_show_all_iterator, |
14539 | vty); | |
718e3744 | 14540 | |
d62a17ae | 14541 | return CMD_SUCCESS; |
718e3744 | 14542 | } |
14543 | ||
e3b78da8 | 14544 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14545 | struct vty *vty) |
57d187bc | 14546 | { |
d62a17ae | 14547 | struct lcommunity *lcom; |
57d187bc | 14548 | |
e3b78da8 | 14549 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 14550 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 14551 | lcommunity_str(lcom, false)); |
57d187bc JS |
14552 | } |
14553 | ||
14554 | /* Show BGP's community internal data. */ | |
14555 | DEFUN (show_ip_bgp_lcommunity_info, | |
14556 | show_ip_bgp_lcommunity_info_cmd, | |
14557 | "show ip bgp large-community-info", | |
14558 | SHOW_STR | |
14559 | IP_STR | |
14560 | BGP_STR | |
14561 | "List all bgp large-community information\n") | |
14562 | { | |
d62a17ae | 14563 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 14564 | |
d62a17ae | 14565 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 14566 | (void (*)(struct hash_bucket *, |
d62a17ae | 14567 | void *))lcommunity_show_all_iterator, |
14568 | vty); | |
57d187bc | 14569 | |
d62a17ae | 14570 | return CMD_SUCCESS; |
57d187bc | 14571 | } |
2986cac2 | 14572 | /* Graceful Restart */ |
14573 | ||
14574 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
14575 | struct bgp *bgp, |
14576 | bool use_json, | |
14577 | json_object *json) | |
2986cac2 | 14578 | { |
57d187bc JS |
14579 | |
14580 | ||
2986cac2 | 14581 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
14582 | ||
7318ae88 | 14583 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 14584 | |
14585 | switch (bgp_global_gr_mode) { | |
14586 | ||
14587 | case GLOBAL_HELPER: | |
13909c4f | 14588 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 14589 | break; |
14590 | ||
14591 | case GLOBAL_GR: | |
13909c4f | 14592 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 14593 | break; |
14594 | ||
14595 | case GLOBAL_DISABLE: | |
13909c4f | 14596 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 14597 | break; |
14598 | ||
14599 | case GLOBAL_INVALID: | |
2986cac2 | 14600 | vty_out(vty, |
2ba1fe69 | 14601 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 14602 | break; |
14603 | } | |
14604 | vty_out(vty, "\n"); | |
14605 | } | |
14606 | ||
36235319 QY |
14607 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
14608 | enum show_type type, | |
14609 | const char *ip_str, | |
14610 | afi_t afi, bool use_json) | |
2986cac2 | 14611 | { |
14612 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14613 | afi = AFI_IP; | |
14614 | ||
14615 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14616 | ||
36235319 QY |
14617 | bgp_show_neighbor_graceful_restart_vty( |
14618 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 14619 | afi++; |
14620 | } | |
14621 | } else if (afi != AFI_MAX) { | |
36235319 QY |
14622 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
14623 | use_json); | |
2986cac2 | 14624 | } else { |
14625 | return CMD_ERR_INCOMPLETE; | |
14626 | } | |
14627 | ||
14628 | return CMD_SUCCESS; | |
14629 | } | |
14630 | /* Graceful Restart */ | |
14631 | ||
f412b39a | 14632 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 14633 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 14634 | "show [ip] bgp attribute-info", |
718e3744 | 14635 | SHOW_STR |
14636 | IP_STR | |
14637 | BGP_STR | |
14638 | "List all bgp attribute information\n") | |
14639 | { | |
d62a17ae | 14640 | attr_show_all(vty); |
14641 | return CMD_SUCCESS; | |
718e3744 | 14642 | } |
6b0655a2 | 14643 | |
03915806 CS |
14644 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
14645 | afi_t afi, safi_t safi, | |
14646 | bool use_json, json_object *json) | |
53089bec | 14647 | { |
14648 | struct bgp *bgp; | |
14649 | struct listnode *node; | |
14650 | char *vname; | |
14651 | char buf1[INET6_ADDRSTRLEN]; | |
14652 | char *ecom_str; | |
14653 | vpn_policy_direction_t dir; | |
14654 | ||
03915806 | 14655 | if (json) { |
b46dfd20 DS |
14656 | json_object *json_import_vrfs = NULL; |
14657 | json_object *json_export_vrfs = NULL; | |
14658 | ||
b46dfd20 DS |
14659 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14660 | ||
53089bec | 14661 | if (!bgp) { |
b46dfd20 DS |
14662 | vty_out(vty, "%s\n", |
14663 | json_object_to_json_string_ext( | |
14664 | json, | |
14665 | JSON_C_TO_STRING_PRETTY)); | |
14666 | json_object_free(json); | |
14667 | ||
53089bec | 14668 | return CMD_WARNING; |
14669 | } | |
b46dfd20 | 14670 | |
94d4c685 DS |
14671 | /* Provide context for the block */ |
14672 | json_object_string_add(json, "vrf", name ? name : "default"); | |
14673 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 14674 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 14675 | |
b46dfd20 DS |
14676 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14677 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14678 | json_object_string_add(json, "importFromVrfs", "none"); | |
14679 | json_object_string_add(json, "importRts", "none"); | |
14680 | } else { | |
6ce24e52 DS |
14681 | json_import_vrfs = json_object_new_array(); |
14682 | ||
b46dfd20 DS |
14683 | for (ALL_LIST_ELEMENTS_RO( |
14684 | bgp->vpn_policy[afi].import_vrf, | |
14685 | node, vname)) | |
14686 | json_object_array_add(json_import_vrfs, | |
14687 | json_object_new_string(vname)); | |
14688 | ||
b20875ea CS |
14689 | json_object_object_add(json, "importFromVrfs", |
14690 | json_import_vrfs); | |
b46dfd20 | 14691 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
14692 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14693 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14694 | bgp->vpn_policy[afi].rtlist[dir], |
14695 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14696 | json_object_string_add(json, "importRts", |
14697 | ecom_str); | |
14698 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14699 | } else | |
14700 | json_object_string_add(json, "importRts", | |
14701 | "none"); | |
b46dfd20 DS |
14702 | } |
14703 | ||
14704 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14705 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
14706 | json_object_string_add(json, "exportToVrfs", "none"); | |
14707 | json_object_string_add(json, "routeDistinguisher", | |
14708 | "none"); | |
14709 | json_object_string_add(json, "exportRts", "none"); | |
14710 | } else { | |
6ce24e52 DS |
14711 | json_export_vrfs = json_object_new_array(); |
14712 | ||
b46dfd20 DS |
14713 | for (ALL_LIST_ELEMENTS_RO( |
14714 | bgp->vpn_policy[afi].export_vrf, | |
14715 | node, vname)) | |
14716 | json_object_array_add(json_export_vrfs, | |
14717 | json_object_new_string(vname)); | |
14718 | json_object_object_add(json, "exportToVrfs", | |
14719 | json_export_vrfs); | |
14720 | json_object_string_add(json, "routeDistinguisher", | |
14721 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14722 | buf1, RD_ADDRSTRLEN)); | |
14723 | ||
14724 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14725 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14726 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14727 | bgp->vpn_policy[afi].rtlist[dir], |
14728 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14729 | json_object_string_add(json, "exportRts", |
14730 | ecom_str); | |
14731 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14732 | } else | |
14733 | json_object_string_add(json, "exportRts", | |
14734 | "none"); | |
b46dfd20 DS |
14735 | } |
14736 | ||
03915806 CS |
14737 | if (use_json) { |
14738 | vty_out(vty, "%s\n", | |
14739 | json_object_to_json_string_ext(json, | |
b46dfd20 | 14740 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
14741 | json_object_free(json); |
14742 | } | |
53089bec | 14743 | } else { |
b46dfd20 DS |
14744 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14745 | ||
53089bec | 14746 | if (!bgp) { |
b46dfd20 | 14747 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 14748 | return CMD_WARNING; |
14749 | } | |
53089bec | 14750 | |
b46dfd20 DS |
14751 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14752 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
14753 | vty_out(vty, | |
14754 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 14755 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14756 | else { |
14757 | vty_out(vty, | |
14758 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 14759 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14760 | |
14761 | for (ALL_LIST_ELEMENTS_RO( | |
14762 | bgp->vpn_policy[afi].import_vrf, | |
14763 | node, vname)) | |
14764 | vty_out(vty, " %s\n", vname); | |
14765 | ||
14766 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
14767 | ecom_str = NULL; |
14768 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14769 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14770 | bgp->vpn_policy[afi].rtlist[dir], |
14771 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 14772 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 14773 | |
b20875ea CS |
14774 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
14775 | } else | |
14776 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14777 | } |
53089bec | 14778 | |
b46dfd20 DS |
14779 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14780 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14781 | vty_out(vty, | |
14782 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 14783 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14784 | else { |
14785 | vty_out(vty, | |
04c9077f | 14786 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 14787 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14788 | |
14789 | for (ALL_LIST_ELEMENTS_RO( | |
14790 | bgp->vpn_policy[afi].export_vrf, | |
14791 | node, vname)) | |
14792 | vty_out(vty, " %s\n", vname); | |
14793 | ||
14794 | vty_out(vty, "RD: %s\n", | |
14795 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14796 | buf1, RD_ADDRSTRLEN)); | |
14797 | ||
14798 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14799 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14800 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14801 | bgp->vpn_policy[afi].rtlist[dir], |
14802 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14803 | vty_out(vty, "Export RT: %s\n", ecom_str); |
14804 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14805 | } else | |
14806 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14807 | } |
53089bec | 14808 | } |
14809 | ||
14810 | return CMD_SUCCESS; | |
14811 | } | |
14812 | ||
03915806 CS |
14813 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
14814 | safi_t safi, bool use_json) | |
14815 | { | |
14816 | struct listnode *node, *nnode; | |
14817 | struct bgp *bgp; | |
14818 | char *vrf_name = NULL; | |
14819 | json_object *json = NULL; | |
14820 | json_object *json_vrf = NULL; | |
14821 | json_object *json_vrfs = NULL; | |
14822 | ||
14823 | if (use_json) { | |
14824 | json = json_object_new_object(); | |
14825 | json_vrfs = json_object_new_object(); | |
14826 | } | |
14827 | ||
14828 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14829 | ||
14830 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
14831 | vrf_name = bgp->name; | |
14832 | ||
14833 | if (use_json) { | |
14834 | json_vrf = json_object_new_object(); | |
14835 | } else { | |
14836 | vty_out(vty, "\nInstance %s:\n", | |
14837 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14838 | ? VRF_DEFAULT_NAME : bgp->name); | |
14839 | } | |
14840 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
14841 | if (use_json) { | |
14842 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14843 | json_object_object_add(json_vrfs, | |
14844 | VRF_DEFAULT_NAME, json_vrf); | |
14845 | else | |
14846 | json_object_object_add(json_vrfs, vrf_name, | |
14847 | json_vrf); | |
14848 | } | |
14849 | } | |
14850 | ||
14851 | if (use_json) { | |
14852 | json_object_object_add(json, "vrfs", json_vrfs); | |
14853 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
14854 | JSON_C_TO_STRING_PRETTY)); | |
14855 | json_object_free(json); | |
14856 | } | |
14857 | ||
14858 | return CMD_SUCCESS; | |
14859 | } | |
14860 | ||
53089bec | 14861 | /* "show [ip] bgp route-leak" command. */ |
14862 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
14863 | show_ip_bgp_route_leak_cmd, |
14864 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
14865 | SHOW_STR |
14866 | IP_STR | |
14867 | BGP_STR | |
14868 | BGP_INSTANCE_HELP_STR | |
14869 | BGP_AFI_HELP_STR | |
14870 | BGP_SAFI_HELP_STR | |
14871 | "Route leaking information\n" | |
14872 | JSON_STR) | |
53089bec | 14873 | { |
14874 | char *vrf = NULL; | |
14875 | afi_t afi = AFI_MAX; | |
14876 | safi_t safi = SAFI_MAX; | |
14877 | ||
9f049418 | 14878 | bool uj = use_json(argc, argv); |
53089bec | 14879 | int idx = 0; |
03915806 | 14880 | json_object *json = NULL; |
53089bec | 14881 | |
14882 | /* show [ip] bgp */ | |
14883 | if (argv_find(argv, argc, "ip", &idx)) { | |
14884 | afi = AFI_IP; | |
14885 | safi = SAFI_UNICAST; | |
14886 | } | |
14887 | /* [vrf VIEWVRFNAME] */ | |
14888 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
14889 | vty_out(vty, |
14890 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 14891 | return CMD_WARNING; |
14892 | } | |
14893 | ||
9a8bdf1c PG |
14894 | if (argv_find(argv, argc, "vrf", &idx)) { |
14895 | vrf = argv[idx + 1]->arg; | |
14896 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14897 | vrf = NULL; | |
14898 | } | |
53089bec | 14899 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14900 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14901 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14902 | } | |
14903 | ||
14904 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
14905 | vty_out(vty, |
14906 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 14907 | return CMD_WARNING; |
14908 | } | |
14909 | ||
03915806 CS |
14910 | if (vrf && strmatch(vrf, "all")) |
14911 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14912 | ||
14913 | if (uj) | |
14914 | json = json_object_new_object(); | |
14915 | ||
14916 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 14917 | } |
14918 | ||
d62a17ae | 14919 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
14920 | safi_t safi) | |
f186de26 | 14921 | { |
d62a17ae | 14922 | struct listnode *node, *nnode; |
14923 | struct bgp *bgp; | |
f186de26 | 14924 | |
d62a17ae | 14925 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
14926 | vty_out(vty, "\nInstance %s:\n", | |
14927 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14928 | ? VRF_DEFAULT_NAME |
d62a17ae | 14929 | : bgp->name); |
14930 | update_group_show(bgp, afi, safi, vty, 0); | |
14931 | } | |
f186de26 | 14932 | } |
14933 | ||
d62a17ae | 14934 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
14935 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 14936 | { |
d62a17ae | 14937 | struct bgp *bgp; |
4fb25c53 | 14938 | |
d62a17ae | 14939 | if (name) { |
14940 | if (strmatch(name, "all")) { | |
14941 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
14942 | return CMD_SUCCESS; | |
14943 | } else { | |
14944 | bgp = bgp_lookup_by_name(name); | |
14945 | } | |
14946 | } else { | |
14947 | bgp = bgp_get_default(); | |
14948 | } | |
4fb25c53 | 14949 | |
d62a17ae | 14950 | if (bgp) |
14951 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
14952 | return CMD_SUCCESS; | |
4fb25c53 DW |
14953 | } |
14954 | ||
8fe8a7f6 DS |
14955 | DEFUN (show_ip_bgp_updgrps, |
14956 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 14957 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 14958 | SHOW_STR |
14959 | IP_STR | |
14960 | BGP_STR | |
14961 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 14962 | BGP_AFI_HELP_STR |
9bedbb1e | 14963 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
14964 | "Detailed info about dynamic update groups\n" |
14965 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 14966 | { |
d62a17ae | 14967 | char *vrf = NULL; |
14968 | afi_t afi = AFI_IP6; | |
14969 | safi_t safi = SAFI_UNICAST; | |
14970 | uint64_t subgrp_id = 0; | |
14971 | ||
14972 | int idx = 0; | |
14973 | ||
14974 | /* show [ip] bgp */ | |
14975 | if (argv_find(argv, argc, "ip", &idx)) | |
14976 | afi = AFI_IP; | |
9a8bdf1c PG |
14977 | /* [<vrf> VIEWVRFNAME] */ |
14978 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14979 | vrf = argv[idx + 1]->arg; | |
14980 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14981 | vrf = NULL; | |
14982 | } else if (argv_find(argv, argc, "view", &idx)) | |
14983 | /* [<view> VIEWVRFNAME] */ | |
14984 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 14985 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14986 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14987 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14988 | } | |
5bf15956 | 14989 | |
d62a17ae | 14990 | /* get subgroup id, if provided */ |
14991 | idx = argc - 1; | |
14992 | if (argv[idx]->type == VARIABLE_TKN) | |
14993 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 14994 | |
d62a17ae | 14995 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
14996 | } |
14997 | ||
f186de26 | 14998 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
14999 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 15000 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 15001 | SHOW_STR |
716b2d8a | 15002 | IP_STR |
f186de26 | 15003 | BGP_STR |
15004 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 15005 | "Detailed info about dynamic update groups\n") |
f186de26 | 15006 | { |
d62a17ae | 15007 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
15008 | return CMD_SUCCESS; | |
f186de26 | 15009 | } |
15010 | ||
43d3f4fc DS |
15011 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15012 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15013 | "show [ip] bgp l2vpn evpn update-groups", | |
15014 | SHOW_STR | |
15015 | IP_STR | |
15016 | BGP_STR | |
15017 | "l2vpn address family\n" | |
15018 | "evpn sub-address family\n" | |
15019 | "Detailed info about dynamic update groups\n") | |
15020 | { | |
15021 | char *vrf = NULL; | |
15022 | uint64_t subgrp_id = 0; | |
15023 | ||
15024 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
15025 | return CMD_SUCCESS; | |
15026 | } | |
15027 | ||
5bf15956 DW |
15028 | DEFUN (show_bgp_updgrps_stats, |
15029 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15030 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15031 | SHOW_STR |
716b2d8a | 15032 | IP_STR |
3f9c7369 | 15033 | BGP_STR |
0c7b1b01 | 15034 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15035 | "Statistics\n") |
15036 | { | |
d62a17ae | 15037 | struct bgp *bgp; |
3f9c7369 | 15038 | |
d62a17ae | 15039 | bgp = bgp_get_default(); |
15040 | if (bgp) | |
15041 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15042 | |
d62a17ae | 15043 | return CMD_SUCCESS; |
3f9c7369 DS |
15044 | } |
15045 | ||
8386ac43 | 15046 | DEFUN (show_bgp_instance_updgrps_stats, |
15047 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15048 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15049 | SHOW_STR |
716b2d8a | 15050 | IP_STR |
8386ac43 | 15051 | BGP_STR |
15052 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15053 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15054 | "Statistics\n") |
15055 | { | |
d62a17ae | 15056 | int idx_word = 3; |
15057 | struct bgp *bgp; | |
8386ac43 | 15058 | |
d62a17ae | 15059 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15060 | if (bgp) | |
15061 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15062 | |
d62a17ae | 15063 | return CMD_SUCCESS; |
8386ac43 | 15064 | } |
15065 | ||
d62a17ae | 15066 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15067 | afi_t afi, safi_t safi, | |
15068 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15069 | { |
d62a17ae | 15070 | struct bgp *bgp; |
8386ac43 | 15071 | |
d62a17ae | 15072 | if (name) |
15073 | bgp = bgp_lookup_by_name(name); | |
15074 | else | |
15075 | bgp = bgp_get_default(); | |
8386ac43 | 15076 | |
d62a17ae | 15077 | if (bgp) { |
15078 | if (!strcmp(what, "advertise-queue")) | |
15079 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15080 | subgrp_id); | |
15081 | else if (!strcmp(what, "advertised-routes")) | |
15082 | update_group_show_advertised(bgp, afi, safi, vty, | |
15083 | subgrp_id); | |
15084 | else if (!strcmp(what, "packet-queue")) | |
15085 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15086 | subgrp_id); | |
15087 | } | |
3f9c7369 DS |
15088 | } |
15089 | ||
dc64bdec QY |
15090 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15091 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15092 | "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", | |
15093 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15094 | BGP_SAFI_HELP_STR | |
15095 | "Detailed info about dynamic update groups\n" | |
15096 | "Specific subgroup to display info for\n" | |
15097 | "Advertisement queue\n" | |
15098 | "Announced routes\n" | |
15099 | "Packet queue\n") | |
3f9c7369 | 15100 | { |
dc64bdec QY |
15101 | uint64_t subgrp_id = 0; |
15102 | afi_t afiz; | |
15103 | safi_t safiz; | |
15104 | if (sgid) | |
15105 | subgrp_id = strtoull(sgid, NULL, 10); | |
15106 | ||
15107 | if (!ip && !afi) | |
15108 | afiz = AFI_IP6; | |
15109 | if (!ip && afi) | |
15110 | afiz = bgp_vty_afi_from_str(afi); | |
15111 | if (ip && !afi) | |
15112 | afiz = AFI_IP; | |
15113 | if (ip && afi) { | |
15114 | afiz = bgp_vty_afi_from_str(afi); | |
15115 | if (afiz != AFI_IP) | |
15116 | vty_out(vty, | |
15117 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15118 | return CMD_WARNING; | |
15119 | } | |
d62a17ae | 15120 | |
dc64bdec | 15121 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15122 | |
dc64bdec | 15123 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15124 | return CMD_SUCCESS; |
15125 | } | |
15126 | ||
d62a17ae | 15127 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
15128 | { | |
15129 | struct listnode *node, *nnode; | |
15130 | struct prefix *range; | |
15131 | struct peer *conf; | |
15132 | struct peer *peer; | |
d62a17ae | 15133 | afi_t afi; |
15134 | safi_t safi; | |
15135 | const char *peer_status; | |
15136 | const char *af_str; | |
15137 | int lr_count; | |
15138 | int dynamic; | |
15139 | int af_cfgd; | |
15140 | ||
15141 | conf = group->conf; | |
15142 | ||
15143 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
6cde4b45 | 15144 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 15145 | group->name, conf->as); |
d62a17ae | 15146 | } else if (conf->as_type == AS_INTERNAL) { |
6cde4b45 | 15147 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 15148 | group->name, group->bgp->as); |
d62a17ae | 15149 | } else { |
15150 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
15151 | } | |
f14e6fdb | 15152 | |
d62a17ae | 15153 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
15154 | vty_out(vty, " Peer-group type is internal\n"); | |
15155 | else | |
15156 | vty_out(vty, " Peer-group type is external\n"); | |
15157 | ||
15158 | /* Display AFs configured. */ | |
15159 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
15160 | FOREACH_AFI_SAFI (afi, safi) { |
15161 | if (conf->afc[afi][safi]) { | |
15162 | af_cfgd = 1; | |
5cb5f4d0 | 15163 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 15164 | } |
05c7a1cc | 15165 | } |
d62a17ae | 15166 | if (!af_cfgd) |
15167 | vty_out(vty, " none\n"); | |
15168 | else | |
15169 | vty_out(vty, "\n"); | |
15170 | ||
15171 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15172 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
15173 | if (afi == AFI_IP) | |
15174 | af_str = "IPv4"; | |
15175 | else if (afi == AFI_IP6) | |
15176 | af_str = "IPv6"; | |
15177 | else | |
15178 | af_str = "???"; | |
15179 | lr_count = listcount(group->listen_range[afi]); | |
15180 | if (lr_count) { | |
15181 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
15182 | af_str); | |
15183 | ||
15184 | ||
15185 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
2dbe669b DA |
15186 | nnode, range)) |
15187 | vty_out(vty, " %pFX\n", range); | |
d62a17ae | 15188 | } |
15189 | } | |
f14e6fdb | 15190 | |
d62a17ae | 15191 | /* Display group members and their status */ |
15192 | if (listcount(group->peer)) { | |
15193 | vty_out(vty, " Peer-group members:\n"); | |
15194 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
cb9196e7 DS |
15195 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15196 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15197 | peer_status = "Idle (Admin)"; |
15198 | else if (CHECK_FLAG(peer->sflags, | |
15199 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15200 | peer_status = "Idle (PfxCt)"; | |
15201 | else | |
15202 | peer_status = lookup_msg(bgp_status_msg, | |
15203 | peer->status, NULL); | |
15204 | ||
15205 | dynamic = peer_dynamic_neighbor(peer); | |
15206 | vty_out(vty, " %s %s %s \n", peer->host, | |
15207 | dynamic ? "(dynamic)" : "", peer_status); | |
15208 | } | |
15209 | } | |
f14e6fdb | 15210 | |
d62a17ae | 15211 | return CMD_SUCCESS; |
15212 | } | |
15213 | ||
ff9959b0 QY |
15214 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
15215 | const char *group_name) | |
d62a17ae | 15216 | { |
ff9959b0 | 15217 | struct bgp *bgp; |
d62a17ae | 15218 | struct listnode *node, *nnode; |
15219 | struct peer_group *group; | |
ff9959b0 QY |
15220 | bool found = false; |
15221 | ||
15222 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15223 | ||
15224 | if (!bgp) { | |
9f049418 | 15225 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
15226 | return CMD_WARNING; |
15227 | } | |
d62a17ae | 15228 | |
15229 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15230 | if (group_name) { |
15231 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 15232 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
15233 | found = true; |
15234 | break; | |
d62a17ae | 15235 | } |
ff9959b0 QY |
15236 | } else { |
15237 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 15238 | } |
f14e6fdb | 15239 | } |
f14e6fdb | 15240 | |
ff9959b0 | 15241 | if (group_name && !found) |
d62a17ae | 15242 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15243 | |
d62a17ae | 15244 | return CMD_SUCCESS; |
f14e6fdb DS |
15245 | } |
15246 | ||
f14e6fdb DS |
15247 | DEFUN (show_ip_bgp_peer_groups, |
15248 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 15249 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
15250 | SHOW_STR |
15251 | IP_STR | |
15252 | BGP_STR | |
8386ac43 | 15253 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
15254 | "Detailed information on BGP peer groups\n" |
15255 | "Peer group name\n") | |
f14e6fdb | 15256 | { |
d62a17ae | 15257 | char *vrf, *pg; |
d62a17ae | 15258 | int idx = 0; |
f14e6fdb | 15259 | |
a4d82a8a PZ |
15260 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15261 | : NULL; | |
d62a17ae | 15262 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15263 | |
ff9959b0 | 15264 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 15265 | } |
3f9c7369 | 15266 | |
d6e3c605 | 15267 | |
718e3744 | 15268 | /* Redistribute VTY commands. */ |
15269 | ||
37a87b8f CS |
15270 | DEFUN_YANG (bgp_redistribute_ipv4, |
15271 | bgp_redistribute_ipv4_cmd, | |
15272 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15273 | "Redistribute information from another routing protocol\n" | |
15274 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15275 | { |
d62a17ae | 15276 | int idx_protocol = 1; |
37a87b8f | 15277 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15278 | |
37a87b8f CS |
15279 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15280 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15281 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15282 | argv[idx_protocol]->text, "0"); | |
15283 | ||
15284 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
7f323236 | 15285 | |
37a87b8f | 15286 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 15287 | } |
15288 | ||
d62a17ae | 15289 | ALIAS_HIDDEN( |
15290 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15291 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15292 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 15293 | |
37a87b8f CS |
15294 | DEFUN_YANG (bgp_redistribute_ipv4_rmap, |
15295 | bgp_redistribute_ipv4_rmap_cmd, | |
15296 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15297 | "Redistribute information from another routing protocol\n" | |
15298 | FRR_IP_REDIST_HELP_STR_BGPD | |
15299 | "Route map reference\n" | |
15300 | "Pointer to route-map entries\n") | |
718e3744 | 15301 | { |
d62a17ae | 15302 | int idx_protocol = 1; |
15303 | int idx_word = 3; | |
37a87b8f CS |
15304 | char base_xpath[XPATH_MAXLEN]; |
15305 | ||
15306 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15307 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15308 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15309 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15310 | |
37a87b8f CS |
15311 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15312 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15313 | argv[idx_word]->arg); | |
15314 | ||
15315 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15316 | } |
15317 | ||
d62a17ae | 15318 | ALIAS_HIDDEN( |
15319 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
15320 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15321 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15322 | "Route map reference\n" | |
15323 | "Pointer to route-map entries\n") | |
596c17ba | 15324 | |
37a87b8f CS |
15325 | DEFUN_YANG (bgp_redistribute_ipv4_metric, |
15326 | bgp_redistribute_ipv4_metric_cmd, | |
15327 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15328 | "Redistribute information from another routing protocol\n" | |
15329 | FRR_IP_REDIST_HELP_STR_BGPD | |
15330 | "Metric for redistributed routes\n" | |
15331 | "Default metric\n") | |
718e3744 | 15332 | { |
d62a17ae | 15333 | int idx_protocol = 1; |
15334 | int idx_number = 3; | |
37a87b8f CS |
15335 | char base_xpath[XPATH_MAXLEN]; |
15336 | ||
15337 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15338 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15339 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15340 | argv[idx_protocol]->text, "0"); | |
d62a17ae | 15341 | |
37a87b8f CS |
15342 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15343 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15344 | argv[idx_number]->arg); | |
15345 | ||
15346 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 15347 | } |
15348 | ||
15349 | ALIAS_HIDDEN( | |
15350 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15351 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15352 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15353 | "Metric for redistributed routes\n" | |
15354 | "Default metric\n") | |
596c17ba | 15355 | |
37a87b8f CS |
15356 | DEFUN_YANG( |
15357 | bgp_redistribute_ipv4_rmap_metric, | |
15358 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
15359 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15360 | " route-map WORD metric (0-4294967295)", | |
15361 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15362 | "Route map reference\n" | |
15363 | "Pointer to route-map entries\n" | |
15364 | "Metric for redistributed routes\n" | |
15365 | "Default metric\n") | |
718e3744 | 15366 | { |
d62a17ae | 15367 | int idx_protocol = 1; |
15368 | int idx_word = 3; | |
15369 | int idx_number = 5; | |
37a87b8f CS |
15370 | char base_xpath[XPATH_MAXLEN]; |
15371 | ||
15372 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15373 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15374 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15375 | argv[idx_protocol]->text, "0"); | |
15376 | ||
15377 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15378 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15379 | argv[idx_word]->arg); | |
15380 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15381 | argv[idx_number]->arg); | |
d62a17ae | 15382 | |
37a87b8f | 15383 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15384 | } |
15385 | ||
15386 | ALIAS_HIDDEN( | |
15387 | bgp_redistribute_ipv4_rmap_metric, | |
15388 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15389 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15390 | " route-map WORD metric (0-4294967295)", | |
15391 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15392 | "Route map reference\n" | |
15393 | "Pointer to route-map entries\n" | |
15394 | "Metric for redistributed routes\n" | |
15395 | "Default metric\n") | |
596c17ba | 15396 | |
37a87b8f CS |
15397 | DEFUN_YANG( |
15398 | bgp_redistribute_ipv4_metric_rmap, | |
15399 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
15400 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15401 | " metric (0-4294967295) route-map WORD", | |
15402 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15403 | "Metric for redistributed routes\n" | |
15404 | "Default metric\n" | |
15405 | "Route map reference\n" | |
15406 | "Pointer to route-map entries\n") | |
718e3744 | 15407 | { |
d62a17ae | 15408 | int idx_protocol = 1; |
d62a17ae | 15409 | int idx_word = 5; |
37a87b8f CS |
15410 | int idx_number = 3; |
15411 | char base_xpath[XPATH_MAXLEN]; | |
15412 | ||
15413 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15414 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15415 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15416 | argv[idx_protocol]->text, "0"); | |
15417 | ||
15418 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15419 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15420 | argv[idx_number]->arg); | |
15421 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15422 | argv[idx_word]->arg); | |
d62a17ae | 15423 | |
37a87b8f | 15424 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15425 | } |
15426 | ||
15427 | ALIAS_HIDDEN( | |
15428 | bgp_redistribute_ipv4_metric_rmap, | |
15429 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15430 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15431 | " metric (0-4294967295) route-map WORD", | |
15432 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15433 | "Metric for redistributed routes\n" | |
15434 | "Default metric\n" | |
15435 | "Route map reference\n" | |
15436 | "Pointer to route-map entries\n") | |
596c17ba | 15437 | |
37a87b8f CS |
15438 | DEFUN_YANG (bgp_redistribute_ipv4_ospf, |
15439 | bgp_redistribute_ipv4_ospf_cmd, | |
15440 | "redistribute <ospf|table> (1-65535)", | |
15441 | "Redistribute information from another routing protocol\n" | |
15442 | "Open Shortest Path First (OSPFv2)\n" | |
15443 | "Non-main Kernel Routing Table\n" | |
15444 | "Instance ID/Table ID\n") | |
7c8ff89e | 15445 | { |
37a87b8f | 15446 | int idx_protocol = 1; |
d62a17ae | 15447 | int idx_number = 2; |
37a87b8f | 15448 | char base_xpath[XPATH_MAXLEN]; |
7c8ff89e | 15449 | |
37a87b8f CS |
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); | |
7a4bb9c5 | 15454 | |
37a87b8f | 15455 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
7a4bb9c5 | 15456 | |
37a87b8f | 15457 | return nb_cli_apply_changes(vty, base_xpath); |
7c8ff89e DS |
15458 | } |
15459 | ||
d62a17ae | 15460 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
15461 | "redistribute <ospf|table> (1-65535)", | |
15462 | "Redistribute information from another routing protocol\n" | |
15463 | "Open Shortest Path First (OSPFv2)\n" | |
15464 | "Non-main Kernel Routing Table\n" | |
15465 | "Instance ID/Table ID\n") | |
596c17ba | 15466 | |
37a87b8f CS |
15467 | DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap, |
15468 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
15469 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15470 | "Redistribute information from another routing protocol\n" | |
15471 | "Open Shortest Path First (OSPFv2)\n" | |
15472 | "Non-main Kernel Routing Table\n" | |
15473 | "Instance ID/Table ID\n" | |
15474 | "Route map reference\n" | |
15475 | "Pointer to route-map entries\n") | |
7c8ff89e | 15476 | { |
37a87b8f | 15477 | int idx_protocol = 1; |
d62a17ae | 15478 | int idx_number = 2; |
15479 | int idx_word = 4; | |
37a87b8f CS |
15480 | char base_xpath[XPATH_MAXLEN]; |
15481 | ||
15482 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15483 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15484 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15485 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15486 | ||
15487 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15488 | ||
15489 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15490 | argv[idx_word]->arg); | |
d62a17ae | 15491 | |
37a87b8f | 15492 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15493 | } |
15494 | ||
15495 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15496 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
15497 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15498 | "Redistribute information from another routing protocol\n" | |
15499 | "Open Shortest Path First (OSPFv2)\n" | |
15500 | "Non-main Kernel Routing Table\n" | |
15501 | "Instance ID/Table ID\n" | |
15502 | "Route map reference\n" | |
15503 | "Pointer to route-map entries\n") | |
596c17ba | 15504 | |
37a87b8f CS |
15505 | DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric, |
15506 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15507 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15508 | "Redistribute information from another routing protocol\n" | |
15509 | "Open Shortest Path First (OSPFv2)\n" | |
15510 | "Non-main Kernel Routing Table\n" | |
15511 | "Instance ID/Table ID\n" | |
15512 | "Metric for redistributed routes\n" | |
15513 | "Default metric\n") | |
7c8ff89e | 15514 | { |
37a87b8f | 15515 | int idx_protocol = 1; |
d62a17ae | 15516 | int idx_number = 2; |
15517 | int idx_number_2 = 4; | |
37a87b8f CS |
15518 | char base_xpath[XPATH_MAXLEN]; |
15519 | ||
15520 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15521 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15522 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15523 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15524 | ||
15525 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15526 | |
37a87b8f CS |
15527 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
15528 | argv[idx_number_2]->arg); | |
d62a17ae | 15529 | |
37a87b8f | 15530 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15531 | } |
15532 | ||
15533 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15534 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15535 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15536 | "Redistribute information from another routing protocol\n" | |
15537 | "Open Shortest Path First (OSPFv2)\n" | |
15538 | "Non-main Kernel Routing Table\n" | |
15539 | "Instance ID/Table ID\n" | |
15540 | "Metric for redistributed routes\n" | |
15541 | "Default metric\n") | |
596c17ba | 15542 | |
37a87b8f CS |
15543 | DEFUN_YANG( |
15544 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15545 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
15546 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15547 | "Redistribute information from another routing protocol\n" | |
15548 | "Open Shortest Path First (OSPFv2)\n" | |
15549 | "Non-main Kernel Routing Table\n" | |
15550 | "Instance ID/Table ID\n" | |
15551 | "Route map reference\n" | |
15552 | "Pointer to route-map entries\n" | |
15553 | "Metric for redistributed routes\n" | |
15554 | "Default metric\n") | |
7c8ff89e | 15555 | { |
37a87b8f | 15556 | int idx_protocol = 1; |
d62a17ae | 15557 | int idx_number = 2; |
15558 | int idx_word = 4; | |
15559 | int idx_number_2 = 6; | |
37a87b8f CS |
15560 | char base_xpath[XPATH_MAXLEN]; |
15561 | ||
15562 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15563 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15564 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15565 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15566 | ||
15567 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15568 | |
37a87b8f CS |
15569 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, |
15570 | argv[idx_word]->arg); | |
15571 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15572 | argv[idx_number_2]->arg); | |
d62a17ae | 15573 | |
37a87b8f | 15574 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15575 | } |
15576 | ||
15577 | ALIAS_HIDDEN( | |
15578 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15579 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
15580 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15581 | "Redistribute information from another routing protocol\n" | |
15582 | "Open Shortest Path First (OSPFv2)\n" | |
15583 | "Non-main Kernel Routing Table\n" | |
15584 | "Instance ID/Table ID\n" | |
15585 | "Route map reference\n" | |
15586 | "Pointer to route-map entries\n" | |
15587 | "Metric for redistributed routes\n" | |
15588 | "Default metric\n") | |
596c17ba | 15589 | |
37a87b8f CS |
15590 | DEFUN_YANG( |
15591 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15592 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
15593 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15594 | "Redistribute information from another routing protocol\n" | |
15595 | "Open Shortest Path First (OSPFv2)\n" | |
15596 | "Non-main Kernel Routing Table\n" | |
15597 | "Instance ID/Table ID\n" | |
15598 | "Metric for redistributed routes\n" | |
15599 | "Default metric\n" | |
15600 | "Route map reference\n" | |
15601 | "Pointer to route-map entries\n") | |
7c8ff89e | 15602 | { |
37a87b8f | 15603 | int idx_protocol = 1; |
d62a17ae | 15604 | int idx_number = 2; |
15605 | int idx_number_2 = 4; | |
15606 | int idx_word = 6; | |
37a87b8f CS |
15607 | char base_xpath[XPATH_MAXLEN]; |
15608 | ||
15609 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15610 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15611 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15612 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15613 | ||
15614 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15615 | |
37a87b8f CS |
15616 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
15617 | argv[idx_number_2]->arg); | |
15618 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15619 | argv[idx_word]->arg); | |
d62a17ae | 15620 | |
37a87b8f | 15621 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15622 | } |
15623 | ||
15624 | ALIAS_HIDDEN( | |
15625 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15626 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
15627 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15628 | "Redistribute information from another routing protocol\n" | |
15629 | "Open Shortest Path First (OSPFv2)\n" | |
15630 | "Non-main Kernel Routing Table\n" | |
15631 | "Instance ID/Table ID\n" | |
15632 | "Metric for redistributed routes\n" | |
15633 | "Default metric\n" | |
15634 | "Route map reference\n" | |
15635 | "Pointer to route-map entries\n") | |
596c17ba | 15636 | |
37a87b8f CS |
15637 | DEFUN_YANG (no_bgp_redistribute_ipv4_ospf, |
15638 | no_bgp_redistribute_ipv4_ospf_cmd, | |
15639 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15640 | NO_STR | |
15641 | "Redistribute information from another routing protocol\n" | |
15642 | "Open Shortest Path First (OSPFv2)\n" | |
15643 | "Non-main Kernel Routing Table\n" | |
15644 | "Instance ID/Table ID\n" | |
15645 | "Metric for redistributed routes\n" | |
15646 | "Default metric\n" | |
15647 | "Route map reference\n" | |
15648 | "Pointer to route-map entries\n") | |
7c8ff89e | 15649 | { |
37a87b8f | 15650 | int idx_protocol = 2; |
d62a17ae | 15651 | int idx_number = 3; |
37a87b8f | 15652 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 15653 | |
37a87b8f CS |
15654 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15655 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15656 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15657 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15658 | ||
15659 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
d62a17ae | 15660 | |
37a87b8f | 15661 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15662 | } |
15663 | ||
15664 | ALIAS_HIDDEN( | |
15665 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 15666 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15667 | NO_STR |
15668 | "Redistribute information from another routing protocol\n" | |
15669 | "Open Shortest Path First (OSPFv2)\n" | |
15670 | "Non-main Kernel Routing Table\n" | |
15671 | "Instance ID/Table ID\n" | |
15672 | "Metric for redistributed routes\n" | |
15673 | "Default metric\n" | |
15674 | "Route map reference\n" | |
15675 | "Pointer to route-map entries\n") | |
596c17ba | 15676 | |
37a87b8f CS |
15677 | DEFUN_YANG (no_bgp_redistribute_ipv4, |
15678 | no_bgp_redistribute_ipv4_cmd, | |
15679 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15680 | NO_STR | |
15681 | "Redistribute information from another routing protocol\n" | |
15682 | FRR_IP_REDIST_HELP_STR_BGPD | |
15683 | "Metric for redistributed routes\n" | |
15684 | "Default metric\n" | |
15685 | "Route map reference\n" | |
15686 | "Pointer to route-map entries\n") | |
718e3744 | 15687 | { |
d62a17ae | 15688 | int idx_protocol = 2; |
37a87b8f | 15689 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 15690 | |
37a87b8f CS |
15691 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15692 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15693 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15694 | argv[idx_protocol]->text, "0"); | |
15695 | ||
15696 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
15697 | ||
15698 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 15699 | } |
15700 | ||
15701 | ALIAS_HIDDEN( | |
15702 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
15703 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 15704 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15705 | NO_STR |
15706 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15707 | "Metric for redistributed routes\n" | |
15708 | "Default metric\n" | |
15709 | "Route map reference\n" | |
15710 | "Pointer to route-map entries\n") | |
596c17ba | 15711 | |
37a87b8f CS |
15712 | DEFUN_YANG (bgp_redistribute_ipv6, |
15713 | bgp_redistribute_ipv6_cmd, | |
15714 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
15715 | "Redistribute information from another routing protocol\n" | |
15716 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 15717 | { |
d62a17ae | 15718 | int idx_protocol = 1; |
37a87b8f | 15719 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15720 | |
37a87b8f CS |
15721 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15722 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15723 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15724 | argv[idx_protocol]->text, "0"); | |
15725 | ||
15726 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
718e3744 | 15727 | |
37a87b8f | 15728 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 15729 | } |
15730 | ||
37a87b8f CS |
15731 | DEFUN_YANG (bgp_redistribute_ipv6_rmap, |
15732 | bgp_redistribute_ipv6_rmap_cmd, | |
15733 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
15734 | "Redistribute information from another routing protocol\n" | |
15735 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15736 | "Route map reference\n" | |
15737 | "Pointer to route-map entries\n") | |
718e3744 | 15738 | { |
d62a17ae | 15739 | int idx_protocol = 1; |
15740 | int idx_word = 3; | |
37a87b8f CS |
15741 | char base_xpath[XPATH_MAXLEN]; |
15742 | ||
15743 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15744 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15745 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15746 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15747 | |
37a87b8f CS |
15748 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15749 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15750 | argv[idx_word]->arg); | |
15751 | ||
15752 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15753 | } |
15754 | ||
37a87b8f | 15755 | DEFUN_YANG (bgp_redistribute_ipv6_metric, |
718e3744 | 15756 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 15757 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 15758 | "Redistribute information from another routing protocol\n" |
ab0181ee | 15759 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 15760 | "Metric for redistributed routes\n" |
15761 | "Default metric\n") | |
15762 | { | |
d62a17ae | 15763 | int idx_protocol = 1; |
15764 | int idx_number = 3; | |
37a87b8f CS |
15765 | char base_xpath[XPATH_MAXLEN]; |
15766 | ||
15767 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15768 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15769 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15770 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15771 | |
37a87b8f CS |
15772 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15773 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15774 | argv[idx_number]->arg); | |
15775 | ||
15776 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15777 | } |
15778 | ||
37a87b8f CS |
15779 | DEFUN_YANG( |
15780 | bgp_redistribute_ipv6_rmap_metric, | |
15781 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
15782 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
15783 | " route-map WORD metric (0-4294967295)", | |
15784 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
15785 | "Route map reference\n" | |
15786 | "Pointer to route-map entries\n" | |
15787 | "Metric for redistributed routes\n" | |
15788 | "Default metric\n") | |
718e3744 | 15789 | { |
d62a17ae | 15790 | int idx_protocol = 1; |
15791 | int idx_word = 3; | |
15792 | int idx_number = 5; | |
37a87b8f CS |
15793 | char base_xpath[XPATH_MAXLEN]; |
15794 | ||
15795 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15796 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15797 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15798 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15799 | |
37a87b8f CS |
15800 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15801 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15802 | argv[idx_word]->arg); | |
15803 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15804 | argv[idx_number]->arg); | |
15805 | ||
15806 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15807 | } |
15808 | ||
37a87b8f CS |
15809 | DEFUN_YANG( |
15810 | bgp_redistribute_ipv6_metric_rmap, | |
15811 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
15812 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
15813 | " metric (0-4294967295) route-map WORD", | |
15814 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
15815 | "Metric for redistributed routes\n" | |
15816 | "Default metric\n" | |
15817 | "Route map reference\n" | |
15818 | "Pointer to route-map entries\n") | |
718e3744 | 15819 | { |
d62a17ae | 15820 | int idx_protocol = 1; |
d62a17ae | 15821 | int idx_word = 5; |
37a87b8f CS |
15822 | int idx_number = 3; |
15823 | char base_xpath[XPATH_MAXLEN]; | |
15824 | ||
15825 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15826 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15827 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15828 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15829 | |
37a87b8f CS |
15830 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15831 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15832 | argv[idx_number]->arg); | |
15833 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15834 | argv[idx_word]->arg); | |
15835 | ||
15836 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15837 | } |
15838 | ||
37a87b8f CS |
15839 | DEFUN_YANG( |
15840 | no_bgp_redistribute_ipv6, | |
15841 | no_bgp_redistribute_ipv6_cmd, | |
15842 | "no redistribute " FRR_IP6_REDIST_STR_BGPD | |
15843 | " [{metric (0-4294967295)|route-map WORD}]", | |
15844 | NO_STR | |
15845 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
15846 | "Metric for redistributed routes\n" | |
15847 | "Default metric\n" | |
15848 | "Route map reference\n" | |
15849 | "Pointer to route-map entries\n") | |
718e3744 | 15850 | { |
d62a17ae | 15851 | int idx_protocol = 2; |
37a87b8f | 15852 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15853 | |
37a87b8f CS |
15854 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15855 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15856 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15857 | argv[idx_protocol]->text, "0"); | |
15858 | ||
15859 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
15860 | ||
15861 | return nb_cli_apply_changes(vty, base_xpath); | |
15862 | } | |
718e3744 | 15863 | |
37a87b8f CS |
15864 | void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list( |
15865 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
15866 | { | |
15867 | uint32_t instance = 0; | |
15868 | ||
15869 | vty_out(vty, " redistribute %s", | |
15870 | yang_dnode_get_string(dnode, "./route-type")); | |
15871 | if ((instance = yang_dnode_get_uint16(dnode, "./route-instance"))) | |
15872 | vty_out(vty, " %d", instance); | |
15873 | if (yang_dnode_exists(dnode, "./metric")) | |
15874 | vty_out(vty, " metric %u", | |
15875 | yang_dnode_get_uint32(dnode, "./metric")); | |
15876 | if (yang_dnode_exists(dnode, "./rmap-policy-import")) | |
15877 | vty_out(vty, " route-map %s", | |
15878 | yang_dnode_get_string(dnode, "./rmap-policy-import")); | |
15879 | vty_out(vty, "\n"); | |
d62a17ae | 15880 | } |
15881 | ||
dd65f45e DL |
15882 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
15883 | afi_t afi, safi_t safi) | |
d62a17ae | 15884 | { |
15885 | int i; | |
15886 | ||
15887 | /* Unicast redistribution only. */ | |
15888 | if (safi != SAFI_UNICAST) | |
2b791107 | 15889 | return; |
d62a17ae | 15890 | |
15891 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
15892 | /* Redistribute BGP does not make sense. */ | |
15893 | if (i != ZEBRA_ROUTE_BGP) { | |
15894 | struct list *red_list; | |
15895 | struct listnode *node; | |
15896 | struct bgp_redist *red; | |
15897 | ||
15898 | red_list = bgp->redist[afi][i]; | |
15899 | if (!red_list) | |
15900 | continue; | |
15901 | ||
15902 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 15903 | /* "redistribute" configuration. */ |
15904 | vty_out(vty, " redistribute %s", | |
15905 | zebra_route_string(i)); | |
15906 | if (red->instance) | |
15907 | vty_out(vty, " %d", red->instance); | |
15908 | if (red->redist_metric_flag) | |
15909 | vty_out(vty, " metric %u", | |
15910 | red->redist_metric); | |
15911 | if (red->rmap.name) | |
15912 | vty_out(vty, " route-map %s", | |
15913 | red->rmap.name); | |
15914 | vty_out(vty, "\n"); | |
15915 | } | |
15916 | } | |
15917 | } | |
718e3744 | 15918 | } |
6b0655a2 | 15919 | |
dd65f45e DL |
15920 | /* peer-group helpers for config-write */ |
15921 | ||
15922 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
15923 | { | |
15924 | if (!peer_group_active(peer)) { | |
15925 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
15926 | return !CHECK_FLAG(peer->flags, flag); | |
15927 | else | |
15928 | return !!CHECK_FLAG(peer->flags, flag); | |
15929 | } | |
15930 | ||
15931 | return !!CHECK_FLAG(peer->flags_override, flag); | |
15932 | } | |
15933 | ||
15934 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
15935 | uint32_t flag) | |
15936 | { | |
15937 | if (!peer_group_active(peer)) { | |
15938 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
15939 | return !peer_af_flag_check(peer, afi, safi, flag); | |
15940 | else | |
15941 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
15942 | } | |
15943 | ||
15944 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
15945 | } | |
15946 | ||
15947 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
15948 | uint8_t type, int direct) | |
15949 | { | |
15950 | struct bgp_filter *filter; | |
15951 | ||
15952 | if (peer_group_active(peer)) | |
15953 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
15954 | type); | |
15955 | ||
15956 | filter = &peer->filter[afi][safi]; | |
15957 | switch (type) { | |
15958 | case PEER_FT_DISTRIBUTE_LIST: | |
15959 | return !!(filter->dlist[direct].name); | |
15960 | case PEER_FT_FILTER_LIST: | |
15961 | return !!(filter->aslist[direct].name); | |
15962 | case PEER_FT_PREFIX_LIST: | |
15963 | return !!(filter->plist[direct].name); | |
15964 | case PEER_FT_ROUTE_MAP: | |
15965 | return !!(filter->map[direct].name); | |
15966 | case PEER_FT_UNSUPPRESS_MAP: | |
15967 | return !!(filter->usmap.name); | |
7f7940e6 MK |
15968 | case PEER_FT_ADVERTISE_MAP: |
15969 | return !!(filter->advmap.aname | |
15970 | && ((filter->advmap.condition == direct) | |
15971 | && filter->advmap.cname)); | |
dd65f45e DL |
15972 | default: |
15973 | return false; | |
15974 | } | |
15975 | } | |
15976 | ||
15977 | /* Return true if the addpath type is set for peer and different from | |
15978 | * peer-group. | |
15979 | */ | |
3dc339cd DA |
15980 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
15981 | safi_t safi) | |
dd65f45e DL |
15982 | { |
15983 | enum bgp_addpath_strat type, g_type; | |
15984 | ||
15985 | type = peer->addpath_type[afi][safi]; | |
15986 | ||
15987 | if (type != BGP_ADDPATH_NONE) { | |
15988 | if (peer_group_active(peer)) { | |
15989 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
15990 | ||
15991 | if (type != g_type) | |
3dc339cd | 15992 | return true; |
dd65f45e | 15993 | else |
3dc339cd | 15994 | return false; |
dd65f45e DL |
15995 | } |
15996 | ||
3dc339cd | 15997 | return true; |
dd65f45e DL |
15998 | } |
15999 | ||
3dc339cd | 16000 | return false; |
dd65f45e DL |
16001 | } |
16002 | ||
b9c7bc5a | 16003 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16004 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16005 | afi_t afi) |
16006 | { | |
b9c7bc5a | 16007 | int indent = 2; |
ddb5b488 | 16008 | |
8a066a70 | 16009 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16010 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16011 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16012 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16013 | bgp->vpn_policy[afi] | |
bb4f6190 | 16014 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16015 | else |
16016 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16017 | bgp->vpn_policy[afi] | |
16018 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16019 | } | |
12a844a5 DS |
16020 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16021 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16022 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16023 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16024 | return; | |
16025 | ||
e70e9f8e PZ |
16026 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16027 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16028 | ||
16029 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16030 | ||
16031 | } else { | |
16032 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16033 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16034 | bgp->vpn_policy[afi].tovpn_label); | |
16035 | } | |
ddb5b488 PZ |
16036 | } |
16037 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16038 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16039 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 16040 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
16041 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
16042 | sizeof(buf))); | |
16043 | } | |
16044 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16045 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16046 | ||
16047 | char buf[PREFIX_STRLEN]; | |
16048 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16049 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16050 | sizeof(buf))) { | |
16051 | ||
b9c7bc5a PZ |
16052 | vty_out(vty, "%*snexthop vpn export %s\n", |
16053 | indent, "", buf); | |
ddb5b488 PZ |
16054 | } |
16055 | } | |
16056 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16057 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16058 | && ecommunity_cmp( | |
16059 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16060 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16061 | ||
16062 | char *b = ecommunity_ecom2str( | |
16063 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16064 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16065 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16066 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16067 | } else { | |
16068 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16069 | char *b = ecommunity_ecom2str( | |
16070 | bgp->vpn_policy[afi] | |
16071 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16072 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16073 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16074 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16075 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16076 | } | |
16077 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16078 | char *b = ecommunity_ecom2str( | |
16079 | bgp->vpn_policy[afi] | |
16080 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16081 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16082 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16083 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16084 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16085 | } | |
16086 | } | |
bb4f6190 DS |
16087 | |
16088 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16089 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16090 | bgp->vpn_policy[afi] |
16091 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16092 | |
301ad80a PG |
16093 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16094 | char *b = ecommunity_ecom2str( | |
16095 | bgp->vpn_policy[afi] | |
16096 | .import_redirect_rtlist, | |
16097 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16098 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16099 | |
9a659715 PG |
16100 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16101 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16102 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16103 | indent, "", b); |
16104 | else | |
16105 | vty_out(vty, "%*srt redirect import %s\n", | |
16106 | indent, "", b); | |
301ad80a PG |
16107 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16108 | } | |
ddb5b488 PZ |
16109 | } |
16110 | ||
dd65f45e DL |
16111 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16112 | afi_t afi, safi_t safi) | |
16113 | { | |
16114 | struct bgp_filter *filter; | |
16115 | char *addr; | |
16116 | ||
16117 | addr = peer->host; | |
16118 | filter = &peer->filter[afi][safi]; | |
16119 | ||
16120 | /* distribute-list. */ | |
16121 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16122 | FILTER_IN)) | |
16123 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16124 | filter->dlist[FILTER_IN].name); | |
16125 | ||
16126 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16127 | FILTER_OUT)) | |
16128 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16129 | filter->dlist[FILTER_OUT].name); | |
16130 | ||
16131 | /* prefix-list. */ | |
16132 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16133 | FILTER_IN)) | |
16134 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16135 | filter->plist[FILTER_IN].name); | |
16136 | ||
16137 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16138 | FILTER_OUT)) | |
16139 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16140 | filter->plist[FILTER_OUT].name); | |
16141 | ||
16142 | /* route-map. */ | |
16143 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16144 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16145 | filter->map[RMAP_IN].name); | |
16146 | ||
16147 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16148 | RMAP_OUT)) | |
16149 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16150 | filter->map[RMAP_OUT].name); | |
16151 | ||
16152 | /* unsuppress-map */ | |
16153 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16154 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16155 | filter->usmap.name); | |
16156 | ||
7f7940e6 MK |
16157 | /* advertise-map : always applied in OUT direction*/ |
16158 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16159 | CONDITION_NON_EXIST)) | |
16160 | vty_out(vty, | |
16161 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16162 | addr, filter->advmap.aname, filter->advmap.cname); | |
16163 | ||
16164 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16165 | CONDITION_EXIST)) | |
16166 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16167 | addr, filter->advmap.aname, filter->advmap.cname); | |
16168 | ||
dd65f45e DL |
16169 | /* filter-list. */ |
16170 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16171 | FILTER_IN)) | |
16172 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16173 | filter->aslist[FILTER_IN].name); | |
16174 | ||
16175 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16176 | FILTER_OUT)) | |
16177 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16178 | filter->aslist[FILTER_OUT].name); | |
16179 | } | |
16180 | ||
16181 | /* BGP peer configuration display function. */ | |
16182 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16183 | struct peer *peer) | |
16184 | { | |
16185 | struct peer *g_peer = NULL; | |
16186 | char buf[SU_ADDRSTRLEN]; | |
16187 | char *addr; | |
16188 | int if_pg_printed = false; | |
16189 | int if_ras_printed = false; | |
16190 | ||
16191 | /* Skip dynamic neighbors. */ | |
16192 | if (peer_dynamic_neighbor(peer)) | |
16193 | return; | |
16194 | ||
16195 | if (peer->conf_if) | |
16196 | addr = peer->conf_if; | |
16197 | else | |
16198 | addr = peer->host; | |
16199 | ||
16200 | /************************************ | |
16201 | ****** Global to the neighbor ****** | |
16202 | ************************************/ | |
16203 | if (peer->conf_if) { | |
16204 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16205 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16206 | else | |
16207 | vty_out(vty, " neighbor %s interface", addr); | |
16208 | ||
16209 | if (peer_group_active(peer)) { | |
16210 | vty_out(vty, " peer-group %s", peer->group->name); | |
16211 | if_pg_printed = true; | |
16212 | } else if (peer->as_type == AS_SPECIFIED) { | |
16213 | vty_out(vty, " remote-as %u", peer->as); | |
16214 | if_ras_printed = true; | |
16215 | } else if (peer->as_type == AS_INTERNAL) { | |
16216 | vty_out(vty, " remote-as internal"); | |
16217 | if_ras_printed = true; | |
16218 | } else if (peer->as_type == AS_EXTERNAL) { | |
16219 | vty_out(vty, " remote-as external"); | |
16220 | if_ras_printed = true; | |
16221 | } | |
16222 | ||
16223 | vty_out(vty, "\n"); | |
16224 | } | |
16225 | ||
16226 | /* remote-as and peer-group */ | |
16227 | /* peer is a member of a peer-group */ | |
16228 | if (peer_group_active(peer)) { | |
16229 | g_peer = peer->group->conf; | |
16230 | ||
16231 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16232 | if (peer->as_type == AS_SPECIFIED) { | |
16233 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16234 | addr, peer->as); | |
16235 | } else if (peer->as_type == AS_INTERNAL) { | |
16236 | vty_out(vty, | |
16237 | " neighbor %s remote-as internal\n", | |
16238 | addr); | |
16239 | } else if (peer->as_type == AS_EXTERNAL) { | |
16240 | vty_out(vty, | |
16241 | " neighbor %s remote-as external\n", | |
16242 | addr); | |
16243 | } | |
16244 | } | |
16245 | ||
16246 | /* For swpX peers we displayed the peer-group | |
16247 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16248 | if (!if_pg_printed) | |
16249 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16250 | peer->group->name); | |
16251 | } | |
16252 | ||
16253 | /* peer is NOT a member of a peer-group */ | |
16254 | else { | |
16255 | /* peer is a peer-group, declare the peer-group */ | |
16256 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16257 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16258 | } | |
16259 | ||
16260 | if (!if_ras_printed) { | |
16261 | if (peer->as_type == AS_SPECIFIED) { | |
16262 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16263 | addr, peer->as); | |
16264 | } else if (peer->as_type == AS_INTERNAL) { | |
16265 | vty_out(vty, | |
16266 | " neighbor %s remote-as internal\n", | |
16267 | addr); | |
16268 | } else if (peer->as_type == AS_EXTERNAL) { | |
16269 | vty_out(vty, | |
16270 | " neighbor %s remote-as external\n", | |
16271 | addr); | |
16272 | } | |
16273 | } | |
16274 | } | |
16275 | ||
16276 | /* local-as */ | |
16277 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16278 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16279 | peer->change_local_as); | |
16280 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16281 | vty_out(vty, " no-prepend"); | |
16282 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16283 | vty_out(vty, " replace-as"); | |
16284 | vty_out(vty, "\n"); | |
16285 | } | |
16286 | ||
16287 | /* description */ | |
16288 | if (peer->desc) { | |
16289 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16290 | } | |
16291 | ||
16292 | /* shutdown */ | |
16293 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16294 | if (peer->tx_shutdown_message) | |
16295 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16296 | peer->tx_shutdown_message); | |
16297 | else | |
16298 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16299 | } | |
16300 | ||
8336c896 DA |
16301 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
16302 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16303 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16304 | ||
dd65f45e DL |
16305 | /* bfd */ |
16306 | if (peer->bfd_info) { | |
16307 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
16308 | bgp_bfd_peer_config_write(vty, peer, addr); | |
16309 | } | |
16310 | } | |
16311 | ||
16312 | /* password */ | |
16313 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16314 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16315 | peer->password); | |
16316 | ||
16317 | /* neighbor solo */ | |
16318 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16319 | if (!peer_group_active(peer)) { | |
16320 | vty_out(vty, " neighbor %s solo\n", addr); | |
16321 | } | |
16322 | } | |
16323 | ||
16324 | /* BGP port */ | |
16325 | if (peer->port != BGP_PORT_DEFAULT) { | |
16326 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16327 | } | |
16328 | ||
16329 | /* Local interface name */ | |
16330 | if (peer->ifname) { | |
16331 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16332 | } | |
16333 | ||
16334 | /* passive */ | |
16335 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16336 | vty_out(vty, " neighbor %s passive\n", addr); | |
16337 | ||
16338 | /* ebgp-multihop */ | |
16339 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
16340 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
16341 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
16342 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
16343 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16344 | peer->ttl); | |
16345 | } | |
16346 | } | |
16347 | ||
16348 | /* ttl-security hops */ | |
e2521429 | 16349 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
16350 | if (!peer_group_active(peer) |
16351 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16352 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16353 | addr, peer->gtsm_hops); | |
16354 | } | |
16355 | } | |
16356 | ||
16357 | /* disable-connected-check */ | |
16358 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16359 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16360 | ||
16361 | /* enforce-first-as */ | |
16362 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16363 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16364 | ||
16365 | /* update-source */ | |
16366 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16367 | if (peer->update_source) | |
16368 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16369 | sockunion2str(peer->update_source, buf, | |
16370 | SU_ADDRSTRLEN)); | |
16371 | else if (peer->update_if) | |
16372 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16373 | peer->update_if); | |
16374 | } | |
16375 | ||
16376 | /* advertisement-interval */ | |
16377 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16378 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16379 | peer->routeadv); | |
16380 | ||
16381 | /* timers */ | |
16382 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16383 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16384 | peer->keepalive, peer->holdtime); | |
16385 | ||
16386 | /* timers connect */ | |
16387 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16388 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16389 | peer->connect); | |
5d5393b9 DL |
16390 | /* need special-case handling for changed default values due to |
16391 | * config profile / version (because there is no "timers bgp connect" | |
16392 | * command, we need to save this per-peer :/) | |
16393 | */ | |
16394 | else if (!peer_group_active(peer) && !peer->connect && | |
16395 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16396 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16397 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
16398 | |
16399 | /* capability dynamic */ | |
16400 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16401 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16402 | ||
16403 | /* capability extended-nexthop */ | |
16404 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
16405 | if (!peer->conf_if) { | |
16406 | if (CHECK_FLAG(peer->flags_invert, | |
16407 | PEER_FLAG_CAPABILITY_ENHE)) | |
16408 | vty_out(vty, | |
16409 | " no neighbor %s capability extended-nexthop\n", | |
16410 | addr); | |
16411 | else | |
16412 | vty_out(vty, | |
16413 | " neighbor %s capability extended-nexthop\n", | |
16414 | addr); | |
16415 | } | |
16416 | } | |
16417 | ||
16418 | /* dont-capability-negotiation */ | |
16419 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16420 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16421 | ||
16422 | /* override-capability */ | |
16423 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16424 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16425 | ||
16426 | /* strict-capability-match */ | |
16427 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16428 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16429 | ||
16430 | /* Sender side AS path loop detection. */ | |
16431 | if (peer->as_path_loop_detection) | |
16432 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16433 | addr); | |
cfd47646 | 16434 | |
16435 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16436 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 16437 | |
16438 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16439 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 16440 | vty_out(vty, |
16441 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
16442 | } else if (CHECK_FLAG( |
16443 | peer->peer_gr_new_status_flag, | |
16444 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 16445 | vty_out(vty, |
16446 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
16447 | } else if ( |
16448 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16449 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16450 | && !(CHECK_FLAG( | |
16451 | peer->peer_gr_new_status_flag, | |
16452 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16453 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16454 | addr); | |
cfd47646 | 16455 | } |
16456 | } | |
dd65f45e DL |
16457 | } |
16458 | ||
16459 | /* BGP peer configuration display function. */ | |
16460 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16461 | struct peer *peer, afi_t afi, safi_t safi) | |
16462 | { | |
16463 | struct peer *g_peer = NULL; | |
16464 | char *addr; | |
16465 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16466 | ||
16467 | /* Skip dynamic neighbors. */ | |
16468 | if (peer_dynamic_neighbor(peer)) | |
16469 | return; | |
16470 | ||
16471 | if (peer->conf_if) | |
16472 | addr = peer->conf_if; | |
16473 | else | |
16474 | addr = peer->host; | |
16475 | ||
16476 | /************************************ | |
16477 | ****** Per AF to the neighbor ****** | |
16478 | ************************************/ | |
16479 | if (peer_group_active(peer)) { | |
16480 | g_peer = peer->group->conf; | |
16481 | ||
16482 | /* If the peer-group is active but peer is not, print a 'no | |
16483 | * activate' */ | |
16484 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16485 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16486 | } | |
16487 | ||
16488 | /* If the peer-group is not active but peer is, print an | |
16489 | 'activate' */ | |
16490 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16491 | vty_out(vty, " neighbor %s activate\n", addr); | |
16492 | } | |
16493 | } else { | |
16494 | if (peer->afc[afi][safi]) { | |
16495 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
16496 | if (CHECK_FLAG(bgp->flags, |
16497 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
16498 | vty_out(vty, " neighbor %s activate\n", |
16499 | addr); | |
16500 | } | |
16501 | } else | |
16502 | vty_out(vty, " neighbor %s activate\n", addr); | |
16503 | } else { | |
16504 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
16505 | if (!CHECK_FLAG(bgp->flags, |
16506 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
16507 | vty_out(vty, |
16508 | " no neighbor %s activate\n", | |
16509 | addr); | |
16510 | } | |
16511 | } | |
16512 | } | |
16513 | } | |
16514 | ||
16515 | /* addpath TX knobs */ | |
16516 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16517 | switch (peer->addpath_type[afi][safi]) { | |
16518 | case BGP_ADDPATH_ALL: | |
16519 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16520 | addr); | |
16521 | break; | |
16522 | case BGP_ADDPATH_BEST_PER_AS: | |
16523 | vty_out(vty, | |
16524 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16525 | addr); | |
16526 | break; | |
16527 | case BGP_ADDPATH_MAX: | |
16528 | case BGP_ADDPATH_NONE: | |
16529 | break; | |
16530 | } | |
16531 | } | |
16532 | ||
16533 | /* ORF capability. */ | |
16534 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16535 | || peergroup_af_flag_check(peer, afi, safi, | |
16536 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16537 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16538 | ||
16539 | if (peergroup_af_flag_check(peer, afi, safi, | |
16540 | PEER_FLAG_ORF_PREFIX_SM) | |
16541 | && peergroup_af_flag_check(peer, afi, safi, | |
16542 | PEER_FLAG_ORF_PREFIX_RM)) | |
16543 | vty_out(vty, " both"); | |
16544 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16545 | PEER_FLAG_ORF_PREFIX_SM)) | |
16546 | vty_out(vty, " send"); | |
16547 | else | |
16548 | vty_out(vty, " receive"); | |
16549 | vty_out(vty, "\n"); | |
16550 | } | |
16551 | ||
dd65f45e DL |
16552 | /* Route reflector client. */ |
16553 | if (peergroup_af_flag_check(peer, afi, safi, | |
16554 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16555 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16556 | } | |
16557 | ||
16558 | /* next-hop-self force */ | |
16559 | if (peergroup_af_flag_check(peer, afi, safi, | |
16560 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16561 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16562 | } | |
16563 | ||
16564 | /* next-hop-self */ | |
16565 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16566 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16567 | } | |
16568 | ||
16569 | /* remove-private-AS */ | |
16570 | if (peergroup_af_flag_check(peer, afi, safi, | |
16571 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16572 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16573 | addr); | |
16574 | } | |
16575 | ||
16576 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16577 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16578 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16579 | addr); | |
16580 | } | |
16581 | ||
16582 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16583 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16584 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16585 | } | |
16586 | ||
16587 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16588 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16589 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16590 | } | |
16591 | ||
16592 | /* as-override */ | |
16593 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16594 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16595 | } | |
16596 | ||
16597 | /* send-community print. */ | |
16598 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16599 | PEER_FLAG_SEND_COMMUNITY); | |
16600 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16601 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16602 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16603 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16604 | ||
16605 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16606 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16607 | } else { | |
16608 | if (flag_scomm) | |
16609 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16610 | if (flag_secomm) | |
16611 | vty_out(vty, | |
16612 | " no neighbor %s send-community extended\n", | |
16613 | addr); | |
16614 | ||
16615 | if (flag_slcomm) | |
16616 | vty_out(vty, " no neighbor %s send-community large\n", | |
16617 | addr); | |
16618 | } | |
16619 | ||
16620 | /* Default information */ | |
16621 | if (peergroup_af_flag_check(peer, afi, safi, | |
16622 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16623 | vty_out(vty, " neighbor %s default-originate", addr); | |
16624 | ||
16625 | if (peer->default_rmap[afi][safi].name) | |
16626 | vty_out(vty, " route-map %s", | |
16627 | peer->default_rmap[afi][safi].name); | |
16628 | ||
16629 | vty_out(vty, "\n"); | |
16630 | } | |
16631 | ||
16632 | /* Soft reconfiguration inbound. */ | |
16633 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16634 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16635 | addr); | |
16636 | } | |
16637 | ||
16638 | /* maximum-prefix. */ | |
16639 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 16640 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
16641 | peer->pmax[afi][safi]); |
16642 | ||
16643 | if (peer->pmax_threshold[afi][safi] | |
16644 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16645 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16646 | if (peer_af_flag_check(peer, afi, safi, | |
16647 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
16648 | vty_out(vty, " warning-only"); | |
16649 | if (peer->pmax_restart[afi][safi]) | |
16650 | vty_out(vty, " restart %u", | |
16651 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
16652 | if (peer_af_flag_check(peer, afi, safi, |
16653 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
16654 | vty_out(vty, " force"); | |
dd65f45e DL |
16655 | |
16656 | vty_out(vty, "\n"); | |
16657 | } | |
16658 | ||
fde246e8 DA |
16659 | /* maximum-prefix-out */ |
16660 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 16661 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
16662 | addr, peer->pmax_out[afi][safi]); |
16663 | ||
dd65f45e DL |
16664 | /* Route server client. */ |
16665 | if (peergroup_af_flag_check(peer, afi, safi, | |
16666 | PEER_FLAG_RSERVER_CLIENT)) { | |
16667 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
16668 | } | |
16669 | ||
16670 | /* Nexthop-local unchanged. */ | |
16671 | if (peergroup_af_flag_check(peer, afi, safi, | |
16672 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
16673 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
16674 | } | |
16675 | ||
16676 | /* allowas-in <1-10> */ | |
16677 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
16678 | if (peer_af_flag_check(peer, afi, safi, | |
16679 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
16680 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
16681 | } else if (peer->allowas_in[afi][safi] == 3) { | |
16682 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
16683 | } else { | |
16684 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
16685 | peer->allowas_in[afi][safi]); | |
16686 | } | |
16687 | } | |
16688 | ||
16689 | /* weight */ | |
16690 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
16691 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
16692 | peer->weight[afi][safi]); | |
16693 | ||
16694 | /* Filter. */ | |
16695 | bgp_config_write_filter(vty, peer, afi, safi); | |
16696 | ||
16697 | /* atribute-unchanged. */ | |
16698 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
16699 | || (safi != SAFI_EVPN | |
16700 | && peer_af_flag_check(peer, afi, safi, | |
16701 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
16702 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
16703 | ||
16704 | if (!peer_group_active(peer) | |
16705 | || peergroup_af_flag_check(peer, afi, safi, | |
16706 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16707 | || peergroup_af_flag_check(peer, afi, safi, | |
16708 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16709 | || peergroup_af_flag_check(peer, afi, safi, | |
16710 | PEER_FLAG_MED_UNCHANGED)) { | |
16711 | ||
16712 | vty_out(vty, | |
16713 | " neighbor %s attribute-unchanged%s%s%s\n", | |
16714 | addr, | |
16715 | peer_af_flag_check(peer, afi, safi, | |
16716 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16717 | ? " as-path" | |
16718 | : "", | |
16719 | peer_af_flag_check(peer, afi, safi, | |
16720 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16721 | ? " next-hop" | |
16722 | : "", | |
16723 | peer_af_flag_check(peer, afi, safi, | |
16724 | PEER_FLAG_MED_UNCHANGED) | |
16725 | ? " med" | |
16726 | : ""); | |
16727 | } | |
16728 | } | |
16729 | } | |
16730 | ||
16731 | /* Address family based peer configuration display. */ | |
16732 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
16733 | safi_t safi) | |
16734 | { | |
16735 | struct peer *peer; | |
16736 | struct peer_group *group; | |
16737 | struct listnode *node, *nnode; | |
16738 | ||
16739 | ||
16740 | vty_frame(vty, " !\n address-family "); | |
16741 | if (afi == AFI_IP) { | |
16742 | if (safi == SAFI_UNICAST) | |
16743 | vty_frame(vty, "ipv4 unicast"); | |
16744 | else if (safi == SAFI_LABELED_UNICAST) | |
16745 | vty_frame(vty, "ipv4 labeled-unicast"); | |
16746 | else if (safi == SAFI_MULTICAST) | |
16747 | vty_frame(vty, "ipv4 multicast"); | |
16748 | else if (safi == SAFI_MPLS_VPN) | |
16749 | vty_frame(vty, "ipv4 vpn"); | |
16750 | else if (safi == SAFI_ENCAP) | |
16751 | vty_frame(vty, "ipv4 encap"); | |
16752 | else if (safi == SAFI_FLOWSPEC) | |
16753 | vty_frame(vty, "ipv4 flowspec"); | |
16754 | } else if (afi == AFI_IP6) { | |
16755 | if (safi == SAFI_UNICAST) | |
16756 | vty_frame(vty, "ipv6 unicast"); | |
16757 | else if (safi == SAFI_LABELED_UNICAST) | |
16758 | vty_frame(vty, "ipv6 labeled-unicast"); | |
16759 | else if (safi == SAFI_MULTICAST) | |
16760 | vty_frame(vty, "ipv6 multicast"); | |
16761 | else if (safi == SAFI_MPLS_VPN) | |
16762 | vty_frame(vty, "ipv6 vpn"); | |
16763 | else if (safi == SAFI_ENCAP) | |
16764 | vty_frame(vty, "ipv6 encap"); | |
16765 | else if (safi == SAFI_FLOWSPEC) | |
16766 | vty_frame(vty, "ipv6 flowspec"); | |
16767 | } else if (afi == AFI_L2VPN) { | |
16768 | if (safi == SAFI_EVPN) | |
16769 | vty_frame(vty, "l2vpn evpn"); | |
16770 | } | |
16771 | vty_frame(vty, "\n"); | |
16772 | ||
16773 | bgp_config_write_distance(vty, bgp, afi, safi); | |
16774 | ||
16775 | bgp_config_write_network(vty, bgp, afi, safi); | |
16776 | ||
16777 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
16778 | ||
8a4e7fe6 DA |
16779 | /* BGP flag dampening. */ |
16780 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
16781 | bgp_config_write_damp(vty, afi, safi); | |
16782 | ||
dd65f45e DL |
16783 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
16784 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
16785 | ||
16786 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
16787 | /* Skip dynamic neighbors. */ | |
16788 | if (peer_dynamic_neighbor(peer)) | |
16789 | continue; | |
16790 | ||
16791 | /* Do not display doppelganger peers */ | |
16792 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
16793 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
16794 | } | |
16795 | ||
16796 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
16797 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
16798 | ||
16799 | if (safi == SAFI_EVPN) | |
16800 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
16801 | ||
16802 | if (safi == SAFI_FLOWSPEC) | |
16803 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
16804 | ||
16805 | if (safi == SAFI_UNICAST) { | |
16806 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
16807 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16808 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
16809 | ||
16810 | vty_out(vty, " export vpn\n"); | |
16811 | } | |
16812 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16813 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
16814 | ||
16815 | vty_out(vty, " import vpn\n"); | |
16816 | } | |
16817 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16818 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
16819 | char *name; | |
16820 | ||
16821 | for (ALL_LIST_ELEMENTS_RO( | |
16822 | bgp->vpn_policy[afi].import_vrf, node, | |
16823 | name)) | |
16824 | vty_out(vty, " import vrf %s\n", name); | |
16825 | } | |
16826 | } | |
16827 | ||
16828 | vty_endframe(vty, " exit-address-family\n"); | |
16829 | } | |
16830 | ||
16831 | int bgp_config_write(struct vty *vty) | |
16832 | { | |
16833 | struct bgp *bgp; | |
16834 | struct peer_group *group; | |
16835 | struct peer *peer; | |
16836 | struct listnode *node, *nnode; | |
16837 | struct listnode *mnode, *mnnode; | |
16838 | ||
16839 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
16840 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
16841 | bm->rmap_update_timer); | |
16842 | ||
d70583f7 D |
16843 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
16844 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
16845 | if (bm->v_update_delay != bm->v_establish_wait) | |
16846 | vty_out(vty, " %d", bm->v_establish_wait); | |
16847 | vty_out(vty, "\n"); | |
16848 | } | |
16849 | ||
05bd726c | 16850 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
16851 | vty_out(vty, "bgp graceful-shutdown\n"); | |
16852 | ||
c163f297 DS |
16853 | /* No-RIB (Zebra) option flag configuration */ |
16854 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
16855 | vty_out(vty, "bgp no-rib\n"); | |
16856 | ||
dd65f45e DL |
16857 | /* BGP configuration. */ |
16858 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
16859 | ||
16860 | /* skip all auto created vrf as they dont have user config */ | |
16861 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
16862 | continue; | |
16863 | ||
16864 | /* Router bgp ASN */ | |
16865 | vty_out(vty, "router bgp %u", bgp->as); | |
16866 | ||
16867 | if (bgp->name) | |
16868 | vty_out(vty, " %s %s", | |
16869 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
16870 | ? "view" : "vrf", bgp->name); | |
16871 | vty_out(vty, "\n"); | |
16872 | ||
16873 | /* BGP fast-external-failover. */ | |
16874 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
16875 | vty_out(vty, " no bgp fast-external-failover\n"); | |
16876 | ||
16877 | /* BGP router ID. */ | |
16878 | if (bgp->router_id_static.s_addr != 0) | |
23d0a753 DA |
16879 | vty_out(vty, " bgp router-id %pI4\n", |
16880 | &bgp->router_id_static); | |
dd65f45e | 16881 | |
c208c586 S |
16882 | /* Suppress fib pending */ |
16883 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
16884 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
16885 | ||
dd65f45e | 16886 | /* BGP log-neighbor-changes. */ |
892fedb6 | 16887 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 16888 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 16889 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
16890 | CHECK_FLAG(bgp->flags, |
16891 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
16892 | ? "" |
16893 | : "no "); | |
16894 | ||
16895 | /* BGP configuration. */ | |
892fedb6 | 16896 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
16897 | vty_out(vty, " bgp always-compare-med\n"); |
16898 | ||
16899 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
16900 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
16901 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
16902 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
16903 | CHECK_FLAG(bgp->flags, | |
16904 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
16905 | ? "" | |
16906 | : "no "); | |
dd65f45e DL |
16907 | |
16908 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 16909 | if (bgp->reject_as_sets) |
dd65f45e DL |
16910 | vty_out(vty, " bgp reject-as-sets\n"); |
16911 | ||
16912 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 16913 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
16914 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
16915 | ||
16916 | /* BGP default local-preference. */ | |
16917 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
16918 | vty_out(vty, " bgp default local-preference %u\n", | |
16919 | bgp->default_local_pref); | |
16920 | ||
16921 | /* BGP default show-hostname */ | |
892fedb6 | 16922 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 16923 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 16924 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 16925 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
16926 | ? "" |
16927 | : "no "); | |
16928 | ||
aef999a2 DA |
16929 | /* BGP default show-nexthop-hostname */ |
16930 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16931 | != SAVE_BGP_SHOW_HOSTNAME) | |
16932 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
16933 | CHECK_FLAG(bgp->flags, | |
16934 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16935 | ? "" | |
16936 | : "no "); | |
16937 | ||
dd65f45e DL |
16938 | /* BGP default subgroup-pkt-queue-max. */ |
16939 | if (bgp->default_subgroup_pkt_queue_max | |
16940 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
16941 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
16942 | bgp->default_subgroup_pkt_queue_max); | |
16943 | ||
16944 | /* BGP client-to-client reflection. */ | |
892fedb6 | 16945 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
16946 | vty_out(vty, " no bgp client-to-client reflection\n"); |
16947 | ||
16948 | /* BGP cluster ID. */ | |
16949 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
16950 | vty_out(vty, " bgp cluster-id %pI4\n", |
16951 | &bgp->cluster_id); | |
dd65f45e DL |
16952 | |
16953 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 16954 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
16955 | vty_out(vty, |
16956 | " bgp disable-ebgp-connected-route-check\n"); | |
16957 | ||
16958 | /* Confederation identifier*/ | |
16959 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
16960 | vty_out(vty, " bgp confederation identifier %u\n", | |
16961 | bgp->confed_id); | |
16962 | ||
16963 | /* Confederation peer */ | |
16964 | if (bgp->confed_peers_cnt > 0) { | |
16965 | int i; | |
16966 | ||
16967 | vty_out(vty, " bgp confederation peers"); | |
16968 | ||
16969 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
16970 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
16971 | ||
16972 | vty_out(vty, "\n"); | |
16973 | } | |
16974 | ||
16975 | /* BGP deterministic-med. */ | |
892fedb6 | 16976 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 16977 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 16978 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
16979 | CHECK_FLAG(bgp->flags, |
16980 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
16981 | ? "" |
16982 | : "no "); | |
16983 | ||
16984 | /* BGP update-delay. */ | |
16985 | bgp_config_write_update_delay(vty, bgp); | |
16986 | ||
16987 | if (bgp->v_maxmed_onstartup | |
16988 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
16989 | vty_out(vty, " bgp max-med on-startup %u", | |
16990 | bgp->v_maxmed_onstartup); | |
16991 | if (bgp->maxmed_onstartup_value | |
16992 | != BGP_MAXMED_VALUE_DEFAULT) | |
16993 | vty_out(vty, " %u", | |
16994 | bgp->maxmed_onstartup_value); | |
16995 | vty_out(vty, "\n"); | |
16996 | } | |
16997 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
16998 | vty_out(vty, " bgp max-med administrative"); | |
16999 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17000 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17001 | vty_out(vty, "\n"); | |
17002 | } | |
17003 | ||
17004 | /* write quanta */ | |
17005 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17006 | /* read quanta */ | |
17007 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17008 | ||
17009 | /* coalesce time */ | |
17010 | bgp_config_write_coalesce_time(vty, bgp); | |
17011 | ||
05bd726c | 17012 | /* BGP per-instance graceful-shutdown */ |
17013 | /* BGP-wide settings and per-instance settings are mutually | |
17014 | * exclusive. | |
17015 | */ | |
17016 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17017 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17018 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17019 | ||
dd65f45e DL |
17020 | /* BGP graceful-restart. */ |
17021 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17022 | vty_out(vty, | |
17023 | " bgp graceful-restart stalepath-time %u\n", | |
17024 | bgp->stalepath_time); | |
cfd47646 | 17025 | |
dd65f45e DL |
17026 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
17027 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17028 | bgp->restart_time); | |
cfd47646 | 17029 | |
17030 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
17031 | vty_out(vty, | |
17032 | " bgp graceful-restart select-defer-time %u\n", | |
17033 | bgp->select_defer_time); | |
17034 | ||
17035 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17036 | vty_out(vty, " bgp graceful-restart\n"); |
17037 | ||
cfd47646 | 17038 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17039 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17040 | ||
dd65f45e | 17041 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 17042 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
17043 | vty_out(vty, |
17044 | " bgp graceful-restart preserve-fw-state\n"); | |
17045 | ||
dc95985f | 17046 | /* Stale timer for RIB */ |
17047 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17048 | vty_out(vty, | |
17049 | " bgp graceful-restart rib-stale-time %u\n", | |
17050 | bgp->rib_stale_time); | |
17051 | ||
dd65f45e | 17052 | /* BGP bestpath method. */ |
892fedb6 | 17053 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 17054 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 17055 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
17056 | vty_out(vty, " bgp bestpath as-path confed\n"); |
17057 | ||
892fedb6 DA |
17058 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
17059 | if (CHECK_FLAG(bgp->flags, | |
17060 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
17061 | vty_out(vty, |
17062 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17063 | } else { | |
17064 | vty_out(vty, | |
17065 | " bgp bestpath as-path multipath-relax\n"); | |
17066 | } | |
17067 | } | |
17068 | ||
892fedb6 | 17069 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
17070 | vty_out(vty, |
17071 | " bgp route-reflector allow-outbound-policy\n"); | |
17072 | } | |
892fedb6 | 17073 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 17074 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
17075 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
17076 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 17077 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 17078 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 17079 | vty_out(vty, " confed"); |
892fedb6 DA |
17080 | if (CHECK_FLAG(bgp->flags, |
17081 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
17082 | vty_out(vty, " missing-as-worst"); |
17083 | vty_out(vty, "\n"); | |
17084 | } | |
17085 | ||
f7e1c681 | 17086 | /* Link bandwidth handling. */ |
17087 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17088 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17089 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17090 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17091 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17092 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17093 | ||
dd65f45e | 17094 | /* BGP network import check. */ |
892fedb6 | 17095 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 17096 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 17097 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 17098 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
17099 | ? "" |
17100 | : "no "); | |
17101 | ||
17102 | /* BGP timers configuration. */ | |
5d5393b9 DL |
17103 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
17104 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
17105 | vty_out(vty, " timers bgp %u %u\n", |
17106 | bgp->default_keepalive, bgp->default_holdtime); | |
17107 | ||
17108 | /* peer-group */ | |
17109 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17110 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17111 | } | |
17112 | ||
17113 | /* Normal neighbor configuration. */ | |
17114 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17115 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17116 | bgp_config_write_peer_global(vty, bgp, peer); | |
17117 | } | |
17118 | ||
17119 | /* listen range and limit for dynamic BGP neighbors */ | |
17120 | bgp_config_write_listen(vty, bgp); | |
17121 | ||
17122 | /* | |
17123 | * BGP default autoshutdown neighbors | |
17124 | * | |
17125 | * This must be placed after any peer and peer-group | |
17126 | * configuration, to avoid setting all peers to shutdown after | |
17127 | * a daemon restart, which is undesired behavior. (see #2286) | |
17128 | */ | |
17129 | if (bgp->autoshutdown) | |
17130 | vty_out(vty, " bgp default shutdown\n"); | |
17131 | ||
9cf59432 DS |
17132 | /* BGP instance administrative shutdown */ |
17133 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17134 | vty_out(vty, " bgp shutdown\n"); | |
17135 | ||
dd65f45e DL |
17136 | /* IPv4 unicast configuration. */ |
17137 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17138 | ||
17139 | /* IPv4 multicast configuration. */ | |
17140 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17141 | ||
17142 | /* IPv4 labeled-unicast configuration. */ | |
17143 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17144 | ||
17145 | /* IPv4 VPN configuration. */ | |
17146 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17147 | ||
17148 | /* ENCAPv4 configuration. */ | |
17149 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17150 | ||
17151 | /* FLOWSPEC v4 configuration. */ | |
17152 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17153 | ||
17154 | /* IPv6 unicast configuration. */ | |
17155 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17156 | ||
17157 | /* IPv6 multicast configuration. */ | |
17158 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17159 | ||
17160 | /* IPv6 labeled-unicast configuration. */ | |
17161 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17162 | SAFI_LABELED_UNICAST); | |
17163 | ||
17164 | /* IPv6 VPN configuration. */ | |
17165 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17166 | ||
17167 | /* ENCAPv6 configuration. */ | |
17168 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17169 | ||
17170 | /* FLOWSPEC v6 configuration. */ | |
17171 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17172 | ||
17173 | /* EVPN configuration. */ | |
17174 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17175 | ||
17176 | hook_call(bgp_inst_config_write, bgp, vty); | |
17177 | ||
49e5a4a0 | 17178 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
17179 | bgp_rfapi_cfg_write(vty, bgp); |
17180 | #endif | |
17181 | ||
17182 | vty_out(vty, "!\n"); | |
17183 | } | |
17184 | return 0; | |
17185 | } | |
17186 | ||
ddb5b488 | 17187 | |
718e3744 | 17188 | /* BGP node structure. */ |
d62a17ae | 17189 | static struct cmd_node bgp_node = { |
f4b8291f | 17190 | .name = "bgp", |
62b346ee | 17191 | .node = BGP_NODE, |
24389580 | 17192 | .parent_node = CONFIG_NODE, |
62b346ee | 17193 | .prompt = "%s(config-router)# ", |
612c2c15 | 17194 | .config_write = bgp_config_write, |
718e3744 | 17195 | }; |
17196 | ||
d62a17ae | 17197 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 17198 | .name = "bgp ipv4 unicast", |
62b346ee | 17199 | .node = BGP_IPV4_NODE, |
24389580 | 17200 | .parent_node = BGP_NODE, |
62b346ee | 17201 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17202 | }; |
17203 | ||
d62a17ae | 17204 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 17205 | .name = "bgp ipv4 multicast", |
62b346ee | 17206 | .node = BGP_IPV4M_NODE, |
24389580 | 17207 | .parent_node = BGP_NODE, |
62b346ee | 17208 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17209 | }; |
17210 | ||
d62a17ae | 17211 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 17212 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 17213 | .node = BGP_IPV4L_NODE, |
24389580 | 17214 | .parent_node = BGP_NODE, |
62b346ee | 17215 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17216 | }; |
17217 | ||
d62a17ae | 17218 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 17219 | .name = "bgp ipv6", |
62b346ee | 17220 | .node = BGP_IPV6_NODE, |
24389580 | 17221 | .parent_node = BGP_NODE, |
62b346ee | 17222 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17223 | }; |
17224 | ||
d62a17ae | 17225 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 17226 | .name = "bgp ipv6 multicast", |
62b346ee | 17227 | .node = BGP_IPV6M_NODE, |
24389580 | 17228 | .parent_node = BGP_NODE, |
62b346ee | 17229 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 17230 | }; |
17231 | ||
d62a17ae | 17232 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 17233 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 17234 | .node = BGP_IPV6L_NODE, |
24389580 | 17235 | .parent_node = BGP_NODE, |
62b346ee | 17236 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17237 | }; |
17238 | ||
62b346ee | 17239 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 17240 | .name = "bgp vpnv4", |
62b346ee | 17241 | .node = BGP_VPNV4_NODE, |
24389580 | 17242 | .parent_node = BGP_NODE, |
62b346ee | 17243 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17244 | }; |
6b0655a2 | 17245 | |
62b346ee | 17246 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 17247 | .name = "bgp vpnv6", |
62b346ee | 17248 | .node = BGP_VPNV6_NODE, |
24389580 | 17249 | .parent_node = BGP_NODE, |
62b346ee | 17250 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17251 | }; |
8ecd3266 | 17252 | |
62b346ee | 17253 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 17254 | .name = "bgp evpn", |
62b346ee | 17255 | .node = BGP_EVPN_NODE, |
24389580 | 17256 | .parent_node = BGP_NODE, |
62b346ee | 17257 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 17258 | }; |
4e0b7b6d | 17259 | |
62b346ee | 17260 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 17261 | .name = "bgp evpn vni", |
62b346ee | 17262 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 17263 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 17264 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 17265 | }; |
90e60aa7 | 17266 | |
62b346ee | 17267 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 17268 | .name = "bgp ipv4 flowspec", |
62b346ee | 17269 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 17270 | .parent_node = BGP_NODE, |
62b346ee | 17271 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17272 | }; |
7c40bf39 | 17273 | |
62b346ee | 17274 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 17275 | .name = "bgp ipv6 flowspec", |
62b346ee | 17276 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 17277 | .parent_node = BGP_NODE, |
62b346ee | 17278 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17279 | }; |
7c40bf39 | 17280 | |
d62a17ae | 17281 | static void community_list_vty(void); |
1f8ae70b | 17282 | |
d62a17ae | 17283 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 17284 | { |
d62a17ae | 17285 | struct bgp *bgp; |
17286 | struct peer *peer; | |
d62a17ae | 17287 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 17288 | |
d62a17ae | 17289 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
17290 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17291 | /* only provide suggestions on the appropriate input | |
17292 | * token type, | |
17293 | * they'll otherwise show up multiple times */ | |
17294 | enum cmd_token_type match_type; | |
17295 | char *name = peer->host; | |
d48ed3e0 | 17296 | |
d62a17ae | 17297 | if (peer->conf_if) { |
17298 | match_type = VARIABLE_TKN; | |
17299 | name = peer->conf_if; | |
17300 | } else if (strchr(peer->host, ':')) | |
17301 | match_type = IPV6_TKN; | |
17302 | else | |
17303 | match_type = IPV4_TKN; | |
d48ed3e0 | 17304 | |
d62a17ae | 17305 | if (token->type != match_type) |
17306 | continue; | |
d48ed3e0 | 17307 | |
d62a17ae | 17308 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
17309 | } | |
d62a17ae | 17310 | } |
b8a815e5 DL |
17311 | } |
17312 | ||
17313 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 17314 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
17315 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 17316 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 17317 | {.completions = NULL}}; |
17318 | ||
47a306a0 DS |
17319 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
17320 | { | |
17321 | struct bgp *bgp; | |
17322 | struct peer_group *group; | |
17323 | struct listnode *lnbgp, *lnpeer; | |
17324 | ||
17325 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17326 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17327 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
17328 | group->name)); | |
17329 | } | |
17330 | } | |
17331 | ||
17332 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
17333 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17334 | {.completions = NULL} }; | |
17335 | ||
d62a17ae | 17336 | void bgp_vty_init(void) |
17337 | { | |
17338 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 17339 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 17340 | |
17341 | /* Install bgp top node. */ | |
612c2c15 DL |
17342 | install_node(&bgp_node); |
17343 | install_node(&bgp_ipv4_unicast_node); | |
17344 | install_node(&bgp_ipv4_multicast_node); | |
17345 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17346 | install_node(&bgp_ipv6_unicast_node); | |
17347 | install_node(&bgp_ipv6_multicast_node); | |
17348 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17349 | install_node(&bgp_vpnv4_node); | |
17350 | install_node(&bgp_vpnv6_node); | |
17351 | install_node(&bgp_evpn_node); | |
17352 | install_node(&bgp_evpn_vni_node); | |
17353 | install_node(&bgp_flowspecv4_node); | |
17354 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 17355 | |
17356 | /* Install default VTY commands to new nodes. */ | |
17357 | install_default(BGP_NODE); | |
17358 | install_default(BGP_IPV4_NODE); | |
17359 | install_default(BGP_IPV4M_NODE); | |
17360 | install_default(BGP_IPV4L_NODE); | |
17361 | install_default(BGP_IPV6_NODE); | |
17362 | install_default(BGP_IPV6M_NODE); | |
17363 | install_default(BGP_IPV6L_NODE); | |
17364 | install_default(BGP_VPNV4_NODE); | |
17365 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 17366 | install_default(BGP_FLOWSPECV4_NODE); |
17367 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 17368 | install_default(BGP_EVPN_NODE); |
17369 | install_default(BGP_EVPN_VNI_NODE); | |
17370 | ||
8029b216 AK |
17371 | /* "bgp local-mac" hidden commands. */ |
17372 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17373 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17374 | ||
d62a17ae | 17375 | /* bgp route-map delay-timer commands. */ |
17376 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17377 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17378 | ||
d70583f7 D |
17379 | /* global bgp update-delay command */ |
17380 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17381 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17382 | ||
05bd726c | 17383 | /* global bgp graceful-shutdown command */ |
17384 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17385 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17386 | ||
d62a17ae | 17387 | /* Dummy commands (Currently not supported) */ |
17388 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17389 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17390 | ||
17391 | /* "router bgp" commands. */ | |
17392 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17393 | ||
17394 | /* "no router bgp" commands. */ | |
17395 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17396 | ||
17397 | /* "bgp router-id" commands. */ | |
17398 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17399 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17400 | ||
c208c586 S |
17401 | /* "bgp suppress-fib-pending" command */ |
17402 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17403 | ||
d62a17ae | 17404 | /* "bgp cluster-id" commands. */ |
17405 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17406 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17407 | ||
c163f297 DS |
17408 | /* "bgp no-rib" commands. */ |
17409 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17410 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17411 | ||
d62a17ae | 17412 | /* "bgp confederation" commands. */ |
17413 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17414 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17415 | ||
17416 | /* "bgp confederation peers" commands. */ | |
17417 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17418 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17419 | ||
17420 | /* bgp max-med command */ | |
17421 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17422 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17423 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17424 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17425 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17426 | ||
17427 | /* bgp disable-ebgp-connected-nh-check */ | |
17428 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17429 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17430 | ||
17431 | /* bgp update-delay command */ | |
17432 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17433 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 17434 | |
17435 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 17436 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 17437 | |
17438 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17439 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17440 | ||
17441 | /* "maximum-paths" commands. */ | |
17442 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17443 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17444 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17445 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17446 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17447 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17448 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17449 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17450 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17451 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17452 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17453 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17454 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17455 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17456 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17457 | ||
39edabac PG |
17458 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
17459 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17460 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17461 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17462 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 17463 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
17464 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17465 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17466 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17467 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17468 | ||
17469 | /* "timers bgp" commands. */ | |
17470 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17471 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17472 | ||
17473 | /* route-map delay-timer commands - per instance for backwards compat. | |
17474 | */ | |
17475 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17476 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17477 | ||
17478 | /* "bgp client-to-client reflection" commands */ | |
17479 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17480 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17481 | ||
17482 | /* "bgp always-compare-med" commands */ | |
17483 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17484 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17485 | ||
9dac9fc8 DA |
17486 | /* bgp ebgp-requires-policy */ |
17487 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17488 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17489 | ||
fb29348a DA |
17490 | /* bgp reject-as-sets */ |
17491 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
17492 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
17493 | ||
d62a17ae | 17494 | /* "bgp deterministic-med" commands */ |
17495 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
17496 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
17497 | ||
055679e9 | 17498 | /* "bgp graceful-restart" command */ |
36235319 QY |
17499 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
17500 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 17501 | |
17502 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
17503 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
17504 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 17505 | |
17506 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
17507 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
17508 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 17509 | |
17510 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
17511 | install_element(BGP_NODE, | |
17512 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
17513 | install_element(BGP_NODE, | |
17514 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
17515 | ||
17516 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
17517 | install_element(BGP_NODE, | |
17518 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
17519 | install_element(BGP_NODE, | |
17520 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
17521 | ||
d62a17ae | 17522 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
17523 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
17524 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
17525 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 17526 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 17527 | install_element(BGP_NODE, |
17528 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 17529 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
17530 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
17531 | ||
d6e3c15b | 17532 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
17533 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 17534 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
17535 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 17536 | |
7f323236 DW |
17537 | /* "bgp graceful-shutdown" commands */ |
17538 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
17539 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
17540 | ||
d62a17ae | 17541 | /* "bgp fast-external-failover" commands */ |
17542 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
17543 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
17544 | ||
d62a17ae | 17545 | /* "bgp bestpath compare-routerid" commands */ |
17546 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
17547 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
17548 | ||
17549 | /* "bgp bestpath as-path ignore" commands */ | |
17550 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
17551 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
17552 | ||
17553 | /* "bgp bestpath as-path confed" commands */ | |
17554 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
17555 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
17556 | ||
17557 | /* "bgp bestpath as-path multipath-relax" commands */ | |
17558 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
17559 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
17560 | ||
17561 | /* "bgp log-neighbor-changes" commands */ | |
17562 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
17563 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
17564 | ||
17565 | /* "bgp bestpath med" commands */ | |
17566 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
17567 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
17568 | ||
f7e1c681 | 17569 | /* "bgp bestpath bandwidth" commands */ |
17570 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 17571 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 17572 | |
d62a17ae | 17573 | /* "no bgp default ipv4-unicast" commands. */ |
17574 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
17575 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
17576 | ||
17577 | /* "bgp network import-check" commands. */ | |
17578 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
17579 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
17580 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
17581 | ||
17582 | /* "bgp default local-preference" commands. */ | |
17583 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
17584 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
17585 | ||
17586 | /* bgp default show-hostname */ | |
17587 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
17588 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
17589 | ||
aef999a2 DA |
17590 | /* bgp default show-nexthop-hostname */ |
17591 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
17592 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
17593 | ||
d62a17ae | 17594 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
17595 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
17596 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
17597 | ||
17598 | /* bgp ibgp-allow-policy-mods command */ | |
17599 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
17600 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
17601 | ||
17602 | /* "bgp listen limit" commands. */ | |
17603 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
17604 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
17605 | ||
17606 | /* "bgp listen range" commands. */ | |
17607 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
17608 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
17609 | ||
8175f54a | 17610 | /* "bgp default shutdown" command */ |
f26845f9 | 17611 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
17612 | |
17613 | /* "bgp shutdown" commands */ | |
17614 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 17615 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 17616 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 17617 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 17618 | |
d62a17ae | 17619 | /* "neighbor remote-as" commands. */ |
17620 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
17621 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
17622 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
17623 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
17624 | install_element(BGP_NODE, | |
17625 | &neighbor_interface_v6only_config_remote_as_cmd); | |
17626 | install_element(BGP_NODE, &no_neighbor_cmd); | |
17627 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
17628 | ||
17629 | /* "neighbor peer-group" commands. */ | |
17630 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
17631 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
17632 | install_element(BGP_NODE, | |
17633 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
17634 | ||
17635 | /* "neighbor local-as" commands. */ | |
17636 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
17637 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
17638 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
17639 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
17640 | ||
17641 | /* "neighbor solo" commands. */ | |
17642 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
17643 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
17644 | ||
17645 | /* "neighbor password" commands. */ | |
17646 | install_element(BGP_NODE, &neighbor_password_cmd); | |
17647 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
17648 | ||
17649 | /* "neighbor activate" commands. */ | |
17650 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
17651 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
17652 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
17653 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
17654 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
17655 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
17656 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
17657 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
17658 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 17659 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
17660 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 17661 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
17662 | ||
17663 | /* "no neighbor activate" commands. */ | |
17664 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
17665 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
17666 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
17667 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
17668 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
17669 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
17670 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
17671 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
17672 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 17673 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
17674 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 17675 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
17676 | ||
17677 | /* "neighbor peer-group" set commands. */ | |
17678 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
17679 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17680 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17681 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17682 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17683 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17684 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17685 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17686 | install_element(BGP_FLOWSPECV4_NODE, |
17687 | &neighbor_set_peer_group_hidden_cmd); | |
17688 | install_element(BGP_FLOWSPECV6_NODE, | |
17689 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17690 | |
17691 | /* "no neighbor peer-group unset" commands. */ | |
17692 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
17693 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17694 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17695 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17696 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17697 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17698 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17699 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17700 | install_element(BGP_FLOWSPECV4_NODE, |
17701 | &no_neighbor_set_peer_group_hidden_cmd); | |
17702 | install_element(BGP_FLOWSPECV6_NODE, | |
17703 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17704 | |
17705 | /* "neighbor softreconfiguration inbound" commands.*/ | |
17706 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
17707 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
17708 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17709 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17710 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17711 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17712 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17713 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17714 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17715 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17716 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17717 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17718 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17719 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17720 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17721 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17722 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17723 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 17724 | install_element(BGP_FLOWSPECV4_NODE, |
17725 | &neighbor_soft_reconfiguration_cmd); | |
17726 | install_element(BGP_FLOWSPECV4_NODE, | |
17727 | &no_neighbor_soft_reconfiguration_cmd); | |
17728 | install_element(BGP_FLOWSPECV6_NODE, | |
17729 | &neighbor_soft_reconfiguration_cmd); | |
17730 | install_element(BGP_FLOWSPECV6_NODE, | |
17731 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
17732 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
17733 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 17734 | |
17735 | /* "neighbor attribute-unchanged" commands. */ | |
17736 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
17737 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
17738 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
17739 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17740 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
17741 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17742 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
17743 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
17744 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
17745 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17746 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
17747 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17748 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
17749 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
17750 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
17751 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17752 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
17753 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17754 | ||
17755 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
17756 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
17757 | ||
17758 | /* "nexthop-local unchanged" commands */ | |
17759 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
17760 | install_element(BGP_IPV6_NODE, | |
17761 | &no_neighbor_nexthop_local_unchanged_cmd); | |
17762 | ||
17763 | /* "neighbor next-hop-self" commands. */ | |
17764 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
17765 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
17766 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
17767 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
17768 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
17769 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
17770 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
17771 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
17772 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
17773 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
17774 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
17775 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
17776 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
17777 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
17778 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
17779 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
17780 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
17781 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
17782 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
17783 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 17784 | |
17785 | /* "neighbor next-hop-self force" commands. */ | |
17786 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
17787 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
17788 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17789 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17790 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
17791 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17792 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17793 | install_element(BGP_IPV4_NODE, | |
17794 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17795 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
17796 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17797 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17798 | install_element(BGP_IPV4M_NODE, | |
17799 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17800 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
17801 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17802 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17803 | install_element(BGP_IPV4L_NODE, | |
17804 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17805 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
17806 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17807 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17808 | install_element(BGP_IPV6_NODE, | |
17809 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17810 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
17811 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17812 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17813 | install_element(BGP_IPV6M_NODE, | |
17814 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17815 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
17816 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17817 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17818 | install_element(BGP_IPV6L_NODE, | |
17819 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17820 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
17821 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17822 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17823 | install_element(BGP_VPNV4_NODE, | |
17824 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17825 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
17826 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17827 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17828 | install_element(BGP_VPNV6_NODE, | |
17829 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
17830 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
17831 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 17832 | |
17833 | /* "neighbor as-override" commands. */ | |
17834 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
17835 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
17836 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
17837 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
17838 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
17839 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
17840 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
17841 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
17842 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
17843 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
17844 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
17845 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
17846 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
17847 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
17848 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
17849 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
17850 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
17851 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
17852 | ||
17853 | /* "neighbor remove-private-AS" commands. */ | |
17854 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
17855 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
17856 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
17857 | install_element(BGP_NODE, | |
17858 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
17859 | install_element(BGP_NODE, | |
17860 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
17861 | install_element(BGP_NODE, | |
17862 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
17863 | install_element(BGP_NODE, | |
17864 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
17865 | install_element( | |
17866 | BGP_NODE, | |
17867 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
17868 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
17869 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
17870 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
17871 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17872 | install_element(BGP_IPV4_NODE, | |
17873 | &neighbor_remove_private_as_replace_as_cmd); | |
17874 | install_element(BGP_IPV4_NODE, | |
17875 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17876 | install_element(BGP_IPV4_NODE, | |
17877 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17878 | install_element(BGP_IPV4_NODE, | |
17879 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17880 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
17881 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
17882 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
17883 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17884 | install_element(BGP_IPV4M_NODE, | |
17885 | &neighbor_remove_private_as_replace_as_cmd); | |
17886 | install_element(BGP_IPV4M_NODE, | |
17887 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17888 | install_element(BGP_IPV4M_NODE, | |
17889 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17890 | install_element(BGP_IPV4M_NODE, | |
17891 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17892 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
17893 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
17894 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
17895 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17896 | install_element(BGP_IPV4L_NODE, | |
17897 | &neighbor_remove_private_as_replace_as_cmd); | |
17898 | install_element(BGP_IPV4L_NODE, | |
17899 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17900 | install_element(BGP_IPV4L_NODE, | |
17901 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17902 | install_element(BGP_IPV4L_NODE, | |
17903 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17904 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
17905 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17906 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17907 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17908 | install_element(BGP_IPV6_NODE, | |
17909 | &neighbor_remove_private_as_replace_as_cmd); | |
17910 | install_element(BGP_IPV6_NODE, | |
17911 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17912 | install_element(BGP_IPV6_NODE, | |
17913 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17914 | install_element(BGP_IPV6_NODE, | |
17915 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17916 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
17917 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
17918 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
17919 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17920 | install_element(BGP_IPV6M_NODE, | |
17921 | &neighbor_remove_private_as_replace_as_cmd); | |
17922 | install_element(BGP_IPV6M_NODE, | |
17923 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17924 | install_element(BGP_IPV6M_NODE, | |
17925 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17926 | install_element(BGP_IPV6M_NODE, | |
17927 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17928 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
17929 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
17930 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
17931 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17932 | install_element(BGP_IPV6L_NODE, | |
17933 | &neighbor_remove_private_as_replace_as_cmd); | |
17934 | install_element(BGP_IPV6L_NODE, | |
17935 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17936 | install_element(BGP_IPV6L_NODE, | |
17937 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17938 | install_element(BGP_IPV6L_NODE, | |
17939 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17940 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
17941 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
17942 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
17943 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17944 | install_element(BGP_VPNV4_NODE, | |
17945 | &neighbor_remove_private_as_replace_as_cmd); | |
17946 | install_element(BGP_VPNV4_NODE, | |
17947 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17948 | install_element(BGP_VPNV4_NODE, | |
17949 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17950 | install_element(BGP_VPNV4_NODE, | |
17951 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17952 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
17953 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17954 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17955 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17956 | install_element(BGP_VPNV6_NODE, | |
17957 | &neighbor_remove_private_as_replace_as_cmd); | |
17958 | install_element(BGP_VPNV6_NODE, | |
17959 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17960 | install_element(BGP_VPNV6_NODE, | |
17961 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17962 | install_element(BGP_VPNV6_NODE, | |
17963 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17964 | ||
17965 | /* "neighbor send-community" commands.*/ | |
17966 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
17967 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
17968 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
17969 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
17970 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
17971 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
17972 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
17973 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
17974 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
17975 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
17976 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
17977 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
17978 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
17979 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
17980 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
17981 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
17982 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
17983 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
17984 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
17985 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
17986 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
17987 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
17988 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
17989 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
17990 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
17991 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
17992 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
17993 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
17994 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
17995 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
17996 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
17997 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
17998 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
17999 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
18000 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
18001 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
18002 | ||
18003 | /* "neighbor route-reflector" commands.*/ | |
18004 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
18005 | install_element(BGP_NODE, | |
18006 | &no_neighbor_route_reflector_client_hidden_cmd); | |
18007 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
18008 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
18009 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
18010 | install_element(BGP_IPV4M_NODE, | |
18011 | &no_neighbor_route_reflector_client_cmd); | |
18012 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
18013 | install_element(BGP_IPV4L_NODE, | |
18014 | &no_neighbor_route_reflector_client_cmd); | |
18015 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
18016 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
18017 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
18018 | install_element(BGP_IPV6M_NODE, | |
18019 | &no_neighbor_route_reflector_client_cmd); | |
18020 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
18021 | install_element(BGP_IPV6L_NODE, | |
18022 | &no_neighbor_route_reflector_client_cmd); | |
18023 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
18024 | install_element(BGP_VPNV4_NODE, | |
18025 | &no_neighbor_route_reflector_client_cmd); | |
18026 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
18027 | install_element(BGP_VPNV6_NODE, | |
18028 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 18029 | install_element(BGP_FLOWSPECV4_NODE, |
18030 | &neighbor_route_reflector_client_cmd); | |
18031 | install_element(BGP_FLOWSPECV4_NODE, | |
18032 | &no_neighbor_route_reflector_client_cmd); | |
18033 | install_element(BGP_FLOWSPECV6_NODE, | |
18034 | &neighbor_route_reflector_client_cmd); | |
18035 | install_element(BGP_FLOWSPECV6_NODE, | |
18036 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 18037 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
18038 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18039 | ||
18040 | /* "neighbor route-server" commands.*/ | |
18041 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18042 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18043 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18044 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18045 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18046 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18047 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18048 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18049 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18050 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18051 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18052 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18053 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18054 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18055 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18056 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18057 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18058 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
18059 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
18060 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 18061 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
18062 | install_element(BGP_FLOWSPECV4_NODE, | |
18063 | &no_neighbor_route_server_client_cmd); | |
18064 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18065 | install_element(BGP_FLOWSPECV6_NODE, | |
18066 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 18067 | |
18068 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
18069 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18070 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18071 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18072 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18073 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18074 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18075 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18076 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18077 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18078 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18079 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18080 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18081 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18082 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18083 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18084 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18085 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18086 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18087 | ||
18088 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18089 | install_element(BGP_NODE, | |
18090 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18091 | install_element(BGP_NODE, | |
18092 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18093 | install_element(BGP_IPV4_NODE, | |
18094 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18095 | install_element(BGP_IPV4_NODE, | |
18096 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18097 | install_element(BGP_IPV4M_NODE, | |
18098 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18099 | install_element(BGP_IPV4M_NODE, | |
18100 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18101 | install_element(BGP_IPV4L_NODE, | |
18102 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18103 | install_element(BGP_IPV4L_NODE, | |
18104 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18105 | install_element(BGP_IPV6_NODE, | |
18106 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18107 | install_element(BGP_IPV6_NODE, | |
18108 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18109 | install_element(BGP_IPV6M_NODE, | |
18110 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18111 | install_element(BGP_IPV6M_NODE, | |
18112 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18113 | install_element(BGP_IPV6L_NODE, | |
18114 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18115 | install_element(BGP_IPV6L_NODE, | |
18116 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18117 | install_element(BGP_VPNV4_NODE, | |
18118 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18119 | install_element(BGP_VPNV4_NODE, | |
18120 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18121 | install_element(BGP_VPNV6_NODE, | |
18122 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18123 | install_element(BGP_VPNV6_NODE, | |
18124 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18125 | ||
2b31007c RZ |
18126 | /* "neighbor sender-as-path-loop-detection" commands. */ |
18127 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18128 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18129 | ||
d62a17ae | 18130 | /* "neighbor passive" commands. */ |
18131 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18132 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18133 | ||
18134 | ||
18135 | /* "neighbor shutdown" commands. */ | |
18136 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18137 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18138 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18139 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
18140 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
18141 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 18142 | |
18143 | /* "neighbor capability extended-nexthop" commands.*/ | |
18144 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18145 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18146 | ||
18147 | /* "neighbor capability orf prefix-list" commands.*/ | |
18148 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18149 | install_element(BGP_NODE, | |
18150 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18151 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18152 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18153 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18154 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18155 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18156 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18157 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18158 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18159 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18160 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18161 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18162 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18163 | ||
18164 | /* "neighbor capability dynamic" commands.*/ | |
18165 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18166 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18167 | ||
18168 | /* "neighbor dont-capability-negotiate" commands. */ | |
18169 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18170 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18171 | ||
18172 | /* "neighbor ebgp-multihop" commands. */ | |
18173 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18174 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18175 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18176 | ||
18177 | /* "neighbor disable-connected-check" commands. */ | |
18178 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18179 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18180 | ||
47cbc09b PM |
18181 | /* "neighbor enforce-first-as" commands. */ |
18182 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18183 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18184 | ||
d62a17ae | 18185 | /* "neighbor description" commands. */ |
18186 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18187 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 18188 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 18189 | |
18190 | /* "neighbor update-source" commands. "*/ | |
18191 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18192 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18193 | ||
18194 | /* "neighbor default-originate" commands. */ | |
18195 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18196 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18197 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18198 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18199 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18200 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18201 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18202 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18203 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18204 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18205 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18206 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18207 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18208 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18209 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18210 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18211 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18212 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18213 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18214 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18215 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18216 | ||
18217 | /* "neighbor port" commands. */ | |
18218 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18219 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18220 | ||
18221 | /* "neighbor weight" commands. */ | |
18222 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18223 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18224 | ||
18225 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18226 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18227 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18228 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18229 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18230 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18231 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18232 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18233 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18234 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18235 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18236 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18237 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18238 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18239 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18240 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18241 | ||
18242 | /* "neighbor override-capability" commands. */ | |
18243 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18244 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18245 | ||
18246 | /* "neighbor strict-capability-match" commands. */ | |
18247 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18248 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18249 | ||
18250 | /* "neighbor timers" commands. */ | |
18251 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18252 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18253 | ||
18254 | /* "neighbor timers connect" commands. */ | |
18255 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18256 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18257 | ||
18258 | /* "neighbor advertisement-interval" commands. */ | |
18259 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18260 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18261 | ||
18262 | /* "neighbor interface" commands. */ | |
18263 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18264 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18265 | ||
18266 | /* "neighbor distribute" commands. */ | |
18267 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18268 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18269 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18270 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18271 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18272 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18273 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18274 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18275 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18276 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18277 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18278 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18279 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18280 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18281 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18282 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18283 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18284 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18285 | ||
18286 | /* "neighbor prefix-list" commands. */ | |
18287 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
18288 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
18289 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
18290 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
18291 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
18292 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
18293 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
18294 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
18295 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
18296 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
18297 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
18298 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
18299 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
18300 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
18301 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
18302 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
18303 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
18304 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 18305 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
18306 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
18307 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
18308 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 18309 | |
18310 | /* "neighbor filter-list" commands. */ | |
18311 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18312 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18313 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18314 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18315 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18316 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18317 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18318 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18319 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18320 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18321 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18322 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18323 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18324 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18325 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18326 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18327 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18328 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 18329 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
18330 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18331 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18332 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 18333 | |
18334 | /* "neighbor route-map" commands. */ | |
18335 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
18336 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
18337 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
18338 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
18339 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
18340 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
18341 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
18342 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
18343 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
18344 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
18345 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
18346 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
18347 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
18348 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
18349 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
18350 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
18351 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
18352 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 18353 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
18354 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
18355 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
18356 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
18357 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
18358 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 18359 | |
18360 | /* "neighbor unsuppress-map" commands. */ | |
18361 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18362 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18363 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18364 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18365 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18366 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18367 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18368 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18369 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18370 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18371 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18372 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18373 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18374 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18375 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18376 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18377 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18378 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18379 | ||
7f7940e6 MK |
18380 | /* "neighbor advertise-map" commands. */ |
18381 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); | |
7f7940e6 | 18382 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18383 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18384 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18385 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18386 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18387 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18388 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18389 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18390 | |
fde246e8 DA |
18391 | /* neighbor maximum-prefix-out commands. */ |
18392 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18393 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18394 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18395 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18396 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18397 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18398 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18399 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18400 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18401 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18402 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18403 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18404 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18405 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18406 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18407 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18408 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18409 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18410 | ||
d62a17ae | 18411 | /* "neighbor maximum-prefix" commands. */ |
18412 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18413 | install_element(BGP_NODE, | |
18414 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18415 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18416 | install_element(BGP_NODE, | |
18417 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18418 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18419 | install_element(BGP_NODE, | |
18420 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18421 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18422 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18423 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18424 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18425 | install_element(BGP_IPV4_NODE, | |
18426 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18427 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18428 | install_element(BGP_IPV4_NODE, | |
18429 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18430 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18431 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18432 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18433 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18434 | install_element(BGP_IPV4M_NODE, | |
18435 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18436 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18437 | install_element(BGP_IPV4M_NODE, | |
18438 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18439 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18440 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
18441 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18442 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18443 | install_element(BGP_IPV4L_NODE, | |
18444 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18445 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18446 | install_element(BGP_IPV4L_NODE, | |
18447 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18448 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18449 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
18450 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18451 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18452 | install_element(BGP_IPV6_NODE, | |
18453 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18454 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18455 | install_element(BGP_IPV6_NODE, | |
18456 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18457 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18458 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
18459 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18460 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18461 | install_element(BGP_IPV6M_NODE, | |
18462 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18463 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18464 | install_element(BGP_IPV6M_NODE, | |
18465 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18466 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18467 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
18468 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18469 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18470 | install_element(BGP_IPV6L_NODE, | |
18471 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18472 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18473 | install_element(BGP_IPV6L_NODE, | |
18474 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18475 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18476 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
18477 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18478 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18479 | install_element(BGP_VPNV4_NODE, | |
18480 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18481 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18482 | install_element(BGP_VPNV4_NODE, | |
18483 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18484 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18485 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
18486 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18487 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18488 | install_element(BGP_VPNV6_NODE, | |
18489 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18490 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18491 | install_element(BGP_VPNV6_NODE, | |
18492 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18493 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18494 | ||
18495 | /* "neighbor allowas-in" */ | |
18496 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
18497 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
18498 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
18499 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
18500 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
18501 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
18502 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
18503 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
18504 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
18505 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
18506 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
18507 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
18508 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
18509 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
18510 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
18511 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
18512 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
18513 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
18514 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
18515 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
18516 | ||
18517 | /* address-family commands. */ | |
18518 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
18519 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 18520 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 18521 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
18522 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 18523 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 18524 | |
d62a17ae | 18525 | install_element(BGP_NODE, &address_family_evpn_cmd); |
18526 | ||
18527 | /* "exit-address-family" command. */ | |
18528 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
18529 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
18530 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
18531 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
18532 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
18533 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
18534 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
18535 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 18536 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
18537 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 18538 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
18539 | ||
18540 | /* "clear ip bgp commands" */ | |
18541 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
18542 | ||
18543 | /* clear ip bgp prefix */ | |
18544 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
18545 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
18546 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
18547 | ||
18548 | /* "show [ip] bgp summary" commands. */ | |
18549 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 18550 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 18551 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 18552 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 18553 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
18554 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 18555 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
18556 | ||
18557 | /* "show [ip] bgp neighbors" commands. */ | |
18558 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
18559 | ||
36235319 | 18560 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 18561 | |
d62a17ae | 18562 | /* "show [ip] bgp peer-group" commands. */ |
18563 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
18564 | ||
18565 | /* "show [ip] bgp paths" commands. */ | |
18566 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
18567 | ||
18568 | /* "show [ip] bgp community" commands. */ | |
18569 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
18570 | ||
18571 | /* "show ip bgp large-community" commands. */ | |
18572 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
18573 | /* "show [ip] bgp attribute-info" commands. */ | |
18574 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 18575 | /* "show [ip] bgp route-leak" command */ |
18576 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 18577 | |
18578 | /* "redistribute" commands. */ | |
18579 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
18580 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
18581 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
18582 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
18583 | install_element(BGP_NODE, | |
18584 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
18585 | install_element(BGP_NODE, | |
18586 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
18587 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18588 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18589 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
18590 | install_element(BGP_NODE, | |
18591 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
18592 | install_element(BGP_NODE, | |
18593 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
18594 | install_element(BGP_NODE, | |
18595 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
18596 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
18597 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
18598 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
18599 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
18600 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
18601 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
18602 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
18603 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
18604 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
18605 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
18606 | install_element(BGP_IPV4_NODE, | |
18607 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
18608 | install_element(BGP_IPV4_NODE, | |
18609 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
18610 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
18611 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
18612 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
18613 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
18614 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
18615 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
18616 | ||
b9c7bc5a PZ |
18617 | /* import|export vpn [route-map WORD] */ |
18618 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
18619 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 18620 | |
12a844a5 DS |
18621 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
18622 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
18623 | ||
d62a17ae | 18624 | /* ttl_security commands */ |
18625 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
18626 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
18627 | ||
18628 | /* "show [ip] bgp memory" commands. */ | |
18629 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
18630 | ||
acf71666 MK |
18631 | /* "show bgp martian next-hop" */ |
18632 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
18633 | ||
48ecf8f5 DS |
18634 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
18635 | ||
d62a17ae | 18636 | /* "show [ip] bgp views" commands. */ |
18637 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
18638 | ||
18639 | /* "show [ip] bgp vrfs" commands. */ | |
18640 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
18641 | ||
18642 | /* Community-list. */ | |
18643 | community_list_vty(); | |
ddb5b488 PZ |
18644 | |
18645 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
18646 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
18647 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
18648 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
18649 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
18650 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
18651 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
18652 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
18653 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
18654 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
18655 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18656 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
18657 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 18658 | |
301ad80a PG |
18659 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
18660 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
18661 | ||
b9c7bc5a PZ |
18662 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
18663 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
18664 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
18665 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
18666 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
18667 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
18668 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
18669 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18670 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
18671 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 18672 | } |
6b0655a2 | 18673 | |
718e3744 | 18674 | #include "memory.h" |
18675 | #include "bgp_regex.h" | |
18676 | #include "bgp_clist.h" | |
18677 | #include "bgp_ecommunity.h" | |
18678 | ||
18679 | /* VTY functions. */ | |
18680 | ||
18681 | /* Direction value to string conversion. */ | |
d62a17ae | 18682 | static const char *community_direct_str(int direct) |
18683 | { | |
18684 | switch (direct) { | |
18685 | case COMMUNITY_DENY: | |
18686 | return "deny"; | |
18687 | case COMMUNITY_PERMIT: | |
18688 | return "permit"; | |
18689 | default: | |
18690 | return "unknown"; | |
18691 | } | |
718e3744 | 18692 | } |
18693 | ||
18694 | /* Display error string. */ | |
d62a17ae | 18695 | static void community_list_perror(struct vty *vty, int ret) |
18696 | { | |
18697 | switch (ret) { | |
18698 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
18699 | vty_out(vty, "%% Can't find community-list\n"); | |
18700 | break; | |
18701 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
18702 | vty_out(vty, "%% Malformed community-list value\n"); | |
18703 | break; | |
18704 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
18705 | vty_out(vty, | |
18706 | "%% Community name conflict, previously defined as standard community\n"); | |
18707 | break; | |
18708 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
18709 | vty_out(vty, | |
18710 | "%% Community name conflict, previously defined as expanded community\n"); | |
18711 | break; | |
18712 | } | |
718e3744 | 18713 | } |
18714 | ||
5bf15956 DW |
18715 | /* "community-list" keyword help string. */ |
18716 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
18717 | ||
7336e101 SP |
18718 | /*community-list standard */ |
18719 | DEFUN (community_list_standard, | |
18720 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 18721 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 18722 | BGP_STR |
718e3744 | 18723 | COMMUNITY_LIST_STR |
18724 | "Community list number (standard)\n" | |
5bf15956 | 18725 | "Add an standard community-list entry\n" |
718e3744 | 18726 | "Community list name\n" |
2f8cc0e5 DA |
18727 | "Sequence number of an entry\n" |
18728 | "Sequence number\n" | |
718e3744 | 18729 | "Specify community to reject\n" |
18730 | "Specify community to accept\n" | |
18731 | COMMUNITY_VAL_STR) | |
18732 | { | |
d62a17ae | 18733 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18734 | char *seq = NULL; |
d62a17ae | 18735 | int direct = 0; |
18736 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 18737 | int idx = 0; |
7336e101 | 18738 | |
2f8cc0e5 DA |
18739 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18740 | if (idx) | |
18741 | seq = argv[idx]->arg; | |
18742 | ||
18743 | idx = 0; | |
d62a17ae | 18744 | argv_find(argv, argc, "(1-99)", &idx); |
18745 | argv_find(argv, argc, "WORD", &idx); | |
18746 | cl_name_or_number = argv[idx]->arg; | |
18747 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
18748 | : COMMUNITY_DENY; | |
18749 | argv_find(argv, argc, "AA:NN", &idx); | |
18750 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18751 | |
2f8cc0e5 DA |
18752 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
18753 | direct, style); | |
42f914d4 | 18754 | |
d62a17ae | 18755 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18756 | |
d62a17ae | 18757 | if (ret < 0) { |
18758 | /* Display error string. */ | |
18759 | community_list_perror(vty, ret); | |
18760 | return CMD_WARNING_CONFIG_FAILED; | |
18761 | } | |
42f914d4 | 18762 | |
d62a17ae | 18763 | return CMD_SUCCESS; |
718e3744 | 18764 | } |
18765 | ||
7336e101 SP |
18766 | DEFUN (no_community_list_standard_all, |
18767 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 18768 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18769 | NO_STR |
18770 | BGP_STR | |
18771 | COMMUNITY_LIST_STR | |
18772 | "Community list number (standard)\n" | |
18773 | "Add an standard community-list entry\n" | |
18774 | "Community list name\n" | |
2f8cc0e5 DA |
18775 | "Sequence number of an entry\n" |
18776 | "Sequence number\n" | |
7336e101 SP |
18777 | "Specify community to reject\n" |
18778 | "Specify community to accept\n" | |
18779 | COMMUNITY_VAL_STR) | |
718e3744 | 18780 | { |
d62a17ae | 18781 | char *cl_name_or_number = NULL; |
174b5cb9 | 18782 | char *str = NULL; |
d62a17ae | 18783 | int direct = 0; |
18784 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 18785 | char *seq = NULL; |
d62a17ae | 18786 | int idx = 0; |
7336e101 | 18787 | |
2f8cc0e5 DA |
18788 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18789 | if (idx) | |
18790 | seq = argv[idx]->arg; | |
18791 | ||
18792 | idx = 0; | |
174b5cb9 DA |
18793 | argv_find(argv, argc, "permit", &idx); |
18794 | argv_find(argv, argc, "deny", &idx); | |
18795 | ||
18796 | if (idx) { | |
18797 | direct = argv_find(argv, argc, "permit", &idx) | |
18798 | ? COMMUNITY_PERMIT | |
18799 | : COMMUNITY_DENY; | |
18800 | ||
18801 | idx = 0; | |
18802 | argv_find(argv, argc, "AA:NN", &idx); | |
18803 | str = argv_concat(argv, argc, idx); | |
18804 | } | |
18805 | ||
18806 | idx = 0; | |
d62a17ae | 18807 | argv_find(argv, argc, "(1-99)", &idx); |
18808 | argv_find(argv, argc, "WORD", &idx); | |
18809 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 18810 | |
2f8cc0e5 | 18811 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 18812 | direct, style); |
42f914d4 | 18813 | |
d62a17ae | 18814 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 18815 | |
d62a17ae | 18816 | if (ret < 0) { |
18817 | community_list_perror(vty, ret); | |
18818 | return CMD_WARNING_CONFIG_FAILED; | |
18819 | } | |
42f914d4 | 18820 | |
d62a17ae | 18821 | return CMD_SUCCESS; |
718e3744 | 18822 | } |
7336e101 | 18823 | |
174b5cb9 DA |
18824 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
18825 | "no bgp community-list <(1-99)|standard WORD>", | |
18826 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
18827 | "Community list number (standard)\n" | |
18828 | "Add an standard community-list entry\n" | |
18829 | "Community list name\n") | |
18830 | ||
7336e101 SP |
18831 | /*community-list expanded */ |
18832 | DEFUN (community_list_expanded_all, | |
18833 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 18834 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18835 | BGP_STR |
18836 | COMMUNITY_LIST_STR | |
718e3744 | 18837 | "Community list number (expanded)\n" |
5bf15956 | 18838 | "Add an expanded community-list entry\n" |
718e3744 | 18839 | "Community list name\n" |
2f8cc0e5 DA |
18840 | "Sequence number of an entry\n" |
18841 | "Sequence number\n" | |
718e3744 | 18842 | "Specify community to reject\n" |
18843 | "Specify community to accept\n" | |
18844 | COMMUNITY_VAL_STR) | |
18845 | { | |
d62a17ae | 18846 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18847 | char *seq = NULL; |
d62a17ae | 18848 | int direct = 0; |
18849 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 18850 | int idx = 0; |
7b9a4750 | 18851 | |
2f8cc0e5 DA |
18852 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18853 | if (idx) | |
18854 | seq = argv[idx]->arg; | |
18855 | ||
18856 | idx = 0; | |
18857 | ||
d62a17ae | 18858 | argv_find(argv, argc, "(100-500)", &idx); |
18859 | argv_find(argv, argc, "WORD", &idx); | |
18860 | cl_name_or_number = argv[idx]->arg; | |
18861 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
18862 | : COMMUNITY_DENY; | |
18863 | argv_find(argv, argc, "AA:NN", &idx); | |
18864 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18865 | |
2f8cc0e5 DA |
18866 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
18867 | direct, style); | |
42f914d4 | 18868 | |
d62a17ae | 18869 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18870 | |
d62a17ae | 18871 | if (ret < 0) { |
18872 | /* Display error string. */ | |
18873 | community_list_perror(vty, ret); | |
18874 | return CMD_WARNING_CONFIG_FAILED; | |
18875 | } | |
42f914d4 | 18876 | |
d62a17ae | 18877 | return CMD_SUCCESS; |
718e3744 | 18878 | } |
18879 | ||
7336e101 SP |
18880 | DEFUN (no_community_list_expanded_all, |
18881 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 18882 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18883 | NO_STR |
18884 | BGP_STR | |
18885 | COMMUNITY_LIST_STR | |
18886 | "Community list number (expanded)\n" | |
18887 | "Add an expanded community-list entry\n" | |
18888 | "Community list name\n" | |
2f8cc0e5 DA |
18889 | "Sequence number of an entry\n" |
18890 | "Sequence number\n" | |
7336e101 SP |
18891 | "Specify community to reject\n" |
18892 | "Specify community to accept\n" | |
18893 | COMMUNITY_VAL_STR) | |
718e3744 | 18894 | { |
d62a17ae | 18895 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18896 | char *seq = NULL; |
174b5cb9 | 18897 | char *str = NULL; |
d62a17ae | 18898 | int direct = 0; |
18899 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 18900 | int idx = 0; |
174b5cb9 | 18901 | |
2f8cc0e5 DA |
18902 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18903 | if (idx) | |
18904 | seq = argv[idx]->arg; | |
18905 | ||
18906 | idx = 0; | |
174b5cb9 DA |
18907 | argv_find(argv, argc, "permit", &idx); |
18908 | argv_find(argv, argc, "deny", &idx); | |
18909 | ||
18910 | if (idx) { | |
18911 | direct = argv_find(argv, argc, "permit", &idx) | |
18912 | ? COMMUNITY_PERMIT | |
18913 | : COMMUNITY_DENY; | |
18914 | ||
18915 | idx = 0; | |
18916 | argv_find(argv, argc, "AA:NN", &idx); | |
18917 | str = argv_concat(argv, argc, idx); | |
7336e101 | 18918 | } |
174b5cb9 DA |
18919 | |
18920 | idx = 0; | |
d62a17ae | 18921 | argv_find(argv, argc, "(100-500)", &idx); |
18922 | argv_find(argv, argc, "WORD", &idx); | |
18923 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 18924 | |
2f8cc0e5 | 18925 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 18926 | direct, style); |
42f914d4 | 18927 | |
d62a17ae | 18928 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 18929 | |
d62a17ae | 18930 | if (ret < 0) { |
18931 | community_list_perror(vty, ret); | |
18932 | return CMD_WARNING_CONFIG_FAILED; | |
18933 | } | |
42f914d4 | 18934 | |
d62a17ae | 18935 | return CMD_SUCCESS; |
718e3744 | 18936 | } |
18937 | ||
36d4bb44 EB |
18938 | ALIAS(no_community_list_expanded_all, |
18939 | no_bgp_community_list_expanded_all_list_cmd, | |
174b5cb9 | 18940 | "no bgp community-list <(100-500)|expanded WORD>", |
36d4bb44 | 18941 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
18942 | "Community list number (expanded)\n" |
18943 | "Add an expanded community-list entry\n" | |
18944 | "Community list name\n") | |
18945 | ||
8d9b8ed9 PM |
18946 | /* Return configuration string of community-list entry. */ |
18947 | static const char *community_list_config_str(struct community_entry *entry) | |
18948 | { | |
18949 | const char *str; | |
18950 | ||
18951 | if (entry->any) | |
18952 | str = ""; | |
18953 | else { | |
18954 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
18955 | str = community_str(entry->u.com, false); | |
18956 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
18957 | str = lcommunity_str(entry->u.lcom, false); | |
18958 | else | |
18959 | str = entry->config; | |
18960 | } | |
18961 | return str; | |
18962 | } | |
18963 | ||
d62a17ae | 18964 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 18965 | { |
d62a17ae | 18966 | struct community_entry *entry; |
718e3744 | 18967 | |
d62a17ae | 18968 | for (entry = list->head; entry; entry = entry->next) { |
18969 | if (entry == list->head) { | |
18970 | if (all_digit(list->name)) | |
18971 | vty_out(vty, "Community %s list %s\n", | |
18972 | entry->style == COMMUNITY_LIST_STANDARD | |
18973 | ? "standard" | |
18974 | : "(expanded) access", | |
18975 | list->name); | |
18976 | else | |
18977 | vty_out(vty, "Named Community %s list %s\n", | |
18978 | entry->style == COMMUNITY_LIST_STANDARD | |
18979 | ? "standard" | |
18980 | : "expanded", | |
18981 | list->name); | |
18982 | } | |
18983 | if (entry->any) | |
18984 | vty_out(vty, " %s\n", | |
18985 | community_direct_str(entry->direct)); | |
18986 | else | |
18987 | vty_out(vty, " %s %s\n", | |
18988 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18989 | community_list_config_str(entry)); |
d62a17ae | 18990 | } |
718e3744 | 18991 | } |
18992 | ||
7336e101 SP |
18993 | DEFUN (show_community_list, |
18994 | show_bgp_community_list_cmd, | |
18995 | "show bgp community-list", | |
718e3744 | 18996 | SHOW_STR |
7336e101 | 18997 | BGP_STR |
718e3744 | 18998 | "List community-list\n") |
18999 | { | |
d62a17ae | 19000 | struct community_list *list; |
19001 | struct community_list_master *cm; | |
718e3744 | 19002 | |
d62a17ae | 19003 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
19004 | if (!cm) | |
19005 | return CMD_SUCCESS; | |
718e3744 | 19006 | |
d62a17ae | 19007 | for (list = cm->num.head; list; list = list->next) |
19008 | community_list_show(vty, list); | |
718e3744 | 19009 | |
d62a17ae | 19010 | for (list = cm->str.head; list; list = list->next) |
19011 | community_list_show(vty, list); | |
718e3744 | 19012 | |
d62a17ae | 19013 | return CMD_SUCCESS; |
718e3744 | 19014 | } |
19015 | ||
7336e101 SP |
19016 | DEFUN (show_community_list_arg, |
19017 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 19018 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
19019 | SHOW_STR |
19020 | BGP_STR | |
718e3744 | 19021 | "List community-list\n" |
19022 | "Community-list number\n" | |
960b69b9 | 19023 | "Community-list name\n" |
19024 | "Detailed information on community-list\n") | |
718e3744 | 19025 | { |
d62a17ae | 19026 | int idx_comm_list = 3; |
19027 | struct community_list *list; | |
718e3744 | 19028 | |
e237b0d2 | 19029 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19030 | COMMUNITY_LIST_MASTER); |
19031 | if (!list) { | |
19032 | vty_out(vty, "%% Can't find community-list\n"); | |
19033 | return CMD_WARNING; | |
19034 | } | |
718e3744 | 19035 | |
d62a17ae | 19036 | community_list_show(vty, list); |
718e3744 | 19037 | |
d62a17ae | 19038 | return CMD_SUCCESS; |
718e3744 | 19039 | } |
6b0655a2 | 19040 | |
57d187bc JS |
19041 | /* |
19042 | * Large Community code. | |
19043 | */ | |
d62a17ae | 19044 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
19045 | struct cmd_token **argv, int style, | |
19046 | int reject_all_digit_name) | |
19047 | { | |
19048 | int ret; | |
19049 | int direct; | |
19050 | char *str; | |
19051 | int idx = 0; | |
19052 | char *cl_name; | |
2f8cc0e5 DA |
19053 | char *seq = NULL; |
19054 | ||
947073e3 | 19055 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 19056 | seq = argv[idx]->arg; |
d62a17ae | 19057 | |
2f8cc0e5 | 19058 | idx = 0; |
d62a17ae | 19059 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19060 | : COMMUNITY_DENY; | |
19061 | ||
19062 | /* All digit name check. */ | |
19063 | idx = 0; | |
19064 | argv_find(argv, argc, "WORD", &idx); | |
19065 | argv_find(argv, argc, "(1-99)", &idx); | |
19066 | argv_find(argv, argc, "(100-500)", &idx); | |
19067 | cl_name = argv[idx]->arg; | |
19068 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19069 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19070 | return CMD_WARNING_CONFIG_FAILED; | |
19071 | } | |
19072 | ||
19073 | idx = 0; | |
19074 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19075 | argv_find(argv, argc, "LINE", &idx); | |
19076 | /* Concat community string argument. */ | |
19077 | if (idx) | |
19078 | str = argv_concat(argv, argc, idx); | |
19079 | else | |
19080 | str = NULL; | |
19081 | ||
2f8cc0e5 | 19082 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 19083 | |
19084 | /* Free temporary community list string allocated by | |
19085 | argv_concat(). */ | |
0a22ddfb | 19086 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19087 | |
19088 | if (ret < 0) { | |
19089 | community_list_perror(vty, ret); | |
19090 | return CMD_WARNING_CONFIG_FAILED; | |
19091 | } | |
19092 | return CMD_SUCCESS; | |
19093 | } | |
19094 | ||
19095 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19096 | struct cmd_token **argv, int style) | |
19097 | { | |
19098 | int ret; | |
19099 | int direct = 0; | |
19100 | char *str = NULL; | |
19101 | int idx = 0; | |
2f8cc0e5 | 19102 | char *seq = NULL; |
d62a17ae | 19103 | |
947073e3 | 19104 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 19105 | seq = argv[idx]->arg; |
d62a17ae | 19106 | |
2f8cc0e5 | 19107 | idx = 0; |
d62a17ae | 19108 | argv_find(argv, argc, "permit", &idx); |
19109 | argv_find(argv, argc, "deny", &idx); | |
19110 | ||
19111 | if (idx) { | |
19112 | /* Check the list direct. */ | |
19113 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19114 | direct = COMMUNITY_PERMIT; | |
19115 | else | |
19116 | direct = COMMUNITY_DENY; | |
19117 | ||
19118 | idx = 0; | |
19119 | argv_find(argv, argc, "LINE", &idx); | |
19120 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19121 | /* Concat community string argument. */ | |
19122 | str = argv_concat(argv, argc, idx); | |
19123 | } | |
19124 | ||
19125 | idx = 0; | |
19126 | argv_find(argv, argc, "(1-99)", &idx); | |
19127 | argv_find(argv, argc, "(100-500)", &idx); | |
19128 | argv_find(argv, argc, "WORD", &idx); | |
19129 | ||
19130 | /* Unset community list. */ | |
2f8cc0e5 | 19131 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 19132 | style); |
19133 | ||
19134 | /* Free temporary community list string allocated by | |
19135 | argv_concat(). */ | |
0a22ddfb | 19136 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19137 | |
19138 | if (ret < 0) { | |
19139 | community_list_perror(vty, ret); | |
19140 | return CMD_WARNING_CONFIG_FAILED; | |
19141 | } | |
19142 | ||
19143 | return CMD_SUCCESS; | |
57d187bc JS |
19144 | } |
19145 | ||
19146 | /* "large-community-list" keyword help string. */ | |
19147 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19148 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19149 | ||
7336e101 SP |
19150 | DEFUN (lcommunity_list_standard, |
19151 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 19152 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19153 | BGP_STR |
19154 | LCOMMUNITY_LIST_STR | |
19155 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19156 | "Sequence number of an entry\n" |
19157 | "Sequence number\n" | |
7336e101 SP |
19158 | "Specify large community to reject\n" |
19159 | "Specify large community to accept\n" | |
19160 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19161 | { |
d62a17ae | 19162 | return lcommunity_list_set_vty(vty, argc, argv, |
19163 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
19164 | } |
19165 | ||
7336e101 SP |
19166 | DEFUN (lcommunity_list_expanded, |
19167 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 19168 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19169 | BGP_STR |
19170 | LCOMMUNITY_LIST_STR | |
19171 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19172 | "Sequence number of an entry\n" |
19173 | "Sequence number\n" | |
7336e101 SP |
19174 | "Specify large community to reject\n" |
19175 | "Specify large community to accept\n" | |
19176 | "An ordered list as a regular-expression\n") | |
57d187bc | 19177 | { |
d62a17ae | 19178 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19179 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
19180 | } |
19181 | ||
7336e101 SP |
19182 | DEFUN (lcommunity_list_name_standard, |
19183 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 19184 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19185 | BGP_STR |
19186 | LCOMMUNITY_LIST_STR | |
19187 | "Specify standard large-community-list\n" | |
19188 | "Large Community list name\n" | |
2f8cc0e5 DA |
19189 | "Sequence number of an entry\n" |
19190 | "Sequence number\n" | |
7336e101 SP |
19191 | "Specify large community to reject\n" |
19192 | "Specify large community to accept\n" | |
19193 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19194 | { |
d62a17ae | 19195 | return lcommunity_list_set_vty(vty, argc, argv, |
19196 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
19197 | } |
19198 | ||
7336e101 SP |
19199 | DEFUN (lcommunity_list_name_expanded, |
19200 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 19201 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19202 | BGP_STR |
19203 | LCOMMUNITY_LIST_STR | |
19204 | "Specify expanded large-community-list\n" | |
19205 | "Large Community list name\n" | |
2f8cc0e5 DA |
19206 | "Sequence number of an entry\n" |
19207 | "Sequence number\n" | |
7336e101 SP |
19208 | "Specify large community to reject\n" |
19209 | "Specify large community to accept\n" | |
19210 | "An ordered list as a regular-expression\n") | |
57d187bc | 19211 | { |
d62a17ae | 19212 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19213 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
19214 | } |
19215 | ||
4378f57c DA |
19216 | DEFUN (no_lcommunity_list_all, |
19217 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
19218 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
19219 | NO_STR | |
19220 | BGP_STR | |
19221 | LCOMMUNITY_LIST_STR | |
19222 | "Large Community list number (standard)\n" | |
19223 | "Large Community list number (expanded)\n" | |
19224 | "Large Community list name\n") | |
57d187bc | 19225 | { |
7336e101 SP |
19226 | return lcommunity_list_unset_vty(vty, argc, argv, |
19227 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
19228 | } |
19229 | ||
4378f57c DA |
19230 | DEFUN (no_lcommunity_list_name_standard_all, |
19231 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
19232 | "no bgp large-community-list standard WORD", | |
19233 | NO_STR | |
19234 | BGP_STR | |
19235 | LCOMMUNITY_LIST_STR | |
19236 | "Specify standard large-community-list\n" | |
19237 | "Large Community list name\n") | |
19238 | { | |
19239 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19240 | LARGE_COMMUNITY_LIST_STANDARD); | |
19241 | } | |
19242 | ||
7336e101 SP |
19243 | DEFUN (no_lcommunity_list_name_expanded_all, |
19244 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
19245 | "no bgp large-community-list expanded WORD", | |
19246 | NO_STR | |
19247 | BGP_STR | |
19248 | LCOMMUNITY_LIST_STR | |
19249 | "Specify expanded large-community-list\n" | |
19250 | "Large Community list name\n") | |
57d187bc | 19251 | { |
d62a17ae | 19252 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19253 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19254 | } |
19255 | ||
7336e101 SP |
19256 | DEFUN (no_lcommunity_list_standard, |
19257 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 19258 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19259 | NO_STR |
19260 | BGP_STR | |
19261 | LCOMMUNITY_LIST_STR | |
19262 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19263 | "Sequence number of an entry\n" |
19264 | "Sequence number\n" | |
7336e101 SP |
19265 | "Specify large community to reject\n" |
19266 | "Specify large community to accept\n" | |
19267 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19268 | { |
d62a17ae | 19269 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19270 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19271 | } |
19272 | ||
7336e101 SP |
19273 | DEFUN (no_lcommunity_list_expanded, |
19274 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 19275 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19276 | NO_STR |
19277 | BGP_STR | |
19278 | LCOMMUNITY_LIST_STR | |
19279 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19280 | "Sequence number of an entry\n" |
19281 | "Sequence number\n" | |
7336e101 SP |
19282 | "Specify large community to reject\n" |
19283 | "Specify large community to accept\n" | |
19284 | "An ordered list as a regular-expression\n") | |
57d187bc | 19285 | { |
d62a17ae | 19286 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19287 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19288 | } |
19289 | ||
7336e101 SP |
19290 | DEFUN (no_lcommunity_list_name_standard, |
19291 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 19292 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19293 | NO_STR |
19294 | BGP_STR | |
19295 | LCOMMUNITY_LIST_STR | |
19296 | "Specify standard large-community-list\n" | |
19297 | "Large Community list name\n" | |
2f8cc0e5 DA |
19298 | "Sequence number of an entry\n" |
19299 | "Sequence number\n" | |
7336e101 SP |
19300 | "Specify large community to reject\n" |
19301 | "Specify large community to accept\n" | |
19302 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19303 | { |
d62a17ae | 19304 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19305 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19306 | } |
19307 | ||
7336e101 SP |
19308 | DEFUN (no_lcommunity_list_name_expanded, |
19309 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 19310 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19311 | NO_STR |
19312 | BGP_STR | |
19313 | LCOMMUNITY_LIST_STR | |
19314 | "Specify expanded large-community-list\n" | |
19315 | "Large community list name\n" | |
2f8cc0e5 DA |
19316 | "Sequence number of an entry\n" |
19317 | "Sequence number\n" | |
7336e101 SP |
19318 | "Specify large community to reject\n" |
19319 | "Specify large community to accept\n" | |
19320 | "An ordered list as a regular-expression\n") | |
57d187bc | 19321 | { |
d62a17ae | 19322 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19323 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19324 | } |
19325 | ||
d62a17ae | 19326 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
19327 | { | |
19328 | struct community_entry *entry; | |
19329 | ||
19330 | for (entry = list->head; entry; entry = entry->next) { | |
19331 | if (entry == list->head) { | |
19332 | if (all_digit(list->name)) | |
19333 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 19334 | entry->style == |
19335 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19336 | ? "standard" |
19337 | : "(expanded) access", | |
19338 | list->name); | |
19339 | else | |
19340 | vty_out(vty, | |
19341 | "Named large community %s list %s\n", | |
169b72c8 | 19342 | entry->style == |
19343 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19344 | ? "standard" |
19345 | : "expanded", | |
19346 | list->name); | |
19347 | } | |
19348 | if (entry->any) | |
19349 | vty_out(vty, " %s\n", | |
19350 | community_direct_str(entry->direct)); | |
19351 | else | |
19352 | vty_out(vty, " %s %s\n", | |
19353 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19354 | community_list_config_str(entry)); |
d62a17ae | 19355 | } |
57d187bc JS |
19356 | } |
19357 | ||
7336e101 SP |
19358 | DEFUN (show_lcommunity_list, |
19359 | show_bgp_lcommunity_list_cmd, | |
19360 | "show bgp large-community-list", | |
57d187bc | 19361 | SHOW_STR |
7336e101 | 19362 | BGP_STR |
57d187bc JS |
19363 | "List large-community list\n") |
19364 | { | |
d62a17ae | 19365 | struct community_list *list; |
19366 | struct community_list_master *cm; | |
57d187bc | 19367 | |
d62a17ae | 19368 | cm = community_list_master_lookup(bgp_clist, |
19369 | LARGE_COMMUNITY_LIST_MASTER); | |
19370 | if (!cm) | |
19371 | return CMD_SUCCESS; | |
57d187bc | 19372 | |
d62a17ae | 19373 | for (list = cm->num.head; list; list = list->next) |
19374 | lcommunity_list_show(vty, list); | |
57d187bc | 19375 | |
d62a17ae | 19376 | for (list = cm->str.head; list; list = list->next) |
19377 | lcommunity_list_show(vty, list); | |
57d187bc | 19378 | |
d62a17ae | 19379 | return CMD_SUCCESS; |
57d187bc JS |
19380 | } |
19381 | ||
7336e101 SP |
19382 | DEFUN (show_lcommunity_list_arg, |
19383 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 19384 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
19385 | SHOW_STR |
19386 | BGP_STR | |
57d187bc | 19387 | "List large-community list\n" |
960b69b9 | 19388 | "Large-community-list number\n" |
19389 | "Large-community-list name\n" | |
19390 | "Detailed information on large-community-list\n") | |
57d187bc | 19391 | { |
d62a17ae | 19392 | struct community_list *list; |
57d187bc | 19393 | |
e237b0d2 | 19394 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 19395 | LARGE_COMMUNITY_LIST_MASTER); |
19396 | if (!list) { | |
960b69b9 | 19397 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 19398 | return CMD_WARNING; |
19399 | } | |
57d187bc | 19400 | |
d62a17ae | 19401 | lcommunity_list_show(vty, list); |
57d187bc | 19402 | |
d62a17ae | 19403 | return CMD_SUCCESS; |
57d187bc JS |
19404 | } |
19405 | ||
718e3744 | 19406 | /* "extcommunity-list" keyword help string. */ |
19407 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19408 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19409 | ||
7336e101 SP |
19410 | DEFUN (extcommunity_list_standard, |
19411 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 19412 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19413 | BGP_STR |
718e3744 | 19414 | EXTCOMMUNITY_LIST_STR |
19415 | "Extended Community list number (standard)\n" | |
718e3744 | 19416 | "Specify standard extcommunity-list\n" |
5bf15956 | 19417 | "Community list name\n" |
2f8cc0e5 DA |
19418 | "Sequence number of an entry\n" |
19419 | "Sequence number\n" | |
718e3744 | 19420 | "Specify community to reject\n" |
19421 | "Specify community to accept\n" | |
19422 | EXTCOMMUNITY_VAL_STR) | |
19423 | { | |
d62a17ae | 19424 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19425 | int direct = 0; | |
19426 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19427 | char *seq = NULL; |
42f914d4 | 19428 | |
d62a17ae | 19429 | int idx = 0; |
7b9a4750 | 19430 | |
d62a17ae | 19431 | argv_find(argv, argc, "(1-99)", &idx); |
19432 | argv_find(argv, argc, "WORD", &idx); | |
19433 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19434 | |
409148f6 | 19435 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19436 | seq = argv[idx]->arg; |
19437 | ||
d62a17ae | 19438 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19439 | : COMMUNITY_DENY; | |
19440 | argv_find(argv, argc, "AA:NN", &idx); | |
19441 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19442 | |
2f8cc0e5 | 19443 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19444 | direct, style); |
42f914d4 | 19445 | |
d62a17ae | 19446 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19447 | |
d62a17ae | 19448 | if (ret < 0) { |
19449 | community_list_perror(vty, ret); | |
19450 | return CMD_WARNING_CONFIG_FAILED; | |
19451 | } | |
42f914d4 | 19452 | |
d62a17ae | 19453 | return CMD_SUCCESS; |
718e3744 | 19454 | } |
19455 | ||
7336e101 SP |
19456 | DEFUN (extcommunity_list_name_expanded, |
19457 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 19458 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19459 | BGP_STR |
19460 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 19461 | "Extended Community list number (expanded)\n" |
718e3744 | 19462 | "Specify expanded extcommunity-list\n" |
19463 | "Extended Community list name\n" | |
2f8cc0e5 DA |
19464 | "Sequence number of an entry\n" |
19465 | "Sequence number\n" | |
718e3744 | 19466 | "Specify community to reject\n" |
19467 | "Specify community to accept\n" | |
19468 | "An ordered list as a regular-expression\n") | |
19469 | { | |
d62a17ae | 19470 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19471 | int direct = 0; | |
19472 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19473 | char *seq = NULL; |
d62a17ae | 19474 | int idx = 0; |
7336e101 | 19475 | |
d62a17ae | 19476 | argv_find(argv, argc, "(100-500)", &idx); |
19477 | argv_find(argv, argc, "WORD", &idx); | |
19478 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19479 | |
409148f6 | 19480 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19481 | seq = argv[idx]->arg; |
19482 | ||
d62a17ae | 19483 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19484 | : COMMUNITY_DENY; | |
19485 | argv_find(argv, argc, "LINE", &idx); | |
19486 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19487 | |
2f8cc0e5 | 19488 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19489 | direct, style); |
42f914d4 | 19490 | |
d62a17ae | 19491 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19492 | |
d62a17ae | 19493 | if (ret < 0) { |
19494 | community_list_perror(vty, ret); | |
19495 | return CMD_WARNING_CONFIG_FAILED; | |
19496 | } | |
42f914d4 | 19497 | |
d62a17ae | 19498 | return CMD_SUCCESS; |
718e3744 | 19499 | } |
19500 | ||
7336e101 SP |
19501 | DEFUN (no_extcommunity_list_standard_all, |
19502 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 19503 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19504 | NO_STR |
19505 | BGP_STR | |
19506 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 19507 | "Extended Community list number (standard)\n" |
718e3744 | 19508 | "Specify standard extcommunity-list\n" |
5bf15956 | 19509 | "Community list name\n" |
2f8cc0e5 DA |
19510 | "Sequence number of an entry\n" |
19511 | "Sequence number\n" | |
718e3744 | 19512 | "Specify community to reject\n" |
19513 | "Specify community to accept\n" | |
19514 | EXTCOMMUNITY_VAL_STR) | |
19515 | { | |
d62a17ae | 19516 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19517 | int direct = 0; | |
19518 | char *cl_number_or_name = NULL; | |
d4455c89 | 19519 | char *str = NULL; |
2f8cc0e5 | 19520 | char *seq = NULL; |
d62a17ae | 19521 | int idx = 0; |
d4455c89 | 19522 | |
409148f6 | 19523 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19524 | seq = argv[idx]->arg; |
19525 | ||
19526 | idx = 0; | |
d4455c89 DA |
19527 | argv_find(argv, argc, "permit", &idx); |
19528 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
19529 | if (idx) { |
19530 | direct = argv_find(argv, argc, "permit", &idx) | |
19531 | ? COMMUNITY_PERMIT | |
19532 | : COMMUNITY_DENY; | |
19533 | ||
19534 | idx = 0; | |
19535 | argv_find(argv, argc, "AA:NN", &idx); | |
19536 | str = argv_concat(argv, argc, idx); | |
19537 | } | |
19538 | ||
19539 | idx = 0; | |
d62a17ae | 19540 | argv_find(argv, argc, "(1-99)", &idx); |
19541 | argv_find(argv, argc, "WORD", &idx); | |
19542 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19543 | |
d62a17ae | 19544 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19545 | seq, direct, style); |
42f914d4 | 19546 | |
d62a17ae | 19547 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19548 | |
d62a17ae | 19549 | if (ret < 0) { |
19550 | community_list_perror(vty, ret); | |
19551 | return CMD_WARNING_CONFIG_FAILED; | |
19552 | } | |
42f914d4 | 19553 | |
d62a17ae | 19554 | return CMD_SUCCESS; |
718e3744 | 19555 | } |
19556 | ||
d4455c89 DA |
19557 | ALIAS(no_extcommunity_list_standard_all, |
19558 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
19559 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
36d4bb44 | 19560 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19561 | "Extended Community list number (standard)\n" |
19562 | "Specify standard extcommunity-list\n" | |
19563 | "Community list name\n") | |
19564 | ||
7336e101 SP |
19565 | DEFUN (no_extcommunity_list_expanded_all, |
19566 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 19567 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19568 | NO_STR |
19569 | BGP_STR | |
19570 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 19571 | "Extended Community list number (expanded)\n" |
718e3744 | 19572 | "Specify expanded extcommunity-list\n" |
5bf15956 | 19573 | "Extended Community list name\n" |
2f8cc0e5 DA |
19574 | "Sequence number of an entry\n" |
19575 | "Sequence number\n" | |
718e3744 | 19576 | "Specify community to reject\n" |
19577 | "Specify community to accept\n" | |
19578 | "An ordered list as a regular-expression\n") | |
19579 | { | |
d62a17ae | 19580 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19581 | int direct = 0; | |
19582 | char *cl_number_or_name = NULL; | |
d4455c89 | 19583 | char *str = NULL; |
2f8cc0e5 | 19584 | char *seq = NULL; |
d62a17ae | 19585 | int idx = 0; |
d4455c89 | 19586 | |
409148f6 | 19587 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19588 | seq = argv[idx]->arg; |
19589 | ||
19590 | idx = 0; | |
d4455c89 DA |
19591 | argv_find(argv, argc, "permit", &idx); |
19592 | argv_find(argv, argc, "deny", &idx); | |
19593 | ||
19594 | if (idx) { | |
19595 | direct = argv_find(argv, argc, "permit", &idx) | |
19596 | ? COMMUNITY_PERMIT | |
19597 | : COMMUNITY_DENY; | |
19598 | ||
19599 | idx = 0; | |
19600 | argv_find(argv, argc, "LINE", &idx); | |
19601 | str = argv_concat(argv, argc, idx); | |
19602 | } | |
19603 | ||
19604 | idx = 0; | |
d62a17ae | 19605 | argv_find(argv, argc, "(100-500)", &idx); |
19606 | argv_find(argv, argc, "WORD", &idx); | |
19607 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19608 | |
d62a17ae | 19609 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19610 | seq, direct, style); |
42f914d4 | 19611 | |
d62a17ae | 19612 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19613 | |
d62a17ae | 19614 | if (ret < 0) { |
19615 | community_list_perror(vty, ret); | |
19616 | return CMD_WARNING_CONFIG_FAILED; | |
19617 | } | |
42f914d4 | 19618 | |
d62a17ae | 19619 | return CMD_SUCCESS; |
718e3744 | 19620 | } |
19621 | ||
d4455c89 DA |
19622 | ALIAS(no_extcommunity_list_expanded_all, |
19623 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
19624 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
36d4bb44 | 19625 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19626 | "Extended Community list number (expanded)\n" |
19627 | "Specify expanded extcommunity-list\n" | |
19628 | "Extended Community list name\n") | |
19629 | ||
d62a17ae | 19630 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19631 | { |
d62a17ae | 19632 | struct community_entry *entry; |
718e3744 | 19633 | |
d62a17ae | 19634 | for (entry = list->head; entry; entry = entry->next) { |
19635 | if (entry == list->head) { | |
19636 | if (all_digit(list->name)) | |
19637 | vty_out(vty, "Extended community %s list %s\n", | |
19638 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19639 | ? "standard" | |
19640 | : "(expanded) access", | |
19641 | list->name); | |
19642 | else | |
19643 | vty_out(vty, | |
19644 | "Named extended community %s list %s\n", | |
19645 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19646 | ? "standard" | |
19647 | : "expanded", | |
19648 | list->name); | |
19649 | } | |
19650 | if (entry->any) | |
19651 | vty_out(vty, " %s\n", | |
19652 | community_direct_str(entry->direct)); | |
19653 | else | |
19654 | vty_out(vty, " %s %s\n", | |
19655 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19656 | community_list_config_str(entry)); |
d62a17ae | 19657 | } |
718e3744 | 19658 | } |
19659 | ||
7336e101 SP |
19660 | DEFUN (show_extcommunity_list, |
19661 | show_bgp_extcommunity_list_cmd, | |
19662 | "show bgp extcommunity-list", | |
718e3744 | 19663 | SHOW_STR |
7336e101 | 19664 | BGP_STR |
718e3744 | 19665 | "List extended-community list\n") |
19666 | { | |
d62a17ae | 19667 | struct community_list *list; |
19668 | struct community_list_master *cm; | |
718e3744 | 19669 | |
d62a17ae | 19670 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
19671 | if (!cm) | |
19672 | return CMD_SUCCESS; | |
718e3744 | 19673 | |
d62a17ae | 19674 | for (list = cm->num.head; list; list = list->next) |
19675 | extcommunity_list_show(vty, list); | |
718e3744 | 19676 | |
d62a17ae | 19677 | for (list = cm->str.head; list; list = list->next) |
19678 | extcommunity_list_show(vty, list); | |
718e3744 | 19679 | |
d62a17ae | 19680 | return CMD_SUCCESS; |
718e3744 | 19681 | } |
19682 | ||
7336e101 SP |
19683 | DEFUN (show_extcommunity_list_arg, |
19684 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 19685 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
19686 | SHOW_STR |
19687 | BGP_STR | |
718e3744 | 19688 | "List extended-community list\n" |
19689 | "Extcommunity-list number\n" | |
960b69b9 | 19690 | "Extcommunity-list name\n" |
19691 | "Detailed information on extcommunity-list\n") | |
718e3744 | 19692 | { |
d62a17ae | 19693 | int idx_comm_list = 3; |
19694 | struct community_list *list; | |
718e3744 | 19695 | |
e237b0d2 | 19696 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19697 | EXTCOMMUNITY_LIST_MASTER); |
19698 | if (!list) { | |
19699 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
19700 | return CMD_WARNING; | |
19701 | } | |
718e3744 | 19702 | |
d62a17ae | 19703 | extcommunity_list_show(vty, list); |
718e3744 | 19704 | |
d62a17ae | 19705 | return CMD_SUCCESS; |
718e3744 | 19706 | } |
6b0655a2 | 19707 | |
718e3744 | 19708 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 19709 | static int community_list_config_write(struct vty *vty) |
19710 | { | |
19711 | struct community_list *list; | |
19712 | struct community_entry *entry; | |
19713 | struct community_list_master *cm; | |
19714 | int write = 0; | |
19715 | ||
19716 | /* Community-list. */ | |
19717 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
19718 | ||
19719 | for (list = cm->num.head; list; list = list->next) | |
19720 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19721 | vty_out(vty, |
19722 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
19723 | list->name, entry->seq, | |
d62a17ae | 19724 | community_direct_str(entry->direct), |
19725 | community_list_config_str(entry)); | |
19726 | write++; | |
19727 | } | |
19728 | for (list = cm->str.head; list; list = list->next) | |
19729 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19730 | vty_out(vty, |
19731 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 19732 | entry->style == COMMUNITY_LIST_STANDARD |
19733 | ? "standard" | |
19734 | : "expanded", | |
2f8cc0e5 DA |
19735 | list->name, entry->seq, |
19736 | community_direct_str(entry->direct), | |
d62a17ae | 19737 | community_list_config_str(entry)); |
19738 | write++; | |
19739 | } | |
19740 | ||
19741 | /* Extcommunity-list. */ | |
19742 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
19743 | ||
19744 | for (list = cm->num.head; list; list = list->next) | |
19745 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19746 | vty_out(vty, |
19747 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
19748 | list->name, entry->seq, | |
19749 | community_direct_str(entry->direct), | |
d62a17ae | 19750 | community_list_config_str(entry)); |
19751 | write++; | |
19752 | } | |
19753 | for (list = cm->str.head; list; list = list->next) | |
19754 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 19755 | vty_out(vty, |
6cde4b45 | 19756 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 19757 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
19758 | ? "standard" | |
19759 | : "expanded", | |
2f8cc0e5 DA |
19760 | list->name, entry->seq, |
19761 | community_direct_str(entry->direct), | |
d62a17ae | 19762 | community_list_config_str(entry)); |
19763 | write++; | |
19764 | } | |
19765 | ||
19766 | ||
19767 | /* lcommunity-list. */ | |
19768 | cm = community_list_master_lookup(bgp_clist, | |
19769 | LARGE_COMMUNITY_LIST_MASTER); | |
19770 | ||
19771 | for (list = cm->num.head; list; list = list->next) | |
19772 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 19773 | vty_out(vty, |
6cde4b45 | 19774 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
19775 | list->name, entry->seq, |
19776 | community_direct_str(entry->direct), | |
d62a17ae | 19777 | community_list_config_str(entry)); |
19778 | write++; | |
19779 | } | |
19780 | for (list = cm->str.head; list; list = list->next) | |
19781 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 19782 | vty_out(vty, |
6cde4b45 | 19783 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 19784 | |
d62a17ae | 19785 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
19786 | ? "standard" | |
19787 | : "expanded", | |
2f8cc0e5 | 19788 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 19789 | community_list_config_str(entry)); |
19790 | write++; | |
19791 | } | |
19792 | ||
19793 | return write; | |
19794 | } | |
19795 | ||
612c2c15 | 19796 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 19797 | static struct cmd_node community_list_node = { |
f4b8291f | 19798 | .name = "community list", |
62b346ee DL |
19799 | .node = COMMUNITY_LIST_NODE, |
19800 | .prompt = "", | |
612c2c15 | 19801 | .config_write = community_list_config_write, |
718e3744 | 19802 | }; |
19803 | ||
d62a17ae | 19804 | static void community_list_vty(void) |
19805 | { | |
612c2c15 | 19806 | install_node(&community_list_node); |
d62a17ae | 19807 | |
19808 | /* Community-list. */ | |
7336e101 SP |
19809 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
19810 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
19811 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 19812 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 19813 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 19814 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
19815 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
19816 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 19817 | |
19818 | /* Extcommunity-list. */ | |
7336e101 SP |
19819 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
19820 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
19821 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
19822 | install_element(CONFIG_NODE, |
19823 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 19824 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
19825 | install_element(CONFIG_NODE, |
19826 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
19827 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
19828 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 19829 | |
19830 | /* Large Community List */ | |
7336e101 | 19831 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
19832 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
19833 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 19834 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
19835 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
19836 | install_element(CONFIG_NODE, | |
19837 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
19838 | install_element(CONFIG_NODE, |
19839 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
19840 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
19841 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
19842 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
19843 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
19844 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
19845 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 19846 | } |