]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP routing information |
2 | Copyright (C) 1996, 97, 98, 99 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 | |
17 | along with GNU Zebra; see the file COPYING. If not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | 02111-1307, USA. */ | |
20 | ||
21 | #include <zebra.h> | |
22 | ||
856ca177 | 23 | #include "lib/json.h" |
718e3744 | 24 | #include "prefix.h" |
25 | #include "linklist.h" | |
26 | #include "memory.h" | |
27 | #include "command.h" | |
28 | #include "stream.h" | |
29 | #include "filter.h" | |
30 | #include "str.h" | |
31 | #include "log.h" | |
32 | #include "routemap.h" | |
33 | #include "buffer.h" | |
34 | #include "sockunion.h" | |
35 | #include "plist.h" | |
36 | #include "thread.h" | |
200df115 | 37 | #include "workqueue.h" |
3f9c7369 | 38 | #include "queue.h" |
6e919709 | 39 | #include "memory.h" |
718e3744 | 40 | |
41 | #include "bgpd/bgpd.h" | |
42 | #include "bgpd/bgp_table.h" | |
43 | #include "bgpd/bgp_route.h" | |
44 | #include "bgpd/bgp_attr.h" | |
45 | #include "bgpd/bgp_debug.h" | |
46 | #include "bgpd/bgp_aspath.h" | |
47 | #include "bgpd/bgp_regex.h" | |
48 | #include "bgpd/bgp_community.h" | |
49 | #include "bgpd/bgp_ecommunity.h" | |
50 | #include "bgpd/bgp_clist.h" | |
51 | #include "bgpd/bgp_packet.h" | |
52 | #include "bgpd/bgp_filter.h" | |
53 | #include "bgpd/bgp_fsm.h" | |
54 | #include "bgpd/bgp_mplsvpn.h" | |
55 | #include "bgpd/bgp_nexthop.h" | |
56 | #include "bgpd/bgp_damp.h" | |
57 | #include "bgpd/bgp_advertise.h" | |
58 | #include "bgpd/bgp_zebra.h" | |
0a486e5f | 59 | #include "bgpd/bgp_vty.h" |
96450faf | 60 | #include "bgpd/bgp_mpath.h" |
fc9a856f | 61 | #include "bgpd/bgp_nht.h" |
3f9c7369 | 62 | #include "bgpd/bgp_updgrp.h" |
8386ac43 | 63 | #include "bgpd/bgp_vty.h" |
718e3744 | 64 | |
65 | /* Extern from bgp_dump.c */ | |
dde72586 SH |
66 | extern const char *bgp_origin_str[]; |
67 | extern const char *bgp_origin_long_str[]; | |
6b0655a2 | 68 | |
4125bb67 | 69 | struct bgp_node * |
fee0f4c6 | 70 | bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, |
718e3744 | 71 | struct prefix_rd *prd) |
72 | { | |
73 | struct bgp_node *rn; | |
74 | struct bgp_node *prn = NULL; | |
da5b30f6 PJ |
75 | |
76 | assert (table); | |
77 | if (!table) | |
78 | return NULL; | |
79 | ||
587ff0fd | 80 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 81 | { |
fee0f4c6 | 82 | prn = bgp_node_get (table, (struct prefix *) prd); |
718e3744 | 83 | |
84 | if (prn->info == NULL) | |
64e580a7 | 85 | prn->info = bgp_table_init (afi, safi); |
718e3744 | 86 | else |
87 | bgp_unlock_node (prn); | |
88 | table = prn->info; | |
89 | } | |
718e3744 | 90 | |
91 | rn = bgp_node_get (table, p); | |
92 | ||
587ff0fd | 93 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 94 | rn->prn = prn; |
95 | ||
96 | return rn; | |
97 | } | |
6b0655a2 | 98 | |
fb982c25 PJ |
99 | /* Allocate bgp_info_extra */ |
100 | static struct bgp_info_extra * | |
101 | bgp_info_extra_new (void) | |
102 | { | |
103 | struct bgp_info_extra *new; | |
104 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); | |
105 | return new; | |
106 | } | |
107 | ||
108 | static void | |
109 | bgp_info_extra_free (struct bgp_info_extra **extra) | |
110 | { | |
111 | if (extra && *extra) | |
112 | { | |
113 | if ((*extra)->damp_info) | |
114 | bgp_damp_info_free ((*extra)->damp_info, 0); | |
115 | ||
116 | (*extra)->damp_info = NULL; | |
117 | ||
118 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); | |
119 | ||
120 | *extra = NULL; | |
121 | } | |
122 | } | |
123 | ||
124 | /* Get bgp_info extra information for the given bgp_info, lazy allocated | |
125 | * if required. | |
126 | */ | |
127 | struct bgp_info_extra * | |
128 | bgp_info_extra_get (struct bgp_info *ri) | |
129 | { | |
130 | if (!ri->extra) | |
131 | ri->extra = bgp_info_extra_new(); | |
132 | return ri->extra; | |
133 | } | |
134 | ||
718e3744 | 135 | /* Free bgp route information. */ |
200df115 | 136 | static void |
718e3744 | 137 | bgp_info_free (struct bgp_info *binfo) |
138 | { | |
139 | if (binfo->attr) | |
f6f434b2 | 140 | bgp_attr_unintern (&binfo->attr); |
fb018d25 DS |
141 | |
142 | bgp_unlink_nexthop(binfo); | |
fb982c25 | 143 | bgp_info_extra_free (&binfo->extra); |
de8d5dff | 144 | bgp_info_mpath_free (&binfo->mpath); |
718e3744 | 145 | |
200df115 | 146 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
147 | ||
718e3744 | 148 | XFREE (MTYPE_BGP_ROUTE, binfo); |
149 | } | |
150 | ||
200df115 | 151 | struct bgp_info * |
152 | bgp_info_lock (struct bgp_info *binfo) | |
153 | { | |
154 | binfo->lock++; | |
155 | return binfo; | |
156 | } | |
157 | ||
158 | struct bgp_info * | |
159 | bgp_info_unlock (struct bgp_info *binfo) | |
160 | { | |
161 | assert (binfo && binfo->lock > 0); | |
162 | binfo->lock--; | |
163 | ||
164 | if (binfo->lock == 0) | |
165 | { | |
166 | #if 0 | |
167 | zlog_debug ("%s: unlocked and freeing", __func__); | |
168 | zlog_backtrace (LOG_DEBUG); | |
169 | #endif | |
170 | bgp_info_free (binfo); | |
171 | return NULL; | |
172 | } | |
173 | ||
174 | #if 0 | |
175 | if (binfo->lock == 1) | |
176 | { | |
177 | zlog_debug ("%s: unlocked to 1", __func__); | |
178 | zlog_backtrace (LOG_DEBUG); | |
179 | } | |
180 | #endif | |
181 | ||
182 | return binfo; | |
183 | } | |
184 | ||
718e3744 | 185 | void |
186 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) | |
187 | { | |
188 | struct bgp_info *top; | |
189 | ||
190 | top = rn->info; | |
200df115 | 191 | |
718e3744 | 192 | ri->next = rn->info; |
193 | ri->prev = NULL; | |
194 | if (top) | |
195 | top->prev = ri; | |
196 | rn->info = ri; | |
200df115 | 197 | |
198 | bgp_info_lock (ri); | |
199 | bgp_lock_node (rn); | |
200 | peer_lock (ri->peer); /* bgp_info peer reference */ | |
718e3744 | 201 | } |
202 | ||
b40d939b | 203 | /* Do the actual removal of info from RIB, for use by bgp_process |
204 | completion callback *only* */ | |
205 | static void | |
206 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) | |
718e3744 | 207 | { |
208 | if (ri->next) | |
209 | ri->next->prev = ri->prev; | |
210 | if (ri->prev) | |
211 | ri->prev->next = ri->next; | |
212 | else | |
213 | rn->info = ri->next; | |
200df115 | 214 | |
de8d5dff | 215 | bgp_info_mpath_dequeue (ri); |
200df115 | 216 | bgp_info_unlock (ri); |
217 | bgp_unlock_node (rn); | |
718e3744 | 218 | } |
219 | ||
b40d939b | 220 | void |
221 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) | |
222 | { | |
1a392d46 PJ |
223 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
224 | /* set of previous already took care of pcount */ | |
b40d939b | 225 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
226 | } | |
227 | ||
8d45210e AS |
228 | /* undo the effects of a previous call to bgp_info_delete; typically |
229 | called when a route is deleted and then quickly re-added before the | |
230 | deletion has been processed */ | |
231 | static void | |
232 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) | |
233 | { | |
234 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); | |
235 | /* unset of previous already took care of pcount */ | |
236 | SET_FLAG (ri->flags, BGP_INFO_VALID); | |
237 | } | |
238 | ||
1a392d46 PJ |
239 | /* Adjust pcount as required */ |
240 | static void | |
241 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) | |
242 | { | |
67174041 AS |
243 | struct bgp_table *table; |
244 | ||
245 | assert (rn && bgp_node_table (rn)); | |
6f58544d PJ |
246 | assert (ri && ri->peer && ri->peer->bgp); |
247 | ||
67174041 AS |
248 | table = bgp_node_table (rn); |
249 | ||
2a3d5731 | 250 | if (ri->peer == ri->peer->bgp->peer_self) |
1a392d46 PJ |
251 | return; |
252 | ||
80e0ad24 | 253 | if (!BGP_INFO_COUNTABLE (ri) |
1a392d46 PJ |
254 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
255 | { | |
256 | ||
257 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
258 | ||
259 | /* slight hack, but more robust against errors. */ | |
67174041 AS |
260 | if (ri->peer->pcount[table->afi][table->safi]) |
261 | ri->peer->pcount[table->afi][table->safi]--; | |
1a392d46 PJ |
262 | else |
263 | { | |
264 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", | |
265 | __func__, ri->peer->host); | |
266 | zlog_backtrace (LOG_WARNING); | |
267 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); | |
268 | } | |
269 | } | |
80e0ad24 | 270 | else if (BGP_INFO_COUNTABLE (ri) |
1a392d46 PJ |
271 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
272 | { | |
273 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
67174041 | 274 | ri->peer->pcount[table->afi][table->safi]++; |
1a392d46 PJ |
275 | } |
276 | } | |
277 | ||
278 | ||
279 | /* Set/unset bgp_info flags, adjusting any other state as needed. | |
280 | * This is here primarily to keep prefix-count in check. | |
281 | */ | |
282 | void | |
283 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
284 | { | |
285 | SET_FLAG (ri->flags, flag); | |
286 | ||
80e0ad24 DS |
287 | /* early bath if we know it's not a flag that changes countability state */ |
288 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED)) | |
1a392d46 PJ |
289 | return; |
290 | ||
291 | bgp_pcount_adjust (rn, ri); | |
292 | } | |
293 | ||
294 | void | |
295 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
296 | { | |
297 | UNSET_FLAG (ri->flags, flag); | |
298 | ||
80e0ad24 DS |
299 | /* early bath if we know it's not a flag that changes countability state */ |
300 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED)) | |
1a392d46 PJ |
301 | return; |
302 | ||
303 | bgp_pcount_adjust (rn, ri); | |
304 | } | |
305 | ||
718e3744 | 306 | /* Get MED value. If MED value is missing and "bgp bestpath |
307 | missing-as-worst" is specified, treat it as the worst value. */ | |
94f2b392 | 308 | static u_int32_t |
718e3744 | 309 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
310 | { | |
311 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
312 | return attr->med; | |
313 | else | |
314 | { | |
315 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
3b424979 | 316 | return BGP_MED_MAX; |
718e3744 | 317 | else |
318 | return 0; | |
319 | } | |
320 | } | |
321 | ||
2ec1e66f DW |
322 | void |
323 | bgp_info_path_with_addpath_rx_str (struct bgp_info *ri, char *buf) | |
324 | { | |
325 | if (ri->addpath_rx_id) | |
326 | sprintf(buf, "path %s (addpath rxid %d)", ri->peer->host, ri->addpath_rx_id); | |
327 | else | |
328 | sprintf(buf, "path %s", ri->peer->host); | |
329 | } | |
330 | ||
9fbdd100 | 331 | /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */ |
94f2b392 | 332 | static int |
96450faf | 333 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
9fbdd100 DS |
334 | int *paths_eq, struct bgp_maxpaths_cfg *mpath_cfg, int debug, |
335 | char *pfx_buf) | |
718e3744 | 336 | { |
8ff56318 JBD |
337 | struct attr *newattr, *existattr; |
338 | struct attr_extra *newattre, *existattre; | |
339 | bgp_peer_sort_t new_sort; | |
340 | bgp_peer_sort_t exist_sort; | |
718e3744 | 341 | u_int32_t new_pref; |
342 | u_int32_t exist_pref; | |
343 | u_int32_t new_med; | |
344 | u_int32_t exist_med; | |
8ff56318 JBD |
345 | u_int32_t new_weight; |
346 | u_int32_t exist_weight; | |
347 | uint32_t newm, existm; | |
718e3744 | 348 | struct in_addr new_id; |
349 | struct in_addr exist_id; | |
350 | int new_cluster; | |
351 | int exist_cluster; | |
8ff56318 JBD |
352 | int internal_as_route; |
353 | int confed_as_route; | |
718e3744 | 354 | int ret; |
2ec1e66f DW |
355 | char new_buf[PATH_ADDPATH_STR_BUFFER]; |
356 | char exist_buf[PATH_ADDPATH_STR_BUFFER]; | |
96450faf JB |
357 | |
358 | *paths_eq = 0; | |
718e3744 | 359 | |
360 | /* 0. Null check. */ | |
361 | if (new == NULL) | |
9fbdd100 DS |
362 | { |
363 | if (debug) | |
364 | zlog_debug("%s: new is NULL", pfx_buf); | |
365 | return 0; | |
366 | } | |
367 | ||
2ec1e66f DW |
368 | if (debug) |
369 | bgp_info_path_with_addpath_rx_str (new, new_buf); | |
370 | ||
718e3744 | 371 | if (exist == NULL) |
9fbdd100 DS |
372 | { |
373 | if (debug) | |
2ec1e66f | 374 | zlog_debug("%s: %s is the initial bestpath", pfx_buf, new_buf); |
9fbdd100 DS |
375 | return 1; |
376 | } | |
718e3744 | 377 | |
2ec1e66f DW |
378 | if (debug) |
379 | bgp_info_path_with_addpath_rx_str (exist, exist_buf); | |
380 | ||
8ff56318 JBD |
381 | newattr = new->attr; |
382 | existattr = exist->attr; | |
383 | newattre = newattr->extra; | |
384 | existattre = existattr->extra; | |
385 | ||
718e3744 | 386 | /* 1. Weight check. */ |
8ff56318 JBD |
387 | new_weight = exist_weight = 0; |
388 | ||
389 | if (newattre) | |
390 | new_weight = newattre->weight; | |
391 | if (existattre) | |
392 | exist_weight = existattre->weight; | |
393 | ||
fb982c25 | 394 | if (new_weight > exist_weight) |
9fbdd100 DS |
395 | { |
396 | if (debug) | |
2ec1e66f DW |
397 | zlog_debug("%s: %s wins over %s due to weight %d > %d", |
398 | pfx_buf, new_buf, exist_buf, new_weight, exist_weight); | |
9fbdd100 DS |
399 | return 1; |
400 | } | |
401 | ||
fb982c25 | 402 | if (new_weight < exist_weight) |
9fbdd100 DS |
403 | { |
404 | if (debug) | |
2ec1e66f DW |
405 | zlog_debug("%s: %s loses to %s due to weight %d < %d", |
406 | pfx_buf, new_buf, exist_buf, new_weight, exist_weight); | |
9fbdd100 DS |
407 | return 0; |
408 | } | |
718e3744 | 409 | |
410 | /* 2. Local preference check. */ | |
8ff56318 JBD |
411 | new_pref = exist_pref = bgp->default_local_pref; |
412 | ||
413 | if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
414 | new_pref = newattr->local_pref; | |
415 | if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
416 | exist_pref = existattr->local_pref; | |
718e3744 | 417 | |
718e3744 | 418 | if (new_pref > exist_pref) |
9fbdd100 DS |
419 | { |
420 | if (debug) | |
2ec1e66f DW |
421 | zlog_debug("%s: %s wins over %s due to localpref %d > %d", |
422 | pfx_buf, new_buf, exist_buf, new_pref, exist_pref); | |
9fbdd100 DS |
423 | return 1; |
424 | } | |
425 | ||
718e3744 | 426 | if (new_pref < exist_pref) |
9fbdd100 DS |
427 | { |
428 | if (debug) | |
2ec1e66f DW |
429 | zlog_debug("%s: %s loses to %s due to localpref %d < %d", |
430 | pfx_buf, new_buf, exist_buf, new_pref, exist_pref); | |
9fbdd100 DS |
431 | return 0; |
432 | } | |
718e3744 | 433 | |
8ff56318 JBD |
434 | /* 3. Local route check. We prefer: |
435 | * - BGP_ROUTE_STATIC | |
436 | * - BGP_ROUTE_AGGREGATE | |
437 | * - BGP_ROUTE_REDISTRIBUTE | |
438 | */ | |
439 | if (! (new->sub_type == BGP_ROUTE_NORMAL)) | |
9fbdd100 DS |
440 | { |
441 | if (debug) | |
2ec1e66f DW |
442 | zlog_debug("%s: %s wins over %s due to preferred BGP_ROUTE type", |
443 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
444 | return 1; |
445 | } | |
446 | ||
8ff56318 | 447 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
9fbdd100 DS |
448 | { |
449 | if (debug) | |
2ec1e66f DW |
450 | zlog_debug("%s: %s loses to %s due to preferred BGP_ROUTE type", |
451 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
452 | return 0; |
453 | } | |
718e3744 | 454 | |
455 | /* 4. AS path length check. */ | |
456 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) | |
457 | { | |
8ff56318 JBD |
458 | int exist_hops = aspath_count_hops (existattr->aspath); |
459 | int exist_confeds = aspath_count_confeds (existattr->aspath); | |
fe69a505 | 460 | |
6811845b | 461 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
462 | { | |
fe69a505 | 463 | int aspath_hops; |
464 | ||
8ff56318 JBD |
465 | aspath_hops = aspath_count_hops (newattr->aspath); |
466 | aspath_hops += aspath_count_confeds (newattr->aspath); | |
fe69a505 | 467 | |
468 | if ( aspath_hops < (exist_hops + exist_confeds)) | |
9fbdd100 DS |
469 | { |
470 | if (debug) | |
2ec1e66f DW |
471 | zlog_debug("%s: %s wins over %s due to aspath (with confeds) hopcount %d < %d", |
472 | pfx_buf, new_buf, exist_buf, | |
9fbdd100 DS |
473 | aspath_hops, (exist_hops + exist_confeds)); |
474 | return 1; | |
475 | } | |
476 | ||
fe69a505 | 477 | if ( aspath_hops > (exist_hops + exist_confeds)) |
9fbdd100 DS |
478 | { |
479 | if (debug) | |
2ec1e66f DW |
480 | zlog_debug("%s: %s loses to %s due to aspath (with confeds) hopcount %d > %d", |
481 | pfx_buf, new_buf, exist_buf, | |
9fbdd100 DS |
482 | aspath_hops, (exist_hops + exist_confeds)); |
483 | return 0; | |
484 | } | |
6811845b | 485 | } |
486 | else | |
487 | { | |
8ff56318 | 488 | int newhops = aspath_count_hops (newattr->aspath); |
fe69a505 | 489 | |
490 | if (newhops < exist_hops) | |
9fbdd100 DS |
491 | { |
492 | if (debug) | |
2ec1e66f DW |
493 | zlog_debug("%s: %s wins over %s due to aspath hopcount %d < %d", |
494 | pfx_buf, new_buf, exist_buf, newhops, exist_hops); | |
9fbdd100 DS |
495 | return 1; |
496 | } | |
497 | ||
fe69a505 | 498 | if (newhops > exist_hops) |
9fbdd100 DS |
499 | { |
500 | if (debug) | |
2ec1e66f DW |
501 | zlog_debug("%s: %s loses to %s due to aspath hopcount %d > %d", |
502 | pfx_buf, new_buf, exist_buf, newhops, exist_hops); | |
9fbdd100 DS |
503 | return 0; |
504 | } | |
6811845b | 505 | } |
718e3744 | 506 | } |
507 | ||
508 | /* 5. Origin check. */ | |
8ff56318 | 509 | if (newattr->origin < existattr->origin) |
9fbdd100 DS |
510 | { |
511 | if (debug) | |
2ec1e66f DW |
512 | zlog_debug("%s: %s wins over %s due to ORIGIN %s < %s", |
513 | pfx_buf, new_buf, exist_buf, | |
9fbdd100 DS |
514 | bgp_origin_long_str[newattr->origin], |
515 | bgp_origin_long_str[existattr->origin]); | |
516 | return 1; | |
517 | } | |
518 | ||
8ff56318 | 519 | if (newattr->origin > existattr->origin) |
9fbdd100 DS |
520 | { |
521 | if (debug) | |
2ec1e66f DW |
522 | zlog_debug("%s: %s loses to %s due to ORIGIN %s > %s", |
523 | pfx_buf, new_buf, exist_buf, | |
9fbdd100 DS |
524 | bgp_origin_long_str[newattr->origin], |
525 | bgp_origin_long_str[existattr->origin]); | |
526 | return 0; | |
527 | } | |
718e3744 | 528 | |
529 | /* 6. MED check. */ | |
8ff56318 JBD |
530 | internal_as_route = (aspath_count_hops (newattr->aspath) == 0 |
531 | && aspath_count_hops (existattr->aspath) == 0); | |
532 | confed_as_route = (aspath_count_confeds (newattr->aspath) > 0 | |
533 | && aspath_count_confeds (existattr->aspath) > 0 | |
534 | && aspath_count_hops (newattr->aspath) == 0 | |
535 | && aspath_count_hops (existattr->aspath) == 0); | |
718e3744 | 536 | |
537 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) | |
538 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) | |
539 | && confed_as_route) | |
8ff56318 JBD |
540 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
541 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) | |
718e3744 | 542 | || internal_as_route) |
543 | { | |
544 | new_med = bgp_med_value (new->attr, bgp); | |
545 | exist_med = bgp_med_value (exist->attr, bgp); | |
546 | ||
547 | if (new_med < exist_med) | |
9fbdd100 DS |
548 | { |
549 | if (debug) | |
2ec1e66f DW |
550 | zlog_debug("%s: %s wins over %s due to MED %d < %d", |
551 | pfx_buf, new_buf, exist_buf, new_med, exist_med); | |
9fbdd100 DS |
552 | return 1; |
553 | } | |
554 | ||
718e3744 | 555 | if (new_med > exist_med) |
9fbdd100 DS |
556 | { |
557 | if (debug) | |
2ec1e66f DW |
558 | zlog_debug("%s: %s loses to %s due to MED %d > %d", |
559 | pfx_buf, new_buf, exist_buf, new_med, exist_med); | |
9fbdd100 DS |
560 | return 0; |
561 | } | |
718e3744 | 562 | } |
563 | ||
564 | /* 7. Peer type check. */ | |
8ff56318 JBD |
565 | new_sort = new->peer->sort; |
566 | exist_sort = exist->peer->sort; | |
567 | ||
568 | if (new_sort == BGP_PEER_EBGP | |
569 | && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) | |
9fbdd100 DS |
570 | { |
571 | if (debug) | |
2ec1e66f DW |
572 | zlog_debug("%s: %s wins over %s due to eBGP peer > iBGP peer", |
573 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
574 | return 1; |
575 | } | |
576 | ||
8ff56318 JBD |
577 | if (exist_sort == BGP_PEER_EBGP |
578 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) | |
9fbdd100 DS |
579 | { |
580 | if (debug) | |
2ec1e66f DW |
581 | zlog_debug("%s: %s loses to %s due to iBGP peer < eBGP peer", |
582 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
583 | return 0; |
584 | } | |
718e3744 | 585 | |
586 | /* 8. IGP metric check. */ | |
8ff56318 JBD |
587 | newm = existm = 0; |
588 | ||
589 | if (new->extra) | |
590 | newm = new->extra->igpmetric; | |
591 | if (exist->extra) | |
592 | existm = exist->extra->igpmetric; | |
593 | ||
96450faf | 594 | if (newm < existm) |
9fbdd100 DS |
595 | { |
596 | if (debug) | |
2ec1e66f DW |
597 | zlog_debug("%s: %s wins over %s due to IGP metric %d < %d", |
598 | pfx_buf, new_buf, exist_buf, newm, existm); | |
9fbdd100 DS |
599 | ret = 1; |
600 | } | |
601 | ||
96450faf | 602 | if (newm > existm) |
9fbdd100 DS |
603 | { |
604 | if (debug) | |
2ec1e66f DW |
605 | zlog_debug("%s: %s loses to %s due to IGP metric %d > %d", |
606 | pfx_buf, new_buf, exist_buf, newm, existm); | |
9fbdd100 DS |
607 | ret = 0; |
608 | } | |
718e3744 | 609 | |
31a4638f | 610 | /* 9. Same IGP metric. Compare the cluster list length as |
5e242b0d DS |
611 | representative of IGP hops metric. Rewrite the metric value |
612 | pair (newm, existm) with the cluster list length. Prefer the | |
613 | path with smaller cluster list length. */ | |
614 | if (newm == existm) | |
615 | { | |
616 | if (peer_sort (new->peer) == BGP_PEER_IBGP | |
617 | && peer_sort (exist->peer) == BGP_PEER_IBGP | |
618 | && CHECK_FLAG (mpath_cfg->ibgp_flags, | |
619 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
620 | { | |
621 | newm = BGP_CLUSTER_LIST_LENGTH(new->attr); | |
622 | existm = BGP_CLUSTER_LIST_LENGTH(exist->attr); | |
9fbdd100 | 623 | |
5e242b0d | 624 | if (newm < existm) |
9fbdd100 DS |
625 | { |
626 | if (debug) | |
2ec1e66f DW |
627 | zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d", |
628 | pfx_buf, new_buf, exist_buf, newm, existm); | |
9fbdd100 DS |
629 | ret = 1; |
630 | } | |
631 | ||
5e242b0d | 632 | if (newm > existm) |
9fbdd100 DS |
633 | { |
634 | if (debug) | |
2ec1e66f DW |
635 | zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d", |
636 | pfx_buf, new_buf, exist_buf, newm, existm); | |
9fbdd100 DS |
637 | ret = 0; |
638 | } | |
5e242b0d DS |
639 | } |
640 | } | |
641 | ||
31a4638f DS |
642 | /* 10. confed-external vs. confed-internal */ |
643 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
644 | { | |
645 | if (new_sort == BGP_PEER_CONFED && exist_sort == BGP_PEER_IBGP) | |
646 | { | |
647 | if (debug) | |
2ec1e66f DW |
648 | zlog_debug("%s: %s wins over %s due to confed-external peer > confed-internal peer", |
649 | pfx_buf, new_buf, exist_buf); | |
31a4638f DS |
650 | return 1; |
651 | } | |
652 | ||
653 | if (exist_sort == BGP_PEER_CONFED && new_sort == BGP_PEER_IBGP) | |
654 | { | |
655 | if (debug) | |
2ec1e66f DW |
656 | zlog_debug("%s: %s loses to %s due to confed-internal peer < confed-external peer", |
657 | pfx_buf, new_buf, exist_buf); | |
31a4638f DS |
658 | return 0; |
659 | } | |
660 | } | |
661 | ||
662 | /* 11. Maximum path check. */ | |
96450faf JB |
663 | if (newm == existm) |
664 | { | |
2fdd455c PM |
665 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) |
666 | { | |
667 | ||
668 | /* | |
669 | * For the two paths, all comparison steps till IGP metric | |
670 | * have succeeded - including AS_PATH hop count. Since 'bgp | |
671 | * bestpath as-path multipath-relax' knob is on, we don't need | |
672 | * an exact match of AS_PATH. Thus, mark the paths are equal. | |
673 | * That will trigger both these paths to get into the multipath | |
674 | * array. | |
675 | */ | |
676 | *paths_eq = 1; | |
9fbdd100 DS |
677 | |
678 | if (debug) | |
2ec1e66f DW |
679 | zlog_debug("%s: %s and %s are equal via multipath-relax", |
680 | pfx_buf, new_buf, exist_buf); | |
2fdd455c PM |
681 | } |
682 | else if (new->peer->sort == BGP_PEER_IBGP) | |
96450faf JB |
683 | { |
684 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) | |
9fbdd100 DS |
685 | { |
686 | *paths_eq = 1; | |
687 | ||
688 | if (debug) | |
2ec1e66f DW |
689 | zlog_debug("%s: %s and %s are equal via matching aspaths", |
690 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 | 691 | } |
96450faf JB |
692 | } |
693 | else if (new->peer->as == exist->peer->as) | |
9fbdd100 DS |
694 | { |
695 | *paths_eq = 1; | |
696 | ||
697 | if (debug) | |
2ec1e66f DW |
698 | zlog_debug("%s: %s and %s are equal via same remote-as", |
699 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 | 700 | } |
96450faf JB |
701 | } |
702 | else | |
703 | { | |
704 | /* | |
705 | * TODO: If unequal cost ibgp multipath is enabled we can | |
706 | * mark the paths as equal here instead of returning | |
707 | */ | |
708 | return ret; | |
709 | } | |
718e3744 | 710 | |
31a4638f | 711 | /* 12. If both paths are external, prefer the path that was received |
718e3744 | 712 | first (the oldest one). This step minimizes route-flap, since a |
713 | newer path won't displace an older one, even if it was the | |
714 | preferred route based on the additional decision criteria below. */ | |
715 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) | |
8ff56318 JBD |
716 | && new_sort == BGP_PEER_EBGP |
717 | && exist_sort == BGP_PEER_EBGP) | |
718e3744 | 718 | { |
719 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) | |
9fbdd100 DS |
720 | { |
721 | if (debug) | |
2ec1e66f DW |
722 | zlog_debug("%s: %s wins over %s due to oldest external", |
723 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
724 | return 1; |
725 | } | |
726 | ||
718e3744 | 727 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
9fbdd100 DS |
728 | { |
729 | if (debug) | |
2ec1e66f DW |
730 | zlog_debug("%s: %s loses to %s due to oldest external", |
731 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
732 | return 0; |
733 | } | |
718e3744 | 734 | } |
735 | ||
31a4638f | 736 | /* 13. Router-ID comparision. */ |
0de5153c DS |
737 | /* If one of the paths is "stale", the corresponding peer router-id will |
738 | * be 0 and would always win over the other path. If originator id is | |
739 | * used for the comparision, it will decide which path is better. | |
740 | */ | |
8ff56318 JBD |
741 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
742 | new_id.s_addr = newattre->originator_id.s_addr; | |
718e3744 | 743 | else |
744 | new_id.s_addr = new->peer->remote_id.s_addr; | |
8ff56318 JBD |
745 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
746 | exist_id.s_addr = existattre->originator_id.s_addr; | |
718e3744 | 747 | else |
748 | exist_id.s_addr = exist->peer->remote_id.s_addr; | |
749 | ||
750 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) | |
9fbdd100 DS |
751 | { |
752 | if (debug) | |
2ec1e66f DW |
753 | zlog_debug("%s: %s wins over %s due to Router-ID comparison", |
754 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
755 | return 1; |
756 | } | |
757 | ||
718e3744 | 758 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
9fbdd100 DS |
759 | { |
760 | if (debug) | |
2ec1e66f DW |
761 | zlog_debug("%s: %s loses to %s due to Router-ID comparison", |
762 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
763 | return 0; |
764 | } | |
718e3744 | 765 | |
31a4638f | 766 | /* 14. Cluster length comparision. */ |
5e242b0d DS |
767 | new_cluster = BGP_CLUSTER_LIST_LENGTH(new->attr); |
768 | exist_cluster = BGP_CLUSTER_LIST_LENGTH(exist->attr); | |
718e3744 | 769 | |
770 | if (new_cluster < exist_cluster) | |
9fbdd100 DS |
771 | { |
772 | if (debug) | |
2ec1e66f DW |
773 | zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d", |
774 | pfx_buf, new_buf, exist_buf, new_cluster, exist_cluster); | |
9fbdd100 DS |
775 | return 1; |
776 | } | |
777 | ||
718e3744 | 778 | if (new_cluster > exist_cluster) |
9fbdd100 DS |
779 | { |
780 | if (debug) | |
2ec1e66f DW |
781 | zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d", |
782 | pfx_buf, new_buf, exist_buf, new_cluster, exist_cluster); | |
9fbdd100 DS |
783 | return 0; |
784 | } | |
718e3744 | 785 | |
31a4638f | 786 | /* 15. Neighbor address comparision. */ |
0de5153c DS |
787 | /* Do this only if neither path is "stale" as stale paths do not have |
788 | * valid peer information (as the connection may or may not be up). | |
789 | */ | |
790 | if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) | |
9fbdd100 DS |
791 | { |
792 | if (debug) | |
2ec1e66f DW |
793 | zlog_debug("%s: %s wins over %s due to latter path being STALE", |
794 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
795 | return 1; |
796 | } | |
797 | ||
0de5153c | 798 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
9fbdd100 DS |
799 | { |
800 | if (debug) | |
2ec1e66f DW |
801 | zlog_debug("%s: %s loses to %s due to former path being STALE", |
802 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
803 | return 0; |
804 | } | |
0de5153c | 805 | |
43ed4fe5 TT |
806 | /* locally configured routes to advertise do not have su_remote */ |
807 | if (new->peer->su_remote == NULL) | |
808 | return 0; | |
809 | if (exist->peer->su_remote == NULL) | |
810 | return 1; | |
811 | ||
718e3744 | 812 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
813 | ||
814 | if (ret == 1) | |
9fbdd100 DS |
815 | { |
816 | if (debug) | |
2ec1e66f DW |
817 | zlog_debug("%s: %s loses to %s due to Neighor IP comparison", |
818 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
819 | return 0; |
820 | } | |
821 | ||
718e3744 | 822 | if (ret == -1) |
9fbdd100 DS |
823 | { |
824 | if (debug) | |
2ec1e66f DW |
825 | zlog_debug("%s: %s wins over %s due to Neighor IP comparison", |
826 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
827 | return 1; |
828 | } | |
829 | ||
830 | if (debug) | |
2ec1e66f DW |
831 | zlog_debug("%s: %s wins over %s due to nothing left to compare", |
832 | pfx_buf, new_buf, exist_buf); | |
718e3744 | 833 | |
834 | return 1; | |
835 | } | |
836 | ||
94f2b392 | 837 | static enum filter_type |
718e3744 | 838 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
839 | afi_t afi, safi_t safi) | |
840 | { | |
841 | struct bgp_filter *filter; | |
842 | ||
843 | filter = &peer->filter[afi][safi]; | |
844 | ||
650f76c2 PJ |
845 | #define FILTER_EXIST_WARN(F,f,filter) \ |
846 | if (BGP_DEBUG (update, UPDATE_IN) \ | |
847 | && !(F ## _IN (filter))) \ | |
16286195 | 848 | zlog_warn ("%s: Could not find configured input %s-list %s!", \ |
650f76c2 PJ |
849 | peer->host, #f, F ## _IN_NAME(filter)); |
850 | ||
851 | if (DISTRIBUTE_IN_NAME (filter)) { | |
852 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
853 | ||
718e3744 | 854 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
855 | return FILTER_DENY; | |
650f76c2 | 856 | } |
718e3744 | 857 | |
650f76c2 PJ |
858 | if (PREFIX_LIST_IN_NAME (filter)) { |
859 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
860 | ||
718e3744 | 861 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
862 | return FILTER_DENY; | |
650f76c2 | 863 | } |
718e3744 | 864 | |
650f76c2 PJ |
865 | if (FILTER_LIST_IN_NAME (filter)) { |
866 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
867 | ||
718e3744 | 868 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
869 | return FILTER_DENY; | |
650f76c2 PJ |
870 | } |
871 | ||
718e3744 | 872 | return FILTER_PERMIT; |
650f76c2 | 873 | #undef FILTER_EXIST_WARN |
718e3744 | 874 | } |
875 | ||
94f2b392 | 876 | static enum filter_type |
718e3744 | 877 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
878 | afi_t afi, safi_t safi) | |
879 | { | |
880 | struct bgp_filter *filter; | |
881 | ||
882 | filter = &peer->filter[afi][safi]; | |
883 | ||
650f76c2 PJ |
884 | #define FILTER_EXIST_WARN(F,f,filter) \ |
885 | if (BGP_DEBUG (update, UPDATE_OUT) \ | |
886 | && !(F ## _OUT (filter))) \ | |
16286195 | 887 | zlog_warn ("%s: Could not find configured output %s-list %s!", \ |
650f76c2 PJ |
888 | peer->host, #f, F ## _OUT_NAME(filter)); |
889 | ||
890 | if (DISTRIBUTE_OUT_NAME (filter)) { | |
891 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
892 | ||
718e3744 | 893 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
894 | return FILTER_DENY; | |
650f76c2 | 895 | } |
718e3744 | 896 | |
650f76c2 PJ |
897 | if (PREFIX_LIST_OUT_NAME (filter)) { |
898 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
899 | ||
718e3744 | 900 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
901 | return FILTER_DENY; | |
650f76c2 | 902 | } |
718e3744 | 903 | |
650f76c2 PJ |
904 | if (FILTER_LIST_OUT_NAME (filter)) { |
905 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
906 | ||
718e3744 | 907 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
908 | return FILTER_DENY; | |
650f76c2 | 909 | } |
718e3744 | 910 | |
911 | return FILTER_PERMIT; | |
650f76c2 | 912 | #undef FILTER_EXIST_WARN |
718e3744 | 913 | } |
914 | ||
915 | /* If community attribute includes no_export then return 1. */ | |
94f2b392 | 916 | static int |
718e3744 | 917 | bgp_community_filter (struct peer *peer, struct attr *attr) |
918 | { | |
919 | if (attr->community) | |
920 | { | |
921 | /* NO_ADVERTISE check. */ | |
922 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) | |
923 | return 1; | |
924 | ||
925 | /* NO_EXPORT check. */ | |
6d85b15b | 926 | if (peer->sort == BGP_PEER_EBGP && |
718e3744 | 927 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
928 | return 1; | |
929 | ||
930 | /* NO_EXPORT_SUBCONFED check. */ | |
6d85b15b JBD |
931 | if (peer->sort == BGP_PEER_EBGP |
932 | || peer->sort == BGP_PEER_CONFED) | |
718e3744 | 933 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
934 | return 1; | |
935 | } | |
936 | return 0; | |
937 | } | |
938 | ||
939 | /* Route reflection loop check. */ | |
940 | static int | |
941 | bgp_cluster_filter (struct peer *peer, struct attr *attr) | |
942 | { | |
943 | struct in_addr cluster_id; | |
944 | ||
fb982c25 | 945 | if (attr->extra && attr->extra->cluster) |
718e3744 | 946 | { |
947 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) | |
948 | cluster_id = peer->bgp->cluster_id; | |
949 | else | |
950 | cluster_id = peer->bgp->router_id; | |
951 | ||
fb982c25 | 952 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
718e3744 | 953 | return 1; |
954 | } | |
955 | return 0; | |
956 | } | |
6b0655a2 | 957 | |
94f2b392 | 958 | static int |
718e3744 | 959 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
ffd0c037 | 960 | afi_t afi, safi_t safi, const char *rmap_name) |
718e3744 | 961 | { |
962 | struct bgp_filter *filter; | |
963 | struct bgp_info info; | |
964 | route_map_result_t ret; | |
0b16f239 | 965 | struct route_map *rmap = NULL; |
718e3744 | 966 | |
967 | filter = &peer->filter[afi][safi]; | |
968 | ||
969 | /* Apply default weight value. */ | |
fb982c25 PJ |
970 | if (peer->weight) |
971 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
718e3744 | 972 | |
0b16f239 DS |
973 | if (rmap_name) |
974 | { | |
975 | rmap = route_map_lookup_by_name(rmap_name); | |
98a4a44e DS |
976 | |
977 | if (rmap == NULL) | |
978 | return RMAP_DENY; | |
0b16f239 DS |
979 | } |
980 | else | |
981 | { | |
982 | if (ROUTE_MAP_IN_NAME(filter)) | |
98a4a44e DS |
983 | { |
984 | rmap = ROUTE_MAP_IN (filter); | |
985 | ||
986 | if (rmap == NULL) | |
987 | return RMAP_DENY; | |
988 | } | |
0b16f239 DS |
989 | } |
990 | ||
718e3744 | 991 | /* Route map apply. */ |
0b16f239 | 992 | if (rmap) |
718e3744 | 993 | { |
994 | /* Duplicate current value to new strucutre for modification. */ | |
995 | info.peer = peer; | |
996 | info.attr = attr; | |
997 | ||
ac41b2a2 | 998 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
999 | ||
718e3744 | 1000 | /* Apply BGP route map to the attribute. */ |
0b16f239 DS |
1001 | ret = route_map_apply (rmap, p, RMAP_BGP, &info); |
1002 | ||
1003 | peer->rmap_type = 0; | |
1004 | ||
1005 | if (ret == RMAP_DENYMATCH) | |
1006 | { | |
1007 | /* Free newly generated AS path and community by route-map. */ | |
1008 | bgp_attr_flush (attr); | |
1009 | return RMAP_DENY; | |
1010 | } | |
1011 | } | |
1012 | return RMAP_PERMIT; | |
1013 | } | |
1014 | ||
1015 | static int | |
1016 | bgp_output_modifier (struct peer *peer, struct prefix *p, struct attr *attr, | |
ffd0c037 | 1017 | afi_t afi, safi_t safi, const char *rmap_name) |
0b16f239 DS |
1018 | { |
1019 | struct bgp_filter *filter; | |
1020 | struct bgp_info info; | |
1021 | route_map_result_t ret; | |
1022 | struct route_map *rmap = NULL; | |
1023 | ||
1024 | filter = &peer->filter[afi][safi]; | |
1025 | ||
1026 | /* Apply default weight value. */ | |
1027 | if (peer->weight) | |
1028 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
1029 | ||
1030 | if (rmap_name) | |
1031 | { | |
1032 | rmap = route_map_lookup_by_name(rmap_name); | |
98a4a44e DS |
1033 | |
1034 | if (rmap == NULL) | |
1035 | return RMAP_DENY; | |
0b16f239 DS |
1036 | } |
1037 | else | |
1038 | { | |
1039 | if (ROUTE_MAP_OUT_NAME(filter)) | |
98a4a44e DS |
1040 | { |
1041 | rmap = ROUTE_MAP_OUT (filter); | |
1042 | ||
1043 | if (rmap == NULL) | |
1044 | return RMAP_DENY; | |
1045 | } | |
0b16f239 DS |
1046 | } |
1047 | ||
1048 | /* Route map apply. */ | |
1049 | if (rmap) | |
1050 | { | |
1051 | /* Duplicate current value to new strucutre for modification. */ | |
1052 | info.peer = peer; | |
1053 | info.attr = attr; | |
1054 | ||
1055 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1056 | ||
1057 | /* Apply BGP route map to the attribute. */ | |
1058 | ret = route_map_apply (rmap, p, RMAP_BGP, &info); | |
ac41b2a2 | 1059 | |
1060 | peer->rmap_type = 0; | |
1061 | ||
718e3744 | 1062 | if (ret == RMAP_DENYMATCH) |
c460e572 DL |
1063 | /* caller has multiple error paths with bgp_attr_flush() */ |
1064 | return RMAP_DENY; | |
718e3744 | 1065 | } |
1066 | return RMAP_PERMIT; | |
1067 | } | |
6b0655a2 | 1068 | |
5000f21c | 1069 | /* If this is an EBGP peer with remove-private-AS */ |
ffd0c037 | 1070 | static void |
5000f21c DS |
1071 | bgp_peer_remove_private_as(struct bgp *bgp, afi_t afi, safi_t safi, |
1072 | struct peer *peer, struct attr *attr) | |
1073 | { | |
1074 | if (peer->sort == BGP_PEER_EBGP && | |
88b8ed8d DW |
1075 | (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE) || |
1076 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE) || | |
1077 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL) || | |
1078 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS))) | |
5000f21c DS |
1079 | { |
1080 | // Take action on the entire aspath | |
88b8ed8d DW |
1081 | if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE) || |
1082 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
5000f21c | 1083 | { |
88b8ed8d | 1084 | if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
5000f21c DS |
1085 | attr->aspath = aspath_replace_private_asns (attr->aspath, bgp->as); |
1086 | ||
1087 | // The entire aspath consists of private ASNs so create an empty aspath | |
1088 | else if (aspath_private_as_check (attr->aspath)) | |
1089 | attr->aspath = aspath_empty_get (); | |
1090 | ||
1091 | // There are some public and some private ASNs, remove the private ASNs | |
1092 | else | |
1093 | attr->aspath = aspath_remove_private_asns (attr->aspath); | |
1094 | } | |
1095 | ||
1096 | // 'all' was not specified so the entire aspath must be private ASNs | |
1097 | // for us to do anything | |
1098 | else if (aspath_private_as_check (attr->aspath)) | |
1099 | { | |
1100 | if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
1101 | attr->aspath = aspath_replace_private_asns (attr->aspath, bgp->as); | |
1102 | else | |
1103 | attr->aspath = aspath_empty_get (); | |
1104 | } | |
1105 | } | |
1106 | } | |
1107 | ||
c7122e14 DS |
1108 | /* If this is an EBGP peer with as-override */ |
1109 | static void | |
1110 | bgp_peer_as_override(struct bgp *bgp, afi_t afi, safi_t safi, | |
1111 | struct peer *peer, struct attr *attr) | |
1112 | { | |
1113 | if (peer->sort == BGP_PEER_EBGP && | |
1114 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) | |
1115 | { | |
1116 | if (aspath_single_asn_check (attr->aspath, peer->as)) | |
1117 | attr->aspath = aspath_replace_specific_asn (attr->aspath, peer->as, bgp->as); | |
1118 | } | |
1119 | } | |
1120 | ||
3f9c7369 DS |
1121 | static void |
1122 | subgroup_announce_reset_nhop (u_char family, struct attr *attr) | |
1123 | { | |
1124 | if (family == AF_INET) | |
1125 | attr->nexthop.s_addr = 0; | |
1126 | #ifdef HAVE_IPV6 | |
1127 | if (family == AF_INET6) | |
1128 | memset (&attr->extra->mp_nexthop_global, 0, IPV6_MAX_BYTELEN); | |
1129 | #endif | |
1130 | } | |
1131 | ||
1132 | int | |
1133 | subgroup_announce_check (struct bgp_info *ri, struct update_subgroup *subgrp, | |
1134 | struct prefix *p, struct attr *attr) | |
1135 | { | |
1136 | struct bgp_filter *filter; | |
1137 | struct peer *from; | |
1138 | struct peer *peer; | |
1139 | struct peer *onlypeer; | |
1140 | struct bgp *bgp; | |
1141 | struct attr *riattr; | |
1142 | struct peer_af *paf; | |
1143 | char buf[SU_ADDRSTRLEN]; | |
1144 | int ret; | |
1145 | int transparent; | |
1146 | int reflect; | |
1147 | afi_t afi; | |
1148 | safi_t safi; | |
1149 | ||
1150 | if (DISABLE_BGP_ANNOUNCE) | |
1151 | return 0; | |
1152 | ||
1153 | afi = SUBGRP_AFI(subgrp); | |
1154 | safi = SUBGRP_SAFI(subgrp); | |
1155 | peer = SUBGRP_PEER(subgrp); | |
1156 | onlypeer = NULL; | |
1157 | if (CHECK_FLAG (peer->flags, PEER_FLAG_LONESOUL)) | |
1158 | onlypeer = SUBGRP_PFIRST(subgrp)->peer; | |
1159 | ||
1160 | from = ri->peer; | |
1161 | filter = &peer->filter[afi][safi]; | |
1162 | bgp = SUBGRP_INST(subgrp); | |
1163 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; | |
1164 | ||
adbac85e DW |
1165 | /* With addpath we may be asked to TX all kinds of paths so make sure |
1166 | * ri is valid */ | |
1167 | if (!CHECK_FLAG (ri->flags, BGP_INFO_VALID) || | |
1168 | CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) || | |
1169 | CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) | |
1170 | { | |
1171 | return 0; | |
1172 | } | |
1173 | ||
06370dac DW |
1174 | /* If this is not the bestpath then check to see if there is an enabled addpath |
1175 | * feature that requires us to advertise it */ | |
1176 | if (! CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1177 | { | |
1178 | if (! bgp_addpath_tx_path(peer, afi, safi, ri)) | |
1179 | { | |
1180 | return 0; | |
1181 | } | |
1182 | } | |
1183 | ||
3f9c7369 DS |
1184 | /* Aggregate-address suppress check. */ |
1185 | if (ri->extra && ri->extra->suppress) | |
1186 | if (! UNSUPPRESS_MAP_NAME (filter)) | |
1187 | { | |
1188 | return 0; | |
1189 | } | |
1190 | ||
3f9c7369 DS |
1191 | /* Do not send back route to sender. */ |
1192 | if (onlypeer && from == onlypeer) | |
1193 | { | |
1194 | return 0; | |
1195 | } | |
1196 | ||
4125bb67 DS |
1197 | /* Do not send the default route in the BGP table if the neighbor is |
1198 | * configured for default-originate */ | |
1199 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
1200 | { | |
1201 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
1202 | return 0; | |
1203 | #ifdef HAVE_IPV6 | |
1204 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
1205 | return 0; | |
1206 | #endif /* HAVE_IPV6 */ | |
1207 | } | |
1208 | ||
3f9c7369 DS |
1209 | /* Transparency check. */ |
1210 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) | |
1211 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
1212 | transparent = 1; | |
1213 | else | |
1214 | transparent = 0; | |
1215 | ||
1216 | /* If community is not disabled check the no-export and local. */ | |
1217 | if (! transparent && bgp_community_filter (peer, riattr)) | |
1218 | { | |
1219 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1220 | zlog_debug ("subgrpannouncecheck: community filter check fail"); | |
1221 | return 0; | |
1222 | } | |
1223 | ||
1224 | /* If the attribute has originator-id and it is same as remote | |
1225 | peer's id. */ | |
1226 | if (onlypeer && | |
1227 | riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) && | |
1228 | (IPV4_ADDR_SAME (&onlypeer->remote_id, &riattr->extra->originator_id))) | |
1229 | { | |
1230 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1231 | zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as " | |
1232 | "remote router-id", | |
1233 | onlypeer->host, | |
1234 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1235 | p->prefixlen); | |
1236 | return 0; | |
1237 | } | |
1238 | ||
1239 | /* ORF prefix-list filter check */ | |
1240 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
1241 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
1242 | || CHECK_FLAG (peer->af_cap[afi][safi], | |
1243 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
1244 | if (peer->orf_plist[afi][safi]) | |
1245 | { | |
1246 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) | |
1247 | { | |
40d2700d DW |
1248 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) |
1249 | zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF", | |
1250 | peer->host, | |
1251 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1252 | p->prefixlen); | |
3f9c7369 DS |
1253 | return 0; |
1254 | } | |
1255 | } | |
1256 | ||
1257 | /* Output filter check. */ | |
1258 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) | |
1259 | { | |
1260 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1261 | zlog_debug ("%s [Update:SEND] %s/%d is filtered", | |
1262 | peer->host, | |
1263 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1264 | p->prefixlen); | |
1265 | return 0; | |
1266 | } | |
1267 | ||
1268 | #ifdef BGP_SEND_ASPATH_CHECK | |
1269 | /* AS path loop check. */ | |
1270 | if (onlypeer && aspath_loop_check (riattr->aspath, onlypeer->as)) | |
1271 | { | |
1272 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1273 | zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u " | |
1274 | "that is part of AS path.", | |
1275 | onlypeer->host, onlypeer->as); | |
1276 | return 0; | |
1277 | } | |
1278 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
1279 | ||
1280 | /* If we're a CONFED we need to loop check the CONFED ID too */ | |
1281 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
1282 | { | |
1283 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) | |
1284 | { | |
1285 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1286 | zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u" | |
1287 | " is AS path.", | |
1288 | peer->host, | |
1289 | bgp->confed_id); | |
1290 | return 0; | |
1291 | } | |
1292 | } | |
1293 | ||
1294 | /* Route-Reflect check. */ | |
1295 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) | |
1296 | reflect = 1; | |
1297 | else | |
1298 | reflect = 0; | |
1299 | ||
1300 | /* IBGP reflection check. */ | |
1301 | if (reflect) | |
1302 | { | |
1303 | /* A route from a Client peer. */ | |
1304 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
1305 | { | |
1306 | /* Reflect to all the Non-Client peers and also to the | |
1307 | Client peers other than the originator. Originator check | |
1308 | is already done. So there is noting to do. */ | |
1309 | /* no bgp client-to-client reflection check. */ | |
1310 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
1311 | if (CHECK_FLAG (peer->af_flags[afi][safi], | |
1312 | PEER_FLAG_REFLECTOR_CLIENT)) | |
1313 | return 0; | |
1314 | } | |
1315 | else | |
1316 | { | |
1317 | /* A route from a Non-client peer. Reflect to all other | |
1318 | clients. */ | |
1319 | if (! CHECK_FLAG (peer->af_flags[afi][safi], | |
1320 | PEER_FLAG_REFLECTOR_CLIENT)) | |
1321 | return 0; | |
1322 | } | |
1323 | } | |
1324 | ||
1325 | /* For modify attribute, copy it to temporary structure. */ | |
1326 | bgp_attr_dup (attr, riattr); | |
1327 | ||
1328 | /* If local-preference is not set. */ | |
1329 | if ((peer->sort == BGP_PEER_IBGP | |
1330 | || peer->sort == BGP_PEER_CONFED) | |
1331 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) | |
1332 | { | |
1333 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); | |
1334 | attr->local_pref = bgp->default_local_pref; | |
1335 | } | |
1336 | ||
1337 | /* If originator-id is not set and the route is to be reflected, | |
1338 | set the originator id */ | |
1339 | if (reflect && (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) | |
1340 | { | |
1341 | attr->extra = bgp_attr_extra_get(attr); | |
1342 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); | |
1343 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); | |
1344 | } | |
1345 | ||
1346 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ | |
1347 | if (peer->sort == BGP_PEER_EBGP | |
1348 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
1349 | { | |
003c1ba0 | 1350 | if (from != bgp->peer_self && ! transparent |
3f9c7369 DS |
1351 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
1352 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); | |
1353 | } | |
1354 | ||
1355 | /* Since the nexthop attribute can vary per peer, it is not explicitly set | |
1356 | * in announce check, only certain flags and length (or number of nexthops | |
1357 | * -- for IPv6/MP_REACH) are set here in order to guide the update formation | |
1358 | * code in setting the nexthop(s) on a per peer basis in reformat_peer(). | |
1359 | * Typically, the source nexthop in the attribute is preserved but in the | |
1360 | * scenarios where we know it will always be overwritten, we reset the | |
1361 | * nexthop to "0" in an attempt to achieve better Update packing. An | |
1362 | * example of this is when a prefix from each of 2 IBGP peers needs to be | |
1363 | * announced to an EBGP peer (and they have the same attributes barring | |
1364 | * their nexthop). | |
1365 | */ | |
1366 | if (reflect) | |
1367 | SET_FLAG(attr->rmap_change_flags, BATTR_REFLECTED); | |
1368 | ||
1369 | #ifdef HAVE_IPV6 | |
587ff0fd LB |
1370 | #define NEXTHOP_IS_V6 (\ |
1371 | (safi != SAFI_ENCAP && \ | |
1372 | (p->family == AF_INET6 || peer_cap_enhe(peer))) || \ | |
1373 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16)) | |
1374 | ||
3811f1e2 DS |
1375 | /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if |
1376 | * the peer (group) is configured to receive link-local nexthop unchanged | |
1377 | * and it is available in the prefix OR we're not reflecting the route and | |
1378 | * the peer (group) to whom we're going to announce is on a shared network | |
003c1ba0 | 1379 | * and this is either a self-originated route or the peer is EBGP. |
3f9c7369 | 1380 | */ |
587ff0fd | 1381 | if (NEXTHOP_IS_V6) |
3f9c7369 | 1382 | { |
801a9bcc | 1383 | attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; |
3811f1e2 DS |
1384 | if ((CHECK_FLAG (peer->af_flags[afi][safi], |
1385 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) && | |
1386 | IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local)) || | |
003c1ba0 | 1387 | (!reflect && peer->shared_network && |
1388 | (from == bgp->peer_self || peer->sort == BGP_PEER_EBGP))) | |
3f9c7369 | 1389 | { |
3811f1e2 | 1390 | attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; |
3f9c7369 DS |
1391 | } |
1392 | ||
3811f1e2 DS |
1393 | /* Clear off link-local nexthop in source, whenever it is not needed to |
1394 | * ensure more prefixes share the same attribute for announcement. | |
3f9c7369 DS |
1395 | */ |
1396 | if (!(CHECK_FLAG (peer->af_flags[afi][safi], | |
1397 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED))) | |
1398 | memset (&attr->extra->mp_nexthop_local, 0, IPV6_MAX_BYTELEN); | |
1399 | } | |
1400 | #endif /* HAVE_IPV6 */ | |
1401 | ||
1402 | bgp_peer_remove_private_as(bgp, afi, safi, peer, attr); | |
1403 | bgp_peer_as_override(bgp, afi, safi, peer, attr); | |
1404 | ||
1405 | /* Route map & unsuppress-map apply. */ | |
1406 | if (ROUTE_MAP_OUT_NAME (filter) | |
1407 | || (ri->extra && ri->extra->suppress) ) | |
1408 | { | |
1409 | struct bgp_info info; | |
1410 | struct attr dummy_attr; | |
1411 | struct attr_extra dummy_extra; | |
1412 | ||
1413 | dummy_attr.extra = &dummy_extra; | |
1414 | ||
1415 | info.peer = peer; | |
1416 | info.attr = attr; | |
316e074d DS |
1417 | /* don't confuse inbound and outbound setting */ |
1418 | RESET_FLAG(attr->rmap_change_flags); | |
3f9c7369 DS |
1419 | |
1420 | /* | |
1421 | * The route reflector is not allowed to modify the attributes | |
1422 | * of the reflected IBGP routes unless explicitly allowed. | |
1423 | */ | |
1424 | if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) | |
1425 | && !bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
1426 | { | |
1427 | bgp_attr_dup (&dummy_attr, attr); | |
1428 | info.attr = &dummy_attr; | |
1429 | } | |
1430 | ||
1431 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1432 | ||
1433 | if (ri->extra && ri->extra->suppress) | |
1434 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); | |
1435 | else | |
1436 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1437 | ||
1438 | peer->rmap_type = 0; | |
1439 | ||
1440 | if (ret == RMAP_DENYMATCH) | |
1441 | { | |
1442 | bgp_attr_flush (attr); | |
1443 | return 0; | |
1444 | } | |
1445 | } | |
1446 | ||
1447 | /* After route-map has been applied, we check to see if the nexthop to | |
1448 | * be carried in the attribute (that is used for the announcement) can | |
1449 | * be cleared off or not. We do this in all cases where we would be | |
1450 | * setting the nexthop to "ourselves". For IPv6, we only need to consider | |
1451 | * the global nexthop here; the link-local nexthop would have been cleared | |
1452 | * already, and if not, it is required by the update formation code. | |
1453 | * Also see earlier comments in this function. | |
43fdf718 | 1454 | */ |
3811f1e2 DS |
1455 | /* |
1456 | * If route-map has performed some operation on the nexthop or the peer | |
1457 | * configuration says to pass it unchanged, we cannot reset the nexthop | |
1458 | * here, so only attempt to do it if these aren't true. Note that the | |
1459 | * route-map handler itself might have cleared the nexthop, if for example, | |
1460 | * it is configured as 'peer-address'. | |
3f9c7369 | 1461 | */ |
3811f1e2 DS |
1462 | if (!bgp_rmap_nhop_changed(attr->rmap_change_flags, |
1463 | riattr->rmap_change_flags) && | |
1464 | !transparent && | |
1465 | !CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
3f9c7369 | 1466 | { |
3811f1e2 | 1467 | /* We can reset the nexthop, if setting (or forcing) it to 'self' */ |
88b8ed8d DW |
1468 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || |
1469 | CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
3f9c7369 DS |
1470 | { |
1471 | if (!reflect || | |
1472 | CHECK_FLAG (peer->af_flags[afi][safi], | |
43fdf718 | 1473 | PEER_FLAG_FORCE_NEXTHOP_SELF)) |
3811f1e2 DS |
1474 | subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ? |
1475 | AF_INET6 : p->family), attr); | |
3f9c7369 DS |
1476 | } |
1477 | else if (peer->sort == BGP_PEER_EBGP) | |
1478 | { | |
3811f1e2 DS |
1479 | /* Can also reset the nexthop if announcing to EBGP, but only if |
1480 | * no peer in the subgroup is on a shared subnet. | |
1481 | * Note: 3rd party nexthop currently implemented for IPv4 only. | |
1482 | */ | |
3f9c7369 DS |
1483 | SUBGRP_FOREACH_PEER (subgrp, paf) |
1484 | { | |
1485 | if (bgp_multiaccess_check_v4 (riattr->nexthop, paf->peer)) | |
1486 | break; | |
1487 | } | |
1488 | if (!paf) | |
8a92a8a0 | 1489 | subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ? AF_INET6 : p->family), attr); |
3f9c7369 | 1490 | } |
003c1ba0 | 1491 | /* If IPv6/MP and nexthop does not have any override and happens to |
1492 | * be a link-local address, reset it so that we don't pass along the | |
1493 | * source's link-local IPv6 address to recipients who may not be on | |
1494 | * the same interface. | |
1495 | */ | |
1496 | if (p->family == AF_INET6 || peer_cap_enhe(peer)) | |
1497 | { | |
1498 | if (IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_global)) | |
1499 | subgroup_announce_reset_nhop (AF_INET6, attr); | |
1500 | } | |
3f9c7369 DS |
1501 | } |
1502 | ||
1503 | return 1; | |
1504 | } | |
1505 | ||
fee0f4c6 | 1506 | struct bgp_info_pair |
1507 | { | |
1508 | struct bgp_info *old; | |
1509 | struct bgp_info *new; | |
1510 | }; | |
1511 | ||
94f2b392 | 1512 | static void |
96450faf JB |
1513 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
1514 | struct bgp_maxpaths_cfg *mpath_cfg, | |
1515 | struct bgp_info_pair *result) | |
718e3744 | 1516 | { |
718e3744 | 1517 | struct bgp_info *new_select; |
1518 | struct bgp_info *old_select; | |
fee0f4c6 | 1519 | struct bgp_info *ri; |
718e3744 | 1520 | struct bgp_info *ri1; |
1521 | struct bgp_info *ri2; | |
b40d939b | 1522 | struct bgp_info *nextri = NULL; |
9fbdd100 | 1523 | int paths_eq, do_mpath, debug; |
96450faf | 1524 | struct list mp_list; |
4690c7d7 | 1525 | char pfx_buf[PREFIX2STR_BUFFER]; |
2ec1e66f | 1526 | char path_buf[PATH_ADDPATH_STR_BUFFER]; |
96450faf JB |
1527 | |
1528 | bgp_mp_list_init (&mp_list); | |
99030da1 | 1529 | do_mpath = (mpath_cfg->maxpaths_ebgp > 1 || mpath_cfg->maxpaths_ibgp > 1); |
96450faf | 1530 | |
9fbdd100 DS |
1531 | debug = bgp_debug_bestpath(&rn->p); |
1532 | ||
1533 | if (debug) | |
1534 | prefix2str (&rn->p, pfx_buf, sizeof (pfx_buf)); | |
1535 | ||
718e3744 | 1536 | /* bgp deterministic-med */ |
1537 | new_select = NULL; | |
1538 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
06370dac DW |
1539 | { |
1540 | ||
1541 | /* Clear BGP_INFO_DMED_SELECTED for all paths */ | |
1542 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1543 | bgp_info_unset_flag (rn, ri1, BGP_INFO_DMED_SELECTED); | |
1544 | ||
1545 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1546 | { | |
1547 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) | |
1548 | continue; | |
1549 | if (BGP_INFO_HOLDDOWN (ri1)) | |
2fed8887 | 1550 | continue; |
06370dac DW |
1551 | if (ri1->peer && ri1->peer != bgp->peer_self) |
1552 | if (ri1->peer->status != Established) | |
1553 | continue; | |
718e3744 | 1554 | |
06370dac | 1555 | new_select = ri1; |
06370dac DW |
1556 | if (ri1->next) |
1557 | { | |
1558 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) | |
1559 | { | |
1560 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) | |
1561 | continue; | |
1562 | if (BGP_INFO_HOLDDOWN (ri2)) | |
1563 | continue; | |
1564 | if (ri2->peer && | |
1565 | ri2->peer != bgp->peer_self && | |
1566 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) | |
1567 | if (ri2->peer->status != Established) | |
1568 | continue; | |
1569 | ||
1570 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) | |
1571 | || aspath_cmp_left_confed (ri1->attr->aspath, | |
1572 | ri2->attr->aspath)) | |
1573 | { | |
06370dac DW |
1574 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq, |
1575 | mpath_cfg, debug, pfx_buf)) | |
1576 | { | |
1577 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
1578 | new_select = ri2; | |
1579 | } | |
1580 | ||
1581 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); | |
1582 | } | |
1583 | } | |
1584 | } | |
1585 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); | |
1586 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1587 | |
06370dac | 1588 | if (debug) |
2ec1e66f DW |
1589 | { |
1590 | bgp_info_path_with_addpath_rx_str (new_select, path_buf); | |
1591 | zlog_debug("%s: %s is the bestpath from AS %d", | |
1592 | pfx_buf, path_buf, aspath_get_firstas(new_select->attr->aspath)); | |
1593 | } | |
06370dac DW |
1594 | } |
1595 | } | |
718e3744 | 1596 | |
1597 | /* Check old selected route and new selected route. */ | |
1598 | old_select = NULL; | |
1599 | new_select = NULL; | |
b40d939b | 1600 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
718e3744 | 1601 | { |
1602 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1603 | old_select = ri; | |
1604 | ||
1605 | if (BGP_INFO_HOLDDOWN (ri)) | |
b40d939b | 1606 | { |
1607 | /* reap REMOVED routes, if needs be | |
1608 | * selected route must stay for a while longer though | |
1609 | */ | |
1610 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) | |
1611 | && (ri != old_select)) | |
1612 | bgp_info_reap (rn, ri); | |
1613 | ||
1614 | continue; | |
1615 | } | |
718e3744 | 1616 | |
2fed8887 DS |
1617 | if (ri->peer && |
1618 | ri->peer != bgp->peer_self && | |
1619 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) | |
1620 | if (ri->peer->status != Established) | |
1621 | continue; | |
1622 | ||
718e3744 | 1623 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
1624 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) | |
1625 | { | |
1a392d46 | 1626 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1627 | continue; |
1628 | } | |
06370dac | 1629 | |
1a392d46 | 1630 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1631 | |
9fbdd100 | 1632 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, debug, pfx_buf)) |
96450faf JB |
1633 | { |
1634 | new_select = ri; | |
96450faf | 1635 | } |
718e3744 | 1636 | } |
b40d939b | 1637 | |
f4eeff72 DS |
1638 | /* Now that we know which path is the bestpath see if any of the other paths |
1639 | * qualify as multipaths | |
1640 | */ | |
1641 | if (do_mpath && new_select) | |
1642 | { | |
9fbdd100 | 1643 | if (debug) |
2ec1e66f DW |
1644 | { |
1645 | bgp_info_path_with_addpath_rx_str (new_select, path_buf); | |
1646 | zlog_debug("%s: %s is the bestpath, now find multipaths", pfx_buf, path_buf); | |
1647 | } | |
9fbdd100 | 1648 | |
f4eeff72 DS |
1649 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
1650 | { | |
2ec1e66f DW |
1651 | |
1652 | if (debug) | |
1653 | bgp_info_path_with_addpath_rx_str (ri, path_buf); | |
1654 | ||
f4eeff72 DS |
1655 | if (ri == new_select) |
1656 | { | |
9fbdd100 | 1657 | if (debug) |
2ec1e66f DW |
1658 | zlog_debug("%s: %s is the bestpath, add to the multipath list", |
1659 | pfx_buf, path_buf); | |
3064bf43 | 1660 | bgp_mp_list_add (&mp_list, ri); |
f4eeff72 DS |
1661 | continue; |
1662 | } | |
1663 | ||
1664 | if (BGP_INFO_HOLDDOWN (ri)) | |
1665 | continue; | |
1666 | ||
1667 | if (ri->peer && | |
1668 | ri->peer != bgp->peer_self && | |
1669 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) | |
1670 | if (ri->peer->status != Established) | |
1671 | continue; | |
1672 | ||
7dc9d4e4 DW |
1673 | if (!bgp_info_nexthop_cmp (ri, new_select)) |
1674 | { | |
1675 | if (debug) | |
2ec1e66f DW |
1676 | zlog_debug("%s: %s has the same nexthop as the bestpath, skip it", |
1677 | pfx_buf, path_buf); | |
7dc9d4e4 DW |
1678 | continue; |
1679 | } | |
1680 | ||
9fbdd100 | 1681 | bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, debug, pfx_buf); |
f4eeff72 DS |
1682 | |
1683 | if (paths_eq) | |
1684 | { | |
9fbdd100 | 1685 | if (debug) |
2ec1e66f DW |
1686 | zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list", |
1687 | pfx_buf, path_buf); | |
f4eeff72 DS |
1688 | bgp_mp_list_add (&mp_list, ri); |
1689 | } | |
1690 | } | |
1691 | } | |
fee0f4c6 | 1692 | |
b354c427 | 1693 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
0b597ef0 | 1694 | bgp_info_mpath_aggregate_update (new_select, old_select); |
96450faf JB |
1695 | bgp_mp_list_clear (&mp_list); |
1696 | ||
1697 | result->old = old_select; | |
1698 | result->new = new_select; | |
1699 | ||
1700 | return; | |
fee0f4c6 | 1701 | } |
1702 | ||
3f9c7369 DS |
1703 | /* |
1704 | * A new route/change in bestpath of an existing route. Evaluate the path | |
1705 | * for advertisement to the subgroup. | |
1706 | */ | |
1707 | int | |
1708 | subgroup_process_announce_selected (struct update_subgroup *subgrp, | |
1709 | struct bgp_info *selected, | |
adbac85e DW |
1710 | struct bgp_node *rn, |
1711 | u_int32_t addpath_tx_id) | |
9eda90ce | 1712 | { |
fee0f4c6 | 1713 | struct prefix *p; |
3f9c7369 | 1714 | struct peer *onlypeer; |
558d1fec JBD |
1715 | struct attr attr; |
1716 | struct attr_extra extra; | |
3f9c7369 DS |
1717 | afi_t afi; |
1718 | safi_t safi; | |
fee0f4c6 | 1719 | |
1720 | p = &rn->p; | |
3f9c7369 DS |
1721 | afi = SUBGRP_AFI(subgrp); |
1722 | safi = SUBGRP_SAFI(subgrp); | |
1723 | onlypeer = ((SUBGRP_PCOUNT(subgrp) == 1) ? | |
1724 | (SUBGRP_PFIRST(subgrp))->peer : NULL); | |
718e3744 | 1725 | |
9eda90ce | 1726 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
3f9c7369 DS |
1727 | if (onlypeer && CHECK_FLAG (onlypeer->af_sflags[afi][safi], |
1728 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
fee0f4c6 | 1729 | return 0; |
718e3744 | 1730 | |
2a3d5731 | 1731 | /* It's initialized in bgp_announce_check() */ |
558d1fec JBD |
1732 | attr.extra = &extra; |
1733 | ||
2a3d5731 DW |
1734 | /* Announcement to the subgroup. If the route is filtered withdraw it. */ |
1735 | if (selected) | |
fee0f4c6 | 1736 | { |
2a3d5731 DW |
1737 | if (subgroup_announce_check(selected, subgrp, p, &attr)) |
1738 | bgp_adj_out_set_subgroup(rn, subgrp, &attr, selected); | |
1739 | else | |
1740 | bgp_adj_out_unset_subgroup(rn, subgrp, 1, selected->addpath_tx_id); | |
1741 | } | |
adbac85e | 1742 | |
2a3d5731 DW |
1743 | /* If selected is NULL we must withdraw the path using addpath_tx_id */ |
1744 | else | |
1745 | { | |
1746 | bgp_adj_out_unset_subgroup(rn, subgrp, 1, addpath_tx_id); | |
fee0f4c6 | 1747 | } |
558d1fec | 1748 | |
fee0f4c6 | 1749 | return 0; |
200df115 | 1750 | } |
fee0f4c6 | 1751 | |
3064bf43 | 1752 | /* |
e1072051 | 1753 | * Clear IGP changed flag and attribute changed flag for a route (all paths). |
1754 | * This is called at the end of route processing. | |
3064bf43 | 1755 | */ |
1756 | static void | |
1757 | bgp_zebra_clear_route_change_flags (struct bgp_node *rn) | |
1758 | { | |
1759 | struct bgp_info *ri; | |
1760 | ||
1761 | for (ri = rn->info; ri; ri = ri->next) | |
1762 | { | |
1763 | if (BGP_INFO_HOLDDOWN (ri)) | |
1764 | continue; | |
1765 | UNSET_FLAG (ri->flags, BGP_INFO_IGP_CHANGED); | |
e1072051 | 1766 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
3064bf43 | 1767 | } |
1768 | } | |
1769 | ||
1770 | /* | |
1771 | * Has the route changed from the RIB's perspective? This is invoked only | |
1772 | * if the route selection returns the same best route as earlier - to | |
1773 | * determine if we need to update zebra or not. | |
1774 | */ | |
1775 | static int | |
1776 | bgp_zebra_has_route_changed (struct bgp_node *rn, struct bgp_info *selected) | |
1777 | { | |
1778 | struct bgp_info *mpinfo; | |
1779 | ||
e1072051 | 1780 | /* If this is multipath, check all selected paths for any nexthop change or |
1781 | * attribute change. Some attribute changes (e.g., community) aren't of | |
1782 | * relevance to the RIB, but we'll update zebra to ensure we handle the | |
1783 | * case of BGP nexthop change. This is the behavior when the best path has | |
1784 | * an attribute change anyway. | |
1785 | */ | |
3064bf43 | 1786 | if (CHECK_FLAG (selected->flags, BGP_INFO_IGP_CHANGED) || |
1787 | CHECK_FLAG (selected->flags, BGP_INFO_MULTIPATH_CHG)) | |
1788 | return 1; | |
1789 | ||
1790 | /* If this is multipath, check all selected paths for any nexthop change */ | |
1791 | for (mpinfo = bgp_info_mpath_first (selected); mpinfo; | |
1792 | mpinfo = bgp_info_mpath_next (mpinfo)) | |
1793 | { | |
e1072051 | 1794 | if (CHECK_FLAG (mpinfo->flags, BGP_INFO_IGP_CHANGED) |
1795 | || CHECK_FLAG (mpinfo->flags, BGP_INFO_ATTR_CHANGED)) | |
3064bf43 | 1796 | return 1; |
1797 | } | |
1798 | ||
1799 | /* Nothing has changed from the RIB's perspective. */ | |
1800 | return 0; | |
1801 | } | |
1802 | ||
3f9c7369 | 1803 | struct bgp_process_queue |
fee0f4c6 | 1804 | { |
200df115 | 1805 | struct bgp *bgp; |
1806 | struct bgp_node *rn; | |
1807 | afi_t afi; | |
1808 | safi_t safi; | |
1809 | }; | |
1810 | ||
200df115 | 1811 | static wq_item_status |
0fb58d5d | 1812 | bgp_process_main (struct work_queue *wq, void *data) |
200df115 | 1813 | { |
0fb58d5d | 1814 | struct bgp_process_queue *pq = data; |
200df115 | 1815 | struct bgp *bgp = pq->bgp; |
1816 | struct bgp_node *rn = pq->rn; | |
1817 | afi_t afi = pq->afi; | |
1818 | safi_t safi = pq->safi; | |
1819 | struct prefix *p = &rn->p; | |
fee0f4c6 | 1820 | struct bgp_info *new_select; |
1821 | struct bgp_info *old_select; | |
1822 | struct bgp_info_pair old_and_new; | |
cb1faec9 DS |
1823 | |
1824 | /* Is it end of initial update? (after startup) */ | |
1825 | if (!rn) | |
1826 | { | |
4a16ae86 DS |
1827 | quagga_timestamp(3, bgp->update_delay_zebra_resume_time, |
1828 | sizeof(bgp->update_delay_zebra_resume_time)); | |
1829 | ||
1830 | bgp->main_zebra_update_hold = 0; | |
1831 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1832 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1833 | { | |
1834 | bgp_zebra_announce_table(bgp, afi, safi); | |
1835 | } | |
1836 | bgp->main_peers_update_hold = 0; | |
1837 | ||
cb1faec9 DS |
1838 | bgp_start_routeadv(bgp); |
1839 | return WQ_SUCCESS; | |
1840 | } | |
1841 | ||
fee0f4c6 | 1842 | /* Best path selection. */ |
96450faf | 1843 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
fee0f4c6 | 1844 | old_select = old_and_new.old; |
1845 | new_select = old_and_new.new; | |
1846 | ||
1847 | /* Nothing to do. */ | |
adbac85e DW |
1848 | if (old_select && old_select == new_select && |
1849 | !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR) && | |
1850 | !CHECK_FLAG(old_select->flags, BGP_INFO_ATTR_CHANGED) && | |
1851 | !bgp->addpath_tx_used[afi][safi]) | |
1852 | { | |
3064bf43 | 1853 | if (bgp_zebra_has_route_changed (rn, old_select)) |
adbac85e | 1854 | bgp_zebra_announce (p, old_select, bgp, afi, safi); |
200df115 | 1855 | |
adbac85e | 1856 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
3064bf43 | 1857 | bgp_zebra_clear_route_change_flags (rn); |
adbac85e DW |
1858 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1859 | return WQ_SUCCESS; | |
fee0f4c6 | 1860 | } |
1861 | ||
8ad7271d DS |
1862 | /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */ |
1863 | UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
1864 | ||
3f9c7369 DS |
1865 | /* bestpath has changed; bump version */ |
1866 | if (old_select || new_select) | |
0de4848d DS |
1867 | { |
1868 | bgp_bump_version(rn); | |
1869 | ||
1870 | if (!bgp->t_rmap_def_originate_eval) | |
1871 | { | |
1872 | bgp_lock (bgp); | |
9229d914 | 1873 | THREAD_TIMER_ON(bm->master, bgp->t_rmap_def_originate_eval, |
0de4848d DS |
1874 | update_group_refresh_default_originate_route_map, |
1875 | bgp, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER); | |
1876 | } | |
1877 | } | |
3f9c7369 | 1878 | |
338b3424 | 1879 | if (old_select) |
1a392d46 | 1880 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
338b3424 | 1881 | if (new_select) |
1882 | { | |
1a392d46 PJ |
1883 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1884 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
8196f13d | 1885 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
338b3424 | 1886 | } |
1887 | ||
3f9c7369 | 1888 | group_announce_route(bgp, afi, safi, rn, new_select); |
718e3744 | 1889 | |
1890 | /* FIB update. */ | |
ad4cbda1 | 1891 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && |
1892 | (bgp->inst_type != BGP_INSTANCE_TYPE_VIEW) && | |
1893 | !bgp_option_check (BGP_OPT_NO_FIB)) | |
718e3744 | 1894 | { |
1895 | if (new_select | |
1896 | && new_select->type == ZEBRA_ROUTE_BGP | |
f992e2a9 DS |
1897 | && (new_select->sub_type == BGP_ROUTE_NORMAL || |
1898 | new_select->sub_type == BGP_ROUTE_AGGREGATE)) | |
73ac8160 | 1899 | bgp_zebra_announce (p, new_select, bgp, afi, safi); |
718e3744 | 1900 | else |
1901 | { | |
1902 | /* Withdraw the route from the kernel. */ | |
1903 | if (old_select | |
1904 | && old_select->type == ZEBRA_ROUTE_BGP | |
f992e2a9 DS |
1905 | && (old_select->sub_type == BGP_ROUTE_NORMAL || |
1906 | old_select->sub_type == BGP_ROUTE_AGGREGATE)) | |
5a616c08 | 1907 | bgp_zebra_withdraw (p, old_select, safi); |
718e3744 | 1908 | } |
1909 | } | |
3064bf43 | 1910 | |
1911 | /* Clear any route change flags. */ | |
1912 | bgp_zebra_clear_route_change_flags (rn); | |
1913 | ||
adbac85e | 1914 | /* Reap old select bgp_info, if it has been removed */ |
b40d939b | 1915 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
1916 | bgp_info_reap (rn, old_select); | |
1917 | ||
200df115 | 1918 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1919 | return WQ_SUCCESS; | |
718e3744 | 1920 | } |
1921 | ||
200df115 | 1922 | static void |
0fb58d5d | 1923 | bgp_processq_del (struct work_queue *wq, void *data) |
200df115 | 1924 | { |
0fb58d5d | 1925 | struct bgp_process_queue *pq = data; |
cb1faec9 DS |
1926 | struct bgp_table *table; |
1927 | ||
228da428 | 1928 | bgp_unlock (pq->bgp); |
cb1faec9 DS |
1929 | if (pq->rn) |
1930 | { | |
1931 | table = bgp_node_table (pq->rn); | |
1932 | bgp_unlock_node (pq->rn); | |
1933 | bgp_table_unlock (table); | |
1934 | } | |
200df115 | 1935 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
1936 | } | |
1937 | ||
f188f2c4 | 1938 | void |
200df115 | 1939 | bgp_process_queue_init (void) |
1940 | { | |
495f0b13 DS |
1941 | if (!bm->process_main_queue) |
1942 | { | |
1943 | bm->process_main_queue | |
87d4a781 | 1944 | = work_queue_new (bm->master, "process_main_queue"); |
495f0b13 | 1945 | |
2a3d5731 DW |
1946 | if ( !bm->process_main_queue) |
1947 | { | |
1948 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
1949 | exit (1); | |
1950 | } | |
200df115 | 1951 | } |
1952 | ||
1953 | bm->process_main_queue->spec.workfunc = &bgp_process_main; | |
200df115 | 1954 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
838bbde0 PJ |
1955 | bm->process_main_queue->spec.max_retries = 0; |
1956 | bm->process_main_queue->spec.hold = 50; | |
d889623f DS |
1957 | /* Use a higher yield value of 50ms for main queue processing */ |
1958 | bm->process_main_queue->spec.yield = 50 * 1000L; | |
200df115 | 1959 | } |
1960 | ||
1961 | void | |
fee0f4c6 | 1962 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
1963 | { | |
200df115 | 1964 | struct bgp_process_queue *pqnode; |
1965 | ||
1966 | /* already scheduled for processing? */ | |
1967 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) | |
1968 | return; | |
495f0b13 | 1969 | |
2a3d5731 | 1970 | if (bm->process_main_queue == NULL) |
2e02b9b2 DS |
1971 | bgp_process_queue_init (); |
1972 | ||
200df115 | 1973 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
1974 | sizeof (struct bgp_process_queue)); | |
1975 | if (!pqnode) | |
1976 | return; | |
228da428 CC |
1977 | |
1978 | /* all unlocked in bgp_processq_del */ | |
67174041 | 1979 | bgp_table_lock (bgp_node_table (rn)); |
228da428 | 1980 | pqnode->rn = bgp_lock_node (rn); |
200df115 | 1981 | pqnode->bgp = bgp; |
228da428 | 1982 | bgp_lock (bgp); |
200df115 | 1983 | pqnode->afi = afi; |
1984 | pqnode->safi = safi; | |
2a3d5731 | 1985 | work_queue_add (bm->process_main_queue, pqnode); |
07ff4dc4 | 1986 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
200df115 | 1987 | return; |
fee0f4c6 | 1988 | } |
0a486e5f | 1989 | |
cb1faec9 | 1990 | void |
2a3d5731 | 1991 | bgp_add_eoiu_mark (struct bgp *bgp) |
cb1faec9 DS |
1992 | { |
1993 | struct bgp_process_queue *pqnode; | |
1994 | ||
2a3d5731 | 1995 | if (bm->process_main_queue == NULL) |
2e02b9b2 DS |
1996 | bgp_process_queue_init (); |
1997 | ||
cb1faec9 DS |
1998 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
1999 | sizeof (struct bgp_process_queue)); | |
2000 | if (!pqnode) | |
2001 | return; | |
2002 | ||
2003 | pqnode->rn = NULL; | |
2004 | pqnode->bgp = bgp; | |
2005 | bgp_lock (bgp); | |
2a3d5731 | 2006 | work_queue_add (bm->process_main_queue, pqnode); |
cb1faec9 DS |
2007 | } |
2008 | ||
94f2b392 | 2009 | static int |
0a486e5f | 2010 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
2011 | { | |
2012 | struct peer *peer; | |
2013 | ||
2014 | peer = THREAD_ARG (thread); | |
2015 | peer->t_pmax_restart = NULL; | |
2016 | ||
16286195 | 2017 | if (bgp_debug_neighbor_events(peer)) |
0a486e5f | 2018 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
2019 | peer->host); | |
2020 | ||
1ff9a340 | 2021 | peer_clear (peer, NULL); |
0a486e5f | 2022 | |
2023 | return 0; | |
2024 | } | |
2025 | ||
718e3744 | 2026 | int |
5228ad27 | 2027 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
2028 | safi_t safi, int always) | |
718e3744 | 2029 | { |
e0701b79 | 2030 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
2031 | return 0; | |
2032 | ||
2033 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) | |
718e3744 | 2034 | { |
e0701b79 | 2035 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
2036 | && ! always) | |
2037 | return 0; | |
2038 | ||
16286195 DS |
2039 | zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
2040 | "limit %ld", afi_safi_print (afi, safi), peer->host, | |
2041 | peer->pcount[afi][safi], peer->pmax[afi][safi]); | |
e0701b79 | 2042 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
2043 | ||
2044 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
2045 | return 0; | |
2046 | ||
2047 | { | |
5228ad27 | 2048 | u_int8_t ndata[7]; |
e0701b79 | 2049 | |
2050 | if (safi == SAFI_MPLS_VPN) | |
42e6d745 | 2051 | safi = SAFI_MPLS_LABELED_VPN; |
5228ad27 | 2052 | |
2053 | ndata[0] = (afi >> 8); | |
2054 | ndata[1] = afi; | |
2055 | ndata[2] = safi; | |
2056 | ndata[3] = (peer->pmax[afi][safi] >> 24); | |
2057 | ndata[4] = (peer->pmax[afi][safi] >> 16); | |
2058 | ndata[5] = (peer->pmax[afi][safi] >> 8); | |
2059 | ndata[6] = (peer->pmax[afi][safi]); | |
e0701b79 | 2060 | |
2061 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); | |
2062 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, | |
2063 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); | |
2064 | } | |
0a486e5f | 2065 | |
f14e6fdb DS |
2066 | /* Dynamic peers will just close their connection. */ |
2067 | if (peer_dynamic_neighbor (peer)) | |
2068 | return 1; | |
2069 | ||
0a486e5f | 2070 | /* restart timer start */ |
2071 | if (peer->pmax_restart[afi][safi]) | |
2072 | { | |
2073 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; | |
2074 | ||
16286195 | 2075 | if (bgp_debug_neighbor_events(peer)) |
0a486e5f | 2076 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
2077 | peer->host, peer->v_pmax_restart); | |
2078 | ||
2079 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, | |
2080 | peer->v_pmax_restart); | |
2081 | } | |
2082 | ||
e0701b79 | 2083 | return 1; |
2084 | } | |
2085 | else | |
2086 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); | |
2087 | ||
2088 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) | |
2089 | { | |
2090 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) | |
2091 | && ! always) | |
2092 | return 0; | |
2093 | ||
16286195 DS |
2094 | zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
2095 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], | |
2096 | peer->pmax[afi][safi]); | |
e0701b79 | 2097 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
718e3744 | 2098 | } |
e0701b79 | 2099 | else |
2100 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); | |
718e3744 | 2101 | return 0; |
2102 | } | |
2103 | ||
b40d939b | 2104 | /* Unconditionally remove the route from the RIB, without taking |
2105 | * damping into consideration (eg, because the session went down) | |
2106 | */ | |
94f2b392 | 2107 | static void |
718e3744 | 2108 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
2109 | afi_t afi, safi_t safi) | |
2110 | { | |
902212c3 | 2111 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
2112 | ||
2113 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2114 | bgp_info_delete (rn, ri); /* keep historical info */ | |
2115 | ||
b40d939b | 2116 | bgp_process (peer->bgp, rn, afi, safi); |
718e3744 | 2117 | } |
2118 | ||
94f2b392 | 2119 | static void |
718e3744 | 2120 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
b40d939b | 2121 | afi_t afi, safi_t safi) |
718e3744 | 2122 | { |
718e3744 | 2123 | int status = BGP_DAMP_NONE; |
2124 | ||
b40d939b | 2125 | /* apply dampening, if result is suppressed, we'll be retaining |
2126 | * the bgp_info in the RIB for historical reference. | |
2127 | */ | |
2128 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2129 | && peer->sort == BGP_PEER_EBGP) |
b40d939b | 2130 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
2131 | == BGP_DAMP_SUPPRESSED) | |
902212c3 | 2132 | { |
902212c3 | 2133 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
2134 | return; | |
2135 | } | |
2136 | ||
2137 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
718e3744 | 2138 | } |
2139 | ||
fb018d25 | 2140 | static struct bgp_info * |
7c8ff89e | 2141 | info_make (int type, int sub_type, u_short instance, struct peer *peer, struct attr *attr, |
fb018d25 DS |
2142 | struct bgp_node *rn) |
2143 | { | |
2144 | struct bgp_info *new; | |
2145 | ||
2146 | /* Make new BGP info. */ | |
2147 | new = XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); | |
2148 | new->type = type; | |
7c8ff89e | 2149 | new->instance = instance; |
fb018d25 DS |
2150 | new->sub_type = sub_type; |
2151 | new->peer = peer; | |
2152 | new->attr = attr; | |
2153 | new->uptime = bgp_clock (); | |
2154 | new->net = rn; | |
adbac85e | 2155 | new->addpath_tx_id = ++peer->bgp->addpath_tx_id; |
fb018d25 DS |
2156 | return new; |
2157 | } | |
2158 | ||
94f2b392 | 2159 | static void |
2ec1e66f | 2160 | bgp_info_addpath_rx_str(u_int32_t addpath_id, char *buf) |
cd808e74 | 2161 | { |
2ec1e66f DW |
2162 | if (addpath_id) |
2163 | sprintf(buf, " with addpath ID %d", addpath_id); | |
cd808e74 DS |
2164 | } |
2165 | ||
2ec1e66f | 2166 | |
c265ee22 DS |
2167 | /* Check if received nexthop is valid or not. */ |
2168 | static int | |
6aeb9e78 | 2169 | bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr *attr) |
c265ee22 DS |
2170 | { |
2171 | struct attr_extra *attre = attr->extra; | |
2172 | int ret = 0; | |
2173 | ||
2174 | /* Only validated for unicast and multicast currently. */ | |
2175 | if (safi != SAFI_UNICAST && safi != SAFI_MULTICAST) | |
2176 | return 0; | |
2177 | ||
2178 | /* If NEXT_HOP is present, validate it. */ | |
2179 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)) | |
2180 | { | |
2181 | if (attr->nexthop.s_addr == 0 || | |
2182 | IPV4_CLASS_DE (ntohl (attr->nexthop.s_addr)) || | |
6aeb9e78 | 2183 | bgp_nexthop_self (bgp, attr)) |
c265ee22 DS |
2184 | ret = 1; |
2185 | } | |
2186 | ||
2187 | /* If MP_NEXTHOP is present, validate it. */ | |
2188 | /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop; | |
2189 | * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if | |
2190 | * it is not an IPv6 link-local address. | |
2191 | */ | |
2192 | if (attre && attre->mp_nexthop_len) | |
2193 | { | |
2194 | switch (attre->mp_nexthop_len) | |
2195 | { | |
2196 | case BGP_ATTR_NHLEN_IPV4: | |
2197 | case BGP_ATTR_NHLEN_VPNV4: | |
2198 | ret = (attre->mp_nexthop_global_in.s_addr == 0 || | |
2199 | IPV4_CLASS_DE (ntohl (attre->mp_nexthop_global_in.s_addr))); | |
2200 | break; | |
2201 | ||
2202 | #ifdef HAVE_IPV6 | |
2203 | case BGP_ATTR_NHLEN_IPV6_GLOBAL: | |
2204 | case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: | |
2205 | ret = (IN6_IS_ADDR_UNSPECIFIED(&attre->mp_nexthop_global) || | |
2206 | IN6_IS_ADDR_LOOPBACK(&attre->mp_nexthop_global) || | |
2207 | IN6_IS_ADDR_MULTICAST(&attre->mp_nexthop_global)); | |
2208 | break; | |
2209 | #endif /* HAVE_IPV6 */ | |
2210 | ||
2211 | default: | |
2212 | ret = 1; | |
2213 | break; | |
2214 | } | |
2215 | } | |
2216 | ||
2217 | return ret; | |
2218 | } | |
2219 | ||
a7ee645d DS |
2220 | int |
2221 | bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, | |
2222 | struct attr *attr, afi_t afi, safi_t safi, int type, | |
2223 | int sub_type, struct prefix_rd *prd, u_char *tag, | |
2224 | int soft_reconfig) | |
718e3744 | 2225 | { |
2226 | int ret; | |
2227 | int aspath_loop_count = 0; | |
2228 | struct bgp_node *rn; | |
2229 | struct bgp *bgp; | |
558d1fec JBD |
2230 | struct attr new_attr; |
2231 | struct attr_extra new_extra; | |
718e3744 | 2232 | struct attr *attr_new; |
2233 | struct bgp_info *ri; | |
2234 | struct bgp_info *new; | |
fd79ac91 | 2235 | const char *reason; |
718e3744 | 2236 | char buf[SU_ADDRSTRLEN]; |
cd808e74 | 2237 | char buf2[30]; |
fc9a856f | 2238 | int connected = 0; |
718e3744 | 2239 | |
2240 | bgp = peer->bgp; | |
fee0f4c6 | 2241 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
fb982c25 | 2242 | |
718e3744 | 2243 | /* When peer's soft reconfiguration enabled. Record input packet in |
2244 | Adj-RIBs-In. */ | |
343aa822 JBD |
2245 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
2246 | && peer != bgp->peer_self) | |
43143c8f | 2247 | bgp_adj_in_set (rn, peer, attr, addpath_id); |
718e3744 | 2248 | |
2249 | /* Check previously received route. */ | |
2250 | for (ri = rn->info; ri; ri = ri->next) | |
a82478b9 DS |
2251 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type && |
2252 | ri->addpath_rx_id == addpath_id) | |
718e3744 | 2253 | break; |
2254 | ||
2255 | /* AS path local-as loop check. */ | |
2256 | if (peer->change_local_as) | |
2257 | { | |
2258 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
2259 | aspath_loop_count = 1; | |
2260 | ||
2261 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) | |
2262 | { | |
2263 | reason = "as-path contains our own AS;"; | |
2264 | goto filtered; | |
2265 | } | |
2266 | } | |
2267 | ||
2268 | /* AS path loop check. */ | |
2269 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] | |
2270 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
2271 | && aspath_loop_check(attr->aspath, bgp->confed_id) | |
2272 | > peer->allowas_in[afi][safi])) | |
2273 | { | |
2274 | reason = "as-path contains our own AS;"; | |
2275 | goto filtered; | |
2276 | } | |
2277 | ||
2278 | /* Route reflector originator ID check. */ | |
2279 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 2280 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
718e3744 | 2281 | { |
2282 | reason = "originator is us;"; | |
2283 | goto filtered; | |
2284 | } | |
2285 | ||
2286 | /* Route reflector cluster ID check. */ | |
2287 | if (bgp_cluster_filter (peer, attr)) | |
2288 | { | |
2289 | reason = "reflected from the same cluster;"; | |
2290 | goto filtered; | |
2291 | } | |
2292 | ||
2293 | /* Apply incoming filter. */ | |
2294 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) | |
2295 | { | |
2296 | reason = "filter;"; | |
2297 | goto filtered; | |
2298 | } | |
2299 | ||
558d1fec | 2300 | new_attr.extra = &new_extra; |
fb982c25 | 2301 | bgp_attr_dup (&new_attr, attr); |
718e3744 | 2302 | |
c460e572 DL |
2303 | /* Apply incoming route-map. |
2304 | * NB: new_attr may now contain newly allocated values from route-map "set" | |
2305 | * commands, so we need bgp_attr_flush in the error paths, until we intern | |
2306 | * the attr (which takes over the memory references) */ | |
0b16f239 | 2307 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi, NULL) == RMAP_DENY) |
718e3744 | 2308 | { |
2309 | reason = "route-map;"; | |
c460e572 | 2310 | bgp_attr_flush (&new_attr); |
718e3744 | 2311 | goto filtered; |
2312 | } | |
2313 | ||
c265ee22 | 2314 | /* next hop check. */ |
6aeb9e78 | 2315 | if (bgp_update_martian_nexthop (bgp, afi, safi, &new_attr)) |
718e3744 | 2316 | { |
c265ee22 DS |
2317 | reason = "martian or self next-hop;"; |
2318 | bgp_attr_flush (&new_attr); | |
2319 | goto filtered; | |
718e3744 | 2320 | } |
2321 | ||
2322 | attr_new = bgp_attr_intern (&new_attr); | |
2323 | ||
2324 | /* If the update is implicit withdraw. */ | |
2325 | if (ri) | |
2326 | { | |
65957886 | 2327 | ri->uptime = bgp_clock (); |
718e3744 | 2328 | |
2329 | /* Same attribute comes in. */ | |
16d2e241 PJ |
2330 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
2331 | && attrhash_cmp (ri->attr, attr_new)) | |
718e3744 | 2332 | { |
718e3744 | 2333 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
6d85b15b | 2334 | && peer->sort == BGP_PEER_EBGP |
718e3744 | 2335 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2336 | { | |
3f9c7369 | 2337 | if (bgp_debug_update(peer, p, NULL, 1)) |
cd808e74 | 2338 | { |
2ec1e66f | 2339 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2340 | zlog_debug ("%s rcvd %s/%d%s", |
16286195 DS |
2341 | peer->host, |
2342 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 DS |
2343 | p->prefixlen, buf2); |
2344 | } | |
718e3744 | 2345 | |
902212c3 | 2346 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
2347 | { | |
2348 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2349 | bgp_process (bgp, rn, afi, safi); | |
2350 | } | |
718e3744 | 2351 | } |
16d2e241 | 2352 | else /* Duplicate - odd */ |
718e3744 | 2353 | { |
3f9c7369 | 2354 | if (bgp_debug_update(peer, p, NULL, 1)) |
16286195 DS |
2355 | { |
2356 | if (!peer->rcvd_attr_printed) | |
2357 | { | |
2358 | zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str); | |
2359 | peer->rcvd_attr_printed = 1; | |
2360 | } | |
2361 | ||
2ec1e66f | 2362 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2363 | zlog_debug ("%s rcvd %s/%d%s...duplicate ignored", |
16286195 DS |
2364 | peer->host, |
2365 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 | 2366 | p->prefixlen, buf2); |
16286195 | 2367 | } |
93406d87 | 2368 | |
2369 | /* graceful restart STALE flag unset. */ | |
2370 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2371 | { | |
1a392d46 | 2372 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
902212c3 | 2373 | bgp_process (bgp, rn, afi, safi); |
93406d87 | 2374 | } |
718e3744 | 2375 | } |
2376 | ||
2377 | bgp_unlock_node (rn); | |
f6f434b2 | 2378 | bgp_attr_unintern (&attr_new); |
558d1fec | 2379 | |
718e3744 | 2380 | return 0; |
2381 | } | |
2382 | ||
16d2e241 PJ |
2383 | /* Withdraw/Announce before we fully processed the withdraw */ |
2384 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
2385 | { | |
3f9c7369 | 2386 | if (bgp_debug_update(peer, p, NULL, 1)) |
cd808e74 | 2387 | { |
2ec1e66f | 2388 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 DS |
2389 | zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing", |
2390 | peer->host, | |
2391 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2392 | p->prefixlen, buf2); | |
2393 | } | |
16d2e241 PJ |
2394 | bgp_info_restore (rn, ri); |
2395 | } | |
2396 | ||
718e3744 | 2397 | /* Received Logging. */ |
3f9c7369 | 2398 | if (bgp_debug_update(peer, p, NULL, 1)) |
cd808e74 | 2399 | { |
2ec1e66f | 2400 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2401 | zlog_debug ("%s rcvd %s/%d%s", |
16286195 DS |
2402 | peer->host, |
2403 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 DS |
2404 | p->prefixlen, buf2); |
2405 | } | |
718e3744 | 2406 | |
93406d87 | 2407 | /* graceful restart STALE flag unset. */ |
2408 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
1a392d46 | 2409 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
93406d87 | 2410 | |
718e3744 | 2411 | /* The attribute is changed. */ |
1a392d46 | 2412 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
902212c3 | 2413 | |
2414 | /* implicit withdraw, decrement aggregate and pcount here. | |
2415 | * only if update is accepted, they'll increment below. | |
2416 | */ | |
902212c3 | 2417 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
2418 | ||
718e3744 | 2419 | /* Update bgp route dampening information. */ |
2420 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2421 | && peer->sort == BGP_PEER_EBGP) |
718e3744 | 2422 | { |
2423 | /* This is implicit withdraw so we should update dampening | |
2424 | information. */ | |
2425 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2426 | bgp_damp_withdraw (ri, rn, afi, safi, 1); | |
718e3744 | 2427 | } |
2428 | ||
718e3744 | 2429 | /* Update to new attribute. */ |
f6f434b2 | 2430 | bgp_attr_unintern (&ri->attr); |
718e3744 | 2431 | ri->attr = attr_new; |
2432 | ||
2433 | /* Update MPLS tag. */ | |
2434 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2435 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
718e3744 | 2436 | |
2437 | /* Update bgp route dampening information. */ | |
2438 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2439 | && peer->sort == BGP_PEER_EBGP) |
718e3744 | 2440 | { |
2441 | /* Now we do normal update dampening. */ | |
2442 | ret = bgp_damp_update (ri, rn, afi, safi); | |
2443 | if (ret == BGP_DAMP_SUPPRESSED) | |
2444 | { | |
2445 | bgp_unlock_node (rn); | |
2446 | return 0; | |
2447 | } | |
2448 | } | |
2449 | ||
2450 | /* Nexthop reachability check. */ | |
fc9a856f | 2451 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
718e3744 | 2452 | { |
fc9a856f | 2453 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 && |
907f92c8 DS |
2454 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) |
2455 | && ! bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
fc9a856f DS |
2456 | connected = 1; |
2457 | else | |
2458 | connected = 0; | |
2459 | ||
75aead62 | 2460 | if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, connected)) |
1a392d46 | 2461 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2462 | else |
fc9a856f DS |
2463 | { |
2464 | if (BGP_DEBUG(nht, NHT)) | |
2465 | { | |
2466 | char buf1[INET6_ADDRSTRLEN]; | |
2467 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN); | |
2468 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); | |
2469 | } | |
2470 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); | |
2471 | } | |
718e3744 | 2472 | } |
2473 | else | |
fc9a856f | 2474 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2475 | |
2476 | /* Process change. */ | |
2477 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2478 | ||
2479 | bgp_process (bgp, rn, afi, safi); | |
2480 | bgp_unlock_node (rn); | |
558d1fec | 2481 | |
718e3744 | 2482 | return 0; |
a82478b9 | 2483 | } // End of implicit withdraw |
718e3744 | 2484 | |
2485 | /* Received Logging. */ | |
3f9c7369 | 2486 | if (bgp_debug_update(peer, p, NULL, 1)) |
718e3744 | 2487 | { |
16286195 DS |
2488 | if (!peer->rcvd_attr_printed) |
2489 | { | |
2490 | zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str); | |
2491 | peer->rcvd_attr_printed = 1; | |
2492 | } | |
2493 | ||
2ec1e66f | 2494 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2495 | zlog_debug ("%s rcvd %s/%d%s", |
16286195 DS |
2496 | peer->host, |
2497 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 | 2498 | p->prefixlen, buf2); |
718e3744 | 2499 | } |
2500 | ||
718e3744 | 2501 | /* Make new BGP info. */ |
7c8ff89e | 2502 | new = info_make(type, sub_type, 0, peer, attr_new, rn); |
718e3744 | 2503 | |
2504 | /* Update MPLS tag. */ | |
2505 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2506 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
718e3744 | 2507 | |
2508 | /* Nexthop reachability check. */ | |
fc9a856f DS |
2509 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
2510 | { | |
2511 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 && | |
907f92c8 DS |
2512 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) |
2513 | && ! bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
fc9a856f DS |
2514 | connected = 1; |
2515 | else | |
2516 | connected = 0; | |
2517 | ||
75aead62 | 2518 | if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, connected)) |
1a392d46 | 2519 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2520 | else |
fc9a856f DS |
2521 | { |
2522 | if (BGP_DEBUG(nht, NHT)) | |
2523 | { | |
2524 | char buf1[INET6_ADDRSTRLEN]; | |
2525 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN); | |
2526 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); | |
2527 | } | |
2528 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); | |
2529 | } | |
718e3744 | 2530 | } |
2531 | else | |
1a392d46 | 2532 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2533 | |
a82478b9 DS |
2534 | /* Addpath ID */ |
2535 | new->addpath_rx_id = addpath_id; | |
a82478b9 | 2536 | |
902212c3 | 2537 | /* Increment prefix */ |
718e3744 | 2538 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
2539 | ||
2540 | /* Register new BGP information. */ | |
2541 | bgp_info_add (rn, new); | |
200df115 | 2542 | |
2543 | /* route_node_get lock */ | |
2544 | bgp_unlock_node (rn); | |
558d1fec | 2545 | |
718e3744 | 2546 | /* If maximum prefix count is configured and current prefix |
2547 | count exeed it. */ | |
e0701b79 | 2548 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
2549 | return -1; | |
718e3744 | 2550 | |
2551 | /* Process change. */ | |
2552 | bgp_process (bgp, rn, afi, safi); | |
2553 | ||
2554 | return 0; | |
2555 | ||
2556 | /* This BGP update is filtered. Log the reason then update BGP | |
2557 | entry. */ | |
2558 | filtered: | |
3f9c7369 | 2559 | if (bgp_debug_update(peer, p, NULL, 1)) |
16286195 DS |
2560 | { |
2561 | if (!peer->rcvd_attr_printed) | |
2562 | { | |
2563 | zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str); | |
2564 | peer->rcvd_attr_printed = 1; | |
2565 | } | |
2566 | ||
2ec1e66f | 2567 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2568 | zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s", |
16286195 DS |
2569 | peer->host, |
2570 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 | 2571 | p->prefixlen, buf2, reason); |
16286195 | 2572 | } |
718e3744 | 2573 | |
2574 | if (ri) | |
b40d939b | 2575 | bgp_rib_remove (rn, ri, peer, afi, safi); |
718e3744 | 2576 | |
2577 | bgp_unlock_node (rn); | |
558d1fec | 2578 | |
718e3744 | 2579 | return 0; |
2580 | } | |
2581 | ||
2582 | int | |
a82478b9 DS |
2583 | bgp_withdraw (struct peer *peer, struct prefix *p, u_int32_t addpath_id, |
2584 | struct attr *attr, afi_t afi, safi_t safi, int type, int sub_type, | |
2585 | struct prefix_rd *prd, u_char *tag) | |
718e3744 | 2586 | { |
2587 | struct bgp *bgp; | |
2588 | char buf[SU_ADDRSTRLEN]; | |
cd808e74 | 2589 | char buf2[30]; |
718e3744 | 2590 | struct bgp_node *rn; |
2591 | struct bgp_info *ri; | |
2592 | ||
2593 | bgp = peer->bgp; | |
2594 | ||
718e3744 | 2595 | /* Lookup node. */ |
fee0f4c6 | 2596 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 2597 | |
2598 | /* If peer is soft reconfiguration enabled. Record input packet for | |
6b87f736 DL |
2599 | * further calculation. |
2600 | * | |
2601 | * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all | |
2602 | * routes that are filtered. This tanks out Quagga RS pretty badly due to | |
2603 | * the iteration over all RS clients. | |
2604 | * Since we need to remove the entry from adj_in anyway, do that first and | |
2605 | * if there was no entry, we don't need to do anything more. | |
2606 | */ | |
718e3744 | 2607 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
2608 | && peer != bgp->peer_self) | |
6b87f736 DL |
2609 | if (!bgp_adj_in_unset (rn, peer, addpath_id)) |
2610 | { | |
2611 | if (bgp_debug_update (peer, p, NULL, 1)) | |
2612 | zlog_debug ("%s withdrawing route %s/%d " | |
2613 | "not in adj-in", peer->host, | |
2614 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2615 | p->prefixlen); | |
2616 | bgp_unlock_node (rn); | |
2617 | return 0; | |
2618 | } | |
718e3744 | 2619 | |
2620 | /* Lookup withdrawn route. */ | |
2621 | for (ri = rn->info; ri; ri = ri->next) | |
a82478b9 DS |
2622 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type && |
2623 | ri->addpath_rx_id == addpath_id) | |
718e3744 | 2624 | break; |
2625 | ||
cd808e74 DS |
2626 | /* Logging. */ |
2627 | if (bgp_debug_update(peer, p, NULL, 1)) | |
2628 | { | |
2ec1e66f | 2629 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 DS |
2630 | zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn", |
2631 | peer->host, | |
2632 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2633 | p->prefixlen, buf2); | |
2634 | } | |
2635 | ||
718e3744 | 2636 | /* Withdraw specified route from routing table. */ |
2637 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2638 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
3f9c7369 | 2639 | else if (bgp_debug_update(peer, p, NULL, 1)) |
16286195 DS |
2640 | zlog_debug ("%s Can't find the route %s/%d", peer->host, |
2641 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2642 | p->prefixlen); | |
718e3744 | 2643 | |
2644 | /* Unlock bgp_node_get() lock. */ | |
2645 | bgp_unlock_node (rn); | |
2646 | ||
2647 | return 0; | |
2648 | } | |
6b0655a2 | 2649 | |
718e3744 | 2650 | void |
2651 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) | |
2652 | { | |
3f9c7369 DS |
2653 | struct update_subgroup *subgrp; |
2654 | subgrp = peer_subgroup(peer, afi, safi); | |
2655 | subgroup_default_originate(subgrp, withdraw); | |
2656 | } | |
6182d65b | 2657 | |
718e3744 | 2658 | |
3f9c7369 DS |
2659 | /* |
2660 | * bgp_stop_announce_route_timer | |
2661 | */ | |
2662 | void | |
2663 | bgp_stop_announce_route_timer (struct peer_af *paf) | |
2664 | { | |
2665 | if (!paf->t_announce_route) | |
2666 | return; | |
718e3744 | 2667 | |
3f9c7369 | 2668 | THREAD_TIMER_OFF (paf->t_announce_route); |
718e3744 | 2669 | } |
6b0655a2 | 2670 | |
3f9c7369 DS |
2671 | /* |
2672 | * bgp_announce_route_timer_expired | |
2673 | * | |
2674 | * Callback that is invoked when the route announcement timer for a | |
2675 | * peer_af expires. | |
2676 | */ | |
2677 | static int | |
2678 | bgp_announce_route_timer_expired (struct thread *t) | |
718e3744 | 2679 | { |
3f9c7369 DS |
2680 | struct peer_af *paf; |
2681 | struct peer *peer; | |
558d1fec | 2682 | |
3f9c7369 DS |
2683 | paf = THREAD_ARG (t); |
2684 | peer = paf->peer; | |
718e3744 | 2685 | |
3f9c7369 DS |
2686 | assert (paf->t_announce_route); |
2687 | paf->t_announce_route = NULL; | |
558d1fec | 2688 | |
3f9c7369 DS |
2689 | if (peer->status != Established) |
2690 | return 0; | |
2691 | ||
2692 | if (!peer->afc_nego[paf->afi][paf->safi]) | |
2693 | return 0; | |
2694 | ||
2695 | peer_af_announce_route (paf, 1); | |
2696 | return 0; | |
718e3744 | 2697 | } |
2698 | ||
3f9c7369 DS |
2699 | /* |
2700 | * bgp_announce_route | |
2701 | * | |
2702 | * *Triggers* announcement of routes of a given AFI/SAFI to a peer. | |
2703 | */ | |
718e3744 | 2704 | void |
2705 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) | |
2706 | { | |
3f9c7369 DS |
2707 | struct peer_af *paf; |
2708 | struct update_subgroup *subgrp; | |
718e3744 | 2709 | |
3f9c7369 DS |
2710 | paf = peer_af_find (peer, afi, safi); |
2711 | if (!paf) | |
718e3744 | 2712 | return; |
3f9c7369 | 2713 | subgrp = PAF_SUBGRP(paf); |
718e3744 | 2714 | |
3f9c7369 DS |
2715 | /* |
2716 | * Ignore if subgroup doesn't exist (implies AF is not negotiated) | |
2717 | * or a refresh has already been triggered. | |
2718 | */ | |
2719 | if (!subgrp || paf->t_announce_route) | |
718e3744 | 2720 | return; |
2721 | ||
d889623f | 2722 | /* |
3f9c7369 DS |
2723 | * Start a timer to stagger/delay the announce. This serves |
2724 | * two purposes - announcement can potentially be combined for | |
2725 | * multiple peers and the announcement doesn't happen in the | |
2726 | * vty context. | |
d889623f | 2727 | */ |
9229d914 | 2728 | THREAD_TIMER_MSEC_ON (bm->master, paf->t_announce_route, |
3f9c7369 DS |
2729 | bgp_announce_route_timer_expired, paf, |
2730 | (subgrp->peer_count == 1) ? | |
2731 | BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS : | |
2732 | BGP_ANNOUNCE_ROUTE_DELAY_MS); | |
2733 | } | |
2734 | ||
2735 | /* | |
2736 | * Announce routes from all AF tables to a peer. | |
2737 | * | |
2738 | * This should ONLY be called when there is a need to refresh the | |
2739 | * routes to the peer based on a policy change for this peer alone | |
2740 | * or a route refresh request received from the peer. | |
2741 | * The operation will result in splitting the peer from its existing | |
2742 | * subgroups and putting it in new subgroups. | |
2743 | */ | |
718e3744 | 2744 | void |
2745 | bgp_announce_route_all (struct peer *peer) | |
2746 | { | |
2747 | afi_t afi; | |
2748 | safi_t safi; | |
2749 | ||
2750 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2751 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2752 | bgp_announce_route (peer, afi, safi); | |
2753 | } | |
6b0655a2 | 2754 | |
fee0f4c6 | 2755 | static void |
718e3744 | 2756 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
8692c506 | 2757 | struct bgp_table *table, struct prefix_rd *prd) |
718e3744 | 2758 | { |
2759 | int ret; | |
2760 | struct bgp_node *rn; | |
2761 | struct bgp_adj_in *ain; | |
2762 | ||
2763 | if (! table) | |
2764 | table = peer->bgp->rib[afi][safi]; | |
2765 | ||
2766 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2767 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2768 | { | |
2769 | if (ain->peer == peer) | |
2770 | { | |
8692c506 | 2771 | struct bgp_info *ri = rn->info; |
d53d8fda | 2772 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
8692c506 | 2773 | |
43143c8f | 2774 | ret = bgp_update (peer, &rn->p, ain->addpath_rx_id, ain->attr, |
a82478b9 | 2775 | afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
d53d8fda | 2776 | prd, tag, 1); |
8692c506 | 2777 | |
718e3744 | 2778 | if (ret < 0) |
2779 | { | |
2780 | bgp_unlock_node (rn); | |
2781 | return; | |
2782 | } | |
718e3744 | 2783 | } |
2784 | } | |
2785 | } | |
2786 | ||
2787 | void | |
2788 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) | |
2789 | { | |
2790 | struct bgp_node *rn; | |
2791 | struct bgp_table *table; | |
2792 | ||
2793 | if (peer->status != Established) | |
2794 | return; | |
2795 | ||
587ff0fd | 2796 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
8692c506 | 2797 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
718e3744 | 2798 | else |
2799 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2800 | rn = bgp_route_next (rn)) | |
2801 | if ((table = rn->info) != NULL) | |
8692c506 JBD |
2802 | { |
2803 | struct prefix_rd prd; | |
2804 | prd.family = AF_UNSPEC; | |
2805 | prd.prefixlen = 64; | |
2806 | memcpy(&prd.val, rn->p.u.val, 8); | |
2807 | ||
2808 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); | |
2809 | } | |
718e3744 | 2810 | } |
6b0655a2 | 2811 | |
228da428 CC |
2812 | |
2813 | struct bgp_clear_node_queue | |
2814 | { | |
2815 | struct bgp_node *rn; | |
228da428 CC |
2816 | }; |
2817 | ||
200df115 | 2818 | static wq_item_status |
0fb58d5d | 2819 | bgp_clear_route_node (struct work_queue *wq, void *data) |
200df115 | 2820 | { |
228da428 CC |
2821 | struct bgp_clear_node_queue *cnq = data; |
2822 | struct bgp_node *rn = cnq->rn; | |
64e580a7 | 2823 | struct peer *peer = wq->spec.data; |
718e3744 | 2824 | struct bgp_info *ri; |
67174041 AS |
2825 | afi_t afi = bgp_node_table (rn)->afi; |
2826 | safi_t safi = bgp_node_table (rn)->safi; | |
200df115 | 2827 | |
64e580a7 | 2828 | assert (rn && peer); |
200df115 | 2829 | |
43143c8f DS |
2830 | /* It is possible that we have multiple paths for a prefix from a peer |
2831 | * if that peer is using AddPath. | |
2832 | */ | |
64e580a7 | 2833 | for (ri = rn->info; ri; ri = ri->next) |
2a3d5731 | 2834 | if (ri->peer == peer) |
200df115 | 2835 | { |
2836 | /* graceful restart STALE flag set. */ | |
64e580a7 PJ |
2837 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
2838 | && peer->nsf[afi][safi] | |
200df115 | 2839 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
1a392d46 PJ |
2840 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2841 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); | |
200df115 | 2842 | else |
64e580a7 | 2843 | bgp_rib_remove (rn, ri, peer, afi, safi); |
200df115 | 2844 | } |
200df115 | 2845 | return WQ_SUCCESS; |
2846 | } | |
2847 | ||
2848 | static void | |
0fb58d5d | 2849 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
200df115 | 2850 | { |
228da428 CC |
2851 | struct bgp_clear_node_queue *cnq = data; |
2852 | struct bgp_node *rn = cnq->rn; | |
67174041 | 2853 | struct bgp_table *table = bgp_node_table (rn); |
64e580a7 PJ |
2854 | |
2855 | bgp_unlock_node (rn); | |
228da428 CC |
2856 | bgp_table_unlock (table); |
2857 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); | |
200df115 | 2858 | } |
2859 | ||
2860 | static void | |
94f2b392 | 2861 | bgp_clear_node_complete (struct work_queue *wq) |
200df115 | 2862 | { |
64e580a7 PJ |
2863 | struct peer *peer = wq->spec.data; |
2864 | ||
3e0c78ef | 2865 | /* Tickle FSM to start moving again */ |
ca058a30 | 2866 | BGP_EVENT_ADD (peer, Clearing_Completed); |
228da428 CC |
2867 | |
2868 | peer_unlock (peer); /* bgp_clear_route */ | |
200df115 | 2869 | } |
2870 | ||
2871 | static void | |
64e580a7 | 2872 | bgp_clear_node_queue_init (struct peer *peer) |
200df115 | 2873 | { |
a2943657 | 2874 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
64e580a7 | 2875 | |
a2943657 | 2876 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
64e580a7 PJ |
2877 | #undef CLEAR_QUEUE_NAME_LEN |
2878 | ||
87d4a781 | 2879 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
200df115 | 2880 | { |
2881 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
2882 | exit (1); | |
2883 | } | |
64e580a7 PJ |
2884 | peer->clear_node_queue->spec.hold = 10; |
2885 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; | |
2886 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; | |
2887 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; | |
2888 | peer->clear_node_queue->spec.max_retries = 0; | |
2889 | ||
2890 | /* we only 'lock' this peer reference when the queue is actually active */ | |
2891 | peer->clear_node_queue->spec.data = peer; | |
200df115 | 2892 | } |
718e3744 | 2893 | |
200df115 | 2894 | static void |
2895 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, | |
2a3d5731 | 2896 | struct bgp_table *table) |
200df115 | 2897 | { |
200df115 | 2898 | struct bgp_node *rn; |
2899 | ||
f2c31acb | 2900 | |
718e3744 | 2901 | if (! table) |
2a3d5731 | 2902 | table = peer->bgp->rib[afi][safi]; |
64e580a7 | 2903 | |
6cf159b9 | 2904 | /* If still no table => afi/safi isn't configured at all or smth. */ |
2905 | if (! table) | |
2906 | return; | |
65ca75e0 PJ |
2907 | |
2908 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2909 | { | |
f2c31acb PJ |
2910 | struct bgp_info *ri; |
2911 | struct bgp_adj_in *ain; | |
43143c8f | 2912 | struct bgp_adj_in *ain_next; |
f2c31acb PJ |
2913 | |
2914 | /* XXX:TODO: This is suboptimal, every non-empty route_node is | |
2915 | * queued for every clearing peer, regardless of whether it is | |
2916 | * relevant to the peer at hand. | |
2917 | * | |
2918 | * Overview: There are 3 different indices which need to be | |
2919 | * scrubbed, potentially, when a peer is removed: | |
2920 | * | |
2921 | * 1 peer's routes visible via the RIB (ie accepted routes) | |
2922 | * 2 peer's routes visible by the (optional) peer's adj-in index | |
2923 | * 3 other routes visible by the peer's adj-out index | |
2924 | * | |
2925 | * 3 there is no hurry in scrubbing, once the struct peer is | |
2926 | * removed from bgp->peer, we could just GC such deleted peer's | |
2927 | * adj-outs at our leisure. | |
2928 | * | |
2929 | * 1 and 2 must be 'scrubbed' in some way, at least made | |
2930 | * invisible via RIB index before peer session is allowed to be | |
2931 | * brought back up. So one needs to know when such a 'search' is | |
2932 | * complete. | |
2933 | * | |
2934 | * Ideally: | |
2935 | * | |
2936 | * - there'd be a single global queue or a single RIB walker | |
2937 | * - rather than tracking which route_nodes still need to be | |
2938 | * examined on a peer basis, we'd track which peers still | |
2939 | * aren't cleared | |
2940 | * | |
2941 | * Given that our per-peer prefix-counts now should be reliable, | |
2942 | * this may actually be achievable. It doesn't seem to be a huge | |
2943 | * problem at this time, | |
43143c8f DS |
2944 | * |
2945 | * It is possible that we have multiple paths for a prefix from a peer | |
2946 | * if that peer is using AddPath. | |
f2c31acb | 2947 | */ |
43143c8f DS |
2948 | ain = rn->adj_in; |
2949 | while (ain) | |
2950 | { | |
2951 | ain_next = ain->next; | |
2952 | ||
2a3d5731 | 2953 | if (ain->peer == peer) |
43143c8f DS |
2954 | { |
2955 | bgp_adj_in_remove (rn, ain); | |
2956 | bgp_unlock_node (rn); | |
2957 | } | |
2958 | ||
2959 | ain = ain_next; | |
2960 | } | |
3f9c7369 | 2961 | |
f2c31acb | 2962 | for (ri = rn->info; ri; ri = ri->next) |
2a3d5731 | 2963 | if (ri->peer == peer) |
f2c31acb | 2964 | { |
228da428 CC |
2965 | struct bgp_clear_node_queue *cnq; |
2966 | ||
2967 | /* both unlocked in bgp_clear_node_queue_del */ | |
67174041 | 2968 | bgp_table_lock (bgp_node_table (rn)); |
228da428 CC |
2969 | bgp_lock_node (rn); |
2970 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, | |
2971 | sizeof (struct bgp_clear_node_queue)); | |
2972 | cnq->rn = rn; | |
228da428 CC |
2973 | work_queue_add (peer->clear_node_queue, cnq); |
2974 | break; | |
f2c31acb | 2975 | } |
65ca75e0 PJ |
2976 | } |
2977 | return; | |
2978 | } | |
2979 | ||
2980 | void | |
2a3d5731 | 2981 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
65ca75e0 PJ |
2982 | { |
2983 | struct bgp_node *rn; | |
2984 | struct bgp_table *table; | |
6cf159b9 | 2985 | |
64e580a7 PJ |
2986 | if (peer->clear_node_queue == NULL) |
2987 | bgp_clear_node_queue_init (peer); | |
200df115 | 2988 | |
ca058a30 PJ |
2989 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
2990 | * Idle until it receives a Clearing_Completed event. This protects | |
2991 | * against peers which flap faster than we can we clear, which could | |
2992 | * lead to: | |
64e580a7 PJ |
2993 | * |
2994 | * a) race with routes from the new session being installed before | |
2995 | * clear_route_node visits the node (to delete the route of that | |
2996 | * peer) | |
2997 | * b) resource exhaustion, clear_route_node likely leads to an entry | |
2998 | * on the process_main queue. Fast-flapping could cause that queue | |
2999 | * to grow and grow. | |
200df115 | 3000 | */ |
dc83d712 DS |
3001 | |
3002 | /* lock peer in assumption that clear-node-queue will get nodes; if so, | |
3003 | * the unlock will happen upon work-queue completion; other wise, the | |
3004 | * unlock happens at the end of this function. | |
3005 | */ | |
ca058a30 | 3006 | if (!peer->clear_node_queue->thread) |
dc83d712 | 3007 | peer_lock (peer); |
fee0f4c6 | 3008 | |
587ff0fd | 3009 | if (safi != SAFI_MPLS_VPN && safi != SAFI_ENCAP) |
2a3d5731 DW |
3010 | bgp_clear_route_table (peer, afi, safi, NULL); |
3011 | else | |
3012 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
3013 | rn = bgp_route_next (rn)) | |
3014 | if ((table = rn->info) != NULL) | |
3015 | bgp_clear_route_table (peer, afi, safi, table); | |
dc83d712 DS |
3016 | |
3017 | /* unlock if no nodes got added to the clear-node-queue. */ | |
65ca75e0 | 3018 | if (!peer->clear_node_queue->thread) |
dc83d712 DS |
3019 | peer_unlock (peer); |
3020 | ||
718e3744 | 3021 | } |
3022 | ||
3023 | void | |
3024 | bgp_clear_route_all (struct peer *peer) | |
3025 | { | |
3026 | afi_t afi; | |
3027 | safi_t safi; | |
3028 | ||
3029 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3030 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2a3d5731 | 3031 | bgp_clear_route (peer, afi, safi); |
718e3744 | 3032 | } |
3033 | ||
3034 | void | |
3035 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) | |
3036 | { | |
3037 | struct bgp_table *table; | |
3038 | struct bgp_node *rn; | |
3039 | struct bgp_adj_in *ain; | |
43143c8f | 3040 | struct bgp_adj_in *ain_next; |
718e3744 | 3041 | |
3042 | table = peer->bgp->rib[afi][safi]; | |
3043 | ||
43143c8f DS |
3044 | /* It is possible that we have multiple paths for a prefix from a peer |
3045 | * if that peer is using AddPath. | |
3046 | */ | |
718e3744 | 3047 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
43143c8f DS |
3048 | { |
3049 | ain = rn->adj_in; | |
3050 | ||
3051 | while (ain) | |
3052 | { | |
3053 | ain_next = ain->next; | |
3054 | ||
3055 | if (ain->peer == peer) | |
3056 | { | |
3057 | bgp_adj_in_remove (rn, ain); | |
3058 | bgp_unlock_node (rn); | |
3059 | } | |
3060 | ||
3061 | ain = ain_next; | |
3062 | } | |
3063 | } | |
718e3744 | 3064 | } |
93406d87 | 3065 | |
3066 | void | |
3067 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) | |
3068 | { | |
3069 | struct bgp_node *rn; | |
3070 | struct bgp_info *ri; | |
3071 | struct bgp_table *table; | |
3072 | ||
3073 | table = peer->bgp->rib[afi][safi]; | |
3074 | ||
3075 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3076 | { | |
3077 | for (ri = rn->info; ri; ri = ri->next) | |
3078 | if (ri->peer == peer) | |
3079 | { | |
3080 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
3081 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
3082 | break; | |
3083 | } | |
3084 | } | |
3085 | } | |
6b0655a2 | 3086 | |
bb86c601 LB |
3087 | static void |
3088 | bgp_cleanup_table(struct bgp_table *table, safi_t safi) | |
3089 | { | |
3090 | struct bgp_node *rn; | |
3091 | struct bgp_info *ri; | |
3092 | struct bgp_info *next; | |
3093 | ||
3094 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3095 | for (ri = rn->info; ri; ri = next) | |
3096 | { | |
3097 | next = ri->next; | |
3098 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
3099 | && ri->type == ZEBRA_ROUTE_BGP | |
3100 | && (ri->sub_type == BGP_ROUTE_NORMAL || | |
3101 | ri->sub_type == BGP_ROUTE_AGGREGATE)) | |
3102 | bgp_zebra_withdraw (&rn->p, ri, safi); | |
3103 | } | |
3104 | } | |
3105 | ||
718e3744 | 3106 | /* Delete all kernel routes. */ |
3107 | void | |
66e5cd87 | 3108 | bgp_cleanup_routes (void) |
718e3744 | 3109 | { |
3110 | struct bgp *bgp; | |
1eb8ef25 | 3111 | struct listnode *node, *nnode; |
bb86c601 | 3112 | afi_t afi; |
718e3744 | 3113 | |
1eb8ef25 | 3114 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 3115 | { |
bb86c601 LB |
3116 | for (afi = AFI_IP; afi < AFI_MAX; ++afi) |
3117 | { | |
3118 | struct bgp_node *rn; | |
3119 | ||
3120 | bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST); | |
3121 | ||
3122 | /* | |
3123 | * VPN and ENCAP tables are two-level (RD is top level) | |
3124 | */ | |
3125 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn; | |
3126 | rn = bgp_route_next (rn)) | |
587ff0fd LB |
3127 | { |
3128 | if (rn->info) | |
bb86c601 | 3129 | { |
587ff0fd LB |
3130 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN); |
3131 | bgp_table_finish ((struct bgp_table **)&(rn->info)); | |
3132 | rn->info = NULL; | |
3133 | bgp_unlock_node(rn); | |
bb86c601 | 3134 | } |
587ff0fd LB |
3135 | } |
3136 | ||
3137 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn; | |
3138 | rn = bgp_route_next (rn)) | |
3139 | { | |
3140 | if (rn->info) | |
3141 | { | |
3142 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP); | |
3143 | bgp_table_finish ((struct bgp_table **)&(rn->info)); | |
3144 | rn->info = NULL; | |
3145 | bgp_unlock_node(rn); | |
3146 | } | |
3147 | } | |
bb86c601 | 3148 | } |
718e3744 | 3149 | } |
3150 | } | |
3151 | ||
3152 | void | |
66e5cd87 | 3153 | bgp_reset (void) |
718e3744 | 3154 | { |
3155 | vty_reset (); | |
3156 | bgp_zclient_reset (); | |
3157 | access_list_reset (); | |
3158 | prefix_list_reset (); | |
3159 | } | |
6b0655a2 | 3160 | |
adbac85e DW |
3161 | static int |
3162 | bgp_addpath_encode_rx (struct peer *peer, afi_t afi, safi_t safi) | |
3163 | { | |
3164 | return (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) && | |
3165 | CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)); | |
3166 | } | |
3167 | ||
718e3744 | 3168 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
3169 | value. */ | |
3170 | int | |
3171 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) | |
3172 | { | |
3173 | u_char *pnt; | |
3174 | u_char *lim; | |
3175 | struct prefix p; | |
3176 | int psize; | |
3177 | int ret; | |
a82478b9 DS |
3178 | afi_t afi; |
3179 | safi_t safi; | |
adbac85e | 3180 | int addpath_encoded; |
a82478b9 | 3181 | u_int32_t addpath_id; |
718e3744 | 3182 | |
3183 | /* Check peer status. */ | |
3184 | if (peer->status != Established) | |
3185 | return 0; | |
3186 | ||
3187 | pnt = packet->nlri; | |
3188 | lim = pnt + packet->length; | |
a82478b9 DS |
3189 | afi = packet->afi; |
3190 | safi = packet->safi; | |
3191 | addpath_id = 0; | |
adbac85e | 3192 | addpath_encoded = bgp_addpath_encode_rx (peer, afi, safi); |
718e3744 | 3193 | |
3194 | for (; pnt < lim; pnt += psize) | |
3195 | { | |
3196 | /* Clear prefix structure. */ | |
3197 | memset (&p, 0, sizeof (struct prefix)); | |
3198 | ||
a82478b9 DS |
3199 | if (addpath_encoded) |
3200 | { | |
cd808e74 DS |
3201 | |
3202 | /* When packet overflow occurs return immediately. */ | |
3203 | if (pnt + BGP_ADDPATH_ID_LEN > lim) | |
3204 | return -1; | |
3205 | ||
a82478b9 DS |
3206 | addpath_id = ntohl(*((uint32_t*) pnt)); |
3207 | pnt += BGP_ADDPATH_ID_LEN; | |
3208 | } | |
3209 | ||
718e3744 | 3210 | /* Fetch prefix length. */ |
3211 | p.prefixlen = *pnt++; | |
a82478b9 | 3212 | p.family = afi2family (afi); |
718e3744 | 3213 | |
3214 | /* Already checked in nlri_sanity_check(). We do double check | |
3215 | here. */ | |
a82478b9 DS |
3216 | if ((afi == AFI_IP && p.prefixlen > 32) |
3217 | || (afi == AFI_IP6 && p.prefixlen > 128)) | |
718e3744 | 3218 | return -1; |
3219 | ||
3220 | /* Packet size overflow check. */ | |
3221 | psize = PSIZE (p.prefixlen); | |
3222 | ||
3223 | /* When packet overflow occur return immediately. */ | |
3224 | if (pnt + psize > lim) | |
3225 | return -1; | |
3226 | ||
3227 | /* Fetch prefix from NLRI packet. */ | |
3228 | memcpy (&p.u.prefix, pnt, psize); | |
3229 | ||
3230 | /* Check address. */ | |
a82478b9 | 3231 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
718e3744 | 3232 | { |
3233 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) | |
3234 | { | |
f5ba3874 | 3235 | /* |
3236 | * From draft-ietf-idr-bgp4-22, Section 6.3: | |
3237 | * If a BGP router receives an UPDATE message with a | |
3238 | * semantically incorrect NLRI field, in which a prefix is | |
3239 | * semantically incorrect (eg. an unexpected multicast IP | |
3240 | * address), it should ignore the prefix. | |
3241 | */ | |
16286195 DS |
3242 | zlog_err ("IPv4 unicast NLRI is multicast address %s", |
3243 | inet_ntoa (p.u.prefix4)); | |
f5ba3874 | 3244 | |
718e3744 | 3245 | return -1; |
3246 | } | |
3247 | } | |
3248 | ||
3249 | #ifdef HAVE_IPV6 | |
3250 | /* Check address. */ | |
a82478b9 | 3251 | if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
718e3744 | 3252 | { |
3253 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3254 | { | |
3255 | char buf[BUFSIZ]; | |
3256 | ||
16286195 DS |
3257 | zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI", |
3258 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); | |
718e3744 | 3259 | |
3260 | continue; | |
3261 | } | |
3262 | } | |
3263 | #endif /* HAVE_IPV6 */ | |
3264 | ||
3265 | /* Normal process. */ | |
3266 | if (attr) | |
a82478b9 | 3267 | ret = bgp_update (peer, &p, addpath_id, attr, afi, safi, |
718e3744 | 3268 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
3269 | else | |
a82478b9 | 3270 | ret = bgp_withdraw (peer, &p, addpath_id, attr, afi, safi, |
718e3744 | 3271 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
3272 | ||
3273 | /* Address family configuration mismatch or maximum-prefix count | |
3274 | overflow. */ | |
3275 | if (ret < 0) | |
3276 | return -1; | |
3277 | } | |
3278 | ||
3279 | /* Packet length consistency check. */ | |
3280 | if (pnt != lim) | |
3281 | return -1; | |
3282 | ||
3283 | return 0; | |
3284 | } | |
3285 | ||
3286 | /* NLRI encode syntax check routine. */ | |
3287 | int | |
a82478b9 | 3288 | bgp_nlri_sanity_check (struct peer *peer, int afi, safi_t safi, u_char *pnt, |
d889623f | 3289 | bgp_size_t length, int *numpfx) |
718e3744 | 3290 | { |
3291 | u_char *end; | |
3292 | u_char prefixlen; | |
3293 | int psize; | |
adbac85e | 3294 | int addpath_encoded; |
718e3744 | 3295 | |
d889623f | 3296 | *numpfx = 0; |
718e3744 | 3297 | end = pnt + length; |
adbac85e | 3298 | addpath_encoded = bgp_addpath_encode_rx (peer, afi, safi); |
a82478b9 | 3299 | |
718e3744 | 3300 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
3301 | syntactic validity. If the field is syntactically incorrect, | |
3302 | then the Error Subcode is set to Invalid Network Field. */ | |
3303 | ||
3304 | while (pnt < end) | |
3305 | { | |
587ff0fd | 3306 | int badlength; |
cd808e74 | 3307 | |
a82478b9 DS |
3308 | /* If the NLRI is encoded using addpath then the first 4 bytes are |
3309 | * the addpath ID. */ | |
3310 | if (addpath_encoded) | |
cd808e74 DS |
3311 | { |
3312 | if (pnt + BGP_ADDPATH_ID_LEN > end) | |
3313 | { | |
3314 | zlog_err ("%s [Error] Update packet error" | |
3315 | " (prefix data addpath overflow)", | |
3316 | peer->host); | |
3317 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3318 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3319 | return -1; | |
3320 | } | |
3321 | pnt += BGP_ADDPATH_ID_LEN; | |
3322 | } | |
a82478b9 | 3323 | |
718e3744 | 3324 | prefixlen = *pnt++; |
3325 | ||
3326 | /* Prefix length check. */ | |
587ff0fd LB |
3327 | badlength = 0; |
3328 | if (safi == SAFI_ENCAP) { | |
3329 | if (prefixlen > 128) | |
3330 | badlength = 1; | |
3331 | } else { | |
3332 | if ((afi == AFI_IP && prefixlen > 32) || | |
3333 | (afi == AFI_IP6 && prefixlen > 128)) { | |
3334 | ||
3335 | badlength = 1; | |
3336 | } | |
3337 | } | |
3338 | if (badlength) | |
718e3744 | 3339 | { |
16286195 | 3340 | zlog_err ("%s [Error] Update packet error (wrong prefix length %d)", |
718e3744 | 3341 | peer->host, prefixlen); |
3342 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3343 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3344 | return -1; | |
3345 | } | |
3346 | ||
3347 | /* Packet size overflow check. */ | |
3348 | psize = PSIZE (prefixlen); | |
3349 | ||
3350 | if (pnt + psize > end) | |
3351 | { | |
16286195 | 3352 | zlog_err ("%s [Error] Update packet error" |
718e3744 | 3353 | " (prefix data overflow prefix size is %d)", |
3354 | peer->host, psize); | |
3355 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3356 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3357 | return -1; | |
3358 | } | |
3359 | ||
3360 | pnt += psize; | |
d889623f | 3361 | (*numpfx)++; |
718e3744 | 3362 | } |
3363 | ||
3364 | /* Packet length consistency check. */ | |
3365 | if (pnt != end) | |
3366 | { | |
16286195 | 3367 | zlog_err ("%s [Error] Update packet error" |
718e3744 | 3368 | " (prefix length mismatch with total length)", |
3369 | peer->host); | |
3370 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3371 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3372 | return -1; | |
3373 | } | |
3374 | return 0; | |
3375 | } | |
6b0655a2 | 3376 | |
94f2b392 | 3377 | static struct bgp_static * |
66e5cd87 | 3378 | bgp_static_new (void) |
718e3744 | 3379 | { |
393deb9b | 3380 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
718e3744 | 3381 | } |
3382 | ||
94f2b392 | 3383 | static void |
718e3744 | 3384 | bgp_static_free (struct bgp_static *bgp_static) |
3385 | { | |
3386 | if (bgp_static->rmap.name) | |
6e919709 | 3387 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
718e3744 | 3388 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
3389 | } | |
3390 | ||
94f2b392 | 3391 | static void |
2a3d5731 DW |
3392 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
3393 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
fee0f4c6 | 3394 | { |
3395 | struct bgp_node *rn; | |
3396 | struct bgp_info *ri; | |
2a3d5731 DW |
3397 | struct bgp_info *new; |
3398 | struct bgp_info info; | |
3399 | struct attr attr; | |
3400 | struct attr *attr_new; | |
3401 | int ret; | |
fee0f4c6 | 3402 | |
2a3d5731 DW |
3403 | assert (bgp_static); |
3404 | if (!bgp_static) | |
3405 | return; | |
dd8103a9 | 3406 | |
fee0f4c6 | 3407 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3408 | |
3409 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
dd8103a9 PJ |
3410 | |
3411 | attr.nexthop = bgp_static->igpnexthop; | |
3412 | attr.med = bgp_static->igpmetric; | |
3413 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
718e3744 | 3414 | |
41367172 PJ |
3415 | if (bgp_static->atomic) |
3416 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3417 | ||
718e3744 | 3418 | /* Apply route-map. */ |
3419 | if (bgp_static->rmap.name) | |
3420 | { | |
fb982c25 | 3421 | struct attr attr_tmp = attr; |
718e3744 | 3422 | info.peer = bgp->peer_self; |
286e1e71 | 3423 | info.attr = &attr_tmp; |
718e3744 | 3424 | |
fee0f4c6 | 3425 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3426 | ||
718e3744 | 3427 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
286e1e71 | 3428 | |
fee0f4c6 | 3429 | bgp->peer_self->rmap_type = 0; |
3430 | ||
718e3744 | 3431 | if (ret == RMAP_DENYMATCH) |
3432 | { | |
3433 | /* Free uninterned attribute. */ | |
286e1e71 | 3434 | bgp_attr_flush (&attr_tmp); |
718e3744 | 3435 | |
3436 | /* Unintern original. */ | |
f6f434b2 | 3437 | aspath_unintern (&attr.aspath); |
fb982c25 | 3438 | bgp_attr_extra_free (&attr); |
718e3744 | 3439 | bgp_static_withdraw (bgp, p, afi, safi); |
3440 | return; | |
3441 | } | |
286e1e71 | 3442 | attr_new = bgp_attr_intern (&attr_tmp); |
718e3744 | 3443 | } |
286e1e71 | 3444 | else |
3445 | attr_new = bgp_attr_intern (&attr); | |
718e3744 | 3446 | |
3447 | for (ri = rn->info; ri; ri = ri->next) | |
3448 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3449 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3450 | break; | |
3451 | ||
3452 | if (ri) | |
3453 | { | |
8d45210e | 3454 | if (attrhash_cmp (ri->attr, attr_new) && |
078430f6 DS |
3455 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) && |
3456 | !bgp_flag_check(bgp, BGP_FLAG_FORCE_STATIC_PROCESS)) | |
718e3744 | 3457 | { |
3458 | bgp_unlock_node (rn); | |
f6f434b2 PJ |
3459 | bgp_attr_unintern (&attr_new); |
3460 | aspath_unintern (&attr.aspath); | |
fb982c25 | 3461 | bgp_attr_extra_free (&attr); |
718e3744 | 3462 | return; |
3463 | } | |
3464 | else | |
3465 | { | |
3466 | /* The attribute is changed. */ | |
1a392d46 | 3467 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 3468 | |
3469 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3470 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3471 | bgp_info_restore(rn, ri); | |
3472 | else | |
3473 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
f6f434b2 | 3474 | bgp_attr_unintern (&ri->attr); |
718e3744 | 3475 | ri->attr = attr_new; |
65957886 | 3476 | ri->uptime = bgp_clock (); |
718e3744 | 3477 | |
fc9a856f DS |
3478 | /* Nexthop reachability check. */ |
3479 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3480 | { | |
75aead62 | 3481 | if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, 0)) |
fc9a856f DS |
3482 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
3483 | else | |
3484 | { | |
3485 | if (BGP_DEBUG(nht, NHT)) | |
3486 | { | |
3487 | char buf1[INET6_ADDRSTRLEN]; | |
078430f6 DS |
3488 | inet_ntop(p->family, &p->u.prefix, buf1, |
3489 | INET6_ADDRSTRLEN); | |
3490 | zlog_debug("%s(%s): Route not in table, not advertising", | |
3491 | __FUNCTION__, buf1); | |
fc9a856f DS |
3492 | } |
3493 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); | |
3494 | } | |
3495 | } | |
078430f6 DS |
3496 | else |
3497 | { | |
3498 | /* Delete the NHT structure if any, if we're toggling between | |
3499 | * enabling/disabling import check. We deregister the route | |
3500 | * from NHT to avoid overloading NHT and the process interaction | |
3501 | */ | |
3502 | bgp_unlink_nexthop(ri); | |
3503 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); | |
3504 | } | |
718e3744 | 3505 | /* Process change. */ |
3506 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
3507 | bgp_process (bgp, rn, afi, safi); | |
3508 | bgp_unlock_node (rn); | |
f6f434b2 | 3509 | aspath_unintern (&attr.aspath); |
fb982c25 | 3510 | bgp_attr_extra_free (&attr); |
718e3744 | 3511 | return; |
3512 | } | |
3513 | } | |
3514 | ||
3515 | /* Make new BGP info. */ | |
7c8ff89e | 3516 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self, attr_new, |
fb018d25 | 3517 | rn); |
fc9a856f DS |
3518 | /* Nexthop reachability check. */ |
3519 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3520 | { | |
75aead62 | 3521 | if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, 0)) |
fc9a856f DS |
3522 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
3523 | else | |
3524 | { | |
3525 | if (BGP_DEBUG(nht, NHT)) | |
3526 | { | |
3527 | char buf1[INET6_ADDRSTRLEN]; | |
078430f6 | 3528 | inet_ntop(p->family, &p->u.prefix, buf1, |
fc9a856f | 3529 | INET6_ADDRSTRLEN); |
078430f6 DS |
3530 | zlog_debug("%s(%s): Route not in table, not advertising", |
3531 | __FUNCTION__, buf1); | |
fc9a856f DS |
3532 | } |
3533 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); | |
3534 | } | |
3535 | } | |
3536 | else | |
078430f6 DS |
3537 | { |
3538 | /* Delete the NHT structure if any, if we're toggling between | |
3539 | * enabling/disabling import check. We deregister the route | |
3540 | * from NHT to avoid overloading NHT and the process interaction | |
3541 | */ | |
3542 | bgp_unlink_nexthop(new); | |
3543 | ||
3544 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); | |
3545 | } | |
718e3744 | 3546 | |
3547 | /* Aggregate address increment. */ | |
3548 | bgp_aggregate_increment (bgp, p, new, afi, safi); | |
3549 | ||
3550 | /* Register new BGP information. */ | |
3551 | bgp_info_add (rn, new); | |
200df115 | 3552 | |
3553 | /* route_node_get lock */ | |
3554 | bgp_unlock_node (rn); | |
3555 | ||
718e3744 | 3556 | /* Process change. */ |
3557 | bgp_process (bgp, rn, afi, safi); | |
3558 | ||
3559 | /* Unintern original. */ | |
f6f434b2 | 3560 | aspath_unintern (&attr.aspath); |
fb982c25 | 3561 | bgp_attr_extra_free (&attr); |
718e3744 | 3562 | } |
3563 | ||
fee0f4c6 | 3564 | void |
3565 | bgp_static_update (struct bgp *bgp, struct prefix *p, | |
3566 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
3567 | { | |
fee0f4c6 | 3568 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
fee0f4c6 | 3569 | } |
3570 | ||
718e3744 | 3571 | void |
3572 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, | |
3573 | safi_t safi) | |
3574 | { | |
3575 | struct bgp_node *rn; | |
3576 | struct bgp_info *ri; | |
3577 | ||
fee0f4c6 | 3578 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3579 | |
3580 | /* Check selected route and self inserted route. */ | |
3581 | for (ri = rn->info; ri; ri = ri->next) | |
3582 | if (ri->peer == bgp->peer_self | |
3583 | && ri->type == ZEBRA_ROUTE_BGP | |
3584 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3585 | break; | |
3586 | ||
3587 | /* Withdraw static BGP route from routing table. */ | |
3588 | if (ri) | |
3589 | { | |
3590 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
fc9a856f | 3591 | bgp_unlink_nexthop(ri); |
718e3744 | 3592 | bgp_info_delete (rn, ri); |
1a392d46 | 3593 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3594 | } |
3595 | ||
3596 | /* Unlock bgp_node_lookup. */ | |
3597 | bgp_unlock_node (rn); | |
3598 | } | |
3599 | ||
137446f9 LB |
3600 | /* |
3601 | * Used for SAFI_MPLS_VPN and SAFI_ENCAP | |
3602 | */ | |
94f2b392 | 3603 | static void |
137446f9 LB |
3604 | bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi, |
3605 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3606 | { |
3607 | struct bgp_node *rn; | |
3608 | struct bgp_info *ri; | |
3609 | ||
fee0f4c6 | 3610 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3611 | |
3612 | /* Check selected route and self inserted route. */ | |
3613 | for (ri = rn->info; ri; ri = ri->next) | |
3614 | if (ri->peer == bgp->peer_self | |
3615 | && ri->type == ZEBRA_ROUTE_BGP | |
3616 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3617 | break; | |
3618 | ||
3619 | /* Withdraw static BGP route from routing table. */ | |
3620 | if (ri) | |
3621 | { | |
3622 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3623 | bgp_info_delete (rn, ri); |
1a392d46 | 3624 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3625 | } |
3626 | ||
3627 | /* Unlock bgp_node_lookup. */ | |
3628 | bgp_unlock_node (rn); | |
3629 | } | |
3630 | ||
137446f9 LB |
3631 | static void |
3632 | bgp_static_update_safi (struct bgp *bgp, struct prefix *p, | |
3633 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
3634 | { | |
3635 | struct bgp_node *rn; | |
3636 | struct bgp_info *new; | |
3637 | struct attr *attr_new; | |
3638 | struct attr attr = { 0 }; | |
3639 | struct bgp_info *ri; | |
3640 | ||
3641 | assert (bgp_static); | |
3642 | ||
3643 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd); | |
3644 | ||
3645 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
3646 | ||
3647 | attr.nexthop = bgp_static->igpnexthop; | |
3648 | attr.med = bgp_static->igpmetric; | |
3649 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
3650 | ||
3651 | /* Apply route-map. */ | |
3652 | if (bgp_static->rmap.name) | |
3653 | { | |
3654 | struct attr attr_tmp = attr; | |
3655 | struct bgp_info info; | |
3656 | int ret; | |
3657 | ||
3658 | info.peer = bgp->peer_self; | |
3659 | info.attr = &attr_tmp; | |
3660 | ||
3661 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); | |
3662 | ||
3663 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); | |
3664 | ||
3665 | bgp->peer_self->rmap_type = 0; | |
3666 | ||
3667 | if (ret == RMAP_DENYMATCH) | |
3668 | { | |
3669 | /* Free uninterned attribute. */ | |
3670 | bgp_attr_flush (&attr_tmp); | |
3671 | ||
3672 | /* Unintern original. */ | |
3673 | aspath_unintern (&attr.aspath); | |
3674 | bgp_attr_extra_free (&attr); | |
3675 | bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd, | |
3676 | bgp_static->tag); | |
3677 | return; | |
3678 | } | |
3679 | ||
3680 | attr_new = bgp_attr_intern (&attr_tmp); | |
3681 | } | |
3682 | else | |
3683 | { | |
3684 | attr_new = bgp_attr_intern (&attr); | |
3685 | } | |
3686 | ||
3687 | for (ri = rn->info; ri; ri = ri->next) | |
3688 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3689 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3690 | break; | |
3691 | ||
3692 | if (ri) | |
3693 | { | |
3694 | if (attrhash_cmp (ri->attr, attr_new) && | |
3695 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
3696 | { | |
3697 | bgp_unlock_node (rn); | |
3698 | bgp_attr_unintern (&attr_new); | |
3699 | aspath_unintern (&attr.aspath); | |
3700 | bgp_attr_extra_free (&attr); | |
3701 | return; | |
3702 | } | |
3703 | else | |
3704 | { | |
3705 | /* The attribute is changed. */ | |
3706 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); | |
3707 | ||
3708 | /* Rewrite BGP route information. */ | |
3709 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
3710 | bgp_info_restore(rn, ri); | |
3711 | else | |
3712 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
3713 | bgp_attr_unintern (&ri->attr); | |
3714 | ri->attr = attr_new; | |
3715 | ri->uptime = bgp_clock (); | |
3716 | ||
3717 | /* Process change. */ | |
3718 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
3719 | bgp_process (bgp, rn, afi, safi); | |
3720 | bgp_unlock_node (rn); | |
3721 | aspath_unintern (&attr.aspath); | |
3722 | bgp_attr_extra_free (&attr); | |
3723 | return; | |
3724 | } | |
3725 | } | |
3726 | ||
3727 | ||
3728 | /* Make new BGP info. */ | |
3729 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self, attr_new, | |
3730 | rn); | |
3731 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3732 | new->extra = bgp_info_extra_new(); | |
3733 | memcpy (new->extra->tag, bgp_static->tag, 3); | |
3734 | ||
3735 | /* Aggregate address increment. */ | |
3736 | bgp_aggregate_increment (bgp, p, new, afi, safi); | |
3737 | ||
3738 | /* Register new BGP information. */ | |
3739 | bgp_info_add (rn, new); | |
3740 | ||
3741 | /* route_node_get lock */ | |
3742 | bgp_unlock_node (rn); | |
3743 | ||
3744 | /* Process change. */ | |
3745 | bgp_process (bgp, rn, afi, safi); | |
3746 | ||
3747 | /* Unintern original. */ | |
3748 | aspath_unintern (&attr.aspath); | |
3749 | bgp_attr_extra_free (&attr); | |
3750 | } | |
3751 | ||
718e3744 | 3752 | /* Configure static BGP network. When user don't run zebra, static |
3753 | route should be installed as valid. */ | |
94f2b392 | 3754 | static int |
fd79ac91 | 3755 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
c8f3fe30 | 3756 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
718e3744 | 3757 | { |
3758 | int ret; | |
3759 | struct prefix p; | |
3760 | struct bgp_static *bgp_static; | |
3761 | struct bgp_node *rn; | |
41367172 | 3762 | u_char need_update = 0; |
718e3744 | 3763 | |
3764 | /* Convert IP prefix string to struct prefix. */ | |
3765 | ret = str2prefix (ip_str, &p); | |
3766 | if (! ret) | |
3767 | { | |
3768 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3769 | return CMD_WARNING; | |
3770 | } | |
3771 | #ifdef HAVE_IPV6 | |
3772 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3773 | { | |
3774 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3775 | VTY_NEWLINE); | |
3776 | return CMD_WARNING; | |
3777 | } | |
3778 | #endif /* HAVE_IPV6 */ | |
3779 | ||
3780 | apply_mask (&p); | |
3781 | ||
3782 | /* Set BGP static route configuration. */ | |
3783 | rn = bgp_node_get (bgp->route[afi][safi], &p); | |
3784 | ||
3785 | if (rn->info) | |
3786 | { | |
3787 | /* Configuration change. */ | |
3788 | bgp_static = rn->info; | |
3789 | ||
3790 | /* Check previous routes are installed into BGP. */ | |
c8f3fe30 PJ |
3791 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
3792 | need_update = 1; | |
41367172 | 3793 | |
718e3744 | 3794 | bgp_static->backdoor = backdoor; |
41367172 | 3795 | |
718e3744 | 3796 | if (rmap) |
3797 | { | |
3798 | if (bgp_static->rmap.name) | |
6e919709 DS |
3799 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
3800 | bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap); | |
718e3744 | 3801 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
3802 | } | |
3803 | else | |
3804 | { | |
3805 | if (bgp_static->rmap.name) | |
6e919709 | 3806 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
718e3744 | 3807 | bgp_static->rmap.name = NULL; |
3808 | bgp_static->rmap.map = NULL; | |
3809 | bgp_static->valid = 0; | |
3810 | } | |
3811 | bgp_unlock_node (rn); | |
3812 | } | |
3813 | else | |
3814 | { | |
3815 | /* New configuration. */ | |
3816 | bgp_static = bgp_static_new (); | |
3817 | bgp_static->backdoor = backdoor; | |
3818 | bgp_static->valid = 0; | |
3819 | bgp_static->igpmetric = 0; | |
3820 | bgp_static->igpnexthop.s_addr = 0; | |
41367172 | 3821 | |
718e3744 | 3822 | if (rmap) |
3823 | { | |
3824 | if (bgp_static->rmap.name) | |
6e919709 DS |
3825 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
3826 | bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap); | |
718e3744 | 3827 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
3828 | } | |
3829 | rn->info = bgp_static; | |
3830 | } | |
3831 | ||
fc9a856f DS |
3832 | bgp_static->valid = 1; |
3833 | if (need_update) | |
3834 | bgp_static_withdraw (bgp, &p, afi, safi); | |
718e3744 | 3835 | |
fc9a856f DS |
3836 | if (! bgp_static->backdoor) |
3837 | bgp_static_update (bgp, &p, bgp_static, afi, safi); | |
718e3744 | 3838 | |
3839 | return CMD_SUCCESS; | |
3840 | } | |
3841 | ||
3842 | /* Configure static BGP network. */ | |
94f2b392 | 3843 | static int |
fd79ac91 | 3844 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
4c9641ba | 3845 | afi_t afi, safi_t safi) |
718e3744 | 3846 | { |
3847 | int ret; | |
3848 | struct prefix p; | |
3849 | struct bgp_static *bgp_static; | |
3850 | struct bgp_node *rn; | |
3851 | ||
3852 | /* Convert IP prefix string to struct prefix. */ | |
3853 | ret = str2prefix (ip_str, &p); | |
3854 | if (! ret) | |
3855 | { | |
3856 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3857 | return CMD_WARNING; | |
3858 | } | |
3859 | #ifdef HAVE_IPV6 | |
3860 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3861 | { | |
3862 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3863 | VTY_NEWLINE); | |
3864 | return CMD_WARNING; | |
3865 | } | |
3866 | #endif /* HAVE_IPV6 */ | |
3867 | ||
3868 | apply_mask (&p); | |
3869 | ||
3870 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); | |
3871 | if (! rn) | |
3872 | { | |
3873 | vty_out (vty, "%% Can't find specified static route configuration.%s", | |
3874 | VTY_NEWLINE); | |
3875 | return CMD_WARNING; | |
3876 | } | |
3877 | ||
3878 | bgp_static = rn->info; | |
41367172 | 3879 | |
718e3744 | 3880 | /* Update BGP RIB. */ |
3881 | if (! bgp_static->backdoor) | |
3882 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3883 | ||
3884 | /* Clear configuration. */ | |
3885 | bgp_static_free (bgp_static); | |
3886 | rn->info = NULL; | |
3887 | bgp_unlock_node (rn); | |
3888 | bgp_unlock_node (rn); | |
3889 | ||
3890 | return CMD_SUCCESS; | |
3891 | } | |
3892 | ||
6aeb9e78 DS |
3893 | void |
3894 | bgp_static_add (struct bgp *bgp) | |
3895 | { | |
3896 | afi_t afi; | |
3897 | safi_t safi; | |
3898 | struct bgp_node *rn; | |
3899 | struct bgp_node *rm; | |
3900 | struct bgp_table *table; | |
3901 | struct bgp_static *bgp_static; | |
3902 | ||
3903 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3904 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3905 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3906 | if (rn->info != NULL) | |
3907 | { | |
3908 | if (safi == SAFI_MPLS_VPN) | |
3909 | { | |
3910 | table = rn->info; | |
3911 | ||
3912 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3913 | { | |
3914 | bgp_static = rn->info; | |
137446f9 | 3915 | bgp_static_update_safi (bgp, &rm->p, bgp_static, afi, safi); |
6aeb9e78 DS |
3916 | } |
3917 | } | |
3918 | else | |
3919 | { | |
3920 | bgp_static_update (bgp, &rn->p, rn->info, afi, safi); | |
3921 | } | |
3922 | } | |
3923 | } | |
3924 | ||
718e3744 | 3925 | /* Called from bgp_delete(). Delete all static routes from the BGP |
3926 | instance. */ | |
3927 | void | |
3928 | bgp_static_delete (struct bgp *bgp) | |
3929 | { | |
3930 | afi_t afi; | |
3931 | safi_t safi; | |
3932 | struct bgp_node *rn; | |
3933 | struct bgp_node *rm; | |
3934 | struct bgp_table *table; | |
3935 | struct bgp_static *bgp_static; | |
3936 | ||
3937 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3938 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3939 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3940 | if (rn->info != NULL) | |
3941 | { | |
587ff0fd | 3942 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 3943 | { |
3944 | table = rn->info; | |
3945 | ||
3946 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3947 | { | |
3948 | bgp_static = rn->info; | |
137446f9 LB |
3949 | bgp_static_withdraw_safi (bgp, &rm->p, |
3950 | AFI_IP, safi, | |
718e3744 | 3951 | (struct prefix_rd *)&rn->p, |
3952 | bgp_static->tag); | |
3953 | bgp_static_free (bgp_static); | |
3954 | rn->info = NULL; | |
3955 | bgp_unlock_node (rn); | |
3956 | } | |
3957 | } | |
3958 | else | |
3959 | { | |
3960 | bgp_static = rn->info; | |
3961 | bgp_static_withdraw (bgp, &rn->p, afi, safi); | |
3962 | bgp_static_free (bgp_static); | |
3963 | rn->info = NULL; | |
3964 | bgp_unlock_node (rn); | |
3965 | } | |
3966 | } | |
3967 | } | |
3968 | ||
078430f6 DS |
3969 | void |
3970 | bgp_static_redo_import_check (struct bgp *bgp) | |
3971 | { | |
3972 | afi_t afi; | |
3973 | safi_t safi; | |
3974 | struct bgp_node *rn; | |
078430f6 DS |
3975 | struct bgp_static *bgp_static; |
3976 | ||
3977 | /* Use this flag to force reprocessing of the route */ | |
3978 | bgp_flag_set(bgp, BGP_FLAG_FORCE_STATIC_PROCESS); | |
3979 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3980 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3981 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3982 | if (rn->info != NULL) | |
3983 | { | |
3984 | bgp_static = rn->info; | |
3985 | bgp_static_update (bgp, &rn->p, bgp_static, afi, safi); | |
3986 | } | |
3987 | bgp_flag_unset(bgp, BGP_FLAG_FORCE_STATIC_PROCESS); | |
3988 | } | |
3989 | ||
ad4cbda1 | 3990 | static void |
3991 | bgp_purge_af_static_redist_routes (struct bgp *bgp, afi_t afi, safi_t safi) | |
3992 | { | |
3993 | struct bgp_table *table; | |
3994 | struct bgp_node *rn; | |
3995 | struct bgp_info *ri; | |
3996 | ||
3997 | table = bgp->rib[afi][safi]; | |
3998 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3999 | { | |
4000 | for (ri = rn->info; ri; ri = ri->next) | |
4001 | { | |
4002 | if (ri->peer == bgp->peer_self && | |
4003 | ((ri->type == ZEBRA_ROUTE_BGP && | |
4004 | ri->sub_type == BGP_ROUTE_STATIC) || | |
4005 | (ri->type != ZEBRA_ROUTE_BGP && | |
4006 | ri->sub_type == BGP_ROUTE_REDISTRIBUTE))) | |
4007 | { | |
4008 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, safi); | |
4009 | bgp_unlink_nexthop(ri); | |
4010 | bgp_info_delete (rn, ri); | |
4011 | bgp_process (bgp, rn, afi, safi); | |
4012 | } | |
4013 | } | |
4014 | } | |
4015 | } | |
4016 | ||
4017 | /* | |
4018 | * Purge all networks and redistributed routes from routing table. | |
4019 | * Invoked upon the instance going down. | |
4020 | */ | |
4021 | void | |
4022 | bgp_purge_static_redist_routes (struct bgp *bgp) | |
4023 | { | |
4024 | afi_t afi; | |
4025 | safi_t safi; | |
4026 | ||
4027 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
4028 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
4029 | bgp_purge_af_static_redist_routes (bgp, afi, safi); | |
4030 | } | |
4031 | ||
137446f9 LB |
4032 | /* |
4033 | * gpz 110624 | |
4034 | * Currently this is used to set static routes for VPN and ENCAP. | |
4035 | * I think it can probably be factored with bgp_static_set. | |
4036 | */ | |
718e3744 | 4037 | int |
137446f9 LB |
4038 | bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, |
4039 | const char *rd_str, const char *tag_str, | |
4040 | const char *rmap_str) | |
718e3744 | 4041 | { |
4042 | int ret; | |
4043 | struct prefix p; | |
4044 | struct prefix_rd prd; | |
4045 | struct bgp *bgp; | |
4046 | struct bgp_node *prn; | |
4047 | struct bgp_node *rn; | |
4048 | struct bgp_table *table; | |
4049 | struct bgp_static *bgp_static; | |
4050 | u_char tag[3]; | |
4051 | ||
4052 | bgp = vty->index; | |
4053 | ||
4054 | ret = str2prefix (ip_str, &p); | |
4055 | if (! ret) | |
4056 | { | |
4057 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
4058 | return CMD_WARNING; | |
4059 | } | |
4060 | apply_mask (&p); | |
4061 | ||
4062 | ret = str2prefix_rd (rd_str, &prd); | |
4063 | if (! ret) | |
4064 | { | |
4065 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
4066 | return CMD_WARNING; | |
4067 | } | |
4068 | ||
4069 | ret = str2tag (tag_str, tag); | |
4070 | if (! ret) | |
4071 | { | |
4072 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
4073 | return CMD_WARNING; | |
4074 | } | |
4075 | ||
137446f9 | 4076 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
718e3744 | 4077 | (struct prefix *)&prd); |
4078 | if (prn->info == NULL) | |
137446f9 | 4079 | prn->info = bgp_table_init (AFI_IP, safi); |
718e3744 | 4080 | else |
4081 | bgp_unlock_node (prn); | |
4082 | table = prn->info; | |
4083 | ||
4084 | rn = bgp_node_get (table, &p); | |
4085 | ||
4086 | if (rn->info) | |
4087 | { | |
4088 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); | |
4089 | bgp_unlock_node (rn); | |
4090 | } | |
4091 | else | |
4092 | { | |
4093 | /* New configuration. */ | |
4094 | bgp_static = bgp_static_new (); | |
137446f9 LB |
4095 | bgp_static->backdoor = 0; |
4096 | bgp_static->valid = 0; | |
4097 | bgp_static->igpmetric = 0; | |
4098 | bgp_static->igpnexthop.s_addr = 0; | |
4099 | memcpy(bgp_static->tag, tag, 3); | |
4100 | bgp_static->prd = prd; | |
4101 | ||
4102 | if (rmap_str) | |
4103 | { | |
4104 | if (bgp_static->rmap.name) | |
4105 | free (bgp_static->rmap.name); | |
4106 | bgp_static->rmap.name = strdup (rmap_str); | |
4107 | bgp_static->rmap.map = route_map_lookup_by_name (rmap_str); | |
4108 | } | |
718e3744 | 4109 | rn->info = bgp_static; |
4110 | ||
137446f9 LB |
4111 | bgp_static->valid = 1; |
4112 | bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); | |
718e3744 | 4113 | } |
4114 | ||
4115 | return CMD_SUCCESS; | |
4116 | } | |
4117 | ||
4118 | /* Configure static BGP network. */ | |
4119 | int | |
137446f9 LB |
4120 | bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str, |
4121 | const char *rd_str, const char *tag_str) | |
718e3744 | 4122 | { |
4123 | int ret; | |
4124 | struct bgp *bgp; | |
4125 | struct prefix p; | |
4126 | struct prefix_rd prd; | |
4127 | struct bgp_node *prn; | |
4128 | struct bgp_node *rn; | |
4129 | struct bgp_table *table; | |
4130 | struct bgp_static *bgp_static; | |
4131 | u_char tag[3]; | |
4132 | ||
4133 | bgp = vty->index; | |
4134 | ||
4135 | /* Convert IP prefix string to struct prefix. */ | |
4136 | ret = str2prefix (ip_str, &p); | |
4137 | if (! ret) | |
4138 | { | |
4139 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
4140 | return CMD_WARNING; | |
4141 | } | |
4142 | apply_mask (&p); | |
4143 | ||
4144 | ret = str2prefix_rd (rd_str, &prd); | |
4145 | if (! ret) | |
4146 | { | |
4147 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
4148 | return CMD_WARNING; | |
4149 | } | |
4150 | ||
4151 | ret = str2tag (tag_str, tag); | |
4152 | if (! ret) | |
4153 | { | |
4154 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
4155 | return CMD_WARNING; | |
4156 | } | |
4157 | ||
137446f9 | 4158 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
718e3744 | 4159 | (struct prefix *)&prd); |
4160 | if (prn->info == NULL) | |
137446f9 | 4161 | prn->info = bgp_table_init (AFI_IP, safi); |
718e3744 | 4162 | else |
4163 | bgp_unlock_node (prn); | |
4164 | table = prn->info; | |
4165 | ||
4166 | rn = bgp_node_lookup (table, &p); | |
4167 | ||
4168 | if (rn) | |
4169 | { | |
137446f9 | 4170 | bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag); |
718e3744 | 4171 | |
4172 | bgp_static = rn->info; | |
4173 | bgp_static_free (bgp_static); | |
4174 | rn->info = NULL; | |
4175 | bgp_unlock_node (rn); | |
4176 | bgp_unlock_node (rn); | |
4177 | } | |
4178 | else | |
4179 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); | |
4180 | ||
4181 | return CMD_SUCCESS; | |
4182 | } | |
6b0655a2 | 4183 | |
73ac8160 DS |
4184 | static int |
4185 | bgp_table_map_set (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
4186 | const char *rmap_name) | |
4187 | { | |
4188 | struct bgp_rmap *rmap; | |
4189 | ||
4190 | rmap = &bgp->table_map[afi][safi]; | |
4191 | if (rmap_name) | |
4192 | { | |
4193 | if (rmap->name) | |
6e919709 DS |
4194 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); |
4195 | rmap->name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_name); | |
73ac8160 DS |
4196 | rmap->map = route_map_lookup_by_name (rmap_name); |
4197 | } | |
4198 | else | |
4199 | { | |
4200 | if (rmap->name) | |
6e919709 | 4201 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); |
73ac8160 DS |
4202 | rmap->name = NULL; |
4203 | rmap->map = NULL; | |
4204 | } | |
4205 | ||
4206 | bgp_zebra_announce_table(bgp, afi, safi); | |
4207 | ||
4208 | return CMD_SUCCESS; | |
4209 | } | |
4210 | ||
4211 | static int | |
4212 | bgp_table_map_unset (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
4213 | const char *rmap_name) | |
4214 | { | |
4215 | struct bgp_rmap *rmap; | |
4216 | ||
4217 | rmap = &bgp->table_map[afi][safi]; | |
4218 | if (rmap->name) | |
6e919709 | 4219 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); |
73ac8160 DS |
4220 | rmap->name = NULL; |
4221 | rmap->map = NULL; | |
4222 | ||
4223 | bgp_zebra_announce_table(bgp, afi, safi); | |
4224 | ||
4225 | return CMD_SUCCESS; | |
4226 | } | |
4227 | ||
4228 | int | |
4229 | bgp_config_write_table_map (struct vty *vty, struct bgp *bgp, afi_t afi, | |
4230 | safi_t safi, int *write) | |
4231 | { | |
4232 | if (bgp->table_map[afi][safi].name) | |
4233 | { | |
4234 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 4235 | vty_out (vty, " table-map %s%s", |
73ac8160 DS |
4236 | bgp->table_map[afi][safi].name, VTY_NEWLINE); |
4237 | } | |
4238 | ||
4239 | return 0; | |
4240 | } | |
4241 | ||
4242 | ||
4243 | DEFUN (bgp_table_map, | |
4244 | bgp_table_map_cmd, | |
4245 | "table-map WORD", | |
4246 | "BGP table to RIB route download filter\n" | |
4247 | "Name of the route map\n") | |
4248 | { | |
4249 | return bgp_table_map_set (vty, vty->index, | |
4250 | bgp_node_afi (vty), bgp_node_safi (vty), argv[0]); | |
4251 | } | |
4252 | DEFUN (no_bgp_table_map, | |
4253 | no_bgp_table_map_cmd, | |
4254 | "no table-map WORD", | |
4255 | "BGP table to RIB route download filter\n" | |
4256 | "Name of the route map\n") | |
4257 | { | |
4258 | return bgp_table_map_unset (vty, vty->index, | |
4259 | bgp_node_afi (vty), bgp_node_safi (vty), argv[0]); | |
4260 | } | |
4261 | ||
718e3744 | 4262 | DEFUN (bgp_network, |
4263 | bgp_network_cmd, | |
4264 | "network A.B.C.D/M", | |
4265 | "Specify a network to announce via BGP\n" | |
4266 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4267 | { | |
4268 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 4269 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4270 | } |
4271 | ||
4272 | DEFUN (bgp_network_route_map, | |
4273 | bgp_network_route_map_cmd, | |
4274 | "network A.B.C.D/M route-map WORD", | |
4275 | "Specify a network to announce via BGP\n" | |
4276 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4277 | "Route-map to modify the attributes\n" | |
4278 | "Name of the route map\n") | |
4279 | { | |
4280 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 4281 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4282 | } |
4283 | ||
4284 | DEFUN (bgp_network_backdoor, | |
4285 | bgp_network_backdoor_cmd, | |
4286 | "network A.B.C.D/M backdoor", | |
4287 | "Specify a network to announce via BGP\n" | |
4288 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4289 | "Specify a BGP backdoor route\n") | |
4290 | { | |
41367172 | 4291 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4292 | NULL, 1); |
718e3744 | 4293 | } |
4294 | ||
4295 | DEFUN (bgp_network_mask, | |
4296 | bgp_network_mask_cmd, | |
4297 | "network A.B.C.D mask A.B.C.D", | |
4298 | "Specify a network to announce via BGP\n" | |
4299 | "Network number\n" | |
4300 | "Network mask\n" | |
4301 | "Network mask\n") | |
4302 | { | |
4303 | int ret; | |
4304 | char prefix_str[BUFSIZ]; | |
41367172 | 4305 | |
718e3744 | 4306 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4307 | if (! ret) | |
4308 | { | |
4309 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4310 | return CMD_WARNING; | |
4311 | } | |
4312 | ||
4313 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4314 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4315 | } |
4316 | ||
4317 | DEFUN (bgp_network_mask_route_map, | |
4318 | bgp_network_mask_route_map_cmd, | |
4319 | "network A.B.C.D mask A.B.C.D route-map WORD", | |
4320 | "Specify a network to announce via BGP\n" | |
4321 | "Network number\n" | |
4322 | "Network mask\n" | |
4323 | "Network mask\n" | |
4324 | "Route-map to modify the attributes\n" | |
4325 | "Name of the route map\n") | |
4326 | { | |
4327 | int ret; | |
4328 | char prefix_str[BUFSIZ]; | |
41367172 | 4329 | |
718e3744 | 4330 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4331 | if (! ret) | |
4332 | { | |
4333 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4334 | return CMD_WARNING; | |
4335 | } | |
4336 | ||
4337 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4338 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
718e3744 | 4339 | } |
4340 | ||
4341 | DEFUN (bgp_network_mask_backdoor, | |
4342 | bgp_network_mask_backdoor_cmd, | |
4343 | "network A.B.C.D mask A.B.C.D backdoor", | |
4344 | "Specify a network to announce via BGP\n" | |
4345 | "Network number\n" | |
4346 | "Network mask\n" | |
4347 | "Network mask\n" | |
4348 | "Specify a BGP backdoor route\n") | |
4349 | { | |
4350 | int ret; | |
4351 | char prefix_str[BUFSIZ]; | |
41367172 | 4352 | |
718e3744 | 4353 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4354 | if (! ret) | |
4355 | { | |
4356 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4357 | return CMD_WARNING; | |
4358 | } | |
4359 | ||
41367172 | 4360 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4361 | NULL, 1); |
718e3744 | 4362 | } |
4363 | ||
4364 | DEFUN (bgp_network_mask_natural, | |
4365 | bgp_network_mask_natural_cmd, | |
4366 | "network A.B.C.D", | |
4367 | "Specify a network to announce via BGP\n" | |
4368 | "Network number\n") | |
4369 | { | |
4370 | int ret; | |
4371 | char prefix_str[BUFSIZ]; | |
4372 | ||
4373 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4374 | if (! ret) | |
4375 | { | |
4376 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4377 | return CMD_WARNING; | |
4378 | } | |
4379 | ||
4380 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4381 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4382 | } |
4383 | ||
4384 | DEFUN (bgp_network_mask_natural_route_map, | |
4385 | bgp_network_mask_natural_route_map_cmd, | |
4386 | "network A.B.C.D route-map WORD", | |
4387 | "Specify a network to announce via BGP\n" | |
4388 | "Network number\n" | |
4389 | "Route-map to modify the attributes\n" | |
4390 | "Name of the route map\n") | |
4391 | { | |
4392 | int ret; | |
4393 | char prefix_str[BUFSIZ]; | |
4394 | ||
4395 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4396 | if (! ret) | |
4397 | { | |
4398 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4399 | return CMD_WARNING; | |
4400 | } | |
4401 | ||
4402 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4403 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4404 | } |
4405 | ||
4406 | DEFUN (bgp_network_mask_natural_backdoor, | |
4407 | bgp_network_mask_natural_backdoor_cmd, | |
4408 | "network A.B.C.D backdoor", | |
4409 | "Specify a network to announce via BGP\n" | |
4410 | "Network number\n" | |
4411 | "Specify a BGP backdoor route\n") | |
4412 | { | |
4413 | int ret; | |
4414 | char prefix_str[BUFSIZ]; | |
4415 | ||
4416 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4417 | if (! ret) | |
4418 | { | |
4419 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4420 | return CMD_WARNING; | |
4421 | } | |
4422 | ||
41367172 | 4423 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4424 | NULL, 1); |
718e3744 | 4425 | } |
4426 | ||
4427 | DEFUN (no_bgp_network, | |
4428 | no_bgp_network_cmd, | |
4429 | "no network A.B.C.D/M", | |
4430 | NO_STR | |
4431 | "Specify a network to announce via BGP\n" | |
4432 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4433 | { | |
4434 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, | |
4435 | bgp_node_safi (vty)); | |
4436 | } | |
4437 | ||
4438 | ALIAS (no_bgp_network, | |
4439 | no_bgp_network_route_map_cmd, | |
4440 | "no network A.B.C.D/M route-map WORD", | |
4441 | NO_STR | |
4442 | "Specify a network to announce via BGP\n" | |
4443 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4444 | "Route-map to modify the attributes\n" | |
4445 | "Name of the route map\n") | |
4446 | ||
4447 | ALIAS (no_bgp_network, | |
4448 | no_bgp_network_backdoor_cmd, | |
4449 | "no network A.B.C.D/M backdoor", | |
4450 | NO_STR | |
4451 | "Specify a network to announce via BGP\n" | |
4452 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4453 | "Specify a BGP backdoor route\n") | |
4454 | ||
4455 | DEFUN (no_bgp_network_mask, | |
4456 | no_bgp_network_mask_cmd, | |
4457 | "no network A.B.C.D mask A.B.C.D", | |
4458 | NO_STR | |
4459 | "Specify a network to announce via BGP\n" | |
4460 | "Network number\n" | |
4461 | "Network mask\n" | |
4462 | "Network mask\n") | |
4463 | { | |
4464 | int ret; | |
4465 | char prefix_str[BUFSIZ]; | |
4466 | ||
4467 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4468 | if (! ret) | |
4469 | { | |
4470 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4471 | return CMD_WARNING; | |
4472 | } | |
4473 | ||
4474 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4475 | bgp_node_safi (vty)); | |
4476 | } | |
4477 | ||
4478 | ALIAS (no_bgp_network_mask, | |
4479 | no_bgp_network_mask_route_map_cmd, | |
4480 | "no network A.B.C.D mask A.B.C.D route-map WORD", | |
4481 | NO_STR | |
4482 | "Specify a network to announce via BGP\n" | |
4483 | "Network number\n" | |
4484 | "Network mask\n" | |
4485 | "Network mask\n" | |
4486 | "Route-map to modify the attributes\n" | |
4487 | "Name of the route map\n") | |
4488 | ||
4489 | ALIAS (no_bgp_network_mask, | |
4490 | no_bgp_network_mask_backdoor_cmd, | |
4491 | "no network A.B.C.D mask A.B.C.D backdoor", | |
4492 | NO_STR | |
4493 | "Specify a network to announce via BGP\n" | |
4494 | "Network number\n" | |
4495 | "Network mask\n" | |
4496 | "Network mask\n" | |
4497 | "Specify a BGP backdoor route\n") | |
4498 | ||
4499 | DEFUN (no_bgp_network_mask_natural, | |
4500 | no_bgp_network_mask_natural_cmd, | |
4501 | "no network A.B.C.D", | |
4502 | NO_STR | |
4503 | "Specify a network to announce via BGP\n" | |
4504 | "Network number\n") | |
4505 | { | |
4506 | int ret; | |
4507 | char prefix_str[BUFSIZ]; | |
4508 | ||
4509 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4510 | if (! ret) | |
4511 | { | |
4512 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4513 | return CMD_WARNING; | |
4514 | } | |
4515 | ||
4516 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4517 | bgp_node_safi (vty)); | |
4518 | } | |
4519 | ||
4520 | ALIAS (no_bgp_network_mask_natural, | |
4521 | no_bgp_network_mask_natural_route_map_cmd, | |
4522 | "no network A.B.C.D route-map WORD", | |
4523 | NO_STR | |
4524 | "Specify a network to announce via BGP\n" | |
4525 | "Network number\n" | |
4526 | "Route-map to modify the attributes\n" | |
4527 | "Name of the route map\n") | |
4528 | ||
4529 | ALIAS (no_bgp_network_mask_natural, | |
4530 | no_bgp_network_mask_natural_backdoor_cmd, | |
4531 | "no network A.B.C.D backdoor", | |
4532 | NO_STR | |
4533 | "Specify a network to announce via BGP\n" | |
4534 | "Network number\n" | |
4535 | "Specify a BGP backdoor route\n") | |
4536 | ||
4537 | #ifdef HAVE_IPV6 | |
4538 | DEFUN (ipv6_bgp_network, | |
4539 | ipv6_bgp_network_cmd, | |
4540 | "network X:X::X:X/M", | |
4541 | "Specify a network to announce via BGP\n" | |
4542 | "IPv6 prefix <network>/<length>\n") | |
4543 | { | |
73bfe0bd | 4544 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty), |
c8f3fe30 | 4545 | NULL, 0); |
718e3744 | 4546 | } |
4547 | ||
4548 | DEFUN (ipv6_bgp_network_route_map, | |
4549 | ipv6_bgp_network_route_map_cmd, | |
4550 | "network X:X::X:X/M route-map WORD", | |
4551 | "Specify a network to announce via BGP\n" | |
4552 | "IPv6 prefix <network>/<length>\n" | |
4553 | "Route-map to modify the attributes\n" | |
4554 | "Name of the route map\n") | |
4555 | { | |
4556 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, | |
c8f3fe30 | 4557 | bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4558 | } |
4559 | ||
4560 | DEFUN (no_ipv6_bgp_network, | |
4561 | no_ipv6_bgp_network_cmd, | |
4562 | "no network X:X::X:X/M", | |
4563 | NO_STR | |
4564 | "Specify a network to announce via BGP\n" | |
4565 | "IPv6 prefix <network>/<length>\n") | |
4566 | { | |
73bfe0bd | 4567 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty)); |
718e3744 | 4568 | } |
4569 | ||
4570 | ALIAS (no_ipv6_bgp_network, | |
4571 | no_ipv6_bgp_network_route_map_cmd, | |
4572 | "no network X:X::X:X/M route-map WORD", | |
4573 | NO_STR | |
4574 | "Specify a network to announce via BGP\n" | |
4575 | "IPv6 prefix <network>/<length>\n" | |
4576 | "Route-map to modify the attributes\n" | |
4577 | "Name of the route map\n") | |
4578 | ||
4579 | ALIAS (ipv6_bgp_network, | |
4580 | old_ipv6_bgp_network_cmd, | |
4581 | "ipv6 bgp network X:X::X:X/M", | |
4582 | IPV6_STR | |
4583 | BGP_STR | |
4584 | "Specify a network to announce via BGP\n" | |
4585 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4586 | ||
4587 | ALIAS (no_ipv6_bgp_network, | |
4588 | old_no_ipv6_bgp_network_cmd, | |
4589 | "no ipv6 bgp network X:X::X:X/M", | |
4590 | NO_STR | |
4591 | IPV6_STR | |
4592 | BGP_STR | |
4593 | "Specify a network to announce via BGP\n" | |
4594 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4595 | #endif /* HAVE_IPV6 */ | |
c8f3fe30 | 4596 | |
718e3744 | 4597 | /* Aggreagete address: |
4598 | ||
4599 | advertise-map Set condition to advertise attribute | |
4600 | as-set Generate AS set path information | |
4601 | attribute-map Set attributes of aggregate | |
4602 | route-map Set parameters of aggregate | |
4603 | summary-only Filter more specific routes from updates | |
4604 | suppress-map Conditionally filter more specific routes from updates | |
4605 | <cr> | |
4606 | */ | |
4607 | struct bgp_aggregate | |
4608 | { | |
4609 | /* Summary-only flag. */ | |
4610 | u_char summary_only; | |
4611 | ||
4612 | /* AS set generation. */ | |
4613 | u_char as_set; | |
4614 | ||
4615 | /* Route-map for aggregated route. */ | |
4616 | struct route_map *map; | |
4617 | ||
4618 | /* Suppress-count. */ | |
4619 | unsigned long count; | |
4620 | ||
4621 | /* SAFI configuration. */ | |
4622 | safi_t safi; | |
4623 | }; | |
4624 | ||
94f2b392 | 4625 | static struct bgp_aggregate * |
66e5cd87 | 4626 | bgp_aggregate_new (void) |
718e3744 | 4627 | { |
393deb9b | 4628 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
718e3744 | 4629 | } |
4630 | ||
94f2b392 | 4631 | static void |
718e3744 | 4632 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
4633 | { | |
4634 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); | |
4635 | } | |
4636 | ||
b5d58c32 | 4637 | /* Update an aggregate as routes are added/removed from the BGP table */ |
94f2b392 | 4638 | static void |
718e3744 | 4639 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
4640 | afi_t afi, safi_t safi, struct bgp_info *del, | |
4641 | struct bgp_aggregate *aggregate) | |
4642 | { | |
4643 | struct bgp_table *table; | |
4644 | struct bgp_node *top; | |
4645 | struct bgp_node *rn; | |
4646 | u_char origin; | |
4647 | struct aspath *aspath = NULL; | |
4648 | struct aspath *asmerge = NULL; | |
4649 | struct community *community = NULL; | |
4650 | struct community *commerge = NULL; | |
ffd0c037 | 4651 | #if defined(AGGREGATE_NEXTHOP_CHECK) |
718e3744 | 4652 | struct in_addr nexthop; |
4653 | u_int32_t med = 0; | |
ffd0c037 | 4654 | #endif |
718e3744 | 4655 | struct bgp_info *ri; |
4656 | struct bgp_info *new; | |
4657 | int first = 1; | |
4658 | unsigned long match = 0; | |
42f7e184 | 4659 | u_char atomic_aggregate = 0; |
718e3744 | 4660 | |
4661 | /* Record adding route's nexthop and med. */ | |
ffd0c037 DS |
4662 | if (rinew) |
4663 | { | |
4664 | #if defined(AGGREGATE_NEXTHOP_CHECK) | |
4665 | nexthop = rinew->attr->nexthop; | |
4666 | med = rinew->attr->med; | |
4667 | #endif | |
4668 | } | |
718e3744 | 4669 | |
4670 | /* ORIGIN attribute: If at least one route among routes that are | |
4671 | aggregated has ORIGIN with the value INCOMPLETE, then the | |
4672 | aggregated route must have the ORIGIN attribute with the value | |
4673 | INCOMPLETE. Otherwise, if at least one route among routes that | |
4674 | are aggregated has ORIGIN with the value EGP, then the aggregated | |
4675 | route must have the origin attribute with the value EGP. In all | |
4676 | other case the value of the ORIGIN attribute of the aggregated | |
4677 | route is INTERNAL. */ | |
4678 | origin = BGP_ORIGIN_IGP; | |
4679 | ||
4680 | table = bgp->rib[afi][safi]; | |
4681 | ||
4682 | top = bgp_node_get (table, p); | |
4683 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4684 | if (rn->p.prefixlen > p->prefixlen) | |
4685 | { | |
4686 | match = 0; | |
4687 | ||
4688 | for (ri = rn->info; ri; ri = ri->next) | |
4689 | { | |
4690 | if (BGP_INFO_HOLDDOWN (ri)) | |
4691 | continue; | |
4692 | ||
4693 | if (del && ri == del) | |
4694 | continue; | |
4695 | ||
4696 | if (! rinew && first) | |
4697 | { | |
ffd0c037 | 4698 | #if defined(AGGREGATE_NEXTHOP_CHECK) |
718e3744 | 4699 | nexthop = ri->attr->nexthop; |
4700 | med = ri->attr->med; | |
ffd0c037 | 4701 | #endif |
718e3744 | 4702 | first = 0; |
4703 | } | |
4704 | ||
4705 | #ifdef AGGREGATE_NEXTHOP_CHECK | |
4706 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) | |
4707 | || ri->attr->med != med) | |
4708 | { | |
4709 | if (aspath) | |
4710 | aspath_free (aspath); | |
4711 | if (community) | |
4712 | community_free (community); | |
4713 | bgp_unlock_node (rn); | |
4714 | bgp_unlock_node (top); | |
4715 | return; | |
4716 | } | |
4717 | #endif /* AGGREGATE_NEXTHOP_CHECK */ | |
4718 | ||
42f7e184 DS |
4719 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
4720 | atomic_aggregate = 1; | |
4721 | ||
718e3744 | 4722 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
4723 | { | |
4724 | if (aggregate->summary_only) | |
4725 | { | |
fb982c25 | 4726 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4727 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4728 | match++; |
4729 | } | |
4730 | ||
4731 | aggregate->count++; | |
4732 | ||
b5d58c32 DS |
4733 | if (origin < ri->attr->origin) |
4734 | origin = ri->attr->origin; | |
4735 | ||
718e3744 | 4736 | if (aggregate->as_set) |
4737 | { | |
718e3744 | 4738 | if (aspath) |
4739 | { | |
4740 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4741 | aspath_free (aspath); | |
4742 | aspath = asmerge; | |
4743 | } | |
4744 | else | |
4745 | aspath = aspath_dup (ri->attr->aspath); | |
4746 | ||
4747 | if (ri->attr->community) | |
4748 | { | |
4749 | if (community) | |
4750 | { | |
4751 | commerge = community_merge (community, | |
4752 | ri->attr->community); | |
4753 | community = community_uniq_sort (commerge); | |
4754 | community_free (commerge); | |
4755 | } | |
4756 | else | |
4757 | community = community_dup (ri->attr->community); | |
4758 | } | |
4759 | } | |
4760 | } | |
4761 | } | |
4762 | if (match) | |
4763 | bgp_process (bgp, rn, afi, safi); | |
4764 | } | |
4765 | bgp_unlock_node (top); | |
4766 | ||
4767 | if (rinew) | |
4768 | { | |
4769 | aggregate->count++; | |
4770 | ||
4771 | if (aggregate->summary_only) | |
fb982c25 | 4772 | (bgp_info_extra_get (rinew))->suppress++; |
718e3744 | 4773 | |
b5d58c32 DS |
4774 | if (origin < rinew->attr->origin) |
4775 | origin = rinew->attr->origin; | |
4776 | ||
718e3744 | 4777 | if (aggregate->as_set) |
4778 | { | |
718e3744 | 4779 | if (aspath) |
4780 | { | |
4781 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); | |
4782 | aspath_free (aspath); | |
4783 | aspath = asmerge; | |
4784 | } | |
4785 | else | |
4786 | aspath = aspath_dup (rinew->attr->aspath); | |
4787 | ||
4788 | if (rinew->attr->community) | |
4789 | { | |
4790 | if (community) | |
4791 | { | |
4792 | commerge = community_merge (community, | |
4793 | rinew->attr->community); | |
4794 | community = community_uniq_sort (commerge); | |
4795 | community_free (commerge); | |
4796 | } | |
4797 | else | |
4798 | community = community_dup (rinew->attr->community); | |
4799 | } | |
4800 | } | |
4801 | } | |
4802 | ||
4803 | if (aggregate->count > 0) | |
4804 | { | |
4805 | rn = bgp_node_get (table, p); | |
7c8ff89e | 4806 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self, |
fb018d25 | 4807 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
42f7e184 DS |
4808 | aggregate->as_set, |
4809 | atomic_aggregate), rn); | |
718e3744 | 4810 | SET_FLAG (new->flags, BGP_INFO_VALID); |
718e3744 | 4811 | |
4812 | bgp_info_add (rn, new); | |
200df115 | 4813 | bgp_unlock_node (rn); |
718e3744 | 4814 | bgp_process (bgp, rn, afi, safi); |
4815 | } | |
4816 | else | |
4817 | { | |
4818 | if (aspath) | |
4819 | aspath_free (aspath); | |
4820 | if (community) | |
4821 | community_free (community); | |
4822 | } | |
4823 | } | |
4824 | ||
4825 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, | |
4826 | struct bgp_aggregate *); | |
4827 | ||
4828 | void | |
4829 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, | |
4830 | struct bgp_info *ri, afi_t afi, safi_t safi) | |
4831 | { | |
4832 | struct bgp_node *child; | |
4833 | struct bgp_node *rn; | |
4834 | struct bgp_aggregate *aggregate; | |
f018db83 | 4835 | struct bgp_table *table; |
718e3744 | 4836 | |
4837 | /* MPLS-VPN aggregation is not yet supported. */ | |
587ff0fd | 4838 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 4839 | return; |
4840 | ||
f018db83 JBD |
4841 | table = bgp->aggregate[afi][safi]; |
4842 | ||
4843 | /* No aggregates configured. */ | |
67174041 | 4844 | if (bgp_table_top_nolock (table) == NULL) |
f018db83 JBD |
4845 | return; |
4846 | ||
718e3744 | 4847 | if (p->prefixlen == 0) |
4848 | return; | |
4849 | ||
4850 | if (BGP_INFO_HOLDDOWN (ri)) | |
4851 | return; | |
4852 | ||
bb782fb5 | 4853 | child = bgp_node_get (table, p); |
718e3744 | 4854 | |
4855 | /* Aggregate address configuration check. */ | |
67174041 | 4856 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
718e3744 | 4857 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
4858 | { | |
4859 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4860 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
718e3744 | 4861 | } |
4862 | bgp_unlock_node (child); | |
4863 | } | |
4864 | ||
4865 | void | |
4866 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, | |
4867 | struct bgp_info *del, afi_t afi, safi_t safi) | |
4868 | { | |
4869 | struct bgp_node *child; | |
4870 | struct bgp_node *rn; | |
4871 | struct bgp_aggregate *aggregate; | |
f018db83 | 4872 | struct bgp_table *table; |
718e3744 | 4873 | |
4874 | /* MPLS-VPN aggregation is not yet supported. */ | |
587ff0fd | 4875 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 4876 | return; |
4877 | ||
f018db83 JBD |
4878 | table = bgp->aggregate[afi][safi]; |
4879 | ||
4880 | /* No aggregates configured. */ | |
67174041 | 4881 | if (bgp_table_top_nolock (table) == NULL) |
f018db83 JBD |
4882 | return; |
4883 | ||
718e3744 | 4884 | if (p->prefixlen == 0) |
4885 | return; | |
4886 | ||
bb782fb5 | 4887 | child = bgp_node_get (table, p); |
718e3744 | 4888 | |
4889 | /* Aggregate address configuration check. */ | |
67174041 | 4890 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
718e3744 | 4891 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
4892 | { | |
4893 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4894 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
718e3744 | 4895 | } |
4896 | bgp_unlock_node (child); | |
4897 | } | |
4898 | ||
b5d58c32 | 4899 | /* Called via bgp_aggregate_set when the user configures aggregate-address */ |
94f2b392 | 4900 | static void |
718e3744 | 4901 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
4902 | struct bgp_aggregate *aggregate) | |
4903 | { | |
4904 | struct bgp_table *table; | |
4905 | struct bgp_node *top; | |
4906 | struct bgp_node *rn; | |
4907 | struct bgp_info *new; | |
4908 | struct bgp_info *ri; | |
4909 | unsigned long match; | |
4910 | u_char origin = BGP_ORIGIN_IGP; | |
4911 | struct aspath *aspath = NULL; | |
4912 | struct aspath *asmerge = NULL; | |
4913 | struct community *community = NULL; | |
4914 | struct community *commerge = NULL; | |
42f7e184 | 4915 | u_char atomic_aggregate = 0; |
718e3744 | 4916 | |
4917 | table = bgp->rib[afi][safi]; | |
4918 | ||
4919 | /* Sanity check. */ | |
4920 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4921 | return; | |
4922 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4923 | return; | |
4924 | ||
4925 | /* If routes exists below this node, generate aggregate routes. */ | |
4926 | top = bgp_node_get (table, p); | |
4927 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4928 | if (rn->p.prefixlen > p->prefixlen) | |
4929 | { | |
4930 | match = 0; | |
4931 | ||
4932 | for (ri = rn->info; ri; ri = ri->next) | |
4933 | { | |
4934 | if (BGP_INFO_HOLDDOWN (ri)) | |
4935 | continue; | |
4936 | ||
42f7e184 DS |
4937 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
4938 | atomic_aggregate = 1; | |
4939 | ||
718e3744 | 4940 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
4941 | { | |
4942 | /* summary-only aggregate route suppress aggregated | |
4943 | route announcement. */ | |
4944 | if (aggregate->summary_only) | |
4945 | { | |
fb982c25 | 4946 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4947 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4948 | match++; |
4949 | } | |
b5d58c32 DS |
4950 | |
4951 | /* If at least one route among routes that are aggregated has | |
4952 | * ORIGIN with the value INCOMPLETE, then the aggregated route | |
4953 | * MUST have the ORIGIN attribute with the value INCOMPLETE. | |
4954 | * Otherwise, if at least one route among routes that are | |
4955 | * aggregated has ORIGIN with the value EGP, then the aggregated | |
4956 | * route MUST have the ORIGIN attribute with the value EGP. | |
4957 | */ | |
4958 | if (origin < ri->attr->origin) | |
4959 | origin = ri->attr->origin; | |
4960 | ||
718e3744 | 4961 | /* as-set aggregate route generate origin, as path, |
4962 | community aggregation. */ | |
4963 | if (aggregate->as_set) | |
4964 | { | |
718e3744 | 4965 | if (aspath) |
4966 | { | |
4967 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4968 | aspath_free (aspath); | |
4969 | aspath = asmerge; | |
4970 | } | |
4971 | else | |
4972 | aspath = aspath_dup (ri->attr->aspath); | |
4973 | ||
4974 | if (ri->attr->community) | |
4975 | { | |
4976 | if (community) | |
4977 | { | |
4978 | commerge = community_merge (community, | |
4979 | ri->attr->community); | |
4980 | community = community_uniq_sort (commerge); | |
4981 | community_free (commerge); | |
4982 | } | |
4983 | else | |
4984 | community = community_dup (ri->attr->community); | |
4985 | } | |
4986 | } | |
4987 | aggregate->count++; | |
4988 | } | |
4989 | } | |
4990 | ||
4991 | /* If this node is suppressed, process the change. */ | |
4992 | if (match) | |
4993 | bgp_process (bgp, rn, afi, safi); | |
4994 | } | |
4995 | bgp_unlock_node (top); | |
4996 | ||
4997 | /* Add aggregate route to BGP table. */ | |
4998 | if (aggregate->count) | |
4999 | { | |
5000 | rn = bgp_node_get (table, p); | |
7c8ff89e | 5001 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self, |
fb018d25 | 5002 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
42f7e184 DS |
5003 | aggregate->as_set, |
5004 | atomic_aggregate), rn); | |
718e3744 | 5005 | SET_FLAG (new->flags, BGP_INFO_VALID); |
718e3744 | 5006 | |
5007 | bgp_info_add (rn, new); | |
200df115 | 5008 | bgp_unlock_node (rn); |
5009 | ||
718e3744 | 5010 | /* Process change. */ |
5011 | bgp_process (bgp, rn, afi, safi); | |
5012 | } | |
610f23cf DV |
5013 | else |
5014 | { | |
5015 | if (aspath) | |
5016 | aspath_free (aspath); | |
5017 | if (community) | |
5018 | community_free (community); | |
5019 | } | |
718e3744 | 5020 | } |
5021 | ||
5022 | void | |
5023 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, | |
5024 | safi_t safi, struct bgp_aggregate *aggregate) | |
5025 | { | |
5026 | struct bgp_table *table; | |
5027 | struct bgp_node *top; | |
5028 | struct bgp_node *rn; | |
5029 | struct bgp_info *ri; | |
5030 | unsigned long match; | |
5031 | ||
5032 | table = bgp->rib[afi][safi]; | |
5033 | ||
5034 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
5035 | return; | |
5036 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
5037 | return; | |
5038 | ||
5039 | /* If routes exists below this node, generate aggregate routes. */ | |
5040 | top = bgp_node_get (table, p); | |
5041 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
5042 | if (rn->p.prefixlen > p->prefixlen) | |
5043 | { | |
5044 | match = 0; | |
5045 | ||
5046 | for (ri = rn->info; ri; ri = ri->next) | |
5047 | { | |
5048 | if (BGP_INFO_HOLDDOWN (ri)) | |
5049 | continue; | |
5050 | ||
5051 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
5052 | { | |
fb982c25 | 5053 | if (aggregate->summary_only && ri->extra) |
718e3744 | 5054 | { |
fb982c25 | 5055 | ri->extra->suppress--; |
718e3744 | 5056 | |
fb982c25 | 5057 | if (ri->extra->suppress == 0) |
718e3744 | 5058 | { |
1a392d46 | 5059 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 5060 | match++; |
5061 | } | |
5062 | } | |
5063 | aggregate->count--; | |
5064 | } | |
5065 | } | |
5066 | ||
fb982c25 | 5067 | /* If this node was suppressed, process the change. */ |
718e3744 | 5068 | if (match) |
5069 | bgp_process (bgp, rn, afi, safi); | |
5070 | } | |
5071 | bgp_unlock_node (top); | |
5072 | ||
5073 | /* Delete aggregate route from BGP table. */ | |
5074 | rn = bgp_node_get (table, p); | |
5075 | ||
5076 | for (ri = rn->info; ri; ri = ri->next) | |
5077 | if (ri->peer == bgp->peer_self | |
5078 | && ri->type == ZEBRA_ROUTE_BGP | |
5079 | && ri->sub_type == BGP_ROUTE_AGGREGATE) | |
5080 | break; | |
5081 | ||
5082 | /* Withdraw static BGP route from routing table. */ | |
5083 | if (ri) | |
5084 | { | |
718e3744 | 5085 | bgp_info_delete (rn, ri); |
1a392d46 | 5086 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 5087 | } |
5088 | ||
5089 | /* Unlock bgp_node_lookup. */ | |
5090 | bgp_unlock_node (rn); | |
5091 | } | |
5092 | ||
5093 | /* Aggregate route attribute. */ | |
5094 | #define AGGREGATE_SUMMARY_ONLY 1 | |
5095 | #define AGGREGATE_AS_SET 1 | |
5096 | ||
94f2b392 | 5097 | static int |
f6269b4f RB |
5098 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
5099 | afi_t afi, safi_t safi) | |
718e3744 | 5100 | { |
5101 | int ret; | |
5102 | struct prefix p; | |
5103 | struct bgp_node *rn; | |
5104 | struct bgp *bgp; | |
5105 | struct bgp_aggregate *aggregate; | |
5106 | ||
5107 | /* Convert string to prefix structure. */ | |
5108 | ret = str2prefix (prefix_str, &p); | |
5109 | if (!ret) | |
5110 | { | |
5111 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
5112 | return CMD_WARNING; | |
5113 | } | |
5114 | apply_mask (&p); | |
5115 | ||
5116 | /* Get BGP structure. */ | |
5117 | bgp = vty->index; | |
5118 | ||
5119 | /* Old configuration check. */ | |
f6269b4f RB |
5120 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
5121 | if (! rn) | |
718e3744 | 5122 | { |
f6269b4f RB |
5123 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
5124 | VTY_NEWLINE); | |
718e3744 | 5125 | return CMD_WARNING; |
5126 | } | |
5127 | ||
f6269b4f RB |
5128 | aggregate = rn->info; |
5129 | if (aggregate->safi & SAFI_UNICAST) | |
5130 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
5131 | if (aggregate->safi & SAFI_MULTICAST) | |
5132 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 5133 | |
f6269b4f RB |
5134 | /* Unlock aggregate address configuration. */ |
5135 | rn->info = NULL; | |
5136 | bgp_aggregate_free (aggregate); | |
5137 | bgp_unlock_node (rn); | |
5138 | bgp_unlock_node (rn); | |
718e3744 | 5139 | |
5140 | return CMD_SUCCESS; | |
5141 | } | |
5142 | ||
94f2b392 | 5143 | static int |
f6269b4f RB |
5144 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
5145 | afi_t afi, safi_t safi, | |
5146 | u_char summary_only, u_char as_set) | |
718e3744 | 5147 | { |
5148 | int ret; | |
5149 | struct prefix p; | |
5150 | struct bgp_node *rn; | |
5151 | struct bgp *bgp; | |
5152 | struct bgp_aggregate *aggregate; | |
5153 | ||
5154 | /* Convert string to prefix structure. */ | |
5155 | ret = str2prefix (prefix_str, &p); | |
5156 | if (!ret) | |
5157 | { | |
5158 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
5159 | return CMD_WARNING; | |
5160 | } | |
5161 | apply_mask (&p); | |
5162 | ||
5163 | /* Get BGP structure. */ | |
5164 | bgp = vty->index; | |
5165 | ||
5166 | /* Old configuration check. */ | |
f6269b4f RB |
5167 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
5168 | ||
5169 | if (rn->info) | |
718e3744 | 5170 | { |
f6269b4f | 5171 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
368473f6 | 5172 | /* try to remove the old entry */ |
f6269b4f RB |
5173 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
5174 | if (ret) | |
5175 | { | |
368473f6 RB |
5176 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
5177 | bgp_unlock_node (rn); | |
f6269b4f RB |
5178 | return CMD_WARNING; |
5179 | } | |
718e3744 | 5180 | } |
5181 | ||
f6269b4f RB |
5182 | /* Make aggregate address structure. */ |
5183 | aggregate = bgp_aggregate_new (); | |
5184 | aggregate->summary_only = summary_only; | |
5185 | aggregate->as_set = as_set; | |
5186 | aggregate->safi = safi; | |
5187 | rn->info = aggregate; | |
718e3744 | 5188 | |
f6269b4f RB |
5189 | /* Aggregate address insert into BGP routing table. */ |
5190 | if (safi & SAFI_UNICAST) | |
5191 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
5192 | if (safi & SAFI_MULTICAST) | |
5193 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 5194 | |
5195 | return CMD_SUCCESS; | |
5196 | } | |
5197 | ||
5198 | DEFUN (aggregate_address, | |
5199 | aggregate_address_cmd, | |
5200 | "aggregate-address A.B.C.D/M", | |
5201 | "Configure BGP aggregate entries\n" | |
5202 | "Aggregate prefix\n") | |
5203 | { | |
5204 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); | |
5205 | } | |
5206 | ||
5207 | DEFUN (aggregate_address_mask, | |
5208 | aggregate_address_mask_cmd, | |
5209 | "aggregate-address A.B.C.D A.B.C.D", | |
5210 | "Configure BGP aggregate entries\n" | |
5211 | "Aggregate address\n" | |
5212 | "Aggregate mask\n") | |
5213 | { | |
5214 | int ret; | |
5215 | char prefix_str[BUFSIZ]; | |
5216 | ||
5217 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5218 | ||
5219 | if (! ret) | |
5220 | { | |
5221 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5222 | return CMD_WARNING; | |
5223 | } | |
5224 | ||
5225 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5226 | 0, 0); | |
5227 | } | |
5228 | ||
5229 | DEFUN (aggregate_address_summary_only, | |
5230 | aggregate_address_summary_only_cmd, | |
5231 | "aggregate-address A.B.C.D/M summary-only", | |
5232 | "Configure BGP aggregate entries\n" | |
5233 | "Aggregate prefix\n" | |
5234 | "Filter more specific routes from updates\n") | |
5235 | { | |
5236 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5237 | AGGREGATE_SUMMARY_ONLY, 0); | |
5238 | } | |
5239 | ||
5240 | DEFUN (aggregate_address_mask_summary_only, | |
5241 | aggregate_address_mask_summary_only_cmd, | |
5242 | "aggregate-address A.B.C.D A.B.C.D summary-only", | |
5243 | "Configure BGP aggregate entries\n" | |
5244 | "Aggregate address\n" | |
5245 | "Aggregate mask\n" | |
5246 | "Filter more specific routes from updates\n") | |
5247 | { | |
5248 | int ret; | |
5249 | char prefix_str[BUFSIZ]; | |
5250 | ||
5251 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5252 | ||
5253 | if (! ret) | |
5254 | { | |
5255 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5256 | return CMD_WARNING; | |
5257 | } | |
5258 | ||
5259 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5260 | AGGREGATE_SUMMARY_ONLY, 0); | |
5261 | } | |
5262 | ||
5263 | DEFUN (aggregate_address_as_set, | |
5264 | aggregate_address_as_set_cmd, | |
5265 | "aggregate-address A.B.C.D/M as-set", | |
5266 | "Configure BGP aggregate entries\n" | |
5267 | "Aggregate prefix\n" | |
5268 | "Generate AS set path information\n") | |
5269 | { | |
5270 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5271 | 0, AGGREGATE_AS_SET); | |
5272 | } | |
5273 | ||
5274 | DEFUN (aggregate_address_mask_as_set, | |
5275 | aggregate_address_mask_as_set_cmd, | |
5276 | "aggregate-address A.B.C.D A.B.C.D as-set", | |
5277 | "Configure BGP aggregate entries\n" | |
5278 | "Aggregate address\n" | |
5279 | "Aggregate mask\n" | |
5280 | "Generate AS set path information\n") | |
5281 | { | |
5282 | int ret; | |
5283 | char prefix_str[BUFSIZ]; | |
5284 | ||
5285 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5286 | ||
5287 | if (! ret) | |
5288 | { | |
5289 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5290 | return CMD_WARNING; | |
5291 | } | |
5292 | ||
5293 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5294 | 0, AGGREGATE_AS_SET); | |
5295 | } | |
5296 | ||
5297 | ||
5298 | DEFUN (aggregate_address_as_set_summary, | |
5299 | aggregate_address_as_set_summary_cmd, | |
5300 | "aggregate-address A.B.C.D/M as-set summary-only", | |
5301 | "Configure BGP aggregate entries\n" | |
5302 | "Aggregate prefix\n" | |
5303 | "Generate AS set path information\n" | |
5304 | "Filter more specific routes from updates\n") | |
5305 | { | |
5306 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5307 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5308 | } | |
5309 | ||
5310 | ALIAS (aggregate_address_as_set_summary, | |
5311 | aggregate_address_summary_as_set_cmd, | |
5312 | "aggregate-address A.B.C.D/M summary-only as-set", | |
5313 | "Configure BGP aggregate entries\n" | |
5314 | "Aggregate prefix\n" | |
5315 | "Filter more specific routes from updates\n" | |
5316 | "Generate AS set path information\n") | |
5317 | ||
5318 | DEFUN (aggregate_address_mask_as_set_summary, | |
5319 | aggregate_address_mask_as_set_summary_cmd, | |
5320 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5321 | "Configure BGP aggregate entries\n" | |
5322 | "Aggregate address\n" | |
5323 | "Aggregate mask\n" | |
5324 | "Generate AS set path information\n" | |
5325 | "Filter more specific routes from updates\n") | |
5326 | { | |
5327 | int ret; | |
5328 | char prefix_str[BUFSIZ]; | |
5329 | ||
5330 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5331 | ||
5332 | if (! ret) | |
5333 | { | |
5334 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5335 | return CMD_WARNING; | |
5336 | } | |
5337 | ||
5338 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5339 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5340 | } | |
5341 | ||
5342 | ALIAS (aggregate_address_mask_as_set_summary, | |
5343 | aggregate_address_mask_summary_as_set_cmd, | |
5344 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5345 | "Configure BGP aggregate entries\n" | |
5346 | "Aggregate address\n" | |
5347 | "Aggregate mask\n" | |
5348 | "Filter more specific routes from updates\n" | |
5349 | "Generate AS set path information\n") | |
5350 | ||
5351 | DEFUN (no_aggregate_address, | |
5352 | no_aggregate_address_cmd, | |
5353 | "no aggregate-address A.B.C.D/M", | |
5354 | NO_STR | |
5355 | "Configure BGP aggregate entries\n" | |
5356 | "Aggregate prefix\n") | |
5357 | { | |
5358 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); | |
5359 | } | |
5360 | ||
5361 | ALIAS (no_aggregate_address, | |
5362 | no_aggregate_address_summary_only_cmd, | |
5363 | "no aggregate-address A.B.C.D/M summary-only", | |
5364 | NO_STR | |
5365 | "Configure BGP aggregate entries\n" | |
5366 | "Aggregate prefix\n" | |
5367 | "Filter more specific routes from updates\n") | |
5368 | ||
5369 | ALIAS (no_aggregate_address, | |
5370 | no_aggregate_address_as_set_cmd, | |
5371 | "no aggregate-address A.B.C.D/M as-set", | |
5372 | NO_STR | |
5373 | "Configure BGP aggregate entries\n" | |
5374 | "Aggregate prefix\n" | |
5375 | "Generate AS set path information\n") | |
5376 | ||
5377 | ALIAS (no_aggregate_address, | |
5378 | no_aggregate_address_as_set_summary_cmd, | |
5379 | "no aggregate-address A.B.C.D/M as-set summary-only", | |
5380 | NO_STR | |
5381 | "Configure BGP aggregate entries\n" | |
5382 | "Aggregate prefix\n" | |
5383 | "Generate AS set path information\n" | |
5384 | "Filter more specific routes from updates\n") | |
5385 | ||
5386 | ALIAS (no_aggregate_address, | |
5387 | no_aggregate_address_summary_as_set_cmd, | |
5388 | "no aggregate-address A.B.C.D/M summary-only as-set", | |
5389 | NO_STR | |
5390 | "Configure BGP aggregate entries\n" | |
5391 | "Aggregate prefix\n" | |
5392 | "Filter more specific routes from updates\n" | |
5393 | "Generate AS set path information\n") | |
5394 | ||
5395 | DEFUN (no_aggregate_address_mask, | |
5396 | no_aggregate_address_mask_cmd, | |
5397 | "no aggregate-address A.B.C.D A.B.C.D", | |
5398 | NO_STR | |
5399 | "Configure BGP aggregate entries\n" | |
5400 | "Aggregate address\n" | |
5401 | "Aggregate mask\n") | |
5402 | { | |
5403 | int ret; | |
5404 | char prefix_str[BUFSIZ]; | |
5405 | ||
5406 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5407 | ||
5408 | if (! ret) | |
5409 | { | |
5410 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5411 | return CMD_WARNING; | |
5412 | } | |
5413 | ||
5414 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); | |
5415 | } | |
5416 | ||
5417 | ALIAS (no_aggregate_address_mask, | |
5418 | no_aggregate_address_mask_summary_only_cmd, | |
5419 | "no aggregate-address A.B.C.D A.B.C.D summary-only", | |
5420 | NO_STR | |
5421 | "Configure BGP aggregate entries\n" | |
5422 | "Aggregate address\n" | |
5423 | "Aggregate mask\n" | |
5424 | "Filter more specific routes from updates\n") | |
5425 | ||
5426 | ALIAS (no_aggregate_address_mask, | |
5427 | no_aggregate_address_mask_as_set_cmd, | |
5428 | "no aggregate-address A.B.C.D A.B.C.D as-set", | |
5429 | NO_STR | |
5430 | "Configure BGP aggregate entries\n" | |
5431 | "Aggregate address\n" | |
5432 | "Aggregate mask\n" | |
5433 | "Generate AS set path information\n") | |
5434 | ||
5435 | ALIAS (no_aggregate_address_mask, | |
5436 | no_aggregate_address_mask_as_set_summary_cmd, | |
5437 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5438 | NO_STR | |
5439 | "Configure BGP aggregate entries\n" | |
5440 | "Aggregate address\n" | |
5441 | "Aggregate mask\n" | |
5442 | "Generate AS set path information\n" | |
5443 | "Filter more specific routes from updates\n") | |
5444 | ||
5445 | ALIAS (no_aggregate_address_mask, | |
5446 | no_aggregate_address_mask_summary_as_set_cmd, | |
5447 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5448 | NO_STR | |
5449 | "Configure BGP aggregate entries\n" | |
5450 | "Aggregate address\n" | |
5451 | "Aggregate mask\n" | |
5452 | "Filter more specific routes from updates\n" | |
5453 | "Generate AS set path information\n") | |
5454 | ||
5455 | #ifdef HAVE_IPV6 | |
5456 | DEFUN (ipv6_aggregate_address, | |
5457 | ipv6_aggregate_address_cmd, | |
5458 | "aggregate-address X:X::X:X/M", | |
5459 | "Configure BGP aggregate entries\n" | |
5460 | "Aggregate prefix\n") | |
5461 | { | |
5462 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); | |
5463 | } | |
5464 | ||
5465 | DEFUN (ipv6_aggregate_address_summary_only, | |
5466 | ipv6_aggregate_address_summary_only_cmd, | |
5467 | "aggregate-address X:X::X:X/M summary-only", | |
5468 | "Configure BGP aggregate entries\n" | |
5469 | "Aggregate prefix\n" | |
5470 | "Filter more specific routes from updates\n") | |
5471 | { | |
5472 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
5473 | AGGREGATE_SUMMARY_ONLY, 0); | |
5474 | } | |
5475 | ||
5476 | DEFUN (no_ipv6_aggregate_address, | |
5477 | no_ipv6_aggregate_address_cmd, | |
5478 | "no aggregate-address X:X::X:X/M", | |
5479 | NO_STR | |
5480 | "Configure BGP aggregate entries\n" | |
5481 | "Aggregate prefix\n") | |
5482 | { | |
5483 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5484 | } | |
5485 | ||
5486 | DEFUN (no_ipv6_aggregate_address_summary_only, | |
5487 | no_ipv6_aggregate_address_summary_only_cmd, | |
5488 | "no aggregate-address X:X::X:X/M summary-only", | |
5489 | NO_STR | |
5490 | "Configure BGP aggregate entries\n" | |
5491 | "Aggregate prefix\n" | |
5492 | "Filter more specific routes from updates\n") | |
5493 | { | |
5494 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5495 | } | |
5496 | ||
5497 | ALIAS (ipv6_aggregate_address, | |
5498 | old_ipv6_aggregate_address_cmd, | |
5499 | "ipv6 bgp aggregate-address X:X::X:X/M", | |
5500 | IPV6_STR | |
5501 | BGP_STR | |
5502 | "Configure BGP aggregate entries\n" | |
5503 | "Aggregate prefix\n") | |
5504 | ||
5505 | ALIAS (ipv6_aggregate_address_summary_only, | |
5506 | old_ipv6_aggregate_address_summary_only_cmd, | |
5507 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5508 | IPV6_STR | |
5509 | BGP_STR | |
5510 | "Configure BGP aggregate entries\n" | |
5511 | "Aggregate prefix\n" | |
5512 | "Filter more specific routes from updates\n") | |
5513 | ||
5514 | ALIAS (no_ipv6_aggregate_address, | |
5515 | old_no_ipv6_aggregate_address_cmd, | |
5516 | "no ipv6 bgp aggregate-address X:X::X:X/M", | |
5517 | NO_STR | |
5518 | IPV6_STR | |
5519 | BGP_STR | |
5520 | "Configure BGP aggregate entries\n" | |
5521 | "Aggregate prefix\n") | |
5522 | ||
5523 | ALIAS (no_ipv6_aggregate_address_summary_only, | |
5524 | old_no_ipv6_aggregate_address_summary_only_cmd, | |
5525 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5526 | NO_STR | |
5527 | IPV6_STR | |
5528 | BGP_STR | |
5529 | "Configure BGP aggregate entries\n" | |
5530 | "Aggregate prefix\n" | |
5531 | "Filter more specific routes from updates\n") | |
5532 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 5533 | |
718e3744 | 5534 | /* Redistribute route treatment. */ |
5535 | void | |
6aeb9e78 | 5536 | bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *nexthop, |
bc413143 | 5537 | const struct in6_addr *nexthop6, unsigned int ifindex, |
7c8ff89e | 5538 | u_int32_t metric, u_char type, u_short instance, u_short tag) |
718e3744 | 5539 | { |
718e3744 | 5540 | struct bgp_info *new; |
5541 | struct bgp_info *bi; | |
5542 | struct bgp_info info; | |
5543 | struct bgp_node *bn; | |
e16a4133 | 5544 | struct attr attr; |
718e3744 | 5545 | struct attr *new_attr; |
5546 | afi_t afi; | |
5547 | int ret; | |
7c8ff89e | 5548 | struct bgp_redist *red; |
718e3744 | 5549 | |
5550 | /* Make default attribute. */ | |
5551 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); | |
5552 | if (nexthop) | |
5553 | attr.nexthop = *nexthop; | |
bc413143 | 5554 | attr.nh_ifindex = ifindex; |
718e3744 | 5555 | |
f04a80a5 SH |
5556 | #ifdef HAVE_IPV6 |
5557 | if (nexthop6) | |
5558 | { | |
5559 | struct attr_extra *extra = bgp_attr_extra_get(&attr); | |
5560 | extra->mp_nexthop_global = *nexthop6; | |
801a9bcc | 5561 | extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; |
f04a80a5 SH |
5562 | } |
5563 | #endif | |
5564 | ||
718e3744 | 5565 | attr.med = metric; |
5566 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
0d9551dc | 5567 | attr.extra->tag = tag; |
718e3744 | 5568 | |
6aeb9e78 DS |
5569 | afi = family2afi (p->family); |
5570 | ||
5571 | red = bgp_redist_lookup(bgp, afi, type, instance); | |
5572 | if (red) | |
718e3744 | 5573 | { |
6aeb9e78 DS |
5574 | struct attr attr_new; |
5575 | struct attr_extra extra_new; | |
718e3744 | 5576 | |
6aeb9e78 DS |
5577 | /* Copy attribute for modification. */ |
5578 | attr_new.extra = &extra_new; | |
5579 | bgp_attr_dup (&attr_new, &attr); | |
558d1fec | 5580 | |
6aeb9e78 DS |
5581 | if (red->redist_metric_flag) |
5582 | attr_new.med = red->redist_metric; | |
718e3744 | 5583 | |
6aeb9e78 DS |
5584 | /* Apply route-map. */ |
5585 | if (red->rmap.name) | |
5586 | { | |
5587 | info.peer = bgp->peer_self; | |
5588 | info.attr = &attr_new; | |
718e3744 | 5589 | |
6aeb9e78 | 5590 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
718e3744 | 5591 | |
6aeb9e78 | 5592 | ret = route_map_apply (red->rmap.map, p, RMAP_BGP, &info); |
fee0f4c6 | 5593 | |
6aeb9e78 | 5594 | bgp->peer_self->rmap_type = 0; |
fee0f4c6 | 5595 | |
6aeb9e78 DS |
5596 | if (ret == RMAP_DENYMATCH) |
5597 | { | |
5598 | /* Free uninterned attribute. */ | |
5599 | bgp_attr_flush (&attr_new); | |
5600 | ||
5601 | /* Unintern original. */ | |
5602 | aspath_unintern (&attr.aspath); | |
5603 | bgp_attr_extra_free (&attr); | |
5604 | bgp_redistribute_delete (bgp, p, type, instance); | |
5605 | return; | |
5606 | } | |
5607 | } | |
fee0f4c6 | 5608 | |
6aeb9e78 DS |
5609 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
5610 | afi, SAFI_UNICAST, p, NULL); | |
718e3744 | 5611 | |
6aeb9e78 | 5612 | new_attr = bgp_attr_intern (&attr_new); |
558d1fec | 5613 | |
6aeb9e78 DS |
5614 | for (bi = bn->info; bi; bi = bi->next) |
5615 | if (bi->peer == bgp->peer_self | |
5616 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
5617 | break; | |
5618 | ||
5619 | if (bi) | |
5620 | { | |
5621 | /* Ensure the (source route) type is updated. */ | |
5622 | bi->type = type; | |
5623 | if (attrhash_cmp (bi->attr, new_attr) && | |
5624 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
5625 | { | |
5626 | bgp_attr_unintern (&new_attr); | |
5627 | aspath_unintern (&attr.aspath); | |
5628 | bgp_attr_extra_free (&attr); | |
5629 | bgp_unlock_node (bn); | |
5630 | return; | |
5631 | } | |
5632 | else | |
5633 | { | |
5634 | /* The attribute is changed. */ | |
5635 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); | |
718e3744 | 5636 | |
6aeb9e78 DS |
5637 | /* Rewrite BGP route information. */ |
5638 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
5639 | bgp_info_restore(bn, bi); | |
5640 | else | |
5641 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); | |
5642 | bgp_attr_unintern (&bi->attr); | |
5643 | bi->attr = new_attr; | |
5644 | bi->uptime = bgp_clock (); | |
5645 | ||
5646 | /* Process change. */ | |
5647 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); | |
5648 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
5649 | bgp_unlock_node (bn); | |
5650 | aspath_unintern (&attr.aspath); | |
5651 | bgp_attr_extra_free (&attr); | |
5652 | return; | |
5653 | } | |
5654 | } | |
718e3744 | 5655 | |
6aeb9e78 DS |
5656 | new = info_make(type, BGP_ROUTE_REDISTRIBUTE, instance, bgp->peer_self, |
5657 | new_attr, bn); | |
5658 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
5659 | ||
5660 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); | |
5661 | bgp_info_add (bn, new); | |
5662 | bgp_unlock_node (bn); | |
5663 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
718e3744 | 5664 | } |
5665 | ||
5666 | /* Unintern original. */ | |
f6f434b2 | 5667 | aspath_unintern (&attr.aspath); |
fb982c25 | 5668 | bgp_attr_extra_free (&attr); |
718e3744 | 5669 | } |
5670 | ||
5671 | void | |
6aeb9e78 | 5672 | bgp_redistribute_delete (struct bgp *bgp, struct prefix *p, u_char type, u_short instance) |
718e3744 | 5673 | { |
718e3744 | 5674 | afi_t afi; |
5675 | struct bgp_node *rn; | |
5676 | struct bgp_info *ri; | |
7c8ff89e | 5677 | struct bgp_redist *red; |
718e3744 | 5678 | |
6aeb9e78 | 5679 | afi = family2afi (p->family); |
718e3744 | 5680 | |
6aeb9e78 DS |
5681 | red = bgp_redist_lookup(bgp, afi, type, instance); |
5682 | if (red) | |
5683 | { | |
5684 | rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); | |
718e3744 | 5685 | |
6aeb9e78 DS |
5686 | for (ri = rn->info; ri; ri = ri->next) |
5687 | if (ri->peer == bgp->peer_self | |
5688 | && ri->type == type) | |
5689 | break; | |
718e3744 | 5690 | |
6aeb9e78 DS |
5691 | if (ri) |
5692 | { | |
5693 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); | |
5694 | bgp_info_delete (rn, ri); | |
5695 | bgp_process (bgp, rn, afi, SAFI_UNICAST); | |
5696 | } | |
5697 | bgp_unlock_node (rn); | |
718e3744 | 5698 | } |
5699 | } | |
5700 | ||
5701 | /* Withdraw specified route type's route. */ | |
5702 | void | |
7c8ff89e | 5703 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type, u_short instance) |
718e3744 | 5704 | { |
5705 | struct bgp_node *rn; | |
5706 | struct bgp_info *ri; | |
5707 | struct bgp_table *table; | |
5708 | ||
5709 | table = bgp->rib[afi][SAFI_UNICAST]; | |
5710 | ||
5711 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
5712 | { | |
5713 | for (ri = rn->info; ri; ri = ri->next) | |
5714 | if (ri->peer == bgp->peer_self | |
7c8ff89e DS |
5715 | && ri->type == type |
5716 | && ri->instance == instance) | |
718e3744 | 5717 | break; |
5718 | ||
5719 | if (ri) | |
5720 | { | |
5721 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5722 | bgp_info_delete (rn, ri); |
1a392d46 | 5723 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5724 | } |
5725 | } | |
5726 | } | |
6b0655a2 | 5727 | |
718e3744 | 5728 | /* Static function to display route. */ |
94f2b392 | 5729 | static void |
718e3744 | 5730 | route_vty_out_route (struct prefix *p, struct vty *vty) |
5731 | { | |
5732 | int len; | |
5733 | u_int32_t destination; | |
5734 | char buf[BUFSIZ]; | |
5735 | ||
5736 | if (p->family == AF_INET) | |
5737 | { | |
5738 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); | |
5739 | destination = ntohl (p->u.prefix4.s_addr); | |
5740 | ||
5741 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
856ca177 MS |
5742 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
5743 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
5744 | || p->u.prefix4.s_addr == 0) | |
5745 | { | |
5746 | /* When mask is natural, mask is not displayed. */ | |
5747 | } | |
718e3744 | 5748 | else |
856ca177 | 5749 | len += vty_out (vty, "/%d", p->prefixlen); |
718e3744 | 5750 | } |
5751 | else | |
5752 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), | |
5753 | p->prefixlen); | |
5754 | ||
5755 | len = 17 - len; | |
5756 | if (len < 1) | |
5757 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); | |
5758 | else | |
5759 | vty_out (vty, "%*s", len, " "); | |
5760 | } | |
5761 | ||
718e3744 | 5762 | enum bgp_display_type |
5763 | { | |
5764 | normal_list, | |
5765 | }; | |
5766 | ||
b40d939b | 5767 | /* Print the short form route status for a bgp_info */ |
5768 | static void | |
b05a1c8b DS |
5769 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo, |
5770 | json_object *json_path) | |
718e3744 | 5771 | { |
b05a1c8b DS |
5772 | if (json_path) |
5773 | { | |
b05a1c8b DS |
5774 | |
5775 | /* Route status display. */ | |
5776 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
f1aa5d8a | 5777 | json_object_boolean_true_add(json_path, "removed"); |
b05a1c8b DS |
5778 | |
5779 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
f1aa5d8a | 5780 | json_object_boolean_true_add(json_path, "stale"); |
b05a1c8b DS |
5781 | |
5782 | if (binfo->extra && binfo->extra->suppress) | |
f1aa5d8a | 5783 | json_object_boolean_true_add(json_path, "suppressed"); |
b05a1c8b DS |
5784 | |
5785 | if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && | |
5786 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
f1aa5d8a | 5787 | json_object_boolean_true_add(json_path, "valid"); |
b05a1c8b DS |
5788 | |
5789 | /* Selected */ | |
5790 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
f1aa5d8a | 5791 | json_object_boolean_true_add(json_path, "history"); |
b05a1c8b DS |
5792 | |
5793 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
f1aa5d8a | 5794 | json_object_boolean_true_add(json_path, "damped"); |
b05a1c8b DS |
5795 | |
5796 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
f1aa5d8a | 5797 | json_object_boolean_true_add(json_path, "bestpath"); |
b05a1c8b DS |
5798 | |
5799 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) | |
f1aa5d8a | 5800 | json_object_boolean_true_add(json_path, "multipath"); |
b05a1c8b DS |
5801 | |
5802 | /* Internal route. */ | |
5803 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) | |
62d6dca0 | 5804 | json_object_string_add(json_path, "pathFrom", "internal"); |
b05a1c8b | 5805 | else |
62d6dca0 | 5806 | json_object_string_add(json_path, "pathFrom", "external"); |
b05a1c8b DS |
5807 | |
5808 | return; | |
5809 | } | |
5810 | ||
b40d939b | 5811 | /* Route status display. */ |
5812 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
5813 | vty_out (vty, "R"); | |
5814 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
93406d87 | 5815 | vty_out (vty, "S"); |
fb982c25 | 5816 | else if (binfo->extra && binfo->extra->suppress) |
718e3744 | 5817 | vty_out (vty, "s"); |
31eba040 DS |
5818 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && |
5819 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
718e3744 | 5820 | vty_out (vty, "*"); |
5821 | else | |
5822 | vty_out (vty, " "); | |
5823 | ||
5824 | /* Selected */ | |
5825 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5826 | vty_out (vty, "h"); | |
5827 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5828 | vty_out (vty, "d"); | |
5829 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
5830 | vty_out (vty, ">"); | |
b366b518 BB |
5831 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
5832 | vty_out (vty, "="); | |
718e3744 | 5833 | else |
5834 | vty_out (vty, " "); | |
5835 | ||
5836 | /* Internal route. */ | |
b05a1c8b DS |
5837 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
5838 | vty_out (vty, "i"); | |
5839 | else | |
5840 | vty_out (vty, " "); | |
b40d939b | 5841 | } |
5842 | ||
5843 | /* called from terminal list command */ | |
5844 | void | |
5845 | route_vty_out (struct vty *vty, struct prefix *p, | |
b05a1c8b DS |
5846 | struct bgp_info *binfo, int display, safi_t safi, |
5847 | json_object *json_paths) | |
b40d939b | 5848 | { |
5849 | struct attr *attr; | |
f1aa5d8a DS |
5850 | json_object *json_path = NULL; |
5851 | json_object *json_nexthops = NULL; | |
5852 | json_object *json_nexthop_global = NULL; | |
5853 | json_object *json_nexthop_ll = NULL; | |
47fc97cc | 5854 | |
b05a1c8b DS |
5855 | if (json_paths) |
5856 | json_path = json_object_new_object(); | |
b05a1c8b DS |
5857 | |
5858 | /* short status lead text */ | |
5859 | route_vty_short_status_out (vty, binfo, json_path); | |
718e3744 | 5860 | |
b05a1c8b DS |
5861 | if (!json_paths) |
5862 | { | |
5863 | /* print prefix and mask */ | |
5864 | if (! display) | |
5865 | route_vty_out_route (p, vty); | |
5866 | else | |
5867 | vty_out (vty, "%*s", 17, " "); | |
5868 | } | |
47fc97cc | 5869 | |
718e3744 | 5870 | /* Print attribute */ |
5871 | attr = binfo->attr; | |
5872 | if (attr) | |
5873 | { | |
587ff0fd LB |
5874 | /* |
5875 | * For ENCAP routes, nexthop address family is not | |
5876 | * neccessarily the same as the prefix address family. | |
5877 | * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field | |
5878 | */ | |
5879 | if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) | |
5880 | { | |
5881 | if (attr->extra) | |
5882 | { | |
5883 | char buf[BUFSIZ]; | |
5884 | int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); | |
b05a1c8b | 5885 | |
587ff0fd LB |
5886 | switch (af) |
5887 | { | |
5888 | case AF_INET: | |
5889 | vty_out (vty, "%s", inet_ntop(af, | |
5890 | &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); | |
5891 | break; | |
5892 | #if HAVE_IPV6 | |
5893 | case AF_INET6: | |
5894 | vty_out (vty, "%s", inet_ntop(af, | |
5895 | &attr->extra->mp_nexthop_global, buf, BUFSIZ)); | |
5896 | break; | |
5897 | #endif | |
5898 | default: | |
5899 | vty_out(vty, "?"); | |
5900 | break; | |
5901 | } | |
5902 | } | |
5903 | else | |
5904 | vty_out(vty, "?"); | |
5905 | } | |
b05a1c8b | 5906 | /* IPv4 Next Hop */ |
587ff0fd | 5907 | else if (p->family == AF_INET || !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) |
718e3744 | 5908 | { |
b05a1c8b DS |
5909 | if (json_paths) |
5910 | { | |
f1aa5d8a DS |
5911 | json_nexthop_global = json_object_new_object(); |
5912 | ||
b05a1c8b | 5913 | if (safi == SAFI_MPLS_VPN) |
f1aa5d8a | 5914 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->extra->mp_nexthop_global_in)); |
b05a1c8b | 5915 | else |
f1aa5d8a DS |
5916 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->nexthop)); |
5917 | ||
5918 | json_object_string_add(json_nexthop_global, "afi", "ipv4"); | |
5919 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
b05a1c8b DS |
5920 | } |
5921 | else | |
5922 | { | |
5923 | if (safi == SAFI_MPLS_VPN) | |
5924 | vty_out (vty, "%-16s", | |
5925 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
5926 | else | |
5927 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5928 | } | |
718e3744 | 5929 | } |
161995ea | 5930 | |
b05a1c8b | 5931 | /* IPv6 Next Hop */ |
8a92a8a0 | 5932 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) |
718e3744 | 5933 | { |
5934 | int len; | |
5935 | char buf[BUFSIZ]; | |
5936 | ||
b05a1c8b DS |
5937 | if (json_paths) |
5938 | { | |
f1aa5d8a DS |
5939 | json_nexthop_global = json_object_new_object(); |
5940 | json_object_string_add(json_nexthop_global, "ip", | |
5941 | inet_ntop (AF_INET6, | |
5942 | &attr->extra->mp_nexthop_global, | |
5943 | buf, BUFSIZ)); | |
5944 | json_object_string_add(json_nexthop_global, "afi", "ipv6"); | |
5945 | json_object_string_add(json_nexthop_global, "scope", "global"); | |
5946 | ||
5947 | /* We display both LL & GL if both have been received */ | |
5948 | if ((attr->extra->mp_nexthop_len == 32) || (binfo->peer->conf_if)) | |
5949 | { | |
5950 | json_nexthop_ll = json_object_new_object(); | |
5951 | json_object_string_add(json_nexthop_ll, "ip", | |
5952 | inet_ntop (AF_INET6, | |
5953 | &attr->extra->mp_nexthop_local, | |
5954 | buf, BUFSIZ)); | |
5955 | json_object_string_add(json_nexthop_ll, "afi", "ipv6"); | |
5956 | json_object_string_add(json_nexthop_ll, "scope", "link-local"); | |
5957 | ||
161995ea DS |
5958 | if ((IPV6_ADDR_CMP (&attr->extra->mp_nexthop_global, |
5959 | &attr->extra->mp_nexthop_local) != 0) && | |
5960 | !attr->extra->mp_nexthop_prefer_global) | |
f1aa5d8a DS |
5961 | json_object_boolean_true_add(json_nexthop_ll, "used"); |
5962 | else | |
5963 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
5964 | } | |
5965 | else | |
5966 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
b05a1c8b DS |
5967 | } |
5968 | else | |
5969 | { | |
161995ea DS |
5970 | /* Display LL if LL/Global both in table unless prefer-global is set */ |
5971 | if (((attr->extra->mp_nexthop_len == 32) && | |
5972 | !attr->extra->mp_nexthop_prefer_global) || | |
5973 | (binfo->peer->conf_if)) | |
433e8b67 DS |
5974 | { |
5975 | if (binfo->peer->conf_if) | |
5976 | { | |
5977 | len = vty_out (vty, "%s", | |
5978 | binfo->peer->conf_if); | |
5979 | len = 7 - len; /* len of IPv6 addr + max len of def ifname */ | |
5980 | ||
5981 | if (len < 1) | |
5982 | vty_out (vty, "%s%*s", VTY_NEWLINE, 45, " "); | |
5983 | else | |
5984 | vty_out (vty, "%*s", len, " "); | |
5985 | } | |
5986 | else | |
5987 | { | |
5988 | len = vty_out (vty, "%s", | |
5989 | inet_ntop (AF_INET6, | |
5990 | &attr->extra->mp_nexthop_local, | |
5991 | buf, BUFSIZ)); | |
5992 | len = 16 - len; | |
5993 | ||
5994 | if (len < 1) | |
5995 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5996 | else | |
5997 | vty_out (vty, "%*s", len, " "); | |
5998 | } | |
5999 | } | |
6000 | else | |
6001 | { | |
6002 | len = vty_out (vty, "%s", | |
6003 | inet_ntop (AF_INET6, | |
6004 | &attr->extra->mp_nexthop_global, | |
6005 | buf, BUFSIZ)); | |
6006 | len = 16 - len; | |
6007 | ||
6008 | if (len < 1) | |
6009 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
6010 | else | |
6011 | vty_out (vty, "%*s", len, " "); | |
6012 | } | |
b05a1c8b | 6013 | } |
718e3744 | 6014 | } |
718e3744 | 6015 | |
b05a1c8b | 6016 | /* MED/Metric */ |
718e3744 | 6017 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
b05a1c8b | 6018 | if (json_paths) |
f1aa5d8a | 6019 | json_object_int_add(json_path, "med", attr->med); |
b05a1c8b DS |
6020 | else |
6021 | vty_out (vty, "%10u", attr->med); | |
718e3744 | 6022 | else |
b05a1c8b DS |
6023 | if (!json_paths) |
6024 | vty_out (vty, " "); | |
47fc97cc | 6025 | |
b05a1c8b | 6026 | /* Local Pref */ |
718e3744 | 6027 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
b05a1c8b | 6028 | if (json_paths) |
f1aa5d8a | 6029 | json_object_int_add(json_path, "localpref", attr->local_pref); |
b05a1c8b DS |
6030 | else |
6031 | vty_out (vty, "%7u", attr->local_pref); | |
718e3744 | 6032 | else |
b05a1c8b DS |
6033 | if (!json_paths) |
6034 | vty_out (vty, " "); | |
718e3744 | 6035 | |
b05a1c8b DS |
6036 | if (json_paths) |
6037 | { | |
6038 | if (attr->extra) | |
f1aa5d8a | 6039 | json_object_int_add(json_path, "weight", attr->extra->weight); |
b05a1c8b | 6040 | else |
f1aa5d8a | 6041 | json_object_int_add(json_path, "weight", 0); |
b05a1c8b DS |
6042 | } |
6043 | else | |
6044 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); | |
47fc97cc | 6045 | |
39e871e6 ST |
6046 | if (json_paths) { |
6047 | char buf[BUFSIZ]; | |
6048 | json_object_string_add(json_path, "peerId", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); | |
6049 | } | |
6050 | ||
b2518c1e PJ |
6051 | /* Print aspath */ |
6052 | if (attr->aspath) | |
b05a1c8b DS |
6053 | { |
6054 | if (json_paths) | |
f1aa5d8a | 6055 | json_object_string_add(json_path, "aspath", attr->aspath->str); |
b05a1c8b | 6056 | else |
f1aa5d8a | 6057 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
b05a1c8b | 6058 | } |
47fc97cc | 6059 | |
b2518c1e | 6060 | /* Print origin */ |
b05a1c8b | 6061 | if (json_paths) |
f1aa5d8a | 6062 | json_object_string_add(json_path, "origin", bgp_origin_long_str[attr->origin]); |
b05a1c8b DS |
6063 | else |
6064 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
b2518c1e | 6065 | } |
856ca177 MS |
6066 | else |
6067 | { | |
6068 | if (json_paths) | |
6069 | json_object_string_add(json_path, "alert", "No attributes"); | |
6070 | else | |
6071 | vty_out (vty, "No attributes to print%s", VTY_NEWLINE); | |
6072 | } | |
b05a1c8b DS |
6073 | |
6074 | if (json_paths) | |
f1aa5d8a DS |
6075 | { |
6076 | if (json_nexthop_global || json_nexthop_ll) | |
6077 | { | |
6078 | json_nexthops = json_object_new_array(); | |
6079 | ||
6080 | if (json_nexthop_global) | |
6081 | json_object_array_add(json_nexthops, json_nexthop_global); | |
6082 | ||
6083 | if (json_nexthop_ll) | |
6084 | json_object_array_add(json_nexthops, json_nexthop_ll); | |
6085 | ||
6086 | json_object_object_add(json_path, "nexthops", json_nexthops); | |
6087 | } | |
6088 | ||
6089 | json_object_array_add(json_paths, json_path); | |
6090 | } | |
b05a1c8b DS |
6091 | else |
6092 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6093 | } |
6094 | ||
6095 | /* called from terminal list command */ | |
6096 | void | |
856ca177 MS |
6097 | route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t safi, |
6098 | u_char use_json, json_object *json_ar) | |
718e3744 | 6099 | { |
856ca177 MS |
6100 | json_object *json_status = NULL; |
6101 | json_object *json_net = NULL; | |
6102 | char buff[BUFSIZ]; | |
718e3744 | 6103 | /* Route status display. */ |
856ca177 MS |
6104 | if (use_json) |
6105 | { | |
6106 | json_status = json_object_new_object(); | |
6107 | json_net = json_object_new_object(); | |
6108 | } | |
6109 | else | |
6110 | { | |
6111 | vty_out (vty, "*"); | |
6112 | vty_out (vty, ">"); | |
6113 | vty_out (vty, " "); | |
6114 | } | |
718e3744 | 6115 | |
6116 | /* print prefix and mask */ | |
856ca177 MS |
6117 | if (use_json) |
6118 | json_object_string_add(json_net, "addrPrefix", inet_ntop (p->family, &p->u.prefix, buff, BUFSIZ)); | |
6119 | else | |
6120 | route_vty_out_route (p, vty); | |
718e3744 | 6121 | |
6122 | /* Print attribute */ | |
6123 | if (attr) | |
6124 | { | |
856ca177 | 6125 | if (use_json) |
718e3744 | 6126 | { |
587ff0fd LB |
6127 | if (p->family == AF_INET && |
6128 | (safi == SAFI_MPLS_VPN || | |
6129 | safi == SAFI_ENCAP || | |
6130 | !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
856ca177 | 6131 | { |
587ff0fd | 6132 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
856ca177 MS |
6133 | json_object_string_add(json_net, "nextHop", inet_ntoa (attr->extra->mp_nexthop_global_in)); |
6134 | else | |
6135 | json_object_string_add(json_net, "nextHop", inet_ntoa (attr->nexthop)); | |
6136 | } | |
6137 | #ifdef HAVE_IPV6 | |
6138 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) | |
6139 | { | |
6140 | char buf[BUFSIZ]; | |
718e3744 | 6141 | |
856ca177 MS |
6142 | json_object_string_add(json_net, "netHopGloabal", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
6143 | buf, BUFSIZ)); | |
6144 | } | |
6145 | #endif /* HAVE_IPV6 */ | |
6146 | ||
6147 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
6148 | json_object_int_add(json_net, "metric", attr->med); | |
6149 | ||
6150 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
6151 | json_object_int_add(json_net, "localPref", attr->local_pref); | |
6152 | ||
6153 | if (attr->extra) | |
6154 | json_object_int_add(json_net, "weight", attr->extra->weight); | |
718e3744 | 6155 | else |
856ca177 MS |
6156 | json_object_int_add(json_net, "weight", 0); |
6157 | ||
6158 | /* Print aspath */ | |
6159 | if (attr->aspath) | |
6160 | json_object_string_add(json_net, "asPath", attr->aspath->str); | |
6161 | ||
6162 | /* Print origin */ | |
6163 | json_object_string_add(json_net, "bgpOriginCode", bgp_origin_str[attr->origin]); | |
718e3744 | 6164 | } |
856ca177 MS |
6165 | else |
6166 | { | |
587ff0fd LB |
6167 | if (p->family == AF_INET && |
6168 | (safi == SAFI_MPLS_VPN || | |
6169 | safi == SAFI_ENCAP || | |
6170 | !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
856ca177 | 6171 | { |
587ff0fd | 6172 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
856ca177 MS |
6173 | vty_out (vty, "%-16s", |
6174 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
6175 | else | |
6176 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
6177 | } | |
6178 | #ifdef HAVE_IPV6 | |
6179 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) | |
6180 | { | |
6181 | int len; | |
6182 | char buf[BUFSIZ]; | |
6183 | ||
6184 | assert (attr->extra); | |
6185 | ||
6186 | len = vty_out (vty, "%s", | |
6187 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6188 | buf, BUFSIZ)); | |
6189 | len = 16 - len; | |
6190 | if (len < 1) | |
6191 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
6192 | else | |
6193 | vty_out (vty, "%*s", len, " "); | |
6194 | } | |
718e3744 | 6195 | #endif /* HAVE_IPV6 */ |
856ca177 MS |
6196 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
6197 | vty_out (vty, "%10u", attr->med); | |
6198 | else | |
6199 | vty_out (vty, " "); | |
718e3744 | 6200 | |
856ca177 MS |
6201 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
6202 | vty_out (vty, "%7u", attr->local_pref); | |
6203 | else | |
6204 | vty_out (vty, " "); | |
718e3744 | 6205 | |
856ca177 | 6206 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
718e3744 | 6207 | |
856ca177 MS |
6208 | /* Print aspath */ |
6209 | if (attr->aspath) | |
6210 | aspath_print_vty (vty, "%s", attr->aspath, " "); | |
718e3744 | 6211 | |
856ca177 MS |
6212 | /* Print origin */ |
6213 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
6214 | } | |
6215 | } | |
6216 | if (use_json) | |
6217 | { | |
6218 | json_object_boolean_true_add(json_status, "*"); | |
6219 | json_object_boolean_true_add(json_status, ">"); | |
6220 | json_object_object_add(json_net, "appliedStatusSymbols", json_status); | |
6221 | char buf_cut[BUFSIZ]; | |
6222 | json_object_object_add(json_ar, inet_ntop (p->family, &p->u.prefix, buf_cut, BUFSIZ), json_net); | |
6223 | } | |
6224 | else | |
6225 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6226 | } |
6227 | ||
5a646650 | 6228 | void |
718e3744 | 6229 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
856ca177 | 6230 | struct bgp_info *binfo, int display, safi_t safi, json_object *json) |
718e3744 | 6231 | { |
856ca177 | 6232 | json_object *json_out = NULL; |
718e3744 | 6233 | struct attr *attr; |
718e3744 | 6234 | u_int32_t label = 0; |
fb982c25 PJ |
6235 | |
6236 | if (!binfo->extra) | |
6237 | return; | |
856ca177 MS |
6238 | |
6239 | if (json) | |
6240 | json_out = json_object_new_object(); | |
fb982c25 | 6241 | |
b40d939b | 6242 | /* short status lead text */ |
856ca177 | 6243 | route_vty_short_status_out (vty, binfo, json_out); |
b40d939b | 6244 | |
718e3744 | 6245 | /* print prefix and mask */ |
856ca177 MS |
6246 | if (json == NULL) |
6247 | { | |
6248 | if (! display) | |
6249 | route_vty_out_route (p, vty); | |
6250 | else | |
6251 | vty_out (vty, "%*s", 17, " "); | |
6252 | } | |
718e3744 | 6253 | |
6254 | /* Print attribute */ | |
6255 | attr = binfo->attr; | |
6256 | if (attr) | |
6257 | { | |
8a92a8a0 DS |
6258 | if (p->family == AF_INET |
6259 | && (safi == SAFI_MPLS_VPN || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
718e3744 | 6260 | { |
587ff0fd | 6261 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
856ca177 MS |
6262 | { |
6263 | if (json) | |
6264 | json_object_string_add(json_out, "mpNexthopGlobalIn", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
6265 | else | |
6266 | vty_out (vty, "%-16s", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
6267 | } | |
718e3744 | 6268 | else |
856ca177 MS |
6269 | { |
6270 | if (json) | |
6271 | json_object_string_add(json_out, "nexthop", inet_ntoa (attr->nexthop)); | |
6272 | else | |
6273 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
6274 | } | |
718e3744 | 6275 | } |
6276 | #ifdef HAVE_IPV6 | |
8a92a8a0 | 6277 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) |
718e3744 | 6278 | { |
fb982c25 | 6279 | assert (attr->extra); |
856ca177 MS |
6280 | char buf_a[BUFSIZ]; |
6281 | char buf_b[BUFSIZ]; | |
6282 | char buf_c[BUFSIZ]; | |
801a9bcc | 6283 | if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) |
856ca177 MS |
6284 | { |
6285 | if (json) | |
6286 | json_object_string_add(json_out, "mpNexthopGlobalIn", | |
6287 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, buf_a, BUFSIZ)); | |
6288 | else | |
6289 | vty_out (vty, "%s", | |
6290 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6291 | buf_a, BUFSIZ)); | |
6292 | } | |
801a9bcc | 6293 | else if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) |
856ca177 MS |
6294 | { |
6295 | if (json) | |
6296 | { | |
6297 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6298 | buf_a, BUFSIZ); | |
6299 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
6300 | buf_b, BUFSIZ); | |
6301 | sprintf(buf_c, "%s(%s)", buf_a, buf_b); | |
6302 | json_object_string_add(json_out, "mpNexthopGlobalLocal", buf_c); | |
6303 | } | |
6304 | else | |
6305 | vty_out (vty, "%s(%s)", | |
6306 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6307 | buf_a, BUFSIZ), | |
6308 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
6309 | buf_b, BUFSIZ)); | |
6310 | } | |
6311 | ||
718e3744 | 6312 | } |
6313 | #endif /* HAVE_IPV6 */ | |
6314 | } | |
6315 | ||
fb982c25 | 6316 | label = decode_label (binfo->extra->tag); |
718e3744 | 6317 | |
856ca177 MS |
6318 | if (json) |
6319 | { | |
6320 | if (label) | |
6321 | json_object_int_add(json_out, "notag", label); | |
6322 | json_object_array_add(json, json_out); | |
6323 | } | |
6324 | else | |
6325 | { | |
6326 | vty_out (vty, "notag/%d", label); | |
6327 | vty_out (vty, "%s", VTY_NEWLINE); | |
6328 | } | |
718e3744 | 6329 | } |
6330 | ||
6331 | /* dampening route */ | |
5a646650 | 6332 | static void |
856ca177 MS |
6333 | damp_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, |
6334 | int display, safi_t safi, u_char use_json, json_object *json) | |
718e3744 | 6335 | { |
6336 | struct attr *attr; | |
718e3744 | 6337 | int len; |
50aef6f3 | 6338 | char timebuf[BGP_UPTIME_LEN]; |
718e3744 | 6339 | |
b40d939b | 6340 | /* short status lead text */ |
856ca177 | 6341 | route_vty_short_status_out (vty, binfo, json); |
b40d939b | 6342 | |
718e3744 | 6343 | /* print prefix and mask */ |
856ca177 MS |
6344 | if (!use_json) |
6345 | { | |
6346 | if (! display) | |
6347 | route_vty_out_route (p, vty); | |
6348 | else | |
6349 | vty_out (vty, "%*s", 17, " "); | |
6350 | } | |
718e3744 | 6351 | |
6352 | len = vty_out (vty, "%s", binfo->peer->host); | |
6353 | len = 17 - len; | |
6354 | if (len < 1) | |
856ca177 MS |
6355 | { |
6356 | if (!use_json) | |
6357 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); | |
6358 | } | |
718e3744 | 6359 | else |
856ca177 MS |
6360 | { |
6361 | if (use_json) | |
6362 | json_object_int_add(json, "peerHost", len); | |
6363 | else | |
6364 | vty_out (vty, "%*s", len, " "); | |
6365 | } | |
718e3744 | 6366 | |
856ca177 MS |
6367 | if (use_json) |
6368 | bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json); | |
6369 | else | |
6370 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json)); | |
718e3744 | 6371 | |
6372 | /* Print attribute */ | |
6373 | attr = binfo->attr; | |
6374 | if (attr) | |
6375 | { | |
6376 | /* Print aspath */ | |
6377 | if (attr->aspath) | |
856ca177 MS |
6378 | { |
6379 | if (use_json) | |
6380 | json_object_string_add(json, "asPath", attr->aspath->str); | |
6381 | else | |
6382 | aspath_print_vty (vty, "%s", attr->aspath, " "); | |
6383 | } | |
718e3744 | 6384 | |
6385 | /* Print origin */ | |
856ca177 MS |
6386 | if (use_json) |
6387 | json_object_string_add(json, "origin", bgp_origin_str[attr->origin]); | |
6388 | else | |
6389 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
718e3744 | 6390 | } |
856ca177 MS |
6391 | if (!use_json) |
6392 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6393 | } |
6394 | ||
718e3744 | 6395 | /* flap route */ |
5a646650 | 6396 | static void |
856ca177 MS |
6397 | flap_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, |
6398 | int display, safi_t safi, u_char use_json, json_object *json) | |
718e3744 | 6399 | { |
6400 | struct attr *attr; | |
6401 | struct bgp_damp_info *bdi; | |
718e3744 | 6402 | char timebuf[BGP_UPTIME_LEN]; |
6403 | int len; | |
fb982c25 PJ |
6404 | |
6405 | if (!binfo->extra) | |
6406 | return; | |
6407 | ||
6408 | bdi = binfo->extra->damp_info; | |
718e3744 | 6409 | |
b40d939b | 6410 | /* short status lead text */ |
856ca177 | 6411 | route_vty_short_status_out (vty, binfo, json); |
b40d939b | 6412 | |
718e3744 | 6413 | /* print prefix and mask */ |
856ca177 MS |
6414 | if (!use_json) |
6415 | { | |
6416 | if (! display) | |
6417 | route_vty_out_route (p, vty); | |
6418 | else | |
6419 | vty_out (vty, "%*s", 17, " "); | |
6420 | } | |
718e3744 | 6421 | |
6422 | len = vty_out (vty, "%s", binfo->peer->host); | |
6423 | len = 16 - len; | |
6424 | if (len < 1) | |
856ca177 MS |
6425 | { |
6426 | if (!use_json) | |
6427 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); | |
6428 | } | |
718e3744 | 6429 | else |
856ca177 MS |
6430 | { |
6431 | if (use_json) | |
6432 | json_object_int_add(json, "peerHost", len); | |
6433 | else | |
6434 | vty_out (vty, "%*s", len, " "); | |
6435 | } | |
718e3744 | 6436 | |
6437 | len = vty_out (vty, "%d", bdi->flap); | |
6438 | len = 5 - len; | |
6439 | if (len < 1) | |
856ca177 MS |
6440 | { |
6441 | if (!use_json) | |
6442 | vty_out (vty, " "); | |
6443 | } | |
718e3744 | 6444 | else |
856ca177 MS |
6445 | { |
6446 | if (use_json) | |
6447 | json_object_int_add(json, "bdiFlap", len); | |
6448 | else | |
6449 | vty_out (vty, "%*s", len, " "); | |
6450 | } | |
6451 | ||
6452 | if (use_json) | |
6453 | peer_uptime (bdi->start_time, timebuf, BGP_UPTIME_LEN, use_json, json); | |
6454 | else | |
6455 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, | |
6456 | timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
718e3744 | 6457 | |
6458 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) | |
6459 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
856ca177 MS |
6460 | { |
6461 | if (use_json) | |
6462 | bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json); | |
6463 | else | |
6464 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json)); | |
6465 | } | |
718e3744 | 6466 | else |
856ca177 MS |
6467 | { |
6468 | if (!use_json) | |
6469 | vty_out (vty, "%*s ", 8, " "); | |
6470 | } | |
718e3744 | 6471 | |
6472 | /* Print attribute */ | |
6473 | attr = binfo->attr; | |
6474 | if (attr) | |
6475 | { | |
6476 | /* Print aspath */ | |
6477 | if (attr->aspath) | |
856ca177 MS |
6478 | { |
6479 | if (use_json) | |
6480 | json_object_string_add(json, "asPath", attr->aspath->str); | |
6481 | else | |
6482 | aspath_print_vty (vty, "%s", attr->aspath, " "); | |
6483 | } | |
718e3744 | 6484 | |
6485 | /* Print origin */ | |
856ca177 MS |
6486 | if (use_json) |
6487 | json_object_string_add(json, "origin", bgp_origin_str[attr->origin]); | |
6488 | else | |
6489 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
718e3744 | 6490 | } |
856ca177 MS |
6491 | if (!use_json) |
6492 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6493 | } |
6494 | ||
adbac85e DW |
6495 | static void |
6496 | route_vty_out_advertised_to (struct vty *vty, struct peer *peer, int *first, | |
6497 | const char *header, json_object *json_adv_to) | |
6498 | { | |
6499 | char buf1[INET6_ADDRSTRLEN]; | |
6500 | json_object *json_peer = NULL; | |
6501 | ||
6502 | if (json_adv_to) | |
6503 | { | |
6504 | /* 'advertised-to' is a dictionary of peers we have advertised this | |
6505 | * prefix too. The key is the peer's IP or swpX, the value is the | |
6506 | * hostname if we know it and "" if not. | |
6507 | */ | |
6508 | json_peer = json_object_new_object(); | |
6509 | ||
6510 | if (peer->hostname) | |
6511 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6512 | ||
6513 | if (peer->conf_if) | |
6514 | json_object_object_add(json_adv_to, peer->conf_if, json_peer); | |
6515 | else | |
6516 | json_object_object_add(json_adv_to, | |
6517 | sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN), | |
6518 | json_peer); | |
6519 | } | |
6520 | else | |
6521 | { | |
6522 | if (*first) | |
6523 | { | |
6524 | vty_out (vty, "%s", header); | |
6525 | *first = 0; | |
6526 | } | |
6527 | ||
6528 | if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6529 | { | |
6530 | if (peer->conf_if) | |
6531 | vty_out (vty, " %s(%s)", peer->hostname, peer->conf_if); | |
6532 | else | |
6533 | vty_out (vty, " %s(%s)", peer->hostname, | |
6534 | sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6535 | } | |
6536 | else | |
6537 | { | |
6538 | if (peer->conf_if) | |
6539 | vty_out (vty, " %s", peer->conf_if); | |
6540 | else | |
6541 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6542 | } | |
6543 | } | |
6544 | } | |
6545 | ||
94f2b392 | 6546 | static void |
718e3744 | 6547 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
b05a1c8b DS |
6548 | struct bgp_info *binfo, afi_t afi, safi_t safi, |
6549 | json_object *json_paths) | |
718e3744 | 6550 | { |
6551 | char buf[INET6_ADDRSTRLEN]; | |
6552 | char buf1[BUFSIZ]; | |
6553 | struct attr *attr; | |
6554 | int sockunion_vty_out (struct vty *, union sockunion *); | |
30b00176 JK |
6555 | #ifdef HAVE_CLOCK_MONOTONIC |
6556 | time_t tbuf; | |
6557 | #endif | |
f1aa5d8a | 6558 | json_object *json_bestpath = NULL; |
ffd0c037 | 6559 | json_object *json_cluster_list = NULL; |
f1aa5d8a DS |
6560 | json_object *json_cluster_list_list = NULL; |
6561 | json_object *json_ext_community = NULL; | |
6562 | json_object *json_last_update = NULL; | |
6563 | json_object *json_nexthop_global = NULL; | |
6564 | json_object *json_nexthop_ll = NULL; | |
6565 | json_object *json_nexthops = NULL; | |
6566 | json_object *json_path = NULL; | |
6567 | json_object *json_peer = NULL; | |
6568 | json_object *json_string = NULL; | |
adbac85e DW |
6569 | json_object *json_adv_to = NULL; |
6570 | int first = 0; | |
6571 | struct listnode *node, *nnode; | |
6572 | struct peer *peer; | |
6573 | int addpath_capable; | |
6574 | int has_adj; | |
06370dac | 6575 | int first_as; |
b05a1c8b DS |
6576 | |
6577 | if (json_paths) | |
6578 | { | |
6579 | json_path = json_object_new_object(); | |
f1aa5d8a DS |
6580 | json_peer = json_object_new_object(); |
6581 | json_nexthop_global = json_object_new_object(); | |
b05a1c8b DS |
6582 | } |
6583 | ||
718e3744 | 6584 | attr = binfo->attr; |
6585 | ||
6586 | if (attr) | |
6587 | { | |
6588 | /* Line1 display AS-path, Aggregator */ | |
6589 | if (attr->aspath) | |
6590 | { | |
f1aa5d8a DS |
6591 | if (json_paths) |
6592 | { | |
6593 | json_object_lock(attr->aspath->json); | |
6594 | json_object_object_add(json_path, "aspath", attr->aspath->json); | |
6595 | } | |
6596 | else | |
b05a1c8b | 6597 | { |
f1aa5d8a DS |
6598 | if (attr->aspath->segments) |
6599 | aspath_print_vty (vty, " %s", attr->aspath, ""); | |
b05a1c8b | 6600 | else |
f1aa5d8a | 6601 | vty_out (vty, " Local"); |
b05a1c8b | 6602 | } |
718e3744 | 6603 | } |
6604 | ||
b40d939b | 6605 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
b05a1c8b DS |
6606 | { |
6607 | if (json_paths) | |
f1aa5d8a | 6608 | json_object_boolean_true_add(json_path, "removed"); |
b05a1c8b DS |
6609 | else |
6610 | vty_out (vty, ", (removed)"); | |
6611 | } | |
6612 | ||
93406d87 | 6613 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
b05a1c8b DS |
6614 | { |
6615 | if (json_paths) | |
f1aa5d8a | 6616 | json_object_boolean_true_add(json_path, "stale"); |
b05a1c8b DS |
6617 | else |
6618 | vty_out (vty, ", (stale)"); | |
6619 | } | |
6620 | ||
93406d87 | 6621 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
b05a1c8b DS |
6622 | { |
6623 | if (json_paths) | |
6624 | { | |
62d6dca0 DS |
6625 | json_object_int_add(json_path, "aggregatorAs", attr->extra->aggregator_as); |
6626 | json_object_string_add(json_path, "aggregatorId", inet_ntoa (attr->extra->aggregator_addr)); | |
b05a1c8b DS |
6627 | } |
6628 | else | |
6629 | { | |
6630 | vty_out (vty, ", (aggregated by %u %s)", | |
6631 | attr->extra->aggregator_as, | |
6632 | inet_ntoa (attr->extra->aggregator_addr)); | |
6633 | } | |
6634 | } | |
6635 | ||
93406d87 | 6636 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
b05a1c8b DS |
6637 | { |
6638 | if (json_paths) | |
62d6dca0 | 6639 | json_object_boolean_true_add(json_path, "rxedFromRrClient"); |
b05a1c8b DS |
6640 | else |
6641 | vty_out (vty, ", (Received from a RR-client)"); | |
6642 | } | |
6643 | ||
93406d87 | 6644 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
b05a1c8b DS |
6645 | { |
6646 | if (json_paths) | |
62d6dca0 | 6647 | json_object_boolean_true_add(json_path, "rxedFromRsClient"); |
b05a1c8b DS |
6648 | else |
6649 | vty_out (vty, ", (Received from a RS-client)"); | |
6650 | } | |
6651 | ||
93406d87 | 6652 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
b05a1c8b DS |
6653 | { |
6654 | if (json_paths) | |
62d6dca0 | 6655 | json_object_boolean_true_add(json_path, "dampeningHistoryEntry"); |
b05a1c8b DS |
6656 | else |
6657 | vty_out (vty, ", (history entry)"); | |
6658 | } | |
93406d87 | 6659 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
b05a1c8b DS |
6660 | { |
6661 | if (json_paths) | |
62d6dca0 | 6662 | json_object_boolean_true_add(json_path, "dampeningSuppressed"); |
b05a1c8b DS |
6663 | else |
6664 | vty_out (vty, ", (suppressed due to dampening)"); | |
6665 | } | |
6666 | ||
6667 | if (!json_paths) | |
6668 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6669 | |
6670 | /* Line2 display Next-hop, Neighbor, Router-id */ | |
f1aa5d8a | 6671 | /* Display the nexthop */ |
587ff0fd LB |
6672 | if (p->family == AF_INET && |
6673 | (safi == SAFI_MPLS_VPN || | |
6674 | safi == SAFI_ENCAP || | |
6675 | !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
718e3744 | 6676 | { |
587ff0fd | 6677 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
b05a1c8b DS |
6678 | { |
6679 | if (json_paths) | |
f1aa5d8a | 6680 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->extra->mp_nexthop_global_in)); |
b05a1c8b DS |
6681 | else |
6682 | vty_out (vty, " %s", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
6683 | } | |
6684 | else | |
6685 | { | |
6686 | if (json_paths) | |
f1aa5d8a | 6687 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->nexthop)); |
b05a1c8b DS |
6688 | else |
6689 | vty_out (vty, " %s", inet_ntoa (attr->nexthop)); | |
6690 | } | |
6691 | ||
6692 | if (json_paths) | |
f1aa5d8a | 6693 | json_object_string_add(json_nexthop_global, "afi", "ipv4"); |
718e3744 | 6694 | } |
718e3744 | 6695 | else |
6696 | { | |
fb982c25 | 6697 | assert (attr->extra); |
b05a1c8b DS |
6698 | if (json_paths) |
6699 | { | |
f1aa5d8a DS |
6700 | json_object_string_add(json_nexthop_global, "ip", |
6701 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6702 | buf, INET6_ADDRSTRLEN)); | |
6703 | json_object_string_add(json_nexthop_global, "afi", "ipv6"); | |
6704 | json_object_string_add(json_nexthop_global, "scope", "global"); | |
b05a1c8b DS |
6705 | } |
6706 | else | |
6707 | { | |
6708 | vty_out (vty, " %s", | |
6709 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6710 | buf, INET6_ADDRSTRLEN)); | |
6711 | } | |
718e3744 | 6712 | } |
b05a1c8b | 6713 | |
f1aa5d8a DS |
6714 | /* Display the IGP cost or 'inaccessible' */ |
6715 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) | |
6716 | { | |
6717 | if (json_paths) | |
6718 | json_object_boolean_false_add(json_nexthop_global, "accessible"); | |
6719 | else | |
6720 | vty_out (vty, " (inaccessible)"); | |
6721 | } | |
6722 | else | |
6723 | { | |
6724 | if (binfo->extra && binfo->extra->igpmetric) | |
b05a1c8b DS |
6725 | { |
6726 | if (json_paths) | |
f1aa5d8a | 6727 | json_object_int_add(json_nexthop_global, "metric", binfo->extra->igpmetric); |
b05a1c8b | 6728 | else |
f1aa5d8a | 6729 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
b05a1c8b | 6730 | } |
f1aa5d8a DS |
6731 | |
6732 | /* IGP cost is 0, display this only for json */ | |
b05a1c8b DS |
6733 | else |
6734 | { | |
6735 | if (json_paths) | |
f1aa5d8a | 6736 | json_object_int_add(json_nexthop_global, "metric", 0); |
b05a1c8b DS |
6737 | } |
6738 | ||
6739 | if (json_paths) | |
f1aa5d8a DS |
6740 | json_object_boolean_true_add(json_nexthop_global, "accessible"); |
6741 | } | |
6742 | ||
6743 | /* Display peer "from" output */ | |
6744 | /* This path was originated locally */ | |
6745 | if (binfo->peer == bgp->peer_self) | |
718e3744 | 6746 | { |
f1aa5d8a DS |
6747 | |
6748 | if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) | |
b05a1c8b DS |
6749 | { |
6750 | if (json_paths) | |
62d6dca0 | 6751 | json_object_string_add(json_peer, "peerId", "0.0.0.0"); |
b05a1c8b | 6752 | else |
f1aa5d8a | 6753 | vty_out (vty, " from 0.0.0.0 "); |
b05a1c8b | 6754 | } |
f1aa5d8a | 6755 | else |
b05a1c8b DS |
6756 | { |
6757 | if (json_paths) | |
62d6dca0 | 6758 | json_object_string_add(json_peer, "peerId", "::"); |
b05a1c8b | 6759 | else |
f1aa5d8a | 6760 | vty_out (vty, " from :: "); |
b05a1c8b DS |
6761 | } |
6762 | ||
f1aa5d8a | 6763 | if (json_paths) |
62d6dca0 | 6764 | json_object_string_add(json_peer, "routerId", inet_ntoa(bgp->router_id)); |
b05a1c8b | 6765 | else |
f1aa5d8a DS |
6766 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
6767 | } | |
6768 | ||
6769 | /* We RXed this path from one of our peers */ | |
6770 | else | |
6771 | { | |
b05a1c8b DS |
6772 | |
6773 | if (json_paths) | |
6774 | { | |
62d6dca0 DS |
6775 | json_object_string_add(json_peer, "peerId", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
6776 | json_object_string_add(json_peer, "routerId", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
f1aa5d8a | 6777 | |
04b6bdc0 DW |
6778 | if (binfo->peer->hostname) |
6779 | json_object_string_add(json_peer, "hostname", binfo->peer->hostname); | |
6780 | ||
6781 | if (binfo->peer->domainname) | |
6782 | json_object_string_add(json_peer, "domainname", binfo->peer->domainname); | |
6783 | ||
036a4e7d | 6784 | if (binfo->peer->conf_if) |
f1aa5d8a | 6785 | json_object_string_add(json_peer, "interface", binfo->peer->conf_if); |
b05a1c8b DS |
6786 | } |
6787 | else | |
6788 | { | |
036a4e7d | 6789 | if (binfo->peer->conf_if) |
04b6bdc0 DW |
6790 | { |
6791 | if (binfo->peer->hostname && | |
6792 | bgp_flag_check(binfo->peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6793 | vty_out (vty, " from %s(%s)", binfo->peer->hostname, | |
6794 | binfo->peer->conf_if); | |
6795 | else | |
6796 | vty_out (vty, " from %s", binfo->peer->conf_if); | |
6797 | } | |
036a4e7d | 6798 | else |
04b6bdc0 DW |
6799 | { |
6800 | if (binfo->peer->hostname && | |
6801 | bgp_flag_check(binfo->peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6802 | vty_out (vty, " from %s(%s)", binfo->peer->hostname, | |
6803 | binfo->peer->host); | |
6804 | else | |
6805 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); | |
6806 | } | |
b05a1c8b | 6807 | |
f1aa5d8a DS |
6808 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
6809 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); | |
6810 | else | |
6811 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
b05a1c8b | 6812 | } |
718e3744 | 6813 | } |
b05a1c8b DS |
6814 | |
6815 | if (!json_paths) | |
6816 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6817 | |
f1aa5d8a | 6818 | /* display the link-local nexthop */ |
801a9bcc | 6819 | if (attr->extra && attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) |
718e3744 | 6820 | { |
b05a1c8b DS |
6821 | if (json_paths) |
6822 | { | |
f1aa5d8a DS |
6823 | json_nexthop_ll = json_object_new_object(); |
6824 | json_object_string_add(json_nexthop_ll, "ip", | |
6825 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
6826 | buf, INET6_ADDRSTRLEN)); | |
6827 | json_object_string_add(json_nexthop_ll, "afi", "ipv6"); | |
6828 | json_object_string_add(json_nexthop_ll, "scope", "link-local"); | |
6829 | ||
6830 | json_object_boolean_true_add(json_nexthop_ll, "accessible"); | |
161995ea DS |
6831 | |
6832 | if (!attr->extra->mp_nexthop_prefer_global) | |
6833 | json_object_boolean_true_add(json_nexthop_ll, "used"); | |
6834 | else | |
6835 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
b05a1c8b DS |
6836 | } |
6837 | else | |
6838 | { | |
161995ea DS |
6839 | vty_out (vty, " (%s) %s%s", |
6840 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
b05a1c8b | 6841 | buf, INET6_ADDRSTRLEN), |
161995ea DS |
6842 | attr->extra->mp_nexthop_prefer_global ? |
6843 | "(prefer-global)" : "(used)", | |
b05a1c8b DS |
6844 | VTY_NEWLINE); |
6845 | } | |
718e3744 | 6846 | } |
f1aa5d8a DS |
6847 | /* If we do not have a link-local nexthop then we must flag the global as "used" */ |
6848 | else | |
6849 | { | |
6850 | if (json_paths) | |
6851 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
6852 | } | |
718e3744 | 6853 | |
0d9551dc | 6854 | /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */ |
b05a1c8b | 6855 | if (json_paths) |
f1aa5d8a | 6856 | json_object_string_add(json_path, "origin", bgp_origin_long_str[attr->origin]); |
b05a1c8b | 6857 | else |
f1aa5d8a | 6858 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
718e3744 | 6859 | |
6860 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) | |
b05a1c8b DS |
6861 | { |
6862 | if (json_paths) | |
f1aa5d8a | 6863 | json_object_int_add(json_path, "med", attr->med); |
b05a1c8b | 6864 | else |
f1aa5d8a | 6865 | vty_out (vty, ", metric %u", attr->med); |
b05a1c8b | 6866 | } |
718e3744 | 6867 | |
6868 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) | |
b05a1c8b DS |
6869 | { |
6870 | if (json_paths) | |
f1aa5d8a | 6871 | json_object_int_add(json_path, "localpref", attr->local_pref); |
b05a1c8b | 6872 | else |
f1aa5d8a | 6873 | vty_out (vty, ", localpref %u", attr->local_pref); |
b05a1c8b | 6874 | } |
718e3744 | 6875 | else |
b05a1c8b DS |
6876 | { |
6877 | if (json_paths) | |
f1aa5d8a | 6878 | json_object_int_add(json_path, "localpref", bgp->default_local_pref); |
b05a1c8b | 6879 | else |
f1aa5d8a | 6880 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
b05a1c8b | 6881 | } |
718e3744 | 6882 | |
fb982c25 | 6883 | if (attr->extra && attr->extra->weight != 0) |
b05a1c8b DS |
6884 | { |
6885 | if (json_paths) | |
f1aa5d8a | 6886 | json_object_int_add(json_path, "weight", attr->extra->weight); |
b05a1c8b | 6887 | else |
f1aa5d8a | 6888 | vty_out (vty, ", weight %u", attr->extra->weight); |
b05a1c8b | 6889 | } |
0d9551dc DS |
6890 | |
6891 | if (attr->extra && attr->extra->tag != 0) | |
b05a1c8b DS |
6892 | { |
6893 | if (json_paths) | |
f1aa5d8a | 6894 | json_object_int_add(json_path, "tag", attr->extra->tag); |
b05a1c8b | 6895 | else |
f1aa5d8a | 6896 | vty_out (vty, ", tag %d", attr->extra->tag); |
b05a1c8b | 6897 | } |
718e3744 | 6898 | |
31eba040 | 6899 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
b05a1c8b DS |
6900 | { |
6901 | if (json_paths) | |
f1aa5d8a | 6902 | json_object_boolean_false_add(json_path, "valid"); |
b05a1c8b DS |
6903 | else |
6904 | vty_out (vty, ", invalid"); | |
6905 | } | |
31eba040 | 6906 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
b05a1c8b DS |
6907 | { |
6908 | if (json_paths) | |
f1aa5d8a | 6909 | json_object_boolean_true_add(json_path, "valid"); |
b05a1c8b DS |
6910 | else |
6911 | vty_out (vty, ", valid"); | |
6912 | } | |
718e3744 | 6913 | |
6914 | if (binfo->peer != bgp->peer_self) | |
6915 | { | |
f1aa5d8a | 6916 | if (binfo->peer->as == binfo->peer->local_as) |
b05a1c8b | 6917 | { |
66b199b2 DS |
6918 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
6919 | { | |
6920 | if (json_paths) | |
f1aa5d8a | 6921 | json_object_string_add(json_peer, "type", "confed-internal"); |
66b199b2 | 6922 | else |
f1aa5d8a | 6923 | vty_out (vty, ", confed-internal"); |
66b199b2 | 6924 | } |
b05a1c8b | 6925 | else |
66b199b2 DS |
6926 | { |
6927 | if (json_paths) | |
f1aa5d8a | 6928 | json_object_string_add(json_peer, "type", "internal"); |
66b199b2 | 6929 | else |
f1aa5d8a | 6930 | vty_out (vty, ", internal"); |
66b199b2 | 6931 | } |
b05a1c8b | 6932 | } |
f1aa5d8a | 6933 | else |
b05a1c8b DS |
6934 | { |
6935 | if (bgp_confederation_peers_check(bgp, binfo->peer->as)) | |
6936 | { | |
6937 | if (json_paths) | |
f1aa5d8a | 6938 | json_object_string_add(json_peer, "type", "confed-external"); |
b05a1c8b | 6939 | else |
f1aa5d8a | 6940 | vty_out (vty, ", confed-external"); |
b05a1c8b DS |
6941 | } |
6942 | else | |
6943 | { | |
6944 | if (json_paths) | |
f1aa5d8a | 6945 | json_object_string_add(json_peer, "type", "external"); |
b05a1c8b | 6946 | else |
f1aa5d8a | 6947 | vty_out (vty, ", external"); |
b05a1c8b DS |
6948 | } |
6949 | } | |
718e3744 | 6950 | } |
6951 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) | |
b05a1c8b DS |
6952 | { |
6953 | if (json_paths) | |
6954 | { | |
f1aa5d8a DS |
6955 | json_object_boolean_true_add(json_path, "aggregated"); |
6956 | json_object_boolean_true_add(json_path, "local"); | |
b05a1c8b DS |
6957 | } |
6958 | else | |
6959 | { | |
6960 | vty_out (vty, ", aggregated, local"); | |
6961 | } | |
6962 | } | |
718e3744 | 6963 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
b05a1c8b DS |
6964 | { |
6965 | if (json_paths) | |
f1aa5d8a | 6966 | json_object_boolean_true_add(json_path, "sourced"); |
b05a1c8b DS |
6967 | else |
6968 | vty_out (vty, ", sourced"); | |
6969 | } | |
718e3744 | 6970 | else |
b05a1c8b DS |
6971 | { |
6972 | if (json_paths) | |
6973 | { | |
f1aa5d8a DS |
6974 | json_object_boolean_true_add(json_path, "sourced"); |
6975 | json_object_boolean_true_add(json_path, "local"); | |
b05a1c8b DS |
6976 | } |
6977 | else | |
6978 | { | |
6979 | vty_out (vty, ", sourced, local"); | |
6980 | } | |
6981 | } | |
718e3744 | 6982 | |
6983 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) | |
b05a1c8b DS |
6984 | { |
6985 | if (json_paths) | |
62d6dca0 | 6986 | json_object_boolean_true_add(json_path, "atomicAggregate"); |
b05a1c8b DS |
6987 | else |
6988 | vty_out (vty, ", atomic-aggregate"); | |
6989 | } | |
718e3744 | 6990 | |
de8d5dff JB |
6991 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
6992 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && | |
6993 | bgp_info_mpath_count (binfo))) | |
b05a1c8b DS |
6994 | { |
6995 | if (json_paths) | |
f1aa5d8a | 6996 | json_object_boolean_true_add(json_path, "multipath"); |
b05a1c8b DS |
6997 | else |
6998 | vty_out (vty, ", multipath"); | |
6999 | } | |
de8d5dff | 7000 | |
06370dac DW |
7001 | // Mark the bestpath(s) |
7002 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DMED_SELECTED)) | |
7003 | { | |
7004 | first_as = aspath_get_firstas(attr->aspath); | |
7005 | ||
7006 | if (json_paths) | |
7007 | { | |
7008 | if (!json_bestpath) | |
7009 | json_bestpath = json_object_new_object(); | |
7010 | json_object_int_add(json_bestpath, "bestpathFromAs", first_as); | |
7011 | } | |
7012 | else | |
7013 | { | |
7014 | if (first_as) | |
7015 | vty_out (vty, ", bestpath-from-AS %d", first_as); | |
7016 | else | |
7017 | vty_out (vty, ", bestpath-from-AS Local"); | |
7018 | } | |
7019 | } | |
7020 | ||
718e3744 | 7021 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
b05a1c8b DS |
7022 | { |
7023 | if (json_paths) | |
f1aa5d8a | 7024 | { |
06370dac DW |
7025 | if (!json_bestpath) |
7026 | json_bestpath = json_object_new_object(); | |
f1aa5d8a | 7027 | json_object_boolean_true_add(json_bestpath, "overall"); |
f1aa5d8a | 7028 | } |
b05a1c8b DS |
7029 | else |
7030 | vty_out (vty, ", best"); | |
7031 | } | |
718e3744 | 7032 | |
06370dac DW |
7033 | if (json_bestpath) |
7034 | json_object_object_add(json_path, "bestpath", json_bestpath); | |
7035 | ||
b05a1c8b DS |
7036 | if (!json_paths) |
7037 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 7038 | |
7039 | /* Line 4 display Community */ | |
7040 | if (attr->community) | |
b05a1c8b DS |
7041 | { |
7042 | if (json_paths) | |
7043 | { | |
f1aa5d8a DS |
7044 | json_object_lock(attr->community->json); |
7045 | json_object_object_add(json_path, "community", attr->community->json); | |
b05a1c8b DS |
7046 | } |
7047 | else | |
7048 | { | |
7049 | vty_out (vty, " Community: %s%s", attr->community->str, | |
7050 | VTY_NEWLINE); | |
7051 | } | |
7052 | } | |
718e3744 | 7053 | |
7054 | /* Line 5 display Extended-community */ | |
7055 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) | |
b05a1c8b DS |
7056 | { |
7057 | if (json_paths) | |
7058 | { | |
f1aa5d8a DS |
7059 | json_ext_community = json_object_new_object(); |
7060 | json_object_string_add(json_ext_community, "string", attr->extra->ecommunity->str); | |
62d6dca0 | 7061 | json_object_object_add(json_path, "extendedCommunity", json_ext_community); |
b05a1c8b DS |
7062 | } |
7063 | else | |
7064 | { | |
7065 | vty_out (vty, " Extended Community: %s%s", | |
7066 | attr->extra->ecommunity->str, VTY_NEWLINE); | |
7067 | } | |
7068 | } | |
7069 | ||
718e3744 | 7070 | /* Line 6 display Originator, Cluster-id */ |
7071 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || | |
7072 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) | |
7073 | { | |
fb982c25 | 7074 | assert (attr->extra); |
718e3744 | 7075 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
b05a1c8b DS |
7076 | { |
7077 | if (json_paths) | |
62d6dca0 | 7078 | json_object_string_add(json_path, "originatorId", inet_ntoa (attr->extra->originator_id)); |
b05a1c8b | 7079 | else |
f1aa5d8a DS |
7080 | vty_out (vty, " Originator: %s", |
7081 | inet_ntoa (attr->extra->originator_id)); | |
b05a1c8b | 7082 | } |
718e3744 | 7083 | |
7084 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
7085 | { | |
7086 | int i; | |
b05a1c8b DS |
7087 | |
7088 | if (json_paths) | |
7089 | { | |
f1aa5d8a DS |
7090 | json_cluster_list = json_object_new_object(); |
7091 | json_cluster_list_list = json_object_new_array(); | |
7092 | ||
b05a1c8b DS |
7093 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
7094 | { | |
7095 | json_string = json_object_new_string(inet_ntoa (attr->extra->cluster->list[i])); | |
f1aa5d8a | 7096 | json_object_array_add(json_cluster_list_list, json_string); |
b05a1c8b | 7097 | } |
f1aa5d8a DS |
7098 | |
7099 | /* struct cluster_list does not have "str" variable like | |
7100 | * aspath and community do. Add this someday if someone | |
7101 | * asks for it. | |
7102 | json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str); | |
7103 | */ | |
7104 | json_object_object_add(json_cluster_list, "list", json_cluster_list_list); | |
62d6dca0 | 7105 | json_object_object_add(json_path, "clusterList", json_cluster_list); |
b05a1c8b DS |
7106 | } |
7107 | else | |
7108 | { | |
7109 | vty_out (vty, ", Cluster list: "); | |
7110 | ||
7111 | for (i = 0; i < attr->extra->cluster->length / 4; i++) | |
7112 | { | |
7113 | vty_out (vty, "%s ", | |
7114 | inet_ntoa (attr->extra->cluster->list[i])); | |
7115 | } | |
7116 | } | |
718e3744 | 7117 | } |
b05a1c8b DS |
7118 | |
7119 | if (!json_paths) | |
7120 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 7121 | } |
b05a1c8b | 7122 | |
fb982c25 | 7123 | if (binfo->extra && binfo->extra->damp_info) |
b05a1c8b | 7124 | bgp_damp_info_vty (vty, binfo, json_path); |
718e3744 | 7125 | |
a82478b9 DS |
7126 | /* Line 7 display Addpath IDs */ |
7127 | if (binfo->addpath_rx_id || binfo->addpath_tx_id) | |
b05a1c8b DS |
7128 | { |
7129 | if (json_paths) | |
7130 | { | |
62d6dca0 DS |
7131 | json_object_int_add(json_path, "addpathRxId", binfo->addpath_rx_id); |
7132 | json_object_int_add(json_path, "addpathTxId", binfo->addpath_tx_id); | |
b05a1c8b DS |
7133 | } |
7134 | else | |
7135 | { | |
7136 | vty_out (vty, " AddPath ID: RX %u, TX %u%s", | |
7137 | binfo->addpath_rx_id, binfo->addpath_tx_id, | |
7138 | VTY_NEWLINE); | |
7139 | } | |
7140 | } | |
a82478b9 | 7141 | |
adbac85e DW |
7142 | /* If we used addpath to TX a non-bestpath we need to display |
7143 | * "Advertised to" on a path-by-path basis */ | |
7144 | if (bgp->addpath_tx_used[afi][safi]) | |
7145 | { | |
7146 | first = 1; | |
7147 | ||
7148 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
7149 | { | |
7150 | addpath_capable = bgp_addpath_encode_tx (peer, afi, safi); | |
7151 | has_adj = bgp_adj_out_lookup (peer, binfo->net, binfo->addpath_tx_id); | |
7152 | ||
7153 | if ((addpath_capable && has_adj) || | |
7154 | (!addpath_capable && has_adj && CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))) | |
7155 | { | |
7156 | if (json_path && !json_adv_to) | |
7157 | json_adv_to = json_object_new_object(); | |
7158 | ||
7159 | route_vty_out_advertised_to(vty, peer, &first, | |
7160 | " Advertised to:", | |
7161 | json_adv_to); | |
7162 | } | |
7163 | } | |
7164 | ||
7165 | if (json_path) | |
7166 | { | |
7167 | if (json_adv_to) | |
7168 | { | |
7169 | json_object_object_add(json_path, "advertisedTo", json_adv_to); | |
7170 | } | |
7171 | } | |
7172 | else | |
7173 | { | |
7174 | if (!first) | |
7175 | { | |
7176 | vty_out (vty, "%s", VTY_NEWLINE); | |
7177 | } | |
7178 | } | |
7179 | } | |
7180 | ||
a82478b9 | 7181 | /* Line 8 display Uptime */ |
30b00176 JK |
7182 | #ifdef HAVE_CLOCK_MONOTONIC |
7183 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); | |
b05a1c8b | 7184 | if (json_paths) |
f1aa5d8a DS |
7185 | { |
7186 | json_last_update = json_object_new_object(); | |
7187 | json_object_int_add(json_last_update, "epoch", tbuf); | |
7188 | json_object_string_add(json_last_update, "string", ctime(&tbuf)); | |
62d6dca0 | 7189 | json_object_object_add(json_path, "lastUpdate", json_last_update); |
f1aa5d8a | 7190 | } |
b05a1c8b DS |
7191 | else |
7192 | vty_out (vty, " Last update: %s", ctime(&tbuf)); | |
30b00176 | 7193 | #else |
b05a1c8b | 7194 | if (json_paths) |
f1aa5d8a DS |
7195 | { |
7196 | json_last_update = json_object_new_object(); | |
7197 | json_object_int_add(json_last_update, "epoch", tbuf); | |
7198 | json_object_string_add(json_last_update, "string", ctime(&binfo->uptime)); | |
62d6dca0 | 7199 | json_object_object_add(json_path, "lastUpdate", json_last_update); |
f1aa5d8a | 7200 | } |
b05a1c8b DS |
7201 | else |
7202 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); | |
30b00176 | 7203 | #endif /* HAVE_CLOCK_MONOTONIC */ |
718e3744 | 7204 | } |
b05a1c8b DS |
7205 | |
7206 | /* We've constructed the json object for this path, add it to the json | |
7207 | * array of paths | |
7208 | */ | |
7209 | if (json_paths) | |
f1aa5d8a DS |
7210 | { |
7211 | if (json_nexthop_global || json_nexthop_ll) | |
7212 | { | |
7213 | json_nexthops = json_object_new_array(); | |
7214 | ||
7215 | if (json_nexthop_global) | |
7216 | json_object_array_add(json_nexthops, json_nexthop_global); | |
7217 | ||
7218 | if (json_nexthop_ll) | |
7219 | json_object_array_add(json_nexthops, json_nexthop_ll); | |
7220 | ||
7221 | json_object_object_add(json_path, "nexthops", json_nexthops); | |
7222 | } | |
7223 | ||
7224 | json_object_object_add(json_path, "peer", json_peer); | |
7225 | json_object_array_add(json_paths, json_path); | |
7226 | } | |
b05a1c8b DS |
7227 | else |
7228 | vty_out (vty, "%s", VTY_NEWLINE); | |
b366b518 BB |
7229 | } |
7230 | ||
47fc97cc | 7231 | #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s" |
718e3744 | 7232 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
7233 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" | |
7234 | ||
7235 | enum bgp_show_type | |
7236 | { | |
7237 | bgp_show_type_normal, | |
7238 | bgp_show_type_regexp, | |
7239 | bgp_show_type_prefix_list, | |
7240 | bgp_show_type_filter_list, | |
7241 | bgp_show_type_route_map, | |
7242 | bgp_show_type_neighbor, | |
7243 | bgp_show_type_cidr_only, | |
7244 | bgp_show_type_prefix_longer, | |
7245 | bgp_show_type_community_all, | |
7246 | bgp_show_type_community, | |
7247 | bgp_show_type_community_exact, | |
7248 | bgp_show_type_community_list, | |
7249 | bgp_show_type_community_list_exact, | |
7250 | bgp_show_type_flap_statistics, | |
7251 | bgp_show_type_flap_address, | |
7252 | bgp_show_type_flap_prefix, | |
7253 | bgp_show_type_flap_cidr_only, | |
7254 | bgp_show_type_flap_regexp, | |
7255 | bgp_show_type_flap_filter_list, | |
7256 | bgp_show_type_flap_prefix_list, | |
7257 | bgp_show_type_flap_prefix_longer, | |
7258 | bgp_show_type_flap_route_map, | |
7259 | bgp_show_type_flap_neighbor, | |
7260 | bgp_show_type_dampend_paths, | |
7261 | bgp_show_type_damp_neighbor | |
7262 | }; | |
7263 | ||
50ef26d4 | 7264 | static int |
7265 | bgp_show_prefix_list (struct vty *vty, const char *name, | |
7266 | const char *prefix_list_str, afi_t afi, | |
7267 | safi_t safi, enum bgp_show_type type); | |
7268 | static int | |
7269 | bgp_show_filter_list (struct vty *vty, const char *name, | |
7270 | const char *filter, afi_t afi, | |
7271 | safi_t safi, enum bgp_show_type type); | |
7272 | static int | |
7273 | bgp_show_route_map (struct vty *vty, const char *name, | |
7274 | const char *rmap_str, afi_t afi, | |
7275 | safi_t safi, enum bgp_show_type type); | |
7276 | static int | |
7277 | bgp_show_community_list (struct vty *vty, const char *name, | |
7278 | const char *com, int exact, | |
7279 | afi_t afi, safi_t safi); | |
7280 | static int | |
7281 | bgp_show_prefix_longer (struct vty *vty, const char *name, | |
7282 | const char *prefix, afi_t afi, | |
7283 | safi_t safi, enum bgp_show_type type); | |
7284 | ||
5a646650 | 7285 | static int |
9f689658 DD |
7286 | bgp_show_table (struct vty *vty, struct bgp_table *table, |
7287 | struct in_addr *router_id, enum bgp_show_type type, | |
7288 | void *output_arg, u_char use_json, json_object *json) | |
718e3744 | 7289 | { |
718e3744 | 7290 | struct bgp_info *ri; |
7291 | struct bgp_node *rn; | |
718e3744 | 7292 | int header = 1; |
718e3744 | 7293 | int display; |
5a646650 | 7294 | unsigned long output_count; |
b05a1c8b DS |
7295 | struct prefix *p; |
7296 | char buf[BUFSIZ]; | |
7297 | char buf2[BUFSIZ]; | |
f1aa5d8a DS |
7298 | json_object *json_paths = NULL; |
7299 | json_object *json_routes = NULL; | |
b05a1c8b DS |
7300 | |
7301 | if (use_json) | |
7302 | { | |
9f689658 DD |
7303 | if (json == NULL) |
7304 | json = json_object_new_object(); | |
7305 | ||
62d6dca0 DS |
7306 | json_object_int_add(json, "tableVersion", table->version); |
7307 | json_object_string_add(json, "routerId", inet_ntoa (*router_id)); | |
b05a1c8b DS |
7308 | json_routes = json_object_new_object(); |
7309 | } | |
718e3744 | 7310 | |
7311 | /* This is first entry point, so reset total line. */ | |
5a646650 | 7312 | output_count = 0; |
718e3744 | 7313 | |
718e3744 | 7314 | /* Start processing of routes. */ |
7315 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
7316 | if (rn->info != NULL) | |
7317 | { | |
856ca177 | 7318 | display = 0; |
718e3744 | 7319 | |
b05a1c8b DS |
7320 | if (use_json) |
7321 | json_paths = json_object_new_array(); | |
7322 | else | |
7323 | json_paths = NULL; | |
7324 | ||
856ca177 MS |
7325 | for (ri = rn->info; ri; ri = ri->next) |
7326 | { | |
7327 | if (type == bgp_show_type_flap_statistics | |
7328 | || type == bgp_show_type_flap_address | |
7329 | || type == bgp_show_type_flap_prefix | |
7330 | || type == bgp_show_type_flap_cidr_only | |
7331 | || type == bgp_show_type_flap_regexp | |
7332 | || type == bgp_show_type_flap_filter_list | |
7333 | || type == bgp_show_type_flap_prefix_list | |
7334 | || type == bgp_show_type_flap_prefix_longer | |
7335 | || type == bgp_show_type_flap_route_map | |
7336 | || type == bgp_show_type_flap_neighbor | |
7337 | || type == bgp_show_type_dampend_paths | |
7338 | || type == bgp_show_type_damp_neighbor) | |
7339 | { | |
7340 | if (!(ri->extra && ri->extra->damp_info)) | |
7341 | continue; | |
7342 | } | |
7343 | if (type == bgp_show_type_regexp | |
7344 | || type == bgp_show_type_flap_regexp) | |
7345 | { | |
7346 | regex_t *regex = output_arg; | |
718e3744 | 7347 | |
856ca177 MS |
7348 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
7349 | continue; | |
7350 | } | |
7351 | if (type == bgp_show_type_prefix_list | |
7352 | || type == bgp_show_type_flap_prefix_list) | |
7353 | { | |
7354 | struct prefix_list *plist = output_arg; | |
718e3744 | 7355 | |
856ca177 MS |
7356 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
7357 | continue; | |
7358 | } | |
7359 | if (type == bgp_show_type_filter_list | |
7360 | || type == bgp_show_type_flap_filter_list) | |
7361 | { | |
7362 | struct as_list *as_list = output_arg; | |
558d1fec | 7363 | |
856ca177 MS |
7364 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
7365 | continue; | |
7366 | } | |
7367 | if (type == bgp_show_type_route_map | |
7368 | || type == bgp_show_type_flap_route_map) | |
7369 | { | |
7370 | struct route_map *rmap = output_arg; | |
7371 | struct bgp_info binfo; | |
7372 | struct attr dummy_attr; | |
7373 | struct attr_extra dummy_extra; | |
7374 | int ret; | |
718e3744 | 7375 | |
856ca177 MS |
7376 | dummy_attr.extra = &dummy_extra; |
7377 | bgp_attr_dup (&dummy_attr, ri->attr); | |
718e3744 | 7378 | |
856ca177 MS |
7379 | binfo.peer = ri->peer; |
7380 | binfo.attr = &dummy_attr; | |
718e3744 | 7381 | |
856ca177 MS |
7382 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
7383 | if (ret == RMAP_DENYMATCH) | |
7384 | continue; | |
7385 | } | |
7386 | if (type == bgp_show_type_neighbor | |
7387 | || type == bgp_show_type_flap_neighbor | |
7388 | || type == bgp_show_type_damp_neighbor) | |
7389 | { | |
7390 | union sockunion *su = output_arg; | |
718e3744 | 7391 | |
856ca177 MS |
7392 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
7393 | continue; | |
7394 | } | |
7395 | if (type == bgp_show_type_cidr_only | |
7396 | || type == bgp_show_type_flap_cidr_only) | |
7397 | { | |
7398 | u_int32_t destination; | |
718e3744 | 7399 | |
856ca177 MS |
7400 | destination = ntohl (rn->p.u.prefix4.s_addr); |
7401 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) | |
7402 | continue; | |
7403 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) | |
7404 | continue; | |
7405 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) | |
7406 | continue; | |
7407 | } | |
7408 | if (type == bgp_show_type_prefix_longer | |
7409 | || type == bgp_show_type_flap_prefix_longer) | |
7410 | { | |
7411 | struct prefix *p = output_arg; | |
718e3744 | 7412 | |
856ca177 MS |
7413 | if (! prefix_match (p, &rn->p)) |
7414 | continue; | |
7415 | } | |
7416 | if (type == bgp_show_type_community_all) | |
7417 | { | |
7418 | if (! ri->attr->community) | |
7419 | continue; | |
7420 | } | |
7421 | if (type == bgp_show_type_community) | |
7422 | { | |
7423 | struct community *com = output_arg; | |
718e3744 | 7424 | |
856ca177 MS |
7425 | if (! ri->attr->community || |
7426 | ! community_match (ri->attr->community, com)) | |
7427 | continue; | |
7428 | } | |
7429 | if (type == bgp_show_type_community_exact) | |
7430 | { | |
7431 | struct community *com = output_arg; | |
718e3744 | 7432 | |
856ca177 MS |
7433 | if (! ri->attr->community || |
7434 | ! community_cmp (ri->attr->community, com)) | |
7435 | continue; | |
7436 | } | |
7437 | if (type == bgp_show_type_community_list) | |
7438 | { | |
7439 | struct community_list *list = output_arg; | |
718e3744 | 7440 | |
856ca177 MS |
7441 | if (! community_list_match (ri->attr->community, list)) |
7442 | continue; | |
7443 | } | |
7444 | if (type == bgp_show_type_community_list_exact) | |
7445 | { | |
7446 | struct community_list *list = output_arg; | |
718e3744 | 7447 | |
856ca177 MS |
7448 | if (! community_list_exact_match (ri->attr->community, list)) |
7449 | continue; | |
7450 | } | |
7451 | if (type == bgp_show_type_flap_address | |
7452 | || type == bgp_show_type_flap_prefix) | |
7453 | { | |
7454 | struct prefix *p = output_arg; | |
718e3744 | 7455 | |
856ca177 MS |
7456 | if (! prefix_match (&rn->p, p)) |
7457 | continue; | |
b05a1c8b | 7458 | |
856ca177 MS |
7459 | if (type == bgp_show_type_flap_prefix) |
7460 | if (p->prefixlen != rn->p.prefixlen) | |
7461 | continue; | |
7462 | } | |
7463 | if (type == bgp_show_type_dampend_paths | |
7464 | || type == bgp_show_type_damp_neighbor) | |
7465 | { | |
7466 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) | |
7467 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
7468 | continue; | |
7469 | } | |
7470 | ||
7471 | if (!use_json && header) | |
7472 | { | |
7473 | vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (*router_id), VTY_NEWLINE); | |
7474 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
7475 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
7476 | if (type == bgp_show_type_dampend_paths | |
7477 | || type == bgp_show_type_damp_neighbor) | |
7478 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); | |
7479 | else if (type == bgp_show_type_flap_statistics | |
7480 | || type == bgp_show_type_flap_address | |
7481 | || type == bgp_show_type_flap_prefix | |
7482 | || type == bgp_show_type_flap_cidr_only | |
7483 | || type == bgp_show_type_flap_regexp | |
7484 | || type == bgp_show_type_flap_filter_list | |
7485 | || type == bgp_show_type_flap_prefix_list | |
7486 | || type == bgp_show_type_flap_prefix_longer | |
7487 | || type == bgp_show_type_flap_route_map | |
7488 | || type == bgp_show_type_flap_neighbor) | |
7489 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); | |
7490 | else | |
7491 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
7492 | header = 0; | |
7493 | } | |
7494 | ||
7495 | if (type == bgp_show_type_dampend_paths | |
7496 | || type == bgp_show_type_damp_neighbor) | |
7497 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); | |
7498 | else if (type == bgp_show_type_flap_statistics | |
7499 | || type == bgp_show_type_flap_address | |
7500 | || type == bgp_show_type_flap_prefix | |
7501 | || type == bgp_show_type_flap_cidr_only | |
7502 | || type == bgp_show_type_flap_regexp | |
7503 | || type == bgp_show_type_flap_filter_list | |
7504 | || type == bgp_show_type_flap_prefix_list | |
7505 | || type == bgp_show_type_flap_prefix_longer | |
7506 | || type == bgp_show_type_flap_route_map | |
7507 | || type == bgp_show_type_flap_neighbor) | |
7508 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); | |
7509 | else | |
7510 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, json_paths); | |
7511 | display++; | |
b05a1c8b DS |
7512 | } |
7513 | ||
856ca177 MS |
7514 | if (display) |
7515 | { | |
7516 | output_count++; | |
7517 | if (use_json) | |
7518 | { | |
7519 | p = &rn->p; | |
7520 | sprintf(buf2, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen); | |
7521 | json_object_object_add(json_routes, buf2, json_paths); | |
7522 | } | |
7523 | } | |
9f689658 | 7524 | } |
718e3744 | 7525 | |
b05a1c8b | 7526 | if (use_json) |
718e3744 | 7527 | { |
d1d16a96 | 7528 | json_object_object_add(json, "routes", json_routes); |
b05a1c8b | 7529 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); |
f1aa5d8a | 7530 | json_object_free(json); |
718e3744 | 7531 | } |
7532 | else | |
b05a1c8b DS |
7533 | { |
7534 | /* No route is displayed */ | |
7535 | if (output_count == 0) | |
7536 | { | |
7537 | if (type == bgp_show_type_normal) | |
856ca177 | 7538 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
b05a1c8b DS |
7539 | } |
7540 | else | |
7541 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
856ca177 | 7542 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
b05a1c8b | 7543 | } |
718e3744 | 7544 | |
7545 | return CMD_SUCCESS; | |
7546 | } | |
7547 | ||
5a646650 | 7548 | static int |
fee0f4c6 | 7549 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
856ca177 | 7550 | enum bgp_show_type type, void *output_arg, u_char use_json) |
fee0f4c6 | 7551 | { |
7552 | struct bgp_table *table; | |
7553 | ||
856ca177 MS |
7554 | if (bgp == NULL) |
7555 | { | |
7556 | bgp = bgp_get_default (); | |
7557 | } | |
fee0f4c6 | 7558 | |
7559 | if (bgp == NULL) | |
7560 | { | |
856ca177 MS |
7561 | if (!use_json) |
7562 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
fee0f4c6 | 7563 | return CMD_WARNING; |
7564 | } | |
7565 | ||
fee0f4c6 | 7566 | table = bgp->rib[afi][safi]; |
7567 | ||
9f689658 DD |
7568 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg, |
7569 | use_json, NULL); | |
fee0f4c6 | 7570 | } |
7571 | ||
f186de26 | 7572 | static void |
7573 | bgp_show_all_instances_routes_vty (struct vty *vty, afi_t afi, safi_t safi, | |
7574 | u_char use_json) | |
7575 | { | |
7576 | struct listnode *node, *nnode; | |
7577 | struct bgp *bgp; | |
7578 | struct bgp_table *table; | |
9f689658 DD |
7579 | json_object *json = NULL; |
7580 | int is_first = 1; | |
7581 | ||
7582 | if (use_json) | |
7583 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 7584 | |
7585 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
7586 | { | |
9f689658 DD |
7587 | if (use_json) |
7588 | { | |
7589 | if (!(json = json_object_new_object())) | |
7590 | { | |
7591 | zlog_err("Unable to allocate memory for JSON object"); | |
7592 | vty_out (vty, | |
7593 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
7594 | VTY_NEWLINE); | |
7595 | return; | |
7596 | } | |
7597 | json_object_int_add(json, "vrfId", | |
7598 | (bgp->vrf_id == VRF_UNKNOWN) | |
7599 | ? -1 : bgp->vrf_id); | |
7600 | json_object_string_add(json, "vrfName", | |
7601 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7602 | ? "Default" : bgp->name); | |
7603 | if (! is_first) | |
7604 | vty_out (vty, ",%s", VTY_NEWLINE); | |
7605 | else | |
7606 | is_first = 0; | |
7607 | ||
7608 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7609 | ? "Default" : bgp->name); | |
7610 | } | |
7611 | else | |
7612 | { | |
7613 | vty_out (vty, "%sInstance %s:%s", | |
7614 | VTY_NEWLINE, | |
7615 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7616 | ? "Default" : bgp->name, | |
7617 | VTY_NEWLINE); | |
7618 | } | |
f186de26 | 7619 | table = bgp->rib[afi][safi]; |
7620 | bgp_show_table (vty, table, &bgp->router_id, | |
9f689658 DD |
7621 | bgp_show_type_normal, NULL, use_json, json); |
7622 | ||
f186de26 | 7623 | } |
9f689658 DD |
7624 | |
7625 | if (use_json) | |
7626 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 7627 | } |
7628 | ||
718e3744 | 7629 | /* Header of detailed BGP route information */ |
94f2b392 | 7630 | static void |
718e3744 | 7631 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
7632 | struct bgp_node *rn, | |
b05a1c8b DS |
7633 | struct prefix_rd *prd, afi_t afi, safi_t safi, |
7634 | json_object *json) | |
718e3744 | 7635 | { |
7636 | struct bgp_info *ri; | |
7637 | struct prefix *p; | |
7638 | struct peer *peer; | |
1eb8ef25 | 7639 | struct listnode *node, *nnode; |
718e3744 | 7640 | char buf1[INET6_ADDRSTRLEN]; |
7641 | char buf2[INET6_ADDRSTRLEN]; | |
7642 | int count = 0; | |
7643 | int best = 0; | |
7644 | int suppress = 0; | |
7645 | int no_export = 0; | |
7646 | int no_advertise = 0; | |
7647 | int local_as = 0; | |
adbac85e | 7648 | int first = 1; |
ffd0c037 | 7649 | json_object *json_adv_to = NULL; |
718e3744 | 7650 | |
7651 | p = &rn->p; | |
b05a1c8b DS |
7652 | |
7653 | if (json) | |
7654 | { | |
f1aa5d8a DS |
7655 | json_object_string_add(json, "prefix", inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN)); |
7656 | json_object_int_add(json, "prefixlen", p->prefixlen); | |
b05a1c8b DS |
7657 | } |
7658 | else | |
7659 | { | |
7660 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", | |
587ff0fd | 7661 | ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) ? |
b05a1c8b DS |
7662 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
7663 | safi == SAFI_MPLS_VPN ? ":" : "", | |
7664 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), | |
7665 | p->prefixlen, VTY_NEWLINE); | |
7666 | } | |
718e3744 | 7667 | |
7668 | for (ri = rn->info; ri; ri = ri->next) | |
7669 | { | |
7670 | count++; | |
7671 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
7672 | { | |
7673 | best = count; | |
fb982c25 | 7674 | if (ri->extra && ri->extra->suppress) |
718e3744 | 7675 | suppress = 1; |
7676 | if (ri->attr->community != NULL) | |
7677 | { | |
7678 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) | |
7679 | no_advertise = 1; | |
7680 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) | |
7681 | no_export = 1; | |
7682 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) | |
7683 | local_as = 1; | |
7684 | } | |
7685 | } | |
7686 | } | |
7687 | ||
b05a1c8b | 7688 | if (!json) |
718e3744 | 7689 | { |
b05a1c8b DS |
7690 | vty_out (vty, "Paths: (%d available", count); |
7691 | if (best) | |
7692 | { | |
7693 | vty_out (vty, ", best #%d", best); | |
7694 | if (safi == SAFI_UNICAST) | |
46827ae9 DS |
7695 | vty_out (vty, ", table %s", |
7696 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7697 | ? "Default-IP-Routing-Table" : bgp->name); | |
b05a1c8b DS |
7698 | } |
7699 | else | |
7700 | vty_out (vty, ", no best path"); | |
7701 | ||
7702 | if (no_advertise) | |
7703 | vty_out (vty, ", not advertised to any peer"); | |
7704 | else if (no_export) | |
7705 | vty_out (vty, ", not advertised to EBGP peer"); | |
7706 | else if (local_as) | |
7707 | vty_out (vty, ", not advertised outside local AS"); | |
7708 | ||
7709 | if (suppress) | |
7710 | vty_out (vty, ", Advertisements suppressed by an aggregate."); | |
7711 | vty_out (vty, ")%s", VTY_NEWLINE); | |
718e3744 | 7712 | } |
718e3744 | 7713 | |
adbac85e DW |
7714 | /* If we are not using addpath then we can display Advertised to and that will |
7715 | * show what peers we advertised the bestpath to. If we are using addpath | |
7716 | * though then we must display Advertised to on a path-by-path basis. */ | |
7717 | if (!bgp->addpath_tx_used[afi][safi]) | |
718e3744 | 7718 | { |
adbac85e DW |
7719 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
7720 | { | |
7721 | if (bgp_adj_out_lookup (peer, rn, 0)) | |
b05a1c8b | 7722 | { |
adbac85e | 7723 | if (json && !json_adv_to) |
f1aa5d8a | 7724 | json_adv_to = json_object_new_object(); |
6410e93a | 7725 | |
adbac85e DW |
7726 | route_vty_out_advertised_to(vty, peer, &first, |
7727 | " Advertised to non peer-group peers:\n ", | |
7728 | json_adv_to); | |
b05a1c8b | 7729 | } |
adbac85e | 7730 | } |
036a4e7d | 7731 | |
adbac85e DW |
7732 | if (json) |
7733 | { | |
7734 | if (json_adv_to) | |
7735 | { | |
7736 | json_object_object_add(json, "advertisedTo", json_adv_to); | |
b05a1c8b | 7737 | } |
adbac85e DW |
7738 | } |
7739 | else | |
b05a1c8b | 7740 | { |
adbac85e DW |
7741 | if (first) |
7742 | vty_out (vty, " Not advertised to any peer"); | |
7743 | vty_out (vty, "%s", VTY_NEWLINE); | |
b05a1c8b DS |
7744 | } |
7745 | } | |
718e3744 | 7746 | } |
7747 | ||
7748 | /* Display specified route of BGP table. */ | |
94f2b392 | 7749 | static int |
fee0f4c6 | 7750 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
fd79ac91 | 7751 | struct bgp_table *rib, const char *ip_str, |
7752 | afi_t afi, safi_t safi, struct prefix_rd *prd, | |
b05a1c8b DS |
7753 | int prefix_check, enum bgp_path_type pathtype, |
7754 | u_char use_json) | |
718e3744 | 7755 | { |
7756 | int ret; | |
7757 | int header; | |
7758 | int display = 0; | |
7759 | struct prefix match; | |
7760 | struct bgp_node *rn; | |
7761 | struct bgp_node *rm; | |
7762 | struct bgp_info *ri; | |
718e3744 | 7763 | struct bgp_table *table; |
f1aa5d8a DS |
7764 | json_object *json = NULL; |
7765 | json_object *json_paths = NULL; | |
718e3744 | 7766 | |
718e3744 | 7767 | /* Check IP address argument. */ |
7768 | ret = str2prefix (ip_str, &match); | |
7769 | if (! ret) | |
7770 | { | |
7771 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); | |
7772 | return CMD_WARNING; | |
7773 | } | |
7774 | ||
7775 | match.family = afi2family (afi); | |
7776 | ||
b05a1c8b DS |
7777 | if (use_json) |
7778 | { | |
7779 | json = json_object_new_object(); | |
7780 | json_paths = json_object_new_array(); | |
7781 | } | |
b05a1c8b | 7782 | |
587ff0fd | 7783 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
718e3744 | 7784 | { |
fee0f4c6 | 7785 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
718e3744 | 7786 | { |
7787 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
7788 | continue; | |
7789 | ||
7790 | if ((table = rn->info) != NULL) | |
7791 | { | |
7792 | header = 1; | |
7793 | ||
7794 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
7795 | { | |
7796 | if (prefix_check && rm->p.prefixlen != match.prefixlen) | |
6c88b44d CC |
7797 | { |
7798 | bgp_unlock_node (rm); | |
7799 | continue; | |
7800 | } | |
718e3744 | 7801 | |
7802 | for (ri = rm->info; ri; ri = ri->next) | |
7803 | { | |
7804 | if (header) | |
7805 | { | |
7806 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, | |
587ff0fd | 7807 | AFI_IP, safi, json); |
718e3744 | 7808 | header = 0; |
7809 | } | |
7810 | display++; | |
4092b06c DS |
7811 | |
7812 | if (pathtype == BGP_PATH_ALL || | |
7813 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || | |
7814 | (pathtype == BGP_PATH_MULTIPATH && | |
7815 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) | |
587ff0fd | 7816 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi, json_paths); |
718e3744 | 7817 | } |
6c88b44d CC |
7818 | |
7819 | bgp_unlock_node (rm); | |
718e3744 | 7820 | } |
7821 | } | |
7822 | } | |
7823 | } | |
7824 | else | |
7825 | { | |
7826 | header = 1; | |
7827 | ||
fee0f4c6 | 7828 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
718e3744 | 7829 | { |
7830 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
7831 | { | |
7832 | for (ri = rn->info; ri; ri = ri->next) | |
7833 | { | |
7834 | if (header) | |
7835 | { | |
b05a1c8b | 7836 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi, json); |
718e3744 | 7837 | header = 0; |
7838 | } | |
7839 | display++; | |
4092b06c DS |
7840 | |
7841 | if (pathtype == BGP_PATH_ALL || | |
7842 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || | |
7843 | (pathtype == BGP_PATH_MULTIPATH && | |
7844 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) | |
b05a1c8b | 7845 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, json_paths); |
718e3744 | 7846 | } |
7847 | } | |
6c88b44d CC |
7848 | |
7849 | bgp_unlock_node (rn); | |
718e3744 | 7850 | } |
7851 | } | |
7852 | ||
e5eee9af | 7853 | if (use_json) |
718e3744 | 7854 | { |
e5eee9af DS |
7855 | if (display) |
7856 | json_object_object_add(json, "paths", json_paths); | |
7857 | ||
7858 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
f1aa5d8a | 7859 | json_object_free(json); |
b05a1c8b DS |
7860 | } |
7861 | else | |
7862 | { | |
e5eee9af | 7863 | if (!display) |
b05a1c8b DS |
7864 | { |
7865 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); | |
7866 | return CMD_WARNING; | |
7867 | } | |
7868 | } | |
7869 | ||
718e3744 | 7870 | return CMD_SUCCESS; |
7871 | } | |
7872 | ||
fee0f4c6 | 7873 | /* Display specified route of Main RIB */ |
94f2b392 | 7874 | static int |
fd79ac91 | 7875 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
fee0f4c6 | 7876 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
b05a1c8b DS |
7877 | int prefix_check, enum bgp_path_type pathtype, |
7878 | u_char use_json) | |
fee0f4c6 | 7879 | { |
7880 | struct bgp *bgp; | |
7881 | ||
7882 | /* BGP structure lookup. */ | |
7883 | if (view_name) | |
7884 | { | |
7885 | bgp = bgp_lookup_by_name (view_name); | |
7886 | if (bgp == NULL) | |
7887 | { | |
6aeb9e78 | 7888 | vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
fee0f4c6 | 7889 | return CMD_WARNING; |
7890 | } | |
7891 | } | |
7892 | else | |
7893 | { | |
7894 | bgp = bgp_get_default (); | |
7895 | if (bgp == NULL) | |
7896 | { | |
7897 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
7898 | return CMD_WARNING; | |
7899 | } | |
7900 | } | |
7901 | ||
7902 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, | |
b05a1c8b DS |
7903 | afi, safi, prd, prefix_check, pathtype, |
7904 | use_json); | |
fee0f4c6 | 7905 | } |
7906 | ||
718e3744 | 7907 | /* BGP route print out function. */ |
7908 | DEFUN (show_ip_bgp, | |
7909 | show_ip_bgp_cmd, | |
b05a1c8b | 7910 | "show ip bgp {json}", |
47fc97cc DS |
7911 | SHOW_STR |
7912 | IP_STR | |
b05a1c8b DS |
7913 | BGP_STR |
7914 | "JavaScript Object Notation\n") | |
47fc97cc | 7915 | { |
db7c8528 | 7916 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); |
718e3744 | 7917 | } |
7918 | ||
7919 | DEFUN (show_ip_bgp_ipv4, | |
7920 | show_ip_bgp_ipv4_cmd, | |
b05a1c8b | 7921 | "show ip bgp ipv4 (unicast|multicast) {json}", |
718e3744 | 7922 | SHOW_STR |
7923 | IP_STR | |
7924 | BGP_STR | |
7925 | "Address family\n" | |
7926 | "Address Family modifier\n" | |
b05a1c8b DS |
7927 | "Address Family modifier\n" |
7928 | "JavaScript Object Notation\n") | |
718e3744 | 7929 | { |
db7c8528 | 7930 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7931 | |
718e3744 | 7932 | if (strncmp (argv[0], "m", 1) == 0) |
5a646650 | 7933 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
db7c8528 | 7934 | NULL, uj); |
718e3744 | 7935 | |
db7c8528 | 7936 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); |
718e3744 | 7937 | } |
7938 | ||
95cbbd2a ML |
7939 | ALIAS (show_ip_bgp_ipv4, |
7940 | show_bgp_ipv4_safi_cmd, | |
b05a1c8b | 7941 | "show bgp ipv4 (unicast|multicast) {json}", |
95cbbd2a ML |
7942 | SHOW_STR |
7943 | BGP_STR | |
7944 | "Address family\n" | |
7945 | "Address Family modifier\n" | |
47fc97cc | 7946 | "Address Family modifier\n" |
b05a1c8b | 7947 | "JavaScript Object Notation\n") |
47fc97cc | 7948 | |
718e3744 | 7949 | DEFUN (show_ip_bgp_route, |
7950 | show_ip_bgp_route_cmd, | |
b05a1c8b | 7951 | "show ip bgp A.B.C.D {json}", |
718e3744 | 7952 | SHOW_STR |
7953 | IP_STR | |
7954 | BGP_STR | |
b05a1c8b DS |
7955 | "Network in the BGP routing table to display\n" |
7956 | "JavaScript Object Notation\n") | |
718e3744 | 7957 | { |
db7c8528 | 7958 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
4092b06c DS |
7959 | } |
7960 | ||
7961 | DEFUN (show_ip_bgp_route_pathtype, | |
7962 | show_ip_bgp_route_pathtype_cmd, | |
b05a1c8b | 7963 | "show ip bgp A.B.C.D (bestpath|multipath) {json}", |
4092b06c DS |
7964 | SHOW_STR |
7965 | IP_STR | |
7966 | BGP_STR | |
7967 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
7968 | "Display only the bestpath\n" | |
b05a1c8b DS |
7969 | "Display only multipaths\n" |
7970 | "JavaScript Object Notation\n") | |
4092b06c | 7971 | { |
db7c8528 | 7972 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7973 | |
4092b06c | 7974 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 7975 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 7976 | else |
db7c8528 | 7977 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
7978 | } |
7979 | ||
7980 | DEFUN (show_bgp_ipv4_safi_route_pathtype, | |
7981 | show_bgp_ipv4_safi_route_pathtype_cmd, | |
b05a1c8b | 7982 | "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}", |
4092b06c DS |
7983 | SHOW_STR |
7984 | BGP_STR | |
7985 | "Address family\n" | |
7986 | "Address Family modifier\n" | |
7987 | "Address Family modifier\n" | |
7988 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
7989 | "Display only the bestpath\n" | |
b05a1c8b DS |
7990 | "Display only multipaths\n" |
7991 | "JavaScript Object Notation\n") | |
4092b06c | 7992 | { |
db7c8528 | 7993 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7994 | |
4092b06c DS |
7995 | if (strncmp (argv[0], "m", 1) == 0) |
7996 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 7997 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 7998 | else |
db7c8528 | 7999 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8000 | else |
8001 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8002 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8003 | else |
db7c8528 | 8004 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
718e3744 | 8005 | } |
8006 | ||
8007 | DEFUN (show_ip_bgp_ipv4_route, | |
8008 | show_ip_bgp_ipv4_route_cmd, | |
b05a1c8b | 8009 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}", |
718e3744 | 8010 | SHOW_STR |
8011 | IP_STR | |
8012 | BGP_STR | |
8013 | "Address family\n" | |
8014 | "Address Family modifier\n" | |
8015 | "Address Family modifier\n" | |
b05a1c8b DS |
8016 | "Network in the BGP routing table to display\n" |
8017 | "JavaScript Object Notation\n") | |
718e3744 | 8018 | { |
db7c8528 | 8019 | u_char uj = use_json(argc, argv); |
b05a1c8b | 8020 | |
718e3744 | 8021 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8022 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); |
718e3744 | 8023 | |
db7c8528 | 8024 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); |
718e3744 | 8025 | } |
8026 | ||
95cbbd2a ML |
8027 | ALIAS (show_ip_bgp_ipv4_route, |
8028 | show_bgp_ipv4_safi_route_cmd, | |
b05a1c8b | 8029 | "show bgp ipv4 (unicast|multicast) A.B.C.D {json}", |
95cbbd2a ML |
8030 | SHOW_STR |
8031 | BGP_STR | |
8032 | "Address family\n" | |
8033 | "Address Family modifier\n" | |
8034 | "Address Family modifier\n" | |
b05a1c8b DS |
8035 | "Network in the BGP routing table to display\n" |
8036 | "JavaScript Object Notation\n") | |
95cbbd2a | 8037 | |
718e3744 | 8038 | DEFUN (show_ip_bgp_vpnv4_all_route, |
8039 | show_ip_bgp_vpnv4_all_route_cmd, | |
b05a1c8b | 8040 | "show ip bgp vpnv4 all A.B.C.D {json}", |
718e3744 | 8041 | SHOW_STR |
8042 | IP_STR | |
8043 | BGP_STR | |
8044 | "Display VPNv4 NLRI specific information\n" | |
8045 | "Display information about all VPNv4 NLRIs\n" | |
b05a1c8b DS |
8046 | "Network in the BGP routing table to display\n" |
8047 | "JavaScript Object Notation\n") | |
718e3744 | 8048 | { |
db7c8528 | 8049 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8050 | } |
8051 | ||
4092b06c | 8052 | |
718e3744 | 8053 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
8054 | show_ip_bgp_vpnv4_rd_route_cmd, | |
b05a1c8b | 8055 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}", |
718e3744 | 8056 | SHOW_STR |
8057 | IP_STR | |
8058 | BGP_STR | |
8059 | "Display VPNv4 NLRI specific information\n" | |
8060 | "Display information for a route distinguisher\n" | |
8061 | "VPN Route Distinguisher\n" | |
b05a1c8b DS |
8062 | "Network in the BGP routing table to display\n" |
8063 | "JavaScript Object Notation\n") | |
718e3744 | 8064 | { |
8065 | int ret; | |
8066 | struct prefix_rd prd; | |
db7c8528 | 8067 | u_char uj= use_json(argc, argv); |
718e3744 | 8068 | |
8069 | ret = str2prefix_rd (argv[0], &prd); | |
8070 | if (! ret) | |
8071 | { | |
8072 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
8073 | return CMD_WARNING; | |
8074 | } | |
db7c8528 | 8075 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); |
718e3744 | 8076 | } |
8077 | ||
8078 | DEFUN (show_ip_bgp_prefix, | |
8079 | show_ip_bgp_prefix_cmd, | |
b05a1c8b | 8080 | "show ip bgp A.B.C.D/M {json}", |
718e3744 | 8081 | SHOW_STR |
8082 | IP_STR | |
8083 | BGP_STR | |
b05a1c8b DS |
8084 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8085 | "JavaScript Object Notation\n") | |
718e3744 | 8086 | { |
db7c8528 | 8087 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
4092b06c DS |
8088 | } |
8089 | ||
8090 | DEFUN (show_ip_bgp_prefix_pathtype, | |
8091 | show_ip_bgp_prefix_pathtype_cmd, | |
b05a1c8b | 8092 | "show ip bgp A.B.C.D/M (bestpath|multipath) {json}", |
4092b06c DS |
8093 | SHOW_STR |
8094 | IP_STR | |
8095 | BGP_STR | |
8096 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8097 | "Display only the bestpath\n" | |
b05a1c8b DS |
8098 | "Display only multipaths\n" |
8099 | "JavaScript Object Notation\n") | |
4092b06c | 8100 | { |
db7c8528 | 8101 | u_char uj = use_json(argc, argv); |
4092b06c | 8102 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 8103 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8104 | else |
db7c8528 | 8105 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
718e3744 | 8106 | } |
8107 | ||
8108 | DEFUN (show_ip_bgp_ipv4_prefix, | |
8109 | show_ip_bgp_ipv4_prefix_cmd, | |
b05a1c8b | 8110 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", |
718e3744 | 8111 | SHOW_STR |
8112 | IP_STR | |
8113 | BGP_STR | |
8114 | "Address family\n" | |
8115 | "Address Family modifier\n" | |
8116 | "Address Family modifier\n" | |
b05a1c8b DS |
8117 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8118 | "JavaScript Object Notation\n") | |
718e3744 | 8119 | { |
db7c8528 | 8120 | u_char uj = use_json(argc, argv); |
b05a1c8b | 8121 | |
718e3744 | 8122 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8123 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); |
718e3744 | 8124 | |
db7c8528 | 8125 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); |
718e3744 | 8126 | } |
8127 | ||
95cbbd2a ML |
8128 | ALIAS (show_ip_bgp_ipv4_prefix, |
8129 | show_bgp_ipv4_safi_prefix_cmd, | |
b05a1c8b | 8130 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", |
95cbbd2a ML |
8131 | SHOW_STR |
8132 | BGP_STR | |
8133 | "Address family\n" | |
8134 | "Address Family modifier\n" | |
8135 | "Address Family modifier\n" | |
b05a1c8b DS |
8136 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8137 | "JavaScript Object Notation\n") | |
95cbbd2a | 8138 | |
4092b06c DS |
8139 | DEFUN (show_ip_bgp_ipv4_prefix_pathtype, |
8140 | show_ip_bgp_ipv4_prefix_pathtype_cmd, | |
b05a1c8b | 8141 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", |
4092b06c DS |
8142 | SHOW_STR |
8143 | IP_STR | |
8144 | BGP_STR | |
8145 | "Address family\n" | |
8146 | "Address Family modifier\n" | |
8147 | "Address Family modifier\n" | |
8148 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8149 | "Display only the bestpath\n" | |
b05a1c8b DS |
8150 | "Display only multipaths\n" |
8151 | "JavaScript Object Notation\n") | |
4092b06c | 8152 | { |
db7c8528 | 8153 | u_char uj = use_json(argc, argv); |
b05a1c8b | 8154 | |
4092b06c DS |
8155 | if (strncmp (argv[0], "m", 1) == 0) |
8156 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8157 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8158 | else |
db7c8528 | 8159 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8160 | else |
8161 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8162 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8163 | else |
db7c8528 | 8164 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8165 | } |
8166 | ||
8167 | ALIAS (show_ip_bgp_ipv4_prefix_pathtype, | |
8168 | show_bgp_ipv4_safi_prefix_pathtype_cmd, | |
b05a1c8b | 8169 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", |
4092b06c DS |
8170 | SHOW_STR |
8171 | BGP_STR | |
8172 | "Address family\n" | |
8173 | "Address Family modifier\n" | |
8174 | "Address Family modifier\n" | |
8175 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8176 | "Display only the bestpath\n" | |
b05a1c8b DS |
8177 | "Display only multipaths\n" |
8178 | "JavaScript Object Notation\n") | |
4092b06c | 8179 | |
718e3744 | 8180 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
8181 | show_ip_bgp_vpnv4_all_prefix_cmd, | |
b05a1c8b | 8182 | "show ip bgp vpnv4 all A.B.C.D/M {json}", |
718e3744 | 8183 | SHOW_STR |
8184 | IP_STR | |
8185 | BGP_STR | |
8186 | "Display VPNv4 NLRI specific information\n" | |
8187 | "Display information about all VPNv4 NLRIs\n" | |
b05a1c8b DS |
8188 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8189 | "JavaScript Object Notation\n") | |
718e3744 | 8190 | { |
db7c8528 | 8191 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8192 | } |
8193 | ||
8194 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, | |
8195 | show_ip_bgp_vpnv4_rd_prefix_cmd, | |
b05a1c8b | 8196 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}", |
718e3744 | 8197 | SHOW_STR |
8198 | IP_STR | |
8199 | BGP_STR | |
8200 | "Display VPNv4 NLRI specific information\n" | |
8201 | "Display information for a route distinguisher\n" | |
8202 | "VPN Route Distinguisher\n" | |
b05a1c8b DS |
8203 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8204 | "JavaScript Object Notation\n") | |
718e3744 | 8205 | { |
8206 | int ret; | |
8207 | struct prefix_rd prd; | |
8208 | ||
8209 | ret = str2prefix_rd (argv[0], &prd); | |
8210 | if (! ret) | |
8211 | { | |
8212 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
8213 | return CMD_WARNING; | |
8214 | } | |
db7c8528 | 8215 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8216 | } |
8217 | ||
8218 | DEFUN (show_ip_bgp_view, | |
8386ac43 | 8219 | show_ip_bgp_instance_cmd, |
8220 | "show ip bgp " BGP_INSTANCE_CMD " {json}", | |
718e3744 | 8221 | SHOW_STR |
8222 | IP_STR | |
8223 | BGP_STR | |
8386ac43 | 8224 | BGP_INSTANCE_HELP_STR |
b05a1c8b | 8225 | "JavaScript Object Notation\n") |
718e3744 | 8226 | { |
bb46e94f | 8227 | struct bgp *bgp; |
8228 | ||
8229 | /* BGP structure lookup. */ | |
6aeb9e78 | 8230 | bgp = bgp_lookup_by_name (argv[1]); |
bb46e94f | 8231 | if (bgp == NULL) |
8232 | { | |
6aeb9e78 | 8233 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
bb46e94f | 8234 | return CMD_WARNING; |
8235 | } | |
8236 | ||
db7c8528 | 8237 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); |
718e3744 | 8238 | } |
8239 | ||
f186de26 | 8240 | DEFUN (show_ip_bgp_instance_all, |
8241 | show_ip_bgp_instance_all_cmd, | |
8242 | "show ip bgp " BGP_INSTANCE_ALL_CMD " {json}", | |
8243 | SHOW_STR | |
8244 | IP_STR | |
8245 | BGP_STR | |
8246 | BGP_INSTANCE_ALL_HELP_STR | |
8247 | "JavaScript Object Notation\n") | |
8248 | { | |
8249 | u_char uj = use_json(argc, argv); | |
8250 | ||
8251 | bgp_show_all_instances_routes_vty (vty, AFI_IP, SAFI_UNICAST, uj); | |
8252 | return CMD_SUCCESS; | |
8253 | } | |
8254 | ||
8386ac43 | 8255 | DEFUN (show_ip_bgp_instance_route, |
8256 | show_ip_bgp_instance_route_cmd, | |
8257 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D {json}", | |
718e3744 | 8258 | SHOW_STR |
8259 | IP_STR | |
8260 | BGP_STR | |
8386ac43 | 8261 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8262 | "Network in the BGP routing table to display\n" |
8263 | "JavaScript Object Notation\n") | |
718e3744 | 8264 | { |
6aeb9e78 | 8265 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8266 | } |
8267 | ||
8386ac43 | 8268 | DEFUN (show_ip_bgp_instance_route_pathtype, |
8269 | show_ip_bgp_instance_route_pathtype_cmd, | |
8270 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D (bestpath|multipath) {json}", | |
50ef26d4 | 8271 | SHOW_STR |
8272 | IP_STR | |
8273 | BGP_STR | |
8386ac43 | 8274 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8275 | "Network in the BGP routing table to display\n" |
8276 | "Display only the bestpath\n" | |
8277 | "Display only multipaths\n" | |
8278 | "JavaScript Object Notation\n") | |
8279 | { | |
8280 | u_char uj = use_json(argc, argv); | |
8281 | ||
8282 | if (strncmp (argv[3], "b", 1) == 0) | |
8283 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); | |
8284 | else | |
8285 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); | |
8286 | } | |
8287 | ||
8386ac43 | 8288 | DEFUN (show_ip_bgp_instance_prefix, |
8289 | show_ip_bgp_instance_prefix_cmd, | |
8290 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M {json}", | |
718e3744 | 8291 | SHOW_STR |
8292 | IP_STR | |
8293 | BGP_STR | |
8386ac43 | 8294 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8295 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8296 | "JavaScript Object Notation\n") | |
718e3744 | 8297 | { |
6aeb9e78 | 8298 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8299 | } |
8300 | ||
8386ac43 | 8301 | DEFUN (show_ip_bgp_instance_prefix_pathtype, |
8302 | show_ip_bgp_instance_prefix_pathtype_cmd, | |
8303 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M (bestpath|multipath) {json}", | |
50ef26d4 | 8304 | SHOW_STR |
8305 | IP_STR | |
8306 | BGP_STR | |
8386ac43 | 8307 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8308 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8309 | "Display only the bestpath\n" | |
8310 | "Display only multipaths\n" | |
8311 | "JavaScript Object Notation\n") | |
8312 | { | |
8313 | u_char uj = use_json(argc, argv); | |
8314 | if (strncmp (argv[3], "b", 1) == 0) | |
8315 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); | |
8316 | else | |
8317 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); | |
8318 | } | |
8319 | ||
718e3744 | 8320 | #ifdef HAVE_IPV6 |
8321 | DEFUN (show_bgp, | |
8322 | show_bgp_cmd, | |
b05a1c8b | 8323 | "show bgp {json}", |
718e3744 | 8324 | SHOW_STR |
b05a1c8b DS |
8325 | BGP_STR |
8326 | "JavaScript Object Notation\n") | |
718e3744 | 8327 | { |
5a646650 | 8328 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
db7c8528 | 8329 | NULL, use_json(argc, argv)); |
718e3744 | 8330 | } |
8331 | ||
8332 | ALIAS (show_bgp, | |
8333 | show_bgp_ipv6_cmd, | |
b05a1c8b | 8334 | "show bgp ipv6 {json}", |
718e3744 | 8335 | SHOW_STR |
8336 | BGP_STR | |
b05a1c8b DS |
8337 | "Address family\n" |
8338 | "JavaScript Object Notation\n") | |
718e3744 | 8339 | |
95cbbd2a ML |
8340 | DEFUN (show_bgp_ipv6_safi, |
8341 | show_bgp_ipv6_safi_cmd, | |
b05a1c8b | 8342 | "show bgp ipv6 (unicast|multicast) {json}", |
95cbbd2a ML |
8343 | SHOW_STR |
8344 | BGP_STR | |
8345 | "Address family\n" | |
8346 | "Address Family modifier\n" | |
47fc97cc | 8347 | "Address Family modifier\n" |
b05a1c8b | 8348 | "JavaScript Object Notation\n") |
47fc97cc | 8349 | { |
db7c8528 | 8350 | u_char uj = use_json(argc, argv); |
47fc97cc DS |
8351 | if (strncmp (argv[0], "m", 1) == 0) |
8352 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, | |
db7c8528 | 8353 | NULL, uj); |
47fc97cc | 8354 | |
db7c8528 | 8355 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); |
95cbbd2a ML |
8356 | } |
8357 | ||
47e9b292 DW |
8358 | static void |
8359 | bgp_show_ipv6_bgp_deprecate_warning (struct vty *vty) | |
8360 | { | |
8361 | vty_out (vty, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our" | |
8362 | " next release%sPlese use 'show bgp ipv6' instead%s%s", | |
8363 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
8364 | } | |
8365 | ||
718e3744 | 8366 | /* old command */ |
8367 | DEFUN (show_ipv6_bgp, | |
8368 | show_ipv6_bgp_cmd, | |
b05a1c8b | 8369 | "show ipv6 bgp {json}", |
718e3744 | 8370 | SHOW_STR |
8371 | IP_STR | |
b05a1c8b DS |
8372 | BGP_STR |
8373 | "JavaScript Object Notation\n") | |
718e3744 | 8374 | { |
47e9b292 | 8375 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
5a646650 | 8376 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
db7c8528 | 8377 | NULL, use_json(argc, argv)); |
718e3744 | 8378 | } |
8379 | ||
8380 | DEFUN (show_bgp_route, | |
8381 | show_bgp_route_cmd, | |
b05a1c8b | 8382 | "show bgp X:X::X:X {json}", |
718e3744 | 8383 | SHOW_STR |
8384 | BGP_STR | |
b05a1c8b DS |
8385 | "Network in the BGP routing table to display\n" |
8386 | "JavaScript Object Notation\n") | |
718e3744 | 8387 | { |
db7c8528 | 8388 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8389 | } |
8390 | ||
8391 | ALIAS (show_bgp_route, | |
8392 | show_bgp_ipv6_route_cmd, | |
b05a1c8b | 8393 | "show bgp ipv6 X:X::X:X {json}", |
718e3744 | 8394 | SHOW_STR |
8395 | BGP_STR | |
8396 | "Address family\n" | |
b05a1c8b DS |
8397 | "Network in the BGP routing table to display\n" |
8398 | "JavaScript Object Notation\n") | |
718e3744 | 8399 | |
95cbbd2a ML |
8400 | DEFUN (show_bgp_ipv6_safi_route, |
8401 | show_bgp_ipv6_safi_route_cmd, | |
b05a1c8b | 8402 | "show bgp ipv6 (unicast|multicast) X:X::X:X {json}", |
95cbbd2a ML |
8403 | SHOW_STR |
8404 | BGP_STR | |
8405 | "Address family\n" | |
8406 | "Address Family modifier\n" | |
8407 | "Address Family modifier\n" | |
b05a1c8b DS |
8408 | "Network in the BGP routing table to display\n" |
8409 | "JavaScript Object Notation\n") | |
95cbbd2a | 8410 | { |
db7c8528 | 8411 | u_char uj = use_json(argc, argv); |
95cbbd2a | 8412 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8413 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); |
95cbbd2a | 8414 | |
db7c8528 | 8415 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); |
4092b06c DS |
8416 | } |
8417 | ||
8418 | DEFUN (show_bgp_route_pathtype, | |
8419 | show_bgp_route_pathtype_cmd, | |
b05a1c8b | 8420 | "show bgp X:X::X:X (bestpath|multipath) {json}", |
4092b06c DS |
8421 | SHOW_STR |
8422 | BGP_STR | |
8423 | "Network in the BGP routing table to display\n" | |
8424 | "Display only the bestpath\n" | |
b05a1c8b DS |
8425 | "Display only multipaths\n" |
8426 | "JavaScript Object Notation\n") | |
4092b06c | 8427 | { |
db7c8528 | 8428 | u_char uj = use_json(argc, argv); |
4092b06c | 8429 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 8430 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8431 | else |
db7c8528 | 8432 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8433 | } |
8434 | ||
8435 | ALIAS (show_bgp_route_pathtype, | |
8436 | show_bgp_ipv6_route_pathtype_cmd, | |
b05a1c8b | 8437 | "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}", |
4092b06c DS |
8438 | SHOW_STR |
8439 | BGP_STR | |
8440 | "Address family\n" | |
8441 | "Network in the BGP routing table to display\n" | |
8442 | "Display only the bestpath\n" | |
b05a1c8b DS |
8443 | "Display only multipaths\n" |
8444 | "JavaScript Object Notation\n") | |
4092b06c DS |
8445 | |
8446 | DEFUN (show_bgp_ipv6_safi_route_pathtype, | |
8447 | show_bgp_ipv6_safi_route_pathtype_cmd, | |
b05a1c8b | 8448 | "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}", |
4092b06c DS |
8449 | SHOW_STR |
8450 | BGP_STR | |
8451 | "Address family\n" | |
8452 | "Address Family modifier\n" | |
8453 | "Address Family modifier\n" | |
8454 | "Network in the BGP routing table to display\n" | |
8455 | "Display only the bestpath\n" | |
b05a1c8b DS |
8456 | "Display only multipaths\n" |
8457 | "JavaScript Object Notation\n") | |
4092b06c | 8458 | { |
db7c8528 | 8459 | u_char uj = use_json(argc, argv); |
4092b06c DS |
8460 | if (strncmp (argv[0], "m", 1) == 0) |
8461 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8462 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8463 | else |
db7c8528 | 8464 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8465 | else |
8466 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8467 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8468 | else |
db7c8528 | 8469 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
95cbbd2a ML |
8470 | } |
8471 | ||
718e3744 | 8472 | /* old command */ |
8473 | DEFUN (show_ipv6_bgp_route, | |
8474 | show_ipv6_bgp_route_cmd, | |
b05a1c8b | 8475 | "show ipv6 bgp X:X::X:X {json}", |
718e3744 | 8476 | SHOW_STR |
8477 | IP_STR | |
8478 | BGP_STR | |
b05a1c8b DS |
8479 | "Network in the BGP routing table to display\n" |
8480 | "JavaScript Object Notation\n") | |
718e3744 | 8481 | { |
47e9b292 | 8482 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8483 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8484 | } |
8485 | ||
8486 | DEFUN (show_bgp_prefix, | |
8487 | show_bgp_prefix_cmd, | |
b05a1c8b | 8488 | "show bgp X:X::X:X/M {json}", |
718e3744 | 8489 | SHOW_STR |
8490 | BGP_STR | |
b05a1c8b DS |
8491 | "IPv6 prefix <network>/<length>\n" |
8492 | "JavaScript Object Notation\n") | |
718e3744 | 8493 | { |
db7c8528 | 8494 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8495 | } |
8496 | ||
8497 | ALIAS (show_bgp_prefix, | |
8498 | show_bgp_ipv6_prefix_cmd, | |
b05a1c8b | 8499 | "show bgp ipv6 X:X::X:X/M {json}", |
718e3744 | 8500 | SHOW_STR |
8501 | BGP_STR | |
8502 | "Address family\n" | |
b05a1c8b DS |
8503 | "IPv6 prefix <network>/<length>\n" |
8504 | "JavaScript Object Notation\n") | |
718e3744 | 8505 | |
95cbbd2a ML |
8506 | DEFUN (show_bgp_ipv6_safi_prefix, |
8507 | show_bgp_ipv6_safi_prefix_cmd, | |
b05a1c8b | 8508 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}", |
95cbbd2a ML |
8509 | SHOW_STR |
8510 | BGP_STR | |
8511 | "Address family\n" | |
8512 | "Address Family modifier\n" | |
8513 | "Address Family modifier\n" | |
b05a1c8b DS |
8514 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
8515 | "JavaScript Object Notation\n") | |
95cbbd2a | 8516 | { |
db7c8528 | 8517 | u_char uj = use_json(argc, argv); |
95cbbd2a | 8518 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8519 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); |
95cbbd2a | 8520 | |
db7c8528 | 8521 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); |
4092b06c DS |
8522 | } |
8523 | ||
8524 | DEFUN (show_bgp_prefix_pathtype, | |
8525 | show_bgp_prefix_pathtype_cmd, | |
b05a1c8b | 8526 | "show bgp X:X::X:X/M (bestpath|multipath) {json}", |
4092b06c DS |
8527 | SHOW_STR |
8528 | BGP_STR | |
8529 | "IPv6 prefix <network>/<length>\n" | |
8530 | "Display only the bestpath\n" | |
b05a1c8b DS |
8531 | "Display only multipaths\n" |
8532 | "JavaScript Object Notation\n") | |
4092b06c | 8533 | { |
db7c8528 | 8534 | u_char uj = use_json(argc, argv); |
4092b06c | 8535 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 8536 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8537 | else |
db7c8528 | 8538 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8539 | } |
8540 | ||
8541 | ALIAS (show_bgp_prefix_pathtype, | |
8542 | show_bgp_ipv6_prefix_pathtype_cmd, | |
b05a1c8b | 8543 | "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}", |
4092b06c DS |
8544 | SHOW_STR |
8545 | BGP_STR | |
8546 | "Address family\n" | |
8547 | "IPv6 prefix <network>/<length>\n" | |
8548 | "Display only the bestpath\n" | |
b05a1c8b DS |
8549 | "Display only multipaths\n" |
8550 | "JavaScript Object Notation\n") | |
4092b06c DS |
8551 | |
8552 | DEFUN (show_bgp_ipv6_safi_prefix_pathtype, | |
8553 | show_bgp_ipv6_safi_prefix_pathtype_cmd, | |
b05a1c8b | 8554 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}", |
4092b06c DS |
8555 | SHOW_STR |
8556 | BGP_STR | |
8557 | "Address family\n" | |
8558 | "Address Family modifier\n" | |
8559 | "Address Family modifier\n" | |
8560 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
8561 | "Display only the bestpath\n" | |
b05a1c8b DS |
8562 | "Display only multipaths\n" |
8563 | "JavaScript Object Notation\n") | |
4092b06c | 8564 | { |
db7c8528 | 8565 | u_char uj = use_json(argc, argv); |
4092b06c DS |
8566 | if (strncmp (argv[0], "m", 1) == 0) |
8567 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8568 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8569 | else |
db7c8528 | 8570 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8571 | else |
8572 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8573 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8574 | else |
db7c8528 | 8575 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
95cbbd2a ML |
8576 | } |
8577 | ||
718e3744 | 8578 | /* old command */ |
8579 | DEFUN (show_ipv6_bgp_prefix, | |
8580 | show_ipv6_bgp_prefix_cmd, | |
b05a1c8b | 8581 | "show ipv6 bgp X:X::X:X/M {json}", |
718e3744 | 8582 | SHOW_STR |
8583 | IP_STR | |
8584 | BGP_STR | |
b05a1c8b DS |
8585 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
8586 | "JavaScript Object Notation\n") | |
718e3744 | 8587 | { |
47e9b292 | 8588 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8589 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8590 | } |
8591 | ||
bb46e94f | 8592 | DEFUN (show_bgp_view, |
8386ac43 | 8593 | show_bgp_instance_cmd, |
8594 | "show bgp " BGP_INSTANCE_CMD " {json}", | |
bb46e94f | 8595 | SHOW_STR |
8596 | BGP_STR | |
8386ac43 | 8597 | BGP_INSTANCE_HELP_STR |
b05a1c8b | 8598 | "JavaScript Object Notation\n") |
bb46e94f | 8599 | { |
8600 | struct bgp *bgp; | |
8601 | ||
8602 | /* BGP structure lookup. */ | |
6aeb9e78 | 8603 | bgp = bgp_lookup_by_name (argv[1]); |
bb46e94f | 8604 | if (bgp == NULL) |
db7c8528 | 8605 | { |
6aeb9e78 | 8606 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
db7c8528 DS |
8607 | return CMD_WARNING; |
8608 | } | |
8609 | ||
8610 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); | |
bb46e94f | 8611 | } |
8612 | ||
f186de26 | 8613 | DEFUN (show_bgp_instance_all, |
8614 | show_bgp_instance_all_cmd, | |
8615 | "show bgp " BGP_INSTANCE_ALL_CMD " {json}", | |
8616 | SHOW_STR | |
8617 | BGP_STR | |
8618 | BGP_INSTANCE_ALL_HELP_STR | |
8619 | "JavaScript Object Notation\n") | |
8620 | { | |
8621 | u_char uj = use_json(argc, argv); | |
8622 | ||
8623 | bgp_show_all_instances_routes_vty (vty, AFI_IP6, SAFI_UNICAST, uj); | |
8624 | return CMD_SUCCESS; | |
8625 | } | |
8626 | ||
bb46e94f | 8627 | ALIAS (show_bgp_view, |
8386ac43 | 8628 | show_bgp_instance_ipv6_cmd, |
8629 | "show bgp " BGP_INSTANCE_CMD " ipv6 {json}", | |
bb46e94f | 8630 | SHOW_STR |
8631 | BGP_STR | |
8386ac43 | 8632 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8633 | "Address family\n" |
8634 | "JavaScript Object Notation\n") | |
bb46e94f | 8635 | |
8386ac43 | 8636 | DEFUN (show_bgp_instance_route, |
8637 | show_bgp_instance_route_cmd, | |
8638 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X {json}", | |
bb46e94f | 8639 | SHOW_STR |
8640 | BGP_STR | |
8386ac43 | 8641 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8642 | "Network in the BGP routing table to display\n" |
8643 | "JavaScript Object Notation\n") | |
bb46e94f | 8644 | { |
6aeb9e78 | 8645 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
bb46e94f | 8646 | } |
8647 | ||
8386ac43 | 8648 | ALIAS (show_bgp_instance_route, |
8649 | show_bgp_instance_ipv6_route_cmd, | |
8650 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X {json}", | |
bb46e94f | 8651 | SHOW_STR |
8652 | BGP_STR | |
8386ac43 | 8653 | BGP_INSTANCE_HELP_STR |
bb46e94f | 8654 | "Address family\n" |
b05a1c8b DS |
8655 | "Network in the BGP routing table to display\n" |
8656 | "JavaScript Object Notation\n") | |
bb46e94f | 8657 | |
8386ac43 | 8658 | DEFUN (show_bgp_instance_route_pathtype, |
8659 | show_bgp_instance_route_pathtype_cmd, | |
8660 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X (bestpath|multipath) {json}", | |
50ef26d4 | 8661 | SHOW_STR |
8662 | BGP_STR | |
8386ac43 | 8663 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8664 | "Network in the BGP routing table to display\n" |
8665 | "Display only the bestpath\n" | |
8666 | "Display only multipaths\n" | |
8667 | "JavaScript Object Notation\n") | |
8668 | { | |
8669 | u_char uj = use_json(argc, argv); | |
8670 | if (strncmp (argv[3], "b", 1) == 0) | |
8671 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); | |
8672 | else | |
8673 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); | |
8674 | } | |
8675 | ||
8386ac43 | 8676 | ALIAS (show_bgp_instance_route_pathtype, |
8677 | show_bgp_instance_ipv6_route_pathtype_cmd, | |
8678 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X (bestpath|multipath) {json}", | |
50ef26d4 | 8679 | SHOW_STR |
8680 | BGP_STR | |
8386ac43 | 8681 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8682 | "Address family\n" |
8683 | "Network in the BGP routing table to display\n" | |
8684 | "Display only the bestpath\n" | |
8685 | "Display only multipaths\n" | |
8686 | "JavaScript Object Notation\n") | |
8687 | ||
8386ac43 | 8688 | DEFUN (show_bgp_instance_prefix, |
8689 | show_bgp_instance_prefix_cmd, | |
8690 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M {json}", | |
bb46e94f | 8691 | SHOW_STR |
8692 | BGP_STR | |
8386ac43 | 8693 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8694 | "IPv6 prefix <network>/<length>\n" |
8695 | "JavaScript Object Notation\n") | |
bb46e94f | 8696 | { |
6aeb9e78 | 8697 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
bb46e94f | 8698 | } |
8699 | ||
8386ac43 | 8700 | ALIAS (show_bgp_instance_prefix, |
8701 | show_bgp_instance_ipv6_prefix_cmd, | |
8702 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M {json}", | |
bb46e94f | 8703 | SHOW_STR |
8704 | BGP_STR | |
8386ac43 | 8705 | BGP_INSTANCE_HELP_STR |
bb46e94f | 8706 | "Address family\n" |
b05a1c8b DS |
8707 | "IPv6 prefix <network>/<length>\n" |
8708 | "JavaScript Object Notation\n") | |
bb46e94f | 8709 | |
8386ac43 | 8710 | DEFUN (show_bgp_instance_prefix_pathtype, |
8711 | show_bgp_instance_prefix_pathtype_cmd, | |
8712 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M (bestpath|multipath) {json}", | |
50ef26d4 | 8713 | SHOW_STR |
8714 | BGP_STR | |
8386ac43 | 8715 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8716 | "IPv6 prefix <network>/<length>\n" |
8717 | "Display only the bestpath\n" | |
8718 | "Display only multipaths\n" | |
8719 | "JavaScript Object Notation\n") | |
8720 | { | |
8721 | u_char uj = use_json(argc, argv); | |
8722 | if (strncmp (argv[3], "b", 1) == 0) | |
8723 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); | |
8724 | else | |
8725 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); | |
8726 | } | |
8727 | ||
8386ac43 | 8728 | ALIAS (show_bgp_instance_prefix_pathtype, |
8729 | show_bgp_instance_ipv6_prefix_pathtype_cmd, | |
8730 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M (bestpath|multipath) {json}", | |
50ef26d4 | 8731 | SHOW_STR |
8732 | BGP_STR | |
8386ac43 | 8733 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8734 | "Address family\n" |
8735 | "IPv6 prefix <network>/<length>\n" | |
8736 | "Display only the bestpath\n" | |
8737 | "Display only multipaths\n" | |
8738 | "JavaScript Object Notation\n") | |
8739 | ||
8386ac43 | 8740 | DEFUN (show_bgp_instance_prefix_list, |
8741 | show_bgp_instance_prefix_list_cmd, | |
8742 | "show bgp " BGP_INSTANCE_CMD " prefix-list WORD", | |
50ef26d4 | 8743 | SHOW_STR |
8744 | BGP_STR | |
8386ac43 | 8745 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8746 | "Display routes conforming to the prefix-list\n" |
8747 | "IPv6 prefix-list name\n") | |
8748 | { | |
8749 | return bgp_show_prefix_list (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8750 | bgp_show_type_prefix_list); | |
8751 | } | |
8752 | ||
8386ac43 | 8753 | ALIAS (show_bgp_instance_prefix_list, |
8754 | show_bgp_instance_ipv6_prefix_list_cmd, | |
8755 | "show bgp " BGP_INSTANCE_CMD " ipv6 prefix-list WORD", | |
50ef26d4 | 8756 | SHOW_STR |
8757 | BGP_STR | |
8386ac43 | 8758 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8759 | "Address family\n" |
8760 | "Display routes conforming to the prefix-list\n" | |
8761 | "IPv6 prefix-list name\n") | |
8762 | ||
8386ac43 | 8763 | DEFUN (show_bgp_instance_filter_list, |
8764 | show_bgp_instance_filter_list_cmd, | |
8765 | "show bgp " BGP_INSTANCE_CMD " filter-list WORD", | |
50ef26d4 | 8766 | SHOW_STR |
8767 | BGP_STR | |
8386ac43 | 8768 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8769 | "Display routes conforming to the filter-list\n" |
8770 | "Regular expression access list name\n") | |
8771 | { | |
8772 | return bgp_show_filter_list (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8773 | bgp_show_type_filter_list); | |
8774 | } | |
8775 | ||
8386ac43 | 8776 | ALIAS (show_bgp_instance_filter_list, |
8777 | show_bgp_instance_ipv6_filter_list_cmd, | |
8778 | "show bgp " BGP_INSTANCE_CMD " ipv6 filter-list WORD", | |
50ef26d4 | 8779 | SHOW_STR |
8780 | BGP_STR | |
8386ac43 | 8781 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8782 | "Address family\n" |
8783 | "Display routes conforming to the filter-list\n" | |
8784 | "Regular expression access list name\n") | |
8785 | ||
8386ac43 | 8786 | DEFUN (show_bgp_instance_route_map, |
8787 | show_bgp_instance_route_map_cmd, | |
8788 | "show bgp " BGP_INSTANCE_CMD " route-map WORD", | |
50ef26d4 | 8789 | SHOW_STR |
8790 | BGP_STR | |
8386ac43 | 8791 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8792 | "Display routes matching the route-map\n" |
8793 | "A route-map to match on\n") | |
8794 | { | |
8795 | return bgp_show_route_map (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8796 | bgp_show_type_route_map); | |
8797 | } | |
8798 | ||
8386ac43 | 8799 | ALIAS (show_bgp_instance_route_map, |
8800 | show_bgp_instance_ipv6_route_map_cmd, | |
8801 | "show bgp " BGP_INSTANCE_CMD " ipv6 route-map WORD", | |
50ef26d4 | 8802 | SHOW_STR |
8803 | BGP_STR | |
8386ac43 | 8804 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8805 | "Address family\n" |
8806 | "Display routes matching the route-map\n" | |
8807 | "A route-map to match on\n") | |
8808 | ||
8386ac43 | 8809 | DEFUN (show_bgp_instance_community_list, |
8810 | show_bgp_instance_community_list_cmd, | |
8811 | "show bgp " BGP_INSTANCE_CMD " community-list (<1-500>|WORD)", | |
50ef26d4 | 8812 | SHOW_STR |
8813 | BGP_STR | |
8386ac43 | 8814 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8815 | "Display routes matching the community-list\n" |
8816 | "community-list number\n" | |
8817 | "community-list name\n") | |
8818 | { | |
8819 | return bgp_show_community_list (vty, argv[1], argv[2], 0, AFI_IP6, SAFI_UNICAST); | |
8820 | } | |
8821 | ||
8386ac43 | 8822 | ALIAS (show_bgp_instance_community_list, |
8823 | show_bgp_instance_ipv6_community_list_cmd, | |
8824 | "show bgp " BGP_INSTANCE_CMD " ipv6 community-list (<1-500>|WORD)", | |
50ef26d4 | 8825 | SHOW_STR |
8826 | BGP_STR | |
8386ac43 | 8827 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8828 | "Address family\n" |
8829 | "Display routes matching the community-list\n" | |
8830 | "community-list number\n" | |
8831 | "community-list name\n") | |
8832 | ||
8386ac43 | 8833 | DEFUN (show_bgp_instance_prefix_longer, |
8834 | show_bgp_instance_prefix_longer_cmd, | |
8835 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M longer-prefixes", | |
50ef26d4 | 8836 | SHOW_STR |
8837 | BGP_STR | |
8386ac43 | 8838 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8839 | "IPv6 prefix <network>/<length>\n" |
8840 | "Display route and more specific routes\n") | |
8841 | { | |
8842 | return bgp_show_prefix_longer (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8843 | bgp_show_type_prefix_longer); | |
8844 | } | |
8845 | ||
8386ac43 | 8846 | ALIAS (show_bgp_instance_prefix_longer, |
8847 | show_bgp_instance_ipv6_prefix_longer_cmd, | |
8848 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M longer-prefixes", | |
50ef26d4 | 8849 | SHOW_STR |
8850 | BGP_STR | |
8386ac43 | 8851 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8852 | "Address family\n" |
8853 | "IPv6 prefix <network>/<length>\n" | |
8854 | "Display route and more specific routes\n") | |
8855 | ||
718e3744 | 8856 | /* old command */ |
8857 | DEFUN (show_ipv6_mbgp, | |
8858 | show_ipv6_mbgp_cmd, | |
b05a1c8b | 8859 | "show ipv6 mbgp {json}", |
718e3744 | 8860 | SHOW_STR |
8861 | IP_STR | |
b05a1c8b DS |
8862 | MBGP_STR |
8863 | "JavaScript Object Notation\n") | |
718e3744 | 8864 | { |
47e9b292 | 8865 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
5a646650 | 8866 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
db7c8528 | 8867 | NULL, use_json(argc, argv)); |
718e3744 | 8868 | } |
8869 | ||
8870 | /* old command */ | |
8871 | DEFUN (show_ipv6_mbgp_route, | |
8872 | show_ipv6_mbgp_route_cmd, | |
b05a1c8b | 8873 | "show ipv6 mbgp X:X::X:X {json}", |
718e3744 | 8874 | SHOW_STR |
8875 | IP_STR | |
8876 | MBGP_STR | |
b05a1c8b DS |
8877 | "Network in the MBGP routing table to display\n" |
8878 | "JavaScript Object Notation\n") | |
718e3744 | 8879 | { |
47e9b292 | 8880 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8881 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8882 | } |
8883 | ||
8884 | /* old command */ | |
8885 | DEFUN (show_ipv6_mbgp_prefix, | |
8886 | show_ipv6_mbgp_prefix_cmd, | |
b05a1c8b | 8887 | "show ipv6 mbgp X:X::X:X/M {json}", |
718e3744 | 8888 | SHOW_STR |
8889 | IP_STR | |
8890 | MBGP_STR | |
b05a1c8b DS |
8891 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
8892 | "JavaScript Object Notation\n") | |
718e3744 | 8893 | { |
47e9b292 | 8894 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8895 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8896 | } |
8897 | #endif | |
6b0655a2 | 8898 | |
718e3744 | 8899 | |
94f2b392 | 8900 | static int |
fd79ac91 | 8901 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
718e3744 | 8902 | safi_t safi, enum bgp_show_type type) |
8903 | { | |
8904 | int i; | |
8905 | struct buffer *b; | |
8906 | char *regstr; | |
8907 | int first; | |
8908 | regex_t *regex; | |
5a646650 | 8909 | int rc; |
718e3744 | 8910 | |
8911 | first = 0; | |
8912 | b = buffer_new (1024); | |
8913 | for (i = 0; i < argc; i++) | |
8914 | { | |
8915 | if (first) | |
8916 | buffer_putc (b, ' '); | |
8917 | else | |
8918 | { | |
8919 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
8920 | continue; | |
8921 | first = 1; | |
8922 | } | |
8923 | ||
8924 | buffer_putstr (b, argv[i]); | |
8925 | } | |
8926 | buffer_putc (b, '\0'); | |
8927 | ||
8928 | regstr = buffer_getstr (b); | |
8929 | buffer_free (b); | |
8930 | ||
8931 | regex = bgp_regcomp (regstr); | |
3b8b1855 | 8932 | XFREE(MTYPE_TMP, regstr); |
718e3744 | 8933 | if (! regex) |
8934 | { | |
8935 | vty_out (vty, "Can't compile regexp %s%s", argv[0], | |
8936 | VTY_NEWLINE); | |
8937 | return CMD_WARNING; | |
8938 | } | |
8939 | ||
b05a1c8b | 8940 | rc = bgp_show (vty, NULL, afi, safi, type, regex, 0); |
5a646650 | 8941 | bgp_regex_free (regex); |
8942 | return rc; | |
718e3744 | 8943 | } |
8944 | ||
8945 | DEFUN (show_ip_bgp_regexp, | |
8946 | show_ip_bgp_regexp_cmd, | |
8947 | "show ip bgp regexp .LINE", | |
8948 | SHOW_STR | |
8949 | IP_STR | |
8950 | BGP_STR | |
8951 | "Display routes matching the AS path regular expression\n" | |
8952 | "A regular-expression to match the BGP AS paths\n") | |
8953 | { | |
8954 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
8955 | bgp_show_type_regexp); | |
8956 | } | |
8957 | ||
8958 | DEFUN (show_ip_bgp_flap_regexp, | |
8959 | show_ip_bgp_flap_regexp_cmd, | |
8960 | "show ip bgp flap-statistics regexp .LINE", | |
8961 | SHOW_STR | |
8962 | IP_STR | |
8963 | BGP_STR | |
8964 | "Display flap statistics of routes\n" | |
8965 | "Display routes matching the AS path regular expression\n" | |
8966 | "A regular-expression to match the BGP AS paths\n") | |
8967 | { | |
8968 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
8969 | bgp_show_type_flap_regexp); | |
8970 | } | |
8971 | ||
81304aaf B |
8972 | ALIAS (show_ip_bgp_flap_regexp, |
8973 | show_ip_bgp_damp_flap_regexp_cmd, | |
8974 | "show ip bgp dampening flap-statistics regexp .LINE", | |
8975 | SHOW_STR | |
8976 | IP_STR | |
8977 | BGP_STR | |
8978 | "Display detailed information about dampening\n" | |
8979 | "Display flap statistics of routes\n" | |
8980 | "Display routes matching the AS path regular expression\n" | |
8981 | "A regular-expression to match the BGP AS paths\n") | |
8982 | ||
718e3744 | 8983 | DEFUN (show_ip_bgp_ipv4_regexp, |
8984 | show_ip_bgp_ipv4_regexp_cmd, | |
8985 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", | |
8986 | SHOW_STR | |
8987 | IP_STR | |
8988 | BGP_STR | |
8989 | "Address family\n" | |
8990 | "Address Family modifier\n" | |
8991 | "Address Family modifier\n" | |
8992 | "Display routes matching the AS path regular expression\n" | |
8993 | "A regular-expression to match the BGP AS paths\n") | |
8994 | { | |
8995 | if (strncmp (argv[0], "m", 1) == 0) | |
8996 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, | |
8997 | bgp_show_type_regexp); | |
8998 | ||
8999 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
9000 | bgp_show_type_regexp); | |
9001 | } | |
9002 | ||
9003 | #ifdef HAVE_IPV6 | |
9004 | DEFUN (show_bgp_regexp, | |
9005 | show_bgp_regexp_cmd, | |
9006 | "show bgp regexp .LINE", | |
9007 | SHOW_STR | |
9008 | BGP_STR | |
9009 | "Display routes matching the AS path regular expression\n" | |
9010 | "A regular-expression to match the BGP AS paths\n") | |
9011 | { | |
9012 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
9013 | bgp_show_type_regexp); | |
9014 | } | |
9015 | ||
9016 | ALIAS (show_bgp_regexp, | |
9017 | show_bgp_ipv6_regexp_cmd, | |
9018 | "show bgp ipv6 regexp .LINE", | |
9019 | SHOW_STR | |
9020 | BGP_STR | |
9021 | "Address family\n" | |
9022 | "Display routes matching the AS path regular expression\n" | |
9023 | "A regular-expression to match the BGP AS paths\n") | |
9024 | ||
9025 | /* old command */ | |
9026 | DEFUN (show_ipv6_bgp_regexp, | |
9027 | show_ipv6_bgp_regexp_cmd, | |
9028 | "show ipv6 bgp regexp .LINE", | |
9029 | SHOW_STR | |
9030 | IP_STR | |
9031 | BGP_STR | |
9032 | "Display routes matching the AS path regular expression\n" | |
9033 | "A regular-expression to match the BGP AS paths\n") | |
9034 | { | |
47e9b292 | 9035 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9036 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
9037 | bgp_show_type_regexp); | |
9038 | } | |
9039 | ||
9040 | /* old command */ | |
9041 | DEFUN (show_ipv6_mbgp_regexp, | |
9042 | show_ipv6_mbgp_regexp_cmd, | |
9043 | "show ipv6 mbgp regexp .LINE", | |
9044 | SHOW_STR | |
9045 | IP_STR | |
9046 | BGP_STR | |
9047 | "Display routes matching the AS path regular expression\n" | |
9048 | "A regular-expression to match the MBGP AS paths\n") | |
9049 | { | |
47e9b292 | 9050 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9051 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
9052 | bgp_show_type_regexp); | |
9053 | } | |
9054 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 9055 | |
94f2b392 | 9056 | static int |
50ef26d4 | 9057 | bgp_show_prefix_list (struct vty *vty, const char *name, |
9058 | const char *prefix_list_str, afi_t afi, | |
718e3744 | 9059 | safi_t safi, enum bgp_show_type type) |
9060 | { | |
9061 | struct prefix_list *plist; | |
50ef26d4 | 9062 | struct bgp *bgp = NULL; |
9063 | ||
9064 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
9065 | { | |
9066 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
9067 | return CMD_WARNING; | |
9068 | } | |
718e3744 | 9069 | |
9070 | plist = prefix_list_lookup (afi, prefix_list_str); | |
9071 | if (plist == NULL) | |
9072 | { | |
9073 | vty_out (vty, "%% %s is not a valid prefix-list name%s", | |
9074 | prefix_list_str, VTY_NEWLINE); | |
9075 | return CMD_WARNING; | |
9076 | } | |
9077 | ||
50ef26d4 | 9078 | return bgp_show (vty, bgp, afi, safi, type, plist, 0); |
718e3744 | 9079 | } |
9080 | ||
9081 | DEFUN (show_ip_bgp_prefix_list, | |
9082 | show_ip_bgp_prefix_list_cmd, | |
9083 | "show ip bgp prefix-list WORD", | |
9084 | SHOW_STR | |
9085 | IP_STR | |
9086 | BGP_STR | |
9087 | "Display routes conforming to the prefix-list\n" | |
9088 | "IP prefix-list name\n") | |
9089 | { | |
50ef26d4 | 9090 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
9091 | bgp_show_type_prefix_list); | |
9092 | } | |
9093 | ||
8386ac43 | 9094 | DEFUN (show_ip_bgp_instance_prefix_list, |
9095 | show_ip_bgp_instance_prefix_list_cmd, | |
9096 | "show ip bgp " BGP_INSTANCE_CMD " prefix-list WORD", | |
50ef26d4 | 9097 | SHOW_STR |
9098 | IP_STR | |
9099 | BGP_STR | |
8386ac43 | 9100 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 9101 | "Display routes conforming to the prefix-list\n" |
9102 | "IP prefix-list name\n") | |
9103 | { | |
9104 | return bgp_show_prefix_list (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 9105 | bgp_show_type_prefix_list); |
9106 | } | |
9107 | ||
9108 | DEFUN (show_ip_bgp_flap_prefix_list, | |
9109 | show_ip_bgp_flap_prefix_list_cmd, | |
9110 | "show ip bgp flap-statistics prefix-list WORD", | |
9111 | SHOW_STR | |
9112 | IP_STR | |
9113 | BGP_STR | |
9114 | "Display flap statistics of routes\n" | |
9115 | "Display routes conforming to the prefix-list\n" | |
9116 | "IP prefix-list name\n") | |
9117 | { | |
50ef26d4 | 9118 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 9119 | bgp_show_type_flap_prefix_list); |
9120 | } | |
9121 | ||
81304aaf B |
9122 | ALIAS (show_ip_bgp_flap_prefix_list, |
9123 | show_ip_bgp_damp_flap_prefix_list_cmd, | |
9124 | "show ip bgp dampening flap-statistics prefix-list WORD", | |
9125 | SHOW_STR | |
9126 | IP_STR | |
9127 | BGP_STR | |
9128 | "Display detailed information about dampening\n" | |
9129 | "Display flap statistics of routes\n" | |
9130 | "Display routes conforming to the prefix-list\n" | |
9131 | "IP prefix-list name\n") | |
9132 | ||
718e3744 | 9133 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
9134 | show_ip_bgp_ipv4_prefix_list_cmd, | |
9135 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", | |
9136 | SHOW_STR | |
9137 | IP_STR | |
9138 | BGP_STR | |
9139 | "Address family\n" | |
9140 | "Address Family modifier\n" | |
9141 | "Address Family modifier\n" | |
9142 | "Display routes conforming to the prefix-list\n" | |
9143 | "IP prefix-list name\n") | |
9144 | { | |
9145 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 9146 | return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 9147 | bgp_show_type_prefix_list); |
9148 | ||
50ef26d4 | 9149 | return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 9150 | bgp_show_type_prefix_list); |
9151 | } | |
9152 | ||
9153 | #ifdef HAVE_IPV6 | |
9154 | DEFUN (show_bgp_prefix_list, | |
9155 | show_bgp_prefix_list_cmd, | |
9156 | "show bgp prefix-list WORD", | |
9157 | SHOW_STR | |
9158 | BGP_STR | |
9159 | "Display routes conforming to the prefix-list\n" | |
9160 | "IPv6 prefix-list name\n") | |
9161 | { | |
50ef26d4 | 9162 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9163 | bgp_show_type_prefix_list); |
9164 | } | |
9165 | ||
9166 | ALIAS (show_bgp_prefix_list, | |
9167 | show_bgp_ipv6_prefix_list_cmd, | |
9168 | "show bgp ipv6 prefix-list WORD", | |
9169 | SHOW_STR | |
9170 | BGP_STR | |
9171 | "Address family\n" | |
9172 | "Display routes conforming to the prefix-list\n" | |
9173 | "IPv6 prefix-list name\n") | |
9174 | ||
9175 | /* old command */ | |
9176 | DEFUN (show_ipv6_bgp_prefix_list, | |
9177 | show_ipv6_bgp_prefix_list_cmd, | |
9178 | "show ipv6 bgp prefix-list WORD", | |
9179 | SHOW_STR | |
9180 | IPV6_STR | |
9181 | BGP_STR | |
9182 | "Display routes matching the prefix-list\n" | |
9183 | "IPv6 prefix-list name\n") | |
9184 | { | |
47e9b292 | 9185 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 9186 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9187 | bgp_show_type_prefix_list); |
9188 | } | |
9189 | ||
9190 | /* old command */ | |
9191 | DEFUN (show_ipv6_mbgp_prefix_list, | |
9192 | show_ipv6_mbgp_prefix_list_cmd, | |
9193 | "show ipv6 mbgp prefix-list WORD", | |
9194 | SHOW_STR | |
9195 | IPV6_STR | |
9196 | MBGP_STR | |
9197 | "Display routes matching the prefix-list\n" | |
9198 | "IPv6 prefix-list name\n") | |
9199 | { | |
47e9b292 | 9200 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 9201 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, |
718e3744 | 9202 | bgp_show_type_prefix_list); |
9203 | } | |
9204 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 9205 | |
94f2b392 | 9206 | static int |
50ef26d4 | 9207 | bgp_show_filter_list (struct vty *vty, const char *name, |
9208 | const char *filter, afi_t afi, | |
718e3744 | 9209 | safi_t safi, enum bgp_show_type type) |
9210 | { | |
9211 | struct as_list *as_list; | |
50ef26d4 | 9212 | struct bgp *bgp = NULL; |
9213 | ||
9214 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
9215 | { | |
9216 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
9217 | return CMD_WARNING; | |
9218 | } | |
718e3744 | 9219 | |
9220 | as_list = as_list_lookup (filter); | |
9221 | if (as_list == NULL) | |
9222 | { | |
9223 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); | |
9224 | return CMD_WARNING; | |
9225 | } | |
9226 | ||
50ef26d4 | 9227 | return bgp_show (vty, bgp, afi, safi, type, as_list, 0); |
718e3744 | 9228 | } |
9229 | ||
9230 | DEFUN (show_ip_bgp_filter_list, | |
9231 | show_ip_bgp_filter_list_cmd, | |
9232 | "show ip bgp filter-list WORD", | |
9233 | SHOW_STR | |
9234 | IP_STR | |
9235 | BGP_STR | |
9236 | "Display routes conforming to the filter-list\n" | |
9237 | "Regular expression access list name\n") | |
9238 | { | |
50ef26d4 | 9239 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
9240 | bgp_show_type_filter_list); | |
9241 | } | |
9242 | ||
8386ac43 | 9243 | DEFUN (show_ip_bgp_instance_filter_list, |
9244 | show_ip_bgp_instance_filter_list_cmd, | |
9245 | "show ip bgp " BGP_INSTANCE_CMD " filter-list WORD", | |
50ef26d4 | 9246 | SHOW_STR |
9247 | IP_STR | |
9248 | BGP_STR | |
8386ac43 | 9249 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 9250 | "Display routes conforming to the filter-list\n" |
9251 | "Regular expression access list name\n") | |
9252 | { | |
9253 | return bgp_show_filter_list (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 9254 | bgp_show_type_filter_list); |
9255 | } | |
9256 | ||
9257 | DEFUN (show_ip_bgp_flap_filter_list, | |
9258 | show_ip_bgp_flap_filter_list_cmd, | |
9259 | "show ip bgp flap-statistics filter-list WORD", | |
9260 | SHOW_STR | |
9261 | IP_STR | |
9262 | BGP_STR | |
9263 | "Display flap statistics of routes\n" | |
9264 | "Display routes conforming to the filter-list\n" | |
9265 | "Regular expression access list name\n") | |
9266 | { | |
50ef26d4 | 9267 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 9268 | bgp_show_type_flap_filter_list); |
9269 | } | |
9270 | ||
81304aaf B |
9271 | ALIAS (show_ip_bgp_flap_filter_list, |
9272 | show_ip_bgp_damp_flap_filter_list_cmd, | |
9273 | "show ip bgp dampening flap-statistics filter-list WORD", | |
9274 | SHOW_STR | |
9275 | IP_STR | |
9276 | BGP_STR | |
9277 | "Display detailed information about dampening\n" | |
9278 | "Display flap statistics of routes\n" | |
9279 | "Display routes conforming to the filter-list\n" | |
9280 | "Regular expression access list name\n") | |
9281 | ||
718e3744 | 9282 | DEFUN (show_ip_bgp_ipv4_filter_list, |
9283 | show_ip_bgp_ipv4_filter_list_cmd, | |
9284 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", | |
9285 | SHOW_STR | |
9286 | IP_STR | |
9287 | BGP_STR | |
9288 | "Address family\n" | |
9289 | "Address Family modifier\n" | |
9290 | "Address Family modifier\n" | |
9291 | "Display routes conforming to the filter-list\n" | |
9292 | "Regular expression access list name\n") | |
9293 | { | |
9294 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 9295 | return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 9296 | bgp_show_type_filter_list); |
9297 | ||
50ef26d4 | 9298 | return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 9299 | bgp_show_type_filter_list); |
9300 | } | |
9301 | ||
9302 | #ifdef HAVE_IPV6 | |
9303 | DEFUN (show_bgp_filter_list, | |
9304 | show_bgp_filter_list_cmd, | |
9305 | "show bgp filter-list WORD", | |
9306 | SHOW_STR | |
9307 | BGP_STR | |
9308 | "Display routes conforming to the filter-list\n" | |
9309 | "Regular expression access list name\n") | |
9310 | { | |
50ef26d4 | 9311 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9312 | bgp_show_type_filter_list); |
9313 | } | |
9314 | ||
9315 | ALIAS (show_bgp_filter_list, | |
9316 | show_bgp_ipv6_filter_list_cmd, | |
9317 | "show bgp ipv6 filter-list WORD", | |
9318 | SHOW_STR | |
9319 | BGP_STR | |
9320 | "Address family\n" | |
9321 | "Display routes conforming to the filter-list\n" | |
9322 | "Regular expression access list name\n") | |
9323 | ||
9324 | /* old command */ | |
9325 | DEFUN (show_ipv6_bgp_filter_list, | |
9326 | show_ipv6_bgp_filter_list_cmd, | |
9327 | "show ipv6 bgp filter-list WORD", | |
9328 | SHOW_STR | |
9329 | IPV6_STR | |
9330 | BGP_STR | |
9331 | "Display routes conforming to the filter-list\n" | |
9332 | "Regular expression access list name\n") | |
9333 | { | |
47e9b292 | 9334 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 9335 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9336 | bgp_show_type_filter_list); |
9337 | } | |
9338 | ||
9339 | /* old command */ | |
9340 | DEFUN (show_ipv6_mbgp_filter_list, | |
9341 | show_ipv6_mbgp_filter_list_cmd, | |
9342 | "show ipv6 mbgp filter-list WORD", | |
9343 | SHOW_STR | |
9344 | IPV6_STR | |
9345 | MBGP_STR | |
9346 | "Display routes conforming to the filter-list\n" | |
9347 | "Regular expression access list name\n") | |
9348 | { | |
47e9b292 | 9349 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 9350 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, |
718e3744 | 9351 | bgp_show_type_filter_list); |
9352 | } | |
9353 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 9354 | |
81304aaf B |
9355 | DEFUN (show_ip_bgp_dampening_info, |
9356 | show_ip_bgp_dampening_params_cmd, | |
9357 | "show ip bgp dampening parameters", | |
9358 | SHOW_STR | |
9359 | IP_STR | |
9360 | BGP_STR | |
9361 | "Display detailed information about dampening\n" | |
9362 | "Display detail of configured dampening parameters\n") | |
9363 | { | |
9364 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); | |
9365 | } | |
9366 | ||
58a90275 B |
9367 | |
9368 | DEFUN (show_ip_bgp_ipv4_dampening_parameters, | |
9369 | show_ip_bgp_ipv4_dampening_parameters_cmd, | |
9370 | "show ip bgp ipv4 (unicast|multicast) dampening parameters", | |
9371 | SHOW_STR | |
9372 | IP_STR | |
9373 | BGP_STR | |
9374 | "Address family\n" | |
9375 | "Address Family modifier\n" | |
9376 | "Address Family modifier\n" | |
9377 | "Display detailed information about dampening\n" | |
9378 | "Display detail of configured dampening parameters\n") | |
9379 | { | |
9380 | if (strncmp(argv[0], "m", 1) == 0) | |
9381 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); | |
9382 | ||
9383 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); | |
9384 | } | |
9385 | ||
9386 | ||
9387 | DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, | |
9388 | show_ip_bgp_ipv4_dampening_flap_stats_cmd, | |
9389 | "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics", | |
9390 | SHOW_STR | |
9391 | IP_STR | |
9392 | BGP_STR | |
9393 | "Address family\n" | |
9394 | "Address Family modifier\n" | |
9395 | "Address Family modifier\n" | |
9396 | "Display detailed information about dampening\n" | |
9397 | "Display flap statistics of routes\n") | |
9398 | { | |
9399 | if (strncmp(argv[0], "m", 1) == 0) | |
9400 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
9401 | bgp_show_type_flap_statistics, NULL, 0); | |
9402 | ||
9403 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
9404 | bgp_show_type_flap_statistics, NULL, 0); | |
9405 | } | |
9406 | ||
9407 | DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, | |
9408 | show_ip_bgp_ipv4_dampening_dampd_paths_cmd, | |
9409 | "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths", | |
9410 | SHOW_STR | |
9411 | IP_STR | |
9412 | BGP_STR | |
9413 | "Address family\n" | |
9414 | "Address Family modifier\n" | |
9415 | "Address Family modifier\n" | |
9416 | "Display detailed information about dampening\n" | |
9417 | "Display paths suppressed due to dampening\n") | |
9418 | { | |
9419 | if (strncmp(argv[0], "m", 1) == 0) | |
9420 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
9421 | bgp_show_type_dampend_paths, NULL, 0); | |
9422 | ||
9423 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
9424 | bgp_show_type_dampend_paths, NULL, 0); | |
9425 | } | |
9426 | ||
94f2b392 | 9427 | static int |
50ef26d4 | 9428 | bgp_show_route_map (struct vty *vty, const char *name, |
9429 | const char *rmap_str, afi_t afi, | |
718e3744 | 9430 | safi_t safi, enum bgp_show_type type) |
9431 | { | |
9432 | struct route_map *rmap; | |
50ef26d4 | 9433 | struct bgp *bgp = NULL; |
9434 | ||
9435 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
9436 | { | |
9437 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
9438 | return CMD_WARNING; | |
9439 | } | |
718e3744 | 9440 | |
9441 | rmap = route_map_lookup_by_name (rmap_str); | |
9442 | if (! rmap) | |
9443 | { | |
9444 | vty_out (vty, "%% %s is not a valid route-map name%s", | |
9445 | rmap_str, VTY_NEWLINE); | |
9446 | return CMD_WARNING; | |
9447 | } | |
9448 | ||
50ef26d4 | 9449 | return bgp_show (vty, bgp, afi, safi, type, rmap, 0); |
718e3744 | 9450 | } |
9451 | ||
9452 | DEFUN (show_ip_bgp_route_map, | |
9453 | show_ip_bgp_route_map_cmd, | |
9454 | "show ip bgp route-map WORD", | |
9455 | SHOW_STR | |
9456 | IP_STR | |
9457 | BGP_STR | |
9458 | "Display routes matching the route-map\n" | |
9459 | "A route-map to match on\n") | |
9460 | { | |
50ef26d4 | 9461 | return bgp_show_route_map (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
9462 | bgp_show_type_route_map); | |
9463 | } | |
9464 | ||
8386ac43 | 9465 | DEFUN (show_ip_bgp_instance_route_map, |
9466 | show_ip_bgp_instance_route_map_cmd, | |
9467 | "show ip bgp " BGP_INSTANCE_CMD " route-map WORD", | |
50ef26d4 | 9468 | SHOW_STR |
9469 | IP_STR | |
9470 | BGP_STR | |
8386ac43 | 9471 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 9472 | "Display routes matching the route-map\n" |
9473 | "A route-map to match on\n") | |
9474 | { | |
9475 | return bgp_show_route_map (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 9476 | bgp_show_type_route_map); |
9477 | } | |
9478 | ||
9479 | DEFUN (show_ip_bgp_flap_route_map, | |
9480 | show_ip_bgp_flap_route_map_cmd, | |
9481 | "show ip bgp flap-statistics route-map WORD", | |
9482 | SHOW_STR | |
9483 | IP_STR | |
9484 | BGP_STR | |
9485 | "Display flap statistics of routes\n" | |
9486 | "Display routes matching the route-map\n" | |
9487 | "A route-map to match on\n") | |
9488 | { | |
50ef26d4 | 9489 | return bgp_show_route_map (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 9490 | bgp_show_type_flap_route_map); |
9491 | } | |
9492 | ||
81304aaf B |
9493 | ALIAS (show_ip_bgp_flap_route_map, |
9494 | show_ip_bgp_damp_flap_route_map_cmd, | |
9495 | "show ip bgp dampening flap-statistics route-map WORD", | |
9496 | SHOW_STR | |
9497 | IP_STR | |
9498 | BGP_STR | |
9499 | "Display detailed information about dampening\n" | |
9500 | "Display flap statistics of routes\n" | |
9501 | "Display routes matching the route-map\n" | |
9502 | "A route-map to match on\n") | |
9503 | ||
718e3744 | 9504 | DEFUN (show_ip_bgp_ipv4_route_map, |
9505 | show_ip_bgp_ipv4_route_map_cmd, | |
9506 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", | |
9507 | SHOW_STR | |
9508 | IP_STR | |
9509 | BGP_STR | |
9510 | "Address family\n" | |
9511 | "Address Family modifier\n" | |
9512 | "Address Family modifier\n" | |
9513 | "Display routes matching the route-map\n" | |
9514 | "A route-map to match on\n") | |
9515 | { | |
9516 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 9517 | return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 9518 | bgp_show_type_route_map); |
9519 | ||
50ef26d4 | 9520 | return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 9521 | bgp_show_type_route_map); |
9522 | } | |
9523 | ||
9524 | DEFUN (show_bgp_route_map, | |
9525 | show_bgp_route_map_cmd, | |
9526 | "show bgp route-map WORD", | |
9527 | SHOW_STR | |
9528 | BGP_STR | |
9529 | "Display routes matching the route-map\n" | |
9530 | "A route-map to match on\n") | |
9531 | { | |
50ef26d4 | 9532 | return bgp_show_route_map (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9533 | bgp_show_type_route_map); |
9534 | } | |
9535 | ||
9536 | ALIAS (show_bgp_route_map, | |
9537 | show_bgp_ipv6_route_map_cmd, | |
9538 | "show bgp ipv6 route-map WORD", | |
9539 | SHOW_STR | |
9540 | BGP_STR | |
9541 | "Address family\n" | |
9542 | "Display routes matching the route-map\n" | |
9543 | "A route-map to match on\n") | |
6b0655a2 | 9544 | |
718e3744 | 9545 | DEFUN (show_ip_bgp_cidr_only, |
9546 | show_ip_bgp_cidr_only_cmd, | |
9547 | "show ip bgp cidr-only", | |
9548 | SHOW_STR | |
9549 | IP_STR | |
9550 | BGP_STR | |
9551 | "Display only routes with non-natural netmasks\n") | |
9552 | { | |
9553 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9554 | bgp_show_type_cidr_only, NULL, 0); |
718e3744 | 9555 | } |
9556 | ||
9557 | DEFUN (show_ip_bgp_flap_cidr_only, | |
9558 | show_ip_bgp_flap_cidr_only_cmd, | |
9559 | "show ip bgp flap-statistics cidr-only", | |
9560 | SHOW_STR | |
9561 | IP_STR | |
9562 | BGP_STR | |
9563 | "Display flap statistics of routes\n" | |
9564 | "Display only routes with non-natural netmasks\n") | |
9565 | { | |
9566 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9567 | bgp_show_type_flap_cidr_only, NULL, 0); |
718e3744 | 9568 | } |
9569 | ||
81304aaf B |
9570 | ALIAS (show_ip_bgp_flap_cidr_only, |
9571 | show_ip_bgp_damp_flap_cidr_only_cmd, | |
9572 | "show ip bgp dampening flap-statistics cidr-only", | |
9573 | SHOW_STR | |
9574 | IP_STR | |
9575 | BGP_STR | |
9576 | "Display detailed information about dampening\n" | |
9577 | "Display flap statistics of routes\n" | |
9578 | "Display only routes with non-natural netmasks\n") | |
9579 | ||
718e3744 | 9580 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
9581 | show_ip_bgp_ipv4_cidr_only_cmd, | |
9582 | "show ip bgp ipv4 (unicast|multicast) cidr-only", | |
9583 | SHOW_STR | |
9584 | IP_STR | |
9585 | BGP_STR | |
9586 | "Address family\n" | |
9587 | "Address Family modifier\n" | |
9588 | "Address Family modifier\n" | |
9589 | "Display only routes with non-natural netmasks\n") | |
9590 | { | |
9591 | if (strncmp (argv[0], "m", 1) == 0) | |
9592 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
b05a1c8b | 9593 | bgp_show_type_cidr_only, NULL, 0); |
718e3744 | 9594 | |
9595 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9596 | bgp_show_type_cidr_only, NULL, 0); |
718e3744 | 9597 | } |
6b0655a2 | 9598 | |
718e3744 | 9599 | DEFUN (show_ip_bgp_community_all, |
9600 | show_ip_bgp_community_all_cmd, | |
9601 | "show ip bgp community", | |
9602 | SHOW_STR | |
9603 | IP_STR | |
9604 | BGP_STR | |
9605 | "Display routes matching the communities\n") | |
9606 | { | |
9607 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9608 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9609 | } |
9610 | ||
9611 | DEFUN (show_ip_bgp_ipv4_community_all, | |
9612 | show_ip_bgp_ipv4_community_all_cmd, | |
9613 | "show ip bgp ipv4 (unicast|multicast) community", | |
9614 | SHOW_STR | |
9615 | IP_STR | |
9616 | BGP_STR | |
9617 | "Address family\n" | |
9618 | "Address Family modifier\n" | |
9619 | "Address Family modifier\n" | |
9620 | "Display routes matching the communities\n") | |
9621 | { | |
9622 | if (strncmp (argv[0], "m", 1) == 0) | |
9623 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
b05a1c8b | 9624 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9625 | |
9626 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9627 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9628 | } |
9629 | ||
9630 | #ifdef HAVE_IPV6 | |
9631 | DEFUN (show_bgp_community_all, | |
9632 | show_bgp_community_all_cmd, | |
9633 | "show bgp community", | |
9634 | SHOW_STR | |
9635 | BGP_STR | |
9636 | "Display routes matching the communities\n") | |
9637 | { | |
9638 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
b05a1c8b | 9639 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9640 | } |
9641 | ||
9642 | ALIAS (show_bgp_community_all, | |
9643 | show_bgp_ipv6_community_all_cmd, | |
9644 | "show bgp ipv6 community", | |
9645 | SHOW_STR | |
9646 | BGP_STR | |
9647 | "Address family\n" | |
9648 | "Display routes matching the communities\n") | |
9649 | ||
9650 | /* old command */ | |
9651 | DEFUN (show_ipv6_bgp_community_all, | |
9652 | show_ipv6_bgp_community_all_cmd, | |
9653 | "show ipv6 bgp community", | |
9654 | SHOW_STR | |
9655 | IPV6_STR | |
9656 | BGP_STR | |
9657 | "Display routes matching the communities\n") | |
9658 | { | |
47e9b292 | 9659 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9660 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
b05a1c8b | 9661 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9662 | } |
9663 | ||
9664 | /* old command */ | |
9665 | DEFUN (show_ipv6_mbgp_community_all, | |
9666 | show_ipv6_mbgp_community_all_cmd, | |
9667 | "show ipv6 mbgp community", | |
9668 | SHOW_STR | |
9669 | IPV6_STR | |
9670 | MBGP_STR | |
9671 | "Display routes matching the communities\n") | |
9672 | { | |
47e9b292 | 9673 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9674 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
b05a1c8b | 9675 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9676 | } |
9677 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 9678 | |
94f2b392 | 9679 | static int |
95cbbd2a ML |
9680 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
9681 | const char **argv, int exact, afi_t afi, safi_t safi) | |
718e3744 | 9682 | { |
9683 | struct community *com; | |
9684 | struct buffer *b; | |
95cbbd2a | 9685 | struct bgp *bgp; |
718e3744 | 9686 | int i; |
9687 | char *str; | |
9688 | int first = 0; | |
9689 | ||
95cbbd2a ML |
9690 | /* BGP structure lookup */ |
9691 | if (view_name) | |
9692 | { | |
9693 | bgp = bgp_lookup_by_name (view_name); | |
9694 | if (bgp == NULL) | |
9695 | { | |
6aeb9e78 | 9696 | vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
95cbbd2a ML |
9697 | return CMD_WARNING; |
9698 | } | |
9699 | } | |
9700 | else | |
9701 | { | |
9702 | bgp = bgp_get_default (); | |
9703 | if (bgp == NULL) | |
9704 | { | |
9705 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
9706 | return CMD_WARNING; | |
9707 | } | |
9708 | } | |
9709 | ||
718e3744 | 9710 | b = buffer_new (1024); |
9711 | for (i = 0; i < argc; i++) | |
9712 | { | |
9713 | if (first) | |
9714 | buffer_putc (b, ' '); | |
9715 | else | |
9716 | { | |
9717 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
9718 | continue; | |
9719 | first = 1; | |
9720 | } | |
9721 | ||
9722 | buffer_putstr (b, argv[i]); | |
9723 | } | |
9724 | buffer_putc (b, '\0'); | |
9725 | ||
9726 | str = buffer_getstr (b); | |
9727 | buffer_free (b); | |
9728 | ||
9729 | com = community_str2com (str); | |
3b8b1855 | 9730 | XFREE (MTYPE_TMP, str); |
718e3744 | 9731 | if (! com) |
9732 | { | |
9733 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); | |
9734 | return CMD_WARNING; | |
9735 | } | |
9736 | ||
95cbbd2a | 9737 | return bgp_show (vty, bgp, afi, safi, |
5a646650 | 9738 | (exact ? bgp_show_type_community_exact : |
b05a1c8b | 9739 | bgp_show_type_community), com, 0); |
718e3744 | 9740 | } |
9741 | ||
9742 | DEFUN (show_ip_bgp_community, | |
9743 | show_ip_bgp_community_cmd, | |
9744 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
9745 | SHOW_STR | |
9746 | IP_STR | |
9747 | BGP_STR | |
9748 | "Display routes matching the communities\n" | |
859d388e | 9749 | COMMUNITY_AANN_STR |
718e3744 | 9750 | "Do not send outside local AS (well-known community)\n" |
9751 | "Do not advertise to any peer (well-known community)\n" | |
9752 | "Do not export to next AS (well-known community)\n") | |
9753 | { | |
95cbbd2a | 9754 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 9755 | } |
9756 | ||
9757 | ALIAS (show_ip_bgp_community, | |
9758 | show_ip_bgp_community2_cmd, | |
9759 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9760 | SHOW_STR | |
9761 | IP_STR | |
9762 | BGP_STR | |
9763 | "Display routes matching the communities\n" | |
859d388e | 9764 | COMMUNITY_AANN_STR |
718e3744 | 9765 | "Do not send outside local AS (well-known community)\n" |
9766 | "Do not advertise to any peer (well-known community)\n" | |
9767 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9768 | COMMUNITY_AANN_STR |
718e3744 | 9769 | "Do not send outside local AS (well-known community)\n" |
9770 | "Do not advertise to any peer (well-known community)\n" | |
9771 | "Do not export to next AS (well-known community)\n") | |
9772 | ||
9773 | ALIAS (show_ip_bgp_community, | |
9774 | show_ip_bgp_community3_cmd, | |
9775 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9776 | SHOW_STR | |
9777 | IP_STR | |
9778 | BGP_STR | |
9779 | "Display routes matching the communities\n" | |
859d388e | 9780 | COMMUNITY_AANN_STR |
718e3744 | 9781 | "Do not send outside local AS (well-known community)\n" |
9782 | "Do not advertise to any peer (well-known community)\n" | |
9783 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9784 | COMMUNITY_AANN_STR |
718e3744 | 9785 | "Do not send outside local AS (well-known community)\n" |
9786 | "Do not advertise to any peer (well-known community)\n" | |
9787 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9788 | COMMUNITY_AANN_STR |
718e3744 | 9789 | "Do not send outside local AS (well-known community)\n" |
9790 | "Do not advertise to any peer (well-known community)\n" | |
9791 | "Do not export to next AS (well-known community)\n") | |
9792 | ||
9793 | ALIAS (show_ip_bgp_community, | |
9794 | show_ip_bgp_community4_cmd, | |
9795 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9796 | SHOW_STR | |
9797 | IP_STR | |
9798 | BGP_STR | |
9799 | "Display routes matching the communities\n" | |
859d388e | 9800 | COMMUNITY_AANN_STR |
718e3744 | 9801 | "Do not send outside local AS (well-known community)\n" |
9802 | "Do not advertise to any peer (well-known community)\n" | |
9803 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9804 | COMMUNITY_AANN_STR |
718e3744 | 9805 | "Do not send outside local AS (well-known community)\n" |
9806 | "Do not advertise to any peer (well-known community)\n" | |
9807 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9808 | COMMUNITY_AANN_STR |
718e3744 | 9809 | "Do not send outside local AS (well-known community)\n" |
9810 | "Do not advertise to any peer (well-known community)\n" | |
9811 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9812 | COMMUNITY_AANN_STR |
718e3744 | 9813 | "Do not send outside local AS (well-known community)\n" |
9814 | "Do not advertise to any peer (well-known community)\n" | |
9815 | "Do not export to next AS (well-known community)\n") | |
9816 | ||
9817 | DEFUN (show_ip_bgp_ipv4_community, | |
9818 | show_ip_bgp_ipv4_community_cmd, | |
9819 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
9820 | SHOW_STR | |
9821 | IP_STR | |
9822 | BGP_STR | |
9823 | "Address family\n" | |
9824 | "Address Family modifier\n" | |
9825 | "Address Family modifier\n" | |
9826 | "Display routes matching the communities\n" | |
859d388e | 9827 | COMMUNITY_AANN_STR |
718e3744 | 9828 | "Do not send outside local AS (well-known community)\n" |
9829 | "Do not advertise to any peer (well-known community)\n" | |
9830 | "Do not export to next AS (well-known community)\n") | |
9831 | { | |
9832 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 9833 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
718e3744 | 9834 | |
95cbbd2a | 9835 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 9836 | } |
9837 | ||
9838 | ALIAS (show_ip_bgp_ipv4_community, | |
9839 | show_ip_bgp_ipv4_community2_cmd, | |
9840 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9841 | SHOW_STR | |
9842 | IP_STR | |
9843 | BGP_STR | |
9844 | "Address family\n" | |
9845 | "Address Family modifier\n" | |
9846 | "Address Family modifier\n" | |
9847 | "Display routes matching the communities\n" | |
859d388e | 9848 | COMMUNITY_AANN_STR |
718e3744 | 9849 | "Do not send outside local AS (well-known community)\n" |
9850 | "Do not advertise to any peer (well-known community)\n" | |
9851 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9852 | COMMUNITY_AANN_STR |
718e3744 | 9853 | "Do not send outside local AS (well-known community)\n" |
9854 | "Do not advertise to any peer (well-known community)\n" | |
9855 | "Do not export to next AS (well-known community)\n") | |
9856 | ||
9857 | ALIAS (show_ip_bgp_ipv4_community, | |
9858 | show_ip_bgp_ipv4_community3_cmd, | |
9859 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9860 | SHOW_STR | |
9861 | IP_STR | |
9862 | BGP_STR | |
9863 | "Address family\n" | |
9864 | "Address Family modifier\n" | |
9865 | "Address Family modifier\n" | |
9866 | "Display routes matching the communities\n" | |
859d388e | 9867 | COMMUNITY_AANN_STR |
718e3744 | 9868 | "Do not send outside local AS (well-known community)\n" |
9869 | "Do not advertise to any peer (well-known community)\n" | |
9870 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9871 | COMMUNITY_AANN_STR |
718e3744 | 9872 | "Do not send outside local AS (well-known community)\n" |
9873 | "Do not advertise to any peer (well-known community)\n" | |
9874 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9875 | COMMUNITY_AANN_STR |
718e3744 | 9876 | "Do not send outside local AS (well-known community)\n" |
9877 | "Do not advertise to any peer (well-known community)\n" | |
9878 | "Do not export to next AS (well-known community)\n") | |
9879 | ||
9880 | ALIAS (show_ip_bgp_ipv4_community, | |
9881 | show_ip_bgp_ipv4_community4_cmd, | |
9882 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9883 | SHOW_STR | |
9884 | IP_STR | |
9885 | BGP_STR | |
9886 | "Address family\n" | |
9887 | "Address Family modifier\n" | |
9888 | "Address Family modifier\n" | |
9889 | "Display routes matching the communities\n" | |
859d388e | 9890 | COMMUNITY_AANN_STR |
718e3744 | 9891 | "Do not send outside local AS (well-known community)\n" |
9892 | "Do not advertise to any peer (well-known community)\n" | |
9893 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9894 | COMMUNITY_AANN_STR |
718e3744 | 9895 | "Do not send outside local AS (well-known community)\n" |
9896 | "Do not advertise to any peer (well-known community)\n" | |
9897 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9898 | COMMUNITY_AANN_STR |
718e3744 | 9899 | "Do not send outside local AS (well-known community)\n" |
9900 | "Do not advertise to any peer (well-known community)\n" | |
9901 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9902 | COMMUNITY_AANN_STR |
718e3744 | 9903 | "Do not send outside local AS (well-known community)\n" |
9904 | "Do not advertise to any peer (well-known community)\n" | |
9905 | "Do not export to next AS (well-known community)\n") | |
9906 | ||
8386ac43 | 9907 | DEFUN (show_bgp_instance_afi_safi_community_all, |
9908 | show_bgp_instance_afi_safi_community_all_cmd, | |
8386ac43 | 9909 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community", |
95cbbd2a ML |
9910 | SHOW_STR |
9911 | BGP_STR | |
8386ac43 | 9912 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 9913 | "Address family\n" |
95cbbd2a | 9914 | "Address family\n" |
95cbbd2a ML |
9915 | "Address Family modifier\n" |
9916 | "Address Family modifier\n" | |
2b00515a | 9917 | "Display routes matching the communities\n") |
95cbbd2a ML |
9918 | { |
9919 | int afi; | |
9920 | int safi; | |
9921 | struct bgp *bgp; | |
9922 | ||
9923 | /* BGP structure lookup. */ | |
6aeb9e78 | 9924 | bgp = bgp_lookup_by_name (argv[1]); |
95cbbd2a ML |
9925 | if (bgp == NULL) |
9926 | { | |
6aeb9e78 | 9927 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
95cbbd2a ML |
9928 | return CMD_WARNING; |
9929 | } | |
9930 | ||
6aeb9e78 DS |
9931 | afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
9932 | safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
b05a1c8b | 9933 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, 0); |
95cbbd2a ML |
9934 | } |
9935 | ||
8386ac43 | 9936 | DEFUN (show_bgp_instance_afi_safi_community, |
9937 | show_bgp_instance_afi_safi_community_cmd, | |
8386ac43 | 9938 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
9939 | SHOW_STR |
9940 | BGP_STR | |
8386ac43 | 9941 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 9942 | "Address family\n" |
95cbbd2a | 9943 | "Address family\n" |
95cbbd2a ML |
9944 | "Address family modifier\n" |
9945 | "Address family modifier\n" | |
9946 | "Display routes matching the communities\n" | |
859d388e | 9947 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9948 | "Do not send outside local AS (well-known community)\n" |
9949 | "Do not advertise to any peer (well-known community)\n" | |
9950 | "Do not export to next AS (well-known community)\n") | |
9951 | { | |
9952 | int afi; | |
9953 | int safi; | |
9954 | ||
6aeb9e78 DS |
9955 | afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
9956 | safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
9957 | return bgp_show_community (vty, argv[1], argc-4, &argv[4], 0, afi, safi); | |
95cbbd2a ML |
9958 | } |
9959 | ||
8386ac43 | 9960 | ALIAS (show_bgp_instance_afi_safi_community, |
9961 | show_bgp_instance_afi_safi_community2_cmd, | |
8386ac43 | 9962 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
9963 | SHOW_STR |
9964 | BGP_STR | |
8386ac43 | 9965 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 9966 | "Address family\n" |
95cbbd2a | 9967 | "Address family\n" |
95cbbd2a ML |
9968 | "Address family modifier\n" |
9969 | "Address family modifier\n" | |
9970 | "Display routes matching the communities\n" | |
859d388e | 9971 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9972 | "Do not send outside local AS (well-known community)\n" |
9973 | "Do not advertise to any peer (well-known community)\n" | |
9974 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9975 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9976 | "Do not send outside local AS (well-known community)\n" |
9977 | "Do not advertise to any peer (well-known community)\n" | |
9978 | "Do not export to next AS (well-known community)\n") | |
9979 | ||
8386ac43 | 9980 | ALIAS (show_bgp_instance_afi_safi_community, |
9981 | show_bgp_instance_afi_safi_community3_cmd, | |
8386ac43 | 9982 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
9983 | SHOW_STR |
9984 | BGP_STR | |
8386ac43 | 9985 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 9986 | "Address family\n" |
95cbbd2a | 9987 | "Address family\n" |
95cbbd2a ML |
9988 | "Address family modifier\n" |
9989 | "Address family modifier\n" | |
9990 | "Display routes matching the communities\n" | |
859d388e | 9991 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9992 | "Do not send outside local AS (well-known community)\n" |
9993 | "Do not advertise to any peer (well-known community)\n" | |
9994 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9995 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9996 | "Do not send outside local AS (well-known community)\n" |
9997 | "Do not advertise to any peer (well-known community)\n" | |
9998 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9999 | COMMUNITY_AANN_STR |
95cbbd2a ML |
10000 | "Do not send outside local AS (well-known community)\n" |
10001 | "Do not advertise to any peer (well-known community)\n" | |
10002 | "Do not export to next AS (well-known community)\n") | |
10003 | ||
8386ac43 | 10004 | ALIAS (show_bgp_instance_afi_safi_community, |
10005 | show_bgp_instance_afi_safi_community4_cmd, | |
8386ac43 | 10006 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
10007 | SHOW_STR |
10008 | BGP_STR | |
8386ac43 | 10009 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 10010 | "Address family\n" |
95cbbd2a | 10011 | "Address family\n" |
95cbbd2a ML |
10012 | "Address family modifier\n" |
10013 | "Address family modifier\n" | |
10014 | "Display routes matching the communities\n" | |
859d388e | 10015 | COMMUNITY_AANN_STR |
95cbbd2a ML |
10016 | "Do not send outside local AS (well-known community)\n" |
10017 | "Do not advertise to any peer (well-known community)\n" | |
10018 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10019 | COMMUNITY_AANN_STR |
95cbbd2a ML |
10020 | "Do not send outside local AS (well-known community)\n" |
10021 | "Do not advertise to any peer (well-known community)\n" | |
10022 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10023 | COMMUNITY_AANN_STR |
95cbbd2a ML |
10024 | "Do not send outside local AS (well-known community)\n" |
10025 | "Do not advertise to any peer (well-known community)\n" | |
10026 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10027 | COMMUNITY_AANN_STR |
95cbbd2a ML |
10028 | "Do not send outside local AS (well-known community)\n" |
10029 | "Do not advertise to any peer (well-known community)\n" | |
10030 | "Do not export to next AS (well-known community)\n") | |
10031 | ||
718e3744 | 10032 | DEFUN (show_ip_bgp_community_exact, |
10033 | show_ip_bgp_community_exact_cmd, | |
10034 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10035 | SHOW_STR | |
10036 | IP_STR | |
10037 | BGP_STR | |
10038 | "Display routes matching the communities\n" | |
859d388e | 10039 | COMMUNITY_AANN_STR |
718e3744 | 10040 | "Do not send outside local AS (well-known community)\n" |
10041 | "Do not advertise to any peer (well-known community)\n" | |
10042 | "Do not export to next AS (well-known community)\n" | |
10043 | "Exact match of the communities") | |
10044 | { | |
95cbbd2a | 10045 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10046 | } |
10047 | ||
10048 | ALIAS (show_ip_bgp_community_exact, | |
10049 | show_ip_bgp_community2_exact_cmd, | |
10050 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10051 | SHOW_STR | |
10052 | IP_STR | |
10053 | BGP_STR | |
10054 | "Display routes matching the communities\n" | |
859d388e | 10055 | COMMUNITY_AANN_STR |
718e3744 | 10056 | "Do not send outside local AS (well-known community)\n" |
10057 | "Do not advertise to any peer (well-known community)\n" | |
10058 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10059 | COMMUNITY_AANN_STR |
718e3744 | 10060 | "Do not send outside local AS (well-known community)\n" |
10061 | "Do not advertise to any peer (well-known community)\n" | |
10062 | "Do not export to next AS (well-known community)\n" | |
10063 | "Exact match of the communities") | |
10064 | ||
10065 | ALIAS (show_ip_bgp_community_exact, | |
10066 | show_ip_bgp_community3_exact_cmd, | |
10067 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10068 | SHOW_STR | |
10069 | IP_STR | |
10070 | BGP_STR | |
10071 | "Display routes matching the communities\n" | |
859d388e | 10072 | COMMUNITY_AANN_STR |
718e3744 | 10073 | "Do not send outside local AS (well-known community)\n" |
10074 | "Do not advertise to any peer (well-known community)\n" | |
10075 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10076 | COMMUNITY_AANN_STR |
718e3744 | 10077 | "Do not send outside local AS (well-known community)\n" |
10078 | "Do not advertise to any peer (well-known community)\n" | |
10079 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10080 | COMMUNITY_AANN_STR |
718e3744 | 10081 | "Do not send outside local AS (well-known community)\n" |
10082 | "Do not advertise to any peer (well-known community)\n" | |
10083 | "Do not export to next AS (well-known community)\n" | |
10084 | "Exact match of the communities") | |
10085 | ||
10086 | ALIAS (show_ip_bgp_community_exact, | |
10087 | show_ip_bgp_community4_exact_cmd, | |
10088 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10089 | SHOW_STR | |
10090 | IP_STR | |
10091 | BGP_STR | |
10092 | "Display routes matching the communities\n" | |
859d388e | 10093 | COMMUNITY_AANN_STR |
718e3744 | 10094 | "Do not send outside local AS (well-known community)\n" |
10095 | "Do not advertise to any peer (well-known community)\n" | |
10096 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10097 | COMMUNITY_AANN_STR |
718e3744 | 10098 | "Do not send outside local AS (well-known community)\n" |
10099 | "Do not advertise to any peer (well-known community)\n" | |
10100 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10101 | COMMUNITY_AANN_STR |
718e3744 | 10102 | "Do not send outside local AS (well-known community)\n" |
10103 | "Do not advertise to any peer (well-known community)\n" | |
10104 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10105 | COMMUNITY_AANN_STR |
718e3744 | 10106 | "Do not send outside local AS (well-known community)\n" |
10107 | "Do not advertise to any peer (well-known community)\n" | |
10108 | "Do not export to next AS (well-known community)\n" | |
10109 | "Exact match of the communities") | |
10110 | ||
10111 | DEFUN (show_ip_bgp_ipv4_community_exact, | |
10112 | show_ip_bgp_ipv4_community_exact_cmd, | |
10113 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10114 | SHOW_STR | |
10115 | IP_STR | |
10116 | BGP_STR | |
10117 | "Address family\n" | |
10118 | "Address Family modifier\n" | |
10119 | "Address Family modifier\n" | |
10120 | "Display routes matching the communities\n" | |
859d388e | 10121 | COMMUNITY_AANN_STR |
718e3744 | 10122 | "Do not send outside local AS (well-known community)\n" |
10123 | "Do not advertise to any peer (well-known community)\n" | |
10124 | "Do not export to next AS (well-known community)\n" | |
10125 | "Exact match of the communities") | |
10126 | { | |
10127 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 10128 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
718e3744 | 10129 | |
95cbbd2a | 10130 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10131 | } |
10132 | ||
10133 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
10134 | show_ip_bgp_ipv4_community2_exact_cmd, | |
10135 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10136 | SHOW_STR | |
10137 | IP_STR | |
10138 | BGP_STR | |
10139 | "Address family\n" | |
10140 | "Address Family modifier\n" | |
10141 | "Address Family modifier\n" | |
10142 | "Display routes matching the communities\n" | |
859d388e | 10143 | COMMUNITY_AANN_STR |
718e3744 | 10144 | "Do not send outside local AS (well-known community)\n" |
10145 | "Do not advertise to any peer (well-known community)\n" | |
10146 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10147 | COMMUNITY_AANN_STR |
718e3744 | 10148 | "Do not send outside local AS (well-known community)\n" |
10149 | "Do not advertise to any peer (well-known community)\n" | |
10150 | "Do not export to next AS (well-known community)\n" | |
10151 | "Exact match of the communities") | |
10152 | ||
10153 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
10154 | show_ip_bgp_ipv4_community3_exact_cmd, | |
10155 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10156 | SHOW_STR | |
10157 | IP_STR | |
10158 | BGP_STR | |
10159 | "Address family\n" | |
10160 | "Address Family modifier\n" | |
10161 | "Address Family modifier\n" | |
10162 | "Display routes matching the communities\n" | |
859d388e | 10163 | COMMUNITY_AANN_STR |
718e3744 | 10164 | "Do not send outside local AS (well-known community)\n" |
10165 | "Do not advertise to any peer (well-known community)\n" | |
10166 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10167 | COMMUNITY_AANN_STR |
718e3744 | 10168 | "Do not send outside local AS (well-known community)\n" |
10169 | "Do not advertise to any peer (well-known community)\n" | |
10170 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10171 | COMMUNITY_AANN_STR |
718e3744 | 10172 | "Do not send outside local AS (well-known community)\n" |
10173 | "Do not advertise to any peer (well-known community)\n" | |
10174 | "Do not export to next AS (well-known community)\n" | |
10175 | "Exact match of the communities") | |
10176 | ||
10177 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
10178 | show_ip_bgp_ipv4_community4_exact_cmd, | |
10179 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10180 | SHOW_STR | |
10181 | IP_STR | |
10182 | BGP_STR | |
10183 | "Address family\n" | |
10184 | "Address Family modifier\n" | |
10185 | "Address Family modifier\n" | |
10186 | "Display routes matching the communities\n" | |
859d388e | 10187 | COMMUNITY_AANN_STR |
718e3744 | 10188 | "Do not send outside local AS (well-known community)\n" |
10189 | "Do not advertise to any peer (well-known community)\n" | |
10190 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10191 | COMMUNITY_AANN_STR |
718e3744 | 10192 | "Do not send outside local AS (well-known community)\n" |
10193 | "Do not advertise to any peer (well-known community)\n" | |
10194 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10195 | COMMUNITY_AANN_STR |
718e3744 | 10196 | "Do not send outside local AS (well-known community)\n" |
10197 | "Do not advertise to any peer (well-known community)\n" | |
10198 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10199 | COMMUNITY_AANN_STR |
718e3744 | 10200 | "Do not send outside local AS (well-known community)\n" |
10201 | "Do not advertise to any peer (well-known community)\n" | |
10202 | "Do not export to next AS (well-known community)\n" | |
10203 | "Exact match of the communities") | |
10204 | ||
10205 | #ifdef HAVE_IPV6 | |
10206 | DEFUN (show_bgp_community, | |
10207 | show_bgp_community_cmd, | |
10208 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
10209 | SHOW_STR | |
10210 | BGP_STR | |
10211 | "Display routes matching the communities\n" | |
859d388e | 10212 | COMMUNITY_AANN_STR |
718e3744 | 10213 | "Do not send outside local AS (well-known community)\n" |
10214 | "Do not advertise to any peer (well-known community)\n" | |
10215 | "Do not export to next AS (well-known community)\n") | |
10216 | { | |
95cbbd2a | 10217 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10218 | } |
10219 | ||
10220 | ALIAS (show_bgp_community, | |
10221 | show_bgp_ipv6_community_cmd, | |
10222 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", | |
10223 | SHOW_STR | |
10224 | BGP_STR | |
10225 | "Address family\n" | |
10226 | "Display routes matching the communities\n" | |
859d388e | 10227 | COMMUNITY_AANN_STR |
718e3744 | 10228 | "Do not send outside local AS (well-known community)\n" |
10229 | "Do not advertise to any peer (well-known community)\n" | |
10230 | "Do not export to next AS (well-known community)\n") | |
10231 | ||
10232 | ALIAS (show_bgp_community, | |
10233 | show_bgp_community2_cmd, | |
10234 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10235 | SHOW_STR | |
10236 | BGP_STR | |
10237 | "Display routes matching the communities\n" | |
859d388e | 10238 | COMMUNITY_AANN_STR |
718e3744 | 10239 | "Do not send outside local AS (well-known community)\n" |
10240 | "Do not advertise to any peer (well-known community)\n" | |
10241 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10242 | COMMUNITY_AANN_STR |
718e3744 | 10243 | "Do not send outside local AS (well-known community)\n" |
10244 | "Do not advertise to any peer (well-known community)\n" | |
10245 | "Do not export to next AS (well-known community)\n") | |
10246 | ||
10247 | ALIAS (show_bgp_community, | |
10248 | show_bgp_ipv6_community2_cmd, | |
10249 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10250 | SHOW_STR | |
10251 | BGP_STR | |
10252 | "Address family\n" | |
10253 | "Display routes matching the communities\n" | |
859d388e | 10254 | COMMUNITY_AANN_STR |
718e3744 | 10255 | "Do not send outside local AS (well-known community)\n" |
10256 | "Do not advertise to any peer (well-known community)\n" | |
10257 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10258 | COMMUNITY_AANN_STR |
718e3744 | 10259 | "Do not send outside local AS (well-known community)\n" |
10260 | "Do not advertise to any peer (well-known community)\n" | |
10261 | "Do not export to next AS (well-known community)\n") | |
10262 | ||
10263 | ALIAS (show_bgp_community, | |
10264 | show_bgp_community3_cmd, | |
10265 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10266 | SHOW_STR | |
10267 | BGP_STR | |
10268 | "Display routes matching the communities\n" | |
859d388e | 10269 | COMMUNITY_AANN_STR |
718e3744 | 10270 | "Do not send outside local AS (well-known community)\n" |
10271 | "Do not advertise to any peer (well-known community)\n" | |
10272 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10273 | COMMUNITY_AANN_STR |
718e3744 | 10274 | "Do not send outside local AS (well-known community)\n" |
10275 | "Do not advertise to any peer (well-known community)\n" | |
10276 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10277 | COMMUNITY_AANN_STR |
718e3744 | 10278 | "Do not send outside local AS (well-known community)\n" |
10279 | "Do not advertise to any peer (well-known community)\n" | |
10280 | "Do not export to next AS (well-known community)\n") | |
10281 | ||
10282 | ALIAS (show_bgp_community, | |
10283 | show_bgp_ipv6_community3_cmd, | |
10284 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10285 | SHOW_STR | |
10286 | BGP_STR | |
10287 | "Address family\n" | |
10288 | "Display routes matching the communities\n" | |
859d388e | 10289 | COMMUNITY_AANN_STR |
718e3744 | 10290 | "Do not send outside local AS (well-known community)\n" |
10291 | "Do not advertise to any peer (well-known community)\n" | |
10292 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10293 | COMMUNITY_AANN_STR |
718e3744 | 10294 | "Do not send outside local AS (well-known community)\n" |
10295 | "Do not advertise to any peer (well-known community)\n" | |
10296 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10297 | COMMUNITY_AANN_STR |
718e3744 | 10298 | "Do not send outside local AS (well-known community)\n" |
10299 | "Do not advertise to any peer (well-known community)\n" | |
10300 | "Do not export to next AS (well-known community)\n") | |
10301 | ||
10302 | ALIAS (show_bgp_community, | |
10303 | show_bgp_community4_cmd, | |
10304 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10305 | SHOW_STR | |
10306 | BGP_STR | |
10307 | "Display routes matching the communities\n" | |
859d388e | 10308 | COMMUNITY_AANN_STR |
718e3744 | 10309 | "Do not send outside local AS (well-known community)\n" |
10310 | "Do not advertise to any peer (well-known community)\n" | |
10311 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10312 | COMMUNITY_AANN_STR |
718e3744 | 10313 | "Do not send outside local AS (well-known community)\n" |
10314 | "Do not advertise to any peer (well-known community)\n" | |
10315 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10316 | COMMUNITY_AANN_STR |
718e3744 | 10317 | "Do not send outside local AS (well-known community)\n" |
10318 | "Do not advertise to any peer (well-known community)\n" | |
10319 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10320 | COMMUNITY_AANN_STR |
718e3744 | 10321 | "Do not send outside local AS (well-known community)\n" |
10322 | "Do not advertise to any peer (well-known community)\n" | |
10323 | "Do not export to next AS (well-known community)\n") | |
10324 | ||
10325 | ALIAS (show_bgp_community, | |
10326 | show_bgp_ipv6_community4_cmd, | |
10327 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10328 | SHOW_STR | |
10329 | BGP_STR | |
10330 | "Address family\n" | |
10331 | "Display routes matching the communities\n" | |
859d388e | 10332 | COMMUNITY_AANN_STR |
718e3744 | 10333 | "Do not send outside local AS (well-known community)\n" |
10334 | "Do not advertise to any peer (well-known community)\n" | |
10335 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10336 | COMMUNITY_AANN_STR |
718e3744 | 10337 | "Do not send outside local AS (well-known community)\n" |
10338 | "Do not advertise to any peer (well-known community)\n" | |
10339 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10340 | COMMUNITY_AANN_STR |
718e3744 | 10341 | "Do not send outside local AS (well-known community)\n" |
10342 | "Do not advertise to any peer (well-known community)\n" | |
10343 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10344 | COMMUNITY_AANN_STR |
718e3744 | 10345 | "Do not send outside local AS (well-known community)\n" |
10346 | "Do not advertise to any peer (well-known community)\n" | |
10347 | "Do not export to next AS (well-known community)\n") | |
10348 | ||
10349 | /* old command */ | |
10350 | DEFUN (show_ipv6_bgp_community, | |
10351 | show_ipv6_bgp_community_cmd, | |
10352 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
10353 | SHOW_STR | |
10354 | IPV6_STR | |
10355 | BGP_STR | |
10356 | "Display routes matching the communities\n" | |
859d388e | 10357 | COMMUNITY_AANN_STR |
718e3744 | 10358 | "Do not send outside local AS (well-known community)\n" |
10359 | "Do not advertise to any peer (well-known community)\n" | |
10360 | "Do not export to next AS (well-known community)\n") | |
10361 | { | |
47e9b292 | 10362 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10363 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10364 | } |
10365 | ||
10366 | /* old command */ | |
10367 | ALIAS (show_ipv6_bgp_community, | |
10368 | show_ipv6_bgp_community2_cmd, | |
10369 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10370 | SHOW_STR | |
10371 | IPV6_STR | |
10372 | BGP_STR | |
10373 | "Display routes matching the communities\n" | |
859d388e | 10374 | COMMUNITY_AANN_STR |
718e3744 | 10375 | "Do not send outside local AS (well-known community)\n" |
10376 | "Do not advertise to any peer (well-known community)\n" | |
10377 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10378 | COMMUNITY_AANN_STR |
718e3744 | 10379 | "Do not send outside local AS (well-known community)\n" |
10380 | "Do not advertise to any peer (well-known community)\n" | |
10381 | "Do not export to next AS (well-known community)\n") | |
10382 | ||
10383 | /* old command */ | |
10384 | ALIAS (show_ipv6_bgp_community, | |
10385 | show_ipv6_bgp_community3_cmd, | |
10386 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10387 | SHOW_STR | |
10388 | IPV6_STR | |
10389 | BGP_STR | |
10390 | "Display routes matching the communities\n" | |
859d388e | 10391 | COMMUNITY_AANN_STR |
718e3744 | 10392 | "Do not send outside local AS (well-known community)\n" |
10393 | "Do not advertise to any peer (well-known community)\n" | |
10394 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10395 | COMMUNITY_AANN_STR |
718e3744 | 10396 | "Do not send outside local AS (well-known community)\n" |
10397 | "Do not advertise to any peer (well-known community)\n" | |
10398 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10399 | COMMUNITY_AANN_STR |
718e3744 | 10400 | "Do not send outside local AS (well-known community)\n" |
10401 | "Do not advertise to any peer (well-known community)\n" | |
10402 | "Do not export to next AS (well-known community)\n") | |
10403 | ||
10404 | /* old command */ | |
10405 | ALIAS (show_ipv6_bgp_community, | |
10406 | show_ipv6_bgp_community4_cmd, | |
10407 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10408 | SHOW_STR | |
10409 | IPV6_STR | |
10410 | BGP_STR | |
10411 | "Display routes matching the communities\n" | |
859d388e | 10412 | COMMUNITY_AANN_STR |
718e3744 | 10413 | "Do not send outside local AS (well-known community)\n" |
10414 | "Do not advertise to any peer (well-known community)\n" | |
10415 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10416 | COMMUNITY_AANN_STR |
718e3744 | 10417 | "Do not send outside local AS (well-known community)\n" |
10418 | "Do not advertise to any peer (well-known community)\n" | |
10419 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10420 | COMMUNITY_AANN_STR |
718e3744 | 10421 | "Do not send outside local AS (well-known community)\n" |
10422 | "Do not advertise to any peer (well-known community)\n" | |
10423 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10424 | COMMUNITY_AANN_STR |
718e3744 | 10425 | "Do not send outside local AS (well-known community)\n" |
10426 | "Do not advertise to any peer (well-known community)\n" | |
10427 | "Do not export to next AS (well-known community)\n") | |
10428 | ||
10429 | DEFUN (show_bgp_community_exact, | |
10430 | show_bgp_community_exact_cmd, | |
10431 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10432 | SHOW_STR | |
10433 | BGP_STR | |
10434 | "Display routes matching the communities\n" | |
859d388e | 10435 | COMMUNITY_AANN_STR |
718e3744 | 10436 | "Do not send outside local AS (well-known community)\n" |
10437 | "Do not advertise to any peer (well-known community)\n" | |
10438 | "Do not export to next AS (well-known community)\n" | |
10439 | "Exact match of the communities") | |
10440 | { | |
95cbbd2a | 10441 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10442 | } |
10443 | ||
10444 | ALIAS (show_bgp_community_exact, | |
10445 | show_bgp_ipv6_community_exact_cmd, | |
10446 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10447 | SHOW_STR | |
10448 | BGP_STR | |
10449 | "Address family\n" | |
10450 | "Display routes matching the communities\n" | |
859d388e | 10451 | COMMUNITY_AANN_STR |
718e3744 | 10452 | "Do not send outside local AS (well-known community)\n" |
10453 | "Do not advertise to any peer (well-known community)\n" | |
10454 | "Do not export to next AS (well-known community)\n" | |
10455 | "Exact match of the communities") | |
10456 | ||
10457 | ALIAS (show_bgp_community_exact, | |
10458 | show_bgp_community2_exact_cmd, | |
10459 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10460 | SHOW_STR | |
10461 | BGP_STR | |
10462 | "Display routes matching the communities\n" | |
859d388e | 10463 | COMMUNITY_AANN_STR |
718e3744 | 10464 | "Do not send outside local AS (well-known community)\n" |
10465 | "Do not advertise to any peer (well-known community)\n" | |
10466 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10467 | COMMUNITY_AANN_STR |
718e3744 | 10468 | "Do not send outside local AS (well-known community)\n" |
10469 | "Do not advertise to any peer (well-known community)\n" | |
10470 | "Do not export to next AS (well-known community)\n" | |
10471 | "Exact match of the communities") | |
10472 | ||
10473 | ALIAS (show_bgp_community_exact, | |
10474 | show_bgp_ipv6_community2_exact_cmd, | |
10475 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10476 | SHOW_STR | |
10477 | BGP_STR | |
10478 | "Address family\n" | |
10479 | "Display routes matching the communities\n" | |
859d388e | 10480 | COMMUNITY_AANN_STR |
718e3744 | 10481 | "Do not send outside local AS (well-known community)\n" |
10482 | "Do not advertise to any peer (well-known community)\n" | |
10483 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10484 | COMMUNITY_AANN_STR |
718e3744 | 10485 | "Do not send outside local AS (well-known community)\n" |
10486 | "Do not advertise to any peer (well-known community)\n" | |
10487 | "Do not export to next AS (well-known community)\n" | |
10488 | "Exact match of the communities") | |
10489 | ||
10490 | ALIAS (show_bgp_community_exact, | |
10491 | show_bgp_community3_exact_cmd, | |
10492 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10493 | SHOW_STR | |
10494 | BGP_STR | |
10495 | "Display routes matching the communities\n" | |
859d388e | 10496 | COMMUNITY_AANN_STR |
718e3744 | 10497 | "Do not send outside local AS (well-known community)\n" |
10498 | "Do not advertise to any peer (well-known community)\n" | |
10499 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10500 | COMMUNITY_AANN_STR |
718e3744 | 10501 | "Do not send outside local AS (well-known community)\n" |
10502 | "Do not advertise to any peer (well-known community)\n" | |
10503 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10504 | COMMUNITY_AANN_STR |
718e3744 | 10505 | "Do not send outside local AS (well-known community)\n" |
10506 | "Do not advertise to any peer (well-known community)\n" | |
10507 | "Do not export to next AS (well-known community)\n" | |
10508 | "Exact match of the communities") | |
10509 | ||
10510 | ALIAS (show_bgp_community_exact, | |
10511 | show_bgp_ipv6_community3_exact_cmd, | |
10512 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10513 | SHOW_STR | |
10514 | BGP_STR | |
10515 | "Address family\n" | |
10516 | "Display routes matching the communities\n" | |
859d388e | 10517 | COMMUNITY_AANN_STR |
718e3744 | 10518 | "Do not send outside local AS (well-known community)\n" |
10519 | "Do not advertise to any peer (well-known community)\n" | |
10520 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10521 | COMMUNITY_AANN_STR |
718e3744 | 10522 | "Do not send outside local AS (well-known community)\n" |
10523 | "Do not advertise to any peer (well-known community)\n" | |
10524 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10525 | COMMUNITY_AANN_STR |
718e3744 | 10526 | "Do not send outside local AS (well-known community)\n" |
10527 | "Do not advertise to any peer (well-known community)\n" | |
10528 | "Do not export to next AS (well-known community)\n" | |
10529 | "Exact match of the communities") | |
10530 | ||
10531 | ALIAS (show_bgp_community_exact, | |
10532 | show_bgp_community4_exact_cmd, | |
10533 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10534 | SHOW_STR | |
10535 | BGP_STR | |
10536 | "Display routes matching the communities\n" | |
859d388e | 10537 | COMMUNITY_AANN_STR |
718e3744 | 10538 | "Do not send outside local AS (well-known community)\n" |
10539 | "Do not advertise to any peer (well-known community)\n" | |
10540 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10541 | COMMUNITY_AANN_STR |
718e3744 | 10542 | "Do not send outside local AS (well-known community)\n" |
10543 | "Do not advertise to any peer (well-known community)\n" | |
10544 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10545 | COMMUNITY_AANN_STR |
718e3744 | 10546 | "Do not send outside local AS (well-known community)\n" |
10547 | "Do not advertise to any peer (well-known community)\n" | |
10548 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10549 | COMMUNITY_AANN_STR |
718e3744 | 10550 | "Do not send outside local AS (well-known community)\n" |
10551 | "Do not advertise to any peer (well-known community)\n" | |
10552 | "Do not export to next AS (well-known community)\n" | |
10553 | "Exact match of the communities") | |
10554 | ||
10555 | ALIAS (show_bgp_community_exact, | |
10556 | show_bgp_ipv6_community4_exact_cmd, | |
10557 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10558 | SHOW_STR | |
10559 | BGP_STR | |
10560 | "Address family\n" | |
10561 | "Display routes matching the communities\n" | |
859d388e | 10562 | COMMUNITY_AANN_STR |
718e3744 | 10563 | "Do not send outside local AS (well-known community)\n" |
10564 | "Do not advertise to any peer (well-known community)\n" | |
10565 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10566 | COMMUNITY_AANN_STR |
718e3744 | 10567 | "Do not send outside local AS (well-known community)\n" |
10568 | "Do not advertise to any peer (well-known community)\n" | |
10569 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10570 | COMMUNITY_AANN_STR |
718e3744 | 10571 | "Do not send outside local AS (well-known community)\n" |
10572 | "Do not advertise to any peer (well-known community)\n" | |
10573 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10574 | COMMUNITY_AANN_STR |
718e3744 | 10575 | "Do not send outside local AS (well-known community)\n" |
10576 | "Do not advertise to any peer (well-known community)\n" | |
10577 | "Do not export to next AS (well-known community)\n" | |
10578 | "Exact match of the communities") | |
10579 | ||
10580 | /* old command */ | |
10581 | DEFUN (show_ipv6_bgp_community_exact, | |
10582 | show_ipv6_bgp_community_exact_cmd, | |
10583 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10584 | SHOW_STR | |
10585 | IPV6_STR | |
10586 | BGP_STR | |
10587 | "Display routes matching the communities\n" | |
859d388e | 10588 | COMMUNITY_AANN_STR |
718e3744 | 10589 | "Do not send outside local AS (well-known community)\n" |
10590 | "Do not advertise to any peer (well-known community)\n" | |
10591 | "Do not export to next AS (well-known community)\n" | |
10592 | "Exact match of the communities") | |
10593 | { | |
47e9b292 | 10594 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10595 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10596 | } |
10597 | ||
10598 | /* old command */ | |
10599 | ALIAS (show_ipv6_bgp_community_exact, | |
10600 | show_ipv6_bgp_community2_exact_cmd, | |
10601 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10602 | SHOW_STR | |
10603 | IPV6_STR | |
10604 | BGP_STR | |
10605 | "Display routes matching the communities\n" | |
859d388e | 10606 | COMMUNITY_AANN_STR |
718e3744 | 10607 | "Do not send outside local AS (well-known community)\n" |
10608 | "Do not advertise to any peer (well-known community)\n" | |
10609 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10610 | COMMUNITY_AANN_STR |
718e3744 | 10611 | "Do not send outside local AS (well-known community)\n" |
10612 | "Do not advertise to any peer (well-known community)\n" | |
10613 | "Do not export to next AS (well-known community)\n" | |
10614 | "Exact match of the communities") | |
10615 | ||
10616 | /* old command */ | |
10617 | ALIAS (show_ipv6_bgp_community_exact, | |
10618 | show_ipv6_bgp_community3_exact_cmd, | |
10619 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10620 | SHOW_STR | |
10621 | IPV6_STR | |
10622 | BGP_STR | |
10623 | "Display routes matching the communities\n" | |
859d388e | 10624 | COMMUNITY_AANN_STR |
718e3744 | 10625 | "Do not send outside local AS (well-known community)\n" |
10626 | "Do not advertise to any peer (well-known community)\n" | |
10627 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10628 | COMMUNITY_AANN_STR |
718e3744 | 10629 | "Do not send outside local AS (well-known community)\n" |
10630 | "Do not advertise to any peer (well-known community)\n" | |
10631 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10632 | COMMUNITY_AANN_STR |
718e3744 | 10633 | "Do not send outside local AS (well-known community)\n" |
10634 | "Do not advertise to any peer (well-known community)\n" | |
10635 | "Do not export to next AS (well-known community)\n" | |
10636 | "Exact match of the communities") | |
10637 | ||
10638 | /* old command */ | |
10639 | ALIAS (show_ipv6_bgp_community_exact, | |
10640 | show_ipv6_bgp_community4_exact_cmd, | |
10641 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10642 | SHOW_STR | |
10643 | IPV6_STR | |
10644 | BGP_STR | |
10645 | "Display routes matching the communities\n" | |
859d388e | 10646 | COMMUNITY_AANN_STR |
718e3744 | 10647 | "Do not send outside local AS (well-known community)\n" |
10648 | "Do not advertise to any peer (well-known community)\n" | |
10649 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10650 | COMMUNITY_AANN_STR |
718e3744 | 10651 | "Do not send outside local AS (well-known community)\n" |
10652 | "Do not advertise to any peer (well-known community)\n" | |
10653 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10654 | COMMUNITY_AANN_STR |
718e3744 | 10655 | "Do not send outside local AS (well-known community)\n" |
10656 | "Do not advertise to any peer (well-known community)\n" | |
10657 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10658 | COMMUNITY_AANN_STR |
718e3744 | 10659 | "Do not send outside local AS (well-known community)\n" |
10660 | "Do not advertise to any peer (well-known community)\n" | |
10661 | "Do not export to next AS (well-known community)\n" | |
10662 | "Exact match of the communities") | |
10663 | ||
10664 | /* old command */ | |
10665 | DEFUN (show_ipv6_mbgp_community, | |
10666 | show_ipv6_mbgp_community_cmd, | |
10667 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", | |
10668 | SHOW_STR | |
10669 | IPV6_STR | |
10670 | MBGP_STR | |
10671 | "Display routes matching the communities\n" | |
859d388e | 10672 | COMMUNITY_AANN_STR |
718e3744 | 10673 | "Do not send outside local AS (well-known community)\n" |
10674 | "Do not advertise to any peer (well-known community)\n" | |
10675 | "Do not export to next AS (well-known community)\n") | |
10676 | { | |
47e9b292 | 10677 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10678 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10679 | } |
10680 | ||
10681 | /* old command */ | |
10682 | ALIAS (show_ipv6_mbgp_community, | |
10683 | show_ipv6_mbgp_community2_cmd, | |
10684 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10685 | SHOW_STR | |
10686 | IPV6_STR | |
10687 | MBGP_STR | |
10688 | "Display routes matching the communities\n" | |
859d388e | 10689 | COMMUNITY_AANN_STR |
718e3744 | 10690 | "Do not send outside local AS (well-known community)\n" |
10691 | "Do not advertise to any peer (well-known community)\n" | |
10692 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10693 | COMMUNITY_AANN_STR |
718e3744 | 10694 | "Do not send outside local AS (well-known community)\n" |
10695 | "Do not advertise to any peer (well-known community)\n" | |
10696 | "Do not export to next AS (well-known community)\n") | |
10697 | ||
10698 | /* old command */ | |
10699 | ALIAS (show_ipv6_mbgp_community, | |
10700 | show_ipv6_mbgp_community3_cmd, | |
10701 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10702 | SHOW_STR | |
10703 | IPV6_STR | |
10704 | MBGP_STR | |
10705 | "Display routes matching the communities\n" | |
859d388e | 10706 | COMMUNITY_AANN_STR |
718e3744 | 10707 | "Do not send outside local AS (well-known community)\n" |
10708 | "Do not advertise to any peer (well-known community)\n" | |
10709 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10710 | COMMUNITY_AANN_STR |
718e3744 | 10711 | "Do not send outside local AS (well-known community)\n" |
10712 | "Do not advertise to any peer (well-known community)\n" | |
10713 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10714 | COMMUNITY_AANN_STR |
718e3744 | 10715 | "Do not send outside local AS (well-known community)\n" |
10716 | "Do not advertise to any peer (well-known community)\n" | |
10717 | "Do not export to next AS (well-known community)\n") | |
10718 | ||
10719 | /* old command */ | |
10720 | ALIAS (show_ipv6_mbgp_community, | |
10721 | show_ipv6_mbgp_community4_cmd, | |
10722 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10723 | SHOW_STR | |
10724 | IPV6_STR | |
10725 | MBGP_STR | |
10726 | "Display routes matching the communities\n" | |
859d388e | 10727 | COMMUNITY_AANN_STR |
718e3744 | 10728 | "Do not send outside local AS (well-known community)\n" |
10729 | "Do not advertise to any peer (well-known community)\n" | |
10730 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10731 | COMMUNITY_AANN_STR |
718e3744 | 10732 | "Do not send outside local AS (well-known community)\n" |
10733 | "Do not advertise to any peer (well-known community)\n" | |
10734 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10735 | COMMUNITY_AANN_STR |
718e3744 | 10736 | "Do not send outside local AS (well-known community)\n" |
10737 | "Do not advertise to any peer (well-known community)\n" | |
10738 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10739 | COMMUNITY_AANN_STR |
718e3744 | 10740 | "Do not send outside local AS (well-known community)\n" |
10741 | "Do not advertise to any peer (well-known community)\n" | |
10742 | "Do not export to next AS (well-known community)\n") | |
10743 | ||
10744 | /* old command */ | |
10745 | DEFUN (show_ipv6_mbgp_community_exact, | |
10746 | show_ipv6_mbgp_community_exact_cmd, | |
10747 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10748 | SHOW_STR | |
10749 | IPV6_STR | |
10750 | MBGP_STR | |
10751 | "Display routes matching the communities\n" | |
859d388e | 10752 | COMMUNITY_AANN_STR |
718e3744 | 10753 | "Do not send outside local AS (well-known community)\n" |
10754 | "Do not advertise to any peer (well-known community)\n" | |
10755 | "Do not export to next AS (well-known community)\n" | |
10756 | "Exact match of the communities") | |
10757 | { | |
47e9b292 | 10758 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10759 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10760 | } |
10761 | ||
10762 | /* old command */ | |
10763 | ALIAS (show_ipv6_mbgp_community_exact, | |
10764 | show_ipv6_mbgp_community2_exact_cmd, | |
10765 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10766 | SHOW_STR | |
10767 | IPV6_STR | |
10768 | MBGP_STR | |
10769 | "Display routes matching the communities\n" | |
859d388e | 10770 | COMMUNITY_AANN_STR |
718e3744 | 10771 | "Do not send outside local AS (well-known community)\n" |
10772 | "Do not advertise to any peer (well-known community)\n" | |
10773 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10774 | COMMUNITY_AANN_STR |
718e3744 | 10775 | "Do not send outside local AS (well-known community)\n" |
10776 | "Do not advertise to any peer (well-known community)\n" | |
10777 | "Do not export to next AS (well-known community)\n" | |
10778 | "Exact match of the communities") | |
10779 | ||
10780 | /* old command */ | |
10781 | ALIAS (show_ipv6_mbgp_community_exact, | |
10782 | show_ipv6_mbgp_community3_exact_cmd, | |
10783 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10784 | SHOW_STR | |
10785 | IPV6_STR | |
10786 | MBGP_STR | |
10787 | "Display routes matching the communities\n" | |
859d388e | 10788 | COMMUNITY_AANN_STR |
718e3744 | 10789 | "Do not send outside local AS (well-known community)\n" |
10790 | "Do not advertise to any peer (well-known community)\n" | |
10791 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10792 | COMMUNITY_AANN_STR |
718e3744 | 10793 | "Do not send outside local AS (well-known community)\n" |
10794 | "Do not advertise to any peer (well-known community)\n" | |
10795 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10796 | COMMUNITY_AANN_STR |
718e3744 | 10797 | "Do not send outside local AS (well-known community)\n" |
10798 | "Do not advertise to any peer (well-known community)\n" | |
10799 | "Do not export to next AS (well-known community)\n" | |
10800 | "Exact match of the communities") | |
10801 | ||
10802 | /* old command */ | |
10803 | ALIAS (show_ipv6_mbgp_community_exact, | |
10804 | show_ipv6_mbgp_community4_exact_cmd, | |
10805 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10806 | SHOW_STR | |
10807 | IPV6_STR | |
10808 | MBGP_STR | |
10809 | "Display routes matching the communities\n" | |
859d388e | 10810 | COMMUNITY_AANN_STR |
718e3744 | 10811 | "Do not send outside local AS (well-known community)\n" |
10812 | "Do not advertise to any peer (well-known community)\n" | |
10813 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10814 | COMMUNITY_AANN_STR |
718e3744 | 10815 | "Do not send outside local AS (well-known community)\n" |
10816 | "Do not advertise to any peer (well-known community)\n" | |
10817 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10818 | COMMUNITY_AANN_STR |
718e3744 | 10819 | "Do not send outside local AS (well-known community)\n" |
10820 | "Do not advertise to any peer (well-known community)\n" | |
10821 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10822 | COMMUNITY_AANN_STR |
718e3744 | 10823 | "Do not send outside local AS (well-known community)\n" |
10824 | "Do not advertise to any peer (well-known community)\n" | |
10825 | "Do not export to next AS (well-known community)\n" | |
10826 | "Exact match of the communities") | |
10827 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 10828 | |
94f2b392 | 10829 | static int |
50ef26d4 | 10830 | bgp_show_community_list (struct vty *vty, const char *name, |
10831 | const char *com, int exact, | |
4c9641ba | 10832 | afi_t afi, safi_t safi) |
718e3744 | 10833 | { |
10834 | struct community_list *list; | |
50ef26d4 | 10835 | struct bgp *bgp = NULL; |
10836 | ||
10837 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
10838 | { | |
10839 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
10840 | return CMD_WARNING; | |
10841 | } | |
718e3744 | 10842 | |
fee6e4e4 | 10843 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
718e3744 | 10844 | if (list == NULL) |
10845 | { | |
10846 | vty_out (vty, "%% %s is not a valid community-list name%s", com, | |
10847 | VTY_NEWLINE); | |
10848 | return CMD_WARNING; | |
10849 | } | |
10850 | ||
50ef26d4 | 10851 | return bgp_show (vty, bgp, afi, safi, |
5a646650 | 10852 | (exact ? bgp_show_type_community_list_exact : |
b05a1c8b | 10853 | bgp_show_type_community_list), list, 0); |
718e3744 | 10854 | } |
10855 | ||
10856 | DEFUN (show_ip_bgp_community_list, | |
10857 | show_ip_bgp_community_list_cmd, | |
fee6e4e4 | 10858 | "show ip bgp community-list (<1-500>|WORD)", |
718e3744 | 10859 | SHOW_STR |
10860 | IP_STR | |
10861 | BGP_STR | |
10862 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10863 | "community-list number\n" |
718e3744 | 10864 | "community-list name\n") |
10865 | { | |
50ef26d4 | 10866 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP, SAFI_UNICAST); |
10867 | } | |
10868 | ||
8386ac43 | 10869 | DEFUN (show_ip_bgp_instance_community_list, |
10870 | show_ip_bgp_instance_community_list_cmd, | |
10871 | "show ip bgp " BGP_INSTANCE_CMD " community-list (<1-500>|WORD)", | |
50ef26d4 | 10872 | SHOW_STR |
10873 | IP_STR | |
10874 | BGP_STR | |
8386ac43 | 10875 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 10876 | "Display routes matching the community-list\n" |
10877 | "community-list number\n" | |
10878 | "community-list name\n") | |
10879 | { | |
10880 | return bgp_show_community_list (vty, argv[1], argv[2], 0, AFI_IP, SAFI_UNICAST); | |
718e3744 | 10881 | } |
10882 | ||
10883 | DEFUN (show_ip_bgp_ipv4_community_list, | |
10884 | show_ip_bgp_ipv4_community_list_cmd, | |
fee6e4e4 | 10885 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
718e3744 | 10886 | SHOW_STR |
10887 | IP_STR | |
10888 | BGP_STR | |
10889 | "Address family\n" | |
10890 | "Address Family modifier\n" | |
10891 | "Address Family modifier\n" | |
10892 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10893 | "community-list number\n" |
718e3744 | 10894 | "community-list name\n") |
10895 | { | |
10896 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 10897 | return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
718e3744 | 10898 | |
50ef26d4 | 10899 | return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 10900 | } |
10901 | ||
10902 | DEFUN (show_ip_bgp_community_list_exact, | |
10903 | show_ip_bgp_community_list_exact_cmd, | |
fee6e4e4 | 10904 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 10905 | SHOW_STR |
10906 | IP_STR | |
10907 | BGP_STR | |
10908 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10909 | "community-list number\n" |
718e3744 | 10910 | "community-list name\n" |
10911 | "Exact match of the communities\n") | |
10912 | { | |
50ef26d4 | 10913 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10914 | } |
10915 | ||
10916 | DEFUN (show_ip_bgp_ipv4_community_list_exact, | |
10917 | show_ip_bgp_ipv4_community_list_exact_cmd, | |
fee6e4e4 | 10918 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
718e3744 | 10919 | SHOW_STR |
10920 | IP_STR | |
10921 | BGP_STR | |
10922 | "Address family\n" | |
10923 | "Address Family modifier\n" | |
10924 | "Address Family modifier\n" | |
10925 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10926 | "community-list number\n" |
718e3744 | 10927 | "community-list name\n" |
10928 | "Exact match of the communities\n") | |
10929 | { | |
10930 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 10931 | return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
718e3744 | 10932 | |
50ef26d4 | 10933 | return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10934 | } |
10935 | ||
10936 | #ifdef HAVE_IPV6 | |
10937 | DEFUN (show_bgp_community_list, | |
10938 | show_bgp_community_list_cmd, | |
fee6e4e4 | 10939 | "show bgp community-list (<1-500>|WORD)", |
718e3744 | 10940 | SHOW_STR |
10941 | BGP_STR | |
10942 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10943 | "community-list number\n" |
718e3744 | 10944 | "community-list name\n") |
10945 | { | |
50ef26d4 | 10946 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10947 | } |
10948 | ||
10949 | ALIAS (show_bgp_community_list, | |
10950 | show_bgp_ipv6_community_list_cmd, | |
fee6e4e4 | 10951 | "show bgp ipv6 community-list (<1-500>|WORD)", |
718e3744 | 10952 | SHOW_STR |
10953 | BGP_STR | |
10954 | "Address family\n" | |
10955 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10956 | "community-list number\n" |
e8e1946e | 10957 | "community-list name\n") |
718e3744 | 10958 | |
10959 | /* old command */ | |
10960 | DEFUN (show_ipv6_bgp_community_list, | |
10961 | show_ipv6_bgp_community_list_cmd, | |
10962 | "show ipv6 bgp community-list WORD", | |
10963 | SHOW_STR | |
10964 | IPV6_STR | |
10965 | BGP_STR | |
10966 | "Display routes matching the community-list\n" | |
10967 | "community-list name\n") | |
10968 | { | |
47e9b292 | 10969 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10970 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10971 | } |
10972 | ||
10973 | /* old command */ | |
10974 | DEFUN (show_ipv6_mbgp_community_list, | |
10975 | show_ipv6_mbgp_community_list_cmd, | |
10976 | "show ipv6 mbgp community-list WORD", | |
10977 | SHOW_STR | |
10978 | IPV6_STR | |
10979 | MBGP_STR | |
10980 | "Display routes matching the community-list\n" | |
10981 | "community-list name\n") | |
10982 | { | |
47e9b292 | 10983 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10984 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10985 | } |
10986 | ||
10987 | DEFUN (show_bgp_community_list_exact, | |
10988 | show_bgp_community_list_exact_cmd, | |
fee6e4e4 | 10989 | "show bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 10990 | SHOW_STR |
10991 | BGP_STR | |
10992 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10993 | "community-list number\n" |
718e3744 | 10994 | "community-list name\n" |
10995 | "Exact match of the communities\n") | |
10996 | { | |
50ef26d4 | 10997 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10998 | } |
10999 | ||
11000 | ALIAS (show_bgp_community_list_exact, | |
11001 | show_bgp_ipv6_community_list_exact_cmd, | |
fee6e4e4 | 11002 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
718e3744 | 11003 | SHOW_STR |
11004 | BGP_STR | |
11005 | "Address family\n" | |
11006 | "Display routes matching the community-list\n" | |
fee6e4e4 | 11007 | "community-list number\n" |
718e3744 | 11008 | "community-list name\n" |
11009 | "Exact match of the communities\n") | |
11010 | ||
11011 | /* old command */ | |
11012 | DEFUN (show_ipv6_bgp_community_list_exact, | |
11013 | show_ipv6_bgp_community_list_exact_cmd, | |
11014 | "show ipv6 bgp community-list WORD exact-match", | |
11015 | SHOW_STR | |
11016 | IPV6_STR | |
11017 | BGP_STR | |
11018 | "Display routes matching the community-list\n" | |
11019 | "community-list name\n" | |
11020 | "Exact match of the communities\n") | |
11021 | { | |
47e9b292 | 11022 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 11023 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 11024 | } |
11025 | ||
11026 | /* old command */ | |
11027 | DEFUN (show_ipv6_mbgp_community_list_exact, | |
11028 | show_ipv6_mbgp_community_list_exact_cmd, | |
11029 | "show ipv6 mbgp community-list WORD exact-match", | |
11030 | SHOW_STR | |
11031 | IPV6_STR | |
11032 | MBGP_STR | |
11033 | "Display routes matching the community-list\n" | |
11034 | "community-list name\n" | |
11035 | "Exact match of the communities\n") | |
11036 | { | |
47e9b292 | 11037 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 11038 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 11039 | } |
11040 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 11041 | |
94f2b392 | 11042 | static int |
50ef26d4 | 11043 | bgp_show_prefix_longer (struct vty *vty, const char *name, |
11044 | const char *prefix, afi_t afi, | |
718e3744 | 11045 | safi_t safi, enum bgp_show_type type) |
11046 | { | |
11047 | int ret; | |
11048 | struct prefix *p; | |
50ef26d4 | 11049 | struct bgp *bgp = NULL; |
11050 | ||
11051 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
11052 | { | |
11053 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
11054 | return CMD_WARNING; | |
11055 | } | |
718e3744 | 11056 | |
11057 | p = prefix_new(); | |
11058 | ||
11059 | ret = str2prefix (prefix, p); | |
11060 | if (! ret) | |
11061 | { | |
11062 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); | |
11063 | return CMD_WARNING; | |
11064 | } | |
11065 | ||
50ef26d4 | 11066 | ret = bgp_show (vty, bgp, afi, safi, type, p, 0); |
5a646650 | 11067 | prefix_free(p); |
11068 | return ret; | |
718e3744 | 11069 | } |
11070 | ||
11071 | DEFUN (show_ip_bgp_prefix_longer, | |
11072 | show_ip_bgp_prefix_longer_cmd, | |
11073 | "show ip bgp A.B.C.D/M longer-prefixes", | |
11074 | SHOW_STR | |
11075 | IP_STR | |
11076 | BGP_STR | |
11077 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
11078 | "Display route and more specific routes\n") | |
11079 | { | |
50ef26d4 | 11080 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
11081 | bgp_show_type_prefix_longer); | |
11082 | } | |
11083 | ||
8386ac43 | 11084 | DEFUN (show_ip_bgp_instance_prefix_longer, |
11085 | show_ip_bgp_instance_prefix_longer_cmd, | |
11086 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M longer-prefixes", | |
50ef26d4 | 11087 | SHOW_STR |
11088 | IP_STR | |
11089 | BGP_STR | |
8386ac43 | 11090 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 11091 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
11092 | "Display route and more specific routes\n") | |
11093 | { | |
11094 | return bgp_show_prefix_longer (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 11095 | bgp_show_type_prefix_longer); |
11096 | } | |
11097 | ||
11098 | DEFUN (show_ip_bgp_flap_prefix_longer, | |
11099 | show_ip_bgp_flap_prefix_longer_cmd, | |
11100 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", | |
11101 | SHOW_STR | |
11102 | IP_STR | |
11103 | BGP_STR | |
11104 | "Display flap statistics of routes\n" | |
11105 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
11106 | "Display route and more specific routes\n") | |
11107 | { | |
50ef26d4 | 11108 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 11109 | bgp_show_type_flap_prefix_longer); |
11110 | } | |
11111 | ||
81304aaf B |
11112 | ALIAS (show_ip_bgp_flap_prefix_longer, |
11113 | show_ip_bgp_damp_flap_prefix_longer_cmd, | |
11114 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", | |
11115 | SHOW_STR | |
11116 | IP_STR | |
11117 | BGP_STR | |
11118 | "Display detailed information about dampening\n" | |
11119 | "Display flap statistics of routes\n" | |
11120 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
11121 | "Display route and more specific routes\n") | |
11122 | ||
718e3744 | 11123 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
11124 | show_ip_bgp_ipv4_prefix_longer_cmd, | |
11125 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", | |
11126 | SHOW_STR | |
11127 | IP_STR | |
11128 | BGP_STR | |
11129 | "Address family\n" | |
11130 | "Address Family modifier\n" | |
11131 | "Address Family modifier\n" | |
11132 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
11133 | "Display route and more specific routes\n") | |
11134 | { | |
11135 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 11136 | return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 11137 | bgp_show_type_prefix_longer); |
11138 | ||
50ef26d4 | 11139 | return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 11140 | bgp_show_type_prefix_longer); |
11141 | } | |
11142 | ||
11143 | DEFUN (show_ip_bgp_flap_address, | |
11144 | show_ip_bgp_flap_address_cmd, | |
11145 | "show ip bgp flap-statistics A.B.C.D", | |
11146 | SHOW_STR | |
11147 | IP_STR | |
11148 | BGP_STR | |
11149 | "Display flap statistics of routes\n" | |
11150 | "Network in the BGP routing table to display\n") | |
11151 | { | |
50ef26d4 | 11152 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 11153 | bgp_show_type_flap_address); |
11154 | } | |
11155 | ||
81304aaf B |
11156 | ALIAS (show_ip_bgp_flap_address, |
11157 | show_ip_bgp_damp_flap_address_cmd, | |
11158 | "show ip bgp dampening flap-statistics A.B.C.D", | |
11159 | SHOW_STR | |
11160 | IP_STR | |
11161 | BGP_STR | |
11162 | "Display detailed information about dampening\n" | |
11163 | "Display flap statistics of routes\n" | |
11164 | "Network in the BGP routing table to display\n") | |
11165 | ||
718e3744 | 11166 | DEFUN (show_ip_bgp_flap_prefix, |
11167 | show_ip_bgp_flap_prefix_cmd, | |
11168 | "show ip bgp flap-statistics A.B.C.D/M", | |
11169 | SHOW_STR | |
11170 | IP_STR | |
11171 | BGP_STR | |
11172 | "Display flap statistics of routes\n" | |
11173 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
11174 | { | |
50ef26d4 | 11175 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 11176 | bgp_show_type_flap_prefix); |
11177 | } | |
81304aaf B |
11178 | |
11179 | ALIAS (show_ip_bgp_flap_prefix, | |
11180 | show_ip_bgp_damp_flap_prefix_cmd, | |
11181 | "show ip bgp dampening flap-statistics A.B.C.D/M", | |
11182 | SHOW_STR | |
11183 | IP_STR | |
11184 | BGP_STR | |
11185 | "Display detailed information about dampening\n" | |
11186 | "Display flap statistics of routes\n" | |
11187 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
11188 | ||
718e3744 | 11189 | #ifdef HAVE_IPV6 |
11190 | DEFUN (show_bgp_prefix_longer, | |
11191 | show_bgp_prefix_longer_cmd, | |
11192 | "show bgp X:X::X:X/M longer-prefixes", | |
11193 | SHOW_STR | |
11194 | BGP_STR | |
11195 | "IPv6 prefix <network>/<length>\n" | |
11196 | "Display route and more specific routes\n") | |
11197 | { | |
50ef26d4 | 11198 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 11199 | bgp_show_type_prefix_longer); |
11200 | } | |
11201 | ||
11202 | ALIAS (show_bgp_prefix_longer, | |
11203 | show_bgp_ipv6_prefix_longer_cmd, | |
11204 | "show bgp ipv6 X:X::X:X/M longer-prefixes", | |
11205 | SHOW_STR | |
11206 | BGP_STR | |
11207 | "Address family\n" | |
11208 | "IPv6 prefix <network>/<length>\n" | |
11209 | "Display route and more specific routes\n") | |
11210 | ||
11211 | /* old command */ | |
11212 | DEFUN (show_ipv6_bgp_prefix_longer, | |
11213 | show_ipv6_bgp_prefix_longer_cmd, | |
11214 | "show ipv6 bgp X:X::X:X/M longer-prefixes", | |
11215 | SHOW_STR | |
11216 | IPV6_STR | |
11217 | BGP_STR | |
11218 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
11219 | "Display route and more specific routes\n") | |
11220 | { | |
47e9b292 | 11221 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 11222 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 11223 | bgp_show_type_prefix_longer); |
11224 | } | |
11225 | ||
11226 | /* old command */ | |
11227 | DEFUN (show_ipv6_mbgp_prefix_longer, | |
11228 | show_ipv6_mbgp_prefix_longer_cmd, | |
11229 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", | |
11230 | SHOW_STR | |
11231 | IPV6_STR | |
11232 | MBGP_STR | |
11233 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
11234 | "Display route and more specific routes\n") | |
11235 | { | |
47e9b292 | 11236 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 11237 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, |
718e3744 | 11238 | bgp_show_type_prefix_longer); |
11239 | } | |
11240 | #endif /* HAVE_IPV6 */ | |
bb46e94f | 11241 | |
94f2b392 | 11242 | static struct peer * |
fd79ac91 | 11243 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
856ca177 | 11244 | const char *ip_str, u_char use_json) |
bb46e94f | 11245 | { |
11246 | int ret; | |
11247 | struct bgp *bgp; | |
11248 | struct peer *peer; | |
11249 | union sockunion su; | |
11250 | ||
11251 | /* BGP structure lookup. */ | |
11252 | if (view_name) | |
11253 | { | |
11254 | bgp = bgp_lookup_by_name (view_name); | |
11255 | if (! bgp) | |
11256 | { | |
856ca177 MS |
11257 | if (use_json) |
11258 | { | |
11259 | json_object *json_no = NULL; | |
11260 | json_no = json_object_new_object(); | |
11261 | json_object_string_add(json_no, "warning", "Can't find BGP view"); | |
11262 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
11263 | json_object_free(json_no); | |
11264 | } | |
11265 | else | |
6aeb9e78 | 11266 | vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
bb46e94f | 11267 | return NULL; |
11268 | } | |
11269 | } | |
5228ad27 | 11270 | else |
bb46e94f | 11271 | { |
11272 | bgp = bgp_get_default (); | |
11273 | if (! bgp) | |
11274 | { | |
856ca177 MS |
11275 | if (use_json) |
11276 | { | |
11277 | json_object *json_no = NULL; | |
11278 | json_no = json_object_new_object(); | |
11279 | json_object_string_add(json_no, "warning", "No BGP process configured"); | |
11280 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
11281 | json_object_free(json_no); | |
11282 | } | |
11283 | else | |
11284 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
bb46e94f | 11285 | return NULL; |
11286 | } | |
11287 | } | |
11288 | ||
11289 | /* Get peer sockunion. */ | |
11290 | ret = str2sockunion (ip_str, &su); | |
11291 | if (ret < 0) | |
11292 | { | |
a80beece DS |
11293 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
11294 | if (!peer) | |
11295 | { | |
04b6bdc0 DW |
11296 | peer = peer_lookup_by_hostname(bgp, ip_str); |
11297 | ||
11298 | if (!peer) | |
856ca177 | 11299 | { |
04b6bdc0 DW |
11300 | if (use_json) |
11301 | { | |
11302 | json_object *json_no = NULL; | |
11303 | json_no = json_object_new_object(); | |
11304 | json_object_string_add(json_no, "malformedAddressOrName", ip_str); | |
11305 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
11306 | json_object_free(json_no); | |
11307 | } | |
11308 | else | |
11309 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
11310 | return NULL; | |
856ca177 | 11311 | } |
a80beece DS |
11312 | } |
11313 | return peer; | |
bb46e94f | 11314 | } |
11315 | ||
11316 | /* Peer structure lookup. */ | |
11317 | peer = peer_lookup (bgp, &su); | |
11318 | if (! peer) | |
11319 | { | |
856ca177 MS |
11320 | if (use_json) |
11321 | { | |
11322 | json_object *json_no = NULL; | |
11323 | json_no = json_object_new_object(); | |
11324 | json_object_string_add(json_no, "warning","No such neighbor"); | |
11325 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
11326 | json_object_free(json_no); | |
11327 | } | |
11328 | else | |
11329 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); | |
bb46e94f | 11330 | return NULL; |
11331 | } | |
11332 | ||
11333 | return peer; | |
11334 | } | |
6b0655a2 | 11335 | |
2815e61f PJ |
11336 | enum bgp_stats |
11337 | { | |
11338 | BGP_STATS_MAXBITLEN = 0, | |
11339 | BGP_STATS_RIB, | |
11340 | BGP_STATS_PREFIXES, | |
11341 | BGP_STATS_TOTPLEN, | |
11342 | BGP_STATS_UNAGGREGATEABLE, | |
11343 | BGP_STATS_MAX_AGGREGATEABLE, | |
11344 | BGP_STATS_AGGREGATES, | |
11345 | BGP_STATS_SPACE, | |
11346 | BGP_STATS_ASPATH_COUNT, | |
11347 | BGP_STATS_ASPATH_MAXHOPS, | |
11348 | BGP_STATS_ASPATH_TOTHOPS, | |
11349 | BGP_STATS_ASPATH_MAXSIZE, | |
11350 | BGP_STATS_ASPATH_TOTSIZE, | |
11351 | BGP_STATS_ASN_HIGHEST, | |
11352 | BGP_STATS_MAX, | |
11353 | }; | |
11354 | ||
11355 | static const char *table_stats_strs[] = | |
11356 | { | |
11357 | [BGP_STATS_PREFIXES] = "Total Prefixes", | |
11358 | [BGP_STATS_TOTPLEN] = "Average prefix length", | |
11359 | [BGP_STATS_RIB] = "Total Advertisements", | |
11360 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", | |
11361 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", | |
11362 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", | |
11363 | [BGP_STATS_SPACE] = "Address space advertised", | |
11364 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", | |
11365 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", | |
11366 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", | |
11367 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", | |
11368 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", | |
11369 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", | |
11370 | [BGP_STATS_MAX] = NULL, | |
11371 | }; | |
11372 | ||
11373 | struct bgp_table_stats | |
11374 | { | |
11375 | struct bgp_table *table; | |
11376 | unsigned long long counts[BGP_STATS_MAX]; | |
11377 | }; | |
11378 | ||
11379 | #if 0 | |
11380 | #define TALLY_SIGFIG 100000 | |
11381 | static unsigned long | |
11382 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) | |
11383 | { | |
11384 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); | |
11385 | unsigned long res = (newtot * TALLY_SIGFIG) / count; | |
11386 | unsigned long ret = newtot / count; | |
11387 | ||
11388 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) | |
11389 | return ret + 1; | |
11390 | else | |
11391 | return ret; | |
11392 | } | |
11393 | #endif | |
11394 | ||
11395 | static int | |
11396 | bgp_table_stats_walker (struct thread *t) | |
11397 | { | |
11398 | struct bgp_node *rn; | |
11399 | struct bgp_node *top; | |
11400 | struct bgp_table_stats *ts = THREAD_ARG (t); | |
11401 | unsigned int space = 0; | |
11402 | ||
53d9f67a PJ |
11403 | if (!(top = bgp_table_top (ts->table))) |
11404 | return 0; | |
2815e61f PJ |
11405 | |
11406 | switch (top->p.family) | |
11407 | { | |
11408 | case AF_INET: | |
11409 | space = IPV4_MAX_BITLEN; | |
11410 | break; | |
11411 | case AF_INET6: | |
11412 | space = IPV6_MAX_BITLEN; | |
11413 | break; | |
11414 | } | |
11415 | ||
11416 | ts->counts[BGP_STATS_MAXBITLEN] = space; | |
11417 | ||
11418 | for (rn = top; rn; rn = bgp_route_next (rn)) | |
11419 | { | |
11420 | struct bgp_info *ri; | |
67174041 | 11421 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
2815e61f PJ |
11422 | unsigned int rinum = 0; |
11423 | ||
11424 | if (rn == top) | |
11425 | continue; | |
11426 | ||
11427 | if (!rn->info) | |
11428 | continue; | |
11429 | ||
11430 | ts->counts[BGP_STATS_PREFIXES]++; | |
11431 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; | |
11432 | ||
11433 | #if 0 | |
11434 | ts->counts[BGP_STATS_AVGPLEN] | |
11435 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], | |
11436 | ts->counts[BGP_STATS_AVGPLEN], | |
11437 | rn->p.prefixlen); | |
11438 | #endif | |
11439 | ||
11440 | /* check if the prefix is included by any other announcements */ | |
11441 | while (prn && !prn->info) | |
67174041 | 11442 | prn = bgp_node_parent_nolock (prn); |
2815e61f PJ |
11443 | |
11444 | if (prn == NULL || prn == top) | |
8383a9bd PJ |
11445 | { |
11446 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; | |
11447 | /* announced address space */ | |
11448 | if (space) | |
11449 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); | |
11450 | } | |
2815e61f PJ |
11451 | else if (prn->info) |
11452 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; | |
11453 | ||
2815e61f PJ |
11454 | for (ri = rn->info; ri; ri = ri->next) |
11455 | { | |
11456 | rinum++; | |
11457 | ts->counts[BGP_STATS_RIB]++; | |
11458 | ||
11459 | if (ri->attr && | |
11460 | (CHECK_FLAG (ri->attr->flag, | |
11461 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) | |
11462 | ts->counts[BGP_STATS_AGGREGATES]++; | |
11463 | ||
11464 | /* as-path stats */ | |
11465 | if (ri->attr && ri->attr->aspath) | |
11466 | { | |
11467 | unsigned int hops = aspath_count_hops (ri->attr->aspath); | |
11468 | unsigned int size = aspath_size (ri->attr->aspath); | |
11469 | as_t highest = aspath_highest (ri->attr->aspath); | |
11470 | ||
11471 | ts->counts[BGP_STATS_ASPATH_COUNT]++; | |
11472 | ||
11473 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) | |
11474 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; | |
11475 | ||
11476 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) | |
11477 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; | |
11478 | ||
11479 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; | |
11480 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; | |
11481 | #if 0 | |
11482 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] | |
11483 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
11484 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], | |
11485 | hops); | |
11486 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] | |
11487 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
11488 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], | |
11489 | size); | |
11490 | #endif | |
11491 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) | |
11492 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; | |
11493 | } | |
11494 | } | |
11495 | } | |
11496 | return 0; | |
11497 | } | |
11498 | ||
11499 | static int | |
11500 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) | |
11501 | { | |
11502 | struct bgp_table_stats ts; | |
11503 | unsigned int i; | |
11504 | ||
11505 | if (!bgp->rib[afi][safi]) | |
11506 | { | |
06da0daf DS |
11507 | vty_out (vty, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s", |
11508 | afi, safi, VTY_NEWLINE); | |
2815e61f PJ |
11509 | return CMD_WARNING; |
11510 | } | |
11511 | ||
11512 | memset (&ts, 0, sizeof (ts)); | |
11513 | ts.table = bgp->rib[afi][safi]; | |
87d4a781 | 11514 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
bb46e94f | 11515 | |
2815e61f PJ |
11516 | vty_out (vty, "BGP %s RIB statistics%s%s", |
11517 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); | |
11518 | ||
11519 | for (i = 0; i < BGP_STATS_MAX; i++) | |
11520 | { | |
11521 | if (!table_stats_strs[i]) | |
11522 | continue; | |
11523 | ||
11524 | switch (i) | |
11525 | { | |
11526 | #if 0 | |
11527 | case BGP_STATS_ASPATH_AVGHOPS: | |
11528 | case BGP_STATS_ASPATH_AVGSIZE: | |
11529 | case BGP_STATS_AVGPLEN: | |
11530 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11531 | vty_out (vty, "%12.2f", | |
11532 | (float)ts.counts[i] / (float)TALLY_SIGFIG); | |
11533 | break; | |
11534 | #endif | |
11535 | case BGP_STATS_ASPATH_TOTHOPS: | |
11536 | case BGP_STATS_ASPATH_TOTSIZE: | |
11537 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11538 | vty_out (vty, "%12.2f", | |
11539 | ts.counts[i] ? | |
11540 | (float)ts.counts[i] / | |
11541 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] | |
11542 | : 0); | |
11543 | break; | |
11544 | case BGP_STATS_TOTPLEN: | |
11545 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11546 | vty_out (vty, "%12.2f", | |
11547 | ts.counts[i] ? | |
11548 | (float)ts.counts[i] / | |
11549 | (float)ts.counts[BGP_STATS_PREFIXES] | |
11550 | : 0); | |
11551 | break; | |
11552 | case BGP_STATS_SPACE: | |
11553 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11554 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); | |
11555 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) | |
11556 | break; | |
30a2231a | 11557 | vty_out (vty, "%30s: ", "%% announced "); |
2815e61f PJ |
11558 | vty_out (vty, "%12.2f%s", |
11559 | 100 * (float)ts.counts[BGP_STATS_SPACE] / | |
56395af7 | 11560 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
2815e61f PJ |
11561 | VTY_NEWLINE); |
11562 | vty_out (vty, "%30s: ", "/8 equivalent "); | |
11563 | vty_out (vty, "%12.2f%s", | |
11564 | (float)ts.counts[BGP_STATS_SPACE] / | |
11565 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), | |
11566 | VTY_NEWLINE); | |
11567 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) | |
11568 | break; | |
11569 | vty_out (vty, "%30s: ", "/24 equivalent "); | |
11570 | vty_out (vty, "%12.2f", | |
11571 | (float)ts.counts[BGP_STATS_SPACE] / | |
11572 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); | |
11573 | break; | |
11574 | default: | |
11575 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11576 | vty_out (vty, "%12llu", ts.counts[i]); | |
11577 | } | |
11578 | ||
11579 | vty_out (vty, "%s", VTY_NEWLINE); | |
11580 | } | |
11581 | return CMD_SUCCESS; | |
11582 | } | |
11583 | ||
11584 | static int | |
11585 | bgp_table_stats_vty (struct vty *vty, const char *name, | |
11586 | const char *afi_str, const char *safi_str) | |
11587 | { | |
11588 | struct bgp *bgp; | |
11589 | afi_t afi; | |
11590 | safi_t safi; | |
11591 | ||
11592 | if (name) | |
11593 | bgp = bgp_lookup_by_name (name); | |
11594 | else | |
11595 | bgp = bgp_get_default (); | |
11596 | ||
11597 | if (!bgp) | |
11598 | { | |
11599 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
11600 | return CMD_WARNING; | |
11601 | } | |
11602 | if (strncmp (afi_str, "ipv", 3) == 0) | |
11603 | { | |
11604 | if (strncmp (afi_str, "ipv4", 4) == 0) | |
11605 | afi = AFI_IP; | |
11606 | else if (strncmp (afi_str, "ipv6", 4) == 0) | |
11607 | afi = AFI_IP6; | |
11608 | else | |
11609 | { | |
11610 | vty_out (vty, "%% Invalid address family %s%s", | |
11611 | afi_str, VTY_NEWLINE); | |
11612 | return CMD_WARNING; | |
11613 | } | |
11614 | if (strncmp (safi_str, "m", 1) == 0) | |
11615 | safi = SAFI_MULTICAST; | |
11616 | else if (strncmp (safi_str, "u", 1) == 0) | |
11617 | safi = SAFI_UNICAST; | |
587ff0fd LB |
11618 | else if (strncmp (safi_str, "e", 1) == 0) |
11619 | safi = SAFI_ENCAP; | |
42e6d745 | 11620 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
06da0daf | 11621 | safi = SAFI_MPLS_VPN; |
2815e61f PJ |
11622 | else |
11623 | { | |
11624 | vty_out (vty, "%% Invalid subsequent address family %s%s", | |
11625 | safi_str, VTY_NEWLINE); | |
587ff0fd LB |
11626 | return CMD_WARNING; |
11627 | } | |
2815e61f PJ |
11628 | } |
11629 | else | |
11630 | { | |
587ff0fd | 11631 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
2815e61f PJ |
11632 | afi_str, VTY_NEWLINE); |
11633 | return CMD_WARNING; | |
11634 | } | |
11635 | ||
2815e61f PJ |
11636 | return bgp_table_stats (vty, bgp, afi, safi); |
11637 | } | |
11638 | ||
11639 | DEFUN (show_bgp_statistics, | |
11640 | show_bgp_statistics_cmd, | |
587ff0fd | 11641 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
2815e61f PJ |
11642 | SHOW_STR |
11643 | BGP_STR | |
11644 | "Address family\n" | |
11645 | "Address family\n" | |
11646 | "Address Family modifier\n" | |
11647 | "Address Family modifier\n" | |
587ff0fd LB |
11648 | "Address Family modifier\n" |
11649 | "Address Family modifier\n" | |
2815e61f PJ |
11650 | "BGP RIB advertisement statistics\n") |
11651 | { | |
11652 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
11653 | } | |
11654 | ||
2815e61f PJ |
11655 | DEFUN (show_bgp_statistics_view, |
11656 | show_bgp_statistics_view_cmd, | |
587ff0fd | 11657 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics", |
2815e61f PJ |
11658 | SHOW_STR |
11659 | BGP_STR | |
8386ac43 | 11660 | BGP_INSTANCE_HELP_STR |
2815e61f PJ |
11661 | "Address family\n" |
11662 | "Address family\n" | |
11663 | "Address Family modifier\n" | |
11664 | "Address Family modifier\n" | |
587ff0fd LB |
11665 | "Address Family modifier\n" |
11666 | "Address Family modifier\n" | |
2815e61f PJ |
11667 | "BGP RIB advertisement statistics\n") |
11668 | { | |
6aeb9e78 | 11669 | return bgp_table_stats_vty (vty, NULL, argv[1], argv[2]); |
2815e61f PJ |
11670 | } |
11671 | ||
ff7924f6 PJ |
11672 | enum bgp_pcounts |
11673 | { | |
11674 | PCOUNT_ADJ_IN = 0, | |
11675 | PCOUNT_DAMPED, | |
11676 | PCOUNT_REMOVED, | |
11677 | PCOUNT_HISTORY, | |
11678 | PCOUNT_STALE, | |
11679 | PCOUNT_VALID, | |
11680 | PCOUNT_ALL, | |
11681 | PCOUNT_COUNTED, | |
11682 | PCOUNT_PFCNT, /* the figure we display to users */ | |
11683 | PCOUNT_MAX, | |
11684 | }; | |
11685 | ||
11686 | static const char *pcount_strs[] = | |
11687 | { | |
11688 | [PCOUNT_ADJ_IN] = "Adj-in", | |
11689 | [PCOUNT_DAMPED] = "Damped", | |
11690 | [PCOUNT_REMOVED] = "Removed", | |
11691 | [PCOUNT_HISTORY] = "History", | |
11692 | [PCOUNT_STALE] = "Stale", | |
11693 | [PCOUNT_VALID] = "Valid", | |
11694 | [PCOUNT_ALL] = "All RIB", | |
11695 | [PCOUNT_COUNTED] = "PfxCt counted", | |
11696 | [PCOUNT_PFCNT] = "Useable", | |
11697 | [PCOUNT_MAX] = NULL, | |
11698 | }; | |
11699 | ||
2815e61f PJ |
11700 | struct peer_pcounts |
11701 | { | |
11702 | unsigned int count[PCOUNT_MAX]; | |
11703 | const struct peer *peer; | |
11704 | const struct bgp_table *table; | |
11705 | }; | |
11706 | ||
ff7924f6 | 11707 | static int |
2815e61f | 11708 | bgp_peer_count_walker (struct thread *t) |
ff7924f6 PJ |
11709 | { |
11710 | struct bgp_node *rn; | |
2815e61f PJ |
11711 | struct peer_pcounts *pc = THREAD_ARG (t); |
11712 | const struct peer *peer = pc->peer; | |
ff7924f6 | 11713 | |
2815e61f | 11714 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
ff7924f6 PJ |
11715 | { |
11716 | struct bgp_adj_in *ain; | |
2815e61f | 11717 | struct bgp_info *ri; |
ff7924f6 PJ |
11718 | |
11719 | for (ain = rn->adj_in; ain; ain = ain->next) | |
11720 | if (ain->peer == peer) | |
2815e61f | 11721 | pc->count[PCOUNT_ADJ_IN]++; |
ff7924f6 | 11722 | |
ff7924f6 PJ |
11723 | for (ri = rn->info; ri; ri = ri->next) |
11724 | { | |
11725 | char buf[SU_ADDRSTRLEN]; | |
11726 | ||
11727 | if (ri->peer != peer) | |
11728 | continue; | |
11729 | ||
2815e61f | 11730 | pc->count[PCOUNT_ALL]++; |
ff7924f6 PJ |
11731 | |
11732 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) | |
2815e61f | 11733 | pc->count[PCOUNT_DAMPED]++; |
ff7924f6 | 11734 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2815e61f | 11735 | pc->count[PCOUNT_HISTORY]++; |
ff7924f6 | 11736 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
2815e61f | 11737 | pc->count[PCOUNT_REMOVED]++; |
ff7924f6 | 11738 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
2815e61f | 11739 | pc->count[PCOUNT_STALE]++; |
ff7924f6 | 11740 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
2815e61f | 11741 | pc->count[PCOUNT_VALID]++; |
1a392d46 | 11742 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2815e61f | 11743 | pc->count[PCOUNT_PFCNT]++; |
ff7924f6 PJ |
11744 | |
11745 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
11746 | { | |
2815e61f | 11747 | pc->count[PCOUNT_COUNTED]++; |
1a392d46 | 11748 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
16286195 | 11749 | zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x", |
ff7924f6 PJ |
11750 | peer->host, |
11751 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
11752 | buf, SU_ADDRSTRLEN), | |
11753 | rn->p.prefixlen, | |
11754 | ri->flags); | |
11755 | } | |
11756 | else | |
11757 | { | |
1a392d46 | 11758 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
16286195 | 11759 | zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x", |
ff7924f6 PJ |
11760 | peer->host, |
11761 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
11762 | buf, SU_ADDRSTRLEN), | |
11763 | rn->p.prefixlen, | |
11764 | ri->flags); | |
11765 | } | |
11766 | } | |
11767 | } | |
2815e61f PJ |
11768 | return 0; |
11769 | } | |
ff7924f6 | 11770 | |
2815e61f | 11771 | static int |
856ca177 | 11772 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_char use_json) |
2815e61f PJ |
11773 | { |
11774 | struct peer_pcounts pcounts = { .peer = peer }; | |
11775 | unsigned int i; | |
856ca177 MS |
11776 | json_object *json = NULL; |
11777 | json_object *json_loop = NULL; | |
11778 | ||
11779 | if (use_json) | |
11780 | { | |
11781 | json = json_object_new_object(); | |
11782 | json_loop = json_object_new_object(); | |
11783 | } | |
2815e61f PJ |
11784 | |
11785 | if (!peer || !peer->bgp || !peer->afc[afi][safi] | |
11786 | || !peer->bgp->rib[afi][safi]) | |
11787 | { | |
856ca177 MS |
11788 | if (use_json) |
11789 | { | |
11790 | json_object_string_add(json, "warning", "No such neighbor or address family"); | |
11791 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11792 | json_object_free(json); | |
11793 | } | |
11794 | else | |
11795 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
11796 | ||
2815e61f PJ |
11797 | return CMD_WARNING; |
11798 | } | |
11799 | ||
11800 | memset (&pcounts, 0, sizeof(pcounts)); | |
11801 | pcounts.peer = peer; | |
11802 | pcounts.table = peer->bgp->rib[afi][safi]; | |
11803 | ||
11804 | /* in-place call via thread subsystem so as to record execution time | |
856ca177 MS |
11805 | * * stats for the thread-walk (i.e. ensure this can't be blamed on |
11806 | * * on just vty_read()). | |
11807 | * */ | |
87d4a781 | 11808 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
6410e93a | 11809 | |
856ca177 MS |
11810 | if (use_json) |
11811 | { | |
11812 | json_object_string_add(json, "prefixCountsFor", peer->host); | |
11813 | json_object_string_add(json, "multiProtocol", afi_safi_print (afi, safi)); | |
11814 | json_object_int_add(json, "pfxCounter", peer->pcount[afi][safi]); | |
11815 | ||
11816 | for (i = 0; i < PCOUNT_MAX; i++) | |
11817 | json_object_int_add(json_loop, pcount_strs[i], pcounts.count[i]); | |
ff7924f6 | 11818 | |
856ca177 | 11819 | json_object_object_add(json, "ribTableWalkCounters", json_loop); |
ff7924f6 | 11820 | |
856ca177 MS |
11821 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
11822 | { | |
11823 | json_object_string_add(json, "pfxctDriftFor", peer->host); | |
11824 | json_object_string_add(json, "recommended", "Please report this bug, with the above command output"); | |
11825 | } | |
11826 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11827 | json_object_free(json); | |
11828 | } | |
11829 | else | |
ff7924f6 | 11830 | { |
04b6bdc0 DW |
11831 | |
11832 | if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
11833 | { | |
11834 | vty_out (vty, "Prefix counts for %s/%s, %s%s", | |
11835 | peer->hostname, peer->host, afi_safi_print (afi, safi), | |
11836 | VTY_NEWLINE); | |
11837 | } | |
11838 | else | |
11839 | { | |
11840 | vty_out (vty, "Prefix counts for %s, %s%s", | |
11841 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); | |
11842 | } | |
11843 | ||
856ca177 MS |
11844 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
11845 | vty_out (vty, "%sCounts from RIB table walk:%s%s", | |
11846 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
11847 | ||
11848 | for (i = 0; i < PCOUNT_MAX; i++) | |
11849 | vty_out (vty, "%20s: %-10d%s", pcount_strs[i], pcounts.count[i], VTY_NEWLINE); | |
11850 | ||
11851 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) | |
11852 | { | |
11853 | vty_out (vty, "%s [pcount] PfxCt drift!%s", | |
11854 | peer->host, VTY_NEWLINE); | |
11855 | vty_out (vty, "Please report this bug, with the above command output%s", | |
11856 | VTY_NEWLINE); | |
11857 | } | |
ff7924f6 PJ |
11858 | } |
11859 | ||
11860 | return CMD_SUCCESS; | |
11861 | } | |
11862 | ||
11863 | DEFUN (show_ip_bgp_neighbor_prefix_counts, | |
11864 | show_ip_bgp_neighbor_prefix_counts_cmd, | |
856ca177 | 11865 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11866 | SHOW_STR |
11867 | IP_STR | |
11868 | BGP_STR | |
11869 | "Detailed information on TCP and BGP neighbor connections\n" | |
11870 | "Neighbor to display information about\n" | |
11871 | "Neighbor to display information about\n" | |
a80beece | 11872 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11873 | "Display detailed prefix count information\n" |
11874 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11875 | { |
11876 | struct peer *peer; | |
db7c8528 | 11877 | u_char uj = use_json(argc, argv); |
ff7924f6 | 11878 | |
db7c8528 | 11879 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
ff7924f6 PJ |
11880 | if (! peer) |
11881 | return CMD_WARNING; | |
11882 | ||
db7c8528 | 11883 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); |
ff7924f6 PJ |
11884 | } |
11885 | ||
8386ac43 | 11886 | DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, |
11887 | show_ip_bgp_instance_neighbor_prefix_counts_cmd, | |
11888 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", | |
50ef26d4 | 11889 | SHOW_STR |
11890 | IP_STR | |
11891 | BGP_STR | |
8386ac43 | 11892 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 11893 | "Detailed information on TCP and BGP neighbor connections\n" |
11894 | "Neighbor to display information about\n" | |
11895 | "Neighbor to display information about\n" | |
11896 | "Neighbor on bgp configured interface\n" | |
11897 | "Display detailed prefix count information\n" | |
11898 | "JavaScript Object Notation\n") | |
11899 | { | |
11900 | struct peer *peer; | |
11901 | u_char uj = use_json(argc, argv); | |
11902 | ||
11903 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
11904 | if (! peer) | |
11905 | return CMD_WARNING; | |
11906 | ||
11907 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); | |
11908 | } | |
11909 | ||
ff7924f6 PJ |
11910 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
11911 | show_bgp_ipv6_neighbor_prefix_counts_cmd, | |
856ca177 | 11912 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11913 | SHOW_STR |
11914 | BGP_STR | |
11915 | "Address family\n" | |
11916 | "Detailed information on TCP and BGP neighbor connections\n" | |
11917 | "Neighbor to display information about\n" | |
11918 | "Neighbor to display information about\n" | |
a80beece | 11919 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11920 | "Display detailed prefix count information\n" |
11921 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11922 | { |
11923 | struct peer *peer; | |
db7c8528 | 11924 | u_char uj = use_json(argc, argv); |
856ca177 | 11925 | |
db7c8528 | 11926 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
ff7924f6 PJ |
11927 | if (! peer) |
11928 | return CMD_WARNING; | |
11929 | ||
db7c8528 | 11930 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); |
ff7924f6 PJ |
11931 | } |
11932 | ||
8386ac43 | 11933 | DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, |
11934 | show_bgp_instance_ipv6_neighbor_prefix_counts_cmd, | |
11935 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", | |
50ef26d4 | 11936 | SHOW_STR |
11937 | BGP_STR | |
8386ac43 | 11938 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 11939 | "Address family\n" |
11940 | "Detailed information on TCP and BGP neighbor connections\n" | |
11941 | "Neighbor to display information about\n" | |
11942 | "Neighbor to display information about\n" | |
11943 | "Neighbor on bgp configured interface\n" | |
11944 | "Display detailed prefix count information\n" | |
11945 | "JavaScript Object Notation\n") | |
11946 | { | |
11947 | struct peer *peer; | |
11948 | u_char uj = use_json(argc, argv); | |
11949 | ||
11950 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
11951 | if (! peer) | |
11952 | return CMD_WARNING; | |
11953 | ||
11954 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); | |
11955 | } | |
11956 | ||
ff7924f6 PJ |
11957 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
11958 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, | |
856ca177 | 11959 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11960 | SHOW_STR |
11961 | IP_STR | |
11962 | BGP_STR | |
11963 | "Address family\n" | |
11964 | "Address Family modifier\n" | |
11965 | "Address Family modifier\n" | |
11966 | "Detailed information on TCP and BGP neighbor connections\n" | |
11967 | "Neighbor to display information about\n" | |
11968 | "Neighbor to display information about\n" | |
a80beece | 11969 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11970 | "Display detailed prefix count information\n" |
11971 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11972 | { |
11973 | struct peer *peer; | |
db7c8528 | 11974 | u_char uj = use_json(argc, argv); |
ff7924f6 | 11975 | |
db7c8528 | 11976 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
ff7924f6 PJ |
11977 | if (! peer) |
11978 | return CMD_WARNING; | |
11979 | ||
11980 | if (strncmp (argv[0], "m", 1) == 0) | |
db7c8528 | 11981 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj); |
ff7924f6 | 11982 | |
db7c8528 | 11983 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); |
ff7924f6 PJ |
11984 | } |
11985 | ||
11986 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, | |
11987 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, | |
856ca177 | 11988 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11989 | SHOW_STR |
11990 | IP_STR | |
11991 | BGP_STR | |
11992 | "Address family\n" | |
11993 | "Address Family modifier\n" | |
11994 | "Address Family modifier\n" | |
11995 | "Detailed information on TCP and BGP neighbor connections\n" | |
11996 | "Neighbor to display information about\n" | |
11997 | "Neighbor to display information about\n" | |
a80beece | 11998 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11999 | "Display detailed prefix count information\n" |
12000 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
12001 | { |
12002 | struct peer *peer; | |
db7c8528 | 12003 | u_char uj = use_json(argc, argv); |
856ca177 | 12004 | |
db7c8528 | 12005 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
ff7924f6 PJ |
12006 | if (! peer) |
12007 | return CMD_WARNING; | |
12008 | ||
db7c8528 | 12009 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN, uj); |
ff7924f6 PJ |
12010 | } |
12011 | ||
94f2b392 | 12012 | static void |
718e3744 | 12013 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
856ca177 | 12014 | int in, const char *rmap_name, u_char use_json, json_object *json) |
718e3744 | 12015 | { |
12016 | struct bgp_table *table; | |
12017 | struct bgp_adj_in *ain; | |
12018 | struct bgp_adj_out *adj; | |
12019 | unsigned long output_count; | |
0b16f239 | 12020 | unsigned long filtered_count; |
718e3744 | 12021 | struct bgp_node *rn; |
12022 | int header1 = 1; | |
12023 | struct bgp *bgp; | |
12024 | int header2 = 1; | |
0b16f239 DS |
12025 | struct attr attr; |
12026 | struct attr_extra extra; | |
12027 | int ret; | |
840fced9 | 12028 | struct update_subgroup *subgrp; |
856ca177 MS |
12029 | json_object *json_scode = NULL; |
12030 | json_object *json_ocode = NULL; | |
12031 | json_object *json_ar = NULL; | |
adbac85e | 12032 | struct peer_af *paf; |
856ca177 MS |
12033 | |
12034 | if (use_json) | |
12035 | { | |
12036 | json_scode = json_object_new_object(); | |
12037 | json_ocode = json_object_new_object(); | |
12038 | json_ar = json_object_new_object(); | |
12039 | ||
12040 | json_object_string_add(json_scode, "suppressed", "s"); | |
12041 | json_object_string_add(json_scode, "damped", "d"); | |
12042 | json_object_string_add(json_scode, "history", "h"); | |
12043 | json_object_string_add(json_scode, "valid", "*"); | |
12044 | json_object_string_add(json_scode, "best", ">"); | |
12045 | json_object_string_add(json_scode, "multipath", "="); | |
12046 | json_object_string_add(json_scode, "internal", "i"); | |
12047 | json_object_string_add(json_scode, "ribFailure", "r"); | |
12048 | json_object_string_add(json_scode, "stale", "S"); | |
12049 | json_object_string_add(json_scode, "removed", "R"); | |
12050 | ||
12051 | json_object_string_add(json_ocode, "igp", "i"); | |
12052 | json_object_string_add(json_ocode, "egp", "e"); | |
12053 | json_object_string_add(json_ocode, "incomplete", "?"); | |
12054 | } | |
718e3744 | 12055 | |
bb46e94f | 12056 | bgp = peer->bgp; |
718e3744 | 12057 | |
12058 | if (! bgp) | |
856ca177 MS |
12059 | { |
12060 | if (use_json) | |
12061 | { | |
12062 | json_object_string_add(json, "alert", "no BGP"); | |
12063 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
12064 | json_object_free(json); | |
12065 | } | |
12066 | else | |
12067 | vty_out (vty, "%% No bgp%s", VTY_NEWLINE); | |
12068 | return; | |
12069 | } | |
718e3744 | 12070 | |
12071 | table = bgp->rib[afi][safi]; | |
12072 | ||
0b16f239 | 12073 | output_count = filtered_count = 0; |
840fced9 | 12074 | subgrp = peer_subgroup(peer, afi, safi); |
47fc97cc | 12075 | |
840fced9 | 12076 | if (!in && subgrp && CHECK_FLAG (subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) |
718e3744 | 12077 | { |
856ca177 MS |
12078 | if (use_json) |
12079 | { | |
12080 | json_object_int_add(json, "bgpTableVersion", table->version); | |
12081 | json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); | |
12082 | json_object_object_add(json, "bgpStatusCodes", json_scode); | |
12083 | json_object_object_add(json, "bgpOriginCodes", json_ocode); | |
12084 | json_object_string_add(json, "bgpOriginatingDefaultNetwork", "0.0.0.0"); | |
12085 | } | |
12086 | else | |
12087 | { | |
12088 | vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
12089 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12090 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 12091 | |
856ca177 MS |
12092 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
12093 | VTY_NEWLINE, VTY_NEWLINE); | |
12094 | } | |
718e3744 | 12095 | header1 = 0; |
12096 | } | |
12097 | ||
0b16f239 | 12098 | attr.extra = &extra; |
718e3744 | 12099 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
856ca177 MS |
12100 | { |
12101 | if (in) | |
12102 | { | |
12103 | for (ain = rn->adj_in; ain; ain = ain->next) | |
12104 | { | |
12105 | if (ain->peer == peer) | |
12106 | { | |
12107 | if (header1) | |
12108 | { | |
12109 | if (use_json) | |
12110 | { | |
12111 | json_object_int_add(json, "bgpTableVersion", 0); | |
12112 | json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); | |
12113 | json_object_object_add(json, "bgpStatusCodes", json_scode); | |
12114 | json_object_object_add(json, "bgpOriginCodes", json_ocode); | |
12115 | } | |
12116 | else | |
12117 | { | |
12118 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
12119 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12120 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12121 | } | |
12122 | header1 = 0; | |
12123 | } | |
12124 | if (header2) | |
12125 | { | |
12126 | if (!use_json) | |
12127 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
12128 | header2 = 0; | |
12129 | } | |
12130 | if (ain->attr) | |
12131 | { | |
12132 | bgp_attr_dup(&attr, ain->attr); | |
12133 | if (bgp_input_modifier(peer, &rn->p, &attr, afi, safi, rmap_name) != RMAP_DENY) | |
12134 | { | |
12135 | route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); | |
12136 | output_count++; | |
12137 | } | |
12138 | else | |
12139 | filtered_count++; | |
12140 | } | |
12141 | } | |
12142 | } | |
12143 | } | |
12144 | else | |
12145 | { | |
adbac85e DW |
12146 | for (adj = rn->adj_out; adj; adj = adj->next) |
12147 | SUBGRP_FOREACH_PEER(adj->subgroup, paf) | |
12148 | if (paf->peer == peer) | |
856ca177 | 12149 | { |
adbac85e | 12150 | if (header1) |
856ca177 | 12151 | { |
adbac85e DW |
12152 | if (use_json) |
12153 | { | |
12154 | json_object_int_add(json, "bgpTableVersion", table->version); | |
12155 | json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); | |
12156 | json_object_object_add(json, "bgpStatusCodes", json_scode); | |
12157 | json_object_object_add(json, "bgpOriginCodes", json_ocode); | |
12158 | } | |
12159 | else | |
12160 | { | |
12161 | vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, | |
12162 | inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
12163 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12164 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12165 | } | |
12166 | header1 = 0; | |
856ca177 | 12167 | } |
adbac85e DW |
12168 | |
12169 | if (header2) | |
856ca177 | 12170 | { |
adbac85e DW |
12171 | if (!use_json) |
12172 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
12173 | header2 = 0; | |
856ca177 | 12174 | } |
adbac85e DW |
12175 | |
12176 | if (adj->attr) | |
856ca177 | 12177 | { |
adbac85e DW |
12178 | bgp_attr_dup(&attr, adj->attr); |
12179 | ret = bgp_output_modifier(peer, &rn->p, &attr, afi, safi, rmap_name); | |
12180 | if (ret != RMAP_DENY) | |
12181 | { | |
12182 | route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); | |
12183 | output_count++; | |
12184 | } | |
12185 | else | |
12186 | filtered_count++; | |
856ca177 | 12187 | } |
856ca177 | 12188 | } |
856ca177 MS |
12189 | } |
12190 | } | |
12191 | if (use_json) | |
12192 | json_object_object_add(json, "advertisedRoutes", json_ar); | |
47fc97cc | 12193 | |
718e3744 | 12194 | if (output_count != 0) |
856ca177 MS |
12195 | { |
12196 | if (use_json) | |
12197 | json_object_int_add(json, "totalPrefixCounter", output_count); | |
12198 | else | |
12199 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
12200 | VTY_NEWLINE, output_count, VTY_NEWLINE); | |
12201 | } | |
12202 | if (use_json) | |
12203 | { | |
12204 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
12205 | json_object_free(json); | |
12206 | } | |
12207 | ||
718e3744 | 12208 | } |
12209 | ||
94f2b392 | 12210 | static int |
47fc97cc | 12211 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
856ca177 MS |
12212 | int in, const char *rmap_name, u_char use_json) |
12213 | { | |
12214 | json_object *json = NULL; | |
12215 | ||
12216 | if (use_json) | |
12217 | json = json_object_new_object(); | |
12218 | ||
12219 | if (!peer || !peer->afc[afi][safi]) | |
718e3744 | 12220 | { |
856ca177 MS |
12221 | if (use_json) |
12222 | { | |
12223 | json_object_string_add(json, "warning", "No such neighbor or address family"); | |
12224 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
12225 | json_object_free(json); | |
12226 | } | |
12227 | else | |
12228 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
12229 | ||
718e3744 | 12230 | return CMD_WARNING; |
12231 | } | |
12232 | ||
856ca177 | 12233 | if (in && !CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
718e3744 | 12234 | { |
856ca177 MS |
12235 | if (use_json) |
12236 | { | |
12237 | json_object_string_add(json, "warning", "Inbound soft reconfiguration not enabled"); | |
12238 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
12239 | json_object_free(json); | |
12240 | } | |
12241 | else | |
12242 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE); | |
12243 | ||
718e3744 | 12244 | return CMD_WARNING; |
12245 | } | |
12246 | ||
856ca177 | 12247 | show_adj_route (vty, peer, afi, safi, in, rmap_name, use_json, json); |
718e3744 | 12248 | |
12249 | return CMD_SUCCESS; | |
12250 | } | |
12251 | ||
8386ac43 | 12252 | DEFUN (show_ip_bgp_instance_neighbor_advertised_route, |
12253 | show_ip_bgp_instance_neighbor_advertised_route_cmd, | |
12254 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", | |
718e3744 | 12255 | SHOW_STR |
12256 | IP_STR | |
12257 | BGP_STR | |
8386ac43 | 12258 | BGP_INSTANCE_HELP_STR |
718e3744 | 12259 | "Detailed information on TCP and BGP neighbor connections\n" |
12260 | "Neighbor to display information about\n" | |
12261 | "Neighbor to display information about\n" | |
856ca177 MS |
12262 | "Display the routes advertised to a BGP neighbor\n" |
12263 | "JavaScript Object Notation\n") | |
718e3744 | 12264 | { |
bb46e94f | 12265 | struct peer *peer; |
db7c8528 | 12266 | u_char uj = use_json(argc, argv); |
856ca177 | 12267 | |
6aeb9e78 DS |
12268 | if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
12269 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
2a71e9ce | 12270 | else |
6aeb9e78 | 12271 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
2a71e9ce | 12272 | |
bb46e94f | 12273 | if (! peer) |
12274 | return CMD_WARNING; | |
0b16f239 | 12275 | |
db7c8528 | 12276 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, NULL, uj); |
718e3744 | 12277 | } |
12278 | ||
0b16f239 | 12279 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
2a71e9ce | 12280 | show_ip_bgp_neighbor_advertised_route_cmd, |
856ca177 | 12281 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
2a71e9ce TP |
12282 | SHOW_STR |
12283 | IP_STR | |
12284 | BGP_STR | |
12285 | "Detailed information on TCP and BGP neighbor connections\n" | |
12286 | "Neighbor to display information about\n" | |
12287 | "Neighbor to display information about\n" | |
a80beece | 12288 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12289 | "Display the routes advertised to a BGP neighbor\n" |
12290 | "JavaScript Object Notation\n") | |
2a71e9ce | 12291 | |
0b16f239 DS |
12292 | { |
12293 | struct peer *peer; | |
ffd0c037 | 12294 | const char *rmap_name = NULL; |
db7c8528 | 12295 | u_char uj = use_json(argc, argv); |
0b16f239 | 12296 | |
db7c8528 | 12297 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
0b16f239 DS |
12298 | |
12299 | if (! peer) | |
12300 | return CMD_WARNING; | |
12301 | ||
856ca177 MS |
12302 | if ((argc == 2 && argv[1] && strcmp(argv[1], "json") != 0) |
12303 | || (argc == 3)) | |
0b16f239 DS |
12304 | rmap_name = argv[1]; |
12305 | ||
db7c8528 | 12306 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); |
0b16f239 DS |
12307 | } |
12308 | ||
12309 | ALIAS (show_ip_bgp_neighbor_advertised_route, | |
12310 | show_ip_bgp_neighbor_advertised_route_rmap_cmd, | |
856ca177 | 12311 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", |
0b16f239 DS |
12312 | SHOW_STR |
12313 | IP_STR | |
12314 | BGP_STR | |
12315 | "Detailed information on TCP and BGP neighbor connections\n" | |
12316 | "Neighbor to display information about\n" | |
12317 | "Neighbor to display information about\n" | |
12318 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12319 | "Display the routes advertised to a BGP neighbor\n" |
12320 | "JavaScript Object Notation\n") | |
0b16f239 | 12321 | |
8386ac43 | 12322 | ALIAS (show_ip_bgp_instance_neighbor_advertised_route, |
12323 | show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd, | |
12324 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", | |
50ef26d4 | 12325 | SHOW_STR |
12326 | IP_STR | |
12327 | BGP_STR | |
8386ac43 | 12328 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 12329 | "Detailed information on TCP and BGP neighbor connections\n" |
12330 | "Neighbor to display information about\n" | |
12331 | "Neighbor to display information about\n" | |
12332 | "Neighbor on bgp configured interface\n" | |
12333 | "Display the routes advertised to a BGP neighbor\n" | |
12334 | "JavaScript Object Notation\n") | |
718e3744 | 12335 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
12336 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, | |
856ca177 | 12337 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12338 | SHOW_STR |
12339 | IP_STR | |
12340 | BGP_STR | |
12341 | "Address family\n" | |
12342 | "Address Family modifier\n" | |
12343 | "Address Family modifier\n" | |
12344 | "Detailed information on TCP and BGP neighbor connections\n" | |
12345 | "Neighbor to display information about\n" | |
12346 | "Neighbor to display information about\n" | |
a80beece | 12347 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12348 | "Display the routes advertised to a BGP neighbor\n" |
12349 | "JavaScript Object Notation\n") | |
718e3744 | 12350 | { |
bb46e94f | 12351 | struct peer *peer; |
ffd0c037 | 12352 | const char *rmap_name = NULL; |
db7c8528 | 12353 | u_char uj = use_json(argc, argv); |
856ca177 | 12354 | |
db7c8528 | 12355 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12356 | if (! peer) |
12357 | return CMD_WARNING; | |
12358 | ||
856ca177 | 12359 | if ((argc == 4) || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
0b16f239 DS |
12360 | rmap_name = argv[2]; |
12361 | ||
718e3744 | 12362 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 12363 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0, rmap_name, uj); |
856ca177 | 12364 | else |
db7c8528 | 12365 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); |
718e3744 | 12366 | } |
12367 | ||
0b16f239 DS |
12368 | ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route, |
12369 | show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd, | |
856ca177 | 12370 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", |
0b16f239 DS |
12371 | SHOW_STR |
12372 | IP_STR | |
12373 | BGP_STR | |
12374 | "Address family\n" | |
12375 | "Address Family modifier\n" | |
12376 | "Address Family modifier\n" | |
12377 | "Detailed information on TCP and BGP neighbor connections\n" | |
12378 | "Neighbor to display information about\n" | |
12379 | "Neighbor to display information about\n" | |
12380 | "Neighbor on bgp configured interface\n" | |
12381 | "Display the routes advertised to a BGP neighbor\n" | |
856ca177 MS |
12382 | "Route-map to control what is displayed\n" |
12383 | "JavaScript Object Notation\n") | |
0b16f239 | 12384 | |
718e3744 | 12385 | #ifdef HAVE_IPV6 |
8386ac43 | 12386 | DEFUN (show_bgp_instance_neighbor_advertised_route, |
12387 | show_bgp_instance_neighbor_advertised_route_cmd, | |
12388 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", | |
718e3744 | 12389 | SHOW_STR |
12390 | BGP_STR | |
8386ac43 | 12391 | BGP_INSTANCE_HELP_STR |
718e3744 | 12392 | "Detailed information on TCP and BGP neighbor connections\n" |
12393 | "Neighbor to display information about\n" | |
12394 | "Neighbor to display information about\n" | |
a80beece | 12395 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12396 | "Display the routes advertised to a BGP neighbor\n" |
12397 | "JavaScript Object Notation\n") | |
718e3744 | 12398 | { |
bb46e94f | 12399 | struct peer *peer; |
db7c8528 | 12400 | u_char uj = use_json(argc, argv); |
856ca177 | 12401 | |
6aeb9e78 DS |
12402 | if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
12403 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
bb46e94f | 12404 | else |
6aeb9e78 | 12405 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12406 | |
12407 | if (! peer) | |
0b16f239 | 12408 | return CMD_WARNING; |
bb46e94f | 12409 | |
db7c8528 | 12410 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, NULL, uj); |
47fc97cc DS |
12411 | } |
12412 | ||
8386ac43 | 12413 | ALIAS (show_bgp_instance_neighbor_advertised_route, |
12414 | show_bgp_instance_ipv6_neighbor_advertised_route_cmd, | |
12415 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", | |
0b16f239 DS |
12416 | SHOW_STR |
12417 | BGP_STR | |
8386ac43 | 12418 | BGP_INSTANCE_HELP_STR |
0b16f239 DS |
12419 | "Address family\n" |
12420 | "Detailed information on TCP and BGP neighbor connections\n" | |
12421 | "Neighbor to display information about\n" | |
12422 | "Neighbor to display information about\n" | |
12423 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12424 | "Display the routes advertised to a BGP neighbor\n" |
12425 | "JavaScript Object Notation\n") | |
0b16f239 | 12426 | |
0b16f239 DS |
12427 | DEFUN (show_bgp_neighbor_advertised_route, |
12428 | show_bgp_neighbor_advertised_route_cmd, | |
856ca177 | 12429 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
bb46e94f | 12430 | SHOW_STR |
12431 | BGP_STR | |
bb46e94f | 12432 | "Detailed information on TCP and BGP neighbor connections\n" |
12433 | "Neighbor to display information about\n" | |
12434 | "Neighbor to display information about\n" | |
a80beece | 12435 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12436 | "Display the routes advertised to a BGP neighbor\n" |
12437 | "JavaScript Object Notation\n") | |
0b16f239 | 12438 | |
bb46e94f | 12439 | { |
12440 | struct peer *peer; | |
ffd0c037 | 12441 | const char *rmap_name = NULL; |
db7c8528 | 12442 | u_char uj = use_json(argc, argv); |
bb46e94f | 12443 | |
db7c8528 | 12444 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
856ca177 MS |
12445 | |
12446 | if (!peer) | |
bb46e94f | 12447 | return CMD_WARNING; |
12448 | ||
856ca177 | 12449 | if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) |
0b16f239 DS |
12450 | rmap_name = argv[1]; |
12451 | ||
db7c8528 | 12452 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, rmap_name, uj); |
718e3744 | 12453 | } |
12454 | ||
0b16f239 DS |
12455 | ALIAS (show_bgp_neighbor_advertised_route, |
12456 | show_bgp_ipv6_neighbor_advertised_route_cmd, | |
856ca177 | 12457 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12458 | SHOW_STR |
12459 | BGP_STR | |
12460 | "Address family\n" | |
12461 | "Detailed information on TCP and BGP neighbor connections\n" | |
12462 | "Neighbor to display information about\n" | |
12463 | "Neighbor to display information about\n" | |
a80beece | 12464 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12465 | "Display the routes advertised to a BGP neighbor\n" |
12466 | "JavaScript Object Notation\n") | |
718e3744 | 12467 | |
12468 | /* old command */ | |
0b16f239 | 12469 | ALIAS (show_bgp_neighbor_advertised_route, |
718e3744 | 12470 | ipv6_bgp_neighbor_advertised_route_cmd, |
856ca177 | 12471 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12472 | SHOW_STR |
12473 | IPV6_STR | |
12474 | BGP_STR | |
12475 | "Detailed information on TCP and BGP neighbor connections\n" | |
12476 | "Neighbor to display information about\n" | |
12477 | "Neighbor to display information about\n" | |
a80beece | 12478 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12479 | "Display the routes advertised to a BGP neighbor\n" |
12480 | "JavaScript Object Notation\n") | |
bb46e94f | 12481 | |
718e3744 | 12482 | /* old command */ |
12483 | DEFUN (ipv6_mbgp_neighbor_advertised_route, | |
12484 | ipv6_mbgp_neighbor_advertised_route_cmd, | |
856ca177 | 12485 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12486 | SHOW_STR |
12487 | IPV6_STR | |
12488 | MBGP_STR | |
12489 | "Detailed information on TCP and BGP neighbor connections\n" | |
12490 | "Neighbor to display information about\n" | |
12491 | "Neighbor to display information about\n" | |
a80beece DS |
12492 | "Neighbor on bgp configured interface\n" |
12493 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12494 | "Display the routes advertised to a BGP neighbor\n" |
12495 | "JavaScript Object Notation\n") | |
718e3744 | 12496 | { |
bb46e94f | 12497 | struct peer *peer; |
db7c8528 | 12498 | u_char uj = use_json(argc, argv); |
856ca177 | 12499 | |
db7c8528 | 12500 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 12501 | if (! peer) |
856ca177 | 12502 | return CMD_WARNING; |
bb46e94f | 12503 | |
47e9b292 | 12504 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 12505 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0, NULL, uj); |
718e3744 | 12506 | } |
12507 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 12508 | |
8386ac43 | 12509 | DEFUN (show_bgp_instance_neighbor_received_routes, |
12510 | show_bgp_instance_neighbor_received_routes_cmd, | |
12511 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", | |
0b16f239 DS |
12512 | SHOW_STR |
12513 | BGP_STR | |
8386ac43 | 12514 | BGP_INSTANCE_HELP_STR |
0b16f239 DS |
12515 | "Detailed information on TCP and BGP neighbor connections\n" |
12516 | "Neighbor to display information about\n" | |
12517 | "Neighbor to display information about\n" | |
12518 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12519 | "Display the received routes from neighbor\n" |
12520 | "JavaScript Object Notation\n") | |
0b16f239 DS |
12521 | { |
12522 | struct peer *peer; | |
db7c8528 | 12523 | u_char uj = use_json(argc, argv); |
856ca177 | 12524 | |
50ef26d4 | 12525 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); |
0b16f239 DS |
12526 | if (! peer) |
12527 | return CMD_WARNING; | |
12528 | ||
db7c8528 | 12529 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, NULL, uj); |
0b16f239 DS |
12530 | } |
12531 | ||
8386ac43 | 12532 | DEFUN (show_ip_bgp_instance_neighbor_received_routes, |
12533 | show_ip_bgp_instance_neighbor_received_routes_cmd, | |
12534 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", | |
718e3744 | 12535 | SHOW_STR |
12536 | IP_STR | |
12537 | BGP_STR | |
8386ac43 | 12538 | BGP_INSTANCE_HELP_STR |
718e3744 | 12539 | "Detailed information on TCP and BGP neighbor connections\n" |
12540 | "Neighbor to display information about\n" | |
12541 | "Neighbor to display information about\n" | |
a80beece | 12542 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12543 | "Display the received routes from neighbor\n" |
12544 | "JavaScript Object Notation\n") | |
718e3744 | 12545 | { |
bb46e94f | 12546 | struct peer *peer; |
db7c8528 | 12547 | u_char uj = use_json(argc, argv); |
856ca177 | 12548 | |
50ef26d4 | 12549 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); |
bb46e94f | 12550 | if (! peer) |
12551 | return CMD_WARNING; | |
12552 | ||
db7c8528 | 12553 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, NULL, uj); |
718e3744 | 12554 | } |
12555 | ||
8386ac43 | 12556 | ALIAS (show_bgp_instance_neighbor_received_routes, |
12557 | show_bgp_instance_ipv6_neighbor_received_routes_cmd, | |
12558 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", | |
0b16f239 DS |
12559 | SHOW_STR |
12560 | BGP_STR | |
8386ac43 | 12561 | BGP_INSTANCE_HELP_STR |
0b16f239 DS |
12562 | "Address family\n" |
12563 | "Detailed information on TCP and BGP neighbor connections\n" | |
12564 | "Neighbor to display information about\n" | |
12565 | "Neighbor to display information about\n" | |
12566 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12567 | "Display the received routes from neighbor\n" |
12568 | "JavaScript Object Notation\n") | |
0b16f239 DS |
12569 | |
12570 | DEFUN (show_ip_bgp_neighbor_received_routes, | |
2a71e9ce | 12571 | show_ip_bgp_neighbor_received_routes_cmd, |
856ca177 | 12572 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
2a71e9ce TP |
12573 | SHOW_STR |
12574 | IP_STR | |
12575 | BGP_STR | |
12576 | "Detailed information on TCP and BGP neighbor connections\n" | |
12577 | "Neighbor to display information about\n" | |
12578 | "Neighbor to display information about\n" | |
a80beece | 12579 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12580 | "Display the received routes from neighbor\n" |
12581 | "JavaScript Object Notation\n") | |
2a71e9ce | 12582 | |
0b16f239 DS |
12583 | { |
12584 | struct peer *peer; | |
ffd0c037 | 12585 | const char *rmap_name = NULL; |
db7c8528 | 12586 | u_char uj = use_json(argc, argv); |
0b16f239 | 12587 | |
db7c8528 | 12588 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
0b16f239 DS |
12589 | |
12590 | if (! peer) | |
12591 | return CMD_WARNING; | |
12592 | ||
856ca177 | 12593 | if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) |
0b16f239 DS |
12594 | rmap_name = argv[1]; |
12595 | ||
db7c8528 | 12596 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); |
0b16f239 DS |
12597 | } |
12598 | ||
12599 | ALIAS (show_ip_bgp_neighbor_received_routes, | |
12600 | show_ip_bgp_neighbor_received_routes_rmap_cmd, | |
856ca177 | 12601 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", |
0b16f239 DS |
12602 | SHOW_STR |
12603 | IP_STR | |
12604 | BGP_STR | |
12605 | "Detailed information on TCP and BGP neighbor connections\n" | |
12606 | "Neighbor to display information about\n" | |
12607 | "Neighbor to display information about\n" | |
12608 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12609 | "Display the received routes from neighbor\n" |
12610 | "JavaScript Object Notation\n") | |
0b16f239 | 12611 | |
8386ac43 | 12612 | ALIAS (show_ip_bgp_instance_neighbor_received_routes, |
12613 | show_ip_bgp_instance_neighbor_received_routes_rmap_cmd, | |
12614 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", | |
50ef26d4 | 12615 | SHOW_STR |
12616 | IP_STR | |
12617 | BGP_STR | |
8386ac43 | 12618 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 12619 | "Detailed information on TCP and BGP neighbor connections\n" |
12620 | "Neighbor to display information about\n" | |
12621 | "Neighbor to display information about\n" | |
12622 | "Neighbor on bgp configured interface\n" | |
12623 | "Display the received routes from neighbor\n" | |
12624 | "JavaScript Object Notation\n") | |
12625 | ||
718e3744 | 12626 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
12627 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, | |
856ca177 | 12628 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 12629 | SHOW_STR |
12630 | IP_STR | |
12631 | BGP_STR | |
12632 | "Address family\n" | |
12633 | "Address Family modifier\n" | |
12634 | "Address Family modifier\n" | |
12635 | "Detailed information on TCP and BGP neighbor connections\n" | |
12636 | "Neighbor to display information about\n" | |
12637 | "Neighbor to display information about\n" | |
a80beece | 12638 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12639 | "Display the received routes from neighbor\n" |
12640 | "JavaScript Object Notation\n") | |
718e3744 | 12641 | { |
bb46e94f | 12642 | struct peer *peer; |
ffd0c037 | 12643 | const char *rmap_name = NULL; |
db7c8528 | 12644 | u_char uj = use_json(argc, argv); |
bb46e94f | 12645 | |
db7c8528 | 12646 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12647 | if (! peer) |
12648 | return CMD_WARNING; | |
0b16f239 | 12649 | |
856ca177 | 12650 | if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
0b16f239 DS |
12651 | rmap_name = argv[2]; |
12652 | ||
718e3744 | 12653 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 12654 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1, rmap_name, uj); |
856ca177 | 12655 | else |
db7c8528 | 12656 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); |
718e3744 | 12657 | } |
12658 | ||
0b16f239 DS |
12659 | ALIAS (show_ip_bgp_ipv4_neighbor_received_routes, |
12660 | show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd, | |
856ca177 | 12661 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", |
0b16f239 DS |
12662 | SHOW_STR |
12663 | IP_STR | |
12664 | BGP_STR | |
12665 | "Address family\n" | |
12666 | "Address Family modifier\n" | |
12667 | "Address Family modifier\n" | |
12668 | "Detailed information on TCP and BGP neighbor connections\n" | |
12669 | "Neighbor to display information about\n" | |
12670 | "Neighbor to display information about\n" | |
12671 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12672 | "Display the received routes from neighbor\n" |
12673 | "JavaScript Object Notation\n") | |
0b16f239 | 12674 | |
8386ac43 | 12675 | DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, |
12676 | show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd, | |
8386ac43 | 12677 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}", |
95cbbd2a ML |
12678 | SHOW_STR |
12679 | BGP_STR | |
8386ac43 | 12680 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 12681 | "Address family\n" |
95cbbd2a | 12682 | "Address family\n" |
95cbbd2a ML |
12683 | "Address family modifier\n" |
12684 | "Address family modifier\n" | |
12685 | "Detailed information on TCP and BGP neighbor connections\n" | |
12686 | "Neighbor to display information about\n" | |
12687 | "Neighbor to display information about\n" | |
a80beece | 12688 | "Neighbor on bgp configured interface\n" |
95cbbd2a | 12689 | "Display the advertised routes to neighbor\n" |
856ca177 MS |
12690 | "Display the received routes from neighbor\n" |
12691 | "JavaScript Object Notation\n") | |
95cbbd2a ML |
12692 | { |
12693 | int afi; | |
12694 | int safi; | |
12695 | int in; | |
12696 | struct peer *peer; | |
db7c8528 | 12697 | u_char uj = use_json(argc, argv); |
856ca177 | 12698 | |
6aeb9e78 | 12699 | peer = peer_lookup_in_view (vty, argv[1], argv[4], uj); |
95cbbd2a ML |
12700 | |
12701 | if (! peer) | |
12702 | return CMD_WARNING; | |
12703 | ||
6aeb9e78 DS |
12704 | afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
12705 | safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
12706 | in = (strncmp (argv[5], "r", 1) == 0) ? 1 : 0; | |
95cbbd2a | 12707 | |
db7c8528 | 12708 | return peer_adj_routes (vty, peer, afi, safi, in, NULL, uj); |
95cbbd2a ML |
12709 | } |
12710 | ||
718e3744 | 12711 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
12712 | show_ip_bgp_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12713 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 12714 | SHOW_STR |
12715 | IP_STR | |
12716 | BGP_STR | |
12717 | "Detailed information on TCP and BGP neighbor connections\n" | |
12718 | "Neighbor to display information about\n" | |
12719 | "Neighbor to display information about\n" | |
a80beece | 12720 | "Neighbor on bgp configured interface\n" |
718e3744 | 12721 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12722 | "Display the prefixlist filter\n" |
12723 | "JavaScript Object Notation\n") | |
718e3744 | 12724 | { |
12725 | char name[BUFSIZ]; | |
c63b83fe | 12726 | union sockunion su; |
718e3744 | 12727 | struct peer *peer; |
c63b83fe | 12728 | int count, ret; |
db7c8528 | 12729 | u_char uj = use_json(argc, argv); |
718e3744 | 12730 | |
c63b83fe JBD |
12731 | ret = str2sockunion (argv[0], &su); |
12732 | if (ret < 0) | |
12733 | { | |
a80beece | 12734 | peer = peer_lookup_by_conf_if (NULL, argv[0]); |
856ca177 | 12735 | if (! peer) |
a80beece | 12736 | { |
db7c8528 | 12737 | if (uj) |
856ca177 MS |
12738 | { |
12739 | json_object *json_no = NULL; | |
12740 | json_object *json_sub = NULL; | |
12741 | json_no = json_object_new_object(); | |
12742 | json_sub = json_object_new_object(); | |
12743 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
12744 | json_object_string_add(json_sub, "warningCause", argv[0]); | |
12745 | json_object_object_add(json_no, "detail", json_sub); | |
12746 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12747 | json_object_free(json_no); | |
12748 | } | |
12749 | else | |
12750 | vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE); | |
a80beece DS |
12751 | return CMD_WARNING; |
12752 | } | |
12753 | } | |
12754 | else | |
12755 | { | |
12756 | peer = peer_lookup (NULL, &su); | |
12757 | if (! peer) | |
856ca177 | 12758 | { |
db7c8528 | 12759 | if (uj) |
856ca177 MS |
12760 | { |
12761 | json_object *json_no = NULL; | |
12762 | json_no = json_object_new_object(); | |
12763 | json_object_string_add(json_no, "warning", "Peer not found"); | |
12764 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12765 | json_object_free(json_no); | |
12766 | } | |
12767 | else | |
12768 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
12769 | return CMD_WARNING; | |
12770 | } | |
c63b83fe | 12771 | } |
718e3744 | 12772 | |
12773 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
db7c8528 | 12774 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); |
718e3744 | 12775 | if (count) |
12776 | { | |
db7c8528 | 12777 | if (!uj) |
856ca177 | 12778 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
db7c8528 | 12779 | prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); |
856ca177 MS |
12780 | } |
12781 | else | |
12782 | { | |
db7c8528 | 12783 | if (uj) |
856ca177 MS |
12784 | { |
12785 | json_object *json_no = NULL; | |
12786 | json_no = json_object_new_object(); | |
12787 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12788 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12789 | json_object_free(json_no); | |
12790 | } | |
12791 | else | |
12792 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
718e3744 | 12793 | } |
12794 | ||
12795 | return CMD_SUCCESS; | |
12796 | } | |
12797 | ||
12798 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, | |
12799 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12800 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 12801 | SHOW_STR |
12802 | IP_STR | |
12803 | BGP_STR | |
12804 | "Address family\n" | |
12805 | "Address Family modifier\n" | |
12806 | "Address Family modifier\n" | |
12807 | "Detailed information on TCP and BGP neighbor connections\n" | |
12808 | "Neighbor to display information about\n" | |
12809 | "Neighbor to display information about\n" | |
a80beece | 12810 | "Neighbor on bgp configured interface\n" |
718e3744 | 12811 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12812 | "Display the prefixlist filter\n" |
12813 | "JavaScript Object Notation\n") | |
718e3744 | 12814 | { |
12815 | char name[BUFSIZ]; | |
c63b83fe | 12816 | union sockunion su; |
718e3744 | 12817 | struct peer *peer; |
c63b83fe | 12818 | int count, ret; |
db7c8528 | 12819 | u_char uj = use_json(argc, argv); |
718e3744 | 12820 | |
c63b83fe JBD |
12821 | ret = str2sockunion (argv[1], &su); |
12822 | if (ret < 0) | |
12823 | { | |
a80beece | 12824 | peer = peer_lookup_by_conf_if (NULL, argv[1]); |
856ca177 | 12825 | if (! peer) |
a80beece | 12826 | { |
db7c8528 | 12827 | if (uj) |
856ca177 MS |
12828 | { |
12829 | json_object *json_no = NULL; | |
12830 | json_object *json_sub = NULL; | |
12831 | json_no = json_object_new_object(); | |
12832 | json_sub = json_object_new_object(); | |
12833 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
12834 | json_object_string_add(json_sub, "warningCause", argv[1]); | |
12835 | json_object_object_add(json_no, "detail", json_sub); | |
12836 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12837 | json_object_free(json_no); | |
12838 | } | |
12839 | else | |
12840 | vty_out (vty, "%% Malformed address or name: %s%s", argv[1], VTY_NEWLINE); | |
a80beece DS |
12841 | return CMD_WARNING; |
12842 | } | |
12843 | } | |
12844 | else | |
12845 | { | |
12846 | peer = peer_lookup (NULL, &su); | |
12847 | if (! peer) | |
856ca177 | 12848 | { |
db7c8528 | 12849 | if (uj) |
856ca177 MS |
12850 | { |
12851 | json_object *json_no = NULL; | |
12852 | json_no = json_object_new_object(); | |
12853 | json_object_string_add(json_no, "warning", "Peer not found"); | |
12854 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12855 | json_object_free(json_no); | |
12856 | } | |
12857 | else | |
12858 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
12859 | return CMD_WARNING; | |
12860 | } | |
c63b83fe | 12861 | } |
718e3744 | 12862 | |
12863 | if (strncmp (argv[0], "m", 1) == 0) | |
12864 | { | |
12865 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); | |
db7c8528 | 12866 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); |
718e3744 | 12867 | if (count) |
856ca177 | 12868 | { |
db7c8528 | 12869 | if (!uj) |
856ca177 | 12870 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
db7c8528 | 12871 | prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); |
856ca177 MS |
12872 | } |
12873 | else | |
12874 | { | |
db7c8528 | 12875 | if (uj) |
856ca177 MS |
12876 | { |
12877 | json_object *json_no = NULL; | |
12878 | json_no = json_object_new_object(); | |
12879 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12880 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12881 | json_object_free(json_no); | |
12882 | } | |
12883 | else | |
12884 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
12885 | } | |
718e3744 | 12886 | } |
12887 | else | |
12888 | { | |
12889 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
db7c8528 | 12890 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); |
718e3744 | 12891 | if (count) |
856ca177 | 12892 | { |
db7c8528 | 12893 | if (!uj) |
856ca177 | 12894 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
db7c8528 | 12895 | prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); |
856ca177 MS |
12896 | } |
12897 | else | |
12898 | { | |
db7c8528 | 12899 | if (uj) |
856ca177 MS |
12900 | { |
12901 | json_object *json_no = NULL; | |
12902 | json_no = json_object_new_object(); | |
12903 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12904 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12905 | json_object_free(json_no); | |
12906 | } | |
12907 | else | |
12908 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
12909 | } | |
718e3744 | 12910 | } |
12911 | ||
12912 | return CMD_SUCCESS; | |
12913 | } | |
718e3744 | 12914 | #ifdef HAVE_IPV6 |
50ef26d4 | 12915 | DEFUN (show_bgp_neighbor_received_routes, |
718e3744 | 12916 | show_bgp_neighbor_received_routes_cmd, |
856ca177 | 12917 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 12918 | SHOW_STR |
12919 | BGP_STR | |
12920 | "Detailed information on TCP and BGP neighbor connections\n" | |
12921 | "Neighbor to display information about\n" | |
12922 | "Neighbor to display information about\n" | |
a80beece | 12923 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12924 | "Display the received routes from neighbor\n" |
12925 | "JavaScript Object Notation\n") | |
50ef26d4 | 12926 | { |
12927 | struct peer *peer; | |
12928 | const char *rmap_name = NULL; | |
12929 | u_char uj = use_json(argc, argv); | |
718e3744 | 12930 | |
50ef26d4 | 12931 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
12932 | ||
12933 | if (! peer) | |
12934 | return CMD_WARNING; | |
12935 | ||
12936 | if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) | |
12937 | rmap_name = argv[1]; | |
12938 | ||
12939 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, rmap_name, uj); | |
12940 | } | |
12941 | ||
12942 | ALIAS (show_bgp_neighbor_received_routes, | |
718e3744 | 12943 | show_bgp_ipv6_neighbor_received_routes_cmd, |
856ca177 | 12944 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
0b16f239 DS |
12945 | SHOW_STR |
12946 | BGP_STR | |
12947 | "Address family\n" | |
12948 | "Detailed information on TCP and BGP neighbor connections\n" | |
12949 | "Neighbor to display information about\n" | |
12950 | "Neighbor to display information about\n" | |
12951 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12952 | "Display the received routes from neighbor\n" |
12953 | "JavaScript Object Notation\n") | |
0b16f239 | 12954 | |
718e3744 | 12955 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
12956 | show_bgp_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12957 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 12958 | SHOW_STR |
12959 | BGP_STR | |
12960 | "Detailed information on TCP and BGP neighbor connections\n" | |
12961 | "Neighbor to display information about\n" | |
12962 | "Neighbor to display information about\n" | |
a80beece | 12963 | "Neighbor on bgp configured interface\n" |
718e3744 | 12964 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12965 | "Display the prefixlist filter\n" |
12966 | "JavaScript Object Notation\n") | |
718e3744 | 12967 | { |
12968 | char name[BUFSIZ]; | |
c63b83fe | 12969 | union sockunion su; |
718e3744 | 12970 | struct peer *peer; |
c63b83fe | 12971 | int count, ret; |
db7c8528 | 12972 | u_char uj = use_json(argc, argv); |
718e3744 | 12973 | |
c63b83fe JBD |
12974 | ret = str2sockunion (argv[0], &su); |
12975 | if (ret < 0) | |
12976 | { | |
a80beece | 12977 | peer = peer_lookup_by_conf_if (NULL, argv[0]); |
856ca177 | 12978 | if (! peer) |
a80beece | 12979 | { |
db7c8528 | 12980 | if (uj) |
856ca177 MS |
12981 | { |
12982 | json_object *json_no = NULL; | |
12983 | json_object *json_sub = NULL; | |
12984 | json_no = json_object_new_object(); | |
12985 | json_sub = json_object_new_object(); | |
12986 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
12987 | json_object_string_add(json_sub, "warningCause", argv[0]); | |
12988 | json_object_object_add(json_no, "detail", json_sub); | |
12989 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12990 | json_object_free(json_no); | |
12991 | } | |
12992 | else | |
12993 | vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE); | |
a80beece DS |
12994 | return CMD_WARNING; |
12995 | } | |
12996 | } | |
12997 | else | |
12998 | { | |
12999 | peer = peer_lookup (NULL, &su); | |
13000 | if (! peer) | |
856ca177 | 13001 | { |
db7c8528 | 13002 | if (uj) |
856ca177 MS |
13003 | { |
13004 | json_object *json_no = NULL; | |
13005 | json_no = json_object_new_object(); | |
13006 | json_object_string_add(json_no, "warning", "No Peer"); | |
13007 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13008 | json_object_free(json_no); | |
13009 | } | |
13010 | else | |
13011 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
13012 | return CMD_WARNING; | |
13013 | } | |
c63b83fe | 13014 | } |
718e3744 | 13015 | |
13016 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
db7c8528 | 13017 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name, uj); |
718e3744 | 13018 | if (count) |
13019 | { | |
db7c8528 | 13020 | if (!uj) |
856ca177 | 13021 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
db7c8528 | 13022 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name, uj); |
856ca177 MS |
13023 | } |
13024 | else | |
13025 | { | |
db7c8528 | 13026 | if (uj) |
856ca177 MS |
13027 | { |
13028 | json_object *json_no = NULL; | |
13029 | json_no = json_object_new_object(); | |
13030 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
13031 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13032 | json_object_free(json_no); | |
13033 | } | |
13034 | else | |
13035 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
718e3744 | 13036 | } |
13037 | ||
13038 | return CMD_SUCCESS; | |
13039 | } | |
13040 | ||
13041 | ALIAS (show_bgp_neighbor_received_prefix_filter, | |
13042 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, | |
856ca177 | 13043 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 13044 | SHOW_STR |
13045 | BGP_STR | |
13046 | "Address family\n" | |
13047 | "Detailed information on TCP and BGP neighbor connections\n" | |
13048 | "Neighbor to display information about\n" | |
13049 | "Neighbor to display information about\n" | |
a80beece | 13050 | "Neighbor on bgp configured interface\n" |
718e3744 | 13051 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
13052 | "Display the prefixlist filter\n" |
13053 | "JavaScript Object Notation\n") | |
718e3744 | 13054 | |
13055 | /* old command */ | |
50ef26d4 | 13056 | ALIAS (show_bgp_neighbor_received_routes, |
718e3744 | 13057 | ipv6_bgp_neighbor_received_routes_cmd, |
856ca177 | 13058 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 13059 | SHOW_STR |
13060 | IPV6_STR | |
13061 | BGP_STR | |
13062 | "Detailed information on TCP and BGP neighbor connections\n" | |
13063 | "Neighbor to display information about\n" | |
13064 | "Neighbor to display information about\n" | |
a80beece | 13065 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13066 | "Display the received routes from neighbor\n" |
13067 | "JavaScript Object Notation\n") | |
718e3744 | 13068 | |
13069 | /* old command */ | |
13070 | DEFUN (ipv6_mbgp_neighbor_received_routes, | |
13071 | ipv6_mbgp_neighbor_received_routes_cmd, | |
856ca177 | 13072 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 13073 | SHOW_STR |
13074 | IPV6_STR | |
13075 | MBGP_STR | |
13076 | "Detailed information on TCP and BGP neighbor connections\n" | |
13077 | "Neighbor to display information about\n" | |
13078 | "Neighbor to display information about\n" | |
a80beece | 13079 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13080 | "Display the received routes from neighbor\n" |
13081 | "JavaScript Object Notation\n") | |
718e3744 | 13082 | { |
bb46e94f | 13083 | struct peer *peer; |
db7c8528 | 13084 | u_char uj = use_json(argc, argv); |
bb46e94f | 13085 | |
db7c8528 | 13086 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13087 | if (! peer) |
13088 | return CMD_WARNING; | |
13089 | ||
47e9b292 | 13090 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 13091 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1, NULL, uj); |
bb46e94f | 13092 | } |
13093 | ||
8386ac43 | 13094 | DEFUN (show_bgp_instance_neighbor_received_prefix_filter, |
13095 | show_bgp_instance_neighbor_received_prefix_filter_cmd, | |
13096 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", | |
bb46e94f | 13097 | SHOW_STR |
13098 | BGP_STR | |
8386ac43 | 13099 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13100 | "Detailed information on TCP and BGP neighbor connections\n" |
13101 | "Neighbor to display information about\n" | |
13102 | "Neighbor to display information about\n" | |
a80beece | 13103 | "Neighbor on bgp configured interface\n" |
bb46e94f | 13104 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
13105 | "Display the prefixlist filter\n" |
13106 | "JavaScript Object Notation\n") | |
bb46e94f | 13107 | { |
13108 | char name[BUFSIZ]; | |
c63b83fe | 13109 | union sockunion su; |
bb46e94f | 13110 | struct peer *peer; |
13111 | struct bgp *bgp; | |
c63b83fe | 13112 | int count, ret; |
db7c8528 | 13113 | u_char uj = use_json(argc, argv); |
bb46e94f | 13114 | |
13115 | /* BGP structure lookup. */ | |
6aeb9e78 | 13116 | bgp = bgp_lookup_by_name (argv[1]); |
bb46e94f | 13117 | if (bgp == NULL) |
856ca177 | 13118 | { |
db7c8528 | 13119 | if (uj) |
856ca177 MS |
13120 | { |
13121 | json_object *json_no = NULL; | |
13122 | json_no = json_object_new_object(); | |
13123 | json_object_string_add(json_no, "warning", "Can't find BGP view"); | |
13124 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13125 | json_object_free(json_no); | |
13126 | } | |
13127 | else | |
6aeb9e78 | 13128 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
856ca177 MS |
13129 | return CMD_WARNING; |
13130 | } | |
13131 | ||
6aeb9e78 | 13132 | ret = str2sockunion (argv[2], &su); |
c63b83fe JBD |
13133 | if (ret < 0) |
13134 | { | |
6aeb9e78 | 13135 | peer = peer_lookup_by_conf_if (bgp, argv[2]); |
856ca177 | 13136 | if (! peer) |
a80beece | 13137 | { |
db7c8528 | 13138 | if (uj) |
856ca177 MS |
13139 | { |
13140 | json_object *json_no = NULL; | |
13141 | json_object *json_sub = NULL; | |
13142 | json_no = json_object_new_object(); | |
13143 | json_sub = json_object_new_object(); | |
13144 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
6aeb9e78 | 13145 | json_object_string_add(json_sub, "warningCause", argv[2]); |
856ca177 MS |
13146 | json_object_object_add(json_no, "detail", json_sub); |
13147 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13148 | json_object_free(json_no); | |
13149 | } | |
13150 | else | |
6aeb9e78 | 13151 | vty_out (vty, "%% Malformed address or name: %s%s", argv[2], VTY_NEWLINE); |
a80beece DS |
13152 | return CMD_WARNING; |
13153 | } | |
13154 | } | |
13155 | else | |
13156 | { | |
13157 | peer = peer_lookup (bgp, &su); | |
13158 | if (! peer) | |
856ca177 | 13159 | { |
db7c8528 | 13160 | if (uj) |
856ca177 MS |
13161 | { |
13162 | json_object *json_no = NULL; | |
13163 | json_no = json_object_new_object(); | |
13164 | json_object_boolean_true_add(json_no, "noPeer"); | |
13165 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13166 | json_object_free(json_no); | |
13167 | } | |
13168 | else | |
13169 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
13170 | return CMD_WARNING; | |
13171 | } | |
13172 | ||
c63b83fe | 13173 | } |
bb46e94f | 13174 | |
13175 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
db7c8528 | 13176 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name, uj); |
bb46e94f | 13177 | if (count) |
13178 | { | |
db7c8528 | 13179 | if (!uj) |
856ca177 | 13180 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
db7c8528 | 13181 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name, uj); |
bb46e94f | 13182 | } |
13183 | ||
13184 | return CMD_SUCCESS; | |
718e3744 | 13185 | } |
8386ac43 | 13186 | ALIAS (show_bgp_instance_neighbor_received_prefix_filter, |
13187 | show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd, | |
13188 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", | |
bb46e94f | 13189 | SHOW_STR |
13190 | BGP_STR | |
8386ac43 | 13191 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13192 | "Address family\n" |
13193 | "Detailed information on TCP and BGP neighbor connections\n" | |
13194 | "Neighbor to display information about\n" | |
13195 | "Neighbor to display information about\n" | |
a80beece | 13196 | "Neighbor on bgp configured interface\n" |
bb46e94f | 13197 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
13198 | "Display the prefixlist filter\n" |
13199 | "JavaScript Object NOtation\n") | |
718e3744 | 13200 | #endif /* HAVE_IPV6 */ |
6b0655a2 | 13201 | |
94f2b392 | 13202 | static int |
bb46e94f | 13203 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
856ca177 | 13204 | safi_t safi, enum bgp_show_type type, u_char use_json) |
718e3744 | 13205 | { |
718e3744 | 13206 | if (! peer || ! peer->afc[afi][safi]) |
13207 | { | |
856ca177 MS |
13208 | if (use_json) |
13209 | { | |
13210 | json_object *json_no = NULL; | |
13211 | json_no = json_object_new_object(); | |
13212 | json_object_string_add(json_no, "warning", "No such neighbor or address family"); | |
13213 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13214 | json_object_free(json_no); | |
13215 | } | |
13216 | else | |
13217 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
718e3744 | 13218 | return CMD_WARNING; |
13219 | } | |
47fc97cc | 13220 | |
856ca177 | 13221 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su, use_json); |
718e3744 | 13222 | } |
13223 | ||
13224 | DEFUN (show_ip_bgp_neighbor_routes, | |
13225 | show_ip_bgp_neighbor_routes_cmd, | |
856ca177 | 13226 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13227 | SHOW_STR |
13228 | IP_STR | |
13229 | BGP_STR | |
13230 | "Detailed information on TCP and BGP neighbor connections\n" | |
13231 | "Neighbor to display information about\n" | |
13232 | "Neighbor to display information about\n" | |
a80beece | 13233 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13234 | "Display routes learned from neighbor\n" |
13235 | "JavaScript Object Notation\n") | |
718e3744 | 13236 | { |
bb46e94f | 13237 | struct peer *peer; |
db7c8528 | 13238 | u_char uj = use_json(argc, argv); |
856ca177 | 13239 | |
db7c8528 | 13240 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13241 | if (! peer) |
13242 | return CMD_WARNING; | |
13243 | ||
13244 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
db7c8528 | 13245 | bgp_show_type_neighbor, uj); |
718e3744 | 13246 | } |
13247 | ||
8386ac43 | 13248 | DEFUN (show_ip_bgp_instance_neighbor_routes, |
13249 | show_ip_bgp_instance_neighbor_routes_cmd, | |
13250 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", | |
50ef26d4 | 13251 | SHOW_STR |
13252 | IP_STR | |
13253 | BGP_STR | |
8386ac43 | 13254 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 13255 | "Detailed information on TCP and BGP neighbor connections\n" |
13256 | "Neighbor to display information about\n" | |
13257 | "Neighbor to display information about\n" | |
13258 | "Neighbor on bgp configured interface\n" | |
13259 | "Display routes learned from neighbor\n" | |
13260 | "JavaScript Object Notation\n") | |
13261 | { | |
13262 | struct peer *peer; | |
13263 | u_char uj = use_json(argc, argv); | |
13264 | ||
13265 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
13266 | if (! peer) | |
13267 | return CMD_WARNING; | |
13268 | ||
13269 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
13270 | bgp_show_type_neighbor, uj); | |
13271 | } | |
13272 | ||
718e3744 | 13273 | DEFUN (show_ip_bgp_neighbor_flap, |
13274 | show_ip_bgp_neighbor_flap_cmd, | |
856ca177 | 13275 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", |
718e3744 | 13276 | SHOW_STR |
13277 | IP_STR | |
13278 | BGP_STR | |
13279 | "Detailed information on TCP and BGP neighbor connections\n" | |
13280 | "Neighbor to display information about\n" | |
13281 | "Neighbor to display information about\n" | |
a80beece | 13282 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13283 | "Display flap statistics of the routes learned from neighbor\n" |
13284 | "JavaScript Object Notation\n") | |
718e3744 | 13285 | { |
bb46e94f | 13286 | struct peer *peer; |
db7c8528 | 13287 | u_char uj = use_json(argc, argv); |
856ca177 | 13288 | |
db7c8528 | 13289 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13290 | if (! peer) |
13291 | return CMD_WARNING; | |
13292 | ||
13293 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
db7c8528 | 13294 | bgp_show_type_flap_neighbor, uj); |
718e3744 | 13295 | } |
13296 | ||
13297 | DEFUN (show_ip_bgp_neighbor_damp, | |
13298 | show_ip_bgp_neighbor_damp_cmd, | |
856ca177 | 13299 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", |
718e3744 | 13300 | SHOW_STR |
13301 | IP_STR | |
13302 | BGP_STR | |
13303 | "Detailed information on TCP and BGP neighbor connections\n" | |
13304 | "Neighbor to display information about\n" | |
13305 | "Neighbor to display information about\n" | |
a80beece | 13306 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13307 | "Display the dampened routes received from neighbor\n" |
13308 | "JavaScript Object Notation\n") | |
718e3744 | 13309 | { |
bb46e94f | 13310 | struct peer *peer; |
db7c8528 | 13311 | u_char uj = use_json(argc, argv); |
856ca177 | 13312 | |
db7c8528 | 13313 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13314 | if (! peer) |
13315 | return CMD_WARNING; | |
13316 | ||
13317 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
db7c8528 | 13318 | bgp_show_type_damp_neighbor, uj); |
718e3744 | 13319 | } |
13320 | ||
13321 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, | |
13322 | show_ip_bgp_ipv4_neighbor_routes_cmd, | |
856ca177 | 13323 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13324 | SHOW_STR |
13325 | IP_STR | |
13326 | BGP_STR | |
13327 | "Address family\n" | |
13328 | "Address Family modifier\n" | |
13329 | "Address Family modifier\n" | |
13330 | "Detailed information on TCP and BGP neighbor connections\n" | |
13331 | "Neighbor to display information about\n" | |
13332 | "Neighbor to display information about\n" | |
a80beece | 13333 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13334 | "Display routes learned from neighbor\n" |
13335 | "JavaScript Object Notation\n") | |
718e3744 | 13336 | { |
bb46e94f | 13337 | struct peer *peer; |
db7c8528 | 13338 | u_char uj = use_json(argc, argv); |
bb46e94f | 13339 | |
db7c8528 | 13340 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 13341 | if (! peer) |
13342 | return CMD_WARNING; | |
13343 | ||
718e3744 | 13344 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 13345 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
db7c8528 | 13346 | bgp_show_type_neighbor, uj); |
718e3744 | 13347 | |
bb46e94f | 13348 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
db7c8528 | 13349 | bgp_show_type_neighbor, uj); |
718e3744 | 13350 | } |
bb46e94f | 13351 | |
2a3d5731 | 13352 | #ifdef HAVE_IPV6 |
8386ac43 | 13353 | DEFUN (show_bgp_instance_neighbor_routes, |
13354 | show_bgp_instance_neighbor_routes_cmd, | |
13355 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", | |
fee0f4c6 | 13356 | SHOW_STR |
fee0f4c6 | 13357 | BGP_STR |
8386ac43 | 13358 | BGP_INSTANCE_HELP_STR |
2a3d5731 DW |
13359 | "Detailed information on TCP and BGP neighbor connections\n" |
13360 | "Neighbor to display information about\n" | |
13361 | "Neighbor to display information about\n" | |
13362 | "Neighbor on bgp configured interface\n" | |
13363 | "Display routes learned from neighbor\n" | |
13364 | "JavaScript Object Notation\n") | |
fee0f4c6 | 13365 | { |
fee0f4c6 | 13366 | struct peer *peer; |
db7c8528 | 13367 | u_char uj = use_json(argc, argv); |
fee0f4c6 | 13368 | |
50ef26d4 | 13369 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); |
fee0f4c6 | 13370 | if (! peer) |
13371 | return CMD_WARNING; | |
13372 | ||
2a3d5731 | 13373 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
db7c8528 | 13374 | bgp_show_type_neighbor, uj); |
fee0f4c6 | 13375 | } |
13376 | ||
8386ac43 | 13377 | ALIAS (show_bgp_instance_neighbor_routes, |
13378 | show_bgp_instance_ipv6_neighbor_routes_cmd, | |
13379 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", | |
fee0f4c6 | 13380 | SHOW_STR |
fee0f4c6 | 13381 | BGP_STR |
8386ac43 | 13382 | BGP_INSTANCE_HELP_STR |
2a3d5731 DW |
13383 | "Address family\n" |
13384 | "Detailed information on TCP and BGP neighbor connections\n" | |
13385 | "Neighbor to display information about\n" | |
13386 | "Neighbor to display information about\n" | |
13387 | "Neighbor on bgp configured interface\n" | |
13388 | "Display routes learned from neighbor\n" | |
13389 | "JavaScript Object Notation\n") | |
fee0f4c6 | 13390 | |
8386ac43 | 13391 | DEFUN (show_bgp_instance_neighbor_damp, |
13392 | show_bgp_instance_neighbor_damp_cmd, | |
13393 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", | |
fee0f4c6 | 13394 | SHOW_STR |
fee0f4c6 | 13395 | BGP_STR |
8386ac43 | 13396 | BGP_INSTANCE_HELP_STR |
2a3d5731 DW |
13397 | "Detailed information on TCP and BGP neighbor connections\n" |
13398 | "Neighbor to display information about\n" | |
13399 | "Neighbor to display information about\n" | |
13400 | "Neighbor on bgp configured interface\n" | |
13401 | "Display the dampened routes received from neighbor\n" | |
13402 | "JavaScript Object Notation\n") | |
bb46e94f | 13403 | { |
13404 | struct peer *peer; | |
db7c8528 | 13405 | u_char uj = use_json(argc, argv); |
856ca177 | 13406 | |
6aeb9e78 DS |
13407 | if ((argc == 4 && argv[3] && strcmp(argv[3], "json") == 0) |
13408 | || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) | |
13409 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
bb46e94f | 13410 | else |
6aeb9e78 | 13411 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 13412 | |
13413 | if (! peer) | |
13414 | return CMD_WARNING; | |
13415 | ||
13416 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
db7c8528 | 13417 | bgp_show_type_damp_neighbor, uj); |
bb46e94f | 13418 | } |
13419 | ||
8386ac43 | 13420 | ALIAS (show_bgp_instance_neighbor_damp, |
13421 | show_bgp_instance_ipv6_neighbor_damp_cmd, | |
13422 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", | |
bb46e94f | 13423 | SHOW_STR |
13424 | BGP_STR | |
8386ac43 | 13425 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13426 | "Address family\n" |
13427 | "Detailed information on TCP and BGP neighbor connections\n" | |
13428 | "Neighbor to display information about\n" | |
13429 | "Neighbor to display information about\n" | |
a80beece | 13430 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13431 | "Display the dampened routes received from neighbor\n" |
13432 | "JavaScript Object Notation\n") | |
bb46e94f | 13433 | |
8386ac43 | 13434 | DEFUN (show_bgp_instance_neighbor_flap, |
13435 | show_bgp_instance_neighbor_flap_cmd, | |
13436 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", | |
bb46e94f | 13437 | SHOW_STR |
13438 | BGP_STR | |
8386ac43 | 13439 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13440 | "Detailed information on TCP and BGP neighbor connections\n" |
13441 | "Neighbor to display information about\n" | |
13442 | "Neighbor to display information about\n" | |
a80beece | 13443 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13444 | "Display flap statistics of the routes learned from neighbor\n" |
13445 | "JavaScript Object Notation\n") | |
bb46e94f | 13446 | { |
13447 | struct peer *peer; | |
db7c8528 | 13448 | u_char uj = use_json(argc, argv); |
856ca177 | 13449 | |
6aeb9e78 DS |
13450 | if ((argc == 4 && argv[3] && strcmp(argv[3], "json") == 0) |
13451 | || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) | |
13452 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
bb46e94f | 13453 | else |
6aeb9e78 | 13454 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 13455 | |
13456 | if (! peer) | |
13457 | return CMD_WARNING; | |
13458 | ||
13459 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
db7c8528 | 13460 | bgp_show_type_flap_neighbor, uj); |
bb46e94f | 13461 | } |
13462 | ||
8386ac43 | 13463 | ALIAS (show_bgp_instance_neighbor_flap, |
13464 | show_bgp_instance_ipv6_neighbor_flap_cmd, | |
13465 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", | |
bb46e94f | 13466 | SHOW_STR |
13467 | BGP_STR | |
8386ac43 | 13468 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13469 | "Address family\n" |
13470 | "Detailed information on TCP and BGP neighbor connections\n" | |
13471 | "Neighbor to display information about\n" | |
13472 | "Neighbor to display information about\n" | |
a80beece | 13473 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13474 | "Display flap statistics of the routes learned from neighbor\n" |
13475 | "JavaScript Object Notation\n") | |
bb46e94f | 13476 | |
50ef26d4 | 13477 | DEFUN (show_bgp_neighbor_routes, |
bb46e94f | 13478 | show_bgp_neighbor_routes_cmd, |
856ca177 | 13479 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
bb46e94f | 13480 | SHOW_STR |
13481 | BGP_STR | |
13482 | "Detailed information on TCP and BGP neighbor connections\n" | |
13483 | "Neighbor to display information about\n" | |
13484 | "Neighbor to display information about\n" | |
a80beece | 13485 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13486 | "Display routes learned from neighbor\n" |
13487 | "JavaScript Object Notation\n") | |
50ef26d4 | 13488 | { |
13489 | struct peer *peer; | |
13490 | u_char uj = use_json(argc, argv); | |
bb46e94f | 13491 | |
50ef26d4 | 13492 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
13493 | if (! peer) | |
13494 | return CMD_WARNING; | |
bb46e94f | 13495 | |
50ef26d4 | 13496 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
13497 | bgp_show_type_neighbor, uj); | |
13498 | } | |
13499 | ||
13500 | ||
13501 | ALIAS (show_bgp_neighbor_routes, | |
718e3744 | 13502 | show_bgp_ipv6_neighbor_routes_cmd, |
856ca177 | 13503 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13504 | SHOW_STR |
13505 | BGP_STR | |
13506 | "Address family\n" | |
13507 | "Detailed information on TCP and BGP neighbor connections\n" | |
13508 | "Neighbor to display information about\n" | |
13509 | "Neighbor to display information about\n" | |
a80beece | 13510 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13511 | "Display routes learned from neighbor\n" |
13512 | "JavaScript Object Notation\n") | |
718e3744 | 13513 | |
13514 | /* old command */ | |
50ef26d4 | 13515 | ALIAS (show_bgp_neighbor_routes, |
718e3744 | 13516 | ipv6_bgp_neighbor_routes_cmd, |
856ca177 | 13517 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13518 | SHOW_STR |
13519 | IPV6_STR | |
13520 | BGP_STR | |
13521 | "Detailed information on TCP and BGP neighbor connections\n" | |
13522 | "Neighbor to display information about\n" | |
13523 | "Neighbor to display information about\n" | |
a80beece | 13524 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13525 | "Display routes learned from neighbor\n" |
13526 | "JavaScript Object Notation\n") | |
718e3744 | 13527 | |
13528 | /* old command */ | |
13529 | DEFUN (ipv6_mbgp_neighbor_routes, | |
13530 | ipv6_mbgp_neighbor_routes_cmd, | |
856ca177 | 13531 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13532 | SHOW_STR |
13533 | IPV6_STR | |
13534 | MBGP_STR | |
13535 | "Detailed information on TCP and BGP neighbor connections\n" | |
13536 | "Neighbor to display information about\n" | |
13537 | "Neighbor to display information about\n" | |
a80beece | 13538 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13539 | "Display routes learned from neighbor\n" |
13540 | "JavaScript Object Notation\n") | |
718e3744 | 13541 | { |
bb46e94f | 13542 | struct peer *peer; |
db7c8528 | 13543 | u_char uj = use_json(argc, argv); |
bb46e94f | 13544 | |
db7c8528 | 13545 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13546 | if (! peer) |
13547 | return CMD_WARNING; | |
13548 | ||
47e9b292 | 13549 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
bb46e94f | 13550 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
db7c8528 | 13551 | bgp_show_type_neighbor, uj); |
718e3744 | 13552 | } |
bb46e94f | 13553 | |
8386ac43 | 13554 | ALIAS (show_bgp_instance_neighbor_flap, |
bb46e94f | 13555 | show_bgp_neighbor_flap_cmd, |
856ca177 | 13556 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", |
bb46e94f | 13557 | SHOW_STR |
13558 | BGP_STR | |
13559 | "Detailed information on TCP and BGP neighbor connections\n" | |
13560 | "Neighbor to display information about\n" | |
13561 | "Neighbor to display information about\n" | |
a80beece | 13562 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13563 | "Display flap statistics of the routes learned from neighbor\n" |
13564 | "JavaScript Object Notation\n") | |
bb46e94f | 13565 | |
8386ac43 | 13566 | ALIAS (show_bgp_instance_neighbor_flap, |
bb46e94f | 13567 | show_bgp_ipv6_neighbor_flap_cmd, |
856ca177 | 13568 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", |
bb46e94f | 13569 | SHOW_STR |
13570 | BGP_STR | |
13571 | "Address family\n" | |
13572 | "Detailed information on TCP and BGP neighbor connections\n" | |
13573 | "Neighbor to display information about\n" | |
13574 | "Neighbor to display information about\n" | |
a80beece | 13575 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13576 | "Display flap statistics of the routes learned from neighbor\n" |
13577 | "JavaScript Object Notation\n") | |
bb46e94f | 13578 | |
8386ac43 | 13579 | ALIAS (show_bgp_instance_neighbor_damp, |
bb46e94f | 13580 | show_bgp_neighbor_damp_cmd, |
856ca177 | 13581 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", |
bb46e94f | 13582 | SHOW_STR |
13583 | BGP_STR | |
13584 | "Detailed information on TCP and BGP neighbor connections\n" | |
13585 | "Neighbor to display information about\n" | |
13586 | "Neighbor to display information about\n" | |
a80beece | 13587 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13588 | "Display the dampened routes received from neighbor\n" |
13589 | "JavaScript Object Notation\n") | |
bb46e94f | 13590 | |
8386ac43 | 13591 | ALIAS (show_bgp_instance_neighbor_damp, |
bb46e94f | 13592 | show_bgp_ipv6_neighbor_damp_cmd, |
856ca177 | 13593 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", |
bb46e94f | 13594 | SHOW_STR |
13595 | BGP_STR | |
13596 | "Address family\n" | |
13597 | "Detailed information on TCP and BGP neighbor connections\n" | |
13598 | "Neighbor to display information about\n" | |
13599 | "Neighbor to display information about\n" | |
a80beece | 13600 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13601 | "Display the dampened routes received from neighbor\n" |
13602 | "JavaScript Object Notation\n") | |
fee0f4c6 | 13603 | |
718e3744 | 13604 | #endif /* HAVE_IPV6 */ |
6b0655a2 | 13605 | |
718e3744 | 13606 | struct bgp_table *bgp_distance_table; |
13607 | ||
13608 | struct bgp_distance | |
13609 | { | |
13610 | /* Distance value for the IP source prefix. */ | |
13611 | u_char distance; | |
13612 | ||
13613 | /* Name of the access-list to be matched. */ | |
13614 | char *access_list; | |
13615 | }; | |
13616 | ||
94f2b392 | 13617 | static struct bgp_distance * |
66e5cd87 | 13618 | bgp_distance_new (void) |
718e3744 | 13619 | { |
393deb9b | 13620 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
718e3744 | 13621 | } |
13622 | ||
94f2b392 | 13623 | static void |
718e3744 | 13624 | bgp_distance_free (struct bgp_distance *bdistance) |
13625 | { | |
13626 | XFREE (MTYPE_BGP_DISTANCE, bdistance); | |
13627 | } | |
13628 | ||
94f2b392 | 13629 | static int |
fd79ac91 | 13630 | bgp_distance_set (struct vty *vty, const char *distance_str, |
13631 | const char *ip_str, const char *access_list_str) | |
718e3744 | 13632 | { |
13633 | int ret; | |
13634 | struct prefix_ipv4 p; | |
13635 | u_char distance; | |
13636 | struct bgp_node *rn; | |
13637 | struct bgp_distance *bdistance; | |
13638 | ||
13639 | ret = str2prefix_ipv4 (ip_str, &p); | |
13640 | if (ret == 0) | |
13641 | { | |
13642 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
13643 | return CMD_WARNING; | |
13644 | } | |
13645 | ||
13646 | distance = atoi (distance_str); | |
13647 | ||
13648 | /* Get BGP distance node. */ | |
13649 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); | |
13650 | if (rn->info) | |
13651 | { | |
13652 | bdistance = rn->info; | |
13653 | bgp_unlock_node (rn); | |
13654 | } | |
13655 | else | |
13656 | { | |
13657 | bdistance = bgp_distance_new (); | |
13658 | rn->info = bdistance; | |
13659 | } | |
13660 | ||
13661 | /* Set distance value. */ | |
13662 | bdistance->distance = distance; | |
13663 | ||
13664 | /* Reset access-list configuration. */ | |
13665 | if (bdistance->access_list) | |
13666 | { | |
6e919709 | 13667 | XFREE(MTYPE_AS_LIST, bdistance->access_list); |
718e3744 | 13668 | bdistance->access_list = NULL; |
13669 | } | |
13670 | if (access_list_str) | |
6e919709 | 13671 | bdistance->access_list = XSTRDUP(MTYPE_AS_LIST, access_list_str); |
718e3744 | 13672 | |
13673 | return CMD_SUCCESS; | |
13674 | } | |
13675 | ||
94f2b392 | 13676 | static int |
fd79ac91 | 13677 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
13678 | const char *ip_str, const char *access_list_str) | |
718e3744 | 13679 | { |
13680 | int ret; | |
1f9a9fff | 13681 | int distance; |
718e3744 | 13682 | struct prefix_ipv4 p; |
718e3744 | 13683 | struct bgp_node *rn; |
13684 | struct bgp_distance *bdistance; | |
13685 | ||
13686 | ret = str2prefix_ipv4 (ip_str, &p); | |
13687 | if (ret == 0) | |
13688 | { | |
13689 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
13690 | return CMD_WARNING; | |
13691 | } | |
13692 | ||
718e3744 | 13693 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
13694 | if (! rn) | |
13695 | { | |
13696 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); | |
13697 | return CMD_WARNING; | |
13698 | } | |
13699 | ||
13700 | bdistance = rn->info; | |
1f9a9fff PJ |
13701 | distance = atoi(distance_str); |
13702 | ||
13703 | if (bdistance->distance != distance) | |
13704 | { | |
13705 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); | |
13706 | return CMD_WARNING; | |
13707 | } | |
718e3744 | 13708 | |
13709 | if (bdistance->access_list) | |
6e919709 | 13710 | XFREE(MTYPE_AS_LIST, bdistance->access_list); |
718e3744 | 13711 | bgp_distance_free (bdistance); |
13712 | ||
13713 | rn->info = NULL; | |
13714 | bgp_unlock_node (rn); | |
13715 | bgp_unlock_node (rn); | |
13716 | ||
13717 | return CMD_SUCCESS; | |
13718 | } | |
13719 | ||
718e3744 | 13720 | /* Apply BGP information to distance method. */ |
13721 | u_char | |
13722 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) | |
13723 | { | |
13724 | struct bgp_node *rn; | |
13725 | struct prefix_ipv4 q; | |
13726 | struct peer *peer; | |
13727 | struct bgp_distance *bdistance; | |
13728 | struct access_list *alist; | |
13729 | struct bgp_static *bgp_static; | |
13730 | ||
13731 | if (! bgp) | |
13732 | return 0; | |
13733 | ||
13734 | if (p->family != AF_INET) | |
13735 | return 0; | |
13736 | ||
13737 | peer = rinfo->peer; | |
13738 | ||
13739 | if (peer->su.sa.sa_family != AF_INET) | |
13740 | return 0; | |
13741 | ||
13742 | memset (&q, 0, sizeof (struct prefix_ipv4)); | |
13743 | q.family = AF_INET; | |
13744 | q.prefix = peer->su.sin.sin_addr; | |
13745 | q.prefixlen = IPV4_MAX_BITLEN; | |
13746 | ||
13747 | /* Check source address. */ | |
13748 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); | |
13749 | if (rn) | |
13750 | { | |
13751 | bdistance = rn->info; | |
13752 | bgp_unlock_node (rn); | |
13753 | ||
13754 | if (bdistance->access_list) | |
13755 | { | |
13756 | alist = access_list_lookup (AFI_IP, bdistance->access_list); | |
13757 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) | |
13758 | return bdistance->distance; | |
13759 | } | |
13760 | else | |
13761 | return bdistance->distance; | |
13762 | } | |
13763 | ||
13764 | /* Backdoor check. */ | |
13765 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); | |
13766 | if (rn) | |
13767 | { | |
13768 | bgp_static = rn->info; | |
13769 | bgp_unlock_node (rn); | |
13770 | ||
13771 | if (bgp_static->backdoor) | |
13772 | { | |
13773 | if (bgp->distance_local) | |
13774 | return bgp->distance_local; | |
13775 | else | |
13776 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
13777 | } | |
13778 | } | |
13779 | ||
6d85b15b | 13780 | if (peer->sort == BGP_PEER_EBGP) |
718e3744 | 13781 | { |
13782 | if (bgp->distance_ebgp) | |
13783 | return bgp->distance_ebgp; | |
13784 | return ZEBRA_EBGP_DISTANCE_DEFAULT; | |
13785 | } | |
13786 | else | |
13787 | { | |
13788 | if (bgp->distance_ibgp) | |
13789 | return bgp->distance_ibgp; | |
13790 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
13791 | } | |
13792 | } | |
13793 | ||
13794 | DEFUN (bgp_distance, | |
13795 | bgp_distance_cmd, | |
13796 | "distance bgp <1-255> <1-255> <1-255>", | |
13797 | "Define an administrative distance\n" | |
13798 | "BGP distance\n" | |
13799 | "Distance for routes external to the AS\n" | |
13800 | "Distance for routes internal to the AS\n" | |
13801 | "Distance for local routes\n") | |
13802 | { | |
13803 | struct bgp *bgp; | |
13804 | ||
13805 | bgp = vty->index; | |
13806 | ||
13807 | bgp->distance_ebgp = atoi (argv[0]); | |
13808 | bgp->distance_ibgp = atoi (argv[1]); | |
13809 | bgp->distance_local = atoi (argv[2]); | |
13810 | return CMD_SUCCESS; | |
13811 | } | |
13812 | ||
13813 | DEFUN (no_bgp_distance, | |
13814 | no_bgp_distance_cmd, | |
13815 | "no distance bgp <1-255> <1-255> <1-255>", | |
13816 | NO_STR | |
13817 | "Define an administrative distance\n" | |
13818 | "BGP distance\n" | |
13819 | "Distance for routes external to the AS\n" | |
13820 | "Distance for routes internal to the AS\n" | |
13821 | "Distance for local routes\n") | |
13822 | { | |
13823 | struct bgp *bgp; | |
13824 | ||
13825 | bgp = vty->index; | |
13826 | ||
13827 | bgp->distance_ebgp= 0; | |
13828 | bgp->distance_ibgp = 0; | |
13829 | bgp->distance_local = 0; | |
13830 | return CMD_SUCCESS; | |
13831 | } | |
13832 | ||
13833 | ALIAS (no_bgp_distance, | |
13834 | no_bgp_distance2_cmd, | |
13835 | "no distance bgp", | |
13836 | NO_STR | |
13837 | "Define an administrative distance\n" | |
13838 | "BGP distance\n") | |
13839 | ||
13840 | DEFUN (bgp_distance_source, | |
13841 | bgp_distance_source_cmd, | |
13842 | "distance <1-255> A.B.C.D/M", | |
13843 | "Define an administrative distance\n" | |
13844 | "Administrative distance\n" | |
13845 | "IP source prefix\n") | |
13846 | { | |
13847 | bgp_distance_set (vty, argv[0], argv[1], NULL); | |
13848 | return CMD_SUCCESS; | |
13849 | } | |
13850 | ||
13851 | DEFUN (no_bgp_distance_source, | |
13852 | no_bgp_distance_source_cmd, | |
13853 | "no distance <1-255> A.B.C.D/M", | |
13854 | NO_STR | |
13855 | "Define an administrative distance\n" | |
13856 | "Administrative distance\n" | |
13857 | "IP source prefix\n") | |
13858 | { | |
13859 | bgp_distance_unset (vty, argv[0], argv[1], NULL); | |
13860 | return CMD_SUCCESS; | |
13861 | } | |
13862 | ||
13863 | DEFUN (bgp_distance_source_access_list, | |
13864 | bgp_distance_source_access_list_cmd, | |
13865 | "distance <1-255> A.B.C.D/M WORD", | |
13866 | "Define an administrative distance\n" | |
13867 | "Administrative distance\n" | |
13868 | "IP source prefix\n" | |
13869 | "Access list name\n") | |
13870 | { | |
13871 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); | |
13872 | return CMD_SUCCESS; | |
13873 | } | |
13874 | ||
13875 | DEFUN (no_bgp_distance_source_access_list, | |
13876 | no_bgp_distance_source_access_list_cmd, | |
13877 | "no distance <1-255> A.B.C.D/M WORD", | |
13878 | NO_STR | |
13879 | "Define an administrative distance\n" | |
13880 | "Administrative distance\n" | |
13881 | "IP source prefix\n" | |
13882 | "Access list name\n") | |
13883 | { | |
13884 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); | |
13885 | return CMD_SUCCESS; | |
13886 | } | |
6b0655a2 | 13887 | |
718e3744 | 13888 | DEFUN (bgp_damp_set, |
13889 | bgp_damp_set_cmd, | |
13890 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
13891 | "BGP Specific commands\n" | |
13892 | "Enable route-flap dampening\n" | |
13893 | "Half-life time for the penalty\n" | |
13894 | "Value to start reusing a route\n" | |
13895 | "Value to start suppressing a route\n" | |
13896 | "Maximum duration to suppress a stable route\n") | |
13897 | { | |
13898 | struct bgp *bgp; | |
13899 | int half = DEFAULT_HALF_LIFE * 60; | |
13900 | int reuse = DEFAULT_REUSE; | |
13901 | int suppress = DEFAULT_SUPPRESS; | |
13902 | int max = 4 * half; | |
13903 | ||
13904 | if (argc == 4) | |
13905 | { | |
13906 | half = atoi (argv[0]) * 60; | |
13907 | reuse = atoi (argv[1]); | |
13908 | suppress = atoi (argv[2]); | |
13909 | max = atoi (argv[3]) * 60; | |
13910 | } | |
13911 | else if (argc == 1) | |
13912 | { | |
13913 | half = atoi (argv[0]) * 60; | |
13914 | max = 4 * half; | |
13915 | } | |
13916 | ||
13917 | bgp = vty->index; | |
7ebe9748 B |
13918 | |
13919 | if (suppress < reuse) | |
13920 | { | |
13921 | vty_out (vty, "Suppress value cannot be less than reuse value %s", | |
13922 | VTY_NEWLINE); | |
13923 | return 0; | |
13924 | } | |
13925 | ||
718e3744 | 13926 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
13927 | half, reuse, suppress, max); | |
13928 | } | |
13929 | ||
13930 | ALIAS (bgp_damp_set, | |
13931 | bgp_damp_set2_cmd, | |
13932 | "bgp dampening <1-45>", | |
13933 | "BGP Specific commands\n" | |
13934 | "Enable route-flap dampening\n" | |
13935 | "Half-life time for the penalty\n") | |
13936 | ||
13937 | ALIAS (bgp_damp_set, | |
13938 | bgp_damp_set3_cmd, | |
13939 | "bgp dampening", | |
13940 | "BGP Specific commands\n" | |
13941 | "Enable route-flap dampening\n") | |
13942 | ||
13943 | DEFUN (bgp_damp_unset, | |
13944 | bgp_damp_unset_cmd, | |
13945 | "no bgp dampening", | |
13946 | NO_STR | |
13947 | "BGP Specific commands\n" | |
13948 | "Enable route-flap dampening\n") | |
13949 | { | |
13950 | struct bgp *bgp; | |
13951 | ||
13952 | bgp = vty->index; | |
13953 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); | |
13954 | } | |
13955 | ||
13956 | ALIAS (bgp_damp_unset, | |
13957 | bgp_damp_unset2_cmd, | |
13958 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
13959 | NO_STR | |
13960 | "BGP Specific commands\n" | |
13961 | "Enable route-flap dampening\n" | |
13962 | "Half-life time for the penalty\n" | |
13963 | "Value to start reusing a route\n" | |
13964 | "Value to start suppressing a route\n" | |
13965 | "Maximum duration to suppress a stable route\n") | |
13966 | ||
813d4307 DW |
13967 | ALIAS (bgp_damp_unset, |
13968 | bgp_damp_unset3_cmd, | |
13969 | "no bgp dampening <1-45>", | |
13970 | NO_STR | |
13971 | "BGP Specific commands\n" | |
13972 | "Enable route-flap dampening\n" | |
13973 | "Half-life time for the penalty\n") | |
13974 | ||
718e3744 | 13975 | DEFUN (show_ip_bgp_dampened_paths, |
13976 | show_ip_bgp_dampened_paths_cmd, | |
13977 | "show ip bgp dampened-paths", | |
13978 | SHOW_STR | |
13979 | IP_STR | |
13980 | BGP_STR | |
13981 | "Display paths suppressed due to dampening\n") | |
13982 | { | |
5a646650 | 13983 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
b05a1c8b | 13984 | NULL, 0); |
718e3744 | 13985 | } |
13986 | ||
81304aaf B |
13987 | ALIAS (show_ip_bgp_dampened_paths, |
13988 | show_ip_bgp_damp_dampened_paths_cmd, | |
13989 | "show ip bgp dampening dampened-paths", | |
13990 | SHOW_STR | |
13991 | IP_STR | |
13992 | BGP_STR | |
13993 | "Display detailed information about dampening\n" | |
13994 | "Display paths suppressed due to dampening\n") | |
13995 | ||
718e3744 | 13996 | DEFUN (show_ip_bgp_flap_statistics, |
13997 | show_ip_bgp_flap_statistics_cmd, | |
13998 | "show ip bgp flap-statistics", | |
13999 | SHOW_STR | |
14000 | IP_STR | |
14001 | BGP_STR | |
14002 | "Display flap statistics of routes\n") | |
14003 | { | |
5a646650 | 14004 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
b05a1c8b | 14005 | bgp_show_type_flap_statistics, NULL, 0); |
718e3744 | 14006 | } |
6b0655a2 | 14007 | |
81304aaf B |
14008 | ALIAS (show_ip_bgp_flap_statistics, |
14009 | show_ip_bgp_damp_flap_statistics_cmd, | |
14010 | "show ip bgp dampening flap-statistics", | |
14011 | SHOW_STR | |
14012 | IP_STR | |
14013 | BGP_STR | |
14014 | "Display detailed information about dampening\n" | |
14015 | "Display flap statistics of routes\n") | |
14016 | ||
718e3744 | 14017 | /* Display specified route of BGP table. */ |
94f2b392 | 14018 | static int |
fd79ac91 | 14019 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
14020 | const char *ip_str, afi_t afi, safi_t safi, | |
14021 | struct prefix_rd *prd, int prefix_check) | |
718e3744 | 14022 | { |
14023 | int ret; | |
14024 | struct prefix match; | |
14025 | struct bgp_node *rn; | |
14026 | struct bgp_node *rm; | |
14027 | struct bgp_info *ri; | |
14028 | struct bgp_info *ri_temp; | |
14029 | struct bgp *bgp; | |
14030 | struct bgp_table *table; | |
14031 | ||
14032 | /* BGP structure lookup. */ | |
14033 | if (view_name) | |
14034 | { | |
14035 | bgp = bgp_lookup_by_name (view_name); | |
14036 | if (bgp == NULL) | |
14037 | { | |
6aeb9e78 | 14038 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
718e3744 | 14039 | return CMD_WARNING; |
14040 | } | |
14041 | } | |
14042 | else | |
14043 | { | |
14044 | bgp = bgp_get_default (); | |
14045 | if (bgp == NULL) | |
14046 | { | |
14047 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
14048 | return CMD_WARNING; | |
14049 | } | |
14050 | } | |
14051 | ||
14052 | /* Check IP address argument. */ | |
14053 | ret = str2prefix (ip_str, &match); | |
14054 | if (! ret) | |
14055 | { | |
14056 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
14057 | return CMD_WARNING; | |
14058 | } | |
14059 | ||
14060 | match.family = afi2family (afi); | |
14061 | ||
587ff0fd | 14062 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 14063 | { |
587ff0fd | 14064 | for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn)) |
718e3744 | 14065 | { |
14066 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
14067 | continue; | |
14068 | ||
14069 | if ((table = rn->info) != NULL) | |
14070 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6c88b44d CC |
14071 | { |
14072 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) | |
14073 | { | |
14074 | ri = rm->info; | |
14075 | while (ri) | |
14076 | { | |
14077 | if (ri->extra && ri->extra->damp_info) | |
14078 | { | |
14079 | ri_temp = ri->next; | |
14080 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
14081 | ri = ri_temp; | |
14082 | } | |
14083 | else | |
14084 | ri = ri->next; | |
14085 | } | |
14086 | } | |
14087 | ||
14088 | bgp_unlock_node (rm); | |
14089 | } | |
718e3744 | 14090 | } |
14091 | } | |
14092 | else | |
14093 | { | |
14094 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) | |
6c88b44d CC |
14095 | { |
14096 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
14097 | { | |
14098 | ri = rn->info; | |
14099 | while (ri) | |
14100 | { | |
14101 | if (ri->extra && ri->extra->damp_info) | |
14102 | { | |
14103 | ri_temp = ri->next; | |
14104 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
14105 | ri = ri_temp; | |
14106 | } | |
14107 | else | |
14108 | ri = ri->next; | |
14109 | } | |
14110 | } | |
14111 | ||
14112 | bgp_unlock_node (rn); | |
14113 | } | |
718e3744 | 14114 | } |
14115 | ||
14116 | return CMD_SUCCESS; | |
14117 | } | |
14118 | ||
14119 | DEFUN (clear_ip_bgp_dampening, | |
14120 | clear_ip_bgp_dampening_cmd, | |
14121 | "clear ip bgp dampening", | |
14122 | CLEAR_STR | |
14123 | IP_STR | |
14124 | BGP_STR | |
14125 | "Clear route flap dampening information\n") | |
14126 | { | |
14127 | bgp_damp_info_clean (); | |
14128 | return CMD_SUCCESS; | |
14129 | } | |
14130 | ||
14131 | DEFUN (clear_ip_bgp_dampening_prefix, | |
14132 | clear_ip_bgp_dampening_prefix_cmd, | |
14133 | "clear ip bgp dampening A.B.C.D/M", | |
14134 | CLEAR_STR | |
14135 | IP_STR | |
14136 | BGP_STR | |
14137 | "Clear route flap dampening information\n" | |
14138 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
14139 | { | |
14140 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
14141 | SAFI_UNICAST, NULL, 1); | |
14142 | } | |
14143 | ||
14144 | DEFUN (clear_ip_bgp_dampening_address, | |
14145 | clear_ip_bgp_dampening_address_cmd, | |
14146 | "clear ip bgp dampening A.B.C.D", | |
14147 | CLEAR_STR | |
14148 | IP_STR | |
14149 | BGP_STR | |
14150 | "Clear route flap dampening information\n" | |
14151 | "Network to clear damping information\n") | |
14152 | { | |
14153 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
14154 | SAFI_UNICAST, NULL, 0); | |
14155 | } | |
14156 | ||
14157 | DEFUN (clear_ip_bgp_dampening_address_mask, | |
14158 | clear_ip_bgp_dampening_address_mask_cmd, | |
14159 | "clear ip bgp dampening A.B.C.D A.B.C.D", | |
14160 | CLEAR_STR | |
14161 | IP_STR | |
14162 | BGP_STR | |
14163 | "Clear route flap dampening information\n" | |
14164 | "Network to clear damping information\n" | |
14165 | "Network mask\n") | |
14166 | { | |
14167 | int ret; | |
14168 | char prefix_str[BUFSIZ]; | |
14169 | ||
14170 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
14171 | if (! ret) | |
14172 | { | |
14173 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
14174 | return CMD_WARNING; | |
14175 | } | |
14176 | ||
14177 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, | |
14178 | SAFI_UNICAST, NULL, 0); | |
14179 | } | |
6b0655a2 | 14180 | |
587ff0fd | 14181 | /* also used for encap safi */ |
94f2b392 | 14182 | static int |
718e3744 | 14183 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
14184 | afi_t afi, safi_t safi, int *write) | |
14185 | { | |
14186 | struct bgp_node *prn; | |
14187 | struct bgp_node *rn; | |
14188 | struct bgp_table *table; | |
14189 | struct prefix *p; | |
14190 | struct prefix_rd *prd; | |
14191 | struct bgp_static *bgp_static; | |
14192 | u_int32_t label; | |
14193 | char buf[SU_ADDRSTRLEN]; | |
14194 | char rdbuf[RD_ADDRSTRLEN]; | |
14195 | ||
14196 | /* Network configuration. */ | |
14197 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) | |
14198 | if ((table = prn->info) != NULL) | |
14199 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
14200 | if ((bgp_static = rn->info) != NULL) | |
14201 | { | |
14202 | p = &rn->p; | |
14203 | prd = (struct prefix_rd *) &prn->p; | |
14204 | ||
14205 | /* "address-family" display. */ | |
14206 | bgp_config_write_family_header (vty, afi, safi, write); | |
14207 | ||
14208 | /* "network" configuration display. */ | |
14209 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); | |
14210 | label = decode_label (bgp_static->tag); | |
14211 | ||
0b960b4d | 14212 | vty_out (vty, " network %s/%d rd %s tag %d", |
718e3744 | 14213 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
14214 | p->prefixlen, | |
14215 | rdbuf, label); | |
14216 | vty_out (vty, "%s", VTY_NEWLINE); | |
14217 | } | |
14218 | return 0; | |
14219 | } | |
14220 | ||
14221 | /* Configuration of static route announcement and aggregate | |
14222 | information. */ | |
14223 | int | |
14224 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, | |
14225 | afi_t afi, safi_t safi, int *write) | |
14226 | { | |
14227 | struct bgp_node *rn; | |
14228 | struct prefix *p; | |
14229 | struct bgp_static *bgp_static; | |
14230 | struct bgp_aggregate *bgp_aggregate; | |
14231 | char buf[SU_ADDRSTRLEN]; | |
14232 | ||
587ff0fd | 14233 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
718e3744 | 14234 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
14235 | ||
14236 | /* Network configuration. */ | |
14237 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
14238 | if ((bgp_static = rn->info) != NULL) | |
14239 | { | |
14240 | p = &rn->p; | |
14241 | ||
14242 | /* "address-family" display. */ | |
14243 | bgp_config_write_family_header (vty, afi, safi, write); | |
14244 | ||
14245 | /* "network" configuration display. */ | |
14246 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
14247 | { | |
14248 | u_int32_t destination; | |
14249 | struct in_addr netmask; | |
14250 | ||
14251 | destination = ntohl (p->u.prefix4.s_addr); | |
14252 | masklen2ip (p->prefixlen, &netmask); | |
0b960b4d | 14253 | vty_out (vty, " network %s", |
718e3744 | 14254 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
14255 | ||
14256 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
14257 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
14258 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
14259 | || p->u.prefix4.s_addr == 0) | |
14260 | { | |
14261 | /* Natural mask is not display. */ | |
14262 | } | |
14263 | else | |
14264 | vty_out (vty, " mask %s", inet_ntoa (netmask)); | |
14265 | } | |
14266 | else | |
14267 | { | |
0b960b4d | 14268 | vty_out (vty, " network %s/%d", |
718e3744 | 14269 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
14270 | p->prefixlen); | |
14271 | } | |
14272 | ||
14273 | if (bgp_static->rmap.name) | |
14274 | vty_out (vty, " route-map %s", bgp_static->rmap.name); | |
41367172 PJ |
14275 | else |
14276 | { | |
14277 | if (bgp_static->backdoor) | |
14278 | vty_out (vty, " backdoor"); | |
41367172 | 14279 | } |
718e3744 | 14280 | |
14281 | vty_out (vty, "%s", VTY_NEWLINE); | |
14282 | } | |
14283 | ||
14284 | /* Aggregate-address configuration. */ | |
14285 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) | |
14286 | if ((bgp_aggregate = rn->info) != NULL) | |
14287 | { | |
14288 | p = &rn->p; | |
14289 | ||
14290 | /* "address-family" display. */ | |
14291 | bgp_config_write_family_header (vty, afi, safi, write); | |
14292 | ||
14293 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
14294 | { | |
14295 | struct in_addr netmask; | |
14296 | ||
14297 | masklen2ip (p->prefixlen, &netmask); | |
0b960b4d | 14298 | vty_out (vty, " aggregate-address %s %s", |
718e3744 | 14299 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
14300 | inet_ntoa (netmask)); | |
14301 | } | |
14302 | else | |
14303 | { | |
0b960b4d | 14304 | vty_out (vty, " aggregate-address %s/%d", |
718e3744 | 14305 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
14306 | p->prefixlen); | |
14307 | } | |
14308 | ||
14309 | if (bgp_aggregate->as_set) | |
14310 | vty_out (vty, " as-set"); | |
14311 | ||
14312 | if (bgp_aggregate->summary_only) | |
14313 | vty_out (vty, " summary-only"); | |
14314 | ||
14315 | vty_out (vty, "%s", VTY_NEWLINE); | |
14316 | } | |
14317 | ||
14318 | return 0; | |
14319 | } | |
14320 | ||
14321 | int | |
14322 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) | |
14323 | { | |
14324 | struct bgp_node *rn; | |
14325 | struct bgp_distance *bdistance; | |
14326 | ||
14327 | /* Distance configuration. */ | |
14328 | if (bgp->distance_ebgp | |
14329 | && bgp->distance_ibgp | |
14330 | && bgp->distance_local | |
14331 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT | |
14332 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT | |
14333 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) | |
14334 | vty_out (vty, " distance bgp %d %d %d%s", | |
14335 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, | |
14336 | VTY_NEWLINE); | |
14337 | ||
14338 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) | |
14339 | if ((bdistance = rn->info) != NULL) | |
14340 | { | |
14341 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, | |
14342 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
14343 | bdistance->access_list ? bdistance->access_list : "", | |
14344 | VTY_NEWLINE); | |
14345 | } | |
14346 | ||
14347 | return 0; | |
14348 | } | |
14349 | ||
14350 | /* Allocate routing table structure and install commands. */ | |
14351 | void | |
66e5cd87 | 14352 | bgp_route_init (void) |
718e3744 | 14353 | { |
14354 | /* Init BGP distance table. */ | |
64e580a7 | 14355 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
718e3744 | 14356 | |
14357 | /* IPv4 BGP commands. */ | |
73ac8160 | 14358 | install_element (BGP_NODE, &bgp_table_map_cmd); |
718e3744 | 14359 | install_element (BGP_NODE, &bgp_network_cmd); |
14360 | install_element (BGP_NODE, &bgp_network_mask_cmd); | |
14361 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); | |
14362 | install_element (BGP_NODE, &bgp_network_route_map_cmd); | |
14363 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); | |
14364 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); | |
14365 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); | |
14366 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); | |
14367 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); | |
73ac8160 | 14368 | install_element (BGP_NODE, &no_bgp_table_map_cmd); |
718e3744 | 14369 | install_element (BGP_NODE, &no_bgp_network_cmd); |
14370 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); | |
14371 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); | |
14372 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); | |
14373 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); | |
14374 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
14375 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); | |
14376 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); | |
14377 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); | |
14378 | ||
14379 | install_element (BGP_NODE, &aggregate_address_cmd); | |
14380 | install_element (BGP_NODE, &aggregate_address_mask_cmd); | |
14381 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); | |
14382 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); | |
14383 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); | |
14384 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); | |
14385 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); | |
14386 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
14387 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); | |
14388 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
14389 | install_element (BGP_NODE, &no_aggregate_address_cmd); | |
14390 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); | |
14391 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); | |
14392 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); | |
14393 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); | |
14394 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); | |
14395 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
14396 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); | |
14397 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
14398 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
14399 | ||
14400 | /* IPv4 unicast configuration. */ | |
73ac8160 | 14401 | install_element (BGP_IPV4_NODE, &bgp_table_map_cmd); |
718e3744 | 14402 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
14403 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); | |
14404 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); | |
14405 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); | |
14406 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); | |
14407 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); | |
73ac8160 | 14408 | install_element (BGP_IPV4_NODE, &no_bgp_table_map_cmd); |
c8f3fe30 | 14409 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
718e3744 | 14410 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
14411 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); | |
14412 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); | |
14413 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); | |
14414 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
c8f3fe30 | 14415 | |
718e3744 | 14416 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
14417 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); | |
14418 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); | |
14419 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); | |
14420 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); | |
14421 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); | |
14422 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); | |
14423 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
14424 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); | |
14425 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
14426 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); | |
14427 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); | |
14428 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); | |
14429 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); | |
14430 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); | |
14431 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); | |
14432 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
14433 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); | |
14434 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
14435 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
14436 | ||
14437 | /* IPv4 multicast configuration. */ | |
73ac8160 | 14438 | install_element (BGP_IPV4M_NODE, &bgp_table_map_cmd); |
718e3744 | 14439 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
14440 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); | |
14441 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); | |
14442 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); | |
14443 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); | |
14444 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); | |
73ac8160 | 14445 | install_element (BGP_IPV4M_NODE, &no_bgp_table_map_cmd); |
718e3744 | 14446 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
14447 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); | |
14448 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); | |
14449 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); | |
14450 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); | |
14451 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
14452 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); | |
14453 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); | |
14454 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); | |
14455 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); | |
14456 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); | |
14457 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); | |
14458 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); | |
14459 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
14460 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); | |
14461 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
14462 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); | |
14463 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); | |
14464 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); | |
14465 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); | |
14466 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); | |
14467 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); | |
14468 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
14469 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); | |
14470 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
14471 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
14472 | ||
14473 | install_element (VIEW_NODE, &show_ip_bgp_cmd); | |
8386ac43 | 14474 | install_element (VIEW_NODE, &show_ip_bgp_instance_cmd); |
f186de26 | 14475 | install_element (VIEW_NODE, &show_ip_bgp_instance_all_cmd); |
718e3744 | 14476 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
95cbbd2a | 14477 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 14478 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
8386ac43 | 14479 | install_element (VIEW_NODE, &show_ip_bgp_instance_route_cmd); |
4092b06c | 14480 | install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); |
8386ac43 | 14481 | install_element (VIEW_NODE, &show_ip_bgp_instance_route_pathtype_cmd); |
4092b06c | 14482 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
718e3744 | 14483 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
95cbbd2a | 14484 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 14485 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
14486 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
14487 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); | |
8386ac43 | 14488 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_cmd); |
718e3744 | 14489 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
4092b06c DS |
14490 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
14491 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); | |
95cbbd2a | 14492 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
4092b06c | 14493 | install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
8386ac43 | 14494 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); |
718e3744 | 14495 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
14496 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
50ef26d4 | 14497 | |
718e3744 | 14498 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
14499 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
14500 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); | |
8386ac43 | 14501 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_list_cmd); |
718e3744 | 14502 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
14503 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); | |
8386ac43 | 14504 | install_element (VIEW_NODE, &show_ip_bgp_instance_filter_list_cmd); |
718e3744 | 14505 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
14506 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); | |
8386ac43 | 14507 | install_element (VIEW_NODE, &show_ip_bgp_instance_route_map_cmd); |
718e3744 | 14508 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
14509 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); | |
14510 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
14511 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); | |
14512 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
14513 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); | |
14514 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); | |
14515 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); | |
14516 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); | |
14517 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); | |
14518 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
14519 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
14520 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
8386ac43 | 14521 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_all_cmd); |
14522 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_cmd); | |
14523 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community2_cmd); | |
14524 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community3_cmd); | |
14525 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community4_cmd); | |
718e3744 | 14526 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
14527 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); | |
14528 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); | |
14529 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); | |
14530 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
14531 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
14532 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
14533 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
14534 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); | |
8386ac43 | 14535 | install_element (VIEW_NODE, &show_ip_bgp_instance_community_list_cmd); |
718e3744 | 14536 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
14537 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); | |
14538 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
14539 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); | |
8386ac43 | 14540 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_longer_cmd); |
718e3744 | 14541 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
14542 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
8386ac43 | 14543 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); |
0b16f239 | 14544 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_rmap_cmd); |
8386ac43 | 14545 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14546 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
0b16f239 | 14547 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14548 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
8386ac43 | 14549 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd); |
0b16f239 | 14550 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14551 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd); |
718e3744 | 14552 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
0b16f239 | 14553 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14554 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 14555 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
8386ac43 | 14556 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_routes_cmd); |
718e3744 | 14557 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
14558 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
14559 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
81304aaf | 14560 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
58a90275 | 14561 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
718e3744 | 14562 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
58a90275 B |
14563 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); |
14564 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); | |
81304aaf | 14565 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
718e3744 | 14566 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
81304aaf | 14567 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
718e3744 | 14568 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
81304aaf | 14569 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
718e3744 | 14570 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
14571 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
81304aaf | 14572 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
718e3744 | 14573 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
14574 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
81304aaf | 14575 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
718e3744 | 14576 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
81304aaf | 14577 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
718e3744 | 14578 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
81304aaf | 14579 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
718e3744 | 14580 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
81304aaf | 14581 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
718e3744 | 14582 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
14583 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
62687ff1 PJ |
14584 | |
14585 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ | |
14586 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); | |
8386ac43 | 14587 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd); |
4092b06c | 14588 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd); |
8386ac43 | 14589 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_pathtype_cmd); |
4092b06c | 14590 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
62687ff1 | 14591 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
95cbbd2a | 14592 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
62687ff1 PJ |
14593 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
14594 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); | |
8386ac43 | 14595 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd); |
62687ff1 | 14596 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
4092b06c DS |
14597 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
14598 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); | |
95cbbd2a | 14599 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
4092b06c | 14600 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
8386ac43 | 14601 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); |
62687ff1 PJ |
14602 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
14603 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
8386ac43 | 14604 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd); |
14605 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd); | |
62687ff1 PJ |
14606 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
14607 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); | |
14608 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); | |
14609 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); | |
14610 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); | |
14611 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
14612 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
14613 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
8386ac43 | 14614 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_all_cmd); |
14615 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_cmd); | |
14616 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community2_cmd); | |
14617 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community3_cmd); | |
14618 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community4_cmd); | |
62687ff1 PJ |
14619 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
14620 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); | |
14621 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); | |
14622 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); | |
14623 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
14624 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
14625 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
14626 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
718e3744 | 14627 | |
14628 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); | |
8386ac43 | 14629 | install_element (ENABLE_NODE, &show_ip_bgp_instance_cmd); |
f186de26 | 14630 | install_element (ENABLE_NODE, &show_ip_bgp_instance_all_cmd); |
718e3744 | 14631 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
95cbbd2a | 14632 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 14633 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
8386ac43 | 14634 | install_element (ENABLE_NODE, &show_ip_bgp_instance_route_cmd); |
4092b06c | 14635 | install_element (ENABLE_NODE, &show_ip_bgp_route_pathtype_cmd); |
8386ac43 | 14636 | install_element (ENABLE_NODE, &show_ip_bgp_instance_route_pathtype_cmd); |
4092b06c | 14637 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
718e3744 | 14638 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
95cbbd2a | 14639 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 14640 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
14641 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
14642 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); | |
8386ac43 | 14643 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_cmd); |
718e3744 | 14644 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
4092b06c DS |
14645 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
14646 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); | |
95cbbd2a | 14647 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
4092b06c | 14648 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
8386ac43 | 14649 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); |
718e3744 | 14650 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
14651 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
50ef26d4 | 14652 | |
718e3744 | 14653 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
14654 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
14655 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); | |
8386ac43 | 14656 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_list_cmd); |
718e3744 | 14657 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
14658 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); | |
8386ac43 | 14659 | install_element (ENABLE_NODE, &show_ip_bgp_instance_filter_list_cmd); |
718e3744 | 14660 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
14661 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); | |
8386ac43 | 14662 | install_element (ENABLE_NODE, &show_ip_bgp_instance_route_map_cmd); |
718e3744 | 14663 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
14664 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); | |
14665 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
14666 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); | |
14667 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
14668 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); | |
14669 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); | |
14670 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); | |
14671 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); | |
14672 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); | |
14673 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
14674 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
14675 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
8386ac43 | 14676 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_all_cmd); |
14677 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_cmd); | |
14678 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community2_cmd); | |
14679 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community3_cmd); | |
14680 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community4_cmd); | |
718e3744 | 14681 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
14682 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); | |
14683 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); | |
14684 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); | |
14685 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
14686 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
14687 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
14688 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
14689 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); | |
8386ac43 | 14690 | install_element (ENABLE_NODE, &show_ip_bgp_instance_community_list_cmd); |
718e3744 | 14691 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
14692 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); | |
14693 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
14694 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); | |
8386ac43 | 14695 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_longer_cmd); |
718e3744 | 14696 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
14697 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
8386ac43 | 14698 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); |
0b16f239 | 14699 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_rmap_cmd); |
8386ac43 | 14700 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14701 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
0b16f239 | 14702 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14703 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
8386ac43 | 14704 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd); |
0b16f239 | 14705 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14706 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd); |
718e3744 | 14707 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
0b16f239 | 14708 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14709 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 14710 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
8386ac43 | 14711 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_routes_cmd); |
718e3744 | 14712 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
14713 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
14714 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
81304aaf | 14715 | install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd); |
718e3744 | 14716 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
58a90275 B |
14717 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
14718 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); | |
14719 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); | |
81304aaf | 14720 | install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
718e3744 | 14721 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
81304aaf | 14722 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
718e3744 | 14723 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
81304aaf | 14724 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd); |
718e3744 | 14725 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
14726 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
81304aaf | 14727 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
718e3744 | 14728 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
81304aaf | 14729 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd); |
718e3744 | 14730 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
81304aaf | 14731 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
718e3744 | 14732 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
81304aaf B |
14733 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
14734 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); | |
718e3744 | 14735 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
81304aaf | 14736 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
718e3744 | 14737 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
81304aaf | 14738 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
718e3744 | 14739 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
14740 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
14741 | ||
14742 | /* BGP dampening clear commands */ | |
14743 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); | |
14744 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); | |
14745 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); | |
14746 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); | |
14747 | ||
ff7924f6 PJ |
14748 | /* prefix count */ |
14749 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); | |
8386ac43 | 14750 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_prefix_counts_cmd); |
ff7924f6 PJ |
14751 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
14752 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); | |
718e3744 | 14753 | #ifdef HAVE_IPV6 |
ff7924f6 | 14754 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
8386ac43 | 14755 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd); |
ff7924f6 | 14756 | |
718e3744 | 14757 | /* New config IPv6 BGP commands. */ |
73ac8160 | 14758 | install_element (BGP_IPV6_NODE, &bgp_table_map_cmd); |
718e3744 | 14759 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
14760 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); | |
73ac8160 | 14761 | install_element (BGP_IPV6_NODE, &no_bgp_table_map_cmd); |
718e3744 | 14762 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
14763 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); | |
14764 | ||
14765 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); | |
14766 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); | |
14767 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); | |
14768 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); | |
73bfe0bd B |
14769 | |
14770 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); | |
14771 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); | |
718e3744 | 14772 | |
14773 | /* Old config IPv6 BGP commands. */ | |
14774 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); | |
14775 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); | |
14776 | ||
14777 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); | |
14778 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); | |
14779 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); | |
14780 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); | |
14781 | ||
14782 | install_element (VIEW_NODE, &show_bgp_cmd); | |
14783 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 14784 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 14785 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
14786 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 14787 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
4092b06c DS |
14788 | install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd); |
14789 | install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd); | |
14790 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); | |
718e3744 | 14791 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
14792 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 14793 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
4092b06c DS |
14794 | install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd); |
14795 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); | |
14796 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); | |
718e3744 | 14797 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
14798 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); | |
14799 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); | |
14800 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
14801 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); | |
14802 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); | |
14803 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); | |
14804 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); | |
14805 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); | |
14806 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); | |
14807 | install_element (VIEW_NODE, &show_bgp_community_cmd); | |
14808 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); | |
14809 | install_element (VIEW_NODE, &show_bgp_community2_cmd); | |
14810 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); | |
14811 | install_element (VIEW_NODE, &show_bgp_community3_cmd); | |
14812 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); | |
14813 | install_element (VIEW_NODE, &show_bgp_community4_cmd); | |
14814 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); | |
14815 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); | |
14816 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); | |
14817 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); | |
14818 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
14819 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); | |
14820 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
14821 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); | |
14822 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
14823 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); | |
14824 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); | |
14825 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); | |
14826 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
14827 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); | |
14828 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
14829 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
14830 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
14831 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); | |
14832 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
14833 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); | |
14834 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
14835 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
14836 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 14837 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
14838 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
14839 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); | |
14840 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
8386ac43 | 14841 | install_element (VIEW_NODE, &show_bgp_instance_cmd); |
f186de26 | 14842 | install_element (VIEW_NODE, &show_bgp_instance_all_cmd); |
8386ac43 | 14843 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_cmd); |
14844 | install_element (VIEW_NODE, &show_bgp_instance_route_cmd); | |
14845 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_cmd); | |
14846 | install_element (VIEW_NODE, &show_bgp_instance_route_pathtype_cmd); | |
14847 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); | |
14848 | install_element (VIEW_NODE, &show_bgp_instance_prefix_cmd); | |
14849 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_cmd); | |
14850 | install_element (VIEW_NODE, &show_bgp_instance_prefix_pathtype_cmd); | |
14851 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_pathtype_cmd); | |
14852 | install_element (VIEW_NODE, &show_bgp_instance_prefix_list_cmd); | |
14853 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_list_cmd); | |
14854 | install_element (VIEW_NODE, &show_bgp_instance_filter_list_cmd); | |
14855 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_filter_list_cmd); | |
14856 | install_element (VIEW_NODE, &show_bgp_instance_route_map_cmd); | |
14857 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_map_cmd); | |
14858 | install_element (VIEW_NODE, &show_bgp_instance_community_list_cmd); | |
14859 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_community_list_cmd); | |
14860 | install_element (VIEW_NODE, &show_bgp_instance_prefix_longer_cmd); | |
14861 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_longer_cmd); | |
14862 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_advertised_route_cmd); | |
14863 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd); | |
14864 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_routes_cmd); | |
14865 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_received_routes_cmd); | |
14866 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_routes_cmd); | |
14867 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_routes_cmd); | |
14868 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); | |
14869 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); | |
14870 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_flap_cmd); | |
14871 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_flap_cmd); | |
14872 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_damp_cmd); | |
14873 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_damp_cmd); | |
62687ff1 PJ |
14874 | |
14875 | /* Restricted: | |
14876 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) | |
14877 | */ | |
14878 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); | |
14879 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 14880 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
4092b06c DS |
14881 | install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd); |
14882 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd); | |
14883 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); | |
62687ff1 PJ |
14884 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
14885 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 14886 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
4092b06c DS |
14887 | install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd); |
14888 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); | |
14889 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); | |
62687ff1 PJ |
14890 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
14891 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); | |
14892 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); | |
14893 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); | |
14894 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); | |
14895 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); | |
14896 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); | |
14897 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); | |
14898 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); | |
14899 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); | |
14900 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); | |
14901 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
14902 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); | |
14903 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
14904 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); | |
14905 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
8386ac43 | 14906 | install_element (RESTRICTED_NODE, &show_bgp_instance_route_cmd); |
14907 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_route_cmd); | |
14908 | install_element (RESTRICTED_NODE, &show_bgp_instance_route_pathtype_cmd); | |
14909 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); | |
14910 | install_element (RESTRICTED_NODE, &show_bgp_instance_prefix_cmd); | |
14911 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_prefix_cmd); | |
14912 | install_element (RESTRICTED_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); | |
14913 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); | |
718e3744 | 14914 | |
14915 | install_element (ENABLE_NODE, &show_bgp_cmd); | |
14916 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 14917 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 14918 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
14919 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 14920 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
4092b06c DS |
14921 | install_element (ENABLE_NODE, &show_bgp_route_pathtype_cmd); |
14922 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_pathtype_cmd); | |
14923 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); | |
718e3744 | 14924 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
4092b06c DS |
14925 | install_element (ENABLE_NODE, &show_bgp_prefix_pathtype_cmd); |
14926 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); | |
14927 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); | |
718e3744 | 14928 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
95cbbd2a | 14929 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
718e3744 | 14930 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
14931 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); | |
14932 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); | |
14933 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
14934 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); | |
14935 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); | |
14936 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); | |
14937 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); | |
14938 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); | |
14939 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); | |
14940 | install_element (ENABLE_NODE, &show_bgp_community_cmd); | |
14941 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); | |
14942 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); | |
14943 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); | |
14944 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); | |
14945 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); | |
14946 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); | |
14947 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); | |
14948 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); | |
14949 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); | |
14950 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); | |
14951 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
14952 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); | |
14953 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
14954 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); | |
14955 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
14956 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); | |
14957 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); | |
14958 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); | |
14959 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
14960 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); | |
14961 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
14962 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
14963 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
14964 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); | |
14965 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
14966 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); | |
14967 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
14968 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
14969 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 14970 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
14971 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
14972 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); | |
14973 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
8386ac43 | 14974 | install_element (ENABLE_NODE, &show_bgp_instance_cmd); |
f186de26 | 14975 | install_element (ENABLE_NODE, &show_bgp_instance_all_cmd); |
8386ac43 | 14976 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_cmd); |
14977 | install_element (ENABLE_NODE, &show_bgp_instance_route_cmd); | |
14978 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_cmd); | |
14979 | install_element (ENABLE_NODE, &show_bgp_instance_route_pathtype_cmd); | |
14980 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); | |
14981 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_cmd); | |
14982 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_cmd); | |
14983 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_pathtype_cmd); | |
14984 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_pathtype_cmd); | |
14985 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_list_cmd); | |
14986 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_list_cmd); | |
14987 | install_element (ENABLE_NODE, &show_bgp_instance_filter_list_cmd); | |
14988 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_filter_list_cmd); | |
14989 | install_element (ENABLE_NODE, &show_bgp_instance_route_map_cmd); | |
14990 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_map_cmd); | |
14991 | install_element (ENABLE_NODE, &show_bgp_instance_community_list_cmd); | |
14992 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_community_list_cmd); | |
14993 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_longer_cmd); | |
14994 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_longer_cmd); | |
14995 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_advertised_route_cmd); | |
14996 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd); | |
14997 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_routes_cmd); | |
14998 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_received_routes_cmd); | |
14999 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_routes_cmd); | |
15000 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_routes_cmd); | |
15001 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); | |
15002 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); | |
15003 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_flap_cmd); | |
15004 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_flap_cmd); | |
15005 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_damp_cmd); | |
15006 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_damp_cmd); | |
50ef26d4 | 15007 | |
2815e61f PJ |
15008 | /* Statistics */ |
15009 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); | |
587ff0fd | 15010 | //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
2815e61f | 15011 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
587ff0fd | 15012 | //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
2815e61f | 15013 | |
718e3744 | 15014 | /* old command */ |
15015 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); | |
15016 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); | |
15017 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); | |
15018 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); | |
15019 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
15020 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); | |
15021 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); | |
15022 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); | |
15023 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); | |
15024 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); | |
15025 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); | |
15026 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); | |
15027 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
15028 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
15029 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
15030 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); | |
15031 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
15032 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
15033 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); | |
15034 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); | |
15035 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); | |
15036 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); | |
15037 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
15038 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
15039 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); | |
15040 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); | |
15041 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); | |
15042 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); | |
15043 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); | |
15044 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
15045 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
15046 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
15047 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
15048 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); | |
15049 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
15050 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
bb46e94f | 15051 | |
718e3744 | 15052 | /* old command */ |
15053 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); | |
15054 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); | |
15055 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); | |
15056 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); | |
15057 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
15058 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); | |
15059 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); | |
15060 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); | |
15061 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); | |
15062 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); | |
15063 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); | |
15064 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); | |
15065 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
15066 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
15067 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
15068 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); | |
15069 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
15070 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
15071 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); | |
15072 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); | |
15073 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); | |
15074 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); | |
15075 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
15076 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
15077 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); | |
15078 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); | |
15079 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); | |
15080 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); | |
15081 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); | |
15082 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
15083 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
15084 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
15085 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
15086 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); | |
15087 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
15088 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
15089 | ||
15090 | /* old command */ | |
15091 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
15092 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
15093 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
15094 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
15095 | ||
15096 | /* old command */ | |
15097 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
15098 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
15099 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
15100 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
15101 | ||
15102 | /* old command */ | |
15103 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
15104 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
15105 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
15106 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
15107 | #endif /* HAVE_IPV6 */ | |
15108 | ||
15109 | install_element (BGP_NODE, &bgp_distance_cmd); | |
15110 | install_element (BGP_NODE, &no_bgp_distance_cmd); | |
15111 | install_element (BGP_NODE, &no_bgp_distance2_cmd); | |
15112 | install_element (BGP_NODE, &bgp_distance_source_cmd); | |
15113 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); | |
15114 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); | |
15115 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); | |
15116 | ||
15117 | install_element (BGP_NODE, &bgp_damp_set_cmd); | |
15118 | install_element (BGP_NODE, &bgp_damp_set2_cmd); | |
15119 | install_element (BGP_NODE, &bgp_damp_set3_cmd); | |
15120 | install_element (BGP_NODE, &bgp_damp_unset_cmd); | |
15121 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); | |
813d4307 | 15122 | install_element (BGP_NODE, &bgp_damp_unset3_cmd); |
718e3744 | 15123 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
15124 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); | |
15125 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); | |
15126 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); | |
15127 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); | |
813d4307 | 15128 | install_element (BGP_IPV4_NODE, &bgp_damp_unset3_cmd); |
5c9e5a8d B |
15129 | |
15130 | /* IPv4 Multicast Mode */ | |
15131 | install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd); | |
15132 | install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd); | |
15133 | install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd); | |
15134 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd); | |
15135 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd); | |
718e3744 | 15136 | } |
228da428 CC |
15137 | |
15138 | void | |
15139 | bgp_route_finish (void) | |
15140 | { | |
15141 | bgp_table_unlock (bgp_distance_table); | |
15142 | bgp_distance_table = NULL; | |
15143 | } |