]>
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 DD |
10812 | if (paf && PAF_SUBGRP(paf)) |
10813 | json_object_int_add(json_peer, | |
10814 | "pfxSnt", | |
10815 | (PAF_SUBGRP(paf))->scount); | |
0e1f8ab5 DA |
10816 | |
10817 | /* BGP FSM state */ | |
cb9196e7 | 10818 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
10819 | || CHECK_FLAG(peer->bgp->flags, |
10820 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
10821 | json_object_string_add(json_peer, |
10822 | "state", | |
3577f1c5 DD |
10823 | "Idle (Admin)"); |
10824 | else if (peer->afc_recv[afi][safi]) | |
10825 | json_object_string_add( | |
0e1f8ab5 DA |
10826 | json_peer, "state", |
10827 | lookup_msg(bgp_status_msg, | |
10828 | peer->status, NULL)); | |
10829 | else if (CHECK_FLAG( | |
10830 | peer->sflags, | |
10831 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10832 | json_object_string_add(json_peer, | |
10833 | "state", | |
3577f1c5 DD |
10834 | "Idle (PfxCt)"); |
10835 | else | |
10836 | json_object_string_add( | |
0e1f8ab5 DA |
10837 | json_peer, "state", |
10838 | lookup_msg(bgp_status_msg, | |
10839 | peer->status, NULL)); | |
10840 | ||
10841 | /* BGP peer state */ | |
10842 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
10843 | || CHECK_FLAG(peer->bgp->flags, | |
10844 | BGP_FLAG_SHUTDOWN)) | |
10845 | json_object_string_add(json_peer, | |
10846 | "peerState", | |
10847 | "Admin"); | |
10848 | else if (CHECK_FLAG( | |
10849 | peer->sflags, | |
10850 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10851 | json_object_string_add(json_peer, | |
10852 | "peerState", | |
10853 | "PfxCt"); | |
10854 | else if (CHECK_FLAG(peer->flags, | |
10855 | PEER_FLAG_PASSIVE)) | |
10856 | json_object_string_add(json_peer, | |
10857 | "peerState", | |
10858 | "Passive"); | |
10859 | else if (CHECK_FLAG(peer->sflags, | |
10860 | PEER_STATUS_NSF_WAIT)) | |
10861 | json_object_string_add(json_peer, | |
10862 | "peerState", | |
10863 | "NSF passive"); | |
10864 | else if (CHECK_FLAG( | |
10865 | peer->bgp->flags, | |
10866 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10867 | && (!bgp_inbound_policy_exists(peer, | |
10868 | filter) | |
10869 | || !bgp_outbound_policy_exists( | |
10870 | peer, filter))) | |
10871 | json_object_string_add(json_peer, | |
10872 | "peerState", | |
10873 | "Policy"); | |
10874 | else | |
10875 | json_object_string_add( | |
10876 | json_peer, "peerState", "OK"); | |
10877 | ||
200116db DD |
10878 | json_object_int_add(json_peer, "connectionsEstablished", |
10879 | peer->established); | |
10880 | json_object_int_add(json_peer, "connectionsDropped", | |
10881 | peer->dropped); | |
b4e9dcba | 10882 | } |
3577f1c5 DD |
10883 | /* Avoid creating empty peer dicts in JSON */ |
10884 | if (json_peer == NULL) | |
10885 | continue; | |
ea47320b DL |
10886 | |
10887 | if (peer->conf_if) | |
60466a63 | 10888 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
10889 | "interface"); |
10890 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
10891 | json_object_string_add(json_peer, "idType", |
10892 | "ipv4"); | |
ea47320b | 10893 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
10894 | json_object_string_add(json_peer, "idType", |
10895 | "ipv6"); | |
ea47320b DL |
10896 | json_object_object_add(json_peers, peer->host, |
10897 | json_peer); | |
10898 | } else { | |
3577f1c5 DD |
10899 | if (show_failed && |
10900 | bgp_has_peer_failed(peer, afi, safi)) { | |
10901 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10902 | max_neighbor_width, | |
10903 | use_json); | |
10904 | } else if (!show_failed) { | |
10b49f14 DA |
10905 | if (show_established |
10906 | && bgp_has_peer_failed(peer, afi, safi)) | |
10907 | continue; | |
10908 | ||
3577f1c5 DD |
10909 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10910 | if (peer_dynamic_neighbor(peer)) { | |
10911 | dn_flag[0] = '*'; | |
10912 | } | |
d62a17ae | 10913 | |
3577f1c5 | 10914 | if (peer->hostname |
892fedb6 DA |
10915 | && CHECK_FLAG(bgp->flags, |
10916 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10917 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10918 | peer->hostname, |
10919 | peer->host); | |
d62a17ae | 10920 | else |
3577f1c5 DD |
10921 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10922 | ||
10923 | /* pad the neighbor column with spaces */ | |
10924 | if (len < max_neighbor_width) | |
10925 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10926 | " "); | |
10927 | ||
43aa5965 QY |
10928 | atomic_size_t outq_count, inq_count; |
10929 | outq_count = atomic_load_explicit( | |
10930 | &peer->obuf->count, | |
10931 | memory_order_relaxed); | |
10932 | inq_count = atomic_load_explicit( | |
10933 | &peer->ibuf->count, | |
10934 | memory_order_relaxed); | |
10935 | ||
566bdaf6 | 10936 | vty_out(vty, |
6cde4b45 | 10937 | "4 %10u %9u %9u %8" PRIu64" %4zu %4zu %8s", |
3577f1c5 | 10938 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 10939 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
10940 | peer->version[afi][safi], inq_count, |
10941 | outq_count, | |
3577f1c5 DD |
10942 | peer_uptime(peer->uptime, timebuf, |
10943 | BGP_UPTIME_LEN, 0, NULL)); | |
10944 | ||
db92d226 | 10945 | if (peer->status == Established) { |
d3ada366 DA |
10946 | if (peer->afc_recv[afi][safi]) { |
10947 | if (CHECK_FLAG( | |
10948 | bgp->flags, | |
10949 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10950 | && !bgp_inbound_policy_exists( | |
10951 | peer, filter)) | |
10952 | vty_out(vty, " %12s", | |
10953 | "(Policy)"); | |
10954 | else | |
10955 | vty_out(vty, | |
6cde4b45 | 10956 | " %12u", |
d3ada366 DA |
10957 | peer->pcount |
10958 | [afi] | |
10959 | [pfx_rcd_safi]); | |
10960 | } else { | |
3577f1c5 | 10961 | vty_out(vty, " NoNeg"); |
d3ada366 | 10962 | } |
db92d226 | 10963 | |
d3ada366 DA |
10964 | if (paf && PAF_SUBGRP(paf)) { |
10965 | if (CHECK_FLAG( | |
10966 | bgp->flags, | |
10967 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10968 | && !bgp_outbound_policy_exists( | |
10969 | peer, filter)) | |
10970 | vty_out(vty, " %8s", | |
10971 | "(Policy)"); | |
10972 | else | |
10973 | vty_out(vty, | |
6cde4b45 | 10974 | " %8u", |
d3ada366 DA |
10975 | (PAF_SUBGRP( |
10976 | paf)) | |
10977 | ->scount); | |
10978 | } | |
db92d226 | 10979 | } else { |
736b68f3 DS |
10980 | if (CHECK_FLAG(peer->flags, |
10981 | PEER_FLAG_SHUTDOWN) | |
10982 | || CHECK_FLAG(peer->bgp->flags, | |
10983 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10984 | vty_out(vty, " Idle (Admin)"); |
10985 | else if (CHECK_FLAG( | |
10986 | peer->sflags, | |
10987 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10988 | vty_out(vty, " Idle (PfxCt)"); | |
10989 | else | |
10990 | vty_out(vty, " %12s", | |
10991 | lookup_msg(bgp_status_msg, | |
10992 | peer->status, NULL)); | |
db92d226 | 10993 | |
6cde4b45 | 10994 | vty_out(vty, " %8u", 0); |
3577f1c5 DD |
10995 | } |
10996 | vty_out(vty, "\n"); | |
d62a17ae | 10997 | } |
3577f1c5 | 10998 | |
d62a17ae | 10999 | } |
11000 | } | |
f933309e | 11001 | |
d62a17ae | 11002 | if (use_json) { |
11003 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 11004 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 11005 | json_object_int_add(json, "totalPeers", count); |
11006 | json_object_int_add(json, "dynamicPeers", dn_count); | |
11007 | ||
3577f1c5 DD |
11008 | if (!show_failed) |
11009 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 11010 | |
996c9314 LB |
11011 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
11012 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 11013 | json_object_free(json); |
11014 | } else { | |
11015 | if (count) | |
11016 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
11017 | else { | |
d6ceaca3 | 11018 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 11019 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11020 | } |
b05a1c8b | 11021 | |
d6ceaca3 | 11022 | if (dn_count) { |
d62a17ae | 11023 | vty_out(vty, "* - dynamic neighbor\n"); |
11024 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
11025 | dn_count, bgp->dynamic_neighbors_limit); | |
11026 | } | |
11027 | } | |
1ff9a340 | 11028 | |
d62a17ae | 11029 | return CMD_SUCCESS; |
718e3744 | 11030 | } |
11031 | ||
d62a17ae | 11032 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
10b49f14 DA |
11033 | int safi, bool show_failed, |
11034 | bool show_established, bool use_json) | |
d62a17ae | 11035 | { |
11036 | int is_first = 1; | |
11037 | int afi_wildcard = (afi == AFI_MAX); | |
11038 | int safi_wildcard = (safi == SAFI_MAX); | |
11039 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11040 | bool nbr_output = false; |
d62a17ae | 11041 | |
11042 | if (use_json && is_wildcard) | |
11043 | vty_out(vty, "{\n"); | |
11044 | if (afi_wildcard) | |
11045 | afi = 1; /* AFI_IP */ | |
11046 | while (afi < AFI_MAX) { | |
11047 | if (safi_wildcard) | |
11048 | safi = 1; /* SAFI_UNICAST */ | |
11049 | while (safi < SAFI_MAX) { | |
318cac96 | 11050 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11051 | nbr_output = true; |
f86897b9 | 11052 | |
d62a17ae | 11053 | if (is_wildcard) { |
11054 | /* | |
11055 | * So limit output to those afi/safi | |
11056 | * pairs that | |
11057 | * actualy have something interesting in | |
11058 | * them | |
11059 | */ | |
11060 | if (use_json) { | |
d62a17ae | 11061 | if (!is_first) |
11062 | vty_out(vty, ",\n"); | |
11063 | else | |
11064 | is_first = 0; | |
11065 | ||
11066 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11067 | get_afi_safi_str(afi, |
11068 | safi, | |
11069 | true)); | |
d62a17ae | 11070 | } else { |
11071 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
11072 | get_afi_safi_str(afi, |
11073 | safi, | |
11074 | false)); | |
d62a17ae | 11075 | } |
11076 | } | |
10b49f14 DA |
11077 | bgp_show_summary(vty, bgp, afi, safi, |
11078 | show_failed, show_established, | |
3577f1c5 | 11079 | use_json); |
d62a17ae | 11080 | } |
11081 | safi++; | |
d62a17ae | 11082 | if (!safi_wildcard) |
11083 | safi = SAFI_MAX; | |
11084 | } | |
11085 | afi++; | |
ee851c8c | 11086 | if (!afi_wildcard) |
d62a17ae | 11087 | afi = AFI_MAX; |
11088 | } | |
11089 | ||
11090 | if (use_json && is_wildcard) | |
11091 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11092 | else if (!nbr_output) { |
11093 | if (use_json) | |
11094 | vty_out(vty, "{}\n"); | |
11095 | else | |
11096 | vty_out(vty, "%% No BGP neighbors found\n"); | |
11097 | } | |
d62a17ae | 11098 | } |
11099 | ||
11100 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 | 11101 | safi_t safi, bool show_failed, |
10b49f14 | 11102 | bool show_established, |
3577f1c5 | 11103 | bool use_json) |
d62a17ae | 11104 | { |
11105 | struct listnode *node, *nnode; | |
11106 | struct bgp *bgp; | |
d62a17ae | 11107 | int is_first = 1; |
9f049418 | 11108 | bool nbr_output = false; |
d62a17ae | 11109 | |
11110 | if (use_json) | |
11111 | vty_out(vty, "{\n"); | |
11112 | ||
11113 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11114 | nbr_output = true; |
d62a17ae | 11115 | if (use_json) { |
d62a17ae | 11116 | if (!is_first) |
11117 | vty_out(vty, ",\n"); | |
11118 | else | |
11119 | is_first = 0; | |
11120 | ||
11121 | vty_out(vty, "\"%s\":", | |
11122 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11123 | ? VRF_DEFAULT_NAME |
d62a17ae | 11124 | : bgp->name); |
11125 | } else { | |
11126 | vty_out(vty, "\nInstance %s:\n", | |
11127 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11128 | ? VRF_DEFAULT_NAME |
d62a17ae | 11129 | : bgp->name); |
11130 | } | |
3577f1c5 | 11131 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 11132 | show_established, use_json); |
d62a17ae | 11133 | } |
11134 | ||
11135 | if (use_json) | |
11136 | vty_out(vty, "}\n"); | |
9f049418 DS |
11137 | else if (!nbr_output) |
11138 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11139 | } |
11140 | ||
11141 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
10b49f14 DA |
11142 | safi_t safi, bool show_failed, bool show_established, |
11143 | bool use_json) | |
d62a17ae | 11144 | { |
11145 | struct bgp *bgp; | |
11146 | ||
11147 | if (name) { | |
11148 | if (strmatch(name, "all")) { | |
10b49f14 DA |
11149 | bgp_show_all_instances_summary_vty( |
11150 | vty, afi, safi, show_failed, show_established, | |
11151 | use_json); | |
d62a17ae | 11152 | return CMD_SUCCESS; |
11153 | } else { | |
11154 | bgp = bgp_lookup_by_name(name); | |
11155 | ||
11156 | if (!bgp) { | |
11157 | if (use_json) | |
11158 | vty_out(vty, "{}\n"); | |
11159 | else | |
11160 | vty_out(vty, | |
ca61fd25 | 11161 | "%% BGP instance not found\n"); |
d62a17ae | 11162 | return CMD_WARNING; |
11163 | } | |
11164 | ||
f86897b9 | 11165 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
10b49f14 DA |
11166 | show_failed, show_established, |
11167 | use_json); | |
d62a17ae | 11168 | return CMD_SUCCESS; |
11169 | } | |
11170 | } | |
11171 | ||
11172 | bgp = bgp_get_default(); | |
11173 | ||
11174 | if (bgp) | |
3577f1c5 | 11175 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 11176 | show_established, use_json); |
9f049418 | 11177 | else { |
ca61fd25 DS |
11178 | if (use_json) |
11179 | vty_out(vty, "{}\n"); | |
11180 | else | |
11181 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11182 | return CMD_WARNING; |
11183 | } | |
d62a17ae | 11184 | |
11185 | return CMD_SUCCESS; | |
4fb25c53 DW |
11186 | } |
11187 | ||
716b2d8a | 11188 | /* `show [ip] bgp summary' commands. */ |
96f3485c | 11189 | DEFPY (show_ip_bgp_summary, |
718e3744 | 11190 | show_ip_bgp_summary_cmd, |
96f3485c | 11191 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] summary [established|failed] [json$uj]", |
718e3744 | 11192 | SHOW_STR |
11193 | IP_STR | |
11194 | BGP_STR | |
8386ac43 | 11195 | BGP_INSTANCE_HELP_STR |
46f296b4 | 11196 | BGP_AFI_HELP_STR |
dd6bd0f1 | 11197 | BGP_SAFI_WITH_LABEL_HELP_STR |
96f3485c | 11198 | "Display the entries for all address families\n" |
b05a1c8b | 11199 | "Summary of BGP neighbor status\n" |
10b49f14 | 11200 | "Show only sessions in Established state\n" |
3577f1c5 | 11201 | "Show only sessions not in Established state\n" |
9973d184 | 11202 | JSON_STR) |
718e3744 | 11203 | { |
d62a17ae | 11204 | char *vrf = NULL; |
11205 | afi_t afi = AFI_MAX; | |
11206 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 11207 | bool show_failed = false; |
10b49f14 | 11208 | bool show_established = false; |
d62a17ae | 11209 | |
11210 | int idx = 0; | |
11211 | ||
11212 | /* show [ip] bgp */ | |
96f3485c | 11213 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11214 | afi = AFI_IP; |
9a8bdf1c PG |
11215 | /* [<vrf> VIEWVRFNAME] */ |
11216 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11217 | vrf = argv[idx + 1]->arg; | |
11218 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11219 | vrf = NULL; | |
11220 | } else if (argv_find(argv, argc, "view", &idx)) | |
11221 | /* [<view> VIEWVRFNAME] */ | |
11222 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11223 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11224 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11225 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11226 | } | |
11227 | ||
3577f1c5 DD |
11228 | if (argv_find(argv, argc, "failed", &idx)) |
11229 | show_failed = true; | |
10b49f14 DA |
11230 | if (argv_find(argv, argc, "established", &idx)) |
11231 | show_established = true; | |
3577f1c5 | 11232 | |
10b49f14 DA |
11233 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, |
11234 | show_established, uj); | |
d62a17ae | 11235 | } |
11236 | ||
5cb5f4d0 | 11237 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11238 | { |
5cb5f4d0 DD |
11239 | if (for_json) |
11240 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11241 | else |
5cb5f4d0 | 11242 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11243 | } |
11244 | ||
d62a17ae | 11245 | |
11246 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11247 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11248 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11249 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11250 | bool use_json, json_object *json_pref) |
d62a17ae | 11251 | { |
11252 | /* Send-Mode */ | |
11253 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11254 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11255 | if (use_json) { | |
11256 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11257 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11258 | json_object_string_add(json_pref, "sendMode", | |
11259 | "advertisedAndReceived"); | |
11260 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11261 | json_object_string_add(json_pref, "sendMode", | |
11262 | "advertised"); | |
11263 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11264 | json_object_string_add(json_pref, "sendMode", | |
11265 | "received"); | |
11266 | } else { | |
11267 | vty_out(vty, " Send-mode: "); | |
11268 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11269 | vty_out(vty, "advertised"); | |
11270 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11271 | vty_out(vty, "%sreceived", | |
11272 | CHECK_FLAG(p->af_cap[afi][safi], | |
11273 | adv_smcap) | |
11274 | ? ", " | |
11275 | : ""); | |
11276 | vty_out(vty, "\n"); | |
11277 | } | |
11278 | } | |
11279 | ||
11280 | /* Receive-Mode */ | |
11281 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11282 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11283 | if (use_json) { | |
11284 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11285 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11286 | json_object_string_add(json_pref, "recvMode", | |
11287 | "advertisedAndReceived"); | |
11288 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11289 | json_object_string_add(json_pref, "recvMode", | |
11290 | "advertised"); | |
11291 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11292 | json_object_string_add(json_pref, "recvMode", | |
11293 | "received"); | |
11294 | } else { | |
11295 | vty_out(vty, " Receive-mode: "); | |
11296 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11297 | vty_out(vty, "advertised"); | |
11298 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11299 | vty_out(vty, "%sreceived", | |
11300 | CHECK_FLAG(p->af_cap[afi][safi], | |
11301 | adv_rmcap) | |
11302 | ? ", " | |
11303 | : ""); | |
11304 | vty_out(vty, "\n"); | |
11305 | } | |
11306 | } | |
11307 | } | |
11308 | ||
13909c4f DS |
11309 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
11310 | struct peer *p, | |
11311 | bool use_json, | |
11312 | json_object *json) | |
2986cac2 | 11313 | { |
08c2d52a | 11314 | bool rbit_status = false; |
2986cac2 | 11315 | |
11316 | if (!use_json) | |
a53ca37b | 11317 | vty_out(vty, "\n R bit: "); |
2986cac2 | 11318 | |
13909c4f DS |
11319 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11320 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
11321 | && (p->status == Established)) { | |
2986cac2 | 11322 | |
11323 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 11324 | rbit_status = true; |
2986cac2 | 11325 | else |
08c2d52a | 11326 | rbit_status = false; |
2986cac2 | 11327 | } |
11328 | ||
11329 | if (rbit_status) { | |
11330 | if (use_json) | |
13909c4f | 11331 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 11332 | else |
11333 | vty_out(vty, "True\n"); | |
11334 | } else { | |
11335 | if (use_json) | |
13909c4f | 11336 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 11337 | else |
11338 | vty_out(vty, "False\n"); | |
11339 | } | |
11340 | } | |
11341 | ||
13909c4f DS |
11342 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11343 | struct peer *peer, | |
11344 | bool use_json, | |
11345 | json_object *json) | |
2986cac2 | 11346 | { |
2bb5d39b | 11347 | const char *mode = "NotApplicable"; |
2986cac2 | 11348 | |
11349 | if (!use_json) | |
a53ca37b | 11350 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11351 | |
13909c4f DS |
11352 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11353 | && (peer->status == Established)) { | |
2986cac2 | 11354 | |
13909c4f DS |
11355 | if ((peer->nsf_af_count == 0) |
11356 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11357 | |
2986cac2 | 11358 | mode = "Disable"; |
11359 | ||
13909c4f DS |
11360 | } else if (peer->nsf_af_count == 0 |
11361 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11362 | |
2986cac2 | 11363 | mode = "Helper"; |
11364 | ||
13909c4f DS |
11365 | } else if (peer->nsf_af_count != 0 |
11366 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11367 | |
2986cac2 | 11368 | mode = "Restart"; |
2986cac2 | 11369 | } |
11370 | } | |
11371 | ||
11372 | if (use_json) { | |
13909c4f | 11373 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11374 | } else |
11375 | vty_out(vty, mode, "\n"); | |
11376 | } | |
11377 | ||
13909c4f DS |
11378 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11379 | struct peer *p, | |
11380 | bool use_json, | |
11381 | json_object *json) | |
2986cac2 | 11382 | { |
11383 | const char *mode = "Invalid"; | |
11384 | ||
11385 | if (!use_json) | |
a53ca37b | 11386 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11387 | |
11388 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11389 | mode = "Helper"; | |
11390 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11391 | mode = "Restart"; | |
11392 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11393 | mode = "Disable"; | |
2ba1fe69 | 11394 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11395 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11396 | mode = "Helper*"; | |
11397 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11398 | mode = "Restart*"; | |
11399 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11400 | mode = "Disable*"; | |
11401 | else | |
11402 | mode = "Invalid*"; | |
2ba1fe69 | 11403 | } |
2986cac2 | 11404 | |
11405 | if (use_json) { | |
13909c4f | 11406 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11407 | } else { |
11408 | vty_out(vty, mode, "\n"); | |
11409 | } | |
11410 | } | |
11411 | ||
13909c4f DS |
11412 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11413 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11414 | { |
2ba1fe69 | 11415 | afi_t afi; |
11416 | safi_t safi; | |
2986cac2 | 11417 | json_object *json_afi_safi = NULL; |
11418 | json_object *json_timer = NULL; | |
11419 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11420 | bool eor_flag = false; |
2986cac2 | 11421 | |
11422 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11423 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
11424 | if (!peer->afc[afi][safi]) |
11425 | continue; | |
2986cac2 | 11426 | |
13909c4f DS |
11427 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11428 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11429 | continue; | |
9e3b51a7 | 11430 | |
13909c4f DS |
11431 | if (use_json) { |
11432 | json_afi_safi = json_object_new_object(); | |
11433 | json_endofrib_status = json_object_new_object(); | |
11434 | json_timer = json_object_new_object(); | |
11435 | } | |
2986cac2 | 11436 | |
13909c4f DS |
11437 | if (peer->eor_stime[afi][safi] |
11438 | >= peer->pkt_stime[afi][safi]) | |
11439 | eor_flag = true; | |
11440 | else | |
11441 | eor_flag = false; | |
2986cac2 | 11442 | |
13909c4f | 11443 | if (!use_json) { |
a53ca37b | 11444 | vty_out(vty, " %s:\n", |
13909c4f | 11445 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 11446 | |
a53ca37b | 11447 | vty_out(vty, " F bit: "); |
698ba8d0 | 11448 | } |
2986cac2 | 11449 | |
13909c4f DS |
11450 | if (peer->nsf[afi][safi] |
11451 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
11452 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11453 | |
13909c4f DS |
11454 | if (use_json) { |
11455 | json_object_boolean_true_add( | |
2986cac2 | 11456 | json_afi_safi, "fBit"); |
13909c4f DS |
11457 | } else |
11458 | vty_out(vty, "True\n"); | |
11459 | } else { | |
11460 | if (use_json) | |
11461 | json_object_boolean_false_add( | |
11462 | json_afi_safi, "fBit"); | |
11463 | else | |
11464 | vty_out(vty, "False\n"); | |
11465 | } | |
2986cac2 | 11466 | |
13909c4f | 11467 | if (!use_json) |
a53ca37b | 11468 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 11469 | |
13909c4f DS |
11470 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11471 | PEER_STATUS_EOR_SEND)) { | |
11472 | if (use_json) { | |
11473 | json_object_boolean_true_add( | |
2986cac2 | 11474 | json_endofrib_status, |
13909c4f | 11475 | "endOfRibSend"); |
9e3b51a7 | 11476 | |
13909c4f DS |
11477 | PRINT_EOR_JSON(eor_flag); |
11478 | } else { | |
11479 | vty_out(vty, "Yes\n"); | |
11480 | vty_out(vty, | |
a53ca37b | 11481 | " End-of-RIB sent after update: "); |
2986cac2 | 11482 | |
13909c4f DS |
11483 | PRINT_EOR(eor_flag); |
11484 | } | |
11485 | } else { | |
11486 | if (use_json) { | |
11487 | json_object_boolean_false_add( | |
2986cac2 | 11488 | json_endofrib_status, |
13909c4f DS |
11489 | "endOfRibSend"); |
11490 | json_object_boolean_false_add( | |
9e3b51a7 | 11491 | json_endofrib_status, |
13909c4f DS |
11492 | "endOfRibSentAfterUpdate"); |
11493 | } else { | |
11494 | vty_out(vty, "No\n"); | |
11495 | vty_out(vty, | |
a53ca37b | 11496 | " End-of-RIB sent after update: "); |
13909c4f | 11497 | vty_out(vty, "No\n"); |
2986cac2 | 11498 | } |
13909c4f | 11499 | } |
2986cac2 | 11500 | |
a53ca37b DA |
11501 | if (!use_json) |
11502 | vty_out(vty, " End-of-RIB received: "); | |
11503 | ||
11504 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
11505 | PEER_STATUS_EOR_RECEIVED)) { | |
11506 | if (use_json) | |
11507 | json_object_boolean_true_add( | |
11508 | json_endofrib_status, | |
11509 | "endOfRibRecv"); | |
11510 | else | |
11511 | vty_out(vty, "Yes\n"); | |
11512 | } else { | |
11513 | if (use_json) | |
11514 | json_object_boolean_false_add( | |
11515 | json_endofrib_status, | |
11516 | "endOfRibRecv"); | |
11517 | else | |
11518 | vty_out(vty, "No\n"); | |
11519 | } | |
11520 | ||
13909c4f DS |
11521 | if (use_json) { |
11522 | json_object_int_add(json_timer, | |
11523 | "stalePathTimer", | |
11524 | peer->bgp->stalepath_time); | |
2986cac2 | 11525 | |
13909c4f DS |
11526 | if (peer->t_gr_stale != NULL) { |
11527 | json_object_int_add( | |
2986cac2 | 11528 | json_timer, |
11529 | "stalePathTimerRemaining", | |
11530 | thread_timer_remain_second( | |
13909c4f DS |
11531 | peer->t_gr_stale)); |
11532 | } | |
3a75afa4 | 11533 | |
13909c4f DS |
11534 | /* Display Configured Selection |
11535 | * Deferral only when when | |
11536 | * Gr mode is enabled. | |
11537 | */ | |
11538 | if (CHECK_FLAG(peer->flags, | |
11539 | PEER_FLAG_GRACEFUL_RESTART)) { | |
11540 | json_object_int_add( | |
3a75afa4 | 11541 | json_timer, |
2986cac2 | 11542 | "selectionDeferralTimer", |
11543 | peer->bgp->stalepath_time); | |
13909c4f | 11544 | } |
2986cac2 | 11545 | |
13909c4f DS |
11546 | if (peer->bgp->gr_info[afi][safi] |
11547 | .t_select_deferral | |
11548 | != NULL) { | |
2986cac2 | 11549 | |
13909c4f | 11550 | json_object_int_add( |
2986cac2 | 11551 | json_timer, |
11552 | "selectionDeferralTimerRemaining", | |
11553 | thread_timer_remain_second( | |
13909c4f DS |
11554 | peer->bgp |
11555 | ->gr_info[afi] | |
11556 | [safi] | |
11557 | .t_select_deferral)); | |
11558 | } | |
11559 | } else { | |
a53ca37b | 11560 | vty_out(vty, " Timers:\n"); |
13909c4f | 11561 | vty_out(vty, |
a53ca37b DA |
11562 | " Configured Stale Path Time(sec): %u\n", |
11563 | peer->bgp->stalepath_time); | |
2986cac2 | 11564 | |
a53ca37b | 11565 | if (peer->t_gr_stale != NULL) |
2986cac2 | 11566 | vty_out(vty, |
a53ca37b | 11567 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 11568 | thread_timer_remain_second( |
13909c4f | 11569 | peer->t_gr_stale)); |
13909c4f DS |
11570 | /* Display Configured Selection |
11571 | * Deferral only when when | |
11572 | * Gr mode is enabled. | |
11573 | */ | |
11574 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 11575 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 11576 | vty_out(vty, |
a53ca37b | 11577 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 11578 | peer->bgp->select_defer_time); |
2986cac2 | 11579 | |
13909c4f DS |
11580 | if (peer->bgp->gr_info[afi][safi] |
11581 | .t_select_deferral | |
a53ca37b | 11582 | != NULL) |
13909c4f | 11583 | vty_out(vty, |
a53ca37b | 11584 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 11585 | thread_timer_remain_second( |
13909c4f DS |
11586 | peer->bgp |
11587 | ->gr_info[afi] | |
11588 | [safi] | |
11589 | .t_select_deferral)); | |
2986cac2 | 11590 | } |
13909c4f DS |
11591 | if (use_json) { |
11592 | json_object_object_add(json_afi_safi, | |
11593 | "endOfRibStatus", | |
11594 | json_endofrib_status); | |
11595 | json_object_object_add(json_afi_safi, "timers", | |
11596 | json_timer); | |
11597 | json_object_object_add( | |
11598 | json, get_afi_safi_str(afi, safi, true), | |
11599 | json_afi_safi); | |
11600 | } | |
2986cac2 | 11601 | } |
11602 | } | |
11603 | } | |
11604 | ||
36235319 QY |
11605 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
11606 | struct peer *p, | |
11607 | bool use_json, | |
11608 | json_object *json) | |
2986cac2 | 11609 | { |
11610 | if (use_json) { | |
11611 | json_object *json_timer = NULL; | |
11612 | ||
11613 | json_timer = json_object_new_object(); | |
11614 | ||
13909c4f DS |
11615 | json_object_int_add(json_timer, "configuredRestartTimer", |
11616 | p->bgp->restart_time); | |
2986cac2 | 11617 | |
13909c4f DS |
11618 | json_object_int_add(json_timer, "receivedRestartTimer", |
11619 | p->v_gr_restart); | |
2986cac2 | 11620 | |
13909c4f DS |
11621 | if (p->t_gr_restart != NULL) |
11622 | json_object_int_add( | |
11623 | json_timer, "restartTimerRemaining", | |
11624 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 11625 | |
11626 | json_object_object_add(json, "timers", json_timer); | |
11627 | } else { | |
11628 | ||
a53ca37b DA |
11629 | vty_out(vty, " Timers:\n"); |
11630 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 11631 | p->bgp->restart_time); |
2986cac2 | 11632 | |
a53ca37b | 11633 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
11634 | p->v_gr_restart); |
11635 | if (p->t_gr_restart != NULL) | |
a53ca37b | 11636 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 11637 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 11638 | if (p->t_gr_restart != NULL) { |
a53ca37b | 11639 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
11640 | thread_timer_remain_second(p->t_gr_restart)); |
11641 | } | |
2986cac2 | 11642 | } |
11643 | } | |
11644 | ||
11645 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 11646 | bool use_json, json_object *json) |
2986cac2 | 11647 | { |
11648 | char buf[SU_ADDRSTRLEN] = {0}; | |
11649 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
11650 | /* '*' + v6 address of neighbor */ |
11651 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 11652 | |
2986cac2 | 11653 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
11654 | dn_flag[0] = '*'; | |
11655 | ||
11656 | if (p->conf_if) { | |
11657 | if (use_json) | |
13909c4f DS |
11658 | json_object_string_add( |
11659 | json, "neighborAddr", | |
2986cac2 | 11660 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
11661 | ? "none" |
11662 | : sockunion2str(&p->su, buf, | |
11663 | SU_ADDRSTRLEN)); | |
2986cac2 | 11664 | else |
13909c4f | 11665 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 11666 | BGP_PEER_SU_UNSPEC(p) |
11667 | ? "none" | |
11668 | : sockunion2str(&p->su, buf, | |
11669 | SU_ADDRSTRLEN)); | |
11670 | } else { | |
772270f3 QY |
11671 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
11672 | p->host); | |
2986cac2 | 11673 | |
11674 | if (use_json) | |
36235319 QY |
11675 | json_object_string_add(json, "neighborAddr", |
11676 | neighborAddr); | |
2986cac2 | 11677 | else |
36235319 | 11678 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 11679 | } |
11680 | ||
11681 | /* more gr info in new format */ | |
11682 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11683 | } | |
11684 | ||
d62a17ae | 11685 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 11686 | safi_t safi, bool use_json, |
d62a17ae | 11687 | json_object *json_neigh) |
11688 | { | |
0291c246 MK |
11689 | struct bgp_filter *filter; |
11690 | struct peer_af *paf; | |
11691 | char orf_pfx_name[BUFSIZ]; | |
11692 | int orf_pfx_count; | |
11693 | json_object *json_af = NULL; | |
11694 | json_object *json_prefA = NULL; | |
11695 | json_object *json_prefB = NULL; | |
11696 | json_object *json_addr = NULL; | |
fa36596c | 11697 | json_object *json_advmap = NULL; |
d62a17ae | 11698 | |
11699 | if (use_json) { | |
11700 | json_addr = json_object_new_object(); | |
11701 | json_af = json_object_new_object(); | |
11702 | filter = &p->filter[afi][safi]; | |
11703 | ||
11704 | if (peer_group_active(p)) | |
11705 | json_object_string_add(json_addr, "peerGroupMember", | |
11706 | p->group->name); | |
11707 | ||
11708 | paf = peer_af_find(p, afi, safi); | |
11709 | if (paf && PAF_SUBGRP(paf)) { | |
11710 | json_object_int_add(json_addr, "updateGroupId", | |
11711 | PAF_UPDGRP(paf)->id); | |
11712 | json_object_int_add(json_addr, "subGroupId", | |
11713 | PAF_SUBGRP(paf)->id); | |
11714 | json_object_int_add(json_addr, "packetQueueLength", | |
11715 | bpacket_queue_virtual_length(paf)); | |
11716 | } | |
11717 | ||
11718 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11719 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11720 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11721 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11722 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11723 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11724 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11725 | json_object_int_add(json_af, "orfType", | |
11726 | ORF_TYPE_PREFIX); | |
11727 | json_prefA = json_object_new_object(); | |
11728 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11729 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11730 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11731 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11732 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11733 | use_json, json_prefA); | |
11734 | json_object_object_add(json_af, "orfPrefixList", | |
11735 | json_prefA); | |
11736 | } | |
11737 | ||
11738 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11739 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11740 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11741 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11742 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11743 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11744 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11745 | json_object_int_add(json_af, "orfOldType", | |
11746 | ORF_TYPE_PREFIX_OLD); | |
11747 | json_prefB = json_object_new_object(); | |
11748 | bgp_show_peer_afi_orf_cap( | |
11749 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11750 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11751 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11752 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11753 | json_prefB); | |
11754 | json_object_object_add(json_af, "orfOldPrefixList", | |
11755 | json_prefB); | |
11756 | } | |
11757 | ||
11758 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11759 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11760 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11761 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11762 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11763 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11764 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11765 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11766 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11767 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11768 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11769 | json_object_object_add(json_addr, "afDependentCap", | |
11770 | json_af); | |
11771 | else | |
11772 | json_object_free(json_af); | |
11773 | ||
772270f3 QY |
11774 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11775 | p->host, afi, safi); | |
d62a17ae | 11776 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11777 | NULL, afi, orf_pfx_name, use_json); | |
11778 | ||
11779 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11780 | PEER_STATUS_ORF_PREFIX_SEND) | |
11781 | || orf_pfx_count) { | |
11782 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11783 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11784 | json_object_boolean_true_add(json_neigh, | |
11785 | "orfSent"); | |
11786 | if (orf_pfx_count) | |
11787 | json_object_int_add(json_addr, "orfRecvCounter", | |
11788 | orf_pfx_count); | |
11789 | } | |
11790 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11791 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11792 | json_object_string_add( | |
11793 | json_addr, "orfFirstUpdate", | |
11794 | "deferredUntilORFOrRouteRefreshRecvd"); | |
11795 | ||
11796 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11797 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11798 | json_object_boolean_true_add(json_addr, | |
11799 | "routeReflectorClient"); | |
11800 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11801 | PEER_FLAG_RSERVER_CLIENT)) | |
11802 | json_object_boolean_true_add(json_addr, | |
11803 | "routeServerClient"); | |
11804 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11805 | json_object_boolean_true_add(json_addr, | |
11806 | "inboundSoftConfigPermit"); | |
11807 | ||
11808 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11809 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11810 | json_object_boolean_true_add( | |
11811 | json_addr, | |
11812 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
11813 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11814 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11815 | json_object_boolean_true_add( | |
11816 | json_addr, | |
11817 | "privateAsNumsReplacedInUpdatesToNbr"); | |
11818 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11819 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11820 | json_object_boolean_true_add( | |
11821 | json_addr, | |
11822 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
11823 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11824 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11825 | json_object_boolean_true_add( | |
11826 | json_addr, | |
11827 | "privateAsNumsRemovedInUpdatesToNbr"); | |
11828 | ||
dcc68b5e MS |
11829 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11830 | json_object_boolean_true_add( | |
11831 | json_addr, | |
11832 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11833 | ->type_json_name); | |
d62a17ae | 11834 | |
11835 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11836 | json_object_string_add(json_addr, | |
11837 | "overrideASNsInOutboundUpdates", | |
11838 | "ifAspathEqualRemoteAs"); | |
11839 | ||
11840 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11841 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11842 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11843 | json_object_boolean_true_add(json_addr, | |
11844 | "routerAlwaysNextHop"); | |
11845 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11846 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11847 | json_object_boolean_true_add( | |
11848 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
11849 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11850 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11851 | json_object_boolean_true_add( | |
11852 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
11853 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11854 | json_object_boolean_true_add( | |
11855 | json_addr, "unchangedMedPropogatedToNbr"); | |
11856 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11857 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11858 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11859 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11860 | PEER_FLAG_SEND_COMMUNITY) | |
11861 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11862 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11863 | json_object_string_add(json_addr, | |
11864 | "commAttriSentToNbr", | |
11865 | "extendedAndStandard"); | |
11866 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11867 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11868 | json_object_string_add(json_addr, | |
11869 | "commAttriSentToNbr", | |
11870 | "extended"); | |
11871 | else | |
11872 | json_object_string_add(json_addr, | |
11873 | "commAttriSentToNbr", | |
11874 | "standard"); | |
11875 | } | |
11876 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11877 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11878 | if (p->default_rmap[afi][safi].name) | |
11879 | json_object_string_add( | |
11880 | json_addr, "defaultRouteMap", | |
11881 | p->default_rmap[afi][safi].name); | |
11882 | ||
11883 | if (paf && PAF_SUBGRP(paf) | |
11884 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11885 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11886 | json_object_boolean_true_add(json_addr, | |
11887 | "defaultSent"); | |
11888 | else | |
11889 | json_object_boolean_true_add(json_addr, | |
11890 | "defaultNotSent"); | |
11891 | } | |
11892 | ||
dff8f48d | 11893 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 11894 | if (is_evpn_enabled()) |
60466a63 QY |
11895 | json_object_boolean_true_add( |
11896 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
11897 | } |
11898 | ||
d62a17ae | 11899 | if (filter->plist[FILTER_IN].name |
11900 | || filter->dlist[FILTER_IN].name | |
11901 | || filter->aslist[FILTER_IN].name | |
11902 | || filter->map[RMAP_IN].name) | |
11903 | json_object_boolean_true_add(json_addr, | |
11904 | "inboundPathPolicyConfig"); | |
11905 | if (filter->plist[FILTER_OUT].name | |
11906 | || filter->dlist[FILTER_OUT].name | |
11907 | || filter->aslist[FILTER_OUT].name | |
11908 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11909 | json_object_boolean_true_add( | |
11910 | json_addr, "outboundPathPolicyConfig"); | |
11911 | ||
11912 | /* prefix-list */ | |
11913 | if (filter->plist[FILTER_IN].name) | |
11914 | json_object_string_add(json_addr, | |
11915 | "incomingUpdatePrefixFilterList", | |
11916 | filter->plist[FILTER_IN].name); | |
11917 | if (filter->plist[FILTER_OUT].name) | |
11918 | json_object_string_add(json_addr, | |
11919 | "outgoingUpdatePrefixFilterList", | |
11920 | filter->plist[FILTER_OUT].name); | |
11921 | ||
11922 | /* distribute-list */ | |
11923 | if (filter->dlist[FILTER_IN].name) | |
11924 | json_object_string_add( | |
11925 | json_addr, "incomingUpdateNetworkFilterList", | |
11926 | filter->dlist[FILTER_IN].name); | |
11927 | if (filter->dlist[FILTER_OUT].name) | |
11928 | json_object_string_add( | |
11929 | json_addr, "outgoingUpdateNetworkFilterList", | |
11930 | filter->dlist[FILTER_OUT].name); | |
11931 | ||
11932 | /* filter-list. */ | |
11933 | if (filter->aslist[FILTER_IN].name) | |
11934 | json_object_string_add(json_addr, | |
11935 | "incomingUpdateAsPathFilterList", | |
11936 | filter->aslist[FILTER_IN].name); | |
11937 | if (filter->aslist[FILTER_OUT].name) | |
11938 | json_object_string_add(json_addr, | |
11939 | "outgoingUpdateAsPathFilterList", | |
11940 | filter->aslist[FILTER_OUT].name); | |
11941 | ||
11942 | /* route-map. */ | |
11943 | if (filter->map[RMAP_IN].name) | |
11944 | json_object_string_add( | |
11945 | json_addr, "routeMapForIncomingAdvertisements", | |
11946 | filter->map[RMAP_IN].name); | |
11947 | if (filter->map[RMAP_OUT].name) | |
11948 | json_object_string_add( | |
11949 | json_addr, "routeMapForOutgoingAdvertisements", | |
11950 | filter->map[RMAP_OUT].name); | |
11951 | ||
9dac9fc8 | 11952 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11953 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11954 | && !bgp_inbound_policy_exists(p, filter)) |
11955 | json_object_string_add( | |
11956 | json_addr, "inboundEbgpRequiresPolicy", | |
11957 | "Inbound updates discarded due to missing policy"); | |
11958 | ||
11959 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11960 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11961 | && (!bgp_outbound_policy_exists(p, filter))) |
11962 | json_object_string_add( | |
11963 | json_addr, "outboundEbgpRequiresPolicy", | |
11964 | "Outbound updates discarded due to missing policy"); | |
11965 | ||
d62a17ae | 11966 | /* unsuppress-map */ |
11967 | if (filter->usmap.name) | |
11968 | json_object_string_add(json_addr, | |
11969 | "selectiveUnsuppressRouteMap", | |
11970 | filter->usmap.name); | |
11971 | ||
fa36596c MK |
11972 | /* advertise-map */ |
11973 | if (filter->advmap.aname) { | |
11974 | json_advmap = json_object_new_object(); | |
11975 | json_object_string_add(json_advmap, "condition", | |
11976 | filter->advmap.condition | |
11977 | ? "EXIST" | |
11978 | : "NON_EXIST"); | |
11979 | json_object_string_add(json_advmap, "conditionMap", | |
11980 | filter->advmap.cname); | |
11981 | json_object_string_add(json_advmap, "advertiseMap", | |
11982 | filter->advmap.aname); | |
11983 | json_object_string_add(json_advmap, "advertiseStatus", | |
11984 | filter->advmap.update_type | |
11985 | == ADVERTISE | |
11986 | ? "Advertise" | |
11987 | : "Withdraw"); | |
11988 | json_object_object_add(json_addr, "advertiseMap", | |
11989 | json_advmap); | |
11990 | } | |
11991 | ||
d62a17ae | 11992 | /* Receive prefix count */ |
11993 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11994 | p->pcount[afi][safi]); | |
50e05855 AD |
11995 | if (paf && PAF_SUBGRP(paf)) |
11996 | json_object_int_add(json_addr, "sentPrefixCounter", | |
11997 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 11998 | |
fde246e8 DA |
11999 | /* Maximum prefix */ |
12000 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
12001 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
12002 | p->pmax_out[afi][safi]); | |
12003 | ||
d62a17ae | 12004 | /* Maximum prefix */ |
12005 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12006 | json_object_int_add(json_addr, "prefixAllowedMax", | |
12007 | p->pmax[afi][safi]); | |
12008 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12009 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
12010 | json_object_boolean_true_add( | |
12011 | json_addr, "prefixAllowedMaxWarning"); | |
12012 | json_object_int_add(json_addr, | |
12013 | "prefixAllowedWarningThresh", | |
12014 | p->pmax_threshold[afi][safi]); | |
12015 | if (p->pmax_restart[afi][safi]) | |
12016 | json_object_int_add( | |
12017 | json_addr, | |
12018 | "prefixAllowedRestartIntervalMsecs", | |
12019 | p->pmax_restart[afi][safi] * 60000); | |
12020 | } | |
2986cac2 | 12021 | json_object_object_add(json_neigh, |
36235319 | 12022 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 12023 | json_addr); |
12024 | ||
12025 | } else { | |
12026 | filter = &p->filter[afi][safi]; | |
12027 | ||
12028 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12029 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12030 | |
12031 | if (peer_group_active(p)) | |
12032 | vty_out(vty, " %s peer-group member\n", | |
12033 | p->group->name); | |
12034 | ||
12035 | paf = peer_af_find(p, afi, safi); | |
12036 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12037 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12038 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12039 | vty_out(vty, " Packet Queue length %d\n", | |
12040 | bpacket_queue_virtual_length(paf)); | |
12041 | } else { | |
12042 | vty_out(vty, " Not part of any update group\n"); | |
12043 | } | |
12044 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12045 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12046 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12047 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12048 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12049 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12050 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12051 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12052 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12053 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12054 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12055 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12056 | ||
12057 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12058 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12059 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12060 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12061 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12062 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12063 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12064 | vty_out(vty, | |
12065 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12066 | ORF_TYPE_PREFIX); | |
12067 | bgp_show_peer_afi_orf_cap( | |
12068 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12069 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12070 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12071 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12072 | } | |
12073 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12074 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12075 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12076 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12077 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12078 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12079 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12080 | vty_out(vty, | |
12081 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12082 | ORF_TYPE_PREFIX_OLD); | |
12083 | bgp_show_peer_afi_orf_cap( | |
12084 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12085 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12086 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12087 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12088 | } | |
12089 | ||
772270f3 QY |
12090 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12091 | p->host, afi, safi); | |
d62a17ae | 12092 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12093 | NULL, afi, orf_pfx_name, use_json); | |
12094 | ||
12095 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12096 | PEER_STATUS_ORF_PREFIX_SEND) | |
12097 | || orf_pfx_count) { | |
12098 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12099 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12100 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12101 | vty_out(vty, " sent;"); | |
12102 | if (orf_pfx_count) | |
12103 | vty_out(vty, " received (%d entries)", | |
12104 | orf_pfx_count); | |
12105 | vty_out(vty, "\n"); | |
12106 | } | |
12107 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12108 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12109 | vty_out(vty, | |
12110 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12111 | ||
12112 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12113 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12114 | vty_out(vty, " Route-Reflector Client\n"); | |
12115 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12116 | PEER_FLAG_RSERVER_CLIENT)) | |
12117 | vty_out(vty, " Route-Server Client\n"); | |
12118 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12119 | vty_out(vty, | |
12120 | " Inbound soft reconfiguration allowed\n"); | |
12121 | ||
12122 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12123 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12124 | vty_out(vty, | |
12125 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12126 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12127 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12128 | vty_out(vty, | |
12129 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12130 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12131 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12132 | vty_out(vty, | |
12133 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12134 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12135 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12136 | vty_out(vty, | |
12137 | " Private AS numbers removed in updates to this neighbor\n"); | |
12138 | ||
dcc68b5e MS |
12139 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12140 | vty_out(vty, " %s\n", | |
12141 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12142 | ->human_description); | |
d62a17ae | 12143 | |
12144 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12145 | vty_out(vty, | |
12146 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12147 | ||
12148 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12149 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12150 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12151 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12152 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12153 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12154 | vty_out(vty, | |
12155 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12156 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12157 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12158 | vty_out(vty, | |
12159 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12160 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12161 | vty_out(vty, | |
12162 | " MED is propagated unchanged to this neighbor\n"); | |
12163 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12164 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12165 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12166 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12167 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12168 | vty_out(vty, | |
12169 | " Community attribute sent to this neighbor"); | |
12170 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12171 | PEER_FLAG_SEND_COMMUNITY) | |
12172 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12173 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12174 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12175 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12176 | vty_out(vty, "(all)\n"); | |
12177 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12178 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12179 | vty_out(vty, "(large)\n"); | |
12180 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12181 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12182 | vty_out(vty, "(extended)\n"); | |
12183 | else | |
12184 | vty_out(vty, "(standard)\n"); | |
12185 | } | |
12186 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12187 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12188 | vty_out(vty, " Default information originate,"); | |
12189 | ||
12190 | if (p->default_rmap[afi][safi].name) | |
12191 | vty_out(vty, " default route-map %s%s,", | |
12192 | p->default_rmap[afi][safi].map ? "*" | |
12193 | : "", | |
12194 | p->default_rmap[afi][safi].name); | |
12195 | if (paf && PAF_SUBGRP(paf) | |
12196 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12197 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12198 | vty_out(vty, " default sent\n"); | |
12199 | else | |
12200 | vty_out(vty, " default not sent\n"); | |
12201 | } | |
12202 | ||
dff8f48d MK |
12203 | /* advertise-vni-all */ |
12204 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12205 | if (is_evpn_enabled()) |
dff8f48d MK |
12206 | vty_out(vty, " advertise-all-vni\n"); |
12207 | } | |
12208 | ||
d62a17ae | 12209 | if (filter->plist[FILTER_IN].name |
12210 | || filter->dlist[FILTER_IN].name | |
12211 | || filter->aslist[FILTER_IN].name | |
12212 | || filter->map[RMAP_IN].name) | |
12213 | vty_out(vty, " Inbound path policy configured\n"); | |
12214 | if (filter->plist[FILTER_OUT].name | |
12215 | || filter->dlist[FILTER_OUT].name | |
12216 | || filter->aslist[FILTER_OUT].name | |
12217 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12218 | vty_out(vty, " Outbound path policy configured\n"); | |
12219 | ||
12220 | /* prefix-list */ | |
12221 | if (filter->plist[FILTER_IN].name) | |
12222 | vty_out(vty, | |
12223 | " Incoming update prefix filter list is %s%s\n", | |
12224 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12225 | filter->plist[FILTER_IN].name); | |
12226 | if (filter->plist[FILTER_OUT].name) | |
12227 | vty_out(vty, | |
12228 | " Outgoing update prefix filter list is %s%s\n", | |
12229 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12230 | filter->plist[FILTER_OUT].name); | |
12231 | ||
12232 | /* distribute-list */ | |
12233 | if (filter->dlist[FILTER_IN].name) | |
12234 | vty_out(vty, | |
12235 | " Incoming update network filter list is %s%s\n", | |
12236 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12237 | filter->dlist[FILTER_IN].name); | |
12238 | if (filter->dlist[FILTER_OUT].name) | |
12239 | vty_out(vty, | |
12240 | " Outgoing update network filter list is %s%s\n", | |
12241 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12242 | filter->dlist[FILTER_OUT].name); | |
12243 | ||
12244 | /* filter-list. */ | |
12245 | if (filter->aslist[FILTER_IN].name) | |
12246 | vty_out(vty, | |
12247 | " Incoming update AS path filter list is %s%s\n", | |
12248 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12249 | filter->aslist[FILTER_IN].name); | |
12250 | if (filter->aslist[FILTER_OUT].name) | |
12251 | vty_out(vty, | |
12252 | " Outgoing update AS path filter list is %s%s\n", | |
12253 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12254 | filter->aslist[FILTER_OUT].name); | |
12255 | ||
12256 | /* route-map. */ | |
12257 | if (filter->map[RMAP_IN].name) | |
12258 | vty_out(vty, | |
12259 | " Route map for incoming advertisements is %s%s\n", | |
12260 | filter->map[RMAP_IN].map ? "*" : "", | |
12261 | filter->map[RMAP_IN].name); | |
12262 | if (filter->map[RMAP_OUT].name) | |
12263 | vty_out(vty, | |
12264 | " Route map for outgoing advertisements is %s%s\n", | |
12265 | filter->map[RMAP_OUT].map ? "*" : "", | |
12266 | filter->map[RMAP_OUT].name); | |
12267 | ||
9dac9fc8 | 12268 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12269 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12270 | && !bgp_inbound_policy_exists(p, filter)) |
12271 | vty_out(vty, | |
12272 | " Inbound updates discarded due to missing policy\n"); | |
12273 | ||
12274 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12275 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12276 | && !bgp_outbound_policy_exists(p, filter)) |
12277 | vty_out(vty, | |
12278 | " Outbound updates discarded due to missing policy\n"); | |
12279 | ||
d62a17ae | 12280 | /* unsuppress-map */ |
12281 | if (filter->usmap.name) | |
12282 | vty_out(vty, | |
12283 | " Route map for selective unsuppress is %s%s\n", | |
12284 | filter->usmap.map ? "*" : "", | |
12285 | filter->usmap.name); | |
12286 | ||
7f7940e6 MK |
12287 | /* advertise-map */ |
12288 | if (filter->advmap.aname && filter->advmap.cname) | |
12289 | vty_out(vty, | |
12290 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12291 | filter->advmap.condition ? "EXIST" | |
12292 | : "NON_EXIST", | |
12293 | filter->advmap.cmap ? "*" : "", | |
12294 | filter->advmap.cname, | |
12295 | filter->advmap.amap ? "*" : "", | |
12296 | filter->advmap.aname, | |
fa36596c | 12297 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
12298 | ? "Advertise" |
12299 | : "Withdraw"); | |
7f7940e6 | 12300 | |
d62a17ae | 12301 | /* Receive prefix count */ |
6cde4b45 | 12302 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12303 | p->pcount[afi][safi]); |
d62a17ae | 12304 | |
fde246e8 DA |
12305 | /* maximum-prefix-out */ |
12306 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12307 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12308 | vty_out(vty, | |
6cde4b45 | 12309 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12310 | p->pmax_out[afi][safi]); |
12311 | ||
d62a17ae | 12312 | /* Maximum prefix */ |
12313 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12314 | vty_out(vty, |
6cde4b45 | 12315 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12316 | p->pmax[afi][safi], |
12317 | CHECK_FLAG(p->af_flags[afi][safi], | |
12318 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12319 | ? " (warning-only)" | |
12320 | : ""); | |
12321 | vty_out(vty, " Threshold for warning message %d%%", | |
12322 | p->pmax_threshold[afi][safi]); | |
12323 | if (p->pmax_restart[afi][safi]) | |
12324 | vty_out(vty, ", restart interval %d min", | |
12325 | p->pmax_restart[afi][safi]); | |
12326 | vty_out(vty, "\n"); | |
12327 | } | |
12328 | ||
12329 | vty_out(vty, "\n"); | |
12330 | } | |
12331 | } | |
12332 | ||
9f049418 | 12333 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12334 | json_object *json) |
718e3744 | 12335 | { |
d62a17ae | 12336 | struct bgp *bgp; |
12337 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12338 | char timebuf[BGP_UPTIME_LEN]; | |
12339 | char dn_flag[2]; | |
d62a17ae | 12340 | afi_t afi; |
12341 | safi_t safi; | |
d7c0a89a QY |
12342 | uint16_t i; |
12343 | uint8_t *msg; | |
d62a17ae | 12344 | json_object *json_neigh = NULL; |
12345 | time_t epoch_tbuf; | |
718e3744 | 12346 | |
d62a17ae | 12347 | bgp = p->bgp; |
12348 | ||
12349 | if (use_json) | |
12350 | json_neigh = json_object_new_object(); | |
12351 | ||
12352 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12353 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12354 | dn_flag[0] = '*'; | |
12355 | ||
12356 | if (!use_json) { | |
12357 | if (p->conf_if) /* Configured interface name. */ | |
12358 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12359 | BGP_PEER_SU_UNSPEC(p) | |
12360 | ? "None" | |
12361 | : sockunion2str(&p->su, buf, | |
12362 | SU_ADDRSTRLEN)); | |
12363 | else /* Configured IP address. */ | |
12364 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12365 | p->host); | |
12366 | } | |
12367 | ||
12368 | if (use_json) { | |
12369 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12370 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12371 | "none"); | |
12372 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12373 | json_object_string_add( | |
12374 | json_neigh, "bgpNeighborAddr", | |
12375 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12376 | ||
12377 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12378 | ||
12379 | if (p->change_local_as) | |
12380 | json_object_int_add(json_neigh, "localAs", | |
12381 | p->change_local_as); | |
12382 | else | |
12383 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12384 | ||
12385 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12386 | json_object_boolean_true_add(json_neigh, | |
12387 | "localAsNoPrepend"); | |
12388 | ||
12389 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12390 | json_object_boolean_true_add(json_neigh, | |
12391 | "localAsReplaceAs"); | |
12392 | } else { | |
12393 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12394 | || (p->as_type == AS_INTERNAL)) | |
12395 | vty_out(vty, "remote AS %u, ", p->as); | |
12396 | else | |
12397 | vty_out(vty, "remote AS Unspecified, "); | |
12398 | vty_out(vty, "local AS %u%s%s, ", | |
12399 | p->change_local_as ? p->change_local_as : p->local_as, | |
12400 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12401 | ? " no-prepend" | |
12402 | : "", | |
12403 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12404 | ? " replace-as" | |
12405 | : ""); | |
12406 | } | |
faa16034 DS |
12407 | /* peer type internal or confed-internal */ |
12408 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12409 | if (use_json) { |
12410 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12411 | json_object_boolean_true_add( | |
12412 | json_neigh, "nbrConfedInternalLink"); | |
12413 | else | |
12414 | json_object_boolean_true_add(json_neigh, | |
12415 | "nbrInternalLink"); | |
12416 | } else { | |
12417 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12418 | vty_out(vty, "confed-internal link\n"); | |
12419 | else | |
12420 | vty_out(vty, "internal link\n"); | |
12421 | } | |
faa16034 DS |
12422 | /* peer type external or confed-external */ |
12423 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12424 | if (use_json) { |
12425 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12426 | json_object_boolean_true_add( | |
12427 | json_neigh, "nbrConfedExternalLink"); | |
12428 | else | |
12429 | json_object_boolean_true_add(json_neigh, | |
12430 | "nbrExternalLink"); | |
12431 | } else { | |
12432 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12433 | vty_out(vty, "confed-external link\n"); | |
12434 | else | |
12435 | vty_out(vty, "external link\n"); | |
12436 | } | |
faa16034 DS |
12437 | } else { |
12438 | if (use_json) | |
12439 | json_object_boolean_true_add(json_neigh, | |
12440 | "nbrUnspecifiedLink"); | |
12441 | else | |
12442 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12443 | } |
12444 | ||
12445 | /* Description. */ | |
12446 | if (p->desc) { | |
12447 | if (use_json) | |
12448 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12449 | else | |
12450 | vty_out(vty, " Description: %s\n", p->desc); | |
12451 | } | |
12452 | ||
12453 | if (p->hostname) { | |
12454 | if (use_json) { | |
12455 | if (p->hostname) | |
12456 | json_object_string_add(json_neigh, "hostname", | |
12457 | p->hostname); | |
12458 | ||
12459 | if (p->domainname) | |
12460 | json_object_string_add(json_neigh, "domainname", | |
12461 | p->domainname); | |
12462 | } else { | |
12463 | if (p->domainname && (p->domainname[0] != '\0')) | |
12464 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12465 | p->domainname); | |
12466 | else | |
12467 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12468 | } | |
12469 | } | |
12470 | ||
12471 | /* Peer-group */ | |
12472 | if (p->group) { | |
12473 | if (use_json) { | |
12474 | json_object_string_add(json_neigh, "peerGroup", | |
12475 | p->group->name); | |
12476 | ||
12477 | if (dn_flag[0]) { | |
12478 | struct prefix prefix, *range = NULL; | |
12479 | ||
0154d8ce DS |
12480 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12481 | range = peer_group_lookup_dynamic_neighbor_range( | |
12482 | p->group, &prefix); | |
d62a17ae | 12483 | |
12484 | if (range) { | |
12485 | prefix2str(range, buf1, sizeof(buf1)); | |
12486 | json_object_string_add( | |
12487 | json_neigh, | |
12488 | "peerSubnetRangeGroup", buf1); | |
12489 | } | |
12490 | } | |
12491 | } else { | |
12492 | vty_out(vty, | |
12493 | " Member of peer-group %s for session parameters\n", | |
12494 | p->group->name); | |
12495 | ||
12496 | if (dn_flag[0]) { | |
12497 | struct prefix prefix, *range = NULL; | |
12498 | ||
0154d8ce DS |
12499 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12500 | range = peer_group_lookup_dynamic_neighbor_range( | |
12501 | p->group, &prefix); | |
d62a17ae | 12502 | |
12503 | if (range) { | |
d62a17ae | 12504 | vty_out(vty, |
1b78780b DL |
12505 | " Belongs to the subnet range group: %pFX\n", |
12506 | range); | |
d62a17ae | 12507 | } |
12508 | } | |
12509 | } | |
12510 | } | |
12511 | ||
12512 | if (use_json) { | |
12513 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12514 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12515 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12516 | json_object_boolean_true_add(json_neigh, |
12517 | "adminShutDown"); | |
12518 | ||
12519 | /* BGP Version. */ | |
12520 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
12521 | json_object_string_add( | |
12522 | json_neigh, "remoteRouterId", | |
12523 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
12524 | json_object_string_add( |
12525 | json_neigh, "localRouterId", | |
12526 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12527 | sizeof(buf1))); | |
d62a17ae | 12528 | |
12529 | /* Confederation */ | |
12530 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12531 | && bgp_confederation_peers_check(bgp, p->as)) | |
12532 | json_object_boolean_true_add(json_neigh, | |
12533 | "nbrCommonAdmin"); | |
12534 | ||
12535 | /* Status. */ | |
12536 | json_object_string_add( | |
12537 | json_neigh, "bgpState", | |
12538 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12539 | ||
12540 | if (p->status == Established) { | |
12541 | time_t uptime; | |
d62a17ae | 12542 | |
12543 | uptime = bgp_clock(); | |
12544 | uptime -= p->uptime; | |
d62a17ae | 12545 | epoch_tbuf = time(NULL) - uptime; |
12546 | ||
d3c7efed DS |
12547 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
12548 | uptime * 1000); | |
d62a17ae | 12549 | json_object_string_add(json_neigh, "bgpTimerUpString", |
12550 | peer_uptime(p->uptime, timebuf, | |
12551 | BGP_UPTIME_LEN, 0, | |
12552 | NULL)); | |
12553 | json_object_int_add(json_neigh, | |
12554 | "bgpTimerUpEstablishedEpoch", | |
12555 | epoch_tbuf); | |
12556 | } | |
12557 | ||
12558 | else if (p->status == Active) { | |
12559 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12560 | json_object_string_add(json_neigh, "bgpStateIs", | |
12561 | "passive"); | |
12562 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12563 | json_object_string_add(json_neigh, "bgpStateIs", | |
12564 | "passiveNSF"); | |
12565 | } | |
12566 | ||
12567 | /* read timer */ | |
12568 | time_t uptime; | |
a2700b50 | 12569 | struct tm tm; |
d62a17ae | 12570 | |
12571 | uptime = bgp_clock(); | |
12572 | uptime -= p->readtime; | |
a2700b50 MS |
12573 | gmtime_r(&uptime, &tm); |
12574 | ||
d62a17ae | 12575 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
12576 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12577 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12578 | |
12579 | uptime = bgp_clock(); | |
12580 | uptime -= p->last_write; | |
a2700b50 MS |
12581 | gmtime_r(&uptime, &tm); |
12582 | ||
d62a17ae | 12583 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
12584 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12585 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12586 | |
12587 | uptime = bgp_clock(); | |
12588 | uptime -= p->update_time; | |
a2700b50 MS |
12589 | gmtime_r(&uptime, &tm); |
12590 | ||
d62a17ae | 12591 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
12592 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12593 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12594 | |
12595 | /* Configured timer values. */ | |
12596 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12597 | p->v_holdtime * 1000); | |
12598 | json_object_int_add(json_neigh, | |
12599 | "bgpTimerKeepAliveIntervalMsecs", | |
12600 | p->v_keepalive * 1000); | |
b90a8e13 | 12601 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12602 | json_object_int_add(json_neigh, |
12603 | "bgpTimerConfiguredHoldTimeMsecs", | |
12604 | p->holdtime * 1000); | |
12605 | json_object_int_add( | |
12606 | json_neigh, | |
12607 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12608 | p->keepalive * 1000); | |
5d5393b9 DL |
12609 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12610 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12611 | json_object_int_add(json_neigh, |
12612 | "bgpTimerConfiguredHoldTimeMsecs", | |
12613 | bgp->default_holdtime); | |
12614 | json_object_int_add( | |
12615 | json_neigh, | |
12616 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12617 | bgp->default_keepalive); | |
d62a17ae | 12618 | } |
12619 | } else { | |
12620 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12621 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12622 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12623 | vty_out(vty, " Administratively shut down\n"); |
12624 | ||
12625 | /* BGP Version. */ | |
12626 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 12627 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 12628 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
12629 | vty_out(vty, ", local router ID %s\n", |
12630 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12631 | sizeof(buf1))); | |
d62a17ae | 12632 | |
12633 | /* Confederation */ | |
12634 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12635 | && bgp_confederation_peers_check(bgp, p->as)) | |
12636 | vty_out(vty, | |
12637 | " Neighbor under common administration\n"); | |
12638 | ||
12639 | /* Status. */ | |
12640 | vty_out(vty, " BGP state = %s", | |
12641 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12642 | ||
12643 | if (p->status == Established) | |
12644 | vty_out(vty, ", up for %8s", | |
12645 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12646 | 0, NULL)); | |
12647 | ||
12648 | else if (p->status == Active) { | |
12649 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12650 | vty_out(vty, " (passive)"); | |
12651 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12652 | vty_out(vty, " (NSF passive)"); | |
12653 | } | |
12654 | vty_out(vty, "\n"); | |
12655 | ||
12656 | /* read timer */ | |
12657 | vty_out(vty, " Last read %s", | |
12658 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12659 | NULL)); | |
12660 | vty_out(vty, ", Last write %s\n", | |
12661 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12662 | NULL)); | |
12663 | ||
12664 | /* Configured timer values. */ | |
12665 | vty_out(vty, | |
12666 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12667 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 12668 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12669 | vty_out(vty, " Configured hold time is %d", |
12670 | p->holdtime); | |
12671 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12672 | p->keepalive); | |
5d5393b9 DL |
12673 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12674 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12675 | vty_out(vty, " Configured hold time is %d", |
12676 | bgp->default_holdtime); | |
12677 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12678 | bgp->default_keepalive); | |
d62a17ae | 12679 | } |
12680 | } | |
12681 | /* Capability. */ | |
12682 | if (p->status == Established) { | |
12683 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
12684 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
12685 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
12686 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
12687 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
12688 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
12689 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
12690 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
12691 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
12692 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
12693 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
12694 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 12695 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
12696 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 12697 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
12698 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 12699 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
12700 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 12701 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
12702 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
12703 | if (use_json) { | |
12704 | json_object *json_cap = NULL; | |
12705 | ||
12706 | json_cap = json_object_new_object(); | |
12707 | ||
12708 | /* AS4 */ | |
12709 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
12710 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12711 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
12712 | && CHECK_FLAG(p->cap, | |
12713 | PEER_CAP_AS4_RCV)) | |
12714 | json_object_string_add( | |
12715 | json_cap, "4byteAs", | |
12716 | "advertisedAndReceived"); | |
12717 | else if (CHECK_FLAG(p->cap, | |
12718 | PEER_CAP_AS4_ADV)) | |
12719 | json_object_string_add( | |
12720 | json_cap, "4byteAs", | |
12721 | "advertised"); | |
12722 | else if (CHECK_FLAG(p->cap, | |
12723 | PEER_CAP_AS4_RCV)) | |
12724 | json_object_string_add( | |
12725 | json_cap, "4byteAs", | |
12726 | "received"); | |
12727 | } | |
12728 | ||
12729 | /* AddPath */ | |
12730 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
12731 | || CHECK_FLAG(p->cap, | |
12732 | PEER_CAP_ADDPATH_ADV)) { | |
12733 | json_object *json_add = NULL; | |
12734 | const char *print_store; | |
12735 | ||
12736 | json_add = json_object_new_object(); | |
12737 | ||
05c7a1cc QY |
12738 | FOREACH_AFI_SAFI (afi, safi) { |
12739 | json_object *json_sub = NULL; | |
12740 | json_sub = | |
12741 | json_object_new_object(); | |
5cb5f4d0 DD |
12742 | print_store = get_afi_safi_str( |
12743 | afi, safi, true); | |
d62a17ae | 12744 | |
05c7a1cc QY |
12745 | if (CHECK_FLAG( |
12746 | p->af_cap[afi] | |
12747 | [safi], | |
12748 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12749 | || CHECK_FLAG( | |
12750 | p->af_cap[afi] | |
12751 | [safi], | |
12752 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 12753 | if (CHECK_FLAG( |
12754 | p->af_cap | |
12755 | [afi] | |
12756 | [safi], | |
12757 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 12758 | && CHECK_FLAG( |
d62a17ae | 12759 | p->af_cap |
12760 | [afi] | |
12761 | [safi], | |
05c7a1cc QY |
12762 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
12763 | json_object_boolean_true_add( | |
12764 | json_sub, | |
12765 | "txAdvertisedAndReceived"); | |
12766 | else if ( | |
12767 | CHECK_FLAG( | |
12768 | p->af_cap | |
12769 | [afi] | |
12770 | [safi], | |
12771 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
12772 | json_object_boolean_true_add( | |
12773 | json_sub, | |
12774 | "txAdvertised"); | |
12775 | else if ( | |
12776 | CHECK_FLAG( | |
12777 | p->af_cap | |
12778 | [afi] | |
12779 | [safi], | |
12780 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12781 | json_object_boolean_true_add( | |
12782 | json_sub, | |
12783 | "txReceived"); | |
12784 | } | |
d62a17ae | 12785 | |
05c7a1cc QY |
12786 | if (CHECK_FLAG( |
12787 | p->af_cap[afi] | |
12788 | [safi], | |
12789 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12790 | || CHECK_FLAG( | |
12791 | p->af_cap[afi] | |
12792 | [safi], | |
12793 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 12794 | if (CHECK_FLAG( |
12795 | p->af_cap | |
12796 | [afi] | |
12797 | [safi], | |
12798 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 12799 | && CHECK_FLAG( |
d62a17ae | 12800 | p->af_cap |
12801 | [afi] | |
12802 | [safi], | |
12803 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
12804 | json_object_boolean_true_add( |
12805 | json_sub, | |
12806 | "rxAdvertisedAndReceived"); | |
12807 | else if ( | |
12808 | CHECK_FLAG( | |
12809 | p->af_cap | |
12810 | [afi] | |
12811 | [safi], | |
12812 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
12813 | json_object_boolean_true_add( | |
12814 | json_sub, | |
12815 | "rxAdvertised"); | |
12816 | else if ( | |
12817 | CHECK_FLAG( | |
12818 | p->af_cap | |
12819 | [afi] | |
12820 | [safi], | |
12821 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12822 | json_object_boolean_true_add( | |
12823 | json_sub, | |
12824 | "rxReceived"); | |
d62a17ae | 12825 | } |
12826 | ||
05c7a1cc QY |
12827 | if (CHECK_FLAG( |
12828 | p->af_cap[afi] | |
12829 | [safi], | |
12830 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12831 | || CHECK_FLAG( | |
12832 | p->af_cap[afi] | |
12833 | [safi], | |
12834 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
12835 | || CHECK_FLAG( | |
12836 | p->af_cap[afi] | |
12837 | [safi], | |
12838 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12839 | || CHECK_FLAG( | |
12840 | p->af_cap[afi] | |
12841 | [safi], | |
12842 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12843 | json_object_object_add( | |
12844 | json_add, | |
12845 | print_store, | |
12846 | json_sub); | |
12847 | else | |
12848 | json_object_free( | |
12849 | json_sub); | |
12850 | } | |
12851 | ||
d62a17ae | 12852 | json_object_object_add( |
12853 | json_cap, "addPath", json_add); | |
12854 | } | |
12855 | ||
12856 | /* Dynamic */ | |
12857 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
12858 | || CHECK_FLAG(p->cap, | |
12859 | PEER_CAP_DYNAMIC_ADV)) { | |
12860 | if (CHECK_FLAG(p->cap, | |
12861 | PEER_CAP_DYNAMIC_ADV) | |
12862 | && CHECK_FLAG(p->cap, | |
12863 | PEER_CAP_DYNAMIC_RCV)) | |
12864 | json_object_string_add( | |
12865 | json_cap, "dynamic", | |
12866 | "advertisedAndReceived"); | |
12867 | else if (CHECK_FLAG( | |
12868 | p->cap, | |
12869 | PEER_CAP_DYNAMIC_ADV)) | |
12870 | json_object_string_add( | |
12871 | json_cap, "dynamic", | |
12872 | "advertised"); | |
12873 | else if (CHECK_FLAG( | |
12874 | p->cap, | |
12875 | PEER_CAP_DYNAMIC_RCV)) | |
12876 | json_object_string_add( | |
12877 | json_cap, "dynamic", | |
12878 | "received"); | |
12879 | } | |
12880 | ||
12881 | /* Extended nexthop */ | |
12882 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
12883 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12884 | json_object *json_nxt = NULL; | |
12885 | const char *print_store; | |
12886 | ||
12887 | ||
12888 | if (CHECK_FLAG(p->cap, | |
12889 | PEER_CAP_ENHE_ADV) | |
12890 | && CHECK_FLAG(p->cap, | |
12891 | PEER_CAP_ENHE_RCV)) | |
12892 | json_object_string_add( | |
12893 | json_cap, | |
12894 | "extendedNexthop", | |
12895 | "advertisedAndReceived"); | |
12896 | else if (CHECK_FLAG(p->cap, | |
12897 | PEER_CAP_ENHE_ADV)) | |
12898 | json_object_string_add( | |
12899 | json_cap, | |
12900 | "extendedNexthop", | |
12901 | "advertised"); | |
12902 | else if (CHECK_FLAG(p->cap, | |
12903 | PEER_CAP_ENHE_RCV)) | |
12904 | json_object_string_add( | |
12905 | json_cap, | |
12906 | "extendedNexthop", | |
12907 | "received"); | |
12908 | ||
12909 | if (CHECK_FLAG(p->cap, | |
12910 | PEER_CAP_ENHE_RCV)) { | |
12911 | json_nxt = | |
12912 | json_object_new_object(); | |
12913 | ||
12914 | for (safi = SAFI_UNICAST; | |
12915 | safi < SAFI_MAX; safi++) { | |
12916 | if (CHECK_FLAG( | |
12917 | p->af_cap | |
12918 | [AFI_IP] | |
12919 | [safi], | |
12920 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 12921 | print_store = get_afi_safi_str( |
d62a17ae | 12922 | AFI_IP, |
5cb5f4d0 | 12923 | safi, true); |
d62a17ae | 12924 | json_object_string_add( |
12925 | json_nxt, | |
12926 | print_store, | |
54f29523 | 12927 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 12928 | } |
12929 | } | |
12930 | json_object_object_add( | |
12931 | json_cap, | |
12932 | "extendedNexthopFamililesByPeer", | |
12933 | json_nxt); | |
12934 | } | |
12935 | } | |
12936 | ||
12937 | /* Route Refresh */ | |
12938 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12939 | || CHECK_FLAG(p->cap, | |
12940 | PEER_CAP_REFRESH_NEW_RCV) | |
12941 | || CHECK_FLAG(p->cap, | |
12942 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12943 | if (CHECK_FLAG(p->cap, | |
12944 | PEER_CAP_REFRESH_ADV) | |
12945 | && (CHECK_FLAG( | |
12946 | p->cap, | |
12947 | PEER_CAP_REFRESH_NEW_RCV) | |
12948 | || CHECK_FLAG( | |
12949 | p->cap, | |
12950 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12951 | if (CHECK_FLAG( | |
12952 | p->cap, | |
12953 | PEER_CAP_REFRESH_OLD_RCV) | |
12954 | && CHECK_FLAG( | |
12955 | p->cap, | |
12956 | PEER_CAP_REFRESH_NEW_RCV)) | |
12957 | json_object_string_add( | |
12958 | json_cap, | |
12959 | "routeRefresh", | |
12960 | "advertisedAndReceivedOldNew"); | |
12961 | else { | |
12962 | if (CHECK_FLAG( | |
12963 | p->cap, | |
12964 | PEER_CAP_REFRESH_OLD_RCV)) | |
12965 | json_object_string_add( | |
12966 | json_cap, | |
12967 | "routeRefresh", | |
12968 | "advertisedAndReceivedOld"); | |
12969 | else | |
12970 | json_object_string_add( | |
12971 | json_cap, | |
12972 | "routeRefresh", | |
12973 | "advertisedAndReceivedNew"); | |
12974 | } | |
12975 | } else if ( | |
12976 | CHECK_FLAG( | |
12977 | p->cap, | |
12978 | PEER_CAP_REFRESH_ADV)) | |
12979 | json_object_string_add( | |
12980 | json_cap, | |
12981 | "routeRefresh", | |
12982 | "advertised"); | |
12983 | else if ( | |
12984 | CHECK_FLAG( | |
12985 | p->cap, | |
12986 | PEER_CAP_REFRESH_NEW_RCV) | |
12987 | || CHECK_FLAG( | |
12988 | p->cap, | |
12989 | PEER_CAP_REFRESH_OLD_RCV)) | |
12990 | json_object_string_add( | |
12991 | json_cap, | |
12992 | "routeRefresh", | |
12993 | "received"); | |
12994 | } | |
12995 | ||
12996 | /* Multiprotocol Extensions */ | |
12997 | json_object *json_multi = NULL; | |
12998 | json_multi = json_object_new_object(); | |
12999 | ||
05c7a1cc QY |
13000 | FOREACH_AFI_SAFI (afi, safi) { |
13001 | if (p->afc_adv[afi][safi] | |
13002 | || p->afc_recv[afi][safi]) { | |
13003 | json_object *json_exten = NULL; | |
13004 | json_exten = | |
13005 | json_object_new_object(); | |
13006 | ||
d62a17ae | 13007 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
13008 | && p->afc_recv[afi][safi]) |
13009 | json_object_boolean_true_add( | |
13010 | json_exten, | |
13011 | "advertisedAndReceived"); | |
13012 | else if (p->afc_adv[afi][safi]) | |
13013 | json_object_boolean_true_add( | |
13014 | json_exten, | |
13015 | "advertised"); | |
13016 | else if (p->afc_recv[afi][safi]) | |
13017 | json_object_boolean_true_add( | |
13018 | json_exten, | |
13019 | "received"); | |
d62a17ae | 13020 | |
05c7a1cc QY |
13021 | json_object_object_add( |
13022 | json_multi, | |
5cb5f4d0 DD |
13023 | get_afi_safi_str(afi, |
13024 | safi, | |
13025 | true), | |
05c7a1cc | 13026 | json_exten); |
d62a17ae | 13027 | } |
13028 | } | |
13029 | json_object_object_add( | |
13030 | json_cap, "multiprotocolExtensions", | |
13031 | json_multi); | |
13032 | ||
d77114b7 | 13033 | /* Hostname capabilities */ |
60466a63 | 13034 | json_object *json_hname = NULL; |
d77114b7 MK |
13035 | |
13036 | json_hname = json_object_new_object(); | |
13037 | ||
13038 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
13039 | json_object_string_add( | |
60466a63 QY |
13040 | json_hname, "advHostName", |
13041 | bgp->peer_self->hostname | |
13042 | ? bgp->peer_self | |
13043 | ->hostname | |
d77114b7 MK |
13044 | : "n/a"); |
13045 | json_object_string_add( | |
60466a63 QY |
13046 | json_hname, "advDomainName", |
13047 | bgp->peer_self->domainname | |
13048 | ? bgp->peer_self | |
13049 | ->domainname | |
d77114b7 MK |
13050 | : "n/a"); |
13051 | } | |
13052 | ||
13053 | ||
13054 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
13055 | json_object_string_add( | |
60466a63 QY |
13056 | json_hname, "rcvHostName", |
13057 | p->hostname ? p->hostname | |
13058 | : "n/a"); | |
d77114b7 | 13059 | json_object_string_add( |
60466a63 QY |
13060 | json_hname, "rcvDomainName", |
13061 | p->domainname ? p->domainname | |
13062 | : "n/a"); | |
d77114b7 MK |
13063 | } |
13064 | ||
60466a63 | 13065 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
13066 | json_hname); |
13067 | ||
d62a17ae | 13068 | /* Gracefull Restart */ |
13069 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
13070 | || CHECK_FLAG(p->cap, | |
13071 | PEER_CAP_RESTART_ADV)) { | |
13072 | if (CHECK_FLAG(p->cap, | |
13073 | PEER_CAP_RESTART_ADV) | |
13074 | && CHECK_FLAG(p->cap, | |
13075 | PEER_CAP_RESTART_RCV)) | |
13076 | json_object_string_add( | |
13077 | json_cap, | |
13078 | "gracefulRestart", | |
13079 | "advertisedAndReceived"); | |
13080 | else if (CHECK_FLAG( | |
13081 | p->cap, | |
13082 | PEER_CAP_RESTART_ADV)) | |
13083 | json_object_string_add( | |
13084 | json_cap, | |
13085 | "gracefulRestartCapability", | |
13086 | "advertised"); | |
13087 | else if (CHECK_FLAG( | |
13088 | p->cap, | |
13089 | PEER_CAP_RESTART_RCV)) | |
13090 | json_object_string_add( | |
13091 | json_cap, | |
13092 | "gracefulRestartCapability", | |
13093 | "received"); | |
13094 | ||
13095 | if (CHECK_FLAG(p->cap, | |
13096 | PEER_CAP_RESTART_RCV)) { | |
13097 | int restart_af_count = 0; | |
13098 | json_object *json_restart = | |
13099 | NULL; | |
13100 | json_restart = | |
13101 | json_object_new_object(); | |
13102 | ||
13103 | json_object_int_add( | |
13104 | json_cap, | |
13105 | "gracefulRestartRemoteTimerMsecs", | |
13106 | p->v_gr_restart * 1000); | |
13107 | ||
05c7a1cc QY |
13108 | FOREACH_AFI_SAFI (afi, safi) { |
13109 | if (CHECK_FLAG( | |
13110 | p->af_cap | |
13111 | [afi] | |
13112 | [safi], | |
13113 | PEER_CAP_RESTART_AF_RCV)) { | |
13114 | json_object * | |
13115 | json_sub = | |
13116 | NULL; | |
13117 | json_sub = | |
13118 | json_object_new_object(); | |
13119 | ||
d62a17ae | 13120 | if (CHECK_FLAG( |
13121 | p->af_cap | |
13122 | [afi] | |
13123 | [safi], | |
05c7a1cc QY |
13124 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13125 | json_object_boolean_true_add( | |
13126 | json_sub, | |
13127 | "preserved"); | |
13128 | restart_af_count++; | |
13129 | json_object_object_add( | |
13130 | json_restart, | |
5cb5f4d0 | 13131 | get_afi_safi_str( |
05c7a1cc | 13132 | afi, |
5cb5f4d0 DD |
13133 | safi, |
13134 | true), | |
05c7a1cc | 13135 | json_sub); |
d62a17ae | 13136 | } |
13137 | } | |
13138 | if (!restart_af_count) { | |
13139 | json_object_string_add( | |
13140 | json_cap, | |
13141 | "addressFamiliesByPeer", | |
13142 | "none"); | |
13143 | json_object_free( | |
13144 | json_restart); | |
13145 | } else | |
13146 | json_object_object_add( | |
13147 | json_cap, | |
13148 | "addressFamiliesByPeer", | |
13149 | json_restart); | |
13150 | } | |
13151 | } | |
13152 | json_object_object_add(json_neigh, | |
13153 | "neighborCapabilities", | |
13154 | json_cap); | |
13155 | } else { | |
13156 | vty_out(vty, " Neighbor capabilities:\n"); | |
13157 | ||
13158 | /* AS4 */ | |
13159 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
13160 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13161 | vty_out(vty, " 4 Byte AS:"); | |
13162 | if (CHECK_FLAG(p->cap, | |
13163 | PEER_CAP_AS4_ADV)) | |
13164 | vty_out(vty, " advertised"); | |
13165 | if (CHECK_FLAG(p->cap, | |
13166 | PEER_CAP_AS4_RCV)) | |
13167 | vty_out(vty, " %sreceived", | |
13168 | CHECK_FLAG( | |
13169 | p->cap, | |
13170 | PEER_CAP_AS4_ADV) | |
13171 | ? "and " | |
13172 | : ""); | |
13173 | vty_out(vty, "\n"); | |
13174 | } | |
13175 | ||
13176 | /* AddPath */ | |
13177 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
13178 | || CHECK_FLAG(p->cap, | |
13179 | PEER_CAP_ADDPATH_ADV)) { | |
13180 | vty_out(vty, " AddPath:\n"); | |
13181 | ||
05c7a1cc QY |
13182 | FOREACH_AFI_SAFI (afi, safi) { |
13183 | if (CHECK_FLAG( | |
13184 | p->af_cap[afi] | |
13185 | [safi], | |
13186 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13187 | || CHECK_FLAG( | |
13188 | p->af_cap[afi] | |
13189 | [safi], | |
13190 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13191 | vty_out(vty, | |
13192 | " %s: TX ", | |
5cb5f4d0 | 13193 | get_afi_safi_str( |
05c7a1cc | 13194 | afi, |
5cb5f4d0 DD |
13195 | safi, |
13196 | false)); | |
05c7a1cc | 13197 | |
d62a17ae | 13198 | if (CHECK_FLAG( |
13199 | p->af_cap | |
13200 | [afi] | |
13201 | [safi], | |
05c7a1cc | 13202 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 13203 | vty_out(vty, |
05c7a1cc | 13204 | "advertised %s", |
5cb5f4d0 | 13205 | get_afi_safi_str( |
d62a17ae | 13206 | afi, |
5cb5f4d0 DD |
13207 | safi, |
13208 | false)); | |
d62a17ae | 13209 | |
05c7a1cc QY |
13210 | if (CHECK_FLAG( |
13211 | p->af_cap | |
13212 | [afi] | |
13213 | [safi], | |
13214 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13215 | vty_out(vty, | |
13216 | "%sreceived", | |
13217 | CHECK_FLAG( | |
13218 | p->af_cap | |
13219 | [afi] | |
13220 | [safi], | |
13221 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13222 | ? " and " | |
13223 | : ""); | |
d62a17ae | 13224 | |
05c7a1cc QY |
13225 | vty_out(vty, "\n"); |
13226 | } | |
d62a17ae | 13227 | |
05c7a1cc QY |
13228 | if (CHECK_FLAG( |
13229 | p->af_cap[afi] | |
13230 | [safi], | |
13231 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13232 | || CHECK_FLAG( | |
13233 | p->af_cap[afi] | |
13234 | [safi], | |
13235 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13236 | vty_out(vty, | |
13237 | " %s: RX ", | |
5cb5f4d0 | 13238 | get_afi_safi_str( |
05c7a1cc | 13239 | afi, |
5cb5f4d0 DD |
13240 | safi, |
13241 | false)); | |
d62a17ae | 13242 | |
13243 | if (CHECK_FLAG( | |
13244 | p->af_cap | |
13245 | [afi] | |
13246 | [safi], | |
05c7a1cc | 13247 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 13248 | vty_out(vty, |
05c7a1cc | 13249 | "advertised %s", |
5cb5f4d0 | 13250 | get_afi_safi_str( |
d62a17ae | 13251 | afi, |
5cb5f4d0 DD |
13252 | safi, |
13253 | false)); | |
d62a17ae | 13254 | |
05c7a1cc QY |
13255 | if (CHECK_FLAG( |
13256 | p->af_cap | |
13257 | [afi] | |
13258 | [safi], | |
13259 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 13260 | vty_out(vty, |
05c7a1cc QY |
13261 | "%sreceived", |
13262 | CHECK_FLAG( | |
13263 | p->af_cap | |
13264 | [afi] | |
13265 | [safi], | |
13266 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13267 | ? " and " | |
13268 | : ""); | |
13269 | ||
13270 | vty_out(vty, "\n"); | |
d62a17ae | 13271 | } |
05c7a1cc | 13272 | } |
d62a17ae | 13273 | } |
13274 | ||
13275 | /* Dynamic */ | |
13276 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
13277 | || CHECK_FLAG(p->cap, | |
13278 | PEER_CAP_DYNAMIC_ADV)) { | |
13279 | vty_out(vty, " Dynamic:"); | |
13280 | if (CHECK_FLAG(p->cap, | |
13281 | PEER_CAP_DYNAMIC_ADV)) | |
13282 | vty_out(vty, " advertised"); | |
13283 | if (CHECK_FLAG(p->cap, | |
13284 | PEER_CAP_DYNAMIC_RCV)) | |
13285 | vty_out(vty, " %sreceived", | |
13286 | CHECK_FLAG( | |
13287 | p->cap, | |
13288 | PEER_CAP_DYNAMIC_ADV) | |
13289 | ? "and " | |
13290 | : ""); | |
13291 | vty_out(vty, "\n"); | |
13292 | } | |
13293 | ||
13294 | /* Extended nexthop */ | |
13295 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
13296 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13297 | vty_out(vty, " Extended nexthop:"); | |
13298 | if (CHECK_FLAG(p->cap, | |
13299 | PEER_CAP_ENHE_ADV)) | |
13300 | vty_out(vty, " advertised"); | |
13301 | if (CHECK_FLAG(p->cap, | |
13302 | PEER_CAP_ENHE_RCV)) | |
13303 | vty_out(vty, " %sreceived", | |
13304 | CHECK_FLAG( | |
13305 | p->cap, | |
13306 | PEER_CAP_ENHE_ADV) | |
13307 | ? "and " | |
13308 | : ""); | |
13309 | vty_out(vty, "\n"); | |
13310 | ||
13311 | if (CHECK_FLAG(p->cap, | |
13312 | PEER_CAP_ENHE_RCV)) { | |
13313 | vty_out(vty, | |
13314 | " Address families by peer:\n "); | |
13315 | for (safi = SAFI_UNICAST; | |
13316 | safi < SAFI_MAX; safi++) | |
13317 | if (CHECK_FLAG( | |
13318 | p->af_cap | |
13319 | [AFI_IP] | |
13320 | [safi], | |
13321 | PEER_CAP_ENHE_AF_RCV)) | |
13322 | vty_out(vty, | |
13323 | " %s\n", | |
5cb5f4d0 | 13324 | get_afi_safi_str( |
d62a17ae | 13325 | AFI_IP, |
5cb5f4d0 DD |
13326 | safi, |
13327 | false)); | |
d62a17ae | 13328 | } |
13329 | } | |
13330 | ||
13331 | /* Route Refresh */ | |
13332 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
13333 | || CHECK_FLAG(p->cap, | |
13334 | PEER_CAP_REFRESH_NEW_RCV) | |
13335 | || CHECK_FLAG(p->cap, | |
13336 | PEER_CAP_REFRESH_OLD_RCV)) { | |
13337 | vty_out(vty, " Route refresh:"); | |
13338 | if (CHECK_FLAG(p->cap, | |
13339 | PEER_CAP_REFRESH_ADV)) | |
13340 | vty_out(vty, " advertised"); | |
13341 | if (CHECK_FLAG(p->cap, | |
13342 | PEER_CAP_REFRESH_NEW_RCV) | |
13343 | || CHECK_FLAG( | |
13344 | p->cap, | |
13345 | PEER_CAP_REFRESH_OLD_RCV)) | |
13346 | vty_out(vty, " %sreceived(%s)", | |
13347 | CHECK_FLAG( | |
13348 | p->cap, | |
13349 | PEER_CAP_REFRESH_ADV) | |
13350 | ? "and " | |
13351 | : "", | |
13352 | (CHECK_FLAG( | |
13353 | p->cap, | |
13354 | PEER_CAP_REFRESH_OLD_RCV) | |
13355 | && CHECK_FLAG( | |
13356 | p->cap, | |
13357 | PEER_CAP_REFRESH_NEW_RCV)) | |
13358 | ? "old & new" | |
13359 | : CHECK_FLAG( | |
13360 | p->cap, | |
13361 | PEER_CAP_REFRESH_OLD_RCV) | |
13362 | ? "old" | |
13363 | : "new"); | |
13364 | ||
13365 | vty_out(vty, "\n"); | |
13366 | } | |
13367 | ||
13368 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
13369 | FOREACH_AFI_SAFI (afi, safi) |
13370 | if (p->afc_adv[afi][safi] | |
13371 | || p->afc_recv[afi][safi]) { | |
13372 | vty_out(vty, | |
13373 | " Address Family %s:", | |
5cb5f4d0 DD |
13374 | get_afi_safi_str( |
13375 | afi, | |
13376 | safi, | |
13377 | false)); | |
05c7a1cc | 13378 | if (p->afc_adv[afi][safi]) |
d62a17ae | 13379 | vty_out(vty, |
05c7a1cc QY |
13380 | " advertised"); |
13381 | if (p->afc_recv[afi][safi]) | |
13382 | vty_out(vty, | |
13383 | " %sreceived", | |
13384 | p->afc_adv[afi] | |
13385 | [safi] | |
13386 | ? "and " | |
13387 | : ""); | |
13388 | vty_out(vty, "\n"); | |
13389 | } | |
d62a17ae | 13390 | |
13391 | /* Hostname capability */ | |
60466a63 | 13392 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
13393 | |
13394 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
13395 | vty_out(vty, |
13396 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
13397 | bgp->peer_self->hostname |
13398 | ? bgp->peer_self | |
13399 | ->hostname | |
d77114b7 | 13400 | : "n/a", |
60466a63 QY |
13401 | bgp->peer_self->domainname |
13402 | ? bgp->peer_self | |
13403 | ->domainname | |
d77114b7 MK |
13404 | : "n/a"); |
13405 | } else { | |
13406 | vty_out(vty, " not advertised"); | |
d62a17ae | 13407 | } |
13408 | ||
d77114b7 | 13409 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
13410 | vty_out(vty, |
13411 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
13412 | p->hostname ? p->hostname |
13413 | : "n/a", | |
13414 | p->domainname ? p->domainname | |
13415 | : "n/a"); | |
d77114b7 MK |
13416 | } else { |
13417 | vty_out(vty, " not received"); | |
13418 | } | |
13419 | ||
13420 | vty_out(vty, "\n"); | |
13421 | ||
61bfbd51 | 13422 | /* Graceful Restart */ |
d62a17ae | 13423 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
13424 | || CHECK_FLAG(p->cap, | |
13425 | PEER_CAP_RESTART_ADV)) { | |
13426 | vty_out(vty, | |
61bfbd51 | 13427 | " Graceful Restart Capability:"); |
d62a17ae | 13428 | if (CHECK_FLAG(p->cap, |
13429 | PEER_CAP_RESTART_ADV)) | |
13430 | vty_out(vty, " advertised"); | |
13431 | if (CHECK_FLAG(p->cap, | |
13432 | PEER_CAP_RESTART_RCV)) | |
13433 | vty_out(vty, " %sreceived", | |
13434 | CHECK_FLAG( | |
13435 | p->cap, | |
13436 | PEER_CAP_RESTART_ADV) | |
13437 | ? "and " | |
13438 | : ""); | |
13439 | vty_out(vty, "\n"); | |
13440 | ||
13441 | if (CHECK_FLAG(p->cap, | |
13442 | PEER_CAP_RESTART_RCV)) { | |
13443 | int restart_af_count = 0; | |
13444 | ||
13445 | vty_out(vty, | |
13446 | " Remote Restart timer is %d seconds\n", | |
13447 | p->v_gr_restart); | |
13448 | vty_out(vty, | |
13449 | " Address families by peer:\n "); | |
13450 | ||
05c7a1cc QY |
13451 | FOREACH_AFI_SAFI (afi, safi) |
13452 | if (CHECK_FLAG( | |
13453 | p->af_cap | |
13454 | [afi] | |
13455 | [safi], | |
13456 | PEER_CAP_RESTART_AF_RCV)) { | |
13457 | vty_out(vty, | |
13458 | "%s%s(%s)", | |
13459 | restart_af_count | |
13460 | ? ", " | |
13461 | : "", | |
5cb5f4d0 | 13462 | get_afi_safi_str( |
05c7a1cc | 13463 | afi, |
5cb5f4d0 DD |
13464 | safi, |
13465 | false), | |
05c7a1cc QY |
13466 | CHECK_FLAG( |
13467 | p->af_cap | |
13468 | [afi] | |
13469 | [safi], | |
13470 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13471 | ? "preserved" | |
13472 | : "not preserved"); | |
13473 | restart_af_count++; | |
13474 | } | |
d62a17ae | 13475 | if (!restart_af_count) |
13476 | vty_out(vty, "none"); | |
13477 | vty_out(vty, "\n"); | |
13478 | } | |
2986cac2 | 13479 | } /* Gracefull Restart */ |
d62a17ae | 13480 | } |
13481 | } | |
13482 | } | |
13483 | ||
13484 | /* graceful restart information */ | |
d62a17ae | 13485 | json_object *json_grace = NULL; |
13486 | json_object *json_grace_send = NULL; | |
13487 | json_object *json_grace_recv = NULL; | |
13488 | int eor_send_af_count = 0; | |
13489 | int eor_receive_af_count = 0; | |
13490 | ||
13491 | if (use_json) { | |
13492 | json_grace = json_object_new_object(); | |
13493 | json_grace_send = json_object_new_object(); | |
13494 | json_grace_recv = json_object_new_object(); | |
13495 | ||
36235319 QY |
13496 | if ((p->status == Established) |
13497 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
13498 | FOREACH_AFI_SAFI (afi, safi) { |
13499 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 13500 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
13501 | json_object_boolean_true_add( |
13502 | json_grace_send, | |
5cb5f4d0 DD |
13503 | get_afi_safi_str(afi, |
13504 | safi, | |
13505 | true)); | |
05c7a1cc | 13506 | eor_send_af_count++; |
d62a17ae | 13507 | } |
13508 | } | |
05c7a1cc QY |
13509 | FOREACH_AFI_SAFI (afi, safi) { |
13510 | if (CHECK_FLAG( | |
36235319 QY |
13511 | p->af_sflags[afi][safi], |
13512 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
13513 | json_object_boolean_true_add( |
13514 | json_grace_recv, | |
5cb5f4d0 DD |
13515 | get_afi_safi_str(afi, |
13516 | safi, | |
13517 | true)); | |
05c7a1cc | 13518 | eor_receive_af_count++; |
d62a17ae | 13519 | } |
13520 | } | |
13521 | } | |
36235319 QY |
13522 | json_object_object_add(json_grace, "endOfRibSend", |
13523 | json_grace_send); | |
13524 | json_object_object_add(json_grace, "endOfRibRecv", | |
13525 | json_grace_recv); | |
d62a17ae | 13526 | |
d62a17ae | 13527 | |
13528 | if (p->t_gr_restart) | |
13529 | json_object_int_add(json_grace, | |
13530 | "gracefulRestartTimerMsecs", | |
13531 | thread_timer_remain_second( | |
13532 | p->t_gr_restart) | |
13533 | * 1000); | |
13534 | ||
13535 | if (p->t_gr_stale) | |
13536 | json_object_int_add( | |
13537 | json_grace, | |
13538 | "gracefulStalepathTimerMsecs", | |
13539 | thread_timer_remain_second( | |
13540 | p->t_gr_stale) | |
13541 | * 1000); | |
2986cac2 | 13542 | /* more gr info in new format */ |
13543 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 13544 | json_grace); |
d62a17ae | 13545 | json_object_object_add( |
13546 | json_neigh, "gracefulRestartInfo", json_grace); | |
13547 | } else { | |
2089dd80 | 13548 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
13549 | if ((p->status == Established) |
13550 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 13551 | |
d62a17ae | 13552 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
13553 | FOREACH_AFI_SAFI (afi, safi) { |
13554 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13555 | PEER_STATUS_EOR_SEND)) { | |
13556 | vty_out(vty, "%s%s", | |
13557 | eor_send_af_count ? ", " | |
13558 | : "", | |
36235319 QY |
13559 | get_afi_safi_str( |
13560 | afi, safi, | |
13561 | false)); | |
05c7a1cc | 13562 | eor_send_af_count++; |
d62a17ae | 13563 | } |
13564 | } | |
13565 | vty_out(vty, "\n"); | |
13566 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
13567 | FOREACH_AFI_SAFI (afi, safi) { |
13568 | if (CHECK_FLAG( | |
13569 | p->af_sflags[afi][safi], | |
13570 | PEER_STATUS_EOR_RECEIVED)) { | |
13571 | vty_out(vty, "%s%s", | |
13572 | eor_receive_af_count | |
13573 | ? ", " | |
13574 | : "", | |
5cb5f4d0 DD |
13575 | get_afi_safi_str(afi, |
13576 | safi, | |
13577 | false)); | |
05c7a1cc | 13578 | eor_receive_af_count++; |
d62a17ae | 13579 | } |
13580 | } | |
13581 | vty_out(vty, "\n"); | |
13582 | } | |
13583 | ||
13584 | if (p->t_gr_restart) | |
13585 | vty_out(vty, | |
13586 | " The remaining time of restart timer is %ld\n", | |
13587 | thread_timer_remain_second( | |
13588 | p->t_gr_restart)); | |
13589 | ||
13590 | if (p->t_gr_stale) | |
13591 | vty_out(vty, | |
13592 | " The remaining time of stalepath timer is %ld\n", | |
13593 | thread_timer_remain_second( | |
13594 | p->t_gr_stale)); | |
2986cac2 | 13595 | |
13596 | /* more gr info in new format */ | |
13597 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 13598 | } |
2986cac2 | 13599 | |
d62a17ae | 13600 | if (use_json) { |
13601 | json_object *json_stat = NULL; | |
13602 | json_stat = json_object_new_object(); | |
13603 | /* Packet counts. */ | |
43aa5965 QY |
13604 | |
13605 | atomic_size_t outq_count, inq_count; | |
13606 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13607 | memory_order_relaxed); | |
13608 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13609 | memory_order_relaxed); | |
13610 | ||
13611 | json_object_int_add(json_stat, "depthInq", | |
13612 | (unsigned long)inq_count); | |
d62a17ae | 13613 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 13614 | (unsigned long)outq_count); |
0112e9e0 QY |
13615 | json_object_int_add(json_stat, "opensSent", |
13616 | atomic_load_explicit(&p->open_out, | |
13617 | memory_order_relaxed)); | |
13618 | json_object_int_add(json_stat, "opensRecv", | |
13619 | atomic_load_explicit(&p->open_in, | |
13620 | memory_order_relaxed)); | |
d62a17ae | 13621 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
13622 | atomic_load_explicit(&p->notify_out, |
13623 | memory_order_relaxed)); | |
d62a17ae | 13624 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
13625 | atomic_load_explicit(&p->notify_in, |
13626 | memory_order_relaxed)); | |
13627 | json_object_int_add(json_stat, "updatesSent", | |
13628 | atomic_load_explicit(&p->update_out, | |
13629 | memory_order_relaxed)); | |
13630 | json_object_int_add(json_stat, "updatesRecv", | |
13631 | atomic_load_explicit(&p->update_in, | |
13632 | memory_order_relaxed)); | |
d62a17ae | 13633 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
13634 | atomic_load_explicit(&p->keepalive_out, |
13635 | memory_order_relaxed)); | |
d62a17ae | 13636 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
13637 | atomic_load_explicit(&p->keepalive_in, |
13638 | memory_order_relaxed)); | |
d62a17ae | 13639 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
13640 | atomic_load_explicit(&p->refresh_out, |
13641 | memory_order_relaxed)); | |
d62a17ae | 13642 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
13643 | atomic_load_explicit(&p->refresh_in, |
13644 | memory_order_relaxed)); | |
d62a17ae | 13645 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
13646 | atomic_load_explicit(&p->dynamic_cap_out, |
13647 | memory_order_relaxed)); | |
d62a17ae | 13648 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
13649 | atomic_load_explicit(&p->dynamic_cap_in, |
13650 | memory_order_relaxed)); | |
13651 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13652 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 13653 | json_object_object_add(json_neigh, "messageStats", json_stat); |
13654 | } else { | |
43aa5965 QY |
13655 | atomic_size_t outq_count, inq_count; |
13656 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13657 | memory_order_relaxed); | |
13658 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13659 | memory_order_relaxed); | |
13660 | ||
d62a17ae | 13661 | /* Packet counts. */ |
13662 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
13663 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
13664 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 13665 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
13666 | vty_out(vty, " Opens: %10d %10d\n", |
13667 | atomic_load_explicit(&p->open_out, | |
13668 | memory_order_relaxed), | |
13669 | atomic_load_explicit(&p->open_in, | |
13670 | memory_order_relaxed)); | |
13671 | vty_out(vty, " Notifications: %10d %10d\n", | |
13672 | atomic_load_explicit(&p->notify_out, | |
13673 | memory_order_relaxed), | |
13674 | atomic_load_explicit(&p->notify_in, | |
13675 | memory_order_relaxed)); | |
13676 | vty_out(vty, " Updates: %10d %10d\n", | |
13677 | atomic_load_explicit(&p->update_out, | |
13678 | memory_order_relaxed), | |
13679 | atomic_load_explicit(&p->update_in, | |
13680 | memory_order_relaxed)); | |
13681 | vty_out(vty, " Keepalives: %10d %10d\n", | |
13682 | atomic_load_explicit(&p->keepalive_out, | |
13683 | memory_order_relaxed), | |
13684 | atomic_load_explicit(&p->keepalive_in, | |
13685 | memory_order_relaxed)); | |
13686 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
13687 | atomic_load_explicit(&p->refresh_out, | |
13688 | memory_order_relaxed), | |
13689 | atomic_load_explicit(&p->refresh_in, | |
13690 | memory_order_relaxed)); | |
d62a17ae | 13691 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
13692 | atomic_load_explicit(&p->dynamic_cap_out, |
13693 | memory_order_relaxed), | |
13694 | atomic_load_explicit(&p->dynamic_cap_in, | |
13695 | memory_order_relaxed)); | |
13696 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
13697 | PEER_TOTAL_RX(p)); | |
d62a17ae | 13698 | } |
13699 | ||
13700 | if (use_json) { | |
13701 | /* advertisement-interval */ | |
13702 | json_object_int_add(json_neigh, | |
13703 | "minBtwnAdvertisementRunsTimerMsecs", | |
13704 | p->v_routeadv * 1000); | |
13705 | ||
13706 | /* Update-source. */ | |
13707 | if (p->update_if || p->update_source) { | |
13708 | if (p->update_if) | |
13709 | json_object_string_add(json_neigh, | |
13710 | "updateSource", | |
13711 | p->update_if); | |
13712 | else if (p->update_source) | |
13713 | json_object_string_add( | |
13714 | json_neigh, "updateSource", | |
13715 | sockunion2str(p->update_source, buf1, | |
13716 | SU_ADDRSTRLEN)); | |
13717 | } | |
13718 | } else { | |
13719 | /* advertisement-interval */ | |
13720 | vty_out(vty, | |
13721 | " Minimum time between advertisement runs is %d seconds\n", | |
13722 | p->v_routeadv); | |
13723 | ||
13724 | /* Update-source. */ | |
13725 | if (p->update_if || p->update_source) { | |
13726 | vty_out(vty, " Update source is "); | |
13727 | if (p->update_if) | |
13728 | vty_out(vty, "%s", p->update_if); | |
13729 | else if (p->update_source) | |
13730 | vty_out(vty, "%s", | |
13731 | sockunion2str(p->update_source, buf1, | |
13732 | SU_ADDRSTRLEN)); | |
13733 | vty_out(vty, "\n"); | |
13734 | } | |
13735 | ||
13736 | vty_out(vty, "\n"); | |
13737 | } | |
13738 | ||
13739 | /* Address Family Information */ | |
13740 | json_object *json_hold = NULL; | |
13741 | ||
13742 | if (use_json) | |
13743 | json_hold = json_object_new_object(); | |
13744 | ||
05c7a1cc QY |
13745 | FOREACH_AFI_SAFI (afi, safi) |
13746 | if (p->afc[afi][safi]) | |
13747 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
13748 | json_hold); | |
d62a17ae | 13749 | |
13750 | if (use_json) { | |
13751 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
13752 | json_hold); | |
13753 | json_object_int_add(json_neigh, "connectionsEstablished", | |
13754 | p->established); | |
13755 | json_object_int_add(json_neigh, "connectionsDropped", | |
13756 | p->dropped); | |
13757 | } else | |
13758 | vty_out(vty, " Connections established %d; dropped %d\n", | |
13759 | p->established, p->dropped); | |
13760 | ||
13761 | if (!p->last_reset) { | |
13762 | if (use_json) | |
13763 | json_object_string_add(json_neigh, "lastReset", | |
13764 | "never"); | |
13765 | else | |
13766 | vty_out(vty, " Last reset never\n"); | |
13767 | } else { | |
13768 | if (use_json) { | |
13769 | time_t uptime; | |
a2700b50 | 13770 | struct tm tm; |
d62a17ae | 13771 | |
13772 | uptime = bgp_clock(); | |
13773 | uptime -= p->resettime; | |
a2700b50 MS |
13774 | gmtime_r(&uptime, &tm); |
13775 | ||
d62a17ae | 13776 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
13777 | (tm.tm_sec * 1000) |
13778 | + (tm.tm_min * 60000) | |
13779 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 13780 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 13781 | } else { |
13782 | vty_out(vty, " Last reset %s, ", | |
13783 | peer_uptime(p->resettime, timebuf, | |
13784 | BGP_UPTIME_LEN, 0, NULL)); | |
13785 | ||
3577f1c5 | 13786 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 13787 | if (p->last_reset_cause_size) { |
13788 | msg = p->last_reset_cause; | |
13789 | vty_out(vty, | |
13790 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
13791 | for (i = 1; i <= p->last_reset_cause_size; | |
13792 | i++) { | |
13793 | vty_out(vty, "%02X", *msg++); | |
13794 | ||
13795 | if (i != p->last_reset_cause_size) { | |
13796 | if (i % 16 == 0) { | |
13797 | vty_out(vty, "\n "); | |
13798 | } else if (i % 4 == 0) { | |
13799 | vty_out(vty, " "); | |
13800 | } | |
13801 | } | |
13802 | } | |
13803 | vty_out(vty, "\n"); | |
13804 | } | |
13805 | } | |
13806 | } | |
13807 | ||
13808 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
13809 | if (use_json) | |
13810 | json_object_boolean_true_add(json_neigh, | |
13811 | "prefixesConfigExceedMax"); | |
13812 | else | |
13813 | vty_out(vty, | |
13814 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
13815 | ||
13816 | if (p->t_pmax_restart) { | |
13817 | if (use_json) { | |
13818 | json_object_boolean_true_add( | |
13819 | json_neigh, "reducePrefixNumFrom"); | |
13820 | json_object_int_add(json_neigh, | |
13821 | "restartInTimerMsec", | |
13822 | thread_timer_remain_second( | |
13823 | p->t_pmax_restart) | |
13824 | * 1000); | |
13825 | } else | |
13826 | vty_out(vty, | |
13827 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
13828 | p->host, thread_timer_remain_second( |
13829 | p->t_pmax_restart)); | |
d62a17ae | 13830 | } else { |
13831 | if (use_json) | |
13832 | json_object_boolean_true_add( | |
13833 | json_neigh, | |
13834 | "reducePrefixNumAndClearIpBgp"); | |
13835 | else | |
13836 | vty_out(vty, | |
13837 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
13838 | p->host); | |
13839 | } | |
13840 | } | |
13841 | ||
13842 | /* EBGP Multihop and GTSM */ | |
13843 | if (p->sort != BGP_PEER_IBGP) { | |
13844 | if (use_json) { | |
e2521429 | 13845 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13846 | json_object_int_add(json_neigh, |
13847 | "externalBgpNbrMaxHopsAway", | |
13848 | p->gtsm_hops); | |
c8d6f0d6 | 13849 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13850 | json_object_int_add(json_neigh, |
13851 | "externalBgpNbrMaxHopsAway", | |
13852 | p->ttl); | |
13853 | } else { | |
e2521429 | 13854 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13855 | vty_out(vty, |
13856 | " External BGP neighbor may be up to %d hops away.\n", | |
13857 | p->gtsm_hops); | |
c8d6f0d6 | 13858 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13859 | vty_out(vty, |
13860 | " External BGP neighbor may be up to %d hops away.\n", | |
13861 | p->ttl); | |
13862 | } | |
13863 | } else { | |
e2521429 | 13864 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 13865 | if (use_json) |
13866 | json_object_int_add(json_neigh, | |
13867 | "internalBgpNbrMaxHopsAway", | |
13868 | p->gtsm_hops); | |
13869 | else | |
13870 | vty_out(vty, | |
13871 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13872 | p->gtsm_hops); | |
13873 | } | |
13874 | } | |
13875 | ||
13876 | /* Local address. */ | |
13877 | if (p->su_local) { | |
13878 | if (use_json) { | |
13879 | json_object_string_add(json_neigh, "hostLocal", | |
13880 | sockunion2str(p->su_local, buf1, | |
13881 | SU_ADDRSTRLEN)); | |
13882 | json_object_int_add(json_neigh, "portLocal", | |
13883 | ntohs(p->su_local->sin.sin_port)); | |
13884 | } else | |
13885 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13886 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
13887 | ntohs(p->su_local->sin.sin_port)); | |
13888 | } | |
13889 | ||
13890 | /* Remote address. */ | |
13891 | if (p->su_remote) { | |
13892 | if (use_json) { | |
13893 | json_object_string_add(json_neigh, "hostForeign", | |
13894 | sockunion2str(p->su_remote, buf1, | |
13895 | SU_ADDRSTRLEN)); | |
13896 | json_object_int_add(json_neigh, "portForeign", | |
13897 | ntohs(p->su_remote->sin.sin_port)); | |
13898 | } else | |
13899 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
13900 | sockunion2str(p->su_remote, buf1, | |
13901 | SU_ADDRSTRLEN), | |
13902 | ntohs(p->su_remote->sin.sin_port)); | |
13903 | } | |
13904 | ||
13905 | /* Nexthop display. */ | |
13906 | if (p->su_local) { | |
13907 | if (use_json) { | |
13908 | json_object_string_add(json_neigh, "nexthop", | |
13909 | inet_ntop(AF_INET, | |
13910 | &p->nexthop.v4, buf1, | |
13911 | sizeof(buf1))); | |
13912 | json_object_string_add(json_neigh, "nexthopGlobal", | |
13913 | inet_ntop(AF_INET6, | |
13914 | &p->nexthop.v6_global, | |
13915 | buf1, sizeof(buf1))); | |
13916 | json_object_string_add(json_neigh, "nexthopLocal", | |
13917 | inet_ntop(AF_INET6, | |
13918 | &p->nexthop.v6_local, | |
13919 | buf1, sizeof(buf1))); | |
13920 | if (p->shared_network) | |
13921 | json_object_string_add(json_neigh, | |
13922 | "bgpConnection", | |
13923 | "sharedNetwork"); | |
13924 | else | |
13925 | json_object_string_add(json_neigh, | |
13926 | "bgpConnection", | |
13927 | "nonSharedNetwork"); | |
13928 | } else { | |
13929 | vty_out(vty, "Nexthop: %s\n", | |
13930 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
13931 | sizeof(buf1))); | |
13932 | vty_out(vty, "Nexthop global: %s\n", | |
13933 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
13934 | sizeof(buf1))); | |
13935 | vty_out(vty, "Nexthop local: %s\n", | |
13936 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
13937 | sizeof(buf1))); | |
13938 | vty_out(vty, "BGP connection: %s\n", | |
13939 | p->shared_network ? "shared network" | |
13940 | : "non shared network"); | |
13941 | } | |
13942 | } | |
13943 | ||
13944 | /* Timer information. */ | |
13945 | if (use_json) { | |
13946 | json_object_int_add(json_neigh, "connectRetryTimer", | |
13947 | p->v_connect); | |
13948 | if (p->status == Established && p->rtt) | |
13949 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
13950 | p->rtt); | |
13951 | if (p->t_start) | |
13952 | json_object_int_add( | |
13953 | json_neigh, "nextStartTimerDueInMsecs", | |
13954 | thread_timer_remain_second(p->t_start) * 1000); | |
13955 | if (p->t_connect) | |
13956 | json_object_int_add( | |
13957 | json_neigh, "nextConnectTimerDueInMsecs", | |
13958 | thread_timer_remain_second(p->t_connect) | |
13959 | * 1000); | |
13960 | if (p->t_routeadv) { | |
13961 | json_object_int_add(json_neigh, "mraiInterval", | |
13962 | p->v_routeadv); | |
13963 | json_object_int_add( | |
13964 | json_neigh, "mraiTimerExpireInMsecs", | |
13965 | thread_timer_remain_second(p->t_routeadv) | |
13966 | * 1000); | |
13967 | } | |
13968 | if (p->password) | |
13969 | json_object_int_add(json_neigh, "authenticationEnabled", | |
13970 | 1); | |
13971 | ||
13972 | if (p->t_read) | |
13973 | json_object_string_add(json_neigh, "readThread", "on"); | |
13974 | else | |
13975 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
13976 | |
13977 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 13978 | json_object_string_add(json_neigh, "writeThread", "on"); |
13979 | else | |
13980 | json_object_string_add(json_neigh, "writeThread", | |
13981 | "off"); | |
13982 | } else { | |
13983 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
13984 | p->v_connect); | |
13985 | if (p->status == Established && p->rtt) | |
13986 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
13987 | p->rtt); | |
13988 | if (p->t_start) | |
13989 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
13990 | thread_timer_remain_second(p->t_start)); | |
13991 | if (p->t_connect) | |
13992 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
13993 | thread_timer_remain_second(p->t_connect)); | |
13994 | if (p->t_routeadv) | |
13995 | vty_out(vty, | |
13996 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
13997 | p->v_routeadv, | |
13998 | thread_timer_remain_second(p->t_routeadv)); | |
13999 | if (p->password) | |
14000 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14001 | ||
cac9e917 | 14002 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14003 | p->t_read ? "on" : "off", |
14004 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14005 | ? "on" | |
cac9e917 | 14006 | : "off", p->fd); |
d62a17ae | 14007 | } |
14008 | ||
14009 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14010 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14011 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14012 | ||
14013 | if (!use_json) | |
14014 | vty_out(vty, "\n"); | |
14015 | ||
14016 | /* BFD information. */ | |
14017 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
14018 | ||
14019 | if (use_json) { | |
14020 | if (p->conf_if) /* Configured interface name. */ | |
14021 | json_object_object_add(json, p->conf_if, json_neigh); | |
14022 | else /* Configured IP address. */ | |
14023 | json_object_object_add(json, p->host, json_neigh); | |
14024 | } | |
14025 | } | |
14026 | ||
36235319 QY |
14027 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14028 | enum show_type type, | |
14029 | union sockunion *su, | |
14030 | const char *conf_if, afi_t afi, | |
74a630b6 | 14031 | bool use_json) |
2986cac2 | 14032 | { |
14033 | struct listnode *node, *nnode; | |
14034 | struct peer *peer; | |
14035 | int find = 0; | |
14036 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 14037 | json_object *json = NULL; |
2986cac2 | 14038 | json_object *json_neighbor = NULL; |
14039 | ||
74a630b6 NT |
14040 | if (use_json) { |
14041 | json = json_object_new_object(); | |
14042 | json_neighbor = json_object_new_object(); | |
14043 | } | |
14044 | ||
2986cac2 | 14045 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
14046 | ||
14047 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14048 | continue; | |
14049 | ||
14050 | if ((peer->afc[afi][safi]) == 0) | |
14051 | continue; | |
14052 | ||
2ba1fe69 | 14053 | if (type == show_all) { |
2986cac2 | 14054 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 14055 | json_neighbor); |
2986cac2 | 14056 | |
74a630b6 | 14057 | if (use_json) { |
13909c4f DS |
14058 | json_object_object_add(json, peer->host, |
14059 | json_neighbor); | |
74a630b6 NT |
14060 | json_neighbor = NULL; |
14061 | } | |
2986cac2 | 14062 | |
2ba1fe69 | 14063 | } else if (type == show_peer) { |
2986cac2 | 14064 | if (conf_if) { |
14065 | if ((peer->conf_if | |
13909c4f DS |
14066 | && !strcmp(peer->conf_if, conf_if)) |
14067 | || (peer->hostname | |
2986cac2 | 14068 | && !strcmp(peer->hostname, conf_if))) { |
14069 | find = 1; | |
13909c4f DS |
14070 | bgp_show_peer_gr_status(vty, peer, |
14071 | use_json, | |
14072 | json_neighbor); | |
2986cac2 | 14073 | } |
14074 | } else { | |
14075 | if (sockunion_same(&peer->su, su)) { | |
14076 | find = 1; | |
13909c4f DS |
14077 | bgp_show_peer_gr_status(vty, peer, |
14078 | use_json, | |
14079 | json_neighbor); | |
2986cac2 | 14080 | } |
14081 | } | |
13909c4f DS |
14082 | if (use_json && find) |
14083 | json_object_object_add(json, peer->host, | |
14084 | json_neighbor); | |
2986cac2 | 14085 | } |
14086 | ||
74a630b6 NT |
14087 | if (find) { |
14088 | json_neighbor = NULL; | |
2986cac2 | 14089 | break; |
74a630b6 | 14090 | } |
2986cac2 | 14091 | } |
14092 | ||
14093 | if (type == show_peer && !find) { | |
14094 | if (use_json) | |
13909c4f | 14095 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14096 | else |
14097 | vty_out(vty, "%% No such neighbor\n"); | |
14098 | } | |
14099 | if (use_json) { | |
13909c4f DS |
14100 | vty_out(vty, "%s\n", |
14101 | json_object_to_json_string_ext( | |
14102 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
14103 | |
14104 | if (json_neighbor) | |
14105 | json_object_free(json_neighbor); | |
14106 | json_object_free(json); | |
2986cac2 | 14107 | } else { |
14108 | vty_out(vty, "\n"); | |
14109 | } | |
14110 | ||
14111 | return CMD_SUCCESS; | |
14112 | } | |
14113 | ||
d62a17ae | 14114 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14115 | enum show_type type, union sockunion *su, | |
9f049418 | 14116 | const char *conf_if, bool use_json, |
d62a17ae | 14117 | json_object *json) |
14118 | { | |
14119 | struct listnode *node, *nnode; | |
14120 | struct peer *peer; | |
14121 | int find = 0; | |
9f049418 | 14122 | bool nbr_output = false; |
d1927ebe AS |
14123 | afi_t afi = AFI_MAX; |
14124 | safi_t safi = SAFI_MAX; | |
14125 | ||
14126 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14127 | afi = AFI_IP; | |
14128 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14129 | afi = AFI_IP6; | |
14130 | } | |
d62a17ae | 14131 | |
14132 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14133 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14134 | continue; | |
14135 | ||
14136 | switch (type) { | |
14137 | case show_all: | |
14138 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14139 | nbr_output = true; |
d62a17ae | 14140 | break; |
14141 | case show_peer: | |
14142 | if (conf_if) { | |
14143 | if ((peer->conf_if | |
14144 | && !strcmp(peer->conf_if, conf_if)) | |
14145 | || (peer->hostname | |
14146 | && !strcmp(peer->hostname, conf_if))) { | |
14147 | find = 1; | |
14148 | bgp_show_peer(vty, peer, use_json, | |
14149 | json); | |
14150 | } | |
14151 | } else { | |
14152 | if (sockunion_same(&peer->su, su)) { | |
14153 | find = 1; | |
14154 | bgp_show_peer(vty, peer, use_json, | |
14155 | json); | |
14156 | } | |
14157 | } | |
14158 | break; | |
d1927ebe AS |
14159 | case show_ipv4_peer: |
14160 | case show_ipv6_peer: | |
14161 | FOREACH_SAFI (safi) { | |
14162 | if (peer->afc[afi][safi]) { | |
14163 | if (conf_if) { | |
14164 | if ((peer->conf_if | |
14165 | && !strcmp(peer->conf_if, conf_if)) | |
14166 | || (peer->hostname | |
14167 | && !strcmp(peer->hostname, conf_if))) { | |
14168 | find = 1; | |
14169 | bgp_show_peer(vty, peer, use_json, | |
14170 | json); | |
14171 | break; | |
14172 | } | |
14173 | } else { | |
14174 | if (sockunion_same(&peer->su, su)) { | |
14175 | find = 1; | |
14176 | bgp_show_peer(vty, peer, use_json, | |
14177 | json); | |
14178 | break; | |
14179 | } | |
14180 | } | |
14181 | } | |
14182 | } | |
14183 | break; | |
14184 | case show_ipv4_all: | |
14185 | case show_ipv6_all: | |
14186 | FOREACH_SAFI (safi) { | |
14187 | if (peer->afc[afi][safi]) { | |
14188 | bgp_show_peer(vty, peer, use_json, json); | |
14189 | nbr_output = true; | |
14190 | break; | |
14191 | } | |
14192 | } | |
14193 | break; | |
d62a17ae | 14194 | } |
14195 | } | |
14196 | ||
d1927ebe AS |
14197 | if ((type == show_peer || type == show_ipv4_peer || |
14198 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14199 | if (use_json) |
14200 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14201 | else | |
88b7d255 | 14202 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14203 | } |
14204 | ||
d1927ebe AS |
14205 | if (type != show_peer && type != show_ipv4_peer && |
14206 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14207 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14208 | |
d62a17ae | 14209 | if (use_json) { |
996c9314 LB |
14210 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14211 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14212 | } else { |
14213 | vty_out(vty, "\n"); | |
14214 | } | |
14215 | ||
14216 | return CMD_SUCCESS; | |
14217 | } | |
14218 | ||
36235319 QY |
14219 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14220 | enum show_type type, | |
14221 | const char *ip_str, | |
14222 | afi_t afi, bool use_json) | |
2986cac2 | 14223 | { |
14224 | ||
14225 | int ret; | |
14226 | struct bgp *bgp; | |
14227 | union sockunion su; | |
2986cac2 | 14228 | |
14229 | bgp = bgp_get_default(); | |
14230 | ||
13909c4f DS |
14231 | if (!bgp) |
14232 | return; | |
2986cac2 | 14233 | |
13909c4f DS |
14234 | if (!use_json) |
14235 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14236 | NULL); | |
2986cac2 | 14237 | |
13909c4f DS |
14238 | if (ip_str) { |
14239 | ret = str2sockunion(ip_str, &su); | |
14240 | if (ret < 0) | |
13909c4f | 14241 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14242 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14243 | else | |
14244 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14245 | NULL, afi, use_json); | |
13909c4f DS |
14246 | } else |
14247 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14248 | afi, use_json); |
2986cac2 | 14249 | } |
14250 | ||
d62a17ae | 14251 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14252 | enum show_type type, |
14253 | const char *ip_str, | |
9f049418 | 14254 | bool use_json) |
d62a17ae | 14255 | { |
0291c246 MK |
14256 | struct listnode *node, *nnode; |
14257 | struct bgp *bgp; | |
71aedaa3 | 14258 | union sockunion su; |
0291c246 | 14259 | json_object *json = NULL; |
71aedaa3 | 14260 | int ret, is_first = 1; |
9f049418 | 14261 | bool nbr_output = false; |
d62a17ae | 14262 | |
14263 | if (use_json) | |
14264 | vty_out(vty, "{\n"); | |
14265 | ||
14266 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14267 | nbr_output = true; |
d62a17ae | 14268 | if (use_json) { |
14269 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14270 | flog_err( |
e50f7cfd | 14271 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14272 | "Unable to allocate memory for JSON object"); |
14273 | vty_out(vty, | |
14274 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14275 | return; | |
14276 | } | |
14277 | ||
14278 | json_object_int_add(json, "vrfId", | |
14279 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14280 | ? -1 |
14281 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14282 | json_object_string_add( |
14283 | json, "vrfName", | |
14284 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14285 | ? VRF_DEFAULT_NAME |
d62a17ae | 14286 | : bgp->name); |
14287 | ||
14288 | if (!is_first) | |
14289 | vty_out(vty, ",\n"); | |
14290 | else | |
14291 | is_first = 0; | |
14292 | ||
14293 | vty_out(vty, "\"%s\":", | |
14294 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14295 | ? VRF_DEFAULT_NAME |
d62a17ae | 14296 | : bgp->name); |
14297 | } else { | |
14298 | vty_out(vty, "\nInstance %s:\n", | |
14299 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14300 | ? VRF_DEFAULT_NAME |
d62a17ae | 14301 | : bgp->name); |
14302 | } | |
71aedaa3 | 14303 | |
d1927ebe AS |
14304 | if (type == show_peer || type == show_ipv4_peer || |
14305 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14306 | ret = str2sockunion(ip_str, &su); |
14307 | if (ret < 0) | |
14308 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14309 | use_json, json); | |
14310 | else | |
14311 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14312 | use_json, json); | |
14313 | } else { | |
d1927ebe | 14314 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14315 | use_json, json); |
14316 | } | |
b77004d6 | 14317 | json_object_free(json); |
121067e9 | 14318 | json = NULL; |
d62a17ae | 14319 | } |
14320 | ||
3e78a6ce | 14321 | if (use_json) |
d62a17ae | 14322 | vty_out(vty, "}\n"); |
9f049418 DS |
14323 | else if (!nbr_output) |
14324 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14325 | } |
14326 | ||
14327 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14328 | enum show_type type, const char *ip_str, | |
9f049418 | 14329 | bool use_json) |
d62a17ae | 14330 | { |
14331 | int ret; | |
14332 | struct bgp *bgp; | |
14333 | union sockunion su; | |
14334 | json_object *json = NULL; | |
14335 | ||
14336 | if (name) { | |
14337 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14338 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14339 | use_json); | |
d62a17ae | 14340 | return CMD_SUCCESS; |
14341 | } else { | |
14342 | bgp = bgp_lookup_by_name(name); | |
14343 | if (!bgp) { | |
14344 | if (use_json) { | |
14345 | json = json_object_new_object(); | |
d62a17ae | 14346 | vty_out(vty, "%s\n", |
14347 | json_object_to_json_string_ext( | |
14348 | json, | |
14349 | JSON_C_TO_STRING_PRETTY)); | |
14350 | json_object_free(json); | |
14351 | } else | |
14352 | vty_out(vty, | |
9f049418 | 14353 | "%% BGP instance not found\n"); |
d62a17ae | 14354 | |
14355 | return CMD_WARNING; | |
14356 | } | |
14357 | } | |
14358 | } else { | |
14359 | bgp = bgp_get_default(); | |
14360 | } | |
14361 | ||
14362 | if (bgp) { | |
14363 | json = json_object_new_object(); | |
14364 | if (ip_str) { | |
14365 | ret = str2sockunion(ip_str, &su); | |
14366 | if (ret < 0) | |
14367 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14368 | use_json, json); | |
14369 | else | |
14370 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14371 | use_json, json); | |
14372 | } else { | |
14373 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14374 | json); | |
14375 | } | |
14376 | json_object_free(json); | |
ca61fd25 DS |
14377 | } else { |
14378 | if (use_json) | |
14379 | vty_out(vty, "{}\n"); | |
14380 | else | |
14381 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14382 | } |
14383 | ||
14384 | return CMD_SUCCESS; | |
4fb25c53 DW |
14385 | } |
14386 | ||
2986cac2 | 14387 | |
14388 | ||
14389 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14390 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14391 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14392 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14393 | SHOW_STR | |
14394 | BGP_STR | |
14395 | IP_STR | |
14396 | IPV6_STR | |
14397 | NEIGHBOR_STR | |
14398 | "Neighbor to display information about\n" | |
14399 | "Neighbor to display information about\n" | |
14400 | "Neighbor on BGP configured interface\n" | |
14401 | GR_SHOW | |
14402 | JSON_STR) | |
14403 | { | |
14404 | char *sh_arg = NULL; | |
14405 | enum show_type sh_type; | |
14406 | int idx = 0; | |
14407 | afi_t afi = AFI_MAX; | |
2986cac2 | 14408 | bool uj = use_json(argc, argv); |
14409 | ||
36235319 | 14410 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 14411 | afi = AFI_MAX; |
14412 | ||
14413 | idx++; | |
14414 | ||
14415 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14416 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14417 | || argv_find(argv, argc, "WORD", &idx)) { | |
14418 | sh_type = show_peer; | |
14419 | sh_arg = argv[idx]->arg; | |
14420 | } else | |
14421 | sh_type = show_all; | |
14422 | ||
14423 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14424 | return CMD_SUCCESS; | |
14425 | ||
14426 | ||
36235319 QY |
14427 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
14428 | afi, uj); | |
2986cac2 | 14429 | } |
14430 | ||
716b2d8a | 14431 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 14432 | DEFUN (show_ip_bgp_neighbors, |
14433 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 14434 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 14435 | SHOW_STR |
14436 | IP_STR | |
14437 | BGP_STR | |
f2a8972b | 14438 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
14439 | "Address Family\n" |
14440 | "Address Family\n" | |
718e3744 | 14441 | "Detailed information on TCP and BGP neighbor connections\n" |
14442 | "Neighbor to display information about\n" | |
a80beece | 14443 | "Neighbor to display information about\n" |
91d37724 | 14444 | "Neighbor on BGP configured interface\n" |
9973d184 | 14445 | JSON_STR) |
718e3744 | 14446 | { |
d62a17ae | 14447 | char *vrf = NULL; |
14448 | char *sh_arg = NULL; | |
14449 | enum show_type sh_type; | |
d1927ebe | 14450 | afi_t afi = AFI_MAX; |
718e3744 | 14451 | |
9f049418 | 14452 | bool uj = use_json(argc, argv); |
718e3744 | 14453 | |
d62a17ae | 14454 | int idx = 0; |
718e3744 | 14455 | |
9a8bdf1c PG |
14456 | /* [<vrf> VIEWVRFNAME] */ |
14457 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14458 | vrf = argv[idx + 1]->arg; | |
14459 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14460 | vrf = NULL; | |
14461 | } else if (argv_find(argv, argc, "view", &idx)) | |
14462 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 14463 | vrf = argv[idx + 1]->arg; |
718e3744 | 14464 | |
d62a17ae | 14465 | idx++; |
d1927ebe AS |
14466 | |
14467 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14468 | sh_type = show_ipv4_all; | |
14469 | afi = AFI_IP; | |
14470 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14471 | sh_type = show_ipv6_all; | |
14472 | afi = AFI_IP6; | |
14473 | } else { | |
14474 | sh_type = show_all; | |
14475 | } | |
14476 | ||
d62a17ae | 14477 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
14478 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14479 | || argv_find(argv, argc, "WORD", &idx)) { | |
14480 | sh_type = show_peer; | |
14481 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
14482 | } |
14483 | ||
14484 | if (sh_type == show_peer && afi == AFI_IP) { | |
14485 | sh_type = show_ipv4_peer; | |
14486 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14487 | sh_type = show_ipv6_peer; | |
14488 | } | |
856ca177 | 14489 | |
d62a17ae | 14490 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 14491 | } |
14492 | ||
716b2d8a | 14493 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 14494 | paths' and `show ip mbgp paths'. Those functions results are the |
14495 | same.*/ | |
f412b39a | 14496 | DEFUN (show_ip_bgp_paths, |
718e3744 | 14497 | show_ip_bgp_paths_cmd, |
46f296b4 | 14498 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 14499 | SHOW_STR |
14500 | IP_STR | |
14501 | BGP_STR | |
46f296b4 | 14502 | BGP_SAFI_HELP_STR |
718e3744 | 14503 | "Path information\n") |
14504 | { | |
d62a17ae | 14505 | vty_out(vty, "Address Refcnt Path\n"); |
14506 | aspath_print_all_vty(vty); | |
14507 | return CMD_SUCCESS; | |
718e3744 | 14508 | } |
14509 | ||
718e3744 | 14510 | #include "hash.h" |
14511 | ||
e3b78da8 | 14512 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14513 | struct vty *vty) |
718e3744 | 14514 | { |
d62a17ae | 14515 | struct community *com; |
718e3744 | 14516 | |
e3b78da8 | 14517 | com = (struct community *)bucket->data; |
3f65c5b1 | 14518 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 14519 | community_str(com, false)); |
718e3744 | 14520 | } |
14521 | ||
14522 | /* Show BGP's community internal data. */ | |
f412b39a | 14523 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 14524 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 14525 | "show [ip] bgp community-info", |
718e3744 | 14526 | SHOW_STR |
14527 | IP_STR | |
14528 | BGP_STR | |
14529 | "List all bgp community information\n") | |
14530 | { | |
d62a17ae | 14531 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 14532 | |
d62a17ae | 14533 | hash_iterate(community_hash(), |
e3b78da8 | 14534 | (void (*)(struct hash_bucket *, |
d62a17ae | 14535 | void *))community_show_all_iterator, |
14536 | vty); | |
718e3744 | 14537 | |
d62a17ae | 14538 | return CMD_SUCCESS; |
718e3744 | 14539 | } |
14540 | ||
e3b78da8 | 14541 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14542 | struct vty *vty) |
57d187bc | 14543 | { |
d62a17ae | 14544 | struct lcommunity *lcom; |
57d187bc | 14545 | |
e3b78da8 | 14546 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 14547 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 14548 | lcommunity_str(lcom, false)); |
57d187bc JS |
14549 | } |
14550 | ||
14551 | /* Show BGP's community internal data. */ | |
14552 | DEFUN (show_ip_bgp_lcommunity_info, | |
14553 | show_ip_bgp_lcommunity_info_cmd, | |
14554 | "show ip bgp large-community-info", | |
14555 | SHOW_STR | |
14556 | IP_STR | |
14557 | BGP_STR | |
14558 | "List all bgp large-community information\n") | |
14559 | { | |
d62a17ae | 14560 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 14561 | |
d62a17ae | 14562 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 14563 | (void (*)(struct hash_bucket *, |
d62a17ae | 14564 | void *))lcommunity_show_all_iterator, |
14565 | vty); | |
57d187bc | 14566 | |
d62a17ae | 14567 | return CMD_SUCCESS; |
57d187bc | 14568 | } |
2986cac2 | 14569 | /* Graceful Restart */ |
14570 | ||
14571 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
14572 | struct bgp *bgp, |
14573 | bool use_json, | |
14574 | json_object *json) | |
2986cac2 | 14575 | { |
57d187bc JS |
14576 | |
14577 | ||
2986cac2 | 14578 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
14579 | ||
7318ae88 | 14580 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 14581 | |
14582 | switch (bgp_global_gr_mode) { | |
14583 | ||
14584 | case GLOBAL_HELPER: | |
13909c4f | 14585 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 14586 | break; |
14587 | ||
14588 | case GLOBAL_GR: | |
13909c4f | 14589 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 14590 | break; |
14591 | ||
14592 | case GLOBAL_DISABLE: | |
13909c4f | 14593 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 14594 | break; |
14595 | ||
14596 | case GLOBAL_INVALID: | |
2986cac2 | 14597 | vty_out(vty, |
2ba1fe69 | 14598 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 14599 | break; |
14600 | } | |
14601 | vty_out(vty, "\n"); | |
14602 | } | |
14603 | ||
36235319 QY |
14604 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
14605 | enum show_type type, | |
14606 | const char *ip_str, | |
14607 | afi_t afi, bool use_json) | |
2986cac2 | 14608 | { |
14609 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14610 | afi = AFI_IP; | |
14611 | ||
14612 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14613 | ||
36235319 QY |
14614 | bgp_show_neighbor_graceful_restart_vty( |
14615 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 14616 | afi++; |
14617 | } | |
14618 | } else if (afi != AFI_MAX) { | |
36235319 QY |
14619 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
14620 | use_json); | |
2986cac2 | 14621 | } else { |
14622 | return CMD_ERR_INCOMPLETE; | |
14623 | } | |
14624 | ||
14625 | return CMD_SUCCESS; | |
14626 | } | |
14627 | /* Graceful Restart */ | |
14628 | ||
f412b39a | 14629 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 14630 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 14631 | "show [ip] bgp attribute-info", |
718e3744 | 14632 | SHOW_STR |
14633 | IP_STR | |
14634 | BGP_STR | |
14635 | "List all bgp attribute information\n") | |
14636 | { | |
d62a17ae | 14637 | attr_show_all(vty); |
14638 | return CMD_SUCCESS; | |
718e3744 | 14639 | } |
6b0655a2 | 14640 | |
03915806 CS |
14641 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
14642 | afi_t afi, safi_t safi, | |
14643 | bool use_json, json_object *json) | |
53089bec | 14644 | { |
14645 | struct bgp *bgp; | |
14646 | struct listnode *node; | |
14647 | char *vname; | |
14648 | char buf1[INET6_ADDRSTRLEN]; | |
14649 | char *ecom_str; | |
14650 | vpn_policy_direction_t dir; | |
14651 | ||
03915806 | 14652 | if (json) { |
b46dfd20 DS |
14653 | json_object *json_import_vrfs = NULL; |
14654 | json_object *json_export_vrfs = NULL; | |
14655 | ||
b46dfd20 DS |
14656 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14657 | ||
53089bec | 14658 | if (!bgp) { |
b46dfd20 DS |
14659 | vty_out(vty, "%s\n", |
14660 | json_object_to_json_string_ext( | |
14661 | json, | |
14662 | JSON_C_TO_STRING_PRETTY)); | |
14663 | json_object_free(json); | |
14664 | ||
53089bec | 14665 | return CMD_WARNING; |
14666 | } | |
b46dfd20 | 14667 | |
94d4c685 DS |
14668 | /* Provide context for the block */ |
14669 | json_object_string_add(json, "vrf", name ? name : "default"); | |
14670 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 14671 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 14672 | |
b46dfd20 DS |
14673 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14674 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14675 | json_object_string_add(json, "importFromVrfs", "none"); | |
14676 | json_object_string_add(json, "importRts", "none"); | |
14677 | } else { | |
6ce24e52 DS |
14678 | json_import_vrfs = json_object_new_array(); |
14679 | ||
b46dfd20 DS |
14680 | for (ALL_LIST_ELEMENTS_RO( |
14681 | bgp->vpn_policy[afi].import_vrf, | |
14682 | node, vname)) | |
14683 | json_object_array_add(json_import_vrfs, | |
14684 | json_object_new_string(vname)); | |
14685 | ||
b20875ea CS |
14686 | json_object_object_add(json, "importFromVrfs", |
14687 | json_import_vrfs); | |
b46dfd20 | 14688 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
14689 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14690 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14691 | bgp->vpn_policy[afi].rtlist[dir], |
14692 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14693 | json_object_string_add(json, "importRts", |
14694 | ecom_str); | |
14695 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14696 | } else | |
14697 | json_object_string_add(json, "importRts", | |
14698 | "none"); | |
b46dfd20 DS |
14699 | } |
14700 | ||
14701 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14702 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
14703 | json_object_string_add(json, "exportToVrfs", "none"); | |
14704 | json_object_string_add(json, "routeDistinguisher", | |
14705 | "none"); | |
14706 | json_object_string_add(json, "exportRts", "none"); | |
14707 | } else { | |
6ce24e52 DS |
14708 | json_export_vrfs = json_object_new_array(); |
14709 | ||
b46dfd20 DS |
14710 | for (ALL_LIST_ELEMENTS_RO( |
14711 | bgp->vpn_policy[afi].export_vrf, | |
14712 | node, vname)) | |
14713 | json_object_array_add(json_export_vrfs, | |
14714 | json_object_new_string(vname)); | |
14715 | json_object_object_add(json, "exportToVrfs", | |
14716 | json_export_vrfs); | |
14717 | json_object_string_add(json, "routeDistinguisher", | |
14718 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14719 | buf1, RD_ADDRSTRLEN)); | |
14720 | ||
14721 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14722 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14723 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14724 | bgp->vpn_policy[afi].rtlist[dir], |
14725 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14726 | json_object_string_add(json, "exportRts", |
14727 | ecom_str); | |
14728 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14729 | } else | |
14730 | json_object_string_add(json, "exportRts", | |
14731 | "none"); | |
b46dfd20 DS |
14732 | } |
14733 | ||
03915806 CS |
14734 | if (use_json) { |
14735 | vty_out(vty, "%s\n", | |
14736 | json_object_to_json_string_ext(json, | |
b46dfd20 | 14737 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
14738 | json_object_free(json); |
14739 | } | |
53089bec | 14740 | } else { |
b46dfd20 DS |
14741 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14742 | ||
53089bec | 14743 | if (!bgp) { |
b46dfd20 | 14744 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 14745 | return CMD_WARNING; |
14746 | } | |
53089bec | 14747 | |
b46dfd20 DS |
14748 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14749 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
14750 | vty_out(vty, | |
14751 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 14752 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14753 | else { |
14754 | vty_out(vty, | |
14755 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 14756 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14757 | |
14758 | for (ALL_LIST_ELEMENTS_RO( | |
14759 | bgp->vpn_policy[afi].import_vrf, | |
14760 | node, vname)) | |
14761 | vty_out(vty, " %s\n", vname); | |
14762 | ||
14763 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
14764 | ecom_str = NULL; |
14765 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14766 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14767 | bgp->vpn_policy[afi].rtlist[dir], |
14768 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 14769 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 14770 | |
b20875ea CS |
14771 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
14772 | } else | |
14773 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14774 | } |
53089bec | 14775 | |
b46dfd20 DS |
14776 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14777 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14778 | vty_out(vty, | |
14779 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 14780 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14781 | else { |
14782 | vty_out(vty, | |
04c9077f | 14783 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 14784 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14785 | |
14786 | for (ALL_LIST_ELEMENTS_RO( | |
14787 | bgp->vpn_policy[afi].export_vrf, | |
14788 | node, vname)) | |
14789 | vty_out(vty, " %s\n", vname); | |
14790 | ||
14791 | vty_out(vty, "RD: %s\n", | |
14792 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14793 | buf1, RD_ADDRSTRLEN)); | |
14794 | ||
14795 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14796 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14797 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14798 | bgp->vpn_policy[afi].rtlist[dir], |
14799 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14800 | vty_out(vty, "Export RT: %s\n", ecom_str); |
14801 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14802 | } else | |
14803 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14804 | } |
53089bec | 14805 | } |
14806 | ||
14807 | return CMD_SUCCESS; | |
14808 | } | |
14809 | ||
03915806 CS |
14810 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
14811 | safi_t safi, bool use_json) | |
14812 | { | |
14813 | struct listnode *node, *nnode; | |
14814 | struct bgp *bgp; | |
14815 | char *vrf_name = NULL; | |
14816 | json_object *json = NULL; | |
14817 | json_object *json_vrf = NULL; | |
14818 | json_object *json_vrfs = NULL; | |
14819 | ||
14820 | if (use_json) { | |
14821 | json = json_object_new_object(); | |
14822 | json_vrfs = json_object_new_object(); | |
14823 | } | |
14824 | ||
14825 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14826 | ||
14827 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
14828 | vrf_name = bgp->name; | |
14829 | ||
14830 | if (use_json) { | |
14831 | json_vrf = json_object_new_object(); | |
14832 | } else { | |
14833 | vty_out(vty, "\nInstance %s:\n", | |
14834 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14835 | ? VRF_DEFAULT_NAME : bgp->name); | |
14836 | } | |
14837 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
14838 | if (use_json) { | |
14839 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14840 | json_object_object_add(json_vrfs, | |
14841 | VRF_DEFAULT_NAME, json_vrf); | |
14842 | else | |
14843 | json_object_object_add(json_vrfs, vrf_name, | |
14844 | json_vrf); | |
14845 | } | |
14846 | } | |
14847 | ||
14848 | if (use_json) { | |
14849 | json_object_object_add(json, "vrfs", json_vrfs); | |
14850 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
14851 | JSON_C_TO_STRING_PRETTY)); | |
14852 | json_object_free(json); | |
14853 | } | |
14854 | ||
14855 | return CMD_SUCCESS; | |
14856 | } | |
14857 | ||
53089bec | 14858 | /* "show [ip] bgp route-leak" command. */ |
14859 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
14860 | show_ip_bgp_route_leak_cmd, |
14861 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
14862 | SHOW_STR |
14863 | IP_STR | |
14864 | BGP_STR | |
14865 | BGP_INSTANCE_HELP_STR | |
14866 | BGP_AFI_HELP_STR | |
14867 | BGP_SAFI_HELP_STR | |
14868 | "Route leaking information\n" | |
14869 | JSON_STR) | |
53089bec | 14870 | { |
14871 | char *vrf = NULL; | |
14872 | afi_t afi = AFI_MAX; | |
14873 | safi_t safi = SAFI_MAX; | |
14874 | ||
9f049418 | 14875 | bool uj = use_json(argc, argv); |
53089bec | 14876 | int idx = 0; |
03915806 | 14877 | json_object *json = NULL; |
53089bec | 14878 | |
14879 | /* show [ip] bgp */ | |
14880 | if (argv_find(argv, argc, "ip", &idx)) { | |
14881 | afi = AFI_IP; | |
14882 | safi = SAFI_UNICAST; | |
14883 | } | |
14884 | /* [vrf VIEWVRFNAME] */ | |
14885 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
14886 | vty_out(vty, |
14887 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 14888 | return CMD_WARNING; |
14889 | } | |
14890 | ||
9a8bdf1c PG |
14891 | if (argv_find(argv, argc, "vrf", &idx)) { |
14892 | vrf = argv[idx + 1]->arg; | |
14893 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14894 | vrf = NULL; | |
14895 | } | |
53089bec | 14896 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14897 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14898 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14899 | } | |
14900 | ||
14901 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
14902 | vty_out(vty, |
14903 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 14904 | return CMD_WARNING; |
14905 | } | |
14906 | ||
03915806 CS |
14907 | if (vrf && strmatch(vrf, "all")) |
14908 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14909 | ||
14910 | if (uj) | |
14911 | json = json_object_new_object(); | |
14912 | ||
14913 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 14914 | } |
14915 | ||
d62a17ae | 14916 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
14917 | safi_t safi) | |
f186de26 | 14918 | { |
d62a17ae | 14919 | struct listnode *node, *nnode; |
14920 | struct bgp *bgp; | |
f186de26 | 14921 | |
d62a17ae | 14922 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
14923 | vty_out(vty, "\nInstance %s:\n", | |
14924 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14925 | ? VRF_DEFAULT_NAME |
d62a17ae | 14926 | : bgp->name); |
14927 | update_group_show(bgp, afi, safi, vty, 0); | |
14928 | } | |
f186de26 | 14929 | } |
14930 | ||
d62a17ae | 14931 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
14932 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 14933 | { |
d62a17ae | 14934 | struct bgp *bgp; |
4fb25c53 | 14935 | |
d62a17ae | 14936 | if (name) { |
14937 | if (strmatch(name, "all")) { | |
14938 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
14939 | return CMD_SUCCESS; | |
14940 | } else { | |
14941 | bgp = bgp_lookup_by_name(name); | |
14942 | } | |
14943 | } else { | |
14944 | bgp = bgp_get_default(); | |
14945 | } | |
4fb25c53 | 14946 | |
d62a17ae | 14947 | if (bgp) |
14948 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
14949 | return CMD_SUCCESS; | |
4fb25c53 DW |
14950 | } |
14951 | ||
8fe8a7f6 DS |
14952 | DEFUN (show_ip_bgp_updgrps, |
14953 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 14954 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 14955 | SHOW_STR |
14956 | IP_STR | |
14957 | BGP_STR | |
14958 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 14959 | BGP_AFI_HELP_STR |
9bedbb1e | 14960 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
14961 | "Detailed info about dynamic update groups\n" |
14962 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 14963 | { |
d62a17ae | 14964 | char *vrf = NULL; |
14965 | afi_t afi = AFI_IP6; | |
14966 | safi_t safi = SAFI_UNICAST; | |
14967 | uint64_t subgrp_id = 0; | |
14968 | ||
14969 | int idx = 0; | |
14970 | ||
14971 | /* show [ip] bgp */ | |
14972 | if (argv_find(argv, argc, "ip", &idx)) | |
14973 | afi = AFI_IP; | |
9a8bdf1c PG |
14974 | /* [<vrf> VIEWVRFNAME] */ |
14975 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14976 | vrf = argv[idx + 1]->arg; | |
14977 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14978 | vrf = NULL; | |
14979 | } else if (argv_find(argv, argc, "view", &idx)) | |
14980 | /* [<view> VIEWVRFNAME] */ | |
14981 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 14982 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14983 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14984 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14985 | } | |
5bf15956 | 14986 | |
d62a17ae | 14987 | /* get subgroup id, if provided */ |
14988 | idx = argc - 1; | |
14989 | if (argv[idx]->type == VARIABLE_TKN) | |
14990 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 14991 | |
d62a17ae | 14992 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
14993 | } |
14994 | ||
f186de26 | 14995 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
14996 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 14997 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 14998 | SHOW_STR |
716b2d8a | 14999 | IP_STR |
f186de26 | 15000 | BGP_STR |
15001 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 15002 | "Detailed info about dynamic update groups\n") |
f186de26 | 15003 | { |
d62a17ae | 15004 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
15005 | return CMD_SUCCESS; | |
f186de26 | 15006 | } |
15007 | ||
43d3f4fc DS |
15008 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15009 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15010 | "show [ip] bgp l2vpn evpn update-groups", | |
15011 | SHOW_STR | |
15012 | IP_STR | |
15013 | BGP_STR | |
15014 | "l2vpn address family\n" | |
15015 | "evpn sub-address family\n" | |
15016 | "Detailed info about dynamic update groups\n") | |
15017 | { | |
15018 | char *vrf = NULL; | |
15019 | uint64_t subgrp_id = 0; | |
15020 | ||
15021 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
15022 | return CMD_SUCCESS; | |
15023 | } | |
15024 | ||
5bf15956 DW |
15025 | DEFUN (show_bgp_updgrps_stats, |
15026 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15027 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15028 | SHOW_STR |
716b2d8a | 15029 | IP_STR |
3f9c7369 | 15030 | BGP_STR |
0c7b1b01 | 15031 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15032 | "Statistics\n") |
15033 | { | |
d62a17ae | 15034 | struct bgp *bgp; |
3f9c7369 | 15035 | |
d62a17ae | 15036 | bgp = bgp_get_default(); |
15037 | if (bgp) | |
15038 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15039 | |
d62a17ae | 15040 | return CMD_SUCCESS; |
3f9c7369 DS |
15041 | } |
15042 | ||
8386ac43 | 15043 | DEFUN (show_bgp_instance_updgrps_stats, |
15044 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15045 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15046 | SHOW_STR |
716b2d8a | 15047 | IP_STR |
8386ac43 | 15048 | BGP_STR |
15049 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15050 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15051 | "Statistics\n") |
15052 | { | |
d62a17ae | 15053 | int idx_word = 3; |
15054 | struct bgp *bgp; | |
8386ac43 | 15055 | |
d62a17ae | 15056 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15057 | if (bgp) | |
15058 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15059 | |
d62a17ae | 15060 | return CMD_SUCCESS; |
8386ac43 | 15061 | } |
15062 | ||
d62a17ae | 15063 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15064 | afi_t afi, safi_t safi, | |
15065 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15066 | { |
d62a17ae | 15067 | struct bgp *bgp; |
8386ac43 | 15068 | |
d62a17ae | 15069 | if (name) |
15070 | bgp = bgp_lookup_by_name(name); | |
15071 | else | |
15072 | bgp = bgp_get_default(); | |
8386ac43 | 15073 | |
d62a17ae | 15074 | if (bgp) { |
15075 | if (!strcmp(what, "advertise-queue")) | |
15076 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15077 | subgrp_id); | |
15078 | else if (!strcmp(what, "advertised-routes")) | |
15079 | update_group_show_advertised(bgp, afi, safi, vty, | |
15080 | subgrp_id); | |
15081 | else if (!strcmp(what, "packet-queue")) | |
15082 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15083 | subgrp_id); | |
15084 | } | |
3f9c7369 DS |
15085 | } |
15086 | ||
dc64bdec QY |
15087 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15088 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15089 | "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", | |
15090 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15091 | BGP_SAFI_HELP_STR | |
15092 | "Detailed info about dynamic update groups\n" | |
15093 | "Specific subgroup to display info for\n" | |
15094 | "Advertisement queue\n" | |
15095 | "Announced routes\n" | |
15096 | "Packet queue\n") | |
3f9c7369 | 15097 | { |
dc64bdec QY |
15098 | uint64_t subgrp_id = 0; |
15099 | afi_t afiz; | |
15100 | safi_t safiz; | |
15101 | if (sgid) | |
15102 | subgrp_id = strtoull(sgid, NULL, 10); | |
15103 | ||
15104 | if (!ip && !afi) | |
15105 | afiz = AFI_IP6; | |
15106 | if (!ip && afi) | |
15107 | afiz = bgp_vty_afi_from_str(afi); | |
15108 | if (ip && !afi) | |
15109 | afiz = AFI_IP; | |
15110 | if (ip && afi) { | |
15111 | afiz = bgp_vty_afi_from_str(afi); | |
15112 | if (afiz != AFI_IP) | |
15113 | vty_out(vty, | |
15114 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15115 | return CMD_WARNING; | |
15116 | } | |
d62a17ae | 15117 | |
dc64bdec | 15118 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15119 | |
dc64bdec | 15120 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15121 | return CMD_SUCCESS; |
15122 | } | |
15123 | ||
d62a17ae | 15124 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
15125 | { | |
15126 | struct listnode *node, *nnode; | |
15127 | struct prefix *range; | |
15128 | struct peer *conf; | |
15129 | struct peer *peer; | |
d62a17ae | 15130 | afi_t afi; |
15131 | safi_t safi; | |
15132 | const char *peer_status; | |
15133 | const char *af_str; | |
15134 | int lr_count; | |
15135 | int dynamic; | |
15136 | int af_cfgd; | |
15137 | ||
15138 | conf = group->conf; | |
15139 | ||
15140 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
6cde4b45 | 15141 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 15142 | group->name, conf->as); |
d62a17ae | 15143 | } else if (conf->as_type == AS_INTERNAL) { |
6cde4b45 | 15144 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 15145 | group->name, group->bgp->as); |
d62a17ae | 15146 | } else { |
15147 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
15148 | } | |
f14e6fdb | 15149 | |
d62a17ae | 15150 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
15151 | vty_out(vty, " Peer-group type is internal\n"); | |
15152 | else | |
15153 | vty_out(vty, " Peer-group type is external\n"); | |
15154 | ||
15155 | /* Display AFs configured. */ | |
15156 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
15157 | FOREACH_AFI_SAFI (afi, safi) { |
15158 | if (conf->afc[afi][safi]) { | |
15159 | af_cfgd = 1; | |
5cb5f4d0 | 15160 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 15161 | } |
05c7a1cc | 15162 | } |
d62a17ae | 15163 | if (!af_cfgd) |
15164 | vty_out(vty, " none\n"); | |
15165 | else | |
15166 | vty_out(vty, "\n"); | |
15167 | ||
15168 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15169 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
15170 | if (afi == AFI_IP) | |
15171 | af_str = "IPv4"; | |
15172 | else if (afi == AFI_IP6) | |
15173 | af_str = "IPv6"; | |
15174 | else | |
15175 | af_str = "???"; | |
15176 | lr_count = listcount(group->listen_range[afi]); | |
15177 | if (lr_count) { | |
15178 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
15179 | af_str); | |
15180 | ||
15181 | ||
15182 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
2dbe669b DA |
15183 | nnode, range)) |
15184 | vty_out(vty, " %pFX\n", range); | |
d62a17ae | 15185 | } |
15186 | } | |
f14e6fdb | 15187 | |
d62a17ae | 15188 | /* Display group members and their status */ |
15189 | if (listcount(group->peer)) { | |
15190 | vty_out(vty, " Peer-group members:\n"); | |
15191 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
cb9196e7 DS |
15192 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15193 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15194 | peer_status = "Idle (Admin)"; |
15195 | else if (CHECK_FLAG(peer->sflags, | |
15196 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15197 | peer_status = "Idle (PfxCt)"; | |
15198 | else | |
15199 | peer_status = lookup_msg(bgp_status_msg, | |
15200 | peer->status, NULL); | |
15201 | ||
15202 | dynamic = peer_dynamic_neighbor(peer); | |
15203 | vty_out(vty, " %s %s %s \n", peer->host, | |
15204 | dynamic ? "(dynamic)" : "", peer_status); | |
15205 | } | |
15206 | } | |
f14e6fdb | 15207 | |
d62a17ae | 15208 | return CMD_SUCCESS; |
15209 | } | |
15210 | ||
ff9959b0 QY |
15211 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
15212 | const char *group_name) | |
d62a17ae | 15213 | { |
ff9959b0 | 15214 | struct bgp *bgp; |
d62a17ae | 15215 | struct listnode *node, *nnode; |
15216 | struct peer_group *group; | |
ff9959b0 QY |
15217 | bool found = false; |
15218 | ||
15219 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15220 | ||
15221 | if (!bgp) { | |
9f049418 | 15222 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
15223 | return CMD_WARNING; |
15224 | } | |
d62a17ae | 15225 | |
15226 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15227 | if (group_name) { |
15228 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 15229 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
15230 | found = true; |
15231 | break; | |
d62a17ae | 15232 | } |
ff9959b0 QY |
15233 | } else { |
15234 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 15235 | } |
f14e6fdb | 15236 | } |
f14e6fdb | 15237 | |
ff9959b0 | 15238 | if (group_name && !found) |
d62a17ae | 15239 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15240 | |
d62a17ae | 15241 | return CMD_SUCCESS; |
f14e6fdb DS |
15242 | } |
15243 | ||
f14e6fdb DS |
15244 | DEFUN (show_ip_bgp_peer_groups, |
15245 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 15246 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
15247 | SHOW_STR |
15248 | IP_STR | |
15249 | BGP_STR | |
8386ac43 | 15250 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
15251 | "Detailed information on BGP peer groups\n" |
15252 | "Peer group name\n") | |
f14e6fdb | 15253 | { |
d62a17ae | 15254 | char *vrf, *pg; |
d62a17ae | 15255 | int idx = 0; |
f14e6fdb | 15256 | |
a4d82a8a PZ |
15257 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15258 | : NULL; | |
d62a17ae | 15259 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15260 | |
ff9959b0 | 15261 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 15262 | } |
3f9c7369 | 15263 | |
d6e3c605 | 15264 | |
718e3744 | 15265 | /* Redistribute VTY commands. */ |
15266 | ||
37a87b8f CS |
15267 | DEFUN_YANG (bgp_redistribute_ipv4, |
15268 | bgp_redistribute_ipv4_cmd, | |
15269 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15270 | "Redistribute information from another routing protocol\n" | |
15271 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15272 | { |
d62a17ae | 15273 | int idx_protocol = 1; |
37a87b8f | 15274 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15275 | |
37a87b8f CS |
15276 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15277 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15278 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15279 | argv[idx_protocol]->text, "0"); | |
15280 | ||
15281 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
7f323236 | 15282 | |
37a87b8f | 15283 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 15284 | } |
15285 | ||
d62a17ae | 15286 | ALIAS_HIDDEN( |
15287 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15288 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15289 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 15290 | |
37a87b8f CS |
15291 | DEFUN_YANG (bgp_redistribute_ipv4_rmap, |
15292 | bgp_redistribute_ipv4_rmap_cmd, | |
15293 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15294 | "Redistribute information from another routing protocol\n" | |
15295 | FRR_IP_REDIST_HELP_STR_BGPD | |
15296 | "Route map reference\n" | |
15297 | "Pointer to route-map entries\n") | |
718e3744 | 15298 | { |
d62a17ae | 15299 | int idx_protocol = 1; |
15300 | int idx_word = 3; | |
37a87b8f CS |
15301 | char base_xpath[XPATH_MAXLEN]; |
15302 | ||
15303 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15304 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15305 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15306 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15307 | |
37a87b8f CS |
15308 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15309 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15310 | argv[idx_word]->arg); | |
15311 | ||
15312 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15313 | } |
15314 | ||
d62a17ae | 15315 | ALIAS_HIDDEN( |
15316 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
15317 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15318 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15319 | "Route map reference\n" | |
15320 | "Pointer to route-map entries\n") | |
596c17ba | 15321 | |
37a87b8f CS |
15322 | DEFUN_YANG (bgp_redistribute_ipv4_metric, |
15323 | bgp_redistribute_ipv4_metric_cmd, | |
15324 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15325 | "Redistribute information from another routing protocol\n" | |
15326 | FRR_IP_REDIST_HELP_STR_BGPD | |
15327 | "Metric for redistributed routes\n" | |
15328 | "Default metric\n") | |
718e3744 | 15329 | { |
d62a17ae | 15330 | int idx_protocol = 1; |
15331 | int idx_number = 3; | |
37a87b8f CS |
15332 | char base_xpath[XPATH_MAXLEN]; |
15333 | ||
15334 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15335 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15336 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15337 | argv[idx_protocol]->text, "0"); | |
d62a17ae | 15338 | |
37a87b8f CS |
15339 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15340 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15341 | argv[idx_number]->arg); | |
15342 | ||
15343 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 15344 | } |
15345 | ||
15346 | ALIAS_HIDDEN( | |
15347 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15348 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15349 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15350 | "Metric for redistributed routes\n" | |
15351 | "Default metric\n") | |
596c17ba | 15352 | |
37a87b8f CS |
15353 | DEFUN_YANG( |
15354 | bgp_redistribute_ipv4_rmap_metric, | |
15355 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
15356 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15357 | " route-map WORD metric (0-4294967295)", | |
15358 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15359 | "Route map reference\n" | |
15360 | "Pointer to route-map entries\n" | |
15361 | "Metric for redistributed routes\n" | |
15362 | "Default metric\n") | |
718e3744 | 15363 | { |
d62a17ae | 15364 | int idx_protocol = 1; |
15365 | int idx_word = 3; | |
15366 | int idx_number = 5; | |
37a87b8f CS |
15367 | char base_xpath[XPATH_MAXLEN]; |
15368 | ||
15369 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15370 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15371 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15372 | argv[idx_protocol]->text, "0"); | |
15373 | ||
15374 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15375 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15376 | argv[idx_word]->arg); | |
15377 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15378 | argv[idx_number]->arg); | |
d62a17ae | 15379 | |
37a87b8f | 15380 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15381 | } |
15382 | ||
15383 | ALIAS_HIDDEN( | |
15384 | bgp_redistribute_ipv4_rmap_metric, | |
15385 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15386 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15387 | " route-map WORD metric (0-4294967295)", | |
15388 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15389 | "Route map reference\n" | |
15390 | "Pointer to route-map entries\n" | |
15391 | "Metric for redistributed routes\n" | |
15392 | "Default metric\n") | |
596c17ba | 15393 | |
37a87b8f CS |
15394 | DEFUN_YANG( |
15395 | bgp_redistribute_ipv4_metric_rmap, | |
15396 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
15397 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15398 | " metric (0-4294967295) route-map WORD", | |
15399 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15400 | "Metric for redistributed routes\n" | |
15401 | "Default metric\n" | |
15402 | "Route map reference\n" | |
15403 | "Pointer to route-map entries\n") | |
718e3744 | 15404 | { |
d62a17ae | 15405 | int idx_protocol = 1; |
d62a17ae | 15406 | int idx_word = 5; |
37a87b8f CS |
15407 | int idx_number = 3; |
15408 | char base_xpath[XPATH_MAXLEN]; | |
15409 | ||
15410 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15411 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15412 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15413 | argv[idx_protocol]->text, "0"); | |
15414 | ||
15415 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15416 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15417 | argv[idx_number]->arg); | |
15418 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15419 | argv[idx_word]->arg); | |
d62a17ae | 15420 | |
37a87b8f | 15421 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15422 | } |
15423 | ||
15424 | ALIAS_HIDDEN( | |
15425 | bgp_redistribute_ipv4_metric_rmap, | |
15426 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15427 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15428 | " metric (0-4294967295) route-map WORD", | |
15429 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15430 | "Metric for redistributed routes\n" | |
15431 | "Default metric\n" | |
15432 | "Route map reference\n" | |
15433 | "Pointer to route-map entries\n") | |
596c17ba | 15434 | |
37a87b8f CS |
15435 | DEFUN_YANG (bgp_redistribute_ipv4_ospf, |
15436 | bgp_redistribute_ipv4_ospf_cmd, | |
15437 | "redistribute <ospf|table> (1-65535)", | |
15438 | "Redistribute information from another routing protocol\n" | |
15439 | "Open Shortest Path First (OSPFv2)\n" | |
15440 | "Non-main Kernel Routing Table\n" | |
15441 | "Instance ID/Table ID\n") | |
7c8ff89e | 15442 | { |
37a87b8f | 15443 | int idx_protocol = 1; |
d62a17ae | 15444 | int idx_number = 2; |
37a87b8f | 15445 | char base_xpath[XPATH_MAXLEN]; |
7c8ff89e | 15446 | |
37a87b8f CS |
15447 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15448 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15449 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15450 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
7a4bb9c5 | 15451 | |
37a87b8f | 15452 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
7a4bb9c5 | 15453 | |
37a87b8f | 15454 | return nb_cli_apply_changes(vty, base_xpath); |
7c8ff89e DS |
15455 | } |
15456 | ||
d62a17ae | 15457 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
15458 | "redistribute <ospf|table> (1-65535)", | |
15459 | "Redistribute information from another routing protocol\n" | |
15460 | "Open Shortest Path First (OSPFv2)\n" | |
15461 | "Non-main Kernel Routing Table\n" | |
15462 | "Instance ID/Table ID\n") | |
596c17ba | 15463 | |
37a87b8f CS |
15464 | DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap, |
15465 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
15466 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15467 | "Redistribute information from another routing protocol\n" | |
15468 | "Open Shortest Path First (OSPFv2)\n" | |
15469 | "Non-main Kernel Routing Table\n" | |
15470 | "Instance ID/Table ID\n" | |
15471 | "Route map reference\n" | |
15472 | "Pointer to route-map entries\n") | |
7c8ff89e | 15473 | { |
37a87b8f | 15474 | int idx_protocol = 1; |
d62a17ae | 15475 | int idx_number = 2; |
15476 | int idx_word = 4; | |
37a87b8f CS |
15477 | char base_xpath[XPATH_MAXLEN]; |
15478 | ||
15479 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15480 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15481 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15482 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15483 | ||
15484 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15485 | ||
15486 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15487 | argv[idx_word]->arg); | |
d62a17ae | 15488 | |
37a87b8f | 15489 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15490 | } |
15491 | ||
15492 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15493 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
15494 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15495 | "Redistribute information from another routing protocol\n" | |
15496 | "Open Shortest Path First (OSPFv2)\n" | |
15497 | "Non-main Kernel Routing Table\n" | |
15498 | "Instance ID/Table ID\n" | |
15499 | "Route map reference\n" | |
15500 | "Pointer to route-map entries\n") | |
596c17ba | 15501 | |
37a87b8f CS |
15502 | DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric, |
15503 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15504 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15505 | "Redistribute information from another routing protocol\n" | |
15506 | "Open Shortest Path First (OSPFv2)\n" | |
15507 | "Non-main Kernel Routing Table\n" | |
15508 | "Instance ID/Table ID\n" | |
15509 | "Metric for redistributed routes\n" | |
15510 | "Default metric\n") | |
7c8ff89e | 15511 | { |
37a87b8f | 15512 | int idx_protocol = 1; |
d62a17ae | 15513 | int idx_number = 2; |
15514 | int idx_number_2 = 4; | |
37a87b8f CS |
15515 | char base_xpath[XPATH_MAXLEN]; |
15516 | ||
15517 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15518 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15519 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15520 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15521 | ||
15522 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15523 | |
37a87b8f CS |
15524 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
15525 | argv[idx_number_2]->arg); | |
d62a17ae | 15526 | |
37a87b8f | 15527 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15528 | } |
15529 | ||
15530 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15531 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15532 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15533 | "Redistribute information from another routing protocol\n" | |
15534 | "Open Shortest Path First (OSPFv2)\n" | |
15535 | "Non-main Kernel Routing Table\n" | |
15536 | "Instance ID/Table ID\n" | |
15537 | "Metric for redistributed routes\n" | |
15538 | "Default metric\n") | |
596c17ba | 15539 | |
37a87b8f CS |
15540 | DEFUN_YANG( |
15541 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15542 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
15543 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15544 | "Redistribute information from another routing protocol\n" | |
15545 | "Open Shortest Path First (OSPFv2)\n" | |
15546 | "Non-main Kernel Routing Table\n" | |
15547 | "Instance ID/Table ID\n" | |
15548 | "Route map reference\n" | |
15549 | "Pointer to route-map entries\n" | |
15550 | "Metric for redistributed routes\n" | |
15551 | "Default metric\n") | |
7c8ff89e | 15552 | { |
37a87b8f | 15553 | int idx_protocol = 1; |
d62a17ae | 15554 | int idx_number = 2; |
15555 | int idx_word = 4; | |
15556 | int idx_number_2 = 6; | |
37a87b8f CS |
15557 | char base_xpath[XPATH_MAXLEN]; |
15558 | ||
15559 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15560 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15561 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15562 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15563 | ||
15564 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15565 | |
37a87b8f CS |
15566 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, |
15567 | argv[idx_word]->arg); | |
15568 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15569 | argv[idx_number_2]->arg); | |
d62a17ae | 15570 | |
37a87b8f | 15571 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15572 | } |
15573 | ||
15574 | ALIAS_HIDDEN( | |
15575 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15576 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
15577 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15578 | "Redistribute information from another routing protocol\n" | |
15579 | "Open Shortest Path First (OSPFv2)\n" | |
15580 | "Non-main Kernel Routing Table\n" | |
15581 | "Instance ID/Table ID\n" | |
15582 | "Route map reference\n" | |
15583 | "Pointer to route-map entries\n" | |
15584 | "Metric for redistributed routes\n" | |
15585 | "Default metric\n") | |
596c17ba | 15586 | |
37a87b8f CS |
15587 | DEFUN_YANG( |
15588 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15589 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
15590 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15591 | "Redistribute information from another routing protocol\n" | |
15592 | "Open Shortest Path First (OSPFv2)\n" | |
15593 | "Non-main Kernel Routing Table\n" | |
15594 | "Instance ID/Table ID\n" | |
15595 | "Metric for redistributed routes\n" | |
15596 | "Default metric\n" | |
15597 | "Route map reference\n" | |
15598 | "Pointer to route-map entries\n") | |
7c8ff89e | 15599 | { |
37a87b8f | 15600 | int idx_protocol = 1; |
d62a17ae | 15601 | int idx_number = 2; |
15602 | int idx_number_2 = 4; | |
15603 | int idx_word = 6; | |
37a87b8f CS |
15604 | char base_xpath[XPATH_MAXLEN]; |
15605 | ||
15606 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15607 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15608 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15609 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15610 | ||
15611 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15612 | |
37a87b8f CS |
15613 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
15614 | argv[idx_number_2]->arg); | |
15615 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15616 | argv[idx_word]->arg); | |
d62a17ae | 15617 | |
37a87b8f | 15618 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15619 | } |
15620 | ||
15621 | ALIAS_HIDDEN( | |
15622 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15623 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
15624 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15625 | "Redistribute information from another routing protocol\n" | |
15626 | "Open Shortest Path First (OSPFv2)\n" | |
15627 | "Non-main Kernel Routing Table\n" | |
15628 | "Instance ID/Table ID\n" | |
15629 | "Metric for redistributed routes\n" | |
15630 | "Default metric\n" | |
15631 | "Route map reference\n" | |
15632 | "Pointer to route-map entries\n") | |
596c17ba | 15633 | |
37a87b8f CS |
15634 | DEFUN_YANG (no_bgp_redistribute_ipv4_ospf, |
15635 | no_bgp_redistribute_ipv4_ospf_cmd, | |
15636 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15637 | NO_STR | |
15638 | "Redistribute information from another routing protocol\n" | |
15639 | "Open Shortest Path First (OSPFv2)\n" | |
15640 | "Non-main Kernel Routing Table\n" | |
15641 | "Instance ID/Table ID\n" | |
15642 | "Metric for redistributed routes\n" | |
15643 | "Default metric\n" | |
15644 | "Route map reference\n" | |
15645 | "Pointer to route-map entries\n") | |
7c8ff89e | 15646 | { |
37a87b8f | 15647 | int idx_protocol = 2; |
d62a17ae | 15648 | int idx_number = 3; |
37a87b8f | 15649 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 15650 | |
37a87b8f CS |
15651 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15652 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15653 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15654 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15655 | ||
15656 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
d62a17ae | 15657 | |
37a87b8f | 15658 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15659 | } |
15660 | ||
15661 | ALIAS_HIDDEN( | |
15662 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 15663 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15664 | NO_STR |
15665 | "Redistribute information from another routing protocol\n" | |
15666 | "Open Shortest Path First (OSPFv2)\n" | |
15667 | "Non-main Kernel Routing Table\n" | |
15668 | "Instance ID/Table ID\n" | |
15669 | "Metric for redistributed routes\n" | |
15670 | "Default metric\n" | |
15671 | "Route map reference\n" | |
15672 | "Pointer to route-map entries\n") | |
596c17ba | 15673 | |
37a87b8f CS |
15674 | DEFUN_YANG (no_bgp_redistribute_ipv4, |
15675 | no_bgp_redistribute_ipv4_cmd, | |
15676 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15677 | NO_STR | |
15678 | "Redistribute information from another routing protocol\n" | |
15679 | FRR_IP_REDIST_HELP_STR_BGPD | |
15680 | "Metric for redistributed routes\n" | |
15681 | "Default metric\n" | |
15682 | "Route map reference\n" | |
15683 | "Pointer to route-map entries\n") | |
718e3744 | 15684 | { |
d62a17ae | 15685 | int idx_protocol = 2; |
37a87b8f | 15686 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 15687 | |
37a87b8f CS |
15688 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15689 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15690 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15691 | argv[idx_protocol]->text, "0"); | |
15692 | ||
15693 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
15694 | ||
15695 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 15696 | } |
15697 | ||
15698 | ALIAS_HIDDEN( | |
15699 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
15700 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 15701 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15702 | NO_STR |
15703 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15704 | "Metric for redistributed routes\n" | |
15705 | "Default metric\n" | |
15706 | "Route map reference\n" | |
15707 | "Pointer to route-map entries\n") | |
596c17ba | 15708 | |
37a87b8f CS |
15709 | DEFUN_YANG (bgp_redistribute_ipv6, |
15710 | bgp_redistribute_ipv6_cmd, | |
15711 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
15712 | "Redistribute information from another routing protocol\n" | |
15713 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 15714 | { |
d62a17ae | 15715 | int idx_protocol = 1; |
37a87b8f | 15716 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15717 | |
37a87b8f CS |
15718 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15719 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15720 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15721 | argv[idx_protocol]->text, "0"); | |
15722 | ||
15723 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
718e3744 | 15724 | |
37a87b8f | 15725 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 15726 | } |
15727 | ||
37a87b8f CS |
15728 | DEFUN_YANG (bgp_redistribute_ipv6_rmap, |
15729 | bgp_redistribute_ipv6_rmap_cmd, | |
15730 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
15731 | "Redistribute information from another routing protocol\n" | |
15732 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15733 | "Route map reference\n" | |
15734 | "Pointer to route-map entries\n") | |
718e3744 | 15735 | { |
d62a17ae | 15736 | int idx_protocol = 1; |
15737 | int idx_word = 3; | |
37a87b8f CS |
15738 | char base_xpath[XPATH_MAXLEN]; |
15739 | ||
15740 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15741 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15742 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15743 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15744 | |
37a87b8f CS |
15745 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15746 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15747 | argv[idx_word]->arg); | |
15748 | ||
15749 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15750 | } |
15751 | ||
37a87b8f | 15752 | DEFUN_YANG (bgp_redistribute_ipv6_metric, |
718e3744 | 15753 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 15754 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 15755 | "Redistribute information from another routing protocol\n" |
ab0181ee | 15756 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 15757 | "Metric for redistributed routes\n" |
15758 | "Default metric\n") | |
15759 | { | |
d62a17ae | 15760 | int idx_protocol = 1; |
15761 | int idx_number = 3; | |
37a87b8f CS |
15762 | char base_xpath[XPATH_MAXLEN]; |
15763 | ||
15764 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15765 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15766 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15767 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15768 | |
37a87b8f CS |
15769 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15770 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15771 | argv[idx_number]->arg); | |
15772 | ||
15773 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15774 | } |
15775 | ||
37a87b8f CS |
15776 | DEFUN_YANG( |
15777 | bgp_redistribute_ipv6_rmap_metric, | |
15778 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
15779 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
15780 | " route-map WORD metric (0-4294967295)", | |
15781 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
15782 | "Route map reference\n" | |
15783 | "Pointer to route-map entries\n" | |
15784 | "Metric for redistributed routes\n" | |
15785 | "Default metric\n") | |
718e3744 | 15786 | { |
d62a17ae | 15787 | int idx_protocol = 1; |
15788 | int idx_word = 3; | |
15789 | int idx_number = 5; | |
37a87b8f CS |
15790 | char base_xpath[XPATH_MAXLEN]; |
15791 | ||
15792 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15793 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15794 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15795 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15796 | |
37a87b8f CS |
15797 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15798 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15799 | argv[idx_word]->arg); | |
15800 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15801 | argv[idx_number]->arg); | |
15802 | ||
15803 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15804 | } |
15805 | ||
37a87b8f CS |
15806 | DEFUN_YANG( |
15807 | bgp_redistribute_ipv6_metric_rmap, | |
15808 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
15809 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
15810 | " metric (0-4294967295) route-map WORD", | |
15811 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
15812 | "Metric for redistributed routes\n" | |
15813 | "Default metric\n" | |
15814 | "Route map reference\n" | |
15815 | "Pointer to route-map entries\n") | |
718e3744 | 15816 | { |
d62a17ae | 15817 | int idx_protocol = 1; |
d62a17ae | 15818 | int idx_word = 5; |
37a87b8f CS |
15819 | int idx_number = 3; |
15820 | char base_xpath[XPATH_MAXLEN]; | |
15821 | ||
15822 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15823 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15824 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15825 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15826 | |
37a87b8f CS |
15827 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15828 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15829 | argv[idx_number]->arg); | |
15830 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15831 | argv[idx_word]->arg); | |
15832 | ||
15833 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15834 | } |
15835 | ||
37a87b8f CS |
15836 | DEFUN_YANG( |
15837 | no_bgp_redistribute_ipv6, | |
15838 | no_bgp_redistribute_ipv6_cmd, | |
15839 | "no redistribute " FRR_IP6_REDIST_STR_BGPD | |
15840 | " [{metric (0-4294967295)|route-map WORD}]", | |
15841 | NO_STR | |
15842 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
15843 | "Metric for redistributed routes\n" | |
15844 | "Default metric\n" | |
15845 | "Route map reference\n" | |
15846 | "Pointer to route-map entries\n") | |
718e3744 | 15847 | { |
d62a17ae | 15848 | int idx_protocol = 2; |
37a87b8f | 15849 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15850 | |
37a87b8f CS |
15851 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15852 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
15853 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
15854 | argv[idx_protocol]->text, "0"); | |
15855 | ||
15856 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
15857 | ||
15858 | return nb_cli_apply_changes(vty, base_xpath); | |
15859 | } | |
718e3744 | 15860 | |
37a87b8f CS |
15861 | void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list( |
15862 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
15863 | { | |
15864 | uint32_t instance = 0; | |
15865 | ||
15866 | vty_out(vty, " redistribute %s", | |
15867 | yang_dnode_get_string(dnode, "./route-type")); | |
15868 | if ((instance = yang_dnode_get_uint16(dnode, "./route-instance"))) | |
15869 | vty_out(vty, " %d", instance); | |
15870 | if (yang_dnode_exists(dnode, "./metric")) | |
15871 | vty_out(vty, " metric %u", | |
15872 | yang_dnode_get_uint32(dnode, "./metric")); | |
15873 | if (yang_dnode_exists(dnode, "./rmap-policy-import")) | |
15874 | vty_out(vty, " route-map %s", | |
15875 | yang_dnode_get_string(dnode, "./rmap-policy-import")); | |
15876 | vty_out(vty, "\n"); | |
d62a17ae | 15877 | } |
15878 | ||
dd65f45e DL |
15879 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
15880 | afi_t afi, safi_t safi) | |
d62a17ae | 15881 | { |
15882 | int i; | |
15883 | ||
15884 | /* Unicast redistribution only. */ | |
15885 | if (safi != SAFI_UNICAST) | |
2b791107 | 15886 | return; |
d62a17ae | 15887 | |
15888 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
15889 | /* Redistribute BGP does not make sense. */ | |
15890 | if (i != ZEBRA_ROUTE_BGP) { | |
15891 | struct list *red_list; | |
15892 | struct listnode *node; | |
15893 | struct bgp_redist *red; | |
15894 | ||
15895 | red_list = bgp->redist[afi][i]; | |
15896 | if (!red_list) | |
15897 | continue; | |
15898 | ||
15899 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 15900 | /* "redistribute" configuration. */ |
15901 | vty_out(vty, " redistribute %s", | |
15902 | zebra_route_string(i)); | |
15903 | if (red->instance) | |
15904 | vty_out(vty, " %d", red->instance); | |
15905 | if (red->redist_metric_flag) | |
15906 | vty_out(vty, " metric %u", | |
15907 | red->redist_metric); | |
15908 | if (red->rmap.name) | |
15909 | vty_out(vty, " route-map %s", | |
15910 | red->rmap.name); | |
15911 | vty_out(vty, "\n"); | |
15912 | } | |
15913 | } | |
15914 | } | |
718e3744 | 15915 | } |
6b0655a2 | 15916 | |
dd65f45e DL |
15917 | /* peer-group helpers for config-write */ |
15918 | ||
15919 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
15920 | { | |
15921 | if (!peer_group_active(peer)) { | |
15922 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
15923 | return !CHECK_FLAG(peer->flags, flag); | |
15924 | else | |
15925 | return !!CHECK_FLAG(peer->flags, flag); | |
15926 | } | |
15927 | ||
15928 | return !!CHECK_FLAG(peer->flags_override, flag); | |
15929 | } | |
15930 | ||
15931 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
15932 | uint32_t flag) | |
15933 | { | |
15934 | if (!peer_group_active(peer)) { | |
15935 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
15936 | return !peer_af_flag_check(peer, afi, safi, flag); | |
15937 | else | |
15938 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
15939 | } | |
15940 | ||
15941 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
15942 | } | |
15943 | ||
15944 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
15945 | uint8_t type, int direct) | |
15946 | { | |
15947 | struct bgp_filter *filter; | |
15948 | ||
15949 | if (peer_group_active(peer)) | |
15950 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
15951 | type); | |
15952 | ||
15953 | filter = &peer->filter[afi][safi]; | |
15954 | switch (type) { | |
15955 | case PEER_FT_DISTRIBUTE_LIST: | |
15956 | return !!(filter->dlist[direct].name); | |
15957 | case PEER_FT_FILTER_LIST: | |
15958 | return !!(filter->aslist[direct].name); | |
15959 | case PEER_FT_PREFIX_LIST: | |
15960 | return !!(filter->plist[direct].name); | |
15961 | case PEER_FT_ROUTE_MAP: | |
15962 | return !!(filter->map[direct].name); | |
15963 | case PEER_FT_UNSUPPRESS_MAP: | |
15964 | return !!(filter->usmap.name); | |
7f7940e6 MK |
15965 | case PEER_FT_ADVERTISE_MAP: |
15966 | return !!(filter->advmap.aname | |
15967 | && ((filter->advmap.condition == direct) | |
15968 | && filter->advmap.cname)); | |
dd65f45e DL |
15969 | default: |
15970 | return false; | |
15971 | } | |
15972 | } | |
15973 | ||
15974 | /* Return true if the addpath type is set for peer and different from | |
15975 | * peer-group. | |
15976 | */ | |
3dc339cd DA |
15977 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
15978 | safi_t safi) | |
dd65f45e DL |
15979 | { |
15980 | enum bgp_addpath_strat type, g_type; | |
15981 | ||
15982 | type = peer->addpath_type[afi][safi]; | |
15983 | ||
15984 | if (type != BGP_ADDPATH_NONE) { | |
15985 | if (peer_group_active(peer)) { | |
15986 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
15987 | ||
15988 | if (type != g_type) | |
3dc339cd | 15989 | return true; |
dd65f45e | 15990 | else |
3dc339cd | 15991 | return false; |
dd65f45e DL |
15992 | } |
15993 | ||
3dc339cd | 15994 | return true; |
dd65f45e DL |
15995 | } |
15996 | ||
3dc339cd | 15997 | return false; |
dd65f45e DL |
15998 | } |
15999 | ||
b9c7bc5a | 16000 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16001 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16002 | afi_t afi) |
16003 | { | |
b9c7bc5a | 16004 | int indent = 2; |
ddb5b488 | 16005 | |
8a066a70 | 16006 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16007 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16008 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16009 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16010 | bgp->vpn_policy[afi] | |
bb4f6190 | 16011 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16012 | else |
16013 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16014 | bgp->vpn_policy[afi] | |
16015 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16016 | } | |
12a844a5 DS |
16017 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16018 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16019 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16020 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16021 | return; | |
16022 | ||
e70e9f8e PZ |
16023 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16024 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16025 | ||
16026 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16027 | ||
16028 | } else { | |
16029 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16030 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16031 | bgp->vpn_policy[afi].tovpn_label); | |
16032 | } | |
ddb5b488 PZ |
16033 | } |
16034 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16035 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16036 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 16037 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
16038 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
16039 | sizeof(buf))); | |
16040 | } | |
16041 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16042 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16043 | ||
16044 | char buf[PREFIX_STRLEN]; | |
16045 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16046 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16047 | sizeof(buf))) { | |
16048 | ||
b9c7bc5a PZ |
16049 | vty_out(vty, "%*snexthop vpn export %s\n", |
16050 | indent, "", buf); | |
ddb5b488 PZ |
16051 | } |
16052 | } | |
16053 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16054 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16055 | && ecommunity_cmp( | |
16056 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16057 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16058 | ||
16059 | char *b = ecommunity_ecom2str( | |
16060 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16061 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16062 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16063 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16064 | } else { | |
16065 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16066 | char *b = ecommunity_ecom2str( | |
16067 | bgp->vpn_policy[afi] | |
16068 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16069 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16070 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16071 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16072 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16073 | } | |
16074 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16075 | char *b = ecommunity_ecom2str( | |
16076 | bgp->vpn_policy[afi] | |
16077 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16078 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16079 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16080 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16081 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16082 | } | |
16083 | } | |
bb4f6190 DS |
16084 | |
16085 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16086 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16087 | bgp->vpn_policy[afi] |
16088 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16089 | |
301ad80a PG |
16090 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16091 | char *b = ecommunity_ecom2str( | |
16092 | bgp->vpn_policy[afi] | |
16093 | .import_redirect_rtlist, | |
16094 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16095 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16096 | |
9a659715 PG |
16097 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16098 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16099 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16100 | indent, "", b); |
16101 | else | |
16102 | vty_out(vty, "%*srt redirect import %s\n", | |
16103 | indent, "", b); | |
301ad80a PG |
16104 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16105 | } | |
ddb5b488 PZ |
16106 | } |
16107 | ||
dd65f45e DL |
16108 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16109 | afi_t afi, safi_t safi) | |
16110 | { | |
16111 | struct bgp_filter *filter; | |
16112 | char *addr; | |
16113 | ||
16114 | addr = peer->host; | |
16115 | filter = &peer->filter[afi][safi]; | |
16116 | ||
16117 | /* distribute-list. */ | |
16118 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16119 | FILTER_IN)) | |
16120 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16121 | filter->dlist[FILTER_IN].name); | |
16122 | ||
16123 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16124 | FILTER_OUT)) | |
16125 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16126 | filter->dlist[FILTER_OUT].name); | |
16127 | ||
16128 | /* prefix-list. */ | |
16129 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16130 | FILTER_IN)) | |
16131 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16132 | filter->plist[FILTER_IN].name); | |
16133 | ||
16134 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16135 | FILTER_OUT)) | |
16136 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16137 | filter->plist[FILTER_OUT].name); | |
16138 | ||
16139 | /* route-map. */ | |
16140 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16141 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16142 | filter->map[RMAP_IN].name); | |
16143 | ||
16144 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16145 | RMAP_OUT)) | |
16146 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16147 | filter->map[RMAP_OUT].name); | |
16148 | ||
16149 | /* unsuppress-map */ | |
16150 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16151 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16152 | filter->usmap.name); | |
16153 | ||
7f7940e6 MK |
16154 | /* advertise-map : always applied in OUT direction*/ |
16155 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16156 | CONDITION_NON_EXIST)) | |
16157 | vty_out(vty, | |
16158 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16159 | addr, filter->advmap.aname, filter->advmap.cname); | |
16160 | ||
16161 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16162 | CONDITION_EXIST)) | |
16163 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16164 | addr, filter->advmap.aname, filter->advmap.cname); | |
16165 | ||
dd65f45e DL |
16166 | /* filter-list. */ |
16167 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16168 | FILTER_IN)) | |
16169 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16170 | filter->aslist[FILTER_IN].name); | |
16171 | ||
16172 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16173 | FILTER_OUT)) | |
16174 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16175 | filter->aslist[FILTER_OUT].name); | |
16176 | } | |
16177 | ||
16178 | /* BGP peer configuration display function. */ | |
16179 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16180 | struct peer *peer) | |
16181 | { | |
16182 | struct peer *g_peer = NULL; | |
16183 | char buf[SU_ADDRSTRLEN]; | |
16184 | char *addr; | |
16185 | int if_pg_printed = false; | |
16186 | int if_ras_printed = false; | |
16187 | ||
16188 | /* Skip dynamic neighbors. */ | |
16189 | if (peer_dynamic_neighbor(peer)) | |
16190 | return; | |
16191 | ||
16192 | if (peer->conf_if) | |
16193 | addr = peer->conf_if; | |
16194 | else | |
16195 | addr = peer->host; | |
16196 | ||
16197 | /************************************ | |
16198 | ****** Global to the neighbor ****** | |
16199 | ************************************/ | |
16200 | if (peer->conf_if) { | |
16201 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16202 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16203 | else | |
16204 | vty_out(vty, " neighbor %s interface", addr); | |
16205 | ||
16206 | if (peer_group_active(peer)) { | |
16207 | vty_out(vty, " peer-group %s", peer->group->name); | |
16208 | if_pg_printed = true; | |
16209 | } else if (peer->as_type == AS_SPECIFIED) { | |
16210 | vty_out(vty, " remote-as %u", peer->as); | |
16211 | if_ras_printed = true; | |
16212 | } else if (peer->as_type == AS_INTERNAL) { | |
16213 | vty_out(vty, " remote-as internal"); | |
16214 | if_ras_printed = true; | |
16215 | } else if (peer->as_type == AS_EXTERNAL) { | |
16216 | vty_out(vty, " remote-as external"); | |
16217 | if_ras_printed = true; | |
16218 | } | |
16219 | ||
16220 | vty_out(vty, "\n"); | |
16221 | } | |
16222 | ||
16223 | /* remote-as and peer-group */ | |
16224 | /* peer is a member of a peer-group */ | |
16225 | if (peer_group_active(peer)) { | |
16226 | g_peer = peer->group->conf; | |
16227 | ||
16228 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16229 | if (peer->as_type == AS_SPECIFIED) { | |
16230 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16231 | addr, peer->as); | |
16232 | } else if (peer->as_type == AS_INTERNAL) { | |
16233 | vty_out(vty, | |
16234 | " neighbor %s remote-as internal\n", | |
16235 | addr); | |
16236 | } else if (peer->as_type == AS_EXTERNAL) { | |
16237 | vty_out(vty, | |
16238 | " neighbor %s remote-as external\n", | |
16239 | addr); | |
16240 | } | |
16241 | } | |
16242 | ||
16243 | /* For swpX peers we displayed the peer-group | |
16244 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16245 | if (!if_pg_printed) | |
16246 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16247 | peer->group->name); | |
16248 | } | |
16249 | ||
16250 | /* peer is NOT a member of a peer-group */ | |
16251 | else { | |
16252 | /* peer is a peer-group, declare the peer-group */ | |
16253 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16254 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16255 | } | |
16256 | ||
16257 | if (!if_ras_printed) { | |
16258 | if (peer->as_type == AS_SPECIFIED) { | |
16259 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16260 | addr, peer->as); | |
16261 | } else if (peer->as_type == AS_INTERNAL) { | |
16262 | vty_out(vty, | |
16263 | " neighbor %s remote-as internal\n", | |
16264 | addr); | |
16265 | } else if (peer->as_type == AS_EXTERNAL) { | |
16266 | vty_out(vty, | |
16267 | " neighbor %s remote-as external\n", | |
16268 | addr); | |
16269 | } | |
16270 | } | |
16271 | } | |
16272 | ||
16273 | /* local-as */ | |
16274 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16275 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16276 | peer->change_local_as); | |
16277 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16278 | vty_out(vty, " no-prepend"); | |
16279 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16280 | vty_out(vty, " replace-as"); | |
16281 | vty_out(vty, "\n"); | |
16282 | } | |
16283 | ||
16284 | /* description */ | |
16285 | if (peer->desc) { | |
16286 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16287 | } | |
16288 | ||
16289 | /* shutdown */ | |
16290 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16291 | if (peer->tx_shutdown_message) | |
16292 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16293 | peer->tx_shutdown_message); | |
16294 | else | |
16295 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16296 | } | |
16297 | ||
8336c896 DA |
16298 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
16299 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16300 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16301 | ||
dd65f45e DL |
16302 | /* bfd */ |
16303 | if (peer->bfd_info) { | |
16304 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
16305 | bgp_bfd_peer_config_write(vty, peer, addr); | |
16306 | } | |
16307 | } | |
16308 | ||
16309 | /* password */ | |
16310 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16311 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16312 | peer->password); | |
16313 | ||
16314 | /* neighbor solo */ | |
16315 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16316 | if (!peer_group_active(peer)) { | |
16317 | vty_out(vty, " neighbor %s solo\n", addr); | |
16318 | } | |
16319 | } | |
16320 | ||
16321 | /* BGP port */ | |
16322 | if (peer->port != BGP_PORT_DEFAULT) { | |
16323 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16324 | } | |
16325 | ||
16326 | /* Local interface name */ | |
16327 | if (peer->ifname) { | |
16328 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16329 | } | |
16330 | ||
16331 | /* passive */ | |
16332 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16333 | vty_out(vty, " neighbor %s passive\n", addr); | |
16334 | ||
16335 | /* ebgp-multihop */ | |
16336 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
16337 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
16338 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
16339 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
16340 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16341 | peer->ttl); | |
16342 | } | |
16343 | } | |
16344 | ||
16345 | /* ttl-security hops */ | |
e2521429 | 16346 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
16347 | if (!peer_group_active(peer) |
16348 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16349 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16350 | addr, peer->gtsm_hops); | |
16351 | } | |
16352 | } | |
16353 | ||
16354 | /* disable-connected-check */ | |
16355 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16356 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16357 | ||
16358 | /* enforce-first-as */ | |
16359 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16360 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16361 | ||
16362 | /* update-source */ | |
16363 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16364 | if (peer->update_source) | |
16365 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16366 | sockunion2str(peer->update_source, buf, | |
16367 | SU_ADDRSTRLEN)); | |
16368 | else if (peer->update_if) | |
16369 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16370 | peer->update_if); | |
16371 | } | |
16372 | ||
16373 | /* advertisement-interval */ | |
16374 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16375 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16376 | peer->routeadv); | |
16377 | ||
16378 | /* timers */ | |
16379 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16380 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16381 | peer->keepalive, peer->holdtime); | |
16382 | ||
16383 | /* timers connect */ | |
16384 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16385 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16386 | peer->connect); | |
5d5393b9 DL |
16387 | /* need special-case handling for changed default values due to |
16388 | * config profile / version (because there is no "timers bgp connect" | |
16389 | * command, we need to save this per-peer :/) | |
16390 | */ | |
16391 | else if (!peer_group_active(peer) && !peer->connect && | |
16392 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16393 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16394 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
16395 | |
16396 | /* capability dynamic */ | |
16397 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16398 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16399 | ||
16400 | /* capability extended-nexthop */ | |
16401 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
16402 | if (!peer->conf_if) { | |
16403 | if (CHECK_FLAG(peer->flags_invert, | |
16404 | PEER_FLAG_CAPABILITY_ENHE)) | |
16405 | vty_out(vty, | |
16406 | " no neighbor %s capability extended-nexthop\n", | |
16407 | addr); | |
16408 | else | |
16409 | vty_out(vty, | |
16410 | " neighbor %s capability extended-nexthop\n", | |
16411 | addr); | |
16412 | } | |
16413 | } | |
16414 | ||
16415 | /* dont-capability-negotiation */ | |
16416 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16417 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16418 | ||
16419 | /* override-capability */ | |
16420 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16421 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16422 | ||
16423 | /* strict-capability-match */ | |
16424 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16425 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16426 | ||
16427 | /* Sender side AS path loop detection. */ | |
16428 | if (peer->as_path_loop_detection) | |
16429 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16430 | addr); | |
cfd47646 | 16431 | |
16432 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16433 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 16434 | |
16435 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16436 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 16437 | vty_out(vty, |
16438 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
16439 | } else if (CHECK_FLAG( |
16440 | peer->peer_gr_new_status_flag, | |
16441 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 16442 | vty_out(vty, |
16443 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
16444 | } else if ( |
16445 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16446 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16447 | && !(CHECK_FLAG( | |
16448 | peer->peer_gr_new_status_flag, | |
16449 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16450 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16451 | addr); | |
cfd47646 | 16452 | } |
16453 | } | |
dd65f45e DL |
16454 | } |
16455 | ||
16456 | /* BGP peer configuration display function. */ | |
16457 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16458 | struct peer *peer, afi_t afi, safi_t safi) | |
16459 | { | |
16460 | struct peer *g_peer = NULL; | |
16461 | char *addr; | |
16462 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16463 | ||
16464 | /* Skip dynamic neighbors. */ | |
16465 | if (peer_dynamic_neighbor(peer)) | |
16466 | return; | |
16467 | ||
16468 | if (peer->conf_if) | |
16469 | addr = peer->conf_if; | |
16470 | else | |
16471 | addr = peer->host; | |
16472 | ||
16473 | /************************************ | |
16474 | ****** Per AF to the neighbor ****** | |
16475 | ************************************/ | |
16476 | if (peer_group_active(peer)) { | |
16477 | g_peer = peer->group->conf; | |
16478 | ||
16479 | /* If the peer-group is active but peer is not, print a 'no | |
16480 | * activate' */ | |
16481 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16482 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16483 | } | |
16484 | ||
16485 | /* If the peer-group is not active but peer is, print an | |
16486 | 'activate' */ | |
16487 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16488 | vty_out(vty, " neighbor %s activate\n", addr); | |
16489 | } | |
16490 | } else { | |
16491 | if (peer->afc[afi][safi]) { | |
16492 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
16493 | if (CHECK_FLAG(bgp->flags, |
16494 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
16495 | vty_out(vty, " neighbor %s activate\n", |
16496 | addr); | |
16497 | } | |
16498 | } else | |
16499 | vty_out(vty, " neighbor %s activate\n", addr); | |
16500 | } else { | |
16501 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
16502 | if (!CHECK_FLAG(bgp->flags, |
16503 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
16504 | vty_out(vty, |
16505 | " no neighbor %s activate\n", | |
16506 | addr); | |
16507 | } | |
16508 | } | |
16509 | } | |
16510 | } | |
16511 | ||
16512 | /* addpath TX knobs */ | |
16513 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16514 | switch (peer->addpath_type[afi][safi]) { | |
16515 | case BGP_ADDPATH_ALL: | |
16516 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16517 | addr); | |
16518 | break; | |
16519 | case BGP_ADDPATH_BEST_PER_AS: | |
16520 | vty_out(vty, | |
16521 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16522 | addr); | |
16523 | break; | |
16524 | case BGP_ADDPATH_MAX: | |
16525 | case BGP_ADDPATH_NONE: | |
16526 | break; | |
16527 | } | |
16528 | } | |
16529 | ||
16530 | /* ORF capability. */ | |
16531 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16532 | || peergroup_af_flag_check(peer, afi, safi, | |
16533 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16534 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16535 | ||
16536 | if (peergroup_af_flag_check(peer, afi, safi, | |
16537 | PEER_FLAG_ORF_PREFIX_SM) | |
16538 | && peergroup_af_flag_check(peer, afi, safi, | |
16539 | PEER_FLAG_ORF_PREFIX_RM)) | |
16540 | vty_out(vty, " both"); | |
16541 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16542 | PEER_FLAG_ORF_PREFIX_SM)) | |
16543 | vty_out(vty, " send"); | |
16544 | else | |
16545 | vty_out(vty, " receive"); | |
16546 | vty_out(vty, "\n"); | |
16547 | } | |
16548 | ||
dd65f45e DL |
16549 | /* Route reflector client. */ |
16550 | if (peergroup_af_flag_check(peer, afi, safi, | |
16551 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16552 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16553 | } | |
16554 | ||
16555 | /* next-hop-self force */ | |
16556 | if (peergroup_af_flag_check(peer, afi, safi, | |
16557 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16558 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16559 | } | |
16560 | ||
16561 | /* next-hop-self */ | |
16562 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16563 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16564 | } | |
16565 | ||
16566 | /* remove-private-AS */ | |
16567 | if (peergroup_af_flag_check(peer, afi, safi, | |
16568 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16569 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16570 | addr); | |
16571 | } | |
16572 | ||
16573 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16574 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16575 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16576 | addr); | |
16577 | } | |
16578 | ||
16579 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16580 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16581 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16582 | } | |
16583 | ||
16584 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16585 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16586 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16587 | } | |
16588 | ||
16589 | /* as-override */ | |
16590 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16591 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16592 | } | |
16593 | ||
16594 | /* send-community print. */ | |
16595 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16596 | PEER_FLAG_SEND_COMMUNITY); | |
16597 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16598 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16599 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16600 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16601 | ||
16602 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16603 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16604 | } else { | |
16605 | if (flag_scomm) | |
16606 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16607 | if (flag_secomm) | |
16608 | vty_out(vty, | |
16609 | " no neighbor %s send-community extended\n", | |
16610 | addr); | |
16611 | ||
16612 | if (flag_slcomm) | |
16613 | vty_out(vty, " no neighbor %s send-community large\n", | |
16614 | addr); | |
16615 | } | |
16616 | ||
16617 | /* Default information */ | |
16618 | if (peergroup_af_flag_check(peer, afi, safi, | |
16619 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16620 | vty_out(vty, " neighbor %s default-originate", addr); | |
16621 | ||
16622 | if (peer->default_rmap[afi][safi].name) | |
16623 | vty_out(vty, " route-map %s", | |
16624 | peer->default_rmap[afi][safi].name); | |
16625 | ||
16626 | vty_out(vty, "\n"); | |
16627 | } | |
16628 | ||
16629 | /* Soft reconfiguration inbound. */ | |
16630 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16631 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16632 | addr); | |
16633 | } | |
16634 | ||
16635 | /* maximum-prefix. */ | |
16636 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 16637 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
16638 | peer->pmax[afi][safi]); |
16639 | ||
16640 | if (peer->pmax_threshold[afi][safi] | |
16641 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16642 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16643 | if (peer_af_flag_check(peer, afi, safi, | |
16644 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
16645 | vty_out(vty, " warning-only"); | |
16646 | if (peer->pmax_restart[afi][safi]) | |
16647 | vty_out(vty, " restart %u", | |
16648 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
16649 | if (peer_af_flag_check(peer, afi, safi, |
16650 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
16651 | vty_out(vty, " force"); | |
dd65f45e DL |
16652 | |
16653 | vty_out(vty, "\n"); | |
16654 | } | |
16655 | ||
fde246e8 DA |
16656 | /* maximum-prefix-out */ |
16657 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 16658 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
16659 | addr, peer->pmax_out[afi][safi]); |
16660 | ||
dd65f45e DL |
16661 | /* Route server client. */ |
16662 | if (peergroup_af_flag_check(peer, afi, safi, | |
16663 | PEER_FLAG_RSERVER_CLIENT)) { | |
16664 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
16665 | } | |
16666 | ||
16667 | /* Nexthop-local unchanged. */ | |
16668 | if (peergroup_af_flag_check(peer, afi, safi, | |
16669 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
16670 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
16671 | } | |
16672 | ||
16673 | /* allowas-in <1-10> */ | |
16674 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
16675 | if (peer_af_flag_check(peer, afi, safi, | |
16676 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
16677 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
16678 | } else if (peer->allowas_in[afi][safi] == 3) { | |
16679 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
16680 | } else { | |
16681 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
16682 | peer->allowas_in[afi][safi]); | |
16683 | } | |
16684 | } | |
16685 | ||
16686 | /* weight */ | |
16687 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
16688 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
16689 | peer->weight[afi][safi]); | |
16690 | ||
16691 | /* Filter. */ | |
16692 | bgp_config_write_filter(vty, peer, afi, safi); | |
16693 | ||
16694 | /* atribute-unchanged. */ | |
16695 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
16696 | || (safi != SAFI_EVPN | |
16697 | && peer_af_flag_check(peer, afi, safi, | |
16698 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
16699 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
16700 | ||
16701 | if (!peer_group_active(peer) | |
16702 | || peergroup_af_flag_check(peer, afi, safi, | |
16703 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16704 | || peergroup_af_flag_check(peer, afi, safi, | |
16705 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16706 | || peergroup_af_flag_check(peer, afi, safi, | |
16707 | PEER_FLAG_MED_UNCHANGED)) { | |
16708 | ||
16709 | vty_out(vty, | |
16710 | " neighbor %s attribute-unchanged%s%s%s\n", | |
16711 | addr, | |
16712 | peer_af_flag_check(peer, afi, safi, | |
16713 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16714 | ? " as-path" | |
16715 | : "", | |
16716 | peer_af_flag_check(peer, afi, safi, | |
16717 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16718 | ? " next-hop" | |
16719 | : "", | |
16720 | peer_af_flag_check(peer, afi, safi, | |
16721 | PEER_FLAG_MED_UNCHANGED) | |
16722 | ? " med" | |
16723 | : ""); | |
16724 | } | |
16725 | } | |
16726 | } | |
16727 | ||
16728 | /* Address family based peer configuration display. */ | |
16729 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
16730 | safi_t safi) | |
16731 | { | |
16732 | struct peer *peer; | |
16733 | struct peer_group *group; | |
16734 | struct listnode *node, *nnode; | |
16735 | ||
16736 | ||
16737 | vty_frame(vty, " !\n address-family "); | |
16738 | if (afi == AFI_IP) { | |
16739 | if (safi == SAFI_UNICAST) | |
16740 | vty_frame(vty, "ipv4 unicast"); | |
16741 | else if (safi == SAFI_LABELED_UNICAST) | |
16742 | vty_frame(vty, "ipv4 labeled-unicast"); | |
16743 | else if (safi == SAFI_MULTICAST) | |
16744 | vty_frame(vty, "ipv4 multicast"); | |
16745 | else if (safi == SAFI_MPLS_VPN) | |
16746 | vty_frame(vty, "ipv4 vpn"); | |
16747 | else if (safi == SAFI_ENCAP) | |
16748 | vty_frame(vty, "ipv4 encap"); | |
16749 | else if (safi == SAFI_FLOWSPEC) | |
16750 | vty_frame(vty, "ipv4 flowspec"); | |
16751 | } else if (afi == AFI_IP6) { | |
16752 | if (safi == SAFI_UNICAST) | |
16753 | vty_frame(vty, "ipv6 unicast"); | |
16754 | else if (safi == SAFI_LABELED_UNICAST) | |
16755 | vty_frame(vty, "ipv6 labeled-unicast"); | |
16756 | else if (safi == SAFI_MULTICAST) | |
16757 | vty_frame(vty, "ipv6 multicast"); | |
16758 | else if (safi == SAFI_MPLS_VPN) | |
16759 | vty_frame(vty, "ipv6 vpn"); | |
16760 | else if (safi == SAFI_ENCAP) | |
16761 | vty_frame(vty, "ipv6 encap"); | |
16762 | else if (safi == SAFI_FLOWSPEC) | |
16763 | vty_frame(vty, "ipv6 flowspec"); | |
16764 | } else if (afi == AFI_L2VPN) { | |
16765 | if (safi == SAFI_EVPN) | |
16766 | vty_frame(vty, "l2vpn evpn"); | |
16767 | } | |
16768 | vty_frame(vty, "\n"); | |
16769 | ||
16770 | bgp_config_write_distance(vty, bgp, afi, safi); | |
16771 | ||
16772 | bgp_config_write_network(vty, bgp, afi, safi); | |
16773 | ||
16774 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
16775 | ||
8a4e7fe6 DA |
16776 | /* BGP flag dampening. */ |
16777 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
16778 | bgp_config_write_damp(vty, afi, safi); | |
16779 | ||
dd65f45e DL |
16780 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
16781 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
16782 | ||
16783 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
16784 | /* Skip dynamic neighbors. */ | |
16785 | if (peer_dynamic_neighbor(peer)) | |
16786 | continue; | |
16787 | ||
16788 | /* Do not display doppelganger peers */ | |
16789 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
16790 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
16791 | } | |
16792 | ||
16793 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
16794 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
16795 | ||
16796 | if (safi == SAFI_EVPN) | |
16797 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
16798 | ||
16799 | if (safi == SAFI_FLOWSPEC) | |
16800 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
16801 | ||
16802 | if (safi == SAFI_UNICAST) { | |
16803 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
16804 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16805 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
16806 | ||
16807 | vty_out(vty, " export vpn\n"); | |
16808 | } | |
16809 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16810 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
16811 | ||
16812 | vty_out(vty, " import vpn\n"); | |
16813 | } | |
16814 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16815 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
16816 | char *name; | |
16817 | ||
16818 | for (ALL_LIST_ELEMENTS_RO( | |
16819 | bgp->vpn_policy[afi].import_vrf, node, | |
16820 | name)) | |
16821 | vty_out(vty, " import vrf %s\n", name); | |
16822 | } | |
16823 | } | |
16824 | ||
16825 | vty_endframe(vty, " exit-address-family\n"); | |
16826 | } | |
16827 | ||
16828 | int bgp_config_write(struct vty *vty) | |
16829 | { | |
16830 | struct bgp *bgp; | |
16831 | struct peer_group *group; | |
16832 | struct peer *peer; | |
16833 | struct listnode *node, *nnode; | |
16834 | struct listnode *mnode, *mnnode; | |
16835 | ||
16836 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
16837 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
16838 | bm->rmap_update_timer); | |
16839 | ||
d70583f7 D |
16840 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
16841 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
16842 | if (bm->v_update_delay != bm->v_establish_wait) | |
16843 | vty_out(vty, " %d", bm->v_establish_wait); | |
16844 | vty_out(vty, "\n"); | |
16845 | } | |
16846 | ||
05bd726c | 16847 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
16848 | vty_out(vty, "bgp graceful-shutdown\n"); | |
16849 | ||
c163f297 DS |
16850 | /* No-RIB (Zebra) option flag configuration */ |
16851 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
16852 | vty_out(vty, "bgp no-rib\n"); | |
16853 | ||
dd65f45e DL |
16854 | /* BGP configuration. */ |
16855 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
16856 | ||
16857 | /* skip all auto created vrf as they dont have user config */ | |
16858 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
16859 | continue; | |
16860 | ||
16861 | /* Router bgp ASN */ | |
16862 | vty_out(vty, "router bgp %u", bgp->as); | |
16863 | ||
16864 | if (bgp->name) | |
16865 | vty_out(vty, " %s %s", | |
16866 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
16867 | ? "view" : "vrf", bgp->name); | |
16868 | vty_out(vty, "\n"); | |
16869 | ||
16870 | /* BGP fast-external-failover. */ | |
16871 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
16872 | vty_out(vty, " no bgp fast-external-failover\n"); | |
16873 | ||
16874 | /* BGP router ID. */ | |
16875 | if (bgp->router_id_static.s_addr != 0) | |
23d0a753 DA |
16876 | vty_out(vty, " bgp router-id %pI4\n", |
16877 | &bgp->router_id_static); | |
dd65f45e | 16878 | |
c208c586 S |
16879 | /* Suppress fib pending */ |
16880 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
16881 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
16882 | ||
dd65f45e | 16883 | /* BGP log-neighbor-changes. */ |
892fedb6 | 16884 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 16885 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 16886 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
16887 | CHECK_FLAG(bgp->flags, |
16888 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
16889 | ? "" |
16890 | : "no "); | |
16891 | ||
16892 | /* BGP configuration. */ | |
892fedb6 | 16893 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
16894 | vty_out(vty, " bgp always-compare-med\n"); |
16895 | ||
16896 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
16897 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
16898 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
16899 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
16900 | CHECK_FLAG(bgp->flags, | |
16901 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
16902 | ? "" | |
16903 | : "no "); | |
dd65f45e DL |
16904 | |
16905 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 16906 | if (bgp->reject_as_sets) |
dd65f45e DL |
16907 | vty_out(vty, " bgp reject-as-sets\n"); |
16908 | ||
16909 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 16910 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
16911 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
16912 | ||
16913 | /* BGP default local-preference. */ | |
16914 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
16915 | vty_out(vty, " bgp default local-preference %u\n", | |
16916 | bgp->default_local_pref); | |
16917 | ||
16918 | /* BGP default show-hostname */ | |
892fedb6 | 16919 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 16920 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 16921 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 16922 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
16923 | ? "" |
16924 | : "no "); | |
16925 | ||
aef999a2 DA |
16926 | /* BGP default show-nexthop-hostname */ |
16927 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16928 | != SAVE_BGP_SHOW_HOSTNAME) | |
16929 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
16930 | CHECK_FLAG(bgp->flags, | |
16931 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16932 | ? "" | |
16933 | : "no "); | |
16934 | ||
dd65f45e DL |
16935 | /* BGP default subgroup-pkt-queue-max. */ |
16936 | if (bgp->default_subgroup_pkt_queue_max | |
16937 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
16938 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
16939 | bgp->default_subgroup_pkt_queue_max); | |
16940 | ||
16941 | /* BGP client-to-client reflection. */ | |
892fedb6 | 16942 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
16943 | vty_out(vty, " no bgp client-to-client reflection\n"); |
16944 | ||
16945 | /* BGP cluster ID. */ | |
16946 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
16947 | vty_out(vty, " bgp cluster-id %pI4\n", |
16948 | &bgp->cluster_id); | |
dd65f45e DL |
16949 | |
16950 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 16951 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
16952 | vty_out(vty, |
16953 | " bgp disable-ebgp-connected-route-check\n"); | |
16954 | ||
16955 | /* Confederation identifier*/ | |
16956 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
16957 | vty_out(vty, " bgp confederation identifier %u\n", | |
16958 | bgp->confed_id); | |
16959 | ||
16960 | /* Confederation peer */ | |
16961 | if (bgp->confed_peers_cnt > 0) { | |
16962 | int i; | |
16963 | ||
16964 | vty_out(vty, " bgp confederation peers"); | |
16965 | ||
16966 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
16967 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
16968 | ||
16969 | vty_out(vty, "\n"); | |
16970 | } | |
16971 | ||
16972 | /* BGP deterministic-med. */ | |
892fedb6 | 16973 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 16974 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 16975 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
16976 | CHECK_FLAG(bgp->flags, |
16977 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
16978 | ? "" |
16979 | : "no "); | |
16980 | ||
16981 | /* BGP update-delay. */ | |
16982 | bgp_config_write_update_delay(vty, bgp); | |
16983 | ||
16984 | if (bgp->v_maxmed_onstartup | |
16985 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
16986 | vty_out(vty, " bgp max-med on-startup %u", | |
16987 | bgp->v_maxmed_onstartup); | |
16988 | if (bgp->maxmed_onstartup_value | |
16989 | != BGP_MAXMED_VALUE_DEFAULT) | |
16990 | vty_out(vty, " %u", | |
16991 | bgp->maxmed_onstartup_value); | |
16992 | vty_out(vty, "\n"); | |
16993 | } | |
16994 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
16995 | vty_out(vty, " bgp max-med administrative"); | |
16996 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
16997 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
16998 | vty_out(vty, "\n"); | |
16999 | } | |
17000 | ||
17001 | /* write quanta */ | |
17002 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17003 | /* read quanta */ | |
17004 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17005 | ||
17006 | /* coalesce time */ | |
17007 | bgp_config_write_coalesce_time(vty, bgp); | |
17008 | ||
05bd726c | 17009 | /* BGP per-instance graceful-shutdown */ |
17010 | /* BGP-wide settings and per-instance settings are mutually | |
17011 | * exclusive. | |
17012 | */ | |
17013 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17014 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17015 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17016 | ||
dd65f45e DL |
17017 | /* BGP graceful-restart. */ |
17018 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17019 | vty_out(vty, | |
17020 | " bgp graceful-restart stalepath-time %u\n", | |
17021 | bgp->stalepath_time); | |
cfd47646 | 17022 | |
dd65f45e DL |
17023 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
17024 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17025 | bgp->restart_time); | |
cfd47646 | 17026 | |
17027 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
17028 | vty_out(vty, | |
17029 | " bgp graceful-restart select-defer-time %u\n", | |
17030 | bgp->select_defer_time); | |
17031 | ||
17032 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17033 | vty_out(vty, " bgp graceful-restart\n"); |
17034 | ||
cfd47646 | 17035 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17036 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17037 | ||
dd65f45e | 17038 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 17039 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
17040 | vty_out(vty, |
17041 | " bgp graceful-restart preserve-fw-state\n"); | |
17042 | ||
dc95985f | 17043 | /* Stale timer for RIB */ |
17044 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17045 | vty_out(vty, | |
17046 | " bgp graceful-restart rib-stale-time %u\n", | |
17047 | bgp->rib_stale_time); | |
17048 | ||
dd65f45e | 17049 | /* BGP bestpath method. */ |
892fedb6 | 17050 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 17051 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 17052 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
17053 | vty_out(vty, " bgp bestpath as-path confed\n"); |
17054 | ||
892fedb6 DA |
17055 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
17056 | if (CHECK_FLAG(bgp->flags, | |
17057 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
17058 | vty_out(vty, |
17059 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17060 | } else { | |
17061 | vty_out(vty, | |
17062 | " bgp bestpath as-path multipath-relax\n"); | |
17063 | } | |
17064 | } | |
17065 | ||
892fedb6 | 17066 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
17067 | vty_out(vty, |
17068 | " bgp route-reflector allow-outbound-policy\n"); | |
17069 | } | |
892fedb6 | 17070 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 17071 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
17072 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
17073 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 17074 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 17075 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 17076 | vty_out(vty, " confed"); |
892fedb6 DA |
17077 | if (CHECK_FLAG(bgp->flags, |
17078 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
17079 | vty_out(vty, " missing-as-worst"); |
17080 | vty_out(vty, "\n"); | |
17081 | } | |
17082 | ||
f7e1c681 | 17083 | /* Link bandwidth handling. */ |
17084 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17085 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17086 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17087 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17088 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17089 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17090 | ||
dd65f45e | 17091 | /* BGP network import check. */ |
892fedb6 | 17092 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 17093 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 17094 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 17095 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
17096 | ? "" |
17097 | : "no "); | |
17098 | ||
17099 | /* BGP timers configuration. */ | |
5d5393b9 DL |
17100 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
17101 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
17102 | vty_out(vty, " timers bgp %u %u\n", |
17103 | bgp->default_keepalive, bgp->default_holdtime); | |
17104 | ||
17105 | /* peer-group */ | |
17106 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17107 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17108 | } | |
17109 | ||
17110 | /* Normal neighbor configuration. */ | |
17111 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17112 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17113 | bgp_config_write_peer_global(vty, bgp, peer); | |
17114 | } | |
17115 | ||
17116 | /* listen range and limit for dynamic BGP neighbors */ | |
17117 | bgp_config_write_listen(vty, bgp); | |
17118 | ||
17119 | /* | |
17120 | * BGP default autoshutdown neighbors | |
17121 | * | |
17122 | * This must be placed after any peer and peer-group | |
17123 | * configuration, to avoid setting all peers to shutdown after | |
17124 | * a daemon restart, which is undesired behavior. (see #2286) | |
17125 | */ | |
17126 | if (bgp->autoshutdown) | |
17127 | vty_out(vty, " bgp default shutdown\n"); | |
17128 | ||
9cf59432 DS |
17129 | /* BGP instance administrative shutdown */ |
17130 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17131 | vty_out(vty, " bgp shutdown\n"); | |
17132 | ||
dd65f45e DL |
17133 | /* IPv4 unicast configuration. */ |
17134 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17135 | ||
17136 | /* IPv4 multicast configuration. */ | |
17137 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17138 | ||
17139 | /* IPv4 labeled-unicast configuration. */ | |
17140 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17141 | ||
17142 | /* IPv4 VPN configuration. */ | |
17143 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17144 | ||
17145 | /* ENCAPv4 configuration. */ | |
17146 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17147 | ||
17148 | /* FLOWSPEC v4 configuration. */ | |
17149 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17150 | ||
17151 | /* IPv6 unicast configuration. */ | |
17152 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17153 | ||
17154 | /* IPv6 multicast configuration. */ | |
17155 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17156 | ||
17157 | /* IPv6 labeled-unicast configuration. */ | |
17158 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17159 | SAFI_LABELED_UNICAST); | |
17160 | ||
17161 | /* IPv6 VPN configuration. */ | |
17162 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17163 | ||
17164 | /* ENCAPv6 configuration. */ | |
17165 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17166 | ||
17167 | /* FLOWSPEC v6 configuration. */ | |
17168 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17169 | ||
17170 | /* EVPN configuration. */ | |
17171 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17172 | ||
17173 | hook_call(bgp_inst_config_write, bgp, vty); | |
17174 | ||
49e5a4a0 | 17175 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
17176 | bgp_rfapi_cfg_write(vty, bgp); |
17177 | #endif | |
17178 | ||
17179 | vty_out(vty, "!\n"); | |
17180 | } | |
17181 | return 0; | |
17182 | } | |
17183 | ||
ddb5b488 | 17184 | |
718e3744 | 17185 | /* BGP node structure. */ |
d62a17ae | 17186 | static struct cmd_node bgp_node = { |
f4b8291f | 17187 | .name = "bgp", |
62b346ee | 17188 | .node = BGP_NODE, |
24389580 | 17189 | .parent_node = CONFIG_NODE, |
62b346ee | 17190 | .prompt = "%s(config-router)# ", |
612c2c15 | 17191 | .config_write = bgp_config_write, |
718e3744 | 17192 | }; |
17193 | ||
d62a17ae | 17194 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 17195 | .name = "bgp ipv4 unicast", |
62b346ee | 17196 | .node = BGP_IPV4_NODE, |
24389580 | 17197 | .parent_node = BGP_NODE, |
62b346ee | 17198 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17199 | }; |
17200 | ||
d62a17ae | 17201 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 17202 | .name = "bgp ipv4 multicast", |
62b346ee | 17203 | .node = BGP_IPV4M_NODE, |
24389580 | 17204 | .parent_node = BGP_NODE, |
62b346ee | 17205 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17206 | }; |
17207 | ||
d62a17ae | 17208 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 17209 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 17210 | .node = BGP_IPV4L_NODE, |
24389580 | 17211 | .parent_node = BGP_NODE, |
62b346ee | 17212 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17213 | }; |
17214 | ||
d62a17ae | 17215 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 17216 | .name = "bgp ipv6", |
62b346ee | 17217 | .node = BGP_IPV6_NODE, |
24389580 | 17218 | .parent_node = BGP_NODE, |
62b346ee | 17219 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17220 | }; |
17221 | ||
d62a17ae | 17222 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 17223 | .name = "bgp ipv6 multicast", |
62b346ee | 17224 | .node = BGP_IPV6M_NODE, |
24389580 | 17225 | .parent_node = BGP_NODE, |
62b346ee | 17226 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 17227 | }; |
17228 | ||
d62a17ae | 17229 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 17230 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 17231 | .node = BGP_IPV6L_NODE, |
24389580 | 17232 | .parent_node = BGP_NODE, |
62b346ee | 17233 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17234 | }; |
17235 | ||
62b346ee | 17236 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 17237 | .name = "bgp vpnv4", |
62b346ee | 17238 | .node = BGP_VPNV4_NODE, |
24389580 | 17239 | .parent_node = BGP_NODE, |
62b346ee | 17240 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17241 | }; |
6b0655a2 | 17242 | |
62b346ee | 17243 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 17244 | .name = "bgp vpnv6", |
62b346ee | 17245 | .node = BGP_VPNV6_NODE, |
24389580 | 17246 | .parent_node = BGP_NODE, |
62b346ee | 17247 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17248 | }; |
8ecd3266 | 17249 | |
62b346ee | 17250 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 17251 | .name = "bgp evpn", |
62b346ee | 17252 | .node = BGP_EVPN_NODE, |
24389580 | 17253 | .parent_node = BGP_NODE, |
62b346ee | 17254 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 17255 | }; |
4e0b7b6d | 17256 | |
62b346ee | 17257 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 17258 | .name = "bgp evpn vni", |
62b346ee | 17259 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 17260 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 17261 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 17262 | }; |
90e60aa7 | 17263 | |
62b346ee | 17264 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 17265 | .name = "bgp ipv4 flowspec", |
62b346ee | 17266 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 17267 | .parent_node = BGP_NODE, |
62b346ee | 17268 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17269 | }; |
7c40bf39 | 17270 | |
62b346ee | 17271 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 17272 | .name = "bgp ipv6 flowspec", |
62b346ee | 17273 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 17274 | .parent_node = BGP_NODE, |
62b346ee | 17275 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17276 | }; |
7c40bf39 | 17277 | |
d62a17ae | 17278 | static void community_list_vty(void); |
1f8ae70b | 17279 | |
d62a17ae | 17280 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 17281 | { |
d62a17ae | 17282 | struct bgp *bgp; |
17283 | struct peer *peer; | |
d62a17ae | 17284 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 17285 | |
d62a17ae | 17286 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
17287 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17288 | /* only provide suggestions on the appropriate input | |
17289 | * token type, | |
17290 | * they'll otherwise show up multiple times */ | |
17291 | enum cmd_token_type match_type; | |
17292 | char *name = peer->host; | |
d48ed3e0 | 17293 | |
d62a17ae | 17294 | if (peer->conf_if) { |
17295 | match_type = VARIABLE_TKN; | |
17296 | name = peer->conf_if; | |
17297 | } else if (strchr(peer->host, ':')) | |
17298 | match_type = IPV6_TKN; | |
17299 | else | |
17300 | match_type = IPV4_TKN; | |
d48ed3e0 | 17301 | |
d62a17ae | 17302 | if (token->type != match_type) |
17303 | continue; | |
d48ed3e0 | 17304 | |
d62a17ae | 17305 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
17306 | } | |
d62a17ae | 17307 | } |
b8a815e5 DL |
17308 | } |
17309 | ||
17310 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 17311 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
17312 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 17313 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 17314 | {.completions = NULL}}; |
17315 | ||
47a306a0 DS |
17316 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
17317 | { | |
17318 | struct bgp *bgp; | |
17319 | struct peer_group *group; | |
17320 | struct listnode *lnbgp, *lnpeer; | |
17321 | ||
17322 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17323 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17324 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
17325 | group->name)); | |
17326 | } | |
17327 | } | |
17328 | ||
17329 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
17330 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17331 | {.completions = NULL} }; | |
17332 | ||
d62a17ae | 17333 | void bgp_vty_init(void) |
17334 | { | |
17335 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 17336 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 17337 | |
17338 | /* Install bgp top node. */ | |
612c2c15 DL |
17339 | install_node(&bgp_node); |
17340 | install_node(&bgp_ipv4_unicast_node); | |
17341 | install_node(&bgp_ipv4_multicast_node); | |
17342 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17343 | install_node(&bgp_ipv6_unicast_node); | |
17344 | install_node(&bgp_ipv6_multicast_node); | |
17345 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17346 | install_node(&bgp_vpnv4_node); | |
17347 | install_node(&bgp_vpnv6_node); | |
17348 | install_node(&bgp_evpn_node); | |
17349 | install_node(&bgp_evpn_vni_node); | |
17350 | install_node(&bgp_flowspecv4_node); | |
17351 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 17352 | |
17353 | /* Install default VTY commands to new nodes. */ | |
17354 | install_default(BGP_NODE); | |
17355 | install_default(BGP_IPV4_NODE); | |
17356 | install_default(BGP_IPV4M_NODE); | |
17357 | install_default(BGP_IPV4L_NODE); | |
17358 | install_default(BGP_IPV6_NODE); | |
17359 | install_default(BGP_IPV6M_NODE); | |
17360 | install_default(BGP_IPV6L_NODE); | |
17361 | install_default(BGP_VPNV4_NODE); | |
17362 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 17363 | install_default(BGP_FLOWSPECV4_NODE); |
17364 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 17365 | install_default(BGP_EVPN_NODE); |
17366 | install_default(BGP_EVPN_VNI_NODE); | |
17367 | ||
8029b216 AK |
17368 | /* "bgp local-mac" hidden commands. */ |
17369 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17370 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17371 | ||
d62a17ae | 17372 | /* bgp route-map delay-timer commands. */ |
17373 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17374 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17375 | ||
d70583f7 D |
17376 | /* global bgp update-delay command */ |
17377 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17378 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17379 | ||
05bd726c | 17380 | /* global bgp graceful-shutdown command */ |
17381 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17382 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17383 | ||
d62a17ae | 17384 | /* Dummy commands (Currently not supported) */ |
17385 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17386 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17387 | ||
17388 | /* "router bgp" commands. */ | |
17389 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17390 | ||
17391 | /* "no router bgp" commands. */ | |
17392 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17393 | ||
17394 | /* "bgp router-id" commands. */ | |
17395 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17396 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17397 | ||
c208c586 S |
17398 | /* "bgp suppress-fib-pending" command */ |
17399 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17400 | ||
d62a17ae | 17401 | /* "bgp cluster-id" commands. */ |
17402 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17403 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17404 | ||
c163f297 DS |
17405 | /* "bgp no-rib" commands. */ |
17406 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17407 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17408 | ||
d62a17ae | 17409 | /* "bgp confederation" commands. */ |
17410 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17411 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17412 | ||
17413 | /* "bgp confederation peers" commands. */ | |
17414 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17415 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17416 | ||
17417 | /* bgp max-med command */ | |
17418 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17419 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17420 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17421 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17422 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17423 | ||
17424 | /* bgp disable-ebgp-connected-nh-check */ | |
17425 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17426 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17427 | ||
17428 | /* bgp update-delay command */ | |
17429 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17430 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 17431 | |
17432 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 17433 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 17434 | |
17435 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17436 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17437 | ||
17438 | /* "maximum-paths" commands. */ | |
17439 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17440 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17441 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17442 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17443 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17444 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17445 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17446 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17447 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17448 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17449 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17450 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17451 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17452 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17453 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17454 | ||
39edabac PG |
17455 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
17456 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17457 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17458 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17459 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 17460 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
17461 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17462 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17463 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17464 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17465 | ||
17466 | /* "timers bgp" commands. */ | |
17467 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17468 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17469 | ||
17470 | /* route-map delay-timer commands - per instance for backwards compat. | |
17471 | */ | |
17472 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17473 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17474 | ||
17475 | /* "bgp client-to-client reflection" commands */ | |
17476 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17477 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17478 | ||
17479 | /* "bgp always-compare-med" commands */ | |
17480 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17481 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17482 | ||
9dac9fc8 DA |
17483 | /* bgp ebgp-requires-policy */ |
17484 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17485 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17486 | ||
fb29348a DA |
17487 | /* bgp reject-as-sets */ |
17488 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
17489 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
17490 | ||
d62a17ae | 17491 | /* "bgp deterministic-med" commands */ |
17492 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
17493 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
17494 | ||
055679e9 | 17495 | /* "bgp graceful-restart" command */ |
36235319 QY |
17496 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
17497 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 17498 | |
17499 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
17500 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
17501 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 17502 | |
17503 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
17504 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
17505 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 17506 | |
17507 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
17508 | install_element(BGP_NODE, | |
17509 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
17510 | install_element(BGP_NODE, | |
17511 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
17512 | ||
17513 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
17514 | install_element(BGP_NODE, | |
17515 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
17516 | install_element(BGP_NODE, | |
17517 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
17518 | ||
d62a17ae | 17519 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
17520 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
17521 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
17522 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 17523 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 17524 | install_element(BGP_NODE, |
17525 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 17526 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
17527 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
17528 | ||
d6e3c15b | 17529 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
17530 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 17531 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
17532 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 17533 | |
7f323236 DW |
17534 | /* "bgp graceful-shutdown" commands */ |
17535 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
17536 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
17537 | ||
d62a17ae | 17538 | /* "bgp fast-external-failover" commands */ |
17539 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
17540 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
17541 | ||
d62a17ae | 17542 | /* "bgp bestpath compare-routerid" commands */ |
17543 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
17544 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
17545 | ||
17546 | /* "bgp bestpath as-path ignore" commands */ | |
17547 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
17548 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
17549 | ||
17550 | /* "bgp bestpath as-path confed" commands */ | |
17551 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
17552 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
17553 | ||
17554 | /* "bgp bestpath as-path multipath-relax" commands */ | |
17555 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
17556 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
17557 | ||
17558 | /* "bgp log-neighbor-changes" commands */ | |
17559 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
17560 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
17561 | ||
17562 | /* "bgp bestpath med" commands */ | |
17563 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
17564 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
17565 | ||
f7e1c681 | 17566 | /* "bgp bestpath bandwidth" commands */ |
17567 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 17568 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 17569 | |
d62a17ae | 17570 | /* "no bgp default ipv4-unicast" commands. */ |
17571 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
17572 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
17573 | ||
17574 | /* "bgp network import-check" commands. */ | |
17575 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
17576 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
17577 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
17578 | ||
17579 | /* "bgp default local-preference" commands. */ | |
17580 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
17581 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
17582 | ||
17583 | /* bgp default show-hostname */ | |
17584 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
17585 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
17586 | ||
aef999a2 DA |
17587 | /* bgp default show-nexthop-hostname */ |
17588 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
17589 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
17590 | ||
d62a17ae | 17591 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
17592 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
17593 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
17594 | ||
17595 | /* bgp ibgp-allow-policy-mods command */ | |
17596 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
17597 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
17598 | ||
17599 | /* "bgp listen limit" commands. */ | |
17600 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
17601 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
17602 | ||
17603 | /* "bgp listen range" commands. */ | |
17604 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
17605 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
17606 | ||
8175f54a | 17607 | /* "bgp default shutdown" command */ |
f26845f9 | 17608 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
17609 | |
17610 | /* "bgp shutdown" commands */ | |
17611 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 17612 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 17613 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 17614 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 17615 | |
d62a17ae | 17616 | /* "neighbor remote-as" commands. */ |
17617 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
17618 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
17619 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
17620 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
17621 | install_element(BGP_NODE, | |
17622 | &neighbor_interface_v6only_config_remote_as_cmd); | |
17623 | install_element(BGP_NODE, &no_neighbor_cmd); | |
17624 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
17625 | ||
17626 | /* "neighbor peer-group" commands. */ | |
17627 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
17628 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
17629 | install_element(BGP_NODE, | |
17630 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
17631 | ||
17632 | /* "neighbor local-as" commands. */ | |
17633 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
17634 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
17635 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
17636 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
17637 | ||
17638 | /* "neighbor solo" commands. */ | |
17639 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
17640 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
17641 | ||
17642 | /* "neighbor password" commands. */ | |
17643 | install_element(BGP_NODE, &neighbor_password_cmd); | |
17644 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
17645 | ||
17646 | /* "neighbor activate" commands. */ | |
17647 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
17648 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
17649 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
17650 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
17651 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
17652 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
17653 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
17654 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
17655 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 17656 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
17657 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 17658 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
17659 | ||
17660 | /* "no neighbor activate" commands. */ | |
17661 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
17662 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
17663 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
17664 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
17665 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
17666 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
17667 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
17668 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
17669 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 17670 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
17671 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 17672 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
17673 | ||
17674 | /* "neighbor peer-group" set commands. */ | |
17675 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
17676 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17677 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17678 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17679 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17680 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17681 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17682 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17683 | install_element(BGP_FLOWSPECV4_NODE, |
17684 | &neighbor_set_peer_group_hidden_cmd); | |
17685 | install_element(BGP_FLOWSPECV6_NODE, | |
17686 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17687 | |
17688 | /* "no neighbor peer-group unset" commands. */ | |
17689 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
17690 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17691 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17692 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17693 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17694 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17695 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17696 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17697 | install_element(BGP_FLOWSPECV4_NODE, |
17698 | &no_neighbor_set_peer_group_hidden_cmd); | |
17699 | install_element(BGP_FLOWSPECV6_NODE, | |
17700 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17701 | |
17702 | /* "neighbor softreconfiguration inbound" commands.*/ | |
17703 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
17704 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
17705 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17706 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17707 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17708 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17709 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17710 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17711 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17712 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17713 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17714 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17715 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17716 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17717 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17718 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17719 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17720 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 17721 | install_element(BGP_FLOWSPECV4_NODE, |
17722 | &neighbor_soft_reconfiguration_cmd); | |
17723 | install_element(BGP_FLOWSPECV4_NODE, | |
17724 | &no_neighbor_soft_reconfiguration_cmd); | |
17725 | install_element(BGP_FLOWSPECV6_NODE, | |
17726 | &neighbor_soft_reconfiguration_cmd); | |
17727 | install_element(BGP_FLOWSPECV6_NODE, | |
17728 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
17729 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
17730 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 17731 | |
17732 | /* "neighbor attribute-unchanged" commands. */ | |
17733 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
17734 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
17735 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
17736 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17737 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
17738 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17739 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
17740 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
17741 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
17742 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17743 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
17744 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17745 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
17746 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
17747 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
17748 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17749 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
17750 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17751 | ||
17752 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
17753 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
17754 | ||
17755 | /* "nexthop-local unchanged" commands */ | |
17756 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
17757 | install_element(BGP_IPV6_NODE, | |
17758 | &no_neighbor_nexthop_local_unchanged_cmd); | |
17759 | ||
17760 | /* "neighbor next-hop-self" commands. */ | |
17761 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
17762 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
17763 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
17764 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
17765 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
17766 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
17767 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
17768 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
17769 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
17770 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
17771 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
17772 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
17773 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
17774 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
17775 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
17776 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
17777 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
17778 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
17779 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
17780 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 17781 | |
17782 | /* "neighbor next-hop-self force" commands. */ | |
17783 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
17784 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
17785 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17786 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17787 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
17788 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17789 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17790 | install_element(BGP_IPV4_NODE, | |
17791 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17792 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
17793 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17794 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17795 | install_element(BGP_IPV4M_NODE, | |
17796 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17797 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
17798 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17799 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17800 | install_element(BGP_IPV4L_NODE, | |
17801 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17802 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
17803 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17804 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17805 | install_element(BGP_IPV6_NODE, | |
17806 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17807 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
17808 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17809 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17810 | install_element(BGP_IPV6M_NODE, | |
17811 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17812 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
17813 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17814 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17815 | install_element(BGP_IPV6L_NODE, | |
17816 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17817 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
17818 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17819 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17820 | install_element(BGP_VPNV4_NODE, | |
17821 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17822 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
17823 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17824 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17825 | install_element(BGP_VPNV6_NODE, | |
17826 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
17827 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
17828 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 17829 | |
17830 | /* "neighbor as-override" commands. */ | |
17831 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
17832 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
17833 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
17834 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
17835 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
17836 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
17837 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
17838 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
17839 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
17840 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
17841 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
17842 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
17843 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
17844 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
17845 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
17846 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
17847 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
17848 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
17849 | ||
17850 | /* "neighbor remove-private-AS" commands. */ | |
17851 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
17852 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
17853 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
17854 | install_element(BGP_NODE, | |
17855 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
17856 | install_element(BGP_NODE, | |
17857 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
17858 | install_element(BGP_NODE, | |
17859 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
17860 | install_element(BGP_NODE, | |
17861 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
17862 | install_element( | |
17863 | BGP_NODE, | |
17864 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
17865 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
17866 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
17867 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
17868 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17869 | install_element(BGP_IPV4_NODE, | |
17870 | &neighbor_remove_private_as_replace_as_cmd); | |
17871 | install_element(BGP_IPV4_NODE, | |
17872 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17873 | install_element(BGP_IPV4_NODE, | |
17874 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17875 | install_element(BGP_IPV4_NODE, | |
17876 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17877 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
17878 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
17879 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
17880 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17881 | install_element(BGP_IPV4M_NODE, | |
17882 | &neighbor_remove_private_as_replace_as_cmd); | |
17883 | install_element(BGP_IPV4M_NODE, | |
17884 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17885 | install_element(BGP_IPV4M_NODE, | |
17886 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17887 | install_element(BGP_IPV4M_NODE, | |
17888 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17889 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
17890 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
17891 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
17892 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17893 | install_element(BGP_IPV4L_NODE, | |
17894 | &neighbor_remove_private_as_replace_as_cmd); | |
17895 | install_element(BGP_IPV4L_NODE, | |
17896 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17897 | install_element(BGP_IPV4L_NODE, | |
17898 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17899 | install_element(BGP_IPV4L_NODE, | |
17900 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17901 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
17902 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17903 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17904 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17905 | install_element(BGP_IPV6_NODE, | |
17906 | &neighbor_remove_private_as_replace_as_cmd); | |
17907 | install_element(BGP_IPV6_NODE, | |
17908 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17909 | install_element(BGP_IPV6_NODE, | |
17910 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17911 | install_element(BGP_IPV6_NODE, | |
17912 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17913 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
17914 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
17915 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
17916 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17917 | install_element(BGP_IPV6M_NODE, | |
17918 | &neighbor_remove_private_as_replace_as_cmd); | |
17919 | install_element(BGP_IPV6M_NODE, | |
17920 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17921 | install_element(BGP_IPV6M_NODE, | |
17922 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17923 | install_element(BGP_IPV6M_NODE, | |
17924 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17925 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
17926 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
17927 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
17928 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17929 | install_element(BGP_IPV6L_NODE, | |
17930 | &neighbor_remove_private_as_replace_as_cmd); | |
17931 | install_element(BGP_IPV6L_NODE, | |
17932 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17933 | install_element(BGP_IPV6L_NODE, | |
17934 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17935 | install_element(BGP_IPV6L_NODE, | |
17936 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17937 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
17938 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
17939 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
17940 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17941 | install_element(BGP_VPNV4_NODE, | |
17942 | &neighbor_remove_private_as_replace_as_cmd); | |
17943 | install_element(BGP_VPNV4_NODE, | |
17944 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17945 | install_element(BGP_VPNV4_NODE, | |
17946 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17947 | install_element(BGP_VPNV4_NODE, | |
17948 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17949 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
17950 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17951 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17952 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17953 | install_element(BGP_VPNV6_NODE, | |
17954 | &neighbor_remove_private_as_replace_as_cmd); | |
17955 | install_element(BGP_VPNV6_NODE, | |
17956 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17957 | install_element(BGP_VPNV6_NODE, | |
17958 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17959 | install_element(BGP_VPNV6_NODE, | |
17960 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17961 | ||
17962 | /* "neighbor send-community" commands.*/ | |
17963 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
17964 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
17965 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
17966 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
17967 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
17968 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
17969 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
17970 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
17971 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
17972 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
17973 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
17974 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
17975 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
17976 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
17977 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
17978 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
17979 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
17980 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
17981 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
17982 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
17983 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
17984 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
17985 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
17986 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
17987 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
17988 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
17989 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
17990 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
17991 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
17992 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
17993 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
17994 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
17995 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
17996 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
17997 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
17998 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
17999 | ||
18000 | /* "neighbor route-reflector" commands.*/ | |
18001 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
18002 | install_element(BGP_NODE, | |
18003 | &no_neighbor_route_reflector_client_hidden_cmd); | |
18004 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
18005 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
18006 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
18007 | install_element(BGP_IPV4M_NODE, | |
18008 | &no_neighbor_route_reflector_client_cmd); | |
18009 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
18010 | install_element(BGP_IPV4L_NODE, | |
18011 | &no_neighbor_route_reflector_client_cmd); | |
18012 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
18013 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
18014 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
18015 | install_element(BGP_IPV6M_NODE, | |
18016 | &no_neighbor_route_reflector_client_cmd); | |
18017 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
18018 | install_element(BGP_IPV6L_NODE, | |
18019 | &no_neighbor_route_reflector_client_cmd); | |
18020 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
18021 | install_element(BGP_VPNV4_NODE, | |
18022 | &no_neighbor_route_reflector_client_cmd); | |
18023 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
18024 | install_element(BGP_VPNV6_NODE, | |
18025 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 18026 | install_element(BGP_FLOWSPECV4_NODE, |
18027 | &neighbor_route_reflector_client_cmd); | |
18028 | install_element(BGP_FLOWSPECV4_NODE, | |
18029 | &no_neighbor_route_reflector_client_cmd); | |
18030 | install_element(BGP_FLOWSPECV6_NODE, | |
18031 | &neighbor_route_reflector_client_cmd); | |
18032 | install_element(BGP_FLOWSPECV6_NODE, | |
18033 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 18034 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
18035 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18036 | ||
18037 | /* "neighbor route-server" commands.*/ | |
18038 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18039 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18040 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18041 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18042 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18043 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18044 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18045 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18046 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18047 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18048 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18049 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18050 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18051 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18052 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18053 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18054 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18055 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
18056 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
18057 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 18058 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
18059 | install_element(BGP_FLOWSPECV4_NODE, | |
18060 | &no_neighbor_route_server_client_cmd); | |
18061 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18062 | install_element(BGP_FLOWSPECV6_NODE, | |
18063 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 18064 | |
18065 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
18066 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18067 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18068 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18069 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18070 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18071 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18072 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18073 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18074 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18075 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18076 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18077 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18078 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18079 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18080 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18081 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18082 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18083 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18084 | ||
18085 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18086 | install_element(BGP_NODE, | |
18087 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18088 | install_element(BGP_NODE, | |
18089 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18090 | install_element(BGP_IPV4_NODE, | |
18091 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18092 | install_element(BGP_IPV4_NODE, | |
18093 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18094 | install_element(BGP_IPV4M_NODE, | |
18095 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18096 | install_element(BGP_IPV4M_NODE, | |
18097 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18098 | install_element(BGP_IPV4L_NODE, | |
18099 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18100 | install_element(BGP_IPV4L_NODE, | |
18101 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18102 | install_element(BGP_IPV6_NODE, | |
18103 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18104 | install_element(BGP_IPV6_NODE, | |
18105 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18106 | install_element(BGP_IPV6M_NODE, | |
18107 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18108 | install_element(BGP_IPV6M_NODE, | |
18109 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18110 | install_element(BGP_IPV6L_NODE, | |
18111 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18112 | install_element(BGP_IPV6L_NODE, | |
18113 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18114 | install_element(BGP_VPNV4_NODE, | |
18115 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18116 | install_element(BGP_VPNV4_NODE, | |
18117 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18118 | install_element(BGP_VPNV6_NODE, | |
18119 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18120 | install_element(BGP_VPNV6_NODE, | |
18121 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18122 | ||
2b31007c RZ |
18123 | /* "neighbor sender-as-path-loop-detection" commands. */ |
18124 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18125 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18126 | ||
d62a17ae | 18127 | /* "neighbor passive" commands. */ |
18128 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18129 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18130 | ||
18131 | ||
18132 | /* "neighbor shutdown" commands. */ | |
18133 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18134 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18135 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18136 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
18137 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
18138 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 18139 | |
18140 | /* "neighbor capability extended-nexthop" commands.*/ | |
18141 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18142 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18143 | ||
18144 | /* "neighbor capability orf prefix-list" commands.*/ | |
18145 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18146 | install_element(BGP_NODE, | |
18147 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18148 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18149 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18150 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18151 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18152 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18153 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18154 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18155 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18156 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18157 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18158 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18159 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18160 | ||
18161 | /* "neighbor capability dynamic" commands.*/ | |
18162 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18163 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18164 | ||
18165 | /* "neighbor dont-capability-negotiate" commands. */ | |
18166 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18167 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18168 | ||
18169 | /* "neighbor ebgp-multihop" commands. */ | |
18170 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18171 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18172 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18173 | ||
18174 | /* "neighbor disable-connected-check" commands. */ | |
18175 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18176 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18177 | ||
47cbc09b PM |
18178 | /* "neighbor enforce-first-as" commands. */ |
18179 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18180 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18181 | ||
d62a17ae | 18182 | /* "neighbor description" commands. */ |
18183 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18184 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 18185 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 18186 | |
18187 | /* "neighbor update-source" commands. "*/ | |
18188 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18189 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18190 | ||
18191 | /* "neighbor default-originate" commands. */ | |
18192 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18193 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18194 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18195 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18196 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18197 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18198 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18199 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18200 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18201 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18202 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18203 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18204 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18205 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18206 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18207 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18208 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18209 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18210 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18211 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18212 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18213 | ||
18214 | /* "neighbor port" commands. */ | |
18215 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18216 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18217 | ||
18218 | /* "neighbor weight" commands. */ | |
18219 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18220 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18221 | ||
18222 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18223 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18224 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18225 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18226 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18227 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18228 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18229 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18230 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18231 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18232 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18233 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18234 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18235 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18236 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18237 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18238 | ||
18239 | /* "neighbor override-capability" commands. */ | |
18240 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18241 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18242 | ||
18243 | /* "neighbor strict-capability-match" commands. */ | |
18244 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18245 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18246 | ||
18247 | /* "neighbor timers" commands. */ | |
18248 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18249 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18250 | ||
18251 | /* "neighbor timers connect" commands. */ | |
18252 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18253 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18254 | ||
18255 | /* "neighbor advertisement-interval" commands. */ | |
18256 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18257 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18258 | ||
18259 | /* "neighbor interface" commands. */ | |
18260 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18261 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18262 | ||
18263 | /* "neighbor distribute" commands. */ | |
18264 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18265 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18266 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18267 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18268 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18269 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18270 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18271 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18272 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18273 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18274 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18275 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18276 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18277 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18278 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18279 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18280 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18281 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18282 | ||
18283 | /* "neighbor prefix-list" commands. */ | |
18284 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
18285 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
18286 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
18287 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
18288 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
18289 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
18290 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
18291 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
18292 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
18293 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
18294 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
18295 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
18296 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
18297 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
18298 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
18299 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
18300 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
18301 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 18302 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
18303 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
18304 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
18305 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 18306 | |
18307 | /* "neighbor filter-list" commands. */ | |
18308 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18309 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18310 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18311 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18312 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18313 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18314 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18315 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18316 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18317 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18318 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18319 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18320 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18321 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18322 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18323 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18324 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18325 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 18326 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
18327 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18328 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18329 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 18330 | |
18331 | /* "neighbor route-map" commands. */ | |
18332 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
18333 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
18334 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
18335 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
18336 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
18337 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
18338 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
18339 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
18340 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
18341 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
18342 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
18343 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
18344 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
18345 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
18346 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
18347 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
18348 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
18349 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 18350 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
18351 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
18352 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
18353 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
18354 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
18355 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 18356 | |
18357 | /* "neighbor unsuppress-map" commands. */ | |
18358 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18359 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18360 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18361 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18362 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18363 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18364 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18365 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18366 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18367 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18368 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18369 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18370 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18371 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18372 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18373 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18374 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18375 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18376 | ||
7f7940e6 MK |
18377 | /* "neighbor advertise-map" commands. */ |
18378 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); | |
7f7940e6 | 18379 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18380 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18381 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18382 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18383 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18384 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18385 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18386 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18387 | |
fde246e8 DA |
18388 | /* neighbor maximum-prefix-out commands. */ |
18389 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18390 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18391 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18392 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18393 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18394 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18395 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18396 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18397 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18398 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18399 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18400 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18401 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18402 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18403 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18404 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18405 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18406 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18407 | ||
d62a17ae | 18408 | /* "neighbor maximum-prefix" commands. */ |
18409 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18410 | install_element(BGP_NODE, | |
18411 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18412 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18413 | install_element(BGP_NODE, | |
18414 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18415 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18416 | install_element(BGP_NODE, | |
18417 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18418 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18419 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18420 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18421 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18422 | install_element(BGP_IPV4_NODE, | |
18423 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18424 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18425 | install_element(BGP_IPV4_NODE, | |
18426 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18427 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18428 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18429 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18430 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18431 | install_element(BGP_IPV4M_NODE, | |
18432 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18433 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18434 | install_element(BGP_IPV4M_NODE, | |
18435 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18436 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18437 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
18438 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18439 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18440 | install_element(BGP_IPV4L_NODE, | |
18441 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18442 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18443 | install_element(BGP_IPV4L_NODE, | |
18444 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18445 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18446 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
18447 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18448 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18449 | install_element(BGP_IPV6_NODE, | |
18450 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18451 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18452 | install_element(BGP_IPV6_NODE, | |
18453 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18454 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18455 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
18456 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18457 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18458 | install_element(BGP_IPV6M_NODE, | |
18459 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18460 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18461 | install_element(BGP_IPV6M_NODE, | |
18462 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18463 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18464 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
18465 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18466 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18467 | install_element(BGP_IPV6L_NODE, | |
18468 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18469 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18470 | install_element(BGP_IPV6L_NODE, | |
18471 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18472 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18473 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
18474 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18475 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18476 | install_element(BGP_VPNV4_NODE, | |
18477 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18478 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18479 | install_element(BGP_VPNV4_NODE, | |
18480 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18481 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18482 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
18483 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18484 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18485 | install_element(BGP_VPNV6_NODE, | |
18486 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18487 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18488 | install_element(BGP_VPNV6_NODE, | |
18489 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18490 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18491 | ||
18492 | /* "neighbor allowas-in" */ | |
18493 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
18494 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
18495 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
18496 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
18497 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
18498 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
18499 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
18500 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
18501 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
18502 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
18503 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
18504 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
18505 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
18506 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
18507 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
18508 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
18509 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
18510 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
18511 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
18512 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
18513 | ||
18514 | /* address-family commands. */ | |
18515 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
18516 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 18517 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 18518 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
18519 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 18520 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 18521 | |
d62a17ae | 18522 | install_element(BGP_NODE, &address_family_evpn_cmd); |
18523 | ||
18524 | /* "exit-address-family" command. */ | |
18525 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
18526 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
18527 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
18528 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
18529 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
18530 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
18531 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
18532 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 18533 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
18534 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 18535 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
18536 | ||
18537 | /* "clear ip bgp commands" */ | |
18538 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
18539 | ||
18540 | /* clear ip bgp prefix */ | |
18541 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
18542 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
18543 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
18544 | ||
18545 | /* "show [ip] bgp summary" commands. */ | |
18546 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 18547 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 18548 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 18549 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 18550 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
18551 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 18552 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
18553 | ||
18554 | /* "show [ip] bgp neighbors" commands. */ | |
18555 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
18556 | ||
36235319 | 18557 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 18558 | |
d62a17ae | 18559 | /* "show [ip] bgp peer-group" commands. */ |
18560 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
18561 | ||
18562 | /* "show [ip] bgp paths" commands. */ | |
18563 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
18564 | ||
18565 | /* "show [ip] bgp community" commands. */ | |
18566 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
18567 | ||
18568 | /* "show ip bgp large-community" commands. */ | |
18569 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
18570 | /* "show [ip] bgp attribute-info" commands. */ | |
18571 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 18572 | /* "show [ip] bgp route-leak" command */ |
18573 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 18574 | |
18575 | /* "redistribute" commands. */ | |
18576 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
18577 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
18578 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
18579 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
18580 | install_element(BGP_NODE, | |
18581 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
18582 | install_element(BGP_NODE, | |
18583 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
18584 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18585 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18586 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
18587 | install_element(BGP_NODE, | |
18588 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
18589 | install_element(BGP_NODE, | |
18590 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
18591 | install_element(BGP_NODE, | |
18592 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
18593 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
18594 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
18595 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
18596 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
18597 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
18598 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
18599 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
18600 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
18601 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
18602 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
18603 | install_element(BGP_IPV4_NODE, | |
18604 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
18605 | install_element(BGP_IPV4_NODE, | |
18606 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
18607 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
18608 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
18609 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
18610 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
18611 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
18612 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
18613 | ||
b9c7bc5a PZ |
18614 | /* import|export vpn [route-map WORD] */ |
18615 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
18616 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 18617 | |
12a844a5 DS |
18618 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
18619 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
18620 | ||
d62a17ae | 18621 | /* ttl_security commands */ |
18622 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
18623 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
18624 | ||
18625 | /* "show [ip] bgp memory" commands. */ | |
18626 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
18627 | ||
acf71666 MK |
18628 | /* "show bgp martian next-hop" */ |
18629 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
18630 | ||
48ecf8f5 DS |
18631 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
18632 | ||
d62a17ae | 18633 | /* "show [ip] bgp views" commands. */ |
18634 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
18635 | ||
18636 | /* "show [ip] bgp vrfs" commands. */ | |
18637 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
18638 | ||
18639 | /* Community-list. */ | |
18640 | community_list_vty(); | |
ddb5b488 PZ |
18641 | |
18642 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
18643 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
18644 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
18645 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
18646 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
18647 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
18648 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
18649 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
18650 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
18651 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
18652 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18653 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
18654 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 18655 | |
301ad80a PG |
18656 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
18657 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
18658 | ||
b9c7bc5a PZ |
18659 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
18660 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
18661 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
18662 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
18663 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
18664 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
18665 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
18666 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18667 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
18668 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 18669 | } |
6b0655a2 | 18670 | |
718e3744 | 18671 | #include "memory.h" |
18672 | #include "bgp_regex.h" | |
18673 | #include "bgp_clist.h" | |
18674 | #include "bgp_ecommunity.h" | |
18675 | ||
18676 | /* VTY functions. */ | |
18677 | ||
18678 | /* Direction value to string conversion. */ | |
d62a17ae | 18679 | static const char *community_direct_str(int direct) |
18680 | { | |
18681 | switch (direct) { | |
18682 | case COMMUNITY_DENY: | |
18683 | return "deny"; | |
18684 | case COMMUNITY_PERMIT: | |
18685 | return "permit"; | |
18686 | default: | |
18687 | return "unknown"; | |
18688 | } | |
718e3744 | 18689 | } |
18690 | ||
18691 | /* Display error string. */ | |
d62a17ae | 18692 | static void community_list_perror(struct vty *vty, int ret) |
18693 | { | |
18694 | switch (ret) { | |
18695 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
18696 | vty_out(vty, "%% Can't find community-list\n"); | |
18697 | break; | |
18698 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
18699 | vty_out(vty, "%% Malformed community-list value\n"); | |
18700 | break; | |
18701 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
18702 | vty_out(vty, | |
18703 | "%% Community name conflict, previously defined as standard community\n"); | |
18704 | break; | |
18705 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
18706 | vty_out(vty, | |
18707 | "%% Community name conflict, previously defined as expanded community\n"); | |
18708 | break; | |
18709 | } | |
718e3744 | 18710 | } |
18711 | ||
5bf15956 DW |
18712 | /* "community-list" keyword help string. */ |
18713 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
18714 | ||
7336e101 SP |
18715 | /*community-list standard */ |
18716 | DEFUN (community_list_standard, | |
18717 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 18718 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 18719 | BGP_STR |
718e3744 | 18720 | COMMUNITY_LIST_STR |
18721 | "Community list number (standard)\n" | |
5bf15956 | 18722 | "Add an standard community-list entry\n" |
718e3744 | 18723 | "Community list name\n" |
2f8cc0e5 DA |
18724 | "Sequence number of an entry\n" |
18725 | "Sequence number\n" | |
718e3744 | 18726 | "Specify community to reject\n" |
18727 | "Specify community to accept\n" | |
18728 | COMMUNITY_VAL_STR) | |
18729 | { | |
d62a17ae | 18730 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18731 | char *seq = NULL; |
d62a17ae | 18732 | int direct = 0; |
18733 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 18734 | int idx = 0; |
7336e101 | 18735 | |
2f8cc0e5 DA |
18736 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18737 | if (idx) | |
18738 | seq = argv[idx]->arg; | |
18739 | ||
18740 | idx = 0; | |
d62a17ae | 18741 | argv_find(argv, argc, "(1-99)", &idx); |
18742 | argv_find(argv, argc, "WORD", &idx); | |
18743 | cl_name_or_number = argv[idx]->arg; | |
18744 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
18745 | : COMMUNITY_DENY; | |
18746 | argv_find(argv, argc, "AA:NN", &idx); | |
18747 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18748 | |
2f8cc0e5 DA |
18749 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
18750 | direct, style); | |
42f914d4 | 18751 | |
d62a17ae | 18752 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18753 | |
d62a17ae | 18754 | if (ret < 0) { |
18755 | /* Display error string. */ | |
18756 | community_list_perror(vty, ret); | |
18757 | return CMD_WARNING_CONFIG_FAILED; | |
18758 | } | |
42f914d4 | 18759 | |
d62a17ae | 18760 | return CMD_SUCCESS; |
718e3744 | 18761 | } |
18762 | ||
7336e101 SP |
18763 | DEFUN (no_community_list_standard_all, |
18764 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 18765 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18766 | NO_STR |
18767 | BGP_STR | |
18768 | COMMUNITY_LIST_STR | |
18769 | "Community list number (standard)\n" | |
18770 | "Add an standard community-list entry\n" | |
18771 | "Community list name\n" | |
2f8cc0e5 DA |
18772 | "Sequence number of an entry\n" |
18773 | "Sequence number\n" | |
7336e101 SP |
18774 | "Specify community to reject\n" |
18775 | "Specify community to accept\n" | |
18776 | COMMUNITY_VAL_STR) | |
718e3744 | 18777 | { |
d62a17ae | 18778 | char *cl_name_or_number = NULL; |
174b5cb9 | 18779 | char *str = NULL; |
d62a17ae | 18780 | int direct = 0; |
18781 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 18782 | char *seq = NULL; |
d62a17ae | 18783 | int idx = 0; |
7336e101 | 18784 | |
2f8cc0e5 DA |
18785 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18786 | if (idx) | |
18787 | seq = argv[idx]->arg; | |
18788 | ||
18789 | idx = 0; | |
174b5cb9 DA |
18790 | argv_find(argv, argc, "permit", &idx); |
18791 | argv_find(argv, argc, "deny", &idx); | |
18792 | ||
18793 | if (idx) { | |
18794 | direct = argv_find(argv, argc, "permit", &idx) | |
18795 | ? COMMUNITY_PERMIT | |
18796 | : COMMUNITY_DENY; | |
18797 | ||
18798 | idx = 0; | |
18799 | argv_find(argv, argc, "AA:NN", &idx); | |
18800 | str = argv_concat(argv, argc, idx); | |
18801 | } | |
18802 | ||
18803 | idx = 0; | |
d62a17ae | 18804 | argv_find(argv, argc, "(1-99)", &idx); |
18805 | argv_find(argv, argc, "WORD", &idx); | |
18806 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 18807 | |
2f8cc0e5 | 18808 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 18809 | direct, style); |
42f914d4 | 18810 | |
d62a17ae | 18811 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 18812 | |
d62a17ae | 18813 | if (ret < 0) { |
18814 | community_list_perror(vty, ret); | |
18815 | return CMD_WARNING_CONFIG_FAILED; | |
18816 | } | |
42f914d4 | 18817 | |
d62a17ae | 18818 | return CMD_SUCCESS; |
718e3744 | 18819 | } |
7336e101 | 18820 | |
174b5cb9 DA |
18821 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
18822 | "no bgp community-list <(1-99)|standard WORD>", | |
18823 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
18824 | "Community list number (standard)\n" | |
18825 | "Add an standard community-list entry\n" | |
18826 | "Community list name\n") | |
18827 | ||
7336e101 SP |
18828 | /*community-list expanded */ |
18829 | DEFUN (community_list_expanded_all, | |
18830 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 18831 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18832 | BGP_STR |
18833 | COMMUNITY_LIST_STR | |
718e3744 | 18834 | "Community list number (expanded)\n" |
5bf15956 | 18835 | "Add an expanded community-list entry\n" |
718e3744 | 18836 | "Community list name\n" |
2f8cc0e5 DA |
18837 | "Sequence number of an entry\n" |
18838 | "Sequence number\n" | |
718e3744 | 18839 | "Specify community to reject\n" |
18840 | "Specify community to accept\n" | |
18841 | COMMUNITY_VAL_STR) | |
18842 | { | |
d62a17ae | 18843 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18844 | char *seq = NULL; |
d62a17ae | 18845 | int direct = 0; |
18846 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 18847 | int idx = 0; |
7b9a4750 | 18848 | |
2f8cc0e5 DA |
18849 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18850 | if (idx) | |
18851 | seq = argv[idx]->arg; | |
18852 | ||
18853 | idx = 0; | |
18854 | ||
d62a17ae | 18855 | argv_find(argv, argc, "(100-500)", &idx); |
18856 | argv_find(argv, argc, "WORD", &idx); | |
18857 | cl_name_or_number = argv[idx]->arg; | |
18858 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
18859 | : COMMUNITY_DENY; | |
18860 | argv_find(argv, argc, "AA:NN", &idx); | |
18861 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18862 | |
2f8cc0e5 DA |
18863 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
18864 | direct, style); | |
42f914d4 | 18865 | |
d62a17ae | 18866 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18867 | |
d62a17ae | 18868 | if (ret < 0) { |
18869 | /* Display error string. */ | |
18870 | community_list_perror(vty, ret); | |
18871 | return CMD_WARNING_CONFIG_FAILED; | |
18872 | } | |
42f914d4 | 18873 | |
d62a17ae | 18874 | return CMD_SUCCESS; |
718e3744 | 18875 | } |
18876 | ||
7336e101 SP |
18877 | DEFUN (no_community_list_expanded_all, |
18878 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 18879 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18880 | NO_STR |
18881 | BGP_STR | |
18882 | COMMUNITY_LIST_STR | |
18883 | "Community list number (expanded)\n" | |
18884 | "Add an expanded community-list entry\n" | |
18885 | "Community list name\n" | |
2f8cc0e5 DA |
18886 | "Sequence number of an entry\n" |
18887 | "Sequence number\n" | |
7336e101 SP |
18888 | "Specify community to reject\n" |
18889 | "Specify community to accept\n" | |
18890 | COMMUNITY_VAL_STR) | |
718e3744 | 18891 | { |
d62a17ae | 18892 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18893 | char *seq = NULL; |
174b5cb9 | 18894 | char *str = NULL; |
d62a17ae | 18895 | int direct = 0; |
18896 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 18897 | int idx = 0; |
174b5cb9 | 18898 | |
2f8cc0e5 DA |
18899 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18900 | if (idx) | |
18901 | seq = argv[idx]->arg; | |
18902 | ||
18903 | idx = 0; | |
174b5cb9 DA |
18904 | argv_find(argv, argc, "permit", &idx); |
18905 | argv_find(argv, argc, "deny", &idx); | |
18906 | ||
18907 | if (idx) { | |
18908 | direct = argv_find(argv, argc, "permit", &idx) | |
18909 | ? COMMUNITY_PERMIT | |
18910 | : COMMUNITY_DENY; | |
18911 | ||
18912 | idx = 0; | |
18913 | argv_find(argv, argc, "AA:NN", &idx); | |
18914 | str = argv_concat(argv, argc, idx); | |
7336e101 | 18915 | } |
174b5cb9 DA |
18916 | |
18917 | idx = 0; | |
d62a17ae | 18918 | argv_find(argv, argc, "(100-500)", &idx); |
18919 | argv_find(argv, argc, "WORD", &idx); | |
18920 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 18921 | |
2f8cc0e5 | 18922 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 18923 | direct, style); |
42f914d4 | 18924 | |
d62a17ae | 18925 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 18926 | |
d62a17ae | 18927 | if (ret < 0) { |
18928 | community_list_perror(vty, ret); | |
18929 | return CMD_WARNING_CONFIG_FAILED; | |
18930 | } | |
42f914d4 | 18931 | |
d62a17ae | 18932 | return CMD_SUCCESS; |
718e3744 | 18933 | } |
18934 | ||
36d4bb44 EB |
18935 | ALIAS(no_community_list_expanded_all, |
18936 | no_bgp_community_list_expanded_all_list_cmd, | |
174b5cb9 | 18937 | "no bgp community-list <(100-500)|expanded WORD>", |
36d4bb44 | 18938 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
18939 | "Community list number (expanded)\n" |
18940 | "Add an expanded community-list entry\n" | |
18941 | "Community list name\n") | |
18942 | ||
8d9b8ed9 PM |
18943 | /* Return configuration string of community-list entry. */ |
18944 | static const char *community_list_config_str(struct community_entry *entry) | |
18945 | { | |
18946 | const char *str; | |
18947 | ||
18948 | if (entry->any) | |
18949 | str = ""; | |
18950 | else { | |
18951 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
18952 | str = community_str(entry->u.com, false); | |
18953 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
18954 | str = lcommunity_str(entry->u.lcom, false); | |
18955 | else | |
18956 | str = entry->config; | |
18957 | } | |
18958 | return str; | |
18959 | } | |
18960 | ||
d62a17ae | 18961 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 18962 | { |
d62a17ae | 18963 | struct community_entry *entry; |
718e3744 | 18964 | |
d62a17ae | 18965 | for (entry = list->head; entry; entry = entry->next) { |
18966 | if (entry == list->head) { | |
18967 | if (all_digit(list->name)) | |
18968 | vty_out(vty, "Community %s list %s\n", | |
18969 | entry->style == COMMUNITY_LIST_STANDARD | |
18970 | ? "standard" | |
18971 | : "(expanded) access", | |
18972 | list->name); | |
18973 | else | |
18974 | vty_out(vty, "Named Community %s list %s\n", | |
18975 | entry->style == COMMUNITY_LIST_STANDARD | |
18976 | ? "standard" | |
18977 | : "expanded", | |
18978 | list->name); | |
18979 | } | |
18980 | if (entry->any) | |
18981 | vty_out(vty, " %s\n", | |
18982 | community_direct_str(entry->direct)); | |
18983 | else | |
18984 | vty_out(vty, " %s %s\n", | |
18985 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18986 | community_list_config_str(entry)); |
d62a17ae | 18987 | } |
718e3744 | 18988 | } |
18989 | ||
7336e101 SP |
18990 | DEFUN (show_community_list, |
18991 | show_bgp_community_list_cmd, | |
18992 | "show bgp community-list", | |
718e3744 | 18993 | SHOW_STR |
7336e101 | 18994 | BGP_STR |
718e3744 | 18995 | "List community-list\n") |
18996 | { | |
d62a17ae | 18997 | struct community_list *list; |
18998 | struct community_list_master *cm; | |
718e3744 | 18999 | |
d62a17ae | 19000 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
19001 | if (!cm) | |
19002 | return CMD_SUCCESS; | |
718e3744 | 19003 | |
d62a17ae | 19004 | for (list = cm->num.head; list; list = list->next) |
19005 | community_list_show(vty, list); | |
718e3744 | 19006 | |
d62a17ae | 19007 | for (list = cm->str.head; list; list = list->next) |
19008 | community_list_show(vty, list); | |
718e3744 | 19009 | |
d62a17ae | 19010 | return CMD_SUCCESS; |
718e3744 | 19011 | } |
19012 | ||
7336e101 SP |
19013 | DEFUN (show_community_list_arg, |
19014 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 19015 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
19016 | SHOW_STR |
19017 | BGP_STR | |
718e3744 | 19018 | "List community-list\n" |
19019 | "Community-list number\n" | |
960b69b9 | 19020 | "Community-list name\n" |
19021 | "Detailed information on community-list\n") | |
718e3744 | 19022 | { |
d62a17ae | 19023 | int idx_comm_list = 3; |
19024 | struct community_list *list; | |
718e3744 | 19025 | |
e237b0d2 | 19026 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19027 | COMMUNITY_LIST_MASTER); |
19028 | if (!list) { | |
19029 | vty_out(vty, "%% Can't find community-list\n"); | |
19030 | return CMD_WARNING; | |
19031 | } | |
718e3744 | 19032 | |
d62a17ae | 19033 | community_list_show(vty, list); |
718e3744 | 19034 | |
d62a17ae | 19035 | return CMD_SUCCESS; |
718e3744 | 19036 | } |
6b0655a2 | 19037 | |
57d187bc JS |
19038 | /* |
19039 | * Large Community code. | |
19040 | */ | |
d62a17ae | 19041 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
19042 | struct cmd_token **argv, int style, | |
19043 | int reject_all_digit_name) | |
19044 | { | |
19045 | int ret; | |
19046 | int direct; | |
19047 | char *str; | |
19048 | int idx = 0; | |
19049 | char *cl_name; | |
2f8cc0e5 DA |
19050 | char *seq = NULL; |
19051 | ||
947073e3 | 19052 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 19053 | seq = argv[idx]->arg; |
d62a17ae | 19054 | |
2f8cc0e5 | 19055 | idx = 0; |
d62a17ae | 19056 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19057 | : COMMUNITY_DENY; | |
19058 | ||
19059 | /* All digit name check. */ | |
19060 | idx = 0; | |
19061 | argv_find(argv, argc, "WORD", &idx); | |
19062 | argv_find(argv, argc, "(1-99)", &idx); | |
19063 | argv_find(argv, argc, "(100-500)", &idx); | |
19064 | cl_name = argv[idx]->arg; | |
19065 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19066 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19067 | return CMD_WARNING_CONFIG_FAILED; | |
19068 | } | |
19069 | ||
19070 | idx = 0; | |
19071 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19072 | argv_find(argv, argc, "LINE", &idx); | |
19073 | /* Concat community string argument. */ | |
19074 | if (idx) | |
19075 | str = argv_concat(argv, argc, idx); | |
19076 | else | |
19077 | str = NULL; | |
19078 | ||
2f8cc0e5 | 19079 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 19080 | |
19081 | /* Free temporary community list string allocated by | |
19082 | argv_concat(). */ | |
0a22ddfb | 19083 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19084 | |
19085 | if (ret < 0) { | |
19086 | community_list_perror(vty, ret); | |
19087 | return CMD_WARNING_CONFIG_FAILED; | |
19088 | } | |
19089 | return CMD_SUCCESS; | |
19090 | } | |
19091 | ||
19092 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19093 | struct cmd_token **argv, int style) | |
19094 | { | |
19095 | int ret; | |
19096 | int direct = 0; | |
19097 | char *str = NULL; | |
19098 | int idx = 0; | |
2f8cc0e5 | 19099 | char *seq = NULL; |
d62a17ae | 19100 | |
947073e3 | 19101 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 19102 | seq = argv[idx]->arg; |
d62a17ae | 19103 | |
2f8cc0e5 | 19104 | idx = 0; |
d62a17ae | 19105 | argv_find(argv, argc, "permit", &idx); |
19106 | argv_find(argv, argc, "deny", &idx); | |
19107 | ||
19108 | if (idx) { | |
19109 | /* Check the list direct. */ | |
19110 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19111 | direct = COMMUNITY_PERMIT; | |
19112 | else | |
19113 | direct = COMMUNITY_DENY; | |
19114 | ||
19115 | idx = 0; | |
19116 | argv_find(argv, argc, "LINE", &idx); | |
19117 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19118 | /* Concat community string argument. */ | |
19119 | str = argv_concat(argv, argc, idx); | |
19120 | } | |
19121 | ||
19122 | idx = 0; | |
19123 | argv_find(argv, argc, "(1-99)", &idx); | |
19124 | argv_find(argv, argc, "(100-500)", &idx); | |
19125 | argv_find(argv, argc, "WORD", &idx); | |
19126 | ||
19127 | /* Unset community list. */ | |
2f8cc0e5 | 19128 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 19129 | style); |
19130 | ||
19131 | /* Free temporary community list string allocated by | |
19132 | argv_concat(). */ | |
0a22ddfb | 19133 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19134 | |
19135 | if (ret < 0) { | |
19136 | community_list_perror(vty, ret); | |
19137 | return CMD_WARNING_CONFIG_FAILED; | |
19138 | } | |
19139 | ||
19140 | return CMD_SUCCESS; | |
57d187bc JS |
19141 | } |
19142 | ||
19143 | /* "large-community-list" keyword help string. */ | |
19144 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19145 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19146 | ||
7336e101 SP |
19147 | DEFUN (lcommunity_list_standard, |
19148 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 19149 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19150 | BGP_STR |
19151 | LCOMMUNITY_LIST_STR | |
19152 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19153 | "Sequence number of an entry\n" |
19154 | "Sequence number\n" | |
7336e101 SP |
19155 | "Specify large community to reject\n" |
19156 | "Specify large community to accept\n" | |
19157 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19158 | { |
d62a17ae | 19159 | return lcommunity_list_set_vty(vty, argc, argv, |
19160 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
19161 | } |
19162 | ||
7336e101 SP |
19163 | DEFUN (lcommunity_list_expanded, |
19164 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 19165 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19166 | BGP_STR |
19167 | LCOMMUNITY_LIST_STR | |
19168 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19169 | "Sequence number of an entry\n" |
19170 | "Sequence number\n" | |
7336e101 SP |
19171 | "Specify large community to reject\n" |
19172 | "Specify large community to accept\n" | |
19173 | "An ordered list as a regular-expression\n") | |
57d187bc | 19174 | { |
d62a17ae | 19175 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19176 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
19177 | } |
19178 | ||
7336e101 SP |
19179 | DEFUN (lcommunity_list_name_standard, |
19180 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 19181 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19182 | BGP_STR |
19183 | LCOMMUNITY_LIST_STR | |
19184 | "Specify standard large-community-list\n" | |
19185 | "Large Community list name\n" | |
2f8cc0e5 DA |
19186 | "Sequence number of an entry\n" |
19187 | "Sequence number\n" | |
7336e101 SP |
19188 | "Specify large community to reject\n" |
19189 | "Specify large community to accept\n" | |
19190 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19191 | { |
d62a17ae | 19192 | return lcommunity_list_set_vty(vty, argc, argv, |
19193 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
19194 | } |
19195 | ||
7336e101 SP |
19196 | DEFUN (lcommunity_list_name_expanded, |
19197 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 19198 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19199 | BGP_STR |
19200 | LCOMMUNITY_LIST_STR | |
19201 | "Specify expanded large-community-list\n" | |
19202 | "Large Community list name\n" | |
2f8cc0e5 DA |
19203 | "Sequence number of an entry\n" |
19204 | "Sequence number\n" | |
7336e101 SP |
19205 | "Specify large community to reject\n" |
19206 | "Specify large community to accept\n" | |
19207 | "An ordered list as a regular-expression\n") | |
57d187bc | 19208 | { |
d62a17ae | 19209 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19210 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
19211 | } |
19212 | ||
4378f57c DA |
19213 | DEFUN (no_lcommunity_list_all, |
19214 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
19215 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
19216 | NO_STR | |
19217 | BGP_STR | |
19218 | LCOMMUNITY_LIST_STR | |
19219 | "Large Community list number (standard)\n" | |
19220 | "Large Community list number (expanded)\n" | |
19221 | "Large Community list name\n") | |
57d187bc | 19222 | { |
7336e101 SP |
19223 | return lcommunity_list_unset_vty(vty, argc, argv, |
19224 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
19225 | } |
19226 | ||
4378f57c DA |
19227 | DEFUN (no_lcommunity_list_name_standard_all, |
19228 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
19229 | "no bgp large-community-list standard WORD", | |
19230 | NO_STR | |
19231 | BGP_STR | |
19232 | LCOMMUNITY_LIST_STR | |
19233 | "Specify standard large-community-list\n" | |
19234 | "Large Community list name\n") | |
19235 | { | |
19236 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19237 | LARGE_COMMUNITY_LIST_STANDARD); | |
19238 | } | |
19239 | ||
7336e101 SP |
19240 | DEFUN (no_lcommunity_list_name_expanded_all, |
19241 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
19242 | "no bgp large-community-list expanded WORD", | |
19243 | NO_STR | |
19244 | BGP_STR | |
19245 | LCOMMUNITY_LIST_STR | |
19246 | "Specify expanded large-community-list\n" | |
19247 | "Large Community list name\n") | |
57d187bc | 19248 | { |
d62a17ae | 19249 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19250 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19251 | } |
19252 | ||
7336e101 SP |
19253 | DEFUN (no_lcommunity_list_standard, |
19254 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 19255 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19256 | NO_STR |
19257 | BGP_STR | |
19258 | LCOMMUNITY_LIST_STR | |
19259 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19260 | "Sequence number of an entry\n" |
19261 | "Sequence number\n" | |
7336e101 SP |
19262 | "Specify large community to reject\n" |
19263 | "Specify large community to accept\n" | |
19264 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19265 | { |
d62a17ae | 19266 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19267 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19268 | } |
19269 | ||
7336e101 SP |
19270 | DEFUN (no_lcommunity_list_expanded, |
19271 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 19272 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19273 | NO_STR |
19274 | BGP_STR | |
19275 | LCOMMUNITY_LIST_STR | |
19276 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19277 | "Sequence number of an entry\n" |
19278 | "Sequence number\n" | |
7336e101 SP |
19279 | "Specify large community to reject\n" |
19280 | "Specify large community to accept\n" | |
19281 | "An ordered list as a regular-expression\n") | |
57d187bc | 19282 | { |
d62a17ae | 19283 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19284 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19285 | } |
19286 | ||
7336e101 SP |
19287 | DEFUN (no_lcommunity_list_name_standard, |
19288 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 19289 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19290 | NO_STR |
19291 | BGP_STR | |
19292 | LCOMMUNITY_LIST_STR | |
19293 | "Specify standard large-community-list\n" | |
19294 | "Large Community list name\n" | |
2f8cc0e5 DA |
19295 | "Sequence number of an entry\n" |
19296 | "Sequence number\n" | |
7336e101 SP |
19297 | "Specify large community to reject\n" |
19298 | "Specify large community to accept\n" | |
19299 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19300 | { |
d62a17ae | 19301 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19302 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19303 | } |
19304 | ||
7336e101 SP |
19305 | DEFUN (no_lcommunity_list_name_expanded, |
19306 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 19307 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19308 | NO_STR |
19309 | BGP_STR | |
19310 | LCOMMUNITY_LIST_STR | |
19311 | "Specify expanded large-community-list\n" | |
19312 | "Large community list name\n" | |
2f8cc0e5 DA |
19313 | "Sequence number of an entry\n" |
19314 | "Sequence number\n" | |
7336e101 SP |
19315 | "Specify large community to reject\n" |
19316 | "Specify large community to accept\n" | |
19317 | "An ordered list as a regular-expression\n") | |
57d187bc | 19318 | { |
d62a17ae | 19319 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19320 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19321 | } |
19322 | ||
d62a17ae | 19323 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
19324 | { | |
19325 | struct community_entry *entry; | |
19326 | ||
19327 | for (entry = list->head; entry; entry = entry->next) { | |
19328 | if (entry == list->head) { | |
19329 | if (all_digit(list->name)) | |
19330 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 19331 | entry->style == |
19332 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19333 | ? "standard" |
19334 | : "(expanded) access", | |
19335 | list->name); | |
19336 | else | |
19337 | vty_out(vty, | |
19338 | "Named large community %s list %s\n", | |
169b72c8 | 19339 | entry->style == |
19340 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19341 | ? "standard" |
19342 | : "expanded", | |
19343 | list->name); | |
19344 | } | |
19345 | if (entry->any) | |
19346 | vty_out(vty, " %s\n", | |
19347 | community_direct_str(entry->direct)); | |
19348 | else | |
19349 | vty_out(vty, " %s %s\n", | |
19350 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19351 | community_list_config_str(entry)); |
d62a17ae | 19352 | } |
57d187bc JS |
19353 | } |
19354 | ||
7336e101 SP |
19355 | DEFUN (show_lcommunity_list, |
19356 | show_bgp_lcommunity_list_cmd, | |
19357 | "show bgp large-community-list", | |
57d187bc | 19358 | SHOW_STR |
7336e101 | 19359 | BGP_STR |
57d187bc JS |
19360 | "List large-community list\n") |
19361 | { | |
d62a17ae | 19362 | struct community_list *list; |
19363 | struct community_list_master *cm; | |
57d187bc | 19364 | |
d62a17ae | 19365 | cm = community_list_master_lookup(bgp_clist, |
19366 | LARGE_COMMUNITY_LIST_MASTER); | |
19367 | if (!cm) | |
19368 | return CMD_SUCCESS; | |
57d187bc | 19369 | |
d62a17ae | 19370 | for (list = cm->num.head; list; list = list->next) |
19371 | lcommunity_list_show(vty, list); | |
57d187bc | 19372 | |
d62a17ae | 19373 | for (list = cm->str.head; list; list = list->next) |
19374 | lcommunity_list_show(vty, list); | |
57d187bc | 19375 | |
d62a17ae | 19376 | return CMD_SUCCESS; |
57d187bc JS |
19377 | } |
19378 | ||
7336e101 SP |
19379 | DEFUN (show_lcommunity_list_arg, |
19380 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 19381 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
19382 | SHOW_STR |
19383 | BGP_STR | |
57d187bc | 19384 | "List large-community list\n" |
960b69b9 | 19385 | "Large-community-list number\n" |
19386 | "Large-community-list name\n" | |
19387 | "Detailed information on large-community-list\n") | |
57d187bc | 19388 | { |
d62a17ae | 19389 | struct community_list *list; |
57d187bc | 19390 | |
e237b0d2 | 19391 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 19392 | LARGE_COMMUNITY_LIST_MASTER); |
19393 | if (!list) { | |
960b69b9 | 19394 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 19395 | return CMD_WARNING; |
19396 | } | |
57d187bc | 19397 | |
d62a17ae | 19398 | lcommunity_list_show(vty, list); |
57d187bc | 19399 | |
d62a17ae | 19400 | return CMD_SUCCESS; |
57d187bc JS |
19401 | } |
19402 | ||
718e3744 | 19403 | /* "extcommunity-list" keyword help string. */ |
19404 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19405 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19406 | ||
7336e101 SP |
19407 | DEFUN (extcommunity_list_standard, |
19408 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 19409 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19410 | BGP_STR |
718e3744 | 19411 | EXTCOMMUNITY_LIST_STR |
19412 | "Extended Community list number (standard)\n" | |
718e3744 | 19413 | "Specify standard extcommunity-list\n" |
5bf15956 | 19414 | "Community list name\n" |
2f8cc0e5 DA |
19415 | "Sequence number of an entry\n" |
19416 | "Sequence number\n" | |
718e3744 | 19417 | "Specify community to reject\n" |
19418 | "Specify community to accept\n" | |
19419 | EXTCOMMUNITY_VAL_STR) | |
19420 | { | |
d62a17ae | 19421 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19422 | int direct = 0; | |
19423 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19424 | char *seq = NULL; |
42f914d4 | 19425 | |
d62a17ae | 19426 | int idx = 0; |
7b9a4750 | 19427 | |
d62a17ae | 19428 | argv_find(argv, argc, "(1-99)", &idx); |
19429 | argv_find(argv, argc, "WORD", &idx); | |
19430 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19431 | |
409148f6 | 19432 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19433 | seq = argv[idx]->arg; |
19434 | ||
d62a17ae | 19435 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19436 | : COMMUNITY_DENY; | |
19437 | argv_find(argv, argc, "AA:NN", &idx); | |
19438 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19439 | |
2f8cc0e5 | 19440 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19441 | direct, style); |
42f914d4 | 19442 | |
d62a17ae | 19443 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19444 | |
d62a17ae | 19445 | if (ret < 0) { |
19446 | community_list_perror(vty, ret); | |
19447 | return CMD_WARNING_CONFIG_FAILED; | |
19448 | } | |
42f914d4 | 19449 | |
d62a17ae | 19450 | return CMD_SUCCESS; |
718e3744 | 19451 | } |
19452 | ||
7336e101 SP |
19453 | DEFUN (extcommunity_list_name_expanded, |
19454 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 19455 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19456 | BGP_STR |
19457 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 19458 | "Extended Community list number (expanded)\n" |
718e3744 | 19459 | "Specify expanded extcommunity-list\n" |
19460 | "Extended Community list name\n" | |
2f8cc0e5 DA |
19461 | "Sequence number of an entry\n" |
19462 | "Sequence number\n" | |
718e3744 | 19463 | "Specify community to reject\n" |
19464 | "Specify community to accept\n" | |
19465 | "An ordered list as a regular-expression\n") | |
19466 | { | |
d62a17ae | 19467 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19468 | int direct = 0; | |
19469 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19470 | char *seq = NULL; |
d62a17ae | 19471 | int idx = 0; |
7336e101 | 19472 | |
d62a17ae | 19473 | argv_find(argv, argc, "(100-500)", &idx); |
19474 | argv_find(argv, argc, "WORD", &idx); | |
19475 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19476 | |
409148f6 | 19477 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19478 | seq = argv[idx]->arg; |
19479 | ||
d62a17ae | 19480 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19481 | : COMMUNITY_DENY; | |
19482 | argv_find(argv, argc, "LINE", &idx); | |
19483 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19484 | |
2f8cc0e5 | 19485 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19486 | direct, style); |
42f914d4 | 19487 | |
d62a17ae | 19488 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19489 | |
d62a17ae | 19490 | if (ret < 0) { |
19491 | community_list_perror(vty, ret); | |
19492 | return CMD_WARNING_CONFIG_FAILED; | |
19493 | } | |
42f914d4 | 19494 | |
d62a17ae | 19495 | return CMD_SUCCESS; |
718e3744 | 19496 | } |
19497 | ||
7336e101 SP |
19498 | DEFUN (no_extcommunity_list_standard_all, |
19499 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 19500 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19501 | NO_STR |
19502 | BGP_STR | |
19503 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 19504 | "Extended Community list number (standard)\n" |
718e3744 | 19505 | "Specify standard extcommunity-list\n" |
5bf15956 | 19506 | "Community list name\n" |
2f8cc0e5 DA |
19507 | "Sequence number of an entry\n" |
19508 | "Sequence number\n" | |
718e3744 | 19509 | "Specify community to reject\n" |
19510 | "Specify community to accept\n" | |
19511 | EXTCOMMUNITY_VAL_STR) | |
19512 | { | |
d62a17ae | 19513 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19514 | int direct = 0; | |
19515 | char *cl_number_or_name = NULL; | |
d4455c89 | 19516 | char *str = NULL; |
2f8cc0e5 | 19517 | char *seq = NULL; |
d62a17ae | 19518 | int idx = 0; |
d4455c89 | 19519 | |
409148f6 | 19520 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19521 | seq = argv[idx]->arg; |
19522 | ||
19523 | idx = 0; | |
d4455c89 DA |
19524 | argv_find(argv, argc, "permit", &idx); |
19525 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
19526 | if (idx) { |
19527 | direct = argv_find(argv, argc, "permit", &idx) | |
19528 | ? COMMUNITY_PERMIT | |
19529 | : COMMUNITY_DENY; | |
19530 | ||
19531 | idx = 0; | |
19532 | argv_find(argv, argc, "AA:NN", &idx); | |
19533 | str = argv_concat(argv, argc, idx); | |
19534 | } | |
19535 | ||
19536 | idx = 0; | |
d62a17ae | 19537 | argv_find(argv, argc, "(1-99)", &idx); |
19538 | argv_find(argv, argc, "WORD", &idx); | |
19539 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19540 | |
d62a17ae | 19541 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19542 | seq, direct, style); |
42f914d4 | 19543 | |
d62a17ae | 19544 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19545 | |
d62a17ae | 19546 | if (ret < 0) { |
19547 | community_list_perror(vty, ret); | |
19548 | return CMD_WARNING_CONFIG_FAILED; | |
19549 | } | |
42f914d4 | 19550 | |
d62a17ae | 19551 | return CMD_SUCCESS; |
718e3744 | 19552 | } |
19553 | ||
d4455c89 DA |
19554 | ALIAS(no_extcommunity_list_standard_all, |
19555 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
19556 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
36d4bb44 | 19557 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19558 | "Extended Community list number (standard)\n" |
19559 | "Specify standard extcommunity-list\n" | |
19560 | "Community list name\n") | |
19561 | ||
7336e101 SP |
19562 | DEFUN (no_extcommunity_list_expanded_all, |
19563 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 19564 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19565 | NO_STR |
19566 | BGP_STR | |
19567 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 19568 | "Extended Community list number (expanded)\n" |
718e3744 | 19569 | "Specify expanded extcommunity-list\n" |
5bf15956 | 19570 | "Extended Community list name\n" |
2f8cc0e5 DA |
19571 | "Sequence number of an entry\n" |
19572 | "Sequence number\n" | |
718e3744 | 19573 | "Specify community to reject\n" |
19574 | "Specify community to accept\n" | |
19575 | "An ordered list as a regular-expression\n") | |
19576 | { | |
d62a17ae | 19577 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19578 | int direct = 0; | |
19579 | char *cl_number_or_name = NULL; | |
d4455c89 | 19580 | char *str = NULL; |
2f8cc0e5 | 19581 | char *seq = NULL; |
d62a17ae | 19582 | int idx = 0; |
d4455c89 | 19583 | |
409148f6 | 19584 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
19585 | seq = argv[idx]->arg; |
19586 | ||
19587 | idx = 0; | |
d4455c89 DA |
19588 | argv_find(argv, argc, "permit", &idx); |
19589 | argv_find(argv, argc, "deny", &idx); | |
19590 | ||
19591 | if (idx) { | |
19592 | direct = argv_find(argv, argc, "permit", &idx) | |
19593 | ? COMMUNITY_PERMIT | |
19594 | : COMMUNITY_DENY; | |
19595 | ||
19596 | idx = 0; | |
19597 | argv_find(argv, argc, "LINE", &idx); | |
19598 | str = argv_concat(argv, argc, idx); | |
19599 | } | |
19600 | ||
19601 | idx = 0; | |
d62a17ae | 19602 | argv_find(argv, argc, "(100-500)", &idx); |
19603 | argv_find(argv, argc, "WORD", &idx); | |
19604 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19605 | |
d62a17ae | 19606 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19607 | seq, direct, style); |
42f914d4 | 19608 | |
d62a17ae | 19609 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19610 | |
d62a17ae | 19611 | if (ret < 0) { |
19612 | community_list_perror(vty, ret); | |
19613 | return CMD_WARNING_CONFIG_FAILED; | |
19614 | } | |
42f914d4 | 19615 | |
d62a17ae | 19616 | return CMD_SUCCESS; |
718e3744 | 19617 | } |
19618 | ||
d4455c89 DA |
19619 | ALIAS(no_extcommunity_list_expanded_all, |
19620 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
19621 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
36d4bb44 | 19622 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19623 | "Extended Community list number (expanded)\n" |
19624 | "Specify expanded extcommunity-list\n" | |
19625 | "Extended Community list name\n") | |
19626 | ||
d62a17ae | 19627 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19628 | { |
d62a17ae | 19629 | struct community_entry *entry; |
718e3744 | 19630 | |
d62a17ae | 19631 | for (entry = list->head; entry; entry = entry->next) { |
19632 | if (entry == list->head) { | |
19633 | if (all_digit(list->name)) | |
19634 | vty_out(vty, "Extended community %s list %s\n", | |
19635 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19636 | ? "standard" | |
19637 | : "(expanded) access", | |
19638 | list->name); | |
19639 | else | |
19640 | vty_out(vty, | |
19641 | "Named extended community %s list %s\n", | |
19642 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19643 | ? "standard" | |
19644 | : "expanded", | |
19645 | list->name); | |
19646 | } | |
19647 | if (entry->any) | |
19648 | vty_out(vty, " %s\n", | |
19649 | community_direct_str(entry->direct)); | |
19650 | else | |
19651 | vty_out(vty, " %s %s\n", | |
19652 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19653 | community_list_config_str(entry)); |
d62a17ae | 19654 | } |
718e3744 | 19655 | } |
19656 | ||
7336e101 SP |
19657 | DEFUN (show_extcommunity_list, |
19658 | show_bgp_extcommunity_list_cmd, | |
19659 | "show bgp extcommunity-list", | |
718e3744 | 19660 | SHOW_STR |
7336e101 | 19661 | BGP_STR |
718e3744 | 19662 | "List extended-community list\n") |
19663 | { | |
d62a17ae | 19664 | struct community_list *list; |
19665 | struct community_list_master *cm; | |
718e3744 | 19666 | |
d62a17ae | 19667 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
19668 | if (!cm) | |
19669 | return CMD_SUCCESS; | |
718e3744 | 19670 | |
d62a17ae | 19671 | for (list = cm->num.head; list; list = list->next) |
19672 | extcommunity_list_show(vty, list); | |
718e3744 | 19673 | |
d62a17ae | 19674 | for (list = cm->str.head; list; list = list->next) |
19675 | extcommunity_list_show(vty, list); | |
718e3744 | 19676 | |
d62a17ae | 19677 | return CMD_SUCCESS; |
718e3744 | 19678 | } |
19679 | ||
7336e101 SP |
19680 | DEFUN (show_extcommunity_list_arg, |
19681 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 19682 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
19683 | SHOW_STR |
19684 | BGP_STR | |
718e3744 | 19685 | "List extended-community list\n" |
19686 | "Extcommunity-list number\n" | |
960b69b9 | 19687 | "Extcommunity-list name\n" |
19688 | "Detailed information on extcommunity-list\n") | |
718e3744 | 19689 | { |
d62a17ae | 19690 | int idx_comm_list = 3; |
19691 | struct community_list *list; | |
718e3744 | 19692 | |
e237b0d2 | 19693 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19694 | EXTCOMMUNITY_LIST_MASTER); |
19695 | if (!list) { | |
19696 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
19697 | return CMD_WARNING; | |
19698 | } | |
718e3744 | 19699 | |
d62a17ae | 19700 | extcommunity_list_show(vty, list); |
718e3744 | 19701 | |
d62a17ae | 19702 | return CMD_SUCCESS; |
718e3744 | 19703 | } |
6b0655a2 | 19704 | |
718e3744 | 19705 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 19706 | static int community_list_config_write(struct vty *vty) |
19707 | { | |
19708 | struct community_list *list; | |
19709 | struct community_entry *entry; | |
19710 | struct community_list_master *cm; | |
19711 | int write = 0; | |
19712 | ||
19713 | /* Community-list. */ | |
19714 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
19715 | ||
19716 | for (list = cm->num.head; list; list = list->next) | |
19717 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19718 | vty_out(vty, |
19719 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
19720 | list->name, entry->seq, | |
d62a17ae | 19721 | community_direct_str(entry->direct), |
19722 | community_list_config_str(entry)); | |
19723 | write++; | |
19724 | } | |
19725 | for (list = cm->str.head; list; list = list->next) | |
19726 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19727 | vty_out(vty, |
19728 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 19729 | entry->style == COMMUNITY_LIST_STANDARD |
19730 | ? "standard" | |
19731 | : "expanded", | |
2f8cc0e5 DA |
19732 | list->name, entry->seq, |
19733 | community_direct_str(entry->direct), | |
d62a17ae | 19734 | community_list_config_str(entry)); |
19735 | write++; | |
19736 | } | |
19737 | ||
19738 | /* Extcommunity-list. */ | |
19739 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
19740 | ||
19741 | for (list = cm->num.head; list; list = list->next) | |
19742 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19743 | vty_out(vty, |
19744 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
19745 | list->name, entry->seq, | |
19746 | community_direct_str(entry->direct), | |
d62a17ae | 19747 | community_list_config_str(entry)); |
19748 | write++; | |
19749 | } | |
19750 | for (list = cm->str.head; list; list = list->next) | |
19751 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 19752 | vty_out(vty, |
6cde4b45 | 19753 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 19754 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
19755 | ? "standard" | |
19756 | : "expanded", | |
2f8cc0e5 DA |
19757 | list->name, entry->seq, |
19758 | community_direct_str(entry->direct), | |
d62a17ae | 19759 | community_list_config_str(entry)); |
19760 | write++; | |
19761 | } | |
19762 | ||
19763 | ||
19764 | /* lcommunity-list. */ | |
19765 | cm = community_list_master_lookup(bgp_clist, | |
19766 | LARGE_COMMUNITY_LIST_MASTER); | |
19767 | ||
19768 | for (list = cm->num.head; list; list = list->next) | |
19769 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 19770 | vty_out(vty, |
6cde4b45 | 19771 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
19772 | list->name, entry->seq, |
19773 | community_direct_str(entry->direct), | |
d62a17ae | 19774 | community_list_config_str(entry)); |
19775 | write++; | |
19776 | } | |
19777 | for (list = cm->str.head; list; list = list->next) | |
19778 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 19779 | vty_out(vty, |
6cde4b45 | 19780 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 19781 | |
d62a17ae | 19782 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
19783 | ? "standard" | |
19784 | : "expanded", | |
2f8cc0e5 | 19785 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 19786 | community_list_config_str(entry)); |
19787 | write++; | |
19788 | } | |
19789 | ||
19790 | return write; | |
19791 | } | |
19792 | ||
612c2c15 | 19793 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 19794 | static struct cmd_node community_list_node = { |
f4b8291f | 19795 | .name = "community list", |
62b346ee DL |
19796 | .node = COMMUNITY_LIST_NODE, |
19797 | .prompt = "", | |
612c2c15 | 19798 | .config_write = community_list_config_write, |
718e3744 | 19799 | }; |
19800 | ||
d62a17ae | 19801 | static void community_list_vty(void) |
19802 | { | |
612c2c15 | 19803 | install_node(&community_list_node); |
d62a17ae | 19804 | |
19805 | /* Community-list. */ | |
7336e101 SP |
19806 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
19807 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
19808 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 19809 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 19810 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 19811 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
19812 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
19813 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 19814 | |
19815 | /* Extcommunity-list. */ | |
7336e101 SP |
19816 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
19817 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
19818 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
19819 | install_element(CONFIG_NODE, |
19820 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 19821 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
19822 | install_element(CONFIG_NODE, |
19823 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
19824 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
19825 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 19826 | |
19827 | /* Large Community List */ | |
7336e101 | 19828 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
19829 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
19830 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 19831 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
19832 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
19833 | install_element(CONFIG_NODE, | |
19834 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
19835 | install_element(CONFIG_NODE, |
19836 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
19837 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
19838 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
19839 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
19840 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
19841 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
19842 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 19843 | } |