]>
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" |
dcc68b5e | 68 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 69 | #include "bgpd/bgp_mac.h" |
dd65f45e DL |
70 | #include "bgpd/bgp_flowspec.h" |
71 | #if ENABLE_BGP_VNC | |
72 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" | |
73 | #endif | |
74 | ||
5d5393b9 DL |
75 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
76 | { .val_long = true, .match_profile = "datacenter", }, | |
77 | { .val_long = false }, | |
78 | ) | |
79 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
80 | { .val_long = true, .match_profile = "datacenter", }, | |
81 | { .val_long = false }, | |
82 | ) | |
83 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, | |
84 | { .val_long = true, .match_profile = "datacenter", }, | |
85 | { .val_long = false }, | |
86 | ) | |
87 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
88 | { .val_long = true, .match_profile = "datacenter", }, | |
89 | { .val_long = false }, | |
90 | ) | |
91 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
92 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
93 | { .val_ulong = 120 }, | |
94 | ) | |
95 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
96 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
97 | { .val_ulong = 180 }, | |
98 | ) | |
99 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
100 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
101 | { .val_ulong = 60 }, | |
102 | ) | |
103 | ||
dd65f45e DL |
104 | DEFINE_HOOK(bgp_inst_config_write, |
105 | (struct bgp *bgp, struct vty *vty), | |
106 | (bgp, vty)) | |
718e3744 | 107 | |
d62a17ae | 108 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
109 | struct prefix *range, int exact); | |
110 | ||
111 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
112 | { | |
113 | switch (afi) { | |
114 | case AFI_IP: | |
115 | switch (safi) { | |
116 | case SAFI_UNICAST: | |
117 | return BGP_IPV4_NODE; | |
118 | break; | |
119 | case SAFI_MULTICAST: | |
120 | return BGP_IPV4M_NODE; | |
121 | break; | |
122 | case SAFI_LABELED_UNICAST: | |
123 | return BGP_IPV4L_NODE; | |
124 | break; | |
125 | case SAFI_MPLS_VPN: | |
126 | return BGP_VPNV4_NODE; | |
127 | break; | |
7c40bf39 | 128 | case SAFI_FLOWSPEC: |
129 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
130 | default: |
131 | /* not expected */ | |
132 | return BGP_IPV4_NODE; | |
133 | break; | |
d62a17ae | 134 | } |
135 | break; | |
136 | case AFI_IP6: | |
137 | switch (safi) { | |
138 | case SAFI_UNICAST: | |
139 | return BGP_IPV6_NODE; | |
140 | break; | |
141 | case SAFI_MULTICAST: | |
142 | return BGP_IPV6M_NODE; | |
143 | break; | |
144 | case SAFI_LABELED_UNICAST: | |
145 | return BGP_IPV6L_NODE; | |
146 | break; | |
147 | case SAFI_MPLS_VPN: | |
148 | return BGP_VPNV6_NODE; | |
149 | break; | |
7c40bf39 | 150 | case SAFI_FLOWSPEC: |
151 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
152 | default: |
153 | /* not expected */ | |
154 | return BGP_IPV4_NODE; | |
155 | break; | |
d62a17ae | 156 | } |
157 | break; | |
158 | case AFI_L2VPN: | |
159 | return BGP_EVPN_NODE; | |
160 | break; | |
b26f891d | 161 | case AFI_UNSPEC: |
d62a17ae | 162 | case AFI_MAX: |
163 | // We should never be here but to clarify the switch statement.. | |
164 | return BGP_IPV4_NODE; | |
165 | break; | |
166 | } | |
167 | ||
168 | // Impossible to happen | |
169 | return BGP_IPV4_NODE; | |
f51bae9c | 170 | } |
20eb8864 | 171 | |
5cb5f4d0 DD |
172 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
173 | { | |
174 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
175 | return "IPv4 Unicast"; | |
176 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
177 | return "IPv4 Multicast"; | |
178 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
179 | return "IPv4 Labeled Unicast"; | |
180 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
181 | return "IPv4 VPN"; | |
182 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
183 | return "IPv4 Encap"; | |
184 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
185 | return "IPv4 Flowspec"; | |
186 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
187 | return "IPv6 Unicast"; | |
188 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
189 | return "IPv6 Multicast"; | |
190 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
191 | return "IPv6 Labeled Unicast"; | |
192 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
193 | return "IPv6 VPN"; | |
194 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
195 | return "IPv6 Encap"; | |
196 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
197 | return "IPv6 Flowspec"; | |
198 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
199 | return "L2VPN EVPN"; | |
8e5509b0 | 200 | else |
5cb5f4d0 | 201 | return "Unknown"; |
5cb5f4d0 DD |
202 | } |
203 | ||
204 | /* | |
205 | * Please note that we have intentionally camelCased | |
206 | * the return strings here. So if you want | |
207 | * to use this function, please ensure you | |
208 | * are doing this within json output | |
209 | */ | |
210 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
211 | { | |
212 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
213 | return "ipv4Unicast"; | |
214 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
215 | return "ipv4Multicast"; | |
216 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
217 | return "ipv4LabeledUnicast"; | |
218 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
219 | return "ipv4Vpn"; | |
220 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
221 | return "ipv4Encap"; | |
222 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
223 | return "ipv4Flowspec"; | |
224 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
225 | return "ipv6Unicast"; | |
226 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
227 | return "ipv6Multicast"; | |
228 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
229 | return "ipv6LabeledUnicast"; | |
230 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
231 | return "ipv6Vpn"; | |
232 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
233 | return "ipv6Encap"; | |
234 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
235 | return "ipv6Flowspec"; | |
236 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
237 | return "l2VpnEvpn"; | |
8e5509b0 | 238 | else |
5cb5f4d0 | 239 | return "Unknown"; |
5cb5f4d0 DD |
240 | } |
241 | ||
718e3744 | 242 | /* Utility function to get address family from current node. */ |
d62a17ae | 243 | afi_t bgp_node_afi(struct vty *vty) |
244 | { | |
245 | afi_t afi; | |
246 | switch (vty->node) { | |
247 | case BGP_IPV6_NODE: | |
248 | case BGP_IPV6M_NODE: | |
249 | case BGP_IPV6L_NODE: | |
250 | case BGP_VPNV6_NODE: | |
7c40bf39 | 251 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 252 | afi = AFI_IP6; |
253 | break; | |
254 | case BGP_EVPN_NODE: | |
255 | afi = AFI_L2VPN; | |
256 | break; | |
257 | default: | |
258 | afi = AFI_IP; | |
259 | break; | |
260 | } | |
261 | return afi; | |
718e3744 | 262 | } |
263 | ||
264 | /* Utility function to get subsequent address family from current | |
265 | node. */ | |
d62a17ae | 266 | safi_t bgp_node_safi(struct vty *vty) |
267 | { | |
268 | safi_t safi; | |
269 | switch (vty->node) { | |
270 | case BGP_VPNV4_NODE: | |
271 | case BGP_VPNV6_NODE: | |
272 | safi = SAFI_MPLS_VPN; | |
273 | break; | |
274 | case BGP_IPV4M_NODE: | |
275 | case BGP_IPV6M_NODE: | |
276 | safi = SAFI_MULTICAST; | |
277 | break; | |
278 | case BGP_EVPN_NODE: | |
279 | safi = SAFI_EVPN; | |
280 | break; | |
281 | case BGP_IPV4L_NODE: | |
282 | case BGP_IPV6L_NODE: | |
283 | safi = SAFI_LABELED_UNICAST; | |
284 | break; | |
7c40bf39 | 285 | case BGP_FLOWSPECV4_NODE: |
286 | case BGP_FLOWSPECV6_NODE: | |
287 | safi = SAFI_FLOWSPEC; | |
288 | break; | |
d62a17ae | 289 | default: |
290 | safi = SAFI_UNICAST; | |
291 | break; | |
292 | } | |
293 | return safi; | |
718e3744 | 294 | } |
295 | ||
55f91488 QY |
296 | /** |
297 | * Converts an AFI in string form to afi_t | |
298 | * | |
299 | * @param afi string, one of | |
300 | * - "ipv4" | |
301 | * - "ipv6" | |
81cf0de5 | 302 | * - "l2vpn" |
55f91488 QY |
303 | * @return the corresponding afi_t |
304 | */ | |
d62a17ae | 305 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
306 | { | |
307 | afi_t afi = AFI_MAX; /* unknown */ | |
308 | if (strmatch(afi_str, "ipv4")) | |
309 | afi = AFI_IP; | |
310 | else if (strmatch(afi_str, "ipv6")) | |
311 | afi = AFI_IP6; | |
81cf0de5 CS |
312 | else if (strmatch(afi_str, "l2vpn")) |
313 | afi = AFI_L2VPN; | |
d62a17ae | 314 | return afi; |
315 | } | |
316 | ||
317 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
318 | afi_t *afi) | |
319 | { | |
320 | int ret = 0; | |
321 | if (argv_find(argv, argc, "ipv4", index)) { | |
322 | ret = 1; | |
323 | if (afi) | |
324 | *afi = AFI_IP; | |
325 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
326 | ret = 1; | |
327 | if (afi) | |
328 | *afi = AFI_IP6; | |
8688b3e7 DS |
329 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
330 | ret = 1; | |
331 | if (afi) | |
332 | *afi = AFI_L2VPN; | |
d62a17ae | 333 | } |
334 | return ret; | |
46f296b4 LB |
335 | } |
336 | ||
375a2e67 | 337 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 338 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
339 | { | |
340 | safi_t safi = SAFI_MAX; /* unknown */ | |
341 | if (strmatch(safi_str, "multicast")) | |
342 | safi = SAFI_MULTICAST; | |
343 | else if (strmatch(safi_str, "unicast")) | |
344 | safi = SAFI_UNICAST; | |
345 | else if (strmatch(safi_str, "vpn")) | |
346 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
347 | else if (strmatch(safi_str, "evpn")) |
348 | safi = SAFI_EVPN; | |
d62a17ae | 349 | else if (strmatch(safi_str, "labeled-unicast")) |
350 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 351 | else if (strmatch(safi_str, "flowspec")) |
352 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 353 | return safi; |
354 | } | |
355 | ||
356 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
357 | safi_t *safi) | |
358 | { | |
359 | int ret = 0; | |
360 | if (argv_find(argv, argc, "unicast", index)) { | |
361 | ret = 1; | |
362 | if (safi) | |
363 | *safi = SAFI_UNICAST; | |
364 | } else if (argv_find(argv, argc, "multicast", index)) { | |
365 | ret = 1; | |
366 | if (safi) | |
367 | *safi = SAFI_MULTICAST; | |
368 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
369 | ret = 1; | |
370 | if (safi) | |
371 | *safi = SAFI_LABELED_UNICAST; | |
372 | } else if (argv_find(argv, argc, "vpn", index)) { | |
373 | ret = 1; | |
374 | if (safi) | |
375 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
376 | } else if (argv_find(argv, argc, "evpn", index)) { |
377 | ret = 1; | |
378 | if (safi) | |
379 | *safi = SAFI_EVPN; | |
7c40bf39 | 380 | } else if (argv_find(argv, argc, "flowspec", index)) { |
381 | ret = 1; | |
382 | if (safi) | |
383 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 384 | } |
385 | return ret; | |
46f296b4 LB |
386 | } |
387 | ||
5d5393b9 DL |
388 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
389 | enum bgp_instance_type inst_type) | |
390 | { | |
391 | int ret = bgp_get(bgp, as, name, inst_type); | |
392 | ||
393 | if (ret == BGP_CREATED) { | |
394 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
395 | DFLT_BGP_CONNECT_RETRY); | |
396 | ||
397 | if (DFLT_BGP_IMPORT_CHECK) | |
398 | bgp_flag_set(*bgp, BGP_FLAG_IMPORT_CHECK); | |
399 | if (DFLT_BGP_SHOW_HOSTNAME) | |
400 | bgp_flag_set(*bgp, BGP_FLAG_SHOW_HOSTNAME); | |
401 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) | |
402 | bgp_flag_set(*bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
403 | if (DFLT_BGP_DETERMINISTIC_MED) | |
404 | bgp_flag_set(*bgp, BGP_FLAG_DETERMINISTIC_MED); | |
405 | ||
406 | ret = BGP_SUCCESS; | |
407 | } | |
408 | return ret; | |
409 | } | |
410 | ||
7eeee51e | 411 | /* |
f212a857 | 412 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 413 | * |
f212a857 DS |
414 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
415 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
416 | * to appropriate values for the calling function. This is to allow the |
417 | * calling function to make decisions appropriate for the show command | |
418 | * that is being parsed. | |
419 | * | |
420 | * The show commands are generally of the form: | |
d62a17ae | 421 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
422 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
423 | * |
424 | * Since we use argv_find if the show command in particular doesn't have: | |
425 | * [ip] | |
18c57037 | 426 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 427 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
428 | * The command parsing should still be ok. |
429 | * | |
430 | * vty -> The vty for the command so we can output some useful data in | |
431 | * the event of a parse error in the vrf. | |
432 | * argv -> The command tokens | |
433 | * argc -> How many command tokens we have | |
d62a17ae | 434 | * idx -> The current place in the command, generally should be 0 for this |
435 | * function | |
7eeee51e DS |
436 | * afi -> The parsed afi if it was included in the show command, returned here |
437 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 438 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 439 | * use_json -> json is configured or not |
7eeee51e DS |
440 | * |
441 | * The function returns the correct location in the parse tree for the | |
442 | * last token found. | |
0e37c258 DS |
443 | * |
444 | * Returns 0 for failure to parse correctly, else the idx position of where | |
445 | * it found the last token. | |
7eeee51e | 446 | */ |
d62a17ae | 447 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
448 | struct cmd_token **argv, int argc, | |
449 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 450 | struct bgp **bgp, bool use_json) |
d62a17ae | 451 | { |
452 | char *vrf_name = NULL; | |
453 | ||
454 | assert(afi); | |
455 | assert(safi); | |
456 | assert(bgp); | |
457 | ||
458 | if (argv_find(argv, argc, "ip", idx)) | |
459 | *afi = AFI_IP; | |
460 | ||
9a8bdf1c | 461 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 462 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
463 | else if (argv_find(argv, argc, "vrf", idx)) { |
464 | vrf_name = argv[*idx + 1]->arg; | |
465 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
466 | vrf_name = NULL; | |
467 | } | |
468 | if (vrf_name) { | |
d62a17ae | 469 | if (strmatch(vrf_name, "all")) |
470 | *bgp = NULL; | |
471 | else { | |
472 | *bgp = bgp_lookup_by_name(vrf_name); | |
473 | if (!*bgp) { | |
52e5b8c4 SP |
474 | if (use_json) { |
475 | json_object *json = NULL; | |
476 | json = json_object_new_object(); | |
477 | json_object_string_add( | |
478 | json, "warning", | |
479 | "View/Vrf is unknown"); | |
480 | vty_out(vty, "%s\n", | |
481 | json_object_to_json_string_ext(json, | |
482 | JSON_C_TO_STRING_PRETTY)); | |
483 | json_object_free(json); | |
484 | } | |
ca61fd25 DS |
485 | else |
486 | vty_out(vty, "View/Vrf %s is unknown\n", | |
487 | vrf_name); | |
d62a17ae | 488 | *idx = 0; |
489 | return 0; | |
490 | } | |
491 | } | |
492 | } else { | |
493 | *bgp = bgp_get_default(); | |
494 | if (!*bgp) { | |
52e5b8c4 SP |
495 | if (use_json) { |
496 | json_object *json = NULL; | |
497 | json = json_object_new_object(); | |
498 | json_object_string_add( | |
499 | json, "warning", | |
500 | "Default BGP instance not found"); | |
501 | vty_out(vty, "%s\n", | |
502 | json_object_to_json_string_ext(json, | |
503 | JSON_C_TO_STRING_PRETTY)); | |
504 | json_object_free(json); | |
505 | } | |
ca61fd25 DS |
506 | else |
507 | vty_out(vty, | |
508 | "Default BGP instance not found\n"); | |
d62a17ae | 509 | *idx = 0; |
510 | return 0; | |
511 | } | |
512 | } | |
513 | ||
514 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
515 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
516 | ||
517 | *idx += 1; | |
518 | return *idx; | |
519 | } | |
520 | ||
521 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
522 | { | |
523 | struct interface *ifp = NULL; | |
524 | ||
525 | if (su->sa.sa_family == AF_INET) | |
526 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
527 | else if (su->sa.sa_family == AF_INET6) | |
528 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
529 | su->sin6.sin6_scope_id, | |
530 | bgp->vrf_id); | |
531 | ||
532 | if (ifp) | |
533 | return 1; | |
534 | ||
535 | return 0; | |
718e3744 | 536 | } |
537 | ||
538 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
539 | /* This is used only for configuration, so disallow if attempted on |
540 | * a dynamic neighbor. | |
541 | */ | |
d62a17ae | 542 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
543 | { | |
544 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
545 | int ret; | |
546 | union sockunion su; | |
547 | struct peer *peer; | |
548 | ||
549 | if (!bgp) { | |
550 | return NULL; | |
551 | } | |
552 | ||
553 | ret = str2sockunion(ip_str, &su); | |
554 | if (ret < 0) { | |
555 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
556 | if (!peer) { | |
557 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
558 | == NULL) { | |
559 | vty_out(vty, | |
560 | "%% Malformed address or name: %s\n", | |
561 | ip_str); | |
562 | return NULL; | |
563 | } | |
564 | } | |
565 | } else { | |
566 | peer = peer_lookup(bgp, &su); | |
567 | if (!peer) { | |
568 | vty_out(vty, | |
569 | "%% Specify remote-as or peer-group commands first\n"); | |
570 | return NULL; | |
571 | } | |
572 | if (peer_dynamic_neighbor(peer)) { | |
573 | vty_out(vty, | |
574 | "%% Operation not allowed on a dynamic neighbor\n"); | |
575 | return NULL; | |
576 | } | |
577 | } | |
578 | return peer; | |
718e3744 | 579 | } |
580 | ||
581 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
582 | /* This is used only for configuration, so disallow if attempted on |
583 | * a dynamic neighbor. | |
584 | */ | |
d62a17ae | 585 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
586 | { | |
587 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
588 | int ret; | |
589 | union sockunion su; | |
590 | struct peer *peer = NULL; | |
591 | struct peer_group *group = NULL; | |
592 | ||
593 | if (!bgp) { | |
594 | return NULL; | |
595 | } | |
596 | ||
597 | ret = str2sockunion(peer_str, &su); | |
598 | if (ret == 0) { | |
599 | /* IP address, locate peer. */ | |
600 | peer = peer_lookup(bgp, &su); | |
601 | } else { | |
602 | /* Not IP, could match either peer configured on interface or a | |
603 | * group. */ | |
604 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
605 | if (!peer) | |
606 | group = peer_group_lookup(bgp, peer_str); | |
607 | } | |
608 | ||
609 | if (peer) { | |
610 | if (peer_dynamic_neighbor(peer)) { | |
611 | vty_out(vty, | |
612 | "%% Operation not allowed on a dynamic neighbor\n"); | |
613 | return NULL; | |
614 | } | |
615 | ||
616 | return peer; | |
617 | } | |
618 | ||
619 | if (group) | |
620 | return group->conf; | |
621 | ||
622 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
623 | ||
624 | return NULL; | |
625 | } | |
626 | ||
627 | int bgp_vty_return(struct vty *vty, int ret) | |
628 | { | |
629 | const char *str = NULL; | |
630 | ||
631 | switch (ret) { | |
632 | case BGP_ERR_INVALID_VALUE: | |
633 | str = "Invalid value"; | |
634 | break; | |
635 | case BGP_ERR_INVALID_FLAG: | |
636 | str = "Invalid flag"; | |
637 | break; | |
638 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
639 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
640 | break; | |
641 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
642 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
643 | break; | |
644 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
645 | str = "Specify remote-as or peer-group remote AS first"; | |
646 | break; | |
647 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
648 | str = "Cannot change the peer-group. Deconfigure first"; | |
649 | break; | |
650 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
651 | str = "Peer is not a member of this peer-group"; | |
652 | break; | |
653 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
654 | str = "Prefix/distribute list can not co-exist"; | |
655 | break; | |
656 | case BGP_ERR_NOT_INTERNAL_PEER: | |
657 | str = "Invalid command. Not an internal neighbor"; | |
658 | break; | |
659 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
660 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
661 | break; | |
662 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
663 | str = "Local-AS allowed only for EBGP peers"; | |
664 | break; | |
665 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
666 | str = "Cannot have local-as same as BGP AS number"; | |
667 | break; | |
668 | case BGP_ERR_TCPSIG_FAILED: | |
669 | str = "Error while applying TCP-Sig to session(s)"; | |
670 | break; | |
671 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
672 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
673 | break; | |
674 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
675 | str = "ttl-security only allowed for EBGP peers"; | |
676 | break; | |
677 | case BGP_ERR_AS_OVERRIDE: | |
678 | str = "as-override cannot be configured for IBGP peers"; | |
679 | break; | |
680 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
681 | str = "Invalid limit for number of dynamic neighbors"; | |
682 | break; | |
683 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
684 | str = "Dynamic neighbor listen range already exists"; | |
685 | break; | |
686 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
687 | str = "Operation not allowed on a dynamic neighbor"; | |
688 | break; | |
689 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
690 | str = "Operation not allowed on a directly connected neighbor"; | |
691 | break; | |
692 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
693 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
694 | break; | |
695 | } | |
696 | if (str) { | |
697 | vty_out(vty, "%% %s\n", str); | |
698 | return CMD_WARNING_CONFIG_FAILED; | |
699 | } | |
700 | return CMD_SUCCESS; | |
718e3744 | 701 | } |
702 | ||
7aafcaca | 703 | /* BGP clear sort. */ |
d62a17ae | 704 | enum clear_sort { |
705 | clear_all, | |
706 | clear_peer, | |
707 | clear_group, | |
708 | clear_external, | |
709 | clear_as | |
7aafcaca DS |
710 | }; |
711 | ||
d62a17ae | 712 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
713 | safi_t safi, int error) | |
714 | { | |
715 | switch (error) { | |
716 | case BGP_ERR_AF_UNCONFIGURED: | |
717 | vty_out(vty, | |
718 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
5cb5f4d0 | 719 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 720 | break; |
721 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
722 | vty_out(vty, | |
723 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
724 | peer->host); | |
725 | break; | |
726 | default: | |
727 | break; | |
728 | } | |
7aafcaca DS |
729 | } |
730 | ||
dc912615 DS |
731 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
732 | struct listnode *nnode, enum bgp_clear_type stype) | |
733 | { | |
734 | int ret = 0; | |
735 | ||
736 | /* if afi/.safi not specified, spin thru all of them */ | |
737 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
738 | afi_t tmp_afi; | |
739 | safi_t tmp_safi; | |
740 | ||
741 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
742 | if (!peer->afc[tmp_afi][tmp_safi]) | |
743 | continue; | |
744 | ||
745 | if (stype == BGP_CLEAR_SOFT_NONE) | |
746 | ret = peer_clear(peer, &nnode); | |
747 | else | |
748 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
749 | stype); | |
750 | } | |
751 | /* if afi specified and safi not, spin thru safis on this afi */ | |
752 | } else if (safi == SAFI_UNSPEC) { | |
753 | safi_t tmp_safi; | |
754 | ||
755 | for (tmp_safi = SAFI_UNICAST; | |
756 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
757 | if (!peer->afc[afi][tmp_safi]) | |
758 | continue; | |
759 | ||
760 | if (stype == BGP_CLEAR_SOFT_NONE) | |
761 | ret = peer_clear(peer, &nnode); | |
762 | else | |
763 | ret = peer_clear_soft(peer, afi, | |
764 | tmp_safi, stype); | |
765 | } | |
766 | /* both afi/safi specified, let the caller know if not defined */ | |
767 | } else { | |
768 | if (!peer->afc[afi][safi]) | |
769 | return 1; | |
770 | ||
771 | if (stype == BGP_CLEAR_SOFT_NONE) | |
772 | ret = peer_clear(peer, &nnode); | |
773 | else | |
774 | ret = peer_clear_soft(peer, afi, safi, stype); | |
775 | } | |
776 | ||
777 | return ret; | |
778 | } | |
779 | ||
7aafcaca | 780 | /* `clear ip bgp' functions. */ |
d62a17ae | 781 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
782 | enum clear_sort sort, enum bgp_clear_type stype, | |
783 | const char *arg) | |
784 | { | |
dc912615 | 785 | int ret = 0; |
3ae8bfa5 | 786 | bool found = false; |
d62a17ae | 787 | struct peer *peer; |
788 | struct listnode *node, *nnode; | |
789 | ||
790 | /* Clear all neighbors. */ | |
791 | /* | |
792 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
793 | * nodes on the BGP instance as that may get freed if it is a |
794 | * doppelganger | |
d62a17ae | 795 | */ |
796 | if (sort == clear_all) { | |
797 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc912615 DS |
798 | ret = bgp_peer_clear(peer, afi, safi, nnode, |
799 | stype); | |
d62a17ae | 800 | |
801 | if (ret < 0) | |
802 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
04b6bdc0 | 803 | } |
d62a17ae | 804 | |
805 | /* This is to apply read-only mode on this clear. */ | |
806 | if (stype == BGP_CLEAR_SOFT_NONE) | |
807 | bgp->update_delay_over = 0; | |
808 | ||
809 | return CMD_SUCCESS; | |
7aafcaca DS |
810 | } |
811 | ||
3ae8bfa5 | 812 | /* Clear specified neighbor. */ |
d62a17ae | 813 | if (sort == clear_peer) { |
814 | union sockunion su; | |
d62a17ae | 815 | |
816 | /* Make sockunion for lookup. */ | |
817 | ret = str2sockunion(arg, &su); | |
818 | if (ret < 0) { | |
819 | peer = peer_lookup_by_conf_if(bgp, arg); | |
820 | if (!peer) { | |
821 | peer = peer_lookup_by_hostname(bgp, arg); | |
822 | if (!peer) { | |
823 | vty_out(vty, | |
824 | "Malformed address or name: %s\n", | |
825 | arg); | |
826 | return CMD_WARNING; | |
827 | } | |
828 | } | |
829 | } else { | |
830 | peer = peer_lookup(bgp, &su); | |
831 | if (!peer) { | |
832 | vty_out(vty, | |
833 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
834 | arg); | |
835 | return CMD_WARNING; | |
836 | } | |
837 | } | |
7aafcaca | 838 | |
dc912615 DS |
839 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
840 | ||
841 | /* if afi/safi not defined for this peer, let caller know */ | |
842 | if (ret == 1) | |
3ae8bfa5 | 843 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 844 | |
d62a17ae | 845 | if (ret < 0) |
846 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 847 | |
d62a17ae | 848 | return CMD_SUCCESS; |
7aafcaca | 849 | } |
7aafcaca | 850 | |
3ae8bfa5 | 851 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 852 | if (sort == clear_group) { |
853 | struct peer_group *group; | |
7aafcaca | 854 | |
d62a17ae | 855 | group = peer_group_lookup(bgp, arg); |
856 | if (!group) { | |
857 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
858 | return CMD_WARNING; | |
859 | } | |
860 | ||
861 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
dc912615 | 862 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 863 | |
d62a17ae | 864 | if (ret < 0) |
865 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
866 | else |
867 | found = true; | |
d62a17ae | 868 | } |
3ae8bfa5 PM |
869 | |
870 | if (!found) | |
871 | vty_out(vty, | |
872 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 873 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 874 | |
d62a17ae | 875 | return CMD_SUCCESS; |
7aafcaca | 876 | } |
7aafcaca | 877 | |
3ae8bfa5 | 878 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 879 | if (sort == clear_external) { |
880 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
881 | if (peer->sort == BGP_PEER_IBGP) | |
882 | continue; | |
7aafcaca | 883 | |
dc912615 | 884 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 885 | |
d62a17ae | 886 | if (ret < 0) |
887 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
888 | else |
889 | found = true; | |
d62a17ae | 890 | } |
3ae8bfa5 PM |
891 | |
892 | if (!found) | |
893 | vty_out(vty, | |
894 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 895 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 896 | |
d62a17ae | 897 | return CMD_SUCCESS; |
898 | } | |
899 | ||
3ae8bfa5 | 900 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 901 | if (sort == clear_as) { |
3ae8bfa5 | 902 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 903 | |
904 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
905 | if (peer->as != as) | |
906 | continue; | |
907 | ||
dc912615 | 908 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
d62a17ae | 909 | |
910 | if (ret < 0) | |
911 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
912 | else |
913 | found = true; | |
d62a17ae | 914 | } |
3ae8bfa5 PM |
915 | |
916 | if (!found) | |
d62a17ae | 917 | vty_out(vty, |
3ae8bfa5 | 918 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 919 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 920 | |
d62a17ae | 921 | return CMD_SUCCESS; |
922 | } | |
923 | ||
924 | return CMD_SUCCESS; | |
925 | } | |
926 | ||
927 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
928 | safi_t safi, enum clear_sort sort, | |
929 | enum bgp_clear_type stype, const char *arg) | |
930 | { | |
931 | struct bgp *bgp; | |
932 | ||
933 | /* BGP structure lookup. */ | |
934 | if (name) { | |
935 | bgp = bgp_lookup_by_name(name); | |
936 | if (bgp == NULL) { | |
937 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
938 | return CMD_WARNING; | |
939 | } | |
940 | } else { | |
941 | bgp = bgp_get_default(); | |
942 | if (bgp == NULL) { | |
943 | vty_out(vty, "No BGP process is configured\n"); | |
944 | return CMD_WARNING; | |
945 | } | |
946 | } | |
947 | ||
948 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
949 | } |
950 | ||
951 | /* clear soft inbound */ | |
d62a17ae | 952 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 953 | { |
99b3ebd3 NS |
954 | afi_t afi; |
955 | safi_t safi; | |
956 | ||
957 | FOREACH_AFI_SAFI (afi, safi) | |
958 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
959 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
960 | } |
961 | ||
962 | /* clear soft outbound */ | |
d62a17ae | 963 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 964 | { |
99b3ebd3 NS |
965 | afi_t afi; |
966 | safi_t safi; | |
967 | ||
968 | FOREACH_AFI_SAFI (afi, safi) | |
969 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
970 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
971 | } |
972 | ||
973 | ||
f787d7a0 | 974 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 975 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
976 | #endif |
977 | ||
8029b216 AK |
978 | DEFUN_HIDDEN (bgp_local_mac, |
979 | bgp_local_mac_cmd, | |
093e3f23 | 980 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
981 | BGP_STR |
982 | "Local MAC config\n" | |
983 | "VxLAN Network Identifier\n" | |
984 | "VNI number\n" | |
985 | "local mac\n" | |
986 | "mac address\n" | |
987 | "mac-mobility sequence\n" | |
988 | "seq number\n") | |
989 | { | |
990 | int rv; | |
991 | vni_t vni; | |
992 | struct ethaddr mac; | |
993 | struct ipaddr ip; | |
994 | uint32_t seq; | |
995 | struct bgp *bgp; | |
996 | ||
997 | vni = strtoul(argv[3]->arg, NULL, 10); | |
998 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
999 | vty_out(vty, "%% Malformed MAC address\n"); | |
1000 | return CMD_WARNING; | |
1001 | } | |
1002 | memset(&ip, 0, sizeof(ip)); | |
1003 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1004 | ||
1005 | bgp = bgp_get_default(); | |
1006 | if (!bgp) { | |
1007 | vty_out(vty, "Default BGP instance is not there\n"); | |
1008 | return CMD_WARNING; | |
1009 | } | |
1010 | ||
1011 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
1012 | if (rv < 0) { | |
1013 | vty_out(vty, "Internal error\n"); | |
1014 | return CMD_WARNING; | |
1015 | } | |
1016 | ||
1017 | return CMD_SUCCESS; | |
1018 | } | |
1019 | ||
1020 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1021 | no_bgp_local_mac_cmd, | |
093e3f23 | 1022 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1023 | NO_STR |
1024 | BGP_STR | |
1025 | "Local MAC config\n" | |
1026 | "VxLAN Network Identifier\n" | |
1027 | "VNI number\n" | |
1028 | "local mac\n" | |
1029 | "mac address\n") | |
1030 | { | |
1031 | int rv; | |
1032 | vni_t vni; | |
1033 | struct ethaddr mac; | |
1034 | struct ipaddr ip; | |
1035 | struct bgp *bgp; | |
1036 | ||
1037 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1038 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1039 | vty_out(vty, "%% Malformed MAC address\n"); | |
1040 | return CMD_WARNING; | |
1041 | } | |
1042 | memset(&ip, 0, sizeof(ip)); | |
1043 | ||
1044 | bgp = bgp_get_default(); | |
1045 | if (!bgp) { | |
1046 | vty_out(vty, "Default BGP instance is not there\n"); | |
1047 | return CMD_WARNING; | |
1048 | } | |
1049 | ||
ec0ab544 | 1050 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1051 | if (rv < 0) { |
1052 | vty_out(vty, "Internal error\n"); | |
1053 | return CMD_WARNING; | |
1054 | } | |
1055 | ||
1056 | return CMD_SUCCESS; | |
1057 | } | |
1058 | ||
718e3744 | 1059 | DEFUN (no_synchronization, |
1060 | no_synchronization_cmd, | |
1061 | "no synchronization", | |
1062 | NO_STR | |
1063 | "Perform IGP synchronization\n") | |
1064 | { | |
d62a17ae | 1065 | return CMD_SUCCESS; |
718e3744 | 1066 | } |
1067 | ||
1068 | DEFUN (no_auto_summary, | |
1069 | no_auto_summary_cmd, | |
1070 | "no auto-summary", | |
1071 | NO_STR | |
1072 | "Enable automatic network number summarization\n") | |
1073 | { | |
d62a17ae | 1074 | return CMD_SUCCESS; |
718e3744 | 1075 | } |
3d515fd9 | 1076 | |
718e3744 | 1077 | /* "router bgp" commands. */ |
505e5056 | 1078 | DEFUN_NOSH (router_bgp, |
f412b39a | 1079 | router_bgp_cmd, |
2ed9fe4a | 1080 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1081 | ROUTER_STR |
1082 | BGP_STR | |
31500417 DW |
1083 | AS_STR |
1084 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1085 | { |
d62a17ae | 1086 | int idx_asn = 2; |
1087 | int idx_view_vrf = 3; | |
1088 | int idx_vrf = 4; | |
ecec9495 | 1089 | int is_new_bgp = 0; |
d62a17ae | 1090 | int ret; |
1091 | as_t as; | |
1092 | struct bgp *bgp; | |
1093 | const char *name = NULL; | |
1094 | enum bgp_instance_type inst_type; | |
1095 | ||
1096 | // "router bgp" without an ASN | |
1097 | if (argc == 2) { | |
1098 | // Pending: Make VRF option available for ASN less config | |
1099 | bgp = bgp_get_default(); | |
1100 | ||
1101 | if (bgp == NULL) { | |
1102 | vty_out(vty, "%% No BGP process is configured\n"); | |
1103 | return CMD_WARNING_CONFIG_FAILED; | |
1104 | } | |
1105 | ||
1106 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1107 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1108 | return CMD_WARNING_CONFIG_FAILED; |
1109 | } | |
1110 | } | |
1111 | ||
1112 | // "router bgp X" | |
1113 | else { | |
1114 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1115 | ||
1116 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1117 | if (argc > 3) { | |
1118 | name = argv[idx_vrf]->arg; | |
1119 | ||
9a8bdf1c PG |
1120 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1121 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1122 | name = NULL; | |
1123 | else | |
1124 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1125 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1126 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1127 | } | |
1128 | ||
ecec9495 AD |
1129 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1130 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1131 | ||
5d5393b9 | 1132 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
d62a17ae | 1133 | switch (ret) { |
d62a17ae | 1134 | case BGP_ERR_AS_MISMATCH: |
1135 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1136 | return CMD_WARNING_CONFIG_FAILED; | |
1137 | case BGP_ERR_INSTANCE_MISMATCH: | |
1138 | vty_out(vty, | |
1139 | "BGP instance name and AS number mismatch\n"); | |
1140 | vty_out(vty, | |
1141 | "BGP instance is already running; AS is %u\n", | |
1142 | as); | |
1143 | return CMD_WARNING_CONFIG_FAILED; | |
1144 | } | |
1145 | ||
3bd70bf8 PZ |
1146 | /* |
1147 | * If we just instantiated the default instance, complete | |
1148 | * any pending VRF-VPN leaking that was configured via | |
1149 | * earlier "router bgp X vrf FOO" blocks. | |
1150 | */ | |
ecec9495 | 1151 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1152 | vpn_leak_postchange_all(); |
1153 | ||
48381346 CS |
1154 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1155 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1156 | /* Pending: handle when user tries to change a view to vrf n vv. |
1157 | */ | |
1158 | } | |
1159 | ||
0b5131c9 MK |
1160 | /* unset the auto created flag as the user config is now present */ |
1161 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1162 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1163 | ||
1164 | return CMD_SUCCESS; | |
718e3744 | 1165 | } |
1166 | ||
718e3744 | 1167 | /* "no router bgp" commands. */ |
1168 | DEFUN (no_router_bgp, | |
1169 | no_router_bgp_cmd, | |
2ed9fe4a | 1170 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1171 | NO_STR |
1172 | ROUTER_STR | |
1173 | BGP_STR | |
31500417 DW |
1174 | AS_STR |
1175 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1176 | { |
d62a17ae | 1177 | int idx_asn = 3; |
1178 | int idx_vrf = 5; | |
1179 | as_t as; | |
1180 | struct bgp *bgp; | |
1181 | const char *name = NULL; | |
718e3744 | 1182 | |
d62a17ae | 1183 | // "no router bgp" without an ASN |
1184 | if (argc == 3) { | |
1185 | // Pending: Make VRF option available for ASN less config | |
1186 | bgp = bgp_get_default(); | |
718e3744 | 1187 | |
d62a17ae | 1188 | if (bgp == NULL) { |
1189 | vty_out(vty, "%% No BGP process is configured\n"); | |
1190 | return CMD_WARNING_CONFIG_FAILED; | |
1191 | } | |
7fb21a9f | 1192 | |
d62a17ae | 1193 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1194 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1195 | return CMD_WARNING_CONFIG_FAILED; |
1196 | } | |
0b5131c9 MK |
1197 | |
1198 | if (bgp->l3vni) { | |
1199 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1200 | bgp->l3vni); | |
1201 | return CMD_WARNING_CONFIG_FAILED; | |
1202 | } | |
d62a17ae | 1203 | } else { |
1204 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1205 | |
d62a17ae | 1206 | if (argc > 4) |
1207 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1208 | |
d62a17ae | 1209 | /* Lookup bgp structure. */ |
1210 | bgp = bgp_lookup(as, name); | |
1211 | if (!bgp) { | |
1212 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1213 | return CMD_WARNING_CONFIG_FAILED; | |
1214 | } | |
0b5131c9 MK |
1215 | |
1216 | if (bgp->l3vni) { | |
dd5868c2 | 1217 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1218 | bgp->l3vni); |
1219 | return CMD_WARNING_CONFIG_FAILED; | |
1220 | } | |
dd5868c2 DS |
1221 | |
1222 | /* Cannot delete default instance if vrf instances exist */ | |
1223 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1224 | struct listnode *node; | |
1225 | struct bgp *tmp_bgp; | |
1226 | ||
1227 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1228 | if (tmp_bgp->inst_type | |
1229 | == BGP_INSTANCE_TYPE_VRF) { | |
1230 | vty_out(vty, | |
1231 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1232 | return CMD_WARNING_CONFIG_FAILED; | |
1233 | } | |
1234 | } | |
1235 | } | |
d62a17ae | 1236 | } |
718e3744 | 1237 | |
9ecf931b CS |
1238 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1239 | return CMD_WARNING_CONFIG_FAILED; | |
1240 | ||
d62a17ae | 1241 | bgp_delete(bgp); |
718e3744 | 1242 | |
d62a17ae | 1243 | return CMD_SUCCESS; |
718e3744 | 1244 | } |
1245 | ||
6b0655a2 | 1246 | |
718e3744 | 1247 | /* BGP router-id. */ |
1248 | ||
f787d7a0 | 1249 | DEFPY (bgp_router_id, |
718e3744 | 1250 | bgp_router_id_cmd, |
1251 | "bgp router-id A.B.C.D", | |
1252 | BGP_STR | |
1253 | "Override configured router identifier\n" | |
1254 | "Manually configured router identifier\n") | |
1255 | { | |
d62a17ae | 1256 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1257 | bgp_router_id_static_set(bgp, router_id); | |
1258 | return CMD_SUCCESS; | |
718e3744 | 1259 | } |
1260 | ||
f787d7a0 | 1261 | DEFPY (no_bgp_router_id, |
718e3744 | 1262 | no_bgp_router_id_cmd, |
31500417 | 1263 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1264 | NO_STR |
1265 | BGP_STR | |
31500417 DW |
1266 | "Override configured router identifier\n" |
1267 | "Manually configured router identifier\n") | |
718e3744 | 1268 | { |
d62a17ae | 1269 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1270 | |
d62a17ae | 1271 | if (router_id_str) { |
1272 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1273 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1274 | return CMD_WARNING_CONFIG_FAILED; | |
1275 | } | |
e018c7cc | 1276 | } |
718e3744 | 1277 | |
d62a17ae | 1278 | router_id.s_addr = 0; |
1279 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1280 | |
d62a17ae | 1281 | return CMD_SUCCESS; |
718e3744 | 1282 | } |
1283 | ||
6b0655a2 | 1284 | |
718e3744 | 1285 | /* BGP Cluster ID. */ |
718e3744 | 1286 | DEFUN (bgp_cluster_id, |
1287 | bgp_cluster_id_cmd, | |
838758ac | 1288 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1289 | BGP_STR |
1290 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1291 | "Route-Reflector Cluster-id in IP address format\n" |
1292 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1293 | { |
d62a17ae | 1294 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1295 | int idx_ipv4 = 2; | |
1296 | int ret; | |
1297 | struct in_addr cluster; | |
718e3744 | 1298 | |
d62a17ae | 1299 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1300 | if (!ret) { | |
1301 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1302 | return CMD_WARNING_CONFIG_FAILED; | |
1303 | } | |
718e3744 | 1304 | |
d62a17ae | 1305 | bgp_cluster_id_set(bgp, &cluster); |
1306 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1307 | |
d62a17ae | 1308 | return CMD_SUCCESS; |
718e3744 | 1309 | } |
1310 | ||
718e3744 | 1311 | DEFUN (no_bgp_cluster_id, |
1312 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1313 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1314 | NO_STR |
1315 | BGP_STR | |
838758ac DW |
1316 | "Configure Route-Reflector Cluster-id\n" |
1317 | "Route-Reflector Cluster-id in IP address format\n" | |
1318 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1319 | { |
d62a17ae | 1320 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1321 | bgp_cluster_id_unset(bgp); | |
1322 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1323 | |
d62a17ae | 1324 | return CMD_SUCCESS; |
718e3744 | 1325 | } |
1326 | ||
718e3744 | 1327 | DEFUN (bgp_confederation_identifier, |
1328 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1329 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1330 | "BGP specific commands\n" |
1331 | "AS confederation parameters\n" | |
1332 | "AS number\n" | |
1333 | "Set routing domain confederation AS\n") | |
1334 | { | |
d62a17ae | 1335 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1336 | int idx_number = 3; | |
1337 | as_t as; | |
718e3744 | 1338 | |
d62a17ae | 1339 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1340 | |
d62a17ae | 1341 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1342 | |
d62a17ae | 1343 | return CMD_SUCCESS; |
718e3744 | 1344 | } |
1345 | ||
1346 | DEFUN (no_bgp_confederation_identifier, | |
1347 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1348 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1349 | NO_STR |
1350 | "BGP specific commands\n" | |
1351 | "AS confederation parameters\n" | |
3a2d747c QY |
1352 | "AS number\n" |
1353 | "Set routing domain confederation AS\n") | |
718e3744 | 1354 | { |
d62a17ae | 1355 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1356 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1357 | |
d62a17ae | 1358 | return CMD_SUCCESS; |
718e3744 | 1359 | } |
1360 | ||
718e3744 | 1361 | DEFUN (bgp_confederation_peers, |
1362 | bgp_confederation_peers_cmd, | |
12dcf78e | 1363 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1364 | "BGP specific commands\n" |
1365 | "AS confederation parameters\n" | |
1366 | "Peer ASs in BGP confederation\n" | |
1367 | AS_STR) | |
1368 | { | |
d62a17ae | 1369 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1370 | int idx_asn = 3; | |
1371 | as_t as; | |
1372 | int i; | |
718e3744 | 1373 | |
d62a17ae | 1374 | for (i = idx_asn; i < argc; i++) { |
1375 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1376 | |
d62a17ae | 1377 | if (bgp->as == as) { |
1378 | vty_out(vty, | |
1379 | "%% Local member-AS not allowed in confed peer list\n"); | |
1380 | continue; | |
1381 | } | |
718e3744 | 1382 | |
d62a17ae | 1383 | bgp_confederation_peers_add(bgp, as); |
1384 | } | |
1385 | return CMD_SUCCESS; | |
718e3744 | 1386 | } |
1387 | ||
1388 | DEFUN (no_bgp_confederation_peers, | |
1389 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1390 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1391 | NO_STR |
1392 | "BGP specific commands\n" | |
1393 | "AS confederation parameters\n" | |
1394 | "Peer ASs in BGP confederation\n" | |
1395 | AS_STR) | |
1396 | { | |
d62a17ae | 1397 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1398 | int idx_asn = 4; | |
1399 | as_t as; | |
1400 | int i; | |
718e3744 | 1401 | |
d62a17ae | 1402 | for (i = idx_asn; i < argc; i++) { |
1403 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1404 | |
d62a17ae | 1405 | bgp_confederation_peers_remove(bgp, as); |
1406 | } | |
1407 | return CMD_SUCCESS; | |
718e3744 | 1408 | } |
6b0655a2 | 1409 | |
5e242b0d DS |
1410 | /** |
1411 | * Central routine for maximum-paths configuration. | |
1412 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1413 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1414 | */ | |
d62a17ae | 1415 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1416 | const char *mpaths, uint16_t options, |
d62a17ae | 1417 | int set) |
1418 | { | |
1419 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1420 | uint16_t maxpaths = 0; |
d62a17ae | 1421 | int ret; |
1422 | afi_t afi; | |
1423 | safi_t safi; | |
1424 | ||
1425 | afi = bgp_node_afi(vty); | |
1426 | safi = bgp_node_safi(vty); | |
1427 | ||
1428 | if (set) { | |
1429 | maxpaths = strtol(mpaths, NULL, 10); | |
1430 | if (maxpaths > multipath_num) { | |
1431 | vty_out(vty, | |
1432 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1433 | maxpaths, multipath_num); | |
1434 | return CMD_WARNING_CONFIG_FAILED; | |
1435 | } | |
1436 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1437 | options); | |
1438 | } else | |
1439 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1440 | ||
1441 | if (ret < 0) { | |
1442 | vty_out(vty, | |
1443 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1444 | (set == 1) ? "" : "un", | |
1445 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1446 | maxpaths, afi, safi); | |
1447 | return CMD_WARNING_CONFIG_FAILED; | |
1448 | } | |
1449 | ||
1450 | bgp_recalculate_all_bestpaths(bgp); | |
1451 | ||
1452 | return CMD_SUCCESS; | |
165b5fff JB |
1453 | } |
1454 | ||
abc920f8 DS |
1455 | DEFUN (bgp_maxmed_admin, |
1456 | bgp_maxmed_admin_cmd, | |
1457 | "bgp max-med administrative ", | |
1458 | BGP_STR | |
1459 | "Advertise routes with max-med\n" | |
1460 | "Administratively applied, for an indefinite period\n") | |
1461 | { | |
d62a17ae | 1462 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1463 | |
d62a17ae | 1464 | bgp->v_maxmed_admin = 1; |
1465 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1466 | |
d62a17ae | 1467 | bgp_maxmed_update(bgp); |
abc920f8 | 1468 | |
d62a17ae | 1469 | return CMD_SUCCESS; |
abc920f8 DS |
1470 | } |
1471 | ||
1472 | DEFUN (bgp_maxmed_admin_medv, | |
1473 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1474 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1475 | BGP_STR |
1476 | "Advertise routes with max-med\n" | |
1477 | "Administratively applied, for an indefinite period\n" | |
1478 | "Max MED value to be used\n") | |
1479 | { | |
d62a17ae | 1480 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1481 | int idx_number = 3; | |
abc920f8 | 1482 | |
d62a17ae | 1483 | bgp->v_maxmed_admin = 1; |
1484 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1485 | |
d62a17ae | 1486 | bgp_maxmed_update(bgp); |
abc920f8 | 1487 | |
d62a17ae | 1488 | return CMD_SUCCESS; |
abc920f8 DS |
1489 | } |
1490 | ||
1491 | DEFUN (no_bgp_maxmed_admin, | |
1492 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1493 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1494 | NO_STR |
1495 | BGP_STR | |
1496 | "Advertise routes with max-med\n" | |
838758ac DW |
1497 | "Administratively applied, for an indefinite period\n" |
1498 | "Max MED value to be used\n") | |
abc920f8 | 1499 | { |
d62a17ae | 1500 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1501 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1502 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1503 | bgp_maxmed_update(bgp); | |
abc920f8 | 1504 | |
d62a17ae | 1505 | return CMD_SUCCESS; |
abc920f8 DS |
1506 | } |
1507 | ||
abc920f8 DS |
1508 | DEFUN (bgp_maxmed_onstartup, |
1509 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1510 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1511 | BGP_STR |
1512 | "Advertise routes with max-med\n" | |
1513 | "Effective on a startup\n" | |
1514 | "Time (seconds) period for max-med\n" | |
1515 | "Max MED value to be used\n") | |
1516 | { | |
d62a17ae | 1517 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1518 | int idx = 0; | |
4668a151 | 1519 | |
d62a17ae | 1520 | argv_find(argv, argc, "(5-86400)", &idx); |
1521 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1522 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1523 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1524 | else | |
1525 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1526 | |
d62a17ae | 1527 | bgp_maxmed_update(bgp); |
abc920f8 | 1528 | |
d62a17ae | 1529 | return CMD_SUCCESS; |
abc920f8 DS |
1530 | } |
1531 | ||
1532 | DEFUN (no_bgp_maxmed_onstartup, | |
1533 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1534 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1535 | NO_STR |
1536 | BGP_STR | |
1537 | "Advertise routes with max-med\n" | |
838758ac DW |
1538 | "Effective on a startup\n" |
1539 | "Time (seconds) period for max-med\n" | |
1540 | "Max MED value to be used\n") | |
abc920f8 | 1541 | { |
d62a17ae | 1542 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1543 | |
d62a17ae | 1544 | /* Cancel max-med onstartup if its on */ |
1545 | if (bgp->t_maxmed_onstartup) { | |
1546 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1547 | bgp->maxmed_onstartup_over = 1; | |
1548 | } | |
abc920f8 | 1549 | |
d62a17ae | 1550 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1551 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1552 | |
d62a17ae | 1553 | bgp_maxmed_update(bgp); |
abc920f8 | 1554 | |
d62a17ae | 1555 | return CMD_SUCCESS; |
abc920f8 DS |
1556 | } |
1557 | ||
d62a17ae | 1558 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1559 | const char *wait) | |
f188f2c4 | 1560 | { |
d62a17ae | 1561 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1562 | uint16_t update_delay; |
1563 | uint16_t establish_wait; | |
f188f2c4 | 1564 | |
d62a17ae | 1565 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1566 | |
d62a17ae | 1567 | if (!wait) /* update-delay <delay> */ |
1568 | { | |
1569 | bgp->v_update_delay = update_delay; | |
1570 | bgp->v_establish_wait = bgp->v_update_delay; | |
1571 | return CMD_SUCCESS; | |
1572 | } | |
f188f2c4 | 1573 | |
d62a17ae | 1574 | /* update-delay <delay> <establish-wait> */ |
1575 | establish_wait = atoi(wait); | |
1576 | if (update_delay < establish_wait) { | |
1577 | vty_out(vty, | |
1578 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1579 | return CMD_WARNING_CONFIG_FAILED; | |
1580 | } | |
f188f2c4 | 1581 | |
d62a17ae | 1582 | bgp->v_update_delay = update_delay; |
1583 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1584 | |
d62a17ae | 1585 | return CMD_SUCCESS; |
f188f2c4 DS |
1586 | } |
1587 | ||
d62a17ae | 1588 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1589 | { |
d62a17ae | 1590 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1591 | |
d62a17ae | 1592 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1593 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1594 | |
d62a17ae | 1595 | return CMD_SUCCESS; |
f188f2c4 DS |
1596 | } |
1597 | ||
2b791107 | 1598 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1599 | { |
d62a17ae | 1600 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1601 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1602 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1603 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1604 | vty_out(vty, "\n"); | |
1605 | } | |
f188f2c4 DS |
1606 | } |
1607 | ||
1608 | ||
1609 | /* Update-delay configuration */ | |
1610 | DEFUN (bgp_update_delay, | |
1611 | bgp_update_delay_cmd, | |
6147e2c6 | 1612 | "update-delay (0-3600)", |
f188f2c4 DS |
1613 | "Force initial delay for best-path and updates\n" |
1614 | "Seconds\n") | |
1615 | { | |
d62a17ae | 1616 | int idx_number = 1; |
1617 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1618 | } |
1619 | ||
1620 | DEFUN (bgp_update_delay_establish_wait, | |
1621 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1622 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1623 | "Force initial delay for best-path and updates\n" |
1624 | "Seconds\n" | |
f188f2c4 DS |
1625 | "Seconds\n") |
1626 | { | |
d62a17ae | 1627 | int idx_number = 1; |
1628 | int idx_number_2 = 2; | |
1629 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1630 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1631 | } |
1632 | ||
1633 | /* Update-delay deconfiguration */ | |
1634 | DEFUN (no_bgp_update_delay, | |
1635 | no_bgp_update_delay_cmd, | |
838758ac DW |
1636 | "no update-delay [(0-3600) [(1-3600)]]", |
1637 | NO_STR | |
f188f2c4 | 1638 | "Force initial delay for best-path and updates\n" |
838758ac | 1639 | "Seconds\n" |
7111c1a0 | 1640 | "Seconds\n") |
f188f2c4 | 1641 | { |
d62a17ae | 1642 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1643 | } |
1644 | ||
5e242b0d | 1645 | |
8fa7732f QY |
1646 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1647 | bool set) | |
cb1faec9 | 1648 | { |
d62a17ae | 1649 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1650 | |
8fa7732f QY |
1651 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1652 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1653 | |
1654 | return CMD_SUCCESS; | |
1655 | } | |
1656 | ||
8fa7732f QY |
1657 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1658 | bool set) | |
555e09d4 QY |
1659 | { |
1660 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1661 | ||
8fa7732f QY |
1662 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1663 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1664 | |
d62a17ae | 1665 | return CMD_SUCCESS; |
cb1faec9 DS |
1666 | } |
1667 | ||
2b791107 | 1668 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1669 | { |
555e09d4 QY |
1670 | uint32_t quanta = |
1671 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1672 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1673 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1674 | } |
1675 | ||
555e09d4 QY |
1676 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1677 | { | |
1678 | uint32_t quanta = | |
1679 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1680 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1681 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1682 | } |
cb1faec9 | 1683 | |
8fa7732f QY |
1684 | /* Packet quanta configuration |
1685 | * | |
1686 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1687 | * thread. When changing these limits be careful to prevent stack overflow. | |
1688 | * | |
1689 | * Furthermore, the maximums used here should correspond to | |
1690 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1691 | */ | |
1692 | DEFPY (bgp_wpkt_quanta, | |
cb1faec9 | 1693 | bgp_wpkt_quanta_cmd, |
8fa7732f | 1694 | "[no] write-quanta (1-64)$quanta", |
d7fa34c1 | 1695 | NO_STR |
8fa7732f | 1696 | "How many packets to write to peer socket per run\n" |
cb1faec9 DS |
1697 | "Number of packets\n") |
1698 | { | |
8fa7732f | 1699 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); |
cb1faec9 DS |
1700 | } |
1701 | ||
8fa7732f | 1702 | DEFPY (bgp_rpkt_quanta, |
555e09d4 | 1703 | bgp_rpkt_quanta_cmd, |
8fa7732f | 1704 | "[no] read-quanta (1-10)$quanta", |
555e09d4 QY |
1705 | NO_STR |
1706 | "How many packets to read from peer socket per I/O cycle\n" | |
1707 | "Number of packets\n") | |
1708 | { | |
8fa7732f | 1709 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); |
555e09d4 QY |
1710 | } |
1711 | ||
2b791107 | 1712 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1713 | { |
37a333fe | 1714 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1715 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1716 | } |
1717 | ||
1718 | ||
1719 | DEFUN (bgp_coalesce_time, | |
1720 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1721 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1722 | "Subgroup coalesce timer\n" |
1723 | "Subgroup coalesce timer value (in ms)\n") | |
1724 | { | |
d62a17ae | 1725 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1726 | |
d62a17ae | 1727 | int idx = 0; |
1728 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1729 | bgp->heuristic_coalesce = false; |
d62a17ae | 1730 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1731 | return CMD_SUCCESS; | |
3f9c7369 DS |
1732 | } |
1733 | ||
1734 | DEFUN (no_bgp_coalesce_time, | |
1735 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1736 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1737 | NO_STR |
3f9c7369 DS |
1738 | "Subgroup coalesce timer\n" |
1739 | "Subgroup coalesce timer value (in ms)\n") | |
1740 | { | |
d62a17ae | 1741 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1742 | |
37a333fe | 1743 | bgp->heuristic_coalesce = true; |
d62a17ae | 1744 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1745 | return CMD_SUCCESS; | |
3f9c7369 DS |
1746 | } |
1747 | ||
5e242b0d DS |
1748 | /* Maximum-paths configuration */ |
1749 | DEFUN (bgp_maxpaths, | |
1750 | bgp_maxpaths_cmd, | |
6319fd63 | 1751 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1752 | "Forward packets over multiple paths\n" |
1753 | "Number of paths\n") | |
1754 | { | |
d62a17ae | 1755 | int idx_number = 1; |
1756 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1757 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1758 | } |
1759 | ||
d62a17ae | 1760 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1761 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1762 | "Forward packets over multiple paths\n" | |
1763 | "Number of paths\n") | |
596c17ba | 1764 | |
165b5fff JB |
1765 | DEFUN (bgp_maxpaths_ibgp, |
1766 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1767 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1768 | "Forward packets over multiple paths\n" |
1769 | "iBGP-multipath\n" | |
1770 | "Number of paths\n") | |
1771 | { | |
d62a17ae | 1772 | int idx_number = 2; |
1773 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1774 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1775 | } |
165b5fff | 1776 | |
d62a17ae | 1777 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1778 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1779 | "Forward packets over multiple paths\n" | |
1780 | "iBGP-multipath\n" | |
1781 | "Number of paths\n") | |
596c17ba | 1782 | |
5e242b0d DS |
1783 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1784 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1785 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1786 | "Forward packets over multiple paths\n" |
1787 | "iBGP-multipath\n" | |
1788 | "Number of paths\n" | |
1789 | "Match the cluster length\n") | |
1790 | { | |
d62a17ae | 1791 | int idx_number = 2; |
1792 | return bgp_maxpaths_config_vty( | |
1793 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1794 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1795 | } |
1796 | ||
d62a17ae | 1797 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1798 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1799 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1800 | "Forward packets over multiple paths\n" | |
1801 | "iBGP-multipath\n" | |
1802 | "Number of paths\n" | |
1803 | "Match the cluster length\n") | |
596c17ba | 1804 | |
165b5fff JB |
1805 | DEFUN (no_bgp_maxpaths, |
1806 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1807 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1808 | NO_STR |
1809 | "Forward packets over multiple paths\n" | |
1810 | "Number of paths\n") | |
1811 | { | |
d62a17ae | 1812 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1813 | } |
1814 | ||
d62a17ae | 1815 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1816 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1817 | "Forward packets over multiple paths\n" |
1818 | "Number of paths\n") | |
596c17ba | 1819 | |
165b5fff JB |
1820 | DEFUN (no_bgp_maxpaths_ibgp, |
1821 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1822 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1823 | NO_STR |
1824 | "Forward packets over multiple paths\n" | |
1825 | "iBGP-multipath\n" | |
838758ac DW |
1826 | "Number of paths\n" |
1827 | "Match the cluster length\n") | |
165b5fff | 1828 | { |
d62a17ae | 1829 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1830 | } |
1831 | ||
d62a17ae | 1832 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1833 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1834 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1835 | NO_STR | |
1836 | "Forward packets over multiple paths\n" | |
1837 | "iBGP-multipath\n" | |
1838 | "Number of paths\n" | |
1839 | "Match the cluster length\n") | |
596c17ba | 1840 | |
dd65f45e DL |
1841 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
1842 | afi_t afi, safi_t safi) | |
165b5fff | 1843 | { |
d62a17ae | 1844 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1845 | vty_out(vty, " maximum-paths %d\n", |
1846 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1847 | } | |
165b5fff | 1848 | |
d62a17ae | 1849 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1850 | vty_out(vty, " maximum-paths ibgp %d", |
1851 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1852 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1853 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1854 | vty_out(vty, " equal-cluster-length"); | |
1855 | vty_out(vty, "\n"); | |
1856 | } | |
165b5fff | 1857 | } |
6b0655a2 | 1858 | |
718e3744 | 1859 | /* BGP timers. */ |
1860 | ||
1861 | DEFUN (bgp_timers, | |
1862 | bgp_timers_cmd, | |
6147e2c6 | 1863 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1864 | "Adjust routing timers\n" |
1865 | "BGP timers\n" | |
1866 | "Keepalive interval\n" | |
1867 | "Holdtime\n") | |
1868 | { | |
d62a17ae | 1869 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1870 | int idx_number = 2; | |
1871 | int idx_number_2 = 3; | |
1872 | unsigned long keepalive = 0; | |
1873 | unsigned long holdtime = 0; | |
718e3744 | 1874 | |
d62a17ae | 1875 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1876 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1877 | |
d62a17ae | 1878 | /* Holdtime value check. */ |
1879 | if (holdtime < 3 && holdtime != 0) { | |
1880 | vty_out(vty, | |
1881 | "%% hold time value must be either 0 or greater than 3\n"); | |
1882 | return CMD_WARNING_CONFIG_FAILED; | |
1883 | } | |
718e3744 | 1884 | |
5d5393b9 | 1885 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY); |
718e3744 | 1886 | |
d62a17ae | 1887 | return CMD_SUCCESS; |
718e3744 | 1888 | } |
1889 | ||
1890 | DEFUN (no_bgp_timers, | |
1891 | no_bgp_timers_cmd, | |
838758ac | 1892 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1893 | NO_STR |
1894 | "Adjust routing timers\n" | |
838758ac DW |
1895 | "BGP timers\n" |
1896 | "Keepalive interval\n" | |
1897 | "Holdtime\n") | |
718e3744 | 1898 | { |
d62a17ae | 1899 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5d5393b9 DL |
1900 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, |
1901 | DFLT_BGP_CONNECT_RETRY); | |
718e3744 | 1902 | |
d62a17ae | 1903 | return CMD_SUCCESS; |
718e3744 | 1904 | } |
1905 | ||
6b0655a2 | 1906 | |
718e3744 | 1907 | DEFUN (bgp_client_to_client_reflection, |
1908 | bgp_client_to_client_reflection_cmd, | |
1909 | "bgp client-to-client reflection", | |
1910 | "BGP specific commands\n" | |
1911 | "Configure client to client route reflection\n" | |
1912 | "reflection of routes allowed\n") | |
1913 | { | |
d62a17ae | 1914 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1915 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1916 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1917 | |
d62a17ae | 1918 | return CMD_SUCCESS; |
718e3744 | 1919 | } |
1920 | ||
1921 | DEFUN (no_bgp_client_to_client_reflection, | |
1922 | no_bgp_client_to_client_reflection_cmd, | |
1923 | "no bgp client-to-client reflection", | |
1924 | NO_STR | |
1925 | "BGP specific commands\n" | |
1926 | "Configure client to client route reflection\n" | |
1927 | "reflection of routes allowed\n") | |
1928 | { | |
d62a17ae | 1929 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1930 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1931 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1932 | |
d62a17ae | 1933 | return CMD_SUCCESS; |
718e3744 | 1934 | } |
1935 | ||
1936 | /* "bgp always-compare-med" configuration. */ | |
1937 | DEFUN (bgp_always_compare_med, | |
1938 | bgp_always_compare_med_cmd, | |
1939 | "bgp always-compare-med", | |
1940 | "BGP specific commands\n" | |
1941 | "Allow comparing MED from different neighbors\n") | |
1942 | { | |
d62a17ae | 1943 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1944 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1945 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1946 | |
d62a17ae | 1947 | return CMD_SUCCESS; |
718e3744 | 1948 | } |
1949 | ||
1950 | DEFUN (no_bgp_always_compare_med, | |
1951 | no_bgp_always_compare_med_cmd, | |
1952 | "no bgp always-compare-med", | |
1953 | NO_STR | |
1954 | "BGP specific commands\n" | |
1955 | "Allow comparing MED from different neighbors\n") | |
1956 | { | |
d62a17ae | 1957 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1958 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1959 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1960 | |
d62a17ae | 1961 | return CMD_SUCCESS; |
718e3744 | 1962 | } |
6b0655a2 | 1963 | |
9dac9fc8 DA |
1964 | |
1965 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
1966 | "bgp ebgp-requires-policy", | |
1967 | "BGP specific commands\n" | |
1968 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1969 | { | |
1970 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1971 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
1972 | return CMD_SUCCESS; | |
1973 | } | |
1974 | ||
1975 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
1976 | "no bgp ebgp-requires-policy", | |
1977 | NO_STR | |
1978 | "BGP specific commands\n" | |
1979 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1980 | { | |
1981 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1982 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
1983 | return CMD_SUCCESS; | |
1984 | } | |
1985 | ||
fb29348a DA |
1986 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
1987 | "bgp reject-as-sets", | |
1988 | "BGP specific commands\n" | |
1989 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
1990 | { | |
1991 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1992 | struct listnode *node, *nnode; | |
1993 | struct peer *peer; | |
1994 | ||
1995 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_ENABLED; | |
1996 | ||
1997 | /* Reset existing BGP sessions to reject routes | |
1998 | * with aspath containing AS_SET or AS_CONFED_SET. | |
1999 | */ | |
2000 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2001 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2002 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2003 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2004 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2005 | } | |
2006 | } | |
2007 | ||
2008 | return CMD_SUCCESS; | |
2009 | } | |
2010 | ||
2011 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2012 | "no bgp reject-as-sets", | |
2013 | NO_STR | |
2014 | "BGP specific commands\n" | |
2015 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2016 | { | |
2017 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2018 | struct listnode *node, *nnode; | |
2019 | struct peer *peer; | |
2020 | ||
2021 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_DISABLED; | |
2022 | ||
2023 | /* Reset existing BGP sessions to reject routes | |
2024 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2025 | */ | |
2026 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2027 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2028 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2029 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2030 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2031 | } | |
2032 | } | |
2033 | ||
2034 | return CMD_SUCCESS; | |
2035 | } | |
9dac9fc8 | 2036 | |
718e3744 | 2037 | /* "bgp deterministic-med" configuration. */ |
2038 | DEFUN (bgp_deterministic_med, | |
2039 | bgp_deterministic_med_cmd, | |
2040 | "bgp deterministic-med", | |
2041 | "BGP specific commands\n" | |
2042 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2043 | { | |
d62a17ae | 2044 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 2045 | |
d62a17ae | 2046 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
2047 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
2048 | bgp_recalculate_all_bestpaths(bgp); | |
2049 | } | |
7aafcaca | 2050 | |
d62a17ae | 2051 | return CMD_SUCCESS; |
718e3744 | 2052 | } |
2053 | ||
2054 | DEFUN (no_bgp_deterministic_med, | |
2055 | no_bgp_deterministic_med_cmd, | |
2056 | "no bgp deterministic-med", | |
2057 | NO_STR | |
2058 | "BGP specific commands\n" | |
2059 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2060 | { | |
d62a17ae | 2061 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2062 | int bestpath_per_as_used; | |
2063 | afi_t afi; | |
2064 | safi_t safi; | |
2065 | struct peer *peer; | |
2066 | struct listnode *node, *nnode; | |
2067 | ||
2068 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
2069 | bestpath_per_as_used = 0; | |
2070 | ||
2071 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 2072 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
2073 | if (bgp_addpath_dmed_required( |
2074 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
2075 | bestpath_per_as_used = 1; |
2076 | break; | |
2077 | } | |
d62a17ae | 2078 | |
2079 | if (bestpath_per_as_used) | |
2080 | break; | |
2081 | } | |
2082 | ||
2083 | if (bestpath_per_as_used) { | |
2084 | vty_out(vty, | |
2085 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2086 | return CMD_WARNING_CONFIG_FAILED; | |
2087 | } else { | |
2088 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
2089 | bgp_recalculate_all_bestpaths(bgp); | |
2090 | } | |
2091 | } | |
2092 | ||
2093 | return CMD_SUCCESS; | |
718e3744 | 2094 | } |
538621f2 | 2095 | |
2096 | /* "bgp graceful-restart" configuration. */ | |
2097 | DEFUN (bgp_graceful_restart, | |
2098 | bgp_graceful_restart_cmd, | |
2099 | "bgp graceful-restart", | |
2100 | "BGP specific commands\n" | |
2101 | "Graceful restart capability parameters\n") | |
2102 | { | |
d62a17ae | 2103 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2104 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
2105 | return CMD_SUCCESS; | |
538621f2 | 2106 | } |
2107 | ||
2108 | DEFUN (no_bgp_graceful_restart, | |
2109 | no_bgp_graceful_restart_cmd, | |
2110 | "no bgp graceful-restart", | |
2111 | NO_STR | |
2112 | "BGP specific commands\n" | |
2113 | "Graceful restart capability parameters\n") | |
2114 | { | |
d62a17ae | 2115 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2116 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
2117 | return CMD_SUCCESS; | |
538621f2 | 2118 | } |
2119 | ||
93406d87 | 2120 | DEFUN (bgp_graceful_restart_stalepath_time, |
2121 | bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 2122 | "bgp graceful-restart stalepath-time (1-4095)", |
93406d87 | 2123 | "BGP specific commands\n" |
2124 | "Graceful restart capability parameters\n" | |
2125 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2126 | "Delay value (seconds)\n") | |
2127 | { | |
d62a17ae | 2128 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2129 | int idx_number = 3; | |
d7c0a89a | 2130 | uint32_t stalepath; |
93406d87 | 2131 | |
d62a17ae | 2132 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2133 | bgp->stalepath_time = stalepath; | |
2134 | return CMD_SUCCESS; | |
93406d87 | 2135 | } |
2136 | ||
eb6f1b41 PG |
2137 | DEFUN (bgp_graceful_restart_restart_time, |
2138 | bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 2139 | "bgp graceful-restart restart-time (1-4095)", |
eb6f1b41 PG |
2140 | "BGP specific commands\n" |
2141 | "Graceful restart capability parameters\n" | |
2142 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2143 | "Delay value (seconds)\n") | |
2144 | { | |
d62a17ae | 2145 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2146 | int idx_number = 3; | |
d7c0a89a | 2147 | uint32_t restart; |
eb6f1b41 | 2148 | |
d62a17ae | 2149 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2150 | bgp->restart_time = restart; | |
2151 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2152 | } |
2153 | ||
93406d87 | 2154 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2155 | no_bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 2156 | "no bgp graceful-restart stalepath-time [(1-4095)]", |
93406d87 | 2157 | NO_STR |
2158 | "BGP specific commands\n" | |
2159 | "Graceful restart capability parameters\n" | |
838758ac DW |
2160 | "Set the max time to hold onto restarting peer's stale paths\n" |
2161 | "Delay value (seconds)\n") | |
93406d87 | 2162 | { |
d62a17ae | 2163 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2164 | |
d62a17ae | 2165 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2166 | return CMD_SUCCESS; | |
93406d87 | 2167 | } |
2168 | ||
eb6f1b41 PG |
2169 | DEFUN (no_bgp_graceful_restart_restart_time, |
2170 | no_bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 2171 | "no bgp graceful-restart restart-time [(1-4095)]", |
eb6f1b41 PG |
2172 | NO_STR |
2173 | "BGP specific commands\n" | |
2174 | "Graceful restart capability parameters\n" | |
838758ac DW |
2175 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
2176 | "Delay value (seconds)\n") | |
eb6f1b41 | 2177 | { |
d62a17ae | 2178 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2179 | |
d62a17ae | 2180 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2181 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2182 | } |
2183 | ||
43fc21b3 JC |
2184 | DEFUN (bgp_graceful_restart_preserve_fw, |
2185 | bgp_graceful_restart_preserve_fw_cmd, | |
2186 | "bgp graceful-restart preserve-fw-state", | |
2187 | "BGP specific commands\n" | |
2188 | "Graceful restart capability parameters\n" | |
2189 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2190 | { | |
d62a17ae | 2191 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2192 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2193 | return CMD_SUCCESS; | |
43fc21b3 JC |
2194 | } |
2195 | ||
2196 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2197 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2198 | "no bgp graceful-restart preserve-fw-state", | |
2199 | NO_STR | |
2200 | "BGP specific commands\n" | |
2201 | "Graceful restart capability parameters\n" | |
2202 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2203 | { | |
d62a17ae | 2204 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2205 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2206 | return CMD_SUCCESS; | |
43fc21b3 JC |
2207 | } |
2208 | ||
7f323236 DW |
2209 | /* "bgp graceful-shutdown" configuration */ |
2210 | DEFUN (bgp_graceful_shutdown, | |
2211 | bgp_graceful_shutdown_cmd, | |
2212 | "bgp graceful-shutdown", | |
2213 | BGP_STR | |
2214 | "Graceful shutdown parameters\n") | |
2215 | { | |
2216 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2217 | ||
2218 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2219 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2220 | bgp_static_redo_import_check(bgp); | |
2221 | bgp_redistribute_redo(bgp); | |
2222 | bgp_clear_star_soft_out(vty, bgp->name); | |
2223 | bgp_clear_star_soft_in(vty, bgp->name); | |
2224 | } | |
2225 | ||
2226 | return CMD_SUCCESS; | |
2227 | } | |
2228 | ||
2229 | DEFUN (no_bgp_graceful_shutdown, | |
2230 | no_bgp_graceful_shutdown_cmd, | |
2231 | "no bgp graceful-shutdown", | |
2232 | NO_STR | |
2233 | BGP_STR | |
2234 | "Graceful shutdown parameters\n") | |
2235 | { | |
2236 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2237 | ||
2238 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2239 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2240 | bgp_static_redo_import_check(bgp); | |
2241 | bgp_redistribute_redo(bgp); | |
2242 | bgp_clear_star_soft_out(vty, bgp->name); | |
2243 | bgp_clear_star_soft_in(vty, bgp->name); | |
2244 | } | |
2245 | ||
2246 | return CMD_SUCCESS; | |
2247 | } | |
2248 | ||
718e3744 | 2249 | /* "bgp fast-external-failover" configuration. */ |
2250 | DEFUN (bgp_fast_external_failover, | |
2251 | bgp_fast_external_failover_cmd, | |
2252 | "bgp fast-external-failover", | |
2253 | BGP_STR | |
2254 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2255 | { | |
d62a17ae | 2256 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2257 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2258 | return CMD_SUCCESS; | |
718e3744 | 2259 | } |
2260 | ||
2261 | DEFUN (no_bgp_fast_external_failover, | |
2262 | no_bgp_fast_external_failover_cmd, | |
2263 | "no bgp fast-external-failover", | |
2264 | NO_STR | |
2265 | BGP_STR | |
2266 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2267 | { | |
d62a17ae | 2268 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2269 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2270 | return CMD_SUCCESS; | |
718e3744 | 2271 | } |
6b0655a2 | 2272 | |
718e3744 | 2273 | /* "bgp bestpath compare-routerid" configuration. */ |
2274 | DEFUN (bgp_bestpath_compare_router_id, | |
2275 | bgp_bestpath_compare_router_id_cmd, | |
2276 | "bgp bestpath compare-routerid", | |
2277 | "BGP specific commands\n" | |
2278 | "Change the default bestpath selection\n" | |
2279 | "Compare router-id for identical EBGP paths\n") | |
2280 | { | |
d62a17ae | 2281 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2282 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2283 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2284 | |
d62a17ae | 2285 | return CMD_SUCCESS; |
718e3744 | 2286 | } |
2287 | ||
2288 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2289 | no_bgp_bestpath_compare_router_id_cmd, | |
2290 | "no bgp bestpath compare-routerid", | |
2291 | NO_STR | |
2292 | "BGP specific commands\n" | |
2293 | "Change the default bestpath selection\n" | |
2294 | "Compare router-id for identical EBGP paths\n") | |
2295 | { | |
d62a17ae | 2296 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2297 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2298 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2299 | |
d62a17ae | 2300 | return CMD_SUCCESS; |
718e3744 | 2301 | } |
6b0655a2 | 2302 | |
718e3744 | 2303 | /* "bgp bestpath as-path ignore" configuration. */ |
2304 | DEFUN (bgp_bestpath_aspath_ignore, | |
2305 | bgp_bestpath_aspath_ignore_cmd, | |
2306 | "bgp bestpath as-path ignore", | |
2307 | "BGP specific commands\n" | |
2308 | "Change the default bestpath selection\n" | |
2309 | "AS-path attribute\n" | |
2310 | "Ignore as-path length in selecting a route\n") | |
2311 | { | |
d62a17ae | 2312 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2313 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2314 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2315 | |
d62a17ae | 2316 | return CMD_SUCCESS; |
718e3744 | 2317 | } |
2318 | ||
2319 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2320 | no_bgp_bestpath_aspath_ignore_cmd, | |
2321 | "no bgp bestpath as-path ignore", | |
2322 | NO_STR | |
2323 | "BGP specific commands\n" | |
2324 | "Change the default bestpath selection\n" | |
2325 | "AS-path attribute\n" | |
2326 | "Ignore as-path length in selecting a route\n") | |
2327 | { | |
d62a17ae | 2328 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2329 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2330 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2331 | |
d62a17ae | 2332 | return CMD_SUCCESS; |
718e3744 | 2333 | } |
6b0655a2 | 2334 | |
6811845b | 2335 | /* "bgp bestpath as-path confed" configuration. */ |
2336 | DEFUN (bgp_bestpath_aspath_confed, | |
2337 | bgp_bestpath_aspath_confed_cmd, | |
2338 | "bgp bestpath as-path confed", | |
2339 | "BGP specific commands\n" | |
2340 | "Change the default bestpath selection\n" | |
2341 | "AS-path attribute\n" | |
2342 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2343 | { | |
d62a17ae | 2344 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2345 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2346 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2347 | |
d62a17ae | 2348 | return CMD_SUCCESS; |
6811845b | 2349 | } |
2350 | ||
2351 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2352 | no_bgp_bestpath_aspath_confed_cmd, | |
2353 | "no bgp bestpath as-path confed", | |
2354 | NO_STR | |
2355 | "BGP specific commands\n" | |
2356 | "Change the default bestpath selection\n" | |
2357 | "AS-path attribute\n" | |
2358 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2359 | { | |
d62a17ae | 2360 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2361 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2362 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2363 | |
d62a17ae | 2364 | return CMD_SUCCESS; |
6811845b | 2365 | } |
6b0655a2 | 2366 | |
2fdd455c PM |
2367 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2368 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2369 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2370 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2371 | "BGP specific commands\n" |
2372 | "Change the default bestpath selection\n" | |
2373 | "AS-path attribute\n" | |
2374 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2375 | "Generate an AS_SET\n" |
16fc1eec DS |
2376 | "Do not generate an AS_SET\n") |
2377 | { | |
d62a17ae | 2378 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2379 | int idx = 0; | |
2380 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2381 | |
d62a17ae | 2382 | /* no-as-set is now the default behavior so we can silently |
2383 | * ignore it */ | |
2384 | if (argv_find(argv, argc, "as-set", &idx)) | |
2385 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2386 | else | |
2387 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2388 | |
d62a17ae | 2389 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2390 | |
d62a17ae | 2391 | return CMD_SUCCESS; |
16fc1eec DS |
2392 | } |
2393 | ||
219178b6 DW |
2394 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2395 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2396 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2397 | NO_STR |
2398 | "BGP specific commands\n" | |
2399 | "Change the default bestpath selection\n" | |
2400 | "AS-path attribute\n" | |
2401 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2402 | "Generate an AS_SET\n" |
16fc1eec DS |
2403 | "Do not generate an AS_SET\n") |
2404 | { | |
d62a17ae | 2405 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2406 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2407 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2408 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2409 | |
d62a17ae | 2410 | return CMD_SUCCESS; |
2fdd455c | 2411 | } |
6b0655a2 | 2412 | |
848973c7 | 2413 | /* "bgp log-neighbor-changes" configuration. */ |
2414 | DEFUN (bgp_log_neighbor_changes, | |
2415 | bgp_log_neighbor_changes_cmd, | |
2416 | "bgp log-neighbor-changes", | |
2417 | "BGP specific commands\n" | |
2418 | "Log neighbor up/down and reset reason\n") | |
2419 | { | |
d62a17ae | 2420 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2421 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2422 | return CMD_SUCCESS; | |
848973c7 | 2423 | } |
2424 | ||
2425 | DEFUN (no_bgp_log_neighbor_changes, | |
2426 | no_bgp_log_neighbor_changes_cmd, | |
2427 | "no bgp log-neighbor-changes", | |
2428 | NO_STR | |
2429 | "BGP specific commands\n" | |
2430 | "Log neighbor up/down and reset reason\n") | |
2431 | { | |
d62a17ae | 2432 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2433 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2434 | return CMD_SUCCESS; | |
848973c7 | 2435 | } |
6b0655a2 | 2436 | |
718e3744 | 2437 | /* "bgp bestpath med" configuration. */ |
2438 | DEFUN (bgp_bestpath_med, | |
2439 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2440 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2441 | "BGP specific commands\n" |
2442 | "Change the default bestpath selection\n" | |
2443 | "MED attribute\n" | |
2444 | "Compare MED among confederation paths\n" | |
838758ac DW |
2445 | "Treat missing MED as the least preferred one\n" |
2446 | "Treat missing MED as the least preferred one\n" | |
2447 | "Compare MED among confederation paths\n") | |
718e3744 | 2448 | { |
d62a17ae | 2449 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2450 | |
d62a17ae | 2451 | int idx = 0; |
2452 | if (argv_find(argv, argc, "confed", &idx)) | |
2453 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2454 | idx = 0; | |
2455 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2456 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2457 | |
d62a17ae | 2458 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2459 | |
d62a17ae | 2460 | return CMD_SUCCESS; |
718e3744 | 2461 | } |
2462 | ||
718e3744 | 2463 | DEFUN (no_bgp_bestpath_med, |
2464 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2465 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2466 | NO_STR |
2467 | "BGP specific commands\n" | |
2468 | "Change the default bestpath selection\n" | |
2469 | "MED attribute\n" | |
2470 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2471 | "Treat missing MED as the least preferred one\n" |
2472 | "Treat missing MED as the least preferred one\n" | |
2473 | "Compare MED among confederation paths\n") | |
718e3744 | 2474 | { |
d62a17ae | 2475 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2476 | |
d62a17ae | 2477 | int idx = 0; |
2478 | if (argv_find(argv, argc, "confed", &idx)) | |
2479 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2480 | idx = 0; | |
2481 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2482 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2483 | |
d62a17ae | 2484 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2485 | |
d62a17ae | 2486 | return CMD_SUCCESS; |
718e3744 | 2487 | } |
2488 | ||
718e3744 | 2489 | /* "no bgp default ipv4-unicast". */ |
2490 | DEFUN (no_bgp_default_ipv4_unicast, | |
2491 | no_bgp_default_ipv4_unicast_cmd, | |
2492 | "no bgp default ipv4-unicast", | |
2493 | NO_STR | |
2494 | "BGP specific commands\n" | |
2495 | "Configure BGP defaults\n" | |
2496 | "Activate ipv4-unicast for a peer by default\n") | |
2497 | { | |
d62a17ae | 2498 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2499 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2500 | return CMD_SUCCESS; | |
718e3744 | 2501 | } |
2502 | ||
2503 | DEFUN (bgp_default_ipv4_unicast, | |
2504 | bgp_default_ipv4_unicast_cmd, | |
2505 | "bgp default ipv4-unicast", | |
2506 | "BGP specific commands\n" | |
2507 | "Configure BGP defaults\n" | |
2508 | "Activate ipv4-unicast for a peer by default\n") | |
2509 | { | |
d62a17ae | 2510 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2511 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2512 | return CMD_SUCCESS; | |
718e3744 | 2513 | } |
6b0655a2 | 2514 | |
04b6bdc0 DW |
2515 | /* Display hostname in certain command outputs */ |
2516 | DEFUN (bgp_default_show_hostname, | |
2517 | bgp_default_show_hostname_cmd, | |
2518 | "bgp default show-hostname", | |
2519 | "BGP specific commands\n" | |
2520 | "Configure BGP defaults\n" | |
0437e105 | 2521 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2522 | { |
d62a17ae | 2523 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2524 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2525 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2526 | } |
2527 | ||
2528 | DEFUN (no_bgp_default_show_hostname, | |
2529 | no_bgp_default_show_hostname_cmd, | |
2530 | "no bgp default show-hostname", | |
2531 | NO_STR | |
2532 | "BGP specific commands\n" | |
2533 | "Configure BGP defaults\n" | |
0437e105 | 2534 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2535 | { |
d62a17ae | 2536 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2537 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2538 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2539 | } |
2540 | ||
8233ef81 | 2541 | /* "bgp network import-check" configuration. */ |
718e3744 | 2542 | DEFUN (bgp_network_import_check, |
2543 | bgp_network_import_check_cmd, | |
5623e905 | 2544 | "bgp network import-check", |
718e3744 | 2545 | "BGP specific commands\n" |
2546 | "BGP network command\n" | |
5623e905 | 2547 | "Check BGP network route exists in IGP\n") |
718e3744 | 2548 | { |
d62a17ae | 2549 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2550 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2551 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2552 | bgp_static_redo_import_check(bgp); | |
2553 | } | |
078430f6 | 2554 | |
d62a17ae | 2555 | return CMD_SUCCESS; |
718e3744 | 2556 | } |
2557 | ||
d62a17ae | 2558 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2559 | "bgp network import-check exact", | |
2560 | "BGP specific commands\n" | |
2561 | "BGP network command\n" | |
2562 | "Check BGP network route exists in IGP\n" | |
2563 | "Match route precisely\n") | |
8233ef81 | 2564 | |
718e3744 | 2565 | DEFUN (no_bgp_network_import_check, |
2566 | no_bgp_network_import_check_cmd, | |
5623e905 | 2567 | "no bgp network import-check", |
718e3744 | 2568 | NO_STR |
2569 | "BGP specific commands\n" | |
2570 | "BGP network command\n" | |
2571 | "Check BGP network route exists in IGP\n") | |
2572 | { | |
d62a17ae | 2573 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2574 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2575 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2576 | bgp_static_redo_import_check(bgp); | |
2577 | } | |
5623e905 | 2578 | |
d62a17ae | 2579 | return CMD_SUCCESS; |
718e3744 | 2580 | } |
6b0655a2 | 2581 | |
718e3744 | 2582 | DEFUN (bgp_default_local_preference, |
2583 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2584 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2585 | "BGP specific commands\n" |
2586 | "Configure BGP defaults\n" | |
2587 | "local preference (higher=more preferred)\n" | |
2588 | "Configure default local preference value\n") | |
2589 | { | |
d62a17ae | 2590 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2591 | int idx_number = 3; | |
d7c0a89a | 2592 | uint32_t local_pref; |
718e3744 | 2593 | |
d62a17ae | 2594 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2595 | |
d62a17ae | 2596 | bgp_default_local_preference_set(bgp, local_pref); |
2597 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2598 | |
d62a17ae | 2599 | return CMD_SUCCESS; |
718e3744 | 2600 | } |
2601 | ||
2602 | DEFUN (no_bgp_default_local_preference, | |
2603 | no_bgp_default_local_preference_cmd, | |
838758ac | 2604 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2605 | NO_STR |
2606 | "BGP specific commands\n" | |
2607 | "Configure BGP defaults\n" | |
838758ac DW |
2608 | "local preference (higher=more preferred)\n" |
2609 | "Configure default local preference value\n") | |
718e3744 | 2610 | { |
d62a17ae | 2611 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2612 | bgp_default_local_preference_unset(bgp); | |
2613 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2614 | |
d62a17ae | 2615 | return CMD_SUCCESS; |
718e3744 | 2616 | } |
2617 | ||
6b0655a2 | 2618 | |
3f9c7369 DS |
2619 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2620 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2621 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2622 | "BGP specific commands\n" |
2623 | "Configure BGP defaults\n" | |
2624 | "subgroup-pkt-queue-max\n" | |
2625 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2626 | { |
d62a17ae | 2627 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2628 | int idx_number = 3; | |
d7c0a89a | 2629 | uint32_t max_size; |
8bd9d948 | 2630 | |
d62a17ae | 2631 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2632 | |
d62a17ae | 2633 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2634 | |
d62a17ae | 2635 | return CMD_SUCCESS; |
3f9c7369 DS |
2636 | } |
2637 | ||
2638 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2639 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2640 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2641 | NO_STR |
2642 | "BGP specific commands\n" | |
2643 | "Configure BGP defaults\n" | |
838758ac DW |
2644 | "subgroup-pkt-queue-max\n" |
2645 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2646 | { |
d62a17ae | 2647 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2648 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2649 | return CMD_SUCCESS; | |
8bd9d948 DS |
2650 | } |
2651 | ||
813d4307 | 2652 | |
8bd9d948 DS |
2653 | DEFUN (bgp_rr_allow_outbound_policy, |
2654 | bgp_rr_allow_outbound_policy_cmd, | |
2655 | "bgp route-reflector allow-outbound-policy", | |
2656 | "BGP specific commands\n" | |
2657 | "Allow modifications made by out route-map\n" | |
2658 | "on ibgp neighbors\n") | |
2659 | { | |
d62a17ae | 2660 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2661 | |
d62a17ae | 2662 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2663 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2664 | update_group_announce_rrclients(bgp); | |
2665 | bgp_clear_star_soft_out(vty, bgp->name); | |
2666 | } | |
8bd9d948 | 2667 | |
d62a17ae | 2668 | return CMD_SUCCESS; |
8bd9d948 DS |
2669 | } |
2670 | ||
2671 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2672 | no_bgp_rr_allow_outbound_policy_cmd, | |
2673 | "no bgp route-reflector allow-outbound-policy", | |
2674 | NO_STR | |
2675 | "BGP specific commands\n" | |
2676 | "Allow modifications made by out route-map\n" | |
2677 | "on ibgp neighbors\n") | |
2678 | { | |
d62a17ae | 2679 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2680 | |
d62a17ae | 2681 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2682 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2683 | update_group_announce_rrclients(bgp); | |
2684 | bgp_clear_star_soft_out(vty, bgp->name); | |
2685 | } | |
8bd9d948 | 2686 | |
d62a17ae | 2687 | return CMD_SUCCESS; |
8bd9d948 DS |
2688 | } |
2689 | ||
f14e6fdb DS |
2690 | DEFUN (bgp_listen_limit, |
2691 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2692 | "bgp listen limit (1-5000)", |
f14e6fdb | 2693 | "BGP specific commands\n" |
1601a46f | 2694 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 2695 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
f14e6fdb DS |
2696 | "Configure Dynamic Neighbors listen limit value\n") |
2697 | { | |
d62a17ae | 2698 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2699 | int idx_number = 3; | |
2700 | int listen_limit; | |
f14e6fdb | 2701 | |
d62a17ae | 2702 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2703 | |
d62a17ae | 2704 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2705 | |
d62a17ae | 2706 | return CMD_SUCCESS; |
f14e6fdb DS |
2707 | } |
2708 | ||
2709 | DEFUN (no_bgp_listen_limit, | |
2710 | no_bgp_listen_limit_cmd, | |
838758ac | 2711 | "no bgp listen limit [(1-5000)]", |
1601a46f | 2712 | NO_STR |
f14e6fdb | 2713 | "BGP specific commands\n" |
1601a46f | 2714 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 2715 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
838758ac | 2716 | "Configure Dynamic Neighbors listen limit value\n") |
f14e6fdb | 2717 | { |
d62a17ae | 2718 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2719 | bgp_listen_limit_unset(bgp); | |
2720 | return CMD_SUCCESS; | |
f14e6fdb DS |
2721 | } |
2722 | ||
2723 | ||
20eb8864 | 2724 | /* |
2725 | * Check if this listen range is already configured. Check for exact | |
2726 | * match or overlap based on input. | |
2727 | */ | |
d62a17ae | 2728 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2729 | struct prefix *range, int exact) | |
2730 | { | |
2731 | struct listnode *node, *nnode; | |
2732 | struct listnode *node1, *nnode1; | |
2733 | struct peer_group *group; | |
2734 | struct prefix *lr; | |
2735 | afi_t afi; | |
2736 | int match; | |
2737 | ||
2738 | afi = family2afi(range->family); | |
2739 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2740 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2741 | lr)) { | |
2742 | if (exact) | |
2743 | match = prefix_same(range, lr); | |
2744 | else | |
2745 | match = (prefix_match(range, lr) | |
2746 | || prefix_match(lr, range)); | |
2747 | if (match) | |
2748 | return group; | |
2749 | } | |
2750 | } | |
2751 | ||
2752 | return NULL; | |
20eb8864 | 2753 | } |
2754 | ||
f14e6fdb DS |
2755 | DEFUN (bgp_listen_range, |
2756 | bgp_listen_range_cmd, | |
d7b9898c | 2757 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 2758 | "BGP specific commands\n" |
d7fa34c1 QY |
2759 | "Configure BGP dynamic neighbors listen range\n" |
2760 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2761 | NEIGHBOR_ADDR_STR |
2762 | "Member of the peer-group\n" | |
2763 | "Peer-group name\n") | |
f14e6fdb | 2764 | { |
d62a17ae | 2765 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2766 | struct prefix range; | |
2767 | struct peer_group *group, *existing_group; | |
2768 | afi_t afi; | |
2769 | int ret; | |
2770 | int idx = 0; | |
2771 | ||
2772 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2773 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2774 | char *prefix = argv[idx]->arg; | |
d7b9898c | 2775 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 2776 | char *peergroup = argv[idx]->arg; |
2777 | ||
2778 | /* Convert IP prefix string to struct prefix. */ | |
2779 | ret = str2prefix(prefix, &range); | |
2780 | if (!ret) { | |
2781 | vty_out(vty, "%% Malformed listen range\n"); | |
2782 | return CMD_WARNING_CONFIG_FAILED; | |
2783 | } | |
2784 | ||
2785 | afi = family2afi(range.family); | |
2786 | ||
2787 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2788 | vty_out(vty, | |
2789 | "%% Malformed listen range (link-local address)\n"); | |
2790 | return CMD_WARNING_CONFIG_FAILED; | |
2791 | } | |
2792 | ||
2793 | apply_mask(&range); | |
2794 | ||
2795 | /* Check if same listen range is already configured. */ | |
2796 | existing_group = listen_range_exists(bgp, &range, 1); | |
2797 | if (existing_group) { | |
2798 | if (strcmp(existing_group->name, peergroup) == 0) | |
2799 | return CMD_SUCCESS; | |
2800 | else { | |
2801 | vty_out(vty, | |
2802 | "%% Same listen range is attached to peer-group %s\n", | |
2803 | existing_group->name); | |
2804 | return CMD_WARNING_CONFIG_FAILED; | |
2805 | } | |
2806 | } | |
2807 | ||
2808 | /* Check if an overlapping listen range exists. */ | |
2809 | if (listen_range_exists(bgp, &range, 0)) { | |
2810 | vty_out(vty, | |
2811 | "%% Listen range overlaps with existing listen range\n"); | |
2812 | return CMD_WARNING_CONFIG_FAILED; | |
2813 | } | |
2814 | ||
2815 | group = peer_group_lookup(bgp, peergroup); | |
2816 | if (!group) { | |
2817 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2818 | return CMD_WARNING_CONFIG_FAILED; | |
2819 | } | |
2820 | ||
2821 | ret = peer_group_listen_range_add(group, &range); | |
2822 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2823 | } |
2824 | ||
2825 | DEFUN (no_bgp_listen_range, | |
2826 | no_bgp_listen_range_cmd, | |
d7b9898c | 2827 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 2828 | NO_STR |
f14e6fdb | 2829 | "BGP specific commands\n" |
d7fa34c1 QY |
2830 | "Unconfigure BGP dynamic neighbors listen range\n" |
2831 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2832 | NEIGHBOR_ADDR_STR | |
2833 | "Member of the peer-group\n" | |
2834 | "Peer-group name\n") | |
f14e6fdb | 2835 | { |
d62a17ae | 2836 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2837 | struct prefix range; | |
2838 | struct peer_group *group; | |
2839 | afi_t afi; | |
2840 | int ret; | |
2841 | int idx = 0; | |
2842 | ||
2843 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2844 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2845 | char *prefix = argv[idx]->arg; | |
21d88a71 | 2846 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 2847 | char *peergroup = argv[idx]->arg; |
2848 | ||
2849 | /* Convert IP prefix string to struct prefix. */ | |
2850 | ret = str2prefix(prefix, &range); | |
2851 | if (!ret) { | |
2852 | vty_out(vty, "%% Malformed listen range\n"); | |
2853 | return CMD_WARNING_CONFIG_FAILED; | |
2854 | } | |
2855 | ||
2856 | afi = family2afi(range.family); | |
2857 | ||
2858 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2859 | vty_out(vty, | |
2860 | "%% Malformed listen range (link-local address)\n"); | |
2861 | return CMD_WARNING_CONFIG_FAILED; | |
2862 | } | |
2863 | ||
2864 | apply_mask(&range); | |
2865 | ||
2866 | group = peer_group_lookup(bgp, peergroup); | |
2867 | if (!group) { | |
2868 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2869 | return CMD_WARNING_CONFIG_FAILED; | |
2870 | } | |
2871 | ||
2872 | ret = peer_group_listen_range_del(group, &range); | |
2873 | return bgp_vty_return(vty, ret); | |
2874 | } | |
2875 | ||
2b791107 | 2876 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2877 | { |
2878 | struct peer_group *group; | |
2879 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2880 | struct prefix *range; | |
2881 | afi_t afi; | |
2882 | char buf[PREFIX2STR_BUFFER]; | |
2883 | ||
2884 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2885 | vty_out(vty, " bgp listen limit %d\n", | |
2886 | bgp->dynamic_neighbors_limit); | |
2887 | ||
2888 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2889 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2890 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2891 | nrnode, range)) { | |
2892 | prefix2str(range, buf, sizeof(buf)); | |
2893 | vty_out(vty, | |
2894 | " bgp listen range %s peer-group %s\n", | |
2895 | buf, group->name); | |
2896 | } | |
2897 | } | |
2898 | } | |
f14e6fdb DS |
2899 | } |
2900 | ||
2901 | ||
907f92c8 DS |
2902 | DEFUN (bgp_disable_connected_route_check, |
2903 | bgp_disable_connected_route_check_cmd, | |
2904 | "bgp disable-ebgp-connected-route-check", | |
2905 | "BGP specific commands\n" | |
2906 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2907 | { | |
d62a17ae | 2908 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2909 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2910 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2911 | |
d62a17ae | 2912 | return CMD_SUCCESS; |
907f92c8 DS |
2913 | } |
2914 | ||
2915 | DEFUN (no_bgp_disable_connected_route_check, | |
2916 | no_bgp_disable_connected_route_check_cmd, | |
2917 | "no bgp disable-ebgp-connected-route-check", | |
2918 | NO_STR | |
2919 | "BGP specific commands\n" | |
2920 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2921 | { | |
d62a17ae | 2922 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2923 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2924 | bgp_clear_star_soft_in(vty, bgp->name); | |
2925 | ||
2926 | return CMD_SUCCESS; | |
2927 | } | |
2928 | ||
2929 | ||
2930 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2931 | const char *as_str, afi_t afi, safi_t safi) | |
2932 | { | |
2933 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2934 | int ret; | |
2935 | as_t as; | |
2936 | int as_type = AS_SPECIFIED; | |
2937 | union sockunion su; | |
2938 | ||
2939 | if (as_str[0] == 'i') { | |
2940 | as = 0; | |
2941 | as_type = AS_INTERNAL; | |
2942 | } else if (as_str[0] == 'e') { | |
2943 | as = 0; | |
2944 | as_type = AS_EXTERNAL; | |
2945 | } else { | |
2946 | /* Get AS number. */ | |
2947 | as = strtoul(as_str, NULL, 10); | |
2948 | } | |
2949 | ||
390485fd | 2950 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 2951 | ret = str2sockunion(peer_str, &su); |
2952 | if (ret < 0) { | |
390485fd DS |
2953 | struct peer *peer; |
2954 | ||
2955 | /* Check if existing interface peer */ | |
2956 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
2957 | ||
d62a17ae | 2958 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
2959 | safi); | |
390485fd DS |
2960 | |
2961 | /* if not interface peer, check peer-group settings */ | |
2962 | if (ret < 0 && !peer) { | |
d62a17ae | 2963 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
2964 | if (ret < 0) { | |
2965 | vty_out(vty, | |
390485fd | 2966 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 2967 | return CMD_WARNING_CONFIG_FAILED; |
2968 | } | |
2969 | return CMD_SUCCESS; | |
2970 | } | |
2971 | } else { | |
2972 | if (peer_address_self_check(bgp, &su)) { | |
2973 | vty_out(vty, | |
2974 | "%% Can not configure the local system as neighbor\n"); | |
2975 | return CMD_WARNING_CONFIG_FAILED; | |
2976 | } | |
2977 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2978 | } | |
2979 | ||
2980 | /* This peer belongs to peer group. */ | |
2981 | switch (ret) { | |
2982 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2983 | vty_out(vty, | |
faa16034 | 2984 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 2985 | return CMD_WARNING_CONFIG_FAILED; |
2986 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2987 | vty_out(vty, | |
faa16034 | 2988 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 2989 | return CMD_WARNING_CONFIG_FAILED; |
2990 | } | |
2991 | return bgp_vty_return(vty, ret); | |
718e3744 | 2992 | } |
2993 | ||
f26845f9 QY |
2994 | DEFUN (bgp_default_shutdown, |
2995 | bgp_default_shutdown_cmd, | |
2996 | "[no] bgp default shutdown", | |
2997 | NO_STR | |
2998 | BGP_STR | |
2999 | "Configure BGP defaults\n" | |
b012cbe2 | 3000 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
3001 | { |
3002 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3003 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
3004 | return CMD_SUCCESS; | |
3005 | } | |
3006 | ||
718e3744 | 3007 | DEFUN (neighbor_remote_as, |
3008 | neighbor_remote_as_cmd, | |
3a2d747c | 3009 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3010 | NEIGHBOR_STR |
3011 | NEIGHBOR_ADDR_STR2 | |
3012 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 3013 | AS_STR |
3a2d747c QY |
3014 | "Internal BGP peer\n" |
3015 | "External BGP peer\n") | |
718e3744 | 3016 | { |
d62a17ae | 3017 | int idx_peer = 1; |
3018 | int idx_remote_as = 3; | |
3019 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
3020 | argv[idx_remote_as]->arg, AFI_IP, | |
3021 | SAFI_UNICAST); | |
3022 | } | |
3023 | ||
3024 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
3025 | afi_t afi, safi_t safi, int v6only, | |
3026 | const char *peer_group_name, | |
3027 | const char *as_str) | |
3028 | { | |
3029 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3030 | as_t as = 0; | |
3031 | int as_type = AS_UNSPECIFIED; | |
3032 | struct peer *peer; | |
3033 | struct peer_group *group; | |
3034 | int ret = 0; | |
3035 | union sockunion su; | |
3036 | ||
3037 | group = peer_group_lookup(bgp, conf_if); | |
3038 | ||
3039 | if (group) { | |
3040 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
3041 | return CMD_WARNING_CONFIG_FAILED; | |
3042 | } | |
3043 | ||
3044 | if (as_str) { | |
3045 | if (as_str[0] == 'i') { | |
3046 | as_type = AS_INTERNAL; | |
3047 | } else if (as_str[0] == 'e') { | |
3048 | as_type = AS_EXTERNAL; | |
3049 | } else { | |
3050 | /* Get AS number. */ | |
3051 | as = strtoul(as_str, NULL, 10); | |
3052 | as_type = AS_SPECIFIED; | |
3053 | } | |
3054 | } | |
3055 | ||
3056 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
3057 | if (peer) { | |
3058 | if (as_str) | |
cc4d4ce8 | 3059 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 3060 | afi, safi); |
3061 | } else { | |
3062 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
3063 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
3064 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3065 | as_type, 0, 0, NULL); | |
3066 | else | |
3067 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3068 | as_type, afi, safi, NULL); | |
3069 | ||
3070 | if (!peer) { | |
3071 | vty_out(vty, "%% BGP failed to create peer\n"); | |
3072 | return CMD_WARNING_CONFIG_FAILED; | |
3073 | } | |
3074 | ||
3075 | if (v6only) | |
527de3dc | 3076 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3077 | |
3078 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
3079 | * this | |
3080 | * any unnumbered peer in order to not worry about run-time | |
3081 | * transitions | |
3082 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3083 | * address | |
3084 | * gets deleted later etc.) | |
3085 | */ | |
3086 | if (peer->ifp) | |
3087 | bgp_zebra_initiate_radv(bgp, peer); | |
3088 | } | |
3089 | ||
3090 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3091 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3092 | if (v6only) | |
527de3dc | 3093 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3094 | else |
527de3dc | 3095 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3096 | |
3097 | /* v6only flag changed. Reset bgp seesion */ | |
3098 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3099 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3100 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3101 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3102 | } else | |
3103 | bgp_session_reset(peer); | |
3104 | } | |
3105 | ||
9fb964de PM |
3106 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3107 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3108 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3109 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3110 | } |
d62a17ae | 3111 | |
3112 | if (peer_group_name) { | |
3113 | group = peer_group_lookup(bgp, peer_group_name); | |
3114 | if (!group) { | |
3115 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3116 | return CMD_WARNING_CONFIG_FAILED; | |
3117 | } | |
3118 | ||
3119 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3120 | } | |
3121 | ||
3122 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3123 | } |
3124 | ||
4c48cf63 DW |
3125 | DEFUN (neighbor_interface_config, |
3126 | neighbor_interface_config_cmd, | |
d7b9898c | 3127 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3128 | NEIGHBOR_STR |
3129 | "Interface name or neighbor tag\n" | |
31500417 DW |
3130 | "Enable BGP on interface\n" |
3131 | "Member of the peer-group\n" | |
16cedbb0 | 3132 | "Peer-group name\n") |
4c48cf63 | 3133 | { |
d62a17ae | 3134 | int idx_word = 1; |
3135 | int idx_peer_group_word = 4; | |
31500417 | 3136 | |
d62a17ae | 3137 | if (argc > idx_peer_group_word) |
3138 | return peer_conf_interface_get( | |
3139 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3140 | argv[idx_peer_group_word]->arg, NULL); | |
3141 | else | |
3142 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3143 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3144 | } |
3145 | ||
4c48cf63 DW |
3146 | DEFUN (neighbor_interface_config_v6only, |
3147 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3148 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3149 | NEIGHBOR_STR |
3150 | "Interface name or neighbor tag\n" | |
3151 | "Enable BGP on interface\n" | |
31500417 DW |
3152 | "Enable BGP with v6 link-local only\n" |
3153 | "Member of the peer-group\n" | |
16cedbb0 | 3154 | "Peer-group name\n") |
4c48cf63 | 3155 | { |
d62a17ae | 3156 | int idx_word = 1; |
3157 | int idx_peer_group_word = 5; | |
31500417 | 3158 | |
d62a17ae | 3159 | if (argc > idx_peer_group_word) |
3160 | return peer_conf_interface_get( | |
3161 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3162 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3163 | |
d62a17ae | 3164 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3165 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3166 | } |
3167 | ||
a80beece | 3168 | |
b3a39dc5 DD |
3169 | DEFUN (neighbor_interface_config_remote_as, |
3170 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3171 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3172 | NEIGHBOR_STR |
3173 | "Interface name or neighbor tag\n" | |
3174 | "Enable BGP on interface\n" | |
3a2d747c | 3175 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3176 | AS_STR |
3a2d747c QY |
3177 | "Internal BGP peer\n" |
3178 | "External BGP peer\n") | |
b3a39dc5 | 3179 | { |
d62a17ae | 3180 | int idx_word = 1; |
3181 | int idx_remote_as = 4; | |
3182 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3183 | SAFI_UNICAST, 0, NULL, | |
3184 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3185 | } |
3186 | ||
3187 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3188 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3189 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3190 | NEIGHBOR_STR |
3191 | "Interface name or neighbor tag\n" | |
3a2d747c | 3192 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3193 | "Enable BGP on interface\n" |
3a2d747c | 3194 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3195 | AS_STR |
3a2d747c QY |
3196 | "Internal BGP peer\n" |
3197 | "External BGP peer\n") | |
b3a39dc5 | 3198 | { |
d62a17ae | 3199 | int idx_word = 1; |
3200 | int idx_remote_as = 5; | |
3201 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3202 | SAFI_UNICAST, 1, NULL, | |
3203 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3204 | } |
3205 | ||
718e3744 | 3206 | DEFUN (neighbor_peer_group, |
3207 | neighbor_peer_group_cmd, | |
3208 | "neighbor WORD peer-group", | |
3209 | NEIGHBOR_STR | |
a80beece | 3210 | "Interface name or neighbor tag\n" |
718e3744 | 3211 | "Configure peer-group\n") |
3212 | { | |
d62a17ae | 3213 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3214 | int idx_word = 1; | |
3215 | struct peer *peer; | |
3216 | struct peer_group *group; | |
718e3744 | 3217 | |
d62a17ae | 3218 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3219 | if (peer) { | |
3220 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3221 | return CMD_WARNING_CONFIG_FAILED; | |
3222 | } | |
718e3744 | 3223 | |
d62a17ae | 3224 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3225 | if (!group) { | |
3226 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3227 | return CMD_WARNING_CONFIG_FAILED; | |
3228 | } | |
718e3744 | 3229 | |
d62a17ae | 3230 | return CMD_SUCCESS; |
718e3744 | 3231 | } |
3232 | ||
3233 | DEFUN (no_neighbor, | |
3234 | no_neighbor_cmd, | |
dab8cd00 | 3235 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3236 | NO_STR |
3237 | NEIGHBOR_STR | |
3a2d747c QY |
3238 | NEIGHBOR_ADDR_STR2 |
3239 | "Specify a BGP neighbor\n" | |
3240 | AS_STR | |
3241 | "Internal BGP peer\n" | |
3242 | "External BGP peer\n") | |
718e3744 | 3243 | { |
d62a17ae | 3244 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3245 | int idx_peer = 2; | |
3246 | int ret; | |
3247 | union sockunion su; | |
3248 | struct peer_group *group; | |
3249 | struct peer *peer; | |
3250 | struct peer *other; | |
3251 | ||
3252 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3253 | if (ret < 0) { | |
3254 | /* look up for neighbor by interface name config. */ | |
3255 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3256 | if (peer) { | |
3257 | /* Request zebra to terminate IPv6 RAs on this | |
3258 | * interface. */ | |
3259 | if (peer->ifp) | |
3260 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3261 | peer_notify_unconfig(peer); |
d62a17ae | 3262 | peer_delete(peer); |
3263 | return CMD_SUCCESS; | |
3264 | } | |
f14e6fdb | 3265 | |
d62a17ae | 3266 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
3267 | if (group) { |
3268 | peer_group_notify_unconfig(group); | |
d62a17ae | 3269 | peer_group_delete(group); |
4e2786df | 3270 | } else { |
d62a17ae | 3271 | vty_out(vty, "%% Create the peer-group first\n"); |
3272 | return CMD_WARNING_CONFIG_FAILED; | |
3273 | } | |
3274 | } else { | |
3275 | peer = peer_lookup(bgp, &su); | |
3276 | if (peer) { | |
3277 | if (peer_dynamic_neighbor(peer)) { | |
3278 | vty_out(vty, | |
3279 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3280 | return CMD_WARNING_CONFIG_FAILED; | |
3281 | } | |
3282 | ||
3283 | other = peer->doppelganger; | |
4e2786df | 3284 | peer_notify_unconfig(peer); |
d62a17ae | 3285 | peer_delete(peer); |
4e2786df DA |
3286 | if (other && other->status != Deleted) { |
3287 | peer_notify_unconfig(other); | |
d62a17ae | 3288 | peer_delete(other); |
4e2786df | 3289 | } |
d62a17ae | 3290 | } |
1ff9a340 | 3291 | } |
718e3744 | 3292 | |
d62a17ae | 3293 | return CMD_SUCCESS; |
718e3744 | 3294 | } |
3295 | ||
a80beece DS |
3296 | DEFUN (no_neighbor_interface_config, |
3297 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3298 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3299 | NO_STR |
3300 | NEIGHBOR_STR | |
3301 | "Interface name\n" | |
31500417 DW |
3302 | "Configure BGP on interface\n" |
3303 | "Enable BGP with v6 link-local only\n" | |
3304 | "Member of the peer-group\n" | |
16cedbb0 | 3305 | "Peer-group name\n" |
3a2d747c QY |
3306 | "Specify a BGP neighbor\n" |
3307 | AS_STR | |
3308 | "Internal BGP peer\n" | |
3309 | "External BGP peer\n") | |
a80beece | 3310 | { |
d62a17ae | 3311 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3312 | int idx_word = 2; | |
3313 | struct peer *peer; | |
3314 | ||
3315 | /* look up for neighbor by interface name config. */ | |
3316 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3317 | if (peer) { | |
3318 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3319 | if (peer->ifp) | |
3320 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3321 | peer_notify_unconfig(peer); |
d62a17ae | 3322 | peer_delete(peer); |
3323 | } else { | |
3324 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3325 | return CMD_WARNING_CONFIG_FAILED; | |
3326 | } | |
3327 | return CMD_SUCCESS; | |
a80beece DS |
3328 | } |
3329 | ||
718e3744 | 3330 | DEFUN (no_neighbor_peer_group, |
3331 | no_neighbor_peer_group_cmd, | |
3332 | "no neighbor WORD peer-group", | |
3333 | NO_STR | |
3334 | NEIGHBOR_STR | |
3335 | "Neighbor tag\n" | |
3336 | "Configure peer-group\n") | |
3337 | { | |
d62a17ae | 3338 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3339 | int idx_word = 2; | |
3340 | struct peer_group *group; | |
718e3744 | 3341 | |
d62a17ae | 3342 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
3343 | if (group) { |
3344 | peer_group_notify_unconfig(group); | |
d62a17ae | 3345 | peer_group_delete(group); |
4e2786df | 3346 | } else { |
d62a17ae | 3347 | vty_out(vty, "%% Create the peer-group first\n"); |
3348 | return CMD_WARNING_CONFIG_FAILED; | |
3349 | } | |
3350 | return CMD_SUCCESS; | |
718e3744 | 3351 | } |
3352 | ||
a80beece DS |
3353 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3354 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3355 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3356 | NO_STR |
3357 | NEIGHBOR_STR | |
a80beece | 3358 | "Interface name or neighbor tag\n" |
718e3744 | 3359 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3360 | AS_STR |
3361 | "Internal BGP peer\n" | |
3362 | "External BGP peer\n") | |
718e3744 | 3363 | { |
d62a17ae | 3364 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3365 | int idx_word = 2; | |
3366 | struct peer_group *group; | |
3367 | struct peer *peer; | |
3368 | ||
3369 | /* look up for neighbor by interface name config. */ | |
3370 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3371 | if (peer) { | |
390485fd | 3372 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3373 | return CMD_SUCCESS; |
3374 | } | |
3375 | ||
3376 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3377 | if (group) | |
3378 | peer_group_remote_as_delete(group); | |
3379 | else { | |
3380 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3381 | return CMD_WARNING_CONFIG_FAILED; | |
3382 | } | |
3383 | return CMD_SUCCESS; | |
718e3744 | 3384 | } |
6b0655a2 | 3385 | |
718e3744 | 3386 | DEFUN (neighbor_local_as, |
3387 | neighbor_local_as_cmd, | |
9ccf14f7 | 3388 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3389 | NEIGHBOR_STR |
3390 | NEIGHBOR_ADDR_STR2 | |
3391 | "Specify a local-as number\n" | |
3392 | "AS number used as local AS\n") | |
3393 | { | |
d62a17ae | 3394 | int idx_peer = 1; |
3395 | int idx_number = 3; | |
3396 | struct peer *peer; | |
3397 | int ret; | |
3398 | as_t as; | |
718e3744 | 3399 | |
d62a17ae | 3400 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3401 | if (!peer) | |
3402 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3403 | |
d62a17ae | 3404 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3405 | ret = peer_local_as_set(peer, as, 0, 0); | |
3406 | return bgp_vty_return(vty, ret); | |
718e3744 | 3407 | } |
3408 | ||
3409 | DEFUN (neighbor_local_as_no_prepend, | |
3410 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3411 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3412 | NEIGHBOR_STR |
3413 | NEIGHBOR_ADDR_STR2 | |
3414 | "Specify a local-as number\n" | |
3415 | "AS number used as local AS\n" | |
3416 | "Do not prepend local-as to updates from ebgp peers\n") | |
3417 | { | |
d62a17ae | 3418 | int idx_peer = 1; |
3419 | int idx_number = 3; | |
3420 | struct peer *peer; | |
3421 | int ret; | |
3422 | as_t as; | |
718e3744 | 3423 | |
d62a17ae | 3424 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3425 | if (!peer) | |
3426 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3427 | |
d62a17ae | 3428 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3429 | ret = peer_local_as_set(peer, as, 1, 0); | |
3430 | return bgp_vty_return(vty, ret); | |
718e3744 | 3431 | } |
3432 | ||
9d3f9705 AC |
3433 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3434 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3435 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3436 | NEIGHBOR_STR |
3437 | NEIGHBOR_ADDR_STR2 | |
3438 | "Specify a local-as number\n" | |
3439 | "AS number used as local AS\n" | |
3440 | "Do not prepend local-as to updates from ebgp peers\n" | |
3441 | "Do not prepend local-as to updates from ibgp peers\n") | |
3442 | { | |
d62a17ae | 3443 | int idx_peer = 1; |
3444 | int idx_number = 3; | |
3445 | struct peer *peer; | |
3446 | int ret; | |
3447 | as_t as; | |
9d3f9705 | 3448 | |
d62a17ae | 3449 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3450 | if (!peer) | |
3451 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3452 | |
d62a17ae | 3453 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3454 | ret = peer_local_as_set(peer, as, 1, 1); | |
3455 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3456 | } |
3457 | ||
718e3744 | 3458 | DEFUN (no_neighbor_local_as, |
3459 | no_neighbor_local_as_cmd, | |
a636c635 | 3460 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3461 | NO_STR |
3462 | NEIGHBOR_STR | |
3463 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3464 | "Specify a local-as number\n" |
3465 | "AS number used as local AS\n" | |
3466 | "Do not prepend local-as to updates from ebgp peers\n" | |
3467 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3468 | { |
d62a17ae | 3469 | int idx_peer = 2; |
3470 | struct peer *peer; | |
3471 | int ret; | |
718e3744 | 3472 | |
d62a17ae | 3473 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3474 | if (!peer) | |
3475 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3476 | |
d62a17ae | 3477 | ret = peer_local_as_unset(peer); |
3478 | return bgp_vty_return(vty, ret); | |
718e3744 | 3479 | } |
3480 | ||
718e3744 | 3481 | |
3f9c7369 DS |
3482 | DEFUN (neighbor_solo, |
3483 | neighbor_solo_cmd, | |
9ccf14f7 | 3484 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3485 | NEIGHBOR_STR |
3486 | NEIGHBOR_ADDR_STR2 | |
3487 | "Solo peer - part of its own update group\n") | |
3488 | { | |
d62a17ae | 3489 | int idx_peer = 1; |
3490 | struct peer *peer; | |
3491 | int ret; | |
3f9c7369 | 3492 | |
d62a17ae | 3493 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3494 | if (!peer) | |
3495 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3496 | |
d62a17ae | 3497 | ret = update_group_adjust_soloness(peer, 1); |
3498 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3499 | } |
3500 | ||
3501 | DEFUN (no_neighbor_solo, | |
3502 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3503 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3504 | NO_STR |
3505 | NEIGHBOR_STR | |
3506 | NEIGHBOR_ADDR_STR2 | |
3507 | "Solo peer - part of its own update group\n") | |
3508 | { | |
d62a17ae | 3509 | int idx_peer = 2; |
3510 | struct peer *peer; | |
3511 | int ret; | |
3f9c7369 | 3512 | |
d62a17ae | 3513 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3514 | if (!peer) | |
3515 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3516 | |
d62a17ae | 3517 | ret = update_group_adjust_soloness(peer, 0); |
3518 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3519 | } |
3520 | ||
0df7c91f PJ |
3521 | DEFUN (neighbor_password, |
3522 | neighbor_password_cmd, | |
9ccf14f7 | 3523 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3524 | NEIGHBOR_STR |
3525 | NEIGHBOR_ADDR_STR2 | |
3526 | "Set a password\n" | |
3527 | "The password\n") | |
3528 | { | |
d62a17ae | 3529 | int idx_peer = 1; |
3530 | int idx_line = 3; | |
3531 | struct peer *peer; | |
3532 | int ret; | |
0df7c91f | 3533 | |
d62a17ae | 3534 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3535 | if (!peer) | |
3536 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3537 | |
d62a17ae | 3538 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3539 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3540 | } |
3541 | ||
3542 | DEFUN (no_neighbor_password, | |
3543 | no_neighbor_password_cmd, | |
a636c635 | 3544 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3545 | NO_STR |
3546 | NEIGHBOR_STR | |
3547 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3548 | "Set a password\n" |
3549 | "The password\n") | |
0df7c91f | 3550 | { |
d62a17ae | 3551 | int idx_peer = 2; |
3552 | struct peer *peer; | |
3553 | int ret; | |
0df7c91f | 3554 | |
d62a17ae | 3555 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3556 | if (!peer) | |
3557 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3558 | |
d62a17ae | 3559 | ret = peer_password_unset(peer); |
3560 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3561 | } |
6b0655a2 | 3562 | |
718e3744 | 3563 | DEFUN (neighbor_activate, |
3564 | neighbor_activate_cmd, | |
9ccf14f7 | 3565 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3566 | NEIGHBOR_STR |
3567 | NEIGHBOR_ADDR_STR2 | |
3568 | "Enable the Address Family for this Neighbor\n") | |
3569 | { | |
d62a17ae | 3570 | int idx_peer = 1; |
3571 | int ret; | |
3572 | struct peer *peer; | |
718e3744 | 3573 | |
d62a17ae | 3574 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3575 | if (!peer) | |
3576 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3577 | |
d62a17ae | 3578 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3579 | return bgp_vty_return(vty, ret); | |
718e3744 | 3580 | } |
3581 | ||
d62a17ae | 3582 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3583 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3584 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3585 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3586 | |
718e3744 | 3587 | DEFUN (no_neighbor_activate, |
3588 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3589 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3590 | NO_STR |
3591 | NEIGHBOR_STR | |
3592 | NEIGHBOR_ADDR_STR2 | |
3593 | "Enable the Address Family for this Neighbor\n") | |
3594 | { | |
d62a17ae | 3595 | int idx_peer = 2; |
3596 | int ret; | |
3597 | struct peer *peer; | |
718e3744 | 3598 | |
d62a17ae | 3599 | /* Lookup peer. */ |
3600 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3601 | if (!peer) | |
3602 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3603 | |
d62a17ae | 3604 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3605 | return bgp_vty_return(vty, ret); | |
718e3744 | 3606 | } |
6b0655a2 | 3607 | |
d62a17ae | 3608 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3609 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3610 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3611 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3612 | |
718e3744 | 3613 | DEFUN (neighbor_set_peer_group, |
3614 | neighbor_set_peer_group_cmd, | |
d7b9898c | 3615 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3616 | NEIGHBOR_STR |
a80beece | 3617 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3618 | "Member of the peer-group\n" |
16cedbb0 | 3619 | "Peer-group name\n") |
718e3744 | 3620 | { |
d62a17ae | 3621 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3622 | int idx_peer = 1; | |
3623 | int idx_word = 3; | |
3624 | int ret; | |
3625 | as_t as; | |
3626 | union sockunion su; | |
3627 | struct peer *peer; | |
3628 | struct peer_group *group; | |
3629 | ||
d62a17ae | 3630 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3631 | if (ret < 0) { | |
3632 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3633 | if (!peer) { | |
3634 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3635 | argv[idx_peer]->arg); | |
3636 | return CMD_WARNING_CONFIG_FAILED; | |
3637 | } | |
3638 | } else { | |
3639 | if (peer_address_self_check(bgp, &su)) { | |
3640 | vty_out(vty, | |
3641 | "%% Can not configure the local system as neighbor\n"); | |
3642 | return CMD_WARNING_CONFIG_FAILED; | |
3643 | } | |
3644 | ||
3645 | /* Disallow for dynamic neighbor. */ | |
3646 | peer = peer_lookup(bgp, &su); | |
3647 | if (peer && peer_dynamic_neighbor(peer)) { | |
3648 | vty_out(vty, | |
3649 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3650 | return CMD_WARNING_CONFIG_FAILED; | |
3651 | } | |
3652 | } | |
3653 | ||
3654 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3655 | if (!group) { | |
3656 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3657 | return CMD_WARNING_CONFIG_FAILED; | |
3658 | } | |
3659 | ||
3660 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3661 | ||
3662 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3663 | vty_out(vty, | |
3664 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3665 | as); | |
3666 | return CMD_WARNING_CONFIG_FAILED; | |
3667 | } | |
3668 | ||
3669 | return bgp_vty_return(vty, ret); | |
3670 | } | |
3671 | ||
3672 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 3673 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3674 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3675 | "Member of the peer-group\n" | |
3676 | "Peer-group name\n") | |
596c17ba | 3677 | |
718e3744 | 3678 | DEFUN (no_neighbor_set_peer_group, |
3679 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 3680 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3681 | NO_STR |
3682 | NEIGHBOR_STR | |
a80beece | 3683 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3684 | "Member of the peer-group\n" |
16cedbb0 | 3685 | "Peer-group name\n") |
718e3744 | 3686 | { |
d62a17ae | 3687 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3688 | int idx_peer = 2; | |
3689 | int idx_word = 4; | |
3690 | int ret; | |
3691 | struct peer *peer; | |
3692 | struct peer_group *group; | |
3693 | ||
3694 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3695 | if (!peer) | |
3696 | return CMD_WARNING_CONFIG_FAILED; | |
3697 | ||
3698 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3699 | if (!group) { | |
3700 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3701 | return CMD_WARNING_CONFIG_FAILED; | |
3702 | } | |
718e3744 | 3703 | |
4e2786df | 3704 | peer_notify_unconfig(peer); |
827ed707 | 3705 | ret = peer_delete(peer); |
718e3744 | 3706 | |
d62a17ae | 3707 | return bgp_vty_return(vty, ret); |
718e3744 | 3708 | } |
6b0655a2 | 3709 | |
d62a17ae | 3710 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 3711 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3712 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3713 | "Member of the peer-group\n" | |
3714 | "Peer-group name\n") | |
596c17ba | 3715 | |
d62a17ae | 3716 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3717 | uint32_t flag, int set) |
718e3744 | 3718 | { |
d62a17ae | 3719 | int ret; |
3720 | struct peer *peer; | |
718e3744 | 3721 | |
d62a17ae | 3722 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3723 | if (!peer) | |
3724 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3725 | |
7ebe625c QY |
3726 | /* |
3727 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3728 | * we should not accept disable-connected-check. | |
3729 | */ | |
3730 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3731 | vty_out(vty, | |
3732 | "%s is directly connected peer, cannot accept disable-" | |
3733 | "connected-check\n", | |
3734 | ip_str); | |
3735 | return CMD_WARNING_CONFIG_FAILED; | |
3736 | } | |
3737 | ||
d62a17ae | 3738 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3739 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3740 | |
d62a17ae | 3741 | if (set) |
3742 | ret = peer_flag_set(peer, flag); | |
3743 | else | |
3744 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3745 | |
d62a17ae | 3746 | return bgp_vty_return(vty, ret); |
718e3744 | 3747 | } |
3748 | ||
47cbc09b | 3749 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3750 | { |
d62a17ae | 3751 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3752 | } |
3753 | ||
d62a17ae | 3754 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3755 | uint32_t flag) |
718e3744 | 3756 | { |
d62a17ae | 3757 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3758 | } |
3759 | ||
3760 | /* neighbor passive. */ | |
3761 | DEFUN (neighbor_passive, | |
3762 | neighbor_passive_cmd, | |
9ccf14f7 | 3763 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3764 | NEIGHBOR_STR |
3765 | NEIGHBOR_ADDR_STR2 | |
3766 | "Don't send open messages to this neighbor\n") | |
3767 | { | |
d62a17ae | 3768 | int idx_peer = 1; |
3769 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3770 | } |
3771 | ||
3772 | DEFUN (no_neighbor_passive, | |
3773 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3774 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3775 | NO_STR |
3776 | NEIGHBOR_STR | |
3777 | NEIGHBOR_ADDR_STR2 | |
3778 | "Don't send open messages to this neighbor\n") | |
3779 | { | |
d62a17ae | 3780 | int idx_peer = 2; |
3781 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3782 | } |
6b0655a2 | 3783 | |
718e3744 | 3784 | /* neighbor shutdown. */ |
73d70fa6 DL |
3785 | DEFUN (neighbor_shutdown_msg, |
3786 | neighbor_shutdown_msg_cmd, | |
3787 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3788 | NEIGHBOR_STR |
3789 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3790 | "Administratively shut down this neighbor\n" |
3791 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3792 | "Shutdown message\n") | |
718e3744 | 3793 | { |
d62a17ae | 3794 | int idx_peer = 1; |
73d70fa6 | 3795 | |
d62a17ae | 3796 | if (argc >= 5) { |
3797 | struct peer *peer = | |
3798 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3799 | char *message; | |
73d70fa6 | 3800 | |
d62a17ae | 3801 | if (!peer) |
3802 | return CMD_WARNING_CONFIG_FAILED; | |
3803 | message = argv_concat(argv, argc, 4); | |
3804 | peer_tx_shutdown_message_set(peer, message); | |
3805 | XFREE(MTYPE_TMP, message); | |
3806 | } | |
73d70fa6 | 3807 | |
d62a17ae | 3808 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3809 | } |
3810 | ||
d62a17ae | 3811 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3812 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3813 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3814 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3815 | |
3816 | DEFUN (no_neighbor_shutdown_msg, | |
3817 | no_neighbor_shutdown_msg_cmd, | |
3818 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3819 | NO_STR | |
3820 | NEIGHBOR_STR | |
3821 | NEIGHBOR_ADDR_STR2 | |
3822 | "Administratively shut down this neighbor\n" | |
3823 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3824 | "Shutdown message\n") | |
718e3744 | 3825 | { |
d62a17ae | 3826 | int idx_peer = 2; |
73d70fa6 | 3827 | |
d62a17ae | 3828 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3829 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3830 | } |
6b0655a2 | 3831 | |
d62a17ae | 3832 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3833 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3834 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3835 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3836 | |
718e3744 | 3837 | /* neighbor capability dynamic. */ |
3838 | DEFUN (neighbor_capability_dynamic, | |
3839 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3840 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3841 | NEIGHBOR_STR |
3842 | NEIGHBOR_ADDR_STR2 | |
3843 | "Advertise capability to the peer\n" | |
3844 | "Advertise dynamic capability to this neighbor\n") | |
3845 | { | |
d62a17ae | 3846 | int idx_peer = 1; |
3847 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3848 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3849 | } |
3850 | ||
3851 | DEFUN (no_neighbor_capability_dynamic, | |
3852 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3853 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3854 | NO_STR |
3855 | NEIGHBOR_STR | |
3856 | NEIGHBOR_ADDR_STR2 | |
3857 | "Advertise capability to the peer\n" | |
3858 | "Advertise dynamic capability to this neighbor\n") | |
3859 | { | |
d62a17ae | 3860 | int idx_peer = 2; |
3861 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3862 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3863 | } |
6b0655a2 | 3864 | |
718e3744 | 3865 | /* neighbor dont-capability-negotiate */ |
3866 | DEFUN (neighbor_dont_capability_negotiate, | |
3867 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3868 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3869 | NEIGHBOR_STR |
3870 | NEIGHBOR_ADDR_STR2 | |
3871 | "Do not perform capability negotiation\n") | |
3872 | { | |
d62a17ae | 3873 | int idx_peer = 1; |
3874 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3875 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3876 | } |
3877 | ||
3878 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3879 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3880 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3881 | NO_STR |
3882 | NEIGHBOR_STR | |
3883 | NEIGHBOR_ADDR_STR2 | |
3884 | "Do not perform capability negotiation\n") | |
3885 | { | |
d62a17ae | 3886 | int idx_peer = 2; |
3887 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3888 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3889 | } |
6b0655a2 | 3890 | |
8a92a8a0 DS |
3891 | /* neighbor capability extended next hop encoding */ |
3892 | DEFUN (neighbor_capability_enhe, | |
3893 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3894 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3895 | NEIGHBOR_STR |
3896 | NEIGHBOR_ADDR_STR2 | |
3897 | "Advertise capability to the peer\n" | |
3898 | "Advertise extended next-hop capability to the peer\n") | |
3899 | { | |
d62a17ae | 3900 | int idx_peer = 1; |
3901 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3902 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3903 | } |
3904 | ||
3905 | DEFUN (no_neighbor_capability_enhe, | |
3906 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3907 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3908 | NO_STR |
3909 | NEIGHBOR_STR | |
3910 | NEIGHBOR_ADDR_STR2 | |
3911 | "Advertise capability to the peer\n" | |
3912 | "Advertise extended next-hop capability to the peer\n") | |
3913 | { | |
d62a17ae | 3914 | int idx_peer = 2; |
3915 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3916 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3917 | } |
3918 | ||
d62a17ae | 3919 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3920 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3921 | int set) |
718e3744 | 3922 | { |
d62a17ae | 3923 | int ret; |
3924 | struct peer *peer; | |
718e3744 | 3925 | |
d62a17ae | 3926 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3927 | if (!peer) | |
3928 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3929 | |
d62a17ae | 3930 | if (set) |
3931 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3932 | else | |
3933 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3934 | |
d62a17ae | 3935 | return bgp_vty_return(vty, ret); |
718e3744 | 3936 | } |
3937 | ||
d62a17ae | 3938 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3939 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3940 | { |
d62a17ae | 3941 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3942 | } |
3943 | ||
d62a17ae | 3944 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3945 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3946 | { |
d62a17ae | 3947 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3948 | } |
6b0655a2 | 3949 | |
718e3744 | 3950 | /* neighbor capability orf prefix-list. */ |
3951 | DEFUN (neighbor_capability_orf_prefix, | |
3952 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3953 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3954 | NEIGHBOR_STR |
3955 | NEIGHBOR_ADDR_STR2 | |
3956 | "Advertise capability to the peer\n" | |
3957 | "Advertise ORF capability to the peer\n" | |
3958 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3959 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3960 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3961 | "Capability to SEND the ORF to this neighbor\n") | |
3962 | { | |
d62a17ae | 3963 | int idx_peer = 1; |
3964 | int idx_send_recv = 5; | |
d7c0a89a | 3965 | uint16_t flag = 0; |
d62a17ae | 3966 | |
3967 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3968 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3969 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3970 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3971 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3972 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3973 | else { | |
3974 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3975 | return CMD_WARNING_CONFIG_FAILED; | |
3976 | } | |
3977 | ||
3978 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3979 | bgp_node_safi(vty), flag); | |
3980 | } | |
3981 | ||
3982 | ALIAS_HIDDEN( | |
3983 | neighbor_capability_orf_prefix, | |
3984 | neighbor_capability_orf_prefix_hidden_cmd, | |
3985 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3986 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3987 | "Advertise capability to the peer\n" | |
3988 | "Advertise ORF capability to the peer\n" | |
3989 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3990 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3991 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3992 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3993 | |
718e3744 | 3994 | DEFUN (no_neighbor_capability_orf_prefix, |
3995 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3996 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3997 | NO_STR |
3998 | NEIGHBOR_STR | |
3999 | NEIGHBOR_ADDR_STR2 | |
4000 | "Advertise capability to the peer\n" | |
4001 | "Advertise ORF capability to the peer\n" | |
4002 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4003 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4004 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4005 | "Capability to SEND the ORF to this neighbor\n") | |
4006 | { | |
d62a17ae | 4007 | int idx_peer = 2; |
4008 | int idx_send_recv = 6; | |
d7c0a89a | 4009 | uint16_t flag = 0; |
d62a17ae | 4010 | |
4011 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4012 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4013 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4014 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4015 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4016 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4017 | else { | |
4018 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4019 | return CMD_WARNING_CONFIG_FAILED; | |
4020 | } | |
4021 | ||
4022 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4023 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4024 | flag); | |
4025 | } | |
4026 | ||
4027 | ALIAS_HIDDEN( | |
4028 | no_neighbor_capability_orf_prefix, | |
4029 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4030 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4031 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4032 | "Advertise capability to the peer\n" | |
4033 | "Advertise ORF capability to the peer\n" | |
4034 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4035 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4036 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4037 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4038 | |
718e3744 | 4039 | /* neighbor next-hop-self. */ |
4040 | DEFUN (neighbor_nexthop_self, | |
4041 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4042 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4043 | NEIGHBOR_STR |
4044 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4045 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4046 | { |
d62a17ae | 4047 | int idx_peer = 1; |
4048 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4049 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4050 | } |
9e7a53c1 | 4051 | |
d62a17ae | 4052 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4053 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4054 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4055 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4056 | |
a538debe DS |
4057 | /* neighbor next-hop-self. */ |
4058 | DEFUN (neighbor_nexthop_self_force, | |
4059 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4060 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4061 | NEIGHBOR_STR |
4062 | NEIGHBOR_ADDR_STR2 | |
4063 | "Disable the next hop calculation for this neighbor\n" | |
4064 | "Set the next hop to self for reflected routes\n") | |
4065 | { | |
d62a17ae | 4066 | int idx_peer = 1; |
4067 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4068 | bgp_node_safi(vty), | |
4069 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4070 | } |
4071 | ||
d62a17ae | 4072 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4073 | neighbor_nexthop_self_force_hidden_cmd, | |
4074 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4075 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4076 | "Disable the next hop calculation for this neighbor\n" | |
4077 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4078 | |
1bc4e531 DA |
4079 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4080 | neighbor_nexthop_self_all_hidden_cmd, | |
4081 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4082 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4083 | "Disable the next hop calculation for this neighbor\n" | |
4084 | "Set the next hop to self for reflected routes\n") | |
4085 | ||
718e3744 | 4086 | DEFUN (no_neighbor_nexthop_self, |
4087 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4088 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4089 | NO_STR |
4090 | NEIGHBOR_STR | |
4091 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4092 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4093 | { |
d62a17ae | 4094 | int idx_peer = 2; |
4095 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4096 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4097 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4098 | } |
6b0655a2 | 4099 | |
d62a17ae | 4100 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4101 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4102 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4103 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4104 | |
88b8ed8d | 4105 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4106 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4107 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4108 | NO_STR |
4109 | NEIGHBOR_STR | |
4110 | NEIGHBOR_ADDR_STR2 | |
4111 | "Disable the next hop calculation for this neighbor\n" | |
4112 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4113 | { |
d62a17ae | 4114 | int idx_peer = 2; |
4115 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4116 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4117 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4118 | } |
a538debe | 4119 | |
d62a17ae | 4120 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4121 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4122 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4123 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4124 | "Disable the next hop calculation for this neighbor\n" | |
4125 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4126 | |
1bc4e531 DA |
4127 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4128 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4129 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4130 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4131 | "Disable the next hop calculation for this neighbor\n" | |
4132 | "Set the next hop to self for reflected routes\n") | |
4133 | ||
c7122e14 DS |
4134 | /* neighbor as-override */ |
4135 | DEFUN (neighbor_as_override, | |
4136 | neighbor_as_override_cmd, | |
9ccf14f7 | 4137 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4138 | NEIGHBOR_STR |
4139 | NEIGHBOR_ADDR_STR2 | |
4140 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4141 | { | |
d62a17ae | 4142 | int idx_peer = 1; |
4143 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4144 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4145 | } |
4146 | ||
d62a17ae | 4147 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4148 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4149 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4150 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4151 | |
c7122e14 DS |
4152 | DEFUN (no_neighbor_as_override, |
4153 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4154 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4155 | NO_STR |
4156 | NEIGHBOR_STR | |
4157 | NEIGHBOR_ADDR_STR2 | |
4158 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4159 | { | |
d62a17ae | 4160 | int idx_peer = 2; |
4161 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4162 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4163 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4164 | } |
4165 | ||
d62a17ae | 4166 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4167 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4168 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4169 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4170 | |
718e3744 | 4171 | /* neighbor remove-private-AS. */ |
4172 | DEFUN (neighbor_remove_private_as, | |
4173 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4174 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4175 | NEIGHBOR_STR |
4176 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4177 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4178 | { |
d62a17ae | 4179 | int idx_peer = 1; |
4180 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4181 | bgp_node_safi(vty), | |
4182 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4183 | } |
4184 | ||
d62a17ae | 4185 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4186 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4187 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4188 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4189 | |
5000f21c DS |
4190 | DEFUN (neighbor_remove_private_as_all, |
4191 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4192 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4193 | NEIGHBOR_STR |
4194 | NEIGHBOR_ADDR_STR2 | |
4195 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4196 | "Apply to all AS numbers\n") |
5000f21c | 4197 | { |
d62a17ae | 4198 | int idx_peer = 1; |
4199 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4200 | bgp_node_safi(vty), | |
4201 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4202 | } |
4203 | ||
d62a17ae | 4204 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4205 | neighbor_remove_private_as_all_hidden_cmd, | |
4206 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4207 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4208 | "Remove private ASNs in outbound updates\n" | |
4209 | "Apply to all AS numbers") | |
596c17ba | 4210 | |
5000f21c DS |
4211 | DEFUN (neighbor_remove_private_as_replace_as, |
4212 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4213 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4214 | NEIGHBOR_STR |
4215 | NEIGHBOR_ADDR_STR2 | |
4216 | "Remove private ASNs in outbound updates\n" | |
4217 | "Replace private ASNs with our ASN in outbound updates\n") | |
4218 | { | |
d62a17ae | 4219 | int idx_peer = 1; |
4220 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4221 | bgp_node_safi(vty), | |
4222 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4223 | } |
4224 | ||
d62a17ae | 4225 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4226 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4227 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4228 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4229 | "Remove private ASNs in outbound updates\n" | |
4230 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4231 | |
5000f21c DS |
4232 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4233 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4234 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4235 | NEIGHBOR_STR |
4236 | NEIGHBOR_ADDR_STR2 | |
4237 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4238 | "Apply to all AS numbers\n" |
5000f21c DS |
4239 | "Replace private ASNs with our ASN in outbound updates\n") |
4240 | { | |
d62a17ae | 4241 | int idx_peer = 1; |
4242 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4243 | bgp_node_safi(vty), | |
4244 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4245 | } |
4246 | ||
d62a17ae | 4247 | ALIAS_HIDDEN( |
4248 | neighbor_remove_private_as_all_replace_as, | |
4249 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4250 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4251 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4252 | "Remove private ASNs in outbound updates\n" | |
4253 | "Apply to all AS numbers\n" | |
4254 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4255 | |
718e3744 | 4256 | DEFUN (no_neighbor_remove_private_as, |
4257 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4258 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4259 | NO_STR |
4260 | NEIGHBOR_STR | |
4261 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4262 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4263 | { |
d62a17ae | 4264 | int idx_peer = 2; |
4265 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4266 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4267 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4268 | } |
6b0655a2 | 4269 | |
d62a17ae | 4270 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4271 | no_neighbor_remove_private_as_hidden_cmd, | |
4272 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4273 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4274 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4275 | |
88b8ed8d | 4276 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4277 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4278 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4279 | NO_STR |
4280 | NEIGHBOR_STR | |
4281 | NEIGHBOR_ADDR_STR2 | |
4282 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4283 | "Apply to all AS numbers\n") |
88b8ed8d | 4284 | { |
d62a17ae | 4285 | int idx_peer = 2; |
4286 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4287 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4288 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4289 | } |
5000f21c | 4290 | |
d62a17ae | 4291 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4292 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4294 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4295 | "Remove private ASNs in outbound updates\n" | |
4296 | "Apply to all AS numbers\n") | |
596c17ba | 4297 | |
88b8ed8d | 4298 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4299 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4300 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4301 | NO_STR |
4302 | NEIGHBOR_STR | |
4303 | NEIGHBOR_ADDR_STR2 | |
4304 | "Remove private ASNs in outbound updates\n" | |
4305 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4306 | { |
d62a17ae | 4307 | int idx_peer = 2; |
4308 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4309 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4310 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4311 | } |
5000f21c | 4312 | |
d62a17ae | 4313 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4314 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4315 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4316 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4317 | "Remove private ASNs in outbound updates\n" | |
4318 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4319 | |
88b8ed8d | 4320 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4321 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4322 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4323 | NO_STR |
4324 | NEIGHBOR_STR | |
4325 | NEIGHBOR_ADDR_STR2 | |
4326 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4327 | "Apply to all AS numbers\n" |
5000f21c | 4328 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4329 | { |
d62a17ae | 4330 | int idx_peer = 2; |
4331 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4332 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4333 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4334 | } |
5000f21c | 4335 | |
d62a17ae | 4336 | ALIAS_HIDDEN( |
4337 | no_neighbor_remove_private_as_all_replace_as, | |
4338 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4339 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4340 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4341 | "Remove private ASNs in outbound updates\n" | |
4342 | "Apply to all AS numbers\n" | |
4343 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4344 | |
5000f21c | 4345 | |
718e3744 | 4346 | /* neighbor send-community. */ |
4347 | DEFUN (neighbor_send_community, | |
4348 | neighbor_send_community_cmd, | |
9ccf14f7 | 4349 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4350 | NEIGHBOR_STR |
4351 | NEIGHBOR_ADDR_STR2 | |
4352 | "Send Community attribute to this neighbor\n") | |
4353 | { | |
d62a17ae | 4354 | int idx_peer = 1; |
27c05d4d | 4355 | |
d62a17ae | 4356 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4357 | bgp_node_safi(vty), | |
4358 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4359 | } |
4360 | ||
d62a17ae | 4361 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4362 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4363 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4364 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4365 | |
718e3744 | 4366 | DEFUN (no_neighbor_send_community, |
4367 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4368 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4369 | NO_STR |
4370 | NEIGHBOR_STR | |
4371 | NEIGHBOR_ADDR_STR2 | |
4372 | "Send Community attribute to this neighbor\n") | |
4373 | { | |
d62a17ae | 4374 | int idx_peer = 2; |
27c05d4d | 4375 | |
d62a17ae | 4376 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4377 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4378 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4379 | } |
6b0655a2 | 4380 | |
d62a17ae | 4381 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4382 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4383 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4384 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4385 | |
718e3744 | 4386 | /* neighbor send-community extended. */ |
4387 | DEFUN (neighbor_send_community_type, | |
4388 | neighbor_send_community_type_cmd, | |
57d187bc | 4389 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4390 | NEIGHBOR_STR |
4391 | NEIGHBOR_ADDR_STR2 | |
4392 | "Send Community attribute to this neighbor\n" | |
4393 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4394 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4395 | "Send Extended Community attributes\n" |
57d187bc JS |
4396 | "Send Standard Community attributes\n" |
4397 | "Send Large Community attributes\n") | |
718e3744 | 4398 | { |
27c05d4d | 4399 | int idx_peer = 1; |
d7c0a89a | 4400 | uint32_t flag = 0; |
27c05d4d | 4401 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4402 | |
27c05d4d | 4403 | if (strmatch(type, "standard")) { |
d62a17ae | 4404 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4405 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4406 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4407 | } else if (strmatch(type, "large")) { |
d62a17ae | 4408 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4409 | } else if (strmatch(type, "both")) { |
d62a17ae | 4410 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4411 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4412 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4413 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4414 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4415 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4416 | } | |
4417 | ||
27c05d4d | 4418 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4419 | bgp_node_safi(vty), flag); |
4420 | } | |
4421 | ||
4422 | ALIAS_HIDDEN( | |
4423 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4424 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4425 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4426 | "Send Community attribute to this neighbor\n" | |
4427 | "Send Standard and Extended Community attributes\n" | |
4428 | "Send Standard, Large and Extended Community attributes\n" | |
4429 | "Send Extended Community attributes\n" | |
4430 | "Send Standard Community attributes\n" | |
4431 | "Send Large Community attributes\n") | |
596c17ba | 4432 | |
718e3744 | 4433 | DEFUN (no_neighbor_send_community_type, |
4434 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4435 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4436 | NO_STR |
4437 | NEIGHBOR_STR | |
4438 | NEIGHBOR_ADDR_STR2 | |
4439 | "Send Community attribute to this neighbor\n" | |
4440 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4441 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4442 | "Send Extended Community attributes\n" |
57d187bc JS |
4443 | "Send Standard Community attributes\n" |
4444 | "Send Large Community attributes\n") | |
718e3744 | 4445 | { |
d62a17ae | 4446 | int idx_peer = 2; |
27c05d4d | 4447 | uint32_t flag = 0; |
d62a17ae | 4448 | const char *type = argv[argc - 1]->text; |
4449 | ||
27c05d4d PM |
4450 | if (strmatch(type, "standard")) { |
4451 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4452 | } else if (strmatch(type, "extended")) { | |
4453 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4454 | } else if (strmatch(type, "large")) { | |
4455 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4456 | } else if (strmatch(type, "both")) { | |
4457 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4458 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4459 | } else { /* if (strmatch(type, "all")) */ | |
4460 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4461 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4462 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4463 | } | |
4464 | ||
4465 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4466 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4467 | flag); | |
d62a17ae | 4468 | } |
4469 | ||
4470 | ALIAS_HIDDEN( | |
4471 | no_neighbor_send_community_type, | |
4472 | no_neighbor_send_community_type_hidden_cmd, | |
4473 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4474 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4475 | "Send Community attribute to this neighbor\n" | |
4476 | "Send Standard and Extended Community attributes\n" | |
4477 | "Send Standard, Large and Extended Community attributes\n" | |
4478 | "Send Extended Community attributes\n" | |
4479 | "Send Standard Community attributes\n" | |
4480 | "Send Large Community attributes\n") | |
596c17ba | 4481 | |
718e3744 | 4482 | /* neighbor soft-reconfig. */ |
4483 | DEFUN (neighbor_soft_reconfiguration, | |
4484 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4485 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4486 | NEIGHBOR_STR |
4487 | NEIGHBOR_ADDR_STR2 | |
4488 | "Per neighbor soft reconfiguration\n" | |
4489 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4490 | { | |
d62a17ae | 4491 | int idx_peer = 1; |
4492 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4493 | bgp_node_safi(vty), | |
4494 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4495 | } |
4496 | ||
d62a17ae | 4497 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4498 | neighbor_soft_reconfiguration_hidden_cmd, | |
4499 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4500 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4501 | "Per neighbor soft reconfiguration\n" | |
4502 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4503 | |
718e3744 | 4504 | DEFUN (no_neighbor_soft_reconfiguration, |
4505 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4506 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4507 | NO_STR |
4508 | NEIGHBOR_STR | |
4509 | NEIGHBOR_ADDR_STR2 | |
4510 | "Per neighbor soft reconfiguration\n" | |
4511 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4512 | { | |
d62a17ae | 4513 | int idx_peer = 2; |
4514 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4515 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4516 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4517 | } |
6b0655a2 | 4518 | |
d62a17ae | 4519 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4520 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4521 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4522 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4523 | "Per neighbor soft reconfiguration\n" | |
4524 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4525 | |
718e3744 | 4526 | DEFUN (neighbor_route_reflector_client, |
4527 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4528 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4529 | NEIGHBOR_STR |
4530 | NEIGHBOR_ADDR_STR2 | |
4531 | "Configure a neighbor as Route Reflector client\n") | |
4532 | { | |
d62a17ae | 4533 | int idx_peer = 1; |
4534 | struct peer *peer; | |
718e3744 | 4535 | |
4536 | ||
d62a17ae | 4537 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4538 | if (!peer) | |
4539 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4540 | |
d62a17ae | 4541 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4542 | bgp_node_safi(vty), | |
4543 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4544 | } |
4545 | ||
d62a17ae | 4546 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4547 | neighbor_route_reflector_client_hidden_cmd, | |
4548 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4549 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4550 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4551 | |
718e3744 | 4552 | DEFUN (no_neighbor_route_reflector_client, |
4553 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4554 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4555 | NO_STR |
4556 | NEIGHBOR_STR | |
4557 | NEIGHBOR_ADDR_STR2 | |
4558 | "Configure a neighbor as Route Reflector client\n") | |
4559 | { | |
d62a17ae | 4560 | int idx_peer = 2; |
4561 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4562 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4563 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4564 | } |
6b0655a2 | 4565 | |
d62a17ae | 4566 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4567 | no_neighbor_route_reflector_client_hidden_cmd, | |
4568 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4569 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4570 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4571 | |
718e3744 | 4572 | /* neighbor route-server-client. */ |
4573 | DEFUN (neighbor_route_server_client, | |
4574 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4575 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4576 | NEIGHBOR_STR |
4577 | NEIGHBOR_ADDR_STR2 | |
4578 | "Configure a neighbor as Route Server client\n") | |
4579 | { | |
d62a17ae | 4580 | int idx_peer = 1; |
4581 | struct peer *peer; | |
2a3d5731 | 4582 | |
d62a17ae | 4583 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4584 | if (!peer) | |
4585 | return CMD_WARNING_CONFIG_FAILED; | |
4586 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4587 | bgp_node_safi(vty), | |
4588 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4589 | } |
4590 | ||
d62a17ae | 4591 | ALIAS_HIDDEN(neighbor_route_server_client, |
4592 | neighbor_route_server_client_hidden_cmd, | |
4593 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4594 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4595 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4596 | |
718e3744 | 4597 | DEFUN (no_neighbor_route_server_client, |
4598 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4599 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4600 | NO_STR |
4601 | NEIGHBOR_STR | |
4602 | NEIGHBOR_ADDR_STR2 | |
4603 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4604 | { |
d62a17ae | 4605 | int idx_peer = 2; |
4606 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4607 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4608 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4609 | } |
6b0655a2 | 4610 | |
d62a17ae | 4611 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4612 | no_neighbor_route_server_client_hidden_cmd, | |
4613 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4614 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4615 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4616 | |
fee0f4c6 | 4617 | DEFUN (neighbor_nexthop_local_unchanged, |
4618 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4619 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4620 | NEIGHBOR_STR |
4621 | NEIGHBOR_ADDR_STR2 | |
4622 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4623 | "Leave link-local nexthop unchanged for this peer\n") | |
4624 | { | |
d62a17ae | 4625 | int idx_peer = 1; |
4626 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4627 | bgp_node_safi(vty), | |
4628 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4629 | } |
6b0655a2 | 4630 | |
fee0f4c6 | 4631 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4632 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4633 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4634 | NO_STR |
4635 | NEIGHBOR_STR | |
4636 | NEIGHBOR_ADDR_STR2 | |
4637 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4638 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4639 | { |
d62a17ae | 4640 | int idx_peer = 2; |
4641 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4642 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4643 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4644 | } |
6b0655a2 | 4645 | |
718e3744 | 4646 | DEFUN (neighbor_attr_unchanged, |
4647 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4648 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4649 | NEIGHBOR_STR |
4650 | NEIGHBOR_ADDR_STR2 | |
4651 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4652 | "As-path attribute\n" | |
4653 | "Nexthop attribute\n" | |
a8206004 | 4654 | "Med attribute\n") |
718e3744 | 4655 | { |
d62a17ae | 4656 | int idx = 0; |
8eeb0335 DW |
4657 | char *peer_str = argv[1]->arg; |
4658 | struct peer *peer; | |
d7c0a89a | 4659 | uint16_t flags = 0; |
8eeb0335 DW |
4660 | afi_t afi = bgp_node_afi(vty); |
4661 | safi_t safi = bgp_node_safi(vty); | |
4662 | ||
4663 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4664 | if (!peer) | |
4665 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4666 | |
4667 | if (argv_find(argv, argc, "as-path", &idx)) | |
4668 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4669 | idx = 0; | |
4670 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4671 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4672 | idx = 0; | |
4673 | if (argv_find(argv, argc, "med", &idx)) | |
4674 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4675 | ||
8eeb0335 DW |
4676 | /* no flags means all of them! */ |
4677 | if (!flags) { | |
d62a17ae | 4678 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4679 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4680 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4681 | } else { |
a4d82a8a PZ |
4682 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4683 | && peer_af_flag_check(peer, afi, safi, | |
4684 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4685 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4686 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4687 | } | |
4688 | ||
a4d82a8a PZ |
4689 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4690 | && peer_af_flag_check(peer, afi, safi, | |
4691 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4692 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4693 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4694 | } | |
4695 | ||
a4d82a8a PZ |
4696 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4697 | && peer_af_flag_check(peer, afi, safi, | |
4698 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4699 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4700 | PEER_FLAG_MED_UNCHANGED); | |
4701 | } | |
d62a17ae | 4702 | } |
4703 | ||
8eeb0335 | 4704 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4705 | } |
4706 | ||
4707 | ALIAS_HIDDEN( | |
4708 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4709 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4710 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4711 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4712 | "As-path attribute\n" | |
4713 | "Nexthop attribute\n" | |
4714 | "Med attribute\n") | |
596c17ba | 4715 | |
718e3744 | 4716 | DEFUN (no_neighbor_attr_unchanged, |
4717 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4718 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4719 | NO_STR |
718e3744 | 4720 | NEIGHBOR_STR |
4721 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4722 | "BGP attribute is propagated unchanged to this neighbor\n" |
4723 | "As-path attribute\n" | |
40e718b5 | 4724 | "Nexthop attribute\n" |
a8206004 | 4725 | "Med attribute\n") |
718e3744 | 4726 | { |
d62a17ae | 4727 | int idx = 0; |
4728 | char *peer = argv[2]->arg; | |
d7c0a89a | 4729 | uint16_t flags = 0; |
d62a17ae | 4730 | |
4731 | if (argv_find(argv, argc, "as-path", &idx)) | |
4732 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4733 | idx = 0; | |
4734 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4735 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4736 | idx = 0; | |
4737 | if (argv_find(argv, argc, "med", &idx)) | |
4738 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4739 | ||
4740 | if (!flags) // no flags means all of them! | |
4741 | { | |
4742 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4743 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4744 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4745 | } | |
4746 | ||
4747 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4748 | bgp_node_safi(vty), flags); | |
4749 | } | |
4750 | ||
4751 | ALIAS_HIDDEN( | |
4752 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4753 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4754 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4755 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4756 | "As-path attribute\n" | |
4757 | "Nexthop attribute\n" | |
4758 | "Med attribute\n") | |
718e3744 | 4759 | |
718e3744 | 4760 | /* EBGP multihop configuration. */ |
d62a17ae | 4761 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4762 | const char *ttl_str) | |
718e3744 | 4763 | { |
d62a17ae | 4764 | struct peer *peer; |
4765 | unsigned int ttl; | |
718e3744 | 4766 | |
d62a17ae | 4767 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4768 | if (!peer) | |
4769 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4770 | |
d62a17ae | 4771 | if (peer->conf_if) |
4772 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4773 | |
d62a17ae | 4774 | if (!ttl_str) |
4775 | ttl = MAXTTL; | |
4776 | else | |
4777 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4778 | |
d62a17ae | 4779 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4780 | } |
4781 | ||
d62a17ae | 4782 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4783 | { |
d62a17ae | 4784 | struct peer *peer; |
718e3744 | 4785 | |
d62a17ae | 4786 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4787 | if (!peer) | |
4788 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4789 | |
d62a17ae | 4790 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4791 | } |
4792 | ||
4793 | /* neighbor ebgp-multihop. */ | |
4794 | DEFUN (neighbor_ebgp_multihop, | |
4795 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4796 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4797 | NEIGHBOR_STR |
4798 | NEIGHBOR_ADDR_STR2 | |
4799 | "Allow EBGP neighbors not on directly connected networks\n") | |
4800 | { | |
d62a17ae | 4801 | int idx_peer = 1; |
4802 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4803 | } |
4804 | ||
4805 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4806 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4807 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4808 | NEIGHBOR_STR |
4809 | NEIGHBOR_ADDR_STR2 | |
4810 | "Allow EBGP neighbors not on directly connected networks\n" | |
4811 | "maximum hop count\n") | |
4812 | { | |
d62a17ae | 4813 | int idx_peer = 1; |
4814 | int idx_number = 3; | |
4815 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4816 | argv[idx_number]->arg); | |
718e3744 | 4817 | } |
4818 | ||
4819 | DEFUN (no_neighbor_ebgp_multihop, | |
4820 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4821 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4822 | NO_STR |
4823 | NEIGHBOR_STR | |
4824 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4825 | "Allow EBGP neighbors not on directly connected networks\n" |
4826 | "maximum hop count\n") | |
718e3744 | 4827 | { |
d62a17ae | 4828 | int idx_peer = 2; |
4829 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4830 | } |
4831 | ||
6b0655a2 | 4832 | |
6ffd2079 | 4833 | /* disable-connected-check */ |
4834 | DEFUN (neighbor_disable_connected_check, | |
4835 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4836 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4837 | NEIGHBOR_STR |
7ebe625c | 4838 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4839 | "one-hop away EBGP peer using loopback address\n" |
4840 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4841 | { |
d62a17ae | 4842 | int idx_peer = 1; |
4843 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4844 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4845 | } |
4846 | ||
4847 | DEFUN (no_neighbor_disable_connected_check, | |
4848 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4849 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4850 | NO_STR |
4851 | NEIGHBOR_STR | |
7ebe625c | 4852 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4853 | "one-hop away EBGP peer using loopback address\n" |
4854 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4855 | { |
d62a17ae | 4856 | int idx_peer = 2; |
4857 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4858 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4859 | } |
4860 | ||
47cbc09b PM |
4861 | |
4862 | /* enforce-first-as */ | |
4863 | DEFUN (neighbor_enforce_first_as, | |
4864 | neighbor_enforce_first_as_cmd, | |
4865 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4866 | NEIGHBOR_STR | |
4867 | NEIGHBOR_ADDR_STR2 | |
4868 | "Enforce the first AS for EBGP routes\n") | |
4869 | { | |
4870 | int idx_peer = 1; | |
4871 | ||
4872 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4873 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4874 | } | |
4875 | ||
4876 | DEFUN (no_neighbor_enforce_first_as, | |
4877 | no_neighbor_enforce_first_as_cmd, | |
4878 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4879 | NO_STR | |
4880 | NEIGHBOR_STR | |
4881 | NEIGHBOR_ADDR_STR2 | |
4882 | "Enforce the first AS for EBGP routes\n") | |
4883 | { | |
4884 | int idx_peer = 2; | |
4885 | ||
4886 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4887 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4888 | } | |
4889 | ||
4890 | ||
718e3744 | 4891 | DEFUN (neighbor_description, |
4892 | neighbor_description_cmd, | |
e961923c | 4893 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4894 | NEIGHBOR_STR |
4895 | NEIGHBOR_ADDR_STR2 | |
4896 | "Neighbor specific description\n" | |
4897 | "Up to 80 characters describing this neighbor\n") | |
4898 | { | |
d62a17ae | 4899 | int idx_peer = 1; |
4900 | int idx_line = 3; | |
4901 | struct peer *peer; | |
4902 | char *str; | |
718e3744 | 4903 | |
d62a17ae | 4904 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4905 | if (!peer) | |
4906 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4907 | |
d62a17ae | 4908 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4909 | |
d62a17ae | 4910 | peer_description_set(peer, str); |
718e3744 | 4911 | |
d62a17ae | 4912 | XFREE(MTYPE_TMP, str); |
718e3744 | 4913 | |
d62a17ae | 4914 | return CMD_SUCCESS; |
718e3744 | 4915 | } |
4916 | ||
4917 | DEFUN (no_neighbor_description, | |
4918 | no_neighbor_description_cmd, | |
a14810f4 | 4919 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4920 | NO_STR |
4921 | NEIGHBOR_STR | |
4922 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4923 | "Neighbor specific description\n") |
718e3744 | 4924 | { |
d62a17ae | 4925 | int idx_peer = 2; |
4926 | struct peer *peer; | |
718e3744 | 4927 | |
d62a17ae | 4928 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4929 | if (!peer) | |
4930 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4931 | |
d62a17ae | 4932 | peer_description_unset(peer); |
718e3744 | 4933 | |
d62a17ae | 4934 | return CMD_SUCCESS; |
718e3744 | 4935 | } |
4936 | ||
a14810f4 PM |
4937 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4938 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4939 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4940 | "Neighbor specific description\n" | |
4941 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4942 | |
718e3744 | 4943 | /* Neighbor update-source. */ |
d62a17ae | 4944 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4945 | const char *source_str) | |
4946 | { | |
4947 | struct peer *peer; | |
4948 | struct prefix p; | |
a14810f4 | 4949 | union sockunion su; |
d62a17ae | 4950 | |
4951 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4952 | if (!peer) | |
4953 | return CMD_WARNING_CONFIG_FAILED; | |
4954 | ||
4955 | if (peer->conf_if) | |
4956 | return CMD_WARNING; | |
4957 | ||
4958 | if (source_str) { | |
a14810f4 | 4959 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4960 | peer_update_source_addr_set(peer, &su); |
4961 | else { | |
4962 | if (str2prefix(source_str, &p)) { | |
4963 | vty_out(vty, | |
4964 | "%% Invalid update-source, remove prefix length \n"); | |
4965 | return CMD_WARNING_CONFIG_FAILED; | |
4966 | } else | |
4967 | peer_update_source_if_set(peer, source_str); | |
4968 | } | |
4969 | } else | |
4970 | peer_update_source_unset(peer); | |
4971 | ||
4972 | return CMD_SUCCESS; | |
4973 | } | |
4974 | ||
4975 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4976 | "IPv4 address\n" \ | |
4977 | "IPv6 address\n" \ | |
4978 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4979 | |
718e3744 | 4980 | DEFUN (neighbor_update_source, |
4981 | neighbor_update_source_cmd, | |
9ccf14f7 | 4982 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4983 | NEIGHBOR_STR |
4984 | NEIGHBOR_ADDR_STR2 | |
4985 | "Source of routing updates\n" | |
369688c0 | 4986 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4987 | { |
d62a17ae | 4988 | int idx_peer = 1; |
4989 | int idx_peer_2 = 3; | |
4990 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4991 | argv[idx_peer_2]->arg); | |
718e3744 | 4992 | } |
4993 | ||
4994 | DEFUN (no_neighbor_update_source, | |
4995 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4996 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4997 | NO_STR |
4998 | NEIGHBOR_STR | |
4999 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5000 | "Source of routing updates\n" |
5001 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5002 | { |
d62a17ae | 5003 | int idx_peer = 2; |
5004 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5005 | } |
6b0655a2 | 5006 | |
d62a17ae | 5007 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5008 | afi_t afi, safi_t safi, | |
5009 | const char *rmap, int set) | |
718e3744 | 5010 | { |
d62a17ae | 5011 | int ret; |
5012 | struct peer *peer; | |
80912664 | 5013 | struct route_map *route_map = NULL; |
718e3744 | 5014 | |
d62a17ae | 5015 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5016 | if (!peer) | |
5017 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5018 | |
1de27621 | 5019 | if (set) { |
80912664 DS |
5020 | if (rmap) |
5021 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5022 | ret = peer_default_originate_set(peer, afi, safi, |
5023 | rmap, route_map); | |
5024 | } else | |
d62a17ae | 5025 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5026 | |
d62a17ae | 5027 | return bgp_vty_return(vty, ret); |
718e3744 | 5028 | } |
5029 | ||
5030 | /* neighbor default-originate. */ | |
5031 | DEFUN (neighbor_default_originate, | |
5032 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5033 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5034 | NEIGHBOR_STR |
5035 | NEIGHBOR_ADDR_STR2 | |
5036 | "Originate default route to this neighbor\n") | |
5037 | { | |
d62a17ae | 5038 | int idx_peer = 1; |
5039 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5040 | bgp_node_afi(vty), | |
5041 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5042 | } |
5043 | ||
d62a17ae | 5044 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5045 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5046 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5047 | "Originate default route to this neighbor\n") | |
596c17ba | 5048 | |
718e3744 | 5049 | DEFUN (neighbor_default_originate_rmap, |
5050 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5051 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5052 | NEIGHBOR_STR |
5053 | NEIGHBOR_ADDR_STR2 | |
5054 | "Originate default route to this neighbor\n" | |
5055 | "Route-map to specify criteria to originate default\n" | |
5056 | "route-map name\n") | |
5057 | { | |
d62a17ae | 5058 | int idx_peer = 1; |
5059 | int idx_word = 4; | |
5060 | return peer_default_originate_set_vty( | |
5061 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5062 | argv[idx_word]->arg, 1); | |
718e3744 | 5063 | } |
5064 | ||
d62a17ae | 5065 | ALIAS_HIDDEN( |
5066 | neighbor_default_originate_rmap, | |
5067 | neighbor_default_originate_rmap_hidden_cmd, | |
5068 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5069 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5070 | "Originate default route to this neighbor\n" | |
5071 | "Route-map to specify criteria to originate default\n" | |
5072 | "route-map name\n") | |
596c17ba | 5073 | |
718e3744 | 5074 | DEFUN (no_neighbor_default_originate, |
5075 | no_neighbor_default_originate_cmd, | |
a636c635 | 5076 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5077 | NO_STR |
5078 | NEIGHBOR_STR | |
5079 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5080 | "Originate default route to this neighbor\n" |
5081 | "Route-map to specify criteria to originate default\n" | |
5082 | "route-map name\n") | |
718e3744 | 5083 | { |
d62a17ae | 5084 | int idx_peer = 2; |
5085 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5086 | bgp_node_afi(vty), | |
5087 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5088 | } |
5089 | ||
d62a17ae | 5090 | ALIAS_HIDDEN( |
5091 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5092 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5093 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5094 | "Originate default route to this neighbor\n" | |
5095 | "Route-map to specify criteria to originate default\n" | |
5096 | "route-map name\n") | |
596c17ba | 5097 | |
6b0655a2 | 5098 | |
718e3744 | 5099 | /* Set neighbor's BGP port. */ |
d62a17ae | 5100 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5101 | const char *port_str) | |
5102 | { | |
5103 | struct peer *peer; | |
d7c0a89a | 5104 | uint16_t port; |
d62a17ae | 5105 | struct servent *sp; |
5106 | ||
5107 | peer = peer_lookup_vty(vty, ip_str); | |
5108 | if (!peer) | |
5109 | return CMD_WARNING_CONFIG_FAILED; | |
5110 | ||
5111 | if (!port_str) { | |
5112 | sp = getservbyname("bgp", "tcp"); | |
5113 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5114 | } else { | |
5115 | port = strtoul(port_str, NULL, 10); | |
5116 | } | |
718e3744 | 5117 | |
d62a17ae | 5118 | peer_port_set(peer, port); |
718e3744 | 5119 | |
d62a17ae | 5120 | return CMD_SUCCESS; |
718e3744 | 5121 | } |
5122 | ||
f418446b | 5123 | /* Set specified peer's BGP port. */ |
718e3744 | 5124 | DEFUN (neighbor_port, |
5125 | neighbor_port_cmd, | |
9ccf14f7 | 5126 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5127 | NEIGHBOR_STR |
5128 | NEIGHBOR_ADDR_STR | |
5129 | "Neighbor's BGP port\n" | |
5130 | "TCP port number\n") | |
5131 | { | |
d62a17ae | 5132 | int idx_ip = 1; |
5133 | int idx_number = 3; | |
5134 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5135 | argv[idx_number]->arg); | |
718e3744 | 5136 | } |
5137 | ||
5138 | DEFUN (no_neighbor_port, | |
5139 | no_neighbor_port_cmd, | |
9ccf14f7 | 5140 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5141 | NO_STR |
5142 | NEIGHBOR_STR | |
5143 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5144 | "Neighbor's BGP port\n" |
5145 | "TCP port number\n") | |
718e3744 | 5146 | { |
d62a17ae | 5147 | int idx_ip = 2; |
5148 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5149 | } |
5150 | ||
6b0655a2 | 5151 | |
718e3744 | 5152 | /* neighbor weight. */ |
d62a17ae | 5153 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5154 | safi_t safi, const char *weight_str) | |
718e3744 | 5155 | { |
d62a17ae | 5156 | int ret; |
5157 | struct peer *peer; | |
5158 | unsigned long weight; | |
718e3744 | 5159 | |
d62a17ae | 5160 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5161 | if (!peer) | |
5162 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5163 | |
d62a17ae | 5164 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5165 | |
d62a17ae | 5166 | ret = peer_weight_set(peer, afi, safi, weight); |
5167 | return bgp_vty_return(vty, ret); | |
718e3744 | 5168 | } |
5169 | ||
d62a17ae | 5170 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5171 | safi_t safi) | |
718e3744 | 5172 | { |
d62a17ae | 5173 | int ret; |
5174 | struct peer *peer; | |
718e3744 | 5175 | |
d62a17ae | 5176 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5177 | if (!peer) | |
5178 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5179 | |
d62a17ae | 5180 | ret = peer_weight_unset(peer, afi, safi); |
5181 | return bgp_vty_return(vty, ret); | |
718e3744 | 5182 | } |
5183 | ||
5184 | DEFUN (neighbor_weight, | |
5185 | neighbor_weight_cmd, | |
9ccf14f7 | 5186 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5187 | NEIGHBOR_STR |
5188 | NEIGHBOR_ADDR_STR2 | |
5189 | "Set default weight for routes from this neighbor\n" | |
5190 | "default weight\n") | |
5191 | { | |
d62a17ae | 5192 | int idx_peer = 1; |
5193 | int idx_number = 3; | |
5194 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5195 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5196 | } |
5197 | ||
d62a17ae | 5198 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5199 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5200 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5201 | "Set default weight for routes from this neighbor\n" | |
5202 | "default weight\n") | |
596c17ba | 5203 | |
718e3744 | 5204 | DEFUN (no_neighbor_weight, |
5205 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5206 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5207 | NO_STR |
5208 | NEIGHBOR_STR | |
5209 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5210 | "Set default weight for routes from this neighbor\n" |
5211 | "default weight\n") | |
718e3744 | 5212 | { |
d62a17ae | 5213 | int idx_peer = 2; |
5214 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5215 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5216 | } |
5217 | ||
d62a17ae | 5218 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5219 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5220 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5221 | "Set default weight for routes from this neighbor\n" | |
5222 | "default weight\n") | |
596c17ba | 5223 | |
6b0655a2 | 5224 | |
718e3744 | 5225 | /* Override capability negotiation. */ |
5226 | DEFUN (neighbor_override_capability, | |
5227 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5228 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5229 | NEIGHBOR_STR |
5230 | NEIGHBOR_ADDR_STR2 | |
5231 | "Override capability negotiation result\n") | |
5232 | { | |
d62a17ae | 5233 | int idx_peer = 1; |
5234 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5235 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5236 | } |
5237 | ||
5238 | DEFUN (no_neighbor_override_capability, | |
5239 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5240 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5241 | NO_STR |
5242 | NEIGHBOR_STR | |
5243 | NEIGHBOR_ADDR_STR2 | |
5244 | "Override capability negotiation result\n") | |
5245 | { | |
d62a17ae | 5246 | int idx_peer = 2; |
5247 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5248 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5249 | } |
6b0655a2 | 5250 | |
718e3744 | 5251 | DEFUN (neighbor_strict_capability, |
5252 | neighbor_strict_capability_cmd, | |
9fb964de | 5253 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5254 | NEIGHBOR_STR |
9fb964de | 5255 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5256 | "Strict capability negotiation match\n") |
5257 | { | |
9fb964de PM |
5258 | int idx_peer = 1; |
5259 | ||
5260 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5261 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5262 | } |
5263 | ||
5264 | DEFUN (no_neighbor_strict_capability, | |
5265 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5266 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5267 | NO_STR |
5268 | NEIGHBOR_STR | |
9fb964de | 5269 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5270 | "Strict capability negotiation match\n") |
5271 | { | |
9fb964de PM |
5272 | int idx_peer = 2; |
5273 | ||
5274 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5275 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5276 | } |
6b0655a2 | 5277 | |
d62a17ae | 5278 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5279 | const char *keep_str, const char *hold_str) | |
718e3744 | 5280 | { |
d62a17ae | 5281 | int ret; |
5282 | struct peer *peer; | |
d7c0a89a QY |
5283 | uint32_t keepalive; |
5284 | uint32_t holdtime; | |
718e3744 | 5285 | |
d62a17ae | 5286 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5287 | if (!peer) | |
5288 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5289 | |
d62a17ae | 5290 | keepalive = strtoul(keep_str, NULL, 10); |
5291 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5292 | |
d62a17ae | 5293 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5294 | |
d62a17ae | 5295 | return bgp_vty_return(vty, ret); |
718e3744 | 5296 | } |
6b0655a2 | 5297 | |
d62a17ae | 5298 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5299 | { |
d62a17ae | 5300 | int ret; |
5301 | struct peer *peer; | |
718e3744 | 5302 | |
d62a17ae | 5303 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5304 | if (!peer) | |
5305 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5306 | |
d62a17ae | 5307 | ret = peer_timers_unset(peer); |
718e3744 | 5308 | |
d62a17ae | 5309 | return bgp_vty_return(vty, ret); |
718e3744 | 5310 | } |
5311 | ||
5312 | DEFUN (neighbor_timers, | |
5313 | neighbor_timers_cmd, | |
9ccf14f7 | 5314 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5315 | NEIGHBOR_STR |
5316 | NEIGHBOR_ADDR_STR2 | |
5317 | "BGP per neighbor timers\n" | |
5318 | "Keepalive interval\n" | |
5319 | "Holdtime\n") | |
5320 | { | |
d62a17ae | 5321 | int idx_peer = 1; |
5322 | int idx_number = 3; | |
5323 | int idx_number_2 = 4; | |
5324 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5325 | argv[idx_number]->arg, | |
5326 | argv[idx_number_2]->arg); | |
718e3744 | 5327 | } |
5328 | ||
5329 | DEFUN (no_neighbor_timers, | |
5330 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5331 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5332 | NO_STR |
5333 | NEIGHBOR_STR | |
5334 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5335 | "BGP per neighbor timers\n" |
5336 | "Keepalive interval\n" | |
5337 | "Holdtime\n") | |
718e3744 | 5338 | { |
d62a17ae | 5339 | int idx_peer = 2; |
5340 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5341 | } |
6b0655a2 | 5342 | |
813d4307 | 5343 | |
d62a17ae | 5344 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5345 | const char *time_str) | |
718e3744 | 5346 | { |
d62a17ae | 5347 | int ret; |
5348 | struct peer *peer; | |
d7c0a89a | 5349 | uint32_t connect; |
718e3744 | 5350 | |
d62a17ae | 5351 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5352 | if (!peer) | |
5353 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5354 | |
d62a17ae | 5355 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5356 | |
d62a17ae | 5357 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5358 | |
d62a17ae | 5359 | return bgp_vty_return(vty, ret); |
718e3744 | 5360 | } |
5361 | ||
d62a17ae | 5362 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5363 | { |
d62a17ae | 5364 | int ret; |
5365 | struct peer *peer; | |
718e3744 | 5366 | |
d62a17ae | 5367 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5368 | if (!peer) | |
5369 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5370 | |
d62a17ae | 5371 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5372 | |
d62a17ae | 5373 | return bgp_vty_return(vty, ret); |
718e3744 | 5374 | } |
5375 | ||
5376 | DEFUN (neighbor_timers_connect, | |
5377 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5378 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5379 | NEIGHBOR_STR |
966f821c | 5380 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5381 | "BGP per neighbor timers\n" |
5382 | "BGP connect timer\n" | |
5383 | "Connect timer\n") | |
5384 | { | |
d62a17ae | 5385 | int idx_peer = 1; |
5386 | int idx_number = 4; | |
5387 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5388 | argv[idx_number]->arg); | |
718e3744 | 5389 | } |
5390 | ||
5391 | DEFUN (no_neighbor_timers_connect, | |
5392 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5393 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5394 | NO_STR |
5395 | NEIGHBOR_STR | |
966f821c | 5396 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5397 | "BGP per neighbor timers\n" |
8334fd5a DW |
5398 | "BGP connect timer\n" |
5399 | "Connect timer\n") | |
718e3744 | 5400 | { |
d62a17ae | 5401 | int idx_peer = 2; |
5402 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5403 | } |
5404 | ||
6b0655a2 | 5405 | |
d62a17ae | 5406 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5407 | const char *time_str, int set) | |
718e3744 | 5408 | { |
d62a17ae | 5409 | int ret; |
5410 | struct peer *peer; | |
d7c0a89a | 5411 | uint32_t routeadv = 0; |
718e3744 | 5412 | |
d62a17ae | 5413 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5414 | if (!peer) | |
5415 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5416 | |
d62a17ae | 5417 | if (time_str) |
5418 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5419 | |
d62a17ae | 5420 | if (set) |
5421 | ret = peer_advertise_interval_set(peer, routeadv); | |
5422 | else | |
5423 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5424 | |
d62a17ae | 5425 | return bgp_vty_return(vty, ret); |
718e3744 | 5426 | } |
5427 | ||
5428 | DEFUN (neighbor_advertise_interval, | |
5429 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5430 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5431 | NEIGHBOR_STR |
966f821c | 5432 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5433 | "Minimum interval between sending BGP routing updates\n" |
5434 | "time in seconds\n") | |
5435 | { | |
d62a17ae | 5436 | int idx_peer = 1; |
5437 | int idx_number = 3; | |
5438 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5439 | argv[idx_number]->arg, 1); | |
718e3744 | 5440 | } |
5441 | ||
5442 | DEFUN (no_neighbor_advertise_interval, | |
5443 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5444 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5445 | NO_STR |
5446 | NEIGHBOR_STR | |
966f821c | 5447 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5448 | "Minimum interval between sending BGP routing updates\n" |
5449 | "time in seconds\n") | |
718e3744 | 5450 | { |
d62a17ae | 5451 | int idx_peer = 2; |
5452 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5453 | } |
5454 | ||
6b0655a2 | 5455 | |
518f0eb1 DS |
5456 | /* Time to wait before processing route-map updates */ |
5457 | DEFUN (bgp_set_route_map_delay_timer, | |
5458 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5459 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5460 | SET_STR |
5461 | "BGP route-map delay timer\n" | |
5462 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5463 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5464 | { |
d62a17ae | 5465 | int idx_number = 3; |
d7c0a89a | 5466 | uint32_t rmap_delay_timer; |
d62a17ae | 5467 | |
5468 | if (argv[idx_number]->arg) { | |
5469 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5470 | bm->rmap_update_timer = rmap_delay_timer; | |
5471 | ||
5472 | /* if the dynamic update handling is being disabled, and a timer | |
5473 | * is | |
5474 | * running, stop the timer and act as if the timer has already | |
5475 | * fired. | |
5476 | */ | |
5477 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5478 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5479 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5480 | NULL, 0); | |
5481 | } | |
5482 | return CMD_SUCCESS; | |
5483 | } else { | |
5484 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5485 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5486 | } |
518f0eb1 DS |
5487 | } |
5488 | ||
5489 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5490 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5491 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5492 | NO_STR |
3a2d747c | 5493 | BGP_STR |
518f0eb1 | 5494 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5495 | "Reset to default time to wait for processing route-map changes\n" |
5496 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5497 | { |
518f0eb1 | 5498 | |
d62a17ae | 5499 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5500 | |
d62a17ae | 5501 | return CMD_SUCCESS; |
518f0eb1 DS |
5502 | } |
5503 | ||
f414725f | 5504 | |
718e3744 | 5505 | /* neighbor interface */ |
d62a17ae | 5506 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5507 | const char *str) | |
718e3744 | 5508 | { |
d62a17ae | 5509 | struct peer *peer; |
718e3744 | 5510 | |
d62a17ae | 5511 | peer = peer_lookup_vty(vty, ip_str); |
5512 | if (!peer || peer->conf_if) { | |
5513 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5514 | return CMD_WARNING_CONFIG_FAILED; | |
5515 | } | |
718e3744 | 5516 | |
d62a17ae | 5517 | if (str) |
5518 | peer_interface_set(peer, str); | |
5519 | else | |
5520 | peer_interface_unset(peer); | |
718e3744 | 5521 | |
d62a17ae | 5522 | return CMD_SUCCESS; |
718e3744 | 5523 | } |
5524 | ||
5525 | DEFUN (neighbor_interface, | |
5526 | neighbor_interface_cmd, | |
9ccf14f7 | 5527 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5528 | NEIGHBOR_STR |
5529 | NEIGHBOR_ADDR_STR | |
5530 | "Interface\n" | |
5531 | "Interface name\n") | |
5532 | { | |
d62a17ae | 5533 | int idx_ip = 1; |
5534 | int idx_word = 3; | |
5535 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5536 | } |
5537 | ||
5538 | DEFUN (no_neighbor_interface, | |
5539 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5540 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5541 | NO_STR |
5542 | NEIGHBOR_STR | |
16cedbb0 | 5543 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5544 | "Interface\n" |
5545 | "Interface name\n") | |
5546 | { | |
d62a17ae | 5547 | int idx_peer = 2; |
5548 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5549 | } |
6b0655a2 | 5550 | |
718e3744 | 5551 | DEFUN (neighbor_distribute_list, |
5552 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5553 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5554 | NEIGHBOR_STR |
5555 | NEIGHBOR_ADDR_STR2 | |
5556 | "Filter updates to/from this neighbor\n" | |
5557 | "IP access-list number\n" | |
5558 | "IP access-list number (expanded range)\n" | |
5559 | "IP Access-list name\n" | |
5560 | "Filter incoming updates\n" | |
5561 | "Filter outgoing updates\n") | |
5562 | { | |
d62a17ae | 5563 | int idx_peer = 1; |
5564 | int idx_acl = 3; | |
5565 | int direct, ret; | |
5566 | struct peer *peer; | |
a8206004 | 5567 | |
d62a17ae | 5568 | const char *pstr = argv[idx_peer]->arg; |
5569 | const char *acl = argv[idx_acl]->arg; | |
5570 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5571 | |
d62a17ae | 5572 | peer = peer_and_group_lookup_vty(vty, pstr); |
5573 | if (!peer) | |
5574 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5575 | |
d62a17ae | 5576 | /* Check filter direction. */ |
5577 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5578 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5579 | direct, acl); | |
a8206004 | 5580 | |
d62a17ae | 5581 | return bgp_vty_return(vty, ret); |
718e3744 | 5582 | } |
5583 | ||
d62a17ae | 5584 | ALIAS_HIDDEN( |
5585 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5586 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5587 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5588 | "Filter updates to/from this neighbor\n" | |
5589 | "IP access-list number\n" | |
5590 | "IP access-list number (expanded range)\n" | |
5591 | "IP Access-list name\n" | |
5592 | "Filter incoming updates\n" | |
5593 | "Filter outgoing updates\n") | |
596c17ba | 5594 | |
718e3744 | 5595 | DEFUN (no_neighbor_distribute_list, |
5596 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5597 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5598 | NO_STR |
5599 | NEIGHBOR_STR | |
5600 | NEIGHBOR_ADDR_STR2 | |
5601 | "Filter updates to/from this neighbor\n" | |
5602 | "IP access-list number\n" | |
5603 | "IP access-list number (expanded range)\n" | |
5604 | "IP Access-list name\n" | |
5605 | "Filter incoming updates\n" | |
5606 | "Filter outgoing updates\n") | |
5607 | { | |
d62a17ae | 5608 | int idx_peer = 2; |
5609 | int direct, ret; | |
5610 | struct peer *peer; | |
a8206004 | 5611 | |
d62a17ae | 5612 | const char *pstr = argv[idx_peer]->arg; |
5613 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5614 | |
d62a17ae | 5615 | peer = peer_and_group_lookup_vty(vty, pstr); |
5616 | if (!peer) | |
5617 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5618 | |
d62a17ae | 5619 | /* Check filter direction. */ |
5620 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5621 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5622 | direct); | |
a8206004 | 5623 | |
d62a17ae | 5624 | return bgp_vty_return(vty, ret); |
718e3744 | 5625 | } |
6b0655a2 | 5626 | |
d62a17ae | 5627 | ALIAS_HIDDEN( |
5628 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5629 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5630 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5631 | "Filter updates to/from this neighbor\n" | |
5632 | "IP access-list number\n" | |
5633 | "IP access-list number (expanded range)\n" | |
5634 | "IP Access-list name\n" | |
5635 | "Filter incoming updates\n" | |
5636 | "Filter outgoing updates\n") | |
596c17ba | 5637 | |
718e3744 | 5638 | /* Set prefix list to the peer. */ |
d62a17ae | 5639 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5640 | afi_t afi, safi_t safi, | |
5641 | const char *name_str, | |
5642 | const char *direct_str) | |
718e3744 | 5643 | { |
d62a17ae | 5644 | int ret; |
d62a17ae | 5645 | int direct = FILTER_IN; |
cf9ac8bf | 5646 | struct peer *peer; |
718e3744 | 5647 | |
d62a17ae | 5648 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5649 | if (!peer) | |
5650 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5651 | |
d62a17ae | 5652 | /* Check filter direction. */ |
5653 | if (strncmp(direct_str, "i", 1) == 0) | |
5654 | direct = FILTER_IN; | |
5655 | else if (strncmp(direct_str, "o", 1) == 0) | |
5656 | direct = FILTER_OUT; | |
718e3744 | 5657 | |
d62a17ae | 5658 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5659 | |
d62a17ae | 5660 | return bgp_vty_return(vty, ret); |
718e3744 | 5661 | } |
5662 | ||
d62a17ae | 5663 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5664 | afi_t afi, safi_t safi, | |
5665 | const char *direct_str) | |
718e3744 | 5666 | { |
d62a17ae | 5667 | int ret; |
5668 | struct peer *peer; | |
5669 | int direct = FILTER_IN; | |
718e3744 | 5670 | |
d62a17ae | 5671 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5672 | if (!peer) | |
5673 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5674 | |
d62a17ae | 5675 | /* Check filter direction. */ |
5676 | if (strncmp(direct_str, "i", 1) == 0) | |
5677 | direct = FILTER_IN; | |
5678 | else if (strncmp(direct_str, "o", 1) == 0) | |
5679 | direct = FILTER_OUT; | |
718e3744 | 5680 | |
d62a17ae | 5681 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5682 | |
d62a17ae | 5683 | return bgp_vty_return(vty, ret); |
718e3744 | 5684 | } |
5685 | ||
5686 | DEFUN (neighbor_prefix_list, | |
5687 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5688 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5689 | NEIGHBOR_STR |
5690 | NEIGHBOR_ADDR_STR2 | |
5691 | "Filter updates to/from this neighbor\n" | |
5692 | "Name of a prefix list\n" | |
5693 | "Filter incoming updates\n" | |
5694 | "Filter outgoing updates\n") | |
5695 | { | |
d62a17ae | 5696 | int idx_peer = 1; |
5697 | int idx_word = 3; | |
5698 | int idx_in_out = 4; | |
5699 | return peer_prefix_list_set_vty( | |
5700 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5701 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5702 | } |
5703 | ||
d62a17ae | 5704 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5705 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5706 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5707 | "Filter updates to/from this neighbor\n" | |
5708 | "Name of a prefix list\n" | |
5709 | "Filter incoming updates\n" | |
5710 | "Filter outgoing updates\n") | |
596c17ba | 5711 | |
718e3744 | 5712 | DEFUN (no_neighbor_prefix_list, |
5713 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5714 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5715 | NO_STR |
5716 | NEIGHBOR_STR | |
5717 | NEIGHBOR_ADDR_STR2 | |
5718 | "Filter updates to/from this neighbor\n" | |
5719 | "Name of a prefix list\n" | |
5720 | "Filter incoming updates\n" | |
5721 | "Filter outgoing updates\n") | |
5722 | { | |
d62a17ae | 5723 | int idx_peer = 2; |
5724 | int idx_in_out = 5; | |
5725 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5726 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5727 | argv[idx_in_out]->arg); | |
718e3744 | 5728 | } |
6b0655a2 | 5729 | |
d62a17ae | 5730 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5731 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5732 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5733 | "Filter updates to/from this neighbor\n" | |
5734 | "Name of a prefix list\n" | |
5735 | "Filter incoming updates\n" | |
5736 | "Filter outgoing updates\n") | |
596c17ba | 5737 | |
d62a17ae | 5738 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5739 | safi_t safi, const char *name_str, | |
5740 | const char *direct_str) | |
718e3744 | 5741 | { |
d62a17ae | 5742 | int ret; |
5743 | struct peer *peer; | |
5744 | int direct = FILTER_IN; | |
718e3744 | 5745 | |
d62a17ae | 5746 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5747 | if (!peer) | |
5748 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5749 | |
d62a17ae | 5750 | /* Check filter direction. */ |
5751 | if (strncmp(direct_str, "i", 1) == 0) | |
5752 | direct = FILTER_IN; | |
5753 | else if (strncmp(direct_str, "o", 1) == 0) | |
5754 | direct = FILTER_OUT; | |
718e3744 | 5755 | |
d62a17ae | 5756 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5757 | |
d62a17ae | 5758 | return bgp_vty_return(vty, ret); |
718e3744 | 5759 | } |
5760 | ||
d62a17ae | 5761 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5762 | safi_t safi, const char *direct_str) | |
718e3744 | 5763 | { |
d62a17ae | 5764 | int ret; |
5765 | struct peer *peer; | |
5766 | int direct = FILTER_IN; | |
718e3744 | 5767 | |
d62a17ae | 5768 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5769 | if (!peer) | |
5770 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5771 | |
d62a17ae | 5772 | /* Check filter direction. */ |
5773 | if (strncmp(direct_str, "i", 1) == 0) | |
5774 | direct = FILTER_IN; | |
5775 | else if (strncmp(direct_str, "o", 1) == 0) | |
5776 | direct = FILTER_OUT; | |
718e3744 | 5777 | |
d62a17ae | 5778 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5779 | |
d62a17ae | 5780 | return bgp_vty_return(vty, ret); |
718e3744 | 5781 | } |
5782 | ||
5783 | DEFUN (neighbor_filter_list, | |
5784 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5785 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5786 | NEIGHBOR_STR |
5787 | NEIGHBOR_ADDR_STR2 | |
5788 | "Establish BGP filters\n" | |
5789 | "AS path access-list name\n" | |
5790 | "Filter incoming routes\n" | |
5791 | "Filter outgoing routes\n") | |
5792 | { | |
d62a17ae | 5793 | int idx_peer = 1; |
5794 | int idx_word = 3; | |
5795 | int idx_in_out = 4; | |
5796 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5797 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5798 | argv[idx_in_out]->arg); | |
718e3744 | 5799 | } |
5800 | ||
d62a17ae | 5801 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5802 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5803 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5804 | "Establish BGP filters\n" | |
5805 | "AS path access-list name\n" | |
5806 | "Filter incoming routes\n" | |
5807 | "Filter outgoing routes\n") | |
596c17ba | 5808 | |
718e3744 | 5809 | DEFUN (no_neighbor_filter_list, |
5810 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5811 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5812 | NO_STR |
5813 | NEIGHBOR_STR | |
5814 | NEIGHBOR_ADDR_STR2 | |
5815 | "Establish BGP filters\n" | |
5816 | "AS path access-list name\n" | |
5817 | "Filter incoming routes\n" | |
5818 | "Filter outgoing routes\n") | |
5819 | { | |
d62a17ae | 5820 | int idx_peer = 2; |
5821 | int idx_in_out = 5; | |
5822 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5823 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5824 | argv[idx_in_out]->arg); | |
718e3744 | 5825 | } |
6b0655a2 | 5826 | |
d62a17ae | 5827 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5828 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5829 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5830 | "Establish BGP filters\n" | |
5831 | "AS path access-list name\n" | |
5832 | "Filter incoming routes\n" | |
5833 | "Filter outgoing routes\n") | |
596c17ba | 5834 | |
718e3744 | 5835 | /* Set route-map to the peer. */ |
d62a17ae | 5836 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5837 | afi_t afi, safi_t safi, const char *name_str, | |
5838 | const char *direct_str) | |
718e3744 | 5839 | { |
d62a17ae | 5840 | int ret; |
5841 | struct peer *peer; | |
5842 | int direct = RMAP_IN; | |
1de27621 | 5843 | struct route_map *route_map; |
718e3744 | 5844 | |
d62a17ae | 5845 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5846 | if (!peer) | |
5847 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5848 | |
d62a17ae | 5849 | /* Check filter direction. */ |
5850 | if (strncmp(direct_str, "in", 2) == 0) | |
5851 | direct = RMAP_IN; | |
5852 | else if (strncmp(direct_str, "o", 1) == 0) | |
5853 | direct = RMAP_OUT; | |
718e3744 | 5854 | |
1de27621 DA |
5855 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5856 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 5857 | |
d62a17ae | 5858 | return bgp_vty_return(vty, ret); |
718e3744 | 5859 | } |
5860 | ||
d62a17ae | 5861 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5862 | afi_t afi, safi_t safi, | |
5863 | const char *direct_str) | |
718e3744 | 5864 | { |
d62a17ae | 5865 | int ret; |
5866 | struct peer *peer; | |
5867 | int direct = RMAP_IN; | |
718e3744 | 5868 | |
d62a17ae | 5869 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5870 | if (!peer) | |
5871 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5872 | |
d62a17ae | 5873 | /* Check filter direction. */ |
5874 | if (strncmp(direct_str, "in", 2) == 0) | |
5875 | direct = RMAP_IN; | |
5876 | else if (strncmp(direct_str, "o", 1) == 0) | |
5877 | direct = RMAP_OUT; | |
718e3744 | 5878 | |
d62a17ae | 5879 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5880 | |
d62a17ae | 5881 | return bgp_vty_return(vty, ret); |
718e3744 | 5882 | } |
5883 | ||
5884 | DEFUN (neighbor_route_map, | |
5885 | neighbor_route_map_cmd, | |
9ccf14f7 | 5886 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5887 | NEIGHBOR_STR |
5888 | NEIGHBOR_ADDR_STR2 | |
5889 | "Apply route map to neighbor\n" | |
5890 | "Name of route map\n" | |
5891 | "Apply map to incoming routes\n" | |
2a3d5731 | 5892 | "Apply map to outbound routes\n") |
718e3744 | 5893 | { |
d62a17ae | 5894 | int idx_peer = 1; |
5895 | int idx_word = 3; | |
5896 | int idx_in_out = 4; | |
5897 | return peer_route_map_set_vty( | |
5898 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5899 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5900 | } |
5901 | ||
d62a17ae | 5902 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5903 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5904 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5905 | "Apply route map to neighbor\n" | |
5906 | "Name of route map\n" | |
5907 | "Apply map to incoming routes\n" | |
5908 | "Apply map to outbound routes\n") | |
596c17ba | 5909 | |
718e3744 | 5910 | DEFUN (no_neighbor_route_map, |
5911 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5912 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5913 | NO_STR |
5914 | NEIGHBOR_STR | |
5915 | NEIGHBOR_ADDR_STR2 | |
5916 | "Apply route map to neighbor\n" | |
5917 | "Name of route map\n" | |
5918 | "Apply map to incoming routes\n" | |
2a3d5731 | 5919 | "Apply map to outbound routes\n") |
718e3744 | 5920 | { |
d62a17ae | 5921 | int idx_peer = 2; |
5922 | int idx_in_out = 5; | |
5923 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5924 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5925 | argv[idx_in_out]->arg); | |
718e3744 | 5926 | } |
6b0655a2 | 5927 | |
d62a17ae | 5928 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5929 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5930 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5931 | "Apply route map to neighbor\n" | |
5932 | "Name of route map\n" | |
5933 | "Apply map to incoming routes\n" | |
5934 | "Apply map to outbound routes\n") | |
596c17ba | 5935 | |
718e3744 | 5936 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5937 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5938 | afi_t afi, safi_t safi, | |
5939 | const char *name_str) | |
718e3744 | 5940 | { |
d62a17ae | 5941 | int ret; |
5942 | struct peer *peer; | |
1de27621 | 5943 | struct route_map *route_map; |
718e3744 | 5944 | |
d62a17ae | 5945 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5946 | if (!peer) | |
5947 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5948 | |
1de27621 DA |
5949 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5950 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 5951 | |
d62a17ae | 5952 | return bgp_vty_return(vty, ret); |
718e3744 | 5953 | } |
5954 | ||
5955 | /* Unset route-map from the peer. */ | |
d62a17ae | 5956 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5957 | afi_t afi, safi_t safi) | |
718e3744 | 5958 | { |
d62a17ae | 5959 | int ret; |
5960 | struct peer *peer; | |
718e3744 | 5961 | |
d62a17ae | 5962 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5963 | if (!peer) | |
5964 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5965 | |
d62a17ae | 5966 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5967 | |
d62a17ae | 5968 | return bgp_vty_return(vty, ret); |
718e3744 | 5969 | } |
5970 | ||
5971 | DEFUN (neighbor_unsuppress_map, | |
5972 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5973 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5974 | NEIGHBOR_STR |
5975 | NEIGHBOR_ADDR_STR2 | |
5976 | "Route-map to selectively unsuppress suppressed routes\n" | |
5977 | "Name of route map\n") | |
5978 | { | |
d62a17ae | 5979 | int idx_peer = 1; |
5980 | int idx_word = 3; | |
5981 | return peer_unsuppress_map_set_vty( | |
5982 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5983 | argv[idx_word]->arg); | |
718e3744 | 5984 | } |
5985 | ||
d62a17ae | 5986 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5987 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5988 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5989 | "Route-map to selectively unsuppress suppressed routes\n" | |
5990 | "Name of route map\n") | |
596c17ba | 5991 | |
718e3744 | 5992 | DEFUN (no_neighbor_unsuppress_map, |
5993 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5994 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5995 | NO_STR |
5996 | NEIGHBOR_STR | |
5997 | NEIGHBOR_ADDR_STR2 | |
5998 | "Route-map to selectively unsuppress suppressed routes\n" | |
5999 | "Name of route map\n") | |
6000 | { | |
d62a17ae | 6001 | int idx_peer = 2; |
6002 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6003 | bgp_node_afi(vty), | |
6004 | bgp_node_safi(vty)); | |
718e3744 | 6005 | } |
6b0655a2 | 6006 | |
d62a17ae | 6007 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6008 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6009 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6010 | "Route-map to selectively unsuppress suppressed routes\n" | |
6011 | "Name of route map\n") | |
596c17ba | 6012 | |
d62a17ae | 6013 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6014 | afi_t afi, safi_t safi, | |
6015 | const char *num_str, | |
6016 | const char *threshold_str, int warning, | |
6017 | const char *restart_str) | |
718e3744 | 6018 | { |
d62a17ae | 6019 | int ret; |
6020 | struct peer *peer; | |
d7c0a89a QY |
6021 | uint32_t max; |
6022 | uint8_t threshold; | |
6023 | uint16_t restart; | |
718e3744 | 6024 | |
d62a17ae | 6025 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6026 | if (!peer) | |
6027 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6028 | |
d62a17ae | 6029 | max = strtoul(num_str, NULL, 10); |
6030 | if (threshold_str) | |
6031 | threshold = atoi(threshold_str); | |
6032 | else | |
6033 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6034 | |
d62a17ae | 6035 | if (restart_str) |
6036 | restart = atoi(restart_str); | |
6037 | else | |
6038 | restart = 0; | |
0a486e5f | 6039 | |
d62a17ae | 6040 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
6041 | restart); | |
718e3744 | 6042 | |
d62a17ae | 6043 | return bgp_vty_return(vty, ret); |
718e3744 | 6044 | } |
6045 | ||
d62a17ae | 6046 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6047 | afi_t afi, safi_t safi) | |
718e3744 | 6048 | { |
d62a17ae | 6049 | int ret; |
6050 | struct peer *peer; | |
718e3744 | 6051 | |
d62a17ae | 6052 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6053 | if (!peer) | |
6054 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6055 | |
d62a17ae | 6056 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6057 | |
d62a17ae | 6058 | return bgp_vty_return(vty, ret); |
718e3744 | 6059 | } |
6060 | ||
fde246e8 DA |
6061 | /* Maximum number of prefix to be sent to the neighbor. */ |
6062 | DEFUN(neighbor_maximum_prefix_out, | |
6063 | neighbor_maximum_prefix_out_cmd, | |
6064 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6065 | NEIGHBOR_STR | |
6066 | NEIGHBOR_ADDR_STR2 | |
6067 | "Maximum number of prefixes to be sent to this peer\n" | |
6068 | "Maximum no. of prefix limit\n") | |
6069 | { | |
6070 | int idx_peer = 1; | |
6071 | int idx_number = 3; | |
6072 | struct peer *peer; | |
6073 | uint32_t max; | |
6074 | afi_t afi = bgp_node_afi(vty); | |
6075 | safi_t safi = bgp_node_safi(vty); | |
6076 | ||
6077 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6078 | if (!peer) | |
6079 | return CMD_WARNING_CONFIG_FAILED; | |
6080 | ||
6081 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6082 | ||
6083 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6084 | peer->pmax_out[afi][safi] = max; | |
6085 | ||
6086 | return CMD_SUCCESS; | |
6087 | } | |
6088 | ||
6089 | DEFUN(no_neighbor_maximum_prefix_out, | |
6090 | no_neighbor_maximum_prefix_out_cmd, | |
6091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6092 | NO_STR | |
6093 | NEIGHBOR_STR | |
6094 | NEIGHBOR_ADDR_STR2 | |
6095 | "Maximum number of prefixes to be sent to this peer\n") | |
6096 | { | |
6097 | int idx_peer = 2; | |
6098 | struct peer *peer; | |
6099 | afi_t afi = bgp_node_afi(vty); | |
6100 | safi_t safi = bgp_node_safi(vty); | |
6101 | ||
6102 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6103 | if (!peer) | |
6104 | return CMD_WARNING_CONFIG_FAILED; | |
6105 | ||
6106 | peer->pmax_out[afi][safi] = 0; | |
6107 | ||
6108 | return CMD_SUCCESS; | |
6109 | } | |
6110 | ||
718e3744 | 6111 | /* Maximum number of prefix configuration. prefix count is different |
6112 | for each peer configuration. So this configuration can be set for | |
6113 | each peer configuration. */ | |
6114 | DEFUN (neighbor_maximum_prefix, | |
6115 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 6116 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 6117 | NEIGHBOR_STR |
6118 | NEIGHBOR_ADDR_STR2 | |
6119 | "Maximum number of prefix accept from this peer\n" | |
6120 | "maximum no. of prefix limit\n") | |
6121 | { | |
d62a17ae | 6122 | int idx_peer = 1; |
6123 | int idx_number = 3; | |
6124 | return peer_maximum_prefix_set_vty( | |
6125 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6126 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 6127 | } |
6128 | ||
d62a17ae | 6129 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
6130 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
6131 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6132 | "Maximum number of prefix accept from this peer\n" | |
6133 | "maximum no. of prefix limit\n") | |
596c17ba | 6134 | |
e0701b79 | 6135 | DEFUN (neighbor_maximum_prefix_threshold, |
6136 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 6137 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 6138 | NEIGHBOR_STR |
6139 | NEIGHBOR_ADDR_STR2 | |
6140 | "Maximum number of prefix accept from this peer\n" | |
6141 | "maximum no. of prefix limit\n" | |
6142 | "Threshold value (%) at which to generate a warning msg\n") | |
6143 | { | |
d62a17ae | 6144 | int idx_peer = 1; |
6145 | int idx_number = 3; | |
6146 | int idx_number_2 = 4; | |
6147 | return peer_maximum_prefix_set_vty( | |
6148 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6149 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6150 | } |
e0701b79 | 6151 | |
d62a17ae | 6152 | ALIAS_HIDDEN( |
6153 | neighbor_maximum_prefix_threshold, | |
6154 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6155 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6156 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6157 | "Maximum number of prefix accept from this peer\n" | |
6158 | "maximum no. of prefix limit\n" | |
6159 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6160 | |
718e3744 | 6161 | DEFUN (neighbor_maximum_prefix_warning, |
6162 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6163 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6164 | NEIGHBOR_STR |
6165 | NEIGHBOR_ADDR_STR2 | |
6166 | "Maximum number of prefix accept from this peer\n" | |
6167 | "maximum no. of prefix limit\n" | |
6168 | "Only give warning message when limit is exceeded\n") | |
6169 | { | |
d62a17ae | 6170 | int idx_peer = 1; |
6171 | int idx_number = 3; | |
6172 | return peer_maximum_prefix_set_vty( | |
6173 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6174 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6175 | } |
6176 | ||
d62a17ae | 6177 | ALIAS_HIDDEN( |
6178 | neighbor_maximum_prefix_warning, | |
6179 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6180 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6181 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6182 | "Maximum number of prefix accept from this peer\n" | |
6183 | "maximum no. of prefix limit\n" | |
6184 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6185 | |
e0701b79 | 6186 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6187 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6188 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6189 | NEIGHBOR_STR |
6190 | NEIGHBOR_ADDR_STR2 | |
6191 | "Maximum number of prefix accept from this peer\n" | |
6192 | "maximum no. of prefix limit\n" | |
6193 | "Threshold value (%) at which to generate a warning msg\n" | |
6194 | "Only give warning message when limit is exceeded\n") | |
6195 | { | |
d62a17ae | 6196 | int idx_peer = 1; |
6197 | int idx_number = 3; | |
6198 | int idx_number_2 = 4; | |
6199 | return peer_maximum_prefix_set_vty( | |
6200 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6201 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6202 | } |
6203 | ||
d62a17ae | 6204 | ALIAS_HIDDEN( |
6205 | neighbor_maximum_prefix_threshold_warning, | |
6206 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6207 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6208 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6209 | "Maximum number of prefix accept from this peer\n" | |
6210 | "maximum no. of prefix limit\n" | |
6211 | "Threshold value (%) at which to generate a warning msg\n" | |
6212 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6213 | |
0a486e5f | 6214 | DEFUN (neighbor_maximum_prefix_restart, |
6215 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6216 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6217 | NEIGHBOR_STR |
6218 | NEIGHBOR_ADDR_STR2 | |
6219 | "Maximum number of prefix accept from this peer\n" | |
6220 | "maximum no. of prefix limit\n" | |
6221 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6222 | "Restart interval in minutes\n") |
0a486e5f | 6223 | { |
d62a17ae | 6224 | int idx_peer = 1; |
6225 | int idx_number = 3; | |
6226 | int idx_number_2 = 5; | |
6227 | return peer_maximum_prefix_set_vty( | |
6228 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6229 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6230 | } |
6231 | ||
d62a17ae | 6232 | ALIAS_HIDDEN( |
6233 | neighbor_maximum_prefix_restart, | |
6234 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6235 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6236 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6237 | "Maximum number of prefix accept from this peer\n" | |
6238 | "maximum no. of prefix limit\n" | |
6239 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6240 | "Restart interval in minutes\n") |
596c17ba | 6241 | |
0a486e5f | 6242 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6243 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6244 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6245 | NEIGHBOR_STR |
6246 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6247 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6248 | "maximum no. of prefix limit\n" |
6249 | "Threshold value (%) at which to generate a warning msg\n" | |
6250 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6251 | "Restart interval in minutes\n") |
0a486e5f | 6252 | { |
d62a17ae | 6253 | int idx_peer = 1; |
6254 | int idx_number = 3; | |
6255 | int idx_number_2 = 4; | |
6256 | int idx_number_3 = 6; | |
6257 | return peer_maximum_prefix_set_vty( | |
6258 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6259 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6260 | argv[idx_number_3]->arg); | |
6261 | } | |
6262 | ||
6263 | ALIAS_HIDDEN( | |
6264 | neighbor_maximum_prefix_threshold_restart, | |
6265 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6266 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6267 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6268 | "Maximum number of prefixes to accept from this peer\n" | |
6269 | "maximum no. of prefix limit\n" | |
6270 | "Threshold value (%) at which to generate a warning msg\n" | |
6271 | "Restart bgp connection after limit is exceeded\n" | |
6272 | "Restart interval in minutes\n") | |
596c17ba | 6273 | |
718e3744 | 6274 | DEFUN (no_neighbor_maximum_prefix, |
6275 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6276 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6277 | NO_STR |
6278 | NEIGHBOR_STR | |
6279 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6280 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6281 | "maximum no. of prefix limit\n" |
6282 | "Threshold value (%) at which to generate a warning msg\n" | |
6283 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6284 | "Restart interval in minutes\n" |
31500417 | 6285 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6286 | { |
d62a17ae | 6287 | int idx_peer = 2; |
6288 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6289 | bgp_node_afi(vty), | |
6290 | bgp_node_safi(vty)); | |
718e3744 | 6291 | } |
e52702f2 | 6292 | |
d62a17ae | 6293 | ALIAS_HIDDEN( |
6294 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6295 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6296 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6297 | "Maximum number of prefixes to accept from this peer\n" | |
6298 | "maximum no. of prefix limit\n" | |
6299 | "Threshold value (%) at which to generate a warning msg\n" | |
6300 | "Restart bgp connection after limit is exceeded\n" | |
6301 | "Restart interval in minutes\n" | |
6302 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6303 | |
718e3744 | 6304 | |
718e3744 | 6305 | /* "neighbor allowas-in" */ |
6306 | DEFUN (neighbor_allowas_in, | |
6307 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6308 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6309 | NEIGHBOR_STR |
6310 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6311 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6312 | "Number of occurrences of AS number\n" |
fd8503f5 | 6313 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6314 | { |
d62a17ae | 6315 | int idx_peer = 1; |
6316 | int idx_number_origin = 3; | |
6317 | int ret; | |
6318 | int origin = 0; | |
6319 | struct peer *peer; | |
6320 | int allow_num = 0; | |
6321 | ||
6322 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6323 | if (!peer) | |
6324 | return CMD_WARNING_CONFIG_FAILED; | |
6325 | ||
6326 | if (argc <= idx_number_origin) | |
6327 | allow_num = 3; | |
6328 | else { | |
6329 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6330 | origin = 1; | |
6331 | else | |
6332 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6333 | } | |
6334 | ||
6335 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6336 | allow_num, origin); | |
6337 | ||
6338 | return bgp_vty_return(vty, ret); | |
6339 | } | |
6340 | ||
6341 | ALIAS_HIDDEN( | |
6342 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6343 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6344 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6345 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6346 | "Number of occurrences of AS number\n" |
d62a17ae | 6347 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6348 | |
718e3744 | 6349 | DEFUN (no_neighbor_allowas_in, |
6350 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6351 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6352 | NO_STR |
6353 | NEIGHBOR_STR | |
6354 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6355 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6356 | "Number of occurrences of AS number\n" |
fd8503f5 | 6357 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6358 | { |
d62a17ae | 6359 | int idx_peer = 2; |
6360 | int ret; | |
6361 | struct peer *peer; | |
718e3744 | 6362 | |
d62a17ae | 6363 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6364 | if (!peer) | |
6365 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6366 | |
d62a17ae | 6367 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6368 | bgp_node_safi(vty)); | |
718e3744 | 6369 | |
d62a17ae | 6370 | return bgp_vty_return(vty, ret); |
718e3744 | 6371 | } |
6b0655a2 | 6372 | |
d62a17ae | 6373 | ALIAS_HIDDEN( |
6374 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6375 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6376 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6377 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6378 | "Number of occurrences of AS number\n" |
d62a17ae | 6379 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6380 | |
fa411a21 NH |
6381 | DEFUN (neighbor_ttl_security, |
6382 | neighbor_ttl_security_cmd, | |
7ebe625c | 6383 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6384 | NEIGHBOR_STR |
7ebe625c | 6385 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6386 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6387 | "Specify the maximum number of hops to the BGP peer\n" |
6388 | "Number of hops to BGP peer\n") | |
fa411a21 | 6389 | { |
d62a17ae | 6390 | int idx_peer = 1; |
6391 | int idx_number = 4; | |
6392 | struct peer *peer; | |
6393 | int gtsm_hops; | |
6394 | ||
6395 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6396 | if (!peer) | |
6397 | return CMD_WARNING_CONFIG_FAILED; | |
6398 | ||
6399 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6400 | ||
7ebe625c QY |
6401 | /* |
6402 | * If 'neighbor swpX', then this is for directly connected peers, | |
6403 | * we should not accept a ttl-security hops value greater than 1. | |
6404 | */ | |
6405 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6406 | vty_out(vty, | |
6407 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6408 | argv[idx_peer]->arg); | |
6409 | return CMD_WARNING_CONFIG_FAILED; | |
6410 | } | |
6411 | ||
d62a17ae | 6412 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6413 | } |
6414 | ||
6415 | DEFUN (no_neighbor_ttl_security, | |
6416 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6417 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6418 | NO_STR |
6419 | NEIGHBOR_STR | |
7ebe625c | 6420 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6421 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6422 | "Specify the maximum number of hops to the BGP peer\n" |
6423 | "Number of hops to BGP peer\n") | |
fa411a21 | 6424 | { |
d62a17ae | 6425 | int idx_peer = 2; |
6426 | struct peer *peer; | |
fa411a21 | 6427 | |
d62a17ae | 6428 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6429 | if (!peer) | |
6430 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6431 | |
d62a17ae | 6432 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6433 | } |
6b0655a2 | 6434 | |
adbac85e DW |
6435 | DEFUN (neighbor_addpath_tx_all_paths, |
6436 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6437 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6438 | NEIGHBOR_STR |
6439 | NEIGHBOR_ADDR_STR2 | |
6440 | "Use addpath to advertise all paths to a neighbor\n") | |
6441 | { | |
d62a17ae | 6442 | int idx_peer = 1; |
6443 | struct peer *peer; | |
adbac85e | 6444 | |
d62a17ae | 6445 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6446 | if (!peer) | |
6447 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6448 | |
dcc68b5e MS |
6449 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6450 | BGP_ADDPATH_ALL); | |
6451 | return CMD_SUCCESS; | |
adbac85e DW |
6452 | } |
6453 | ||
d62a17ae | 6454 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6455 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6456 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6457 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6458 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6459 | |
adbac85e DW |
6460 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6461 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6462 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6463 | NO_STR |
6464 | NEIGHBOR_STR | |
6465 | NEIGHBOR_ADDR_STR2 | |
6466 | "Use addpath to advertise all paths to a neighbor\n") | |
6467 | { | |
d62a17ae | 6468 | int idx_peer = 2; |
dcc68b5e MS |
6469 | struct peer *peer; |
6470 | ||
6471 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6472 | if (!peer) | |
6473 | return CMD_WARNING_CONFIG_FAILED; | |
6474 | ||
6475 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6476 | != BGP_ADDPATH_ALL) { | |
6477 | vty_out(vty, | |
6478 | "%% Peer not currently configured to transmit all paths."); | |
6479 | return CMD_WARNING_CONFIG_FAILED; | |
6480 | } | |
6481 | ||
6482 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6483 | BGP_ADDPATH_NONE); | |
6484 | ||
6485 | return CMD_SUCCESS; | |
adbac85e DW |
6486 | } |
6487 | ||
d62a17ae | 6488 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6489 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6490 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6491 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6492 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6493 | |
06370dac DW |
6494 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6495 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6496 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6497 | NEIGHBOR_STR |
6498 | NEIGHBOR_ADDR_STR2 | |
6499 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6500 | { | |
d62a17ae | 6501 | int idx_peer = 1; |
6502 | struct peer *peer; | |
06370dac | 6503 | |
d62a17ae | 6504 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6505 | if (!peer) | |
6506 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6507 | |
dcc68b5e MS |
6508 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6509 | BGP_ADDPATH_BEST_PER_AS); | |
6510 | ||
6511 | return CMD_SUCCESS; | |
06370dac DW |
6512 | } |
6513 | ||
d62a17ae | 6514 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6515 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6516 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6517 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6518 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6519 | |
06370dac DW |
6520 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6521 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6522 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6523 | NO_STR |
6524 | NEIGHBOR_STR | |
6525 | NEIGHBOR_ADDR_STR2 | |
6526 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6527 | { | |
d62a17ae | 6528 | int idx_peer = 2; |
dcc68b5e MS |
6529 | struct peer *peer; |
6530 | ||
6531 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6532 | if (!peer) | |
6533 | return CMD_WARNING_CONFIG_FAILED; | |
6534 | ||
6535 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6536 | != BGP_ADDPATH_BEST_PER_AS) { | |
6537 | vty_out(vty, | |
6538 | "%% Peer not currently configured to transmit all best path per as."); | |
6539 | return CMD_WARNING_CONFIG_FAILED; | |
6540 | } | |
6541 | ||
6542 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6543 | BGP_ADDPATH_NONE); | |
6544 | ||
6545 | return CMD_SUCCESS; | |
06370dac DW |
6546 | } |
6547 | ||
d62a17ae | 6548 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6549 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6550 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6551 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6552 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6553 | |
2b31007c RZ |
6554 | DEFPY( |
6555 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
6556 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
6557 | NEIGHBOR_STR | |
6558 | NEIGHBOR_ADDR_STR2 | |
6559 | "Detect AS loops before sending to neighbor\n") | |
6560 | { | |
6561 | struct peer *peer; | |
6562 | ||
6563 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6564 | if (!peer) | |
6565 | return CMD_WARNING_CONFIG_FAILED; | |
6566 | ||
6567 | peer->as_path_loop_detection = true; | |
6568 | ||
6569 | return CMD_SUCCESS; | |
6570 | } | |
6571 | ||
6572 | DEFPY( | |
6573 | no_neighbor_aspath_loop_detection, | |
6574 | no_neighbor_aspath_loop_detection_cmd, | |
6575 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
6576 | NO_STR | |
6577 | NEIGHBOR_STR | |
6578 | NEIGHBOR_ADDR_STR2 | |
6579 | "Detect AS loops before sending to neighbor\n") | |
6580 | { | |
6581 | struct peer *peer; | |
6582 | ||
6583 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6584 | if (!peer) | |
6585 | return CMD_WARNING_CONFIG_FAILED; | |
6586 | ||
6587 | peer->as_path_loop_detection = false; | |
6588 | ||
6589 | return CMD_SUCCESS; | |
6590 | } | |
6591 | ||
b9c7bc5a PZ |
6592 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6593 | struct ecommunity **list) | |
ddb5b488 | 6594 | { |
b9c7bc5a PZ |
6595 | struct ecommunity *ecom = NULL; |
6596 | struct ecommunity *ecomadd; | |
ddb5b488 | 6597 | |
b9c7bc5a | 6598 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6599 | |
b9c7bc5a PZ |
6600 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6601 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6602 | if (!ecomadd) { | |
6603 | vty_out(vty, "Malformed community-list value\n"); | |
6604 | if (ecom) | |
6605 | ecommunity_free(&ecom); | |
6606 | return CMD_WARNING_CONFIG_FAILED; | |
6607 | } | |
ddb5b488 | 6608 | |
b9c7bc5a PZ |
6609 | if (ecom) { |
6610 | ecommunity_merge(ecom, ecomadd); | |
6611 | ecommunity_free(&ecomadd); | |
6612 | } else { | |
6613 | ecom = ecomadd; | |
6614 | } | |
6615 | } | |
6616 | ||
6617 | if (*list) { | |
6618 | ecommunity_free(&*list); | |
ddb5b488 | 6619 | } |
b9c7bc5a PZ |
6620 | *list = ecom; |
6621 | ||
6622 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6623 | } |
6624 | ||
0ca70ba5 DS |
6625 | /* |
6626 | * v2vimport is true if we are handling a `import vrf ...` command | |
6627 | */ | |
6628 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6629 | { |
0ca70ba5 DS |
6630 | afi_t afi; |
6631 | ||
ddb5b488 | 6632 | switch (vty->node) { |
b9c7bc5a | 6633 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6634 | afi = AFI_IP; |
6635 | break; | |
b9c7bc5a | 6636 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6637 | afi = AFI_IP6; |
6638 | break; | |
ddb5b488 PZ |
6639 | default: |
6640 | vty_out(vty, | |
b9c7bc5a | 6641 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6642 | return AFI_MAX; |
ddb5b488 | 6643 | } |
69b07479 | 6644 | |
0ca70ba5 DS |
6645 | if (!v2vimport) { |
6646 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6647 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6648 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6649 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6650 | vty_out(vty, | |
6651 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6652 | return AFI_MAX; | |
6653 | } | |
6654 | } else { | |
6655 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6656 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6657 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6658 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6659 | vty_out(vty, | |
6660 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6661 | return AFI_MAX; | |
6662 | } | |
6663 | } | |
6664 | return afi; | |
ddb5b488 PZ |
6665 | } |
6666 | ||
b9c7bc5a PZ |
6667 | DEFPY (af_rd_vpn_export, |
6668 | af_rd_vpn_export_cmd, | |
6669 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6670 | NO_STR | |
ddb5b488 | 6671 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6672 | "Between current address-family and vpn\n" |
6673 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6674 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6675 | { | |
6676 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6677 | struct prefix_rd prd; | |
6678 | int ret; | |
ddb5b488 | 6679 | afi_t afi; |
b9c7bc5a PZ |
6680 | int idx = 0; |
6681 | int yes = 1; | |
ddb5b488 | 6682 | |
b9c7bc5a | 6683 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6684 | yes = 0; |
b9c7bc5a PZ |
6685 | |
6686 | if (yes) { | |
6687 | ret = str2prefix_rd(rd_str, &prd); | |
6688 | if (!ret) { | |
6689 | vty_out(vty, "%% Malformed rd\n"); | |
6690 | return CMD_WARNING_CONFIG_FAILED; | |
6691 | } | |
ddb5b488 PZ |
6692 | } |
6693 | ||
0ca70ba5 | 6694 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6695 | if (afi == AFI_MAX) |
6696 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6697 | |
69b07479 DS |
6698 | /* |
6699 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6700 | */ | |
6701 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6702 | bgp_get_default(), bgp); | |
ddb5b488 | 6703 | |
69b07479 DS |
6704 | if (yes) { |
6705 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6706 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6707 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6708 | } else { | |
6709 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6710 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6711 | } |
6712 | ||
69b07479 DS |
6713 | /* post-change: re-export vpn routes */ |
6714 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6715 | bgp_get_default(), bgp); | |
6716 | ||
ddb5b488 PZ |
6717 | return CMD_SUCCESS; |
6718 | } | |
6719 | ||
b9c7bc5a PZ |
6720 | ALIAS (af_rd_vpn_export, |
6721 | af_no_rd_vpn_export_cmd, | |
6722 | "no rd vpn export", | |
ddb5b488 | 6723 | NO_STR |
b9c7bc5a PZ |
6724 | "Specify route distinguisher\n" |
6725 | "Between current address-family and vpn\n" | |
6726 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6727 | |
b9c7bc5a PZ |
6728 | DEFPY (af_label_vpn_export, |
6729 | af_label_vpn_export_cmd, | |
e70e9f8e | 6730 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6731 | NO_STR |
ddb5b488 | 6732 | "label value for VRF\n" |
b9c7bc5a PZ |
6733 | "Between current address-family and vpn\n" |
6734 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6735 | "Label Value <0-1048575>\n" |
6736 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6737 | { |
6738 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6739 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6740 | afi_t afi; |
b9c7bc5a PZ |
6741 | int idx = 0; |
6742 | int yes = 1; | |
6743 | ||
6744 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6745 | yes = 0; |
ddb5b488 | 6746 | |
21a16cc2 PZ |
6747 | /* If "no ...", squash trailing parameter */ |
6748 | if (!yes) | |
6749 | label_auto = NULL; | |
6750 | ||
e70e9f8e PZ |
6751 | if (yes) { |
6752 | if (!label_auto) | |
6753 | label = label_val; /* parser should force unsigned */ | |
6754 | } | |
ddb5b488 | 6755 | |
0ca70ba5 | 6756 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6757 | if (afi == AFI_MAX) |
6758 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6759 | |
e70e9f8e | 6760 | |
69b07479 DS |
6761 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6762 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6763 | /* no change */ | |
6764 | return CMD_SUCCESS; | |
e70e9f8e | 6765 | |
69b07479 DS |
6766 | /* |
6767 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6768 | */ | |
6769 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6770 | bgp_get_default(), bgp); | |
6771 | ||
6772 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6773 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6774 | ||
6775 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6776 | ||
6777 | /* | |
6778 | * label has previously been automatically | |
6779 | * assigned by labelpool: release it | |
6780 | * | |
6781 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6782 | * means the automatic assignment is in flight | |
6783 | * and therefore the labelpool callback must | |
6784 | * detect that the auto label is not needed. | |
6785 | */ | |
6786 | ||
6787 | bgp_lp_release(LP_TYPE_VRF, | |
6788 | &bgp->vpn_policy[afi], | |
6789 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6790 | } |
69b07479 DS |
6791 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6792 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6793 | } | |
ddb5b488 | 6794 | |
69b07479 DS |
6795 | bgp->vpn_policy[afi].tovpn_label = label; |
6796 | if (label_auto) { | |
6797 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6798 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6799 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6800 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6801 | } |
6802 | ||
69b07479 DS |
6803 | /* post-change: re-export vpn routes */ |
6804 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6805 | bgp_get_default(), bgp); | |
6806 | ||
ddb5b488 PZ |
6807 | return CMD_SUCCESS; |
6808 | } | |
6809 | ||
b9c7bc5a PZ |
6810 | ALIAS (af_label_vpn_export, |
6811 | af_no_label_vpn_export_cmd, | |
6812 | "no label vpn export", | |
6813 | NO_STR | |
6814 | "label value for VRF\n" | |
6815 | "Between current address-family and vpn\n" | |
6816 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6817 | |
b9c7bc5a PZ |
6818 | DEFPY (af_nexthop_vpn_export, |
6819 | af_nexthop_vpn_export_cmd, | |
6820 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6821 | NO_STR | |
ddb5b488 | 6822 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6823 | "Between current address-family and vpn\n" |
6824 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6825 | "IPv4 prefix\n" |
6826 | "IPv6 prefix\n") | |
6827 | { | |
6828 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6829 | afi_t afi; |
ddb5b488 | 6830 | struct prefix p; |
b9c7bc5a PZ |
6831 | int idx = 0; |
6832 | int yes = 1; | |
ddb5b488 | 6833 | |
b9c7bc5a | 6834 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6835 | yes = 0; |
b9c7bc5a PZ |
6836 | |
6837 | if (yes) { | |
6838 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6839 | return CMD_WARNING_CONFIG_FAILED; | |
6840 | } | |
ddb5b488 | 6841 | |
0ca70ba5 | 6842 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6843 | if (afi == AFI_MAX) |
6844 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6845 | |
69b07479 DS |
6846 | /* |
6847 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6848 | */ | |
6849 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6850 | bgp_get_default(), bgp); | |
ddb5b488 | 6851 | |
69b07479 DS |
6852 | if (yes) { |
6853 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6854 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6855 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6856 | } else { | |
6857 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6858 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6859 | } |
6860 | ||
69b07479 DS |
6861 | /* post-change: re-export vpn routes */ |
6862 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6863 | bgp_get_default(), bgp); | |
6864 | ||
ddb5b488 PZ |
6865 | return CMD_SUCCESS; |
6866 | } | |
6867 | ||
b9c7bc5a PZ |
6868 | ALIAS (af_nexthop_vpn_export, |
6869 | af_no_nexthop_vpn_export_cmd, | |
6870 | "no nexthop vpn export", | |
ddb5b488 | 6871 | NO_STR |
b9c7bc5a PZ |
6872 | "Specify next hop to use for VRF advertised prefixes\n" |
6873 | "Between current address-family and vpn\n" | |
6874 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6875 | |
b9c7bc5a | 6876 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6877 | { |
b9c7bc5a PZ |
6878 | if (!strcmp(dstr, "import")) { |
6879 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6880 | } else if (!strcmp(dstr, "export")) { | |
6881 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6882 | } else if (!strcmp(dstr, "both")) { | |
6883 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6884 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6885 | } else { | |
6886 | vty_out(vty, "%% direction parse error\n"); | |
6887 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6888 | } |
ddb5b488 PZ |
6889 | return CMD_SUCCESS; |
6890 | } | |
6891 | ||
b9c7bc5a PZ |
6892 | DEFPY (af_rt_vpn_imexport, |
6893 | af_rt_vpn_imexport_cmd, | |
6894 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6895 | NO_STR | |
6896 | "Specify route target list\n" | |
ddb5b488 | 6897 | "Specify route target list\n" |
b9c7bc5a PZ |
6898 | "Between current address-family and vpn\n" |
6899 | "For routes leaked from vpn to current address-family: match any\n" | |
6900 | "For routes leaked from current address-family to vpn: set\n" | |
6901 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6902 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6903 | { | |
6904 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6905 | int ret; | |
6906 | struct ecommunity *ecom = NULL; | |
6907 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6908 | vpn_policy_direction_t dir; |
6909 | afi_t afi; | |
6910 | int idx = 0; | |
b9c7bc5a | 6911 | int yes = 1; |
ddb5b488 | 6912 | |
b9c7bc5a | 6913 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6914 | yes = 0; |
b9c7bc5a | 6915 | |
0ca70ba5 | 6916 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6917 | if (afi == AFI_MAX) |
6918 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6919 | |
b9c7bc5a | 6920 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6921 | if (ret != CMD_SUCCESS) |
6922 | return ret; | |
6923 | ||
b9c7bc5a PZ |
6924 | if (yes) { |
6925 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6926 | vty_out(vty, "%% Missing RTLIST\n"); | |
6927 | return CMD_WARNING_CONFIG_FAILED; | |
6928 | } | |
6929 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6930 | if (ret != CMD_SUCCESS) { | |
6931 | return ret; | |
6932 | } | |
ddb5b488 PZ |
6933 | } |
6934 | ||
69b07479 DS |
6935 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6936 | if (!dodir[dir]) | |
ddb5b488 | 6937 | continue; |
ddb5b488 | 6938 | |
69b07479 | 6939 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6940 | |
69b07479 DS |
6941 | if (yes) { |
6942 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6943 | ecommunity_free( | |
6944 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6945 | bgp->vpn_policy[afi].rtlist[dir] = | |
6946 | ecommunity_dup(ecom); | |
6947 | } else { | |
6948 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6949 | ecommunity_free( | |
6950 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6951 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6952 | } |
69b07479 DS |
6953 | |
6954 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6955 | } |
69b07479 | 6956 | |
d555f3e9 PZ |
6957 | if (ecom) |
6958 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6959 | |
6960 | return CMD_SUCCESS; | |
6961 | } | |
6962 | ||
b9c7bc5a PZ |
6963 | ALIAS (af_rt_vpn_imexport, |
6964 | af_no_rt_vpn_imexport_cmd, | |
6965 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6966 | NO_STR |
6967 | "Specify route target list\n" | |
b9c7bc5a PZ |
6968 | "Specify route target list\n" |
6969 | "Between current address-family and vpn\n" | |
6970 | "For routes leaked from vpn to current address-family\n" | |
6971 | "For routes leaked from current address-family to vpn\n" | |
6972 | "both import and export\n") | |
6973 | ||
6974 | DEFPY (af_route_map_vpn_imexport, | |
6975 | af_route_map_vpn_imexport_cmd, | |
6976 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6977 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6978 | NO_STR | |
ddb5b488 | 6979 | "Specify route map\n" |
b9c7bc5a PZ |
6980 | "Between current address-family and vpn\n" |
6981 | "For routes leaked from vpn to current address-family\n" | |
6982 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6983 | "name of route-map\n") |
6984 | { | |
6985 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6986 | int ret; | |
6987 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6988 | vpn_policy_direction_t dir; |
6989 | afi_t afi; | |
ddb5b488 | 6990 | int idx = 0; |
b9c7bc5a | 6991 | int yes = 1; |
ddb5b488 | 6992 | |
b9c7bc5a | 6993 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6994 | yes = 0; |
b9c7bc5a | 6995 | |
0ca70ba5 | 6996 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6997 | if (afi == AFI_MAX) |
6998 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6999 | |
b9c7bc5a | 7000 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7001 | if (ret != CMD_SUCCESS) |
7002 | return ret; | |
7003 | ||
69b07479 DS |
7004 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7005 | if (!dodir[dir]) | |
ddb5b488 | 7006 | continue; |
ddb5b488 | 7007 | |
69b07479 | 7008 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7009 | |
69b07479 DS |
7010 | if (yes) { |
7011 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7012 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7013 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7014 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7015 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7016 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7017 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7018 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7019 | return CMD_SUCCESS; | |
7020 | } else { | |
7021 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7022 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7023 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7024 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7025 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7026 | } |
69b07479 DS |
7027 | |
7028 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7029 | } |
7030 | ||
7031 | return CMD_SUCCESS; | |
7032 | } | |
7033 | ||
b9c7bc5a PZ |
7034 | ALIAS (af_route_map_vpn_imexport, |
7035 | af_no_route_map_vpn_imexport_cmd, | |
7036 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7037 | NO_STR |
7038 | "Specify route map\n" | |
b9c7bc5a PZ |
7039 | "Between current address-family and vpn\n" |
7040 | "For routes leaked from vpn to current address-family\n" | |
7041 | "For routes leaked from current address-family to vpn\n") | |
7042 | ||
bb4f6190 DS |
7043 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
7044 | "[no] import vrf route-map RMAP$rmap_str", | |
7045 | NO_STR | |
7046 | "Import routes from another VRF\n" | |
7047 | "Vrf routes being filtered\n" | |
7048 | "Specify route map\n" | |
7049 | "name of route-map\n") | |
7050 | { | |
7051 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7052 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7053 | afi_t afi; | |
7054 | int idx = 0; | |
7055 | int yes = 1; | |
7056 | struct bgp *bgp_default; | |
7057 | ||
7058 | if (argv_find(argv, argc, "no", &idx)) | |
7059 | yes = 0; | |
7060 | ||
0ca70ba5 | 7061 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7062 | if (afi == AFI_MAX) |
7063 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7064 | |
7065 | bgp_default = bgp_get_default(); | |
7066 | if (!bgp_default) { | |
7067 | int32_t ret; | |
7068 | as_t as = bgp->as; | |
7069 | ||
7070 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7071 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7072 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7073 | |
7074 | if (ret) { | |
7075 | vty_out(vty, | |
7076 | "VRF default is not configured as a bgp instance\n"); | |
7077 | return CMD_WARNING; | |
7078 | } | |
7079 | } | |
7080 | ||
69b07479 | 7081 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7082 | |
69b07479 DS |
7083 | if (yes) { |
7084 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7085 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7086 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7087 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7088 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7089 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7090 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7091 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7092 | return CMD_SUCCESS; | |
7093 | } else { | |
7094 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7095 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7096 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7097 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7098 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
7099 | } |
7100 | ||
69b07479 DS |
7101 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7102 | ||
bb4f6190 DS |
7103 | return CMD_SUCCESS; |
7104 | } | |
7105 | ||
7106 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
7107 | "no import vrf route-map", | |
7108 | NO_STR | |
7109 | "Import routes from another VRF\n" | |
7110 | "Vrf routes being filtered\n" | |
7111 | "Specify route map\n") | |
7112 | ||
4d1b335c DA |
7113 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7114 | "[no] import vrf VIEWVRFNAME$import_name", | |
7115 | NO_STR | |
7116 | "Import routes from another VRF\n" | |
7117 | "VRF to import from\n" | |
7118 | "The name of the VRF\n") | |
12a844a5 DS |
7119 | { |
7120 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7121 | struct listnode *node; | |
79ef8664 DS |
7122 | struct bgp *vrf_bgp, *bgp_default; |
7123 | int32_t ret = 0; | |
7124 | as_t as = bgp->as; | |
12a844a5 DS |
7125 | bool remove = false; |
7126 | int32_t idx = 0; | |
7127 | char *vname; | |
a8dadcf6 | 7128 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7129 | safi_t safi; |
7130 | afi_t afi; | |
7131 | ||
867f0cca | 7132 | if (import_name == NULL) { |
7133 | vty_out(vty, "%% Missing import name\n"); | |
7134 | return CMD_WARNING; | |
7135 | } | |
7136 | ||
12a844a5 DS |
7137 | if (argv_find(argv, argc, "no", &idx)) |
7138 | remove = true; | |
7139 | ||
0ca70ba5 DS |
7140 | afi = vpn_policy_getafi(vty, bgp, true); |
7141 | if (afi == AFI_MAX) | |
7142 | return CMD_WARNING_CONFIG_FAILED; | |
7143 | ||
12a844a5 DS |
7144 | safi = bgp_node_safi(vty); |
7145 | ||
25679caa | 7146 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7147 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7148 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7149 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7150 | remove ? "unimport" : "import", import_name); | |
7151 | return CMD_WARNING; | |
7152 | } | |
7153 | ||
79ef8664 DS |
7154 | bgp_default = bgp_get_default(); |
7155 | if (!bgp_default) { | |
7156 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7157 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7158 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7159 | |
7160 | if (ret) { | |
7161 | vty_out(vty, | |
7162 | "VRF default is not configured as a bgp instance\n"); | |
7163 | return CMD_WARNING; | |
7164 | } | |
7165 | } | |
7166 | ||
12a844a5 DS |
7167 | vrf_bgp = bgp_lookup_by_name(import_name); |
7168 | if (!vrf_bgp) { | |
5742e42b | 7169 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7170 | vrf_bgp = bgp_default; |
7171 | else | |
0fb8d6e6 | 7172 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7173 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7174 | |
6e2c7fe6 | 7175 | if (ret) { |
020a3f60 DS |
7176 | vty_out(vty, |
7177 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7178 | import_name); |
7179 | return CMD_WARNING; | |
7180 | } | |
12a844a5 DS |
7181 | } |
7182 | ||
12a844a5 | 7183 | if (remove) { |
44338987 | 7184 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7185 | } else { |
44338987 | 7186 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7187 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7188 | vname)) { | |
7189 | if (strcmp(vname, import_name) == 0) | |
7190 | return CMD_WARNING; | |
7191 | } | |
7192 | ||
44338987 | 7193 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7194 | } |
7195 | ||
7196 | return CMD_SUCCESS; | |
7197 | } | |
7198 | ||
b9c7bc5a PZ |
7199 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7200 | DEFPY (bgp_imexport_vpn, | |
7201 | bgp_imexport_vpn_cmd, | |
7202 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7203 | NO_STR |
7204 | "Import routes to this address-family\n" | |
7205 | "Export routes from this address-family\n" | |
7206 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7207 | { |
7208 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7209 | int previous_state; |
ddb5b488 | 7210 | afi_t afi; |
b9c7bc5a | 7211 | safi_t safi; |
ddb5b488 | 7212 | int idx = 0; |
b9c7bc5a PZ |
7213 | int yes = 1; |
7214 | int flag; | |
7215 | vpn_policy_direction_t dir; | |
ddb5b488 | 7216 | |
b9c7bc5a | 7217 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7218 | yes = 0; |
ddb5b488 | 7219 | |
b9c7bc5a PZ |
7220 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7221 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7222 | |
b9c7bc5a PZ |
7223 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7224 | return CMD_WARNING_CONFIG_FAILED; | |
7225 | } | |
ddb5b488 | 7226 | |
b9c7bc5a PZ |
7227 | afi = bgp_node_afi(vty); |
7228 | safi = bgp_node_safi(vty); | |
7229 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7230 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7231 | return CMD_WARNING_CONFIG_FAILED; | |
7232 | } | |
ddb5b488 | 7233 | |
b9c7bc5a PZ |
7234 | if (!strcmp(direction_str, "import")) { |
7235 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7236 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7237 | } else if (!strcmp(direction_str, "export")) { | |
7238 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7239 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7240 | } else { | |
7241 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7242 | return CMD_WARNING_CONFIG_FAILED; | |
7243 | } | |
7244 | ||
7245 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7246 | |
b9c7bc5a PZ |
7247 | if (yes) { |
7248 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7249 | if (!previous_state) { | |
7250 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7251 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7252 | } | |
b9c7bc5a PZ |
7253 | } else { |
7254 | if (previous_state) { | |
7255 | /* trigger un-export current vrf */ | |
7256 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7257 | } | |
7258 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7259 | } |
7260 | ||
7261 | return CMD_SUCCESS; | |
7262 | } | |
7263 | ||
301ad80a PG |
7264 | DEFPY (af_routetarget_import, |
7265 | af_routetarget_import_cmd, | |
7266 | "[no] <rt|route-target> redirect import RTLIST...", | |
7267 | NO_STR | |
7268 | "Specify route target list\n" | |
7269 | "Specify route target list\n" | |
7270 | "Flow-spec redirect type route target\n" | |
7271 | "Import routes to this address-family\n" | |
7272 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7273 | { | |
7274 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7275 | int ret; | |
7276 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7277 | afi_t afi; |
7278 | int idx = 0; | |
7279 | int yes = 1; | |
7280 | ||
7281 | if (argv_find(argv, argc, "no", &idx)) | |
7282 | yes = 0; | |
7283 | ||
0ca70ba5 | 7284 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7285 | if (afi == AFI_MAX) |
7286 | return CMD_WARNING_CONFIG_FAILED; | |
7287 | ||
301ad80a PG |
7288 | if (yes) { |
7289 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7290 | vty_out(vty, "%% Missing RTLIST\n"); | |
7291 | return CMD_WARNING_CONFIG_FAILED; | |
7292 | } | |
7293 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7294 | if (ret != CMD_SUCCESS) | |
7295 | return ret; | |
7296 | } | |
69b07479 DS |
7297 | |
7298 | if (yes) { | |
7299 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7300 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7301 | .import_redirect_rtlist); |
69b07479 DS |
7302 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7303 | ecommunity_dup(ecom); | |
7304 | } else { | |
7305 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7306 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7307 | .import_redirect_rtlist); |
69b07479 | 7308 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7309 | } |
69b07479 | 7310 | |
301ad80a PG |
7311 | if (ecom) |
7312 | ecommunity_free(&ecom); | |
7313 | ||
7314 | return CMD_SUCCESS; | |
7315 | } | |
7316 | ||
505e5056 | 7317 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7318 | address_family_ipv4_safi_cmd, |
7319 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7320 | "Enter Address Family command mode\n" | |
7321 | "Address Family\n" | |
7322 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7323 | { |
f51bae9c | 7324 | |
d62a17ae | 7325 | if (argc == 3) { |
2131d5cf | 7326 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7327 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7328 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7329 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7330 | && safi != SAFI_EVPN) { |
31947174 MK |
7331 | vty_out(vty, |
7332 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7333 | return CMD_WARNING_CONFIG_FAILED; |
7334 | } | |
d62a17ae | 7335 | vty->node = bgp_node_type(AFI_IP, safi); |
7336 | } else | |
7337 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7338 | |
d62a17ae | 7339 | return CMD_SUCCESS; |
718e3744 | 7340 | } |
7341 | ||
505e5056 | 7342 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7343 | address_family_ipv6_safi_cmd, |
7344 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7345 | "Enter Address Family command mode\n" | |
7346 | "Address Family\n" | |
7347 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7348 | { |
d62a17ae | 7349 | if (argc == 3) { |
2131d5cf | 7350 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7351 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7352 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7353 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7354 | && safi != SAFI_EVPN) { |
31947174 MK |
7355 | vty_out(vty, |
7356 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7357 | return CMD_WARNING_CONFIG_FAILED; |
7358 | } | |
d62a17ae | 7359 | vty->node = bgp_node_type(AFI_IP6, safi); |
7360 | } else | |
7361 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7362 | |
d62a17ae | 7363 | return CMD_SUCCESS; |
25ffbdc1 | 7364 | } |
718e3744 | 7365 | |
d6902373 | 7366 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7367 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7368 | address_family_vpnv4_cmd, |
8334fd5a | 7369 | "address-family vpnv4 [unicast]", |
718e3744 | 7370 | "Enter Address Family command mode\n" |
8c3deaae | 7371 | "Address Family\n" |
3a2d747c | 7372 | "Address Family modifier\n") |
718e3744 | 7373 | { |
d62a17ae | 7374 | vty->node = BGP_VPNV4_NODE; |
7375 | return CMD_SUCCESS; | |
718e3744 | 7376 | } |
7377 | ||
505e5056 | 7378 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7379 | address_family_vpnv6_cmd, |
8334fd5a | 7380 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7381 | "Enter Address Family command mode\n" |
8c3deaae | 7382 | "Address Family\n" |
3a2d747c | 7383 | "Address Family modifier\n") |
8ecd3266 | 7384 | { |
d62a17ae | 7385 | vty->node = BGP_VPNV6_NODE; |
7386 | return CMD_SUCCESS; | |
8ecd3266 | 7387 | } |
64e4a6c5 | 7388 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7389 | |
505e5056 | 7390 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7391 | address_family_evpn_cmd, |
7111c1a0 | 7392 | "address-family l2vpn evpn", |
4e0b7b6d | 7393 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7394 | "Address Family\n" |
7395 | "Address Family modifier\n") | |
4e0b7b6d | 7396 | { |
2131d5cf | 7397 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7398 | vty->node = BGP_EVPN_NODE; |
7399 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7400 | } |
7401 | ||
505e5056 | 7402 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7403 | exit_address_family_cmd, |
7404 | "exit-address-family", | |
7405 | "Exit from Address Family configuration mode\n") | |
7406 | { | |
d62a17ae | 7407 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7408 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7409 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7410 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7411 | || vty->node == BGP_EVPN_NODE |
7412 | || vty->node == BGP_FLOWSPECV4_NODE | |
7413 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7414 | vty->node = BGP_NODE; |
7415 | return CMD_SUCCESS; | |
718e3744 | 7416 | } |
6b0655a2 | 7417 | |
8ad7271d | 7418 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7419 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7420 | const char *ip_str, afi_t afi, safi_t safi, | |
7421 | struct prefix_rd *prd) | |
7422 | { | |
7423 | int ret; | |
7424 | struct prefix match; | |
7425 | struct bgp_node *rn; | |
7426 | struct bgp_node *rm; | |
7427 | struct bgp *bgp; | |
7428 | struct bgp_table *table; | |
7429 | struct bgp_table *rib; | |
7430 | ||
7431 | /* BGP structure lookup. */ | |
7432 | if (view_name) { | |
7433 | bgp = bgp_lookup_by_name(view_name); | |
7434 | if (bgp == NULL) { | |
7435 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7436 | view_name); | |
7437 | return CMD_WARNING; | |
7438 | } | |
7439 | } else { | |
7440 | bgp = bgp_get_default(); | |
7441 | if (bgp == NULL) { | |
7442 | vty_out(vty, "%% No BGP process is configured\n"); | |
7443 | return CMD_WARNING; | |
7444 | } | |
7445 | } | |
7446 | ||
7447 | /* Check IP address argument. */ | |
7448 | ret = str2prefix(ip_str, &match); | |
7449 | if (!ret) { | |
7450 | vty_out(vty, "%% address is malformed\n"); | |
7451 | return CMD_WARNING; | |
7452 | } | |
7453 | ||
7454 | match.family = afi2family(afi); | |
7455 | rib = bgp->rib[afi][safi]; | |
7456 | ||
7457 | if (safi == SAFI_MPLS_VPN) { | |
7458 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7459 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7460 | continue; | |
7461 | ||
67009e22 DS |
7462 | table = bgp_node_get_bgp_table_info(rn); |
7463 | if (table != NULL) { | |
7464 | ||
d62a17ae | 7465 | if ((rm = bgp_node_match(table, &match)) |
7466 | != NULL) { | |
7467 | if (rm->p.prefixlen | |
7468 | == match.prefixlen) { | |
343cdb61 | 7469 | SET_FLAG(rm->flags, |
d62a17ae | 7470 | BGP_NODE_USER_CLEAR); |
7471 | bgp_process(bgp, rm, afi, safi); | |
7472 | } | |
7473 | bgp_unlock_node(rm); | |
7474 | } | |
7475 | } | |
7476 | } | |
7477 | } else { | |
7478 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7479 | if (rn->p.prefixlen == match.prefixlen) { | |
7480 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7481 | bgp_process(bgp, rn, afi, safi); | |
7482 | } | |
7483 | bgp_unlock_node(rn); | |
7484 | } | |
7485 | } | |
7486 | ||
7487 | return CMD_SUCCESS; | |
8ad7271d DS |
7488 | } |
7489 | ||
b09b5ae0 | 7490 | /* one clear bgp command to rule them all */ |
718e3744 | 7491 | DEFUN (clear_ip_bgp_all, |
7492 | clear_ip_bgp_all_cmd, | |
453c92f6 | 7493 | "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 | 7494 | CLEAR_STR |
7495 | IP_STR | |
7496 | BGP_STR | |
838758ac | 7497 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7498 | BGP_AFI_HELP_STR |
fd5e7b70 | 7499 | "Address Family\n" |
510afcd6 | 7500 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7501 | "Address Family modifier\n" |
b09b5ae0 | 7502 | "Clear all peers\n" |
453c92f6 | 7503 | "BGP IPv4 neighbor to clear\n" |
a80beece | 7504 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7505 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7506 | "Clear peers with the AS number\n" |
7507 | "Clear all external peers\n" | |
718e3744 | 7508 | "Clear all members of peer-group\n" |
b09b5ae0 | 7509 | "BGP peer-group name\n" |
b09b5ae0 DW |
7510 | BGP_SOFT_STR |
7511 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7512 | BGP_SOFT_OUT_STR |
7513 | BGP_SOFT_IN_STR | |
7514 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7515 | BGP_SOFT_OUT_STR) |
718e3744 | 7516 | { |
d62a17ae | 7517 | char *vrf = NULL; |
7518 | ||
dc912615 DS |
7519 | afi_t afi = AFI_UNSPEC; |
7520 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 7521 | enum clear_sort clr_sort = clear_peer; |
7522 | enum bgp_clear_type clr_type; | |
7523 | char *clr_arg = NULL; | |
7524 | ||
7525 | int idx = 0; | |
7526 | ||
7527 | /* clear [ip] bgp */ | |
7528 | if (argv_find(argv, argc, "ip", &idx)) | |
7529 | afi = AFI_IP; | |
7530 | ||
9a8bdf1c PG |
7531 | /* [<vrf> VIEWVRFNAME] */ |
7532 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7533 | vrf = argv[idx + 1]->arg; | |
7534 | idx += 2; | |
7535 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7536 | vrf = NULL; | |
7537 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7538 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7539 | vrf = argv[idx + 1]->arg; |
7540 | idx += 2; | |
7541 | } | |
d62a17ae | 7542 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7543 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7544 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7545 | ||
d7b9898c | 7546 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 7547 | if (argv_find(argv, argc, "*", &idx)) { |
7548 | clr_sort = clear_all; | |
7549 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7550 | clr_sort = clear_peer; | |
7551 | clr_arg = argv[idx]->arg; | |
7552 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7553 | clr_sort = clear_peer; | |
7554 | clr_arg = argv[idx]->arg; | |
7555 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7556 | clr_sort = clear_group; | |
7557 | idx++; | |
7558 | clr_arg = argv[idx]->arg; | |
d7b9898c | 7559 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 7560 | clr_sort = clear_peer; |
7561 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
7562 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
7563 | clr_sort = clear_peer; | |
7564 | clr_arg = argv[idx]->arg; | |
d62a17ae | 7565 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
7566 | clr_sort = clear_as; | |
7567 | clr_arg = argv[idx]->arg; | |
7568 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7569 | clr_sort = clear_external; | |
7570 | } | |
7571 | ||
7572 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7573 | if (argv_find(argv, argc, "soft", &idx)) { | |
7574 | if (argv_find(argv, argc, "in", &idx) | |
7575 | || argv_find(argv, argc, "out", &idx)) | |
7576 | clr_type = strmatch(argv[idx]->text, "in") | |
7577 | ? BGP_CLEAR_SOFT_IN | |
7578 | : BGP_CLEAR_SOFT_OUT; | |
7579 | else | |
7580 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7581 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7582 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7583 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7584 | : BGP_CLEAR_SOFT_IN; | |
7585 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7586 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7587 | } else | |
7588 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7589 | ||
7590 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7591 | } |
01080f7c | 7592 | |
8ad7271d DS |
7593 | DEFUN (clear_ip_bgp_prefix, |
7594 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7595 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7596 | CLEAR_STR |
7597 | IP_STR | |
7598 | BGP_STR | |
838758ac | 7599 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7600 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7601 | "IPv4 prefix\n") |
8ad7271d | 7602 | { |
d62a17ae | 7603 | char *vrf = NULL; |
7604 | char *prefix = NULL; | |
8ad7271d | 7605 | |
d62a17ae | 7606 | int idx = 0; |
01080f7c | 7607 | |
d62a17ae | 7608 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7609 | if (argv_find(argv, argc, "vrf", &idx)) { |
7610 | vrf = argv[idx + 1]->arg; | |
7611 | idx += 2; | |
7612 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7613 | vrf = NULL; | |
7614 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7615 | /* [<view> VIEWVRFNAME] */ | |
7616 | vrf = argv[idx + 1]->arg; | |
7617 | idx += 2; | |
7618 | } | |
0c7b1b01 | 7619 | |
d62a17ae | 7620 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7621 | |
d62a17ae | 7622 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7623 | } |
8ad7271d | 7624 | |
b09b5ae0 DW |
7625 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7626 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7627 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7628 | CLEAR_STR |
3a2d747c | 7629 | IP_STR |
718e3744 | 7630 | BGP_STR |
8c3deaae | 7631 | "Address Family\n" |
46f296b4 | 7632 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7633 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7634 | "IPv6 prefix\n") |
718e3744 | 7635 | { |
9b475e76 PG |
7636 | int idx_safi = 0; |
7637 | int idx_ipv6_prefix = 0; | |
7638 | safi_t safi = SAFI_UNICAST; | |
7639 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7640 | argv[idx_ipv6_prefix]->arg : NULL; | |
7641 | ||
7642 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7643 | return bgp_clear_prefix( |
9b475e76 PG |
7644 | vty, NULL, prefix, AFI_IP6, |
7645 | safi, NULL); | |
838758ac | 7646 | } |
01080f7c | 7647 | |
b09b5ae0 DW |
7648 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7649 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7650 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7651 | CLEAR_STR |
3a2d747c | 7652 | IP_STR |
718e3744 | 7653 | BGP_STR |
838758ac | 7654 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7655 | "Address Family\n" |
46f296b4 | 7656 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7657 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7658 | "IPv6 prefix\n") |
718e3744 | 7659 | { |
9b475e76 | 7660 | int idx_safi = 0; |
9a8bdf1c | 7661 | int idx_vrfview = 0; |
9b475e76 PG |
7662 | int idx_ipv6_prefix = 0; |
7663 | safi_t safi = SAFI_UNICAST; | |
7664 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7665 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 7666 | char *vrfview = NULL; |
9b475e76 | 7667 | |
9a8bdf1c PG |
7668 | /* [<view|vrf> VIEWVRFNAME] */ |
7669 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
7670 | vrfview = argv[idx_vrfview + 1]->arg; | |
7671 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
7672 | vrfview = NULL; | |
7673 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
7674 | /* [<view> VIEWVRFNAME] */ | |
7675 | vrfview = argv[idx_vrfview + 1]->arg; | |
7676 | } | |
9b475e76 PG |
7677 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
7678 | ||
d62a17ae | 7679 | return bgp_clear_prefix( |
9b475e76 PG |
7680 | vty, vrfview, prefix, |
7681 | AFI_IP6, safi, NULL); | |
718e3744 | 7682 | } |
7683 | ||
b09b5ae0 DW |
7684 | DEFUN (show_bgp_views, |
7685 | show_bgp_views_cmd, | |
d6e3c605 | 7686 | "show [ip] bgp views", |
b09b5ae0 | 7687 | SHOW_STR |
d6e3c605 | 7688 | IP_STR |
01080f7c | 7689 | BGP_STR |
b09b5ae0 | 7690 | "Show the defined BGP views\n") |
01080f7c | 7691 | { |
d62a17ae | 7692 | struct list *inst = bm->bgp; |
7693 | struct listnode *node; | |
7694 | struct bgp *bgp; | |
01080f7c | 7695 | |
d62a17ae | 7696 | vty_out(vty, "Defined BGP views:\n"); |
7697 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7698 | /* Skip VRFs. */ | |
7699 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7700 | continue; | |
7701 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7702 | bgp->as); | |
7703 | } | |
e52702f2 | 7704 | |
d62a17ae | 7705 | return CMD_SUCCESS; |
e0081f70 ML |
7706 | } |
7707 | ||
8386ac43 | 7708 | DEFUN (show_bgp_vrfs, |
7709 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7710 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7711 | SHOW_STR |
d6e3c605 | 7712 | IP_STR |
8386ac43 | 7713 | BGP_STR |
7714 | "Show BGP VRFs\n" | |
9973d184 | 7715 | JSON_STR) |
8386ac43 | 7716 | { |
fe1dc5a3 | 7717 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7718 | struct list *inst = bm->bgp; |
7719 | struct listnode *node; | |
7720 | struct bgp *bgp; | |
9f049418 | 7721 | bool uj = use_json(argc, argv); |
d62a17ae | 7722 | json_object *json = NULL; |
7723 | json_object *json_vrfs = NULL; | |
7724 | int count = 0; | |
d62a17ae | 7725 | |
d62a17ae | 7726 | if (uj) { |
7727 | json = json_object_new_object(); | |
7728 | json_vrfs = json_object_new_object(); | |
7729 | } | |
7730 | ||
7731 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7732 | const char *name, *type; | |
7733 | struct peer *peer; | |
7fe96307 | 7734 | struct listnode *node2, *nnode2; |
d62a17ae | 7735 | int peers_cfg, peers_estb; |
7736 | json_object *json_vrf = NULL; | |
d62a17ae | 7737 | |
7738 | /* Skip Views. */ | |
7739 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7740 | continue; | |
7741 | ||
7742 | count++; | |
efb4077a | 7743 | if (!uj && count == 1) { |
fe1dc5a3 | 7744 | vty_out(vty, |
efb4077a | 7745 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 7746 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
7747 | "#PeersEstb", "Name"); |
7748 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
7749 | "L3-VNI", "RouterMAC", "Interface"); | |
7750 | } | |
d62a17ae | 7751 | |
7752 | peers_cfg = peers_estb = 0; | |
7753 | if (uj) | |
7754 | json_vrf = json_object_new_object(); | |
7755 | ||
7756 | ||
7fe96307 | 7757 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 7758 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7759 | continue; | |
7760 | peers_cfg++; | |
7761 | if (peer->status == Established) | |
7762 | peers_estb++; | |
7763 | } | |
7764 | ||
7765 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 7766 | name = VRF_DEFAULT_NAME; |
d62a17ae | 7767 | type = "DFLT"; |
7768 | } else { | |
7769 | name = bgp->name; | |
7770 | type = "VRF"; | |
7771 | } | |
7772 | ||
a8bf7d9c | 7773 | |
d62a17ae | 7774 | if (uj) { |
a4d82a8a PZ |
7775 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7776 | ? -1 | |
7777 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7778 | json_object_string_add(json_vrf, "type", type); |
7779 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7780 | json_object_string_add(json_vrf, "routerId", | |
7781 | inet_ntoa(bgp->router_id)); | |
7782 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7783 | peers_cfg); | |
7784 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7785 | peers_estb); | |
7786 | ||
fe1dc5a3 | 7787 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7788 | json_object_string_add( |
7789 | json_vrf, "rmac", | |
7790 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
7791 | json_object_string_add(json_vrf, "interface", |
7792 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7793 | bgp->vrf_id)); | |
d62a17ae | 7794 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 7795 | } else { |
fe1dc5a3 | 7796 | vty_out(vty, |
efb4077a | 7797 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
7798 | type, |
7799 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7800 | : (int)bgp->vrf_id, | |
7801 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
7802 | peers_estb, name); |
7803 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
7804 | bgp->l3vni, | |
7805 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
7806 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7807 | bgp->vrf_id)); | |
7808 | } | |
d62a17ae | 7809 | } |
7810 | ||
7811 | if (uj) { | |
7812 | json_object_object_add(json, "vrfs", json_vrfs); | |
7813 | ||
7814 | json_object_int_add(json, "totalVrfs", count); | |
7815 | ||
996c9314 LB |
7816 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7817 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7818 | json_object_free(json); |
7819 | } else { | |
7820 | if (count) | |
7821 | vty_out(vty, | |
7822 | "\nTotal number of VRFs (including default): %d\n", | |
7823 | count); | |
7824 | } | |
7825 | ||
7826 | return CMD_SUCCESS; | |
8386ac43 | 7827 | } |
7828 | ||
48ecf8f5 DS |
7829 | DEFUN (show_bgp_mac_hash, |
7830 | show_bgp_mac_hash_cmd, | |
7831 | "show bgp mac hash", | |
7832 | SHOW_STR | |
7833 | BGP_STR | |
7834 | "Mac Address\n" | |
7835 | "Mac Address database\n") | |
7836 | { | |
7837 | bgp_mac_dump_table(vty); | |
7838 | ||
7839 | return CMD_SUCCESS; | |
7840 | } | |
acf71666 | 7841 | |
e3b78da8 | 7842 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 7843 | { |
0291c246 | 7844 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 7845 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 7846 | |
60466a63 | 7847 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7848 | tip->refcnt); |
7849 | } | |
7850 | ||
7851 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7852 | { | |
7853 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 7854 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
7855 | |
7856 | vty_out(vty, "Tunnel-ip database:\n"); | |
7857 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 7858 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
7859 | vty); |
7860 | } | |
7861 | ||
15c81ca4 DS |
7862 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7863 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7864 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7865 | "martian next-hops\n" |
7866 | "martian next-hop database\n") | |
acf71666 | 7867 | { |
0291c246 | 7868 | struct bgp *bgp = NULL; |
15c81ca4 | 7869 | int idx = 0; |
9a8bdf1c PG |
7870 | char *name = NULL; |
7871 | ||
7872 | /* [<vrf> VIEWVRFNAME] */ | |
7873 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7874 | name = argv[idx + 1]->arg; | |
7875 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
7876 | name = NULL; | |
7877 | } else if (argv_find(argv, argc, "view", &idx)) | |
7878 | /* [<view> VIEWVRFNAME] */ | |
7879 | name = argv[idx + 1]->arg; | |
7880 | if (name) | |
7881 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
7882 | else |
7883 | bgp = bgp_get_default(); | |
acf71666 | 7884 | |
acf71666 MK |
7885 | if (!bgp) { |
7886 | vty_out(vty, "%% No BGP process is configured\n"); | |
7887 | return CMD_WARNING; | |
7888 | } | |
7889 | bgp_show_martian_nexthops(vty, bgp); | |
7890 | ||
7891 | return CMD_SUCCESS; | |
7892 | } | |
7893 | ||
f412b39a | 7894 | DEFUN (show_bgp_memory, |
4bf6a362 | 7895 | show_bgp_memory_cmd, |
7fa12b13 | 7896 | "show [ip] bgp memory", |
4bf6a362 | 7897 | SHOW_STR |
3a2d747c | 7898 | IP_STR |
4bf6a362 PJ |
7899 | BGP_STR |
7900 | "Global BGP memory statistics\n") | |
7901 | { | |
d62a17ae | 7902 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7903 | unsigned long count; | |
7904 | ||
7905 | /* RIB related usage stats */ | |
7906 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7907 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7908 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7909 | count * sizeof(struct bgp_node))); | |
7910 | ||
7911 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7912 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7913 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 7914 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 7915 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
7916 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7917 | count, | |
4b7e6066 DS |
7918 | mtype_memstr( |
7919 | memstrbuf, sizeof(memstrbuf), | |
7920 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 7921 | |
7922 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7923 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7924 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7925 | count * sizeof(struct bgp_static))); | |
7926 | ||
7927 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7928 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7929 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7930 | count * sizeof(struct bpacket))); | |
7931 | ||
7932 | /* Adj-In/Out */ | |
7933 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7934 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7935 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7936 | count * sizeof(struct bgp_adj_in))); | |
7937 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7938 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7939 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7940 | count * sizeof(struct bgp_adj_out))); | |
7941 | ||
7942 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7943 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7944 | count, | |
7945 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7946 | count * sizeof(struct bgp_nexthop_cache))); | |
7947 | ||
7948 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7949 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7950 | count, | |
7951 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7952 | count * sizeof(struct bgp_damp_info))); | |
7953 | ||
7954 | /* Attributes */ | |
7955 | count = attr_count(); | |
7956 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7957 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7958 | count * sizeof(struct attr))); | |
7959 | ||
7960 | if ((count = attr_unknown_count())) | |
7961 | vty_out(vty, "%ld unknown attributes\n", count); | |
7962 | ||
7963 | /* AS_PATH attributes */ | |
7964 | count = aspath_count(); | |
7965 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7966 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7967 | count * sizeof(struct aspath))); | |
7968 | ||
7969 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7970 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7971 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7972 | count * sizeof(struct assegment))); | |
7973 | ||
7974 | /* Other attributes */ | |
7975 | if ((count = community_count())) | |
7976 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7977 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7978 | count * sizeof(struct community))); | |
d62a17ae | 7979 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7980 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7981 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7982 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7983 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7984 | vty_out(vty, | |
7985 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7986 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7987 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7988 | |
7989 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7990 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7991 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7992 | count * sizeof(struct cluster_list))); | |
7993 | ||
7994 | /* Peer related usage */ | |
7995 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7996 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7997 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7998 | count * sizeof(struct peer))); | |
7999 | ||
8000 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8001 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8002 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8003 | count * sizeof(struct peer_group))); | |
8004 | ||
8005 | /* Other */ | |
d62a17ae | 8006 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8007 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8008 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8009 | count * sizeof(regex_t))); | |
d62a17ae | 8010 | return CMD_SUCCESS; |
4bf6a362 | 8011 | } |
fee0f4c6 | 8012 | |
57a9c8a8 DS |
8013 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8014 | { | |
8015 | json_object *bestpath = json_object_new_object(); | |
8016 | ||
8017 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
8018 | json_object_string_add(bestpath, "asPath", "ignore"); | |
8019 | ||
8020 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
8021 | json_object_string_add(bestpath, "asPath", "confed"); | |
8022 | ||
8023 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
8024 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
8025 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
8026 | "as-set"); |
8027 | else | |
a4d82a8a | 8028 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8029 | "true"); |
8030 | } else | |
a4d82a8a | 8031 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
8032 | |
8033 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
8034 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
8035 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
8036 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8037 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8038 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
8039 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
8040 | json_object_string_add(bestpath, "med", | |
8041 | "missing-as-worst"); | |
8042 | else | |
8043 | json_object_string_add(bestpath, "med", "true"); | |
8044 | } | |
8045 | ||
8046 | json_object_object_add(json, "bestPath", bestpath); | |
8047 | } | |
8048 | ||
3577f1c5 DD |
8049 | /* Print the error code/subcode for why the peer is down */ |
8050 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8051 | json_object *json_peer, bool use_json) | |
8052 | { | |
8053 | const char *code_str; | |
8054 | const char *subcode_str; | |
8055 | ||
8056 | if (use_json) { | |
8057 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8058 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8059 | char errorcodesubcode_hexstr[5]; | |
8060 | char errorcodesubcode_str[256]; | |
8061 | ||
8062 | code_str = bgp_notify_code_str(peer->notify.code); | |
8063 | subcode_str = bgp_notify_subcode_str( | |
8064 | peer->notify.code, | |
8065 | peer->notify.subcode); | |
8066 | ||
8067 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
8068 | peer->notify.code, peer->notify.subcode); | |
8069 | json_object_string_add(json_peer, | |
8070 | "lastErrorCodeSubcode", | |
8071 | errorcodesubcode_hexstr); | |
8072 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8073 | code_str, subcode_str); | |
8074 | json_object_string_add(json_peer, | |
8075 | "lastNotificationReason", | |
8076 | errorcodesubcode_str); | |
8077 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8078 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8079 | && (peer->notify.subcode | |
8080 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8081 | || peer->notify.subcode | |
8082 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8083 | && peer->notify.length) { | |
8084 | char msgbuf[1024]; | |
8085 | const char *msg_str; | |
8086 | ||
8087 | msg_str = bgp_notify_admin_message( | |
8088 | msgbuf, sizeof(msgbuf), | |
8089 | (uint8_t *)peer->notify.data, | |
8090 | peer->notify.length); | |
8091 | if (msg_str) | |
8092 | json_object_string_add( | |
8093 | json_peer, | |
8094 | "lastShutdownDescription", | |
8095 | msg_str); | |
8096 | } | |
8097 | ||
c258527b | 8098 | } |
3577f1c5 DD |
8099 | json_object_string_add(json_peer, "lastResetDueTo", |
8100 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8101 | json_object_int_add(json_peer, "lastResetCode", |
8102 | peer->last_reset); | |
3577f1c5 DD |
8103 | } else { |
8104 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8105 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8106 | code_str = bgp_notify_code_str(peer->notify.code); | |
8107 | subcode_str = | |
8108 | bgp_notify_subcode_str(peer->notify.code, | |
8109 | peer->notify.subcode); | |
8110 | vty_out(vty, " Notification %s (%s%s)\n", | |
8111 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8112 | ? "sent" | |
8113 | : "received", | |
8114 | code_str, subcode_str); | |
8115 | } else { | |
8116 | vty_out(vty, " %s\n", | |
8117 | peer_down_str[(int)peer->last_reset]); | |
8118 | } | |
8119 | } | |
8120 | } | |
8121 | ||
8122 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8123 | safi_t safi) | |
8124 | { | |
8125 | return ((peer->status != Established) || | |
8126 | !peer->afc_recv[afi][safi]); | |
8127 | } | |
8128 | ||
8129 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8130 | struct peer *peer, json_object *json_peer, | |
8131 | int max_neighbor_width, bool use_json) | |
8132 | { | |
8133 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8134 | int len; | |
8135 | ||
8136 | if (use_json) { | |
8137 | if (peer_dynamic_neighbor(peer)) | |
8138 | json_object_boolean_true_add(json_peer, | |
8139 | "dynamicPeer"); | |
8140 | if (peer->hostname) | |
8141 | json_object_string_add(json_peer, "hostname", | |
8142 | peer->hostname); | |
8143 | ||
8144 | if (peer->domainname) | |
8145 | json_object_string_add(json_peer, "domainname", | |
8146 | peer->domainname); | |
8147 | json_object_int_add(json_peer, "connectionsEstablished", | |
8148 | peer->established); | |
8149 | json_object_int_add(json_peer, "connectionsDropped", | |
8150 | peer->dropped); | |
8151 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8152 | use_json, json_peer); | |
8153 | if (peer->status == Established) | |
8154 | json_object_string_add(json_peer, "lastResetDueTo", | |
8155 | "AFI/SAFI Not Negotiated"); | |
8156 | else | |
8157 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8158 | } else { | |
8159 | dn_flag[1] = '\0'; | |
8160 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8161 | if (peer->hostname | |
8162 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
8163 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
8164 | peer->hostname, peer->host); | |
8165 | else | |
8166 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8167 | ||
8168 | /* pad the neighbor column with spaces */ | |
8169 | if (len < max_neighbor_width) | |
8170 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8171 | " "); | |
8172 | vty_out(vty, "%7d %7d %8s", peer->established, | |
8173 | peer->dropped, | |
8174 | peer_uptime(peer->uptime, timebuf, | |
8175 | BGP_UPTIME_LEN, 0, NULL)); | |
8176 | if (peer->status == Established) | |
8177 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8178 | else | |
8179 | bgp_show_peer_reset(vty, peer, NULL, | |
8180 | false); | |
8181 | } | |
8182 | } | |
c258527b | 8183 | |
3577f1c5 | 8184 | |
718e3744 | 8185 | /* Show BGP peer's summary information. */ |
d62a17ae | 8186 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8187 | bool show_failed, bool use_json) |
d62a17ae | 8188 | { |
8189 | struct peer *peer; | |
8190 | struct listnode *node, *nnode; | |
8191 | unsigned int count = 0, dn_count = 0; | |
8192 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8193 | char neighbor_buf[VTY_BUFSIZ]; | |
8194 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8195 | int len, failed_count = 0; |
d62a17ae | 8196 | int max_neighbor_width = 0; |
8197 | int pfx_rcd_safi; | |
3c13337d | 8198 | json_object *json = NULL; |
d62a17ae | 8199 | json_object *json_peer = NULL; |
8200 | json_object *json_peers = NULL; | |
50e05855 | 8201 | struct peer_af *paf; |
d62a17ae | 8202 | |
8203 | /* labeled-unicast routes are installed in the unicast table so in order | |
8204 | * to | |
8205 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8206 | */ | |
3577f1c5 | 8207 | |
d62a17ae | 8208 | if (safi == SAFI_LABELED_UNICAST) |
8209 | pfx_rcd_safi = SAFI_UNICAST; | |
8210 | else | |
8211 | pfx_rcd_safi = safi; | |
8212 | ||
8213 | if (use_json) { | |
3c13337d | 8214 | json = json_object_new_object(); |
d62a17ae | 8215 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8216 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8217 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8218 | continue; | |
8219 | ||
8220 | if (peer->afc[afi][safi]) { | |
8221 | /* See if we have at least a single failed peer */ | |
8222 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8223 | failed_count++; | |
8224 | count++; | |
8225 | } | |
8226 | if (peer_dynamic_neighbor(peer)) | |
8227 | dn_count++; | |
8228 | } | |
c258527b | 8229 | |
d62a17ae | 8230 | } else { |
8231 | /* Loop over all neighbors that will be displayed to determine | |
8232 | * how many | |
8233 | * characters are needed for the Neighbor column | |
8234 | */ | |
8235 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8236 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8237 | continue; | |
8238 | ||
8239 | if (peer->afc[afi][safi]) { | |
8240 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8241 | if (peer_dynamic_neighbor(peer)) | |
8242 | dn_flag[0] = '*'; | |
8243 | ||
8244 | if (peer->hostname | |
8245 | && bgp_flag_check(bgp, | |
8246 | BGP_FLAG_SHOW_HOSTNAME)) | |
8247 | sprintf(neighbor_buf, "%s%s(%s) ", | |
8248 | dn_flag, peer->hostname, | |
8249 | peer->host); | |
8250 | else | |
8251 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
8252 | peer->host); | |
8253 | ||
8254 | len = strlen(neighbor_buf); | |
8255 | ||
8256 | if (len > max_neighbor_width) | |
8257 | max_neighbor_width = len; | |
c258527b | 8258 | |
3577f1c5 DD |
8259 | /* See if we have at least a single failed peer */ |
8260 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8261 | failed_count++; | |
8262 | count++; | |
d62a17ae | 8263 | } |
8264 | } | |
f933309e | 8265 | |
d62a17ae | 8266 | /* Originally we displayed the Neighbor column as 16 |
8267 | * characters wide so make that the default | |
8268 | */ | |
8269 | if (max_neighbor_width < neighbor_col_default_width) | |
8270 | max_neighbor_width = neighbor_col_default_width; | |
8271 | } | |
f933309e | 8272 | |
3577f1c5 DD |
8273 | if (show_failed && !failed_count) { |
8274 | if (use_json) { | |
8275 | json_object_int_add(json, "failedPeersCount", 0); | |
8276 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8277 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8278 | |
8279 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8280 | json, JSON_C_TO_STRING_PRETTY)); | |
8281 | json_object_free(json); | |
8282 | } else { | |
8283 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8284 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8285 | } | |
8286 | return CMD_SUCCESS; | |
8287 | } | |
c258527b | 8288 | |
3577f1c5 | 8289 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8290 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8291 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8292 | continue; | |
8293 | ||
ea47320b DL |
8294 | if (!peer->afc[afi][safi]) |
8295 | continue; | |
d62a17ae | 8296 | |
ea47320b DL |
8297 | if (!count) { |
8298 | unsigned long ents; | |
8299 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8300 | int64_t vrf_id_ui; |
d62a17ae | 8301 | |
a4d82a8a PZ |
8302 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8303 | ? -1 | |
8304 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8305 | |
8306 | /* Usage summary and header */ | |
8307 | if (use_json) { | |
8308 | json_object_string_add( | |
8309 | json, "routerId", | |
8310 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8311 | json_object_int_add(json, "as", bgp->as); |
8312 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8313 | json_object_string_add( |
8314 | json, "vrfName", | |
8315 | (bgp->inst_type | |
8316 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8317 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8318 | : bgp->name); |
8319 | } else { | |
8320 | vty_out(vty, | |
8321 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8322 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8323 | bgp->vrf_id == VRF_UNKNOWN |
8324 | ? -1 | |
8325 | : (int)bgp->vrf_id); | |
ea47320b DL |
8326 | vty_out(vty, "\n"); |
8327 | } | |
d62a17ae | 8328 | |
ea47320b | 8329 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8330 | if (use_json) { |
ea47320b | 8331 | json_object_int_add( |
60466a63 | 8332 | json, "updateDelayLimit", |
ea47320b | 8333 | bgp->v_update_delay); |
d62a17ae | 8334 | |
ea47320b DL |
8335 | if (bgp->v_update_delay |
8336 | != bgp->v_establish_wait) | |
d62a17ae | 8337 | json_object_int_add( |
8338 | json, | |
ea47320b DL |
8339 | "updateDelayEstablishWait", |
8340 | bgp->v_establish_wait); | |
d62a17ae | 8341 | |
60466a63 | 8342 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8343 | json_object_string_add( |
8344 | json, | |
8345 | "updateDelayFirstNeighbor", | |
8346 | bgp->update_delay_begin_time); | |
8347 | json_object_boolean_true_add( | |
8348 | json, | |
8349 | "updateDelayInProgress"); | |
8350 | } else { | |
8351 | if (bgp->update_delay_over) { | |
d62a17ae | 8352 | json_object_string_add( |
8353 | json, | |
8354 | "updateDelayFirstNeighbor", | |
8355 | bgp->update_delay_begin_time); | |
ea47320b | 8356 | json_object_string_add( |
d62a17ae | 8357 | json, |
ea47320b DL |
8358 | "updateDelayBestpathResumed", |
8359 | bgp->update_delay_end_time); | |
8360 | json_object_string_add( | |
d62a17ae | 8361 | json, |
ea47320b DL |
8362 | "updateDelayZebraUpdateResume", |
8363 | bgp->update_delay_zebra_resume_time); | |
8364 | json_object_string_add( | |
8365 | json, | |
8366 | "updateDelayPeerUpdateResume", | |
8367 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8368 | } |
ea47320b DL |
8369 | } |
8370 | } else { | |
8371 | vty_out(vty, | |
8372 | "Read-only mode update-delay limit: %d seconds\n", | |
8373 | bgp->v_update_delay); | |
8374 | if (bgp->v_update_delay | |
8375 | != bgp->v_establish_wait) | |
d62a17ae | 8376 | vty_out(vty, |
ea47320b DL |
8377 | " Establish wait: %d seconds\n", |
8378 | bgp->v_establish_wait); | |
d62a17ae | 8379 | |
60466a63 | 8380 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8381 | vty_out(vty, |
8382 | " First neighbor established: %s\n", | |
8383 | bgp->update_delay_begin_time); | |
8384 | vty_out(vty, | |
8385 | " Delay in progress\n"); | |
8386 | } else { | |
8387 | if (bgp->update_delay_over) { | |
d62a17ae | 8388 | vty_out(vty, |
8389 | " First neighbor established: %s\n", | |
8390 | bgp->update_delay_begin_time); | |
8391 | vty_out(vty, | |
ea47320b DL |
8392 | " Best-paths resumed: %s\n", |
8393 | bgp->update_delay_end_time); | |
8394 | vty_out(vty, | |
8395 | " zebra update resumed: %s\n", | |
8396 | bgp->update_delay_zebra_resume_time); | |
8397 | vty_out(vty, | |
8398 | " peers update resumed: %s\n", | |
8399 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8400 | } |
8401 | } | |
8402 | } | |
ea47320b | 8403 | } |
d62a17ae | 8404 | |
ea47320b DL |
8405 | if (use_json) { |
8406 | if (bgp_maxmed_onstartup_configured(bgp) | |
8407 | && bgp->maxmed_active) | |
8408 | json_object_boolean_true_add( | |
60466a63 | 8409 | json, "maxMedOnStartup"); |
ea47320b DL |
8410 | if (bgp->v_maxmed_admin) |
8411 | json_object_boolean_true_add( | |
60466a63 | 8412 | json, "maxMedAdministrative"); |
d62a17ae | 8413 | |
ea47320b DL |
8414 | json_object_int_add( |
8415 | json, "tableVersion", | |
60466a63 | 8416 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8417 | |
60466a63 QY |
8418 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8419 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8420 | json_object_int_add( |
8421 | json, "ribMemory", | |
8422 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8423 | |
210ec2a0 | 8424 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8425 | json_object_int_add(json, "peerCount", ents); |
8426 | json_object_int_add(json, "peerMemory", | |
8427 | ents * sizeof(struct peer)); | |
d62a17ae | 8428 | |
ea47320b DL |
8429 | if ((ents = listcount(bgp->group))) { |
8430 | json_object_int_add( | |
60466a63 | 8431 | json, "peerGroupCount", ents); |
ea47320b DL |
8432 | json_object_int_add( |
8433 | json, "peerGroupMemory", | |
996c9314 LB |
8434 | ents * sizeof(struct |
8435 | peer_group)); | |
ea47320b | 8436 | } |
d62a17ae | 8437 | |
ea47320b DL |
8438 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8439 | BGP_CONFIG_DAMPENING)) | |
8440 | json_object_boolean_true_add( | |
60466a63 | 8441 | json, "dampeningEnabled"); |
ea47320b DL |
8442 | } else { |
8443 | if (bgp_maxmed_onstartup_configured(bgp) | |
8444 | && bgp->maxmed_active) | |
d62a17ae | 8445 | vty_out(vty, |
ea47320b DL |
8446 | "Max-med on-startup active\n"); |
8447 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8448 | vty_out(vty, |
ea47320b | 8449 | "Max-med administrative active\n"); |
d62a17ae | 8450 | |
60466a63 QY |
8451 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8452 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8453 | |
60466a63 | 8454 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8455 | vty_out(vty, |
8456 | "RIB entries %ld, using %s of memory\n", | |
8457 | ents, | |
996c9314 LB |
8458 | mtype_memstr(memstrbuf, |
8459 | sizeof(memstrbuf), | |
8460 | ents * sizeof(struct | |
8461 | bgp_node))); | |
ea47320b DL |
8462 | |
8463 | /* Peer related usage */ | |
210ec2a0 | 8464 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8465 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8466 | ents, |
8467 | mtype_memstr( | |
60466a63 QY |
8468 | memstrbuf, sizeof(memstrbuf), |
8469 | ents * sizeof(struct peer))); | |
ea47320b DL |
8470 | |
8471 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8472 | vty_out(vty, |
ea47320b | 8473 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8474 | ents, |
8475 | mtype_memstr( | |
8476 | memstrbuf, | |
8477 | sizeof(memstrbuf), | |
996c9314 LB |
8478 | ents * sizeof(struct |
8479 | peer_group))); | |
d62a17ae | 8480 | |
ea47320b DL |
8481 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8482 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8483 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8484 | vty_out(vty, "\n"); |
d62a17ae | 8485 | |
ea47320b DL |
8486 | /* Subtract 8 here because 'Neighbor' is |
8487 | * 8 characters */ | |
8488 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8489 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8490 | " "); | |
3577f1c5 DD |
8491 | if (show_failed) |
8492 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
8493 | else | |
8494 | vty_out(vty, | |
ea47320b | 8495 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); |
d62a17ae | 8496 | } |
ea47320b | 8497 | } |
d62a17ae | 8498 | |
ea47320b | 8499 | count++; |
3577f1c5 DD |
8500 | /* Works for both failed & successful cases */ |
8501 | if (peer_dynamic_neighbor(peer)) | |
8502 | dn_count++; | |
d62a17ae | 8503 | |
ea47320b | 8504 | if (use_json) { |
3577f1c5 DD |
8505 | json_peer = NULL; |
8506 | ||
8507 | if (show_failed && | |
8508 | bgp_has_peer_failed(peer, afi, safi)) { | |
8509 | json_peer = json_object_new_object(); | |
8510 | bgp_show_failed_summary(vty, bgp, peer, | |
8511 | json_peer, 0, use_json); | |
8512 | } else if (!show_failed) { | |
8513 | json_peer = json_object_new_object(); | |
8514 | if (peer_dynamic_neighbor(peer)) { | |
8515 | json_object_boolean_true_add(json_peer, | |
8516 | "dynamicPeer"); | |
8517 | } | |
d62a17ae | 8518 | |
3577f1c5 DD |
8519 | if (peer->hostname) |
8520 | json_object_string_add(json_peer, "hostname", | |
8521 | peer->hostname); | |
8522 | ||
8523 | if (peer->domainname) | |
8524 | json_object_string_add(json_peer, "domainname", | |
8525 | peer->domainname); | |
8526 | ||
8527 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
8528 | json_object_int_add(json_peer, "version", 4); | |
8529 | json_object_int_add(json_peer, "msgRcvd", | |
8530 | PEER_TOTAL_RX(peer)); | |
8531 | json_object_int_add(json_peer, "msgSent", | |
8532 | PEER_TOTAL_TX(peer)); | |
8533 | ||
8534 | json_object_int_add(json_peer, "tableVersion", | |
8535 | peer->version[afi][safi]); | |
8536 | json_object_int_add(json_peer, "outq", | |
8537 | peer->obuf->count); | |
8538 | json_object_int_add(json_peer, "inq", 0); | |
8539 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8540 | use_json, json_peer); | |
8541 | ||
8542 | /* | |
8543 | * Adding "pfxRcd" field to match with the corresponding | |
8544 | * CLI. "prefixReceivedCount" will be deprecated in | |
8545 | * future. | |
8546 | */ | |
8547 | json_object_int_add(json_peer, "prefixReceivedCount", | |
8548 | peer->pcount[afi][pfx_rcd_safi]); | |
8549 | json_object_int_add(json_peer, "pfxRcd", | |
8550 | peer->pcount[afi][pfx_rcd_safi]); | |
8551 | ||
8552 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8553 | if (paf && PAF_SUBGRP(paf)) | |
8554 | json_object_int_add(json_peer, | |
8555 | "pfxSnt", | |
8556 | (PAF_SUBGRP(paf))->scount); | |
8557 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
8558 | json_object_string_add(json_peer, "state", | |
8559 | "Idle (Admin)"); | |
8560 | else if (peer->afc_recv[afi][safi]) | |
8561 | json_object_string_add( | |
8562 | json_peer, "state", | |
8563 | lookup_msg(bgp_status_msg, peer->status, | |
8564 | NULL)); | |
8565 | else if (CHECK_FLAG(peer->sflags, | |
8566 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8567 | json_object_string_add(json_peer, "state", | |
8568 | "Idle (PfxCt)"); | |
8569 | else | |
8570 | json_object_string_add( | |
8571 | json_peer, "state", | |
8572 | lookup_msg(bgp_status_msg, peer->status, | |
8573 | NULL)); | |
200116db DD |
8574 | json_object_int_add(json_peer, "connectionsEstablished", |
8575 | peer->established); | |
8576 | json_object_int_add(json_peer, "connectionsDropped", | |
8577 | peer->dropped); | |
b4e9dcba | 8578 | } |
3577f1c5 DD |
8579 | /* Avoid creating empty peer dicts in JSON */ |
8580 | if (json_peer == NULL) | |
8581 | continue; | |
ea47320b DL |
8582 | |
8583 | if (peer->conf_if) | |
60466a63 | 8584 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8585 | "interface"); |
8586 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8587 | json_object_string_add(json_peer, "idType", |
8588 | "ipv4"); | |
ea47320b | 8589 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8590 | json_object_string_add(json_peer, "idType", |
8591 | "ipv6"); | |
ea47320b DL |
8592 | json_object_object_add(json_peers, peer->host, |
8593 | json_peer); | |
8594 | } else { | |
3577f1c5 DD |
8595 | if (show_failed && |
8596 | bgp_has_peer_failed(peer, afi, safi)) { | |
8597 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
8598 | max_neighbor_width, | |
8599 | use_json); | |
8600 | } else if (!show_failed) { | |
8601 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8602 | if (peer_dynamic_neighbor(peer)) { | |
8603 | dn_flag[0] = '*'; | |
8604 | } | |
d62a17ae | 8605 | |
3577f1c5 DD |
8606 | if (peer->hostname |
8607 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
8608 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
8609 | peer->hostname, peer->host); | |
d62a17ae | 8610 | else |
3577f1c5 DD |
8611 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
8612 | ||
8613 | /* pad the neighbor column with spaces */ | |
8614 | if (len < max_neighbor_width) | |
8615 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8616 | " "); | |
8617 | ||
8618 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", | |
8619 | peer->as, PEER_TOTAL_RX(peer), | |
8620 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8621 | 0, peer->obuf->count, | |
8622 | peer_uptime(peer->uptime, timebuf, | |
8623 | BGP_UPTIME_LEN, 0, NULL)); | |
8624 | ||
8625 | if (peer->status == Established) | |
8626 | if (peer->afc_recv[afi][safi]) | |
a0a87037 DA |
8627 | vty_out(vty, " %12" PRIu32, |
8628 | peer->pcount | |
8629 | [afi] | |
8630 | [pfx_rcd_safi]); | |
3577f1c5 DD |
8631 | else |
8632 | vty_out(vty, " NoNeg"); | |
8633 | else { | |
8634 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
8635 | vty_out(vty, " Idle (Admin)"); | |
8636 | else if (CHECK_FLAG( | |
8637 | peer->sflags, | |
8638 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8639 | vty_out(vty, " Idle (PfxCt)"); | |
8640 | else | |
8641 | vty_out(vty, " %12s", | |
8642 | lookup_msg(bgp_status_msg, | |
8643 | peer->status, NULL)); | |
8644 | } | |
8645 | vty_out(vty, "\n"); | |
d62a17ae | 8646 | } |
3577f1c5 | 8647 | |
d62a17ae | 8648 | } |
8649 | } | |
f933309e | 8650 | |
d62a17ae | 8651 | if (use_json) { |
8652 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 8653 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 8654 | json_object_int_add(json, "totalPeers", count); |
8655 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8656 | ||
3577f1c5 DD |
8657 | if (!show_failed) |
8658 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 8659 | |
996c9314 LB |
8660 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8661 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8662 | json_object_free(json); |
8663 | } else { | |
8664 | if (count) | |
8665 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8666 | else { | |
d6ceaca3 | 8667 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 8668 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 8669 | } |
b05a1c8b | 8670 | |
d6ceaca3 | 8671 | if (dn_count) { |
d62a17ae | 8672 | vty_out(vty, "* - dynamic neighbor\n"); |
8673 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8674 | dn_count, bgp->dynamic_neighbors_limit); | |
8675 | } | |
8676 | } | |
1ff9a340 | 8677 | |
d62a17ae | 8678 | return CMD_SUCCESS; |
718e3744 | 8679 | } |
8680 | ||
d62a17ae | 8681 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 8682 | int safi, bool show_failed, bool use_json) |
d62a17ae | 8683 | { |
8684 | int is_first = 1; | |
8685 | int afi_wildcard = (afi == AFI_MAX); | |
8686 | int safi_wildcard = (safi == SAFI_MAX); | |
8687 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 8688 | bool nbr_output = false; |
d62a17ae | 8689 | |
8690 | if (use_json && is_wildcard) | |
8691 | vty_out(vty, "{\n"); | |
8692 | if (afi_wildcard) | |
8693 | afi = 1; /* AFI_IP */ | |
8694 | while (afi < AFI_MAX) { | |
8695 | if (safi_wildcard) | |
8696 | safi = 1; /* SAFI_UNICAST */ | |
8697 | while (safi < SAFI_MAX) { | |
318cac96 | 8698 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 8699 | nbr_output = true; |
f86897b9 | 8700 | |
d62a17ae | 8701 | if (is_wildcard) { |
8702 | /* | |
8703 | * So limit output to those afi/safi | |
8704 | * pairs that | |
8705 | * actualy have something interesting in | |
8706 | * them | |
8707 | */ | |
8708 | if (use_json) { | |
d62a17ae | 8709 | if (!is_first) |
8710 | vty_out(vty, ",\n"); | |
8711 | else | |
8712 | is_first = 0; | |
8713 | ||
8714 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
8715 | get_afi_safi_str(afi, |
8716 | safi, | |
8717 | true)); | |
d62a17ae | 8718 | } else { |
8719 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
8720 | get_afi_safi_str(afi, |
8721 | safi, | |
8722 | false)); | |
d62a17ae | 8723 | } |
8724 | } | |
3577f1c5 DD |
8725 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
8726 | use_json); | |
d62a17ae | 8727 | } |
8728 | safi++; | |
d62a17ae | 8729 | if (!safi_wildcard) |
8730 | safi = SAFI_MAX; | |
8731 | } | |
8732 | afi++; | |
ee851c8c | 8733 | if (!afi_wildcard) |
d62a17ae | 8734 | afi = AFI_MAX; |
8735 | } | |
8736 | ||
8737 | if (use_json && is_wildcard) | |
8738 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
8739 | else if (!nbr_output) { |
8740 | if (use_json) | |
8741 | vty_out(vty, "{}\n"); | |
8742 | else | |
8743 | vty_out(vty, "%% No BGP neighbors found\n"); | |
8744 | } | |
d62a17ae | 8745 | } |
8746 | ||
8747 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
8748 | safi_t safi, bool show_failed, |
8749 | bool use_json) | |
d62a17ae | 8750 | { |
8751 | struct listnode *node, *nnode; | |
8752 | struct bgp *bgp; | |
d62a17ae | 8753 | int is_first = 1; |
9f049418 | 8754 | bool nbr_output = false; |
d62a17ae | 8755 | |
8756 | if (use_json) | |
8757 | vty_out(vty, "{\n"); | |
8758 | ||
8759 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 8760 | nbr_output = true; |
d62a17ae | 8761 | if (use_json) { |
d62a17ae | 8762 | if (!is_first) |
8763 | vty_out(vty, ",\n"); | |
8764 | else | |
8765 | is_first = 0; | |
8766 | ||
8767 | vty_out(vty, "\"%s\":", | |
8768 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8769 | ? VRF_DEFAULT_NAME |
d62a17ae | 8770 | : bgp->name); |
8771 | } else { | |
8772 | vty_out(vty, "\nInstance %s:\n", | |
8773 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8774 | ? VRF_DEFAULT_NAME |
d62a17ae | 8775 | : bgp->name); |
8776 | } | |
3577f1c5 DD |
8777 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
8778 | use_json); | |
d62a17ae | 8779 | } |
8780 | ||
8781 | if (use_json) | |
8782 | vty_out(vty, "}\n"); | |
9f049418 DS |
8783 | else if (!nbr_output) |
8784 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 8785 | } |
8786 | ||
8787 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 8788 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 8789 | { |
8790 | struct bgp *bgp; | |
8791 | ||
8792 | if (name) { | |
8793 | if (strmatch(name, "all")) { | |
8794 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 8795 | show_failed, |
d62a17ae | 8796 | use_json); |
8797 | return CMD_SUCCESS; | |
8798 | } else { | |
8799 | bgp = bgp_lookup_by_name(name); | |
8800 | ||
8801 | if (!bgp) { | |
8802 | if (use_json) | |
8803 | vty_out(vty, "{}\n"); | |
8804 | else | |
8805 | vty_out(vty, | |
ca61fd25 | 8806 | "%% BGP instance not found\n"); |
d62a17ae | 8807 | return CMD_WARNING; |
8808 | } | |
8809 | ||
f86897b9 | 8810 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 8811 | show_failed, use_json); |
d62a17ae | 8812 | return CMD_SUCCESS; |
8813 | } | |
8814 | } | |
8815 | ||
8816 | bgp = bgp_get_default(); | |
8817 | ||
8818 | if (bgp) | |
3577f1c5 DD |
8819 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
8820 | use_json); | |
9f049418 | 8821 | else { |
ca61fd25 DS |
8822 | if (use_json) |
8823 | vty_out(vty, "{}\n"); | |
8824 | else | |
8825 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
8826 | return CMD_WARNING; |
8827 | } | |
d62a17ae | 8828 | |
8829 | return CMD_SUCCESS; | |
4fb25c53 DW |
8830 | } |
8831 | ||
716b2d8a | 8832 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8833 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8834 | show_ip_bgp_summary_cmd, |
3577f1c5 | 8835 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 8836 | SHOW_STR |
8837 | IP_STR | |
8838 | BGP_STR | |
8386ac43 | 8839 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8840 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8841 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8842 | "Summary of BGP neighbor status\n" |
3577f1c5 | 8843 | "Show only sessions not in Established state\n" |
9973d184 | 8844 | JSON_STR) |
718e3744 | 8845 | { |
d62a17ae | 8846 | char *vrf = NULL; |
8847 | afi_t afi = AFI_MAX; | |
8848 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 8849 | bool show_failed = false; |
d62a17ae | 8850 | |
8851 | int idx = 0; | |
8852 | ||
8853 | /* show [ip] bgp */ | |
8854 | if (argv_find(argv, argc, "ip", &idx)) | |
8855 | afi = AFI_IP; | |
9a8bdf1c PG |
8856 | /* [<vrf> VIEWVRFNAME] */ |
8857 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8858 | vrf = argv[idx + 1]->arg; | |
8859 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8860 | vrf = NULL; | |
8861 | } else if (argv_find(argv, argc, "view", &idx)) | |
8862 | /* [<view> VIEWVRFNAME] */ | |
8863 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 8864 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8865 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8866 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8867 | } | |
8868 | ||
3577f1c5 DD |
8869 | if (argv_find(argv, argc, "failed", &idx)) |
8870 | show_failed = true; | |
8871 | ||
9f049418 | 8872 | bool uj = use_json(argc, argv); |
d62a17ae | 8873 | |
3577f1c5 | 8874 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 8875 | } |
8876 | ||
5cb5f4d0 | 8877 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 8878 | { |
5cb5f4d0 DD |
8879 | if (for_json) |
8880 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 8881 | else |
5cb5f4d0 | 8882 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
8883 | } |
8884 | ||
718e3744 | 8885 | /* Show BGP peer's information. */ |
d1927ebe | 8886 | enum show_type { show_all, show_peer, show_ipv4_all, show_ipv6_all, show_ipv4_peer, show_ipv6_peer }; |
d62a17ae | 8887 | |
8888 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8889 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8890 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8891 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 8892 | bool use_json, json_object *json_pref) |
d62a17ae | 8893 | { |
8894 | /* Send-Mode */ | |
8895 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8896 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8897 | if (use_json) { | |
8898 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8899 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8900 | json_object_string_add(json_pref, "sendMode", | |
8901 | "advertisedAndReceived"); | |
8902 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8903 | json_object_string_add(json_pref, "sendMode", | |
8904 | "advertised"); | |
8905 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8906 | json_object_string_add(json_pref, "sendMode", | |
8907 | "received"); | |
8908 | } else { | |
8909 | vty_out(vty, " Send-mode: "); | |
8910 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8911 | vty_out(vty, "advertised"); | |
8912 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8913 | vty_out(vty, "%sreceived", | |
8914 | CHECK_FLAG(p->af_cap[afi][safi], | |
8915 | adv_smcap) | |
8916 | ? ", " | |
8917 | : ""); | |
8918 | vty_out(vty, "\n"); | |
8919 | } | |
8920 | } | |
8921 | ||
8922 | /* Receive-Mode */ | |
8923 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8924 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8925 | if (use_json) { | |
8926 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8927 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8928 | json_object_string_add(json_pref, "recvMode", | |
8929 | "advertisedAndReceived"); | |
8930 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8931 | json_object_string_add(json_pref, "recvMode", | |
8932 | "advertised"); | |
8933 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8934 | json_object_string_add(json_pref, "recvMode", | |
8935 | "received"); | |
8936 | } else { | |
8937 | vty_out(vty, " Receive-mode: "); | |
8938 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8939 | vty_out(vty, "advertised"); | |
8940 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8941 | vty_out(vty, "%sreceived", | |
8942 | CHECK_FLAG(p->af_cap[afi][safi], | |
8943 | adv_rmcap) | |
8944 | ? ", " | |
8945 | : ""); | |
8946 | vty_out(vty, "\n"); | |
8947 | } | |
8948 | } | |
8949 | } | |
8950 | ||
8951 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
9f049418 | 8952 | safi_t safi, bool use_json, |
d62a17ae | 8953 | json_object *json_neigh) |
8954 | { | |
0291c246 MK |
8955 | struct bgp_filter *filter; |
8956 | struct peer_af *paf; | |
8957 | char orf_pfx_name[BUFSIZ]; | |
8958 | int orf_pfx_count; | |
8959 | json_object *json_af = NULL; | |
8960 | json_object *json_prefA = NULL; | |
8961 | json_object *json_prefB = NULL; | |
8962 | json_object *json_addr = NULL; | |
d62a17ae | 8963 | |
8964 | if (use_json) { | |
8965 | json_addr = json_object_new_object(); | |
8966 | json_af = json_object_new_object(); | |
8967 | filter = &p->filter[afi][safi]; | |
8968 | ||
8969 | if (peer_group_active(p)) | |
8970 | json_object_string_add(json_addr, "peerGroupMember", | |
8971 | p->group->name); | |
8972 | ||
8973 | paf = peer_af_find(p, afi, safi); | |
8974 | if (paf && PAF_SUBGRP(paf)) { | |
8975 | json_object_int_add(json_addr, "updateGroupId", | |
8976 | PAF_UPDGRP(paf)->id); | |
8977 | json_object_int_add(json_addr, "subGroupId", | |
8978 | PAF_SUBGRP(paf)->id); | |
8979 | json_object_int_add(json_addr, "packetQueueLength", | |
8980 | bpacket_queue_virtual_length(paf)); | |
8981 | } | |
8982 | ||
8983 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8984 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8985 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8986 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8987 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8988 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8989 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8990 | json_object_int_add(json_af, "orfType", | |
8991 | ORF_TYPE_PREFIX); | |
8992 | json_prefA = json_object_new_object(); | |
8993 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8994 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8995 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8996 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8997 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8998 | use_json, json_prefA); | |
8999 | json_object_object_add(json_af, "orfPrefixList", | |
9000 | json_prefA); | |
9001 | } | |
9002 | ||
9003 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9004 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9005 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9006 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9007 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9008 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9009 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9010 | json_object_int_add(json_af, "orfOldType", | |
9011 | ORF_TYPE_PREFIX_OLD); | |
9012 | json_prefB = json_object_new_object(); | |
9013 | bgp_show_peer_afi_orf_cap( | |
9014 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9015 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9016 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9017 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
9018 | json_prefB); | |
9019 | json_object_object_add(json_af, "orfOldPrefixList", | |
9020 | json_prefB); | |
9021 | } | |
9022 | ||
9023 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9024 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9025 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9026 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9027 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9028 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9029 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9030 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9031 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9032 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9033 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9034 | json_object_object_add(json_addr, "afDependentCap", | |
9035 | json_af); | |
9036 | else | |
9037 | json_object_free(json_af); | |
9038 | ||
9039 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
9040 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
9041 | NULL, afi, orf_pfx_name, use_json); | |
9042 | ||
9043 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9044 | PEER_STATUS_ORF_PREFIX_SEND) | |
9045 | || orf_pfx_count) { | |
9046 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9047 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9048 | json_object_boolean_true_add(json_neigh, | |
9049 | "orfSent"); | |
9050 | if (orf_pfx_count) | |
9051 | json_object_int_add(json_addr, "orfRecvCounter", | |
9052 | orf_pfx_count); | |
9053 | } | |
9054 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9055 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9056 | json_object_string_add( | |
9057 | json_addr, "orfFirstUpdate", | |
9058 | "deferredUntilORFOrRouteRefreshRecvd"); | |
9059 | ||
9060 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9061 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9062 | json_object_boolean_true_add(json_addr, | |
9063 | "routeReflectorClient"); | |
9064 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9065 | PEER_FLAG_RSERVER_CLIENT)) | |
9066 | json_object_boolean_true_add(json_addr, | |
9067 | "routeServerClient"); | |
9068 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9069 | json_object_boolean_true_add(json_addr, | |
9070 | "inboundSoftConfigPermit"); | |
9071 | ||
9072 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9073 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9074 | json_object_boolean_true_add( | |
9075 | json_addr, | |
9076 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
9077 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9078 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9079 | json_object_boolean_true_add( | |
9080 | json_addr, | |
9081 | "privateAsNumsReplacedInUpdatesToNbr"); | |
9082 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9083 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9084 | json_object_boolean_true_add( | |
9085 | json_addr, | |
9086 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
9087 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9088 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9089 | json_object_boolean_true_add( | |
9090 | json_addr, | |
9091 | "privateAsNumsRemovedInUpdatesToNbr"); | |
9092 | ||
dcc68b5e MS |
9093 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9094 | json_object_boolean_true_add( | |
9095 | json_addr, | |
9096 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9097 | ->type_json_name); | |
d62a17ae | 9098 | |
9099 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9100 | json_object_string_add(json_addr, | |
9101 | "overrideASNsInOutboundUpdates", | |
9102 | "ifAspathEqualRemoteAs"); | |
9103 | ||
9104 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9105 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9106 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9107 | json_object_boolean_true_add(json_addr, | |
9108 | "routerAlwaysNextHop"); | |
9109 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9110 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9111 | json_object_boolean_true_add( | |
9112 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
9113 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9114 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9115 | json_object_boolean_true_add( | |
9116 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
9117 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9118 | json_object_boolean_true_add( | |
9119 | json_addr, "unchangedMedPropogatedToNbr"); | |
9120 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
9121 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9122 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
9123 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9124 | PEER_FLAG_SEND_COMMUNITY) | |
9125 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9126 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9127 | json_object_string_add(json_addr, | |
9128 | "commAttriSentToNbr", | |
9129 | "extendedAndStandard"); | |
9130 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9131 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9132 | json_object_string_add(json_addr, | |
9133 | "commAttriSentToNbr", | |
9134 | "extended"); | |
9135 | else | |
9136 | json_object_string_add(json_addr, | |
9137 | "commAttriSentToNbr", | |
9138 | "standard"); | |
9139 | } | |
9140 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9141 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9142 | if (p->default_rmap[afi][safi].name) | |
9143 | json_object_string_add( | |
9144 | json_addr, "defaultRouteMap", | |
9145 | p->default_rmap[afi][safi].name); | |
9146 | ||
9147 | if (paf && PAF_SUBGRP(paf) | |
9148 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9149 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9150 | json_object_boolean_true_add(json_addr, | |
9151 | "defaultSent"); | |
9152 | else | |
9153 | json_object_boolean_true_add(json_addr, | |
9154 | "defaultNotSent"); | |
9155 | } | |
9156 | ||
dff8f48d | 9157 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 9158 | if (is_evpn_enabled()) |
60466a63 QY |
9159 | json_object_boolean_true_add( |
9160 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
9161 | } |
9162 | ||
d62a17ae | 9163 | if (filter->plist[FILTER_IN].name |
9164 | || filter->dlist[FILTER_IN].name | |
9165 | || filter->aslist[FILTER_IN].name | |
9166 | || filter->map[RMAP_IN].name) | |
9167 | json_object_boolean_true_add(json_addr, | |
9168 | "inboundPathPolicyConfig"); | |
9169 | if (filter->plist[FILTER_OUT].name | |
9170 | || filter->dlist[FILTER_OUT].name | |
9171 | || filter->aslist[FILTER_OUT].name | |
9172 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9173 | json_object_boolean_true_add( | |
9174 | json_addr, "outboundPathPolicyConfig"); | |
9175 | ||
9176 | /* prefix-list */ | |
9177 | if (filter->plist[FILTER_IN].name) | |
9178 | json_object_string_add(json_addr, | |
9179 | "incomingUpdatePrefixFilterList", | |
9180 | filter->plist[FILTER_IN].name); | |
9181 | if (filter->plist[FILTER_OUT].name) | |
9182 | json_object_string_add(json_addr, | |
9183 | "outgoingUpdatePrefixFilterList", | |
9184 | filter->plist[FILTER_OUT].name); | |
9185 | ||
9186 | /* distribute-list */ | |
9187 | if (filter->dlist[FILTER_IN].name) | |
9188 | json_object_string_add( | |
9189 | json_addr, "incomingUpdateNetworkFilterList", | |
9190 | filter->dlist[FILTER_IN].name); | |
9191 | if (filter->dlist[FILTER_OUT].name) | |
9192 | json_object_string_add( | |
9193 | json_addr, "outgoingUpdateNetworkFilterList", | |
9194 | filter->dlist[FILTER_OUT].name); | |
9195 | ||
9196 | /* filter-list. */ | |
9197 | if (filter->aslist[FILTER_IN].name) | |
9198 | json_object_string_add(json_addr, | |
9199 | "incomingUpdateAsPathFilterList", | |
9200 | filter->aslist[FILTER_IN].name); | |
9201 | if (filter->aslist[FILTER_OUT].name) | |
9202 | json_object_string_add(json_addr, | |
9203 | "outgoingUpdateAsPathFilterList", | |
9204 | filter->aslist[FILTER_OUT].name); | |
9205 | ||
9206 | /* route-map. */ | |
9207 | if (filter->map[RMAP_IN].name) | |
9208 | json_object_string_add( | |
9209 | json_addr, "routeMapForIncomingAdvertisements", | |
9210 | filter->map[RMAP_IN].name); | |
9211 | if (filter->map[RMAP_OUT].name) | |
9212 | json_object_string_add( | |
9213 | json_addr, "routeMapForOutgoingAdvertisements", | |
9214 | filter->map[RMAP_OUT].name); | |
9215 | ||
9dac9fc8 DA |
9216 | /* ebgp-requires-policy (inbound) */ |
9217 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9218 | && !bgp_inbound_policy_exists(p, filter)) | |
9219 | json_object_string_add( | |
9220 | json_addr, "inboundEbgpRequiresPolicy", | |
9221 | "Inbound updates discarded due to missing policy"); | |
9222 | ||
9223 | /* ebgp-requires-policy (outbound) */ | |
9224 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9225 | && (!bgp_outbound_policy_exists(p, filter))) | |
9226 | json_object_string_add( | |
9227 | json_addr, "outboundEbgpRequiresPolicy", | |
9228 | "Outbound updates discarded due to missing policy"); | |
9229 | ||
d62a17ae | 9230 | /* unsuppress-map */ |
9231 | if (filter->usmap.name) | |
9232 | json_object_string_add(json_addr, | |
9233 | "selectiveUnsuppressRouteMap", | |
9234 | filter->usmap.name); | |
9235 | ||
9236 | /* Receive prefix count */ | |
9237 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
9238 | p->pcount[afi][safi]); | |
50e05855 AD |
9239 | if (paf && PAF_SUBGRP(paf)) |
9240 | json_object_int_add(json_addr, "sentPrefixCounter", | |
9241 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 9242 | |
fde246e8 DA |
9243 | /* Maximum prefix */ |
9244 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
9245 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
9246 | p->pmax_out[afi][safi]); | |
9247 | ||
d62a17ae | 9248 | /* Maximum prefix */ |
9249 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9250 | json_object_int_add(json_addr, "prefixAllowedMax", | |
9251 | p->pmax[afi][safi]); | |
9252 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9253 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
9254 | json_object_boolean_true_add( | |
9255 | json_addr, "prefixAllowedMaxWarning"); | |
9256 | json_object_int_add(json_addr, | |
9257 | "prefixAllowedWarningThresh", | |
9258 | p->pmax_threshold[afi][safi]); | |
9259 | if (p->pmax_restart[afi][safi]) | |
9260 | json_object_int_add( | |
9261 | json_addr, | |
9262 | "prefixAllowedRestartIntervalMsecs", | |
9263 | p->pmax_restart[afi][safi] * 60000); | |
9264 | } | |
5cb5f4d0 | 9265 | json_object_object_add(json_neigh, get_afi_safi_str(afi, safi, true), |
d62a17ae | 9266 | json_addr); |
9267 | ||
9268 | } else { | |
9269 | filter = &p->filter[afi][safi]; | |
9270 | ||
9271 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 9272 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9273 | |
9274 | if (peer_group_active(p)) | |
9275 | vty_out(vty, " %s peer-group member\n", | |
9276 | p->group->name); | |
9277 | ||
9278 | paf = peer_af_find(p, afi, safi); | |
9279 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
9280 | vty_out(vty, " Update group %" PRIu64 |
9281 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 9282 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
9283 | vty_out(vty, " Packet Queue length %d\n", | |
9284 | bpacket_queue_virtual_length(paf)); | |
9285 | } else { | |
9286 | vty_out(vty, " Not part of any update group\n"); | |
9287 | } | |
9288 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9289 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9290 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9291 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9292 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9293 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9294 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9295 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9296 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9297 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9298 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9299 | vty_out(vty, " AF-dependant capabilities:\n"); | |
9300 | ||
9301 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9302 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9303 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9304 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9305 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9306 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9307 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
9308 | vty_out(vty, | |
9309 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
9310 | ORF_TYPE_PREFIX); | |
9311 | bgp_show_peer_afi_orf_cap( | |
9312 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9313 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9314 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
9315 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
9316 | } | |
9317 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9318 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9319 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9320 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9321 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9322 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9323 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9324 | vty_out(vty, | |
9325 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
9326 | ORF_TYPE_PREFIX_OLD); | |
9327 | bgp_show_peer_afi_orf_cap( | |
9328 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9329 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9330 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9331 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
9332 | } | |
9333 | ||
9334 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
9335 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
9336 | NULL, afi, orf_pfx_name, use_json); | |
9337 | ||
9338 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9339 | PEER_STATUS_ORF_PREFIX_SEND) | |
9340 | || orf_pfx_count) { | |
9341 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
9342 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9343 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9344 | vty_out(vty, " sent;"); | |
9345 | if (orf_pfx_count) | |
9346 | vty_out(vty, " received (%d entries)", | |
9347 | orf_pfx_count); | |
9348 | vty_out(vty, "\n"); | |
9349 | } | |
9350 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9351 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9352 | vty_out(vty, | |
9353 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
9354 | ||
9355 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9356 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9357 | vty_out(vty, " Route-Reflector Client\n"); | |
9358 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9359 | PEER_FLAG_RSERVER_CLIENT)) | |
9360 | vty_out(vty, " Route-Server Client\n"); | |
9361 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9362 | vty_out(vty, | |
9363 | " Inbound soft reconfiguration allowed\n"); | |
9364 | ||
9365 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9366 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9367 | vty_out(vty, | |
9368 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
9369 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9370 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9371 | vty_out(vty, | |
9372 | " Private AS numbers replaced in updates to this neighbor\n"); | |
9373 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9374 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9375 | vty_out(vty, | |
9376 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
9377 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9378 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9379 | vty_out(vty, | |
9380 | " Private AS numbers removed in updates to this neighbor\n"); | |
9381 | ||
dcc68b5e MS |
9382 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9383 | vty_out(vty, " %s\n", | |
9384 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9385 | ->human_description); | |
d62a17ae | 9386 | |
9387 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9388 | vty_out(vty, | |
9389 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
9390 | ||
9391 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9392 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9393 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9394 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
9395 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9396 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9397 | vty_out(vty, | |
9398 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
9399 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9400 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9401 | vty_out(vty, | |
9402 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
9403 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9404 | vty_out(vty, | |
9405 | " MED is propagated unchanged to this neighbor\n"); | |
9406 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
9407 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9408 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9409 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9410 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
9411 | vty_out(vty, | |
9412 | " Community attribute sent to this neighbor"); | |
9413 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9414 | PEER_FLAG_SEND_COMMUNITY) | |
9415 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9416 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9417 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9418 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9419 | vty_out(vty, "(all)\n"); | |
9420 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9421 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9422 | vty_out(vty, "(large)\n"); | |
9423 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9424 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9425 | vty_out(vty, "(extended)\n"); | |
9426 | else | |
9427 | vty_out(vty, "(standard)\n"); | |
9428 | } | |
9429 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9430 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9431 | vty_out(vty, " Default information originate,"); | |
9432 | ||
9433 | if (p->default_rmap[afi][safi].name) | |
9434 | vty_out(vty, " default route-map %s%s,", | |
9435 | p->default_rmap[afi][safi].map ? "*" | |
9436 | : "", | |
9437 | p->default_rmap[afi][safi].name); | |
9438 | if (paf && PAF_SUBGRP(paf) | |
9439 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9440 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9441 | vty_out(vty, " default sent\n"); | |
9442 | else | |
9443 | vty_out(vty, " default not sent\n"); | |
9444 | } | |
9445 | ||
dff8f48d MK |
9446 | /* advertise-vni-all */ |
9447 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 9448 | if (is_evpn_enabled()) |
dff8f48d MK |
9449 | vty_out(vty, " advertise-all-vni\n"); |
9450 | } | |
9451 | ||
d62a17ae | 9452 | if (filter->plist[FILTER_IN].name |
9453 | || filter->dlist[FILTER_IN].name | |
9454 | || filter->aslist[FILTER_IN].name | |
9455 | || filter->map[RMAP_IN].name) | |
9456 | vty_out(vty, " Inbound path policy configured\n"); | |
9457 | if (filter->plist[FILTER_OUT].name | |
9458 | || filter->dlist[FILTER_OUT].name | |
9459 | || filter->aslist[FILTER_OUT].name | |
9460 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9461 | vty_out(vty, " Outbound path policy configured\n"); | |
9462 | ||
9463 | /* prefix-list */ | |
9464 | if (filter->plist[FILTER_IN].name) | |
9465 | vty_out(vty, | |
9466 | " Incoming update prefix filter list is %s%s\n", | |
9467 | filter->plist[FILTER_IN].plist ? "*" : "", | |
9468 | filter->plist[FILTER_IN].name); | |
9469 | if (filter->plist[FILTER_OUT].name) | |
9470 | vty_out(vty, | |
9471 | " Outgoing update prefix filter list is %s%s\n", | |
9472 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
9473 | filter->plist[FILTER_OUT].name); | |
9474 | ||
9475 | /* distribute-list */ | |
9476 | if (filter->dlist[FILTER_IN].name) | |
9477 | vty_out(vty, | |
9478 | " Incoming update network filter list is %s%s\n", | |
9479 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
9480 | filter->dlist[FILTER_IN].name); | |
9481 | if (filter->dlist[FILTER_OUT].name) | |
9482 | vty_out(vty, | |
9483 | " Outgoing update network filter list is %s%s\n", | |
9484 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
9485 | filter->dlist[FILTER_OUT].name); | |
9486 | ||
9487 | /* filter-list. */ | |
9488 | if (filter->aslist[FILTER_IN].name) | |
9489 | vty_out(vty, | |
9490 | " Incoming update AS path filter list is %s%s\n", | |
9491 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
9492 | filter->aslist[FILTER_IN].name); | |
9493 | if (filter->aslist[FILTER_OUT].name) | |
9494 | vty_out(vty, | |
9495 | " Outgoing update AS path filter list is %s%s\n", | |
9496 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
9497 | filter->aslist[FILTER_OUT].name); | |
9498 | ||
9499 | /* route-map. */ | |
9500 | if (filter->map[RMAP_IN].name) | |
9501 | vty_out(vty, | |
9502 | " Route map for incoming advertisements is %s%s\n", | |
9503 | filter->map[RMAP_IN].map ? "*" : "", | |
9504 | filter->map[RMAP_IN].name); | |
9505 | if (filter->map[RMAP_OUT].name) | |
9506 | vty_out(vty, | |
9507 | " Route map for outgoing advertisements is %s%s\n", | |
9508 | filter->map[RMAP_OUT].map ? "*" : "", | |
9509 | filter->map[RMAP_OUT].name); | |
9510 | ||
9dac9fc8 DA |
9511 | /* ebgp-requires-policy (inbound) */ |
9512 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9513 | && !bgp_inbound_policy_exists(p, filter)) | |
9514 | vty_out(vty, | |
9515 | " Inbound updates discarded due to missing policy\n"); | |
9516 | ||
9517 | /* ebgp-requires-policy (outbound) */ | |
9518 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9519 | && !bgp_outbound_policy_exists(p, filter)) | |
9520 | vty_out(vty, | |
9521 | " Outbound updates discarded due to missing policy\n"); | |
9522 | ||
d62a17ae | 9523 | /* unsuppress-map */ |
9524 | if (filter->usmap.name) | |
9525 | vty_out(vty, | |
9526 | " Route map for selective unsuppress is %s%s\n", | |
9527 | filter->usmap.map ? "*" : "", | |
9528 | filter->usmap.name); | |
9529 | ||
9530 | /* Receive prefix count */ | |
a0a87037 DA |
9531 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
9532 | p->pcount[afi][safi]); | |
d62a17ae | 9533 | |
fde246e8 DA |
9534 | /* maximum-prefix-out */ |
9535 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9536 | PEER_FLAG_MAX_PREFIX_OUT)) | |
9537 | vty_out(vty, | |
9538 | " Maximum allowed prefixes sent %" PRIu32 "\n", | |
9539 | p->pmax_out[afi][safi]); | |
9540 | ||
d62a17ae | 9541 | /* Maximum prefix */ |
9542 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
9543 | vty_out(vty, |
9544 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 9545 | p->pmax[afi][safi], |
9546 | CHECK_FLAG(p->af_flags[afi][safi], | |
9547 | PEER_FLAG_MAX_PREFIX_WARNING) | |
9548 | ? " (warning-only)" | |
9549 | : ""); | |
9550 | vty_out(vty, " Threshold for warning message %d%%", | |
9551 | p->pmax_threshold[afi][safi]); | |
9552 | if (p->pmax_restart[afi][safi]) | |
9553 | vty_out(vty, ", restart interval %d min", | |
9554 | p->pmax_restart[afi][safi]); | |
9555 | vty_out(vty, "\n"); | |
9556 | } | |
9557 | ||
9558 | vty_out(vty, "\n"); | |
9559 | } | |
9560 | } | |
9561 | ||
9f049418 | 9562 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 9563 | json_object *json) |
718e3744 | 9564 | { |
d62a17ae | 9565 | struct bgp *bgp; |
9566 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
9567 | char timebuf[BGP_UPTIME_LEN]; | |
9568 | char dn_flag[2]; | |
d62a17ae | 9569 | afi_t afi; |
9570 | safi_t safi; | |
d7c0a89a QY |
9571 | uint16_t i; |
9572 | uint8_t *msg; | |
d62a17ae | 9573 | json_object *json_neigh = NULL; |
9574 | time_t epoch_tbuf; | |
718e3744 | 9575 | |
d62a17ae | 9576 | bgp = p->bgp; |
9577 | ||
9578 | if (use_json) | |
9579 | json_neigh = json_object_new_object(); | |
9580 | ||
9581 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9582 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9583 | dn_flag[0] = '*'; | |
9584 | ||
9585 | if (!use_json) { | |
9586 | if (p->conf_if) /* Configured interface name. */ | |
9587 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
9588 | BGP_PEER_SU_UNSPEC(p) | |
9589 | ? "None" | |
9590 | : sockunion2str(&p->su, buf, | |
9591 | SU_ADDRSTRLEN)); | |
9592 | else /* Configured IP address. */ | |
9593 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
9594 | p->host); | |
9595 | } | |
9596 | ||
9597 | if (use_json) { | |
9598 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
9599 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
9600 | "none"); | |
9601 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
9602 | json_object_string_add( | |
9603 | json_neigh, "bgpNeighborAddr", | |
9604 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
9605 | ||
9606 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
9607 | ||
9608 | if (p->change_local_as) | |
9609 | json_object_int_add(json_neigh, "localAs", | |
9610 | p->change_local_as); | |
9611 | else | |
9612 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
9613 | ||
9614 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
9615 | json_object_boolean_true_add(json_neigh, | |
9616 | "localAsNoPrepend"); | |
9617 | ||
9618 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
9619 | json_object_boolean_true_add(json_neigh, | |
9620 | "localAsReplaceAs"); | |
9621 | } else { | |
9622 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9623 | || (p->as_type == AS_INTERNAL)) | |
9624 | vty_out(vty, "remote AS %u, ", p->as); | |
9625 | else | |
9626 | vty_out(vty, "remote AS Unspecified, "); | |
9627 | vty_out(vty, "local AS %u%s%s, ", | |
9628 | p->change_local_as ? p->change_local_as : p->local_as, | |
9629 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9630 | ? " no-prepend" | |
9631 | : "", | |
9632 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9633 | ? " replace-as" | |
9634 | : ""); | |
9635 | } | |
faa16034 DS |
9636 | /* peer type internal or confed-internal */ |
9637 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 9638 | if (use_json) { |
9639 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9640 | json_object_boolean_true_add( | |
9641 | json_neigh, "nbrConfedInternalLink"); | |
9642 | else | |
9643 | json_object_boolean_true_add(json_neigh, | |
9644 | "nbrInternalLink"); | |
9645 | } else { | |
9646 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9647 | vty_out(vty, "confed-internal link\n"); | |
9648 | else | |
9649 | vty_out(vty, "internal link\n"); | |
9650 | } | |
faa16034 DS |
9651 | /* peer type external or confed-external */ |
9652 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 9653 | if (use_json) { |
9654 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9655 | json_object_boolean_true_add( | |
9656 | json_neigh, "nbrConfedExternalLink"); | |
9657 | else | |
9658 | json_object_boolean_true_add(json_neigh, | |
9659 | "nbrExternalLink"); | |
9660 | } else { | |
9661 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9662 | vty_out(vty, "confed-external link\n"); | |
9663 | else | |
9664 | vty_out(vty, "external link\n"); | |
9665 | } | |
faa16034 DS |
9666 | } else { |
9667 | if (use_json) | |
9668 | json_object_boolean_true_add(json_neigh, | |
9669 | "nbrUnspecifiedLink"); | |
9670 | else | |
9671 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 9672 | } |
9673 | ||
9674 | /* Description. */ | |
9675 | if (p->desc) { | |
9676 | if (use_json) | |
9677 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9678 | else | |
9679 | vty_out(vty, " Description: %s\n", p->desc); | |
9680 | } | |
9681 | ||
9682 | if (p->hostname) { | |
9683 | if (use_json) { | |
9684 | if (p->hostname) | |
9685 | json_object_string_add(json_neigh, "hostname", | |
9686 | p->hostname); | |
9687 | ||
9688 | if (p->domainname) | |
9689 | json_object_string_add(json_neigh, "domainname", | |
9690 | p->domainname); | |
9691 | } else { | |
9692 | if (p->domainname && (p->domainname[0] != '\0')) | |
9693 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9694 | p->domainname); | |
9695 | else | |
9696 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9697 | } | |
9698 | } | |
9699 | ||
9700 | /* Peer-group */ | |
9701 | if (p->group) { | |
9702 | if (use_json) { | |
9703 | json_object_string_add(json_neigh, "peerGroup", | |
9704 | p->group->name); | |
9705 | ||
9706 | if (dn_flag[0]) { | |
9707 | struct prefix prefix, *range = NULL; | |
9708 | ||
9709 | sockunion2hostprefix(&(p->su), &prefix); | |
9710 | range = peer_group_lookup_dynamic_neighbor_range( | |
9711 | p->group, &prefix); | |
9712 | ||
9713 | if (range) { | |
9714 | prefix2str(range, buf1, sizeof(buf1)); | |
9715 | json_object_string_add( | |
9716 | json_neigh, | |
9717 | "peerSubnetRangeGroup", buf1); | |
9718 | } | |
9719 | } | |
9720 | } else { | |
9721 | vty_out(vty, | |
9722 | " Member of peer-group %s for session parameters\n", | |
9723 | p->group->name); | |
9724 | ||
9725 | if (dn_flag[0]) { | |
9726 | struct prefix prefix, *range = NULL; | |
9727 | ||
9728 | sockunion2hostprefix(&(p->su), &prefix); | |
9729 | range = peer_group_lookup_dynamic_neighbor_range( | |
9730 | p->group, &prefix); | |
9731 | ||
9732 | if (range) { | |
9733 | prefix2str(range, buf1, sizeof(buf1)); | |
9734 | vty_out(vty, | |
9735 | " Belongs to the subnet range group: %s\n", | |
9736 | buf1); | |
9737 | } | |
9738 | } | |
9739 | } | |
9740 | } | |
9741 | ||
9742 | if (use_json) { | |
9743 | /* Administrative shutdown. */ | |
9744 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9745 | json_object_boolean_true_add(json_neigh, | |
9746 | "adminShutDown"); | |
9747 | ||
9748 | /* BGP Version. */ | |
9749 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9750 | json_object_string_add( | |
9751 | json_neigh, "remoteRouterId", | |
9752 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9753 | json_object_string_add( |
9754 | json_neigh, "localRouterId", | |
9755 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9756 | sizeof(buf1))); | |
d62a17ae | 9757 | |
9758 | /* Confederation */ | |
9759 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9760 | && bgp_confederation_peers_check(bgp, p->as)) | |
9761 | json_object_boolean_true_add(json_neigh, | |
9762 | "nbrCommonAdmin"); | |
9763 | ||
9764 | /* Status. */ | |
9765 | json_object_string_add( | |
9766 | json_neigh, "bgpState", | |
9767 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9768 | ||
9769 | if (p->status == Established) { | |
9770 | time_t uptime; | |
d62a17ae | 9771 | |
9772 | uptime = bgp_clock(); | |
9773 | uptime -= p->uptime; | |
d62a17ae | 9774 | epoch_tbuf = time(NULL) - uptime; |
9775 | ||
d3c7efed DS |
9776 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9777 | uptime * 1000); | |
d62a17ae | 9778 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9779 | peer_uptime(p->uptime, timebuf, | |
9780 | BGP_UPTIME_LEN, 0, | |
9781 | NULL)); | |
9782 | json_object_int_add(json_neigh, | |
9783 | "bgpTimerUpEstablishedEpoch", | |
9784 | epoch_tbuf); | |
9785 | } | |
9786 | ||
9787 | else if (p->status == Active) { | |
9788 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9789 | json_object_string_add(json_neigh, "bgpStateIs", | |
9790 | "passive"); | |
9791 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9792 | json_object_string_add(json_neigh, "bgpStateIs", | |
9793 | "passiveNSF"); | |
9794 | } | |
9795 | ||
9796 | /* read timer */ | |
9797 | time_t uptime; | |
9798 | struct tm *tm; | |
9799 | ||
9800 | uptime = bgp_clock(); | |
9801 | uptime -= p->readtime; | |
9802 | tm = gmtime(&uptime); | |
9803 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9804 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9805 | + (tm->tm_hour * 3600000)); | |
9806 | ||
9807 | uptime = bgp_clock(); | |
9808 | uptime -= p->last_write; | |
9809 | tm = gmtime(&uptime); | |
9810 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9811 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9812 | + (tm->tm_hour * 3600000)); | |
9813 | ||
9814 | uptime = bgp_clock(); | |
9815 | uptime -= p->update_time; | |
9816 | tm = gmtime(&uptime); | |
9817 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9818 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9819 | + (tm->tm_hour * 3600000)); | |
9820 | ||
9821 | /* Configured timer values. */ | |
9822 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9823 | p->v_holdtime * 1000); | |
9824 | json_object_int_add(json_neigh, | |
9825 | "bgpTimerKeepAliveIntervalMsecs", | |
9826 | p->v_keepalive * 1000); | |
b90a8e13 | 9827 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9828 | json_object_int_add(json_neigh, |
9829 | "bgpTimerConfiguredHoldTimeMsecs", | |
9830 | p->holdtime * 1000); | |
9831 | json_object_int_add( | |
9832 | json_neigh, | |
9833 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9834 | p->keepalive * 1000); | |
5d5393b9 DL |
9835 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
9836 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
9837 | json_object_int_add(json_neigh, |
9838 | "bgpTimerConfiguredHoldTimeMsecs", | |
9839 | bgp->default_holdtime); | |
9840 | json_object_int_add( | |
9841 | json_neigh, | |
9842 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9843 | bgp->default_keepalive); | |
d62a17ae | 9844 | } |
9845 | } else { | |
9846 | /* Administrative shutdown. */ | |
9847 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9848 | vty_out(vty, " Administratively shut down\n"); | |
9849 | ||
9850 | /* BGP Version. */ | |
9851 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9852 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9853 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9854 | vty_out(vty, ", local router ID %s\n", |
9855 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9856 | sizeof(buf1))); | |
d62a17ae | 9857 | |
9858 | /* Confederation */ | |
9859 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9860 | && bgp_confederation_peers_check(bgp, p->as)) | |
9861 | vty_out(vty, | |
9862 | " Neighbor under common administration\n"); | |
9863 | ||
9864 | /* Status. */ | |
9865 | vty_out(vty, " BGP state = %s", | |
9866 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9867 | ||
9868 | if (p->status == Established) | |
9869 | vty_out(vty, ", up for %8s", | |
9870 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9871 | 0, NULL)); | |
9872 | ||
9873 | else if (p->status == Active) { | |
9874 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9875 | vty_out(vty, " (passive)"); | |
9876 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9877 | vty_out(vty, " (NSF passive)"); | |
9878 | } | |
9879 | vty_out(vty, "\n"); | |
9880 | ||
9881 | /* read timer */ | |
9882 | vty_out(vty, " Last read %s", | |
9883 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9884 | NULL)); | |
9885 | vty_out(vty, ", Last write %s\n", | |
9886 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9887 | NULL)); | |
9888 | ||
9889 | /* Configured timer values. */ | |
9890 | vty_out(vty, | |
9891 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9892 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9893 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9894 | vty_out(vty, " Configured hold time is %d", |
9895 | p->holdtime); | |
9896 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9897 | p->keepalive); | |
5d5393b9 DL |
9898 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
9899 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
9900 | vty_out(vty, " Configured hold time is %d", |
9901 | bgp->default_holdtime); | |
9902 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9903 | bgp->default_keepalive); | |
d62a17ae | 9904 | } |
9905 | } | |
9906 | /* Capability. */ | |
9907 | if (p->status == Established) { | |
9908 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9909 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9910 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9911 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9912 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9913 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9914 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9915 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9916 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9917 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9918 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9919 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9920 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9921 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9922 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9923 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9924 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9925 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9926 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9927 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9928 | if (use_json) { | |
9929 | json_object *json_cap = NULL; | |
9930 | ||
9931 | json_cap = json_object_new_object(); | |
9932 | ||
9933 | /* AS4 */ | |
9934 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9935 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9936 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9937 | && CHECK_FLAG(p->cap, | |
9938 | PEER_CAP_AS4_RCV)) | |
9939 | json_object_string_add( | |
9940 | json_cap, "4byteAs", | |
9941 | "advertisedAndReceived"); | |
9942 | else if (CHECK_FLAG(p->cap, | |
9943 | PEER_CAP_AS4_ADV)) | |
9944 | json_object_string_add( | |
9945 | json_cap, "4byteAs", | |
9946 | "advertised"); | |
9947 | else if (CHECK_FLAG(p->cap, | |
9948 | PEER_CAP_AS4_RCV)) | |
9949 | json_object_string_add( | |
9950 | json_cap, "4byteAs", | |
9951 | "received"); | |
9952 | } | |
9953 | ||
9954 | /* AddPath */ | |
9955 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9956 | || CHECK_FLAG(p->cap, | |
9957 | PEER_CAP_ADDPATH_ADV)) { | |
9958 | json_object *json_add = NULL; | |
9959 | const char *print_store; | |
9960 | ||
9961 | json_add = json_object_new_object(); | |
9962 | ||
05c7a1cc QY |
9963 | FOREACH_AFI_SAFI (afi, safi) { |
9964 | json_object *json_sub = NULL; | |
9965 | json_sub = | |
9966 | json_object_new_object(); | |
5cb5f4d0 DD |
9967 | print_store = get_afi_safi_str( |
9968 | afi, safi, true); | |
d62a17ae | 9969 | |
05c7a1cc QY |
9970 | if (CHECK_FLAG( |
9971 | p->af_cap[afi] | |
9972 | [safi], | |
9973 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9974 | || CHECK_FLAG( | |
9975 | p->af_cap[afi] | |
9976 | [safi], | |
9977 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9978 | if (CHECK_FLAG( |
9979 | p->af_cap | |
9980 | [afi] | |
9981 | [safi], | |
9982 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9983 | && CHECK_FLAG( |
d62a17ae | 9984 | p->af_cap |
9985 | [afi] | |
9986 | [safi], | |
05c7a1cc QY |
9987 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9988 | json_object_boolean_true_add( | |
9989 | json_sub, | |
9990 | "txAdvertisedAndReceived"); | |
9991 | else if ( | |
9992 | CHECK_FLAG( | |
9993 | p->af_cap | |
9994 | [afi] | |
9995 | [safi], | |
9996 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9997 | json_object_boolean_true_add( | |
9998 | json_sub, | |
9999 | "txAdvertised"); | |
10000 | else if ( | |
10001 | CHECK_FLAG( | |
10002 | p->af_cap | |
10003 | [afi] | |
10004 | [safi], | |
10005 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10006 | json_object_boolean_true_add( | |
10007 | json_sub, | |
10008 | "txReceived"); | |
10009 | } | |
d62a17ae | 10010 | |
05c7a1cc QY |
10011 | if (CHECK_FLAG( |
10012 | p->af_cap[afi] | |
10013 | [safi], | |
10014 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10015 | || CHECK_FLAG( | |
10016 | p->af_cap[afi] | |
10017 | [safi], | |
10018 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 10019 | if (CHECK_FLAG( |
10020 | p->af_cap | |
10021 | [afi] | |
10022 | [safi], | |
10023 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 10024 | && CHECK_FLAG( |
d62a17ae | 10025 | p->af_cap |
10026 | [afi] | |
10027 | [safi], | |
10028 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
10029 | json_object_boolean_true_add( |
10030 | json_sub, | |
10031 | "rxAdvertisedAndReceived"); | |
10032 | else if ( | |
10033 | CHECK_FLAG( | |
10034 | p->af_cap | |
10035 | [afi] | |
10036 | [safi], | |
10037 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
10038 | json_object_boolean_true_add( | |
10039 | json_sub, | |
10040 | "rxAdvertised"); | |
10041 | else if ( | |
10042 | CHECK_FLAG( | |
10043 | p->af_cap | |
10044 | [afi] | |
10045 | [safi], | |
10046 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10047 | json_object_boolean_true_add( | |
10048 | json_sub, | |
10049 | "rxReceived"); | |
d62a17ae | 10050 | } |
10051 | ||
05c7a1cc QY |
10052 | if (CHECK_FLAG( |
10053 | p->af_cap[afi] | |
10054 | [safi], | |
10055 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10056 | || CHECK_FLAG( | |
10057 | p->af_cap[afi] | |
10058 | [safi], | |
10059 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
10060 | || CHECK_FLAG( | |
10061 | p->af_cap[afi] | |
10062 | [safi], | |
10063 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10064 | || CHECK_FLAG( | |
10065 | p->af_cap[afi] | |
10066 | [safi], | |
10067 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10068 | json_object_object_add( | |
10069 | json_add, | |
10070 | print_store, | |
10071 | json_sub); | |
10072 | else | |
10073 | json_object_free( | |
10074 | json_sub); | |
10075 | } | |
10076 | ||
d62a17ae | 10077 | json_object_object_add( |
10078 | json_cap, "addPath", json_add); | |
10079 | } | |
10080 | ||
10081 | /* Dynamic */ | |
10082 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10083 | || CHECK_FLAG(p->cap, | |
10084 | PEER_CAP_DYNAMIC_ADV)) { | |
10085 | if (CHECK_FLAG(p->cap, | |
10086 | PEER_CAP_DYNAMIC_ADV) | |
10087 | && CHECK_FLAG(p->cap, | |
10088 | PEER_CAP_DYNAMIC_RCV)) | |
10089 | json_object_string_add( | |
10090 | json_cap, "dynamic", | |
10091 | "advertisedAndReceived"); | |
10092 | else if (CHECK_FLAG( | |
10093 | p->cap, | |
10094 | PEER_CAP_DYNAMIC_ADV)) | |
10095 | json_object_string_add( | |
10096 | json_cap, "dynamic", | |
10097 | "advertised"); | |
10098 | else if (CHECK_FLAG( | |
10099 | p->cap, | |
10100 | PEER_CAP_DYNAMIC_RCV)) | |
10101 | json_object_string_add( | |
10102 | json_cap, "dynamic", | |
10103 | "received"); | |
10104 | } | |
10105 | ||
10106 | /* Extended nexthop */ | |
10107 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10108 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10109 | json_object *json_nxt = NULL; | |
10110 | const char *print_store; | |
10111 | ||
10112 | ||
10113 | if (CHECK_FLAG(p->cap, | |
10114 | PEER_CAP_ENHE_ADV) | |
10115 | && CHECK_FLAG(p->cap, | |
10116 | PEER_CAP_ENHE_RCV)) | |
10117 | json_object_string_add( | |
10118 | json_cap, | |
10119 | "extendedNexthop", | |
10120 | "advertisedAndReceived"); | |
10121 | else if (CHECK_FLAG(p->cap, | |
10122 | PEER_CAP_ENHE_ADV)) | |
10123 | json_object_string_add( | |
10124 | json_cap, | |
10125 | "extendedNexthop", | |
10126 | "advertised"); | |
10127 | else if (CHECK_FLAG(p->cap, | |
10128 | PEER_CAP_ENHE_RCV)) | |
10129 | json_object_string_add( | |
10130 | json_cap, | |
10131 | "extendedNexthop", | |
10132 | "received"); | |
10133 | ||
10134 | if (CHECK_FLAG(p->cap, | |
10135 | PEER_CAP_ENHE_RCV)) { | |
10136 | json_nxt = | |
10137 | json_object_new_object(); | |
10138 | ||
10139 | for (safi = SAFI_UNICAST; | |
10140 | safi < SAFI_MAX; safi++) { | |
10141 | if (CHECK_FLAG( | |
10142 | p->af_cap | |
10143 | [AFI_IP] | |
10144 | [safi], | |
10145 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 10146 | print_store = get_afi_safi_str( |
d62a17ae | 10147 | AFI_IP, |
5cb5f4d0 | 10148 | safi, true); |
d62a17ae | 10149 | json_object_string_add( |
10150 | json_nxt, | |
10151 | print_store, | |
54f29523 | 10152 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 10153 | } |
10154 | } | |
10155 | json_object_object_add( | |
10156 | json_cap, | |
10157 | "extendedNexthopFamililesByPeer", | |
10158 | json_nxt); | |
10159 | } | |
10160 | } | |
10161 | ||
10162 | /* Route Refresh */ | |
10163 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10164 | || CHECK_FLAG(p->cap, | |
10165 | PEER_CAP_REFRESH_NEW_RCV) | |
10166 | || CHECK_FLAG(p->cap, | |
10167 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10168 | if (CHECK_FLAG(p->cap, | |
10169 | PEER_CAP_REFRESH_ADV) | |
10170 | && (CHECK_FLAG( | |
10171 | p->cap, | |
10172 | PEER_CAP_REFRESH_NEW_RCV) | |
10173 | || CHECK_FLAG( | |
10174 | p->cap, | |
10175 | PEER_CAP_REFRESH_OLD_RCV))) { | |
10176 | if (CHECK_FLAG( | |
10177 | p->cap, | |
10178 | PEER_CAP_REFRESH_OLD_RCV) | |
10179 | && CHECK_FLAG( | |
10180 | p->cap, | |
10181 | PEER_CAP_REFRESH_NEW_RCV)) | |
10182 | json_object_string_add( | |
10183 | json_cap, | |
10184 | "routeRefresh", | |
10185 | "advertisedAndReceivedOldNew"); | |
10186 | else { | |
10187 | if (CHECK_FLAG( | |
10188 | p->cap, | |
10189 | PEER_CAP_REFRESH_OLD_RCV)) | |
10190 | json_object_string_add( | |
10191 | json_cap, | |
10192 | "routeRefresh", | |
10193 | "advertisedAndReceivedOld"); | |
10194 | else | |
10195 | json_object_string_add( | |
10196 | json_cap, | |
10197 | "routeRefresh", | |
10198 | "advertisedAndReceivedNew"); | |
10199 | } | |
10200 | } else if ( | |
10201 | CHECK_FLAG( | |
10202 | p->cap, | |
10203 | PEER_CAP_REFRESH_ADV)) | |
10204 | json_object_string_add( | |
10205 | json_cap, | |
10206 | "routeRefresh", | |
10207 | "advertised"); | |
10208 | else if ( | |
10209 | CHECK_FLAG( | |
10210 | p->cap, | |
10211 | PEER_CAP_REFRESH_NEW_RCV) | |
10212 | || CHECK_FLAG( | |
10213 | p->cap, | |
10214 | PEER_CAP_REFRESH_OLD_RCV)) | |
10215 | json_object_string_add( | |
10216 | json_cap, | |
10217 | "routeRefresh", | |
10218 | "received"); | |
10219 | } | |
10220 | ||
10221 | /* Multiprotocol Extensions */ | |
10222 | json_object *json_multi = NULL; | |
10223 | json_multi = json_object_new_object(); | |
10224 | ||
05c7a1cc QY |
10225 | FOREACH_AFI_SAFI (afi, safi) { |
10226 | if (p->afc_adv[afi][safi] | |
10227 | || p->afc_recv[afi][safi]) { | |
10228 | json_object *json_exten = NULL; | |
10229 | json_exten = | |
10230 | json_object_new_object(); | |
10231 | ||
d62a17ae | 10232 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
10233 | && p->afc_recv[afi][safi]) |
10234 | json_object_boolean_true_add( | |
10235 | json_exten, | |
10236 | "advertisedAndReceived"); | |
10237 | else if (p->afc_adv[afi][safi]) | |
10238 | json_object_boolean_true_add( | |
10239 | json_exten, | |
10240 | "advertised"); | |
10241 | else if (p->afc_recv[afi][safi]) | |
10242 | json_object_boolean_true_add( | |
10243 | json_exten, | |
10244 | "received"); | |
d62a17ae | 10245 | |
05c7a1cc QY |
10246 | json_object_object_add( |
10247 | json_multi, | |
5cb5f4d0 DD |
10248 | get_afi_safi_str(afi, |
10249 | safi, | |
10250 | true), | |
05c7a1cc | 10251 | json_exten); |
d62a17ae | 10252 | } |
10253 | } | |
10254 | json_object_object_add( | |
10255 | json_cap, "multiprotocolExtensions", | |
10256 | json_multi); | |
10257 | ||
d77114b7 | 10258 | /* Hostname capabilities */ |
60466a63 | 10259 | json_object *json_hname = NULL; |
d77114b7 MK |
10260 | |
10261 | json_hname = json_object_new_object(); | |
10262 | ||
10263 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
10264 | json_object_string_add( | |
60466a63 QY |
10265 | json_hname, "advHostName", |
10266 | bgp->peer_self->hostname | |
10267 | ? bgp->peer_self | |
10268 | ->hostname | |
d77114b7 MK |
10269 | : "n/a"); |
10270 | json_object_string_add( | |
60466a63 QY |
10271 | json_hname, "advDomainName", |
10272 | bgp->peer_self->domainname | |
10273 | ? bgp->peer_self | |
10274 | ->domainname | |
d77114b7 MK |
10275 | : "n/a"); |
10276 | } | |
10277 | ||
10278 | ||
10279 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
10280 | json_object_string_add( | |
60466a63 QY |
10281 | json_hname, "rcvHostName", |
10282 | p->hostname ? p->hostname | |
10283 | : "n/a"); | |
d77114b7 | 10284 | json_object_string_add( |
60466a63 QY |
10285 | json_hname, "rcvDomainName", |
10286 | p->domainname ? p->domainname | |
10287 | : "n/a"); | |
d77114b7 MK |
10288 | } |
10289 | ||
60466a63 | 10290 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
10291 | json_hname); |
10292 | ||
d62a17ae | 10293 | /* Gracefull Restart */ |
10294 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10295 | || CHECK_FLAG(p->cap, | |
10296 | PEER_CAP_RESTART_ADV)) { | |
10297 | if (CHECK_FLAG(p->cap, | |
10298 | PEER_CAP_RESTART_ADV) | |
10299 | && CHECK_FLAG(p->cap, | |
10300 | PEER_CAP_RESTART_RCV)) | |
10301 | json_object_string_add( | |
10302 | json_cap, | |
10303 | "gracefulRestart", | |
10304 | "advertisedAndReceived"); | |
10305 | else if (CHECK_FLAG( | |
10306 | p->cap, | |
10307 | PEER_CAP_RESTART_ADV)) | |
10308 | json_object_string_add( | |
10309 | json_cap, | |
10310 | "gracefulRestartCapability", | |
10311 | "advertised"); | |
10312 | else if (CHECK_FLAG( | |
10313 | p->cap, | |
10314 | PEER_CAP_RESTART_RCV)) | |
10315 | json_object_string_add( | |
10316 | json_cap, | |
10317 | "gracefulRestartCapability", | |
10318 | "received"); | |
10319 | ||
10320 | if (CHECK_FLAG(p->cap, | |
10321 | PEER_CAP_RESTART_RCV)) { | |
10322 | int restart_af_count = 0; | |
10323 | json_object *json_restart = | |
10324 | NULL; | |
10325 | json_restart = | |
10326 | json_object_new_object(); | |
10327 | ||
10328 | json_object_int_add( | |
10329 | json_cap, | |
10330 | "gracefulRestartRemoteTimerMsecs", | |
10331 | p->v_gr_restart * 1000); | |
10332 | ||
05c7a1cc QY |
10333 | FOREACH_AFI_SAFI (afi, safi) { |
10334 | if (CHECK_FLAG( | |
10335 | p->af_cap | |
10336 | [afi] | |
10337 | [safi], | |
10338 | PEER_CAP_RESTART_AF_RCV)) { | |
10339 | json_object * | |
10340 | json_sub = | |
10341 | NULL; | |
10342 | json_sub = | |
10343 | json_object_new_object(); | |
10344 | ||
d62a17ae | 10345 | if (CHECK_FLAG( |
10346 | p->af_cap | |
10347 | [afi] | |
10348 | [safi], | |
05c7a1cc QY |
10349 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
10350 | json_object_boolean_true_add( | |
10351 | json_sub, | |
10352 | "preserved"); | |
10353 | restart_af_count++; | |
10354 | json_object_object_add( | |
10355 | json_restart, | |
5cb5f4d0 | 10356 | get_afi_safi_str( |
05c7a1cc | 10357 | afi, |
5cb5f4d0 DD |
10358 | safi, |
10359 | true), | |
05c7a1cc | 10360 | json_sub); |
d62a17ae | 10361 | } |
10362 | } | |
10363 | if (!restart_af_count) { | |
10364 | json_object_string_add( | |
10365 | json_cap, | |
10366 | "addressFamiliesByPeer", | |
10367 | "none"); | |
10368 | json_object_free( | |
10369 | json_restart); | |
10370 | } else | |
10371 | json_object_object_add( | |
10372 | json_cap, | |
10373 | "addressFamiliesByPeer", | |
10374 | json_restart); | |
10375 | } | |
10376 | } | |
10377 | json_object_object_add(json_neigh, | |
10378 | "neighborCapabilities", | |
10379 | json_cap); | |
10380 | } else { | |
10381 | vty_out(vty, " Neighbor capabilities:\n"); | |
10382 | ||
10383 | /* AS4 */ | |
10384 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10385 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10386 | vty_out(vty, " 4 Byte AS:"); | |
10387 | if (CHECK_FLAG(p->cap, | |
10388 | PEER_CAP_AS4_ADV)) | |
10389 | vty_out(vty, " advertised"); | |
10390 | if (CHECK_FLAG(p->cap, | |
10391 | PEER_CAP_AS4_RCV)) | |
10392 | vty_out(vty, " %sreceived", | |
10393 | CHECK_FLAG( | |
10394 | p->cap, | |
10395 | PEER_CAP_AS4_ADV) | |
10396 | ? "and " | |
10397 | : ""); | |
10398 | vty_out(vty, "\n"); | |
10399 | } | |
10400 | ||
10401 | /* AddPath */ | |
10402 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10403 | || CHECK_FLAG(p->cap, | |
10404 | PEER_CAP_ADDPATH_ADV)) { | |
10405 | vty_out(vty, " AddPath:\n"); | |
10406 | ||
05c7a1cc QY |
10407 | FOREACH_AFI_SAFI (afi, safi) { |
10408 | if (CHECK_FLAG( | |
10409 | p->af_cap[afi] | |
10410 | [safi], | |
10411 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10412 | || CHECK_FLAG( | |
10413 | p->af_cap[afi] | |
10414 | [safi], | |
10415 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
10416 | vty_out(vty, | |
10417 | " %s: TX ", | |
5cb5f4d0 | 10418 | get_afi_safi_str( |
05c7a1cc | 10419 | afi, |
5cb5f4d0 DD |
10420 | safi, |
10421 | false)); | |
05c7a1cc | 10422 | |
d62a17ae | 10423 | if (CHECK_FLAG( |
10424 | p->af_cap | |
10425 | [afi] | |
10426 | [safi], | |
05c7a1cc | 10427 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 10428 | vty_out(vty, |
05c7a1cc | 10429 | "advertised %s", |
5cb5f4d0 | 10430 | get_afi_safi_str( |
d62a17ae | 10431 | afi, |
5cb5f4d0 DD |
10432 | safi, |
10433 | false)); | |
d62a17ae | 10434 | |
05c7a1cc QY |
10435 | if (CHECK_FLAG( |
10436 | p->af_cap | |
10437 | [afi] | |
10438 | [safi], | |
10439 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10440 | vty_out(vty, | |
10441 | "%sreceived", | |
10442 | CHECK_FLAG( | |
10443 | p->af_cap | |
10444 | [afi] | |
10445 | [safi], | |
10446 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10447 | ? " and " | |
10448 | : ""); | |
d62a17ae | 10449 | |
05c7a1cc QY |
10450 | vty_out(vty, "\n"); |
10451 | } | |
d62a17ae | 10452 | |
05c7a1cc QY |
10453 | if (CHECK_FLAG( |
10454 | p->af_cap[afi] | |
10455 | [safi], | |
10456 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10457 | || CHECK_FLAG( | |
10458 | p->af_cap[afi] | |
10459 | [safi], | |
10460 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
10461 | vty_out(vty, | |
10462 | " %s: RX ", | |
5cb5f4d0 | 10463 | get_afi_safi_str( |
05c7a1cc | 10464 | afi, |
5cb5f4d0 DD |
10465 | safi, |
10466 | false)); | |
d62a17ae | 10467 | |
10468 | if (CHECK_FLAG( | |
10469 | p->af_cap | |
10470 | [afi] | |
10471 | [safi], | |
05c7a1cc | 10472 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 10473 | vty_out(vty, |
05c7a1cc | 10474 | "advertised %s", |
5cb5f4d0 | 10475 | get_afi_safi_str( |
d62a17ae | 10476 | afi, |
5cb5f4d0 DD |
10477 | safi, |
10478 | false)); | |
d62a17ae | 10479 | |
05c7a1cc QY |
10480 | if (CHECK_FLAG( |
10481 | p->af_cap | |
10482 | [afi] | |
10483 | [safi], | |
10484 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 10485 | vty_out(vty, |
05c7a1cc QY |
10486 | "%sreceived", |
10487 | CHECK_FLAG( | |
10488 | p->af_cap | |
10489 | [afi] | |
10490 | [safi], | |
10491 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10492 | ? " and " | |
10493 | : ""); | |
10494 | ||
10495 | vty_out(vty, "\n"); | |
d62a17ae | 10496 | } |
05c7a1cc | 10497 | } |
d62a17ae | 10498 | } |
10499 | ||
10500 | /* Dynamic */ | |
10501 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10502 | || CHECK_FLAG(p->cap, | |
10503 | PEER_CAP_DYNAMIC_ADV)) { | |
10504 | vty_out(vty, " Dynamic:"); | |
10505 | if (CHECK_FLAG(p->cap, | |
10506 | PEER_CAP_DYNAMIC_ADV)) | |
10507 | vty_out(vty, " advertised"); | |
10508 | if (CHECK_FLAG(p->cap, | |
10509 | PEER_CAP_DYNAMIC_RCV)) | |
10510 | vty_out(vty, " %sreceived", | |
10511 | CHECK_FLAG( | |
10512 | p->cap, | |
10513 | PEER_CAP_DYNAMIC_ADV) | |
10514 | ? "and " | |
10515 | : ""); | |
10516 | vty_out(vty, "\n"); | |
10517 | } | |
10518 | ||
10519 | /* Extended nexthop */ | |
10520 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10521 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10522 | vty_out(vty, " Extended nexthop:"); | |
10523 | if (CHECK_FLAG(p->cap, | |
10524 | PEER_CAP_ENHE_ADV)) | |
10525 | vty_out(vty, " advertised"); | |
10526 | if (CHECK_FLAG(p->cap, | |
10527 | PEER_CAP_ENHE_RCV)) | |
10528 | vty_out(vty, " %sreceived", | |
10529 | CHECK_FLAG( | |
10530 | p->cap, | |
10531 | PEER_CAP_ENHE_ADV) | |
10532 | ? "and " | |
10533 | : ""); | |
10534 | vty_out(vty, "\n"); | |
10535 | ||
10536 | if (CHECK_FLAG(p->cap, | |
10537 | PEER_CAP_ENHE_RCV)) { | |
10538 | vty_out(vty, | |
10539 | " Address families by peer:\n "); | |
10540 | for (safi = SAFI_UNICAST; | |
10541 | safi < SAFI_MAX; safi++) | |
10542 | if (CHECK_FLAG( | |
10543 | p->af_cap | |
10544 | [AFI_IP] | |
10545 | [safi], | |
10546 | PEER_CAP_ENHE_AF_RCV)) | |
10547 | vty_out(vty, | |
10548 | " %s\n", | |
5cb5f4d0 | 10549 | get_afi_safi_str( |
d62a17ae | 10550 | AFI_IP, |
5cb5f4d0 DD |
10551 | safi, |
10552 | false)); | |
d62a17ae | 10553 | } |
10554 | } | |
10555 | ||
10556 | /* Route Refresh */ | |
10557 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10558 | || CHECK_FLAG(p->cap, | |
10559 | PEER_CAP_REFRESH_NEW_RCV) | |
10560 | || CHECK_FLAG(p->cap, | |
10561 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10562 | vty_out(vty, " Route refresh:"); | |
10563 | if (CHECK_FLAG(p->cap, | |
10564 | PEER_CAP_REFRESH_ADV)) | |
10565 | vty_out(vty, " advertised"); | |
10566 | if (CHECK_FLAG(p->cap, | |
10567 | PEER_CAP_REFRESH_NEW_RCV) | |
10568 | || CHECK_FLAG( | |
10569 | p->cap, | |
10570 | PEER_CAP_REFRESH_OLD_RCV)) | |
10571 | vty_out(vty, " %sreceived(%s)", | |
10572 | CHECK_FLAG( | |
10573 | p->cap, | |
10574 | PEER_CAP_REFRESH_ADV) | |
10575 | ? "and " | |
10576 | : "", | |
10577 | (CHECK_FLAG( | |
10578 | p->cap, | |
10579 | PEER_CAP_REFRESH_OLD_RCV) | |
10580 | && CHECK_FLAG( | |
10581 | p->cap, | |
10582 | PEER_CAP_REFRESH_NEW_RCV)) | |
10583 | ? "old & new" | |
10584 | : CHECK_FLAG( | |
10585 | p->cap, | |
10586 | PEER_CAP_REFRESH_OLD_RCV) | |
10587 | ? "old" | |
10588 | : "new"); | |
10589 | ||
10590 | vty_out(vty, "\n"); | |
10591 | } | |
10592 | ||
10593 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
10594 | FOREACH_AFI_SAFI (afi, safi) |
10595 | if (p->afc_adv[afi][safi] | |
10596 | || p->afc_recv[afi][safi]) { | |
10597 | vty_out(vty, | |
10598 | " Address Family %s:", | |
5cb5f4d0 DD |
10599 | get_afi_safi_str( |
10600 | afi, | |
10601 | safi, | |
10602 | false)); | |
05c7a1cc | 10603 | if (p->afc_adv[afi][safi]) |
d62a17ae | 10604 | vty_out(vty, |
05c7a1cc QY |
10605 | " advertised"); |
10606 | if (p->afc_recv[afi][safi]) | |
10607 | vty_out(vty, | |
10608 | " %sreceived", | |
10609 | p->afc_adv[afi] | |
10610 | [safi] | |
10611 | ? "and " | |
10612 | : ""); | |
10613 | vty_out(vty, "\n"); | |
10614 | } | |
d62a17ae | 10615 | |
10616 | /* Hostname capability */ | |
60466a63 | 10617 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10618 | |
10619 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10620 | vty_out(vty, |
10621 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10622 | bgp->peer_self->hostname |
10623 | ? bgp->peer_self | |
10624 | ->hostname | |
d77114b7 | 10625 | : "n/a", |
60466a63 QY |
10626 | bgp->peer_self->domainname |
10627 | ? bgp->peer_self | |
10628 | ->domainname | |
d77114b7 MK |
10629 | : "n/a"); |
10630 | } else { | |
10631 | vty_out(vty, " not advertised"); | |
d62a17ae | 10632 | } |
10633 | ||
d77114b7 | 10634 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10635 | vty_out(vty, |
10636 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10637 | p->hostname ? p->hostname |
10638 | : "n/a", | |
10639 | p->domainname ? p->domainname | |
10640 | : "n/a"); | |
d77114b7 MK |
10641 | } else { |
10642 | vty_out(vty, " not received"); | |
10643 | } | |
10644 | ||
10645 | vty_out(vty, "\n"); | |
10646 | ||
d62a17ae | 10647 | /* Gracefull Restart */ |
10648 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10649 | || CHECK_FLAG(p->cap, | |
10650 | PEER_CAP_RESTART_ADV)) { | |
10651 | vty_out(vty, | |
10652 | " Graceful Restart Capabilty:"); | |
10653 | if (CHECK_FLAG(p->cap, | |
10654 | PEER_CAP_RESTART_ADV)) | |
10655 | vty_out(vty, " advertised"); | |
10656 | if (CHECK_FLAG(p->cap, | |
10657 | PEER_CAP_RESTART_RCV)) | |
10658 | vty_out(vty, " %sreceived", | |
10659 | CHECK_FLAG( | |
10660 | p->cap, | |
10661 | PEER_CAP_RESTART_ADV) | |
10662 | ? "and " | |
10663 | : ""); | |
10664 | vty_out(vty, "\n"); | |
10665 | ||
10666 | if (CHECK_FLAG(p->cap, | |
10667 | PEER_CAP_RESTART_RCV)) { | |
10668 | int restart_af_count = 0; | |
10669 | ||
10670 | vty_out(vty, | |
10671 | " Remote Restart timer is %d seconds\n", | |
10672 | p->v_gr_restart); | |
10673 | vty_out(vty, | |
10674 | " Address families by peer:\n "); | |
10675 | ||
05c7a1cc QY |
10676 | FOREACH_AFI_SAFI (afi, safi) |
10677 | if (CHECK_FLAG( | |
10678 | p->af_cap | |
10679 | [afi] | |
10680 | [safi], | |
10681 | PEER_CAP_RESTART_AF_RCV)) { | |
10682 | vty_out(vty, | |
10683 | "%s%s(%s)", | |
10684 | restart_af_count | |
10685 | ? ", " | |
10686 | : "", | |
5cb5f4d0 | 10687 | get_afi_safi_str( |
05c7a1cc | 10688 | afi, |
5cb5f4d0 DD |
10689 | safi, |
10690 | false), | |
05c7a1cc QY |
10691 | CHECK_FLAG( |
10692 | p->af_cap | |
10693 | [afi] | |
10694 | [safi], | |
10695 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10696 | ? "preserved" | |
10697 | : "not preserved"); | |
10698 | restart_af_count++; | |
10699 | } | |
d62a17ae | 10700 | if (!restart_af_count) |
10701 | vty_out(vty, "none"); | |
10702 | vty_out(vty, "\n"); | |
10703 | } | |
10704 | } | |
10705 | } | |
10706 | } | |
10707 | } | |
10708 | ||
10709 | /* graceful restart information */ | |
10710 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10711 | || p->t_gr_stale) { | |
10712 | json_object *json_grace = NULL; | |
10713 | json_object *json_grace_send = NULL; | |
10714 | json_object *json_grace_recv = NULL; | |
10715 | int eor_send_af_count = 0; | |
10716 | int eor_receive_af_count = 0; | |
10717 | ||
10718 | if (use_json) { | |
10719 | json_grace = json_object_new_object(); | |
10720 | json_grace_send = json_object_new_object(); | |
10721 | json_grace_recv = json_object_new_object(); | |
10722 | ||
10723 | if (p->status == Established) { | |
05c7a1cc QY |
10724 | FOREACH_AFI_SAFI (afi, safi) { |
10725 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10726 | PEER_STATUS_EOR_SEND)) { | |
10727 | json_object_boolean_true_add( | |
10728 | json_grace_send, | |
5cb5f4d0 DD |
10729 | get_afi_safi_str(afi, |
10730 | safi, | |
10731 | true)); | |
05c7a1cc | 10732 | eor_send_af_count++; |
d62a17ae | 10733 | } |
10734 | } | |
05c7a1cc QY |
10735 | FOREACH_AFI_SAFI (afi, safi) { |
10736 | if (CHECK_FLAG( | |
10737 | p->af_sflags[afi][safi], | |
10738 | PEER_STATUS_EOR_RECEIVED)) { | |
10739 | json_object_boolean_true_add( | |
10740 | json_grace_recv, | |
5cb5f4d0 DD |
10741 | get_afi_safi_str(afi, |
10742 | safi, | |
10743 | true)); | |
05c7a1cc | 10744 | eor_receive_af_count++; |
d62a17ae | 10745 | } |
10746 | } | |
10747 | } | |
10748 | ||
10749 | json_object_object_add(json_grace, "endOfRibSend", | |
10750 | json_grace_send); | |
10751 | json_object_object_add(json_grace, "endOfRibRecv", | |
10752 | json_grace_recv); | |
10753 | ||
10754 | if (p->t_gr_restart) | |
10755 | json_object_int_add(json_grace, | |
10756 | "gracefulRestartTimerMsecs", | |
10757 | thread_timer_remain_second( | |
10758 | p->t_gr_restart) | |
10759 | * 1000); | |
10760 | ||
10761 | if (p->t_gr_stale) | |
10762 | json_object_int_add( | |
10763 | json_grace, | |
10764 | "gracefulStalepathTimerMsecs", | |
10765 | thread_timer_remain_second( | |
10766 | p->t_gr_stale) | |
10767 | * 1000); | |
10768 | ||
10769 | json_object_object_add( | |
10770 | json_neigh, "gracefulRestartInfo", json_grace); | |
10771 | } else { | |
0437e105 | 10772 | vty_out(vty, " Graceful restart information:\n"); |
d62a17ae | 10773 | if (p->status == Established) { |
10774 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10775 | FOREACH_AFI_SAFI (afi, safi) { |
10776 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10777 | PEER_STATUS_EOR_SEND)) { | |
10778 | vty_out(vty, "%s%s", | |
10779 | eor_send_af_count ? ", " | |
10780 | : "", | |
5cb5f4d0 DD |
10781 | get_afi_safi_str(afi, |
10782 | safi, | |
10783 | false)); | |
05c7a1cc | 10784 | eor_send_af_count++; |
d62a17ae | 10785 | } |
10786 | } | |
10787 | vty_out(vty, "\n"); | |
10788 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10789 | FOREACH_AFI_SAFI (afi, safi) { |
10790 | if (CHECK_FLAG( | |
10791 | p->af_sflags[afi][safi], | |
10792 | PEER_STATUS_EOR_RECEIVED)) { | |
10793 | vty_out(vty, "%s%s", | |
10794 | eor_receive_af_count | |
10795 | ? ", " | |
10796 | : "", | |
5cb5f4d0 DD |
10797 | get_afi_safi_str(afi, |
10798 | safi, | |
10799 | false)); | |
05c7a1cc | 10800 | eor_receive_af_count++; |
d62a17ae | 10801 | } |
10802 | } | |
10803 | vty_out(vty, "\n"); | |
10804 | } | |
10805 | ||
10806 | if (p->t_gr_restart) | |
10807 | vty_out(vty, | |
10808 | " The remaining time of restart timer is %ld\n", | |
10809 | thread_timer_remain_second( | |
10810 | p->t_gr_restart)); | |
10811 | ||
10812 | if (p->t_gr_stale) | |
10813 | vty_out(vty, | |
10814 | " The remaining time of stalepath timer is %ld\n", | |
10815 | thread_timer_remain_second( | |
10816 | p->t_gr_stale)); | |
10817 | } | |
10818 | } | |
10819 | if (use_json) { | |
10820 | json_object *json_stat = NULL; | |
10821 | json_stat = json_object_new_object(); | |
10822 | /* Packet counts. */ | |
10823 | json_object_int_add(json_stat, "depthInq", 0); | |
10824 | json_object_int_add(json_stat, "depthOutq", | |
10825 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10826 | json_object_int_add(json_stat, "opensSent", |
10827 | atomic_load_explicit(&p->open_out, | |
10828 | memory_order_relaxed)); | |
10829 | json_object_int_add(json_stat, "opensRecv", | |
10830 | atomic_load_explicit(&p->open_in, | |
10831 | memory_order_relaxed)); | |
d62a17ae | 10832 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10833 | atomic_load_explicit(&p->notify_out, |
10834 | memory_order_relaxed)); | |
d62a17ae | 10835 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10836 | atomic_load_explicit(&p->notify_in, |
10837 | memory_order_relaxed)); | |
10838 | json_object_int_add(json_stat, "updatesSent", | |
10839 | atomic_load_explicit(&p->update_out, | |
10840 | memory_order_relaxed)); | |
10841 | json_object_int_add(json_stat, "updatesRecv", | |
10842 | atomic_load_explicit(&p->update_in, | |
10843 | memory_order_relaxed)); | |
d62a17ae | 10844 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10845 | atomic_load_explicit(&p->keepalive_out, |
10846 | memory_order_relaxed)); | |
d62a17ae | 10847 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10848 | atomic_load_explicit(&p->keepalive_in, |
10849 | memory_order_relaxed)); | |
d62a17ae | 10850 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10851 | atomic_load_explicit(&p->refresh_out, |
10852 | memory_order_relaxed)); | |
d62a17ae | 10853 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10854 | atomic_load_explicit(&p->refresh_in, |
10855 | memory_order_relaxed)); | |
d62a17ae | 10856 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10857 | atomic_load_explicit(&p->dynamic_cap_out, |
10858 | memory_order_relaxed)); | |
d62a17ae | 10859 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10860 | atomic_load_explicit(&p->dynamic_cap_in, |
10861 | memory_order_relaxed)); | |
10862 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10863 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10864 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10865 | } else { | |
10866 | /* Packet counts. */ | |
10867 | vty_out(vty, " Message statistics:\n"); | |
10868 | vty_out(vty, " Inq depth is 0\n"); | |
10869 | vty_out(vty, " Outq depth is %lu\n", | |
10870 | (unsigned long)p->obuf->count); | |
10871 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10872 | vty_out(vty, " Opens: %10d %10d\n", |
10873 | atomic_load_explicit(&p->open_out, | |
10874 | memory_order_relaxed), | |
10875 | atomic_load_explicit(&p->open_in, | |
10876 | memory_order_relaxed)); | |
10877 | vty_out(vty, " Notifications: %10d %10d\n", | |
10878 | atomic_load_explicit(&p->notify_out, | |
10879 | memory_order_relaxed), | |
10880 | atomic_load_explicit(&p->notify_in, | |
10881 | memory_order_relaxed)); | |
10882 | vty_out(vty, " Updates: %10d %10d\n", | |
10883 | atomic_load_explicit(&p->update_out, | |
10884 | memory_order_relaxed), | |
10885 | atomic_load_explicit(&p->update_in, | |
10886 | memory_order_relaxed)); | |
10887 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10888 | atomic_load_explicit(&p->keepalive_out, | |
10889 | memory_order_relaxed), | |
10890 | atomic_load_explicit(&p->keepalive_in, | |
10891 | memory_order_relaxed)); | |
10892 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10893 | atomic_load_explicit(&p->refresh_out, | |
10894 | memory_order_relaxed), | |
10895 | atomic_load_explicit(&p->refresh_in, | |
10896 | memory_order_relaxed)); | |
d62a17ae | 10897 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10898 | atomic_load_explicit(&p->dynamic_cap_out, |
10899 | memory_order_relaxed), | |
10900 | atomic_load_explicit(&p->dynamic_cap_in, | |
10901 | memory_order_relaxed)); | |
10902 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10903 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10904 | } |
10905 | ||
10906 | if (use_json) { | |
10907 | /* advertisement-interval */ | |
10908 | json_object_int_add(json_neigh, | |
10909 | "minBtwnAdvertisementRunsTimerMsecs", | |
10910 | p->v_routeadv * 1000); | |
10911 | ||
10912 | /* Update-source. */ | |
10913 | if (p->update_if || p->update_source) { | |
10914 | if (p->update_if) | |
10915 | json_object_string_add(json_neigh, | |
10916 | "updateSource", | |
10917 | p->update_if); | |
10918 | else if (p->update_source) | |
10919 | json_object_string_add( | |
10920 | json_neigh, "updateSource", | |
10921 | sockunion2str(p->update_source, buf1, | |
10922 | SU_ADDRSTRLEN)); | |
10923 | } | |
10924 | } else { | |
10925 | /* advertisement-interval */ | |
10926 | vty_out(vty, | |
10927 | " Minimum time between advertisement runs is %d seconds\n", | |
10928 | p->v_routeadv); | |
10929 | ||
10930 | /* Update-source. */ | |
10931 | if (p->update_if || p->update_source) { | |
10932 | vty_out(vty, " Update source is "); | |
10933 | if (p->update_if) | |
10934 | vty_out(vty, "%s", p->update_if); | |
10935 | else if (p->update_source) | |
10936 | vty_out(vty, "%s", | |
10937 | sockunion2str(p->update_source, buf1, | |
10938 | SU_ADDRSTRLEN)); | |
10939 | vty_out(vty, "\n"); | |
10940 | } | |
10941 | ||
10942 | vty_out(vty, "\n"); | |
10943 | } | |
10944 | ||
10945 | /* Address Family Information */ | |
10946 | json_object *json_hold = NULL; | |
10947 | ||
10948 | if (use_json) | |
10949 | json_hold = json_object_new_object(); | |
10950 | ||
05c7a1cc QY |
10951 | FOREACH_AFI_SAFI (afi, safi) |
10952 | if (p->afc[afi][safi]) | |
10953 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10954 | json_hold); | |
d62a17ae | 10955 | |
10956 | if (use_json) { | |
10957 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10958 | json_hold); | |
10959 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10960 | p->established); | |
10961 | json_object_int_add(json_neigh, "connectionsDropped", | |
10962 | p->dropped); | |
10963 | } else | |
10964 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10965 | p->established, p->dropped); | |
10966 | ||
10967 | if (!p->last_reset) { | |
10968 | if (use_json) | |
10969 | json_object_string_add(json_neigh, "lastReset", | |
10970 | "never"); | |
10971 | else | |
10972 | vty_out(vty, " Last reset never\n"); | |
10973 | } else { | |
10974 | if (use_json) { | |
10975 | time_t uptime; | |
10976 | struct tm *tm; | |
10977 | ||
10978 | uptime = bgp_clock(); | |
10979 | uptime -= p->resettime; | |
10980 | tm = gmtime(&uptime); | |
10981 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10982 | (tm->tm_sec * 1000) | |
10983 | + (tm->tm_min * 60000) | |
10984 | + (tm->tm_hour * 3600000)); | |
3577f1c5 | 10985 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 10986 | } else { |
10987 | vty_out(vty, " Last reset %s, ", | |
10988 | peer_uptime(p->resettime, timebuf, | |
10989 | BGP_UPTIME_LEN, 0, NULL)); | |
10990 | ||
3577f1c5 | 10991 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 10992 | if (p->last_reset_cause_size) { |
10993 | msg = p->last_reset_cause; | |
10994 | vty_out(vty, | |
10995 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10996 | for (i = 1; i <= p->last_reset_cause_size; | |
10997 | i++) { | |
10998 | vty_out(vty, "%02X", *msg++); | |
10999 | ||
11000 | if (i != p->last_reset_cause_size) { | |
11001 | if (i % 16 == 0) { | |
11002 | vty_out(vty, "\n "); | |
11003 | } else if (i % 4 == 0) { | |
11004 | vty_out(vty, " "); | |
11005 | } | |
11006 | } | |
11007 | } | |
11008 | vty_out(vty, "\n"); | |
11009 | } | |
11010 | } | |
11011 | } | |
11012 | ||
11013 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
11014 | if (use_json) | |
11015 | json_object_boolean_true_add(json_neigh, | |
11016 | "prefixesConfigExceedMax"); | |
11017 | else | |
11018 | vty_out(vty, | |
11019 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
11020 | ||
11021 | if (p->t_pmax_restart) { | |
11022 | if (use_json) { | |
11023 | json_object_boolean_true_add( | |
11024 | json_neigh, "reducePrefixNumFrom"); | |
11025 | json_object_int_add(json_neigh, | |
11026 | "restartInTimerMsec", | |
11027 | thread_timer_remain_second( | |
11028 | p->t_pmax_restart) | |
11029 | * 1000); | |
11030 | } else | |
11031 | vty_out(vty, | |
11032 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
11033 | p->host, thread_timer_remain_second( |
11034 | p->t_pmax_restart)); | |
d62a17ae | 11035 | } else { |
11036 | if (use_json) | |
11037 | json_object_boolean_true_add( | |
11038 | json_neigh, | |
11039 | "reducePrefixNumAndClearIpBgp"); | |
11040 | else | |
11041 | vty_out(vty, | |
11042 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
11043 | p->host); | |
11044 | } | |
11045 | } | |
11046 | ||
11047 | /* EBGP Multihop and GTSM */ | |
11048 | if (p->sort != BGP_PEER_IBGP) { | |
11049 | if (use_json) { | |
11050 | if (p->gtsm_hops > 0) | |
11051 | json_object_int_add(json_neigh, | |
11052 | "externalBgpNbrMaxHopsAway", | |
11053 | p->gtsm_hops); | |
c8d6f0d6 | 11054 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11055 | json_object_int_add(json_neigh, |
11056 | "externalBgpNbrMaxHopsAway", | |
11057 | p->ttl); | |
11058 | } else { | |
11059 | if (p->gtsm_hops > 0) | |
11060 | vty_out(vty, | |
11061 | " External BGP neighbor may be up to %d hops away.\n", | |
11062 | p->gtsm_hops); | |
c8d6f0d6 | 11063 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11064 | vty_out(vty, |
11065 | " External BGP neighbor may be up to %d hops away.\n", | |
11066 | p->ttl); | |
11067 | } | |
11068 | } else { | |
11069 | if (p->gtsm_hops > 0) { | |
11070 | if (use_json) | |
11071 | json_object_int_add(json_neigh, | |
11072 | "internalBgpNbrMaxHopsAway", | |
11073 | p->gtsm_hops); | |
11074 | else | |
11075 | vty_out(vty, | |
11076 | " Internal BGP neighbor may be up to %d hops away.\n", | |
11077 | p->gtsm_hops); | |
11078 | } | |
11079 | } | |
11080 | ||
11081 | /* Local address. */ | |
11082 | if (p->su_local) { | |
11083 | if (use_json) { | |
11084 | json_object_string_add(json_neigh, "hostLocal", | |
11085 | sockunion2str(p->su_local, buf1, | |
11086 | SU_ADDRSTRLEN)); | |
11087 | json_object_int_add(json_neigh, "portLocal", | |
11088 | ntohs(p->su_local->sin.sin_port)); | |
11089 | } else | |
11090 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
11091 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
11092 | ntohs(p->su_local->sin.sin_port)); | |
11093 | } | |
11094 | ||
11095 | /* Remote address. */ | |
11096 | if (p->su_remote) { | |
11097 | if (use_json) { | |
11098 | json_object_string_add(json_neigh, "hostForeign", | |
11099 | sockunion2str(p->su_remote, buf1, | |
11100 | SU_ADDRSTRLEN)); | |
11101 | json_object_int_add(json_neigh, "portForeign", | |
11102 | ntohs(p->su_remote->sin.sin_port)); | |
11103 | } else | |
11104 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
11105 | sockunion2str(p->su_remote, buf1, | |
11106 | SU_ADDRSTRLEN), | |
11107 | ntohs(p->su_remote->sin.sin_port)); | |
11108 | } | |
11109 | ||
11110 | /* Nexthop display. */ | |
11111 | if (p->su_local) { | |
11112 | if (use_json) { | |
11113 | json_object_string_add(json_neigh, "nexthop", | |
11114 | inet_ntop(AF_INET, | |
11115 | &p->nexthop.v4, buf1, | |
11116 | sizeof(buf1))); | |
11117 | json_object_string_add(json_neigh, "nexthopGlobal", | |
11118 | inet_ntop(AF_INET6, | |
11119 | &p->nexthop.v6_global, | |
11120 | buf1, sizeof(buf1))); | |
11121 | json_object_string_add(json_neigh, "nexthopLocal", | |
11122 | inet_ntop(AF_INET6, | |
11123 | &p->nexthop.v6_local, | |
11124 | buf1, sizeof(buf1))); | |
11125 | if (p->shared_network) | |
11126 | json_object_string_add(json_neigh, | |
11127 | "bgpConnection", | |
11128 | "sharedNetwork"); | |
11129 | else | |
11130 | json_object_string_add(json_neigh, | |
11131 | "bgpConnection", | |
11132 | "nonSharedNetwork"); | |
11133 | } else { | |
11134 | vty_out(vty, "Nexthop: %s\n", | |
11135 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
11136 | sizeof(buf1))); | |
11137 | vty_out(vty, "Nexthop global: %s\n", | |
11138 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
11139 | sizeof(buf1))); | |
11140 | vty_out(vty, "Nexthop local: %s\n", | |
11141 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
11142 | sizeof(buf1))); | |
11143 | vty_out(vty, "BGP connection: %s\n", | |
11144 | p->shared_network ? "shared network" | |
11145 | : "non shared network"); | |
11146 | } | |
11147 | } | |
11148 | ||
11149 | /* Timer information. */ | |
11150 | if (use_json) { | |
11151 | json_object_int_add(json_neigh, "connectRetryTimer", | |
11152 | p->v_connect); | |
11153 | if (p->status == Established && p->rtt) | |
11154 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
11155 | p->rtt); | |
11156 | if (p->t_start) | |
11157 | json_object_int_add( | |
11158 | json_neigh, "nextStartTimerDueInMsecs", | |
11159 | thread_timer_remain_second(p->t_start) * 1000); | |
11160 | if (p->t_connect) | |
11161 | json_object_int_add( | |
11162 | json_neigh, "nextConnectTimerDueInMsecs", | |
11163 | thread_timer_remain_second(p->t_connect) | |
11164 | * 1000); | |
11165 | if (p->t_routeadv) { | |
11166 | json_object_int_add(json_neigh, "mraiInterval", | |
11167 | p->v_routeadv); | |
11168 | json_object_int_add( | |
11169 | json_neigh, "mraiTimerExpireInMsecs", | |
11170 | thread_timer_remain_second(p->t_routeadv) | |
11171 | * 1000); | |
11172 | } | |
11173 | if (p->password) | |
11174 | json_object_int_add(json_neigh, "authenticationEnabled", | |
11175 | 1); | |
11176 | ||
11177 | if (p->t_read) | |
11178 | json_object_string_add(json_neigh, "readThread", "on"); | |
11179 | else | |
11180 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
11181 | |
11182 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 11183 | json_object_string_add(json_neigh, "writeThread", "on"); |
11184 | else | |
11185 | json_object_string_add(json_neigh, "writeThread", | |
11186 | "off"); | |
11187 | } else { | |
11188 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
11189 | p->v_connect); | |
11190 | if (p->status == Established && p->rtt) | |
11191 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
11192 | p->rtt); | |
11193 | if (p->t_start) | |
11194 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
11195 | thread_timer_remain_second(p->t_start)); | |
11196 | if (p->t_connect) | |
11197 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
11198 | thread_timer_remain_second(p->t_connect)); | |
11199 | if (p->t_routeadv) | |
11200 | vty_out(vty, | |
11201 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
11202 | p->v_routeadv, | |
11203 | thread_timer_remain_second(p->t_routeadv)); | |
11204 | if (p->password) | |
11205 | vty_out(vty, "Peer Authentication Enabled\n"); | |
11206 | ||
cac9e917 | 11207 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
11208 | p->t_read ? "on" : "off", |
11209 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
11210 | ? "on" | |
cac9e917 | 11211 | : "off", p->fd); |
d62a17ae | 11212 | } |
11213 | ||
11214 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
11215 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
11216 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
11217 | ||
11218 | if (!use_json) | |
11219 | vty_out(vty, "\n"); | |
11220 | ||
11221 | /* BFD information. */ | |
11222 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
11223 | ||
11224 | if (use_json) { | |
11225 | if (p->conf_if) /* Configured interface name. */ | |
11226 | json_object_object_add(json, p->conf_if, json_neigh); | |
11227 | else /* Configured IP address. */ | |
11228 | json_object_object_add(json, p->host, json_neigh); | |
11229 | } | |
11230 | } | |
11231 | ||
11232 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
11233 | enum show_type type, union sockunion *su, | |
9f049418 | 11234 | const char *conf_if, bool use_json, |
d62a17ae | 11235 | json_object *json) |
11236 | { | |
11237 | struct listnode *node, *nnode; | |
11238 | struct peer *peer; | |
11239 | int find = 0; | |
9f049418 | 11240 | bool nbr_output = false; |
d1927ebe AS |
11241 | afi_t afi = AFI_MAX; |
11242 | safi_t safi = SAFI_MAX; | |
11243 | ||
11244 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
11245 | afi = AFI_IP; | |
11246 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
11247 | afi = AFI_IP6; | |
11248 | } | |
d62a17ae | 11249 | |
11250 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
11251 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
11252 | continue; | |
11253 | ||
11254 | switch (type) { | |
11255 | case show_all: | |
11256 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 11257 | nbr_output = true; |
d62a17ae | 11258 | break; |
11259 | case show_peer: | |
11260 | if (conf_if) { | |
11261 | if ((peer->conf_if | |
11262 | && !strcmp(peer->conf_if, conf_if)) | |
11263 | || (peer->hostname | |
11264 | && !strcmp(peer->hostname, conf_if))) { | |
11265 | find = 1; | |
11266 | bgp_show_peer(vty, peer, use_json, | |
11267 | json); | |
11268 | } | |
11269 | } else { | |
11270 | if (sockunion_same(&peer->su, su)) { | |
11271 | find = 1; | |
11272 | bgp_show_peer(vty, peer, use_json, | |
11273 | json); | |
11274 | } | |
11275 | } | |
11276 | break; | |
d1927ebe AS |
11277 | case show_ipv4_peer: |
11278 | case show_ipv6_peer: | |
11279 | FOREACH_SAFI (safi) { | |
11280 | if (peer->afc[afi][safi]) { | |
11281 | if (conf_if) { | |
11282 | if ((peer->conf_if | |
11283 | && !strcmp(peer->conf_if, conf_if)) | |
11284 | || (peer->hostname | |
11285 | && !strcmp(peer->hostname, conf_if))) { | |
11286 | find = 1; | |
11287 | bgp_show_peer(vty, peer, use_json, | |
11288 | json); | |
11289 | break; | |
11290 | } | |
11291 | } else { | |
11292 | if (sockunion_same(&peer->su, su)) { | |
11293 | find = 1; | |
11294 | bgp_show_peer(vty, peer, use_json, | |
11295 | json); | |
11296 | break; | |
11297 | } | |
11298 | } | |
11299 | } | |
11300 | } | |
11301 | break; | |
11302 | case show_ipv4_all: | |
11303 | case show_ipv6_all: | |
11304 | FOREACH_SAFI (safi) { | |
11305 | if (peer->afc[afi][safi]) { | |
11306 | bgp_show_peer(vty, peer, use_json, json); | |
11307 | nbr_output = true; | |
11308 | break; | |
11309 | } | |
11310 | } | |
11311 | break; | |
d62a17ae | 11312 | } |
11313 | } | |
11314 | ||
d1927ebe AS |
11315 | if ((type == show_peer || type == show_ipv4_peer || |
11316 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 11317 | if (use_json) |
11318 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
11319 | else | |
88b7d255 | 11320 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 11321 | } |
11322 | ||
d1927ebe AS |
11323 | if (type != show_peer && type != show_ipv4_peer && |
11324 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 11325 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 11326 | |
d62a17ae | 11327 | if (use_json) { |
996c9314 LB |
11328 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
11329 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 11330 | } else { |
11331 | vty_out(vty, "\n"); | |
11332 | } | |
11333 | ||
11334 | return CMD_SUCCESS; | |
11335 | } | |
11336 | ||
11337 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
11338 | enum show_type type, |
11339 | const char *ip_str, | |
9f049418 | 11340 | bool use_json) |
d62a17ae | 11341 | { |
0291c246 MK |
11342 | struct listnode *node, *nnode; |
11343 | struct bgp *bgp; | |
71aedaa3 | 11344 | union sockunion su; |
0291c246 | 11345 | json_object *json = NULL; |
71aedaa3 | 11346 | int ret, is_first = 1; |
9f049418 | 11347 | bool nbr_output = false; |
d62a17ae | 11348 | |
11349 | if (use_json) | |
11350 | vty_out(vty, "{\n"); | |
11351 | ||
11352 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11353 | nbr_output = true; |
d62a17ae | 11354 | if (use_json) { |
11355 | if (!(json = json_object_new_object())) { | |
af4c2728 | 11356 | flog_err( |
e50f7cfd | 11357 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 11358 | "Unable to allocate memory for JSON object"); |
11359 | vty_out(vty, | |
11360 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
11361 | return; | |
11362 | } | |
11363 | ||
11364 | json_object_int_add(json, "vrfId", | |
11365 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
11366 | ? -1 |
11367 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 11368 | json_object_string_add( |
11369 | json, "vrfName", | |
11370 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11371 | ? VRF_DEFAULT_NAME |
d62a17ae | 11372 | : bgp->name); |
11373 | ||
11374 | if (!is_first) | |
11375 | vty_out(vty, ",\n"); | |
11376 | else | |
11377 | is_first = 0; | |
11378 | ||
11379 | vty_out(vty, "\"%s\":", | |
11380 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11381 | ? VRF_DEFAULT_NAME |
d62a17ae | 11382 | : bgp->name); |
11383 | } else { | |
11384 | vty_out(vty, "\nInstance %s:\n", | |
11385 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11386 | ? VRF_DEFAULT_NAME |
d62a17ae | 11387 | : bgp->name); |
11388 | } | |
71aedaa3 | 11389 | |
d1927ebe AS |
11390 | if (type == show_peer || type == show_ipv4_peer || |
11391 | type == show_ipv6_peer) { | |
71aedaa3 DS |
11392 | ret = str2sockunion(ip_str, &su); |
11393 | if (ret < 0) | |
11394 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11395 | use_json, json); | |
11396 | else | |
11397 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11398 | use_json, json); | |
11399 | } else { | |
d1927ebe | 11400 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
11401 | use_json, json); |
11402 | } | |
b77004d6 | 11403 | json_object_free(json); |
d62a17ae | 11404 | } |
11405 | ||
01cbfd04 | 11406 | if (use_json) { |
d62a17ae | 11407 | vty_out(vty, "}\n"); |
01cbfd04 QY |
11408 | json_object_free(json); |
11409 | } | |
9f049418 DS |
11410 | else if (!nbr_output) |
11411 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11412 | } |
11413 | ||
11414 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
11415 | enum show_type type, const char *ip_str, | |
9f049418 | 11416 | bool use_json) |
d62a17ae | 11417 | { |
11418 | int ret; | |
11419 | struct bgp *bgp; | |
11420 | union sockunion su; | |
11421 | json_object *json = NULL; | |
11422 | ||
11423 | if (name) { | |
11424 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
11425 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
11426 | use_json); | |
d62a17ae | 11427 | return CMD_SUCCESS; |
11428 | } else { | |
11429 | bgp = bgp_lookup_by_name(name); | |
11430 | if (!bgp) { | |
11431 | if (use_json) { | |
11432 | json = json_object_new_object(); | |
d62a17ae | 11433 | vty_out(vty, "%s\n", |
11434 | json_object_to_json_string_ext( | |
11435 | json, | |
11436 | JSON_C_TO_STRING_PRETTY)); | |
11437 | json_object_free(json); | |
11438 | } else | |
11439 | vty_out(vty, | |
9f049418 | 11440 | "%% BGP instance not found\n"); |
d62a17ae | 11441 | |
11442 | return CMD_WARNING; | |
11443 | } | |
11444 | } | |
11445 | } else { | |
11446 | bgp = bgp_get_default(); | |
11447 | } | |
11448 | ||
11449 | if (bgp) { | |
11450 | json = json_object_new_object(); | |
11451 | if (ip_str) { | |
11452 | ret = str2sockunion(ip_str, &su); | |
11453 | if (ret < 0) | |
11454 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11455 | use_json, json); | |
11456 | else | |
11457 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11458 | use_json, json); | |
11459 | } else { | |
11460 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
11461 | json); | |
11462 | } | |
11463 | json_object_free(json); | |
ca61fd25 DS |
11464 | } else { |
11465 | if (use_json) | |
11466 | vty_out(vty, "{}\n"); | |
11467 | else | |
11468 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11469 | } |
11470 | ||
11471 | return CMD_SUCCESS; | |
4fb25c53 DW |
11472 | } |
11473 | ||
716b2d8a | 11474 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11475 | DEFUN (show_ip_bgp_neighbors, |
11476 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 11477 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 11478 | SHOW_STR |
11479 | IP_STR | |
11480 | BGP_STR | |
f2a8972b | 11481 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
11482 | "Address Family\n" |
11483 | "Address Family\n" | |
718e3744 | 11484 | "Detailed information on TCP and BGP neighbor connections\n" |
11485 | "Neighbor to display information about\n" | |
a80beece | 11486 | "Neighbor to display information about\n" |
91d37724 | 11487 | "Neighbor on BGP configured interface\n" |
9973d184 | 11488 | JSON_STR) |
718e3744 | 11489 | { |
d62a17ae | 11490 | char *vrf = NULL; |
11491 | char *sh_arg = NULL; | |
11492 | enum show_type sh_type; | |
d1927ebe | 11493 | afi_t afi = AFI_MAX; |
718e3744 | 11494 | |
9f049418 | 11495 | bool uj = use_json(argc, argv); |
718e3744 | 11496 | |
d62a17ae | 11497 | int idx = 0; |
718e3744 | 11498 | |
9a8bdf1c PG |
11499 | /* [<vrf> VIEWVRFNAME] */ |
11500 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11501 | vrf = argv[idx + 1]->arg; | |
11502 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11503 | vrf = NULL; | |
11504 | } else if (argv_find(argv, argc, "view", &idx)) | |
11505 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 11506 | vrf = argv[idx + 1]->arg; |
718e3744 | 11507 | |
d62a17ae | 11508 | idx++; |
d1927ebe AS |
11509 | |
11510 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
11511 | sh_type = show_ipv4_all; | |
11512 | afi = AFI_IP; | |
11513 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
11514 | sh_type = show_ipv6_all; | |
11515 | afi = AFI_IP6; | |
11516 | } else { | |
11517 | sh_type = show_all; | |
11518 | } | |
11519 | ||
d62a17ae | 11520 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
11521 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
11522 | || argv_find(argv, argc, "WORD", &idx)) { | |
11523 | sh_type = show_peer; | |
11524 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
11525 | } |
11526 | ||
11527 | if (sh_type == show_peer && afi == AFI_IP) { | |
11528 | sh_type = show_ipv4_peer; | |
11529 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
11530 | sh_type = show_ipv6_peer; | |
11531 | } | |
856ca177 | 11532 | |
d62a17ae | 11533 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 11534 | } |
11535 | ||
716b2d8a | 11536 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 11537 | paths' and `show ip mbgp paths'. Those functions results are the |
11538 | same.*/ | |
f412b39a | 11539 | DEFUN (show_ip_bgp_paths, |
718e3744 | 11540 | show_ip_bgp_paths_cmd, |
46f296b4 | 11541 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 11542 | SHOW_STR |
11543 | IP_STR | |
11544 | BGP_STR | |
46f296b4 | 11545 | BGP_SAFI_HELP_STR |
718e3744 | 11546 | "Path information\n") |
11547 | { | |
d62a17ae | 11548 | vty_out(vty, "Address Refcnt Path\n"); |
11549 | aspath_print_all_vty(vty); | |
11550 | return CMD_SUCCESS; | |
718e3744 | 11551 | } |
11552 | ||
718e3744 | 11553 | #include "hash.h" |
11554 | ||
e3b78da8 | 11555 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11556 | struct vty *vty) |
718e3744 | 11557 | { |
d62a17ae | 11558 | struct community *com; |
718e3744 | 11559 | |
e3b78da8 | 11560 | com = (struct community *)bucket->data; |
3f65c5b1 | 11561 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 11562 | community_str(com, false)); |
718e3744 | 11563 | } |
11564 | ||
11565 | /* Show BGP's community internal data. */ | |
f412b39a | 11566 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 11567 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 11568 | "show [ip] bgp community-info", |
718e3744 | 11569 | SHOW_STR |
11570 | IP_STR | |
11571 | BGP_STR | |
11572 | "List all bgp community information\n") | |
11573 | { | |
d62a17ae | 11574 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 11575 | |
d62a17ae | 11576 | hash_iterate(community_hash(), |
e3b78da8 | 11577 | (void (*)(struct hash_bucket *, |
d62a17ae | 11578 | void *))community_show_all_iterator, |
11579 | vty); | |
718e3744 | 11580 | |
d62a17ae | 11581 | return CMD_SUCCESS; |
718e3744 | 11582 | } |
11583 | ||
e3b78da8 | 11584 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11585 | struct vty *vty) |
57d187bc | 11586 | { |
d62a17ae | 11587 | struct lcommunity *lcom; |
57d187bc | 11588 | |
e3b78da8 | 11589 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 11590 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 11591 | lcommunity_str(lcom, false)); |
57d187bc JS |
11592 | } |
11593 | ||
11594 | /* Show BGP's community internal data. */ | |
11595 | DEFUN (show_ip_bgp_lcommunity_info, | |
11596 | show_ip_bgp_lcommunity_info_cmd, | |
11597 | "show ip bgp large-community-info", | |
11598 | SHOW_STR | |
11599 | IP_STR | |
11600 | BGP_STR | |
11601 | "List all bgp large-community information\n") | |
11602 | { | |
d62a17ae | 11603 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 11604 | |
d62a17ae | 11605 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 11606 | (void (*)(struct hash_bucket *, |
d62a17ae | 11607 | void *))lcommunity_show_all_iterator, |
11608 | vty); | |
57d187bc | 11609 | |
d62a17ae | 11610 | return CMD_SUCCESS; |
57d187bc JS |
11611 | } |
11612 | ||
11613 | ||
f412b39a | 11614 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 11615 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 11616 | "show [ip] bgp attribute-info", |
718e3744 | 11617 | SHOW_STR |
11618 | IP_STR | |
11619 | BGP_STR | |
11620 | "List all bgp attribute information\n") | |
11621 | { | |
d62a17ae | 11622 | attr_show_all(vty); |
11623 | return CMD_SUCCESS; | |
718e3744 | 11624 | } |
6b0655a2 | 11625 | |
03915806 CS |
11626 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
11627 | afi_t afi, safi_t safi, | |
11628 | bool use_json, json_object *json) | |
53089bec | 11629 | { |
11630 | struct bgp *bgp; | |
11631 | struct listnode *node; | |
11632 | char *vname; | |
11633 | char buf1[INET6_ADDRSTRLEN]; | |
11634 | char *ecom_str; | |
11635 | vpn_policy_direction_t dir; | |
11636 | ||
03915806 | 11637 | if (json) { |
b46dfd20 DS |
11638 | json_object *json_import_vrfs = NULL; |
11639 | json_object *json_export_vrfs = NULL; | |
11640 | ||
b46dfd20 DS |
11641 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11642 | ||
53089bec | 11643 | if (!bgp) { |
b46dfd20 DS |
11644 | vty_out(vty, "%s\n", |
11645 | json_object_to_json_string_ext( | |
11646 | json, | |
11647 | JSON_C_TO_STRING_PRETTY)); | |
11648 | json_object_free(json); | |
11649 | ||
53089bec | 11650 | return CMD_WARNING; |
11651 | } | |
b46dfd20 | 11652 | |
94d4c685 DS |
11653 | /* Provide context for the block */ |
11654 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11655 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 11656 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 11657 | |
b46dfd20 DS |
11658 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11659 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11660 | json_object_string_add(json, "importFromVrfs", "none"); | |
11661 | json_object_string_add(json, "importRts", "none"); | |
11662 | } else { | |
6ce24e52 DS |
11663 | json_import_vrfs = json_object_new_array(); |
11664 | ||
b46dfd20 DS |
11665 | for (ALL_LIST_ELEMENTS_RO( |
11666 | bgp->vpn_policy[afi].import_vrf, | |
11667 | node, vname)) | |
11668 | json_object_array_add(json_import_vrfs, | |
11669 | json_object_new_string(vname)); | |
11670 | ||
b20875ea CS |
11671 | json_object_object_add(json, "importFromVrfs", |
11672 | json_import_vrfs); | |
b46dfd20 | 11673 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
11674 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11675 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11676 | bgp->vpn_policy[afi].rtlist[dir], |
11677 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11678 | json_object_string_add(json, "importRts", |
11679 | ecom_str); | |
11680 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11681 | } else | |
11682 | json_object_string_add(json, "importRts", | |
11683 | "none"); | |
b46dfd20 DS |
11684 | } |
11685 | ||
11686 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11687 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11688 | json_object_string_add(json, "exportToVrfs", "none"); | |
11689 | json_object_string_add(json, "routeDistinguisher", | |
11690 | "none"); | |
11691 | json_object_string_add(json, "exportRts", "none"); | |
11692 | } else { | |
6ce24e52 DS |
11693 | json_export_vrfs = json_object_new_array(); |
11694 | ||
b46dfd20 DS |
11695 | for (ALL_LIST_ELEMENTS_RO( |
11696 | bgp->vpn_policy[afi].export_vrf, | |
11697 | node, vname)) | |
11698 | json_object_array_add(json_export_vrfs, | |
11699 | json_object_new_string(vname)); | |
11700 | json_object_object_add(json, "exportToVrfs", | |
11701 | json_export_vrfs); | |
11702 | json_object_string_add(json, "routeDistinguisher", | |
11703 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11704 | buf1, RD_ADDRSTRLEN)); | |
11705 | ||
11706 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
11707 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11708 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11709 | bgp->vpn_policy[afi].rtlist[dir], |
11710 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11711 | json_object_string_add(json, "exportRts", |
11712 | ecom_str); | |
11713 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11714 | } else | |
11715 | json_object_string_add(json, "exportRts", | |
11716 | "none"); | |
b46dfd20 DS |
11717 | } |
11718 | ||
03915806 CS |
11719 | if (use_json) { |
11720 | vty_out(vty, "%s\n", | |
11721 | json_object_to_json_string_ext(json, | |
b46dfd20 | 11722 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
11723 | json_object_free(json); |
11724 | } | |
53089bec | 11725 | } else { |
b46dfd20 DS |
11726 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11727 | ||
53089bec | 11728 | if (!bgp) { |
b46dfd20 | 11729 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11730 | return CMD_WARNING; |
11731 | } | |
53089bec | 11732 | |
b46dfd20 DS |
11733 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11734 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11735 | vty_out(vty, | |
11736 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 11737 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11738 | else { |
11739 | vty_out(vty, | |
11740 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 11741 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11742 | |
11743 | for (ALL_LIST_ELEMENTS_RO( | |
11744 | bgp->vpn_policy[afi].import_vrf, | |
11745 | node, vname)) | |
11746 | vty_out(vty, " %s\n", vname); | |
11747 | ||
11748 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
11749 | ecom_str = NULL; |
11750 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
11751 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11752 | bgp->vpn_policy[afi].rtlist[dir], |
11753 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 11754 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 11755 | |
b20875ea CS |
11756 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
11757 | } else | |
11758 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 11759 | } |
53089bec | 11760 | |
b46dfd20 DS |
11761 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11762 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11763 | vty_out(vty, | |
11764 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 11765 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11766 | else { |
11767 | vty_out(vty, | |
04c9077f | 11768 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 11769 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
11770 | |
11771 | for (ALL_LIST_ELEMENTS_RO( | |
11772 | bgp->vpn_policy[afi].export_vrf, | |
11773 | node, vname)) | |
11774 | vty_out(vty, " %s\n", vname); | |
11775 | ||
11776 | vty_out(vty, "RD: %s\n", | |
11777 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11778 | buf1, RD_ADDRSTRLEN)); | |
11779 | ||
11780 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
11781 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11782 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11783 | bgp->vpn_policy[afi].rtlist[dir], |
11784 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11785 | vty_out(vty, "Export RT: %s\n", ecom_str); |
11786 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11787 | } else | |
11788 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 11789 | } |
53089bec | 11790 | } |
11791 | ||
11792 | return CMD_SUCCESS; | |
11793 | } | |
11794 | ||
03915806 CS |
11795 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
11796 | safi_t safi, bool use_json) | |
11797 | { | |
11798 | struct listnode *node, *nnode; | |
11799 | struct bgp *bgp; | |
11800 | char *vrf_name = NULL; | |
11801 | json_object *json = NULL; | |
11802 | json_object *json_vrf = NULL; | |
11803 | json_object *json_vrfs = NULL; | |
11804 | ||
11805 | if (use_json) { | |
11806 | json = json_object_new_object(); | |
11807 | json_vrfs = json_object_new_object(); | |
11808 | } | |
11809 | ||
11810 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
11811 | ||
11812 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
11813 | vrf_name = bgp->name; | |
11814 | ||
11815 | if (use_json) { | |
11816 | json_vrf = json_object_new_object(); | |
11817 | } else { | |
11818 | vty_out(vty, "\nInstance %s:\n", | |
11819 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11820 | ? VRF_DEFAULT_NAME : bgp->name); | |
11821 | } | |
11822 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
11823 | if (use_json) { | |
11824 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11825 | json_object_object_add(json_vrfs, | |
11826 | VRF_DEFAULT_NAME, json_vrf); | |
11827 | else | |
11828 | json_object_object_add(json_vrfs, vrf_name, | |
11829 | json_vrf); | |
11830 | } | |
11831 | } | |
11832 | ||
11833 | if (use_json) { | |
11834 | json_object_object_add(json, "vrfs", json_vrfs); | |
11835 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
11836 | JSON_C_TO_STRING_PRETTY)); | |
11837 | json_object_free(json); | |
11838 | } | |
11839 | ||
11840 | return CMD_SUCCESS; | |
11841 | } | |
11842 | ||
53089bec | 11843 | /* "show [ip] bgp route-leak" command. */ |
11844 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11845 | show_ip_bgp_route_leak_cmd, |
11846 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11847 | SHOW_STR |
11848 | IP_STR | |
11849 | BGP_STR | |
11850 | BGP_INSTANCE_HELP_STR | |
11851 | BGP_AFI_HELP_STR | |
11852 | BGP_SAFI_HELP_STR | |
11853 | "Route leaking information\n" | |
11854 | JSON_STR) | |
53089bec | 11855 | { |
11856 | char *vrf = NULL; | |
11857 | afi_t afi = AFI_MAX; | |
11858 | safi_t safi = SAFI_MAX; | |
11859 | ||
9f049418 | 11860 | bool uj = use_json(argc, argv); |
53089bec | 11861 | int idx = 0; |
03915806 | 11862 | json_object *json = NULL; |
53089bec | 11863 | |
11864 | /* show [ip] bgp */ | |
11865 | if (argv_find(argv, argc, "ip", &idx)) { | |
11866 | afi = AFI_IP; | |
11867 | safi = SAFI_UNICAST; | |
11868 | } | |
11869 | /* [vrf VIEWVRFNAME] */ | |
11870 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11871 | vty_out(vty, |
11872 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11873 | return CMD_WARNING; |
11874 | } | |
11875 | ||
9a8bdf1c PG |
11876 | if (argv_find(argv, argc, "vrf", &idx)) { |
11877 | vrf = argv[idx + 1]->arg; | |
11878 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11879 | vrf = NULL; | |
11880 | } | |
53089bec | 11881 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11882 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11883 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11884 | } | |
11885 | ||
11886 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11887 | vty_out(vty, |
11888 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11889 | return CMD_WARNING; |
11890 | } | |
11891 | ||
03915806 CS |
11892 | if (vrf && strmatch(vrf, "all")) |
11893 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
11894 | ||
11895 | if (uj) | |
11896 | json = json_object_new_object(); | |
11897 | ||
11898 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 11899 | } |
11900 | ||
d62a17ae | 11901 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11902 | safi_t safi) | |
f186de26 | 11903 | { |
d62a17ae | 11904 | struct listnode *node, *nnode; |
11905 | struct bgp *bgp; | |
f186de26 | 11906 | |
d62a17ae | 11907 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11908 | vty_out(vty, "\nInstance %s:\n", | |
11909 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11910 | ? VRF_DEFAULT_NAME |
d62a17ae | 11911 | : bgp->name); |
11912 | update_group_show(bgp, afi, safi, vty, 0); | |
11913 | } | |
f186de26 | 11914 | } |
11915 | ||
d62a17ae | 11916 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11917 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11918 | { |
d62a17ae | 11919 | struct bgp *bgp; |
4fb25c53 | 11920 | |
d62a17ae | 11921 | if (name) { |
11922 | if (strmatch(name, "all")) { | |
11923 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11924 | return CMD_SUCCESS; | |
11925 | } else { | |
11926 | bgp = bgp_lookup_by_name(name); | |
11927 | } | |
11928 | } else { | |
11929 | bgp = bgp_get_default(); | |
11930 | } | |
4fb25c53 | 11931 | |
d62a17ae | 11932 | if (bgp) |
11933 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11934 | return CMD_SUCCESS; | |
4fb25c53 DW |
11935 | } |
11936 | ||
8fe8a7f6 DS |
11937 | DEFUN (show_ip_bgp_updgrps, |
11938 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11939 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11940 | SHOW_STR |
11941 | IP_STR | |
11942 | BGP_STR | |
11943 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11944 | BGP_AFI_HELP_STR |
9bedbb1e | 11945 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11946 | "Detailed info about dynamic update groups\n" |
11947 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11948 | { |
d62a17ae | 11949 | char *vrf = NULL; |
11950 | afi_t afi = AFI_IP6; | |
11951 | safi_t safi = SAFI_UNICAST; | |
11952 | uint64_t subgrp_id = 0; | |
11953 | ||
11954 | int idx = 0; | |
11955 | ||
11956 | /* show [ip] bgp */ | |
11957 | if (argv_find(argv, argc, "ip", &idx)) | |
11958 | afi = AFI_IP; | |
9a8bdf1c PG |
11959 | /* [<vrf> VIEWVRFNAME] */ |
11960 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11961 | vrf = argv[idx + 1]->arg; | |
11962 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11963 | vrf = NULL; | |
11964 | } else if (argv_find(argv, argc, "view", &idx)) | |
11965 | /* [<view> VIEWVRFNAME] */ | |
11966 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11967 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11968 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11969 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11970 | } | |
5bf15956 | 11971 | |
d62a17ae | 11972 | /* get subgroup id, if provided */ |
11973 | idx = argc - 1; | |
11974 | if (argv[idx]->type == VARIABLE_TKN) | |
11975 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11976 | |
d62a17ae | 11977 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11978 | } |
11979 | ||
f186de26 | 11980 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11981 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11982 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11983 | SHOW_STR |
716b2d8a | 11984 | IP_STR |
f186de26 | 11985 | BGP_STR |
11986 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11987 | "Detailed info about dynamic update groups\n") |
f186de26 | 11988 | { |
d62a17ae | 11989 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11990 | return CMD_SUCCESS; | |
f186de26 | 11991 | } |
11992 | ||
43d3f4fc DS |
11993 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
11994 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
11995 | "show [ip] bgp l2vpn evpn update-groups", | |
11996 | SHOW_STR | |
11997 | IP_STR | |
11998 | BGP_STR | |
11999 | "l2vpn address family\n" | |
12000 | "evpn sub-address family\n" | |
12001 | "Detailed info about dynamic update groups\n") | |
12002 | { | |
12003 | char *vrf = NULL; | |
12004 | uint64_t subgrp_id = 0; | |
12005 | ||
12006 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
12007 | return CMD_SUCCESS; | |
12008 | } | |
12009 | ||
5bf15956 DW |
12010 | DEFUN (show_bgp_updgrps_stats, |
12011 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 12012 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 12013 | SHOW_STR |
716b2d8a | 12014 | IP_STR |
3f9c7369 | 12015 | BGP_STR |
0c7b1b01 | 12016 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
12017 | "Statistics\n") |
12018 | { | |
d62a17ae | 12019 | struct bgp *bgp; |
3f9c7369 | 12020 | |
d62a17ae | 12021 | bgp = bgp_get_default(); |
12022 | if (bgp) | |
12023 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 12024 | |
d62a17ae | 12025 | return CMD_SUCCESS; |
3f9c7369 DS |
12026 | } |
12027 | ||
8386ac43 | 12028 | DEFUN (show_bgp_instance_updgrps_stats, |
12029 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 12030 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 12031 | SHOW_STR |
716b2d8a | 12032 | IP_STR |
8386ac43 | 12033 | BGP_STR |
12034 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 12035 | "Detailed info about dynamic update groups\n" |
8386ac43 | 12036 | "Statistics\n") |
12037 | { | |
d62a17ae | 12038 | int idx_word = 3; |
12039 | struct bgp *bgp; | |
8386ac43 | 12040 | |
d62a17ae | 12041 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
12042 | if (bgp) | |
12043 | update_group_show_stats(bgp, vty); | |
8386ac43 | 12044 | |
d62a17ae | 12045 | return CMD_SUCCESS; |
8386ac43 | 12046 | } |
12047 | ||
d62a17ae | 12048 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
12049 | afi_t afi, safi_t safi, | |
12050 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 12051 | { |
d62a17ae | 12052 | struct bgp *bgp; |
8386ac43 | 12053 | |
d62a17ae | 12054 | if (name) |
12055 | bgp = bgp_lookup_by_name(name); | |
12056 | else | |
12057 | bgp = bgp_get_default(); | |
8386ac43 | 12058 | |
d62a17ae | 12059 | if (bgp) { |
12060 | if (!strcmp(what, "advertise-queue")) | |
12061 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
12062 | subgrp_id); | |
12063 | else if (!strcmp(what, "advertised-routes")) | |
12064 | update_group_show_advertised(bgp, afi, safi, vty, | |
12065 | subgrp_id); | |
12066 | else if (!strcmp(what, "packet-queue")) | |
12067 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
12068 | subgrp_id); | |
12069 | } | |
3f9c7369 DS |
12070 | } |
12071 | ||
dc64bdec QY |
12072 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
12073 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
12074 | "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", | |
12075 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
12076 | BGP_SAFI_HELP_STR | |
12077 | "Detailed info about dynamic update groups\n" | |
12078 | "Specific subgroup to display info for\n" | |
12079 | "Advertisement queue\n" | |
12080 | "Announced routes\n" | |
12081 | "Packet queue\n") | |
3f9c7369 | 12082 | { |
dc64bdec QY |
12083 | uint64_t subgrp_id = 0; |
12084 | afi_t afiz; | |
12085 | safi_t safiz; | |
12086 | if (sgid) | |
12087 | subgrp_id = strtoull(sgid, NULL, 10); | |
12088 | ||
12089 | if (!ip && !afi) | |
12090 | afiz = AFI_IP6; | |
12091 | if (!ip && afi) | |
12092 | afiz = bgp_vty_afi_from_str(afi); | |
12093 | if (ip && !afi) | |
12094 | afiz = AFI_IP; | |
12095 | if (ip && afi) { | |
12096 | afiz = bgp_vty_afi_from_str(afi); | |
12097 | if (afiz != AFI_IP) | |
12098 | vty_out(vty, | |
12099 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
12100 | return CMD_WARNING; | |
12101 | } | |
d62a17ae | 12102 | |
dc64bdec | 12103 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 12104 | |
dc64bdec | 12105 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 12106 | return CMD_SUCCESS; |
12107 | } | |
12108 | ||
d62a17ae | 12109 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
12110 | { | |
12111 | struct listnode *node, *nnode; | |
12112 | struct prefix *range; | |
12113 | struct peer *conf; | |
12114 | struct peer *peer; | |
12115 | char buf[PREFIX2STR_BUFFER]; | |
12116 | afi_t afi; | |
12117 | safi_t safi; | |
12118 | const char *peer_status; | |
12119 | const char *af_str; | |
12120 | int lr_count; | |
12121 | int dynamic; | |
12122 | int af_cfgd; | |
12123 | ||
12124 | conf = group->conf; | |
12125 | ||
12126 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
12127 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
12128 | group->name, conf->as); | |
d62a17ae | 12129 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
12130 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
12131 | group->name, group->bgp->as); | |
d62a17ae | 12132 | } else { |
12133 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
12134 | } | |
f14e6fdb | 12135 | |
d62a17ae | 12136 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
12137 | vty_out(vty, " Peer-group type is internal\n"); | |
12138 | else | |
12139 | vty_out(vty, " Peer-group type is external\n"); | |
12140 | ||
12141 | /* Display AFs configured. */ | |
12142 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
12143 | FOREACH_AFI_SAFI (afi, safi) { |
12144 | if (conf->afc[afi][safi]) { | |
12145 | af_cfgd = 1; | |
5cb5f4d0 | 12146 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12147 | } |
05c7a1cc | 12148 | } |
d62a17ae | 12149 | if (!af_cfgd) |
12150 | vty_out(vty, " none\n"); | |
12151 | else | |
12152 | vty_out(vty, "\n"); | |
12153 | ||
12154 | /* Display listen ranges (for dynamic neighbors), if any */ | |
12155 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
12156 | if (afi == AFI_IP) | |
12157 | af_str = "IPv4"; | |
12158 | else if (afi == AFI_IP6) | |
12159 | af_str = "IPv6"; | |
12160 | else | |
12161 | af_str = "???"; | |
12162 | lr_count = listcount(group->listen_range[afi]); | |
12163 | if (lr_count) { | |
12164 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
12165 | af_str); | |
12166 | ||
12167 | ||
12168 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
12169 | nnode, range)) { | |
12170 | prefix2str(range, buf, sizeof(buf)); | |
12171 | vty_out(vty, " %s\n", buf); | |
12172 | } | |
12173 | } | |
12174 | } | |
f14e6fdb | 12175 | |
d62a17ae | 12176 | /* Display group members and their status */ |
12177 | if (listcount(group->peer)) { | |
12178 | vty_out(vty, " Peer-group members:\n"); | |
12179 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
12180 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
12181 | peer_status = "Idle (Admin)"; | |
12182 | else if (CHECK_FLAG(peer->sflags, | |
12183 | PEER_STATUS_PREFIX_OVERFLOW)) | |
12184 | peer_status = "Idle (PfxCt)"; | |
12185 | else | |
12186 | peer_status = lookup_msg(bgp_status_msg, | |
12187 | peer->status, NULL); | |
12188 | ||
12189 | dynamic = peer_dynamic_neighbor(peer); | |
12190 | vty_out(vty, " %s %s %s \n", peer->host, | |
12191 | dynamic ? "(dynamic)" : "", peer_status); | |
12192 | } | |
12193 | } | |
f14e6fdb | 12194 | |
d62a17ae | 12195 | return CMD_SUCCESS; |
12196 | } | |
12197 | ||
ff9959b0 QY |
12198 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
12199 | const char *group_name) | |
d62a17ae | 12200 | { |
ff9959b0 | 12201 | struct bgp *bgp; |
d62a17ae | 12202 | struct listnode *node, *nnode; |
12203 | struct peer_group *group; | |
ff9959b0 QY |
12204 | bool found = false; |
12205 | ||
12206 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
12207 | ||
12208 | if (!bgp) { | |
9f049418 | 12209 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
12210 | return CMD_WARNING; |
12211 | } | |
d62a17ae | 12212 | |
12213 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
12214 | if (group_name) { |
12215 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 12216 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
12217 | found = true; |
12218 | break; | |
d62a17ae | 12219 | } |
ff9959b0 QY |
12220 | } else { |
12221 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 12222 | } |
f14e6fdb | 12223 | } |
f14e6fdb | 12224 | |
ff9959b0 | 12225 | if (group_name && !found) |
d62a17ae | 12226 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 12227 | |
d62a17ae | 12228 | return CMD_SUCCESS; |
f14e6fdb DS |
12229 | } |
12230 | ||
f14e6fdb DS |
12231 | DEFUN (show_ip_bgp_peer_groups, |
12232 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 12233 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
12234 | SHOW_STR |
12235 | IP_STR | |
12236 | BGP_STR | |
8386ac43 | 12237 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
12238 | "Detailed information on BGP peer groups\n" |
12239 | "Peer group name\n") | |
f14e6fdb | 12240 | { |
d62a17ae | 12241 | char *vrf, *pg; |
d62a17ae | 12242 | int idx = 0; |
f14e6fdb | 12243 | |
a4d82a8a PZ |
12244 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
12245 | : NULL; | |
d62a17ae | 12246 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 12247 | |
ff9959b0 | 12248 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 12249 | } |
3f9c7369 | 12250 | |
d6e3c605 | 12251 | |
718e3744 | 12252 | /* Redistribute VTY commands. */ |
12253 | ||
718e3744 | 12254 | DEFUN (bgp_redistribute_ipv4, |
12255 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 12256 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 12257 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12258 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 12259 | { |
d62a17ae | 12260 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12261 | int idx_protocol = 1; | |
12262 | int type; | |
718e3744 | 12263 | |
d62a17ae | 12264 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
12265 | if (type < 0) { | |
12266 | vty_out(vty, "%% Invalid route type\n"); | |
12267 | return CMD_WARNING_CONFIG_FAILED; | |
12268 | } | |
7f323236 | 12269 | |
d62a17ae | 12270 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 12271 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 12272 | } |
12273 | ||
d62a17ae | 12274 | ALIAS_HIDDEN( |
12275 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
12276 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
12277 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 12278 | |
718e3744 | 12279 | DEFUN (bgp_redistribute_ipv4_rmap, |
12280 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 12281 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12282 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12283 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12284 | "Route map reference\n" |
12285 | "Pointer to route-map entries\n") | |
12286 | { | |
d62a17ae | 12287 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12288 | int idx_protocol = 1; | |
12289 | int idx_word = 3; | |
12290 | int type; | |
12291 | struct bgp_redist *red; | |
e923dd62 | 12292 | bool changed; |
1de27621 DA |
12293 | struct route_map *route_map = route_map_lookup_warn_noexist( |
12294 | vty, argv[idx_word]->arg); | |
718e3744 | 12295 | |
d62a17ae | 12296 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
12297 | if (type < 0) { | |
12298 | vty_out(vty, "%% Invalid route type\n"); | |
12299 | return CMD_WARNING_CONFIG_FAILED; | |
12300 | } | |
718e3744 | 12301 | |
d62a17ae | 12302 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
12303 | changed = |
12304 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12305 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 12306 | } |
12307 | ||
d62a17ae | 12308 | ALIAS_HIDDEN( |
12309 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
12310 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
12311 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12312 | "Route map reference\n" | |
12313 | "Pointer to route-map entries\n") | |
596c17ba | 12314 | |
718e3744 | 12315 | DEFUN (bgp_redistribute_ipv4_metric, |
12316 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 12317 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12318 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12319 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12320 | "Metric for redistributed routes\n" |
12321 | "Default metric\n") | |
12322 | { | |
d62a17ae | 12323 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12324 | int idx_protocol = 1; | |
12325 | int idx_number = 3; | |
12326 | int type; | |
d7c0a89a | 12327 | uint32_t metric; |
d62a17ae | 12328 | struct bgp_redist *red; |
e923dd62 | 12329 | bool changed; |
d62a17ae | 12330 | |
12331 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12332 | if (type < 0) { | |
12333 | vty_out(vty, "%% Invalid route type\n"); | |
12334 | return CMD_WARNING_CONFIG_FAILED; | |
12335 | } | |
12336 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12337 | ||
12338 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12339 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12340 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12341 | } |
12342 | ||
12343 | ALIAS_HIDDEN( | |
12344 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
12345 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
12346 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12347 | "Metric for redistributed routes\n" | |
12348 | "Default metric\n") | |
596c17ba | 12349 | |
718e3744 | 12350 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
12351 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 12352 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12353 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12354 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12355 | "Route map reference\n" |
12356 | "Pointer to route-map entries\n" | |
12357 | "Metric for redistributed routes\n" | |
12358 | "Default metric\n") | |
12359 | { | |
d62a17ae | 12360 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12361 | int idx_protocol = 1; | |
12362 | int idx_word = 3; | |
12363 | int idx_number = 5; | |
12364 | int type; | |
d7c0a89a | 12365 | uint32_t metric; |
d62a17ae | 12366 | struct bgp_redist *red; |
e923dd62 | 12367 | bool changed; |
1de27621 DA |
12368 | struct route_map *route_map = |
12369 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12370 | |
12371 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12372 | if (type < 0) { | |
12373 | vty_out(vty, "%% Invalid route type\n"); | |
12374 | return CMD_WARNING_CONFIG_FAILED; | |
12375 | } | |
12376 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12377 | ||
12378 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
12379 | changed = |
12380 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12381 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12382 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12383 | } |
12384 | ||
12385 | ALIAS_HIDDEN( | |
12386 | bgp_redistribute_ipv4_rmap_metric, | |
12387 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
12388 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12389 | " route-map WORD metric (0-4294967295)", | |
12390 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12391 | "Route map reference\n" | |
12392 | "Pointer to route-map entries\n" | |
12393 | "Metric for redistributed routes\n" | |
12394 | "Default metric\n") | |
596c17ba | 12395 | |
718e3744 | 12396 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
12397 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 12398 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12399 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12400 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12401 | "Metric for redistributed routes\n" |
12402 | "Default metric\n" | |
12403 | "Route map reference\n" | |
12404 | "Pointer to route-map entries\n") | |
12405 | { | |
d62a17ae | 12406 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12407 | int idx_protocol = 1; | |
12408 | int idx_number = 3; | |
12409 | int idx_word = 5; | |
12410 | int type; | |
d7c0a89a | 12411 | uint32_t metric; |
d62a17ae | 12412 | struct bgp_redist *red; |
e923dd62 | 12413 | bool changed; |
1de27621 DA |
12414 | struct route_map *route_map = |
12415 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12416 | |
12417 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12418 | if (type < 0) { | |
12419 | vty_out(vty, "%% Invalid route type\n"); | |
12420 | return CMD_WARNING_CONFIG_FAILED; | |
12421 | } | |
12422 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12423 | ||
12424 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12425 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
12426 | changed |= |
12427 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12428 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 12429 | } |
12430 | ||
12431 | ALIAS_HIDDEN( | |
12432 | bgp_redistribute_ipv4_metric_rmap, | |
12433 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
12434 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12435 | " metric (0-4294967295) route-map WORD", | |
12436 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12437 | "Metric for redistributed routes\n" | |
12438 | "Default metric\n" | |
12439 | "Route map reference\n" | |
12440 | "Pointer to route-map entries\n") | |
596c17ba | 12441 | |
7c8ff89e DS |
12442 | DEFUN (bgp_redistribute_ipv4_ospf, |
12443 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 12444 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
12445 | "Redistribute information from another routing protocol\n" |
12446 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12447 | "Non-main Kernel Routing Table\n" |
12448 | "Instance ID/Table ID\n") | |
7c8ff89e | 12449 | { |
d62a17ae | 12450 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12451 | int idx_ospf_table = 1; | |
12452 | int idx_number = 2; | |
d7c0a89a QY |
12453 | unsigned short instance; |
12454 | unsigned short protocol; | |
7c8ff89e | 12455 | |
d62a17ae | 12456 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 12457 | |
d62a17ae | 12458 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
12459 | protocol = ZEBRA_ROUTE_OSPF; | |
12460 | else | |
12461 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 12462 | |
d62a17ae | 12463 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 12464 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
12465 | } |
12466 | ||
d62a17ae | 12467 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
12468 | "redistribute <ospf|table> (1-65535)", | |
12469 | "Redistribute information from another routing protocol\n" | |
12470 | "Open Shortest Path First (OSPFv2)\n" | |
12471 | "Non-main Kernel Routing Table\n" | |
12472 | "Instance ID/Table ID\n") | |
596c17ba | 12473 | |
7c8ff89e DS |
12474 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
12475 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 12476 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
12477 | "Redistribute information from another routing protocol\n" |
12478 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12479 | "Non-main Kernel Routing Table\n" |
12480 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12481 | "Route map reference\n" |
12482 | "Pointer to route-map entries\n") | |
12483 | { | |
d62a17ae | 12484 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12485 | int idx_ospf_table = 1; | |
12486 | int idx_number = 2; | |
12487 | int idx_word = 4; | |
12488 | struct bgp_redist *red; | |
d7c0a89a | 12489 | unsigned short instance; |
d62a17ae | 12490 | int protocol; |
e923dd62 | 12491 | bool changed; |
1de27621 DA |
12492 | struct route_map *route_map = |
12493 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12494 | |
12495 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12496 | protocol = ZEBRA_ROUTE_OSPF; | |
12497 | else | |
12498 | protocol = ZEBRA_ROUTE_TABLE; | |
12499 | ||
12500 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12501 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12502 | changed = |
12503 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12504 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12505 | } |
12506 | ||
12507 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
12508 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
12509 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
12510 | "Redistribute information from another routing protocol\n" | |
12511 | "Open Shortest Path First (OSPFv2)\n" | |
12512 | "Non-main Kernel Routing Table\n" | |
12513 | "Instance ID/Table ID\n" | |
12514 | "Route map reference\n" | |
12515 | "Pointer to route-map entries\n") | |
596c17ba | 12516 | |
7c8ff89e DS |
12517 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
12518 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 12519 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
12520 | "Redistribute information from another routing protocol\n" |
12521 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12522 | "Non-main Kernel Routing Table\n" |
12523 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12524 | "Metric for redistributed routes\n" |
12525 | "Default metric\n") | |
12526 | { | |
d62a17ae | 12527 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12528 | int idx_ospf_table = 1; | |
12529 | int idx_number = 2; | |
12530 | int idx_number_2 = 4; | |
d7c0a89a | 12531 | uint32_t metric; |
d62a17ae | 12532 | struct bgp_redist *red; |
d7c0a89a | 12533 | unsigned short instance; |
d62a17ae | 12534 | int protocol; |
e923dd62 | 12535 | bool changed; |
d62a17ae | 12536 | |
12537 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12538 | protocol = ZEBRA_ROUTE_OSPF; | |
12539 | else | |
12540 | protocol = ZEBRA_ROUTE_TABLE; | |
12541 | ||
12542 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12543 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12544 | ||
12545 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12546 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12547 | metric); | |
12548 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12549 | } |
12550 | ||
12551 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
12552 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
12553 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
12554 | "Redistribute information from another routing protocol\n" | |
12555 | "Open Shortest Path First (OSPFv2)\n" | |
12556 | "Non-main Kernel Routing Table\n" | |
12557 | "Instance ID/Table ID\n" | |
12558 | "Metric for redistributed routes\n" | |
12559 | "Default metric\n") | |
596c17ba | 12560 | |
7c8ff89e DS |
12561 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
12562 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 12563 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
12564 | "Redistribute information from another routing protocol\n" |
12565 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12566 | "Non-main Kernel Routing Table\n" |
12567 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12568 | "Route map reference\n" |
12569 | "Pointer to route-map entries\n" | |
12570 | "Metric for redistributed routes\n" | |
12571 | "Default metric\n") | |
12572 | { | |
d62a17ae | 12573 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12574 | int idx_ospf_table = 1; | |
12575 | int idx_number = 2; | |
12576 | int idx_word = 4; | |
12577 | int idx_number_2 = 6; | |
d7c0a89a | 12578 | uint32_t metric; |
d62a17ae | 12579 | struct bgp_redist *red; |
d7c0a89a | 12580 | unsigned short instance; |
d62a17ae | 12581 | int protocol; |
e923dd62 | 12582 | bool changed; |
1de27621 DA |
12583 | struct route_map *route_map = |
12584 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12585 | |
12586 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12587 | protocol = ZEBRA_ROUTE_OSPF; | |
12588 | else | |
12589 | protocol = ZEBRA_ROUTE_TABLE; | |
12590 | ||
12591 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12592 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12593 | ||
12594 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12595 | changed = |
12596 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12597 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12598 | metric); | |
12599 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12600 | } |
12601 | ||
12602 | ALIAS_HIDDEN( | |
12603 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
12604 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
12605 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
12606 | "Redistribute information from another routing protocol\n" | |
12607 | "Open Shortest Path First (OSPFv2)\n" | |
12608 | "Non-main Kernel Routing Table\n" | |
12609 | "Instance ID/Table ID\n" | |
12610 | "Route map reference\n" | |
12611 | "Pointer to route-map entries\n" | |
12612 | "Metric for redistributed routes\n" | |
12613 | "Default metric\n") | |
596c17ba | 12614 | |
7c8ff89e DS |
12615 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
12616 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 12617 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
12618 | "Redistribute information from another routing protocol\n" |
12619 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12620 | "Non-main Kernel Routing Table\n" |
12621 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12622 | "Metric for redistributed routes\n" |
12623 | "Default metric\n" | |
12624 | "Route map reference\n" | |
12625 | "Pointer to route-map entries\n") | |
12626 | { | |
d62a17ae | 12627 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12628 | int idx_ospf_table = 1; | |
12629 | int idx_number = 2; | |
12630 | int idx_number_2 = 4; | |
12631 | int idx_word = 6; | |
d7c0a89a | 12632 | uint32_t metric; |
d62a17ae | 12633 | struct bgp_redist *red; |
d7c0a89a | 12634 | unsigned short instance; |
d62a17ae | 12635 | int protocol; |
e923dd62 | 12636 | bool changed; |
1de27621 DA |
12637 | struct route_map *route_map = |
12638 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12639 | |
12640 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12641 | protocol = ZEBRA_ROUTE_OSPF; | |
12642 | else | |
12643 | protocol = ZEBRA_ROUTE_TABLE; | |
12644 | ||
12645 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12646 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12647 | ||
12648 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12649 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12650 | metric); | |
1de27621 DA |
12651 | changed |= |
12652 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12653 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12654 | } |
12655 | ||
12656 | ALIAS_HIDDEN( | |
12657 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
12658 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
12659 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
12660 | "Redistribute information from another routing protocol\n" | |
12661 | "Open Shortest Path First (OSPFv2)\n" | |
12662 | "Non-main Kernel Routing Table\n" | |
12663 | "Instance ID/Table ID\n" | |
12664 | "Metric for redistributed routes\n" | |
12665 | "Default metric\n" | |
12666 | "Route map reference\n" | |
12667 | "Pointer to route-map entries\n") | |
596c17ba | 12668 | |
7c8ff89e DS |
12669 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
12670 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 12671 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
12672 | NO_STR |
12673 | "Redistribute information from another routing protocol\n" | |
12674 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 12675 | "Non-main Kernel Routing Table\n" |
31500417 DW |
12676 | "Instance ID/Table ID\n" |
12677 | "Metric for redistributed routes\n" | |
12678 | "Default metric\n" | |
12679 | "Route map reference\n" | |
12680 | "Pointer to route-map entries\n") | |
7c8ff89e | 12681 | { |
d62a17ae | 12682 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12683 | int idx_ospf_table = 2; | |
12684 | int idx_number = 3; | |
d7c0a89a | 12685 | unsigned short instance; |
d62a17ae | 12686 | int protocol; |
12687 | ||
12688 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12689 | protocol = ZEBRA_ROUTE_OSPF; | |
12690 | else | |
12691 | protocol = ZEBRA_ROUTE_TABLE; | |
12692 | ||
12693 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12694 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
12695 | } | |
12696 | ||
12697 | ALIAS_HIDDEN( | |
12698 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 12699 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 12700 | NO_STR |
12701 | "Redistribute information from another routing protocol\n" | |
12702 | "Open Shortest Path First (OSPFv2)\n" | |
12703 | "Non-main Kernel Routing Table\n" | |
12704 | "Instance ID/Table ID\n" | |
12705 | "Metric for redistributed routes\n" | |
12706 | "Default metric\n" | |
12707 | "Route map reference\n" | |
12708 | "Pointer to route-map entries\n") | |
596c17ba | 12709 | |
718e3744 | 12710 | DEFUN (no_bgp_redistribute_ipv4, |
12711 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 12712 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 12713 | NO_STR |
12714 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12715 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
12716 | "Metric for redistributed routes\n" |
12717 | "Default metric\n" | |
12718 | "Route map reference\n" | |
12719 | "Pointer to route-map entries\n") | |
718e3744 | 12720 | { |
d62a17ae | 12721 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12722 | int idx_protocol = 2; | |
12723 | int type; | |
12724 | ||
12725 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12726 | if (type < 0) { | |
12727 | vty_out(vty, "%% Invalid route type\n"); | |
12728 | return CMD_WARNING_CONFIG_FAILED; | |
12729 | } | |
12730 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
12731 | } | |
12732 | ||
12733 | ALIAS_HIDDEN( | |
12734 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
12735 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 12736 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 12737 | NO_STR |
12738 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12739 | "Metric for redistributed routes\n" | |
12740 | "Default metric\n" | |
12741 | "Route map reference\n" | |
12742 | "Pointer to route-map entries\n") | |
596c17ba | 12743 | |
718e3744 | 12744 | DEFUN (bgp_redistribute_ipv6, |
12745 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12746 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12747 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12748 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12749 | { |
d62a17ae | 12750 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12751 | int idx_protocol = 1; | |
12752 | int type; | |
718e3744 | 12753 | |
d62a17ae | 12754 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12755 | if (type < 0) { | |
12756 | vty_out(vty, "%% Invalid route type\n"); | |
12757 | return CMD_WARNING_CONFIG_FAILED; | |
12758 | } | |
718e3744 | 12759 | |
d62a17ae | 12760 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12761 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12762 | } |
12763 | ||
12764 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12765 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12766 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12767 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12768 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12769 | "Route map reference\n" |
12770 | "Pointer to route-map entries\n") | |
12771 | { | |
d62a17ae | 12772 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12773 | int idx_protocol = 1; | |
12774 | int idx_word = 3; | |
12775 | int type; | |
12776 | struct bgp_redist *red; | |
e923dd62 | 12777 | bool changed; |
1de27621 DA |
12778 | struct route_map *route_map = |
12779 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 12780 | |
d62a17ae | 12781 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12782 | if (type < 0) { | |
12783 | vty_out(vty, "%% Invalid route type\n"); | |
12784 | return CMD_WARNING_CONFIG_FAILED; | |
12785 | } | |
718e3744 | 12786 | |
d62a17ae | 12787 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12788 | changed = |
12789 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12790 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12791 | } |
12792 | ||
12793 | DEFUN (bgp_redistribute_ipv6_metric, | |
12794 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12795 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12796 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12797 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12798 | "Metric for redistributed routes\n" |
12799 | "Default metric\n") | |
12800 | { | |
d62a17ae | 12801 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12802 | int idx_protocol = 1; | |
12803 | int idx_number = 3; | |
12804 | int type; | |
d7c0a89a | 12805 | uint32_t metric; |
d62a17ae | 12806 | struct bgp_redist *red; |
e923dd62 | 12807 | bool changed; |
d62a17ae | 12808 | |
12809 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12810 | if (type < 0) { | |
12811 | vty_out(vty, "%% Invalid route type\n"); | |
12812 | return CMD_WARNING_CONFIG_FAILED; | |
12813 | } | |
12814 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12815 | |
d62a17ae | 12816 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12817 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12818 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12819 | } |
12820 | ||
12821 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12822 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12823 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12824 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12825 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12826 | "Route map reference\n" |
12827 | "Pointer to route-map entries\n" | |
12828 | "Metric for redistributed routes\n" | |
12829 | "Default metric\n") | |
12830 | { | |
d62a17ae | 12831 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12832 | int idx_protocol = 1; | |
12833 | int idx_word = 3; | |
12834 | int idx_number = 5; | |
12835 | int type; | |
d7c0a89a | 12836 | uint32_t metric; |
d62a17ae | 12837 | struct bgp_redist *red; |
e923dd62 | 12838 | bool changed; |
1de27621 DA |
12839 | struct route_map *route_map = |
12840 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12841 | |
12842 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12843 | if (type < 0) { | |
12844 | vty_out(vty, "%% Invalid route type\n"); | |
12845 | return CMD_WARNING_CONFIG_FAILED; | |
12846 | } | |
12847 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12848 | |
d62a17ae | 12849 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12850 | changed = |
12851 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12852 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
12853 | metric); | |
12854 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12855 | } |
12856 | ||
12857 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12858 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12859 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12860 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12861 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12862 | "Metric for redistributed routes\n" |
12863 | "Default metric\n" | |
12864 | "Route map reference\n" | |
12865 | "Pointer to route-map entries\n") | |
12866 | { | |
d62a17ae | 12867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12868 | int idx_protocol = 1; | |
12869 | int idx_number = 3; | |
12870 | int idx_word = 5; | |
12871 | int type; | |
d7c0a89a | 12872 | uint32_t metric; |
d62a17ae | 12873 | struct bgp_redist *red; |
e923dd62 | 12874 | bool changed; |
1de27621 DA |
12875 | struct route_map *route_map = |
12876 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12877 | |
12878 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12879 | if (type < 0) { | |
12880 | vty_out(vty, "%% Invalid route type\n"); | |
12881 | return CMD_WARNING_CONFIG_FAILED; | |
12882 | } | |
12883 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12884 | |
d62a17ae | 12885 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12886 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12887 | metric); | |
1de27621 DA |
12888 | changed |= |
12889 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12890 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12891 | } |
12892 | ||
12893 | DEFUN (no_bgp_redistribute_ipv6, | |
12894 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 12895 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 12896 | NO_STR |
12897 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12898 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12899 | "Metric for redistributed routes\n" |
12900 | "Default metric\n" | |
12901 | "Route map reference\n" | |
12902 | "Pointer to route-map entries\n") | |
718e3744 | 12903 | { |
d62a17ae | 12904 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12905 | int idx_protocol = 2; | |
12906 | int type; | |
718e3744 | 12907 | |
d62a17ae | 12908 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12909 | if (type < 0) { | |
12910 | vty_out(vty, "%% Invalid route type\n"); | |
12911 | return CMD_WARNING_CONFIG_FAILED; | |
12912 | } | |
718e3744 | 12913 | |
d62a17ae | 12914 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12915 | } | |
12916 | ||
dd65f45e DL |
12917 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
12918 | afi_t afi, safi_t safi) | |
d62a17ae | 12919 | { |
12920 | int i; | |
12921 | ||
12922 | /* Unicast redistribution only. */ | |
12923 | if (safi != SAFI_UNICAST) | |
2b791107 | 12924 | return; |
d62a17ae | 12925 | |
12926 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12927 | /* Redistribute BGP does not make sense. */ | |
12928 | if (i != ZEBRA_ROUTE_BGP) { | |
12929 | struct list *red_list; | |
12930 | struct listnode *node; | |
12931 | struct bgp_redist *red; | |
12932 | ||
12933 | red_list = bgp->redist[afi][i]; | |
12934 | if (!red_list) | |
12935 | continue; | |
12936 | ||
12937 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12938 | /* "redistribute" configuration. */ |
12939 | vty_out(vty, " redistribute %s", | |
12940 | zebra_route_string(i)); | |
12941 | if (red->instance) | |
12942 | vty_out(vty, " %d", red->instance); | |
12943 | if (red->redist_metric_flag) | |
12944 | vty_out(vty, " metric %u", | |
12945 | red->redist_metric); | |
12946 | if (red->rmap.name) | |
12947 | vty_out(vty, " route-map %s", | |
12948 | red->rmap.name); | |
12949 | vty_out(vty, "\n"); | |
12950 | } | |
12951 | } | |
12952 | } | |
718e3744 | 12953 | } |
6b0655a2 | 12954 | |
dd65f45e DL |
12955 | /* peer-group helpers for config-write */ |
12956 | ||
12957 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
12958 | { | |
12959 | if (!peer_group_active(peer)) { | |
12960 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
12961 | return !CHECK_FLAG(peer->flags, flag); | |
12962 | else | |
12963 | return !!CHECK_FLAG(peer->flags, flag); | |
12964 | } | |
12965 | ||
12966 | return !!CHECK_FLAG(peer->flags_override, flag); | |
12967 | } | |
12968 | ||
12969 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
12970 | uint32_t flag) | |
12971 | { | |
12972 | if (!peer_group_active(peer)) { | |
12973 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
12974 | return !peer_af_flag_check(peer, afi, safi, flag); | |
12975 | else | |
12976 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
12977 | } | |
12978 | ||
12979 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
12980 | } | |
12981 | ||
12982 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
12983 | uint8_t type, int direct) | |
12984 | { | |
12985 | struct bgp_filter *filter; | |
12986 | ||
12987 | if (peer_group_active(peer)) | |
12988 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
12989 | type); | |
12990 | ||
12991 | filter = &peer->filter[afi][safi]; | |
12992 | switch (type) { | |
12993 | case PEER_FT_DISTRIBUTE_LIST: | |
12994 | return !!(filter->dlist[direct].name); | |
12995 | case PEER_FT_FILTER_LIST: | |
12996 | return !!(filter->aslist[direct].name); | |
12997 | case PEER_FT_PREFIX_LIST: | |
12998 | return !!(filter->plist[direct].name); | |
12999 | case PEER_FT_ROUTE_MAP: | |
13000 | return !!(filter->map[direct].name); | |
13001 | case PEER_FT_UNSUPPRESS_MAP: | |
13002 | return !!(filter->usmap.name); | |
13003 | default: | |
13004 | return false; | |
13005 | } | |
13006 | } | |
13007 | ||
13008 | /* Return true if the addpath type is set for peer and different from | |
13009 | * peer-group. | |
13010 | */ | |
13011 | static int peergroup_af_addpath_check(struct peer *peer, afi_t afi, safi_t safi) | |
13012 | { | |
13013 | enum bgp_addpath_strat type, g_type; | |
13014 | ||
13015 | type = peer->addpath_type[afi][safi]; | |
13016 | ||
13017 | if (type != BGP_ADDPATH_NONE) { | |
13018 | if (peer_group_active(peer)) { | |
13019 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
13020 | ||
13021 | if (type != g_type) | |
13022 | return 1; | |
13023 | else | |
13024 | return 0; | |
13025 | } | |
13026 | ||
13027 | return 1; | |
13028 | } | |
13029 | ||
13030 | return 0; | |
13031 | } | |
13032 | ||
b9c7bc5a | 13033 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 13034 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
13035 | afi_t afi) |
13036 | { | |
b9c7bc5a | 13037 | int indent = 2; |
ddb5b488 | 13038 | |
8a066a70 PG |
13039 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
13040 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
13041 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
13042 | bgp->vpn_policy[afi] | |
bb4f6190 | 13043 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
13044 | else |
13045 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
13046 | bgp->vpn_policy[afi] | |
13047 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
13048 | } | |
12a844a5 DS |
13049 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
13050 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
13051 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
13052 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
13053 | return; | |
13054 | ||
e70e9f8e PZ |
13055 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
13056 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
13057 | ||
13058 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
13059 | ||
13060 | } else { | |
13061 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
13062 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
13063 | bgp->vpn_policy[afi].tovpn_label); | |
13064 | } | |
ddb5b488 PZ |
13065 | } |
13066 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
13067 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
13068 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 13069 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
13070 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
13071 | sizeof(buf))); | |
13072 | } | |
13073 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
13074 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
13075 | ||
13076 | char buf[PREFIX_STRLEN]; | |
13077 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
13078 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
13079 | sizeof(buf))) { | |
13080 | ||
b9c7bc5a PZ |
13081 | vty_out(vty, "%*snexthop vpn export %s\n", |
13082 | indent, "", buf); | |
ddb5b488 PZ |
13083 | } |
13084 | } | |
13085 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
13086 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
13087 | && ecommunity_cmp( | |
13088 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
13089 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
13090 | ||
13091 | char *b = ecommunity_ecom2str( | |
13092 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
13093 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 13094 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
13095 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
13096 | } else { | |
13097 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
13098 | char *b = ecommunity_ecom2str( | |
13099 | bgp->vpn_policy[afi] | |
13100 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
13101 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
13102 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 13103 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
13104 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
13105 | } | |
13106 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
13107 | char *b = ecommunity_ecom2str( | |
13108 | bgp->vpn_policy[afi] | |
13109 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
13110 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
13111 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 13112 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
13113 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
13114 | } | |
13115 | } | |
bb4f6190 DS |
13116 | |
13117 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 13118 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
13119 | bgp->vpn_policy[afi] |
13120 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 13121 | |
301ad80a PG |
13122 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
13123 | char *b = ecommunity_ecom2str( | |
13124 | bgp->vpn_policy[afi] | |
13125 | .import_redirect_rtlist, | |
13126 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
13127 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 13128 | |
301ad80a PG |
13129 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
13130 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
13131 | } | |
ddb5b488 PZ |
13132 | } |
13133 | ||
dd65f45e DL |
13134 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
13135 | afi_t afi, safi_t safi) | |
13136 | { | |
13137 | struct bgp_filter *filter; | |
13138 | char *addr; | |
13139 | ||
13140 | addr = peer->host; | |
13141 | filter = &peer->filter[afi][safi]; | |
13142 | ||
13143 | /* distribute-list. */ | |
13144 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
13145 | FILTER_IN)) | |
13146 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
13147 | filter->dlist[FILTER_IN].name); | |
13148 | ||
13149 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
13150 | FILTER_OUT)) | |
13151 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
13152 | filter->dlist[FILTER_OUT].name); | |
13153 | ||
13154 | /* prefix-list. */ | |
13155 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
13156 | FILTER_IN)) | |
13157 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
13158 | filter->plist[FILTER_IN].name); | |
13159 | ||
13160 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
13161 | FILTER_OUT)) | |
13162 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
13163 | filter->plist[FILTER_OUT].name); | |
13164 | ||
13165 | /* route-map. */ | |
13166 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
13167 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
13168 | filter->map[RMAP_IN].name); | |
13169 | ||
13170 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
13171 | RMAP_OUT)) | |
13172 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
13173 | filter->map[RMAP_OUT].name); | |
13174 | ||
13175 | /* unsuppress-map */ | |
13176 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
13177 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
13178 | filter->usmap.name); | |
13179 | ||
13180 | /* filter-list. */ | |
13181 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
13182 | FILTER_IN)) | |
13183 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
13184 | filter->aslist[FILTER_IN].name); | |
13185 | ||
13186 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
13187 | FILTER_OUT)) | |
13188 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
13189 | filter->aslist[FILTER_OUT].name); | |
13190 | } | |
13191 | ||
13192 | /* BGP peer configuration display function. */ | |
13193 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
13194 | struct peer *peer) | |
13195 | { | |
13196 | struct peer *g_peer = NULL; | |
13197 | char buf[SU_ADDRSTRLEN]; | |
13198 | char *addr; | |
13199 | int if_pg_printed = false; | |
13200 | int if_ras_printed = false; | |
13201 | ||
13202 | /* Skip dynamic neighbors. */ | |
13203 | if (peer_dynamic_neighbor(peer)) | |
13204 | return; | |
13205 | ||
13206 | if (peer->conf_if) | |
13207 | addr = peer->conf_if; | |
13208 | else | |
13209 | addr = peer->host; | |
13210 | ||
13211 | /************************************ | |
13212 | ****** Global to the neighbor ****** | |
13213 | ************************************/ | |
13214 | if (peer->conf_if) { | |
13215 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
13216 | vty_out(vty, " neighbor %s interface v6only", addr); | |
13217 | else | |
13218 | vty_out(vty, " neighbor %s interface", addr); | |
13219 | ||
13220 | if (peer_group_active(peer)) { | |
13221 | vty_out(vty, " peer-group %s", peer->group->name); | |
13222 | if_pg_printed = true; | |
13223 | } else if (peer->as_type == AS_SPECIFIED) { | |
13224 | vty_out(vty, " remote-as %u", peer->as); | |
13225 | if_ras_printed = true; | |
13226 | } else if (peer->as_type == AS_INTERNAL) { | |
13227 | vty_out(vty, " remote-as internal"); | |
13228 | if_ras_printed = true; | |
13229 | } else if (peer->as_type == AS_EXTERNAL) { | |
13230 | vty_out(vty, " remote-as external"); | |
13231 | if_ras_printed = true; | |
13232 | } | |
13233 | ||
13234 | vty_out(vty, "\n"); | |
13235 | } | |
13236 | ||
13237 | /* remote-as and peer-group */ | |
13238 | /* peer is a member of a peer-group */ | |
13239 | if (peer_group_active(peer)) { | |
13240 | g_peer = peer->group->conf; | |
13241 | ||
13242 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
13243 | if (peer->as_type == AS_SPECIFIED) { | |
13244 | vty_out(vty, " neighbor %s remote-as %u\n", | |
13245 | addr, peer->as); | |
13246 | } else if (peer->as_type == AS_INTERNAL) { | |
13247 | vty_out(vty, | |
13248 | " neighbor %s remote-as internal\n", | |
13249 | addr); | |
13250 | } else if (peer->as_type == AS_EXTERNAL) { | |
13251 | vty_out(vty, | |
13252 | " neighbor %s remote-as external\n", | |
13253 | addr); | |
13254 | } | |
13255 | } | |
13256 | ||
13257 | /* For swpX peers we displayed the peer-group | |
13258 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
13259 | if (!if_pg_printed) | |
13260 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
13261 | peer->group->name); | |
13262 | } | |
13263 | ||
13264 | /* peer is NOT a member of a peer-group */ | |
13265 | else { | |
13266 | /* peer is a peer-group, declare the peer-group */ | |
13267 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
13268 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
13269 | } | |
13270 | ||
13271 | if (!if_ras_printed) { | |
13272 | if (peer->as_type == AS_SPECIFIED) { | |
13273 | vty_out(vty, " neighbor %s remote-as %u\n", | |
13274 | addr, peer->as); | |
13275 | } else if (peer->as_type == AS_INTERNAL) { | |
13276 | vty_out(vty, | |
13277 | " neighbor %s remote-as internal\n", | |
13278 | addr); | |
13279 | } else if (peer->as_type == AS_EXTERNAL) { | |
13280 | vty_out(vty, | |
13281 | " neighbor %s remote-as external\n", | |
13282 | addr); | |
13283 | } | |
13284 | } | |
13285 | } | |
13286 | ||
13287 | /* local-as */ | |
13288 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
13289 | vty_out(vty, " neighbor %s local-as %u", addr, | |
13290 | peer->change_local_as); | |
13291 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
13292 | vty_out(vty, " no-prepend"); | |
13293 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
13294 | vty_out(vty, " replace-as"); | |
13295 | vty_out(vty, "\n"); | |
13296 | } | |
13297 | ||
13298 | /* description */ | |
13299 | if (peer->desc) { | |
13300 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
13301 | } | |
13302 | ||
13303 | /* shutdown */ | |
13304 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
13305 | if (peer->tx_shutdown_message) | |
13306 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
13307 | peer->tx_shutdown_message); | |
13308 | else | |
13309 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
13310 | } | |
13311 | ||
13312 | /* bfd */ | |
13313 | if (peer->bfd_info) { | |
13314 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
13315 | bgp_bfd_peer_config_write(vty, peer, addr); | |
13316 | } | |
13317 | } | |
13318 | ||
13319 | /* password */ | |
13320 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
13321 | vty_out(vty, " neighbor %s password %s\n", addr, | |
13322 | peer->password); | |
13323 | ||
13324 | /* neighbor solo */ | |
13325 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
13326 | if (!peer_group_active(peer)) { | |
13327 | vty_out(vty, " neighbor %s solo\n", addr); | |
13328 | } | |
13329 | } | |
13330 | ||
13331 | /* BGP port */ | |
13332 | if (peer->port != BGP_PORT_DEFAULT) { | |
13333 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
13334 | } | |
13335 | ||
13336 | /* Local interface name */ | |
13337 | if (peer->ifname) { | |
13338 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
13339 | } | |
13340 | ||
13341 | /* passive */ | |
13342 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
13343 | vty_out(vty, " neighbor %s passive\n", addr); | |
13344 | ||
13345 | /* ebgp-multihop */ | |
13346 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
13347 | && !(peer->gtsm_hops != 0 && peer->ttl == MAXTTL)) { | |
13348 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { | |
13349 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
13350 | peer->ttl); | |
13351 | } | |
13352 | } | |
13353 | ||
13354 | /* ttl-security hops */ | |
13355 | if (peer->gtsm_hops != 0) { | |
13356 | if (!peer_group_active(peer) | |
13357 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
13358 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
13359 | addr, peer->gtsm_hops); | |
13360 | } | |
13361 | } | |
13362 | ||
13363 | /* disable-connected-check */ | |
13364 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
13365 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
13366 | ||
13367 | /* enforce-first-as */ | |
13368 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
13369 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
13370 | ||
13371 | /* update-source */ | |
13372 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
13373 | if (peer->update_source) | |
13374 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
13375 | sockunion2str(peer->update_source, buf, | |
13376 | SU_ADDRSTRLEN)); | |
13377 | else if (peer->update_if) | |
13378 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
13379 | peer->update_if); | |
13380 | } | |
13381 | ||
13382 | /* advertisement-interval */ | |
13383 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
13384 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
13385 | peer->routeadv); | |
13386 | ||
13387 | /* timers */ | |
13388 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
13389 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
13390 | peer->keepalive, peer->holdtime); | |
13391 | ||
13392 | /* timers connect */ | |
13393 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
13394 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
13395 | peer->connect); | |
5d5393b9 DL |
13396 | /* need special-case handling for changed default values due to |
13397 | * config profile / version (because there is no "timers bgp connect" | |
13398 | * command, we need to save this per-peer :/) | |
13399 | */ | |
13400 | else if (!peer_group_active(peer) && !peer->connect && | |
13401 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
13402 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
13403 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
13404 | |
13405 | /* capability dynamic */ | |
13406 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
13407 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
13408 | ||
13409 | /* capability extended-nexthop */ | |
13410 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
13411 | if (!peer->conf_if) { | |
13412 | if (CHECK_FLAG(peer->flags_invert, | |
13413 | PEER_FLAG_CAPABILITY_ENHE)) | |
13414 | vty_out(vty, | |
13415 | " no neighbor %s capability extended-nexthop\n", | |
13416 | addr); | |
13417 | else | |
13418 | vty_out(vty, | |
13419 | " neighbor %s capability extended-nexthop\n", | |
13420 | addr); | |
13421 | } | |
13422 | } | |
13423 | ||
13424 | /* dont-capability-negotiation */ | |
13425 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
13426 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
13427 | ||
13428 | /* override-capability */ | |
13429 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
13430 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
13431 | ||
13432 | /* strict-capability-match */ | |
13433 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
13434 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
13435 | ||
13436 | /* Sender side AS path loop detection. */ | |
13437 | if (peer->as_path_loop_detection) | |
13438 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
13439 | addr); | |
13440 | } | |
13441 | ||
13442 | /* BGP peer configuration display function. */ | |
13443 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
13444 | struct peer *peer, afi_t afi, safi_t safi) | |
13445 | { | |
13446 | struct peer *g_peer = NULL; | |
13447 | char *addr; | |
13448 | bool flag_scomm, flag_secomm, flag_slcomm; | |
13449 | ||
13450 | /* Skip dynamic neighbors. */ | |
13451 | if (peer_dynamic_neighbor(peer)) | |
13452 | return; | |
13453 | ||
13454 | if (peer->conf_if) | |
13455 | addr = peer->conf_if; | |
13456 | else | |
13457 | addr = peer->host; | |
13458 | ||
13459 | /************************************ | |
13460 | ****** Per AF to the neighbor ****** | |
13461 | ************************************/ | |
13462 | if (peer_group_active(peer)) { | |
13463 | g_peer = peer->group->conf; | |
13464 | ||
13465 | /* If the peer-group is active but peer is not, print a 'no | |
13466 | * activate' */ | |
13467 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
13468 | vty_out(vty, " no neighbor %s activate\n", addr); | |
13469 | } | |
13470 | ||
13471 | /* If the peer-group is not active but peer is, print an | |
13472 | 'activate' */ | |
13473 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
13474 | vty_out(vty, " neighbor %s activate\n", addr); | |
13475 | } | |
13476 | } else { | |
13477 | if (peer->afc[afi][safi]) { | |
13478 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
13479 | if (bgp_flag_check(bgp, | |
13480 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
13481 | vty_out(vty, " neighbor %s activate\n", | |
13482 | addr); | |
13483 | } | |
13484 | } else | |
13485 | vty_out(vty, " neighbor %s activate\n", addr); | |
13486 | } else { | |
13487 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
13488 | if (!bgp_flag_check(bgp, | |
13489 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
13490 | vty_out(vty, | |
13491 | " no neighbor %s activate\n", | |
13492 | addr); | |
13493 | } | |
13494 | } | |
13495 | } | |
13496 | } | |
13497 | ||
13498 | /* addpath TX knobs */ | |
13499 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
13500 | switch (peer->addpath_type[afi][safi]) { | |
13501 | case BGP_ADDPATH_ALL: | |
13502 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
13503 | addr); | |
13504 | break; | |
13505 | case BGP_ADDPATH_BEST_PER_AS: | |
13506 | vty_out(vty, | |
13507 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
13508 | addr); | |
13509 | break; | |
13510 | case BGP_ADDPATH_MAX: | |
13511 | case BGP_ADDPATH_NONE: | |
13512 | break; | |
13513 | } | |
13514 | } | |
13515 | ||
13516 | /* ORF capability. */ | |
13517 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
13518 | || peergroup_af_flag_check(peer, afi, safi, | |
13519 | PEER_FLAG_ORF_PREFIX_RM)) { | |
13520 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
13521 | ||
13522 | if (peergroup_af_flag_check(peer, afi, safi, | |
13523 | PEER_FLAG_ORF_PREFIX_SM) | |
13524 | && peergroup_af_flag_check(peer, afi, safi, | |
13525 | PEER_FLAG_ORF_PREFIX_RM)) | |
13526 | vty_out(vty, " both"); | |
13527 | else if (peergroup_af_flag_check(peer, afi, safi, | |
13528 | PEER_FLAG_ORF_PREFIX_SM)) | |
13529 | vty_out(vty, " send"); | |
13530 | else | |
13531 | vty_out(vty, " receive"); | |
13532 | vty_out(vty, "\n"); | |
13533 | } | |
13534 | ||
13535 | /* BGP flag dampening. */ | |
13536 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
13537 | BGP_CONFIG_DAMPENING)) | |
13538 | bgp_config_write_damp(vty, afi, safi); | |
13539 | ||
13540 | /* Route reflector client. */ | |
13541 | if (peergroup_af_flag_check(peer, afi, safi, | |
13542 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
13543 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
13544 | } | |
13545 | ||
13546 | /* next-hop-self force */ | |
13547 | if (peergroup_af_flag_check(peer, afi, safi, | |
13548 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
13549 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
13550 | } | |
13551 | ||
13552 | /* next-hop-self */ | |
13553 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
13554 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
13555 | } | |
13556 | ||
13557 | /* remove-private-AS */ | |
13558 | if (peergroup_af_flag_check(peer, afi, safi, | |
13559 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
13560 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
13561 | addr); | |
13562 | } | |
13563 | ||
13564 | else if (peergroup_af_flag_check(peer, afi, safi, | |
13565 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
13566 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
13567 | addr); | |
13568 | } | |
13569 | ||
13570 | else if (peergroup_af_flag_check(peer, afi, safi, | |
13571 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
13572 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
13573 | } | |
13574 | ||
13575 | else if (peergroup_af_flag_check(peer, afi, safi, | |
13576 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
13577 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
13578 | } | |
13579 | ||
13580 | /* as-override */ | |
13581 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
13582 | vty_out(vty, " neighbor %s as-override\n", addr); | |
13583 | } | |
13584 | ||
13585 | /* send-community print. */ | |
13586 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
13587 | PEER_FLAG_SEND_COMMUNITY); | |
13588 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
13589 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
13590 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
13591 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
13592 | ||
13593 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
13594 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
13595 | } else { | |
13596 | if (flag_scomm) | |
13597 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
13598 | if (flag_secomm) | |
13599 | vty_out(vty, | |
13600 | " no neighbor %s send-community extended\n", | |
13601 | addr); | |
13602 | ||
13603 | if (flag_slcomm) | |
13604 | vty_out(vty, " no neighbor %s send-community large\n", | |
13605 | addr); | |
13606 | } | |
13607 | ||
13608 | /* Default information */ | |
13609 | if (peergroup_af_flag_check(peer, afi, safi, | |
13610 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
13611 | vty_out(vty, " neighbor %s default-originate", addr); | |
13612 | ||
13613 | if (peer->default_rmap[afi][safi].name) | |
13614 | vty_out(vty, " route-map %s", | |
13615 | peer->default_rmap[afi][safi].name); | |
13616 | ||
13617 | vty_out(vty, "\n"); | |
13618 | } | |
13619 | ||
13620 | /* Soft reconfiguration inbound. */ | |
13621 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
13622 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
13623 | addr); | |
13624 | } | |
13625 | ||
13626 | /* maximum-prefix. */ | |
13627 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
13628 | vty_out(vty, " neighbor %s maximum-prefix %" PRIu32, addr, | |
13629 | peer->pmax[afi][safi]); | |
13630 | ||
13631 | if (peer->pmax_threshold[afi][safi] | |
13632 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
13633 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
13634 | if (peer_af_flag_check(peer, afi, safi, | |
13635 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
13636 | vty_out(vty, " warning-only"); | |
13637 | if (peer->pmax_restart[afi][safi]) | |
13638 | vty_out(vty, " restart %u", | |
13639 | peer->pmax_restart[afi][safi]); | |
13640 | ||
13641 | vty_out(vty, "\n"); | |
13642 | } | |
13643 | ||
fde246e8 DA |
13644 | /* maximum-prefix-out */ |
13645 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
13646 | vty_out(vty, " neighbor %s maximum-prefix-out %" PRIu32 "\n", | |
13647 | addr, peer->pmax_out[afi][safi]); | |
13648 | ||
dd65f45e DL |
13649 | /* Route server client. */ |
13650 | if (peergroup_af_flag_check(peer, afi, safi, | |
13651 | PEER_FLAG_RSERVER_CLIENT)) { | |
13652 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
13653 | } | |
13654 | ||
13655 | /* Nexthop-local unchanged. */ | |
13656 | if (peergroup_af_flag_check(peer, afi, safi, | |
13657 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
13658 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
13659 | } | |
13660 | ||
13661 | /* allowas-in <1-10> */ | |
13662 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
13663 | if (peer_af_flag_check(peer, afi, safi, | |
13664 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
13665 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
13666 | } else if (peer->allowas_in[afi][safi] == 3) { | |
13667 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
13668 | } else { | |
13669 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
13670 | peer->allowas_in[afi][safi]); | |
13671 | } | |
13672 | } | |
13673 | ||
13674 | /* weight */ | |
13675 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
13676 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
13677 | peer->weight[afi][safi]); | |
13678 | ||
13679 | /* Filter. */ | |
13680 | bgp_config_write_filter(vty, peer, afi, safi); | |
13681 | ||
13682 | /* atribute-unchanged. */ | |
13683 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
13684 | || (safi != SAFI_EVPN | |
13685 | && peer_af_flag_check(peer, afi, safi, | |
13686 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
13687 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
13688 | ||
13689 | if (!peer_group_active(peer) | |
13690 | || peergroup_af_flag_check(peer, afi, safi, | |
13691 | PEER_FLAG_AS_PATH_UNCHANGED) | |
13692 | || peergroup_af_flag_check(peer, afi, safi, | |
13693 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
13694 | || peergroup_af_flag_check(peer, afi, safi, | |
13695 | PEER_FLAG_MED_UNCHANGED)) { | |
13696 | ||
13697 | vty_out(vty, | |
13698 | " neighbor %s attribute-unchanged%s%s%s\n", | |
13699 | addr, | |
13700 | peer_af_flag_check(peer, afi, safi, | |
13701 | PEER_FLAG_AS_PATH_UNCHANGED) | |
13702 | ? " as-path" | |
13703 | : "", | |
13704 | peer_af_flag_check(peer, afi, safi, | |
13705 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
13706 | ? " next-hop" | |
13707 | : "", | |
13708 | peer_af_flag_check(peer, afi, safi, | |
13709 | PEER_FLAG_MED_UNCHANGED) | |
13710 | ? " med" | |
13711 | : ""); | |
13712 | } | |
13713 | } | |
13714 | } | |
13715 | ||
13716 | /* Address family based peer configuration display. */ | |
13717 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
13718 | safi_t safi) | |
13719 | { | |
13720 | struct peer *peer; | |
13721 | struct peer_group *group; | |
13722 | struct listnode *node, *nnode; | |
13723 | ||
13724 | ||
13725 | vty_frame(vty, " !\n address-family "); | |
13726 | if (afi == AFI_IP) { | |
13727 | if (safi == SAFI_UNICAST) | |
13728 | vty_frame(vty, "ipv4 unicast"); | |
13729 | else if (safi == SAFI_LABELED_UNICAST) | |
13730 | vty_frame(vty, "ipv4 labeled-unicast"); | |
13731 | else if (safi == SAFI_MULTICAST) | |
13732 | vty_frame(vty, "ipv4 multicast"); | |
13733 | else if (safi == SAFI_MPLS_VPN) | |
13734 | vty_frame(vty, "ipv4 vpn"); | |
13735 | else if (safi == SAFI_ENCAP) | |
13736 | vty_frame(vty, "ipv4 encap"); | |
13737 | else if (safi == SAFI_FLOWSPEC) | |
13738 | vty_frame(vty, "ipv4 flowspec"); | |
13739 | } else if (afi == AFI_IP6) { | |
13740 | if (safi == SAFI_UNICAST) | |
13741 | vty_frame(vty, "ipv6 unicast"); | |
13742 | else if (safi == SAFI_LABELED_UNICAST) | |
13743 | vty_frame(vty, "ipv6 labeled-unicast"); | |
13744 | else if (safi == SAFI_MULTICAST) | |
13745 | vty_frame(vty, "ipv6 multicast"); | |
13746 | else if (safi == SAFI_MPLS_VPN) | |
13747 | vty_frame(vty, "ipv6 vpn"); | |
13748 | else if (safi == SAFI_ENCAP) | |
13749 | vty_frame(vty, "ipv6 encap"); | |
13750 | else if (safi == SAFI_FLOWSPEC) | |
13751 | vty_frame(vty, "ipv6 flowspec"); | |
13752 | } else if (afi == AFI_L2VPN) { | |
13753 | if (safi == SAFI_EVPN) | |
13754 | vty_frame(vty, "l2vpn evpn"); | |
13755 | } | |
13756 | vty_frame(vty, "\n"); | |
13757 | ||
13758 | bgp_config_write_distance(vty, bgp, afi, safi); | |
13759 | ||
13760 | bgp_config_write_network(vty, bgp, afi, safi); | |
13761 | ||
13762 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
13763 | ||
13764 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) | |
13765 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
13766 | ||
13767 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
13768 | /* Skip dynamic neighbors. */ | |
13769 | if (peer_dynamic_neighbor(peer)) | |
13770 | continue; | |
13771 | ||
13772 | /* Do not display doppelganger peers */ | |
13773 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
13774 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
13775 | } | |
13776 | ||
13777 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
13778 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
13779 | ||
13780 | if (safi == SAFI_EVPN) | |
13781 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
13782 | ||
13783 | if (safi == SAFI_FLOWSPEC) | |
13784 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
13785 | ||
13786 | if (safi == SAFI_UNICAST) { | |
13787 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
13788 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
13789 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
13790 | ||
13791 | vty_out(vty, " export vpn\n"); | |
13792 | } | |
13793 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
13794 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
13795 | ||
13796 | vty_out(vty, " import vpn\n"); | |
13797 | } | |
13798 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
13799 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
13800 | char *name; | |
13801 | ||
13802 | for (ALL_LIST_ELEMENTS_RO( | |
13803 | bgp->vpn_policy[afi].import_vrf, node, | |
13804 | name)) | |
13805 | vty_out(vty, " import vrf %s\n", name); | |
13806 | } | |
13807 | } | |
13808 | ||
13809 | vty_endframe(vty, " exit-address-family\n"); | |
13810 | } | |
13811 | ||
13812 | int bgp_config_write(struct vty *vty) | |
13813 | { | |
13814 | struct bgp *bgp; | |
13815 | struct peer_group *group; | |
13816 | struct peer *peer; | |
13817 | struct listnode *node, *nnode; | |
13818 | struct listnode *mnode, *mnnode; | |
13819 | ||
13820 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
13821 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
13822 | bm->rmap_update_timer); | |
13823 | ||
13824 | /* BGP configuration. */ | |
13825 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
13826 | ||
13827 | /* skip all auto created vrf as they dont have user config */ | |
13828 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
13829 | continue; | |
13830 | ||
13831 | /* Router bgp ASN */ | |
13832 | vty_out(vty, "router bgp %u", bgp->as); | |
13833 | ||
13834 | if (bgp->name) | |
13835 | vty_out(vty, " %s %s", | |
13836 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
13837 | ? "view" : "vrf", bgp->name); | |
13838 | vty_out(vty, "\n"); | |
13839 | ||
13840 | /* BGP fast-external-failover. */ | |
13841 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
13842 | vty_out(vty, " no bgp fast-external-failover\n"); | |
13843 | ||
13844 | /* BGP router ID. */ | |
13845 | if (bgp->router_id_static.s_addr != 0) | |
13846 | vty_out(vty, " bgp router-id %s\n", | |
13847 | inet_ntoa(bgp->router_id_static)); | |
13848 | ||
13849 | /* BGP log-neighbor-changes. */ | |
13850 | if (!!bgp_flag_check(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
5d5393b9 | 13851 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e DL |
13852 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
13853 | bgp_flag_check(bgp, | |
13854 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
13855 | ? "" | |
13856 | : "no "); | |
13857 | ||
13858 | /* BGP configuration. */ | |
13859 | if (bgp_flag_check(bgp, BGP_FLAG_ALWAYS_COMPARE_MED)) | |
13860 | vty_out(vty, " bgp always-compare-med\n"); | |
13861 | ||
13862 | /* RFC8212 default eBGP policy. */ | |
13863 | if (bgp->ebgp_requires_policy | |
13864 | == DEFAULT_EBGP_POLICY_ENABLED) | |
13865 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
13866 | ||
13867 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
13868 | if (bgp->reject_as_sets == BGP_REJECT_AS_SETS_ENABLED) | |
13869 | vty_out(vty, " bgp reject-as-sets\n"); | |
13870 | ||
13871 | /* BGP default ipv4-unicast. */ | |
13872 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4)) | |
13873 | vty_out(vty, " no bgp default ipv4-unicast\n"); | |
13874 | ||
13875 | /* BGP default local-preference. */ | |
13876 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
13877 | vty_out(vty, " bgp default local-preference %u\n", | |
13878 | bgp->default_local_pref); | |
13879 | ||
13880 | /* BGP default show-hostname */ | |
13881 | if (!!bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) | |
5d5393b9 | 13882 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e DL |
13883 | vty_out(vty, " %sbgp default show-hostname\n", |
13884 | bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) | |
13885 | ? "" | |
13886 | : "no "); | |
13887 | ||
13888 | /* BGP default subgroup-pkt-queue-max. */ | |
13889 | if (bgp->default_subgroup_pkt_queue_max | |
13890 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
13891 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
13892 | bgp->default_subgroup_pkt_queue_max); | |
13893 | ||
13894 | /* BGP client-to-client reflection. */ | |
13895 | if (bgp_flag_check(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
13896 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
13897 | ||
13898 | /* BGP cluster ID. */ | |
13899 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
13900 | vty_out(vty, " bgp cluster-id %s\n", | |
13901 | inet_ntoa(bgp->cluster_id)); | |
13902 | ||
13903 | /* Disable ebgp connected nexthop check */ | |
13904 | if (bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
13905 | vty_out(vty, | |
13906 | " bgp disable-ebgp-connected-route-check\n"); | |
13907 | ||
13908 | /* Confederation identifier*/ | |
13909 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13910 | vty_out(vty, " bgp confederation identifier %u\n", | |
13911 | bgp->confed_id); | |
13912 | ||
13913 | /* Confederation peer */ | |
13914 | if (bgp->confed_peers_cnt > 0) { | |
13915 | int i; | |
13916 | ||
13917 | vty_out(vty, " bgp confederation peers"); | |
13918 | ||
13919 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
13920 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
13921 | ||
13922 | vty_out(vty, "\n"); | |
13923 | } | |
13924 | ||
13925 | /* BGP deterministic-med. */ | |
13926 | if (!!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) | |
5d5393b9 | 13927 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e DL |
13928 | vty_out(vty, " %sbgp deterministic-med\n", |
13929 | bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) | |
13930 | ? "" | |
13931 | : "no "); | |
13932 | ||
13933 | /* BGP update-delay. */ | |
13934 | bgp_config_write_update_delay(vty, bgp); | |
13935 | ||
13936 | if (bgp->v_maxmed_onstartup | |
13937 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
13938 | vty_out(vty, " bgp max-med on-startup %u", | |
13939 | bgp->v_maxmed_onstartup); | |
13940 | if (bgp->maxmed_onstartup_value | |
13941 | != BGP_MAXMED_VALUE_DEFAULT) | |
13942 | vty_out(vty, " %u", | |
13943 | bgp->maxmed_onstartup_value); | |
13944 | vty_out(vty, "\n"); | |
13945 | } | |
13946 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
13947 | vty_out(vty, " bgp max-med administrative"); | |
13948 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
13949 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
13950 | vty_out(vty, "\n"); | |
13951 | } | |
13952 | ||
13953 | /* write quanta */ | |
13954 | bgp_config_write_wpkt_quanta(vty, bgp); | |
13955 | /* read quanta */ | |
13956 | bgp_config_write_rpkt_quanta(vty, bgp); | |
13957 | ||
13958 | /* coalesce time */ | |
13959 | bgp_config_write_coalesce_time(vty, bgp); | |
13960 | ||
13961 | /* BGP graceful-restart. */ | |
13962 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
13963 | vty_out(vty, | |
13964 | " bgp graceful-restart stalepath-time %u\n", | |
13965 | bgp->stalepath_time); | |
13966 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) | |
13967 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
13968 | bgp->restart_time); | |
13969 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_RESTART)) | |
13970 | vty_out(vty, " bgp graceful-restart\n"); | |
13971 | ||
13972 | /* BGP graceful-shutdown */ | |
13973 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
13974 | vty_out(vty, " bgp graceful-shutdown\n"); | |
13975 | ||
13976 | /* BGP graceful-restart Preserve State F bit. */ | |
13977 | if (bgp_flag_check(bgp, BGP_FLAG_GR_PRESERVE_FWD)) | |
13978 | vty_out(vty, | |
13979 | " bgp graceful-restart preserve-fw-state\n"); | |
13980 | ||
13981 | /* BGP bestpath method. */ | |
13982 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
13983 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
13984 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
13985 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
13986 | ||
13987 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
13988 | if (bgp_flag_check(bgp, | |
13989 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
13990 | vty_out(vty, | |
13991 | " bgp bestpath as-path multipath-relax as-set\n"); | |
13992 | } else { | |
13993 | vty_out(vty, | |
13994 | " bgp bestpath as-path multipath-relax\n"); | |
13995 | } | |
13996 | } | |
13997 | ||
13998 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { | |
13999 | vty_out(vty, | |
14000 | " bgp route-reflector allow-outbound-policy\n"); | |
14001 | } | |
14002 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
14003 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
14004 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
14005 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
14006 | vty_out(vty, " bgp bestpath med"); | |
14007 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
14008 | vty_out(vty, " confed"); | |
14009 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
14010 | vty_out(vty, " missing-as-worst"); | |
14011 | vty_out(vty, "\n"); | |
14012 | } | |
14013 | ||
14014 | /* BGP network import check. */ | |
14015 | if (!!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK) | |
5d5393b9 | 14016 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e DL |
14017 | vty_out(vty, " %sbgp network import-check\n", |
14018 | bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK) | |
14019 | ? "" | |
14020 | : "no "); | |
14021 | ||
14022 | /* BGP timers configuration. */ | |
5d5393b9 DL |
14023 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
14024 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
14025 | vty_out(vty, " timers bgp %u %u\n", |
14026 | bgp->default_keepalive, bgp->default_holdtime); | |
14027 | ||
14028 | /* peer-group */ | |
14029 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
14030 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
14031 | } | |
14032 | ||
14033 | /* Normal neighbor configuration. */ | |
14034 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14035 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14036 | bgp_config_write_peer_global(vty, bgp, peer); | |
14037 | } | |
14038 | ||
14039 | /* listen range and limit for dynamic BGP neighbors */ | |
14040 | bgp_config_write_listen(vty, bgp); | |
14041 | ||
14042 | /* | |
14043 | * BGP default autoshutdown neighbors | |
14044 | * | |
14045 | * This must be placed after any peer and peer-group | |
14046 | * configuration, to avoid setting all peers to shutdown after | |
14047 | * a daemon restart, which is undesired behavior. (see #2286) | |
14048 | */ | |
14049 | if (bgp->autoshutdown) | |
14050 | vty_out(vty, " bgp default shutdown\n"); | |
14051 | ||
14052 | /* IPv4 unicast configuration. */ | |
14053 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
14054 | ||
14055 | /* IPv4 multicast configuration. */ | |
14056 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
14057 | ||
14058 | /* IPv4 labeled-unicast configuration. */ | |
14059 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
14060 | ||
14061 | /* IPv4 VPN configuration. */ | |
14062 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
14063 | ||
14064 | /* ENCAPv4 configuration. */ | |
14065 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
14066 | ||
14067 | /* FLOWSPEC v4 configuration. */ | |
14068 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
14069 | ||
14070 | /* IPv6 unicast configuration. */ | |
14071 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
14072 | ||
14073 | /* IPv6 multicast configuration. */ | |
14074 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
14075 | ||
14076 | /* IPv6 labeled-unicast configuration. */ | |
14077 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
14078 | SAFI_LABELED_UNICAST); | |
14079 | ||
14080 | /* IPv6 VPN configuration. */ | |
14081 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
14082 | ||
14083 | /* ENCAPv6 configuration. */ | |
14084 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
14085 | ||
14086 | /* FLOWSPEC v6 configuration. */ | |
14087 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
14088 | ||
14089 | /* EVPN configuration. */ | |
14090 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
14091 | ||
14092 | hook_call(bgp_inst_config_write, bgp, vty); | |
14093 | ||
14094 | #if ENABLE_BGP_VNC | |
14095 | bgp_rfapi_cfg_write(vty, bgp); | |
14096 | #endif | |
14097 | ||
14098 | vty_out(vty, "!\n"); | |
14099 | } | |
14100 | return 0; | |
14101 | } | |
14102 | ||
ddb5b488 | 14103 | |
718e3744 | 14104 | /* BGP node structure. */ |
d62a17ae | 14105 | static struct cmd_node bgp_node = { |
9d303b37 | 14106 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 14107 | }; |
14108 | ||
d62a17ae | 14109 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 14110 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 14111 | }; |
14112 | ||
d62a17ae | 14113 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 14114 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 14115 | }; |
14116 | ||
d62a17ae | 14117 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 14118 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
14119 | }; |
14120 | ||
d62a17ae | 14121 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 14122 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 14123 | }; |
14124 | ||
d62a17ae | 14125 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 14126 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 14127 | }; |
14128 | ||
d62a17ae | 14129 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 14130 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
14131 | }; |
14132 | ||
d62a17ae | 14133 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
14134 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 14135 | |
d62a17ae | 14136 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
14137 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 14138 | |
d62a17ae | 14139 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
14140 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 14141 | |
d62a17ae | 14142 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
14143 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 14144 | |
7c40bf39 | 14145 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
14146 | "%s(config-router-af)# ", 1}; | |
14147 | ||
14148 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
14149 | "%s(config-router-af-vpnv6)# ", 1}; | |
14150 | ||
d62a17ae | 14151 | static void community_list_vty(void); |
1f8ae70b | 14152 | |
d62a17ae | 14153 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 14154 | { |
d62a17ae | 14155 | struct bgp *bgp; |
14156 | struct peer *peer; | |
d62a17ae | 14157 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 14158 | |
d62a17ae | 14159 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
14160 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
14161 | /* only provide suggestions on the appropriate input | |
14162 | * token type, | |
14163 | * they'll otherwise show up multiple times */ | |
14164 | enum cmd_token_type match_type; | |
14165 | char *name = peer->host; | |
d48ed3e0 | 14166 | |
d62a17ae | 14167 | if (peer->conf_if) { |
14168 | match_type = VARIABLE_TKN; | |
14169 | name = peer->conf_if; | |
14170 | } else if (strchr(peer->host, ':')) | |
14171 | match_type = IPV6_TKN; | |
14172 | else | |
14173 | match_type = IPV4_TKN; | |
d48ed3e0 | 14174 | |
d62a17ae | 14175 | if (token->type != match_type) |
14176 | continue; | |
d48ed3e0 | 14177 | |
d62a17ae | 14178 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
14179 | } | |
d62a17ae | 14180 | } |
b8a815e5 DL |
14181 | } |
14182 | ||
14183 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 14184 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
14185 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 14186 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 14187 | {.completions = NULL}}; |
14188 | ||
47a306a0 DS |
14189 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
14190 | { | |
14191 | struct bgp *bgp; | |
14192 | struct peer_group *group; | |
14193 | struct listnode *lnbgp, *lnpeer; | |
14194 | ||
14195 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
14196 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
14197 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
14198 | group->name)); | |
14199 | } | |
14200 | } | |
14201 | ||
14202 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
14203 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
14204 | {.completions = NULL} }; | |
14205 | ||
d62a17ae | 14206 | void bgp_vty_init(void) |
14207 | { | |
14208 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 14209 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 14210 | |
14211 | /* Install bgp top node. */ | |
14212 | install_node(&bgp_node, bgp_config_write); | |
14213 | install_node(&bgp_ipv4_unicast_node, NULL); | |
14214 | install_node(&bgp_ipv4_multicast_node, NULL); | |
14215 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
14216 | install_node(&bgp_ipv6_unicast_node, NULL); | |
14217 | install_node(&bgp_ipv6_multicast_node, NULL); | |
14218 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
14219 | install_node(&bgp_vpnv4_node, NULL); | |
14220 | install_node(&bgp_vpnv6_node, NULL); | |
14221 | install_node(&bgp_evpn_node, NULL); | |
14222 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 14223 | install_node(&bgp_flowspecv4_node, NULL); |
14224 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 14225 | |
14226 | /* Install default VTY commands to new nodes. */ | |
14227 | install_default(BGP_NODE); | |
14228 | install_default(BGP_IPV4_NODE); | |
14229 | install_default(BGP_IPV4M_NODE); | |
14230 | install_default(BGP_IPV4L_NODE); | |
14231 | install_default(BGP_IPV6_NODE); | |
14232 | install_default(BGP_IPV6M_NODE); | |
14233 | install_default(BGP_IPV6L_NODE); | |
14234 | install_default(BGP_VPNV4_NODE); | |
14235 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 14236 | install_default(BGP_FLOWSPECV4_NODE); |
14237 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 14238 | install_default(BGP_EVPN_NODE); |
14239 | install_default(BGP_EVPN_VNI_NODE); | |
14240 | ||
8029b216 AK |
14241 | /* "bgp local-mac" hidden commands. */ |
14242 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
14243 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
14244 | ||
d62a17ae | 14245 | /* bgp route-map delay-timer commands. */ |
14246 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
14247 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
14248 | ||
14249 | /* Dummy commands (Currently not supported) */ | |
14250 | install_element(BGP_NODE, &no_synchronization_cmd); | |
14251 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
14252 | ||
14253 | /* "router bgp" commands. */ | |
14254 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
14255 | ||
14256 | /* "no router bgp" commands. */ | |
14257 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
14258 | ||
14259 | /* "bgp router-id" commands. */ | |
14260 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
14261 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
14262 | ||
14263 | /* "bgp cluster-id" commands. */ | |
14264 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
14265 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
14266 | ||
14267 | /* "bgp confederation" commands. */ | |
14268 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
14269 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
14270 | ||
14271 | /* "bgp confederation peers" commands. */ | |
14272 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
14273 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
14274 | ||
14275 | /* bgp max-med command */ | |
14276 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
14277 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
14278 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
14279 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
14280 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
14281 | ||
14282 | /* bgp disable-ebgp-connected-nh-check */ | |
14283 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
14284 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
14285 | ||
14286 | /* bgp update-delay command */ | |
14287 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
14288 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
14289 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
14290 | ||
14291 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 14292 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 14293 | |
14294 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
14295 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
14296 | ||
14297 | /* "maximum-paths" commands. */ | |
14298 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
14299 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
14300 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
14301 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
14302 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
14303 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
14304 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
14305 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
14306 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
14307 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
14308 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
14309 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
14310 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
14311 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
14312 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
14313 | ||
14314 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
14315 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
14316 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
14317 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
14318 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
14319 | ||
14320 | /* "timers bgp" commands. */ | |
14321 | install_element(BGP_NODE, &bgp_timers_cmd); | |
14322 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
14323 | ||
14324 | /* route-map delay-timer commands - per instance for backwards compat. | |
14325 | */ | |
14326 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
14327 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
14328 | ||
14329 | /* "bgp client-to-client reflection" commands */ | |
14330 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
14331 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
14332 | ||
14333 | /* "bgp always-compare-med" commands */ | |
14334 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
14335 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
14336 | ||
9dac9fc8 DA |
14337 | /* bgp ebgp-requires-policy */ |
14338 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
14339 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
14340 | ||
fb29348a DA |
14341 | /* bgp reject-as-sets */ |
14342 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
14343 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
14344 | ||
d62a17ae | 14345 | /* "bgp deterministic-med" commands */ |
14346 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
14347 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
14348 | ||
14349 | /* "bgp graceful-restart" commands */ | |
14350 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
14351 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
14352 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
14353 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
14354 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
14355 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
14356 | ||
14357 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
14358 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
14359 | ||
7f323236 DW |
14360 | /* "bgp graceful-shutdown" commands */ |
14361 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
14362 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
14363 | ||
d62a17ae | 14364 | /* "bgp fast-external-failover" commands */ |
14365 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
14366 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
14367 | ||
d62a17ae | 14368 | /* "bgp bestpath compare-routerid" commands */ |
14369 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
14370 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
14371 | ||
14372 | /* "bgp bestpath as-path ignore" commands */ | |
14373 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
14374 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
14375 | ||
14376 | /* "bgp bestpath as-path confed" commands */ | |
14377 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
14378 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
14379 | ||
14380 | /* "bgp bestpath as-path multipath-relax" commands */ | |
14381 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
14382 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
14383 | ||
14384 | /* "bgp log-neighbor-changes" commands */ | |
14385 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
14386 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
14387 | ||
14388 | /* "bgp bestpath med" commands */ | |
14389 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
14390 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
14391 | ||
14392 | /* "no bgp default ipv4-unicast" commands. */ | |
14393 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
14394 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
14395 | ||
14396 | /* "bgp network import-check" commands. */ | |
14397 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
14398 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
14399 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
14400 | ||
14401 | /* "bgp default local-preference" commands. */ | |
14402 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
14403 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
14404 | ||
14405 | /* bgp default show-hostname */ | |
14406 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
14407 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
14408 | ||
14409 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
14410 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
14411 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
14412 | ||
14413 | /* bgp ibgp-allow-policy-mods command */ | |
14414 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
14415 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
14416 | ||
14417 | /* "bgp listen limit" commands. */ | |
14418 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
14419 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
14420 | ||
14421 | /* "bgp listen range" commands. */ | |
14422 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
14423 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
14424 | ||
8175f54a | 14425 | /* "bgp default shutdown" command */ |
f26845f9 QY |
14426 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
14427 | ||
d62a17ae | 14428 | /* "neighbor remote-as" commands. */ |
14429 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
14430 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
14431 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
14432 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
14433 | install_element(BGP_NODE, | |
14434 | &neighbor_interface_v6only_config_remote_as_cmd); | |
14435 | install_element(BGP_NODE, &no_neighbor_cmd); | |
14436 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
14437 | ||
14438 | /* "neighbor peer-group" commands. */ | |
14439 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
14440 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
14441 | install_element(BGP_NODE, | |
14442 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
14443 | ||
14444 | /* "neighbor local-as" commands. */ | |
14445 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
14446 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
14447 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
14448 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
14449 | ||
14450 | /* "neighbor solo" commands. */ | |
14451 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
14452 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
14453 | ||
14454 | /* "neighbor password" commands. */ | |
14455 | install_element(BGP_NODE, &neighbor_password_cmd); | |
14456 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
14457 | ||
14458 | /* "neighbor activate" commands. */ | |
14459 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
14460 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
14461 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
14462 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
14463 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
14464 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
14465 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
14466 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
14467 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 14468 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
14469 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 14470 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
14471 | ||
14472 | /* "no neighbor activate" commands. */ | |
14473 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
14474 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
14475 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
14476 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
14477 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
14478 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
14479 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
14480 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
14481 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 14482 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
14483 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 14484 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
14485 | ||
14486 | /* "neighbor peer-group" set commands. */ | |
14487 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
14488 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
14489 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
14490 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
14491 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
14492 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
14493 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
14494 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 14495 | install_element(BGP_FLOWSPECV4_NODE, |
14496 | &neighbor_set_peer_group_hidden_cmd); | |
14497 | install_element(BGP_FLOWSPECV6_NODE, | |
14498 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 14499 | |
14500 | /* "no neighbor peer-group unset" commands. */ | |
14501 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
14502 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
14503 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
14504 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
14505 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
14506 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
14507 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
14508 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 14509 | install_element(BGP_FLOWSPECV4_NODE, |
14510 | &no_neighbor_set_peer_group_hidden_cmd); | |
14511 | install_element(BGP_FLOWSPECV6_NODE, | |
14512 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 14513 | |
14514 | /* "neighbor softreconfiguration inbound" commands.*/ | |
14515 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
14516 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
14517 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
14518 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
14519 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
14520 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
14521 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
14522 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
14523 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
14524 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
14525 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
14526 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
14527 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
14528 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
14529 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
14530 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
14531 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
14532 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 14533 | install_element(BGP_FLOWSPECV4_NODE, |
14534 | &neighbor_soft_reconfiguration_cmd); | |
14535 | install_element(BGP_FLOWSPECV4_NODE, | |
14536 | &no_neighbor_soft_reconfiguration_cmd); | |
14537 | install_element(BGP_FLOWSPECV6_NODE, | |
14538 | &neighbor_soft_reconfiguration_cmd); | |
14539 | install_element(BGP_FLOWSPECV6_NODE, | |
14540 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
14541 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
14542 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 14543 | |
14544 | /* "neighbor attribute-unchanged" commands. */ | |
14545 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
14546 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
14547 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
14548 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
14549 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
14550 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
14551 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
14552 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
14553 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
14554 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
14555 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
14556 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
14557 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
14558 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
14559 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
14560 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
14561 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
14562 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
14563 | ||
14564 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
14565 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
14566 | ||
14567 | /* "nexthop-local unchanged" commands */ | |
14568 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
14569 | install_element(BGP_IPV6_NODE, | |
14570 | &no_neighbor_nexthop_local_unchanged_cmd); | |
14571 | ||
14572 | /* "neighbor next-hop-self" commands. */ | |
14573 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
14574 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
14575 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
14576 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
14577 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
14578 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
14579 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
14580 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
14581 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
14582 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
14583 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
14584 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
14585 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
14586 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
14587 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
14588 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
14589 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
14590 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
14591 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
14592 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 14593 | |
14594 | /* "neighbor next-hop-self force" commands. */ | |
14595 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
14596 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
14597 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
14598 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 14599 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
14600 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
14601 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
14602 | install_element(BGP_IPV4_NODE, | |
14603 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 14604 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
14605 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
14606 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
14607 | install_element(BGP_IPV4M_NODE, | |
14608 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 14609 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
14610 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
14611 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
14612 | install_element(BGP_IPV4L_NODE, | |
14613 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 14614 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
14615 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
14616 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
14617 | install_element(BGP_IPV6_NODE, | |
14618 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 14619 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
14620 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
14621 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
14622 | install_element(BGP_IPV6M_NODE, | |
14623 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 14624 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
14625 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
14626 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
14627 | install_element(BGP_IPV6L_NODE, | |
14628 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 14629 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
14630 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
14631 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
14632 | install_element(BGP_VPNV4_NODE, | |
14633 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 14634 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
14635 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
14636 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
14637 | install_element(BGP_VPNV6_NODE, | |
14638 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 14639 | |
14640 | /* "neighbor as-override" commands. */ | |
14641 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
14642 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
14643 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
14644 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
14645 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
14646 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
14647 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
14648 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
14649 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
14650 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
14651 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
14652 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
14653 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
14654 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
14655 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
14656 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
14657 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
14658 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
14659 | ||
14660 | /* "neighbor remove-private-AS" commands. */ | |
14661 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
14662 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
14663 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
14664 | install_element(BGP_NODE, | |
14665 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
14666 | install_element(BGP_NODE, | |
14667 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
14668 | install_element(BGP_NODE, | |
14669 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
14670 | install_element(BGP_NODE, | |
14671 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
14672 | install_element( | |
14673 | BGP_NODE, | |
14674 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
14675 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
14676 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
14677 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
14678 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
14679 | install_element(BGP_IPV4_NODE, | |
14680 | &neighbor_remove_private_as_replace_as_cmd); | |
14681 | install_element(BGP_IPV4_NODE, | |
14682 | &no_neighbor_remove_private_as_replace_as_cmd); | |
14683 | install_element(BGP_IPV4_NODE, | |
14684 | &neighbor_remove_private_as_all_replace_as_cmd); | |
14685 | install_element(BGP_IPV4_NODE, | |
14686 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
14687 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
14688 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
14689 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
14690 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
14691 | install_element(BGP_IPV4M_NODE, | |
14692 | &neighbor_remove_private_as_replace_as_cmd); | |
14693 | install_element(BGP_IPV4M_NODE, | |
14694 | &no_neighbor_remove_private_as_replace_as_cmd); | |
14695 | install_element(BGP_IPV4M_NODE, | |
14696 | &neighbor_remove_private_as_all_replace_as_cmd); | |
14697 | install_element(BGP_IPV4M_NODE, | |
14698 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
14699 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
14700 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
14701 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
14702 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
14703 | install_element(BGP_IPV4L_NODE, | |
14704 | &neighbor_remove_private_as_replace_as_cmd); | |
14705 | install_element(BGP_IPV4L_NODE, | |
14706 | &no_neighbor_remove_private_as_replace_as_cmd); | |
14707 | install_element(BGP_IPV4L_NODE, | |
14708 | &neighbor_remove_private_as_all_replace_as_cmd); | |
14709 | install_element(BGP_IPV4L_NODE, | |
14710 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
14711 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
14712 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
14713 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
14714 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
14715 | install_element(BGP_IPV6_NODE, | |
14716 | &neighbor_remove_private_as_replace_as_cmd); | |
14717 | install_element(BGP_IPV6_NODE, | |
14718 | &no_neighbor_remove_private_as_replace_as_cmd); | |
14719 | install_element(BGP_IPV6_NODE, | |
14720 | &neighbor_remove_private_as_all_replace_as_cmd); | |
14721 | install_element(BGP_IPV6_NODE, | |
14722 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
14723 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
14724 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
14725 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
14726 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
14727 | install_element(BGP_IPV6M_NODE, | |
14728 | &neighbor_remove_private_as_replace_as_cmd); | |
14729 | install_element(BGP_IPV6M_NODE, | |
14730 | &no_neighbor_remove_private_as_replace_as_cmd); | |
14731 | install_element(BGP_IPV6M_NODE, | |
14732 | &neighbor_remove_private_as_all_replace_as_cmd); | |
14733 | install_element(BGP_IPV6M_NODE, | |
14734 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
14735 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
14736 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
14737 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
14738 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
14739 | install_element(BGP_IPV6L_NODE, | |
14740 | &neighbor_remove_private_as_replace_as_cmd); | |
14741 | install_element(BGP_IPV6L_NODE, | |
14742 | &no_neighbor_remove_private_as_replace_as_cmd); | |
14743 | install_element(BGP_IPV6L_NODE, | |
14744 | &neighbor_remove_private_as_all_replace_as_cmd); | |
14745 | install_element(BGP_IPV6L_NODE, | |
14746 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
14747 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
14748 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
14749 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
14750 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
14751 | install_element(BGP_VPNV4_NODE, | |
14752 | &neighbor_remove_private_as_replace_as_cmd); | |
14753 | install_element(BGP_VPNV4_NODE, | |
14754 | &no_neighbor_remove_private_as_replace_as_cmd); | |
14755 | install_element(BGP_VPNV4_NODE, | |
14756 | &neighbor_remove_private_as_all_replace_as_cmd); | |
14757 | install_element(BGP_VPNV4_NODE, | |
14758 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
14759 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
14760 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
14761 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
14762 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
14763 | install_element(BGP_VPNV6_NODE, | |
14764 | &neighbor_remove_private_as_replace_as_cmd); | |
14765 | install_element(BGP_VPNV6_NODE, | |
14766 | &no_neighbor_remove_private_as_replace_as_cmd); | |
14767 | install_element(BGP_VPNV6_NODE, | |
14768 | &neighbor_remove_private_as_all_replace_as_cmd); | |
14769 | install_element(BGP_VPNV6_NODE, | |
14770 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
14771 | ||
14772 | /* "neighbor send-community" commands.*/ | |
14773 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
14774 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
14775 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
14776 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
14777 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
14778 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
14779 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
14780 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
14781 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
14782 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
14783 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
14784 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
14785 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
14786 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
14787 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
14788 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
14789 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
14790 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
14791 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
14792 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
14793 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
14794 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
14795 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
14796 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
14797 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
14798 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
14799 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
14800 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
14801 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
14802 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
14803 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
14804 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
14805 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
14806 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
14807 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
14808 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
14809 | ||
14810 | /* "neighbor route-reflector" commands.*/ | |
14811 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
14812 | install_element(BGP_NODE, | |
14813 | &no_neighbor_route_reflector_client_hidden_cmd); | |
14814 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
14815 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
14816 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
14817 | install_element(BGP_IPV4M_NODE, | |
14818 | &no_neighbor_route_reflector_client_cmd); | |
14819 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
14820 | install_element(BGP_IPV4L_NODE, | |
14821 | &no_neighbor_route_reflector_client_cmd); | |
14822 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
14823 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
14824 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
14825 | install_element(BGP_IPV6M_NODE, | |
14826 | &no_neighbor_route_reflector_client_cmd); | |
14827 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
14828 | install_element(BGP_IPV6L_NODE, | |
14829 | &no_neighbor_route_reflector_client_cmd); | |
14830 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
14831 | install_element(BGP_VPNV4_NODE, | |
14832 | &no_neighbor_route_reflector_client_cmd); | |
14833 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
14834 | install_element(BGP_VPNV6_NODE, | |
14835 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 14836 | install_element(BGP_FLOWSPECV4_NODE, |
14837 | &neighbor_route_reflector_client_cmd); | |
14838 | install_element(BGP_FLOWSPECV4_NODE, | |
14839 | &no_neighbor_route_reflector_client_cmd); | |
14840 | install_element(BGP_FLOWSPECV6_NODE, | |
14841 | &neighbor_route_reflector_client_cmd); | |
14842 | install_element(BGP_FLOWSPECV6_NODE, | |
14843 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 14844 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
14845 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
14846 | ||
14847 | /* "neighbor route-server" commands.*/ | |
14848 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
14849 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
14850 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
14851 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
14852 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
14853 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
14854 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
14855 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
14856 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
14857 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
14858 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
14859 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
14860 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
14861 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
14862 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
14863 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
14864 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
14865 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
14866 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
14867 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 14868 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
14869 | install_element(BGP_FLOWSPECV4_NODE, | |
14870 | &no_neighbor_route_server_client_cmd); | |
14871 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
14872 | install_element(BGP_FLOWSPECV6_NODE, | |
14873 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 14874 | |
14875 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
14876 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
14877 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
14878 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
14879 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
14880 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
14881 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
14882 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
14883 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
14884 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
14885 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
14886 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
14887 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
14888 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
14889 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
14890 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
14891 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
14892 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
14893 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
14894 | ||
14895 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
14896 | install_element(BGP_NODE, | |
14897 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
14898 | install_element(BGP_NODE, | |
14899 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
14900 | install_element(BGP_IPV4_NODE, | |
14901 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
14902 | install_element(BGP_IPV4_NODE, | |
14903 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
14904 | install_element(BGP_IPV4M_NODE, | |
14905 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
14906 | install_element(BGP_IPV4M_NODE, | |
14907 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
14908 | install_element(BGP_IPV4L_NODE, | |
14909 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
14910 | install_element(BGP_IPV4L_NODE, | |
14911 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
14912 | install_element(BGP_IPV6_NODE, | |
14913 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
14914 | install_element(BGP_IPV6_NODE, | |
14915 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
14916 | install_element(BGP_IPV6M_NODE, | |
14917 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
14918 | install_element(BGP_IPV6M_NODE, | |
14919 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
14920 | install_element(BGP_IPV6L_NODE, | |
14921 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
14922 | install_element(BGP_IPV6L_NODE, | |
14923 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
14924 | install_element(BGP_VPNV4_NODE, | |
14925 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
14926 | install_element(BGP_VPNV4_NODE, | |
14927 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
14928 | install_element(BGP_VPNV6_NODE, | |
14929 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
14930 | install_element(BGP_VPNV6_NODE, | |
14931 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
14932 | ||
2b31007c RZ |
14933 | /* "neighbor sender-as-path-loop-detection" commands. */ |
14934 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
14935 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
14936 | ||
d62a17ae | 14937 | /* "neighbor passive" commands. */ |
14938 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
14939 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
14940 | ||
14941 | ||
14942 | /* "neighbor shutdown" commands. */ | |
14943 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
14944 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
14945 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
14946 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
14947 | ||
14948 | /* "neighbor capability extended-nexthop" commands.*/ | |
14949 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
14950 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
14951 | ||
14952 | /* "neighbor capability orf prefix-list" commands.*/ | |
14953 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
14954 | install_element(BGP_NODE, | |
14955 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
14956 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
14957 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
14958 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
14959 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
14960 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
14961 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
14962 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
14963 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
14964 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
14965 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
14966 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
14967 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
14968 | ||
14969 | /* "neighbor capability dynamic" commands.*/ | |
14970 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
14971 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
14972 | ||
14973 | /* "neighbor dont-capability-negotiate" commands. */ | |
14974 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
14975 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
14976 | ||
14977 | /* "neighbor ebgp-multihop" commands. */ | |
14978 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
14979 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
14980 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
14981 | ||
14982 | /* "neighbor disable-connected-check" commands. */ | |
14983 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
14984 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
14985 | ||
47cbc09b PM |
14986 | /* "neighbor enforce-first-as" commands. */ |
14987 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
14988 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
14989 | ||
d62a17ae | 14990 | /* "neighbor description" commands. */ |
14991 | install_element(BGP_NODE, &neighbor_description_cmd); | |
14992 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 14993 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 14994 | |
14995 | /* "neighbor update-source" commands. "*/ | |
14996 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
14997 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
14998 | ||
14999 | /* "neighbor default-originate" commands. */ | |
15000 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
15001 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
15002 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
15003 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
15004 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
15005 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
15006 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
15007 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
15008 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
15009 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
15010 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
15011 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
15012 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
15013 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
15014 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
15015 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
15016 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
15017 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
15018 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
15019 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
15020 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
15021 | ||
15022 | /* "neighbor port" commands. */ | |
15023 | install_element(BGP_NODE, &neighbor_port_cmd); | |
15024 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
15025 | ||
15026 | /* "neighbor weight" commands. */ | |
15027 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
15028 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
15029 | ||
15030 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
15031 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
15032 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
15033 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
15034 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
15035 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
15036 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
15037 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
15038 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
15039 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
15040 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
15041 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
15042 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
15043 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
15044 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
15045 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
15046 | ||
15047 | /* "neighbor override-capability" commands. */ | |
15048 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
15049 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
15050 | ||
15051 | /* "neighbor strict-capability-match" commands. */ | |
15052 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
15053 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
15054 | ||
15055 | /* "neighbor timers" commands. */ | |
15056 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
15057 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
15058 | ||
15059 | /* "neighbor timers connect" commands. */ | |
15060 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
15061 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
15062 | ||
15063 | /* "neighbor advertisement-interval" commands. */ | |
15064 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
15065 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
15066 | ||
15067 | /* "neighbor interface" commands. */ | |
15068 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
15069 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
15070 | ||
15071 | /* "neighbor distribute" commands. */ | |
15072 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
15073 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
15074 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
15075 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
15076 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
15077 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
15078 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
15079 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
15080 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
15081 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
15082 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
15083 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
15084 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
15085 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
15086 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
15087 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
15088 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
15089 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
15090 | ||
15091 | /* "neighbor prefix-list" commands. */ | |
15092 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
15093 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
15094 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
15095 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
15096 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
15097 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
15098 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
15099 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
15100 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
15101 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
15102 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
15103 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
15104 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
15105 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
15106 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
15107 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
15108 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
15109 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 15110 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
15111 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
15112 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
15113 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 15114 | |
15115 | /* "neighbor filter-list" commands. */ | |
15116 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
15117 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
15118 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
15119 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
15120 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
15121 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
15122 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
15123 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
15124 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
15125 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
15126 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
15127 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
15128 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
15129 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
15130 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
15131 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
15132 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
15133 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 15134 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
15135 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
15136 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
15137 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 15138 | |
15139 | /* "neighbor route-map" commands. */ | |
15140 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
15141 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
15142 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
15143 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
15144 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
15145 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
15146 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
15147 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
15148 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
15149 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
15150 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
15151 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
15152 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
15153 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
15154 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
15155 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
15156 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
15157 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 15158 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
15159 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
15160 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
15161 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
15162 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
15163 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 15164 | |
15165 | /* "neighbor unsuppress-map" commands. */ | |
15166 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
15167 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
15168 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
15169 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
15170 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
15171 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
15172 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
15173 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
15174 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
15175 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
15176 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
15177 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
15178 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
15179 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
15180 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
15181 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
15182 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
15183 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
15184 | ||
fde246e8 DA |
15185 | /* neighbor maximum-prefix-out commands. */ |
15186 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
15187 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
15188 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
15189 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
15190 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
15191 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
15192 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
15193 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
15194 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
15195 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
15196 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
15197 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
15198 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
15199 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
15200 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
15201 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
15202 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
15203 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
15204 | ||
d62a17ae | 15205 | /* "neighbor maximum-prefix" commands. */ |
15206 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
15207 | install_element(BGP_NODE, | |
15208 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
15209 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
15210 | install_element(BGP_NODE, | |
15211 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
15212 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
15213 | install_element(BGP_NODE, | |
15214 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
15215 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
15216 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
15217 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
15218 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
15219 | install_element(BGP_IPV4_NODE, | |
15220 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
15221 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
15222 | install_element(BGP_IPV4_NODE, | |
15223 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
15224 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
15225 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
15226 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
15227 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
15228 | install_element(BGP_IPV4M_NODE, | |
15229 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
15230 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
15231 | install_element(BGP_IPV4M_NODE, | |
15232 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
15233 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
15234 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
15235 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
15236 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
15237 | install_element(BGP_IPV4L_NODE, | |
15238 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
15239 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
15240 | install_element(BGP_IPV4L_NODE, | |
15241 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
15242 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
15243 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
15244 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
15245 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
15246 | install_element(BGP_IPV6_NODE, | |
15247 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
15248 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
15249 | install_element(BGP_IPV6_NODE, | |
15250 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
15251 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
15252 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
15253 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
15254 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
15255 | install_element(BGP_IPV6M_NODE, | |
15256 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
15257 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
15258 | install_element(BGP_IPV6M_NODE, | |
15259 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
15260 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
15261 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
15262 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
15263 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
15264 | install_element(BGP_IPV6L_NODE, | |
15265 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
15266 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
15267 | install_element(BGP_IPV6L_NODE, | |
15268 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
15269 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
15270 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
15271 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
15272 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
15273 | install_element(BGP_VPNV4_NODE, | |
15274 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
15275 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
15276 | install_element(BGP_VPNV4_NODE, | |
15277 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
15278 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
15279 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
15280 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
15281 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
15282 | install_element(BGP_VPNV6_NODE, | |
15283 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
15284 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
15285 | install_element(BGP_VPNV6_NODE, | |
15286 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
15287 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
15288 | ||
15289 | /* "neighbor allowas-in" */ | |
15290 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
15291 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
15292 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
15293 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
15294 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
15295 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
15296 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
15297 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
15298 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
15299 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
15300 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
15301 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
15302 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
15303 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
15304 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
15305 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
15306 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
15307 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
15308 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
15309 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
15310 | ||
15311 | /* address-family commands. */ | |
15312 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
15313 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 15314 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 15315 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
15316 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 15317 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 15318 | |
d62a17ae | 15319 | install_element(BGP_NODE, &address_family_evpn_cmd); |
15320 | ||
15321 | /* "exit-address-family" command. */ | |
15322 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
15323 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
15324 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
15325 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
15326 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
15327 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
15328 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
15329 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 15330 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
15331 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 15332 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
15333 | ||
15334 | /* "clear ip bgp commands" */ | |
15335 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
15336 | ||
15337 | /* clear ip bgp prefix */ | |
15338 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
15339 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
15340 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
15341 | ||
15342 | /* "show [ip] bgp summary" commands. */ | |
15343 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 15344 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 15345 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 15346 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 15347 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
15348 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 15349 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
15350 | ||
15351 | /* "show [ip] bgp neighbors" commands. */ | |
15352 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
15353 | ||
15354 | /* "show [ip] bgp peer-group" commands. */ | |
15355 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
15356 | ||
15357 | /* "show [ip] bgp paths" commands. */ | |
15358 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
15359 | ||
15360 | /* "show [ip] bgp community" commands. */ | |
15361 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
15362 | ||
15363 | /* "show ip bgp large-community" commands. */ | |
15364 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
15365 | /* "show [ip] bgp attribute-info" commands. */ | |
15366 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 15367 | /* "show [ip] bgp route-leak" command */ |
15368 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 15369 | |
15370 | /* "redistribute" commands. */ | |
15371 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
15372 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
15373 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
15374 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
15375 | install_element(BGP_NODE, | |
15376 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
15377 | install_element(BGP_NODE, | |
15378 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
15379 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
15380 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
15381 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
15382 | install_element(BGP_NODE, | |
15383 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
15384 | install_element(BGP_NODE, | |
15385 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
15386 | install_element(BGP_NODE, | |
15387 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
15388 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
15389 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
15390 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
15391 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
15392 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
15393 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
15394 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
15395 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
15396 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
15397 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
15398 | install_element(BGP_IPV4_NODE, | |
15399 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
15400 | install_element(BGP_IPV4_NODE, | |
15401 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
15402 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
15403 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
15404 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
15405 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
15406 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
15407 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
15408 | ||
b9c7bc5a PZ |
15409 | /* import|export vpn [route-map WORD] */ |
15410 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
15411 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 15412 | |
12a844a5 DS |
15413 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
15414 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
15415 | ||
d62a17ae | 15416 | /* ttl_security commands */ |
15417 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
15418 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
15419 | ||
15420 | /* "show [ip] bgp memory" commands. */ | |
15421 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
15422 | ||
acf71666 MK |
15423 | /* "show bgp martian next-hop" */ |
15424 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
15425 | ||
48ecf8f5 DS |
15426 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
15427 | ||
d62a17ae | 15428 | /* "show [ip] bgp views" commands. */ |
15429 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
15430 | ||
15431 | /* "show [ip] bgp vrfs" commands. */ | |
15432 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
15433 | ||
15434 | /* Community-list. */ | |
15435 | community_list_vty(); | |
ddb5b488 PZ |
15436 | |
15437 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
15438 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
15439 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
15440 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
15441 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
15442 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
15443 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
15444 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
15445 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
15446 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
15447 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
15448 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
15449 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 15450 | |
301ad80a PG |
15451 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
15452 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
15453 | ||
b9c7bc5a PZ |
15454 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
15455 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
15456 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
15457 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
15458 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
15459 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
15460 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
15461 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
15462 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
15463 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
15464 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
15465 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 15466 | } |
6b0655a2 | 15467 | |
718e3744 | 15468 | #include "memory.h" |
15469 | #include "bgp_regex.h" | |
15470 | #include "bgp_clist.h" | |
15471 | #include "bgp_ecommunity.h" | |
15472 | ||
15473 | /* VTY functions. */ | |
15474 | ||
15475 | /* Direction value to string conversion. */ | |
d62a17ae | 15476 | static const char *community_direct_str(int direct) |
15477 | { | |
15478 | switch (direct) { | |
15479 | case COMMUNITY_DENY: | |
15480 | return "deny"; | |
15481 | case COMMUNITY_PERMIT: | |
15482 | return "permit"; | |
15483 | default: | |
15484 | return "unknown"; | |
15485 | } | |
718e3744 | 15486 | } |
15487 | ||
15488 | /* Display error string. */ | |
d62a17ae | 15489 | static void community_list_perror(struct vty *vty, int ret) |
15490 | { | |
15491 | switch (ret) { | |
15492 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
15493 | vty_out(vty, "%% Can't find community-list\n"); | |
15494 | break; | |
15495 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
15496 | vty_out(vty, "%% Malformed community-list value\n"); | |
15497 | break; | |
15498 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
15499 | vty_out(vty, | |
15500 | "%% Community name conflict, previously defined as standard community\n"); | |
15501 | break; | |
15502 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
15503 | vty_out(vty, | |
15504 | "%% Community name conflict, previously defined as expanded community\n"); | |
15505 | break; | |
15506 | } | |
718e3744 | 15507 | } |
15508 | ||
5bf15956 DW |
15509 | /* "community-list" keyword help string. */ |
15510 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
15511 | ||
7336e101 SP |
15512 | /*community-list standard */ |
15513 | DEFUN (community_list_standard, | |
15514 | bgp_community_list_standard_cmd, | |
15515 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15516 | BGP_STR | |
718e3744 | 15517 | COMMUNITY_LIST_STR |
15518 | "Community list number (standard)\n" | |
5bf15956 | 15519 | "Add an standard community-list entry\n" |
718e3744 | 15520 | "Community list name\n" |
15521 | "Specify community to reject\n" | |
15522 | "Specify community to accept\n" | |
15523 | COMMUNITY_VAL_STR) | |
15524 | { | |
d62a17ae | 15525 | char *cl_name_or_number = NULL; |
15526 | int direct = 0; | |
15527 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 15528 | int idx = 0; |
7336e101 | 15529 | |
d62a17ae | 15530 | argv_find(argv, argc, "(1-99)", &idx); |
15531 | argv_find(argv, argc, "WORD", &idx); | |
15532 | cl_name_or_number = argv[idx]->arg; | |
15533 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15534 | : COMMUNITY_DENY; | |
15535 | argv_find(argv, argc, "AA:NN", &idx); | |
15536 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15537 | |
d62a17ae | 15538 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
15539 | style); | |
42f914d4 | 15540 | |
d62a17ae | 15541 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15542 | |
d62a17ae | 15543 | if (ret < 0) { |
15544 | /* Display error string. */ | |
15545 | community_list_perror(vty, ret); | |
15546 | return CMD_WARNING_CONFIG_FAILED; | |
15547 | } | |
42f914d4 | 15548 | |
d62a17ae | 15549 | return CMD_SUCCESS; |
718e3744 | 15550 | } |
15551 | ||
7336e101 SP |
15552 | DEFUN (no_community_list_standard_all, |
15553 | no_bgp_community_list_standard_all_cmd, | |
15554 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15555 | NO_STR | |
15556 | BGP_STR | |
15557 | COMMUNITY_LIST_STR | |
15558 | "Community list number (standard)\n" | |
15559 | "Add an standard community-list entry\n" | |
15560 | "Community list name\n" | |
15561 | "Specify community to reject\n" | |
15562 | "Specify community to accept\n" | |
15563 | COMMUNITY_VAL_STR) | |
718e3744 | 15564 | { |
d62a17ae | 15565 | char *cl_name_or_number = NULL; |
174b5cb9 | 15566 | char *str = NULL; |
d62a17ae | 15567 | int direct = 0; |
15568 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 15569 | |
d62a17ae | 15570 | int idx = 0; |
7336e101 | 15571 | |
174b5cb9 DA |
15572 | argv_find(argv, argc, "permit", &idx); |
15573 | argv_find(argv, argc, "deny", &idx); | |
15574 | ||
15575 | if (idx) { | |
15576 | direct = argv_find(argv, argc, "permit", &idx) | |
15577 | ? COMMUNITY_PERMIT | |
15578 | : COMMUNITY_DENY; | |
15579 | ||
15580 | idx = 0; | |
15581 | argv_find(argv, argc, "AA:NN", &idx); | |
15582 | str = argv_concat(argv, argc, idx); | |
15583 | } | |
15584 | ||
15585 | idx = 0; | |
d62a17ae | 15586 | argv_find(argv, argc, "(1-99)", &idx); |
15587 | argv_find(argv, argc, "WORD", &idx); | |
15588 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 15589 | |
d62a17ae | 15590 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 15591 | direct, style); |
42f914d4 | 15592 | |
d62a17ae | 15593 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 15594 | |
d62a17ae | 15595 | if (ret < 0) { |
15596 | community_list_perror(vty, ret); | |
15597 | return CMD_WARNING_CONFIG_FAILED; | |
15598 | } | |
42f914d4 | 15599 | |
d62a17ae | 15600 | return CMD_SUCCESS; |
718e3744 | 15601 | } |
7336e101 | 15602 | |
174b5cb9 DA |
15603 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
15604 | "no bgp community-list <(1-99)|standard WORD>", | |
15605 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
15606 | "Community list number (standard)\n" | |
15607 | "Add an standard community-list entry\n" | |
15608 | "Community list name\n") | |
15609 | ||
7336e101 SP |
15610 | /*community-list expanded */ |
15611 | DEFUN (community_list_expanded_all, | |
15612 | bgp_community_list_expanded_all_cmd, | |
15613 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
15614 | BGP_STR | |
15615 | COMMUNITY_LIST_STR | |
718e3744 | 15616 | "Community list number (expanded)\n" |
5bf15956 | 15617 | "Add an expanded community-list entry\n" |
718e3744 | 15618 | "Community list name\n" |
15619 | "Specify community to reject\n" | |
15620 | "Specify community to accept\n" | |
15621 | COMMUNITY_VAL_STR) | |
15622 | { | |
d62a17ae | 15623 | char *cl_name_or_number = NULL; |
15624 | int direct = 0; | |
15625 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 15626 | |
d62a17ae | 15627 | int idx = 0; |
7b9a4750 | 15628 | |
d62a17ae | 15629 | argv_find(argv, argc, "(100-500)", &idx); |
15630 | argv_find(argv, argc, "WORD", &idx); | |
15631 | cl_name_or_number = argv[idx]->arg; | |
15632 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15633 | : COMMUNITY_DENY; | |
15634 | argv_find(argv, argc, "AA:NN", &idx); | |
15635 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15636 | |
d62a17ae | 15637 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
15638 | style); | |
42f914d4 | 15639 | |
d62a17ae | 15640 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15641 | |
d62a17ae | 15642 | if (ret < 0) { |
15643 | /* Display error string. */ | |
15644 | community_list_perror(vty, ret); | |
15645 | return CMD_WARNING_CONFIG_FAILED; | |
15646 | } | |
42f914d4 | 15647 | |
d62a17ae | 15648 | return CMD_SUCCESS; |
718e3744 | 15649 | } |
15650 | ||
7336e101 SP |
15651 | DEFUN (no_community_list_expanded_all, |
15652 | no_bgp_community_list_expanded_all_cmd, | |
15653 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
15654 | NO_STR | |
15655 | BGP_STR | |
15656 | COMMUNITY_LIST_STR | |
15657 | "Community list number (expanded)\n" | |
15658 | "Add an expanded community-list entry\n" | |
15659 | "Community list name\n" | |
15660 | "Specify community to reject\n" | |
15661 | "Specify community to accept\n" | |
15662 | COMMUNITY_VAL_STR) | |
718e3744 | 15663 | { |
d62a17ae | 15664 | char *cl_name_or_number = NULL; |
174b5cb9 | 15665 | char *str = NULL; |
d62a17ae | 15666 | int direct = 0; |
15667 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 15668 | |
d62a17ae | 15669 | int idx = 0; |
174b5cb9 DA |
15670 | |
15671 | argv_find(argv, argc, "permit", &idx); | |
15672 | argv_find(argv, argc, "deny", &idx); | |
15673 | ||
15674 | if (idx) { | |
15675 | direct = argv_find(argv, argc, "permit", &idx) | |
15676 | ? COMMUNITY_PERMIT | |
15677 | : COMMUNITY_DENY; | |
15678 | ||
15679 | idx = 0; | |
15680 | argv_find(argv, argc, "AA:NN", &idx); | |
15681 | str = argv_concat(argv, argc, idx); | |
7336e101 | 15682 | } |
174b5cb9 DA |
15683 | |
15684 | idx = 0; | |
d62a17ae | 15685 | argv_find(argv, argc, "(100-500)", &idx); |
15686 | argv_find(argv, argc, "WORD", &idx); | |
15687 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 15688 | |
d62a17ae | 15689 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 15690 | direct, style); |
42f914d4 | 15691 | |
d62a17ae | 15692 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 15693 | |
d62a17ae | 15694 | if (ret < 0) { |
15695 | community_list_perror(vty, ret); | |
15696 | return CMD_WARNING_CONFIG_FAILED; | |
15697 | } | |
42f914d4 | 15698 | |
d62a17ae | 15699 | return CMD_SUCCESS; |
718e3744 | 15700 | } |
15701 | ||
174b5cb9 DA |
15702 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
15703 | "no bgp community-list <(100-500)|expanded WORD>", | |
15704 | NO_STR IP_STR COMMUNITY_LIST_STR | |
15705 | "Community list number (expanded)\n" | |
15706 | "Add an expanded community-list entry\n" | |
15707 | "Community list name\n") | |
15708 | ||
8d9b8ed9 PM |
15709 | /* Return configuration string of community-list entry. */ |
15710 | static const char *community_list_config_str(struct community_entry *entry) | |
15711 | { | |
15712 | const char *str; | |
15713 | ||
15714 | if (entry->any) | |
15715 | str = ""; | |
15716 | else { | |
15717 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
15718 | str = community_str(entry->u.com, false); | |
15719 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
15720 | str = lcommunity_str(entry->u.lcom, false); | |
15721 | else | |
15722 | str = entry->config; | |
15723 | } | |
15724 | return str; | |
15725 | } | |
15726 | ||
d62a17ae | 15727 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 15728 | { |
d62a17ae | 15729 | struct community_entry *entry; |
718e3744 | 15730 | |
d62a17ae | 15731 | for (entry = list->head; entry; entry = entry->next) { |
15732 | if (entry == list->head) { | |
15733 | if (all_digit(list->name)) | |
15734 | vty_out(vty, "Community %s list %s\n", | |
15735 | entry->style == COMMUNITY_LIST_STANDARD | |
15736 | ? "standard" | |
15737 | : "(expanded) access", | |
15738 | list->name); | |
15739 | else | |
15740 | vty_out(vty, "Named Community %s list %s\n", | |
15741 | entry->style == COMMUNITY_LIST_STANDARD | |
15742 | ? "standard" | |
15743 | : "expanded", | |
15744 | list->name); | |
15745 | } | |
15746 | if (entry->any) | |
15747 | vty_out(vty, " %s\n", | |
15748 | community_direct_str(entry->direct)); | |
15749 | else | |
15750 | vty_out(vty, " %s %s\n", | |
15751 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15752 | community_list_config_str(entry)); |
d62a17ae | 15753 | } |
718e3744 | 15754 | } |
15755 | ||
7336e101 SP |
15756 | DEFUN (show_community_list, |
15757 | show_bgp_community_list_cmd, | |
15758 | "show bgp community-list", | |
718e3744 | 15759 | SHOW_STR |
7336e101 | 15760 | BGP_STR |
718e3744 | 15761 | "List community-list\n") |
15762 | { | |
d62a17ae | 15763 | struct community_list *list; |
15764 | struct community_list_master *cm; | |
718e3744 | 15765 | |
d62a17ae | 15766 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
15767 | if (!cm) | |
15768 | return CMD_SUCCESS; | |
718e3744 | 15769 | |
d62a17ae | 15770 | for (list = cm->num.head; list; list = list->next) |
15771 | community_list_show(vty, list); | |
718e3744 | 15772 | |
d62a17ae | 15773 | for (list = cm->str.head; list; list = list->next) |
15774 | community_list_show(vty, list); | |
718e3744 | 15775 | |
d62a17ae | 15776 | return CMD_SUCCESS; |
718e3744 | 15777 | } |
15778 | ||
7336e101 SP |
15779 | DEFUN (show_community_list_arg, |
15780 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 15781 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
15782 | SHOW_STR |
15783 | BGP_STR | |
718e3744 | 15784 | "List community-list\n" |
15785 | "Community-list number\n" | |
960b69b9 | 15786 | "Community-list name\n" |
15787 | "Detailed information on community-list\n") | |
718e3744 | 15788 | { |
d62a17ae | 15789 | int idx_comm_list = 3; |
15790 | struct community_list *list; | |
718e3744 | 15791 | |
e237b0d2 | 15792 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 15793 | COMMUNITY_LIST_MASTER); |
15794 | if (!list) { | |
15795 | vty_out(vty, "%% Can't find community-list\n"); | |
15796 | return CMD_WARNING; | |
15797 | } | |
718e3744 | 15798 | |
d62a17ae | 15799 | community_list_show(vty, list); |
718e3744 | 15800 | |
d62a17ae | 15801 | return CMD_SUCCESS; |
718e3744 | 15802 | } |
6b0655a2 | 15803 | |
57d187bc JS |
15804 | /* |
15805 | * Large Community code. | |
15806 | */ | |
d62a17ae | 15807 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
15808 | struct cmd_token **argv, int style, | |
15809 | int reject_all_digit_name) | |
15810 | { | |
15811 | int ret; | |
15812 | int direct; | |
15813 | char *str; | |
15814 | int idx = 0; | |
15815 | char *cl_name; | |
15816 | ||
15817 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15818 | : COMMUNITY_DENY; | |
15819 | ||
15820 | /* All digit name check. */ | |
15821 | idx = 0; | |
15822 | argv_find(argv, argc, "WORD", &idx); | |
15823 | argv_find(argv, argc, "(1-99)", &idx); | |
15824 | argv_find(argv, argc, "(100-500)", &idx); | |
15825 | cl_name = argv[idx]->arg; | |
15826 | if (reject_all_digit_name && all_digit(cl_name)) { | |
15827 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
15828 | return CMD_WARNING_CONFIG_FAILED; | |
15829 | } | |
15830 | ||
15831 | idx = 0; | |
15832 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
15833 | argv_find(argv, argc, "LINE", &idx); | |
15834 | /* Concat community string argument. */ | |
15835 | if (idx) | |
15836 | str = argv_concat(argv, argc, idx); | |
15837 | else | |
15838 | str = NULL; | |
15839 | ||
15840 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
15841 | ||
15842 | /* Free temporary community list string allocated by | |
15843 | argv_concat(). */ | |
0a22ddfb | 15844 | XFREE(MTYPE_TMP, str); |
d62a17ae | 15845 | |
15846 | if (ret < 0) { | |
15847 | community_list_perror(vty, ret); | |
15848 | return CMD_WARNING_CONFIG_FAILED; | |
15849 | } | |
15850 | return CMD_SUCCESS; | |
15851 | } | |
15852 | ||
15853 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
15854 | struct cmd_token **argv, int style) | |
15855 | { | |
15856 | int ret; | |
15857 | int direct = 0; | |
15858 | char *str = NULL; | |
15859 | int idx = 0; | |
15860 | ||
15861 | argv_find(argv, argc, "permit", &idx); | |
15862 | argv_find(argv, argc, "deny", &idx); | |
15863 | ||
15864 | if (idx) { | |
15865 | /* Check the list direct. */ | |
15866 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
15867 | direct = COMMUNITY_PERMIT; | |
15868 | else | |
15869 | direct = COMMUNITY_DENY; | |
15870 | ||
15871 | idx = 0; | |
15872 | argv_find(argv, argc, "LINE", &idx); | |
15873 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
15874 | /* Concat community string argument. */ | |
15875 | str = argv_concat(argv, argc, idx); | |
15876 | } | |
15877 | ||
15878 | idx = 0; | |
15879 | argv_find(argv, argc, "(1-99)", &idx); | |
15880 | argv_find(argv, argc, "(100-500)", &idx); | |
15881 | argv_find(argv, argc, "WORD", &idx); | |
15882 | ||
15883 | /* Unset community list. */ | |
15884 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
15885 | style); | |
15886 | ||
15887 | /* Free temporary community list string allocated by | |
15888 | argv_concat(). */ | |
0a22ddfb | 15889 | XFREE(MTYPE_TMP, str); |
d62a17ae | 15890 | |
15891 | if (ret < 0) { | |
15892 | community_list_perror(vty, ret); | |
15893 | return CMD_WARNING_CONFIG_FAILED; | |
15894 | } | |
15895 | ||
15896 | return CMD_SUCCESS; | |
57d187bc JS |
15897 | } |
15898 | ||
15899 | /* "large-community-list" keyword help string. */ | |
15900 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
15901 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
15902 | ||
7336e101 SP |
15903 | DEFUN (lcommunity_list_standard, |
15904 | bgp_lcommunity_list_standard_cmd, | |
7336e101 SP |
15905 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", |
15906 | BGP_STR | |
15907 | LCOMMUNITY_LIST_STR | |
15908 | "Large Community list number (standard)\n" | |
15909 | "Specify large community to reject\n" | |
15910 | "Specify large community to accept\n" | |
15911 | LCOMMUNITY_VAL_STR) | |
52951b63 | 15912 | { |
d62a17ae | 15913 | return lcommunity_list_set_vty(vty, argc, argv, |
15914 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
15915 | } |
15916 | ||
7336e101 SP |
15917 | DEFUN (lcommunity_list_expanded, |
15918 | bgp_lcommunity_list_expanded_cmd, | |
15919 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
15920 | BGP_STR | |
15921 | LCOMMUNITY_LIST_STR | |
15922 | "Large Community list number (expanded)\n" | |
15923 | "Specify large community to reject\n" | |
15924 | "Specify large community to accept\n" | |
15925 | "An ordered list as a regular-expression\n") | |
57d187bc | 15926 | { |
d62a17ae | 15927 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 15928 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
15929 | } |
15930 | ||
7336e101 SP |
15931 | DEFUN (lcommunity_list_name_standard, |
15932 | bgp_lcommunity_list_name_standard_cmd, | |
7336e101 SP |
15933 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", |
15934 | BGP_STR | |
15935 | LCOMMUNITY_LIST_STR | |
15936 | "Specify standard large-community-list\n" | |
15937 | "Large Community list name\n" | |
15938 | "Specify large community to reject\n" | |
15939 | "Specify large community to accept\n" | |
15940 | LCOMMUNITY_VAL_STR) | |
52951b63 | 15941 | { |
d62a17ae | 15942 | return lcommunity_list_set_vty(vty, argc, argv, |
15943 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
15944 | } |
15945 | ||
7336e101 SP |
15946 | DEFUN (lcommunity_list_name_expanded, |
15947 | bgp_lcommunity_list_name_expanded_cmd, | |
15948 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
15949 | BGP_STR | |
15950 | LCOMMUNITY_LIST_STR | |
15951 | "Specify expanded large-community-list\n" | |
15952 | "Large Community list name\n" | |
15953 | "Specify large community to reject\n" | |
15954 | "Specify large community to accept\n" | |
15955 | "An ordered list as a regular-expression\n") | |
57d187bc | 15956 | { |
d62a17ae | 15957 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 15958 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
15959 | } |
15960 | ||
7336e101 SP |
15961 | DEFUN (no_lcommunity_list_standard_all, |
15962 | no_bgp_lcommunity_list_standard_all_cmd, | |
15963 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
15964 | NO_STR | |
15965 | BGP_STR | |
15966 | LCOMMUNITY_LIST_STR | |
15967 | "Large Community list number (standard)\n" | |
15968 | "Large Community list number (expanded)\n" | |
15969 | "Large Community list name\n") | |
57d187bc | 15970 | { |
7336e101 SP |
15971 | return lcommunity_list_unset_vty(vty, argc, argv, |
15972 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
15973 | } |
15974 | ||
7336e101 SP |
15975 | DEFUN (no_lcommunity_list_name_expanded_all, |
15976 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
15977 | "no bgp large-community-list expanded WORD", | |
15978 | NO_STR | |
15979 | BGP_STR | |
15980 | LCOMMUNITY_LIST_STR | |
15981 | "Specify expanded large-community-list\n" | |
15982 | "Large Community list name\n") | |
57d187bc | 15983 | { |
d62a17ae | 15984 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 15985 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
15986 | } |
15987 | ||
7336e101 SP |
15988 | DEFUN (no_lcommunity_list_standard, |
15989 | no_bgp_lcommunity_list_standard_cmd, | |
15990 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
15991 | NO_STR | |
15992 | BGP_STR | |
15993 | LCOMMUNITY_LIST_STR | |
15994 | "Large Community list number (standard)\n" | |
15995 | "Specify large community to reject\n" | |
15996 | "Specify large community to accept\n" | |
15997 | LCOMMUNITY_VAL_STR) | |
57d187bc | 15998 | { |
d62a17ae | 15999 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 16000 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
16001 | } |
16002 | ||
7336e101 SP |
16003 | DEFUN (no_lcommunity_list_expanded, |
16004 | no_bgp_lcommunity_list_expanded_cmd, | |
16005 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
16006 | NO_STR | |
16007 | BGP_STR | |
16008 | LCOMMUNITY_LIST_STR | |
16009 | "Large Community list number (expanded)\n" | |
16010 | "Specify large community to reject\n" | |
16011 | "Specify large community to accept\n" | |
16012 | "An ordered list as a regular-expression\n") | |
57d187bc | 16013 | { |
d62a17ae | 16014 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 16015 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
16016 | } |
16017 | ||
7336e101 SP |
16018 | DEFUN (no_lcommunity_list_name_standard, |
16019 | no_bgp_lcommunity_list_name_standard_cmd, | |
16020 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
16021 | NO_STR | |
16022 | BGP_STR | |
16023 | LCOMMUNITY_LIST_STR | |
16024 | "Specify standard large-community-list\n" | |
16025 | "Large Community list name\n" | |
16026 | "Specify large community to reject\n" | |
16027 | "Specify large community to accept\n" | |
16028 | LCOMMUNITY_VAL_STR) | |
57d187bc | 16029 | { |
d62a17ae | 16030 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 16031 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
16032 | } |
16033 | ||
7336e101 SP |
16034 | DEFUN (no_lcommunity_list_name_expanded, |
16035 | no_bgp_lcommunity_list_name_expanded_cmd, | |
16036 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
16037 | NO_STR | |
16038 | BGP_STR | |
16039 | LCOMMUNITY_LIST_STR | |
16040 | "Specify expanded large-community-list\n" | |
16041 | "Large community list name\n" | |
16042 | "Specify large community to reject\n" | |
16043 | "Specify large community to accept\n" | |
16044 | "An ordered list as a regular-expression\n") | |
57d187bc | 16045 | { |
d62a17ae | 16046 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 16047 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
16048 | } |
16049 | ||
d62a17ae | 16050 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
16051 | { | |
16052 | struct community_entry *entry; | |
16053 | ||
16054 | for (entry = list->head; entry; entry = entry->next) { | |
16055 | if (entry == list->head) { | |
16056 | if (all_digit(list->name)) | |
16057 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 16058 | entry->style == |
16059 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 16060 | ? "standard" |
16061 | : "(expanded) access", | |
16062 | list->name); | |
16063 | else | |
16064 | vty_out(vty, | |
16065 | "Named large community %s list %s\n", | |
169b72c8 | 16066 | entry->style == |
16067 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 16068 | ? "standard" |
16069 | : "expanded", | |
16070 | list->name); | |
16071 | } | |
16072 | if (entry->any) | |
16073 | vty_out(vty, " %s\n", | |
16074 | community_direct_str(entry->direct)); | |
16075 | else | |
16076 | vty_out(vty, " %s %s\n", | |
16077 | community_direct_str(entry->direct), | |
8d9b8ed9 | 16078 | community_list_config_str(entry)); |
d62a17ae | 16079 | } |
57d187bc JS |
16080 | } |
16081 | ||
7336e101 SP |
16082 | DEFUN (show_lcommunity_list, |
16083 | show_bgp_lcommunity_list_cmd, | |
16084 | "show bgp large-community-list", | |
57d187bc | 16085 | SHOW_STR |
7336e101 | 16086 | BGP_STR |
57d187bc JS |
16087 | "List large-community list\n") |
16088 | { | |
d62a17ae | 16089 | struct community_list *list; |
16090 | struct community_list_master *cm; | |
57d187bc | 16091 | |
d62a17ae | 16092 | cm = community_list_master_lookup(bgp_clist, |
16093 | LARGE_COMMUNITY_LIST_MASTER); | |
16094 | if (!cm) | |
16095 | return CMD_SUCCESS; | |
57d187bc | 16096 | |
d62a17ae | 16097 | for (list = cm->num.head; list; list = list->next) |
16098 | lcommunity_list_show(vty, list); | |
57d187bc | 16099 | |
d62a17ae | 16100 | for (list = cm->str.head; list; list = list->next) |
16101 | lcommunity_list_show(vty, list); | |
57d187bc | 16102 | |
d62a17ae | 16103 | return CMD_SUCCESS; |
57d187bc JS |
16104 | } |
16105 | ||
7336e101 SP |
16106 | DEFUN (show_lcommunity_list_arg, |
16107 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 16108 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
16109 | SHOW_STR |
16110 | BGP_STR | |
57d187bc | 16111 | "List large-community list\n" |
960b69b9 | 16112 | "Large-community-list number\n" |
16113 | "Large-community-list name\n" | |
16114 | "Detailed information on large-community-list\n") | |
57d187bc | 16115 | { |
d62a17ae | 16116 | struct community_list *list; |
57d187bc | 16117 | |
e237b0d2 | 16118 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 16119 | LARGE_COMMUNITY_LIST_MASTER); |
16120 | if (!list) { | |
960b69b9 | 16121 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 16122 | return CMD_WARNING; |
16123 | } | |
57d187bc | 16124 | |
d62a17ae | 16125 | lcommunity_list_show(vty, list); |
57d187bc | 16126 | |
d62a17ae | 16127 | return CMD_SUCCESS; |
57d187bc JS |
16128 | } |
16129 | ||
718e3744 | 16130 | /* "extcommunity-list" keyword help string. */ |
16131 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
16132 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
16133 | ||
7336e101 SP |
16134 | DEFUN (extcommunity_list_standard, |
16135 | bgp_extcommunity_list_standard_cmd, | |
16136 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
16137 | BGP_STR | |
718e3744 | 16138 | EXTCOMMUNITY_LIST_STR |
16139 | "Extended Community list number (standard)\n" | |
718e3744 | 16140 | "Specify standard extcommunity-list\n" |
5bf15956 | 16141 | "Community list name\n" |
718e3744 | 16142 | "Specify community to reject\n" |
16143 | "Specify community to accept\n" | |
16144 | EXTCOMMUNITY_VAL_STR) | |
16145 | { | |
d62a17ae | 16146 | int style = EXTCOMMUNITY_LIST_STANDARD; |
16147 | int direct = 0; | |
16148 | char *cl_number_or_name = NULL; | |
42f914d4 | 16149 | |
d62a17ae | 16150 | int idx = 0; |
7b9a4750 | 16151 | |
d62a17ae | 16152 | argv_find(argv, argc, "(1-99)", &idx); |
16153 | argv_find(argv, argc, "WORD", &idx); | |
16154 | cl_number_or_name = argv[idx]->arg; | |
16155 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16156 | : COMMUNITY_DENY; | |
16157 | argv_find(argv, argc, "AA:NN", &idx); | |
16158 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16159 | |
d62a17ae | 16160 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
16161 | direct, style); | |
42f914d4 | 16162 | |
d62a17ae | 16163 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16164 | |
d62a17ae | 16165 | if (ret < 0) { |
16166 | community_list_perror(vty, ret); | |
16167 | return CMD_WARNING_CONFIG_FAILED; | |
16168 | } | |
42f914d4 | 16169 | |
d62a17ae | 16170 | return CMD_SUCCESS; |
718e3744 | 16171 | } |
16172 | ||
7336e101 SP |
16173 | DEFUN (extcommunity_list_name_expanded, |
16174 | bgp_extcommunity_list_name_expanded_cmd, | |
16175 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
16176 | BGP_STR | |
16177 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 16178 | "Extended Community list number (expanded)\n" |
718e3744 | 16179 | "Specify expanded extcommunity-list\n" |
16180 | "Extended Community list name\n" | |
16181 | "Specify community to reject\n" | |
16182 | "Specify community to accept\n" | |
16183 | "An ordered list as a regular-expression\n") | |
16184 | { | |
d62a17ae | 16185 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
16186 | int direct = 0; | |
16187 | char *cl_number_or_name = NULL; | |
d62a17ae | 16188 | int idx = 0; |
7336e101 | 16189 | |
d62a17ae | 16190 | argv_find(argv, argc, "(100-500)", &idx); |
16191 | argv_find(argv, argc, "WORD", &idx); | |
16192 | cl_number_or_name = argv[idx]->arg; | |
16193 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16194 | : COMMUNITY_DENY; | |
16195 | argv_find(argv, argc, "LINE", &idx); | |
16196 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16197 | |
d62a17ae | 16198 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
16199 | direct, style); | |
42f914d4 | 16200 | |
d62a17ae | 16201 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16202 | |
d62a17ae | 16203 | if (ret < 0) { |
16204 | community_list_perror(vty, ret); | |
16205 | return CMD_WARNING_CONFIG_FAILED; | |
16206 | } | |
42f914d4 | 16207 | |
d62a17ae | 16208 | return CMD_SUCCESS; |
718e3744 | 16209 | } |
16210 | ||
7336e101 SP |
16211 | DEFUN (no_extcommunity_list_standard_all, |
16212 | no_bgp_extcommunity_list_standard_all_cmd, | |
16213 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
16214 | NO_STR | |
16215 | BGP_STR | |
16216 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 16217 | "Extended Community list number (standard)\n" |
718e3744 | 16218 | "Specify standard extcommunity-list\n" |
5bf15956 | 16219 | "Community list name\n" |
718e3744 | 16220 | "Specify community to reject\n" |
16221 | "Specify community to accept\n" | |
16222 | EXTCOMMUNITY_VAL_STR) | |
16223 | { | |
d62a17ae | 16224 | int style = EXTCOMMUNITY_LIST_STANDARD; |
16225 | int direct = 0; | |
16226 | char *cl_number_or_name = NULL; | |
d4455c89 | 16227 | char *str = NULL; |
d62a17ae | 16228 | int idx = 0; |
d4455c89 | 16229 | |
d4455c89 DA |
16230 | argv_find(argv, argc, "permit", &idx); |
16231 | argv_find(argv, argc, "deny", &idx); | |
16232 | ||
16233 | if (idx) { | |
16234 | direct = argv_find(argv, argc, "permit", &idx) | |
16235 | ? COMMUNITY_PERMIT | |
16236 | : COMMUNITY_DENY; | |
16237 | ||
16238 | idx = 0; | |
16239 | argv_find(argv, argc, "AA:NN", &idx); | |
16240 | str = argv_concat(argv, argc, idx); | |
16241 | } | |
16242 | ||
16243 | idx = 0; | |
d62a17ae | 16244 | argv_find(argv, argc, "(1-99)", &idx); |
16245 | argv_find(argv, argc, "WORD", &idx); | |
16246 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 16247 | |
d62a17ae | 16248 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 16249 | direct, style); |
42f914d4 | 16250 | |
d62a17ae | 16251 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16252 | |
d62a17ae | 16253 | if (ret < 0) { |
16254 | community_list_perror(vty, ret); | |
16255 | return CMD_WARNING_CONFIG_FAILED; | |
16256 | } | |
42f914d4 | 16257 | |
d62a17ae | 16258 | return CMD_SUCCESS; |
718e3744 | 16259 | } |
16260 | ||
d4455c89 DA |
16261 | ALIAS(no_extcommunity_list_standard_all, |
16262 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
16263 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
16264 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
16265 | "Extended Community list number (standard)\n" | |
16266 | "Specify standard extcommunity-list\n" | |
16267 | "Community list name\n") | |
16268 | ||
7336e101 SP |
16269 | DEFUN (no_extcommunity_list_expanded_all, |
16270 | no_bgp_extcommunity_list_expanded_all_cmd, | |
16271 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
16272 | NO_STR | |
16273 | BGP_STR | |
16274 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 16275 | "Extended Community list number (expanded)\n" |
718e3744 | 16276 | "Specify expanded extcommunity-list\n" |
5bf15956 | 16277 | "Extended Community list name\n" |
718e3744 | 16278 | "Specify community to reject\n" |
16279 | "Specify community to accept\n" | |
16280 | "An ordered list as a regular-expression\n") | |
16281 | { | |
d62a17ae | 16282 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
16283 | int direct = 0; | |
16284 | char *cl_number_or_name = NULL; | |
d4455c89 | 16285 | char *str = NULL; |
d62a17ae | 16286 | int idx = 0; |
d4455c89 | 16287 | |
d4455c89 DA |
16288 | argv_find(argv, argc, "permit", &idx); |
16289 | argv_find(argv, argc, "deny", &idx); | |
16290 | ||
16291 | if (idx) { | |
16292 | direct = argv_find(argv, argc, "permit", &idx) | |
16293 | ? COMMUNITY_PERMIT | |
16294 | : COMMUNITY_DENY; | |
16295 | ||
16296 | idx = 0; | |
16297 | argv_find(argv, argc, "LINE", &idx); | |
16298 | str = argv_concat(argv, argc, idx); | |
16299 | } | |
16300 | ||
16301 | idx = 0; | |
d62a17ae | 16302 | argv_find(argv, argc, "(100-500)", &idx); |
16303 | argv_find(argv, argc, "WORD", &idx); | |
16304 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 16305 | |
d62a17ae | 16306 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 16307 | direct, style); |
42f914d4 | 16308 | |
d62a17ae | 16309 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16310 | |
d62a17ae | 16311 | if (ret < 0) { |
16312 | community_list_perror(vty, ret); | |
16313 | return CMD_WARNING_CONFIG_FAILED; | |
16314 | } | |
42f914d4 | 16315 | |
d62a17ae | 16316 | return CMD_SUCCESS; |
718e3744 | 16317 | } |
16318 | ||
d4455c89 DA |
16319 | ALIAS(no_extcommunity_list_expanded_all, |
16320 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
16321 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
16322 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
16323 | "Extended Community list number (expanded)\n" | |
16324 | "Specify expanded extcommunity-list\n" | |
16325 | "Extended Community list name\n") | |
16326 | ||
d62a17ae | 16327 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 16328 | { |
d62a17ae | 16329 | struct community_entry *entry; |
718e3744 | 16330 | |
d62a17ae | 16331 | for (entry = list->head; entry; entry = entry->next) { |
16332 | if (entry == list->head) { | |
16333 | if (all_digit(list->name)) | |
16334 | vty_out(vty, "Extended community %s list %s\n", | |
16335 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
16336 | ? "standard" | |
16337 | : "(expanded) access", | |
16338 | list->name); | |
16339 | else | |
16340 | vty_out(vty, | |
16341 | "Named extended community %s list %s\n", | |
16342 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
16343 | ? "standard" | |
16344 | : "expanded", | |
16345 | list->name); | |
16346 | } | |
16347 | if (entry->any) | |
16348 | vty_out(vty, " %s\n", | |
16349 | community_direct_str(entry->direct)); | |
16350 | else | |
16351 | vty_out(vty, " %s %s\n", | |
16352 | community_direct_str(entry->direct), | |
8d9b8ed9 | 16353 | community_list_config_str(entry)); |
d62a17ae | 16354 | } |
718e3744 | 16355 | } |
16356 | ||
7336e101 SP |
16357 | DEFUN (show_extcommunity_list, |
16358 | show_bgp_extcommunity_list_cmd, | |
16359 | "show bgp extcommunity-list", | |
718e3744 | 16360 | SHOW_STR |
7336e101 | 16361 | BGP_STR |
718e3744 | 16362 | "List extended-community list\n") |
16363 | { | |
d62a17ae | 16364 | struct community_list *list; |
16365 | struct community_list_master *cm; | |
718e3744 | 16366 | |
d62a17ae | 16367 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
16368 | if (!cm) | |
16369 | return CMD_SUCCESS; | |
718e3744 | 16370 | |
d62a17ae | 16371 | for (list = cm->num.head; list; list = list->next) |
16372 | extcommunity_list_show(vty, list); | |
718e3744 | 16373 | |
d62a17ae | 16374 | for (list = cm->str.head; list; list = list->next) |
16375 | extcommunity_list_show(vty, list); | |
718e3744 | 16376 | |
d62a17ae | 16377 | return CMD_SUCCESS; |
718e3744 | 16378 | } |
16379 | ||
7336e101 SP |
16380 | DEFUN (show_extcommunity_list_arg, |
16381 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 16382 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
16383 | SHOW_STR |
16384 | BGP_STR | |
718e3744 | 16385 | "List extended-community list\n" |
16386 | "Extcommunity-list number\n" | |
960b69b9 | 16387 | "Extcommunity-list name\n" |
16388 | "Detailed information on extcommunity-list\n") | |
718e3744 | 16389 | { |
d62a17ae | 16390 | int idx_comm_list = 3; |
16391 | struct community_list *list; | |
718e3744 | 16392 | |
e237b0d2 | 16393 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 16394 | EXTCOMMUNITY_LIST_MASTER); |
16395 | if (!list) { | |
16396 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
16397 | return CMD_WARNING; | |
16398 | } | |
718e3744 | 16399 | |
d62a17ae | 16400 | extcommunity_list_show(vty, list); |
718e3744 | 16401 | |
d62a17ae | 16402 | return CMD_SUCCESS; |
718e3744 | 16403 | } |
6b0655a2 | 16404 | |
718e3744 | 16405 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 16406 | static int community_list_config_write(struct vty *vty) |
16407 | { | |
16408 | struct community_list *list; | |
16409 | struct community_entry *entry; | |
16410 | struct community_list_master *cm; | |
16411 | int write = 0; | |
16412 | ||
16413 | /* Community-list. */ | |
16414 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
16415 | ||
16416 | for (list = cm->num.head; list; list = list->next) | |
16417 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 16418 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 16419 | community_direct_str(entry->direct), |
16420 | community_list_config_str(entry)); | |
16421 | write++; | |
16422 | } | |
16423 | for (list = cm->str.head; list; list = list->next) | |
16424 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 16425 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 16426 | entry->style == COMMUNITY_LIST_STANDARD |
16427 | ? "standard" | |
16428 | : "expanded", | |
16429 | list->name, community_direct_str(entry->direct), | |
16430 | community_list_config_str(entry)); | |
16431 | write++; | |
16432 | } | |
16433 | ||
16434 | /* Extcommunity-list. */ | |
16435 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
16436 | ||
16437 | for (list = cm->num.head; list; list = list->next) | |
16438 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 16439 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 16440 | list->name, community_direct_str(entry->direct), |
16441 | community_list_config_str(entry)); | |
16442 | write++; | |
16443 | } | |
16444 | for (list = cm->str.head; list; list = list->next) | |
16445 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 16446 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 16447 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
16448 | ? "standard" | |
16449 | : "expanded", | |
16450 | list->name, community_direct_str(entry->direct), | |
16451 | community_list_config_str(entry)); | |
16452 | write++; | |
16453 | } | |
16454 | ||
16455 | ||
16456 | /* lcommunity-list. */ | |
16457 | cm = community_list_master_lookup(bgp_clist, | |
16458 | LARGE_COMMUNITY_LIST_MASTER); | |
16459 | ||
16460 | for (list = cm->num.head; list; list = list->next) | |
16461 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 16462 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 16463 | list->name, community_direct_str(entry->direct), |
16464 | community_list_config_str(entry)); | |
16465 | write++; | |
16466 | } | |
16467 | for (list = cm->str.head; list; list = list->next) | |
16468 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 16469 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 16470 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
16471 | ? "standard" | |
16472 | : "expanded", | |
16473 | list->name, community_direct_str(entry->direct), | |
16474 | community_list_config_str(entry)); | |
16475 | write++; | |
16476 | } | |
16477 | ||
16478 | return write; | |
16479 | } | |
16480 | ||
16481 | static struct cmd_node community_list_node = { | |
16482 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 16483 | }; |
16484 | ||
d62a17ae | 16485 | static void community_list_vty(void) |
16486 | { | |
16487 | install_node(&community_list_node, community_list_config_write); | |
16488 | ||
16489 | /* Community-list. */ | |
7336e101 SP |
16490 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
16491 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
16492 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 16493 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 16494 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 16495 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
16496 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
16497 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 16498 | |
16499 | /* Extcommunity-list. */ | |
7336e101 SP |
16500 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
16501 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
16502 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
16503 | install_element(CONFIG_NODE, |
16504 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 16505 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
16506 | install_element(CONFIG_NODE, |
16507 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
16508 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
16509 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 16510 | |
16511 | /* Large Community List */ | |
7336e101 | 16512 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
16513 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
16514 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 SP |
16515 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
16516 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
16517 | install_element(CONFIG_NODE, | |
16518 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
16519 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
16520 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
16521 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
16522 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
16523 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
16524 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 16525 | } |