]>
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 | ||
718e3744 | 80 | if (safi == SAFI_MPLS_VPN) |
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 | ||
93 | if (safi == SAFI_MPLS_VPN) | |
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 | |
718e3744 | 806 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
807 | ||
808 | if (ret == 1) | |
9fbdd100 DS |
809 | { |
810 | if (debug) | |
2ec1e66f DW |
811 | zlog_debug("%s: %s loses to %s due to Neighor IP comparison", |
812 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
813 | return 0; |
814 | } | |
815 | ||
718e3744 | 816 | if (ret == -1) |
9fbdd100 DS |
817 | { |
818 | if (debug) | |
2ec1e66f DW |
819 | zlog_debug("%s: %s wins over %s due to Neighor IP comparison", |
820 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
821 | return 1; |
822 | } | |
823 | ||
824 | if (debug) | |
2ec1e66f DW |
825 | zlog_debug("%s: %s wins over %s due to nothing left to compare", |
826 | pfx_buf, new_buf, exist_buf); | |
718e3744 | 827 | |
828 | return 1; | |
829 | } | |
830 | ||
94f2b392 | 831 | static enum filter_type |
718e3744 | 832 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
833 | afi_t afi, safi_t safi) | |
834 | { | |
835 | struct bgp_filter *filter; | |
836 | ||
837 | filter = &peer->filter[afi][safi]; | |
838 | ||
650f76c2 PJ |
839 | #define FILTER_EXIST_WARN(F,f,filter) \ |
840 | if (BGP_DEBUG (update, UPDATE_IN) \ | |
841 | && !(F ## _IN (filter))) \ | |
16286195 | 842 | zlog_warn ("%s: Could not find configured input %s-list %s!", \ |
650f76c2 PJ |
843 | peer->host, #f, F ## _IN_NAME(filter)); |
844 | ||
845 | if (DISTRIBUTE_IN_NAME (filter)) { | |
846 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
847 | ||
718e3744 | 848 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
849 | return FILTER_DENY; | |
650f76c2 | 850 | } |
718e3744 | 851 | |
650f76c2 PJ |
852 | if (PREFIX_LIST_IN_NAME (filter)) { |
853 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
854 | ||
718e3744 | 855 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
856 | return FILTER_DENY; | |
650f76c2 | 857 | } |
718e3744 | 858 | |
650f76c2 PJ |
859 | if (FILTER_LIST_IN_NAME (filter)) { |
860 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
861 | ||
718e3744 | 862 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
863 | return FILTER_DENY; | |
650f76c2 PJ |
864 | } |
865 | ||
718e3744 | 866 | return FILTER_PERMIT; |
650f76c2 | 867 | #undef FILTER_EXIST_WARN |
718e3744 | 868 | } |
869 | ||
94f2b392 | 870 | static enum filter_type |
718e3744 | 871 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
872 | afi_t afi, safi_t safi) | |
873 | { | |
874 | struct bgp_filter *filter; | |
875 | ||
876 | filter = &peer->filter[afi][safi]; | |
877 | ||
650f76c2 PJ |
878 | #define FILTER_EXIST_WARN(F,f,filter) \ |
879 | if (BGP_DEBUG (update, UPDATE_OUT) \ | |
880 | && !(F ## _OUT (filter))) \ | |
16286195 | 881 | zlog_warn ("%s: Could not find configured output %s-list %s!", \ |
650f76c2 PJ |
882 | peer->host, #f, F ## _OUT_NAME(filter)); |
883 | ||
884 | if (DISTRIBUTE_OUT_NAME (filter)) { | |
885 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
886 | ||
718e3744 | 887 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
888 | return FILTER_DENY; | |
650f76c2 | 889 | } |
718e3744 | 890 | |
650f76c2 PJ |
891 | if (PREFIX_LIST_OUT_NAME (filter)) { |
892 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
893 | ||
718e3744 | 894 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
895 | return FILTER_DENY; | |
650f76c2 | 896 | } |
718e3744 | 897 | |
650f76c2 PJ |
898 | if (FILTER_LIST_OUT_NAME (filter)) { |
899 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
900 | ||
718e3744 | 901 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
902 | return FILTER_DENY; | |
650f76c2 | 903 | } |
718e3744 | 904 | |
905 | return FILTER_PERMIT; | |
650f76c2 | 906 | #undef FILTER_EXIST_WARN |
718e3744 | 907 | } |
908 | ||
909 | /* If community attribute includes no_export then return 1. */ | |
94f2b392 | 910 | static int |
718e3744 | 911 | bgp_community_filter (struct peer *peer, struct attr *attr) |
912 | { | |
913 | if (attr->community) | |
914 | { | |
915 | /* NO_ADVERTISE check. */ | |
916 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) | |
917 | return 1; | |
918 | ||
919 | /* NO_EXPORT check. */ | |
6d85b15b | 920 | if (peer->sort == BGP_PEER_EBGP && |
718e3744 | 921 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
922 | return 1; | |
923 | ||
924 | /* NO_EXPORT_SUBCONFED check. */ | |
6d85b15b JBD |
925 | if (peer->sort == BGP_PEER_EBGP |
926 | || peer->sort == BGP_PEER_CONFED) | |
718e3744 | 927 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
928 | return 1; | |
929 | } | |
930 | return 0; | |
931 | } | |
932 | ||
933 | /* Route reflection loop check. */ | |
934 | static int | |
935 | bgp_cluster_filter (struct peer *peer, struct attr *attr) | |
936 | { | |
937 | struct in_addr cluster_id; | |
938 | ||
fb982c25 | 939 | if (attr->extra && attr->extra->cluster) |
718e3744 | 940 | { |
941 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) | |
942 | cluster_id = peer->bgp->cluster_id; | |
943 | else | |
944 | cluster_id = peer->bgp->router_id; | |
945 | ||
fb982c25 | 946 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
718e3744 | 947 | return 1; |
948 | } | |
949 | return 0; | |
950 | } | |
6b0655a2 | 951 | |
94f2b392 | 952 | static int |
718e3744 | 953 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
ffd0c037 | 954 | afi_t afi, safi_t safi, const char *rmap_name) |
718e3744 | 955 | { |
956 | struct bgp_filter *filter; | |
957 | struct bgp_info info; | |
958 | route_map_result_t ret; | |
0b16f239 | 959 | struct route_map *rmap = NULL; |
718e3744 | 960 | |
961 | filter = &peer->filter[afi][safi]; | |
962 | ||
963 | /* Apply default weight value. */ | |
fb982c25 PJ |
964 | if (peer->weight) |
965 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
718e3744 | 966 | |
0b16f239 DS |
967 | if (rmap_name) |
968 | { | |
969 | rmap = route_map_lookup_by_name(rmap_name); | |
98a4a44e DS |
970 | |
971 | if (rmap == NULL) | |
972 | return RMAP_DENY; | |
0b16f239 DS |
973 | } |
974 | else | |
975 | { | |
976 | if (ROUTE_MAP_IN_NAME(filter)) | |
98a4a44e DS |
977 | { |
978 | rmap = ROUTE_MAP_IN (filter); | |
979 | ||
980 | if (rmap == NULL) | |
981 | return RMAP_DENY; | |
982 | } | |
0b16f239 DS |
983 | } |
984 | ||
718e3744 | 985 | /* Route map apply. */ |
0b16f239 | 986 | if (rmap) |
718e3744 | 987 | { |
988 | /* Duplicate current value to new strucutre for modification. */ | |
989 | info.peer = peer; | |
990 | info.attr = attr; | |
991 | ||
ac41b2a2 | 992 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
993 | ||
718e3744 | 994 | /* Apply BGP route map to the attribute. */ |
0b16f239 DS |
995 | ret = route_map_apply (rmap, p, RMAP_BGP, &info); |
996 | ||
997 | peer->rmap_type = 0; | |
998 | ||
999 | if (ret == RMAP_DENYMATCH) | |
1000 | { | |
1001 | /* Free newly generated AS path and community by route-map. */ | |
1002 | bgp_attr_flush (attr); | |
1003 | return RMAP_DENY; | |
1004 | } | |
1005 | } | |
1006 | return RMAP_PERMIT; | |
1007 | } | |
1008 | ||
1009 | static int | |
1010 | bgp_output_modifier (struct peer *peer, struct prefix *p, struct attr *attr, | |
ffd0c037 | 1011 | afi_t afi, safi_t safi, const char *rmap_name) |
0b16f239 DS |
1012 | { |
1013 | struct bgp_filter *filter; | |
1014 | struct bgp_info info; | |
1015 | route_map_result_t ret; | |
1016 | struct route_map *rmap = NULL; | |
1017 | ||
1018 | filter = &peer->filter[afi][safi]; | |
1019 | ||
1020 | /* Apply default weight value. */ | |
1021 | if (peer->weight) | |
1022 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
1023 | ||
1024 | if (rmap_name) | |
1025 | { | |
1026 | rmap = route_map_lookup_by_name(rmap_name); | |
98a4a44e DS |
1027 | |
1028 | if (rmap == NULL) | |
1029 | return RMAP_DENY; | |
0b16f239 DS |
1030 | } |
1031 | else | |
1032 | { | |
1033 | if (ROUTE_MAP_OUT_NAME(filter)) | |
98a4a44e DS |
1034 | { |
1035 | rmap = ROUTE_MAP_OUT (filter); | |
1036 | ||
1037 | if (rmap == NULL) | |
1038 | return RMAP_DENY; | |
1039 | } | |
0b16f239 DS |
1040 | } |
1041 | ||
1042 | /* Route map apply. */ | |
1043 | if (rmap) | |
1044 | { | |
1045 | /* Duplicate current value to new strucutre for modification. */ | |
1046 | info.peer = peer; | |
1047 | info.attr = attr; | |
1048 | ||
1049 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1050 | ||
1051 | /* Apply BGP route map to the attribute. */ | |
1052 | ret = route_map_apply (rmap, p, RMAP_BGP, &info); | |
ac41b2a2 | 1053 | |
1054 | peer->rmap_type = 0; | |
1055 | ||
718e3744 | 1056 | if (ret == RMAP_DENYMATCH) |
c460e572 DL |
1057 | /* caller has multiple error paths with bgp_attr_flush() */ |
1058 | return RMAP_DENY; | |
718e3744 | 1059 | } |
1060 | return RMAP_PERMIT; | |
1061 | } | |
6b0655a2 | 1062 | |
5000f21c | 1063 | /* If this is an EBGP peer with remove-private-AS */ |
ffd0c037 | 1064 | static void |
5000f21c DS |
1065 | bgp_peer_remove_private_as(struct bgp *bgp, afi_t afi, safi_t safi, |
1066 | struct peer *peer, struct attr *attr) | |
1067 | { | |
1068 | if (peer->sort == BGP_PEER_EBGP && | |
88b8ed8d DW |
1069 | (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE) || |
1070 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE) || | |
1071 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL) || | |
1072 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS))) | |
5000f21c DS |
1073 | { |
1074 | // Take action on the entire aspath | |
88b8ed8d DW |
1075 | if (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_ALL)) | |
5000f21c | 1077 | { |
88b8ed8d | 1078 | if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
5000f21c DS |
1079 | attr->aspath = aspath_replace_private_asns (attr->aspath, bgp->as); |
1080 | ||
1081 | // The entire aspath consists of private ASNs so create an empty aspath | |
1082 | else if (aspath_private_as_check (attr->aspath)) | |
1083 | attr->aspath = aspath_empty_get (); | |
1084 | ||
1085 | // There are some public and some private ASNs, remove the private ASNs | |
1086 | else | |
1087 | attr->aspath = aspath_remove_private_asns (attr->aspath); | |
1088 | } | |
1089 | ||
1090 | // 'all' was not specified so the entire aspath must be private ASNs | |
1091 | // for us to do anything | |
1092 | else if (aspath_private_as_check (attr->aspath)) | |
1093 | { | |
1094 | if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
1095 | attr->aspath = aspath_replace_private_asns (attr->aspath, bgp->as); | |
1096 | else | |
1097 | attr->aspath = aspath_empty_get (); | |
1098 | } | |
1099 | } | |
1100 | } | |
1101 | ||
c7122e14 DS |
1102 | /* If this is an EBGP peer with as-override */ |
1103 | static void | |
1104 | bgp_peer_as_override(struct bgp *bgp, afi_t afi, safi_t safi, | |
1105 | struct peer *peer, struct attr *attr) | |
1106 | { | |
1107 | if (peer->sort == BGP_PEER_EBGP && | |
1108 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) | |
1109 | { | |
1110 | if (aspath_single_asn_check (attr->aspath, peer->as)) | |
1111 | attr->aspath = aspath_replace_specific_asn (attr->aspath, peer->as, bgp->as); | |
1112 | } | |
1113 | } | |
1114 | ||
3f9c7369 DS |
1115 | static void |
1116 | subgroup_announce_reset_nhop (u_char family, struct attr *attr) | |
1117 | { | |
1118 | if (family == AF_INET) | |
1119 | attr->nexthop.s_addr = 0; | |
1120 | #ifdef HAVE_IPV6 | |
1121 | if (family == AF_INET6) | |
1122 | memset (&attr->extra->mp_nexthop_global, 0, IPV6_MAX_BYTELEN); | |
1123 | #endif | |
1124 | } | |
1125 | ||
1126 | int | |
1127 | subgroup_announce_check (struct bgp_info *ri, struct update_subgroup *subgrp, | |
1128 | struct prefix *p, struct attr *attr) | |
1129 | { | |
1130 | struct bgp_filter *filter; | |
1131 | struct peer *from; | |
1132 | struct peer *peer; | |
1133 | struct peer *onlypeer; | |
1134 | struct bgp *bgp; | |
1135 | struct attr *riattr; | |
1136 | struct peer_af *paf; | |
1137 | char buf[SU_ADDRSTRLEN]; | |
1138 | int ret; | |
1139 | int transparent; | |
1140 | int reflect; | |
1141 | afi_t afi; | |
1142 | safi_t safi; | |
1143 | ||
1144 | if (DISABLE_BGP_ANNOUNCE) | |
1145 | return 0; | |
1146 | ||
1147 | afi = SUBGRP_AFI(subgrp); | |
1148 | safi = SUBGRP_SAFI(subgrp); | |
1149 | peer = SUBGRP_PEER(subgrp); | |
1150 | onlypeer = NULL; | |
1151 | if (CHECK_FLAG (peer->flags, PEER_FLAG_LONESOUL)) | |
1152 | onlypeer = SUBGRP_PFIRST(subgrp)->peer; | |
1153 | ||
1154 | from = ri->peer; | |
1155 | filter = &peer->filter[afi][safi]; | |
1156 | bgp = SUBGRP_INST(subgrp); | |
1157 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; | |
1158 | ||
adbac85e DW |
1159 | /* With addpath we may be asked to TX all kinds of paths so make sure |
1160 | * ri is valid */ | |
1161 | if (!CHECK_FLAG (ri->flags, BGP_INFO_VALID) || | |
1162 | CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) || | |
1163 | CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) | |
1164 | { | |
1165 | return 0; | |
1166 | } | |
1167 | ||
06370dac DW |
1168 | /* If this is not the bestpath then check to see if there is an enabled addpath |
1169 | * feature that requires us to advertise it */ | |
1170 | if (! CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1171 | { | |
1172 | if (! bgp_addpath_tx_path(peer, afi, safi, ri)) | |
1173 | { | |
1174 | return 0; | |
1175 | } | |
1176 | } | |
1177 | ||
3f9c7369 DS |
1178 | /* Aggregate-address suppress check. */ |
1179 | if (ri->extra && ri->extra->suppress) | |
1180 | if (! UNSUPPRESS_MAP_NAME (filter)) | |
1181 | { | |
1182 | return 0; | |
1183 | } | |
1184 | ||
3f9c7369 DS |
1185 | /* Do not send back route to sender. */ |
1186 | if (onlypeer && from == onlypeer) | |
1187 | { | |
1188 | return 0; | |
1189 | } | |
1190 | ||
4125bb67 DS |
1191 | /* Do not send the default route in the BGP table if the neighbor is |
1192 | * configured for default-originate */ | |
1193 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
1194 | { | |
1195 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
1196 | return 0; | |
1197 | #ifdef HAVE_IPV6 | |
1198 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
1199 | return 0; | |
1200 | #endif /* HAVE_IPV6 */ | |
1201 | } | |
1202 | ||
3f9c7369 DS |
1203 | /* Transparency check. */ |
1204 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) | |
1205 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
1206 | transparent = 1; | |
1207 | else | |
1208 | transparent = 0; | |
1209 | ||
1210 | /* If community is not disabled check the no-export and local. */ | |
1211 | if (! transparent && bgp_community_filter (peer, riattr)) | |
1212 | { | |
1213 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1214 | zlog_debug ("subgrpannouncecheck: community filter check fail"); | |
1215 | return 0; | |
1216 | } | |
1217 | ||
1218 | /* If the attribute has originator-id and it is same as remote | |
1219 | peer's id. */ | |
1220 | if (onlypeer && | |
1221 | riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) && | |
1222 | (IPV4_ADDR_SAME (&onlypeer->remote_id, &riattr->extra->originator_id))) | |
1223 | { | |
1224 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1225 | zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as " | |
1226 | "remote router-id", | |
1227 | onlypeer->host, | |
1228 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1229 | p->prefixlen); | |
1230 | return 0; | |
1231 | } | |
1232 | ||
1233 | /* ORF prefix-list filter check */ | |
1234 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
1235 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
1236 | || CHECK_FLAG (peer->af_cap[afi][safi], | |
1237 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
1238 | if (peer->orf_plist[afi][safi]) | |
1239 | { | |
1240 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) | |
1241 | { | |
40d2700d DW |
1242 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) |
1243 | zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF", | |
1244 | peer->host, | |
1245 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1246 | p->prefixlen); | |
3f9c7369 DS |
1247 | return 0; |
1248 | } | |
1249 | } | |
1250 | ||
1251 | /* Output filter check. */ | |
1252 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) | |
1253 | { | |
1254 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1255 | zlog_debug ("%s [Update:SEND] %s/%d is filtered", | |
1256 | peer->host, | |
1257 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1258 | p->prefixlen); | |
1259 | return 0; | |
1260 | } | |
1261 | ||
1262 | #ifdef BGP_SEND_ASPATH_CHECK | |
1263 | /* AS path loop check. */ | |
1264 | if (onlypeer && aspath_loop_check (riattr->aspath, onlypeer->as)) | |
1265 | { | |
1266 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1267 | zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u " | |
1268 | "that is part of AS path.", | |
1269 | onlypeer->host, onlypeer->as); | |
1270 | return 0; | |
1271 | } | |
1272 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
1273 | ||
1274 | /* If we're a CONFED we need to loop check the CONFED ID too */ | |
1275 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
1276 | { | |
1277 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) | |
1278 | { | |
1279 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1280 | zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u" | |
1281 | " is AS path.", | |
1282 | peer->host, | |
1283 | bgp->confed_id); | |
1284 | return 0; | |
1285 | } | |
1286 | } | |
1287 | ||
1288 | /* Route-Reflect check. */ | |
1289 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) | |
1290 | reflect = 1; | |
1291 | else | |
1292 | reflect = 0; | |
1293 | ||
1294 | /* IBGP reflection check. */ | |
1295 | if (reflect) | |
1296 | { | |
1297 | /* A route from a Client peer. */ | |
1298 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
1299 | { | |
1300 | /* Reflect to all the Non-Client peers and also to the | |
1301 | Client peers other than the originator. Originator check | |
1302 | is already done. So there is noting to do. */ | |
1303 | /* no bgp client-to-client reflection check. */ | |
1304 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
1305 | if (CHECK_FLAG (peer->af_flags[afi][safi], | |
1306 | PEER_FLAG_REFLECTOR_CLIENT)) | |
1307 | return 0; | |
1308 | } | |
1309 | else | |
1310 | { | |
1311 | /* A route from a Non-client peer. Reflect to all other | |
1312 | clients. */ | |
1313 | if (! CHECK_FLAG (peer->af_flags[afi][safi], | |
1314 | PEER_FLAG_REFLECTOR_CLIENT)) | |
1315 | return 0; | |
1316 | } | |
1317 | } | |
1318 | ||
1319 | /* For modify attribute, copy it to temporary structure. */ | |
1320 | bgp_attr_dup (attr, riattr); | |
1321 | ||
1322 | /* If local-preference is not set. */ | |
1323 | if ((peer->sort == BGP_PEER_IBGP | |
1324 | || peer->sort == BGP_PEER_CONFED) | |
1325 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) | |
1326 | { | |
1327 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); | |
1328 | attr->local_pref = bgp->default_local_pref; | |
1329 | } | |
1330 | ||
1331 | /* If originator-id is not set and the route is to be reflected, | |
1332 | set the originator id */ | |
1333 | if (reflect && (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) | |
1334 | { | |
1335 | attr->extra = bgp_attr_extra_get(attr); | |
1336 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); | |
1337 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); | |
1338 | } | |
1339 | ||
1340 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ | |
1341 | if (peer->sort == BGP_PEER_EBGP | |
1342 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
1343 | { | |
003c1ba0 | 1344 | if (from != bgp->peer_self && ! transparent |
3f9c7369 DS |
1345 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
1346 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); | |
1347 | } | |
1348 | ||
1349 | /* Since the nexthop attribute can vary per peer, it is not explicitly set | |
1350 | * in announce check, only certain flags and length (or number of nexthops | |
1351 | * -- for IPv6/MP_REACH) are set here in order to guide the update formation | |
1352 | * code in setting the nexthop(s) on a per peer basis in reformat_peer(). | |
1353 | * Typically, the source nexthop in the attribute is preserved but in the | |
1354 | * scenarios where we know it will always be overwritten, we reset the | |
1355 | * nexthop to "0" in an attempt to achieve better Update packing. An | |
1356 | * example of this is when a prefix from each of 2 IBGP peers needs to be | |
1357 | * announced to an EBGP peer (and they have the same attributes barring | |
1358 | * their nexthop). | |
1359 | */ | |
1360 | if (reflect) | |
1361 | SET_FLAG(attr->rmap_change_flags, BATTR_REFLECTED); | |
1362 | ||
1363 | #ifdef HAVE_IPV6 | |
3811f1e2 DS |
1364 | /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if |
1365 | * the peer (group) is configured to receive link-local nexthop unchanged | |
1366 | * and it is available in the prefix OR we're not reflecting the route and | |
1367 | * the peer (group) to whom we're going to announce is on a shared network | |
003c1ba0 | 1368 | * and this is either a self-originated route or the peer is EBGP. |
3f9c7369 | 1369 | */ |
8a92a8a0 | 1370 | if (p->family == AF_INET6 || peer_cap_enhe(peer)) |
3f9c7369 | 1371 | { |
801a9bcc | 1372 | attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; |
3811f1e2 DS |
1373 | if ((CHECK_FLAG (peer->af_flags[afi][safi], |
1374 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) && | |
1375 | IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local)) || | |
003c1ba0 | 1376 | (!reflect && peer->shared_network && |
1377 | (from == bgp->peer_self || peer->sort == BGP_PEER_EBGP))) | |
3f9c7369 | 1378 | { |
3811f1e2 | 1379 | attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; |
3f9c7369 DS |
1380 | } |
1381 | ||
3811f1e2 DS |
1382 | /* Clear off link-local nexthop in source, whenever it is not needed to |
1383 | * ensure more prefixes share the same attribute for announcement. | |
3f9c7369 DS |
1384 | */ |
1385 | if (!(CHECK_FLAG (peer->af_flags[afi][safi], | |
1386 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED))) | |
1387 | memset (&attr->extra->mp_nexthop_local, 0, IPV6_MAX_BYTELEN); | |
1388 | } | |
1389 | #endif /* HAVE_IPV6 */ | |
1390 | ||
1391 | bgp_peer_remove_private_as(bgp, afi, safi, peer, attr); | |
1392 | bgp_peer_as_override(bgp, afi, safi, peer, attr); | |
1393 | ||
1394 | /* Route map & unsuppress-map apply. */ | |
1395 | if (ROUTE_MAP_OUT_NAME (filter) | |
1396 | || (ri->extra && ri->extra->suppress) ) | |
1397 | { | |
1398 | struct bgp_info info; | |
1399 | struct attr dummy_attr; | |
1400 | struct attr_extra dummy_extra; | |
1401 | ||
1402 | dummy_attr.extra = &dummy_extra; | |
1403 | ||
1404 | info.peer = peer; | |
1405 | info.attr = attr; | |
316e074d DS |
1406 | /* don't confuse inbound and outbound setting */ |
1407 | RESET_FLAG(attr->rmap_change_flags); | |
3f9c7369 DS |
1408 | |
1409 | /* | |
1410 | * The route reflector is not allowed to modify the attributes | |
1411 | * of the reflected IBGP routes unless explicitly allowed. | |
1412 | */ | |
1413 | if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) | |
1414 | && !bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
1415 | { | |
1416 | bgp_attr_dup (&dummy_attr, attr); | |
1417 | info.attr = &dummy_attr; | |
1418 | } | |
1419 | ||
1420 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1421 | ||
1422 | if (ri->extra && ri->extra->suppress) | |
1423 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); | |
1424 | else | |
1425 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1426 | ||
1427 | peer->rmap_type = 0; | |
1428 | ||
1429 | if (ret == RMAP_DENYMATCH) | |
1430 | { | |
1431 | bgp_attr_flush (attr); | |
1432 | return 0; | |
1433 | } | |
1434 | } | |
1435 | ||
1436 | /* After route-map has been applied, we check to see if the nexthop to | |
1437 | * be carried in the attribute (that is used for the announcement) can | |
1438 | * be cleared off or not. We do this in all cases where we would be | |
1439 | * setting the nexthop to "ourselves". For IPv6, we only need to consider | |
1440 | * the global nexthop here; the link-local nexthop would have been cleared | |
1441 | * already, and if not, it is required by the update formation code. | |
1442 | * Also see earlier comments in this function. | |
43fdf718 | 1443 | */ |
3811f1e2 DS |
1444 | /* |
1445 | * If route-map has performed some operation on the nexthop or the peer | |
1446 | * configuration says to pass it unchanged, we cannot reset the nexthop | |
1447 | * here, so only attempt to do it if these aren't true. Note that the | |
1448 | * route-map handler itself might have cleared the nexthop, if for example, | |
1449 | * it is configured as 'peer-address'. | |
3f9c7369 | 1450 | */ |
3811f1e2 DS |
1451 | if (!bgp_rmap_nhop_changed(attr->rmap_change_flags, |
1452 | riattr->rmap_change_flags) && | |
1453 | !transparent && | |
1454 | !CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
3f9c7369 | 1455 | { |
3811f1e2 | 1456 | /* We can reset the nexthop, if setting (or forcing) it to 'self' */ |
88b8ed8d DW |
1457 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || |
1458 | CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
3f9c7369 DS |
1459 | { |
1460 | if (!reflect || | |
1461 | CHECK_FLAG (peer->af_flags[afi][safi], | |
43fdf718 | 1462 | PEER_FLAG_FORCE_NEXTHOP_SELF)) |
3811f1e2 DS |
1463 | subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ? |
1464 | AF_INET6 : p->family), attr); | |
3f9c7369 DS |
1465 | } |
1466 | else if (peer->sort == BGP_PEER_EBGP) | |
1467 | { | |
3811f1e2 DS |
1468 | /* Can also reset the nexthop if announcing to EBGP, but only if |
1469 | * no peer in the subgroup is on a shared subnet. | |
1470 | * Note: 3rd party nexthop currently implemented for IPv4 only. | |
1471 | */ | |
3f9c7369 DS |
1472 | SUBGRP_FOREACH_PEER (subgrp, paf) |
1473 | { | |
1474 | if (bgp_multiaccess_check_v4 (riattr->nexthop, paf->peer)) | |
1475 | break; | |
1476 | } | |
1477 | if (!paf) | |
8a92a8a0 | 1478 | subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ? AF_INET6 : p->family), attr); |
3f9c7369 | 1479 | } |
003c1ba0 | 1480 | /* If IPv6/MP and nexthop does not have any override and happens to |
1481 | * be a link-local address, reset it so that we don't pass along the | |
1482 | * source's link-local IPv6 address to recipients who may not be on | |
1483 | * the same interface. | |
1484 | */ | |
1485 | if (p->family == AF_INET6 || peer_cap_enhe(peer)) | |
1486 | { | |
1487 | if (IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_global)) | |
1488 | subgroup_announce_reset_nhop (AF_INET6, attr); | |
1489 | } | |
3f9c7369 DS |
1490 | } |
1491 | ||
1492 | return 1; | |
1493 | } | |
1494 | ||
fee0f4c6 | 1495 | struct bgp_info_pair |
1496 | { | |
1497 | struct bgp_info *old; | |
1498 | struct bgp_info *new; | |
1499 | }; | |
1500 | ||
94f2b392 | 1501 | static void |
96450faf JB |
1502 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
1503 | struct bgp_maxpaths_cfg *mpath_cfg, | |
1504 | struct bgp_info_pair *result) | |
718e3744 | 1505 | { |
718e3744 | 1506 | struct bgp_info *new_select; |
1507 | struct bgp_info *old_select; | |
fee0f4c6 | 1508 | struct bgp_info *ri; |
718e3744 | 1509 | struct bgp_info *ri1; |
1510 | struct bgp_info *ri2; | |
b40d939b | 1511 | struct bgp_info *nextri = NULL; |
9fbdd100 | 1512 | int paths_eq, do_mpath, debug; |
96450faf | 1513 | struct list mp_list; |
4690c7d7 | 1514 | char pfx_buf[PREFIX2STR_BUFFER]; |
2ec1e66f | 1515 | char path_buf[PATH_ADDPATH_STR_BUFFER]; |
96450faf JB |
1516 | |
1517 | bgp_mp_list_init (&mp_list); | |
99030da1 | 1518 | do_mpath = (mpath_cfg->maxpaths_ebgp > 1 || mpath_cfg->maxpaths_ibgp > 1); |
96450faf | 1519 | |
9fbdd100 DS |
1520 | debug = bgp_debug_bestpath(&rn->p); |
1521 | ||
1522 | if (debug) | |
1523 | prefix2str (&rn->p, pfx_buf, sizeof (pfx_buf)); | |
1524 | ||
718e3744 | 1525 | /* bgp deterministic-med */ |
1526 | new_select = NULL; | |
1527 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
06370dac DW |
1528 | { |
1529 | ||
1530 | /* Clear BGP_INFO_DMED_SELECTED for all paths */ | |
1531 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1532 | bgp_info_unset_flag (rn, ri1, BGP_INFO_DMED_SELECTED); | |
1533 | ||
1534 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1535 | { | |
1536 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) | |
1537 | continue; | |
1538 | if (BGP_INFO_HOLDDOWN (ri1)) | |
2fed8887 | 1539 | continue; |
06370dac DW |
1540 | if (ri1->peer && ri1->peer != bgp->peer_self) |
1541 | if (ri1->peer->status != Established) | |
1542 | continue; | |
718e3744 | 1543 | |
06370dac DW |
1544 | new_select = ri1; |
1545 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; | |
1546 | if (ri1->next) | |
1547 | { | |
1548 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) | |
1549 | { | |
1550 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) | |
1551 | continue; | |
1552 | if (BGP_INFO_HOLDDOWN (ri2)) | |
1553 | continue; | |
1554 | if (ri2->peer && | |
1555 | ri2->peer != bgp->peer_self && | |
1556 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) | |
1557 | if (ri2->peer->status != Established) | |
1558 | continue; | |
1559 | ||
1560 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) | |
1561 | || aspath_cmp_left_confed (ri1->attr->aspath, | |
1562 | ri2->attr->aspath)) | |
1563 | { | |
1564 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) | |
1565 | old_select = ri2; | |
1566 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq, | |
1567 | mpath_cfg, debug, pfx_buf)) | |
1568 | { | |
1569 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
1570 | new_select = ri2; | |
1571 | } | |
1572 | ||
1573 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); | |
1574 | } | |
1575 | } | |
1576 | } | |
1577 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); | |
1578 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1579 | |
06370dac | 1580 | if (debug) |
2ec1e66f DW |
1581 | { |
1582 | bgp_info_path_with_addpath_rx_str (new_select, path_buf); | |
1583 | zlog_debug("%s: %s is the bestpath from AS %d", | |
1584 | pfx_buf, path_buf, aspath_get_firstas(new_select->attr->aspath)); | |
1585 | } | |
06370dac DW |
1586 | } |
1587 | } | |
718e3744 | 1588 | |
1589 | /* Check old selected route and new selected route. */ | |
1590 | old_select = NULL; | |
1591 | new_select = NULL; | |
b40d939b | 1592 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
718e3744 | 1593 | { |
1594 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1595 | old_select = ri; | |
1596 | ||
1597 | if (BGP_INFO_HOLDDOWN (ri)) | |
b40d939b | 1598 | { |
1599 | /* reap REMOVED routes, if needs be | |
1600 | * selected route must stay for a while longer though | |
1601 | */ | |
1602 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) | |
1603 | && (ri != old_select)) | |
1604 | bgp_info_reap (rn, ri); | |
1605 | ||
1606 | continue; | |
1607 | } | |
718e3744 | 1608 | |
2fed8887 DS |
1609 | if (ri->peer && |
1610 | ri->peer != bgp->peer_self && | |
1611 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) | |
1612 | if (ri->peer->status != Established) | |
1613 | continue; | |
1614 | ||
718e3744 | 1615 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
1616 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) | |
1617 | { | |
1a392d46 | 1618 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1619 | continue; |
1620 | } | |
06370dac | 1621 | |
1a392d46 | 1622 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1623 | |
9fbdd100 | 1624 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, debug, pfx_buf)) |
96450faf JB |
1625 | { |
1626 | new_select = ri; | |
96450faf | 1627 | } |
718e3744 | 1628 | } |
b40d939b | 1629 | |
f4eeff72 DS |
1630 | /* Now that we know which path is the bestpath see if any of the other paths |
1631 | * qualify as multipaths | |
1632 | */ | |
1633 | if (do_mpath && new_select) | |
1634 | { | |
9fbdd100 | 1635 | if (debug) |
2ec1e66f DW |
1636 | { |
1637 | bgp_info_path_with_addpath_rx_str (new_select, path_buf); | |
1638 | zlog_debug("%s: %s is the bestpath, now find multipaths", pfx_buf, path_buf); | |
1639 | } | |
9fbdd100 | 1640 | |
f4eeff72 DS |
1641 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
1642 | { | |
2ec1e66f DW |
1643 | |
1644 | if (debug) | |
1645 | bgp_info_path_with_addpath_rx_str (ri, path_buf); | |
1646 | ||
f4eeff72 DS |
1647 | if (ri == new_select) |
1648 | { | |
9fbdd100 | 1649 | if (debug) |
2ec1e66f DW |
1650 | zlog_debug("%s: %s is the bestpath, add to the multipath list", |
1651 | pfx_buf, path_buf); | |
f4eeff72 DS |
1652 | bgp_mp_list_add (&mp_list, ri); |
1653 | continue; | |
1654 | } | |
1655 | ||
1656 | if (BGP_INFO_HOLDDOWN (ri)) | |
1657 | continue; | |
1658 | ||
1659 | if (ri->peer && | |
1660 | ri->peer != bgp->peer_self && | |
1661 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) | |
1662 | if (ri->peer->status != Established) | |
1663 | continue; | |
1664 | ||
7dc9d4e4 DW |
1665 | if (!bgp_info_nexthop_cmp (ri, new_select)) |
1666 | { | |
1667 | if (debug) | |
2ec1e66f DW |
1668 | zlog_debug("%s: %s has the same nexthop as the bestpath, skip it", |
1669 | pfx_buf, path_buf); | |
7dc9d4e4 DW |
1670 | continue; |
1671 | } | |
1672 | ||
9fbdd100 | 1673 | bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, debug, pfx_buf); |
f4eeff72 DS |
1674 | |
1675 | if (paths_eq) | |
1676 | { | |
9fbdd100 | 1677 | if (debug) |
2ec1e66f DW |
1678 | zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list", |
1679 | pfx_buf, path_buf); | |
f4eeff72 DS |
1680 | bgp_mp_list_add (&mp_list, ri); |
1681 | } | |
1682 | } | |
1683 | } | |
fee0f4c6 | 1684 | |
b354c427 | 1685 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
0b597ef0 | 1686 | bgp_info_mpath_aggregate_update (new_select, old_select); |
96450faf JB |
1687 | bgp_mp_list_clear (&mp_list); |
1688 | ||
1689 | result->old = old_select; | |
1690 | result->new = new_select; | |
1691 | ||
1692 | return; | |
fee0f4c6 | 1693 | } |
1694 | ||
3f9c7369 DS |
1695 | /* |
1696 | * A new route/change in bestpath of an existing route. Evaluate the path | |
1697 | * for advertisement to the subgroup. | |
1698 | */ | |
1699 | int | |
1700 | subgroup_process_announce_selected (struct update_subgroup *subgrp, | |
1701 | struct bgp_info *selected, | |
adbac85e DW |
1702 | struct bgp_node *rn, |
1703 | u_int32_t addpath_tx_id) | |
9eda90ce | 1704 | { |
fee0f4c6 | 1705 | struct prefix *p; |
3f9c7369 | 1706 | struct peer *onlypeer; |
558d1fec JBD |
1707 | struct attr attr; |
1708 | struct attr_extra extra; | |
3f9c7369 DS |
1709 | afi_t afi; |
1710 | safi_t safi; | |
fee0f4c6 | 1711 | |
1712 | p = &rn->p; | |
3f9c7369 DS |
1713 | afi = SUBGRP_AFI(subgrp); |
1714 | safi = SUBGRP_SAFI(subgrp); | |
1715 | onlypeer = ((SUBGRP_PCOUNT(subgrp) == 1) ? | |
1716 | (SUBGRP_PFIRST(subgrp))->peer : NULL); | |
718e3744 | 1717 | |
9eda90ce | 1718 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
3f9c7369 DS |
1719 | if (onlypeer && CHECK_FLAG (onlypeer->af_sflags[afi][safi], |
1720 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
fee0f4c6 | 1721 | return 0; |
718e3744 | 1722 | |
2a3d5731 | 1723 | /* It's initialized in bgp_announce_check() */ |
558d1fec JBD |
1724 | attr.extra = &extra; |
1725 | ||
2a3d5731 DW |
1726 | /* Announcement to the subgroup. If the route is filtered withdraw it. */ |
1727 | if (selected) | |
fee0f4c6 | 1728 | { |
2a3d5731 DW |
1729 | if (subgroup_announce_check(selected, subgrp, p, &attr)) |
1730 | bgp_adj_out_set_subgroup(rn, subgrp, &attr, selected); | |
1731 | else | |
1732 | bgp_adj_out_unset_subgroup(rn, subgrp, 1, selected->addpath_tx_id); | |
1733 | } | |
adbac85e | 1734 | |
2a3d5731 DW |
1735 | /* If selected is NULL we must withdraw the path using addpath_tx_id */ |
1736 | else | |
1737 | { | |
1738 | bgp_adj_out_unset_subgroup(rn, subgrp, 1, addpath_tx_id); | |
fee0f4c6 | 1739 | } |
558d1fec | 1740 | |
fee0f4c6 | 1741 | return 0; |
200df115 | 1742 | } |
fee0f4c6 | 1743 | |
3f9c7369 | 1744 | struct bgp_process_queue |
fee0f4c6 | 1745 | { |
200df115 | 1746 | struct bgp *bgp; |
1747 | struct bgp_node *rn; | |
1748 | afi_t afi; | |
1749 | safi_t safi; | |
1750 | }; | |
1751 | ||
200df115 | 1752 | static wq_item_status |
0fb58d5d | 1753 | bgp_process_main (struct work_queue *wq, void *data) |
200df115 | 1754 | { |
0fb58d5d | 1755 | struct bgp_process_queue *pq = data; |
200df115 | 1756 | struct bgp *bgp = pq->bgp; |
1757 | struct bgp_node *rn = pq->rn; | |
1758 | afi_t afi = pq->afi; | |
1759 | safi_t safi = pq->safi; | |
1760 | struct prefix *p = &rn->p; | |
fee0f4c6 | 1761 | struct bgp_info *new_select; |
1762 | struct bgp_info *old_select; | |
1763 | struct bgp_info_pair old_and_new; | |
cb1faec9 DS |
1764 | |
1765 | /* Is it end of initial update? (after startup) */ | |
1766 | if (!rn) | |
1767 | { | |
4a16ae86 DS |
1768 | quagga_timestamp(3, bgp->update_delay_zebra_resume_time, |
1769 | sizeof(bgp->update_delay_zebra_resume_time)); | |
1770 | ||
1771 | bgp->main_zebra_update_hold = 0; | |
1772 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1773 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1774 | { | |
1775 | bgp_zebra_announce_table(bgp, afi, safi); | |
1776 | } | |
1777 | bgp->main_peers_update_hold = 0; | |
1778 | ||
cb1faec9 DS |
1779 | bgp_start_routeadv(bgp); |
1780 | return WQ_SUCCESS; | |
1781 | } | |
1782 | ||
fee0f4c6 | 1783 | /* Best path selection. */ |
96450faf | 1784 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
fee0f4c6 | 1785 | old_select = old_and_new.old; |
1786 | new_select = old_and_new.new; | |
1787 | ||
1788 | /* Nothing to do. */ | |
adbac85e DW |
1789 | if (old_select && old_select == new_select && |
1790 | !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR) && | |
1791 | !CHECK_FLAG(old_select->flags, BGP_INFO_ATTR_CHANGED) && | |
1792 | !bgp->addpath_tx_used[afi][safi]) | |
1793 | { | |
1794 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || | |
1795 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) | |
1796 | bgp_zebra_announce (p, old_select, bgp, afi, safi); | |
200df115 | 1797 | |
adbac85e DW |
1798 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
1799 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); | |
1800 | return WQ_SUCCESS; | |
fee0f4c6 | 1801 | } |
1802 | ||
8ad7271d DS |
1803 | /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */ |
1804 | UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
1805 | ||
3f9c7369 DS |
1806 | /* bestpath has changed; bump version */ |
1807 | if (old_select || new_select) | |
0de4848d DS |
1808 | { |
1809 | bgp_bump_version(rn); | |
1810 | ||
1811 | if (!bgp->t_rmap_def_originate_eval) | |
1812 | { | |
1813 | bgp_lock (bgp); | |
9229d914 | 1814 | THREAD_TIMER_ON(bm->master, bgp->t_rmap_def_originate_eval, |
0de4848d DS |
1815 | update_group_refresh_default_originate_route_map, |
1816 | bgp, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER); | |
1817 | } | |
1818 | } | |
3f9c7369 | 1819 | |
338b3424 | 1820 | if (old_select) |
1a392d46 | 1821 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
338b3424 | 1822 | if (new_select) |
1823 | { | |
1a392d46 PJ |
1824 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1825 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
8196f13d | 1826 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
338b3424 | 1827 | } |
1828 | ||
3f9c7369 | 1829 | group_announce_route(bgp, afi, safi, rn, new_select); |
718e3744 | 1830 | |
1831 | /* FIB update. */ | |
ad4cbda1 | 1832 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && |
1833 | (bgp->inst_type != BGP_INSTANCE_TYPE_VIEW) && | |
1834 | !bgp_option_check (BGP_OPT_NO_FIB)) | |
718e3744 | 1835 | { |
1836 | if (new_select | |
1837 | && new_select->type == ZEBRA_ROUTE_BGP | |
f992e2a9 DS |
1838 | && (new_select->sub_type == BGP_ROUTE_NORMAL || |
1839 | new_select->sub_type == BGP_ROUTE_AGGREGATE)) | |
73ac8160 | 1840 | bgp_zebra_announce (p, new_select, bgp, afi, safi); |
718e3744 | 1841 | else |
1842 | { | |
1843 | /* Withdraw the route from the kernel. */ | |
1844 | if (old_select | |
1845 | && old_select->type == ZEBRA_ROUTE_BGP | |
f992e2a9 DS |
1846 | && (old_select->sub_type == BGP_ROUTE_NORMAL || |
1847 | old_select->sub_type == BGP_ROUTE_AGGREGATE)) | |
5a616c08 | 1848 | bgp_zebra_withdraw (p, old_select, safi); |
718e3744 | 1849 | } |
1850 | } | |
b40d939b | 1851 | |
adbac85e | 1852 | /* Reap old select bgp_info, if it has been removed */ |
b40d939b | 1853 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
1854 | bgp_info_reap (rn, old_select); | |
1855 | ||
200df115 | 1856 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1857 | return WQ_SUCCESS; | |
718e3744 | 1858 | } |
1859 | ||
200df115 | 1860 | static void |
0fb58d5d | 1861 | bgp_processq_del (struct work_queue *wq, void *data) |
200df115 | 1862 | { |
0fb58d5d | 1863 | struct bgp_process_queue *pq = data; |
cb1faec9 DS |
1864 | struct bgp_table *table; |
1865 | ||
228da428 | 1866 | bgp_unlock (pq->bgp); |
cb1faec9 DS |
1867 | if (pq->rn) |
1868 | { | |
1869 | table = bgp_node_table (pq->rn); | |
1870 | bgp_unlock_node (pq->rn); | |
1871 | bgp_table_unlock (table); | |
1872 | } | |
200df115 | 1873 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
1874 | } | |
1875 | ||
f188f2c4 | 1876 | void |
200df115 | 1877 | bgp_process_queue_init (void) |
1878 | { | |
495f0b13 DS |
1879 | if (!bm->process_main_queue) |
1880 | { | |
1881 | bm->process_main_queue | |
87d4a781 | 1882 | = work_queue_new (bm->master, "process_main_queue"); |
495f0b13 | 1883 | |
2a3d5731 DW |
1884 | if ( !bm->process_main_queue) |
1885 | { | |
1886 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
1887 | exit (1); | |
1888 | } | |
200df115 | 1889 | } |
1890 | ||
1891 | bm->process_main_queue->spec.workfunc = &bgp_process_main; | |
200df115 | 1892 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
838bbde0 PJ |
1893 | bm->process_main_queue->spec.max_retries = 0; |
1894 | bm->process_main_queue->spec.hold = 50; | |
d889623f DS |
1895 | /* Use a higher yield value of 50ms for main queue processing */ |
1896 | bm->process_main_queue->spec.yield = 50 * 1000L; | |
200df115 | 1897 | } |
1898 | ||
1899 | void | |
fee0f4c6 | 1900 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
1901 | { | |
200df115 | 1902 | struct bgp_process_queue *pqnode; |
1903 | ||
1904 | /* already scheduled for processing? */ | |
1905 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) | |
1906 | return; | |
495f0b13 | 1907 | |
2a3d5731 | 1908 | if (bm->process_main_queue == NULL) |
2e02b9b2 DS |
1909 | bgp_process_queue_init (); |
1910 | ||
200df115 | 1911 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
1912 | sizeof (struct bgp_process_queue)); | |
1913 | if (!pqnode) | |
1914 | return; | |
228da428 CC |
1915 | |
1916 | /* all unlocked in bgp_processq_del */ | |
67174041 | 1917 | bgp_table_lock (bgp_node_table (rn)); |
228da428 | 1918 | pqnode->rn = bgp_lock_node (rn); |
200df115 | 1919 | pqnode->bgp = bgp; |
228da428 | 1920 | bgp_lock (bgp); |
200df115 | 1921 | pqnode->afi = afi; |
1922 | pqnode->safi = safi; | |
2a3d5731 | 1923 | work_queue_add (bm->process_main_queue, pqnode); |
07ff4dc4 | 1924 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
200df115 | 1925 | return; |
fee0f4c6 | 1926 | } |
0a486e5f | 1927 | |
cb1faec9 | 1928 | void |
2a3d5731 | 1929 | bgp_add_eoiu_mark (struct bgp *bgp) |
cb1faec9 DS |
1930 | { |
1931 | struct bgp_process_queue *pqnode; | |
1932 | ||
2a3d5731 | 1933 | if (bm->process_main_queue == NULL) |
2e02b9b2 DS |
1934 | bgp_process_queue_init (); |
1935 | ||
cb1faec9 DS |
1936 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
1937 | sizeof (struct bgp_process_queue)); | |
1938 | if (!pqnode) | |
1939 | return; | |
1940 | ||
1941 | pqnode->rn = NULL; | |
1942 | pqnode->bgp = bgp; | |
1943 | bgp_lock (bgp); | |
2a3d5731 | 1944 | work_queue_add (bm->process_main_queue, pqnode); |
cb1faec9 DS |
1945 | } |
1946 | ||
94f2b392 | 1947 | static int |
0a486e5f | 1948 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
1949 | { | |
1950 | struct peer *peer; | |
1951 | ||
1952 | peer = THREAD_ARG (thread); | |
1953 | peer->t_pmax_restart = NULL; | |
1954 | ||
16286195 | 1955 | if (bgp_debug_neighbor_events(peer)) |
0a486e5f | 1956 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
1957 | peer->host); | |
1958 | ||
1ff9a340 | 1959 | peer_clear (peer, NULL); |
0a486e5f | 1960 | |
1961 | return 0; | |
1962 | } | |
1963 | ||
718e3744 | 1964 | int |
5228ad27 | 1965 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
1966 | safi_t safi, int always) | |
718e3744 | 1967 | { |
e0701b79 | 1968 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
1969 | return 0; | |
1970 | ||
1971 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) | |
718e3744 | 1972 | { |
e0701b79 | 1973 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
1974 | && ! always) | |
1975 | return 0; | |
1976 | ||
16286195 DS |
1977 | zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
1978 | "limit %ld", afi_safi_print (afi, safi), peer->host, | |
1979 | peer->pcount[afi][safi], peer->pmax[afi][safi]); | |
e0701b79 | 1980 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
1981 | ||
1982 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
1983 | return 0; | |
1984 | ||
1985 | { | |
5228ad27 | 1986 | u_int8_t ndata[7]; |
e0701b79 | 1987 | |
1988 | if (safi == SAFI_MPLS_VPN) | |
42e6d745 | 1989 | safi = SAFI_MPLS_LABELED_VPN; |
5228ad27 | 1990 | |
1991 | ndata[0] = (afi >> 8); | |
1992 | ndata[1] = afi; | |
1993 | ndata[2] = safi; | |
1994 | ndata[3] = (peer->pmax[afi][safi] >> 24); | |
1995 | ndata[4] = (peer->pmax[afi][safi] >> 16); | |
1996 | ndata[5] = (peer->pmax[afi][safi] >> 8); | |
1997 | ndata[6] = (peer->pmax[afi][safi]); | |
e0701b79 | 1998 | |
1999 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); | |
2000 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, | |
2001 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); | |
2002 | } | |
0a486e5f | 2003 | |
f14e6fdb DS |
2004 | /* Dynamic peers will just close their connection. */ |
2005 | if (peer_dynamic_neighbor (peer)) | |
2006 | return 1; | |
2007 | ||
0a486e5f | 2008 | /* restart timer start */ |
2009 | if (peer->pmax_restart[afi][safi]) | |
2010 | { | |
2011 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; | |
2012 | ||
16286195 | 2013 | if (bgp_debug_neighbor_events(peer)) |
0a486e5f | 2014 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
2015 | peer->host, peer->v_pmax_restart); | |
2016 | ||
2017 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, | |
2018 | peer->v_pmax_restart); | |
2019 | } | |
2020 | ||
e0701b79 | 2021 | return 1; |
2022 | } | |
2023 | else | |
2024 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); | |
2025 | ||
2026 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) | |
2027 | { | |
2028 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) | |
2029 | && ! always) | |
2030 | return 0; | |
2031 | ||
16286195 DS |
2032 | zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
2033 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], | |
2034 | peer->pmax[afi][safi]); | |
e0701b79 | 2035 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
718e3744 | 2036 | } |
e0701b79 | 2037 | else |
2038 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); | |
718e3744 | 2039 | return 0; |
2040 | } | |
2041 | ||
b40d939b | 2042 | /* Unconditionally remove the route from the RIB, without taking |
2043 | * damping into consideration (eg, because the session went down) | |
2044 | */ | |
94f2b392 | 2045 | static void |
718e3744 | 2046 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
2047 | afi_t afi, safi_t safi) | |
2048 | { | |
902212c3 | 2049 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
2050 | ||
2051 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2052 | bgp_info_delete (rn, ri); /* keep historical info */ | |
2053 | ||
b40d939b | 2054 | bgp_process (peer->bgp, rn, afi, safi); |
718e3744 | 2055 | } |
2056 | ||
94f2b392 | 2057 | static void |
718e3744 | 2058 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
b40d939b | 2059 | afi_t afi, safi_t safi) |
718e3744 | 2060 | { |
718e3744 | 2061 | int status = BGP_DAMP_NONE; |
2062 | ||
b40d939b | 2063 | /* apply dampening, if result is suppressed, we'll be retaining |
2064 | * the bgp_info in the RIB for historical reference. | |
2065 | */ | |
2066 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2067 | && peer->sort == BGP_PEER_EBGP) |
b40d939b | 2068 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
2069 | == BGP_DAMP_SUPPRESSED) | |
902212c3 | 2070 | { |
902212c3 | 2071 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
2072 | return; | |
2073 | } | |
2074 | ||
2075 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
718e3744 | 2076 | } |
2077 | ||
fb018d25 | 2078 | static struct bgp_info * |
7c8ff89e | 2079 | info_make (int type, int sub_type, u_short instance, struct peer *peer, struct attr *attr, |
fb018d25 DS |
2080 | struct bgp_node *rn) |
2081 | { | |
2082 | struct bgp_info *new; | |
2083 | ||
2084 | /* Make new BGP info. */ | |
2085 | new = XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); | |
2086 | new->type = type; | |
7c8ff89e | 2087 | new->instance = instance; |
fb018d25 DS |
2088 | new->sub_type = sub_type; |
2089 | new->peer = peer; | |
2090 | new->attr = attr; | |
2091 | new->uptime = bgp_clock (); | |
2092 | new->net = rn; | |
adbac85e | 2093 | new->addpath_tx_id = ++peer->bgp->addpath_tx_id; |
fb018d25 DS |
2094 | return new; |
2095 | } | |
2096 | ||
94f2b392 | 2097 | static void |
2ec1e66f | 2098 | bgp_info_addpath_rx_str(u_int32_t addpath_id, char *buf) |
cd808e74 | 2099 | { |
2ec1e66f DW |
2100 | if (addpath_id) |
2101 | sprintf(buf, " with addpath ID %d", addpath_id); | |
cd808e74 DS |
2102 | } |
2103 | ||
2ec1e66f | 2104 | |
c265ee22 DS |
2105 | /* Check if received nexthop is valid or not. */ |
2106 | static int | |
6aeb9e78 | 2107 | bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr *attr) |
c265ee22 DS |
2108 | { |
2109 | struct attr_extra *attre = attr->extra; | |
2110 | int ret = 0; | |
2111 | ||
2112 | /* Only validated for unicast and multicast currently. */ | |
2113 | if (safi != SAFI_UNICAST && safi != SAFI_MULTICAST) | |
2114 | return 0; | |
2115 | ||
2116 | /* If NEXT_HOP is present, validate it. */ | |
2117 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)) | |
2118 | { | |
2119 | if (attr->nexthop.s_addr == 0 || | |
2120 | IPV4_CLASS_DE (ntohl (attr->nexthop.s_addr)) || | |
6aeb9e78 | 2121 | bgp_nexthop_self (bgp, attr)) |
c265ee22 DS |
2122 | ret = 1; |
2123 | } | |
2124 | ||
2125 | /* If MP_NEXTHOP is present, validate it. */ | |
2126 | /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop; | |
2127 | * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if | |
2128 | * it is not an IPv6 link-local address. | |
2129 | */ | |
2130 | if (attre && attre->mp_nexthop_len) | |
2131 | { | |
2132 | switch (attre->mp_nexthop_len) | |
2133 | { | |
2134 | case BGP_ATTR_NHLEN_IPV4: | |
2135 | case BGP_ATTR_NHLEN_VPNV4: | |
2136 | ret = (attre->mp_nexthop_global_in.s_addr == 0 || | |
2137 | IPV4_CLASS_DE (ntohl (attre->mp_nexthop_global_in.s_addr))); | |
2138 | break; | |
2139 | ||
2140 | #ifdef HAVE_IPV6 | |
2141 | case BGP_ATTR_NHLEN_IPV6_GLOBAL: | |
2142 | case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: | |
2143 | ret = (IN6_IS_ADDR_UNSPECIFIED(&attre->mp_nexthop_global) || | |
2144 | IN6_IS_ADDR_LOOPBACK(&attre->mp_nexthop_global) || | |
2145 | IN6_IS_ADDR_MULTICAST(&attre->mp_nexthop_global)); | |
2146 | break; | |
2147 | #endif /* HAVE_IPV6 */ | |
2148 | ||
2149 | default: | |
2150 | ret = 1; | |
2151 | break; | |
2152 | } | |
2153 | } | |
2154 | ||
2155 | return ret; | |
2156 | } | |
2157 | ||
a7ee645d DS |
2158 | int |
2159 | bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, | |
2160 | struct attr *attr, afi_t afi, safi_t safi, int type, | |
2161 | int sub_type, struct prefix_rd *prd, u_char *tag, | |
2162 | int soft_reconfig) | |
718e3744 | 2163 | { |
2164 | int ret; | |
2165 | int aspath_loop_count = 0; | |
2166 | struct bgp_node *rn; | |
2167 | struct bgp *bgp; | |
558d1fec JBD |
2168 | struct attr new_attr; |
2169 | struct attr_extra new_extra; | |
718e3744 | 2170 | struct attr *attr_new; |
2171 | struct bgp_info *ri; | |
2172 | struct bgp_info *new; | |
fd79ac91 | 2173 | const char *reason; |
718e3744 | 2174 | char buf[SU_ADDRSTRLEN]; |
cd808e74 | 2175 | char buf2[30]; |
fc9a856f | 2176 | int connected = 0; |
718e3744 | 2177 | |
2178 | bgp = peer->bgp; | |
fee0f4c6 | 2179 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
fb982c25 | 2180 | |
718e3744 | 2181 | /* When peer's soft reconfiguration enabled. Record input packet in |
2182 | Adj-RIBs-In. */ | |
343aa822 JBD |
2183 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
2184 | && peer != bgp->peer_self) | |
43143c8f | 2185 | bgp_adj_in_set (rn, peer, attr, addpath_id); |
718e3744 | 2186 | |
2187 | /* Check previously received route. */ | |
2188 | for (ri = rn->info; ri; ri = ri->next) | |
a82478b9 DS |
2189 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type && |
2190 | ri->addpath_rx_id == addpath_id) | |
718e3744 | 2191 | break; |
2192 | ||
2193 | /* AS path local-as loop check. */ | |
2194 | if (peer->change_local_as) | |
2195 | { | |
2196 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
2197 | aspath_loop_count = 1; | |
2198 | ||
2199 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) | |
2200 | { | |
2201 | reason = "as-path contains our own AS;"; | |
2202 | goto filtered; | |
2203 | } | |
2204 | } | |
2205 | ||
2206 | /* AS path loop check. */ | |
2207 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] | |
2208 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
2209 | && aspath_loop_check(attr->aspath, bgp->confed_id) | |
2210 | > peer->allowas_in[afi][safi])) | |
2211 | { | |
2212 | reason = "as-path contains our own AS;"; | |
2213 | goto filtered; | |
2214 | } | |
2215 | ||
2216 | /* Route reflector originator ID check. */ | |
2217 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 2218 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
718e3744 | 2219 | { |
2220 | reason = "originator is us;"; | |
2221 | goto filtered; | |
2222 | } | |
2223 | ||
2224 | /* Route reflector cluster ID check. */ | |
2225 | if (bgp_cluster_filter (peer, attr)) | |
2226 | { | |
2227 | reason = "reflected from the same cluster;"; | |
2228 | goto filtered; | |
2229 | } | |
2230 | ||
2231 | /* Apply incoming filter. */ | |
2232 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) | |
2233 | { | |
2234 | reason = "filter;"; | |
2235 | goto filtered; | |
2236 | } | |
2237 | ||
558d1fec | 2238 | new_attr.extra = &new_extra; |
fb982c25 | 2239 | bgp_attr_dup (&new_attr, attr); |
718e3744 | 2240 | |
c460e572 DL |
2241 | /* Apply incoming route-map. |
2242 | * NB: new_attr may now contain newly allocated values from route-map "set" | |
2243 | * commands, so we need bgp_attr_flush in the error paths, until we intern | |
2244 | * the attr (which takes over the memory references) */ | |
0b16f239 | 2245 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi, NULL) == RMAP_DENY) |
718e3744 | 2246 | { |
2247 | reason = "route-map;"; | |
c460e572 | 2248 | bgp_attr_flush (&new_attr); |
718e3744 | 2249 | goto filtered; |
2250 | } | |
2251 | ||
c265ee22 | 2252 | /* next hop check. */ |
6aeb9e78 | 2253 | if (bgp_update_martian_nexthop (bgp, afi, safi, &new_attr)) |
718e3744 | 2254 | { |
c265ee22 DS |
2255 | reason = "martian or self next-hop;"; |
2256 | bgp_attr_flush (&new_attr); | |
2257 | goto filtered; | |
718e3744 | 2258 | } |
2259 | ||
2260 | attr_new = bgp_attr_intern (&new_attr); | |
2261 | ||
2262 | /* If the update is implicit withdraw. */ | |
2263 | if (ri) | |
2264 | { | |
65957886 | 2265 | ri->uptime = bgp_clock (); |
718e3744 | 2266 | |
2267 | /* Same attribute comes in. */ | |
16d2e241 PJ |
2268 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
2269 | && attrhash_cmp (ri->attr, attr_new)) | |
718e3744 | 2270 | { |
718e3744 | 2271 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
6d85b15b | 2272 | && peer->sort == BGP_PEER_EBGP |
718e3744 | 2273 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2274 | { | |
3f9c7369 | 2275 | if (bgp_debug_update(peer, p, NULL, 1)) |
cd808e74 | 2276 | { |
2ec1e66f | 2277 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2278 | zlog_debug ("%s rcvd %s/%d%s", |
16286195 DS |
2279 | peer->host, |
2280 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 DS |
2281 | p->prefixlen, buf2); |
2282 | } | |
718e3744 | 2283 | |
902212c3 | 2284 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
2285 | { | |
2286 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2287 | bgp_process (bgp, rn, afi, safi); | |
2288 | } | |
718e3744 | 2289 | } |
16d2e241 | 2290 | else /* Duplicate - odd */ |
718e3744 | 2291 | { |
3f9c7369 | 2292 | if (bgp_debug_update(peer, p, NULL, 1)) |
16286195 DS |
2293 | { |
2294 | if (!peer->rcvd_attr_printed) | |
2295 | { | |
2296 | zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str); | |
2297 | peer->rcvd_attr_printed = 1; | |
2298 | } | |
2299 | ||
2ec1e66f | 2300 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2301 | zlog_debug ("%s rcvd %s/%d%s...duplicate ignored", |
16286195 DS |
2302 | peer->host, |
2303 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 | 2304 | p->prefixlen, buf2); |
16286195 | 2305 | } |
93406d87 | 2306 | |
2307 | /* graceful restart STALE flag unset. */ | |
2308 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2309 | { | |
1a392d46 | 2310 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
902212c3 | 2311 | bgp_process (bgp, rn, afi, safi); |
93406d87 | 2312 | } |
718e3744 | 2313 | } |
2314 | ||
2315 | bgp_unlock_node (rn); | |
f6f434b2 | 2316 | bgp_attr_unintern (&attr_new); |
558d1fec | 2317 | |
718e3744 | 2318 | return 0; |
2319 | } | |
2320 | ||
16d2e241 PJ |
2321 | /* Withdraw/Announce before we fully processed the withdraw */ |
2322 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
2323 | { | |
3f9c7369 | 2324 | if (bgp_debug_update(peer, p, NULL, 1)) |
cd808e74 | 2325 | { |
2ec1e66f | 2326 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 DS |
2327 | zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing", |
2328 | peer->host, | |
2329 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2330 | p->prefixlen, buf2); | |
2331 | } | |
16d2e241 PJ |
2332 | bgp_info_restore (rn, ri); |
2333 | } | |
2334 | ||
718e3744 | 2335 | /* Received Logging. */ |
3f9c7369 | 2336 | if (bgp_debug_update(peer, p, NULL, 1)) |
cd808e74 | 2337 | { |
2ec1e66f | 2338 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2339 | zlog_debug ("%s rcvd %s/%d%s", |
16286195 DS |
2340 | peer->host, |
2341 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 DS |
2342 | p->prefixlen, buf2); |
2343 | } | |
718e3744 | 2344 | |
93406d87 | 2345 | /* graceful restart STALE flag unset. */ |
2346 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
1a392d46 | 2347 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
93406d87 | 2348 | |
718e3744 | 2349 | /* The attribute is changed. */ |
1a392d46 | 2350 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
902212c3 | 2351 | |
2352 | /* implicit withdraw, decrement aggregate and pcount here. | |
2353 | * only if update is accepted, they'll increment below. | |
2354 | */ | |
902212c3 | 2355 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
2356 | ||
718e3744 | 2357 | /* Update bgp route dampening information. */ |
2358 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2359 | && peer->sort == BGP_PEER_EBGP) |
718e3744 | 2360 | { |
2361 | /* This is implicit withdraw so we should update dampening | |
2362 | information. */ | |
2363 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2364 | bgp_damp_withdraw (ri, rn, afi, safi, 1); | |
718e3744 | 2365 | } |
2366 | ||
718e3744 | 2367 | /* Update to new attribute. */ |
f6f434b2 | 2368 | bgp_attr_unintern (&ri->attr); |
718e3744 | 2369 | ri->attr = attr_new; |
2370 | ||
2371 | /* Update MPLS tag. */ | |
2372 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2373 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
718e3744 | 2374 | |
2375 | /* Update bgp route dampening information. */ | |
2376 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2377 | && peer->sort == BGP_PEER_EBGP) |
718e3744 | 2378 | { |
2379 | /* Now we do normal update dampening. */ | |
2380 | ret = bgp_damp_update (ri, rn, afi, safi); | |
2381 | if (ret == BGP_DAMP_SUPPRESSED) | |
2382 | { | |
2383 | bgp_unlock_node (rn); | |
2384 | return 0; | |
2385 | } | |
2386 | } | |
2387 | ||
2388 | /* Nexthop reachability check. */ | |
fc9a856f | 2389 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
718e3744 | 2390 | { |
fc9a856f | 2391 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 && |
907f92c8 DS |
2392 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) |
2393 | && ! bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
fc9a856f DS |
2394 | connected = 1; |
2395 | else | |
2396 | connected = 0; | |
2397 | ||
75aead62 | 2398 | if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, connected)) |
1a392d46 | 2399 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2400 | else |
fc9a856f DS |
2401 | { |
2402 | if (BGP_DEBUG(nht, NHT)) | |
2403 | { | |
2404 | char buf1[INET6_ADDRSTRLEN]; | |
2405 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN); | |
2406 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); | |
2407 | } | |
2408 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); | |
2409 | } | |
718e3744 | 2410 | } |
2411 | else | |
fc9a856f | 2412 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2413 | |
2414 | /* Process change. */ | |
2415 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2416 | ||
2417 | bgp_process (bgp, rn, afi, safi); | |
2418 | bgp_unlock_node (rn); | |
558d1fec | 2419 | |
718e3744 | 2420 | return 0; |
a82478b9 | 2421 | } // End of implicit withdraw |
718e3744 | 2422 | |
2423 | /* Received Logging. */ | |
3f9c7369 | 2424 | if (bgp_debug_update(peer, p, NULL, 1)) |
718e3744 | 2425 | { |
16286195 DS |
2426 | if (!peer->rcvd_attr_printed) |
2427 | { | |
2428 | zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str); | |
2429 | peer->rcvd_attr_printed = 1; | |
2430 | } | |
2431 | ||
2ec1e66f | 2432 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2433 | zlog_debug ("%s rcvd %s/%d%s", |
16286195 DS |
2434 | peer->host, |
2435 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 | 2436 | p->prefixlen, buf2); |
718e3744 | 2437 | } |
2438 | ||
718e3744 | 2439 | /* Make new BGP info. */ |
7c8ff89e | 2440 | new = info_make(type, sub_type, 0, peer, attr_new, rn); |
718e3744 | 2441 | |
2442 | /* Update MPLS tag. */ | |
2443 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2444 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
718e3744 | 2445 | |
2446 | /* Nexthop reachability check. */ | |
fc9a856f DS |
2447 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
2448 | { | |
2449 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 && | |
907f92c8 DS |
2450 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) |
2451 | && ! bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
fc9a856f DS |
2452 | connected = 1; |
2453 | else | |
2454 | connected = 0; | |
2455 | ||
75aead62 | 2456 | if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, connected)) |
1a392d46 | 2457 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2458 | else |
fc9a856f DS |
2459 | { |
2460 | if (BGP_DEBUG(nht, NHT)) | |
2461 | { | |
2462 | char buf1[INET6_ADDRSTRLEN]; | |
2463 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN); | |
2464 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); | |
2465 | } | |
2466 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); | |
2467 | } | |
718e3744 | 2468 | } |
2469 | else | |
1a392d46 | 2470 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2471 | |
a82478b9 DS |
2472 | /* Addpath ID */ |
2473 | new->addpath_rx_id = addpath_id; | |
a82478b9 | 2474 | |
902212c3 | 2475 | /* Increment prefix */ |
718e3744 | 2476 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
2477 | ||
2478 | /* Register new BGP information. */ | |
2479 | bgp_info_add (rn, new); | |
200df115 | 2480 | |
2481 | /* route_node_get lock */ | |
2482 | bgp_unlock_node (rn); | |
558d1fec | 2483 | |
718e3744 | 2484 | /* If maximum prefix count is configured and current prefix |
2485 | count exeed it. */ | |
e0701b79 | 2486 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
2487 | return -1; | |
718e3744 | 2488 | |
2489 | /* Process change. */ | |
2490 | bgp_process (bgp, rn, afi, safi); | |
2491 | ||
2492 | return 0; | |
2493 | ||
2494 | /* This BGP update is filtered. Log the reason then update BGP | |
2495 | entry. */ | |
2496 | filtered: | |
3f9c7369 | 2497 | if (bgp_debug_update(peer, p, NULL, 1)) |
16286195 DS |
2498 | { |
2499 | if (!peer->rcvd_attr_printed) | |
2500 | { | |
2501 | zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str); | |
2502 | peer->rcvd_attr_printed = 1; | |
2503 | } | |
2504 | ||
2ec1e66f | 2505 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2506 | zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s", |
16286195 DS |
2507 | peer->host, |
2508 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 | 2509 | p->prefixlen, buf2, reason); |
16286195 | 2510 | } |
718e3744 | 2511 | |
2512 | if (ri) | |
b40d939b | 2513 | bgp_rib_remove (rn, ri, peer, afi, safi); |
718e3744 | 2514 | |
2515 | bgp_unlock_node (rn); | |
558d1fec | 2516 | |
718e3744 | 2517 | return 0; |
2518 | } | |
2519 | ||
2520 | int | |
a82478b9 DS |
2521 | bgp_withdraw (struct peer *peer, struct prefix *p, u_int32_t addpath_id, |
2522 | struct attr *attr, afi_t afi, safi_t safi, int type, int sub_type, | |
2523 | struct prefix_rd *prd, u_char *tag) | |
718e3744 | 2524 | { |
2525 | struct bgp *bgp; | |
2526 | char buf[SU_ADDRSTRLEN]; | |
cd808e74 | 2527 | char buf2[30]; |
718e3744 | 2528 | struct bgp_node *rn; |
2529 | struct bgp_info *ri; | |
2530 | ||
2531 | bgp = peer->bgp; | |
2532 | ||
718e3744 | 2533 | /* Lookup node. */ |
fee0f4c6 | 2534 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 2535 | |
2536 | /* If peer is soft reconfiguration enabled. Record input packet for | |
2537 | further calculation. */ | |
2538 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2539 | && peer != bgp->peer_self) | |
43143c8f | 2540 | bgp_adj_in_unset (rn, peer, addpath_id); |
718e3744 | 2541 | |
2542 | /* Lookup withdrawn route. */ | |
2543 | for (ri = rn->info; ri; ri = ri->next) | |
a82478b9 DS |
2544 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type && |
2545 | ri->addpath_rx_id == addpath_id) | |
718e3744 | 2546 | break; |
2547 | ||
cd808e74 DS |
2548 | /* Logging. */ |
2549 | if (bgp_debug_update(peer, p, NULL, 1)) | |
2550 | { | |
2ec1e66f | 2551 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 DS |
2552 | zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn", |
2553 | peer->host, | |
2554 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2555 | p->prefixlen, buf2); | |
2556 | } | |
2557 | ||
718e3744 | 2558 | /* Withdraw specified route from routing table. */ |
2559 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2560 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
3f9c7369 | 2561 | else if (bgp_debug_update(peer, p, NULL, 1)) |
16286195 DS |
2562 | zlog_debug ("%s Can't find the route %s/%d", peer->host, |
2563 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2564 | p->prefixlen); | |
718e3744 | 2565 | |
2566 | /* Unlock bgp_node_get() lock. */ | |
2567 | bgp_unlock_node (rn); | |
2568 | ||
2569 | return 0; | |
2570 | } | |
6b0655a2 | 2571 | |
718e3744 | 2572 | void |
2573 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) | |
2574 | { | |
3f9c7369 DS |
2575 | struct update_subgroup *subgrp; |
2576 | subgrp = peer_subgroup(peer, afi, safi); | |
2577 | subgroup_default_originate(subgrp, withdraw); | |
2578 | } | |
6182d65b | 2579 | |
718e3744 | 2580 | |
3f9c7369 DS |
2581 | /* |
2582 | * bgp_stop_announce_route_timer | |
2583 | */ | |
2584 | void | |
2585 | bgp_stop_announce_route_timer (struct peer_af *paf) | |
2586 | { | |
2587 | if (!paf->t_announce_route) | |
2588 | return; | |
718e3744 | 2589 | |
3f9c7369 | 2590 | THREAD_TIMER_OFF (paf->t_announce_route); |
718e3744 | 2591 | } |
6b0655a2 | 2592 | |
3f9c7369 DS |
2593 | /* |
2594 | * bgp_announce_route_timer_expired | |
2595 | * | |
2596 | * Callback that is invoked when the route announcement timer for a | |
2597 | * peer_af expires. | |
2598 | */ | |
2599 | static int | |
2600 | bgp_announce_route_timer_expired (struct thread *t) | |
718e3744 | 2601 | { |
3f9c7369 DS |
2602 | struct peer_af *paf; |
2603 | struct peer *peer; | |
558d1fec | 2604 | |
718e3744 | 2605 | |
3f9c7369 DS |
2606 | paf = THREAD_ARG (t); |
2607 | peer = paf->peer; | |
718e3744 | 2608 | |
3f9c7369 DS |
2609 | assert (paf->t_announce_route); |
2610 | paf->t_announce_route = NULL; | |
558d1fec | 2611 | |
3f9c7369 DS |
2612 | if (peer->status != Established) |
2613 | return 0; | |
2614 | ||
2615 | if (!peer->afc_nego[paf->afi][paf->safi]) | |
2616 | return 0; | |
2617 | ||
2618 | peer_af_announce_route (paf, 1); | |
2619 | return 0; | |
718e3744 | 2620 | } |
2621 | ||
3f9c7369 DS |
2622 | /* |
2623 | * bgp_announce_route | |
2624 | * | |
2625 | * *Triggers* announcement of routes of a given AFI/SAFI to a peer. | |
2626 | */ | |
718e3744 | 2627 | void |
2628 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) | |
2629 | { | |
3f9c7369 DS |
2630 | struct peer_af *paf; |
2631 | struct update_subgroup *subgrp; | |
718e3744 | 2632 | |
3f9c7369 DS |
2633 | paf = peer_af_find (peer, afi, safi); |
2634 | if (!paf) | |
718e3744 | 2635 | return; |
3f9c7369 | 2636 | subgrp = PAF_SUBGRP(paf); |
718e3744 | 2637 | |
3f9c7369 DS |
2638 | /* |
2639 | * Ignore if subgroup doesn't exist (implies AF is not negotiated) | |
2640 | * or a refresh has already been triggered. | |
2641 | */ | |
2642 | if (!subgrp || paf->t_announce_route) | |
718e3744 | 2643 | return; |
2644 | ||
d889623f | 2645 | /* |
3f9c7369 DS |
2646 | * Start a timer to stagger/delay the announce. This serves |
2647 | * two purposes - announcement can potentially be combined for | |
2648 | * multiple peers and the announcement doesn't happen in the | |
2649 | * vty context. | |
d889623f | 2650 | */ |
9229d914 | 2651 | THREAD_TIMER_MSEC_ON (bm->master, paf->t_announce_route, |
3f9c7369 DS |
2652 | bgp_announce_route_timer_expired, paf, |
2653 | (subgrp->peer_count == 1) ? | |
2654 | BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS : | |
2655 | BGP_ANNOUNCE_ROUTE_DELAY_MS); | |
2656 | } | |
2657 | ||
2658 | /* | |
2659 | * Announce routes from all AF tables to a peer. | |
2660 | * | |
2661 | * This should ONLY be called when there is a need to refresh the | |
2662 | * routes to the peer based on a policy change for this peer alone | |
2663 | * or a route refresh request received from the peer. | |
2664 | * The operation will result in splitting the peer from its existing | |
2665 | * subgroups and putting it in new subgroups. | |
2666 | */ | |
718e3744 | 2667 | void |
2668 | bgp_announce_route_all (struct peer *peer) | |
2669 | { | |
2670 | afi_t afi; | |
2671 | safi_t safi; | |
2672 | ||
2673 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2674 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2675 | bgp_announce_route (peer, afi, safi); | |
2676 | } | |
6b0655a2 | 2677 | |
fee0f4c6 | 2678 | static void |
718e3744 | 2679 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
8692c506 | 2680 | struct bgp_table *table, struct prefix_rd *prd) |
718e3744 | 2681 | { |
2682 | int ret; | |
2683 | struct bgp_node *rn; | |
2684 | struct bgp_adj_in *ain; | |
2685 | ||
2686 | if (! table) | |
2687 | table = peer->bgp->rib[afi][safi]; | |
2688 | ||
2689 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2690 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2691 | { | |
2692 | if (ain->peer == peer) | |
2693 | { | |
8692c506 | 2694 | struct bgp_info *ri = rn->info; |
d53d8fda | 2695 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
8692c506 | 2696 | |
43143c8f | 2697 | ret = bgp_update (peer, &rn->p, ain->addpath_rx_id, ain->attr, |
a82478b9 | 2698 | afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
d53d8fda | 2699 | prd, tag, 1); |
8692c506 | 2700 | |
718e3744 | 2701 | if (ret < 0) |
2702 | { | |
2703 | bgp_unlock_node (rn); | |
2704 | return; | |
2705 | } | |
718e3744 | 2706 | } |
2707 | } | |
2708 | } | |
2709 | ||
2710 | void | |
2711 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) | |
2712 | { | |
2713 | struct bgp_node *rn; | |
2714 | struct bgp_table *table; | |
2715 | ||
2716 | if (peer->status != Established) | |
2717 | return; | |
2718 | ||
2719 | if (safi != SAFI_MPLS_VPN) | |
8692c506 | 2720 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
718e3744 | 2721 | else |
2722 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2723 | rn = bgp_route_next (rn)) | |
2724 | if ((table = rn->info) != NULL) | |
8692c506 JBD |
2725 | { |
2726 | struct prefix_rd prd; | |
2727 | prd.family = AF_UNSPEC; | |
2728 | prd.prefixlen = 64; | |
2729 | memcpy(&prd.val, rn->p.u.val, 8); | |
2730 | ||
2731 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); | |
2732 | } | |
718e3744 | 2733 | } |
6b0655a2 | 2734 | |
228da428 CC |
2735 | |
2736 | struct bgp_clear_node_queue | |
2737 | { | |
2738 | struct bgp_node *rn; | |
228da428 CC |
2739 | }; |
2740 | ||
200df115 | 2741 | static wq_item_status |
0fb58d5d | 2742 | bgp_clear_route_node (struct work_queue *wq, void *data) |
200df115 | 2743 | { |
228da428 CC |
2744 | struct bgp_clear_node_queue *cnq = data; |
2745 | struct bgp_node *rn = cnq->rn; | |
64e580a7 | 2746 | struct peer *peer = wq->spec.data; |
718e3744 | 2747 | struct bgp_info *ri; |
67174041 AS |
2748 | afi_t afi = bgp_node_table (rn)->afi; |
2749 | safi_t safi = bgp_node_table (rn)->safi; | |
200df115 | 2750 | |
64e580a7 | 2751 | assert (rn && peer); |
200df115 | 2752 | |
43143c8f DS |
2753 | /* It is possible that we have multiple paths for a prefix from a peer |
2754 | * if that peer is using AddPath. | |
2755 | */ | |
64e580a7 | 2756 | for (ri = rn->info; ri; ri = ri->next) |
2a3d5731 | 2757 | if (ri->peer == peer) |
200df115 | 2758 | { |
2759 | /* graceful restart STALE flag set. */ | |
64e580a7 PJ |
2760 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
2761 | && peer->nsf[afi][safi] | |
200df115 | 2762 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
1a392d46 PJ |
2763 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2764 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); | |
200df115 | 2765 | else |
64e580a7 | 2766 | bgp_rib_remove (rn, ri, peer, afi, safi); |
200df115 | 2767 | } |
200df115 | 2768 | return WQ_SUCCESS; |
2769 | } | |
2770 | ||
2771 | static void | |
0fb58d5d | 2772 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
200df115 | 2773 | { |
228da428 CC |
2774 | struct bgp_clear_node_queue *cnq = data; |
2775 | struct bgp_node *rn = cnq->rn; | |
67174041 | 2776 | struct bgp_table *table = bgp_node_table (rn); |
64e580a7 PJ |
2777 | |
2778 | bgp_unlock_node (rn); | |
228da428 CC |
2779 | bgp_table_unlock (table); |
2780 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); | |
200df115 | 2781 | } |
2782 | ||
2783 | static void | |
94f2b392 | 2784 | bgp_clear_node_complete (struct work_queue *wq) |
200df115 | 2785 | { |
64e580a7 PJ |
2786 | struct peer *peer = wq->spec.data; |
2787 | ||
3e0c78ef | 2788 | /* Tickle FSM to start moving again */ |
ca058a30 | 2789 | BGP_EVENT_ADD (peer, Clearing_Completed); |
228da428 CC |
2790 | |
2791 | peer_unlock (peer); /* bgp_clear_route */ | |
200df115 | 2792 | } |
2793 | ||
2794 | static void | |
64e580a7 | 2795 | bgp_clear_node_queue_init (struct peer *peer) |
200df115 | 2796 | { |
a2943657 | 2797 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
64e580a7 | 2798 | |
a2943657 | 2799 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
64e580a7 PJ |
2800 | #undef CLEAR_QUEUE_NAME_LEN |
2801 | ||
87d4a781 | 2802 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
200df115 | 2803 | { |
2804 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
2805 | exit (1); | |
2806 | } | |
64e580a7 PJ |
2807 | peer->clear_node_queue->spec.hold = 10; |
2808 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; | |
2809 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; | |
2810 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; | |
2811 | peer->clear_node_queue->spec.max_retries = 0; | |
2812 | ||
2813 | /* we only 'lock' this peer reference when the queue is actually active */ | |
2814 | peer->clear_node_queue->spec.data = peer; | |
200df115 | 2815 | } |
718e3744 | 2816 | |
200df115 | 2817 | static void |
2818 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, | |
2a3d5731 | 2819 | struct bgp_table *table) |
200df115 | 2820 | { |
200df115 | 2821 | struct bgp_node *rn; |
2822 | ||
f2c31acb | 2823 | |
718e3744 | 2824 | if (! table) |
2a3d5731 | 2825 | table = peer->bgp->rib[afi][safi]; |
64e580a7 | 2826 | |
6cf159b9 | 2827 | /* If still no table => afi/safi isn't configured at all or smth. */ |
2828 | if (! table) | |
2829 | return; | |
65ca75e0 PJ |
2830 | |
2831 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2832 | { | |
f2c31acb PJ |
2833 | struct bgp_info *ri; |
2834 | struct bgp_adj_in *ain; | |
43143c8f | 2835 | struct bgp_adj_in *ain_next; |
f2c31acb PJ |
2836 | |
2837 | /* XXX:TODO: This is suboptimal, every non-empty route_node is | |
2838 | * queued for every clearing peer, regardless of whether it is | |
2839 | * relevant to the peer at hand. | |
2840 | * | |
2841 | * Overview: There are 3 different indices which need to be | |
2842 | * scrubbed, potentially, when a peer is removed: | |
2843 | * | |
2844 | * 1 peer's routes visible via the RIB (ie accepted routes) | |
2845 | * 2 peer's routes visible by the (optional) peer's adj-in index | |
2846 | * 3 other routes visible by the peer's adj-out index | |
2847 | * | |
2848 | * 3 there is no hurry in scrubbing, once the struct peer is | |
2849 | * removed from bgp->peer, we could just GC such deleted peer's | |
2850 | * adj-outs at our leisure. | |
2851 | * | |
2852 | * 1 and 2 must be 'scrubbed' in some way, at least made | |
2853 | * invisible via RIB index before peer session is allowed to be | |
2854 | * brought back up. So one needs to know when such a 'search' is | |
2855 | * complete. | |
2856 | * | |
2857 | * Ideally: | |
2858 | * | |
2859 | * - there'd be a single global queue or a single RIB walker | |
2860 | * - rather than tracking which route_nodes still need to be | |
2861 | * examined on a peer basis, we'd track which peers still | |
2862 | * aren't cleared | |
2863 | * | |
2864 | * Given that our per-peer prefix-counts now should be reliable, | |
2865 | * this may actually be achievable. It doesn't seem to be a huge | |
2866 | * problem at this time, | |
43143c8f DS |
2867 | * |
2868 | * It is possible that we have multiple paths for a prefix from a peer | |
2869 | * if that peer is using AddPath. | |
f2c31acb | 2870 | */ |
43143c8f DS |
2871 | ain = rn->adj_in; |
2872 | while (ain) | |
2873 | { | |
2874 | ain_next = ain->next; | |
2875 | ||
2a3d5731 | 2876 | if (ain->peer == peer) |
43143c8f DS |
2877 | { |
2878 | bgp_adj_in_remove (rn, ain); | |
2879 | bgp_unlock_node (rn); | |
2880 | } | |
2881 | ||
2882 | ain = ain_next; | |
2883 | } | |
3f9c7369 | 2884 | |
f2c31acb | 2885 | for (ri = rn->info; ri; ri = ri->next) |
2a3d5731 | 2886 | if (ri->peer == peer) |
f2c31acb | 2887 | { |
228da428 CC |
2888 | struct bgp_clear_node_queue *cnq; |
2889 | ||
2890 | /* both unlocked in bgp_clear_node_queue_del */ | |
67174041 | 2891 | bgp_table_lock (bgp_node_table (rn)); |
228da428 CC |
2892 | bgp_lock_node (rn); |
2893 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, | |
2894 | sizeof (struct bgp_clear_node_queue)); | |
2895 | cnq->rn = rn; | |
228da428 CC |
2896 | work_queue_add (peer->clear_node_queue, cnq); |
2897 | break; | |
f2c31acb | 2898 | } |
65ca75e0 PJ |
2899 | } |
2900 | return; | |
2901 | } | |
2902 | ||
2903 | void | |
2a3d5731 | 2904 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
65ca75e0 PJ |
2905 | { |
2906 | struct bgp_node *rn; | |
2907 | struct bgp_table *table; | |
6cf159b9 | 2908 | |
64e580a7 PJ |
2909 | if (peer->clear_node_queue == NULL) |
2910 | bgp_clear_node_queue_init (peer); | |
200df115 | 2911 | |
ca058a30 PJ |
2912 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
2913 | * Idle until it receives a Clearing_Completed event. This protects | |
2914 | * against peers which flap faster than we can we clear, which could | |
2915 | * lead to: | |
64e580a7 PJ |
2916 | * |
2917 | * a) race with routes from the new session being installed before | |
2918 | * clear_route_node visits the node (to delete the route of that | |
2919 | * peer) | |
2920 | * b) resource exhaustion, clear_route_node likely leads to an entry | |
2921 | * on the process_main queue. Fast-flapping could cause that queue | |
2922 | * to grow and grow. | |
200df115 | 2923 | */ |
dc83d712 DS |
2924 | |
2925 | /* lock peer in assumption that clear-node-queue will get nodes; if so, | |
2926 | * the unlock will happen upon work-queue completion; other wise, the | |
2927 | * unlock happens at the end of this function. | |
2928 | */ | |
ca058a30 | 2929 | if (!peer->clear_node_queue->thread) |
dc83d712 | 2930 | peer_lock (peer); |
fee0f4c6 | 2931 | |
2a3d5731 DW |
2932 | if (safi != SAFI_MPLS_VPN) |
2933 | bgp_clear_route_table (peer, afi, safi, NULL); | |
2934 | else | |
2935 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2936 | rn = bgp_route_next (rn)) | |
2937 | if ((table = rn->info) != NULL) | |
2938 | bgp_clear_route_table (peer, afi, safi, table); | |
dc83d712 DS |
2939 | |
2940 | /* unlock if no nodes got added to the clear-node-queue. */ | |
65ca75e0 | 2941 | if (!peer->clear_node_queue->thread) |
dc83d712 DS |
2942 | peer_unlock (peer); |
2943 | ||
718e3744 | 2944 | } |
2945 | ||
2946 | void | |
2947 | bgp_clear_route_all (struct peer *peer) | |
2948 | { | |
2949 | afi_t afi; | |
2950 | safi_t safi; | |
2951 | ||
2952 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2953 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2a3d5731 | 2954 | bgp_clear_route (peer, afi, safi); |
718e3744 | 2955 | } |
2956 | ||
2957 | void | |
2958 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) | |
2959 | { | |
2960 | struct bgp_table *table; | |
2961 | struct bgp_node *rn; | |
2962 | struct bgp_adj_in *ain; | |
43143c8f | 2963 | struct bgp_adj_in *ain_next; |
718e3744 | 2964 | |
2965 | table = peer->bgp->rib[afi][safi]; | |
2966 | ||
43143c8f DS |
2967 | /* It is possible that we have multiple paths for a prefix from a peer |
2968 | * if that peer is using AddPath. | |
2969 | */ | |
718e3744 | 2970 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
43143c8f DS |
2971 | { |
2972 | ain = rn->adj_in; | |
2973 | ||
2974 | while (ain) | |
2975 | { | |
2976 | ain_next = ain->next; | |
2977 | ||
2978 | if (ain->peer == peer) | |
2979 | { | |
2980 | bgp_adj_in_remove (rn, ain); | |
2981 | bgp_unlock_node (rn); | |
2982 | } | |
2983 | ||
2984 | ain = ain_next; | |
2985 | } | |
2986 | } | |
718e3744 | 2987 | } |
93406d87 | 2988 | |
2989 | void | |
2990 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) | |
2991 | { | |
2992 | struct bgp_node *rn; | |
2993 | struct bgp_info *ri; | |
2994 | struct bgp_table *table; | |
2995 | ||
2996 | table = peer->bgp->rib[afi][safi]; | |
2997 | ||
2998 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2999 | { | |
3000 | for (ri = rn->info; ri; ri = ri->next) | |
3001 | if (ri->peer == peer) | |
3002 | { | |
3003 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
3004 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
3005 | break; | |
3006 | } | |
3007 | } | |
3008 | } | |
6b0655a2 | 3009 | |
718e3744 | 3010 | /* Delete all kernel routes. */ |
3011 | void | |
66e5cd87 | 3012 | bgp_cleanup_routes (void) |
718e3744 | 3013 | { |
3014 | struct bgp *bgp; | |
1eb8ef25 | 3015 | struct listnode *node, *nnode; |
718e3744 | 3016 | struct bgp_node *rn; |
3017 | struct bgp_table *table; | |
3018 | struct bgp_info *ri; | |
3019 | ||
1eb8ef25 | 3020 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 3021 | { |
3022 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; | |
3023 | ||
3024 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3025 | for (ri = rn->info; ri; ri = ri->next) | |
3026 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
3027 | && ri->type == ZEBRA_ROUTE_BGP | |
f992e2a9 DS |
3028 | && (ri->sub_type == BGP_ROUTE_NORMAL || |
3029 | ri->sub_type == BGP_ROUTE_AGGREGATE)) | |
5a616c08 | 3030 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
718e3744 | 3031 | |
3032 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; | |
3033 | ||
3034 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3035 | for (ri = rn->info; ri; ri = ri->next) | |
3036 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
3037 | && ri->type == ZEBRA_ROUTE_BGP | |
f992e2a9 DS |
3038 | && (ri->sub_type == BGP_ROUTE_NORMAL || |
3039 | ri->sub_type == BGP_ROUTE_AGGREGATE)) | |
5a616c08 | 3040 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
718e3744 | 3041 | } |
3042 | } | |
3043 | ||
3044 | void | |
66e5cd87 | 3045 | bgp_reset (void) |
718e3744 | 3046 | { |
3047 | vty_reset (); | |
3048 | bgp_zclient_reset (); | |
3049 | access_list_reset (); | |
3050 | prefix_list_reset (); | |
3051 | } | |
6b0655a2 | 3052 | |
adbac85e DW |
3053 | static int |
3054 | bgp_addpath_encode_rx (struct peer *peer, afi_t afi, safi_t safi) | |
3055 | { | |
3056 | return (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) && | |
3057 | CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)); | |
3058 | } | |
3059 | ||
718e3744 | 3060 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
3061 | value. */ | |
3062 | int | |
3063 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) | |
3064 | { | |
3065 | u_char *pnt; | |
3066 | u_char *lim; | |
3067 | struct prefix p; | |
3068 | int psize; | |
3069 | int ret; | |
a82478b9 DS |
3070 | afi_t afi; |
3071 | safi_t safi; | |
adbac85e | 3072 | int addpath_encoded; |
a82478b9 | 3073 | u_int32_t addpath_id; |
718e3744 | 3074 | |
3075 | /* Check peer status. */ | |
3076 | if (peer->status != Established) | |
3077 | return 0; | |
3078 | ||
3079 | pnt = packet->nlri; | |
3080 | lim = pnt + packet->length; | |
a82478b9 DS |
3081 | afi = packet->afi; |
3082 | safi = packet->safi; | |
3083 | addpath_id = 0; | |
adbac85e | 3084 | addpath_encoded = bgp_addpath_encode_rx (peer, afi, safi); |
718e3744 | 3085 | |
3086 | for (; pnt < lim; pnt += psize) | |
3087 | { | |
3088 | /* Clear prefix structure. */ | |
3089 | memset (&p, 0, sizeof (struct prefix)); | |
3090 | ||
a82478b9 DS |
3091 | if (addpath_encoded) |
3092 | { | |
cd808e74 DS |
3093 | |
3094 | /* When packet overflow occurs return immediately. */ | |
3095 | if (pnt + BGP_ADDPATH_ID_LEN > lim) | |
3096 | return -1; | |
3097 | ||
a82478b9 DS |
3098 | addpath_id = ntohl(*((uint32_t*) pnt)); |
3099 | pnt += BGP_ADDPATH_ID_LEN; | |
3100 | } | |
3101 | ||
718e3744 | 3102 | /* Fetch prefix length. */ |
3103 | p.prefixlen = *pnt++; | |
a82478b9 | 3104 | p.family = afi2family (afi); |
718e3744 | 3105 | |
3106 | /* Already checked in nlri_sanity_check(). We do double check | |
3107 | here. */ | |
a82478b9 DS |
3108 | if ((afi == AFI_IP && p.prefixlen > 32) |
3109 | || (afi == AFI_IP6 && p.prefixlen > 128)) | |
718e3744 | 3110 | return -1; |
3111 | ||
3112 | /* Packet size overflow check. */ | |
3113 | psize = PSIZE (p.prefixlen); | |
3114 | ||
3115 | /* When packet overflow occur return immediately. */ | |
3116 | if (pnt + psize > lim) | |
3117 | return -1; | |
3118 | ||
3119 | /* Fetch prefix from NLRI packet. */ | |
3120 | memcpy (&p.u.prefix, pnt, psize); | |
3121 | ||
3122 | /* Check address. */ | |
a82478b9 | 3123 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
718e3744 | 3124 | { |
3125 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) | |
3126 | { | |
f5ba3874 | 3127 | /* |
3128 | * From draft-ietf-idr-bgp4-22, Section 6.3: | |
3129 | * If a BGP router receives an UPDATE message with a | |
3130 | * semantically incorrect NLRI field, in which a prefix is | |
3131 | * semantically incorrect (eg. an unexpected multicast IP | |
3132 | * address), it should ignore the prefix. | |
3133 | */ | |
16286195 DS |
3134 | zlog_err ("IPv4 unicast NLRI is multicast address %s", |
3135 | inet_ntoa (p.u.prefix4)); | |
f5ba3874 | 3136 | |
718e3744 | 3137 | return -1; |
3138 | } | |
3139 | } | |
3140 | ||
3141 | #ifdef HAVE_IPV6 | |
3142 | /* Check address. */ | |
a82478b9 | 3143 | if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
718e3744 | 3144 | { |
3145 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3146 | { | |
3147 | char buf[BUFSIZ]; | |
3148 | ||
16286195 DS |
3149 | zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI", |
3150 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); | |
718e3744 | 3151 | |
3152 | continue; | |
3153 | } | |
3154 | } | |
3155 | #endif /* HAVE_IPV6 */ | |
3156 | ||
3157 | /* Normal process. */ | |
3158 | if (attr) | |
a82478b9 | 3159 | ret = bgp_update (peer, &p, addpath_id, attr, afi, safi, |
718e3744 | 3160 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
3161 | else | |
a82478b9 | 3162 | ret = bgp_withdraw (peer, &p, addpath_id, attr, afi, safi, |
718e3744 | 3163 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
3164 | ||
3165 | /* Address family configuration mismatch or maximum-prefix count | |
3166 | overflow. */ | |
3167 | if (ret < 0) | |
3168 | return -1; | |
3169 | } | |
3170 | ||
3171 | /* Packet length consistency check. */ | |
3172 | if (pnt != lim) | |
3173 | return -1; | |
3174 | ||
3175 | return 0; | |
3176 | } | |
3177 | ||
3178 | /* NLRI encode syntax check routine. */ | |
3179 | int | |
a82478b9 | 3180 | bgp_nlri_sanity_check (struct peer *peer, int afi, safi_t safi, u_char *pnt, |
d889623f | 3181 | bgp_size_t length, int *numpfx) |
718e3744 | 3182 | { |
3183 | u_char *end; | |
3184 | u_char prefixlen; | |
3185 | int psize; | |
adbac85e | 3186 | int addpath_encoded; |
718e3744 | 3187 | |
d889623f | 3188 | *numpfx = 0; |
718e3744 | 3189 | end = pnt + length; |
adbac85e | 3190 | addpath_encoded = bgp_addpath_encode_rx (peer, afi, safi); |
a82478b9 | 3191 | |
718e3744 | 3192 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
3193 | syntactic validity. If the field is syntactically incorrect, | |
3194 | then the Error Subcode is set to Invalid Network Field. */ | |
3195 | ||
3196 | while (pnt < end) | |
3197 | { | |
cd808e74 | 3198 | |
a82478b9 DS |
3199 | /* If the NLRI is encoded using addpath then the first 4 bytes are |
3200 | * the addpath ID. */ | |
3201 | if (addpath_encoded) | |
cd808e74 DS |
3202 | { |
3203 | if (pnt + BGP_ADDPATH_ID_LEN > end) | |
3204 | { | |
3205 | zlog_err ("%s [Error] Update packet error" | |
3206 | " (prefix data addpath overflow)", | |
3207 | peer->host); | |
3208 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3209 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3210 | return -1; | |
3211 | } | |
3212 | pnt += BGP_ADDPATH_ID_LEN; | |
3213 | } | |
a82478b9 | 3214 | |
718e3744 | 3215 | prefixlen = *pnt++; |
3216 | ||
3217 | /* Prefix length check. */ | |
3218 | if ((afi == AFI_IP && prefixlen > 32) | |
3219 | || (afi == AFI_IP6 && prefixlen > 128)) | |
3220 | { | |
16286195 | 3221 | zlog_err ("%s [Error] Update packet error (wrong prefix length %d)", |
718e3744 | 3222 | peer->host, prefixlen); |
3223 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3224 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3225 | return -1; | |
3226 | } | |
3227 | ||
3228 | /* Packet size overflow check. */ | |
3229 | psize = PSIZE (prefixlen); | |
3230 | ||
3231 | if (pnt + psize > end) | |
3232 | { | |
16286195 | 3233 | zlog_err ("%s [Error] Update packet error" |
718e3744 | 3234 | " (prefix data overflow prefix size is %d)", |
3235 | peer->host, psize); | |
3236 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3237 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3238 | return -1; | |
3239 | } | |
3240 | ||
3241 | pnt += psize; | |
d889623f | 3242 | (*numpfx)++; |
718e3744 | 3243 | } |
3244 | ||
3245 | /* Packet length consistency check. */ | |
3246 | if (pnt != end) | |
3247 | { | |
16286195 | 3248 | zlog_err ("%s [Error] Update packet error" |
718e3744 | 3249 | " (prefix length mismatch with total length)", |
3250 | peer->host); | |
3251 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3252 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3253 | return -1; | |
3254 | } | |
3255 | return 0; | |
3256 | } | |
6b0655a2 | 3257 | |
94f2b392 | 3258 | static struct bgp_static * |
66e5cd87 | 3259 | bgp_static_new (void) |
718e3744 | 3260 | { |
393deb9b | 3261 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
718e3744 | 3262 | } |
3263 | ||
94f2b392 | 3264 | static void |
718e3744 | 3265 | bgp_static_free (struct bgp_static *bgp_static) |
3266 | { | |
3267 | if (bgp_static->rmap.name) | |
6e919709 | 3268 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
718e3744 | 3269 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
3270 | } | |
3271 | ||
94f2b392 | 3272 | static void |
2a3d5731 DW |
3273 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
3274 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
fee0f4c6 | 3275 | { |
3276 | struct bgp_node *rn; | |
3277 | struct bgp_info *ri; | |
2a3d5731 DW |
3278 | struct bgp_info *new; |
3279 | struct bgp_info info; | |
3280 | struct attr attr; | |
3281 | struct attr *attr_new; | |
3282 | int ret; | |
fee0f4c6 | 3283 | |
2a3d5731 DW |
3284 | assert (bgp_static); |
3285 | if (!bgp_static) | |
3286 | return; | |
dd8103a9 | 3287 | |
fee0f4c6 | 3288 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3289 | |
3290 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
dd8103a9 PJ |
3291 | |
3292 | attr.nexthop = bgp_static->igpnexthop; | |
3293 | attr.med = bgp_static->igpmetric; | |
3294 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
718e3744 | 3295 | |
41367172 PJ |
3296 | if (bgp_static->atomic) |
3297 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3298 | ||
718e3744 | 3299 | /* Apply route-map. */ |
3300 | if (bgp_static->rmap.name) | |
3301 | { | |
fb982c25 | 3302 | struct attr attr_tmp = attr; |
718e3744 | 3303 | info.peer = bgp->peer_self; |
286e1e71 | 3304 | info.attr = &attr_tmp; |
718e3744 | 3305 | |
fee0f4c6 | 3306 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3307 | ||
718e3744 | 3308 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
286e1e71 | 3309 | |
fee0f4c6 | 3310 | bgp->peer_self->rmap_type = 0; |
3311 | ||
718e3744 | 3312 | if (ret == RMAP_DENYMATCH) |
3313 | { | |
3314 | /* Free uninterned attribute. */ | |
286e1e71 | 3315 | bgp_attr_flush (&attr_tmp); |
718e3744 | 3316 | |
3317 | /* Unintern original. */ | |
f6f434b2 | 3318 | aspath_unintern (&attr.aspath); |
fb982c25 | 3319 | bgp_attr_extra_free (&attr); |
718e3744 | 3320 | bgp_static_withdraw (bgp, p, afi, safi); |
3321 | return; | |
3322 | } | |
286e1e71 | 3323 | attr_new = bgp_attr_intern (&attr_tmp); |
718e3744 | 3324 | } |
286e1e71 | 3325 | else |
3326 | attr_new = bgp_attr_intern (&attr); | |
718e3744 | 3327 | |
3328 | for (ri = rn->info; ri; ri = ri->next) | |
3329 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3330 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3331 | break; | |
3332 | ||
3333 | if (ri) | |
3334 | { | |
8d45210e | 3335 | if (attrhash_cmp (ri->attr, attr_new) && |
078430f6 DS |
3336 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) && |
3337 | !bgp_flag_check(bgp, BGP_FLAG_FORCE_STATIC_PROCESS)) | |
718e3744 | 3338 | { |
3339 | bgp_unlock_node (rn); | |
f6f434b2 PJ |
3340 | bgp_attr_unintern (&attr_new); |
3341 | aspath_unintern (&attr.aspath); | |
fb982c25 | 3342 | bgp_attr_extra_free (&attr); |
718e3744 | 3343 | return; |
3344 | } | |
3345 | else | |
3346 | { | |
3347 | /* The attribute is changed. */ | |
1a392d46 | 3348 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 3349 | |
3350 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3351 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3352 | bgp_info_restore(rn, ri); | |
3353 | else | |
3354 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
f6f434b2 | 3355 | bgp_attr_unintern (&ri->attr); |
718e3744 | 3356 | ri->attr = attr_new; |
65957886 | 3357 | ri->uptime = bgp_clock (); |
718e3744 | 3358 | |
fc9a856f DS |
3359 | /* Nexthop reachability check. */ |
3360 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3361 | { | |
75aead62 | 3362 | if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, 0)) |
fc9a856f DS |
3363 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
3364 | else | |
3365 | { | |
3366 | if (BGP_DEBUG(nht, NHT)) | |
3367 | { | |
3368 | char buf1[INET6_ADDRSTRLEN]; | |
078430f6 DS |
3369 | inet_ntop(p->family, &p->u.prefix, buf1, |
3370 | INET6_ADDRSTRLEN); | |
3371 | zlog_debug("%s(%s): Route not in table, not advertising", | |
3372 | __FUNCTION__, buf1); | |
fc9a856f DS |
3373 | } |
3374 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); | |
3375 | } | |
3376 | } | |
078430f6 DS |
3377 | else |
3378 | { | |
3379 | /* Delete the NHT structure if any, if we're toggling between | |
3380 | * enabling/disabling import check. We deregister the route | |
3381 | * from NHT to avoid overloading NHT and the process interaction | |
3382 | */ | |
3383 | bgp_unlink_nexthop(ri); | |
3384 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); | |
3385 | } | |
718e3744 | 3386 | /* Process change. */ |
3387 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
3388 | bgp_process (bgp, rn, afi, safi); | |
3389 | bgp_unlock_node (rn); | |
f6f434b2 | 3390 | aspath_unintern (&attr.aspath); |
fb982c25 | 3391 | bgp_attr_extra_free (&attr); |
718e3744 | 3392 | return; |
3393 | } | |
3394 | } | |
3395 | ||
3396 | /* Make new BGP info. */ | |
7c8ff89e | 3397 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self, attr_new, |
fb018d25 | 3398 | rn); |
fc9a856f DS |
3399 | /* Nexthop reachability check. */ |
3400 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3401 | { | |
75aead62 | 3402 | if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, 0)) |
fc9a856f DS |
3403 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
3404 | else | |
3405 | { | |
3406 | if (BGP_DEBUG(nht, NHT)) | |
3407 | { | |
3408 | char buf1[INET6_ADDRSTRLEN]; | |
078430f6 | 3409 | inet_ntop(p->family, &p->u.prefix, buf1, |
fc9a856f | 3410 | INET6_ADDRSTRLEN); |
078430f6 DS |
3411 | zlog_debug("%s(%s): Route not in table, not advertising", |
3412 | __FUNCTION__, buf1); | |
fc9a856f DS |
3413 | } |
3414 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); | |
3415 | } | |
3416 | } | |
3417 | else | |
078430f6 DS |
3418 | { |
3419 | /* Delete the NHT structure if any, if we're toggling between | |
3420 | * enabling/disabling import check. We deregister the route | |
3421 | * from NHT to avoid overloading NHT and the process interaction | |
3422 | */ | |
3423 | bgp_unlink_nexthop(new); | |
3424 | ||
3425 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); | |
3426 | } | |
718e3744 | 3427 | |
3428 | /* Aggregate address increment. */ | |
3429 | bgp_aggregate_increment (bgp, p, new, afi, safi); | |
3430 | ||
3431 | /* Register new BGP information. */ | |
3432 | bgp_info_add (rn, new); | |
200df115 | 3433 | |
3434 | /* route_node_get lock */ | |
3435 | bgp_unlock_node (rn); | |
3436 | ||
718e3744 | 3437 | /* Process change. */ |
3438 | bgp_process (bgp, rn, afi, safi); | |
3439 | ||
3440 | /* Unintern original. */ | |
f6f434b2 | 3441 | aspath_unintern (&attr.aspath); |
fb982c25 | 3442 | bgp_attr_extra_free (&attr); |
718e3744 | 3443 | } |
3444 | ||
fee0f4c6 | 3445 | void |
3446 | bgp_static_update (struct bgp *bgp, struct prefix *p, | |
3447 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
3448 | { | |
fee0f4c6 | 3449 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
fee0f4c6 | 3450 | } |
3451 | ||
94f2b392 | 3452 | static void |
4c9641ba ML |
3453 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3454 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3455 | { |
3456 | struct bgp_node *rn; | |
3457 | struct bgp_info *new; | |
fb982c25 | 3458 | |
fee0f4c6 | 3459 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3460 | |
3461 | /* Make new BGP info. */ | |
7c8ff89e | 3462 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self, |
fb018d25 DS |
3463 | bgp_attr_default_intern(BGP_ORIGIN_IGP), rn); |
3464 | ||
718e3744 | 3465 | SET_FLAG (new->flags, BGP_INFO_VALID); |
fb982c25 PJ |
3466 | new->extra = bgp_info_extra_new(); |
3467 | memcpy (new->extra->tag, tag, 3); | |
718e3744 | 3468 | |
3469 | /* Aggregate address increment. */ | |
200df115 | 3470 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
718e3744 | 3471 | |
3472 | /* Register new BGP information. */ | |
200df115 | 3473 | bgp_info_add (rn, new); |
718e3744 | 3474 | |
200df115 | 3475 | /* route_node_get lock */ |
3476 | bgp_unlock_node (rn); | |
3477 | ||
718e3744 | 3478 | /* Process change. */ |
3479 | bgp_process (bgp, rn, afi, safi); | |
3480 | } | |
3481 | ||
3482 | void | |
3483 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, | |
3484 | safi_t safi) | |
3485 | { | |
3486 | struct bgp_node *rn; | |
3487 | struct bgp_info *ri; | |
3488 | ||
fee0f4c6 | 3489 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3490 | |
3491 | /* Check selected route and self inserted route. */ | |
3492 | for (ri = rn->info; ri; ri = ri->next) | |
3493 | if (ri->peer == bgp->peer_self | |
3494 | && ri->type == ZEBRA_ROUTE_BGP | |
3495 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3496 | break; | |
3497 | ||
3498 | /* Withdraw static BGP route from routing table. */ | |
3499 | if (ri) | |
3500 | { | |
3501 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
fc9a856f | 3502 | bgp_unlink_nexthop(ri); |
718e3744 | 3503 | bgp_info_delete (rn, ri); |
1a392d46 | 3504 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3505 | } |
3506 | ||
3507 | /* Unlock bgp_node_lookup. */ | |
3508 | bgp_unlock_node (rn); | |
3509 | } | |
3510 | ||
94f2b392 | 3511 | static void |
4c9641ba ML |
3512 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3513 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3514 | { |
3515 | struct bgp_node *rn; | |
3516 | struct bgp_info *ri; | |
3517 | ||
fee0f4c6 | 3518 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3519 | |
3520 | /* Check selected route and self inserted route. */ | |
3521 | for (ri = rn->info; ri; ri = ri->next) | |
3522 | if (ri->peer == bgp->peer_self | |
3523 | && ri->type == ZEBRA_ROUTE_BGP | |
3524 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3525 | break; | |
3526 | ||
3527 | /* Withdraw static BGP route from routing table. */ | |
3528 | if (ri) | |
3529 | { | |
3530 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3531 | bgp_info_delete (rn, ri); |
1a392d46 | 3532 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3533 | } |
3534 | ||
3535 | /* Unlock bgp_node_lookup. */ | |
3536 | bgp_unlock_node (rn); | |
3537 | } | |
3538 | ||
3539 | /* Configure static BGP network. When user don't run zebra, static | |
3540 | route should be installed as valid. */ | |
94f2b392 | 3541 | static int |
fd79ac91 | 3542 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
c8f3fe30 | 3543 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
718e3744 | 3544 | { |
3545 | int ret; | |
3546 | struct prefix p; | |
3547 | struct bgp_static *bgp_static; | |
3548 | struct bgp_node *rn; | |
41367172 | 3549 | u_char need_update = 0; |
718e3744 | 3550 | |
3551 | /* Convert IP prefix string to struct prefix. */ | |
3552 | ret = str2prefix (ip_str, &p); | |
3553 | if (! ret) | |
3554 | { | |
3555 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3556 | return CMD_WARNING; | |
3557 | } | |
3558 | #ifdef HAVE_IPV6 | |
3559 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3560 | { | |
3561 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3562 | VTY_NEWLINE); | |
3563 | return CMD_WARNING; | |
3564 | } | |
3565 | #endif /* HAVE_IPV6 */ | |
3566 | ||
3567 | apply_mask (&p); | |
3568 | ||
3569 | /* Set BGP static route configuration. */ | |
3570 | rn = bgp_node_get (bgp->route[afi][safi], &p); | |
3571 | ||
3572 | if (rn->info) | |
3573 | { | |
3574 | /* Configuration change. */ | |
3575 | bgp_static = rn->info; | |
3576 | ||
3577 | /* Check previous routes are installed into BGP. */ | |
c8f3fe30 PJ |
3578 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
3579 | need_update = 1; | |
41367172 | 3580 | |
718e3744 | 3581 | bgp_static->backdoor = backdoor; |
41367172 | 3582 | |
718e3744 | 3583 | if (rmap) |
3584 | { | |
3585 | if (bgp_static->rmap.name) | |
6e919709 DS |
3586 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
3587 | bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap); | |
718e3744 | 3588 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
3589 | } | |
3590 | else | |
3591 | { | |
3592 | if (bgp_static->rmap.name) | |
6e919709 | 3593 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
718e3744 | 3594 | bgp_static->rmap.name = NULL; |
3595 | bgp_static->rmap.map = NULL; | |
3596 | bgp_static->valid = 0; | |
3597 | } | |
3598 | bgp_unlock_node (rn); | |
3599 | } | |
3600 | else | |
3601 | { | |
3602 | /* New configuration. */ | |
3603 | bgp_static = bgp_static_new (); | |
3604 | bgp_static->backdoor = backdoor; | |
3605 | bgp_static->valid = 0; | |
3606 | bgp_static->igpmetric = 0; | |
3607 | bgp_static->igpnexthop.s_addr = 0; | |
41367172 | 3608 | |
718e3744 | 3609 | if (rmap) |
3610 | { | |
3611 | if (bgp_static->rmap.name) | |
6e919709 DS |
3612 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
3613 | bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap); | |
718e3744 | 3614 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
3615 | } | |
3616 | rn->info = bgp_static; | |
3617 | } | |
3618 | ||
fc9a856f DS |
3619 | bgp_static->valid = 1; |
3620 | if (need_update) | |
3621 | bgp_static_withdraw (bgp, &p, afi, safi); | |
718e3744 | 3622 | |
fc9a856f DS |
3623 | if (! bgp_static->backdoor) |
3624 | bgp_static_update (bgp, &p, bgp_static, afi, safi); | |
718e3744 | 3625 | |
3626 | return CMD_SUCCESS; | |
3627 | } | |
3628 | ||
3629 | /* Configure static BGP network. */ | |
94f2b392 | 3630 | static int |
fd79ac91 | 3631 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
4c9641ba | 3632 | afi_t afi, safi_t safi) |
718e3744 | 3633 | { |
3634 | int ret; | |
3635 | struct prefix p; | |
3636 | struct bgp_static *bgp_static; | |
3637 | struct bgp_node *rn; | |
3638 | ||
3639 | /* Convert IP prefix string to struct prefix. */ | |
3640 | ret = str2prefix (ip_str, &p); | |
3641 | if (! ret) | |
3642 | { | |
3643 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3644 | return CMD_WARNING; | |
3645 | } | |
3646 | #ifdef HAVE_IPV6 | |
3647 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3648 | { | |
3649 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3650 | VTY_NEWLINE); | |
3651 | return CMD_WARNING; | |
3652 | } | |
3653 | #endif /* HAVE_IPV6 */ | |
3654 | ||
3655 | apply_mask (&p); | |
3656 | ||
3657 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); | |
3658 | if (! rn) | |
3659 | { | |
3660 | vty_out (vty, "%% Can't find specified static route configuration.%s", | |
3661 | VTY_NEWLINE); | |
3662 | return CMD_WARNING; | |
3663 | } | |
3664 | ||
3665 | bgp_static = rn->info; | |
41367172 | 3666 | |
718e3744 | 3667 | /* Update BGP RIB. */ |
3668 | if (! bgp_static->backdoor) | |
3669 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3670 | ||
3671 | /* Clear configuration. */ | |
3672 | bgp_static_free (bgp_static); | |
3673 | rn->info = NULL; | |
3674 | bgp_unlock_node (rn); | |
3675 | bgp_unlock_node (rn); | |
3676 | ||
3677 | return CMD_SUCCESS; | |
3678 | } | |
3679 | ||
6aeb9e78 DS |
3680 | void |
3681 | bgp_static_add (struct bgp *bgp) | |
3682 | { | |
3683 | afi_t afi; | |
3684 | safi_t safi; | |
3685 | struct bgp_node *rn; | |
3686 | struct bgp_node *rm; | |
3687 | struct bgp_table *table; | |
3688 | struct bgp_static *bgp_static; | |
3689 | ||
3690 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3691 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3692 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3693 | if (rn->info != NULL) | |
3694 | { | |
3695 | if (safi == SAFI_MPLS_VPN) | |
3696 | { | |
3697 | table = rn->info; | |
3698 | ||
3699 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3700 | { | |
3701 | bgp_static = rn->info; | |
3702 | bgp_static_update_vpnv4 (bgp, &rm->p, | |
3703 | AFI_IP, SAFI_MPLS_VPN, | |
3704 | (struct prefix_rd *)&rn->p, | |
3705 | bgp_static->tag); | |
3706 | } | |
3707 | } | |
3708 | else | |
3709 | { | |
3710 | bgp_static_update (bgp, &rn->p, rn->info, afi, safi); | |
3711 | } | |
3712 | } | |
3713 | } | |
3714 | ||
718e3744 | 3715 | /* Called from bgp_delete(). Delete all static routes from the BGP |
3716 | instance. */ | |
3717 | void | |
3718 | bgp_static_delete (struct bgp *bgp) | |
3719 | { | |
3720 | afi_t afi; | |
3721 | safi_t safi; | |
3722 | struct bgp_node *rn; | |
3723 | struct bgp_node *rm; | |
3724 | struct bgp_table *table; | |
3725 | struct bgp_static *bgp_static; | |
3726 | ||
3727 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3728 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3729 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3730 | if (rn->info != NULL) | |
3731 | { | |
3732 | if (safi == SAFI_MPLS_VPN) | |
3733 | { | |
3734 | table = rn->info; | |
3735 | ||
3736 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3737 | { | |
3738 | bgp_static = rn->info; | |
3739 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, | |
3740 | AFI_IP, SAFI_MPLS_VPN, | |
3741 | (struct prefix_rd *)&rn->p, | |
3742 | bgp_static->tag); | |
3743 | bgp_static_free (bgp_static); | |
3744 | rn->info = NULL; | |
3745 | bgp_unlock_node (rn); | |
3746 | } | |
3747 | } | |
3748 | else | |
3749 | { | |
3750 | bgp_static = rn->info; | |
3751 | bgp_static_withdraw (bgp, &rn->p, afi, safi); | |
3752 | bgp_static_free (bgp_static); | |
3753 | rn->info = NULL; | |
3754 | bgp_unlock_node (rn); | |
3755 | } | |
3756 | } | |
3757 | } | |
3758 | ||
078430f6 DS |
3759 | void |
3760 | bgp_static_redo_import_check (struct bgp *bgp) | |
3761 | { | |
3762 | afi_t afi; | |
3763 | safi_t safi; | |
3764 | struct bgp_node *rn; | |
078430f6 DS |
3765 | struct bgp_static *bgp_static; |
3766 | ||
3767 | /* Use this flag to force reprocessing of the route */ | |
3768 | bgp_flag_set(bgp, BGP_FLAG_FORCE_STATIC_PROCESS); | |
3769 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3770 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3771 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3772 | if (rn->info != NULL) | |
3773 | { | |
3774 | bgp_static = rn->info; | |
3775 | bgp_static_update (bgp, &rn->p, bgp_static, afi, safi); | |
3776 | } | |
3777 | bgp_flag_unset(bgp, BGP_FLAG_FORCE_STATIC_PROCESS); | |
3778 | } | |
3779 | ||
ad4cbda1 | 3780 | static void |
3781 | bgp_purge_af_static_redist_routes (struct bgp *bgp, afi_t afi, safi_t safi) | |
3782 | { | |
3783 | struct bgp_table *table; | |
3784 | struct bgp_node *rn; | |
3785 | struct bgp_info *ri; | |
3786 | ||
3787 | table = bgp->rib[afi][safi]; | |
3788 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3789 | { | |
3790 | for (ri = rn->info; ri; ri = ri->next) | |
3791 | { | |
3792 | if (ri->peer == bgp->peer_self && | |
3793 | ((ri->type == ZEBRA_ROUTE_BGP && | |
3794 | ri->sub_type == BGP_ROUTE_STATIC) || | |
3795 | (ri->type != ZEBRA_ROUTE_BGP && | |
3796 | ri->sub_type == BGP_ROUTE_REDISTRIBUTE))) | |
3797 | { | |
3798 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, safi); | |
3799 | bgp_unlink_nexthop(ri); | |
3800 | bgp_info_delete (rn, ri); | |
3801 | bgp_process (bgp, rn, afi, safi); | |
3802 | } | |
3803 | } | |
3804 | } | |
3805 | } | |
3806 | ||
3807 | /* | |
3808 | * Purge all networks and redistributed routes from routing table. | |
3809 | * Invoked upon the instance going down. | |
3810 | */ | |
3811 | void | |
3812 | bgp_purge_static_redist_routes (struct bgp *bgp) | |
3813 | { | |
3814 | afi_t afi; | |
3815 | safi_t safi; | |
3816 | ||
3817 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3818 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3819 | bgp_purge_af_static_redist_routes (bgp, afi, safi); | |
3820 | } | |
3821 | ||
718e3744 | 3822 | int |
fd79ac91 | 3823 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
3824 | const char *tag_str) | |
718e3744 | 3825 | { |
3826 | int ret; | |
3827 | struct prefix p; | |
3828 | struct prefix_rd prd; | |
3829 | struct bgp *bgp; | |
3830 | struct bgp_node *prn; | |
3831 | struct bgp_node *rn; | |
3832 | struct bgp_table *table; | |
3833 | struct bgp_static *bgp_static; | |
3834 | u_char tag[3]; | |
3835 | ||
3836 | bgp = vty->index; | |
3837 | ||
3838 | ret = str2prefix (ip_str, &p); | |
3839 | if (! ret) | |
3840 | { | |
3841 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3842 | return CMD_WARNING; | |
3843 | } | |
3844 | apply_mask (&p); | |
3845 | ||
3846 | ret = str2prefix_rd (rd_str, &prd); | |
3847 | if (! ret) | |
3848 | { | |
3849 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3850 | return CMD_WARNING; | |
3851 | } | |
3852 | ||
3853 | ret = str2tag (tag_str, tag); | |
3854 | if (! ret) | |
3855 | { | |
3856 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3857 | return CMD_WARNING; | |
3858 | } | |
3859 | ||
3860 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
3861 | (struct prefix *)&prd); | |
3862 | if (prn->info == NULL) | |
64e580a7 | 3863 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 3864 | else |
3865 | bgp_unlock_node (prn); | |
3866 | table = prn->info; | |
3867 | ||
3868 | rn = bgp_node_get (table, &p); | |
3869 | ||
3870 | if (rn->info) | |
3871 | { | |
3872 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); | |
3873 | bgp_unlock_node (rn); | |
3874 | } | |
3875 | else | |
3876 | { | |
3877 | /* New configuration. */ | |
3878 | bgp_static = bgp_static_new (); | |
3879 | bgp_static->valid = 1; | |
3880 | memcpy (bgp_static->tag, tag, 3); | |
3881 | rn->info = bgp_static; | |
3882 | ||
3883 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
3884 | } | |
3885 | ||
3886 | return CMD_SUCCESS; | |
3887 | } | |
3888 | ||
3889 | /* Configure static BGP network. */ | |
3890 | int | |
fd79ac91 | 3891 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
3892 | const char *rd_str, const char *tag_str) | |
718e3744 | 3893 | { |
3894 | int ret; | |
3895 | struct bgp *bgp; | |
3896 | struct prefix p; | |
3897 | struct prefix_rd prd; | |
3898 | struct bgp_node *prn; | |
3899 | struct bgp_node *rn; | |
3900 | struct bgp_table *table; | |
3901 | struct bgp_static *bgp_static; | |
3902 | u_char tag[3]; | |
3903 | ||
3904 | bgp = vty->index; | |
3905 | ||
3906 | /* Convert IP prefix string to struct prefix. */ | |
3907 | ret = str2prefix (ip_str, &p); | |
3908 | if (! ret) | |
3909 | { | |
3910 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3911 | return CMD_WARNING; | |
3912 | } | |
3913 | apply_mask (&p); | |
3914 | ||
3915 | ret = str2prefix_rd (rd_str, &prd); | |
3916 | if (! ret) | |
3917 | { | |
3918 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3919 | return CMD_WARNING; | |
3920 | } | |
3921 | ||
3922 | ret = str2tag (tag_str, tag); | |
3923 | if (! ret) | |
3924 | { | |
3925 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3926 | return CMD_WARNING; | |
3927 | } | |
3928 | ||
3929 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
3930 | (struct prefix *)&prd); | |
3931 | if (prn->info == NULL) | |
64e580a7 | 3932 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 3933 | else |
3934 | bgp_unlock_node (prn); | |
3935 | table = prn->info; | |
3936 | ||
3937 | rn = bgp_node_lookup (table, &p); | |
3938 | ||
3939 | if (rn) | |
3940 | { | |
3941 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
3942 | ||
3943 | bgp_static = rn->info; | |
3944 | bgp_static_free (bgp_static); | |
3945 | rn->info = NULL; | |
3946 | bgp_unlock_node (rn); | |
3947 | bgp_unlock_node (rn); | |
3948 | } | |
3949 | else | |
3950 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); | |
3951 | ||
3952 | return CMD_SUCCESS; | |
3953 | } | |
6b0655a2 | 3954 | |
73ac8160 DS |
3955 | static int |
3956 | bgp_table_map_set (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
3957 | const char *rmap_name) | |
3958 | { | |
3959 | struct bgp_rmap *rmap; | |
3960 | ||
3961 | rmap = &bgp->table_map[afi][safi]; | |
3962 | if (rmap_name) | |
3963 | { | |
3964 | if (rmap->name) | |
6e919709 DS |
3965 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); |
3966 | rmap->name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_name); | |
73ac8160 DS |
3967 | rmap->map = route_map_lookup_by_name (rmap_name); |
3968 | } | |
3969 | else | |
3970 | { | |
3971 | if (rmap->name) | |
6e919709 | 3972 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); |
73ac8160 DS |
3973 | rmap->name = NULL; |
3974 | rmap->map = NULL; | |
3975 | } | |
3976 | ||
3977 | bgp_zebra_announce_table(bgp, afi, safi); | |
3978 | ||
3979 | return CMD_SUCCESS; | |
3980 | } | |
3981 | ||
3982 | static int | |
3983 | bgp_table_map_unset (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
3984 | const char *rmap_name) | |
3985 | { | |
3986 | struct bgp_rmap *rmap; | |
3987 | ||
3988 | rmap = &bgp->table_map[afi][safi]; | |
3989 | if (rmap->name) | |
6e919709 | 3990 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); |
73ac8160 DS |
3991 | rmap->name = NULL; |
3992 | rmap->map = NULL; | |
3993 | ||
3994 | bgp_zebra_announce_table(bgp, afi, safi); | |
3995 | ||
3996 | return CMD_SUCCESS; | |
3997 | } | |
3998 | ||
3999 | int | |
4000 | bgp_config_write_table_map (struct vty *vty, struct bgp *bgp, afi_t afi, | |
4001 | safi_t safi, int *write) | |
4002 | { | |
4003 | if (bgp->table_map[afi][safi].name) | |
4004 | { | |
4005 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 4006 | vty_out (vty, " table-map %s%s", |
73ac8160 DS |
4007 | bgp->table_map[afi][safi].name, VTY_NEWLINE); |
4008 | } | |
4009 | ||
4010 | return 0; | |
4011 | } | |
4012 | ||
4013 | ||
4014 | DEFUN (bgp_table_map, | |
4015 | bgp_table_map_cmd, | |
4016 | "table-map WORD", | |
4017 | "BGP table to RIB route download filter\n" | |
4018 | "Name of the route map\n") | |
4019 | { | |
4020 | return bgp_table_map_set (vty, vty->index, | |
4021 | bgp_node_afi (vty), bgp_node_safi (vty), argv[0]); | |
4022 | } | |
4023 | DEFUN (no_bgp_table_map, | |
4024 | no_bgp_table_map_cmd, | |
4025 | "no table-map WORD", | |
4026 | "BGP table to RIB route download filter\n" | |
4027 | "Name of the route map\n") | |
4028 | { | |
4029 | return bgp_table_map_unset (vty, vty->index, | |
4030 | bgp_node_afi (vty), bgp_node_safi (vty), argv[0]); | |
4031 | } | |
4032 | ||
718e3744 | 4033 | DEFUN (bgp_network, |
4034 | bgp_network_cmd, | |
4035 | "network A.B.C.D/M", | |
4036 | "Specify a network to announce via BGP\n" | |
4037 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4038 | { | |
4039 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 4040 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4041 | } |
4042 | ||
4043 | DEFUN (bgp_network_route_map, | |
4044 | bgp_network_route_map_cmd, | |
4045 | "network A.B.C.D/M route-map WORD", | |
4046 | "Specify a network to announce via BGP\n" | |
4047 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4048 | "Route-map to modify the attributes\n" | |
4049 | "Name of the route map\n") | |
4050 | { | |
4051 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 4052 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4053 | } |
4054 | ||
4055 | DEFUN (bgp_network_backdoor, | |
4056 | bgp_network_backdoor_cmd, | |
4057 | "network A.B.C.D/M backdoor", | |
4058 | "Specify a network to announce via BGP\n" | |
4059 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4060 | "Specify a BGP backdoor route\n") | |
4061 | { | |
41367172 | 4062 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4063 | NULL, 1); |
718e3744 | 4064 | } |
4065 | ||
4066 | DEFUN (bgp_network_mask, | |
4067 | bgp_network_mask_cmd, | |
4068 | "network A.B.C.D mask A.B.C.D", | |
4069 | "Specify a network to announce via BGP\n" | |
4070 | "Network number\n" | |
4071 | "Network mask\n" | |
4072 | "Network mask\n") | |
4073 | { | |
4074 | int ret; | |
4075 | char prefix_str[BUFSIZ]; | |
41367172 | 4076 | |
718e3744 | 4077 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4078 | if (! ret) | |
4079 | { | |
4080 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4081 | return CMD_WARNING; | |
4082 | } | |
4083 | ||
4084 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4085 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4086 | } |
4087 | ||
4088 | DEFUN (bgp_network_mask_route_map, | |
4089 | bgp_network_mask_route_map_cmd, | |
4090 | "network A.B.C.D mask A.B.C.D route-map WORD", | |
4091 | "Specify a network to announce via BGP\n" | |
4092 | "Network number\n" | |
4093 | "Network mask\n" | |
4094 | "Network mask\n" | |
4095 | "Route-map to modify the attributes\n" | |
4096 | "Name of the route map\n") | |
4097 | { | |
4098 | int ret; | |
4099 | char prefix_str[BUFSIZ]; | |
41367172 | 4100 | |
718e3744 | 4101 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4102 | if (! ret) | |
4103 | { | |
4104 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4105 | return CMD_WARNING; | |
4106 | } | |
4107 | ||
4108 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4109 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
718e3744 | 4110 | } |
4111 | ||
4112 | DEFUN (bgp_network_mask_backdoor, | |
4113 | bgp_network_mask_backdoor_cmd, | |
4114 | "network A.B.C.D mask A.B.C.D backdoor", | |
4115 | "Specify a network to announce via BGP\n" | |
4116 | "Network number\n" | |
4117 | "Network mask\n" | |
4118 | "Network mask\n" | |
4119 | "Specify a BGP backdoor route\n") | |
4120 | { | |
4121 | int ret; | |
4122 | char prefix_str[BUFSIZ]; | |
41367172 | 4123 | |
718e3744 | 4124 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4125 | if (! ret) | |
4126 | { | |
4127 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4128 | return CMD_WARNING; | |
4129 | } | |
4130 | ||
41367172 | 4131 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4132 | NULL, 1); |
718e3744 | 4133 | } |
4134 | ||
4135 | DEFUN (bgp_network_mask_natural, | |
4136 | bgp_network_mask_natural_cmd, | |
4137 | "network A.B.C.D", | |
4138 | "Specify a network to announce via BGP\n" | |
4139 | "Network number\n") | |
4140 | { | |
4141 | int ret; | |
4142 | char prefix_str[BUFSIZ]; | |
4143 | ||
4144 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4145 | if (! ret) | |
4146 | { | |
4147 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4148 | return CMD_WARNING; | |
4149 | } | |
4150 | ||
4151 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4152 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4153 | } |
4154 | ||
4155 | DEFUN (bgp_network_mask_natural_route_map, | |
4156 | bgp_network_mask_natural_route_map_cmd, | |
4157 | "network A.B.C.D route-map WORD", | |
4158 | "Specify a network to announce via BGP\n" | |
4159 | "Network number\n" | |
4160 | "Route-map to modify the attributes\n" | |
4161 | "Name of the route map\n") | |
4162 | { | |
4163 | int ret; | |
4164 | char prefix_str[BUFSIZ]; | |
4165 | ||
4166 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4167 | if (! ret) | |
4168 | { | |
4169 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4170 | return CMD_WARNING; | |
4171 | } | |
4172 | ||
4173 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4174 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4175 | } |
4176 | ||
4177 | DEFUN (bgp_network_mask_natural_backdoor, | |
4178 | bgp_network_mask_natural_backdoor_cmd, | |
4179 | "network A.B.C.D backdoor", | |
4180 | "Specify a network to announce via BGP\n" | |
4181 | "Network number\n" | |
4182 | "Specify a BGP backdoor route\n") | |
4183 | { | |
4184 | int ret; | |
4185 | char prefix_str[BUFSIZ]; | |
4186 | ||
4187 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4188 | if (! ret) | |
4189 | { | |
4190 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4191 | return CMD_WARNING; | |
4192 | } | |
4193 | ||
41367172 | 4194 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4195 | NULL, 1); |
718e3744 | 4196 | } |
4197 | ||
4198 | DEFUN (no_bgp_network, | |
4199 | no_bgp_network_cmd, | |
4200 | "no network A.B.C.D/M", | |
4201 | NO_STR | |
4202 | "Specify a network to announce via BGP\n" | |
4203 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4204 | { | |
4205 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, | |
4206 | bgp_node_safi (vty)); | |
4207 | } | |
4208 | ||
4209 | ALIAS (no_bgp_network, | |
4210 | no_bgp_network_route_map_cmd, | |
4211 | "no network A.B.C.D/M route-map WORD", | |
4212 | NO_STR | |
4213 | "Specify a network to announce via BGP\n" | |
4214 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4215 | "Route-map to modify the attributes\n" | |
4216 | "Name of the route map\n") | |
4217 | ||
4218 | ALIAS (no_bgp_network, | |
4219 | no_bgp_network_backdoor_cmd, | |
4220 | "no network A.B.C.D/M backdoor", | |
4221 | NO_STR | |
4222 | "Specify a network to announce via BGP\n" | |
4223 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4224 | "Specify a BGP backdoor route\n") | |
4225 | ||
4226 | DEFUN (no_bgp_network_mask, | |
4227 | no_bgp_network_mask_cmd, | |
4228 | "no network A.B.C.D mask A.B.C.D", | |
4229 | NO_STR | |
4230 | "Specify a network to announce via BGP\n" | |
4231 | "Network number\n" | |
4232 | "Network mask\n" | |
4233 | "Network mask\n") | |
4234 | { | |
4235 | int ret; | |
4236 | char prefix_str[BUFSIZ]; | |
4237 | ||
4238 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4239 | if (! ret) | |
4240 | { | |
4241 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4242 | return CMD_WARNING; | |
4243 | } | |
4244 | ||
4245 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4246 | bgp_node_safi (vty)); | |
4247 | } | |
4248 | ||
4249 | ALIAS (no_bgp_network_mask, | |
4250 | no_bgp_network_mask_route_map_cmd, | |
4251 | "no network A.B.C.D mask A.B.C.D route-map WORD", | |
4252 | NO_STR | |
4253 | "Specify a network to announce via BGP\n" | |
4254 | "Network number\n" | |
4255 | "Network mask\n" | |
4256 | "Network mask\n" | |
4257 | "Route-map to modify the attributes\n" | |
4258 | "Name of the route map\n") | |
4259 | ||
4260 | ALIAS (no_bgp_network_mask, | |
4261 | no_bgp_network_mask_backdoor_cmd, | |
4262 | "no network A.B.C.D mask A.B.C.D backdoor", | |
4263 | NO_STR | |
4264 | "Specify a network to announce via BGP\n" | |
4265 | "Network number\n" | |
4266 | "Network mask\n" | |
4267 | "Network mask\n" | |
4268 | "Specify a BGP backdoor route\n") | |
4269 | ||
4270 | DEFUN (no_bgp_network_mask_natural, | |
4271 | no_bgp_network_mask_natural_cmd, | |
4272 | "no network A.B.C.D", | |
4273 | NO_STR | |
4274 | "Specify a network to announce via BGP\n" | |
4275 | "Network number\n") | |
4276 | { | |
4277 | int ret; | |
4278 | char prefix_str[BUFSIZ]; | |
4279 | ||
4280 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4281 | if (! ret) | |
4282 | { | |
4283 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4284 | return CMD_WARNING; | |
4285 | } | |
4286 | ||
4287 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4288 | bgp_node_safi (vty)); | |
4289 | } | |
4290 | ||
4291 | ALIAS (no_bgp_network_mask_natural, | |
4292 | no_bgp_network_mask_natural_route_map_cmd, | |
4293 | "no network A.B.C.D route-map WORD", | |
4294 | NO_STR | |
4295 | "Specify a network to announce via BGP\n" | |
4296 | "Network number\n" | |
4297 | "Route-map to modify the attributes\n" | |
4298 | "Name of the route map\n") | |
4299 | ||
4300 | ALIAS (no_bgp_network_mask_natural, | |
4301 | no_bgp_network_mask_natural_backdoor_cmd, | |
4302 | "no network A.B.C.D backdoor", | |
4303 | NO_STR | |
4304 | "Specify a network to announce via BGP\n" | |
4305 | "Network number\n" | |
4306 | "Specify a BGP backdoor route\n") | |
4307 | ||
4308 | #ifdef HAVE_IPV6 | |
4309 | DEFUN (ipv6_bgp_network, | |
4310 | ipv6_bgp_network_cmd, | |
4311 | "network X:X::X:X/M", | |
4312 | "Specify a network to announce via BGP\n" | |
4313 | "IPv6 prefix <network>/<length>\n") | |
4314 | { | |
73bfe0bd | 4315 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty), |
c8f3fe30 | 4316 | NULL, 0); |
718e3744 | 4317 | } |
4318 | ||
4319 | DEFUN (ipv6_bgp_network_route_map, | |
4320 | ipv6_bgp_network_route_map_cmd, | |
4321 | "network X:X::X:X/M route-map WORD", | |
4322 | "Specify a network to announce via BGP\n" | |
4323 | "IPv6 prefix <network>/<length>\n" | |
4324 | "Route-map to modify the attributes\n" | |
4325 | "Name of the route map\n") | |
4326 | { | |
4327 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, | |
c8f3fe30 | 4328 | bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4329 | } |
4330 | ||
4331 | DEFUN (no_ipv6_bgp_network, | |
4332 | no_ipv6_bgp_network_cmd, | |
4333 | "no network X:X::X:X/M", | |
4334 | NO_STR | |
4335 | "Specify a network to announce via BGP\n" | |
4336 | "IPv6 prefix <network>/<length>\n") | |
4337 | { | |
73bfe0bd | 4338 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty)); |
718e3744 | 4339 | } |
4340 | ||
4341 | ALIAS (no_ipv6_bgp_network, | |
4342 | no_ipv6_bgp_network_route_map_cmd, | |
4343 | "no network X:X::X:X/M route-map WORD", | |
4344 | NO_STR | |
4345 | "Specify a network to announce via BGP\n" | |
4346 | "IPv6 prefix <network>/<length>\n" | |
4347 | "Route-map to modify the attributes\n" | |
4348 | "Name of the route map\n") | |
4349 | ||
4350 | ALIAS (ipv6_bgp_network, | |
4351 | old_ipv6_bgp_network_cmd, | |
4352 | "ipv6 bgp network X:X::X:X/M", | |
4353 | IPV6_STR | |
4354 | BGP_STR | |
4355 | "Specify a network to announce via BGP\n" | |
4356 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4357 | ||
4358 | ALIAS (no_ipv6_bgp_network, | |
4359 | old_no_ipv6_bgp_network_cmd, | |
4360 | "no ipv6 bgp network X:X::X:X/M", | |
4361 | NO_STR | |
4362 | IPV6_STR | |
4363 | BGP_STR | |
4364 | "Specify a network to announce via BGP\n" | |
4365 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4366 | #endif /* HAVE_IPV6 */ | |
c8f3fe30 | 4367 | |
718e3744 | 4368 | /* Aggreagete address: |
4369 | ||
4370 | advertise-map Set condition to advertise attribute | |
4371 | as-set Generate AS set path information | |
4372 | attribute-map Set attributes of aggregate | |
4373 | route-map Set parameters of aggregate | |
4374 | summary-only Filter more specific routes from updates | |
4375 | suppress-map Conditionally filter more specific routes from updates | |
4376 | <cr> | |
4377 | */ | |
4378 | struct bgp_aggregate | |
4379 | { | |
4380 | /* Summary-only flag. */ | |
4381 | u_char summary_only; | |
4382 | ||
4383 | /* AS set generation. */ | |
4384 | u_char as_set; | |
4385 | ||
4386 | /* Route-map for aggregated route. */ | |
4387 | struct route_map *map; | |
4388 | ||
4389 | /* Suppress-count. */ | |
4390 | unsigned long count; | |
4391 | ||
4392 | /* SAFI configuration. */ | |
4393 | safi_t safi; | |
4394 | }; | |
4395 | ||
94f2b392 | 4396 | static struct bgp_aggregate * |
66e5cd87 | 4397 | bgp_aggregate_new (void) |
718e3744 | 4398 | { |
393deb9b | 4399 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
718e3744 | 4400 | } |
4401 | ||
94f2b392 | 4402 | static void |
718e3744 | 4403 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
4404 | { | |
4405 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); | |
4406 | } | |
4407 | ||
b5d58c32 | 4408 | /* Update an aggregate as routes are added/removed from the BGP table */ |
94f2b392 | 4409 | static void |
718e3744 | 4410 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
4411 | afi_t afi, safi_t safi, struct bgp_info *del, | |
4412 | struct bgp_aggregate *aggregate) | |
4413 | { | |
4414 | struct bgp_table *table; | |
4415 | struct bgp_node *top; | |
4416 | struct bgp_node *rn; | |
4417 | u_char origin; | |
4418 | struct aspath *aspath = NULL; | |
4419 | struct aspath *asmerge = NULL; | |
4420 | struct community *community = NULL; | |
4421 | struct community *commerge = NULL; | |
ffd0c037 | 4422 | #if defined(AGGREGATE_NEXTHOP_CHECK) |
718e3744 | 4423 | struct in_addr nexthop; |
4424 | u_int32_t med = 0; | |
ffd0c037 | 4425 | #endif |
718e3744 | 4426 | struct bgp_info *ri; |
4427 | struct bgp_info *new; | |
4428 | int first = 1; | |
4429 | unsigned long match = 0; | |
42f7e184 | 4430 | u_char atomic_aggregate = 0; |
718e3744 | 4431 | |
4432 | /* Record adding route's nexthop and med. */ | |
ffd0c037 DS |
4433 | if (rinew) |
4434 | { | |
4435 | #if defined(AGGREGATE_NEXTHOP_CHECK) | |
4436 | nexthop = rinew->attr->nexthop; | |
4437 | med = rinew->attr->med; | |
4438 | #endif | |
4439 | } | |
718e3744 | 4440 | |
4441 | /* ORIGIN attribute: If at least one route among routes that are | |
4442 | aggregated has ORIGIN with the value INCOMPLETE, then the | |
4443 | aggregated route must have the ORIGIN attribute with the value | |
4444 | INCOMPLETE. Otherwise, if at least one route among routes that | |
4445 | are aggregated has ORIGIN with the value EGP, then the aggregated | |
4446 | route must have the origin attribute with the value EGP. In all | |
4447 | other case the value of the ORIGIN attribute of the aggregated | |
4448 | route is INTERNAL. */ | |
4449 | origin = BGP_ORIGIN_IGP; | |
4450 | ||
4451 | table = bgp->rib[afi][safi]; | |
4452 | ||
4453 | top = bgp_node_get (table, p); | |
4454 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4455 | if (rn->p.prefixlen > p->prefixlen) | |
4456 | { | |
4457 | match = 0; | |
4458 | ||
4459 | for (ri = rn->info; ri; ri = ri->next) | |
4460 | { | |
4461 | if (BGP_INFO_HOLDDOWN (ri)) | |
4462 | continue; | |
4463 | ||
4464 | if (del && ri == del) | |
4465 | continue; | |
4466 | ||
4467 | if (! rinew && first) | |
4468 | { | |
ffd0c037 | 4469 | #if defined(AGGREGATE_NEXTHOP_CHECK) |
718e3744 | 4470 | nexthop = ri->attr->nexthop; |
4471 | med = ri->attr->med; | |
ffd0c037 | 4472 | #endif |
718e3744 | 4473 | first = 0; |
4474 | } | |
4475 | ||
4476 | #ifdef AGGREGATE_NEXTHOP_CHECK | |
4477 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) | |
4478 | || ri->attr->med != med) | |
4479 | { | |
4480 | if (aspath) | |
4481 | aspath_free (aspath); | |
4482 | if (community) | |
4483 | community_free (community); | |
4484 | bgp_unlock_node (rn); | |
4485 | bgp_unlock_node (top); | |
4486 | return; | |
4487 | } | |
4488 | #endif /* AGGREGATE_NEXTHOP_CHECK */ | |
4489 | ||
42f7e184 DS |
4490 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
4491 | atomic_aggregate = 1; | |
4492 | ||
718e3744 | 4493 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
4494 | { | |
4495 | if (aggregate->summary_only) | |
4496 | { | |
fb982c25 | 4497 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4498 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4499 | match++; |
4500 | } | |
4501 | ||
4502 | aggregate->count++; | |
4503 | ||
b5d58c32 DS |
4504 | if (origin < ri->attr->origin) |
4505 | origin = ri->attr->origin; | |
4506 | ||
718e3744 | 4507 | if (aggregate->as_set) |
4508 | { | |
718e3744 | 4509 | if (aspath) |
4510 | { | |
4511 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4512 | aspath_free (aspath); | |
4513 | aspath = asmerge; | |
4514 | } | |
4515 | else | |
4516 | aspath = aspath_dup (ri->attr->aspath); | |
4517 | ||
4518 | if (ri->attr->community) | |
4519 | { | |
4520 | if (community) | |
4521 | { | |
4522 | commerge = community_merge (community, | |
4523 | ri->attr->community); | |
4524 | community = community_uniq_sort (commerge); | |
4525 | community_free (commerge); | |
4526 | } | |
4527 | else | |
4528 | community = community_dup (ri->attr->community); | |
4529 | } | |
4530 | } | |
4531 | } | |
4532 | } | |
4533 | if (match) | |
4534 | bgp_process (bgp, rn, afi, safi); | |
4535 | } | |
4536 | bgp_unlock_node (top); | |
4537 | ||
4538 | if (rinew) | |
4539 | { | |
4540 | aggregate->count++; | |
4541 | ||
4542 | if (aggregate->summary_only) | |
fb982c25 | 4543 | (bgp_info_extra_get (rinew))->suppress++; |
718e3744 | 4544 | |
b5d58c32 DS |
4545 | if (origin < rinew->attr->origin) |
4546 | origin = rinew->attr->origin; | |
4547 | ||
718e3744 | 4548 | if (aggregate->as_set) |
4549 | { | |
718e3744 | 4550 | if (aspath) |
4551 | { | |
4552 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); | |
4553 | aspath_free (aspath); | |
4554 | aspath = asmerge; | |
4555 | } | |
4556 | else | |
4557 | aspath = aspath_dup (rinew->attr->aspath); | |
4558 | ||
4559 | if (rinew->attr->community) | |
4560 | { | |
4561 | if (community) | |
4562 | { | |
4563 | commerge = community_merge (community, | |
4564 | rinew->attr->community); | |
4565 | community = community_uniq_sort (commerge); | |
4566 | community_free (commerge); | |
4567 | } | |
4568 | else | |
4569 | community = community_dup (rinew->attr->community); | |
4570 | } | |
4571 | } | |
4572 | } | |
4573 | ||
4574 | if (aggregate->count > 0) | |
4575 | { | |
4576 | rn = bgp_node_get (table, p); | |
7c8ff89e | 4577 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self, |
fb018d25 | 4578 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
42f7e184 DS |
4579 | aggregate->as_set, |
4580 | atomic_aggregate), rn); | |
718e3744 | 4581 | SET_FLAG (new->flags, BGP_INFO_VALID); |
718e3744 | 4582 | |
4583 | bgp_info_add (rn, new); | |
200df115 | 4584 | bgp_unlock_node (rn); |
718e3744 | 4585 | bgp_process (bgp, rn, afi, safi); |
4586 | } | |
4587 | else | |
4588 | { | |
4589 | if (aspath) | |
4590 | aspath_free (aspath); | |
4591 | if (community) | |
4592 | community_free (community); | |
4593 | } | |
4594 | } | |
4595 | ||
4596 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, | |
4597 | struct bgp_aggregate *); | |
4598 | ||
4599 | void | |
4600 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, | |
4601 | struct bgp_info *ri, afi_t afi, safi_t safi) | |
4602 | { | |
4603 | struct bgp_node *child; | |
4604 | struct bgp_node *rn; | |
4605 | struct bgp_aggregate *aggregate; | |
f018db83 | 4606 | struct bgp_table *table; |
718e3744 | 4607 | |
4608 | /* MPLS-VPN aggregation is not yet supported. */ | |
4609 | if (safi == SAFI_MPLS_VPN) | |
4610 | return; | |
4611 | ||
f018db83 JBD |
4612 | table = bgp->aggregate[afi][safi]; |
4613 | ||
4614 | /* No aggregates configured. */ | |
67174041 | 4615 | if (bgp_table_top_nolock (table) == NULL) |
f018db83 JBD |
4616 | return; |
4617 | ||
718e3744 | 4618 | if (p->prefixlen == 0) |
4619 | return; | |
4620 | ||
4621 | if (BGP_INFO_HOLDDOWN (ri)) | |
4622 | return; | |
4623 | ||
bb782fb5 | 4624 | child = bgp_node_get (table, p); |
718e3744 | 4625 | |
4626 | /* Aggregate address configuration check. */ | |
67174041 | 4627 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
718e3744 | 4628 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
4629 | { | |
4630 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4631 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
718e3744 | 4632 | } |
4633 | bgp_unlock_node (child); | |
4634 | } | |
4635 | ||
4636 | void | |
4637 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, | |
4638 | struct bgp_info *del, afi_t afi, safi_t safi) | |
4639 | { | |
4640 | struct bgp_node *child; | |
4641 | struct bgp_node *rn; | |
4642 | struct bgp_aggregate *aggregate; | |
f018db83 | 4643 | struct bgp_table *table; |
718e3744 | 4644 | |
4645 | /* MPLS-VPN aggregation is not yet supported. */ | |
4646 | if (safi == SAFI_MPLS_VPN) | |
4647 | return; | |
4648 | ||
f018db83 JBD |
4649 | table = bgp->aggregate[afi][safi]; |
4650 | ||
4651 | /* No aggregates configured. */ | |
67174041 | 4652 | if (bgp_table_top_nolock (table) == NULL) |
f018db83 JBD |
4653 | return; |
4654 | ||
718e3744 | 4655 | if (p->prefixlen == 0) |
4656 | return; | |
4657 | ||
bb782fb5 | 4658 | child = bgp_node_get (table, p); |
718e3744 | 4659 | |
4660 | /* Aggregate address configuration check. */ | |
67174041 | 4661 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
718e3744 | 4662 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
4663 | { | |
4664 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4665 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
718e3744 | 4666 | } |
4667 | bgp_unlock_node (child); | |
4668 | } | |
4669 | ||
b5d58c32 | 4670 | /* Called via bgp_aggregate_set when the user configures aggregate-address */ |
94f2b392 | 4671 | static void |
718e3744 | 4672 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
4673 | struct bgp_aggregate *aggregate) | |
4674 | { | |
4675 | struct bgp_table *table; | |
4676 | struct bgp_node *top; | |
4677 | struct bgp_node *rn; | |
4678 | struct bgp_info *new; | |
4679 | struct bgp_info *ri; | |
4680 | unsigned long match; | |
4681 | u_char origin = BGP_ORIGIN_IGP; | |
4682 | struct aspath *aspath = NULL; | |
4683 | struct aspath *asmerge = NULL; | |
4684 | struct community *community = NULL; | |
4685 | struct community *commerge = NULL; | |
42f7e184 | 4686 | u_char atomic_aggregate = 0; |
718e3744 | 4687 | |
4688 | table = bgp->rib[afi][safi]; | |
4689 | ||
4690 | /* Sanity check. */ | |
4691 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4692 | return; | |
4693 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4694 | return; | |
4695 | ||
4696 | /* If routes exists below this node, generate aggregate routes. */ | |
4697 | top = bgp_node_get (table, p); | |
4698 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4699 | if (rn->p.prefixlen > p->prefixlen) | |
4700 | { | |
4701 | match = 0; | |
4702 | ||
4703 | for (ri = rn->info; ri; ri = ri->next) | |
4704 | { | |
4705 | if (BGP_INFO_HOLDDOWN (ri)) | |
4706 | continue; | |
4707 | ||
42f7e184 DS |
4708 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
4709 | atomic_aggregate = 1; | |
4710 | ||
718e3744 | 4711 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
4712 | { | |
4713 | /* summary-only aggregate route suppress aggregated | |
4714 | route announcement. */ | |
4715 | if (aggregate->summary_only) | |
4716 | { | |
fb982c25 | 4717 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4718 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4719 | match++; |
4720 | } | |
b5d58c32 DS |
4721 | |
4722 | /* If at least one route among routes that are aggregated has | |
4723 | * ORIGIN with the value INCOMPLETE, then the aggregated route | |
4724 | * MUST have the ORIGIN attribute with the value INCOMPLETE. | |
4725 | * Otherwise, if at least one route among routes that are | |
4726 | * aggregated has ORIGIN with the value EGP, then the aggregated | |
4727 | * route MUST have the ORIGIN attribute with the value EGP. | |
4728 | */ | |
4729 | if (origin < ri->attr->origin) | |
4730 | origin = ri->attr->origin; | |
4731 | ||
718e3744 | 4732 | /* as-set aggregate route generate origin, as path, |
4733 | community aggregation. */ | |
4734 | if (aggregate->as_set) | |
4735 | { | |
718e3744 | 4736 | if (aspath) |
4737 | { | |
4738 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4739 | aspath_free (aspath); | |
4740 | aspath = asmerge; | |
4741 | } | |
4742 | else | |
4743 | aspath = aspath_dup (ri->attr->aspath); | |
4744 | ||
4745 | if (ri->attr->community) | |
4746 | { | |
4747 | if (community) | |
4748 | { | |
4749 | commerge = community_merge (community, | |
4750 | ri->attr->community); | |
4751 | community = community_uniq_sort (commerge); | |
4752 | community_free (commerge); | |
4753 | } | |
4754 | else | |
4755 | community = community_dup (ri->attr->community); | |
4756 | } | |
4757 | } | |
4758 | aggregate->count++; | |
4759 | } | |
4760 | } | |
4761 | ||
4762 | /* If this node is suppressed, process the change. */ | |
4763 | if (match) | |
4764 | bgp_process (bgp, rn, afi, safi); | |
4765 | } | |
4766 | bgp_unlock_node (top); | |
4767 | ||
4768 | /* Add aggregate route to BGP table. */ | |
4769 | if (aggregate->count) | |
4770 | { | |
4771 | rn = bgp_node_get (table, p); | |
7c8ff89e | 4772 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self, |
fb018d25 | 4773 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
42f7e184 DS |
4774 | aggregate->as_set, |
4775 | atomic_aggregate), rn); | |
718e3744 | 4776 | SET_FLAG (new->flags, BGP_INFO_VALID); |
718e3744 | 4777 | |
4778 | bgp_info_add (rn, new); | |
200df115 | 4779 | bgp_unlock_node (rn); |
4780 | ||
718e3744 | 4781 | /* Process change. */ |
4782 | bgp_process (bgp, rn, afi, safi); | |
4783 | } | |
610f23cf DV |
4784 | else |
4785 | { | |
4786 | if (aspath) | |
4787 | aspath_free (aspath); | |
4788 | if (community) | |
4789 | community_free (community); | |
4790 | } | |
718e3744 | 4791 | } |
4792 | ||
4793 | void | |
4794 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, | |
4795 | safi_t safi, struct bgp_aggregate *aggregate) | |
4796 | { | |
4797 | struct bgp_table *table; | |
4798 | struct bgp_node *top; | |
4799 | struct bgp_node *rn; | |
4800 | struct bgp_info *ri; | |
4801 | unsigned long match; | |
4802 | ||
4803 | table = bgp->rib[afi][safi]; | |
4804 | ||
4805 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4806 | return; | |
4807 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4808 | return; | |
4809 | ||
4810 | /* If routes exists below this node, generate aggregate routes. */ | |
4811 | top = bgp_node_get (table, p); | |
4812 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4813 | if (rn->p.prefixlen > p->prefixlen) | |
4814 | { | |
4815 | match = 0; | |
4816 | ||
4817 | for (ri = rn->info; ri; ri = ri->next) | |
4818 | { | |
4819 | if (BGP_INFO_HOLDDOWN (ri)) | |
4820 | continue; | |
4821 | ||
4822 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4823 | { | |
fb982c25 | 4824 | if (aggregate->summary_only && ri->extra) |
718e3744 | 4825 | { |
fb982c25 | 4826 | ri->extra->suppress--; |
718e3744 | 4827 | |
fb982c25 | 4828 | if (ri->extra->suppress == 0) |
718e3744 | 4829 | { |
1a392d46 | 4830 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4831 | match++; |
4832 | } | |
4833 | } | |
4834 | aggregate->count--; | |
4835 | } | |
4836 | } | |
4837 | ||
fb982c25 | 4838 | /* If this node was suppressed, process the change. */ |
718e3744 | 4839 | if (match) |
4840 | bgp_process (bgp, rn, afi, safi); | |
4841 | } | |
4842 | bgp_unlock_node (top); | |
4843 | ||
4844 | /* Delete aggregate route from BGP table. */ | |
4845 | rn = bgp_node_get (table, p); | |
4846 | ||
4847 | for (ri = rn->info; ri; ri = ri->next) | |
4848 | if (ri->peer == bgp->peer_self | |
4849 | && ri->type == ZEBRA_ROUTE_BGP | |
4850 | && ri->sub_type == BGP_ROUTE_AGGREGATE) | |
4851 | break; | |
4852 | ||
4853 | /* Withdraw static BGP route from routing table. */ | |
4854 | if (ri) | |
4855 | { | |
718e3744 | 4856 | bgp_info_delete (rn, ri); |
1a392d46 | 4857 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 4858 | } |
4859 | ||
4860 | /* Unlock bgp_node_lookup. */ | |
4861 | bgp_unlock_node (rn); | |
4862 | } | |
4863 | ||
4864 | /* Aggregate route attribute. */ | |
4865 | #define AGGREGATE_SUMMARY_ONLY 1 | |
4866 | #define AGGREGATE_AS_SET 1 | |
4867 | ||
94f2b392 | 4868 | static int |
f6269b4f RB |
4869 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
4870 | afi_t afi, safi_t safi) | |
718e3744 | 4871 | { |
4872 | int ret; | |
4873 | struct prefix p; | |
4874 | struct bgp_node *rn; | |
4875 | struct bgp *bgp; | |
4876 | struct bgp_aggregate *aggregate; | |
4877 | ||
4878 | /* Convert string to prefix structure. */ | |
4879 | ret = str2prefix (prefix_str, &p); | |
4880 | if (!ret) | |
4881 | { | |
4882 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
4883 | return CMD_WARNING; | |
4884 | } | |
4885 | apply_mask (&p); | |
4886 | ||
4887 | /* Get BGP structure. */ | |
4888 | bgp = vty->index; | |
4889 | ||
4890 | /* Old configuration check. */ | |
f6269b4f RB |
4891 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
4892 | if (! rn) | |
718e3744 | 4893 | { |
f6269b4f RB |
4894 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
4895 | VTY_NEWLINE); | |
718e3744 | 4896 | return CMD_WARNING; |
4897 | } | |
4898 | ||
f6269b4f RB |
4899 | aggregate = rn->info; |
4900 | if (aggregate->safi & SAFI_UNICAST) | |
4901 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
4902 | if (aggregate->safi & SAFI_MULTICAST) | |
4903 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 4904 | |
f6269b4f RB |
4905 | /* Unlock aggregate address configuration. */ |
4906 | rn->info = NULL; | |
4907 | bgp_aggregate_free (aggregate); | |
4908 | bgp_unlock_node (rn); | |
4909 | bgp_unlock_node (rn); | |
718e3744 | 4910 | |
4911 | return CMD_SUCCESS; | |
4912 | } | |
4913 | ||
94f2b392 | 4914 | static int |
f6269b4f RB |
4915 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
4916 | afi_t afi, safi_t safi, | |
4917 | u_char summary_only, u_char as_set) | |
718e3744 | 4918 | { |
4919 | int ret; | |
4920 | struct prefix p; | |
4921 | struct bgp_node *rn; | |
4922 | struct bgp *bgp; | |
4923 | struct bgp_aggregate *aggregate; | |
4924 | ||
4925 | /* Convert string to prefix structure. */ | |
4926 | ret = str2prefix (prefix_str, &p); | |
4927 | if (!ret) | |
4928 | { | |
4929 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
4930 | return CMD_WARNING; | |
4931 | } | |
4932 | apply_mask (&p); | |
4933 | ||
4934 | /* Get BGP structure. */ | |
4935 | bgp = vty->index; | |
4936 | ||
4937 | /* Old configuration check. */ | |
f6269b4f RB |
4938 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
4939 | ||
4940 | if (rn->info) | |
718e3744 | 4941 | { |
f6269b4f | 4942 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
368473f6 | 4943 | /* try to remove the old entry */ |
f6269b4f RB |
4944 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
4945 | if (ret) | |
4946 | { | |
368473f6 RB |
4947 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
4948 | bgp_unlock_node (rn); | |
f6269b4f RB |
4949 | return CMD_WARNING; |
4950 | } | |
718e3744 | 4951 | } |
4952 | ||
f6269b4f RB |
4953 | /* Make aggregate address structure. */ |
4954 | aggregate = bgp_aggregate_new (); | |
4955 | aggregate->summary_only = summary_only; | |
4956 | aggregate->as_set = as_set; | |
4957 | aggregate->safi = safi; | |
4958 | rn->info = aggregate; | |
718e3744 | 4959 | |
f6269b4f RB |
4960 | /* Aggregate address insert into BGP routing table. */ |
4961 | if (safi & SAFI_UNICAST) | |
4962 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
4963 | if (safi & SAFI_MULTICAST) | |
4964 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 4965 | |
4966 | return CMD_SUCCESS; | |
4967 | } | |
4968 | ||
4969 | DEFUN (aggregate_address, | |
4970 | aggregate_address_cmd, | |
4971 | "aggregate-address A.B.C.D/M", | |
4972 | "Configure BGP aggregate entries\n" | |
4973 | "Aggregate prefix\n") | |
4974 | { | |
4975 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); | |
4976 | } | |
4977 | ||
4978 | DEFUN (aggregate_address_mask, | |
4979 | aggregate_address_mask_cmd, | |
4980 | "aggregate-address A.B.C.D A.B.C.D", | |
4981 | "Configure BGP aggregate entries\n" | |
4982 | "Aggregate address\n" | |
4983 | "Aggregate mask\n") | |
4984 | { | |
4985 | int ret; | |
4986 | char prefix_str[BUFSIZ]; | |
4987 | ||
4988 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4989 | ||
4990 | if (! ret) | |
4991 | { | |
4992 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4993 | return CMD_WARNING; | |
4994 | } | |
4995 | ||
4996 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
4997 | 0, 0); | |
4998 | } | |
4999 | ||
5000 | DEFUN (aggregate_address_summary_only, | |
5001 | aggregate_address_summary_only_cmd, | |
5002 | "aggregate-address A.B.C.D/M summary-only", | |
5003 | "Configure BGP aggregate entries\n" | |
5004 | "Aggregate prefix\n" | |
5005 | "Filter more specific routes from updates\n") | |
5006 | { | |
5007 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5008 | AGGREGATE_SUMMARY_ONLY, 0); | |
5009 | } | |
5010 | ||
5011 | DEFUN (aggregate_address_mask_summary_only, | |
5012 | aggregate_address_mask_summary_only_cmd, | |
5013 | "aggregate-address A.B.C.D A.B.C.D summary-only", | |
5014 | "Configure BGP aggregate entries\n" | |
5015 | "Aggregate address\n" | |
5016 | "Aggregate mask\n" | |
5017 | "Filter more specific routes from updates\n") | |
5018 | { | |
5019 | int ret; | |
5020 | char prefix_str[BUFSIZ]; | |
5021 | ||
5022 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5023 | ||
5024 | if (! ret) | |
5025 | { | |
5026 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5027 | return CMD_WARNING; | |
5028 | } | |
5029 | ||
5030 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5031 | AGGREGATE_SUMMARY_ONLY, 0); | |
5032 | } | |
5033 | ||
5034 | DEFUN (aggregate_address_as_set, | |
5035 | aggregate_address_as_set_cmd, | |
5036 | "aggregate-address A.B.C.D/M as-set", | |
5037 | "Configure BGP aggregate entries\n" | |
5038 | "Aggregate prefix\n" | |
5039 | "Generate AS set path information\n") | |
5040 | { | |
5041 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5042 | 0, AGGREGATE_AS_SET); | |
5043 | } | |
5044 | ||
5045 | DEFUN (aggregate_address_mask_as_set, | |
5046 | aggregate_address_mask_as_set_cmd, | |
5047 | "aggregate-address A.B.C.D A.B.C.D as-set", | |
5048 | "Configure BGP aggregate entries\n" | |
5049 | "Aggregate address\n" | |
5050 | "Aggregate mask\n" | |
5051 | "Generate AS set path information\n") | |
5052 | { | |
5053 | int ret; | |
5054 | char prefix_str[BUFSIZ]; | |
5055 | ||
5056 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5057 | ||
5058 | if (! ret) | |
5059 | { | |
5060 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5061 | return CMD_WARNING; | |
5062 | } | |
5063 | ||
5064 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5065 | 0, AGGREGATE_AS_SET); | |
5066 | } | |
5067 | ||
5068 | ||
5069 | DEFUN (aggregate_address_as_set_summary, | |
5070 | aggregate_address_as_set_summary_cmd, | |
5071 | "aggregate-address A.B.C.D/M as-set summary-only", | |
5072 | "Configure BGP aggregate entries\n" | |
5073 | "Aggregate prefix\n" | |
5074 | "Generate AS set path information\n" | |
5075 | "Filter more specific routes from updates\n") | |
5076 | { | |
5077 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5078 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5079 | } | |
5080 | ||
5081 | ALIAS (aggregate_address_as_set_summary, | |
5082 | aggregate_address_summary_as_set_cmd, | |
5083 | "aggregate-address A.B.C.D/M summary-only as-set", | |
5084 | "Configure BGP aggregate entries\n" | |
5085 | "Aggregate prefix\n" | |
5086 | "Filter more specific routes from updates\n" | |
5087 | "Generate AS set path information\n") | |
5088 | ||
5089 | DEFUN (aggregate_address_mask_as_set_summary, | |
5090 | aggregate_address_mask_as_set_summary_cmd, | |
5091 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5092 | "Configure BGP aggregate entries\n" | |
5093 | "Aggregate address\n" | |
5094 | "Aggregate mask\n" | |
5095 | "Generate AS set path information\n" | |
5096 | "Filter more specific routes from updates\n") | |
5097 | { | |
5098 | int ret; | |
5099 | char prefix_str[BUFSIZ]; | |
5100 | ||
5101 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5102 | ||
5103 | if (! ret) | |
5104 | { | |
5105 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5106 | return CMD_WARNING; | |
5107 | } | |
5108 | ||
5109 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5110 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5111 | } | |
5112 | ||
5113 | ALIAS (aggregate_address_mask_as_set_summary, | |
5114 | aggregate_address_mask_summary_as_set_cmd, | |
5115 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5116 | "Configure BGP aggregate entries\n" | |
5117 | "Aggregate address\n" | |
5118 | "Aggregate mask\n" | |
5119 | "Filter more specific routes from updates\n" | |
5120 | "Generate AS set path information\n") | |
5121 | ||
5122 | DEFUN (no_aggregate_address, | |
5123 | no_aggregate_address_cmd, | |
5124 | "no aggregate-address A.B.C.D/M", | |
5125 | NO_STR | |
5126 | "Configure BGP aggregate entries\n" | |
5127 | "Aggregate prefix\n") | |
5128 | { | |
5129 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); | |
5130 | } | |
5131 | ||
5132 | ALIAS (no_aggregate_address, | |
5133 | no_aggregate_address_summary_only_cmd, | |
5134 | "no aggregate-address A.B.C.D/M summary-only", | |
5135 | NO_STR | |
5136 | "Configure BGP aggregate entries\n" | |
5137 | "Aggregate prefix\n" | |
5138 | "Filter more specific routes from updates\n") | |
5139 | ||
5140 | ALIAS (no_aggregate_address, | |
5141 | no_aggregate_address_as_set_cmd, | |
5142 | "no aggregate-address A.B.C.D/M as-set", | |
5143 | NO_STR | |
5144 | "Configure BGP aggregate entries\n" | |
5145 | "Aggregate prefix\n" | |
5146 | "Generate AS set path information\n") | |
5147 | ||
5148 | ALIAS (no_aggregate_address, | |
5149 | no_aggregate_address_as_set_summary_cmd, | |
5150 | "no aggregate-address A.B.C.D/M as-set summary-only", | |
5151 | NO_STR | |
5152 | "Configure BGP aggregate entries\n" | |
5153 | "Aggregate prefix\n" | |
5154 | "Generate AS set path information\n" | |
5155 | "Filter more specific routes from updates\n") | |
5156 | ||
5157 | ALIAS (no_aggregate_address, | |
5158 | no_aggregate_address_summary_as_set_cmd, | |
5159 | "no aggregate-address A.B.C.D/M summary-only as-set", | |
5160 | NO_STR | |
5161 | "Configure BGP aggregate entries\n" | |
5162 | "Aggregate prefix\n" | |
5163 | "Filter more specific routes from updates\n" | |
5164 | "Generate AS set path information\n") | |
5165 | ||
5166 | DEFUN (no_aggregate_address_mask, | |
5167 | no_aggregate_address_mask_cmd, | |
5168 | "no aggregate-address A.B.C.D A.B.C.D", | |
5169 | NO_STR | |
5170 | "Configure BGP aggregate entries\n" | |
5171 | "Aggregate address\n" | |
5172 | "Aggregate mask\n") | |
5173 | { | |
5174 | int ret; | |
5175 | char prefix_str[BUFSIZ]; | |
5176 | ||
5177 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5178 | ||
5179 | if (! ret) | |
5180 | { | |
5181 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5182 | return CMD_WARNING; | |
5183 | } | |
5184 | ||
5185 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); | |
5186 | } | |
5187 | ||
5188 | ALIAS (no_aggregate_address_mask, | |
5189 | no_aggregate_address_mask_summary_only_cmd, | |
5190 | "no aggregate-address A.B.C.D A.B.C.D summary-only", | |
5191 | NO_STR | |
5192 | "Configure BGP aggregate entries\n" | |
5193 | "Aggregate address\n" | |
5194 | "Aggregate mask\n" | |
5195 | "Filter more specific routes from updates\n") | |
5196 | ||
5197 | ALIAS (no_aggregate_address_mask, | |
5198 | no_aggregate_address_mask_as_set_cmd, | |
5199 | "no aggregate-address A.B.C.D A.B.C.D as-set", | |
5200 | NO_STR | |
5201 | "Configure BGP aggregate entries\n" | |
5202 | "Aggregate address\n" | |
5203 | "Aggregate mask\n" | |
5204 | "Generate AS set path information\n") | |
5205 | ||
5206 | ALIAS (no_aggregate_address_mask, | |
5207 | no_aggregate_address_mask_as_set_summary_cmd, | |
5208 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5209 | NO_STR | |
5210 | "Configure BGP aggregate entries\n" | |
5211 | "Aggregate address\n" | |
5212 | "Aggregate mask\n" | |
5213 | "Generate AS set path information\n" | |
5214 | "Filter more specific routes from updates\n") | |
5215 | ||
5216 | ALIAS (no_aggregate_address_mask, | |
5217 | no_aggregate_address_mask_summary_as_set_cmd, | |
5218 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5219 | NO_STR | |
5220 | "Configure BGP aggregate entries\n" | |
5221 | "Aggregate address\n" | |
5222 | "Aggregate mask\n" | |
5223 | "Filter more specific routes from updates\n" | |
5224 | "Generate AS set path information\n") | |
5225 | ||
5226 | #ifdef HAVE_IPV6 | |
5227 | DEFUN (ipv6_aggregate_address, | |
5228 | ipv6_aggregate_address_cmd, | |
5229 | "aggregate-address X:X::X:X/M", | |
5230 | "Configure BGP aggregate entries\n" | |
5231 | "Aggregate prefix\n") | |
5232 | { | |
5233 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); | |
5234 | } | |
5235 | ||
5236 | DEFUN (ipv6_aggregate_address_summary_only, | |
5237 | ipv6_aggregate_address_summary_only_cmd, | |
5238 | "aggregate-address X:X::X:X/M summary-only", | |
5239 | "Configure BGP aggregate entries\n" | |
5240 | "Aggregate prefix\n" | |
5241 | "Filter more specific routes from updates\n") | |
5242 | { | |
5243 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
5244 | AGGREGATE_SUMMARY_ONLY, 0); | |
5245 | } | |
5246 | ||
5247 | DEFUN (no_ipv6_aggregate_address, | |
5248 | no_ipv6_aggregate_address_cmd, | |
5249 | "no aggregate-address X:X::X:X/M", | |
5250 | NO_STR | |
5251 | "Configure BGP aggregate entries\n" | |
5252 | "Aggregate prefix\n") | |
5253 | { | |
5254 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5255 | } | |
5256 | ||
5257 | DEFUN (no_ipv6_aggregate_address_summary_only, | |
5258 | no_ipv6_aggregate_address_summary_only_cmd, | |
5259 | "no aggregate-address X:X::X:X/M summary-only", | |
5260 | NO_STR | |
5261 | "Configure BGP aggregate entries\n" | |
5262 | "Aggregate prefix\n" | |
5263 | "Filter more specific routes from updates\n") | |
5264 | { | |
5265 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5266 | } | |
5267 | ||
5268 | ALIAS (ipv6_aggregate_address, | |
5269 | old_ipv6_aggregate_address_cmd, | |
5270 | "ipv6 bgp aggregate-address X:X::X:X/M", | |
5271 | IPV6_STR | |
5272 | BGP_STR | |
5273 | "Configure BGP aggregate entries\n" | |
5274 | "Aggregate prefix\n") | |
5275 | ||
5276 | ALIAS (ipv6_aggregate_address_summary_only, | |
5277 | old_ipv6_aggregate_address_summary_only_cmd, | |
5278 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5279 | IPV6_STR | |
5280 | BGP_STR | |
5281 | "Configure BGP aggregate entries\n" | |
5282 | "Aggregate prefix\n" | |
5283 | "Filter more specific routes from updates\n") | |
5284 | ||
5285 | ALIAS (no_ipv6_aggregate_address, | |
5286 | old_no_ipv6_aggregate_address_cmd, | |
5287 | "no ipv6 bgp aggregate-address X:X::X:X/M", | |
5288 | NO_STR | |
5289 | IPV6_STR | |
5290 | BGP_STR | |
5291 | "Configure BGP aggregate entries\n" | |
5292 | "Aggregate prefix\n") | |
5293 | ||
5294 | ALIAS (no_ipv6_aggregate_address_summary_only, | |
5295 | old_no_ipv6_aggregate_address_summary_only_cmd, | |
5296 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5297 | NO_STR | |
5298 | IPV6_STR | |
5299 | BGP_STR | |
5300 | "Configure BGP aggregate entries\n" | |
5301 | "Aggregate prefix\n" | |
5302 | "Filter more specific routes from updates\n") | |
5303 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 5304 | |
718e3744 | 5305 | /* Redistribute route treatment. */ |
5306 | void | |
6aeb9e78 | 5307 | bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *nexthop, |
bc413143 | 5308 | const struct in6_addr *nexthop6, unsigned int ifindex, |
7c8ff89e | 5309 | u_int32_t metric, u_char type, u_short instance, u_short tag) |
718e3744 | 5310 | { |
718e3744 | 5311 | struct bgp_info *new; |
5312 | struct bgp_info *bi; | |
5313 | struct bgp_info info; | |
5314 | struct bgp_node *bn; | |
e16a4133 | 5315 | struct attr attr; |
718e3744 | 5316 | struct attr *new_attr; |
5317 | afi_t afi; | |
5318 | int ret; | |
7c8ff89e | 5319 | struct bgp_redist *red; |
718e3744 | 5320 | |
5321 | /* Make default attribute. */ | |
5322 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); | |
5323 | if (nexthop) | |
5324 | attr.nexthop = *nexthop; | |
bc413143 | 5325 | attr.nh_ifindex = ifindex; |
718e3744 | 5326 | |
f04a80a5 SH |
5327 | #ifdef HAVE_IPV6 |
5328 | if (nexthop6) | |
5329 | { | |
5330 | struct attr_extra *extra = bgp_attr_extra_get(&attr); | |
5331 | extra->mp_nexthop_global = *nexthop6; | |
801a9bcc | 5332 | extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; |
f04a80a5 SH |
5333 | } |
5334 | #endif | |
5335 | ||
718e3744 | 5336 | attr.med = metric; |
5337 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
0d9551dc | 5338 | attr.extra->tag = tag; |
718e3744 | 5339 | |
6aeb9e78 DS |
5340 | afi = family2afi (p->family); |
5341 | ||
5342 | red = bgp_redist_lookup(bgp, afi, type, instance); | |
5343 | if (red) | |
718e3744 | 5344 | { |
6aeb9e78 DS |
5345 | struct attr attr_new; |
5346 | struct attr_extra extra_new; | |
718e3744 | 5347 | |
6aeb9e78 DS |
5348 | /* Copy attribute for modification. */ |
5349 | attr_new.extra = &extra_new; | |
5350 | bgp_attr_dup (&attr_new, &attr); | |
558d1fec | 5351 | |
6aeb9e78 DS |
5352 | if (red->redist_metric_flag) |
5353 | attr_new.med = red->redist_metric; | |
718e3744 | 5354 | |
6aeb9e78 DS |
5355 | /* Apply route-map. */ |
5356 | if (red->rmap.name) | |
5357 | { | |
5358 | info.peer = bgp->peer_self; | |
5359 | info.attr = &attr_new; | |
718e3744 | 5360 | |
6aeb9e78 | 5361 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
718e3744 | 5362 | |
6aeb9e78 | 5363 | ret = route_map_apply (red->rmap.map, p, RMAP_BGP, &info); |
fee0f4c6 | 5364 | |
6aeb9e78 | 5365 | bgp->peer_self->rmap_type = 0; |
fee0f4c6 | 5366 | |
6aeb9e78 DS |
5367 | if (ret == RMAP_DENYMATCH) |
5368 | { | |
5369 | /* Free uninterned attribute. */ | |
5370 | bgp_attr_flush (&attr_new); | |
5371 | ||
5372 | /* Unintern original. */ | |
5373 | aspath_unintern (&attr.aspath); | |
5374 | bgp_attr_extra_free (&attr); | |
5375 | bgp_redistribute_delete (bgp, p, type, instance); | |
5376 | return; | |
5377 | } | |
5378 | } | |
fee0f4c6 | 5379 | |
6aeb9e78 DS |
5380 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
5381 | afi, SAFI_UNICAST, p, NULL); | |
718e3744 | 5382 | |
6aeb9e78 | 5383 | new_attr = bgp_attr_intern (&attr_new); |
558d1fec | 5384 | |
6aeb9e78 DS |
5385 | for (bi = bn->info; bi; bi = bi->next) |
5386 | if (bi->peer == bgp->peer_self | |
5387 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
5388 | break; | |
5389 | ||
5390 | if (bi) | |
5391 | { | |
5392 | /* Ensure the (source route) type is updated. */ | |
5393 | bi->type = type; | |
5394 | if (attrhash_cmp (bi->attr, new_attr) && | |
5395 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
5396 | { | |
5397 | bgp_attr_unintern (&new_attr); | |
5398 | aspath_unintern (&attr.aspath); | |
5399 | bgp_attr_extra_free (&attr); | |
5400 | bgp_unlock_node (bn); | |
5401 | return; | |
5402 | } | |
5403 | else | |
5404 | { | |
5405 | /* The attribute is changed. */ | |
5406 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); | |
718e3744 | 5407 | |
6aeb9e78 DS |
5408 | /* Rewrite BGP route information. */ |
5409 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
5410 | bgp_info_restore(bn, bi); | |
5411 | else | |
5412 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); | |
5413 | bgp_attr_unintern (&bi->attr); | |
5414 | bi->attr = new_attr; | |
5415 | bi->uptime = bgp_clock (); | |
5416 | ||
5417 | /* Process change. */ | |
5418 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); | |
5419 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
5420 | bgp_unlock_node (bn); | |
5421 | aspath_unintern (&attr.aspath); | |
5422 | bgp_attr_extra_free (&attr); | |
5423 | return; | |
5424 | } | |
5425 | } | |
718e3744 | 5426 | |
6aeb9e78 DS |
5427 | new = info_make(type, BGP_ROUTE_REDISTRIBUTE, instance, bgp->peer_self, |
5428 | new_attr, bn); | |
5429 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
5430 | ||
5431 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); | |
5432 | bgp_info_add (bn, new); | |
5433 | bgp_unlock_node (bn); | |
5434 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
718e3744 | 5435 | } |
5436 | ||
5437 | /* Unintern original. */ | |
f6f434b2 | 5438 | aspath_unintern (&attr.aspath); |
fb982c25 | 5439 | bgp_attr_extra_free (&attr); |
718e3744 | 5440 | } |
5441 | ||
5442 | void | |
6aeb9e78 | 5443 | bgp_redistribute_delete (struct bgp *bgp, struct prefix *p, u_char type, u_short instance) |
718e3744 | 5444 | { |
718e3744 | 5445 | afi_t afi; |
5446 | struct bgp_node *rn; | |
5447 | struct bgp_info *ri; | |
7c8ff89e | 5448 | struct bgp_redist *red; |
718e3744 | 5449 | |
6aeb9e78 | 5450 | afi = family2afi (p->family); |
718e3744 | 5451 | |
6aeb9e78 DS |
5452 | red = bgp_redist_lookup(bgp, afi, type, instance); |
5453 | if (red) | |
5454 | { | |
5455 | rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); | |
718e3744 | 5456 | |
6aeb9e78 DS |
5457 | for (ri = rn->info; ri; ri = ri->next) |
5458 | if (ri->peer == bgp->peer_self | |
5459 | && ri->type == type) | |
5460 | break; | |
718e3744 | 5461 | |
6aeb9e78 DS |
5462 | if (ri) |
5463 | { | |
5464 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); | |
5465 | bgp_info_delete (rn, ri); | |
5466 | bgp_process (bgp, rn, afi, SAFI_UNICAST); | |
5467 | } | |
5468 | bgp_unlock_node (rn); | |
718e3744 | 5469 | } |
5470 | } | |
5471 | ||
5472 | /* Withdraw specified route type's route. */ | |
5473 | void | |
7c8ff89e | 5474 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type, u_short instance) |
718e3744 | 5475 | { |
5476 | struct bgp_node *rn; | |
5477 | struct bgp_info *ri; | |
5478 | struct bgp_table *table; | |
5479 | ||
5480 | table = bgp->rib[afi][SAFI_UNICAST]; | |
5481 | ||
5482 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
5483 | { | |
5484 | for (ri = rn->info; ri; ri = ri->next) | |
5485 | if (ri->peer == bgp->peer_self | |
7c8ff89e DS |
5486 | && ri->type == type |
5487 | && ri->instance == instance) | |
718e3744 | 5488 | break; |
5489 | ||
5490 | if (ri) | |
5491 | { | |
5492 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5493 | bgp_info_delete (rn, ri); |
1a392d46 | 5494 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5495 | } |
5496 | } | |
5497 | } | |
6b0655a2 | 5498 | |
718e3744 | 5499 | /* Static function to display route. */ |
94f2b392 | 5500 | static void |
718e3744 | 5501 | route_vty_out_route (struct prefix *p, struct vty *vty) |
5502 | { | |
5503 | int len; | |
5504 | u_int32_t destination; | |
5505 | char buf[BUFSIZ]; | |
5506 | ||
5507 | if (p->family == AF_INET) | |
5508 | { | |
5509 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); | |
5510 | destination = ntohl (p->u.prefix4.s_addr); | |
5511 | ||
5512 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
856ca177 MS |
5513 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
5514 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
5515 | || p->u.prefix4.s_addr == 0) | |
5516 | { | |
5517 | /* When mask is natural, mask is not displayed. */ | |
5518 | } | |
718e3744 | 5519 | else |
856ca177 | 5520 | len += vty_out (vty, "/%d", p->prefixlen); |
718e3744 | 5521 | } |
5522 | else | |
5523 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), | |
5524 | p->prefixlen); | |
5525 | ||
5526 | len = 17 - len; | |
5527 | if (len < 1) | |
5528 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); | |
5529 | else | |
5530 | vty_out (vty, "%*s", len, " "); | |
5531 | } | |
5532 | ||
718e3744 | 5533 | enum bgp_display_type |
5534 | { | |
5535 | normal_list, | |
5536 | }; | |
5537 | ||
b40d939b | 5538 | /* Print the short form route status for a bgp_info */ |
5539 | static void | |
b05a1c8b DS |
5540 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo, |
5541 | json_object *json_path) | |
718e3744 | 5542 | { |
b05a1c8b DS |
5543 | if (json_path) |
5544 | { | |
b05a1c8b DS |
5545 | |
5546 | /* Route status display. */ | |
5547 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
f1aa5d8a | 5548 | json_object_boolean_true_add(json_path, "removed"); |
b05a1c8b DS |
5549 | |
5550 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
f1aa5d8a | 5551 | json_object_boolean_true_add(json_path, "stale"); |
b05a1c8b DS |
5552 | |
5553 | if (binfo->extra && binfo->extra->suppress) | |
f1aa5d8a | 5554 | json_object_boolean_true_add(json_path, "suppressed"); |
b05a1c8b DS |
5555 | |
5556 | if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && | |
5557 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
f1aa5d8a | 5558 | json_object_boolean_true_add(json_path, "valid"); |
b05a1c8b DS |
5559 | |
5560 | /* Selected */ | |
5561 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
f1aa5d8a | 5562 | json_object_boolean_true_add(json_path, "history"); |
b05a1c8b DS |
5563 | |
5564 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
f1aa5d8a | 5565 | json_object_boolean_true_add(json_path, "damped"); |
b05a1c8b DS |
5566 | |
5567 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
f1aa5d8a | 5568 | json_object_boolean_true_add(json_path, "bestpath"); |
b05a1c8b DS |
5569 | |
5570 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) | |
f1aa5d8a | 5571 | json_object_boolean_true_add(json_path, "multipath"); |
b05a1c8b DS |
5572 | |
5573 | /* Internal route. */ | |
5574 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) | |
62d6dca0 | 5575 | json_object_string_add(json_path, "pathFrom", "internal"); |
b05a1c8b | 5576 | else |
62d6dca0 | 5577 | json_object_string_add(json_path, "pathFrom", "external"); |
b05a1c8b DS |
5578 | |
5579 | return; | |
5580 | } | |
5581 | ||
b40d939b | 5582 | /* Route status display. */ |
5583 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
5584 | vty_out (vty, "R"); | |
5585 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
93406d87 | 5586 | vty_out (vty, "S"); |
fb982c25 | 5587 | else if (binfo->extra && binfo->extra->suppress) |
718e3744 | 5588 | vty_out (vty, "s"); |
31eba040 DS |
5589 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && |
5590 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
718e3744 | 5591 | vty_out (vty, "*"); |
5592 | else | |
5593 | vty_out (vty, " "); | |
5594 | ||
5595 | /* Selected */ | |
5596 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5597 | vty_out (vty, "h"); | |
5598 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5599 | vty_out (vty, "d"); | |
5600 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
5601 | vty_out (vty, ">"); | |
b366b518 BB |
5602 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
5603 | vty_out (vty, "="); | |
718e3744 | 5604 | else |
5605 | vty_out (vty, " "); | |
5606 | ||
5607 | /* Internal route. */ | |
b05a1c8b DS |
5608 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
5609 | vty_out (vty, "i"); | |
5610 | else | |
5611 | vty_out (vty, " "); | |
b40d939b | 5612 | } |
5613 | ||
5614 | /* called from terminal list command */ | |
5615 | void | |
5616 | route_vty_out (struct vty *vty, struct prefix *p, | |
b05a1c8b DS |
5617 | struct bgp_info *binfo, int display, safi_t safi, |
5618 | json_object *json_paths) | |
b40d939b | 5619 | { |
5620 | struct attr *attr; | |
f1aa5d8a DS |
5621 | json_object *json_path = NULL; |
5622 | json_object *json_nexthops = NULL; | |
5623 | json_object *json_nexthop_global = NULL; | |
5624 | json_object *json_nexthop_ll = NULL; | |
47fc97cc | 5625 | |
b05a1c8b DS |
5626 | if (json_paths) |
5627 | json_path = json_object_new_object(); | |
b05a1c8b DS |
5628 | |
5629 | /* short status lead text */ | |
5630 | route_vty_short_status_out (vty, binfo, json_path); | |
718e3744 | 5631 | |
b05a1c8b DS |
5632 | if (!json_paths) |
5633 | { | |
5634 | /* print prefix and mask */ | |
5635 | if (! display) | |
5636 | route_vty_out_route (p, vty); | |
5637 | else | |
5638 | vty_out (vty, "%*s", 17, " "); | |
5639 | } | |
47fc97cc | 5640 | |
718e3744 | 5641 | /* Print attribute */ |
5642 | attr = binfo->attr; | |
5643 | if (attr) | |
5644 | { | |
b05a1c8b DS |
5645 | |
5646 | /* IPv4 Next Hop */ | |
8a92a8a0 DS |
5647 | if (p->family == AF_INET |
5648 | && (safi == SAFI_MPLS_VPN || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
718e3744 | 5649 | { |
b05a1c8b DS |
5650 | if (json_paths) |
5651 | { | |
f1aa5d8a DS |
5652 | json_nexthop_global = json_object_new_object(); |
5653 | ||
b05a1c8b | 5654 | if (safi == SAFI_MPLS_VPN) |
f1aa5d8a | 5655 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->extra->mp_nexthop_global_in)); |
b05a1c8b | 5656 | else |
f1aa5d8a DS |
5657 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->nexthop)); |
5658 | ||
5659 | json_object_string_add(json_nexthop_global, "afi", "ipv4"); | |
5660 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
b05a1c8b DS |
5661 | } |
5662 | else | |
5663 | { | |
5664 | if (safi == SAFI_MPLS_VPN) | |
5665 | vty_out (vty, "%-16s", | |
5666 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
5667 | else | |
5668 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5669 | } | |
718e3744 | 5670 | } |
b05a1c8b DS |
5671 | |
5672 | #ifdef HAVE_IPV6 | |
5673 | /* IPv6 Next Hop */ | |
8a92a8a0 | 5674 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) |
718e3744 | 5675 | { |
5676 | int len; | |
5677 | char buf[BUFSIZ]; | |
5678 | ||
b05a1c8b DS |
5679 | if (json_paths) |
5680 | { | |
f1aa5d8a DS |
5681 | json_nexthop_global = json_object_new_object(); |
5682 | json_object_string_add(json_nexthop_global, "ip", | |
5683 | inet_ntop (AF_INET6, | |
5684 | &attr->extra->mp_nexthop_global, | |
5685 | buf, BUFSIZ)); | |
5686 | json_object_string_add(json_nexthop_global, "afi", "ipv6"); | |
5687 | json_object_string_add(json_nexthop_global, "scope", "global"); | |
5688 | ||
5689 | /* We display both LL & GL if both have been received */ | |
5690 | if ((attr->extra->mp_nexthop_len == 32) || (binfo->peer->conf_if)) | |
5691 | { | |
5692 | json_nexthop_ll = json_object_new_object(); | |
5693 | json_object_string_add(json_nexthop_ll, "ip", | |
5694 | inet_ntop (AF_INET6, | |
5695 | &attr->extra->mp_nexthop_local, | |
5696 | buf, BUFSIZ)); | |
5697 | json_object_string_add(json_nexthop_ll, "afi", "ipv6"); | |
5698 | json_object_string_add(json_nexthop_ll, "scope", "link-local"); | |
5699 | ||
5700 | if (IPV6_ADDR_CMP (&attr->extra->mp_nexthop_global, | |
5701 | &attr->extra->mp_nexthop_local) != 0) | |
5702 | json_object_boolean_true_add(json_nexthop_ll, "used"); | |
5703 | else | |
5704 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
5705 | } | |
5706 | else | |
5707 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
b05a1c8b DS |
5708 | } |
5709 | else | |
5710 | { | |
433e8b67 DS |
5711 | if ((attr->extra->mp_nexthop_len == 32) || (binfo->peer->conf_if)) |
5712 | { | |
5713 | if (binfo->peer->conf_if) | |
5714 | { | |
5715 | len = vty_out (vty, "%s", | |
5716 | binfo->peer->conf_if); | |
5717 | len = 7 - len; /* len of IPv6 addr + max len of def ifname */ | |
5718 | ||
5719 | if (len < 1) | |
5720 | vty_out (vty, "%s%*s", VTY_NEWLINE, 45, " "); | |
5721 | else | |
5722 | vty_out (vty, "%*s", len, " "); | |
5723 | } | |
5724 | else | |
5725 | { | |
5726 | len = vty_out (vty, "%s", | |
5727 | inet_ntop (AF_INET6, | |
5728 | &attr->extra->mp_nexthop_local, | |
5729 | buf, BUFSIZ)); | |
5730 | len = 16 - len; | |
5731 | ||
5732 | if (len < 1) | |
5733 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5734 | else | |
5735 | vty_out (vty, "%*s", len, " "); | |
5736 | } | |
5737 | } | |
5738 | else | |
5739 | { | |
5740 | len = vty_out (vty, "%s", | |
5741 | inet_ntop (AF_INET6, | |
5742 | &attr->extra->mp_nexthop_global, | |
5743 | buf, BUFSIZ)); | |
5744 | len = 16 - len; | |
5745 | ||
5746 | if (len < 1) | |
5747 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5748 | else | |
5749 | vty_out (vty, "%*s", len, " "); | |
5750 | } | |
b05a1c8b | 5751 | } |
718e3744 | 5752 | } |
5753 | #endif /* HAVE_IPV6 */ | |
5754 | ||
b05a1c8b | 5755 | /* MED/Metric */ |
718e3744 | 5756 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
b05a1c8b | 5757 | if (json_paths) |
f1aa5d8a | 5758 | json_object_int_add(json_path, "med", attr->med); |
b05a1c8b DS |
5759 | else |
5760 | vty_out (vty, "%10u", attr->med); | |
718e3744 | 5761 | else |
b05a1c8b DS |
5762 | if (!json_paths) |
5763 | vty_out (vty, " "); | |
47fc97cc | 5764 | |
b05a1c8b | 5765 | /* Local Pref */ |
718e3744 | 5766 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
b05a1c8b | 5767 | if (json_paths) |
f1aa5d8a | 5768 | json_object_int_add(json_path, "localpref", attr->local_pref); |
b05a1c8b DS |
5769 | else |
5770 | vty_out (vty, "%7u", attr->local_pref); | |
718e3744 | 5771 | else |
b05a1c8b DS |
5772 | if (!json_paths) |
5773 | vty_out (vty, " "); | |
718e3744 | 5774 | |
b05a1c8b DS |
5775 | if (json_paths) |
5776 | { | |
5777 | if (attr->extra) | |
f1aa5d8a | 5778 | json_object_int_add(json_path, "weight", attr->extra->weight); |
b05a1c8b | 5779 | else |
f1aa5d8a | 5780 | json_object_int_add(json_path, "weight", 0); |
b05a1c8b DS |
5781 | } |
5782 | else | |
5783 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); | |
47fc97cc | 5784 | |
b2518c1e PJ |
5785 | /* Print aspath */ |
5786 | if (attr->aspath) | |
b05a1c8b DS |
5787 | { |
5788 | if (json_paths) | |
f1aa5d8a | 5789 | json_object_string_add(json_path, "aspath", attr->aspath->str); |
b05a1c8b | 5790 | else |
f1aa5d8a | 5791 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
b05a1c8b | 5792 | } |
47fc97cc | 5793 | |
b2518c1e | 5794 | /* Print origin */ |
b05a1c8b | 5795 | if (json_paths) |
f1aa5d8a | 5796 | json_object_string_add(json_path, "origin", bgp_origin_long_str[attr->origin]); |
b05a1c8b DS |
5797 | else |
5798 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
b2518c1e | 5799 | } |
856ca177 MS |
5800 | else |
5801 | { | |
5802 | if (json_paths) | |
5803 | json_object_string_add(json_path, "alert", "No attributes"); | |
5804 | else | |
5805 | vty_out (vty, "No attributes to print%s", VTY_NEWLINE); | |
5806 | } | |
b05a1c8b DS |
5807 | |
5808 | if (json_paths) | |
f1aa5d8a DS |
5809 | { |
5810 | if (json_nexthop_global || json_nexthop_ll) | |
5811 | { | |
5812 | json_nexthops = json_object_new_array(); | |
5813 | ||
5814 | if (json_nexthop_global) | |
5815 | json_object_array_add(json_nexthops, json_nexthop_global); | |
5816 | ||
5817 | if (json_nexthop_ll) | |
5818 | json_object_array_add(json_nexthops, json_nexthop_ll); | |
5819 | ||
5820 | json_object_object_add(json_path, "nexthops", json_nexthops); | |
5821 | } | |
5822 | ||
5823 | json_object_array_add(json_paths, json_path); | |
5824 | } | |
b05a1c8b DS |
5825 | else |
5826 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5827 | } |
5828 | ||
5829 | /* called from terminal list command */ | |
5830 | void | |
856ca177 MS |
5831 | route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t safi, |
5832 | u_char use_json, json_object *json_ar) | |
718e3744 | 5833 | { |
856ca177 MS |
5834 | json_object *json_status = NULL; |
5835 | json_object *json_net = NULL; | |
5836 | char buff[BUFSIZ]; | |
718e3744 | 5837 | /* Route status display. */ |
856ca177 MS |
5838 | if (use_json) |
5839 | { | |
5840 | json_status = json_object_new_object(); | |
5841 | json_net = json_object_new_object(); | |
5842 | } | |
5843 | else | |
5844 | { | |
5845 | vty_out (vty, "*"); | |
5846 | vty_out (vty, ">"); | |
5847 | vty_out (vty, " "); | |
5848 | } | |
718e3744 | 5849 | |
5850 | /* print prefix and mask */ | |
856ca177 MS |
5851 | if (use_json) |
5852 | json_object_string_add(json_net, "addrPrefix", inet_ntop (p->family, &p->u.prefix, buff, BUFSIZ)); | |
5853 | else | |
5854 | route_vty_out_route (p, vty); | |
718e3744 | 5855 | |
5856 | /* Print attribute */ | |
5857 | if (attr) | |
5858 | { | |
856ca177 | 5859 | if (use_json) |
718e3744 | 5860 | { |
856ca177 MS |
5861 | if (p->family == AF_INET && (safi == SAFI_MPLS_VPN || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) |
5862 | { | |
5863 | if (safi == SAFI_MPLS_VPN) | |
5864 | json_object_string_add(json_net, "nextHop", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
5865 | else | |
5866 | json_object_string_add(json_net, "nextHop", inet_ntoa (attr->nexthop)); | |
5867 | } | |
5868 | #ifdef HAVE_IPV6 | |
5869 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) | |
5870 | { | |
5871 | char buf[BUFSIZ]; | |
718e3744 | 5872 | |
856ca177 MS |
5873 | json_object_string_add(json_net, "netHopGloabal", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5874 | buf, BUFSIZ)); | |
5875 | } | |
5876 | #endif /* HAVE_IPV6 */ | |
5877 | ||
5878 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
5879 | json_object_int_add(json_net, "metric", attr->med); | |
5880 | ||
5881 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
5882 | json_object_int_add(json_net, "localPref", attr->local_pref); | |
5883 | ||
5884 | if (attr->extra) | |
5885 | json_object_int_add(json_net, "weight", attr->extra->weight); | |
718e3744 | 5886 | else |
856ca177 MS |
5887 | json_object_int_add(json_net, "weight", 0); |
5888 | ||
5889 | /* Print aspath */ | |
5890 | if (attr->aspath) | |
5891 | json_object_string_add(json_net, "asPath", attr->aspath->str); | |
5892 | ||
5893 | /* Print origin */ | |
5894 | json_object_string_add(json_net, "bgpOriginCode", bgp_origin_str[attr->origin]); | |
718e3744 | 5895 | } |
856ca177 MS |
5896 | else |
5897 | { | |
5898 | if (p->family == AF_INET && (safi == SAFI_MPLS_VPN || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
5899 | { | |
5900 | if (safi == SAFI_MPLS_VPN) | |
5901 | vty_out (vty, "%-16s", | |
5902 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
5903 | else | |
5904 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5905 | } | |
5906 | #ifdef HAVE_IPV6 | |
5907 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) | |
5908 | { | |
5909 | int len; | |
5910 | char buf[BUFSIZ]; | |
5911 | ||
5912 | assert (attr->extra); | |
5913 | ||
5914 | len = vty_out (vty, "%s", | |
5915 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
5916 | buf, BUFSIZ)); | |
5917 | len = 16 - len; | |
5918 | if (len < 1) | |
5919 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5920 | else | |
5921 | vty_out (vty, "%*s", len, " "); | |
5922 | } | |
718e3744 | 5923 | #endif /* HAVE_IPV6 */ |
856ca177 MS |
5924 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
5925 | vty_out (vty, "%10u", attr->med); | |
5926 | else | |
5927 | vty_out (vty, " "); | |
718e3744 | 5928 | |
856ca177 MS |
5929 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
5930 | vty_out (vty, "%7u", attr->local_pref); | |
5931 | else | |
5932 | vty_out (vty, " "); | |
718e3744 | 5933 | |
856ca177 | 5934 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
718e3744 | 5935 | |
856ca177 MS |
5936 | /* Print aspath */ |
5937 | if (attr->aspath) | |
5938 | aspath_print_vty (vty, "%s", attr->aspath, " "); | |
718e3744 | 5939 | |
856ca177 MS |
5940 | /* Print origin */ |
5941 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
5942 | } | |
5943 | } | |
5944 | if (use_json) | |
5945 | { | |
5946 | json_object_boolean_true_add(json_status, "*"); | |
5947 | json_object_boolean_true_add(json_status, ">"); | |
5948 | json_object_object_add(json_net, "appliedStatusSymbols", json_status); | |
5949 | char buf_cut[BUFSIZ]; | |
5950 | json_object_object_add(json_ar, inet_ntop (p->family, &p->u.prefix, buf_cut, BUFSIZ), json_net); | |
5951 | } | |
5952 | else | |
5953 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5954 | } |
5955 | ||
5a646650 | 5956 | void |
718e3744 | 5957 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
856ca177 | 5958 | struct bgp_info *binfo, int display, safi_t safi, json_object *json) |
718e3744 | 5959 | { |
856ca177 | 5960 | json_object *json_out = NULL; |
718e3744 | 5961 | struct attr *attr; |
718e3744 | 5962 | u_int32_t label = 0; |
fb982c25 PJ |
5963 | |
5964 | if (!binfo->extra) | |
5965 | return; | |
856ca177 MS |
5966 | |
5967 | if (json) | |
5968 | json_out = json_object_new_object(); | |
fb982c25 | 5969 | |
b40d939b | 5970 | /* short status lead text */ |
856ca177 | 5971 | route_vty_short_status_out (vty, binfo, json_out); |
b40d939b | 5972 | |
718e3744 | 5973 | /* print prefix and mask */ |
856ca177 MS |
5974 | if (json == NULL) |
5975 | { | |
5976 | if (! display) | |
5977 | route_vty_out_route (p, vty); | |
5978 | else | |
5979 | vty_out (vty, "%*s", 17, " "); | |
5980 | } | |
718e3744 | 5981 | |
5982 | /* Print attribute */ | |
5983 | attr = binfo->attr; | |
5984 | if (attr) | |
5985 | { | |
8a92a8a0 DS |
5986 | if (p->family == AF_INET |
5987 | && (safi == SAFI_MPLS_VPN || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
718e3744 | 5988 | { |
5989 | if (safi == SAFI_MPLS_VPN) | |
856ca177 MS |
5990 | { |
5991 | if (json) | |
5992 | json_object_string_add(json_out, "mpNexthopGlobalIn", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
5993 | else | |
5994 | vty_out (vty, "%-16s", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
5995 | } | |
718e3744 | 5996 | else |
856ca177 MS |
5997 | { |
5998 | if (json) | |
5999 | json_object_string_add(json_out, "nexthop", inet_ntoa (attr->nexthop)); | |
6000 | else | |
6001 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
6002 | } | |
718e3744 | 6003 | } |
6004 | #ifdef HAVE_IPV6 | |
8a92a8a0 | 6005 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) |
718e3744 | 6006 | { |
fb982c25 | 6007 | assert (attr->extra); |
856ca177 MS |
6008 | char buf_a[BUFSIZ]; |
6009 | char buf_b[BUFSIZ]; | |
6010 | char buf_c[BUFSIZ]; | |
801a9bcc | 6011 | if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) |
856ca177 MS |
6012 | { |
6013 | if (json) | |
6014 | json_object_string_add(json_out, "mpNexthopGlobalIn", | |
6015 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, buf_a, BUFSIZ)); | |
6016 | else | |
6017 | vty_out (vty, "%s", | |
6018 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6019 | buf_a, BUFSIZ)); | |
6020 | } | |
801a9bcc | 6021 | else if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) |
856ca177 MS |
6022 | { |
6023 | if (json) | |
6024 | { | |
6025 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6026 | buf_a, BUFSIZ); | |
6027 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
6028 | buf_b, BUFSIZ); | |
6029 | sprintf(buf_c, "%s(%s)", buf_a, buf_b); | |
6030 | json_object_string_add(json_out, "mpNexthopGlobalLocal", buf_c); | |
6031 | } | |
6032 | else | |
6033 | vty_out (vty, "%s(%s)", | |
6034 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6035 | buf_a, BUFSIZ), | |
6036 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
6037 | buf_b, BUFSIZ)); | |
6038 | } | |
6039 | ||
718e3744 | 6040 | } |
6041 | #endif /* HAVE_IPV6 */ | |
6042 | } | |
6043 | ||
fb982c25 | 6044 | label = decode_label (binfo->extra->tag); |
718e3744 | 6045 | |
856ca177 MS |
6046 | if (json) |
6047 | { | |
6048 | if (label) | |
6049 | json_object_int_add(json_out, "notag", label); | |
6050 | json_object_array_add(json, json_out); | |
6051 | } | |
6052 | else | |
6053 | { | |
6054 | vty_out (vty, "notag/%d", label); | |
6055 | vty_out (vty, "%s", VTY_NEWLINE); | |
6056 | } | |
718e3744 | 6057 | } |
6058 | ||
6059 | /* dampening route */ | |
5a646650 | 6060 | static void |
856ca177 MS |
6061 | damp_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, |
6062 | int display, safi_t safi, u_char use_json, json_object *json) | |
718e3744 | 6063 | { |
6064 | struct attr *attr; | |
718e3744 | 6065 | int len; |
50aef6f3 | 6066 | char timebuf[BGP_UPTIME_LEN]; |
718e3744 | 6067 | |
b40d939b | 6068 | /* short status lead text */ |
856ca177 | 6069 | route_vty_short_status_out (vty, binfo, json); |
b40d939b | 6070 | |
718e3744 | 6071 | /* print prefix and mask */ |
856ca177 MS |
6072 | if (!use_json) |
6073 | { | |
6074 | if (! display) | |
6075 | route_vty_out_route (p, vty); | |
6076 | else | |
6077 | vty_out (vty, "%*s", 17, " "); | |
6078 | } | |
718e3744 | 6079 | |
6080 | len = vty_out (vty, "%s", binfo->peer->host); | |
6081 | len = 17 - len; | |
6082 | if (len < 1) | |
856ca177 MS |
6083 | { |
6084 | if (!use_json) | |
6085 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); | |
6086 | } | |
718e3744 | 6087 | else |
856ca177 MS |
6088 | { |
6089 | if (use_json) | |
6090 | json_object_int_add(json, "peerHost", len); | |
6091 | else | |
6092 | vty_out (vty, "%*s", len, " "); | |
6093 | } | |
718e3744 | 6094 | |
856ca177 MS |
6095 | if (use_json) |
6096 | bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json); | |
6097 | else | |
6098 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json)); | |
718e3744 | 6099 | |
6100 | /* Print attribute */ | |
6101 | attr = binfo->attr; | |
6102 | if (attr) | |
6103 | { | |
6104 | /* Print aspath */ | |
6105 | if (attr->aspath) | |
856ca177 MS |
6106 | { |
6107 | if (use_json) | |
6108 | json_object_string_add(json, "asPath", attr->aspath->str); | |
6109 | else | |
6110 | aspath_print_vty (vty, "%s", attr->aspath, " "); | |
6111 | } | |
718e3744 | 6112 | |
6113 | /* Print origin */ | |
856ca177 MS |
6114 | if (use_json) |
6115 | json_object_string_add(json, "origin", bgp_origin_str[attr->origin]); | |
6116 | else | |
6117 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
718e3744 | 6118 | } |
856ca177 MS |
6119 | if (!use_json) |
6120 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6121 | } |
6122 | ||
718e3744 | 6123 | /* flap route */ |
5a646650 | 6124 | static void |
856ca177 MS |
6125 | flap_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, |
6126 | int display, safi_t safi, u_char use_json, json_object *json) | |
718e3744 | 6127 | { |
6128 | struct attr *attr; | |
6129 | struct bgp_damp_info *bdi; | |
718e3744 | 6130 | char timebuf[BGP_UPTIME_LEN]; |
6131 | int len; | |
fb982c25 PJ |
6132 | |
6133 | if (!binfo->extra) | |
6134 | return; | |
6135 | ||
6136 | bdi = binfo->extra->damp_info; | |
718e3744 | 6137 | |
b40d939b | 6138 | /* short status lead text */ |
856ca177 | 6139 | route_vty_short_status_out (vty, binfo, json); |
b40d939b | 6140 | |
718e3744 | 6141 | /* print prefix and mask */ |
856ca177 MS |
6142 | if (!use_json) |
6143 | { | |
6144 | if (! display) | |
6145 | route_vty_out_route (p, vty); | |
6146 | else | |
6147 | vty_out (vty, "%*s", 17, " "); | |
6148 | } | |
718e3744 | 6149 | |
6150 | len = vty_out (vty, "%s", binfo->peer->host); | |
6151 | len = 16 - len; | |
6152 | if (len < 1) | |
856ca177 MS |
6153 | { |
6154 | if (!use_json) | |
6155 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); | |
6156 | } | |
718e3744 | 6157 | else |
856ca177 MS |
6158 | { |
6159 | if (use_json) | |
6160 | json_object_int_add(json, "peerHost", len); | |
6161 | else | |
6162 | vty_out (vty, "%*s", len, " "); | |
6163 | } | |
718e3744 | 6164 | |
6165 | len = vty_out (vty, "%d", bdi->flap); | |
6166 | len = 5 - len; | |
6167 | if (len < 1) | |
856ca177 MS |
6168 | { |
6169 | if (!use_json) | |
6170 | vty_out (vty, " "); | |
6171 | } | |
718e3744 | 6172 | else |
856ca177 MS |
6173 | { |
6174 | if (use_json) | |
6175 | json_object_int_add(json, "bdiFlap", len); | |
6176 | else | |
6177 | vty_out (vty, "%*s", len, " "); | |
6178 | } | |
6179 | ||
6180 | if (use_json) | |
6181 | peer_uptime (bdi->start_time, timebuf, BGP_UPTIME_LEN, use_json, json); | |
6182 | else | |
6183 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, | |
6184 | timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
718e3744 | 6185 | |
6186 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) | |
6187 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
856ca177 MS |
6188 | { |
6189 | if (use_json) | |
6190 | bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json); | |
6191 | else | |
6192 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json)); | |
6193 | } | |
718e3744 | 6194 | else |
856ca177 MS |
6195 | { |
6196 | if (!use_json) | |
6197 | vty_out (vty, "%*s ", 8, " "); | |
6198 | } | |
718e3744 | 6199 | |
6200 | /* Print attribute */ | |
6201 | attr = binfo->attr; | |
6202 | if (attr) | |
6203 | { | |
6204 | /* Print aspath */ | |
6205 | if (attr->aspath) | |
856ca177 MS |
6206 | { |
6207 | if (use_json) | |
6208 | json_object_string_add(json, "asPath", attr->aspath->str); | |
6209 | else | |
6210 | aspath_print_vty (vty, "%s", attr->aspath, " "); | |
6211 | } | |
718e3744 | 6212 | |
6213 | /* Print origin */ | |
856ca177 MS |
6214 | if (use_json) |
6215 | json_object_string_add(json, "origin", bgp_origin_str[attr->origin]); | |
6216 | else | |
6217 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
718e3744 | 6218 | } |
856ca177 MS |
6219 | if (!use_json) |
6220 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6221 | } |
6222 | ||
adbac85e DW |
6223 | static void |
6224 | route_vty_out_advertised_to (struct vty *vty, struct peer *peer, int *first, | |
6225 | const char *header, json_object *json_adv_to) | |
6226 | { | |
6227 | char buf1[INET6_ADDRSTRLEN]; | |
6228 | json_object *json_peer = NULL; | |
6229 | ||
6230 | if (json_adv_to) | |
6231 | { | |
6232 | /* 'advertised-to' is a dictionary of peers we have advertised this | |
6233 | * prefix too. The key is the peer's IP or swpX, the value is the | |
6234 | * hostname if we know it and "" if not. | |
6235 | */ | |
6236 | json_peer = json_object_new_object(); | |
6237 | ||
6238 | if (peer->hostname) | |
6239 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6240 | ||
6241 | if (peer->conf_if) | |
6242 | json_object_object_add(json_adv_to, peer->conf_if, json_peer); | |
6243 | else | |
6244 | json_object_object_add(json_adv_to, | |
6245 | sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN), | |
6246 | json_peer); | |
6247 | } | |
6248 | else | |
6249 | { | |
6250 | if (*first) | |
6251 | { | |
6252 | vty_out (vty, "%s", header); | |
6253 | *first = 0; | |
6254 | } | |
6255 | ||
6256 | if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6257 | { | |
6258 | if (peer->conf_if) | |
6259 | vty_out (vty, " %s(%s)", peer->hostname, peer->conf_if); | |
6260 | else | |
6261 | vty_out (vty, " %s(%s)", peer->hostname, | |
6262 | sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6263 | } | |
6264 | else | |
6265 | { | |
6266 | if (peer->conf_if) | |
6267 | vty_out (vty, " %s", peer->conf_if); | |
6268 | else | |
6269 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6270 | } | |
6271 | } | |
6272 | } | |
6273 | ||
94f2b392 | 6274 | static void |
718e3744 | 6275 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
b05a1c8b DS |
6276 | struct bgp_info *binfo, afi_t afi, safi_t safi, |
6277 | json_object *json_paths) | |
718e3744 | 6278 | { |
6279 | char buf[INET6_ADDRSTRLEN]; | |
6280 | char buf1[BUFSIZ]; | |
6281 | struct attr *attr; | |
6282 | int sockunion_vty_out (struct vty *, union sockunion *); | |
30b00176 JK |
6283 | #ifdef HAVE_CLOCK_MONOTONIC |
6284 | time_t tbuf; | |
6285 | #endif | |
f1aa5d8a | 6286 | json_object *json_bestpath = NULL; |
ffd0c037 | 6287 | json_object *json_cluster_list = NULL; |
f1aa5d8a DS |
6288 | json_object *json_cluster_list_list = NULL; |
6289 | json_object *json_ext_community = NULL; | |
6290 | json_object *json_last_update = NULL; | |
6291 | json_object *json_nexthop_global = NULL; | |
6292 | json_object *json_nexthop_ll = NULL; | |
6293 | json_object *json_nexthops = NULL; | |
6294 | json_object *json_path = NULL; | |
6295 | json_object *json_peer = NULL; | |
6296 | json_object *json_string = NULL; | |
adbac85e DW |
6297 | json_object *json_adv_to = NULL; |
6298 | int first = 0; | |
6299 | struct listnode *node, *nnode; | |
6300 | struct peer *peer; | |
6301 | int addpath_capable; | |
6302 | int has_adj; | |
06370dac | 6303 | int first_as; |
b05a1c8b DS |
6304 | |
6305 | if (json_paths) | |
6306 | { | |
6307 | json_path = json_object_new_object(); | |
f1aa5d8a DS |
6308 | json_peer = json_object_new_object(); |
6309 | json_nexthop_global = json_object_new_object(); | |
b05a1c8b DS |
6310 | } |
6311 | ||
718e3744 | 6312 | attr = binfo->attr; |
6313 | ||
6314 | if (attr) | |
6315 | { | |
6316 | /* Line1 display AS-path, Aggregator */ | |
6317 | if (attr->aspath) | |
6318 | { | |
f1aa5d8a DS |
6319 | if (json_paths) |
6320 | { | |
6321 | json_object_lock(attr->aspath->json); | |
6322 | json_object_object_add(json_path, "aspath", attr->aspath->json); | |
6323 | } | |
6324 | else | |
b05a1c8b | 6325 | { |
f1aa5d8a DS |
6326 | if (attr->aspath->segments) |
6327 | aspath_print_vty (vty, " %s", attr->aspath, ""); | |
b05a1c8b | 6328 | else |
f1aa5d8a | 6329 | vty_out (vty, " Local"); |
b05a1c8b | 6330 | } |
718e3744 | 6331 | } |
6332 | ||
b40d939b | 6333 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
b05a1c8b DS |
6334 | { |
6335 | if (json_paths) | |
f1aa5d8a | 6336 | json_object_boolean_true_add(json_path, "removed"); |
b05a1c8b DS |
6337 | else |
6338 | vty_out (vty, ", (removed)"); | |
6339 | } | |
6340 | ||
93406d87 | 6341 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
b05a1c8b DS |
6342 | { |
6343 | if (json_paths) | |
f1aa5d8a | 6344 | json_object_boolean_true_add(json_path, "stale"); |
b05a1c8b DS |
6345 | else |
6346 | vty_out (vty, ", (stale)"); | |
6347 | } | |
6348 | ||
93406d87 | 6349 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
b05a1c8b DS |
6350 | { |
6351 | if (json_paths) | |
6352 | { | |
62d6dca0 DS |
6353 | json_object_int_add(json_path, "aggregatorAs", attr->extra->aggregator_as); |
6354 | json_object_string_add(json_path, "aggregatorId", inet_ntoa (attr->extra->aggregator_addr)); | |
b05a1c8b DS |
6355 | } |
6356 | else | |
6357 | { | |
6358 | vty_out (vty, ", (aggregated by %u %s)", | |
6359 | attr->extra->aggregator_as, | |
6360 | inet_ntoa (attr->extra->aggregator_addr)); | |
6361 | } | |
6362 | } | |
6363 | ||
93406d87 | 6364 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
b05a1c8b DS |
6365 | { |
6366 | if (json_paths) | |
62d6dca0 | 6367 | json_object_boolean_true_add(json_path, "rxedFromRrClient"); |
b05a1c8b DS |
6368 | else |
6369 | vty_out (vty, ", (Received from a RR-client)"); | |
6370 | } | |
6371 | ||
93406d87 | 6372 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
b05a1c8b DS |
6373 | { |
6374 | if (json_paths) | |
62d6dca0 | 6375 | json_object_boolean_true_add(json_path, "rxedFromRsClient"); |
b05a1c8b DS |
6376 | else |
6377 | vty_out (vty, ", (Received from a RS-client)"); | |
6378 | } | |
6379 | ||
93406d87 | 6380 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
b05a1c8b DS |
6381 | { |
6382 | if (json_paths) | |
62d6dca0 | 6383 | json_object_boolean_true_add(json_path, "dampeningHistoryEntry"); |
b05a1c8b DS |
6384 | else |
6385 | vty_out (vty, ", (history entry)"); | |
6386 | } | |
93406d87 | 6387 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
b05a1c8b DS |
6388 | { |
6389 | if (json_paths) | |
62d6dca0 | 6390 | json_object_boolean_true_add(json_path, "dampeningSuppressed"); |
b05a1c8b DS |
6391 | else |
6392 | vty_out (vty, ", (suppressed due to dampening)"); | |
6393 | } | |
6394 | ||
6395 | if (!json_paths) | |
6396 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6397 | |
6398 | /* Line2 display Next-hop, Neighbor, Router-id */ | |
f1aa5d8a | 6399 | /* Display the nexthop */ |
8a92a8a0 DS |
6400 | if (p->family == AF_INET |
6401 | && (safi == SAFI_MPLS_VPN || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
718e3744 | 6402 | { |
b05a1c8b DS |
6403 | if (safi == SAFI_MPLS_VPN) |
6404 | { | |
6405 | if (json_paths) | |
f1aa5d8a | 6406 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->extra->mp_nexthop_global_in)); |
b05a1c8b DS |
6407 | else |
6408 | vty_out (vty, " %s", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
6409 | } | |
6410 | else | |
6411 | { | |
6412 | if (json_paths) | |
f1aa5d8a | 6413 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->nexthop)); |
b05a1c8b DS |
6414 | else |
6415 | vty_out (vty, " %s", inet_ntoa (attr->nexthop)); | |
6416 | } | |
6417 | ||
6418 | if (json_paths) | |
f1aa5d8a | 6419 | json_object_string_add(json_nexthop_global, "afi", "ipv4"); |
718e3744 | 6420 | } |
6421 | #ifdef HAVE_IPV6 | |
6422 | else | |
6423 | { | |
fb982c25 | 6424 | assert (attr->extra); |
b05a1c8b DS |
6425 | if (json_paths) |
6426 | { | |
f1aa5d8a DS |
6427 | json_object_string_add(json_nexthop_global, "ip", |
6428 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6429 | buf, INET6_ADDRSTRLEN)); | |
6430 | json_object_string_add(json_nexthop_global, "afi", "ipv6"); | |
6431 | json_object_string_add(json_nexthop_global, "scope", "global"); | |
b05a1c8b DS |
6432 | } |
6433 | else | |
6434 | { | |
6435 | vty_out (vty, " %s", | |
6436 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6437 | buf, INET6_ADDRSTRLEN)); | |
6438 | } | |
718e3744 | 6439 | } |
6440 | #endif /* HAVE_IPV6 */ | |
6441 | ||
b05a1c8b | 6442 | |
f1aa5d8a DS |
6443 | /* Display the IGP cost or 'inaccessible' */ |
6444 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) | |
6445 | { | |
6446 | if (json_paths) | |
6447 | json_object_boolean_false_add(json_nexthop_global, "accessible"); | |
6448 | else | |
6449 | vty_out (vty, " (inaccessible)"); | |
6450 | } | |
6451 | else | |
6452 | { | |
6453 | if (binfo->extra && binfo->extra->igpmetric) | |
b05a1c8b DS |
6454 | { |
6455 | if (json_paths) | |
f1aa5d8a | 6456 | json_object_int_add(json_nexthop_global, "metric", binfo->extra->igpmetric); |
b05a1c8b | 6457 | else |
f1aa5d8a | 6458 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
b05a1c8b | 6459 | } |
f1aa5d8a DS |
6460 | |
6461 | /* IGP cost is 0, display this only for json */ | |
b05a1c8b DS |
6462 | else |
6463 | { | |
6464 | if (json_paths) | |
f1aa5d8a | 6465 | json_object_int_add(json_nexthop_global, "metric", 0); |
b05a1c8b DS |
6466 | } |
6467 | ||
6468 | if (json_paths) | |
f1aa5d8a DS |
6469 | json_object_boolean_true_add(json_nexthop_global, "accessible"); |
6470 | } | |
6471 | ||
6472 | /* Display peer "from" output */ | |
6473 | /* This path was originated locally */ | |
6474 | if (binfo->peer == bgp->peer_self) | |
718e3744 | 6475 | { |
f1aa5d8a DS |
6476 | |
6477 | if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) | |
b05a1c8b DS |
6478 | { |
6479 | if (json_paths) | |
62d6dca0 | 6480 | json_object_string_add(json_peer, "peerId", "0.0.0.0"); |
b05a1c8b | 6481 | else |
f1aa5d8a | 6482 | vty_out (vty, " from 0.0.0.0 "); |
b05a1c8b | 6483 | } |
f1aa5d8a | 6484 | else |
b05a1c8b DS |
6485 | { |
6486 | if (json_paths) | |
62d6dca0 | 6487 | json_object_string_add(json_peer, "peerId", "::"); |
b05a1c8b | 6488 | else |
f1aa5d8a | 6489 | vty_out (vty, " from :: "); |
b05a1c8b DS |
6490 | } |
6491 | ||
f1aa5d8a | 6492 | if (json_paths) |
62d6dca0 | 6493 | json_object_string_add(json_peer, "routerId", inet_ntoa(bgp->router_id)); |
b05a1c8b | 6494 | else |
f1aa5d8a DS |
6495 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
6496 | } | |
6497 | ||
6498 | /* We RXed this path from one of our peers */ | |
6499 | else | |
6500 | { | |
b05a1c8b DS |
6501 | |
6502 | if (json_paths) | |
6503 | { | |
62d6dca0 DS |
6504 | json_object_string_add(json_peer, "peerId", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
6505 | json_object_string_add(json_peer, "routerId", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
f1aa5d8a | 6506 | |
04b6bdc0 DW |
6507 | if (binfo->peer->hostname) |
6508 | json_object_string_add(json_peer, "hostname", binfo->peer->hostname); | |
6509 | ||
6510 | if (binfo->peer->domainname) | |
6511 | json_object_string_add(json_peer, "domainname", binfo->peer->domainname); | |
6512 | ||
036a4e7d | 6513 | if (binfo->peer->conf_if) |
f1aa5d8a | 6514 | json_object_string_add(json_peer, "interface", binfo->peer->conf_if); |
b05a1c8b DS |
6515 | } |
6516 | else | |
6517 | { | |
036a4e7d | 6518 | if (binfo->peer->conf_if) |
04b6bdc0 DW |
6519 | { |
6520 | if (binfo->peer->hostname && | |
6521 | bgp_flag_check(binfo->peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6522 | vty_out (vty, " from %s(%s)", binfo->peer->hostname, | |
6523 | binfo->peer->conf_if); | |
6524 | else | |
6525 | vty_out (vty, " from %s", binfo->peer->conf_if); | |
6526 | } | |
036a4e7d | 6527 | else |
04b6bdc0 DW |
6528 | { |
6529 | if (binfo->peer->hostname && | |
6530 | bgp_flag_check(binfo->peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6531 | vty_out (vty, " from %s(%s)", binfo->peer->hostname, | |
6532 | binfo->peer->host); | |
6533 | else | |
6534 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); | |
6535 | } | |
b05a1c8b | 6536 | |
f1aa5d8a DS |
6537 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
6538 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); | |
6539 | else | |
6540 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
b05a1c8b | 6541 | } |
718e3744 | 6542 | } |
b05a1c8b DS |
6543 | |
6544 | if (!json_paths) | |
6545 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6546 | |
6547 | #ifdef HAVE_IPV6 | |
f1aa5d8a | 6548 | /* display the link-local nexthop */ |
801a9bcc | 6549 | if (attr->extra && attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) |
718e3744 | 6550 | { |
b05a1c8b DS |
6551 | if (json_paths) |
6552 | { | |
f1aa5d8a DS |
6553 | json_nexthop_ll = json_object_new_object(); |
6554 | json_object_string_add(json_nexthop_ll, "ip", | |
6555 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
6556 | buf, INET6_ADDRSTRLEN)); | |
6557 | json_object_string_add(json_nexthop_ll, "afi", "ipv6"); | |
6558 | json_object_string_add(json_nexthop_ll, "scope", "link-local"); | |
6559 | ||
6560 | json_object_boolean_true_add(json_nexthop_ll, "accessible"); | |
6561 | json_object_boolean_true_add(json_nexthop_ll, "used"); | |
b05a1c8b DS |
6562 | } |
6563 | else | |
6564 | { | |
356b3294 | 6565 | vty_out (vty, " (%s) (used)%s", |
b05a1c8b DS |
6566 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
6567 | buf, INET6_ADDRSTRLEN), | |
6568 | VTY_NEWLINE); | |
6569 | } | |
718e3744 | 6570 | } |
f1aa5d8a DS |
6571 | /* If we do not have a link-local nexthop then we must flag the global as "used" */ |
6572 | else | |
6573 | { | |
6574 | if (json_paths) | |
6575 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
6576 | } | |
718e3744 | 6577 | #endif /* HAVE_IPV6 */ |
6578 | ||
0d9551dc | 6579 | /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */ |
b05a1c8b | 6580 | if (json_paths) |
f1aa5d8a | 6581 | json_object_string_add(json_path, "origin", bgp_origin_long_str[attr->origin]); |
b05a1c8b | 6582 | else |
f1aa5d8a | 6583 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
718e3744 | 6584 | |
6585 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) | |
b05a1c8b DS |
6586 | { |
6587 | if (json_paths) | |
f1aa5d8a | 6588 | json_object_int_add(json_path, "med", attr->med); |
b05a1c8b | 6589 | else |
f1aa5d8a | 6590 | vty_out (vty, ", metric %u", attr->med); |
b05a1c8b | 6591 | } |
718e3744 | 6592 | |
6593 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) | |
b05a1c8b DS |
6594 | { |
6595 | if (json_paths) | |
f1aa5d8a | 6596 | json_object_int_add(json_path, "localpref", attr->local_pref); |
b05a1c8b | 6597 | else |
f1aa5d8a | 6598 | vty_out (vty, ", localpref %u", attr->local_pref); |
b05a1c8b | 6599 | } |
718e3744 | 6600 | else |
b05a1c8b DS |
6601 | { |
6602 | if (json_paths) | |
f1aa5d8a | 6603 | json_object_int_add(json_path, "localpref", bgp->default_local_pref); |
b05a1c8b | 6604 | else |
f1aa5d8a | 6605 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
b05a1c8b | 6606 | } |
718e3744 | 6607 | |
fb982c25 | 6608 | if (attr->extra && attr->extra->weight != 0) |
b05a1c8b DS |
6609 | { |
6610 | if (json_paths) | |
f1aa5d8a | 6611 | json_object_int_add(json_path, "weight", attr->extra->weight); |
b05a1c8b | 6612 | else |
f1aa5d8a | 6613 | vty_out (vty, ", weight %u", attr->extra->weight); |
b05a1c8b | 6614 | } |
0d9551dc DS |
6615 | |
6616 | if (attr->extra && attr->extra->tag != 0) | |
b05a1c8b DS |
6617 | { |
6618 | if (json_paths) | |
f1aa5d8a | 6619 | json_object_int_add(json_path, "tag", attr->extra->tag); |
b05a1c8b | 6620 | else |
f1aa5d8a | 6621 | vty_out (vty, ", tag %d", attr->extra->tag); |
b05a1c8b | 6622 | } |
718e3744 | 6623 | |
31eba040 | 6624 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
b05a1c8b DS |
6625 | { |
6626 | if (json_paths) | |
f1aa5d8a | 6627 | json_object_boolean_false_add(json_path, "valid"); |
b05a1c8b DS |
6628 | else |
6629 | vty_out (vty, ", invalid"); | |
6630 | } | |
31eba040 | 6631 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
b05a1c8b DS |
6632 | { |
6633 | if (json_paths) | |
f1aa5d8a | 6634 | json_object_boolean_true_add(json_path, "valid"); |
b05a1c8b DS |
6635 | else |
6636 | vty_out (vty, ", valid"); | |
6637 | } | |
718e3744 | 6638 | |
6639 | if (binfo->peer != bgp->peer_self) | |
6640 | { | |
f1aa5d8a | 6641 | if (binfo->peer->as == binfo->peer->local_as) |
b05a1c8b | 6642 | { |
66b199b2 DS |
6643 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
6644 | { | |
6645 | if (json_paths) | |
f1aa5d8a | 6646 | json_object_string_add(json_peer, "type", "confed-internal"); |
66b199b2 | 6647 | else |
f1aa5d8a | 6648 | vty_out (vty, ", confed-internal"); |
66b199b2 | 6649 | } |
b05a1c8b | 6650 | else |
66b199b2 DS |
6651 | { |
6652 | if (json_paths) | |
f1aa5d8a | 6653 | json_object_string_add(json_peer, "type", "internal"); |
66b199b2 | 6654 | else |
f1aa5d8a | 6655 | vty_out (vty, ", internal"); |
66b199b2 | 6656 | } |
b05a1c8b | 6657 | } |
f1aa5d8a | 6658 | else |
b05a1c8b DS |
6659 | { |
6660 | if (bgp_confederation_peers_check(bgp, binfo->peer->as)) | |
6661 | { | |
6662 | if (json_paths) | |
f1aa5d8a | 6663 | json_object_string_add(json_peer, "type", "confed-external"); |
b05a1c8b | 6664 | else |
f1aa5d8a | 6665 | vty_out (vty, ", confed-external"); |
b05a1c8b DS |
6666 | } |
6667 | else | |
6668 | { | |
6669 | if (json_paths) | |
f1aa5d8a | 6670 | json_object_string_add(json_peer, "type", "external"); |
b05a1c8b | 6671 | else |
f1aa5d8a | 6672 | vty_out (vty, ", external"); |
b05a1c8b DS |
6673 | } |
6674 | } | |
718e3744 | 6675 | } |
6676 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) | |
b05a1c8b DS |
6677 | { |
6678 | if (json_paths) | |
6679 | { | |
f1aa5d8a DS |
6680 | json_object_boolean_true_add(json_path, "aggregated"); |
6681 | json_object_boolean_true_add(json_path, "local"); | |
b05a1c8b DS |
6682 | } |
6683 | else | |
6684 | { | |
6685 | vty_out (vty, ", aggregated, local"); | |
6686 | } | |
6687 | } | |
718e3744 | 6688 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
b05a1c8b DS |
6689 | { |
6690 | if (json_paths) | |
f1aa5d8a | 6691 | json_object_boolean_true_add(json_path, "sourced"); |
b05a1c8b DS |
6692 | else |
6693 | vty_out (vty, ", sourced"); | |
6694 | } | |
718e3744 | 6695 | else |
b05a1c8b DS |
6696 | { |
6697 | if (json_paths) | |
6698 | { | |
f1aa5d8a DS |
6699 | json_object_boolean_true_add(json_path, "sourced"); |
6700 | json_object_boolean_true_add(json_path, "local"); | |
b05a1c8b DS |
6701 | } |
6702 | else | |
6703 | { | |
6704 | vty_out (vty, ", sourced, local"); | |
6705 | } | |
6706 | } | |
718e3744 | 6707 | |
6708 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) | |
b05a1c8b DS |
6709 | { |
6710 | if (json_paths) | |
62d6dca0 | 6711 | json_object_boolean_true_add(json_path, "atomicAggregate"); |
b05a1c8b DS |
6712 | else |
6713 | vty_out (vty, ", atomic-aggregate"); | |
6714 | } | |
718e3744 | 6715 | |
de8d5dff JB |
6716 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
6717 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && | |
6718 | bgp_info_mpath_count (binfo))) | |
b05a1c8b DS |
6719 | { |
6720 | if (json_paths) | |
f1aa5d8a | 6721 | json_object_boolean_true_add(json_path, "multipath"); |
b05a1c8b DS |
6722 | else |
6723 | vty_out (vty, ", multipath"); | |
6724 | } | |
de8d5dff | 6725 | |
06370dac DW |
6726 | // Mark the bestpath(s) |
6727 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DMED_SELECTED)) | |
6728 | { | |
6729 | first_as = aspath_get_firstas(attr->aspath); | |
6730 | ||
6731 | if (json_paths) | |
6732 | { | |
6733 | if (!json_bestpath) | |
6734 | json_bestpath = json_object_new_object(); | |
6735 | json_object_int_add(json_bestpath, "bestpathFromAs", first_as); | |
6736 | } | |
6737 | else | |
6738 | { | |
6739 | if (first_as) | |
6740 | vty_out (vty, ", bestpath-from-AS %d", first_as); | |
6741 | else | |
6742 | vty_out (vty, ", bestpath-from-AS Local"); | |
6743 | } | |
6744 | } | |
6745 | ||
718e3744 | 6746 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
b05a1c8b DS |
6747 | { |
6748 | if (json_paths) | |
f1aa5d8a | 6749 | { |
06370dac DW |
6750 | if (!json_bestpath) |
6751 | json_bestpath = json_object_new_object(); | |
f1aa5d8a | 6752 | json_object_boolean_true_add(json_bestpath, "overall"); |
f1aa5d8a | 6753 | } |
b05a1c8b DS |
6754 | else |
6755 | vty_out (vty, ", best"); | |
6756 | } | |
718e3744 | 6757 | |
06370dac DW |
6758 | if (json_bestpath) |
6759 | json_object_object_add(json_path, "bestpath", json_bestpath); | |
6760 | ||
b05a1c8b DS |
6761 | if (!json_paths) |
6762 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6763 | |
6764 | /* Line 4 display Community */ | |
6765 | if (attr->community) | |
b05a1c8b DS |
6766 | { |
6767 | if (json_paths) | |
6768 | { | |
f1aa5d8a DS |
6769 | json_object_lock(attr->community->json); |
6770 | json_object_object_add(json_path, "community", attr->community->json); | |
b05a1c8b DS |
6771 | } |
6772 | else | |
6773 | { | |
6774 | vty_out (vty, " Community: %s%s", attr->community->str, | |
6775 | VTY_NEWLINE); | |
6776 | } | |
6777 | } | |
718e3744 | 6778 | |
6779 | /* Line 5 display Extended-community */ | |
6780 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) | |
b05a1c8b DS |
6781 | { |
6782 | if (json_paths) | |
6783 | { | |
f1aa5d8a DS |
6784 | json_ext_community = json_object_new_object(); |
6785 | json_object_string_add(json_ext_community, "string", attr->extra->ecommunity->str); | |
62d6dca0 | 6786 | json_object_object_add(json_path, "extendedCommunity", json_ext_community); |
b05a1c8b DS |
6787 | } |
6788 | else | |
6789 | { | |
6790 | vty_out (vty, " Extended Community: %s%s", | |
6791 | attr->extra->ecommunity->str, VTY_NEWLINE); | |
6792 | } | |
6793 | } | |
6794 | ||
718e3744 | 6795 | /* Line 6 display Originator, Cluster-id */ |
6796 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || | |
6797 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) | |
6798 | { | |
fb982c25 | 6799 | assert (attr->extra); |
718e3744 | 6800 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
b05a1c8b DS |
6801 | { |
6802 | if (json_paths) | |
62d6dca0 | 6803 | json_object_string_add(json_path, "originatorId", inet_ntoa (attr->extra->originator_id)); |
b05a1c8b | 6804 | else |
f1aa5d8a DS |
6805 | vty_out (vty, " Originator: %s", |
6806 | inet_ntoa (attr->extra->originator_id)); | |
b05a1c8b | 6807 | } |
718e3744 | 6808 | |
6809 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
6810 | { | |
6811 | int i; | |
b05a1c8b DS |
6812 | |
6813 | if (json_paths) | |
6814 | { | |
f1aa5d8a DS |
6815 | json_cluster_list = json_object_new_object(); |
6816 | json_cluster_list_list = json_object_new_array(); | |
6817 | ||
b05a1c8b DS |
6818 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
6819 | { | |
6820 | json_string = json_object_new_string(inet_ntoa (attr->extra->cluster->list[i])); | |
f1aa5d8a | 6821 | json_object_array_add(json_cluster_list_list, json_string); |
b05a1c8b | 6822 | } |
f1aa5d8a DS |
6823 | |
6824 | /* struct cluster_list does not have "str" variable like | |
6825 | * aspath and community do. Add this someday if someone | |
6826 | * asks for it. | |
6827 | json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str); | |
6828 | */ | |
6829 | json_object_object_add(json_cluster_list, "list", json_cluster_list_list); | |
62d6dca0 | 6830 | json_object_object_add(json_path, "clusterList", json_cluster_list); |
b05a1c8b DS |
6831 | } |
6832 | else | |
6833 | { | |
6834 | vty_out (vty, ", Cluster list: "); | |
6835 | ||
6836 | for (i = 0; i < attr->extra->cluster->length / 4; i++) | |
6837 | { | |
6838 | vty_out (vty, "%s ", | |
6839 | inet_ntoa (attr->extra->cluster->list[i])); | |
6840 | } | |
6841 | } | |
718e3744 | 6842 | } |
b05a1c8b DS |
6843 | |
6844 | if (!json_paths) | |
6845 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6846 | } |
b05a1c8b | 6847 | |
fb982c25 | 6848 | if (binfo->extra && binfo->extra->damp_info) |
b05a1c8b | 6849 | bgp_damp_info_vty (vty, binfo, json_path); |
718e3744 | 6850 | |
a82478b9 DS |
6851 | /* Line 7 display Addpath IDs */ |
6852 | if (binfo->addpath_rx_id || binfo->addpath_tx_id) | |
b05a1c8b DS |
6853 | { |
6854 | if (json_paths) | |
6855 | { | |
62d6dca0 DS |
6856 | json_object_int_add(json_path, "addpathRxId", binfo->addpath_rx_id); |
6857 | json_object_int_add(json_path, "addpathTxId", binfo->addpath_tx_id); | |
b05a1c8b DS |
6858 | } |
6859 | else | |
6860 | { | |
6861 | vty_out (vty, " AddPath ID: RX %u, TX %u%s", | |
6862 | binfo->addpath_rx_id, binfo->addpath_tx_id, | |
6863 | VTY_NEWLINE); | |
6864 | } | |
6865 | } | |
a82478b9 | 6866 | |
adbac85e DW |
6867 | /* If we used addpath to TX a non-bestpath we need to display |
6868 | * "Advertised to" on a path-by-path basis */ | |
6869 | if (bgp->addpath_tx_used[afi][safi]) | |
6870 | { | |
6871 | first = 1; | |
6872 | ||
6873 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6874 | { | |
6875 | addpath_capable = bgp_addpath_encode_tx (peer, afi, safi); | |
6876 | has_adj = bgp_adj_out_lookup (peer, binfo->net, binfo->addpath_tx_id); | |
6877 | ||
6878 | if ((addpath_capable && has_adj) || | |
6879 | (!addpath_capable && has_adj && CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))) | |
6880 | { | |
6881 | if (json_path && !json_adv_to) | |
6882 | json_adv_to = json_object_new_object(); | |
6883 | ||
6884 | route_vty_out_advertised_to(vty, peer, &first, | |
6885 | " Advertised to:", | |
6886 | json_adv_to); | |
6887 | } | |
6888 | } | |
6889 | ||
6890 | if (json_path) | |
6891 | { | |
6892 | if (json_adv_to) | |
6893 | { | |
6894 | json_object_object_add(json_path, "advertisedTo", json_adv_to); | |
6895 | } | |
6896 | } | |
6897 | else | |
6898 | { | |
6899 | if (!first) | |
6900 | { | |
6901 | vty_out (vty, "%s", VTY_NEWLINE); | |
6902 | } | |
6903 | } | |
6904 | } | |
6905 | ||
a82478b9 | 6906 | /* Line 8 display Uptime */ |
30b00176 JK |
6907 | #ifdef HAVE_CLOCK_MONOTONIC |
6908 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); | |
b05a1c8b | 6909 | if (json_paths) |
f1aa5d8a DS |
6910 | { |
6911 | json_last_update = json_object_new_object(); | |
6912 | json_object_int_add(json_last_update, "epoch", tbuf); | |
6913 | json_object_string_add(json_last_update, "string", ctime(&tbuf)); | |
62d6dca0 | 6914 | json_object_object_add(json_path, "lastUpdate", json_last_update); |
f1aa5d8a | 6915 | } |
b05a1c8b DS |
6916 | else |
6917 | vty_out (vty, " Last update: %s", ctime(&tbuf)); | |
30b00176 | 6918 | #else |
b05a1c8b | 6919 | if (json_paths) |
f1aa5d8a DS |
6920 | { |
6921 | json_last_update = json_object_new_object(); | |
6922 | json_object_int_add(json_last_update, "epoch", tbuf); | |
6923 | json_object_string_add(json_last_update, "string", ctime(&binfo->uptime)); | |
62d6dca0 | 6924 | json_object_object_add(json_path, "lastUpdate", json_last_update); |
f1aa5d8a | 6925 | } |
b05a1c8b DS |
6926 | else |
6927 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); | |
30b00176 | 6928 | #endif /* HAVE_CLOCK_MONOTONIC */ |
718e3744 | 6929 | } |
b05a1c8b DS |
6930 | |
6931 | /* We've constructed the json object for this path, add it to the json | |
6932 | * array of paths | |
6933 | */ | |
6934 | if (json_paths) | |
f1aa5d8a DS |
6935 | { |
6936 | if (json_nexthop_global || json_nexthop_ll) | |
6937 | { | |
6938 | json_nexthops = json_object_new_array(); | |
6939 | ||
6940 | if (json_nexthop_global) | |
6941 | json_object_array_add(json_nexthops, json_nexthop_global); | |
6942 | ||
6943 | if (json_nexthop_ll) | |
6944 | json_object_array_add(json_nexthops, json_nexthop_ll); | |
6945 | ||
6946 | json_object_object_add(json_path, "nexthops", json_nexthops); | |
6947 | } | |
6948 | ||
6949 | json_object_object_add(json_path, "peer", json_peer); | |
6950 | json_object_array_add(json_paths, json_path); | |
6951 | } | |
b05a1c8b DS |
6952 | else |
6953 | vty_out (vty, "%s", VTY_NEWLINE); | |
b366b518 BB |
6954 | } |
6955 | ||
47fc97cc | 6956 | #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s" |
718e3744 | 6957 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
6958 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" | |
6959 | ||
6960 | enum bgp_show_type | |
6961 | { | |
6962 | bgp_show_type_normal, | |
6963 | bgp_show_type_regexp, | |
6964 | bgp_show_type_prefix_list, | |
6965 | bgp_show_type_filter_list, | |
6966 | bgp_show_type_route_map, | |
6967 | bgp_show_type_neighbor, | |
6968 | bgp_show_type_cidr_only, | |
6969 | bgp_show_type_prefix_longer, | |
6970 | bgp_show_type_community_all, | |
6971 | bgp_show_type_community, | |
6972 | bgp_show_type_community_exact, | |
6973 | bgp_show_type_community_list, | |
6974 | bgp_show_type_community_list_exact, | |
6975 | bgp_show_type_flap_statistics, | |
6976 | bgp_show_type_flap_address, | |
6977 | bgp_show_type_flap_prefix, | |
6978 | bgp_show_type_flap_cidr_only, | |
6979 | bgp_show_type_flap_regexp, | |
6980 | bgp_show_type_flap_filter_list, | |
6981 | bgp_show_type_flap_prefix_list, | |
6982 | bgp_show_type_flap_prefix_longer, | |
6983 | bgp_show_type_flap_route_map, | |
6984 | bgp_show_type_flap_neighbor, | |
6985 | bgp_show_type_dampend_paths, | |
6986 | bgp_show_type_damp_neighbor | |
6987 | }; | |
6988 | ||
50ef26d4 | 6989 | static int |
6990 | bgp_show_prefix_list (struct vty *vty, const char *name, | |
6991 | const char *prefix_list_str, afi_t afi, | |
6992 | safi_t safi, enum bgp_show_type type); | |
6993 | static int | |
6994 | bgp_show_filter_list (struct vty *vty, const char *name, | |
6995 | const char *filter, afi_t afi, | |
6996 | safi_t safi, enum bgp_show_type type); | |
6997 | static int | |
6998 | bgp_show_route_map (struct vty *vty, const char *name, | |
6999 | const char *rmap_str, afi_t afi, | |
7000 | safi_t safi, enum bgp_show_type type); | |
7001 | static int | |
7002 | bgp_show_community_list (struct vty *vty, const char *name, | |
7003 | const char *com, int exact, | |
7004 | afi_t afi, safi_t safi); | |
7005 | static int | |
7006 | bgp_show_prefix_longer (struct vty *vty, const char *name, | |
7007 | const char *prefix, afi_t afi, | |
7008 | safi_t safi, enum bgp_show_type type); | |
7009 | ||
5a646650 | 7010 | static int |
fee0f4c6 | 7011 | bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id, |
856ca177 | 7012 | enum bgp_show_type type, void *output_arg, u_char use_json) |
718e3744 | 7013 | { |
718e3744 | 7014 | struct bgp_info *ri; |
7015 | struct bgp_node *rn; | |
718e3744 | 7016 | int header = 1; |
718e3744 | 7017 | int display; |
5a646650 | 7018 | unsigned long output_count; |
b05a1c8b DS |
7019 | struct prefix *p; |
7020 | char buf[BUFSIZ]; | |
7021 | char buf2[BUFSIZ]; | |
f1aa5d8a DS |
7022 | json_object *json = NULL; |
7023 | json_object *json_paths = NULL; | |
7024 | json_object *json_routes = NULL; | |
b05a1c8b DS |
7025 | |
7026 | if (use_json) | |
7027 | { | |
7028 | json = json_object_new_object(); | |
62d6dca0 DS |
7029 | json_object_int_add(json, "tableVersion", table->version); |
7030 | json_object_string_add(json, "routerId", inet_ntoa (*router_id)); | |
b05a1c8b DS |
7031 | json_routes = json_object_new_object(); |
7032 | } | |
718e3744 | 7033 | |
7034 | /* This is first entry point, so reset total line. */ | |
5a646650 | 7035 | output_count = 0; |
718e3744 | 7036 | |
718e3744 | 7037 | /* Start processing of routes. */ |
7038 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
7039 | if (rn->info != NULL) | |
7040 | { | |
856ca177 | 7041 | display = 0; |
718e3744 | 7042 | |
b05a1c8b DS |
7043 | if (use_json) |
7044 | json_paths = json_object_new_array(); | |
7045 | else | |
7046 | json_paths = NULL; | |
7047 | ||
856ca177 MS |
7048 | for (ri = rn->info; ri; ri = ri->next) |
7049 | { | |
7050 | if (type == bgp_show_type_flap_statistics | |
7051 | || type == bgp_show_type_flap_address | |
7052 | || type == bgp_show_type_flap_prefix | |
7053 | || type == bgp_show_type_flap_cidr_only | |
7054 | || type == bgp_show_type_flap_regexp | |
7055 | || type == bgp_show_type_flap_filter_list | |
7056 | || type == bgp_show_type_flap_prefix_list | |
7057 | || type == bgp_show_type_flap_prefix_longer | |
7058 | || type == bgp_show_type_flap_route_map | |
7059 | || type == bgp_show_type_flap_neighbor | |
7060 | || type == bgp_show_type_dampend_paths | |
7061 | || type == bgp_show_type_damp_neighbor) | |
7062 | { | |
7063 | if (!(ri->extra && ri->extra->damp_info)) | |
7064 | continue; | |
7065 | } | |
7066 | if (type == bgp_show_type_regexp | |
7067 | || type == bgp_show_type_flap_regexp) | |
7068 | { | |
7069 | regex_t *regex = output_arg; | |
718e3744 | 7070 | |
856ca177 MS |
7071 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
7072 | continue; | |
7073 | } | |
7074 | if (type == bgp_show_type_prefix_list | |
7075 | || type == bgp_show_type_flap_prefix_list) | |
7076 | { | |
7077 | struct prefix_list *plist = output_arg; | |
718e3744 | 7078 | |
856ca177 MS |
7079 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
7080 | continue; | |
7081 | } | |
7082 | if (type == bgp_show_type_filter_list | |
7083 | || type == bgp_show_type_flap_filter_list) | |
7084 | { | |
7085 | struct as_list *as_list = output_arg; | |
558d1fec | 7086 | |
856ca177 MS |
7087 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
7088 | continue; | |
7089 | } | |
7090 | if (type == bgp_show_type_route_map | |
7091 | || type == bgp_show_type_flap_route_map) | |
7092 | { | |
7093 | struct route_map *rmap = output_arg; | |
7094 | struct bgp_info binfo; | |
7095 | struct attr dummy_attr; | |
7096 | struct attr_extra dummy_extra; | |
7097 | int ret; | |
718e3744 | 7098 | |
856ca177 MS |
7099 | dummy_attr.extra = &dummy_extra; |
7100 | bgp_attr_dup (&dummy_attr, ri->attr); | |
718e3744 | 7101 | |
856ca177 MS |
7102 | binfo.peer = ri->peer; |
7103 | binfo.attr = &dummy_attr; | |
718e3744 | 7104 | |
856ca177 MS |
7105 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
7106 | if (ret == RMAP_DENYMATCH) | |
7107 | continue; | |
7108 | } | |
7109 | if (type == bgp_show_type_neighbor | |
7110 | || type == bgp_show_type_flap_neighbor | |
7111 | || type == bgp_show_type_damp_neighbor) | |
7112 | { | |
7113 | union sockunion *su = output_arg; | |
718e3744 | 7114 | |
856ca177 MS |
7115 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
7116 | continue; | |
7117 | } | |
7118 | if (type == bgp_show_type_cidr_only | |
7119 | || type == bgp_show_type_flap_cidr_only) | |
7120 | { | |
7121 | u_int32_t destination; | |
718e3744 | 7122 | |
856ca177 MS |
7123 | destination = ntohl (rn->p.u.prefix4.s_addr); |
7124 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) | |
7125 | continue; | |
7126 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) | |
7127 | continue; | |
7128 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) | |
7129 | continue; | |
7130 | } | |
7131 | if (type == bgp_show_type_prefix_longer | |
7132 | || type == bgp_show_type_flap_prefix_longer) | |
7133 | { | |
7134 | struct prefix *p = output_arg; | |
718e3744 | 7135 | |
856ca177 MS |
7136 | if (! prefix_match (p, &rn->p)) |
7137 | continue; | |
7138 | } | |
7139 | if (type == bgp_show_type_community_all) | |
7140 | { | |
7141 | if (! ri->attr->community) | |
7142 | continue; | |
7143 | } | |
7144 | if (type == bgp_show_type_community) | |
7145 | { | |
7146 | struct community *com = output_arg; | |
718e3744 | 7147 | |
856ca177 MS |
7148 | if (! ri->attr->community || |
7149 | ! community_match (ri->attr->community, com)) | |
7150 | continue; | |
7151 | } | |
7152 | if (type == bgp_show_type_community_exact) | |
7153 | { | |
7154 | struct community *com = output_arg; | |
718e3744 | 7155 | |
856ca177 MS |
7156 | if (! ri->attr->community || |
7157 | ! community_cmp (ri->attr->community, com)) | |
7158 | continue; | |
7159 | } | |
7160 | if (type == bgp_show_type_community_list) | |
7161 | { | |
7162 | struct community_list *list = output_arg; | |
718e3744 | 7163 | |
856ca177 MS |
7164 | if (! community_list_match (ri->attr->community, list)) |
7165 | continue; | |
7166 | } | |
7167 | if (type == bgp_show_type_community_list_exact) | |
7168 | { | |
7169 | struct community_list *list = output_arg; | |
718e3744 | 7170 | |
856ca177 MS |
7171 | if (! community_list_exact_match (ri->attr->community, list)) |
7172 | continue; | |
7173 | } | |
7174 | if (type == bgp_show_type_flap_address | |
7175 | || type == bgp_show_type_flap_prefix) | |
7176 | { | |
7177 | struct prefix *p = output_arg; | |
718e3744 | 7178 | |
856ca177 MS |
7179 | if (! prefix_match (&rn->p, p)) |
7180 | continue; | |
b05a1c8b | 7181 | |
856ca177 MS |
7182 | if (type == bgp_show_type_flap_prefix) |
7183 | if (p->prefixlen != rn->p.prefixlen) | |
7184 | continue; | |
7185 | } | |
7186 | if (type == bgp_show_type_dampend_paths | |
7187 | || type == bgp_show_type_damp_neighbor) | |
7188 | { | |
7189 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) | |
7190 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
7191 | continue; | |
7192 | } | |
7193 | ||
7194 | if (!use_json && header) | |
7195 | { | |
7196 | vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (*router_id), VTY_NEWLINE); | |
7197 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
7198 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
7199 | if (type == bgp_show_type_dampend_paths | |
7200 | || type == bgp_show_type_damp_neighbor) | |
7201 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); | |
7202 | else if (type == bgp_show_type_flap_statistics | |
7203 | || type == bgp_show_type_flap_address | |
7204 | || type == bgp_show_type_flap_prefix | |
7205 | || type == bgp_show_type_flap_cidr_only | |
7206 | || type == bgp_show_type_flap_regexp | |
7207 | || type == bgp_show_type_flap_filter_list | |
7208 | || type == bgp_show_type_flap_prefix_list | |
7209 | || type == bgp_show_type_flap_prefix_longer | |
7210 | || type == bgp_show_type_flap_route_map | |
7211 | || type == bgp_show_type_flap_neighbor) | |
7212 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); | |
7213 | else | |
7214 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
7215 | header = 0; | |
7216 | } | |
7217 | ||
7218 | if (type == bgp_show_type_dampend_paths | |
7219 | || type == bgp_show_type_damp_neighbor) | |
7220 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); | |
7221 | else if (type == bgp_show_type_flap_statistics | |
7222 | || type == bgp_show_type_flap_address | |
7223 | || type == bgp_show_type_flap_prefix | |
7224 | || type == bgp_show_type_flap_cidr_only | |
7225 | || type == bgp_show_type_flap_regexp | |
7226 | || type == bgp_show_type_flap_filter_list | |
7227 | || type == bgp_show_type_flap_prefix_list | |
7228 | || type == bgp_show_type_flap_prefix_longer | |
7229 | || type == bgp_show_type_flap_route_map | |
7230 | || type == bgp_show_type_flap_neighbor) | |
7231 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); | |
7232 | else | |
7233 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, json_paths); | |
7234 | display++; | |
b05a1c8b DS |
7235 | } |
7236 | ||
856ca177 MS |
7237 | if (display) |
7238 | { | |
7239 | output_count++; | |
7240 | if (use_json) | |
7241 | { | |
7242 | p = &rn->p; | |
7243 | sprintf(buf2, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen); | |
7244 | json_object_object_add(json_routes, buf2, json_paths); | |
7245 | } | |
7246 | } | |
718e3744 | 7247 | } |
7248 | ||
b05a1c8b | 7249 | if (use_json) |
718e3744 | 7250 | { |
d1d16a96 | 7251 | json_object_object_add(json, "routes", json_routes); |
b05a1c8b | 7252 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); |
f1aa5d8a | 7253 | json_object_free(json); |
718e3744 | 7254 | } |
7255 | else | |
b05a1c8b DS |
7256 | { |
7257 | /* No route is displayed */ | |
7258 | if (output_count == 0) | |
7259 | { | |
7260 | if (type == bgp_show_type_normal) | |
856ca177 | 7261 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
b05a1c8b DS |
7262 | } |
7263 | else | |
7264 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
856ca177 | 7265 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
b05a1c8b | 7266 | } |
718e3744 | 7267 | |
7268 | return CMD_SUCCESS; | |
7269 | } | |
7270 | ||
5a646650 | 7271 | static int |
fee0f4c6 | 7272 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
856ca177 | 7273 | enum bgp_show_type type, void *output_arg, u_char use_json) |
fee0f4c6 | 7274 | { |
7275 | struct bgp_table *table; | |
7276 | ||
856ca177 MS |
7277 | if (bgp == NULL) |
7278 | { | |
7279 | bgp = bgp_get_default (); | |
7280 | } | |
fee0f4c6 | 7281 | |
7282 | if (bgp == NULL) | |
7283 | { | |
856ca177 MS |
7284 | if (!use_json) |
7285 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
fee0f4c6 | 7286 | return CMD_WARNING; |
7287 | } | |
7288 | ||
fee0f4c6 | 7289 | table = bgp->rib[afi][safi]; |
7290 | ||
b05a1c8b | 7291 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg, use_json); |
fee0f4c6 | 7292 | } |
7293 | ||
718e3744 | 7294 | /* Header of detailed BGP route information */ |
94f2b392 | 7295 | static void |
718e3744 | 7296 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
7297 | struct bgp_node *rn, | |
b05a1c8b DS |
7298 | struct prefix_rd *prd, afi_t afi, safi_t safi, |
7299 | json_object *json) | |
718e3744 | 7300 | { |
7301 | struct bgp_info *ri; | |
7302 | struct prefix *p; | |
7303 | struct peer *peer; | |
1eb8ef25 | 7304 | struct listnode *node, *nnode; |
718e3744 | 7305 | char buf1[INET6_ADDRSTRLEN]; |
7306 | char buf2[INET6_ADDRSTRLEN]; | |
7307 | int count = 0; | |
7308 | int best = 0; | |
7309 | int suppress = 0; | |
7310 | int no_export = 0; | |
7311 | int no_advertise = 0; | |
7312 | int local_as = 0; | |
adbac85e | 7313 | int first = 1; |
ffd0c037 | 7314 | json_object *json_adv_to = NULL; |
718e3744 | 7315 | |
7316 | p = &rn->p; | |
b05a1c8b DS |
7317 | |
7318 | if (json) | |
7319 | { | |
f1aa5d8a DS |
7320 | json_object_string_add(json, "prefix", inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN)); |
7321 | json_object_int_add(json, "prefixlen", p->prefixlen); | |
b05a1c8b DS |
7322 | } |
7323 | else | |
7324 | { | |
7325 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", | |
7326 | (safi == SAFI_MPLS_VPN ? | |
7327 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), | |
7328 | safi == SAFI_MPLS_VPN ? ":" : "", | |
7329 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), | |
7330 | p->prefixlen, VTY_NEWLINE); | |
7331 | } | |
718e3744 | 7332 | |
7333 | for (ri = rn->info; ri; ri = ri->next) | |
7334 | { | |
7335 | count++; | |
7336 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
7337 | { | |
7338 | best = count; | |
fb982c25 | 7339 | if (ri->extra && ri->extra->suppress) |
718e3744 | 7340 | suppress = 1; |
7341 | if (ri->attr->community != NULL) | |
7342 | { | |
7343 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) | |
7344 | no_advertise = 1; | |
7345 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) | |
7346 | no_export = 1; | |
7347 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) | |
7348 | local_as = 1; | |
7349 | } | |
7350 | } | |
7351 | } | |
7352 | ||
b05a1c8b | 7353 | if (!json) |
718e3744 | 7354 | { |
b05a1c8b DS |
7355 | vty_out (vty, "Paths: (%d available", count); |
7356 | if (best) | |
7357 | { | |
7358 | vty_out (vty, ", best #%d", best); | |
7359 | if (safi == SAFI_UNICAST) | |
7360 | vty_out (vty, ", table Default-IP-Routing-Table"); | |
7361 | } | |
7362 | else | |
7363 | vty_out (vty, ", no best path"); | |
7364 | ||
7365 | if (no_advertise) | |
7366 | vty_out (vty, ", not advertised to any peer"); | |
7367 | else if (no_export) | |
7368 | vty_out (vty, ", not advertised to EBGP peer"); | |
7369 | else if (local_as) | |
7370 | vty_out (vty, ", not advertised outside local AS"); | |
7371 | ||
7372 | if (suppress) | |
7373 | vty_out (vty, ", Advertisements suppressed by an aggregate."); | |
7374 | vty_out (vty, ")%s", VTY_NEWLINE); | |
718e3744 | 7375 | } |
718e3744 | 7376 | |
adbac85e DW |
7377 | /* If we are not using addpath then we can display Advertised to and that will |
7378 | * show what peers we advertised the bestpath to. If we are using addpath | |
7379 | * though then we must display Advertised to on a path-by-path basis. */ | |
7380 | if (!bgp->addpath_tx_used[afi][safi]) | |
718e3744 | 7381 | { |
adbac85e DW |
7382 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
7383 | { | |
7384 | if (bgp_adj_out_lookup (peer, rn, 0)) | |
b05a1c8b | 7385 | { |
adbac85e | 7386 | if (json && !json_adv_to) |
f1aa5d8a | 7387 | json_adv_to = json_object_new_object(); |
6410e93a | 7388 | |
adbac85e DW |
7389 | route_vty_out_advertised_to(vty, peer, &first, |
7390 | " Advertised to non peer-group peers:\n ", | |
7391 | json_adv_to); | |
b05a1c8b | 7392 | } |
adbac85e | 7393 | } |
036a4e7d | 7394 | |
adbac85e DW |
7395 | if (json) |
7396 | { | |
7397 | if (json_adv_to) | |
7398 | { | |
7399 | json_object_object_add(json, "advertisedTo", json_adv_to); | |
b05a1c8b | 7400 | } |
adbac85e DW |
7401 | } |
7402 | else | |
b05a1c8b | 7403 | { |
adbac85e DW |
7404 | if (first) |
7405 | vty_out (vty, " Not advertised to any peer"); | |
7406 | vty_out (vty, "%s", VTY_NEWLINE); | |
b05a1c8b DS |
7407 | } |
7408 | } | |
718e3744 | 7409 | } |
7410 | ||
7411 | /* Display specified route of BGP table. */ | |
94f2b392 | 7412 | static int |
fee0f4c6 | 7413 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
fd79ac91 | 7414 | struct bgp_table *rib, const char *ip_str, |
7415 | afi_t afi, safi_t safi, struct prefix_rd *prd, | |
b05a1c8b DS |
7416 | int prefix_check, enum bgp_path_type pathtype, |
7417 | u_char use_json) | |
718e3744 | 7418 | { |
7419 | int ret; | |
7420 | int header; | |
7421 | int display = 0; | |
7422 | struct prefix match; | |
7423 | struct bgp_node *rn; | |
7424 | struct bgp_node *rm; | |
7425 | struct bgp_info *ri; | |
718e3744 | 7426 | struct bgp_table *table; |
f1aa5d8a DS |
7427 | json_object *json = NULL; |
7428 | json_object *json_paths = NULL; | |
718e3744 | 7429 | |
718e3744 | 7430 | /* Check IP address argument. */ |
7431 | ret = str2prefix (ip_str, &match); | |
7432 | if (! ret) | |
7433 | { | |
7434 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); | |
7435 | return CMD_WARNING; | |
7436 | } | |
7437 | ||
7438 | match.family = afi2family (afi); | |
7439 | ||
b05a1c8b DS |
7440 | if (use_json) |
7441 | { | |
7442 | json = json_object_new_object(); | |
7443 | json_paths = json_object_new_array(); | |
7444 | } | |
b05a1c8b | 7445 | |
718e3744 | 7446 | if (safi == SAFI_MPLS_VPN) |
7447 | { | |
fee0f4c6 | 7448 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
718e3744 | 7449 | { |
7450 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
7451 | continue; | |
7452 | ||
7453 | if ((table = rn->info) != NULL) | |
7454 | { | |
7455 | header = 1; | |
7456 | ||
7457 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
7458 | { | |
7459 | if (prefix_check && rm->p.prefixlen != match.prefixlen) | |
6c88b44d CC |
7460 | { |
7461 | bgp_unlock_node (rm); | |
7462 | continue; | |
7463 | } | |
718e3744 | 7464 | |
7465 | for (ri = rm->info; ri; ri = ri->next) | |
7466 | { | |
7467 | if (header) | |
7468 | { | |
7469 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, | |
b05a1c8b | 7470 | AFI_IP, SAFI_MPLS_VPN, json); |
718e3744 | 7471 | |
7472 | header = 0; | |
7473 | } | |
7474 | display++; | |
4092b06c DS |
7475 | |
7476 | if (pathtype == BGP_PATH_ALL || | |
7477 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || | |
7478 | (pathtype == BGP_PATH_MULTIPATH && | |
7479 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) | |
b05a1c8b | 7480 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN, json_paths); |
718e3744 | 7481 | } |
6c88b44d CC |
7482 | |
7483 | bgp_unlock_node (rm); | |
718e3744 | 7484 | } |
7485 | } | |
7486 | } | |
7487 | } | |
7488 | else | |
7489 | { | |
7490 | header = 1; | |
7491 | ||
fee0f4c6 | 7492 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
718e3744 | 7493 | { |
7494 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
7495 | { | |
7496 | for (ri = rn->info; ri; ri = ri->next) | |
7497 | { | |
7498 | if (header) | |
7499 | { | |
b05a1c8b | 7500 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi, json); |
718e3744 | 7501 | header = 0; |
7502 | } | |
7503 | display++; | |
4092b06c DS |
7504 | |
7505 | if (pathtype == BGP_PATH_ALL || | |
7506 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || | |
7507 | (pathtype == BGP_PATH_MULTIPATH && | |
7508 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) | |
b05a1c8b | 7509 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, json_paths); |
718e3744 | 7510 | } |
7511 | } | |
6c88b44d CC |
7512 | |
7513 | bgp_unlock_node (rn); | |
718e3744 | 7514 | } |
7515 | } | |
7516 | ||
e5eee9af | 7517 | if (use_json) |
718e3744 | 7518 | { |
e5eee9af DS |
7519 | if (display) |
7520 | json_object_object_add(json, "paths", json_paths); | |
7521 | ||
7522 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
f1aa5d8a | 7523 | json_object_free(json); |
b05a1c8b DS |
7524 | } |
7525 | else | |
7526 | { | |
e5eee9af | 7527 | if (!display) |
b05a1c8b DS |
7528 | { |
7529 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); | |
7530 | return CMD_WARNING; | |
7531 | } | |
7532 | } | |
7533 | ||
718e3744 | 7534 | return CMD_SUCCESS; |
7535 | } | |
7536 | ||
fee0f4c6 | 7537 | /* Display specified route of Main RIB */ |
94f2b392 | 7538 | static int |
fd79ac91 | 7539 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
fee0f4c6 | 7540 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
b05a1c8b DS |
7541 | int prefix_check, enum bgp_path_type pathtype, |
7542 | u_char use_json) | |
fee0f4c6 | 7543 | { |
7544 | struct bgp *bgp; | |
7545 | ||
7546 | /* BGP structure lookup. */ | |
7547 | if (view_name) | |
7548 | { | |
7549 | bgp = bgp_lookup_by_name (view_name); | |
7550 | if (bgp == NULL) | |
7551 | { | |
6aeb9e78 | 7552 | vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
fee0f4c6 | 7553 | return CMD_WARNING; |
7554 | } | |
7555 | } | |
7556 | else | |
7557 | { | |
7558 | bgp = bgp_get_default (); | |
7559 | if (bgp == NULL) | |
7560 | { | |
7561 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
7562 | return CMD_WARNING; | |
7563 | } | |
7564 | } | |
7565 | ||
7566 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, | |
b05a1c8b DS |
7567 | afi, safi, prd, prefix_check, pathtype, |
7568 | use_json); | |
fee0f4c6 | 7569 | } |
7570 | ||
718e3744 | 7571 | /* BGP route print out function. */ |
7572 | DEFUN (show_ip_bgp, | |
7573 | show_ip_bgp_cmd, | |
b05a1c8b | 7574 | "show ip bgp {json}", |
47fc97cc DS |
7575 | SHOW_STR |
7576 | IP_STR | |
b05a1c8b DS |
7577 | BGP_STR |
7578 | "JavaScript Object Notation\n") | |
47fc97cc | 7579 | { |
db7c8528 | 7580 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); |
718e3744 | 7581 | } |
7582 | ||
7583 | DEFUN (show_ip_bgp_ipv4, | |
7584 | show_ip_bgp_ipv4_cmd, | |
b05a1c8b | 7585 | "show ip bgp ipv4 (unicast|multicast) {json}", |
718e3744 | 7586 | SHOW_STR |
7587 | IP_STR | |
7588 | BGP_STR | |
7589 | "Address family\n" | |
7590 | "Address Family modifier\n" | |
b05a1c8b DS |
7591 | "Address Family modifier\n" |
7592 | "JavaScript Object Notation\n") | |
718e3744 | 7593 | { |
db7c8528 | 7594 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7595 | |
718e3744 | 7596 | if (strncmp (argv[0], "m", 1) == 0) |
5a646650 | 7597 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
db7c8528 | 7598 | NULL, uj); |
718e3744 | 7599 | |
db7c8528 | 7600 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); |
718e3744 | 7601 | } |
7602 | ||
95cbbd2a ML |
7603 | ALIAS (show_ip_bgp_ipv4, |
7604 | show_bgp_ipv4_safi_cmd, | |
b05a1c8b | 7605 | "show bgp ipv4 (unicast|multicast) {json}", |
95cbbd2a ML |
7606 | SHOW_STR |
7607 | BGP_STR | |
7608 | "Address family\n" | |
7609 | "Address Family modifier\n" | |
47fc97cc | 7610 | "Address Family modifier\n" |
b05a1c8b | 7611 | "JavaScript Object Notation\n") |
47fc97cc | 7612 | |
718e3744 | 7613 | DEFUN (show_ip_bgp_route, |
7614 | show_ip_bgp_route_cmd, | |
b05a1c8b | 7615 | "show ip bgp A.B.C.D {json}", |
718e3744 | 7616 | SHOW_STR |
7617 | IP_STR | |
7618 | BGP_STR | |
b05a1c8b DS |
7619 | "Network in the BGP routing table to display\n" |
7620 | "JavaScript Object Notation\n") | |
718e3744 | 7621 | { |
db7c8528 | 7622 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
4092b06c DS |
7623 | } |
7624 | ||
7625 | DEFUN (show_ip_bgp_route_pathtype, | |
7626 | show_ip_bgp_route_pathtype_cmd, | |
b05a1c8b | 7627 | "show ip bgp A.B.C.D (bestpath|multipath) {json}", |
4092b06c DS |
7628 | SHOW_STR |
7629 | IP_STR | |
7630 | BGP_STR | |
7631 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
7632 | "Display only the bestpath\n" | |
b05a1c8b DS |
7633 | "Display only multipaths\n" |
7634 | "JavaScript Object Notation\n") | |
4092b06c | 7635 | { |
db7c8528 | 7636 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7637 | |
4092b06c | 7638 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 7639 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 7640 | else |
db7c8528 | 7641 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
7642 | } |
7643 | ||
7644 | DEFUN (show_bgp_ipv4_safi_route_pathtype, | |
7645 | show_bgp_ipv4_safi_route_pathtype_cmd, | |
b05a1c8b | 7646 | "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}", |
4092b06c DS |
7647 | SHOW_STR |
7648 | BGP_STR | |
7649 | "Address family\n" | |
7650 | "Address Family modifier\n" | |
7651 | "Address Family modifier\n" | |
7652 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
7653 | "Display only the bestpath\n" | |
b05a1c8b DS |
7654 | "Display only multipaths\n" |
7655 | "JavaScript Object Notation\n") | |
4092b06c | 7656 | { |
db7c8528 | 7657 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7658 | |
4092b06c DS |
7659 | if (strncmp (argv[0], "m", 1) == 0) |
7660 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 7661 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 7662 | else |
db7c8528 | 7663 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
7664 | else |
7665 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 7666 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 7667 | else |
db7c8528 | 7668 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
718e3744 | 7669 | } |
7670 | ||
7671 | DEFUN (show_ip_bgp_ipv4_route, | |
7672 | show_ip_bgp_ipv4_route_cmd, | |
b05a1c8b | 7673 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}", |
718e3744 | 7674 | SHOW_STR |
7675 | IP_STR | |
7676 | BGP_STR | |
7677 | "Address family\n" | |
7678 | "Address Family modifier\n" | |
7679 | "Address Family modifier\n" | |
b05a1c8b DS |
7680 | "Network in the BGP routing table to display\n" |
7681 | "JavaScript Object Notation\n") | |
718e3744 | 7682 | { |
db7c8528 | 7683 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7684 | |
718e3744 | 7685 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 7686 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); |
718e3744 | 7687 | |
db7c8528 | 7688 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); |
718e3744 | 7689 | } |
7690 | ||
95cbbd2a ML |
7691 | ALIAS (show_ip_bgp_ipv4_route, |
7692 | show_bgp_ipv4_safi_route_cmd, | |
b05a1c8b | 7693 | "show bgp ipv4 (unicast|multicast) A.B.C.D {json}", |
95cbbd2a ML |
7694 | SHOW_STR |
7695 | BGP_STR | |
7696 | "Address family\n" | |
7697 | "Address Family modifier\n" | |
7698 | "Address Family modifier\n" | |
b05a1c8b DS |
7699 | "Network in the BGP routing table to display\n" |
7700 | "JavaScript Object Notation\n") | |
95cbbd2a | 7701 | |
718e3744 | 7702 | DEFUN (show_ip_bgp_vpnv4_all_route, |
7703 | show_ip_bgp_vpnv4_all_route_cmd, | |
b05a1c8b | 7704 | "show ip bgp vpnv4 all A.B.C.D {json}", |
718e3744 | 7705 | SHOW_STR |
7706 | IP_STR | |
7707 | BGP_STR | |
7708 | "Display VPNv4 NLRI specific information\n" | |
7709 | "Display information about all VPNv4 NLRIs\n" | |
b05a1c8b DS |
7710 | "Network in the BGP routing table to display\n" |
7711 | "JavaScript Object Notation\n") | |
718e3744 | 7712 | { |
db7c8528 | 7713 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 7714 | } |
7715 | ||
4092b06c | 7716 | |
718e3744 | 7717 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
7718 | show_ip_bgp_vpnv4_rd_route_cmd, | |
b05a1c8b | 7719 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}", |
718e3744 | 7720 | SHOW_STR |
7721 | IP_STR | |
7722 | BGP_STR | |
7723 | "Display VPNv4 NLRI specific information\n" | |
7724 | "Display information for a route distinguisher\n" | |
7725 | "VPN Route Distinguisher\n" | |
b05a1c8b DS |
7726 | "Network in the BGP routing table to display\n" |
7727 | "JavaScript Object Notation\n") | |
718e3744 | 7728 | { |
7729 | int ret; | |
7730 | struct prefix_rd prd; | |
db7c8528 | 7731 | u_char uj= use_json(argc, argv); |
718e3744 | 7732 | |
7733 | ret = str2prefix_rd (argv[0], &prd); | |
7734 | if (! ret) | |
7735 | { | |
7736 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
7737 | return CMD_WARNING; | |
7738 | } | |
db7c8528 | 7739 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); |
718e3744 | 7740 | } |
7741 | ||
7742 | DEFUN (show_ip_bgp_prefix, | |
7743 | show_ip_bgp_prefix_cmd, | |
b05a1c8b | 7744 | "show ip bgp A.B.C.D/M {json}", |
718e3744 | 7745 | SHOW_STR |
7746 | IP_STR | |
7747 | BGP_STR | |
b05a1c8b DS |
7748 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
7749 | "JavaScript Object Notation\n") | |
718e3744 | 7750 | { |
db7c8528 | 7751 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
4092b06c DS |
7752 | } |
7753 | ||
7754 | DEFUN (show_ip_bgp_prefix_pathtype, | |
7755 | show_ip_bgp_prefix_pathtype_cmd, | |
b05a1c8b | 7756 | "show ip bgp A.B.C.D/M (bestpath|multipath) {json}", |
4092b06c DS |
7757 | SHOW_STR |
7758 | IP_STR | |
7759 | BGP_STR | |
7760 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
7761 | "Display only the bestpath\n" | |
b05a1c8b DS |
7762 | "Display only multipaths\n" |
7763 | "JavaScript Object Notation\n") | |
4092b06c | 7764 | { |
db7c8528 | 7765 | u_char uj = use_json(argc, argv); |
4092b06c | 7766 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 7767 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 7768 | else |
db7c8528 | 7769 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
718e3744 | 7770 | } |
7771 | ||
7772 | DEFUN (show_ip_bgp_ipv4_prefix, | |
7773 | show_ip_bgp_ipv4_prefix_cmd, | |
b05a1c8b | 7774 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", |
718e3744 | 7775 | SHOW_STR |
7776 | IP_STR | |
7777 | BGP_STR | |
7778 | "Address family\n" | |
7779 | "Address Family modifier\n" | |
7780 | "Address Family modifier\n" | |
b05a1c8b DS |
7781 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
7782 | "JavaScript Object Notation\n") | |
718e3744 | 7783 | { |
db7c8528 | 7784 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7785 | |
718e3744 | 7786 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 7787 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); |
718e3744 | 7788 | |
db7c8528 | 7789 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); |
718e3744 | 7790 | } |
7791 | ||
95cbbd2a ML |
7792 | ALIAS (show_ip_bgp_ipv4_prefix, |
7793 | show_bgp_ipv4_safi_prefix_cmd, | |
b05a1c8b | 7794 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", |
95cbbd2a ML |
7795 | SHOW_STR |
7796 | BGP_STR | |
7797 | "Address family\n" | |
7798 | "Address Family modifier\n" | |
7799 | "Address Family modifier\n" | |
b05a1c8b DS |
7800 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
7801 | "JavaScript Object Notation\n") | |
95cbbd2a | 7802 | |
4092b06c DS |
7803 | DEFUN (show_ip_bgp_ipv4_prefix_pathtype, |
7804 | show_ip_bgp_ipv4_prefix_pathtype_cmd, | |
b05a1c8b | 7805 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", |
4092b06c DS |
7806 | SHOW_STR |
7807 | IP_STR | |
7808 | BGP_STR | |
7809 | "Address family\n" | |
7810 | "Address Family modifier\n" | |
7811 | "Address Family modifier\n" | |
7812 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
7813 | "Display only the bestpath\n" | |
b05a1c8b DS |
7814 | "Display only multipaths\n" |
7815 | "JavaScript Object Notation\n") | |
4092b06c | 7816 | { |
db7c8528 | 7817 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7818 | |
4092b06c DS |
7819 | if (strncmp (argv[0], "m", 1) == 0) |
7820 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 7821 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 7822 | else |
db7c8528 | 7823 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
7824 | else |
7825 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 7826 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 7827 | else |
db7c8528 | 7828 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
7829 | } |
7830 | ||
7831 | ALIAS (show_ip_bgp_ipv4_prefix_pathtype, | |
7832 | show_bgp_ipv4_safi_prefix_pathtype_cmd, | |
b05a1c8b | 7833 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", |
4092b06c DS |
7834 | SHOW_STR |
7835 | BGP_STR | |
7836 | "Address family\n" | |
7837 | "Address Family modifier\n" | |
7838 | "Address Family modifier\n" | |
7839 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
7840 | "Display only the bestpath\n" | |
b05a1c8b DS |
7841 | "Display only multipaths\n" |
7842 | "JavaScript Object Notation\n") | |
4092b06c | 7843 | |
718e3744 | 7844 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
7845 | show_ip_bgp_vpnv4_all_prefix_cmd, | |
b05a1c8b | 7846 | "show ip bgp vpnv4 all A.B.C.D/M {json}", |
718e3744 | 7847 | SHOW_STR |
7848 | IP_STR | |
7849 | BGP_STR | |
7850 | "Display VPNv4 NLRI specific information\n" | |
7851 | "Display information about all VPNv4 NLRIs\n" | |
b05a1c8b DS |
7852 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
7853 | "JavaScript Object Notation\n") | |
718e3744 | 7854 | { |
db7c8528 | 7855 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 7856 | } |
7857 | ||
7858 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, | |
7859 | show_ip_bgp_vpnv4_rd_prefix_cmd, | |
b05a1c8b | 7860 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}", |
718e3744 | 7861 | SHOW_STR |
7862 | IP_STR | |
7863 | BGP_STR | |
7864 | "Display VPNv4 NLRI specific information\n" | |
7865 | "Display information for a route distinguisher\n" | |
7866 | "VPN Route Distinguisher\n" | |
b05a1c8b DS |
7867 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
7868 | "JavaScript Object Notation\n") | |
718e3744 | 7869 | { |
7870 | int ret; | |
7871 | struct prefix_rd prd; | |
7872 | ||
7873 | ret = str2prefix_rd (argv[0], &prd); | |
7874 | if (! ret) | |
7875 | { | |
7876 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
7877 | return CMD_WARNING; | |
7878 | } | |
db7c8528 | 7879 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 7880 | } |
7881 | ||
7882 | DEFUN (show_ip_bgp_view, | |
8386ac43 | 7883 | show_ip_bgp_instance_cmd, |
7884 | "show ip bgp " BGP_INSTANCE_CMD " {json}", | |
718e3744 | 7885 | SHOW_STR |
7886 | IP_STR | |
7887 | BGP_STR | |
8386ac43 | 7888 | BGP_INSTANCE_HELP_STR |
b05a1c8b | 7889 | "JavaScript Object Notation\n") |
718e3744 | 7890 | { |
bb46e94f | 7891 | struct bgp *bgp; |
7892 | ||
7893 | /* BGP structure lookup. */ | |
6aeb9e78 | 7894 | bgp = bgp_lookup_by_name (argv[1]); |
bb46e94f | 7895 | if (bgp == NULL) |
7896 | { | |
6aeb9e78 | 7897 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
bb46e94f | 7898 | return CMD_WARNING; |
7899 | } | |
7900 | ||
db7c8528 | 7901 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); |
718e3744 | 7902 | } |
7903 | ||
8386ac43 | 7904 | DEFUN (show_ip_bgp_instance_route, |
7905 | show_ip_bgp_instance_route_cmd, | |
7906 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D {json}", | |
718e3744 | 7907 | SHOW_STR |
7908 | IP_STR | |
7909 | BGP_STR | |
8386ac43 | 7910 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
7911 | "Network in the BGP routing table to display\n" |
7912 | "JavaScript Object Notation\n") | |
718e3744 | 7913 | { |
6aeb9e78 | 7914 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 7915 | } |
7916 | ||
8386ac43 | 7917 | DEFUN (show_ip_bgp_instance_route_pathtype, |
7918 | show_ip_bgp_instance_route_pathtype_cmd, | |
7919 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D (bestpath|multipath) {json}", | |
50ef26d4 | 7920 | SHOW_STR |
7921 | IP_STR | |
7922 | BGP_STR | |
8386ac43 | 7923 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 7924 | "Network in the BGP routing table to display\n" |
7925 | "Display only the bestpath\n" | |
7926 | "Display only multipaths\n" | |
7927 | "JavaScript Object Notation\n") | |
7928 | { | |
7929 | u_char uj = use_json(argc, argv); | |
7930 | ||
7931 | if (strncmp (argv[3], "b", 1) == 0) | |
7932 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); | |
7933 | else | |
7934 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); | |
7935 | } | |
7936 | ||
8386ac43 | 7937 | DEFUN (show_ip_bgp_instance_prefix, |
7938 | show_ip_bgp_instance_prefix_cmd, | |
7939 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M {json}", | |
718e3744 | 7940 | SHOW_STR |
7941 | IP_STR | |
7942 | BGP_STR | |
8386ac43 | 7943 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
7944 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
7945 | "JavaScript Object Notation\n") | |
718e3744 | 7946 | { |
6aeb9e78 | 7947 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 7948 | } |
7949 | ||
8386ac43 | 7950 | DEFUN (show_ip_bgp_instance_prefix_pathtype, |
7951 | show_ip_bgp_instance_prefix_pathtype_cmd, | |
7952 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M (bestpath|multipath) {json}", | |
50ef26d4 | 7953 | SHOW_STR |
7954 | IP_STR | |
7955 | BGP_STR | |
8386ac43 | 7956 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 7957 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
7958 | "Display only the bestpath\n" | |
7959 | "Display only multipaths\n" | |
7960 | "JavaScript Object Notation\n") | |
7961 | { | |
7962 | u_char uj = use_json(argc, argv); | |
7963 | if (strncmp (argv[3], "b", 1) == 0) | |
7964 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); | |
7965 | else | |
7966 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); | |
7967 | } | |
7968 | ||
718e3744 | 7969 | #ifdef HAVE_IPV6 |
7970 | DEFUN (show_bgp, | |
7971 | show_bgp_cmd, | |
b05a1c8b | 7972 | "show bgp {json}", |
718e3744 | 7973 | SHOW_STR |
b05a1c8b DS |
7974 | BGP_STR |
7975 | "JavaScript Object Notation\n") | |
718e3744 | 7976 | { |
5a646650 | 7977 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
db7c8528 | 7978 | NULL, use_json(argc, argv)); |
718e3744 | 7979 | } |
7980 | ||
7981 | ALIAS (show_bgp, | |
7982 | show_bgp_ipv6_cmd, | |
b05a1c8b | 7983 | "show bgp ipv6 {json}", |
718e3744 | 7984 | SHOW_STR |
7985 | BGP_STR | |
b05a1c8b DS |
7986 | "Address family\n" |
7987 | "JavaScript Object Notation\n") | |
718e3744 | 7988 | |
95cbbd2a ML |
7989 | DEFUN (show_bgp_ipv6_safi, |
7990 | show_bgp_ipv6_safi_cmd, | |
b05a1c8b | 7991 | "show bgp ipv6 (unicast|multicast) {json}", |
95cbbd2a ML |
7992 | SHOW_STR |
7993 | BGP_STR | |
7994 | "Address family\n" | |
7995 | "Address Family modifier\n" | |
47fc97cc | 7996 | "Address Family modifier\n" |
b05a1c8b | 7997 | "JavaScript Object Notation\n") |
47fc97cc | 7998 | { |
db7c8528 | 7999 | u_char uj = use_json(argc, argv); |
47fc97cc DS |
8000 | if (strncmp (argv[0], "m", 1) == 0) |
8001 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, | |
db7c8528 | 8002 | NULL, uj); |
47fc97cc | 8003 | |
db7c8528 | 8004 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); |
95cbbd2a ML |
8005 | } |
8006 | ||
47e9b292 DW |
8007 | static void |
8008 | bgp_show_ipv6_bgp_deprecate_warning (struct vty *vty) | |
8009 | { | |
8010 | vty_out (vty, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our" | |
8011 | " next release%sPlese use 'show bgp ipv6' instead%s%s", | |
8012 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
8013 | } | |
8014 | ||
718e3744 | 8015 | /* old command */ |
8016 | DEFUN (show_ipv6_bgp, | |
8017 | show_ipv6_bgp_cmd, | |
b05a1c8b | 8018 | "show ipv6 bgp {json}", |
718e3744 | 8019 | SHOW_STR |
8020 | IP_STR | |
b05a1c8b DS |
8021 | BGP_STR |
8022 | "JavaScript Object Notation\n") | |
718e3744 | 8023 | { |
47e9b292 | 8024 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
5a646650 | 8025 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
db7c8528 | 8026 | NULL, use_json(argc, argv)); |
718e3744 | 8027 | } |
8028 | ||
8029 | DEFUN (show_bgp_route, | |
8030 | show_bgp_route_cmd, | |
b05a1c8b | 8031 | "show bgp X:X::X:X {json}", |
718e3744 | 8032 | SHOW_STR |
8033 | BGP_STR | |
b05a1c8b DS |
8034 | "Network in the BGP routing table to display\n" |
8035 | "JavaScript Object Notation\n") | |
718e3744 | 8036 | { |
db7c8528 | 8037 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8038 | } |
8039 | ||
8040 | ALIAS (show_bgp_route, | |
8041 | show_bgp_ipv6_route_cmd, | |
b05a1c8b | 8042 | "show bgp ipv6 X:X::X:X {json}", |
718e3744 | 8043 | SHOW_STR |
8044 | BGP_STR | |
8045 | "Address family\n" | |
b05a1c8b DS |
8046 | "Network in the BGP routing table to display\n" |
8047 | "JavaScript Object Notation\n") | |
718e3744 | 8048 | |
95cbbd2a ML |
8049 | DEFUN (show_bgp_ipv6_safi_route, |
8050 | show_bgp_ipv6_safi_route_cmd, | |
b05a1c8b | 8051 | "show bgp ipv6 (unicast|multicast) X:X::X:X {json}", |
95cbbd2a ML |
8052 | SHOW_STR |
8053 | BGP_STR | |
8054 | "Address family\n" | |
8055 | "Address Family modifier\n" | |
8056 | "Address Family modifier\n" | |
b05a1c8b DS |
8057 | "Network in the BGP routing table to display\n" |
8058 | "JavaScript Object Notation\n") | |
95cbbd2a | 8059 | { |
db7c8528 | 8060 | u_char uj = use_json(argc, argv); |
95cbbd2a | 8061 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8062 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); |
95cbbd2a | 8063 | |
db7c8528 | 8064 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); |
4092b06c DS |
8065 | } |
8066 | ||
8067 | DEFUN (show_bgp_route_pathtype, | |
8068 | show_bgp_route_pathtype_cmd, | |
b05a1c8b | 8069 | "show bgp X:X::X:X (bestpath|multipath) {json}", |
4092b06c DS |
8070 | SHOW_STR |
8071 | BGP_STR | |
8072 | "Network in the BGP routing table to display\n" | |
8073 | "Display only the bestpath\n" | |
b05a1c8b DS |
8074 | "Display only multipaths\n" |
8075 | "JavaScript Object Notation\n") | |
4092b06c | 8076 | { |
db7c8528 | 8077 | u_char uj = use_json(argc, argv); |
4092b06c | 8078 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 8079 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8080 | else |
db7c8528 | 8081 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8082 | } |
8083 | ||
8084 | ALIAS (show_bgp_route_pathtype, | |
8085 | show_bgp_ipv6_route_pathtype_cmd, | |
b05a1c8b | 8086 | "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}", |
4092b06c DS |
8087 | SHOW_STR |
8088 | BGP_STR | |
8089 | "Address family\n" | |
8090 | "Network in the BGP routing table to display\n" | |
8091 | "Display only the bestpath\n" | |
b05a1c8b DS |
8092 | "Display only multipaths\n" |
8093 | "JavaScript Object Notation\n") | |
4092b06c DS |
8094 | |
8095 | DEFUN (show_bgp_ipv6_safi_route_pathtype, | |
8096 | show_bgp_ipv6_safi_route_pathtype_cmd, | |
b05a1c8b | 8097 | "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}", |
4092b06c DS |
8098 | SHOW_STR |
8099 | BGP_STR | |
8100 | "Address family\n" | |
8101 | "Address Family modifier\n" | |
8102 | "Address Family modifier\n" | |
8103 | "Network in the BGP routing table to display\n" | |
8104 | "Display only the bestpath\n" | |
b05a1c8b DS |
8105 | "Display only multipaths\n" |
8106 | "JavaScript Object Notation\n") | |
4092b06c | 8107 | { |
db7c8528 | 8108 | u_char uj = use_json(argc, argv); |
4092b06c DS |
8109 | if (strncmp (argv[0], "m", 1) == 0) |
8110 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8111 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8112 | else |
db7c8528 | 8113 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8114 | else |
8115 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8116 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8117 | else |
db7c8528 | 8118 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
95cbbd2a ML |
8119 | } |
8120 | ||
718e3744 | 8121 | /* old command */ |
8122 | DEFUN (show_ipv6_bgp_route, | |
8123 | show_ipv6_bgp_route_cmd, | |
b05a1c8b | 8124 | "show ipv6 bgp X:X::X:X {json}", |
718e3744 | 8125 | SHOW_STR |
8126 | IP_STR | |
8127 | BGP_STR | |
b05a1c8b DS |
8128 | "Network in the BGP routing table to display\n" |
8129 | "JavaScript Object Notation\n") | |
718e3744 | 8130 | { |
47e9b292 | 8131 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8132 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8133 | } |
8134 | ||
8135 | DEFUN (show_bgp_prefix, | |
8136 | show_bgp_prefix_cmd, | |
b05a1c8b | 8137 | "show bgp X:X::X:X/M {json}", |
718e3744 | 8138 | SHOW_STR |
8139 | BGP_STR | |
b05a1c8b DS |
8140 | "IPv6 prefix <network>/<length>\n" |
8141 | "JavaScript Object Notation\n") | |
718e3744 | 8142 | { |
db7c8528 | 8143 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8144 | } |
8145 | ||
8146 | ALIAS (show_bgp_prefix, | |
8147 | show_bgp_ipv6_prefix_cmd, | |
b05a1c8b | 8148 | "show bgp ipv6 X:X::X:X/M {json}", |
718e3744 | 8149 | SHOW_STR |
8150 | BGP_STR | |
8151 | "Address family\n" | |
b05a1c8b DS |
8152 | "IPv6 prefix <network>/<length>\n" |
8153 | "JavaScript Object Notation\n") | |
718e3744 | 8154 | |
95cbbd2a ML |
8155 | DEFUN (show_bgp_ipv6_safi_prefix, |
8156 | show_bgp_ipv6_safi_prefix_cmd, | |
b05a1c8b | 8157 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}", |
95cbbd2a ML |
8158 | SHOW_STR |
8159 | BGP_STR | |
8160 | "Address family\n" | |
8161 | "Address Family modifier\n" | |
8162 | "Address Family modifier\n" | |
b05a1c8b DS |
8163 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
8164 | "JavaScript Object Notation\n") | |
95cbbd2a | 8165 | { |
db7c8528 | 8166 | u_char uj = use_json(argc, argv); |
95cbbd2a | 8167 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8168 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); |
95cbbd2a | 8169 | |
db7c8528 | 8170 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); |
4092b06c DS |
8171 | } |
8172 | ||
8173 | DEFUN (show_bgp_prefix_pathtype, | |
8174 | show_bgp_prefix_pathtype_cmd, | |
b05a1c8b | 8175 | "show bgp X:X::X:X/M (bestpath|multipath) {json}", |
4092b06c DS |
8176 | SHOW_STR |
8177 | BGP_STR | |
8178 | "IPv6 prefix <network>/<length>\n" | |
8179 | "Display only the bestpath\n" | |
b05a1c8b DS |
8180 | "Display only multipaths\n" |
8181 | "JavaScript Object Notation\n") | |
4092b06c | 8182 | { |
db7c8528 | 8183 | u_char uj = use_json(argc, argv); |
4092b06c | 8184 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 8185 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8186 | else |
db7c8528 | 8187 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8188 | } |
8189 | ||
8190 | ALIAS (show_bgp_prefix_pathtype, | |
8191 | show_bgp_ipv6_prefix_pathtype_cmd, | |
b05a1c8b | 8192 | "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}", |
4092b06c DS |
8193 | SHOW_STR |
8194 | BGP_STR | |
8195 | "Address family\n" | |
8196 | "IPv6 prefix <network>/<length>\n" | |
8197 | "Display only the bestpath\n" | |
b05a1c8b DS |
8198 | "Display only multipaths\n" |
8199 | "JavaScript Object Notation\n") | |
4092b06c DS |
8200 | |
8201 | DEFUN (show_bgp_ipv6_safi_prefix_pathtype, | |
8202 | show_bgp_ipv6_safi_prefix_pathtype_cmd, | |
b05a1c8b | 8203 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}", |
4092b06c DS |
8204 | SHOW_STR |
8205 | BGP_STR | |
8206 | "Address family\n" | |
8207 | "Address Family modifier\n" | |
8208 | "Address Family modifier\n" | |
8209 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
8210 | "Display only the bestpath\n" | |
b05a1c8b DS |
8211 | "Display only multipaths\n" |
8212 | "JavaScript Object Notation\n") | |
4092b06c | 8213 | { |
db7c8528 | 8214 | u_char uj = use_json(argc, argv); |
4092b06c DS |
8215 | if (strncmp (argv[0], "m", 1) == 0) |
8216 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8217 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8218 | else |
db7c8528 | 8219 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8220 | else |
8221 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8222 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8223 | else |
db7c8528 | 8224 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
95cbbd2a ML |
8225 | } |
8226 | ||
718e3744 | 8227 | /* old command */ |
8228 | DEFUN (show_ipv6_bgp_prefix, | |
8229 | show_ipv6_bgp_prefix_cmd, | |
b05a1c8b | 8230 | "show ipv6 bgp X:X::X:X/M {json}", |
718e3744 | 8231 | SHOW_STR |
8232 | IP_STR | |
8233 | BGP_STR | |
b05a1c8b DS |
8234 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
8235 | "JavaScript Object Notation\n") | |
718e3744 | 8236 | { |
47e9b292 | 8237 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8238 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8239 | } |
8240 | ||
bb46e94f | 8241 | DEFUN (show_bgp_view, |
8386ac43 | 8242 | show_bgp_instance_cmd, |
8243 | "show bgp " BGP_INSTANCE_CMD " {json}", | |
bb46e94f | 8244 | SHOW_STR |
8245 | BGP_STR | |
8386ac43 | 8246 | BGP_INSTANCE_HELP_STR |
b05a1c8b | 8247 | "JavaScript Object Notation\n") |
bb46e94f | 8248 | { |
8249 | struct bgp *bgp; | |
8250 | ||
8251 | /* BGP structure lookup. */ | |
6aeb9e78 | 8252 | bgp = bgp_lookup_by_name (argv[1]); |
bb46e94f | 8253 | if (bgp == NULL) |
db7c8528 | 8254 | { |
6aeb9e78 | 8255 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
db7c8528 DS |
8256 | return CMD_WARNING; |
8257 | } | |
8258 | ||
8259 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); | |
bb46e94f | 8260 | } |
8261 | ||
8262 | ALIAS (show_bgp_view, | |
8386ac43 | 8263 | show_bgp_instance_ipv6_cmd, |
8264 | "show bgp " BGP_INSTANCE_CMD " ipv6 {json}", | |
bb46e94f | 8265 | SHOW_STR |
8266 | BGP_STR | |
8386ac43 | 8267 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8268 | "Address family\n" |
8269 | "JavaScript Object Notation\n") | |
bb46e94f | 8270 | |
8386ac43 | 8271 | DEFUN (show_bgp_instance_route, |
8272 | show_bgp_instance_route_cmd, | |
8273 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X {json}", | |
bb46e94f | 8274 | SHOW_STR |
8275 | BGP_STR | |
8386ac43 | 8276 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8277 | "Network in the BGP routing table to display\n" |
8278 | "JavaScript Object Notation\n") | |
bb46e94f | 8279 | { |
6aeb9e78 | 8280 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
bb46e94f | 8281 | } |
8282 | ||
8386ac43 | 8283 | ALIAS (show_bgp_instance_route, |
8284 | show_bgp_instance_ipv6_route_cmd, | |
8285 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X {json}", | |
bb46e94f | 8286 | SHOW_STR |
8287 | BGP_STR | |
8386ac43 | 8288 | BGP_INSTANCE_HELP_STR |
bb46e94f | 8289 | "Address family\n" |
b05a1c8b DS |
8290 | "Network in the BGP routing table to display\n" |
8291 | "JavaScript Object Notation\n") | |
bb46e94f | 8292 | |
8386ac43 | 8293 | DEFUN (show_bgp_instance_route_pathtype, |
8294 | show_bgp_instance_route_pathtype_cmd, | |
8295 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X (bestpath|multipath) {json}", | |
50ef26d4 | 8296 | SHOW_STR |
8297 | BGP_STR | |
8386ac43 | 8298 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8299 | "Network in the BGP routing table to display\n" |
8300 | "Display only the bestpath\n" | |
8301 | "Display only multipaths\n" | |
8302 | "JavaScript Object Notation\n") | |
8303 | { | |
8304 | u_char uj = use_json(argc, argv); | |
8305 | if (strncmp (argv[3], "b", 1) == 0) | |
8306 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); | |
8307 | else | |
8308 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); | |
8309 | } | |
8310 | ||
8386ac43 | 8311 | ALIAS (show_bgp_instance_route_pathtype, |
8312 | show_bgp_instance_ipv6_route_pathtype_cmd, | |
8313 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X (bestpath|multipath) {json}", | |
50ef26d4 | 8314 | SHOW_STR |
8315 | BGP_STR | |
8386ac43 | 8316 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8317 | "Address family\n" |
8318 | "Network in the BGP routing table to display\n" | |
8319 | "Display only the bestpath\n" | |
8320 | "Display only multipaths\n" | |
8321 | "JavaScript Object Notation\n") | |
8322 | ||
8386ac43 | 8323 | DEFUN (show_bgp_instance_prefix, |
8324 | show_bgp_instance_prefix_cmd, | |
8325 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M {json}", | |
bb46e94f | 8326 | SHOW_STR |
8327 | BGP_STR | |
8386ac43 | 8328 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8329 | "IPv6 prefix <network>/<length>\n" |
8330 | "JavaScript Object Notation\n") | |
bb46e94f | 8331 | { |
6aeb9e78 | 8332 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
bb46e94f | 8333 | } |
8334 | ||
8386ac43 | 8335 | ALIAS (show_bgp_instance_prefix, |
8336 | show_bgp_instance_ipv6_prefix_cmd, | |
8337 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M {json}", | |
bb46e94f | 8338 | SHOW_STR |
8339 | BGP_STR | |
8386ac43 | 8340 | BGP_INSTANCE_HELP_STR |
bb46e94f | 8341 | "Address family\n" |
b05a1c8b DS |
8342 | "IPv6 prefix <network>/<length>\n" |
8343 | "JavaScript Object Notation\n") | |
bb46e94f | 8344 | |
8386ac43 | 8345 | DEFUN (show_bgp_instance_prefix_pathtype, |
8346 | show_bgp_instance_prefix_pathtype_cmd, | |
8347 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M (bestpath|multipath) {json}", | |
50ef26d4 | 8348 | SHOW_STR |
8349 | BGP_STR | |
8386ac43 | 8350 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8351 | "IPv6 prefix <network>/<length>\n" |
8352 | "Display only the bestpath\n" | |
8353 | "Display only multipaths\n" | |
8354 | "JavaScript Object Notation\n") | |
8355 | { | |
8356 | u_char uj = use_json(argc, argv); | |
8357 | if (strncmp (argv[3], "b", 1) == 0) | |
8358 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); | |
8359 | else | |
8360 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); | |
8361 | } | |
8362 | ||
8386ac43 | 8363 | ALIAS (show_bgp_instance_prefix_pathtype, |
8364 | show_bgp_instance_ipv6_prefix_pathtype_cmd, | |
8365 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M (bestpath|multipath) {json}", | |
50ef26d4 | 8366 | SHOW_STR |
8367 | BGP_STR | |
8386ac43 | 8368 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8369 | "Address family\n" |
8370 | "IPv6 prefix <network>/<length>\n" | |
8371 | "Display only the bestpath\n" | |
8372 | "Display only multipaths\n" | |
8373 | "JavaScript Object Notation\n") | |
8374 | ||
8386ac43 | 8375 | DEFUN (show_bgp_instance_prefix_list, |
8376 | show_bgp_instance_prefix_list_cmd, | |
8377 | "show bgp " BGP_INSTANCE_CMD " prefix-list WORD", | |
50ef26d4 | 8378 | SHOW_STR |
8379 | BGP_STR | |
8386ac43 | 8380 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8381 | "Display routes conforming to the prefix-list\n" |
8382 | "IPv6 prefix-list name\n") | |
8383 | { | |
8384 | return bgp_show_prefix_list (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8385 | bgp_show_type_prefix_list); | |
8386 | } | |
8387 | ||
8386ac43 | 8388 | ALIAS (show_bgp_instance_prefix_list, |
8389 | show_bgp_instance_ipv6_prefix_list_cmd, | |
8390 | "show bgp " BGP_INSTANCE_CMD " ipv6 prefix-list WORD", | |
50ef26d4 | 8391 | SHOW_STR |
8392 | BGP_STR | |
8386ac43 | 8393 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8394 | "Address family\n" |
8395 | "Display routes conforming to the prefix-list\n" | |
8396 | "IPv6 prefix-list name\n") | |
8397 | ||
8386ac43 | 8398 | DEFUN (show_bgp_instance_filter_list, |
8399 | show_bgp_instance_filter_list_cmd, | |
8400 | "show bgp " BGP_INSTANCE_CMD " filter-list WORD", | |
50ef26d4 | 8401 | SHOW_STR |
8402 | BGP_STR | |
8386ac43 | 8403 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8404 | "Display routes conforming to the filter-list\n" |
8405 | "Regular expression access list name\n") | |
8406 | { | |
8407 | return bgp_show_filter_list (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8408 | bgp_show_type_filter_list); | |
8409 | } | |
8410 | ||
8386ac43 | 8411 | ALIAS (show_bgp_instance_filter_list, |
8412 | show_bgp_instance_ipv6_filter_list_cmd, | |
8413 | "show bgp " BGP_INSTANCE_CMD " ipv6 filter-list WORD", | |
50ef26d4 | 8414 | SHOW_STR |
8415 | BGP_STR | |
8386ac43 | 8416 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8417 | "Address family\n" |
8418 | "Display routes conforming to the filter-list\n" | |
8419 | "Regular expression access list name\n") | |
8420 | ||
8386ac43 | 8421 | DEFUN (show_bgp_instance_route_map, |
8422 | show_bgp_instance_route_map_cmd, | |
8423 | "show bgp " BGP_INSTANCE_CMD " route-map WORD", | |
50ef26d4 | 8424 | SHOW_STR |
8425 | BGP_STR | |
8386ac43 | 8426 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8427 | "Display routes matching the route-map\n" |
8428 | "A route-map to match on\n") | |
8429 | { | |
8430 | return bgp_show_route_map (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8431 | bgp_show_type_route_map); | |
8432 | } | |
8433 | ||
8386ac43 | 8434 | ALIAS (show_bgp_instance_route_map, |
8435 | show_bgp_instance_ipv6_route_map_cmd, | |
8436 | "show bgp " BGP_INSTANCE_CMD " ipv6 route-map WORD", | |
50ef26d4 | 8437 | SHOW_STR |
8438 | BGP_STR | |
8386ac43 | 8439 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8440 | "Address family\n" |
8441 | "Display routes matching the route-map\n" | |
8442 | "A route-map to match on\n") | |
8443 | ||
8386ac43 | 8444 | DEFUN (show_bgp_instance_community_list, |
8445 | show_bgp_instance_community_list_cmd, | |
8446 | "show bgp " BGP_INSTANCE_CMD " community-list (<1-500>|WORD)", | |
50ef26d4 | 8447 | SHOW_STR |
8448 | BGP_STR | |
8386ac43 | 8449 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8450 | "Display routes matching the community-list\n" |
8451 | "community-list number\n" | |
8452 | "community-list name\n") | |
8453 | { | |
8454 | return bgp_show_community_list (vty, argv[1], argv[2], 0, AFI_IP6, SAFI_UNICAST); | |
8455 | } | |
8456 | ||
8386ac43 | 8457 | ALIAS (show_bgp_instance_community_list, |
8458 | show_bgp_instance_ipv6_community_list_cmd, | |
8459 | "show bgp " BGP_INSTANCE_CMD " ipv6 community-list (<1-500>|WORD)", | |
50ef26d4 | 8460 | SHOW_STR |
8461 | BGP_STR | |
8386ac43 | 8462 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8463 | "Address family\n" |
8464 | "Display routes matching the community-list\n" | |
8465 | "community-list number\n" | |
8466 | "community-list name\n") | |
8467 | ||
8386ac43 | 8468 | DEFUN (show_bgp_instance_prefix_longer, |
8469 | show_bgp_instance_prefix_longer_cmd, | |
8470 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M longer-prefixes", | |
50ef26d4 | 8471 | SHOW_STR |
8472 | BGP_STR | |
8386ac43 | 8473 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8474 | "IPv6 prefix <network>/<length>\n" |
8475 | "Display route and more specific routes\n") | |
8476 | { | |
8477 | return bgp_show_prefix_longer (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8478 | bgp_show_type_prefix_longer); | |
8479 | } | |
8480 | ||
8386ac43 | 8481 | ALIAS (show_bgp_instance_prefix_longer, |
8482 | show_bgp_instance_ipv6_prefix_longer_cmd, | |
8483 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M longer-prefixes", | |
50ef26d4 | 8484 | SHOW_STR |
8485 | BGP_STR | |
8386ac43 | 8486 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8487 | "Address family\n" |
8488 | "IPv6 prefix <network>/<length>\n" | |
8489 | "Display route and more specific routes\n") | |
8490 | ||
718e3744 | 8491 | /* old command */ |
8492 | DEFUN (show_ipv6_mbgp, | |
8493 | show_ipv6_mbgp_cmd, | |
b05a1c8b | 8494 | "show ipv6 mbgp {json}", |
718e3744 | 8495 | SHOW_STR |
8496 | IP_STR | |
b05a1c8b DS |
8497 | MBGP_STR |
8498 | "JavaScript Object Notation\n") | |
718e3744 | 8499 | { |
47e9b292 | 8500 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
5a646650 | 8501 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
db7c8528 | 8502 | NULL, use_json(argc, argv)); |
718e3744 | 8503 | } |
8504 | ||
8505 | /* old command */ | |
8506 | DEFUN (show_ipv6_mbgp_route, | |
8507 | show_ipv6_mbgp_route_cmd, | |
b05a1c8b | 8508 | "show ipv6 mbgp X:X::X:X {json}", |
718e3744 | 8509 | SHOW_STR |
8510 | IP_STR | |
8511 | MBGP_STR | |
b05a1c8b DS |
8512 | "Network in the MBGP routing table to display\n" |
8513 | "JavaScript Object Notation\n") | |
718e3744 | 8514 | { |
47e9b292 | 8515 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8516 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8517 | } |
8518 | ||
8519 | /* old command */ | |
8520 | DEFUN (show_ipv6_mbgp_prefix, | |
8521 | show_ipv6_mbgp_prefix_cmd, | |
b05a1c8b | 8522 | "show ipv6 mbgp X:X::X:X/M {json}", |
718e3744 | 8523 | SHOW_STR |
8524 | IP_STR | |
8525 | MBGP_STR | |
b05a1c8b DS |
8526 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
8527 | "JavaScript Object Notation\n") | |
718e3744 | 8528 | { |
47e9b292 | 8529 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8530 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8531 | } |
8532 | #endif | |
6b0655a2 | 8533 | |
718e3744 | 8534 | |
94f2b392 | 8535 | static int |
fd79ac91 | 8536 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
718e3744 | 8537 | safi_t safi, enum bgp_show_type type) |
8538 | { | |
8539 | int i; | |
8540 | struct buffer *b; | |
8541 | char *regstr; | |
8542 | int first; | |
8543 | regex_t *regex; | |
5a646650 | 8544 | int rc; |
718e3744 | 8545 | |
8546 | first = 0; | |
8547 | b = buffer_new (1024); | |
8548 | for (i = 0; i < argc; i++) | |
8549 | { | |
8550 | if (first) | |
8551 | buffer_putc (b, ' '); | |
8552 | else | |
8553 | { | |
8554 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
8555 | continue; | |
8556 | first = 1; | |
8557 | } | |
8558 | ||
8559 | buffer_putstr (b, argv[i]); | |
8560 | } | |
8561 | buffer_putc (b, '\0'); | |
8562 | ||
8563 | regstr = buffer_getstr (b); | |
8564 | buffer_free (b); | |
8565 | ||
8566 | regex = bgp_regcomp (regstr); | |
3b8b1855 | 8567 | XFREE(MTYPE_TMP, regstr); |
718e3744 | 8568 | if (! regex) |
8569 | { | |
8570 | vty_out (vty, "Can't compile regexp %s%s", argv[0], | |
8571 | VTY_NEWLINE); | |
8572 | return CMD_WARNING; | |
8573 | } | |
8574 | ||
b05a1c8b | 8575 | rc = bgp_show (vty, NULL, afi, safi, type, regex, 0); |
5a646650 | 8576 | bgp_regex_free (regex); |
8577 | return rc; | |
718e3744 | 8578 | } |
8579 | ||
8580 | DEFUN (show_ip_bgp_regexp, | |
8581 | show_ip_bgp_regexp_cmd, | |
8582 | "show ip bgp regexp .LINE", | |
8583 | SHOW_STR | |
8584 | IP_STR | |
8585 | BGP_STR | |
8586 | "Display routes matching the AS path regular expression\n" | |
8587 | "A regular-expression to match the BGP AS paths\n") | |
8588 | { | |
8589 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
8590 | bgp_show_type_regexp); | |
8591 | } | |
8592 | ||
8593 | DEFUN (show_ip_bgp_flap_regexp, | |
8594 | show_ip_bgp_flap_regexp_cmd, | |
8595 | "show ip bgp flap-statistics regexp .LINE", | |
8596 | SHOW_STR | |
8597 | IP_STR | |
8598 | BGP_STR | |
8599 | "Display flap statistics of routes\n" | |
8600 | "Display routes matching the AS path regular expression\n" | |
8601 | "A regular-expression to match the BGP AS paths\n") | |
8602 | { | |
8603 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
8604 | bgp_show_type_flap_regexp); | |
8605 | } | |
8606 | ||
8607 | DEFUN (show_ip_bgp_ipv4_regexp, | |
8608 | show_ip_bgp_ipv4_regexp_cmd, | |
8609 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", | |
8610 | SHOW_STR | |
8611 | IP_STR | |
8612 | BGP_STR | |
8613 | "Address family\n" | |
8614 | "Address Family modifier\n" | |
8615 | "Address Family modifier\n" | |
8616 | "Display routes matching the AS path regular expression\n" | |
8617 | "A regular-expression to match the BGP AS paths\n") | |
8618 | { | |
8619 | if (strncmp (argv[0], "m", 1) == 0) | |
8620 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, | |
8621 | bgp_show_type_regexp); | |
8622 | ||
8623 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
8624 | bgp_show_type_regexp); | |
8625 | } | |
8626 | ||
8627 | #ifdef HAVE_IPV6 | |
8628 | DEFUN (show_bgp_regexp, | |
8629 | show_bgp_regexp_cmd, | |
8630 | "show bgp regexp .LINE", | |
8631 | SHOW_STR | |
8632 | BGP_STR | |
8633 | "Display routes matching the AS path regular expression\n" | |
8634 | "A regular-expression to match the BGP AS paths\n") | |
8635 | { | |
8636 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
8637 | bgp_show_type_regexp); | |
8638 | } | |
8639 | ||
8640 | ALIAS (show_bgp_regexp, | |
8641 | show_bgp_ipv6_regexp_cmd, | |
8642 | "show bgp ipv6 regexp .LINE", | |
8643 | SHOW_STR | |
8644 | BGP_STR | |
8645 | "Address family\n" | |
8646 | "Display routes matching the AS path regular expression\n" | |
8647 | "A regular-expression to match the BGP AS paths\n") | |
8648 | ||
8649 | /* old command */ | |
8650 | DEFUN (show_ipv6_bgp_regexp, | |
8651 | show_ipv6_bgp_regexp_cmd, | |
8652 | "show ipv6 bgp regexp .LINE", | |
8653 | SHOW_STR | |
8654 | IP_STR | |
8655 | BGP_STR | |
8656 | "Display routes matching the AS path regular expression\n" | |
8657 | "A regular-expression to match the BGP AS paths\n") | |
8658 | { | |
47e9b292 | 8659 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 8660 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
8661 | bgp_show_type_regexp); | |
8662 | } | |
8663 | ||
8664 | /* old command */ | |
8665 | DEFUN (show_ipv6_mbgp_regexp, | |
8666 | show_ipv6_mbgp_regexp_cmd, | |
8667 | "show ipv6 mbgp regexp .LINE", | |
8668 | SHOW_STR | |
8669 | IP_STR | |
8670 | BGP_STR | |
8671 | "Display routes matching the AS path regular expression\n" | |
8672 | "A regular-expression to match the MBGP AS paths\n") | |
8673 | { | |
47e9b292 | 8674 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 8675 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
8676 | bgp_show_type_regexp); | |
8677 | } | |
8678 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 8679 | |
94f2b392 | 8680 | static int |
50ef26d4 | 8681 | bgp_show_prefix_list (struct vty *vty, const char *name, |
8682 | const char *prefix_list_str, afi_t afi, | |
718e3744 | 8683 | safi_t safi, enum bgp_show_type type) |
8684 | { | |
8685 | struct prefix_list *plist; | |
50ef26d4 | 8686 | struct bgp *bgp = NULL; |
8687 | ||
8688 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
8689 | { | |
8690 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
8691 | return CMD_WARNING; | |
8692 | } | |
718e3744 | 8693 | |
8694 | plist = prefix_list_lookup (afi, prefix_list_str); | |
8695 | if (plist == NULL) | |
8696 | { | |
8697 | vty_out (vty, "%% %s is not a valid prefix-list name%s", | |
8698 | prefix_list_str, VTY_NEWLINE); | |
8699 | return CMD_WARNING; | |
8700 | } | |
8701 | ||
50ef26d4 | 8702 | return bgp_show (vty, bgp, afi, safi, type, plist, 0); |
718e3744 | 8703 | } |
8704 | ||
8705 | DEFUN (show_ip_bgp_prefix_list, | |
8706 | show_ip_bgp_prefix_list_cmd, | |
8707 | "show ip bgp prefix-list WORD", | |
8708 | SHOW_STR | |
8709 | IP_STR | |
8710 | BGP_STR | |
8711 | "Display routes conforming to the prefix-list\n" | |
8712 | "IP prefix-list name\n") | |
8713 | { | |
50ef26d4 | 8714 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
8715 | bgp_show_type_prefix_list); | |
8716 | } | |
8717 | ||
8386ac43 | 8718 | DEFUN (show_ip_bgp_instance_prefix_list, |
8719 | show_ip_bgp_instance_prefix_list_cmd, | |
8720 | "show ip bgp " BGP_INSTANCE_CMD " prefix-list WORD", | |
50ef26d4 | 8721 | SHOW_STR |
8722 | IP_STR | |
8723 | BGP_STR | |
8386ac43 | 8724 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8725 | "Display routes conforming to the prefix-list\n" |
8726 | "IP prefix-list name\n") | |
8727 | { | |
8728 | return bgp_show_prefix_list (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 8729 | bgp_show_type_prefix_list); |
8730 | } | |
8731 | ||
8732 | DEFUN (show_ip_bgp_flap_prefix_list, | |
8733 | show_ip_bgp_flap_prefix_list_cmd, | |
8734 | "show ip bgp flap-statistics prefix-list WORD", | |
8735 | SHOW_STR | |
8736 | IP_STR | |
8737 | BGP_STR | |
8738 | "Display flap statistics of routes\n" | |
8739 | "Display routes conforming to the prefix-list\n" | |
8740 | "IP prefix-list name\n") | |
8741 | { | |
50ef26d4 | 8742 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 8743 | bgp_show_type_flap_prefix_list); |
8744 | } | |
8745 | ||
8746 | DEFUN (show_ip_bgp_ipv4_prefix_list, | |
8747 | show_ip_bgp_ipv4_prefix_list_cmd, | |
8748 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", | |
8749 | SHOW_STR | |
8750 | IP_STR | |
8751 | BGP_STR | |
8752 | "Address family\n" | |
8753 | "Address Family modifier\n" | |
8754 | "Address Family modifier\n" | |
8755 | "Display routes conforming to the prefix-list\n" | |
8756 | "IP prefix-list name\n") | |
8757 | { | |
8758 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 8759 | return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 8760 | bgp_show_type_prefix_list); |
8761 | ||
50ef26d4 | 8762 | return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 8763 | bgp_show_type_prefix_list); |
8764 | } | |
8765 | ||
8766 | #ifdef HAVE_IPV6 | |
8767 | DEFUN (show_bgp_prefix_list, | |
8768 | show_bgp_prefix_list_cmd, | |
8769 | "show bgp prefix-list WORD", | |
8770 | SHOW_STR | |
8771 | BGP_STR | |
8772 | "Display routes conforming to the prefix-list\n" | |
8773 | "IPv6 prefix-list name\n") | |
8774 | { | |
50ef26d4 | 8775 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 8776 | bgp_show_type_prefix_list); |
8777 | } | |
8778 | ||
8779 | ALIAS (show_bgp_prefix_list, | |
8780 | show_bgp_ipv6_prefix_list_cmd, | |
8781 | "show bgp ipv6 prefix-list WORD", | |
8782 | SHOW_STR | |
8783 | BGP_STR | |
8784 | "Address family\n" | |
8785 | "Display routes conforming to the prefix-list\n" | |
8786 | "IPv6 prefix-list name\n") | |
8787 | ||
8788 | /* old command */ | |
8789 | DEFUN (show_ipv6_bgp_prefix_list, | |
8790 | show_ipv6_bgp_prefix_list_cmd, | |
8791 | "show ipv6 bgp prefix-list WORD", | |
8792 | SHOW_STR | |
8793 | IPV6_STR | |
8794 | BGP_STR | |
8795 | "Display routes matching the prefix-list\n" | |
8796 | "IPv6 prefix-list name\n") | |
8797 | { | |
47e9b292 | 8798 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 8799 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 8800 | bgp_show_type_prefix_list); |
8801 | } | |
8802 | ||
8803 | /* old command */ | |
8804 | DEFUN (show_ipv6_mbgp_prefix_list, | |
8805 | show_ipv6_mbgp_prefix_list_cmd, | |
8806 | "show ipv6 mbgp prefix-list WORD", | |
8807 | SHOW_STR | |
8808 | IPV6_STR | |
8809 | MBGP_STR | |
8810 | "Display routes matching the prefix-list\n" | |
8811 | "IPv6 prefix-list name\n") | |
8812 | { | |
47e9b292 | 8813 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 8814 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, |
718e3744 | 8815 | bgp_show_type_prefix_list); |
8816 | } | |
8817 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 8818 | |
94f2b392 | 8819 | static int |
50ef26d4 | 8820 | bgp_show_filter_list (struct vty *vty, const char *name, |
8821 | const char *filter, afi_t afi, | |
718e3744 | 8822 | safi_t safi, enum bgp_show_type type) |
8823 | { | |
8824 | struct as_list *as_list; | |
50ef26d4 | 8825 | struct bgp *bgp = NULL; |
8826 | ||
8827 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
8828 | { | |
8829 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
8830 | return CMD_WARNING; | |
8831 | } | |
718e3744 | 8832 | |
8833 | as_list = as_list_lookup (filter); | |
8834 | if (as_list == NULL) | |
8835 | { | |
8836 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); | |
8837 | return CMD_WARNING; | |
8838 | } | |
8839 | ||
50ef26d4 | 8840 | return bgp_show (vty, bgp, afi, safi, type, as_list, 0); |
718e3744 | 8841 | } |
8842 | ||
8843 | DEFUN (show_ip_bgp_filter_list, | |
8844 | show_ip_bgp_filter_list_cmd, | |
8845 | "show ip bgp filter-list WORD", | |
8846 | SHOW_STR | |
8847 | IP_STR | |
8848 | BGP_STR | |
8849 | "Display routes conforming to the filter-list\n" | |
8850 | "Regular expression access list name\n") | |
8851 | { | |
50ef26d4 | 8852 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
8853 | bgp_show_type_filter_list); | |
8854 | } | |
8855 | ||
8386ac43 | 8856 | DEFUN (show_ip_bgp_instance_filter_list, |
8857 | show_ip_bgp_instance_filter_list_cmd, | |
8858 | "show ip bgp " BGP_INSTANCE_CMD " filter-list WORD", | |
50ef26d4 | 8859 | SHOW_STR |
8860 | IP_STR | |
8861 | BGP_STR | |
8386ac43 | 8862 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8863 | "Display routes conforming to the filter-list\n" |
8864 | "Regular expression access list name\n") | |
8865 | { | |
8866 | return bgp_show_filter_list (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 8867 | bgp_show_type_filter_list); |
8868 | } | |
8869 | ||
8870 | DEFUN (show_ip_bgp_flap_filter_list, | |
8871 | show_ip_bgp_flap_filter_list_cmd, | |
8872 | "show ip bgp flap-statistics filter-list WORD", | |
8873 | SHOW_STR | |
8874 | IP_STR | |
8875 | BGP_STR | |
8876 | "Display flap statistics of routes\n" | |
8877 | "Display routes conforming to the filter-list\n" | |
8878 | "Regular expression access list name\n") | |
8879 | { | |
50ef26d4 | 8880 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 8881 | bgp_show_type_flap_filter_list); |
8882 | } | |
8883 | ||
8884 | DEFUN (show_ip_bgp_ipv4_filter_list, | |
8885 | show_ip_bgp_ipv4_filter_list_cmd, | |
8886 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", | |
8887 | SHOW_STR | |
8888 | IP_STR | |
8889 | BGP_STR | |
8890 | "Address family\n" | |
8891 | "Address Family modifier\n" | |
8892 | "Address Family modifier\n" | |
8893 | "Display routes conforming to the filter-list\n" | |
8894 | "Regular expression access list name\n") | |
8895 | { | |
8896 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 8897 | return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 8898 | bgp_show_type_filter_list); |
8899 | ||
50ef26d4 | 8900 | return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 8901 | bgp_show_type_filter_list); |
8902 | } | |
8903 | ||
8904 | #ifdef HAVE_IPV6 | |
8905 | DEFUN (show_bgp_filter_list, | |
8906 | show_bgp_filter_list_cmd, | |
8907 | "show bgp filter-list WORD", | |
8908 | SHOW_STR | |
8909 | BGP_STR | |
8910 | "Display routes conforming to the filter-list\n" | |
8911 | "Regular expression access list name\n") | |
8912 | { | |
50ef26d4 | 8913 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 8914 | bgp_show_type_filter_list); |
8915 | } | |
8916 | ||
8917 | ALIAS (show_bgp_filter_list, | |
8918 | show_bgp_ipv6_filter_list_cmd, | |
8919 | "show bgp ipv6 filter-list WORD", | |
8920 | SHOW_STR | |
8921 | BGP_STR | |
8922 | "Address family\n" | |
8923 | "Display routes conforming to the filter-list\n" | |
8924 | "Regular expression access list name\n") | |
8925 | ||
8926 | /* old command */ | |
8927 | DEFUN (show_ipv6_bgp_filter_list, | |
8928 | show_ipv6_bgp_filter_list_cmd, | |
8929 | "show ipv6 bgp filter-list WORD", | |
8930 | SHOW_STR | |
8931 | IPV6_STR | |
8932 | BGP_STR | |
8933 | "Display routes conforming to the filter-list\n" | |
8934 | "Regular expression access list name\n") | |
8935 | { | |
47e9b292 | 8936 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 8937 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 8938 | bgp_show_type_filter_list); |
8939 | } | |
8940 | ||
8941 | /* old command */ | |
8942 | DEFUN (show_ipv6_mbgp_filter_list, | |
8943 | show_ipv6_mbgp_filter_list_cmd, | |
8944 | "show ipv6 mbgp filter-list WORD", | |
8945 | SHOW_STR | |
8946 | IPV6_STR | |
8947 | MBGP_STR | |
8948 | "Display routes conforming to the filter-list\n" | |
8949 | "Regular expression access list name\n") | |
8950 | { | |
47e9b292 | 8951 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 8952 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, |
718e3744 | 8953 | bgp_show_type_filter_list); |
8954 | } | |
8955 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 8956 | |
94f2b392 | 8957 | static int |
50ef26d4 | 8958 | bgp_show_route_map (struct vty *vty, const char *name, |
8959 | const char *rmap_str, afi_t afi, | |
718e3744 | 8960 | safi_t safi, enum bgp_show_type type) |
8961 | { | |
8962 | struct route_map *rmap; | |
50ef26d4 | 8963 | struct bgp *bgp = NULL; |
8964 | ||
8965 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
8966 | { | |
8967 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
8968 | return CMD_WARNING; | |
8969 | } | |
718e3744 | 8970 | |
8971 | rmap = route_map_lookup_by_name (rmap_str); | |
8972 | if (! rmap) | |
8973 | { | |
8974 | vty_out (vty, "%% %s is not a valid route-map name%s", | |
8975 | rmap_str, VTY_NEWLINE); | |
8976 | return CMD_WARNING; | |
8977 | } | |
8978 | ||
50ef26d4 | 8979 | return bgp_show (vty, bgp, afi, safi, type, rmap, 0); |
718e3744 | 8980 | } |
8981 | ||
8982 | DEFUN (show_ip_bgp_route_map, | |
8983 | show_ip_bgp_route_map_cmd, | |
8984 | "show ip bgp route-map WORD", | |
8985 | SHOW_STR | |
8986 | IP_STR | |
8987 | BGP_STR | |
8988 | "Display routes matching the route-map\n" | |
8989 | "A route-map to match on\n") | |
8990 | { | |
50ef26d4 | 8991 | return bgp_show_route_map (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
8992 | bgp_show_type_route_map); | |
8993 | } | |
8994 | ||
8386ac43 | 8995 | DEFUN (show_ip_bgp_instance_route_map, |
8996 | show_ip_bgp_instance_route_map_cmd, | |
8997 | "show ip bgp " BGP_INSTANCE_CMD " route-map WORD", | |
50ef26d4 | 8998 | SHOW_STR |
8999 | IP_STR | |
9000 | BGP_STR | |
8386ac43 | 9001 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 9002 | "Display routes matching the route-map\n" |
9003 | "A route-map to match on\n") | |
9004 | { | |
9005 | return bgp_show_route_map (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 9006 | bgp_show_type_route_map); |
9007 | } | |
9008 | ||
9009 | DEFUN (show_ip_bgp_flap_route_map, | |
9010 | show_ip_bgp_flap_route_map_cmd, | |
9011 | "show ip bgp flap-statistics route-map WORD", | |
9012 | SHOW_STR | |
9013 | IP_STR | |
9014 | BGP_STR | |
9015 | "Display flap statistics of routes\n" | |
9016 | "Display routes matching the route-map\n" | |
9017 | "A route-map to match on\n") | |
9018 | { | |
50ef26d4 | 9019 | return bgp_show_route_map (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 9020 | bgp_show_type_flap_route_map); |
9021 | } | |
9022 | ||
9023 | DEFUN (show_ip_bgp_ipv4_route_map, | |
9024 | show_ip_bgp_ipv4_route_map_cmd, | |
9025 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", | |
9026 | SHOW_STR | |
9027 | IP_STR | |
9028 | BGP_STR | |
9029 | "Address family\n" | |
9030 | "Address Family modifier\n" | |
9031 | "Address Family modifier\n" | |
9032 | "Display routes matching the route-map\n" | |
9033 | "A route-map to match on\n") | |
9034 | { | |
9035 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 9036 | return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 9037 | bgp_show_type_route_map); |
9038 | ||
50ef26d4 | 9039 | return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 9040 | bgp_show_type_route_map); |
9041 | } | |
9042 | ||
9043 | DEFUN (show_bgp_route_map, | |
9044 | show_bgp_route_map_cmd, | |
9045 | "show bgp route-map WORD", | |
9046 | SHOW_STR | |
9047 | BGP_STR | |
9048 | "Display routes matching the route-map\n" | |
9049 | "A route-map to match on\n") | |
9050 | { | |
50ef26d4 | 9051 | return bgp_show_route_map (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9052 | bgp_show_type_route_map); |
9053 | } | |
9054 | ||
9055 | ALIAS (show_bgp_route_map, | |
9056 | show_bgp_ipv6_route_map_cmd, | |
9057 | "show bgp ipv6 route-map WORD", | |
9058 | SHOW_STR | |
9059 | BGP_STR | |
9060 | "Address family\n" | |
9061 | "Display routes matching the route-map\n" | |
9062 | "A route-map to match on\n") | |
6b0655a2 | 9063 | |
718e3744 | 9064 | DEFUN (show_ip_bgp_cidr_only, |
9065 | show_ip_bgp_cidr_only_cmd, | |
9066 | "show ip bgp cidr-only", | |
9067 | SHOW_STR | |
9068 | IP_STR | |
9069 | BGP_STR | |
9070 | "Display only routes with non-natural netmasks\n") | |
9071 | { | |
9072 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9073 | bgp_show_type_cidr_only, NULL, 0); |
718e3744 | 9074 | } |
9075 | ||
9076 | DEFUN (show_ip_bgp_flap_cidr_only, | |
9077 | show_ip_bgp_flap_cidr_only_cmd, | |
9078 | "show ip bgp flap-statistics cidr-only", | |
9079 | SHOW_STR | |
9080 | IP_STR | |
9081 | BGP_STR | |
9082 | "Display flap statistics of routes\n" | |
9083 | "Display only routes with non-natural netmasks\n") | |
9084 | { | |
9085 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9086 | bgp_show_type_flap_cidr_only, NULL, 0); |
718e3744 | 9087 | } |
9088 | ||
9089 | DEFUN (show_ip_bgp_ipv4_cidr_only, | |
9090 | show_ip_bgp_ipv4_cidr_only_cmd, | |
9091 | "show ip bgp ipv4 (unicast|multicast) cidr-only", | |
9092 | SHOW_STR | |
9093 | IP_STR | |
9094 | BGP_STR | |
9095 | "Address family\n" | |
9096 | "Address Family modifier\n" | |
9097 | "Address Family modifier\n" | |
9098 | "Display only routes with non-natural netmasks\n") | |
9099 | { | |
9100 | if (strncmp (argv[0], "m", 1) == 0) | |
9101 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
b05a1c8b | 9102 | bgp_show_type_cidr_only, NULL, 0); |
718e3744 | 9103 | |
9104 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9105 | bgp_show_type_cidr_only, NULL, 0); |
718e3744 | 9106 | } |
6b0655a2 | 9107 | |
718e3744 | 9108 | DEFUN (show_ip_bgp_community_all, |
9109 | show_ip_bgp_community_all_cmd, | |
9110 | "show ip bgp community", | |
9111 | SHOW_STR | |
9112 | IP_STR | |
9113 | BGP_STR | |
9114 | "Display routes matching the communities\n") | |
9115 | { | |
9116 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9117 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9118 | } |
9119 | ||
9120 | DEFUN (show_ip_bgp_ipv4_community_all, | |
9121 | show_ip_bgp_ipv4_community_all_cmd, | |
9122 | "show ip bgp ipv4 (unicast|multicast) community", | |
9123 | SHOW_STR | |
9124 | IP_STR | |
9125 | BGP_STR | |
9126 | "Address family\n" | |
9127 | "Address Family modifier\n" | |
9128 | "Address Family modifier\n" | |
9129 | "Display routes matching the communities\n") | |
9130 | { | |
9131 | if (strncmp (argv[0], "m", 1) == 0) | |
9132 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
b05a1c8b | 9133 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9134 | |
9135 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9136 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9137 | } |
9138 | ||
9139 | #ifdef HAVE_IPV6 | |
9140 | DEFUN (show_bgp_community_all, | |
9141 | show_bgp_community_all_cmd, | |
9142 | "show bgp community", | |
9143 | SHOW_STR | |
9144 | BGP_STR | |
9145 | "Display routes matching the communities\n") | |
9146 | { | |
9147 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
b05a1c8b | 9148 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9149 | } |
9150 | ||
9151 | ALIAS (show_bgp_community_all, | |
9152 | show_bgp_ipv6_community_all_cmd, | |
9153 | "show bgp ipv6 community", | |
9154 | SHOW_STR | |
9155 | BGP_STR | |
9156 | "Address family\n" | |
9157 | "Display routes matching the communities\n") | |
9158 | ||
9159 | /* old command */ | |
9160 | DEFUN (show_ipv6_bgp_community_all, | |
9161 | show_ipv6_bgp_community_all_cmd, | |
9162 | "show ipv6 bgp community", | |
9163 | SHOW_STR | |
9164 | IPV6_STR | |
9165 | BGP_STR | |
9166 | "Display routes matching the communities\n") | |
9167 | { | |
47e9b292 | 9168 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9169 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
b05a1c8b | 9170 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9171 | } |
9172 | ||
9173 | /* old command */ | |
9174 | DEFUN (show_ipv6_mbgp_community_all, | |
9175 | show_ipv6_mbgp_community_all_cmd, | |
9176 | "show ipv6 mbgp community", | |
9177 | SHOW_STR | |
9178 | IPV6_STR | |
9179 | MBGP_STR | |
9180 | "Display routes matching the communities\n") | |
9181 | { | |
47e9b292 | 9182 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9183 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
b05a1c8b | 9184 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9185 | } |
9186 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 9187 | |
94f2b392 | 9188 | static int |
95cbbd2a ML |
9189 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
9190 | const char **argv, int exact, afi_t afi, safi_t safi) | |
718e3744 | 9191 | { |
9192 | struct community *com; | |
9193 | struct buffer *b; | |
95cbbd2a | 9194 | struct bgp *bgp; |
718e3744 | 9195 | int i; |
9196 | char *str; | |
9197 | int first = 0; | |
9198 | ||
95cbbd2a ML |
9199 | /* BGP structure lookup */ |
9200 | if (view_name) | |
9201 | { | |
9202 | bgp = bgp_lookup_by_name (view_name); | |
9203 | if (bgp == NULL) | |
9204 | { | |
6aeb9e78 | 9205 | vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
95cbbd2a ML |
9206 | return CMD_WARNING; |
9207 | } | |
9208 | } | |
9209 | else | |
9210 | { | |
9211 | bgp = bgp_get_default (); | |
9212 | if (bgp == NULL) | |
9213 | { | |
9214 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
9215 | return CMD_WARNING; | |
9216 | } | |
9217 | } | |
9218 | ||
718e3744 | 9219 | b = buffer_new (1024); |
9220 | for (i = 0; i < argc; i++) | |
9221 | { | |
9222 | if (first) | |
9223 | buffer_putc (b, ' '); | |
9224 | else | |
9225 | { | |
9226 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
9227 | continue; | |
9228 | first = 1; | |
9229 | } | |
9230 | ||
9231 | buffer_putstr (b, argv[i]); | |
9232 | } | |
9233 | buffer_putc (b, '\0'); | |
9234 | ||
9235 | str = buffer_getstr (b); | |
9236 | buffer_free (b); | |
9237 | ||
9238 | com = community_str2com (str); | |
3b8b1855 | 9239 | XFREE (MTYPE_TMP, str); |
718e3744 | 9240 | if (! com) |
9241 | { | |
9242 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); | |
9243 | return CMD_WARNING; | |
9244 | } | |
9245 | ||
95cbbd2a | 9246 | return bgp_show (vty, bgp, afi, safi, |
5a646650 | 9247 | (exact ? bgp_show_type_community_exact : |
b05a1c8b | 9248 | bgp_show_type_community), com, 0); |
718e3744 | 9249 | } |
9250 | ||
9251 | DEFUN (show_ip_bgp_community, | |
9252 | show_ip_bgp_community_cmd, | |
9253 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
9254 | SHOW_STR | |
9255 | IP_STR | |
9256 | BGP_STR | |
9257 | "Display routes matching the communities\n" | |
9258 | "community number\n" | |
9259 | "Do not send outside local AS (well-known community)\n" | |
9260 | "Do not advertise to any peer (well-known community)\n" | |
9261 | "Do not export to next AS (well-known community)\n") | |
9262 | { | |
95cbbd2a | 9263 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 9264 | } |
9265 | ||
9266 | ALIAS (show_ip_bgp_community, | |
9267 | show_ip_bgp_community2_cmd, | |
9268 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9269 | SHOW_STR | |
9270 | IP_STR | |
9271 | BGP_STR | |
9272 | "Display routes matching the communities\n" | |
9273 | "community number\n" | |
9274 | "Do not send outside local AS (well-known community)\n" | |
9275 | "Do not advertise to any peer (well-known community)\n" | |
9276 | "Do not export to next AS (well-known community)\n" | |
9277 | "community number\n" | |
9278 | "Do not send outside local AS (well-known community)\n" | |
9279 | "Do not advertise to any peer (well-known community)\n" | |
9280 | "Do not export to next AS (well-known community)\n") | |
9281 | ||
9282 | ALIAS (show_ip_bgp_community, | |
9283 | show_ip_bgp_community3_cmd, | |
9284 | "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)", | |
9285 | SHOW_STR | |
9286 | IP_STR | |
9287 | BGP_STR | |
9288 | "Display routes matching the communities\n" | |
9289 | "community number\n" | |
9290 | "Do not send outside local AS (well-known community)\n" | |
9291 | "Do not advertise to any peer (well-known community)\n" | |
9292 | "Do not export to next AS (well-known community)\n" | |
9293 | "community number\n" | |
9294 | "Do not send outside local AS (well-known community)\n" | |
9295 | "Do not advertise to any peer (well-known community)\n" | |
9296 | "Do not export to next AS (well-known community)\n" | |
9297 | "community number\n" | |
9298 | "Do not send outside local AS (well-known community)\n" | |
9299 | "Do not advertise to any peer (well-known community)\n" | |
9300 | "Do not export to next AS (well-known community)\n") | |
9301 | ||
9302 | ALIAS (show_ip_bgp_community, | |
9303 | show_ip_bgp_community4_cmd, | |
9304 | "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)", | |
9305 | SHOW_STR | |
9306 | IP_STR | |
9307 | BGP_STR | |
9308 | "Display routes matching the communities\n" | |
9309 | "community number\n" | |
9310 | "Do not send outside local AS (well-known community)\n" | |
9311 | "Do not advertise to any peer (well-known community)\n" | |
9312 | "Do not export to next AS (well-known community)\n" | |
9313 | "community number\n" | |
9314 | "Do not send outside local AS (well-known community)\n" | |
9315 | "Do not advertise to any peer (well-known community)\n" | |
9316 | "Do not export to next AS (well-known community)\n" | |
9317 | "community number\n" | |
9318 | "Do not send outside local AS (well-known community)\n" | |
9319 | "Do not advertise to any peer (well-known community)\n" | |
9320 | "Do not export to next AS (well-known community)\n" | |
9321 | "community number\n" | |
9322 | "Do not send outside local AS (well-known community)\n" | |
9323 | "Do not advertise to any peer (well-known community)\n" | |
9324 | "Do not export to next AS (well-known community)\n") | |
9325 | ||
9326 | DEFUN (show_ip_bgp_ipv4_community, | |
9327 | show_ip_bgp_ipv4_community_cmd, | |
9328 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
9329 | SHOW_STR | |
9330 | IP_STR | |
9331 | BGP_STR | |
9332 | "Address family\n" | |
9333 | "Address Family modifier\n" | |
9334 | "Address Family modifier\n" | |
9335 | "Display routes matching the communities\n" | |
9336 | "community number\n" | |
9337 | "Do not send outside local AS (well-known community)\n" | |
9338 | "Do not advertise to any peer (well-known community)\n" | |
9339 | "Do not export to next AS (well-known community)\n") | |
9340 | { | |
9341 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 9342 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
718e3744 | 9343 | |
95cbbd2a | 9344 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 9345 | } |
9346 | ||
9347 | ALIAS (show_ip_bgp_ipv4_community, | |
9348 | show_ip_bgp_ipv4_community2_cmd, | |
9349 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9350 | SHOW_STR | |
9351 | IP_STR | |
9352 | BGP_STR | |
9353 | "Address family\n" | |
9354 | "Address Family modifier\n" | |
9355 | "Address Family modifier\n" | |
9356 | "Display routes matching the communities\n" | |
9357 | "community number\n" | |
9358 | "Do not send outside local AS (well-known community)\n" | |
9359 | "Do not advertise to any peer (well-known community)\n" | |
9360 | "Do not export to next AS (well-known community)\n" | |
9361 | "community number\n" | |
9362 | "Do not send outside local AS (well-known community)\n" | |
9363 | "Do not advertise to any peer (well-known community)\n" | |
9364 | "Do not export to next AS (well-known community)\n") | |
9365 | ||
9366 | ALIAS (show_ip_bgp_ipv4_community, | |
9367 | show_ip_bgp_ipv4_community3_cmd, | |
9368 | "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)", | |
9369 | SHOW_STR | |
9370 | IP_STR | |
9371 | BGP_STR | |
9372 | "Address family\n" | |
9373 | "Address Family modifier\n" | |
9374 | "Address Family modifier\n" | |
9375 | "Display routes matching the communities\n" | |
9376 | "community number\n" | |
9377 | "Do not send outside local AS (well-known community)\n" | |
9378 | "Do not advertise to any peer (well-known community)\n" | |
9379 | "Do not export to next AS (well-known community)\n" | |
9380 | "community number\n" | |
9381 | "Do not send outside local AS (well-known community)\n" | |
9382 | "Do not advertise to any peer (well-known community)\n" | |
9383 | "Do not export to next AS (well-known community)\n" | |
9384 | "community number\n" | |
9385 | "Do not send outside local AS (well-known community)\n" | |
9386 | "Do not advertise to any peer (well-known community)\n" | |
9387 | "Do not export to next AS (well-known community)\n") | |
9388 | ||
9389 | ALIAS (show_ip_bgp_ipv4_community, | |
9390 | show_ip_bgp_ipv4_community4_cmd, | |
9391 | "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)", | |
9392 | SHOW_STR | |
9393 | IP_STR | |
9394 | BGP_STR | |
9395 | "Address family\n" | |
9396 | "Address Family modifier\n" | |
9397 | "Address Family modifier\n" | |
9398 | "Display routes matching the communities\n" | |
9399 | "community number\n" | |
9400 | "Do not send outside local AS (well-known community)\n" | |
9401 | "Do not advertise to any peer (well-known community)\n" | |
9402 | "Do not export to next AS (well-known community)\n" | |
9403 | "community number\n" | |
9404 | "Do not send outside local AS (well-known community)\n" | |
9405 | "Do not advertise to any peer (well-known community)\n" | |
9406 | "Do not export to next AS (well-known community)\n" | |
9407 | "community number\n" | |
9408 | "Do not send outside local AS (well-known community)\n" | |
9409 | "Do not advertise to any peer (well-known community)\n" | |
9410 | "Do not export to next AS (well-known community)\n" | |
9411 | "community number\n" | |
9412 | "Do not send outside local AS (well-known community)\n" | |
9413 | "Do not advertise to any peer (well-known community)\n" | |
9414 | "Do not export to next AS (well-known community)\n") | |
9415 | ||
8386ac43 | 9416 | DEFUN (show_bgp_instance_afi_safi_community_all, |
9417 | show_bgp_instance_afi_safi_community_all_cmd, | |
95cbbd2a | 9418 | #ifdef HAVE_IPV6 |
8386ac43 | 9419 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community", |
95cbbd2a | 9420 | #else |
8386ac43 | 9421 | "show bgp " BGP_INSTANCE_CMD " ipv4 (unicast|multicast) community", |
95cbbd2a ML |
9422 | #endif |
9423 | SHOW_STR | |
9424 | BGP_STR | |
8386ac43 | 9425 | BGP_INSTANCE_HELP_STR |
95cbbd2a ML |
9426 | "Address family\n" |
9427 | #ifdef HAVE_IPV6 | |
9428 | "Address family\n" | |
9429 | #endif | |
9430 | "Address Family modifier\n" | |
9431 | "Address Family modifier\n" | |
2b00515a | 9432 | "Display routes matching the communities\n") |
95cbbd2a ML |
9433 | { |
9434 | int afi; | |
9435 | int safi; | |
9436 | struct bgp *bgp; | |
9437 | ||
9438 | /* BGP structure lookup. */ | |
6aeb9e78 | 9439 | bgp = bgp_lookup_by_name (argv[1]); |
95cbbd2a ML |
9440 | if (bgp == NULL) |
9441 | { | |
6aeb9e78 | 9442 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
95cbbd2a ML |
9443 | return CMD_WARNING; |
9444 | } | |
9445 | ||
9446 | #ifdef HAVE_IPV6 | |
6aeb9e78 DS |
9447 | afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
9448 | safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
95cbbd2a ML |
9449 | #else |
9450 | afi = AFI_IP; | |
6aeb9e78 | 9451 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
95cbbd2a | 9452 | #endif |
b05a1c8b | 9453 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, 0); |
95cbbd2a ML |
9454 | } |
9455 | ||
8386ac43 | 9456 | DEFUN (show_bgp_instance_afi_safi_community, |
9457 | show_bgp_instance_afi_safi_community_cmd, | |
95cbbd2a | 9458 | #ifdef HAVE_IPV6 |
8386ac43 | 9459 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a | 9460 | #else |
8386ac43 | 9461 | "show bgp " BGP_INSTANCE_CMD " ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
9462 | #endif |
9463 | SHOW_STR | |
9464 | BGP_STR | |
8386ac43 | 9465 | BGP_INSTANCE_HELP_STR |
95cbbd2a ML |
9466 | "Address family\n" |
9467 | #ifdef HAVE_IPV6 | |
9468 | "Address family\n" | |
9469 | #endif | |
9470 | "Address family modifier\n" | |
9471 | "Address family modifier\n" | |
9472 | "Display routes matching the communities\n" | |
9473 | "community number\n" | |
9474 | "Do not send outside local AS (well-known community)\n" | |
9475 | "Do not advertise to any peer (well-known community)\n" | |
9476 | "Do not export to next AS (well-known community)\n") | |
9477 | { | |
9478 | int afi; | |
9479 | int safi; | |
9480 | ||
9481 | #ifdef HAVE_IPV6 | |
6aeb9e78 DS |
9482 | afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
9483 | safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
9484 | return bgp_show_community (vty, argv[1], argc-4, &argv[4], 0, afi, safi); | |
95cbbd2a ML |
9485 | #else |
9486 | afi = AFI_IP; | |
6aeb9e78 DS |
9487 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
9488 | return bgp_show_community (vty, argv[1], argc-3, &argv[3], 0, afi, safi); | |
95cbbd2a ML |
9489 | #endif |
9490 | } | |
9491 | ||
8386ac43 | 9492 | ALIAS (show_bgp_instance_afi_safi_community, |
9493 | show_bgp_instance_afi_safi_community2_cmd, | |
95cbbd2a | 9494 | #ifdef HAVE_IPV6 |
8386ac43 | 9495 | "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 | 9496 | #else |
8386ac43 | 9497 | "show bgp " BGP_INSTANCE_CMD " ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
9498 | #endif |
9499 | SHOW_STR | |
9500 | BGP_STR | |
8386ac43 | 9501 | BGP_INSTANCE_HELP_STR |
95cbbd2a ML |
9502 | "Address family\n" |
9503 | #ifdef HAVE_IPV6 | |
9504 | "Address family\n" | |
9505 | #endif | |
9506 | "Address family modifier\n" | |
9507 | "Address family modifier\n" | |
9508 | "Display routes matching the communities\n" | |
9509 | "community number\n" | |
9510 | "Do not send outside local AS (well-known community)\n" | |
9511 | "Do not advertise to any peer (well-known community)\n" | |
9512 | "Do not export to next AS (well-known community)\n" | |
9513 | "community number\n" | |
9514 | "Do not send outside local AS (well-known community)\n" | |
9515 | "Do not advertise to any peer (well-known community)\n" | |
9516 | "Do not export to next AS (well-known community)\n") | |
9517 | ||
8386ac43 | 9518 | ALIAS (show_bgp_instance_afi_safi_community, |
9519 | show_bgp_instance_afi_safi_community3_cmd, | |
95cbbd2a | 9520 | #ifdef HAVE_IPV6 |
8386ac43 | 9521 | "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 | 9522 | #else |
8386ac43 | 9523 | "show bgp " BGP_INSTANCE_CMD " 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)", |
95cbbd2a ML |
9524 | #endif |
9525 | SHOW_STR | |
9526 | BGP_STR | |
8386ac43 | 9527 | BGP_INSTANCE_HELP_STR |
95cbbd2a ML |
9528 | "Address family\n" |
9529 | #ifdef HAVE_IPV6 | |
9530 | "Address family\n" | |
9531 | #endif | |
9532 | "Address family modifier\n" | |
9533 | "Address family modifier\n" | |
9534 | "Display routes matching the communities\n" | |
9535 | "community number\n" | |
9536 | "Do not send outside local AS (well-known community)\n" | |
9537 | "Do not advertise to any peer (well-known community)\n" | |
9538 | "Do not export to next AS (well-known community)\n" | |
9539 | "community number\n" | |
9540 | "Do not send outside local AS (well-known community)\n" | |
9541 | "Do not advertise to any peer (well-known community)\n" | |
9542 | "Do not export to next AS (well-known community)\n" | |
9543 | "community number\n" | |
9544 | "Do not send outside local AS (well-known community)\n" | |
9545 | "Do not advertise to any peer (well-known community)\n" | |
9546 | "Do not export to next AS (well-known community)\n") | |
9547 | ||
8386ac43 | 9548 | ALIAS (show_bgp_instance_afi_safi_community, |
9549 | show_bgp_instance_afi_safi_community4_cmd, | |
95cbbd2a | 9550 | #ifdef HAVE_IPV6 |
8386ac43 | 9551 | "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 | 9552 | #else |
8386ac43 | 9553 | "show bgp " BGP_INSTANCE_CMD " 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)", |
95cbbd2a ML |
9554 | #endif |
9555 | SHOW_STR | |
9556 | BGP_STR | |
8386ac43 | 9557 | BGP_INSTANCE_HELP_STR |
95cbbd2a ML |
9558 | "Address family\n" |
9559 | #ifdef HAVE_IPV6 | |
9560 | "Address family\n" | |
9561 | #endif | |
9562 | "Address family modifier\n" | |
9563 | "Address family modifier\n" | |
9564 | "Display routes matching the communities\n" | |
9565 | "community number\n" | |
9566 | "Do not send outside local AS (well-known community)\n" | |
9567 | "Do not advertise to any peer (well-known community)\n" | |
9568 | "Do not export to next AS (well-known community)\n" | |
9569 | "community number\n" | |
9570 | "Do not send outside local AS (well-known community)\n" | |
9571 | "Do not advertise to any peer (well-known community)\n" | |
9572 | "Do not export to next AS (well-known community)\n" | |
9573 | "community number\n" | |
9574 | "Do not send outside local AS (well-known community)\n" | |
9575 | "Do not advertise to any peer (well-known community)\n" | |
9576 | "Do not export to next AS (well-known community)\n" | |
9577 | "community number\n" | |
9578 | "Do not send outside local AS (well-known community)\n" | |
9579 | "Do not advertise to any peer (well-known community)\n" | |
9580 | "Do not export to next AS (well-known community)\n") | |
9581 | ||
718e3744 | 9582 | DEFUN (show_ip_bgp_community_exact, |
9583 | show_ip_bgp_community_exact_cmd, | |
9584 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
9585 | SHOW_STR | |
9586 | IP_STR | |
9587 | BGP_STR | |
9588 | "Display routes matching the communities\n" | |
9589 | "community number\n" | |
9590 | "Do not send outside local AS (well-known community)\n" | |
9591 | "Do not advertise to any peer (well-known community)\n" | |
9592 | "Do not export to next AS (well-known community)\n" | |
9593 | "Exact match of the communities") | |
9594 | { | |
95cbbd2a | 9595 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 9596 | } |
9597 | ||
9598 | ALIAS (show_ip_bgp_community_exact, | |
9599 | show_ip_bgp_community2_exact_cmd, | |
9600 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
9601 | SHOW_STR | |
9602 | IP_STR | |
9603 | BGP_STR | |
9604 | "Display routes matching the communities\n" | |
9605 | "community number\n" | |
9606 | "Do not send outside local AS (well-known community)\n" | |
9607 | "Do not advertise to any peer (well-known community)\n" | |
9608 | "Do not export to next AS (well-known community)\n" | |
9609 | "community number\n" | |
9610 | "Do not send outside local AS (well-known community)\n" | |
9611 | "Do not advertise to any peer (well-known community)\n" | |
9612 | "Do not export to next AS (well-known community)\n" | |
9613 | "Exact match of the communities") | |
9614 | ||
9615 | ALIAS (show_ip_bgp_community_exact, | |
9616 | show_ip_bgp_community3_exact_cmd, | |
9617 | "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", | |
9618 | SHOW_STR | |
9619 | IP_STR | |
9620 | BGP_STR | |
9621 | "Display routes matching the communities\n" | |
9622 | "community number\n" | |
9623 | "Do not send outside local AS (well-known community)\n" | |
9624 | "Do not advertise to any peer (well-known community)\n" | |
9625 | "Do not export to next AS (well-known community)\n" | |
9626 | "community number\n" | |
9627 | "Do not send outside local AS (well-known community)\n" | |
9628 | "Do not advertise to any peer (well-known community)\n" | |
9629 | "Do not export to next AS (well-known community)\n" | |
9630 | "community number\n" | |
9631 | "Do not send outside local AS (well-known community)\n" | |
9632 | "Do not advertise to any peer (well-known community)\n" | |
9633 | "Do not export to next AS (well-known community)\n" | |
9634 | "Exact match of the communities") | |
9635 | ||
9636 | ALIAS (show_ip_bgp_community_exact, | |
9637 | show_ip_bgp_community4_exact_cmd, | |
9638 | "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", | |
9639 | SHOW_STR | |
9640 | IP_STR | |
9641 | BGP_STR | |
9642 | "Display routes matching the communities\n" | |
9643 | "community number\n" | |
9644 | "Do not send outside local AS (well-known community)\n" | |
9645 | "Do not advertise to any peer (well-known community)\n" | |
9646 | "Do not export to next AS (well-known community)\n" | |
9647 | "community number\n" | |
9648 | "Do not send outside local AS (well-known community)\n" | |
9649 | "Do not advertise to any peer (well-known community)\n" | |
9650 | "Do not export to next AS (well-known community)\n" | |
9651 | "community number\n" | |
9652 | "Do not send outside local AS (well-known community)\n" | |
9653 | "Do not advertise to any peer (well-known community)\n" | |
9654 | "Do not export to next AS (well-known community)\n" | |
9655 | "community number\n" | |
9656 | "Do not send outside local AS (well-known community)\n" | |
9657 | "Do not advertise to any peer (well-known community)\n" | |
9658 | "Do not export to next AS (well-known community)\n" | |
9659 | "Exact match of the communities") | |
9660 | ||
9661 | DEFUN (show_ip_bgp_ipv4_community_exact, | |
9662 | show_ip_bgp_ipv4_community_exact_cmd, | |
9663 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
9664 | SHOW_STR | |
9665 | IP_STR | |
9666 | BGP_STR | |
9667 | "Address family\n" | |
9668 | "Address Family modifier\n" | |
9669 | "Address Family modifier\n" | |
9670 | "Display routes matching the communities\n" | |
9671 | "community number\n" | |
9672 | "Do not send outside local AS (well-known community)\n" | |
9673 | "Do not advertise to any peer (well-known community)\n" | |
9674 | "Do not export to next AS (well-known community)\n" | |
9675 | "Exact match of the communities") | |
9676 | { | |
9677 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 9678 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
718e3744 | 9679 | |
95cbbd2a | 9680 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 9681 | } |
9682 | ||
9683 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
9684 | show_ip_bgp_ipv4_community2_exact_cmd, | |
9685 | "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", | |
9686 | SHOW_STR | |
9687 | IP_STR | |
9688 | BGP_STR | |
9689 | "Address family\n" | |
9690 | "Address Family modifier\n" | |
9691 | "Address Family modifier\n" | |
9692 | "Display routes matching the communities\n" | |
9693 | "community number\n" | |
9694 | "Do not send outside local AS (well-known community)\n" | |
9695 | "Do not advertise to any peer (well-known community)\n" | |
9696 | "Do not export to next AS (well-known community)\n" | |
9697 | "community number\n" | |
9698 | "Do not send outside local AS (well-known community)\n" | |
9699 | "Do not advertise to any peer (well-known community)\n" | |
9700 | "Do not export to next AS (well-known community)\n" | |
9701 | "Exact match of the communities") | |
9702 | ||
9703 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
9704 | show_ip_bgp_ipv4_community3_exact_cmd, | |
9705 | "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", | |
9706 | SHOW_STR | |
9707 | IP_STR | |
9708 | BGP_STR | |
9709 | "Address family\n" | |
9710 | "Address Family modifier\n" | |
9711 | "Address Family modifier\n" | |
9712 | "Display routes matching the communities\n" | |
9713 | "community number\n" | |
9714 | "Do not send outside local AS (well-known community)\n" | |
9715 | "Do not advertise to any peer (well-known community)\n" | |
9716 | "Do not export to next AS (well-known community)\n" | |
9717 | "community number\n" | |
9718 | "Do not send outside local AS (well-known community)\n" | |
9719 | "Do not advertise to any peer (well-known community)\n" | |
9720 | "Do not export to next AS (well-known community)\n" | |
9721 | "community number\n" | |
9722 | "Do not send outside local AS (well-known community)\n" | |
9723 | "Do not advertise to any peer (well-known community)\n" | |
9724 | "Do not export to next AS (well-known community)\n" | |
9725 | "Exact match of the communities") | |
9726 | ||
9727 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
9728 | show_ip_bgp_ipv4_community4_exact_cmd, | |
9729 | "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", | |
9730 | SHOW_STR | |
9731 | IP_STR | |
9732 | BGP_STR | |
9733 | "Address family\n" | |
9734 | "Address Family modifier\n" | |
9735 | "Address Family modifier\n" | |
9736 | "Display routes matching the communities\n" | |
9737 | "community number\n" | |
9738 | "Do not send outside local AS (well-known community)\n" | |
9739 | "Do not advertise to any peer (well-known community)\n" | |
9740 | "Do not export to next AS (well-known community)\n" | |
9741 | "community number\n" | |
9742 | "Do not send outside local AS (well-known community)\n" | |
9743 | "Do not advertise to any peer (well-known community)\n" | |
9744 | "Do not export to next AS (well-known community)\n" | |
9745 | "community number\n" | |
9746 | "Do not send outside local AS (well-known community)\n" | |
9747 | "Do not advertise to any peer (well-known community)\n" | |
9748 | "Do not export to next AS (well-known community)\n" | |
9749 | "community number\n" | |
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 | "Exact match of the communities") | |
9754 | ||
9755 | #ifdef HAVE_IPV6 | |
9756 | DEFUN (show_bgp_community, | |
9757 | show_bgp_community_cmd, | |
9758 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
9759 | SHOW_STR | |
9760 | BGP_STR | |
9761 | "Display routes matching the communities\n" | |
9762 | "community number\n" | |
9763 | "Do not send outside local AS (well-known community)\n" | |
9764 | "Do not advertise to any peer (well-known community)\n" | |
9765 | "Do not export to next AS (well-known community)\n") | |
9766 | { | |
95cbbd2a | 9767 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 9768 | } |
9769 | ||
9770 | ALIAS (show_bgp_community, | |
9771 | show_bgp_ipv6_community_cmd, | |
9772 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", | |
9773 | SHOW_STR | |
9774 | BGP_STR | |
9775 | "Address family\n" | |
9776 | "Display routes matching the communities\n" | |
9777 | "community number\n" | |
9778 | "Do not send outside local AS (well-known community)\n" | |
9779 | "Do not advertise to any peer (well-known community)\n" | |
9780 | "Do not export to next AS (well-known community)\n") | |
9781 | ||
9782 | ALIAS (show_bgp_community, | |
9783 | show_bgp_community2_cmd, | |
9784 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9785 | SHOW_STR | |
9786 | BGP_STR | |
9787 | "Display routes matching the communities\n" | |
9788 | "community number\n" | |
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 | "community number\n" | |
9793 | "Do not send outside local AS (well-known community)\n" | |
9794 | "Do not advertise to any peer (well-known community)\n" | |
9795 | "Do not export to next AS (well-known community)\n") | |
9796 | ||
9797 | ALIAS (show_bgp_community, | |
9798 | show_bgp_ipv6_community2_cmd, | |
9799 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9800 | SHOW_STR | |
9801 | BGP_STR | |
9802 | "Address family\n" | |
9803 | "Display routes matching the communities\n" | |
9804 | "community number\n" | |
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" | |
9808 | "community number\n" | |
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") | |
9812 | ||
9813 | ALIAS (show_bgp_community, | |
9814 | show_bgp_community3_cmd, | |
9815 | "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)", | |
9816 | SHOW_STR | |
9817 | BGP_STR | |
9818 | "Display routes matching the communities\n" | |
9819 | "community number\n" | |
9820 | "Do not send outside local AS (well-known community)\n" | |
9821 | "Do not advertise to any peer (well-known community)\n" | |
9822 | "Do not export to next AS (well-known community)\n" | |
9823 | "community number\n" | |
9824 | "Do not send outside local AS (well-known community)\n" | |
9825 | "Do not advertise to any peer (well-known community)\n" | |
9826 | "Do not export to next AS (well-known community)\n" | |
9827 | "community number\n" | |
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 | ALIAS (show_bgp_community, | |
9833 | show_bgp_ipv6_community3_cmd, | |
9834 | "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)", | |
9835 | SHOW_STR | |
9836 | BGP_STR | |
9837 | "Address family\n" | |
9838 | "Display routes matching the communities\n" | |
9839 | "community number\n" | |
9840 | "Do not send outside local AS (well-known community)\n" | |
9841 | "Do not advertise to any peer (well-known community)\n" | |
9842 | "Do not export to next AS (well-known community)\n" | |
9843 | "community number\n" | |
9844 | "Do not send outside local AS (well-known community)\n" | |
9845 | "Do not advertise to any peer (well-known community)\n" | |
9846 | "Do not export to next AS (well-known community)\n" | |
9847 | "community number\n" | |
9848 | "Do not send outside local AS (well-known community)\n" | |
9849 | "Do not advertise to any peer (well-known community)\n" | |
9850 | "Do not export to next AS (well-known community)\n") | |
9851 | ||
9852 | ALIAS (show_bgp_community, | |
9853 | show_bgp_community4_cmd, | |
9854 | "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)", | |
9855 | SHOW_STR | |
9856 | BGP_STR | |
9857 | "Display routes matching the communities\n" | |
9858 | "community number\n" | |
9859 | "Do not send outside local AS (well-known community)\n" | |
9860 | "Do not advertise to any peer (well-known community)\n" | |
9861 | "Do not export to next AS (well-known community)\n" | |
9862 | "community number\n" | |
9863 | "Do not send outside local AS (well-known community)\n" | |
9864 | "Do not advertise to any peer (well-known community)\n" | |
9865 | "Do not export to next AS (well-known community)\n" | |
9866 | "community number\n" | |
9867 | "Do not send outside local AS (well-known community)\n" | |
9868 | "Do not advertise to any peer (well-known community)\n" | |
9869 | "Do not export to next AS (well-known community)\n" | |
9870 | "community number\n" | |
9871 | "Do not send outside local AS (well-known community)\n" | |
9872 | "Do not advertise to any peer (well-known community)\n" | |
9873 | "Do not export to next AS (well-known community)\n") | |
9874 | ||
9875 | ALIAS (show_bgp_community, | |
9876 | show_bgp_ipv6_community4_cmd, | |
9877 | "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)", | |
9878 | SHOW_STR | |
9879 | BGP_STR | |
9880 | "Address family\n" | |
9881 | "Display routes matching the communities\n" | |
9882 | "community number\n" | |
9883 | "Do not send outside local AS (well-known community)\n" | |
9884 | "Do not advertise to any peer (well-known community)\n" | |
9885 | "Do not export to next AS (well-known community)\n" | |
9886 | "community number\n" | |
9887 | "Do not send outside local AS (well-known community)\n" | |
9888 | "Do not advertise to any peer (well-known community)\n" | |
9889 | "Do not export to next AS (well-known community)\n" | |
9890 | "community number\n" | |
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" | |
9894 | "community number\n" | |
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") | |
9898 | ||
9899 | /* old command */ | |
9900 | DEFUN (show_ipv6_bgp_community, | |
9901 | show_ipv6_bgp_community_cmd, | |
9902 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
9903 | SHOW_STR | |
9904 | IPV6_STR | |
9905 | BGP_STR | |
9906 | "Display routes matching the communities\n" | |
9907 | "community number\n" | |
9908 | "Do not send outside local AS (well-known community)\n" | |
9909 | "Do not advertise to any peer (well-known community)\n" | |
9910 | "Do not export to next AS (well-known community)\n") | |
9911 | { | |
47e9b292 | 9912 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 9913 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 9914 | } |
9915 | ||
9916 | /* old command */ | |
9917 | ALIAS (show_ipv6_bgp_community, | |
9918 | show_ipv6_bgp_community2_cmd, | |
9919 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9920 | SHOW_STR | |
9921 | IPV6_STR | |
9922 | BGP_STR | |
9923 | "Display routes matching the communities\n" | |
9924 | "community number\n" | |
9925 | "Do not send outside local AS (well-known community)\n" | |
9926 | "Do not advertise to any peer (well-known community)\n" | |
9927 | "Do not export to next AS (well-known community)\n" | |
9928 | "community number\n" | |
9929 | "Do not send outside local AS (well-known community)\n" | |
9930 | "Do not advertise to any peer (well-known community)\n" | |
9931 | "Do not export to next AS (well-known community)\n") | |
9932 | ||
9933 | /* old command */ | |
9934 | ALIAS (show_ipv6_bgp_community, | |
9935 | show_ipv6_bgp_community3_cmd, | |
9936 | "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)", | |
9937 | SHOW_STR | |
9938 | IPV6_STR | |
9939 | BGP_STR | |
9940 | "Display routes matching the communities\n" | |
9941 | "community number\n" | |
9942 | "Do not send outside local AS (well-known community)\n" | |
9943 | "Do not advertise to any peer (well-known community)\n" | |
9944 | "Do not export to next AS (well-known community)\n" | |
9945 | "community number\n" | |
9946 | "Do not send outside local AS (well-known community)\n" | |
9947 | "Do not advertise to any peer (well-known community)\n" | |
9948 | "Do not export to next AS (well-known community)\n" | |
9949 | "community number\n" | |
9950 | "Do not send outside local AS (well-known community)\n" | |
9951 | "Do not advertise to any peer (well-known community)\n" | |
9952 | "Do not export to next AS (well-known community)\n") | |
9953 | ||
9954 | /* old command */ | |
9955 | ALIAS (show_ipv6_bgp_community, | |
9956 | show_ipv6_bgp_community4_cmd, | |
9957 | "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)", | |
9958 | SHOW_STR | |
9959 | IPV6_STR | |
9960 | BGP_STR | |
9961 | "Display routes matching the communities\n" | |
9962 | "community number\n" | |
9963 | "Do not send outside local AS (well-known community)\n" | |
9964 | "Do not advertise to any peer (well-known community)\n" | |
9965 | "Do not export to next AS (well-known community)\n" | |
9966 | "community number\n" | |
9967 | "Do not send outside local AS (well-known community)\n" | |
9968 | "Do not advertise to any peer (well-known community)\n" | |
9969 | "Do not export to next AS (well-known community)\n" | |
9970 | "community number\n" | |
9971 | "Do not send outside local AS (well-known community)\n" | |
9972 | "Do not advertise to any peer (well-known community)\n" | |
9973 | "Do not export to next AS (well-known community)\n" | |
9974 | "community number\n" | |
9975 | "Do not send outside local AS (well-known community)\n" | |
9976 | "Do not advertise to any peer (well-known community)\n" | |
9977 | "Do not export to next AS (well-known community)\n") | |
9978 | ||
9979 | DEFUN (show_bgp_community_exact, | |
9980 | show_bgp_community_exact_cmd, | |
9981 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
9982 | SHOW_STR | |
9983 | BGP_STR | |
9984 | "Display routes matching the communities\n" | |
9985 | "community number\n" | |
9986 | "Do not send outside local AS (well-known community)\n" | |
9987 | "Do not advertise to any peer (well-known community)\n" | |
9988 | "Do not export to next AS (well-known community)\n" | |
9989 | "Exact match of the communities") | |
9990 | { | |
95cbbd2a | 9991 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 9992 | } |
9993 | ||
9994 | ALIAS (show_bgp_community_exact, | |
9995 | show_bgp_ipv6_community_exact_cmd, | |
9996 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
9997 | SHOW_STR | |
9998 | BGP_STR | |
9999 | "Address family\n" | |
10000 | "Display routes matching the communities\n" | |
10001 | "community number\n" | |
10002 | "Do not send outside local AS (well-known community)\n" | |
10003 | "Do not advertise to any peer (well-known community)\n" | |
10004 | "Do not export to next AS (well-known community)\n" | |
10005 | "Exact match of the communities") | |
10006 | ||
10007 | ALIAS (show_bgp_community_exact, | |
10008 | show_bgp_community2_exact_cmd, | |
10009 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10010 | SHOW_STR | |
10011 | BGP_STR | |
10012 | "Display routes matching the communities\n" | |
10013 | "community number\n" | |
10014 | "Do not send outside local AS (well-known community)\n" | |
10015 | "Do not advertise to any peer (well-known community)\n" | |
10016 | "Do not export to next AS (well-known community)\n" | |
10017 | "community number\n" | |
10018 | "Do not send outside local AS (well-known community)\n" | |
10019 | "Do not advertise to any peer (well-known community)\n" | |
10020 | "Do not export to next AS (well-known community)\n" | |
10021 | "Exact match of the communities") | |
10022 | ||
10023 | ALIAS (show_bgp_community_exact, | |
10024 | show_bgp_ipv6_community2_exact_cmd, | |
10025 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10026 | SHOW_STR | |
10027 | BGP_STR | |
10028 | "Address family\n" | |
10029 | "Display routes matching the communities\n" | |
10030 | "community number\n" | |
10031 | "Do not send outside local AS (well-known community)\n" | |
10032 | "Do not advertise to any peer (well-known community)\n" | |
10033 | "Do not export to next AS (well-known community)\n" | |
10034 | "community number\n" | |
10035 | "Do not send outside local AS (well-known community)\n" | |
10036 | "Do not advertise to any peer (well-known community)\n" | |
10037 | "Do not export to next AS (well-known community)\n" | |
10038 | "Exact match of the communities") | |
10039 | ||
10040 | ALIAS (show_bgp_community_exact, | |
10041 | show_bgp_community3_exact_cmd, | |
10042 | "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", | |
10043 | SHOW_STR | |
10044 | BGP_STR | |
10045 | "Display routes matching the communities\n" | |
10046 | "community number\n" | |
10047 | "Do not send outside local AS (well-known community)\n" | |
10048 | "Do not advertise to any peer (well-known community)\n" | |
10049 | "Do not export to next AS (well-known community)\n" | |
10050 | "community number\n" | |
10051 | "Do not send outside local AS (well-known community)\n" | |
10052 | "Do not advertise to any peer (well-known community)\n" | |
10053 | "Do not export to next AS (well-known community)\n" | |
10054 | "community number\n" | |
10055 | "Do not send outside local AS (well-known community)\n" | |
10056 | "Do not advertise to any peer (well-known community)\n" | |
10057 | "Do not export to next AS (well-known community)\n" | |
10058 | "Exact match of the communities") | |
10059 | ||
10060 | ALIAS (show_bgp_community_exact, | |
10061 | show_bgp_ipv6_community3_exact_cmd, | |
10062 | "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", | |
10063 | SHOW_STR | |
10064 | BGP_STR | |
10065 | "Address family\n" | |
10066 | "Display routes matching the communities\n" | |
10067 | "community number\n" | |
10068 | "Do not send outside local AS (well-known community)\n" | |
10069 | "Do not advertise to any peer (well-known community)\n" | |
10070 | "Do not export to next AS (well-known community)\n" | |
10071 | "community number\n" | |
10072 | "Do not send outside local AS (well-known community)\n" | |
10073 | "Do not advertise to any peer (well-known community)\n" | |
10074 | "Do not export to next AS (well-known community)\n" | |
10075 | "community number\n" | |
10076 | "Do not send outside local AS (well-known community)\n" | |
10077 | "Do not advertise to any peer (well-known community)\n" | |
10078 | "Do not export to next AS (well-known community)\n" | |
10079 | "Exact match of the communities") | |
10080 | ||
10081 | ALIAS (show_bgp_community_exact, | |
10082 | show_bgp_community4_exact_cmd, | |
10083 | "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", | |
10084 | SHOW_STR | |
10085 | BGP_STR | |
10086 | "Display routes matching the communities\n" | |
10087 | "community number\n" | |
10088 | "Do not send outside local AS (well-known community)\n" | |
10089 | "Do not advertise to any peer (well-known community)\n" | |
10090 | "Do not export to next AS (well-known community)\n" | |
10091 | "community number\n" | |
10092 | "Do not send outside local AS (well-known community)\n" | |
10093 | "Do not advertise to any peer (well-known community)\n" | |
10094 | "Do not export to next AS (well-known community)\n" | |
10095 | "community number\n" | |
10096 | "Do not send outside local AS (well-known community)\n" | |
10097 | "Do not advertise to any peer (well-known community)\n" | |
10098 | "Do not export to next AS (well-known community)\n" | |
10099 | "community number\n" | |
10100 | "Do not send outside local AS (well-known community)\n" | |
10101 | "Do not advertise to any peer (well-known community)\n" | |
10102 | "Do not export to next AS (well-known community)\n" | |
10103 | "Exact match of the communities") | |
10104 | ||
10105 | ALIAS (show_bgp_community_exact, | |
10106 | show_bgp_ipv6_community4_exact_cmd, | |
10107 | "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", | |
10108 | SHOW_STR | |
10109 | BGP_STR | |
10110 | "Address family\n" | |
10111 | "Display routes matching the communities\n" | |
10112 | "community number\n" | |
10113 | "Do not send outside local AS (well-known community)\n" | |
10114 | "Do not advertise to any peer (well-known community)\n" | |
10115 | "Do not export to next AS (well-known community)\n" | |
10116 | "community number\n" | |
10117 | "Do not send outside local AS (well-known community)\n" | |
10118 | "Do not advertise to any peer (well-known community)\n" | |
10119 | "Do not export to next AS (well-known community)\n" | |
10120 | "community number\n" | |
10121 | "Do not send outside local AS (well-known community)\n" | |
10122 | "Do not advertise to any peer (well-known community)\n" | |
10123 | "Do not export to next AS (well-known community)\n" | |
10124 | "community number\n" | |
10125 | "Do not send outside local AS (well-known community)\n" | |
10126 | "Do not advertise to any peer (well-known community)\n" | |
10127 | "Do not export to next AS (well-known community)\n" | |
10128 | "Exact match of the communities") | |
10129 | ||
10130 | /* old command */ | |
10131 | DEFUN (show_ipv6_bgp_community_exact, | |
10132 | show_ipv6_bgp_community_exact_cmd, | |
10133 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10134 | SHOW_STR | |
10135 | IPV6_STR | |
10136 | BGP_STR | |
10137 | "Display routes matching the communities\n" | |
10138 | "community number\n" | |
10139 | "Do not send outside local AS (well-known community)\n" | |
10140 | "Do not advertise to any peer (well-known community)\n" | |
10141 | "Do not export to next AS (well-known community)\n" | |
10142 | "Exact match of the communities") | |
10143 | { | |
47e9b292 | 10144 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10145 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10146 | } |
10147 | ||
10148 | /* old command */ | |
10149 | ALIAS (show_ipv6_bgp_community_exact, | |
10150 | show_ipv6_bgp_community2_exact_cmd, | |
10151 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10152 | SHOW_STR | |
10153 | IPV6_STR | |
10154 | BGP_STR | |
10155 | "Display routes matching the communities\n" | |
10156 | "community number\n" | |
10157 | "Do not send outside local AS (well-known community)\n" | |
10158 | "Do not advertise to any peer (well-known community)\n" | |
10159 | "Do not export to next AS (well-known community)\n" | |
10160 | "community number\n" | |
10161 | "Do not send outside local AS (well-known community)\n" | |
10162 | "Do not advertise to any peer (well-known community)\n" | |
10163 | "Do not export to next AS (well-known community)\n" | |
10164 | "Exact match of the communities") | |
10165 | ||
10166 | /* old command */ | |
10167 | ALIAS (show_ipv6_bgp_community_exact, | |
10168 | show_ipv6_bgp_community3_exact_cmd, | |
10169 | "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", | |
10170 | SHOW_STR | |
10171 | IPV6_STR | |
10172 | BGP_STR | |
10173 | "Display routes matching the communities\n" | |
10174 | "community number\n" | |
10175 | "Do not send outside local AS (well-known community)\n" | |
10176 | "Do not advertise to any peer (well-known community)\n" | |
10177 | "Do not export to next AS (well-known community)\n" | |
10178 | "community number\n" | |
10179 | "Do not send outside local AS (well-known community)\n" | |
10180 | "Do not advertise to any peer (well-known community)\n" | |
10181 | "Do not export to next AS (well-known community)\n" | |
10182 | "community number\n" | |
10183 | "Do not send outside local AS (well-known community)\n" | |
10184 | "Do not advertise to any peer (well-known community)\n" | |
10185 | "Do not export to next AS (well-known community)\n" | |
10186 | "Exact match of the communities") | |
10187 | ||
10188 | /* old command */ | |
10189 | ALIAS (show_ipv6_bgp_community_exact, | |
10190 | show_ipv6_bgp_community4_exact_cmd, | |
10191 | "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", | |
10192 | SHOW_STR | |
10193 | IPV6_STR | |
10194 | BGP_STR | |
10195 | "Display routes matching the communities\n" | |
10196 | "community number\n" | |
10197 | "Do not send outside local AS (well-known community)\n" | |
10198 | "Do not advertise to any peer (well-known community)\n" | |
10199 | "Do not export to next AS (well-known community)\n" | |
10200 | "community number\n" | |
10201 | "Do not send outside local AS (well-known community)\n" | |
10202 | "Do not advertise to any peer (well-known community)\n" | |
10203 | "Do not export to next AS (well-known community)\n" | |
10204 | "community number\n" | |
10205 | "Do not send outside local AS (well-known community)\n" | |
10206 | "Do not advertise to any peer (well-known community)\n" | |
10207 | "Do not export to next AS (well-known community)\n" | |
10208 | "community number\n" | |
10209 | "Do not send outside local AS (well-known community)\n" | |
10210 | "Do not advertise to any peer (well-known community)\n" | |
10211 | "Do not export to next AS (well-known community)\n" | |
10212 | "Exact match of the communities") | |
10213 | ||
10214 | /* old command */ | |
10215 | DEFUN (show_ipv6_mbgp_community, | |
10216 | show_ipv6_mbgp_community_cmd, | |
10217 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", | |
10218 | SHOW_STR | |
10219 | IPV6_STR | |
10220 | MBGP_STR | |
10221 | "Display routes matching the communities\n" | |
10222 | "community number\n" | |
10223 | "Do not send outside local AS (well-known community)\n" | |
10224 | "Do not advertise to any peer (well-known community)\n" | |
10225 | "Do not export to next AS (well-known community)\n") | |
10226 | { | |
47e9b292 | 10227 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10228 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10229 | } |
10230 | ||
10231 | /* old command */ | |
10232 | ALIAS (show_ipv6_mbgp_community, | |
10233 | show_ipv6_mbgp_community2_cmd, | |
10234 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10235 | SHOW_STR | |
10236 | IPV6_STR | |
10237 | MBGP_STR | |
10238 | "Display routes matching the communities\n" | |
10239 | "community number\n" | |
10240 | "Do not send outside local AS (well-known community)\n" | |
10241 | "Do not advertise to any peer (well-known community)\n" | |
10242 | "Do not export to next AS (well-known community)\n" | |
10243 | "community number\n" | |
10244 | "Do not send outside local AS (well-known community)\n" | |
10245 | "Do not advertise to any peer (well-known community)\n" | |
10246 | "Do not export to next AS (well-known community)\n") | |
10247 | ||
10248 | /* old command */ | |
10249 | ALIAS (show_ipv6_mbgp_community, | |
10250 | show_ipv6_mbgp_community3_cmd, | |
10251 | "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)", | |
10252 | SHOW_STR | |
10253 | IPV6_STR | |
10254 | MBGP_STR | |
10255 | "Display routes matching the communities\n" | |
10256 | "community number\n" | |
10257 | "Do not send outside local AS (well-known community)\n" | |
10258 | "Do not advertise to any peer (well-known community)\n" | |
10259 | "Do not export to next AS (well-known community)\n" | |
10260 | "community number\n" | |
10261 | "Do not send outside local AS (well-known community)\n" | |
10262 | "Do not advertise to any peer (well-known community)\n" | |
10263 | "Do not export to next AS (well-known community)\n" | |
10264 | "community number\n" | |
10265 | "Do not send outside local AS (well-known community)\n" | |
10266 | "Do not advertise to any peer (well-known community)\n" | |
10267 | "Do not export to next AS (well-known community)\n") | |
10268 | ||
10269 | /* old command */ | |
10270 | ALIAS (show_ipv6_mbgp_community, | |
10271 | show_ipv6_mbgp_community4_cmd, | |
10272 | "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)", | |
10273 | SHOW_STR | |
10274 | IPV6_STR | |
10275 | MBGP_STR | |
10276 | "Display routes matching the communities\n" | |
10277 | "community number\n" | |
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 | "community number\n" | |
10282 | "Do not send outside local AS (well-known community)\n" | |
10283 | "Do not advertise to any peer (well-known community)\n" | |
10284 | "Do not export to next AS (well-known community)\n" | |
10285 | "community number\n" | |
10286 | "Do not send outside local AS (well-known community)\n" | |
10287 | "Do not advertise to any peer (well-known community)\n" | |
10288 | "Do not export to next AS (well-known community)\n" | |
10289 | "community number\n" | |
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") | |
10293 | ||
10294 | /* old command */ | |
10295 | DEFUN (show_ipv6_mbgp_community_exact, | |
10296 | show_ipv6_mbgp_community_exact_cmd, | |
10297 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10298 | SHOW_STR | |
10299 | IPV6_STR | |
10300 | MBGP_STR | |
10301 | "Display routes matching the communities\n" | |
10302 | "community number\n" | |
10303 | "Do not send outside local AS (well-known community)\n" | |
10304 | "Do not advertise to any peer (well-known community)\n" | |
10305 | "Do not export to next AS (well-known community)\n" | |
10306 | "Exact match of the communities") | |
10307 | { | |
47e9b292 | 10308 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10309 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10310 | } |
10311 | ||
10312 | /* old command */ | |
10313 | ALIAS (show_ipv6_mbgp_community_exact, | |
10314 | show_ipv6_mbgp_community2_exact_cmd, | |
10315 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10316 | SHOW_STR | |
10317 | IPV6_STR | |
10318 | MBGP_STR | |
10319 | "Display routes matching the communities\n" | |
10320 | "community number\n" | |
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 | "community number\n" | |
10325 | "Do not send outside local AS (well-known community)\n" | |
10326 | "Do not advertise to any peer (well-known community)\n" | |
10327 | "Do not export to next AS (well-known community)\n" | |
10328 | "Exact match of the communities") | |
10329 | ||
10330 | /* old command */ | |
10331 | ALIAS (show_ipv6_mbgp_community_exact, | |
10332 | show_ipv6_mbgp_community3_exact_cmd, | |
10333 | "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", | |
10334 | SHOW_STR | |
10335 | IPV6_STR | |
10336 | MBGP_STR | |
10337 | "Display routes matching the communities\n" | |
10338 | "community number\n" | |
10339 | "Do not send outside local AS (well-known community)\n" | |
10340 | "Do not advertise to any peer (well-known community)\n" | |
10341 | "Do not export to next AS (well-known community)\n" | |
10342 | "community number\n" | |
10343 | "Do not send outside local AS (well-known community)\n" | |
10344 | "Do not advertise to any peer (well-known community)\n" | |
10345 | "Do not export to next AS (well-known community)\n" | |
10346 | "community number\n" | |
10347 | "Do not send outside local AS (well-known community)\n" | |
10348 | "Do not advertise to any peer (well-known community)\n" | |
10349 | "Do not export to next AS (well-known community)\n" | |
10350 | "Exact match of the communities") | |
10351 | ||
10352 | /* old command */ | |
10353 | ALIAS (show_ipv6_mbgp_community_exact, | |
10354 | show_ipv6_mbgp_community4_exact_cmd, | |
10355 | "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", | |
10356 | SHOW_STR | |
10357 | IPV6_STR | |
10358 | MBGP_STR | |
10359 | "Display routes matching the communities\n" | |
10360 | "community number\n" | |
10361 | "Do not send outside local AS (well-known community)\n" | |
10362 | "Do not advertise to any peer (well-known community)\n" | |
10363 | "Do not export to next AS (well-known community)\n" | |
10364 | "community number\n" | |
10365 | "Do not send outside local AS (well-known community)\n" | |
10366 | "Do not advertise to any peer (well-known community)\n" | |
10367 | "Do not export to next AS (well-known community)\n" | |
10368 | "community number\n" | |
10369 | "Do not send outside local AS (well-known community)\n" | |
10370 | "Do not advertise to any peer (well-known community)\n" | |
10371 | "Do not export to next AS (well-known community)\n" | |
10372 | "community number\n" | |
10373 | "Do not send outside local AS (well-known community)\n" | |
10374 | "Do not advertise to any peer (well-known community)\n" | |
10375 | "Do not export to next AS (well-known community)\n" | |
10376 | "Exact match of the communities") | |
10377 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 10378 | |
94f2b392 | 10379 | static int |
50ef26d4 | 10380 | bgp_show_community_list (struct vty *vty, const char *name, |
10381 | const char *com, int exact, | |
4c9641ba | 10382 | afi_t afi, safi_t safi) |
718e3744 | 10383 | { |
10384 | struct community_list *list; | |
50ef26d4 | 10385 | struct bgp *bgp = NULL; |
10386 | ||
10387 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
10388 | { | |
10389 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
10390 | return CMD_WARNING; | |
10391 | } | |
718e3744 | 10392 | |
fee6e4e4 | 10393 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
718e3744 | 10394 | if (list == NULL) |
10395 | { | |
10396 | vty_out (vty, "%% %s is not a valid community-list name%s", com, | |
10397 | VTY_NEWLINE); | |
10398 | return CMD_WARNING; | |
10399 | } | |
10400 | ||
50ef26d4 | 10401 | return bgp_show (vty, bgp, afi, safi, |
5a646650 | 10402 | (exact ? bgp_show_type_community_list_exact : |
b05a1c8b | 10403 | bgp_show_type_community_list), list, 0); |
718e3744 | 10404 | } |
10405 | ||
10406 | DEFUN (show_ip_bgp_community_list, | |
10407 | show_ip_bgp_community_list_cmd, | |
fee6e4e4 | 10408 | "show ip bgp community-list (<1-500>|WORD)", |
718e3744 | 10409 | SHOW_STR |
10410 | IP_STR | |
10411 | BGP_STR | |
10412 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10413 | "community-list number\n" |
718e3744 | 10414 | "community-list name\n") |
10415 | { | |
50ef26d4 | 10416 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP, SAFI_UNICAST); |
10417 | } | |
10418 | ||
8386ac43 | 10419 | DEFUN (show_ip_bgp_instance_community_list, |
10420 | show_ip_bgp_instance_community_list_cmd, | |
10421 | "show ip bgp " BGP_INSTANCE_CMD " community-list (<1-500>|WORD)", | |
50ef26d4 | 10422 | SHOW_STR |
10423 | IP_STR | |
10424 | BGP_STR | |
8386ac43 | 10425 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 10426 | "Display routes matching the community-list\n" |
10427 | "community-list number\n" | |
10428 | "community-list name\n") | |
10429 | { | |
10430 | return bgp_show_community_list (vty, argv[1], argv[2], 0, AFI_IP, SAFI_UNICAST); | |
718e3744 | 10431 | } |
10432 | ||
10433 | DEFUN (show_ip_bgp_ipv4_community_list, | |
10434 | show_ip_bgp_ipv4_community_list_cmd, | |
fee6e4e4 | 10435 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
718e3744 | 10436 | SHOW_STR |
10437 | IP_STR | |
10438 | BGP_STR | |
10439 | "Address family\n" | |
10440 | "Address Family modifier\n" | |
10441 | "Address Family modifier\n" | |
10442 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10443 | "community-list number\n" |
718e3744 | 10444 | "community-list name\n") |
10445 | { | |
10446 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 10447 | return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
718e3744 | 10448 | |
50ef26d4 | 10449 | return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 10450 | } |
10451 | ||
10452 | DEFUN (show_ip_bgp_community_list_exact, | |
10453 | show_ip_bgp_community_list_exact_cmd, | |
fee6e4e4 | 10454 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 10455 | SHOW_STR |
10456 | IP_STR | |
10457 | BGP_STR | |
10458 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10459 | "community-list number\n" |
718e3744 | 10460 | "community-list name\n" |
10461 | "Exact match of the communities\n") | |
10462 | { | |
50ef26d4 | 10463 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10464 | } |
10465 | ||
10466 | DEFUN (show_ip_bgp_ipv4_community_list_exact, | |
10467 | show_ip_bgp_ipv4_community_list_exact_cmd, | |
fee6e4e4 | 10468 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
718e3744 | 10469 | SHOW_STR |
10470 | IP_STR | |
10471 | BGP_STR | |
10472 | "Address family\n" | |
10473 | "Address Family modifier\n" | |
10474 | "Address Family modifier\n" | |
10475 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10476 | "community-list number\n" |
718e3744 | 10477 | "community-list name\n" |
10478 | "Exact match of the communities\n") | |
10479 | { | |
10480 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 10481 | return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
718e3744 | 10482 | |
50ef26d4 | 10483 | return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10484 | } |
10485 | ||
10486 | #ifdef HAVE_IPV6 | |
10487 | DEFUN (show_bgp_community_list, | |
10488 | show_bgp_community_list_cmd, | |
fee6e4e4 | 10489 | "show bgp community-list (<1-500>|WORD)", |
718e3744 | 10490 | SHOW_STR |
10491 | BGP_STR | |
10492 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10493 | "community-list number\n" |
718e3744 | 10494 | "community-list name\n") |
10495 | { | |
50ef26d4 | 10496 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10497 | } |
10498 | ||
10499 | ALIAS (show_bgp_community_list, | |
10500 | show_bgp_ipv6_community_list_cmd, | |
fee6e4e4 | 10501 | "show bgp ipv6 community-list (<1-500>|WORD)", |
718e3744 | 10502 | SHOW_STR |
10503 | BGP_STR | |
10504 | "Address family\n" | |
10505 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10506 | "community-list number\n" |
e8e1946e | 10507 | "community-list name\n") |
718e3744 | 10508 | |
10509 | /* old command */ | |
10510 | DEFUN (show_ipv6_bgp_community_list, | |
10511 | show_ipv6_bgp_community_list_cmd, | |
10512 | "show ipv6 bgp community-list WORD", | |
10513 | SHOW_STR | |
10514 | IPV6_STR | |
10515 | BGP_STR | |
10516 | "Display routes matching the community-list\n" | |
10517 | "community-list name\n") | |
10518 | { | |
47e9b292 | 10519 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10520 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10521 | } |
10522 | ||
10523 | /* old command */ | |
10524 | DEFUN (show_ipv6_mbgp_community_list, | |
10525 | show_ipv6_mbgp_community_list_cmd, | |
10526 | "show ipv6 mbgp community-list WORD", | |
10527 | SHOW_STR | |
10528 | IPV6_STR | |
10529 | MBGP_STR | |
10530 | "Display routes matching the community-list\n" | |
10531 | "community-list name\n") | |
10532 | { | |
47e9b292 | 10533 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10534 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10535 | } |
10536 | ||
10537 | DEFUN (show_bgp_community_list_exact, | |
10538 | show_bgp_community_list_exact_cmd, | |
fee6e4e4 | 10539 | "show bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 10540 | SHOW_STR |
10541 | BGP_STR | |
10542 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10543 | "community-list number\n" |
718e3744 | 10544 | "community-list name\n" |
10545 | "Exact match of the communities\n") | |
10546 | { | |
50ef26d4 | 10547 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10548 | } |
10549 | ||
10550 | ALIAS (show_bgp_community_list_exact, | |
10551 | show_bgp_ipv6_community_list_exact_cmd, | |
fee6e4e4 | 10552 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
718e3744 | 10553 | SHOW_STR |
10554 | BGP_STR | |
10555 | "Address family\n" | |
10556 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10557 | "community-list number\n" |
718e3744 | 10558 | "community-list name\n" |
10559 | "Exact match of the communities\n") | |
10560 | ||
10561 | /* old command */ | |
10562 | DEFUN (show_ipv6_bgp_community_list_exact, | |
10563 | show_ipv6_bgp_community_list_exact_cmd, | |
10564 | "show ipv6 bgp community-list WORD exact-match", | |
10565 | SHOW_STR | |
10566 | IPV6_STR | |
10567 | BGP_STR | |
10568 | "Display routes matching the community-list\n" | |
10569 | "community-list name\n" | |
10570 | "Exact match of the communities\n") | |
10571 | { | |
47e9b292 | 10572 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10573 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10574 | } |
10575 | ||
10576 | /* old command */ | |
10577 | DEFUN (show_ipv6_mbgp_community_list_exact, | |
10578 | show_ipv6_mbgp_community_list_exact_cmd, | |
10579 | "show ipv6 mbgp community-list WORD exact-match", | |
10580 | SHOW_STR | |
10581 | IPV6_STR | |
10582 | MBGP_STR | |
10583 | "Display routes matching the community-list\n" | |
10584 | "community-list name\n" | |
10585 | "Exact match of the communities\n") | |
10586 | { | |
47e9b292 | 10587 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10588 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10589 | } |
10590 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 10591 | |
94f2b392 | 10592 | static int |
50ef26d4 | 10593 | bgp_show_prefix_longer (struct vty *vty, const char *name, |
10594 | const char *prefix, afi_t afi, | |
718e3744 | 10595 | safi_t safi, enum bgp_show_type type) |
10596 | { | |
10597 | int ret; | |
10598 | struct prefix *p; | |
50ef26d4 | 10599 | struct bgp *bgp = NULL; |
10600 | ||
10601 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
10602 | { | |
10603 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
10604 | return CMD_WARNING; | |
10605 | } | |
718e3744 | 10606 | |
10607 | p = prefix_new(); | |
10608 | ||
10609 | ret = str2prefix (prefix, p); | |
10610 | if (! ret) | |
10611 | { | |
10612 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); | |
10613 | return CMD_WARNING; | |
10614 | } | |
10615 | ||
50ef26d4 | 10616 | ret = bgp_show (vty, bgp, afi, safi, type, p, 0); |
5a646650 | 10617 | prefix_free(p); |
10618 | return ret; | |
718e3744 | 10619 | } |
10620 | ||
10621 | DEFUN (show_ip_bgp_prefix_longer, | |
10622 | show_ip_bgp_prefix_longer_cmd, | |
10623 | "show ip bgp A.B.C.D/M longer-prefixes", | |
10624 | SHOW_STR | |
10625 | IP_STR | |
10626 | BGP_STR | |
10627 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
10628 | "Display route and more specific routes\n") | |
10629 | { | |
50ef26d4 | 10630 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
10631 | bgp_show_type_prefix_longer); | |
10632 | } | |
10633 | ||
8386ac43 | 10634 | DEFUN (show_ip_bgp_instance_prefix_longer, |
10635 | show_ip_bgp_instance_prefix_longer_cmd, | |
10636 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M longer-prefixes", | |
50ef26d4 | 10637 | SHOW_STR |
10638 | IP_STR | |
10639 | BGP_STR | |
8386ac43 | 10640 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 10641 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
10642 | "Display route and more specific routes\n") | |
10643 | { | |
10644 | return bgp_show_prefix_longer (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 10645 | bgp_show_type_prefix_longer); |
10646 | } | |
10647 | ||
10648 | DEFUN (show_ip_bgp_flap_prefix_longer, | |
10649 | show_ip_bgp_flap_prefix_longer_cmd, | |
10650 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", | |
10651 | SHOW_STR | |
10652 | IP_STR | |
10653 | BGP_STR | |
10654 | "Display flap statistics of routes\n" | |
10655 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
10656 | "Display route and more specific routes\n") | |
10657 | { | |
50ef26d4 | 10658 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 10659 | bgp_show_type_flap_prefix_longer); |
10660 | } | |
10661 | ||
10662 | DEFUN (show_ip_bgp_ipv4_prefix_longer, | |
10663 | show_ip_bgp_ipv4_prefix_longer_cmd, | |
10664 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", | |
10665 | SHOW_STR | |
10666 | IP_STR | |
10667 | BGP_STR | |
10668 | "Address family\n" | |
10669 | "Address Family modifier\n" | |
10670 | "Address Family modifier\n" | |
10671 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
10672 | "Display route and more specific routes\n") | |
10673 | { | |
10674 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 10675 | return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 10676 | bgp_show_type_prefix_longer); |
10677 | ||
50ef26d4 | 10678 | return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 10679 | bgp_show_type_prefix_longer); |
10680 | } | |
10681 | ||
10682 | DEFUN (show_ip_bgp_flap_address, | |
10683 | show_ip_bgp_flap_address_cmd, | |
10684 | "show ip bgp flap-statistics A.B.C.D", | |
10685 | SHOW_STR | |
10686 | IP_STR | |
10687 | BGP_STR | |
10688 | "Display flap statistics of routes\n" | |
10689 | "Network in the BGP routing table to display\n") | |
10690 | { | |
50ef26d4 | 10691 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 10692 | bgp_show_type_flap_address); |
10693 | } | |
10694 | ||
10695 | DEFUN (show_ip_bgp_flap_prefix, | |
10696 | show_ip_bgp_flap_prefix_cmd, | |
10697 | "show ip bgp flap-statistics A.B.C.D/M", | |
10698 | SHOW_STR | |
10699 | IP_STR | |
10700 | BGP_STR | |
10701 | "Display flap statistics of routes\n" | |
10702 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10703 | { | |
50ef26d4 | 10704 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 10705 | bgp_show_type_flap_prefix); |
10706 | } | |
10707 | #ifdef HAVE_IPV6 | |
10708 | DEFUN (show_bgp_prefix_longer, | |
10709 | show_bgp_prefix_longer_cmd, | |
10710 | "show bgp X:X::X:X/M longer-prefixes", | |
10711 | SHOW_STR | |
10712 | BGP_STR | |
10713 | "IPv6 prefix <network>/<length>\n" | |
10714 | "Display route and more specific routes\n") | |
10715 | { | |
50ef26d4 | 10716 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 10717 | bgp_show_type_prefix_longer); |
10718 | } | |
10719 | ||
10720 | ALIAS (show_bgp_prefix_longer, | |
10721 | show_bgp_ipv6_prefix_longer_cmd, | |
10722 | "show bgp ipv6 X:X::X:X/M longer-prefixes", | |
10723 | SHOW_STR | |
10724 | BGP_STR | |
10725 | "Address family\n" | |
10726 | "IPv6 prefix <network>/<length>\n" | |
10727 | "Display route and more specific routes\n") | |
10728 | ||
10729 | /* old command */ | |
10730 | DEFUN (show_ipv6_bgp_prefix_longer, | |
10731 | show_ipv6_bgp_prefix_longer_cmd, | |
10732 | "show ipv6 bgp X:X::X:X/M longer-prefixes", | |
10733 | SHOW_STR | |
10734 | IPV6_STR | |
10735 | BGP_STR | |
10736 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
10737 | "Display route and more specific routes\n") | |
10738 | { | |
47e9b292 | 10739 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10740 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 10741 | bgp_show_type_prefix_longer); |
10742 | } | |
10743 | ||
10744 | /* old command */ | |
10745 | DEFUN (show_ipv6_mbgp_prefix_longer, | |
10746 | show_ipv6_mbgp_prefix_longer_cmd, | |
10747 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", | |
10748 | SHOW_STR | |
10749 | IPV6_STR | |
10750 | MBGP_STR | |
10751 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
10752 | "Display route and more specific routes\n") | |
10753 | { | |
47e9b292 | 10754 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10755 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, |
718e3744 | 10756 | bgp_show_type_prefix_longer); |
10757 | } | |
10758 | #endif /* HAVE_IPV6 */ | |
bb46e94f | 10759 | |
94f2b392 | 10760 | static struct peer * |
fd79ac91 | 10761 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
856ca177 | 10762 | const char *ip_str, u_char use_json) |
bb46e94f | 10763 | { |
10764 | int ret; | |
10765 | struct bgp *bgp; | |
10766 | struct peer *peer; | |
10767 | union sockunion su; | |
10768 | ||
10769 | /* BGP structure lookup. */ | |
10770 | if (view_name) | |
10771 | { | |
10772 | bgp = bgp_lookup_by_name (view_name); | |
10773 | if (! bgp) | |
10774 | { | |
856ca177 MS |
10775 | if (use_json) |
10776 | { | |
10777 | json_object *json_no = NULL; | |
10778 | json_no = json_object_new_object(); | |
10779 | json_object_string_add(json_no, "warning", "Can't find BGP view"); | |
10780 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
10781 | json_object_free(json_no); | |
10782 | } | |
10783 | else | |
6aeb9e78 | 10784 | vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
bb46e94f | 10785 | return NULL; |
10786 | } | |
10787 | } | |
5228ad27 | 10788 | else |
bb46e94f | 10789 | { |
10790 | bgp = bgp_get_default (); | |
10791 | if (! bgp) | |
10792 | { | |
856ca177 MS |
10793 | if (use_json) |
10794 | { | |
10795 | json_object *json_no = NULL; | |
10796 | json_no = json_object_new_object(); | |
10797 | json_object_string_add(json_no, "warning", "No BGP process configured"); | |
10798 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
10799 | json_object_free(json_no); | |
10800 | } | |
10801 | else | |
10802 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
bb46e94f | 10803 | return NULL; |
10804 | } | |
10805 | } | |
10806 | ||
10807 | /* Get peer sockunion. */ | |
10808 | ret = str2sockunion (ip_str, &su); | |
10809 | if (ret < 0) | |
10810 | { | |
a80beece DS |
10811 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
10812 | if (!peer) | |
10813 | { | |
04b6bdc0 DW |
10814 | peer = peer_lookup_by_hostname(bgp, ip_str); |
10815 | ||
10816 | if (!peer) | |
856ca177 | 10817 | { |
04b6bdc0 DW |
10818 | if (use_json) |
10819 | { | |
10820 | json_object *json_no = NULL; | |
10821 | json_no = json_object_new_object(); | |
10822 | json_object_string_add(json_no, "malformedAddressOrName", ip_str); | |
10823 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
10824 | json_object_free(json_no); | |
10825 | } | |
10826 | else | |
10827 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
10828 | return NULL; | |
856ca177 | 10829 | } |
a80beece DS |
10830 | } |
10831 | return peer; | |
bb46e94f | 10832 | } |
10833 | ||
10834 | /* Peer structure lookup. */ | |
10835 | peer = peer_lookup (bgp, &su); | |
10836 | if (! peer) | |
10837 | { | |
856ca177 MS |
10838 | if (use_json) |
10839 | { | |
10840 | json_object *json_no = NULL; | |
10841 | json_no = json_object_new_object(); | |
10842 | json_object_string_add(json_no, "warning","No such neighbor"); | |
10843 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
10844 | json_object_free(json_no); | |
10845 | } | |
10846 | else | |
10847 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); | |
bb46e94f | 10848 | return NULL; |
10849 | } | |
10850 | ||
10851 | return peer; | |
10852 | } | |
6b0655a2 | 10853 | |
2815e61f PJ |
10854 | enum bgp_stats |
10855 | { | |
10856 | BGP_STATS_MAXBITLEN = 0, | |
10857 | BGP_STATS_RIB, | |
10858 | BGP_STATS_PREFIXES, | |
10859 | BGP_STATS_TOTPLEN, | |
10860 | BGP_STATS_UNAGGREGATEABLE, | |
10861 | BGP_STATS_MAX_AGGREGATEABLE, | |
10862 | BGP_STATS_AGGREGATES, | |
10863 | BGP_STATS_SPACE, | |
10864 | BGP_STATS_ASPATH_COUNT, | |
10865 | BGP_STATS_ASPATH_MAXHOPS, | |
10866 | BGP_STATS_ASPATH_TOTHOPS, | |
10867 | BGP_STATS_ASPATH_MAXSIZE, | |
10868 | BGP_STATS_ASPATH_TOTSIZE, | |
10869 | BGP_STATS_ASN_HIGHEST, | |
10870 | BGP_STATS_MAX, | |
10871 | }; | |
10872 | ||
10873 | static const char *table_stats_strs[] = | |
10874 | { | |
10875 | [BGP_STATS_PREFIXES] = "Total Prefixes", | |
10876 | [BGP_STATS_TOTPLEN] = "Average prefix length", | |
10877 | [BGP_STATS_RIB] = "Total Advertisements", | |
10878 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", | |
10879 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", | |
10880 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", | |
10881 | [BGP_STATS_SPACE] = "Address space advertised", | |
10882 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", | |
10883 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", | |
10884 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", | |
10885 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", | |
10886 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", | |
10887 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", | |
10888 | [BGP_STATS_MAX] = NULL, | |
10889 | }; | |
10890 | ||
10891 | struct bgp_table_stats | |
10892 | { | |
10893 | struct bgp_table *table; | |
10894 | unsigned long long counts[BGP_STATS_MAX]; | |
10895 | }; | |
10896 | ||
10897 | #if 0 | |
10898 | #define TALLY_SIGFIG 100000 | |
10899 | static unsigned long | |
10900 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) | |
10901 | { | |
10902 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); | |
10903 | unsigned long res = (newtot * TALLY_SIGFIG) / count; | |
10904 | unsigned long ret = newtot / count; | |
10905 | ||
10906 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) | |
10907 | return ret + 1; | |
10908 | else | |
10909 | return ret; | |
10910 | } | |
10911 | #endif | |
10912 | ||
10913 | static int | |
10914 | bgp_table_stats_walker (struct thread *t) | |
10915 | { | |
10916 | struct bgp_node *rn; | |
10917 | struct bgp_node *top; | |
10918 | struct bgp_table_stats *ts = THREAD_ARG (t); | |
10919 | unsigned int space = 0; | |
10920 | ||
53d9f67a PJ |
10921 | if (!(top = bgp_table_top (ts->table))) |
10922 | return 0; | |
2815e61f PJ |
10923 | |
10924 | switch (top->p.family) | |
10925 | { | |
10926 | case AF_INET: | |
10927 | space = IPV4_MAX_BITLEN; | |
10928 | break; | |
10929 | case AF_INET6: | |
10930 | space = IPV6_MAX_BITLEN; | |
10931 | break; | |
10932 | } | |
10933 | ||
10934 | ts->counts[BGP_STATS_MAXBITLEN] = space; | |
10935 | ||
10936 | for (rn = top; rn; rn = bgp_route_next (rn)) | |
10937 | { | |
10938 | struct bgp_info *ri; | |
67174041 | 10939 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
2815e61f PJ |
10940 | unsigned int rinum = 0; |
10941 | ||
10942 | if (rn == top) | |
10943 | continue; | |
10944 | ||
10945 | if (!rn->info) | |
10946 | continue; | |
10947 | ||
10948 | ts->counts[BGP_STATS_PREFIXES]++; | |
10949 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; | |
10950 | ||
10951 | #if 0 | |
10952 | ts->counts[BGP_STATS_AVGPLEN] | |
10953 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], | |
10954 | ts->counts[BGP_STATS_AVGPLEN], | |
10955 | rn->p.prefixlen); | |
10956 | #endif | |
10957 | ||
10958 | /* check if the prefix is included by any other announcements */ | |
10959 | while (prn && !prn->info) | |
67174041 | 10960 | prn = bgp_node_parent_nolock (prn); |
2815e61f PJ |
10961 | |
10962 | if (prn == NULL || prn == top) | |
8383a9bd PJ |
10963 | { |
10964 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; | |
10965 | /* announced address space */ | |
10966 | if (space) | |
10967 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); | |
10968 | } | |
2815e61f PJ |
10969 | else if (prn->info) |
10970 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; | |
10971 | ||
2815e61f PJ |
10972 | for (ri = rn->info; ri; ri = ri->next) |
10973 | { | |
10974 | rinum++; | |
10975 | ts->counts[BGP_STATS_RIB]++; | |
10976 | ||
10977 | if (ri->attr && | |
10978 | (CHECK_FLAG (ri->attr->flag, | |
10979 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) | |
10980 | ts->counts[BGP_STATS_AGGREGATES]++; | |
10981 | ||
10982 | /* as-path stats */ | |
10983 | if (ri->attr && ri->attr->aspath) | |
10984 | { | |
10985 | unsigned int hops = aspath_count_hops (ri->attr->aspath); | |
10986 | unsigned int size = aspath_size (ri->attr->aspath); | |
10987 | as_t highest = aspath_highest (ri->attr->aspath); | |
10988 | ||
10989 | ts->counts[BGP_STATS_ASPATH_COUNT]++; | |
10990 | ||
10991 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) | |
10992 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; | |
10993 | ||
10994 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) | |
10995 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; | |
10996 | ||
10997 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; | |
10998 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; | |
10999 | #if 0 | |
11000 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] | |
11001 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
11002 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], | |
11003 | hops); | |
11004 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] | |
11005 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
11006 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], | |
11007 | size); | |
11008 | #endif | |
11009 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) | |
11010 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; | |
11011 | } | |
11012 | } | |
11013 | } | |
11014 | return 0; | |
11015 | } | |
11016 | ||
11017 | static int | |
11018 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) | |
11019 | { | |
11020 | struct bgp_table_stats ts; | |
11021 | unsigned int i; | |
11022 | ||
11023 | if (!bgp->rib[afi][safi]) | |
11024 | { | |
06da0daf DS |
11025 | vty_out (vty, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s", |
11026 | afi, safi, VTY_NEWLINE); | |
2815e61f PJ |
11027 | return CMD_WARNING; |
11028 | } | |
11029 | ||
11030 | memset (&ts, 0, sizeof (ts)); | |
11031 | ts.table = bgp->rib[afi][safi]; | |
87d4a781 | 11032 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
bb46e94f | 11033 | |
2815e61f PJ |
11034 | vty_out (vty, "BGP %s RIB statistics%s%s", |
11035 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); | |
11036 | ||
11037 | for (i = 0; i < BGP_STATS_MAX; i++) | |
11038 | { | |
11039 | if (!table_stats_strs[i]) | |
11040 | continue; | |
11041 | ||
11042 | switch (i) | |
11043 | { | |
11044 | #if 0 | |
11045 | case BGP_STATS_ASPATH_AVGHOPS: | |
11046 | case BGP_STATS_ASPATH_AVGSIZE: | |
11047 | case BGP_STATS_AVGPLEN: | |
11048 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11049 | vty_out (vty, "%12.2f", | |
11050 | (float)ts.counts[i] / (float)TALLY_SIGFIG); | |
11051 | break; | |
11052 | #endif | |
11053 | case BGP_STATS_ASPATH_TOTHOPS: | |
11054 | case BGP_STATS_ASPATH_TOTSIZE: | |
11055 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11056 | vty_out (vty, "%12.2f", | |
11057 | ts.counts[i] ? | |
11058 | (float)ts.counts[i] / | |
11059 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] | |
11060 | : 0); | |
11061 | break; | |
11062 | case BGP_STATS_TOTPLEN: | |
11063 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11064 | vty_out (vty, "%12.2f", | |
11065 | ts.counts[i] ? | |
11066 | (float)ts.counts[i] / | |
11067 | (float)ts.counts[BGP_STATS_PREFIXES] | |
11068 | : 0); | |
11069 | break; | |
11070 | case BGP_STATS_SPACE: | |
11071 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11072 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); | |
11073 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) | |
11074 | break; | |
30a2231a | 11075 | vty_out (vty, "%30s: ", "%% announced "); |
2815e61f PJ |
11076 | vty_out (vty, "%12.2f%s", |
11077 | 100 * (float)ts.counts[BGP_STATS_SPACE] / | |
56395af7 | 11078 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
2815e61f PJ |
11079 | VTY_NEWLINE); |
11080 | vty_out (vty, "%30s: ", "/8 equivalent "); | |
11081 | vty_out (vty, "%12.2f%s", | |
11082 | (float)ts.counts[BGP_STATS_SPACE] / | |
11083 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), | |
11084 | VTY_NEWLINE); | |
11085 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) | |
11086 | break; | |
11087 | vty_out (vty, "%30s: ", "/24 equivalent "); | |
11088 | vty_out (vty, "%12.2f", | |
11089 | (float)ts.counts[BGP_STATS_SPACE] / | |
11090 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); | |
11091 | break; | |
11092 | default: | |
11093 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11094 | vty_out (vty, "%12llu", ts.counts[i]); | |
11095 | } | |
11096 | ||
11097 | vty_out (vty, "%s", VTY_NEWLINE); | |
11098 | } | |
11099 | return CMD_SUCCESS; | |
11100 | } | |
11101 | ||
11102 | static int | |
11103 | bgp_table_stats_vty (struct vty *vty, const char *name, | |
11104 | const char *afi_str, const char *safi_str) | |
11105 | { | |
11106 | struct bgp *bgp; | |
11107 | afi_t afi; | |
11108 | safi_t safi; | |
11109 | ||
11110 | if (name) | |
11111 | bgp = bgp_lookup_by_name (name); | |
11112 | else | |
11113 | bgp = bgp_get_default (); | |
11114 | ||
11115 | if (!bgp) | |
11116 | { | |
11117 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
11118 | return CMD_WARNING; | |
11119 | } | |
11120 | if (strncmp (afi_str, "ipv", 3) == 0) | |
11121 | { | |
11122 | if (strncmp (afi_str, "ipv4", 4) == 0) | |
11123 | afi = AFI_IP; | |
11124 | else if (strncmp (afi_str, "ipv6", 4) == 0) | |
11125 | afi = AFI_IP6; | |
11126 | else | |
11127 | { | |
11128 | vty_out (vty, "%% Invalid address family %s%s", | |
11129 | afi_str, VTY_NEWLINE); | |
11130 | return CMD_WARNING; | |
11131 | } | |
11132 | if (strncmp (safi_str, "m", 1) == 0) | |
11133 | safi = SAFI_MULTICAST; | |
11134 | else if (strncmp (safi_str, "u", 1) == 0) | |
11135 | safi = SAFI_UNICAST; | |
42e6d745 | 11136 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
06da0daf | 11137 | safi = SAFI_MPLS_VPN; |
2815e61f PJ |
11138 | else |
11139 | { | |
11140 | vty_out (vty, "%% Invalid subsequent address family %s%s", | |
11141 | safi_str, VTY_NEWLINE); | |
11142 | return CMD_WARNING; | |
11143 | } | |
11144 | } | |
11145 | else | |
11146 | { | |
11147 | vty_out (vty, "%% Invalid address family %s%s", | |
11148 | afi_str, VTY_NEWLINE); | |
11149 | return CMD_WARNING; | |
11150 | } | |
11151 | ||
2815e61f PJ |
11152 | return bgp_table_stats (vty, bgp, afi, safi); |
11153 | } | |
11154 | ||
11155 | DEFUN (show_bgp_statistics, | |
11156 | show_bgp_statistics_cmd, | |
11157 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", | |
11158 | SHOW_STR | |
11159 | BGP_STR | |
11160 | "Address family\n" | |
11161 | "Address family\n" | |
11162 | "Address Family modifier\n" | |
11163 | "Address Family modifier\n" | |
11164 | "BGP RIB advertisement statistics\n") | |
11165 | { | |
11166 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
11167 | } | |
11168 | ||
11169 | ALIAS (show_bgp_statistics, | |
11170 | show_bgp_statistics_vpnv4_cmd, | |
11171 | "show bgp (ipv4) (vpnv4) statistics", | |
11172 | SHOW_STR | |
11173 | BGP_STR | |
11174 | "Address family\n" | |
11175 | "Address Family modifier\n" | |
11176 | "BGP RIB advertisement statistics\n") | |
11177 | ||
11178 | DEFUN (show_bgp_statistics_view, | |
11179 | show_bgp_statistics_view_cmd, | |
8386ac43 | 11180 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) statistics", |
2815e61f PJ |
11181 | SHOW_STR |
11182 | BGP_STR | |
8386ac43 | 11183 | BGP_INSTANCE_HELP_STR |
2815e61f PJ |
11184 | "Address family\n" |
11185 | "Address family\n" | |
11186 | "Address Family modifier\n" | |
11187 | "Address Family modifier\n" | |
11188 | "BGP RIB advertisement statistics\n") | |
11189 | { | |
6aeb9e78 | 11190 | return bgp_table_stats_vty (vty, NULL, argv[1], argv[2]); |
2815e61f PJ |
11191 | } |
11192 | ||
11193 | ALIAS (show_bgp_statistics_view, | |
11194 | show_bgp_statistics_view_vpnv4_cmd, | |
8386ac43 | 11195 | "show bgp " BGP_INSTANCE_CMD " (ipv4) (vpnv4) statistics", |
2815e61f PJ |
11196 | SHOW_STR |
11197 | BGP_STR | |
8386ac43 | 11198 | BGP_INSTANCE_HELP_STR |
2815e61f PJ |
11199 | "Address family\n" |
11200 | "Address Family modifier\n" | |
11201 | "BGP RIB advertisement statistics\n") | |
6b0655a2 | 11202 | |
ff7924f6 PJ |
11203 | enum bgp_pcounts |
11204 | { | |
11205 | PCOUNT_ADJ_IN = 0, | |
11206 | PCOUNT_DAMPED, | |
11207 | PCOUNT_REMOVED, | |
11208 | PCOUNT_HISTORY, | |
11209 | PCOUNT_STALE, | |
11210 | PCOUNT_VALID, | |
11211 | PCOUNT_ALL, | |
11212 | PCOUNT_COUNTED, | |
11213 | PCOUNT_PFCNT, /* the figure we display to users */ | |
11214 | PCOUNT_MAX, | |
11215 | }; | |
11216 | ||
11217 | static const char *pcount_strs[] = | |
11218 | { | |
11219 | [PCOUNT_ADJ_IN] = "Adj-in", | |
11220 | [PCOUNT_DAMPED] = "Damped", | |
11221 | [PCOUNT_REMOVED] = "Removed", | |
11222 | [PCOUNT_HISTORY] = "History", | |
11223 | [PCOUNT_STALE] = "Stale", | |
11224 | [PCOUNT_VALID] = "Valid", | |
11225 | [PCOUNT_ALL] = "All RIB", | |
11226 | [PCOUNT_COUNTED] = "PfxCt counted", | |
11227 | [PCOUNT_PFCNT] = "Useable", | |
11228 | [PCOUNT_MAX] = NULL, | |
11229 | }; | |
11230 | ||
2815e61f PJ |
11231 | struct peer_pcounts |
11232 | { | |
11233 | unsigned int count[PCOUNT_MAX]; | |
11234 | const struct peer *peer; | |
11235 | const struct bgp_table *table; | |
11236 | }; | |
11237 | ||
ff7924f6 | 11238 | static int |
2815e61f | 11239 | bgp_peer_count_walker (struct thread *t) |
ff7924f6 PJ |
11240 | { |
11241 | struct bgp_node *rn; | |
2815e61f PJ |
11242 | struct peer_pcounts *pc = THREAD_ARG (t); |
11243 | const struct peer *peer = pc->peer; | |
ff7924f6 | 11244 | |
2815e61f | 11245 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
ff7924f6 PJ |
11246 | { |
11247 | struct bgp_adj_in *ain; | |
2815e61f | 11248 | struct bgp_info *ri; |
ff7924f6 PJ |
11249 | |
11250 | for (ain = rn->adj_in; ain; ain = ain->next) | |
11251 | if (ain->peer == peer) | |
2815e61f | 11252 | pc->count[PCOUNT_ADJ_IN]++; |
ff7924f6 | 11253 | |
ff7924f6 PJ |
11254 | for (ri = rn->info; ri; ri = ri->next) |
11255 | { | |
11256 | char buf[SU_ADDRSTRLEN]; | |
11257 | ||
11258 | if (ri->peer != peer) | |
11259 | continue; | |
11260 | ||
2815e61f | 11261 | pc->count[PCOUNT_ALL]++; |
ff7924f6 PJ |
11262 | |
11263 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) | |
2815e61f | 11264 | pc->count[PCOUNT_DAMPED]++; |
ff7924f6 | 11265 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2815e61f | 11266 | pc->count[PCOUNT_HISTORY]++; |
ff7924f6 | 11267 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
2815e61f | 11268 | pc->count[PCOUNT_REMOVED]++; |
ff7924f6 | 11269 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
2815e61f | 11270 | pc->count[PCOUNT_STALE]++; |
ff7924f6 | 11271 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
2815e61f | 11272 | pc->count[PCOUNT_VALID]++; |
1a392d46 | 11273 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2815e61f | 11274 | pc->count[PCOUNT_PFCNT]++; |
ff7924f6 PJ |
11275 | |
11276 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
11277 | { | |
2815e61f | 11278 | pc->count[PCOUNT_COUNTED]++; |
1a392d46 | 11279 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
16286195 | 11280 | zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x", |
ff7924f6 PJ |
11281 | peer->host, |
11282 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
11283 | buf, SU_ADDRSTRLEN), | |
11284 | rn->p.prefixlen, | |
11285 | ri->flags); | |
11286 | } | |
11287 | else | |
11288 | { | |
1a392d46 | 11289 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
16286195 | 11290 | zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x", |
ff7924f6 PJ |
11291 | peer->host, |
11292 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
11293 | buf, SU_ADDRSTRLEN), | |
11294 | rn->p.prefixlen, | |
11295 | ri->flags); | |
11296 | } | |
11297 | } | |
11298 | } | |
2815e61f PJ |
11299 | return 0; |
11300 | } | |
ff7924f6 | 11301 | |
2815e61f | 11302 | static int |
856ca177 | 11303 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_char use_json) |
2815e61f PJ |
11304 | { |
11305 | struct peer_pcounts pcounts = { .peer = peer }; | |
11306 | unsigned int i; | |
856ca177 MS |
11307 | json_object *json = NULL; |
11308 | json_object *json_loop = NULL; | |
11309 | ||
11310 | if (use_json) | |
11311 | { | |
11312 | json = json_object_new_object(); | |
11313 | json_loop = json_object_new_object(); | |
11314 | } | |
2815e61f PJ |
11315 | |
11316 | if (!peer || !peer->bgp || !peer->afc[afi][safi] | |
11317 | || !peer->bgp->rib[afi][safi]) | |
11318 | { | |
856ca177 MS |
11319 | if (use_json) |
11320 | { | |
11321 | json_object_string_add(json, "warning", "No such neighbor or address family"); | |
11322 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11323 | json_object_free(json); | |
11324 | } | |
11325 | else | |
11326 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
11327 | ||
2815e61f PJ |
11328 | return CMD_WARNING; |
11329 | } | |
11330 | ||
11331 | memset (&pcounts, 0, sizeof(pcounts)); | |
11332 | pcounts.peer = peer; | |
11333 | pcounts.table = peer->bgp->rib[afi][safi]; | |
11334 | ||
11335 | /* in-place call via thread subsystem so as to record execution time | |
856ca177 MS |
11336 | * * stats for the thread-walk (i.e. ensure this can't be blamed on |
11337 | * * on just vty_read()). | |
11338 | * */ | |
87d4a781 | 11339 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
6410e93a | 11340 | |
856ca177 MS |
11341 | if (use_json) |
11342 | { | |
11343 | json_object_string_add(json, "prefixCountsFor", peer->host); | |
11344 | json_object_string_add(json, "multiProtocol", afi_safi_print (afi, safi)); | |
11345 | json_object_int_add(json, "pfxCounter", peer->pcount[afi][safi]); | |
11346 | ||
11347 | for (i = 0; i < PCOUNT_MAX; i++) | |
11348 | json_object_int_add(json_loop, pcount_strs[i], pcounts.count[i]); | |
ff7924f6 | 11349 | |
856ca177 | 11350 | json_object_object_add(json, "ribTableWalkCounters", json_loop); |
ff7924f6 | 11351 | |
856ca177 MS |
11352 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
11353 | { | |
11354 | json_object_string_add(json, "pfxctDriftFor", peer->host); | |
11355 | json_object_string_add(json, "recommended", "Please report this bug, with the above command output"); | |
11356 | } | |
11357 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11358 | json_object_free(json); | |
11359 | } | |
11360 | else | |
ff7924f6 | 11361 | { |
04b6bdc0 DW |
11362 | |
11363 | if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
11364 | { | |
11365 | vty_out (vty, "Prefix counts for %s/%s, %s%s", | |
11366 | peer->hostname, peer->host, afi_safi_print (afi, safi), | |
11367 | VTY_NEWLINE); | |
11368 | } | |
11369 | else | |
11370 | { | |
11371 | vty_out (vty, "Prefix counts for %s, %s%s", | |
11372 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); | |
11373 | } | |
11374 | ||
856ca177 MS |
11375 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
11376 | vty_out (vty, "%sCounts from RIB table walk:%s%s", | |
11377 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
11378 | ||
11379 | for (i = 0; i < PCOUNT_MAX; i++) | |
11380 | vty_out (vty, "%20s: %-10d%s", pcount_strs[i], pcounts.count[i], VTY_NEWLINE); | |
11381 | ||
11382 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) | |
11383 | { | |
11384 | vty_out (vty, "%s [pcount] PfxCt drift!%s", | |
11385 | peer->host, VTY_NEWLINE); | |
11386 | vty_out (vty, "Please report this bug, with the above command output%s", | |
11387 | VTY_NEWLINE); | |
11388 | } | |
ff7924f6 PJ |
11389 | } |
11390 | ||
11391 | return CMD_SUCCESS; | |
11392 | } | |
11393 | ||
11394 | DEFUN (show_ip_bgp_neighbor_prefix_counts, | |
11395 | show_ip_bgp_neighbor_prefix_counts_cmd, | |
856ca177 | 11396 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11397 | SHOW_STR |
11398 | IP_STR | |
11399 | BGP_STR | |
11400 | "Detailed information on TCP and BGP neighbor connections\n" | |
11401 | "Neighbor to display information about\n" | |
11402 | "Neighbor to display information about\n" | |
a80beece | 11403 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11404 | "Display detailed prefix count information\n" |
11405 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11406 | { |
11407 | struct peer *peer; | |
db7c8528 | 11408 | u_char uj = use_json(argc, argv); |
ff7924f6 | 11409 | |
db7c8528 | 11410 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
ff7924f6 PJ |
11411 | if (! peer) |
11412 | return CMD_WARNING; | |
11413 | ||
db7c8528 | 11414 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); |
ff7924f6 PJ |
11415 | } |
11416 | ||
8386ac43 | 11417 | DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, |
11418 | show_ip_bgp_instance_neighbor_prefix_counts_cmd, | |
11419 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", | |
50ef26d4 | 11420 | SHOW_STR |
11421 | IP_STR | |
11422 | BGP_STR | |
8386ac43 | 11423 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 11424 | "Detailed information on TCP and BGP neighbor connections\n" |
11425 | "Neighbor to display information about\n" | |
11426 | "Neighbor to display information about\n" | |
11427 | "Neighbor on bgp configured interface\n" | |
11428 | "Display detailed prefix count information\n" | |
11429 | "JavaScript Object Notation\n") | |
11430 | { | |
11431 | struct peer *peer; | |
11432 | u_char uj = use_json(argc, argv); | |
11433 | ||
11434 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
11435 | if (! peer) | |
11436 | return CMD_WARNING; | |
11437 | ||
11438 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); | |
11439 | } | |
11440 | ||
ff7924f6 PJ |
11441 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
11442 | show_bgp_ipv6_neighbor_prefix_counts_cmd, | |
856ca177 | 11443 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11444 | SHOW_STR |
11445 | BGP_STR | |
11446 | "Address family\n" | |
11447 | "Detailed information on TCP and BGP neighbor connections\n" | |
11448 | "Neighbor to display information about\n" | |
11449 | "Neighbor to display information about\n" | |
a80beece | 11450 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11451 | "Display detailed prefix count information\n" |
11452 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11453 | { |
11454 | struct peer *peer; | |
db7c8528 | 11455 | u_char uj = use_json(argc, argv); |
856ca177 | 11456 | |
db7c8528 | 11457 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
ff7924f6 PJ |
11458 | if (! peer) |
11459 | return CMD_WARNING; | |
11460 | ||
db7c8528 | 11461 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); |
ff7924f6 PJ |
11462 | } |
11463 | ||
8386ac43 | 11464 | DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, |
11465 | show_bgp_instance_ipv6_neighbor_prefix_counts_cmd, | |
11466 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", | |
50ef26d4 | 11467 | SHOW_STR |
11468 | BGP_STR | |
8386ac43 | 11469 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 11470 | "Address family\n" |
11471 | "Detailed information on TCP and BGP neighbor connections\n" | |
11472 | "Neighbor to display information about\n" | |
11473 | "Neighbor to display information about\n" | |
11474 | "Neighbor on bgp configured interface\n" | |
11475 | "Display detailed prefix count information\n" | |
11476 | "JavaScript Object Notation\n") | |
11477 | { | |
11478 | struct peer *peer; | |
11479 | u_char uj = use_json(argc, argv); | |
11480 | ||
11481 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
11482 | if (! peer) | |
11483 | return CMD_WARNING; | |
11484 | ||
11485 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); | |
11486 | } | |
11487 | ||
ff7924f6 PJ |
11488 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
11489 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, | |
856ca177 | 11490 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11491 | SHOW_STR |
11492 | IP_STR | |
11493 | BGP_STR | |
11494 | "Address family\n" | |
11495 | "Address Family modifier\n" | |
11496 | "Address Family modifier\n" | |
11497 | "Detailed information on TCP and BGP neighbor connections\n" | |
11498 | "Neighbor to display information about\n" | |
11499 | "Neighbor to display information about\n" | |
a80beece | 11500 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11501 | "Display detailed prefix count information\n" |
11502 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11503 | { |
11504 | struct peer *peer; | |
db7c8528 | 11505 | u_char uj = use_json(argc, argv); |
ff7924f6 | 11506 | |
db7c8528 | 11507 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
ff7924f6 PJ |
11508 | if (! peer) |
11509 | return CMD_WARNING; | |
11510 | ||
11511 | if (strncmp (argv[0], "m", 1) == 0) | |
db7c8528 | 11512 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj); |
ff7924f6 | 11513 | |
db7c8528 | 11514 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); |
ff7924f6 PJ |
11515 | } |
11516 | ||
11517 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, | |
11518 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, | |
856ca177 | 11519 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11520 | SHOW_STR |
11521 | IP_STR | |
11522 | BGP_STR | |
11523 | "Address family\n" | |
11524 | "Address Family modifier\n" | |
11525 | "Address Family modifier\n" | |
11526 | "Detailed information on TCP and BGP neighbor connections\n" | |
11527 | "Neighbor to display information about\n" | |
11528 | "Neighbor to display information about\n" | |
a80beece | 11529 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11530 | "Display detailed prefix count information\n" |
11531 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11532 | { |
11533 | struct peer *peer; | |
db7c8528 | 11534 | u_char uj = use_json(argc, argv); |
856ca177 | 11535 | |
db7c8528 | 11536 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
ff7924f6 PJ |
11537 | if (! peer) |
11538 | return CMD_WARNING; | |
11539 | ||
db7c8528 | 11540 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN, uj); |
ff7924f6 PJ |
11541 | } |
11542 | ||
94f2b392 | 11543 | static void |
718e3744 | 11544 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
856ca177 | 11545 | int in, const char *rmap_name, u_char use_json, json_object *json) |
718e3744 | 11546 | { |
11547 | struct bgp_table *table; | |
11548 | struct bgp_adj_in *ain; | |
11549 | struct bgp_adj_out *adj; | |
11550 | unsigned long output_count; | |
0b16f239 | 11551 | unsigned long filtered_count; |
718e3744 | 11552 | struct bgp_node *rn; |
11553 | int header1 = 1; | |
11554 | struct bgp *bgp; | |
11555 | int header2 = 1; | |
0b16f239 DS |
11556 | struct attr attr; |
11557 | struct attr_extra extra; | |
11558 | int ret; | |
840fced9 | 11559 | struct update_subgroup *subgrp; |
856ca177 MS |
11560 | json_object *json_scode = NULL; |
11561 | json_object *json_ocode = NULL; | |
11562 | json_object *json_ar = NULL; | |
adbac85e | 11563 | struct peer_af *paf; |
856ca177 MS |
11564 | |
11565 | if (use_json) | |
11566 | { | |
11567 | json_scode = json_object_new_object(); | |
11568 | json_ocode = json_object_new_object(); | |
11569 | json_ar = json_object_new_object(); | |
11570 | ||
11571 | json_object_string_add(json_scode, "suppressed", "s"); | |
11572 | json_object_string_add(json_scode, "damped", "d"); | |
11573 | json_object_string_add(json_scode, "history", "h"); | |
11574 | json_object_string_add(json_scode, "valid", "*"); | |
11575 | json_object_string_add(json_scode, "best", ">"); | |
11576 | json_object_string_add(json_scode, "multipath", "="); | |
11577 | json_object_string_add(json_scode, "internal", "i"); | |
11578 | json_object_string_add(json_scode, "ribFailure", "r"); | |
11579 | json_object_string_add(json_scode, "stale", "S"); | |
11580 | json_object_string_add(json_scode, "removed", "R"); | |
11581 | ||
11582 | json_object_string_add(json_ocode, "igp", "i"); | |
11583 | json_object_string_add(json_ocode, "egp", "e"); | |
11584 | json_object_string_add(json_ocode, "incomplete", "?"); | |
11585 | } | |
718e3744 | 11586 | |
bb46e94f | 11587 | bgp = peer->bgp; |
718e3744 | 11588 | |
11589 | if (! bgp) | |
856ca177 MS |
11590 | { |
11591 | if (use_json) | |
11592 | { | |
11593 | json_object_string_add(json, "alert", "no BGP"); | |
11594 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11595 | json_object_free(json); | |
11596 | } | |
11597 | else | |
11598 | vty_out (vty, "%% No bgp%s", VTY_NEWLINE); | |
11599 | return; | |
11600 | } | |
718e3744 | 11601 | |
11602 | table = bgp->rib[afi][safi]; | |
11603 | ||
0b16f239 | 11604 | output_count = filtered_count = 0; |
840fced9 | 11605 | subgrp = peer_subgroup(peer, afi, safi); |
47fc97cc | 11606 | |
840fced9 | 11607 | if (!in && subgrp && CHECK_FLAG (subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) |
718e3744 | 11608 | { |
856ca177 MS |
11609 | if (use_json) |
11610 | { | |
11611 | json_object_int_add(json, "bgpTableVersion", table->version); | |
11612 | json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); | |
11613 | json_object_object_add(json, "bgpStatusCodes", json_scode); | |
11614 | json_object_object_add(json, "bgpOriginCodes", json_ocode); | |
11615 | json_object_string_add(json, "bgpOriginatingDefaultNetwork", "0.0.0.0"); | |
11616 | } | |
11617 | else | |
11618 | { | |
11619 | vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
11620 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
11621 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 11622 | |
856ca177 MS |
11623 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
11624 | VTY_NEWLINE, VTY_NEWLINE); | |
11625 | } | |
718e3744 | 11626 | header1 = 0; |
11627 | } | |
11628 | ||
0b16f239 | 11629 | attr.extra = &extra; |
718e3744 | 11630 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
856ca177 MS |
11631 | { |
11632 | if (in) | |
11633 | { | |
11634 | for (ain = rn->adj_in; ain; ain = ain->next) | |
11635 | { | |
11636 | if (ain->peer == peer) | |
11637 | { | |
11638 | if (header1) | |
11639 | { | |
11640 | if (use_json) | |
11641 | { | |
11642 | json_object_int_add(json, "bgpTableVersion", 0); | |
11643 | json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); | |
11644 | json_object_object_add(json, "bgpStatusCodes", json_scode); | |
11645 | json_object_object_add(json, "bgpOriginCodes", json_ocode); | |
11646 | } | |
11647 | else | |
11648 | { | |
11649 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
11650 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
11651 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
11652 | } | |
11653 | header1 = 0; | |
11654 | } | |
11655 | if (header2) | |
11656 | { | |
11657 | if (!use_json) | |
11658 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
11659 | header2 = 0; | |
11660 | } | |
11661 | if (ain->attr) | |
11662 | { | |
11663 | bgp_attr_dup(&attr, ain->attr); | |
11664 | if (bgp_input_modifier(peer, &rn->p, &attr, afi, safi, rmap_name) != RMAP_DENY) | |
11665 | { | |
11666 | route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); | |
11667 | output_count++; | |
11668 | } | |
11669 | else | |
11670 | filtered_count++; | |
11671 | } | |
11672 | } | |
11673 | } | |
11674 | } | |
11675 | else | |
11676 | { | |
adbac85e DW |
11677 | for (adj = rn->adj_out; adj; adj = adj->next) |
11678 | SUBGRP_FOREACH_PEER(adj->subgroup, paf) | |
11679 | if (paf->peer == peer) | |
856ca177 | 11680 | { |
adbac85e | 11681 | if (header1) |
856ca177 | 11682 | { |
adbac85e DW |
11683 | if (use_json) |
11684 | { | |
11685 | json_object_int_add(json, "bgpTableVersion", table->version); | |
11686 | json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); | |
11687 | json_object_object_add(json, "bgpStatusCodes", json_scode); | |
11688 | json_object_object_add(json, "bgpOriginCodes", json_ocode); | |
11689 | } | |
11690 | else | |
11691 | { | |
11692 | vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, | |
11693 | inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
11694 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
11695 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
11696 | } | |
11697 | header1 = 0; | |
856ca177 | 11698 | } |
adbac85e DW |
11699 | |
11700 | if (header2) | |
856ca177 | 11701 | { |
adbac85e DW |
11702 | if (!use_json) |
11703 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
11704 | header2 = 0; | |
856ca177 | 11705 | } |
adbac85e DW |
11706 | |
11707 | if (adj->attr) | |
856ca177 | 11708 | { |
adbac85e DW |
11709 | bgp_attr_dup(&attr, adj->attr); |
11710 | ret = bgp_output_modifier(peer, &rn->p, &attr, afi, safi, rmap_name); | |
11711 | if (ret != RMAP_DENY) | |
11712 | { | |
11713 | route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); | |
11714 | output_count++; | |
11715 | } | |
11716 | else | |
11717 | filtered_count++; | |
856ca177 | 11718 | } |
856ca177 | 11719 | } |
856ca177 MS |
11720 | } |
11721 | } | |
11722 | if (use_json) | |
11723 | json_object_object_add(json, "advertisedRoutes", json_ar); | |
47fc97cc | 11724 | |
718e3744 | 11725 | if (output_count != 0) |
856ca177 MS |
11726 | { |
11727 | if (use_json) | |
11728 | json_object_int_add(json, "totalPrefixCounter", output_count); | |
11729 | else | |
11730 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
11731 | VTY_NEWLINE, output_count, VTY_NEWLINE); | |
11732 | } | |
11733 | if (use_json) | |
11734 | { | |
11735 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11736 | json_object_free(json); | |
11737 | } | |
11738 | ||
718e3744 | 11739 | } |
11740 | ||
94f2b392 | 11741 | static int |
47fc97cc | 11742 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
856ca177 MS |
11743 | int in, const char *rmap_name, u_char use_json) |
11744 | { | |
11745 | json_object *json = NULL; | |
11746 | ||
11747 | if (use_json) | |
11748 | json = json_object_new_object(); | |
11749 | ||
11750 | if (!peer || !peer->afc[afi][safi]) | |
718e3744 | 11751 | { |
856ca177 MS |
11752 | if (use_json) |
11753 | { | |
11754 | json_object_string_add(json, "warning", "No such neighbor or address family"); | |
11755 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11756 | json_object_free(json); | |
11757 | } | |
11758 | else | |
11759 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
11760 | ||
718e3744 | 11761 | return CMD_WARNING; |
11762 | } | |
11763 | ||
856ca177 | 11764 | if (in && !CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
718e3744 | 11765 | { |
856ca177 MS |
11766 | if (use_json) |
11767 | { | |
11768 | json_object_string_add(json, "warning", "Inbound soft reconfiguration not enabled"); | |
11769 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11770 | json_object_free(json); | |
11771 | } | |
11772 | else | |
11773 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE); | |
11774 | ||
718e3744 | 11775 | return CMD_WARNING; |
11776 | } | |
11777 | ||
856ca177 | 11778 | show_adj_route (vty, peer, afi, safi, in, rmap_name, use_json, json); |
718e3744 | 11779 | |
11780 | return CMD_SUCCESS; | |
11781 | } | |
11782 | ||
8386ac43 | 11783 | DEFUN (show_ip_bgp_instance_neighbor_advertised_route, |
11784 | show_ip_bgp_instance_neighbor_advertised_route_cmd, | |
11785 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", | |
718e3744 | 11786 | SHOW_STR |
11787 | IP_STR | |
11788 | BGP_STR | |
8386ac43 | 11789 | BGP_INSTANCE_HELP_STR |
718e3744 | 11790 | "Detailed information on TCP and BGP neighbor connections\n" |
11791 | "Neighbor to display information about\n" | |
11792 | "Neighbor to display information about\n" | |
856ca177 MS |
11793 | "Display the routes advertised to a BGP neighbor\n" |
11794 | "JavaScript Object Notation\n") | |
718e3744 | 11795 | { |
bb46e94f | 11796 | struct peer *peer; |
db7c8528 | 11797 | u_char uj = use_json(argc, argv); |
856ca177 | 11798 | |
6aeb9e78 DS |
11799 | if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
11800 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
2a71e9ce | 11801 | else |
6aeb9e78 | 11802 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
2a71e9ce | 11803 | |
bb46e94f | 11804 | if (! peer) |
11805 | return CMD_WARNING; | |
0b16f239 | 11806 | |
db7c8528 | 11807 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, NULL, uj); |
718e3744 | 11808 | } |
11809 | ||
0b16f239 | 11810 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
2a71e9ce | 11811 | show_ip_bgp_neighbor_advertised_route_cmd, |
856ca177 | 11812 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
2a71e9ce TP |
11813 | SHOW_STR |
11814 | IP_STR | |
11815 | BGP_STR | |
11816 | "Detailed information on TCP and BGP neighbor connections\n" | |
11817 | "Neighbor to display information about\n" | |
11818 | "Neighbor to display information about\n" | |
a80beece | 11819 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11820 | "Display the routes advertised to a BGP neighbor\n" |
11821 | "JavaScript Object Notation\n") | |
2a71e9ce | 11822 | |
0b16f239 DS |
11823 | { |
11824 | struct peer *peer; | |
ffd0c037 | 11825 | const char *rmap_name = NULL; |
db7c8528 | 11826 | u_char uj = use_json(argc, argv); |
0b16f239 | 11827 | |
db7c8528 | 11828 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
0b16f239 DS |
11829 | |
11830 | if (! peer) | |
11831 | return CMD_WARNING; | |
11832 | ||
856ca177 MS |
11833 | if ((argc == 2 && argv[1] && strcmp(argv[1], "json") != 0) |
11834 | || (argc == 3)) | |
0b16f239 DS |
11835 | rmap_name = argv[1]; |
11836 | ||
db7c8528 | 11837 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); |
0b16f239 DS |
11838 | } |
11839 | ||
11840 | ALIAS (show_ip_bgp_neighbor_advertised_route, | |
11841 | show_ip_bgp_neighbor_advertised_route_rmap_cmd, | |
856ca177 | 11842 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", |
0b16f239 DS |
11843 | SHOW_STR |
11844 | IP_STR | |
11845 | BGP_STR | |
11846 | "Detailed information on TCP and BGP neighbor connections\n" | |
11847 | "Neighbor to display information about\n" | |
11848 | "Neighbor to display information about\n" | |
11849 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
11850 | "Display the routes advertised to a BGP neighbor\n" |
11851 | "JavaScript Object Notation\n") | |
0b16f239 | 11852 | |
8386ac43 | 11853 | ALIAS (show_ip_bgp_instance_neighbor_advertised_route, |
11854 | show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd, | |
11855 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", | |
50ef26d4 | 11856 | SHOW_STR |
11857 | IP_STR | |
11858 | BGP_STR | |
8386ac43 | 11859 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 11860 | "Detailed information on TCP and BGP neighbor connections\n" |
11861 | "Neighbor to display information about\n" | |
11862 | "Neighbor to display information about\n" | |
11863 | "Neighbor on bgp configured interface\n" | |
11864 | "Display the routes advertised to a BGP neighbor\n" | |
11865 | "JavaScript Object Notation\n") | |
718e3744 | 11866 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
11867 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, | |
856ca177 | 11868 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 11869 | SHOW_STR |
11870 | IP_STR | |
11871 | BGP_STR | |
11872 | "Address family\n" | |
11873 | "Address Family modifier\n" | |
11874 | "Address Family modifier\n" | |
11875 | "Detailed information on TCP and BGP neighbor connections\n" | |
11876 | "Neighbor to display information about\n" | |
11877 | "Neighbor to display information about\n" | |
a80beece | 11878 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11879 | "Display the routes advertised to a BGP neighbor\n" |
11880 | "JavaScript Object Notation\n") | |
718e3744 | 11881 | { |
bb46e94f | 11882 | struct peer *peer; |
ffd0c037 | 11883 | const char *rmap_name = NULL; |
db7c8528 | 11884 | u_char uj = use_json(argc, argv); |
856ca177 | 11885 | |
db7c8528 | 11886 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 11887 | if (! peer) |
11888 | return CMD_WARNING; | |
11889 | ||
856ca177 | 11890 | if ((argc == 4) || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
0b16f239 DS |
11891 | rmap_name = argv[2]; |
11892 | ||
718e3744 | 11893 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 11894 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0, rmap_name, uj); |
856ca177 | 11895 | else |
db7c8528 | 11896 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); |
718e3744 | 11897 | } |
11898 | ||
0b16f239 DS |
11899 | ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route, |
11900 | show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd, | |
856ca177 | 11901 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", |
0b16f239 DS |
11902 | SHOW_STR |
11903 | IP_STR | |
11904 | BGP_STR | |
11905 | "Address family\n" | |
11906 | "Address Family modifier\n" | |
11907 | "Address Family modifier\n" | |
11908 | "Detailed information on TCP and BGP neighbor connections\n" | |
11909 | "Neighbor to display information about\n" | |
11910 | "Neighbor to display information about\n" | |
11911 | "Neighbor on bgp configured interface\n" | |
11912 | "Display the routes advertised to a BGP neighbor\n" | |
856ca177 MS |
11913 | "Route-map to control what is displayed\n" |
11914 | "JavaScript Object Notation\n") | |
0b16f239 | 11915 | |
718e3744 | 11916 | #ifdef HAVE_IPV6 |
8386ac43 | 11917 | DEFUN (show_bgp_instance_neighbor_advertised_route, |
11918 | show_bgp_instance_neighbor_advertised_route_cmd, | |
11919 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", | |
718e3744 | 11920 | SHOW_STR |
11921 | BGP_STR | |
8386ac43 | 11922 | BGP_INSTANCE_HELP_STR |
718e3744 | 11923 | "Detailed information on TCP and BGP neighbor connections\n" |
11924 | "Neighbor to display information about\n" | |
11925 | "Neighbor to display information about\n" | |
a80beece | 11926 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11927 | "Display the routes advertised to a BGP neighbor\n" |
11928 | "JavaScript Object Notation\n") | |
718e3744 | 11929 | { |
bb46e94f | 11930 | struct peer *peer; |
db7c8528 | 11931 | u_char uj = use_json(argc, argv); |
856ca177 | 11932 | |
6aeb9e78 DS |
11933 | if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
11934 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
bb46e94f | 11935 | else |
6aeb9e78 | 11936 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 11937 | |
11938 | if (! peer) | |
0b16f239 | 11939 | return CMD_WARNING; |
bb46e94f | 11940 | |
db7c8528 | 11941 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, NULL, uj); |
47fc97cc DS |
11942 | } |
11943 | ||
8386ac43 | 11944 | ALIAS (show_bgp_instance_neighbor_advertised_route, |
11945 | show_bgp_instance_ipv6_neighbor_advertised_route_cmd, | |
11946 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", | |
0b16f239 DS |
11947 | SHOW_STR |
11948 | BGP_STR | |
8386ac43 | 11949 | BGP_INSTANCE_HELP_STR |
0b16f239 DS |
11950 | "Address family\n" |
11951 | "Detailed information on TCP and BGP neighbor connections\n" | |
11952 | "Neighbor to display information about\n" | |
11953 | "Neighbor to display information about\n" | |
11954 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
11955 | "Display the routes advertised to a BGP neighbor\n" |
11956 | "JavaScript Object Notation\n") | |
0b16f239 | 11957 | |
0b16f239 DS |
11958 | DEFUN (show_bgp_neighbor_advertised_route, |
11959 | show_bgp_neighbor_advertised_route_cmd, | |
856ca177 | 11960 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
bb46e94f | 11961 | SHOW_STR |
11962 | BGP_STR | |
bb46e94f | 11963 | "Detailed information on TCP and BGP neighbor connections\n" |
11964 | "Neighbor to display information about\n" | |
11965 | "Neighbor to display information about\n" | |
a80beece | 11966 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11967 | "Display the routes advertised to a BGP neighbor\n" |
11968 | "JavaScript Object Notation\n") | |
0b16f239 | 11969 | |
bb46e94f | 11970 | { |
11971 | struct peer *peer; | |
ffd0c037 | 11972 | const char *rmap_name = NULL; |
db7c8528 | 11973 | u_char uj = use_json(argc, argv); |
bb46e94f | 11974 | |
db7c8528 | 11975 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
856ca177 MS |
11976 | |
11977 | if (!peer) | |
bb46e94f | 11978 | return CMD_WARNING; |
11979 | ||
856ca177 | 11980 | if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) |
0b16f239 DS |
11981 | rmap_name = argv[1]; |
11982 | ||
db7c8528 | 11983 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, rmap_name, uj); |
718e3744 | 11984 | } |
11985 | ||
0b16f239 DS |
11986 | ALIAS (show_bgp_neighbor_advertised_route, |
11987 | show_bgp_ipv6_neighbor_advertised_route_cmd, | |
856ca177 | 11988 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 11989 | SHOW_STR |
11990 | BGP_STR | |
11991 | "Address family\n" | |
11992 | "Detailed information on TCP and BGP neighbor connections\n" | |
11993 | "Neighbor to display information about\n" | |
11994 | "Neighbor to display information about\n" | |
a80beece | 11995 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11996 | "Display the routes advertised to a BGP neighbor\n" |
11997 | "JavaScript Object Notation\n") | |
718e3744 | 11998 | |
11999 | /* old command */ | |
0b16f239 | 12000 | ALIAS (show_bgp_neighbor_advertised_route, |
718e3744 | 12001 | ipv6_bgp_neighbor_advertised_route_cmd, |
856ca177 | 12002 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12003 | SHOW_STR |
12004 | IPV6_STR | |
12005 | BGP_STR | |
12006 | "Detailed information on TCP and BGP neighbor connections\n" | |
12007 | "Neighbor to display information about\n" | |
12008 | "Neighbor to display information about\n" | |
a80beece | 12009 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12010 | "Display the routes advertised to a BGP neighbor\n" |
12011 | "JavaScript Object Notation\n") | |
bb46e94f | 12012 | |
718e3744 | 12013 | /* old command */ |
12014 | DEFUN (ipv6_mbgp_neighbor_advertised_route, | |
12015 | ipv6_mbgp_neighbor_advertised_route_cmd, | |
856ca177 | 12016 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12017 | SHOW_STR |
12018 | IPV6_STR | |
12019 | MBGP_STR | |
12020 | "Detailed information on TCP and BGP neighbor connections\n" | |
12021 | "Neighbor to display information about\n" | |
12022 | "Neighbor to display information about\n" | |
a80beece DS |
12023 | "Neighbor on bgp configured interface\n" |
12024 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12025 | "Display the routes advertised to a BGP neighbor\n" |
12026 | "JavaScript Object Notation\n") | |
718e3744 | 12027 | { |
bb46e94f | 12028 | struct peer *peer; |
db7c8528 | 12029 | u_char uj = use_json(argc, argv); |
856ca177 | 12030 | |
db7c8528 | 12031 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 12032 | if (! peer) |
856ca177 | 12033 | return CMD_WARNING; |
bb46e94f | 12034 | |
47e9b292 | 12035 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 12036 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0, NULL, uj); |
718e3744 | 12037 | } |
12038 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 12039 | |
8386ac43 | 12040 | DEFUN (show_bgp_instance_neighbor_received_routes, |
12041 | show_bgp_instance_neighbor_received_routes_cmd, | |
12042 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", | |
0b16f239 DS |
12043 | SHOW_STR |
12044 | BGP_STR | |
8386ac43 | 12045 | BGP_INSTANCE_HELP_STR |
0b16f239 DS |
12046 | "Detailed information on TCP and BGP neighbor connections\n" |
12047 | "Neighbor to display information about\n" | |
12048 | "Neighbor to display information about\n" | |
12049 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12050 | "Display the received routes from neighbor\n" |
12051 | "JavaScript Object Notation\n") | |
0b16f239 DS |
12052 | { |
12053 | struct peer *peer; | |
db7c8528 | 12054 | u_char uj = use_json(argc, argv); |
856ca177 | 12055 | |
50ef26d4 | 12056 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); |
0b16f239 DS |
12057 | if (! peer) |
12058 | return CMD_WARNING; | |
12059 | ||
db7c8528 | 12060 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, NULL, uj); |
0b16f239 DS |
12061 | } |
12062 | ||
8386ac43 | 12063 | DEFUN (show_ip_bgp_instance_neighbor_received_routes, |
12064 | show_ip_bgp_instance_neighbor_received_routes_cmd, | |
12065 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", | |
718e3744 | 12066 | SHOW_STR |
12067 | IP_STR | |
12068 | BGP_STR | |
8386ac43 | 12069 | BGP_INSTANCE_HELP_STR |
718e3744 | 12070 | "Detailed information on TCP and BGP neighbor connections\n" |
12071 | "Neighbor to display information about\n" | |
12072 | "Neighbor to display information about\n" | |
a80beece | 12073 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12074 | "Display the received routes from neighbor\n" |
12075 | "JavaScript Object Notation\n") | |
718e3744 | 12076 | { |
bb46e94f | 12077 | struct peer *peer; |
db7c8528 | 12078 | u_char uj = use_json(argc, argv); |
856ca177 | 12079 | |
50ef26d4 | 12080 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); |
bb46e94f | 12081 | if (! peer) |
12082 | return CMD_WARNING; | |
12083 | ||
db7c8528 | 12084 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, NULL, uj); |
718e3744 | 12085 | } |
12086 | ||
8386ac43 | 12087 | ALIAS (show_bgp_instance_neighbor_received_routes, |
12088 | show_bgp_instance_ipv6_neighbor_received_routes_cmd, | |
12089 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", | |
0b16f239 DS |
12090 | SHOW_STR |
12091 | BGP_STR | |
8386ac43 | 12092 | BGP_INSTANCE_HELP_STR |
0b16f239 DS |
12093 | "Address family\n" |
12094 | "Detailed information on TCP and BGP neighbor connections\n" | |
12095 | "Neighbor to display information about\n" | |
12096 | "Neighbor to display information about\n" | |
12097 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12098 | "Display the received routes from neighbor\n" |
12099 | "JavaScript Object Notation\n") | |
0b16f239 DS |
12100 | |
12101 | DEFUN (show_ip_bgp_neighbor_received_routes, | |
2a71e9ce | 12102 | show_ip_bgp_neighbor_received_routes_cmd, |
856ca177 | 12103 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
2a71e9ce TP |
12104 | SHOW_STR |
12105 | IP_STR | |
12106 | BGP_STR | |
12107 | "Detailed information on TCP and BGP neighbor connections\n" | |
12108 | "Neighbor to display information about\n" | |
12109 | "Neighbor to display information about\n" | |
a80beece | 12110 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12111 | "Display the received routes from neighbor\n" |
12112 | "JavaScript Object Notation\n") | |
2a71e9ce | 12113 | |
0b16f239 DS |
12114 | { |
12115 | struct peer *peer; | |
ffd0c037 | 12116 | const char *rmap_name = NULL; |
db7c8528 | 12117 | u_char uj = use_json(argc, argv); |
0b16f239 | 12118 | |
db7c8528 | 12119 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
0b16f239 DS |
12120 | |
12121 | if (! peer) | |
12122 | return CMD_WARNING; | |
12123 | ||
856ca177 | 12124 | if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) |
0b16f239 DS |
12125 | rmap_name = argv[1]; |
12126 | ||
db7c8528 | 12127 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); |
0b16f239 DS |
12128 | } |
12129 | ||
12130 | ALIAS (show_ip_bgp_neighbor_received_routes, | |
12131 | show_ip_bgp_neighbor_received_routes_rmap_cmd, | |
856ca177 | 12132 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", |
0b16f239 DS |
12133 | SHOW_STR |
12134 | IP_STR | |
12135 | BGP_STR | |
12136 | "Detailed information on TCP and BGP neighbor connections\n" | |
12137 | "Neighbor to display information about\n" | |
12138 | "Neighbor to display information about\n" | |
12139 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12140 | "Display the received routes from neighbor\n" |
12141 | "JavaScript Object Notation\n") | |
0b16f239 | 12142 | |
8386ac43 | 12143 | ALIAS (show_ip_bgp_instance_neighbor_received_routes, |
12144 | show_ip_bgp_instance_neighbor_received_routes_rmap_cmd, | |
12145 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", | |
50ef26d4 | 12146 | SHOW_STR |
12147 | IP_STR | |
12148 | BGP_STR | |
8386ac43 | 12149 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 12150 | "Detailed information on TCP and BGP neighbor connections\n" |
12151 | "Neighbor to display information about\n" | |
12152 | "Neighbor to display information about\n" | |
12153 | "Neighbor on bgp configured interface\n" | |
12154 | "Display the received routes from neighbor\n" | |
12155 | "JavaScript Object Notation\n") | |
12156 | ||
718e3744 | 12157 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
12158 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, | |
856ca177 | 12159 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 12160 | SHOW_STR |
12161 | IP_STR | |
12162 | BGP_STR | |
12163 | "Address family\n" | |
12164 | "Address Family modifier\n" | |
12165 | "Address Family modifier\n" | |
12166 | "Detailed information on TCP and BGP neighbor connections\n" | |
12167 | "Neighbor to display information about\n" | |
12168 | "Neighbor to display information about\n" | |
a80beece | 12169 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12170 | "Display the received routes from neighbor\n" |
12171 | "JavaScript Object Notation\n") | |
718e3744 | 12172 | { |
bb46e94f | 12173 | struct peer *peer; |
ffd0c037 | 12174 | const char *rmap_name = NULL; |
db7c8528 | 12175 | u_char uj = use_json(argc, argv); |
bb46e94f | 12176 | |
db7c8528 | 12177 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12178 | if (! peer) |
12179 | return CMD_WARNING; | |
0b16f239 | 12180 | |
856ca177 | 12181 | if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
0b16f239 DS |
12182 | rmap_name = argv[2]; |
12183 | ||
718e3744 | 12184 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 12185 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1, rmap_name, uj); |
856ca177 | 12186 | else |
db7c8528 | 12187 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); |
718e3744 | 12188 | } |
12189 | ||
0b16f239 DS |
12190 | ALIAS (show_ip_bgp_ipv4_neighbor_received_routes, |
12191 | show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd, | |
856ca177 | 12192 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", |
0b16f239 DS |
12193 | SHOW_STR |
12194 | IP_STR | |
12195 | BGP_STR | |
12196 | "Address family\n" | |
12197 | "Address Family modifier\n" | |
12198 | "Address Family modifier\n" | |
12199 | "Detailed information on TCP and BGP neighbor connections\n" | |
12200 | "Neighbor to display information about\n" | |
12201 | "Neighbor to display information about\n" | |
12202 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12203 | "Display the received routes from neighbor\n" |
12204 | "JavaScript Object Notation\n") | |
0b16f239 | 12205 | |
8386ac43 | 12206 | DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, |
12207 | show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd, | |
95cbbd2a | 12208 | #ifdef HAVE_IPV6 |
8386ac43 | 12209 | "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 | 12210 | #else |
8386ac43 | 12211 | "show bgp " BGP_INSTANCE_CMD " ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}", |
95cbbd2a ML |
12212 | #endif |
12213 | SHOW_STR | |
12214 | BGP_STR | |
8386ac43 | 12215 | BGP_INSTANCE_HELP_STR |
95cbbd2a ML |
12216 | "Address family\n" |
12217 | #ifdef HAVE_IPV6 | |
12218 | "Address family\n" | |
12219 | #endif | |
12220 | "Address family modifier\n" | |
12221 | "Address family modifier\n" | |
12222 | "Detailed information on TCP and BGP neighbor connections\n" | |
12223 | "Neighbor to display information about\n" | |
12224 | "Neighbor to display information about\n" | |
a80beece | 12225 | "Neighbor on bgp configured interface\n" |
95cbbd2a | 12226 | "Display the advertised routes to neighbor\n" |
856ca177 MS |
12227 | "Display the received routes from neighbor\n" |
12228 | "JavaScript Object Notation\n") | |
95cbbd2a ML |
12229 | { |
12230 | int afi; | |
12231 | int safi; | |
12232 | int in; | |
12233 | struct peer *peer; | |
db7c8528 | 12234 | u_char uj = use_json(argc, argv); |
856ca177 | 12235 | |
6aeb9e78 | 12236 | peer = peer_lookup_in_view (vty, argv[1], argv[4], uj); |
95cbbd2a ML |
12237 | |
12238 | if (! peer) | |
12239 | return CMD_WARNING; | |
12240 | ||
6aeb9e78 DS |
12241 | afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
12242 | safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
12243 | in = (strncmp (argv[5], "r", 1) == 0) ? 1 : 0; | |
95cbbd2a | 12244 | |
db7c8528 | 12245 | return peer_adj_routes (vty, peer, afi, safi, in, NULL, uj); |
95cbbd2a ML |
12246 | } |
12247 | ||
718e3744 | 12248 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
12249 | show_ip_bgp_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12250 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 12251 | SHOW_STR |
12252 | IP_STR | |
12253 | BGP_STR | |
12254 | "Detailed information on TCP and BGP neighbor connections\n" | |
12255 | "Neighbor to display information about\n" | |
12256 | "Neighbor to display information about\n" | |
a80beece | 12257 | "Neighbor on bgp configured interface\n" |
718e3744 | 12258 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12259 | "Display the prefixlist filter\n" |
12260 | "JavaScript Object Notation\n") | |
718e3744 | 12261 | { |
12262 | char name[BUFSIZ]; | |
c63b83fe | 12263 | union sockunion su; |
718e3744 | 12264 | struct peer *peer; |
c63b83fe | 12265 | int count, ret; |
db7c8528 | 12266 | u_char uj = use_json(argc, argv); |
718e3744 | 12267 | |
c63b83fe JBD |
12268 | ret = str2sockunion (argv[0], &su); |
12269 | if (ret < 0) | |
12270 | { | |
a80beece | 12271 | peer = peer_lookup_by_conf_if (NULL, argv[0]); |
856ca177 | 12272 | if (! peer) |
a80beece | 12273 | { |
db7c8528 | 12274 | if (uj) |
856ca177 MS |
12275 | { |
12276 | json_object *json_no = NULL; | |
12277 | json_object *json_sub = NULL; | |
12278 | json_no = json_object_new_object(); | |
12279 | json_sub = json_object_new_object(); | |
12280 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
12281 | json_object_string_add(json_sub, "warningCause", argv[0]); | |
12282 | json_object_object_add(json_no, "detail", json_sub); | |
12283 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12284 | json_object_free(json_no); | |
12285 | } | |
12286 | else | |
12287 | vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE); | |
a80beece DS |
12288 | return CMD_WARNING; |
12289 | } | |
12290 | } | |
12291 | else | |
12292 | { | |
12293 | peer = peer_lookup (NULL, &su); | |
12294 | if (! peer) | |
856ca177 | 12295 | { |
db7c8528 | 12296 | if (uj) |
856ca177 MS |
12297 | { |
12298 | json_object *json_no = NULL; | |
12299 | json_no = json_object_new_object(); | |
12300 | json_object_string_add(json_no, "warning", "Peer not found"); | |
12301 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12302 | json_object_free(json_no); | |
12303 | } | |
12304 | else | |
12305 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
12306 | return CMD_WARNING; | |
12307 | } | |
c63b83fe | 12308 | } |
718e3744 | 12309 | |
12310 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
db7c8528 | 12311 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); |
718e3744 | 12312 | if (count) |
12313 | { | |
db7c8528 | 12314 | if (!uj) |
856ca177 | 12315 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
db7c8528 | 12316 | prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); |
856ca177 MS |
12317 | } |
12318 | else | |
12319 | { | |
db7c8528 | 12320 | if (uj) |
856ca177 MS |
12321 | { |
12322 | json_object *json_no = NULL; | |
12323 | json_no = json_object_new_object(); | |
12324 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12325 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12326 | json_object_free(json_no); | |
12327 | } | |
12328 | else | |
12329 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
718e3744 | 12330 | } |
12331 | ||
12332 | return CMD_SUCCESS; | |
12333 | } | |
12334 | ||
12335 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, | |
12336 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12337 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {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" |
718e3744 | 12348 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12349 | "Display the prefixlist filter\n" |
12350 | "JavaScript Object Notation\n") | |
718e3744 | 12351 | { |
12352 | char name[BUFSIZ]; | |
c63b83fe | 12353 | union sockunion su; |
718e3744 | 12354 | struct peer *peer; |
c63b83fe | 12355 | int count, ret; |
db7c8528 | 12356 | u_char uj = use_json(argc, argv); |
718e3744 | 12357 | |
c63b83fe JBD |
12358 | ret = str2sockunion (argv[1], &su); |
12359 | if (ret < 0) | |
12360 | { | |
a80beece | 12361 | peer = peer_lookup_by_conf_if (NULL, argv[1]); |
856ca177 | 12362 | if (! peer) |
a80beece | 12363 | { |
db7c8528 | 12364 | if (uj) |
856ca177 MS |
12365 | { |
12366 | json_object *json_no = NULL; | |
12367 | json_object *json_sub = NULL; | |
12368 | json_no = json_object_new_object(); | |
12369 | json_sub = json_object_new_object(); | |
12370 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
12371 | json_object_string_add(json_sub, "warningCause", argv[1]); | |
12372 | json_object_object_add(json_no, "detail", json_sub); | |
12373 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12374 | json_object_free(json_no); | |
12375 | } | |
12376 | else | |
12377 | vty_out (vty, "%% Malformed address or name: %s%s", argv[1], VTY_NEWLINE); | |
a80beece DS |
12378 | return CMD_WARNING; |
12379 | } | |
12380 | } | |
12381 | else | |
12382 | { | |
12383 | peer = peer_lookup (NULL, &su); | |
12384 | if (! peer) | |
856ca177 | 12385 | { |
db7c8528 | 12386 | if (uj) |
856ca177 MS |
12387 | { |
12388 | json_object *json_no = NULL; | |
12389 | json_no = json_object_new_object(); | |
12390 | json_object_string_add(json_no, "warning", "Peer not found"); | |
12391 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12392 | json_object_free(json_no); | |
12393 | } | |
12394 | else | |
12395 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
12396 | return CMD_WARNING; | |
12397 | } | |
c63b83fe | 12398 | } |
718e3744 | 12399 | |
12400 | if (strncmp (argv[0], "m", 1) == 0) | |
12401 | { | |
12402 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); | |
db7c8528 | 12403 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); |
718e3744 | 12404 | if (count) |
856ca177 | 12405 | { |
db7c8528 | 12406 | if (!uj) |
856ca177 | 12407 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
db7c8528 | 12408 | prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); |
856ca177 MS |
12409 | } |
12410 | else | |
12411 | { | |
db7c8528 | 12412 | if (uj) |
856ca177 MS |
12413 | { |
12414 | json_object *json_no = NULL; | |
12415 | json_no = json_object_new_object(); | |
12416 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12417 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12418 | json_object_free(json_no); | |
12419 | } | |
12420 | else | |
12421 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
12422 | } | |
718e3744 | 12423 | } |
12424 | else | |
12425 | { | |
12426 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
db7c8528 | 12427 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); |
718e3744 | 12428 | if (count) |
856ca177 | 12429 | { |
db7c8528 | 12430 | if (!uj) |
856ca177 | 12431 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
db7c8528 | 12432 | prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); |
856ca177 MS |
12433 | } |
12434 | else | |
12435 | { | |
db7c8528 | 12436 | if (uj) |
856ca177 MS |
12437 | { |
12438 | json_object *json_no = NULL; | |
12439 | json_no = json_object_new_object(); | |
12440 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12441 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12442 | json_object_free(json_no); | |
12443 | } | |
12444 | else | |
12445 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
12446 | } | |
718e3744 | 12447 | } |
12448 | ||
12449 | return CMD_SUCCESS; | |
12450 | } | |
718e3744 | 12451 | #ifdef HAVE_IPV6 |
50ef26d4 | 12452 | DEFUN (show_bgp_neighbor_received_routes, |
718e3744 | 12453 | show_bgp_neighbor_received_routes_cmd, |
856ca177 | 12454 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 12455 | SHOW_STR |
12456 | BGP_STR | |
12457 | "Detailed information on TCP and BGP neighbor connections\n" | |
12458 | "Neighbor to display information about\n" | |
12459 | "Neighbor to display information about\n" | |
a80beece | 12460 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12461 | "Display the received routes from neighbor\n" |
12462 | "JavaScript Object Notation\n") | |
50ef26d4 | 12463 | { |
12464 | struct peer *peer; | |
12465 | const char *rmap_name = NULL; | |
12466 | u_char uj = use_json(argc, argv); | |
718e3744 | 12467 | |
50ef26d4 | 12468 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
12469 | ||
12470 | if (! peer) | |
12471 | return CMD_WARNING; | |
12472 | ||
12473 | if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) | |
12474 | rmap_name = argv[1]; | |
12475 | ||
12476 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, rmap_name, uj); | |
12477 | } | |
12478 | ||
12479 | ALIAS (show_bgp_neighbor_received_routes, | |
718e3744 | 12480 | show_bgp_ipv6_neighbor_received_routes_cmd, |
856ca177 | 12481 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
0b16f239 DS |
12482 | SHOW_STR |
12483 | BGP_STR | |
12484 | "Address family\n" | |
12485 | "Detailed information on TCP and BGP neighbor connections\n" | |
12486 | "Neighbor to display information about\n" | |
12487 | "Neighbor to display information about\n" | |
12488 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12489 | "Display the received routes from neighbor\n" |
12490 | "JavaScript Object Notation\n") | |
0b16f239 | 12491 | |
718e3744 | 12492 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
12493 | show_bgp_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12494 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 12495 | SHOW_STR |
12496 | BGP_STR | |
12497 | "Detailed information on TCP and BGP neighbor connections\n" | |
12498 | "Neighbor to display information about\n" | |
12499 | "Neighbor to display information about\n" | |
a80beece | 12500 | "Neighbor on bgp configured interface\n" |
718e3744 | 12501 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12502 | "Display the prefixlist filter\n" |
12503 | "JavaScript Object Notation\n") | |
718e3744 | 12504 | { |
12505 | char name[BUFSIZ]; | |
c63b83fe | 12506 | union sockunion su; |
718e3744 | 12507 | struct peer *peer; |
c63b83fe | 12508 | int count, ret; |
db7c8528 | 12509 | u_char uj = use_json(argc, argv); |
718e3744 | 12510 | |
c63b83fe JBD |
12511 | ret = str2sockunion (argv[0], &su); |
12512 | if (ret < 0) | |
12513 | { | |
a80beece | 12514 | peer = peer_lookup_by_conf_if (NULL, argv[0]); |
856ca177 | 12515 | if (! peer) |
a80beece | 12516 | { |
db7c8528 | 12517 | if (uj) |
856ca177 MS |
12518 | { |
12519 | json_object *json_no = NULL; | |
12520 | json_object *json_sub = NULL; | |
12521 | json_no = json_object_new_object(); | |
12522 | json_sub = json_object_new_object(); | |
12523 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
12524 | json_object_string_add(json_sub, "warningCause", argv[0]); | |
12525 | json_object_object_add(json_no, "detail", json_sub); | |
12526 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12527 | json_object_free(json_no); | |
12528 | } | |
12529 | else | |
12530 | vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE); | |
a80beece DS |
12531 | return CMD_WARNING; |
12532 | } | |
12533 | } | |
12534 | else | |
12535 | { | |
12536 | peer = peer_lookup (NULL, &su); | |
12537 | if (! peer) | |
856ca177 | 12538 | { |
db7c8528 | 12539 | if (uj) |
856ca177 MS |
12540 | { |
12541 | json_object *json_no = NULL; | |
12542 | json_no = json_object_new_object(); | |
12543 | json_object_string_add(json_no, "warning", "No Peer"); | |
12544 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12545 | json_object_free(json_no); | |
12546 | } | |
12547 | else | |
12548 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
12549 | return CMD_WARNING; | |
12550 | } | |
c63b83fe | 12551 | } |
718e3744 | 12552 | |
12553 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
db7c8528 | 12554 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name, uj); |
718e3744 | 12555 | if (count) |
12556 | { | |
db7c8528 | 12557 | if (!uj) |
856ca177 | 12558 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
db7c8528 | 12559 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name, uj); |
856ca177 MS |
12560 | } |
12561 | else | |
12562 | { | |
db7c8528 | 12563 | if (uj) |
856ca177 MS |
12564 | { |
12565 | json_object *json_no = NULL; | |
12566 | json_no = json_object_new_object(); | |
12567 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12568 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12569 | json_object_free(json_no); | |
12570 | } | |
12571 | else | |
12572 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
718e3744 | 12573 | } |
12574 | ||
12575 | return CMD_SUCCESS; | |
12576 | } | |
12577 | ||
12578 | ALIAS (show_bgp_neighbor_received_prefix_filter, | |
12579 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12580 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 12581 | SHOW_STR |
12582 | BGP_STR | |
12583 | "Address family\n" | |
12584 | "Detailed information on TCP and BGP neighbor connections\n" | |
12585 | "Neighbor to display information about\n" | |
12586 | "Neighbor to display information about\n" | |
a80beece | 12587 | "Neighbor on bgp configured interface\n" |
718e3744 | 12588 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12589 | "Display the prefixlist filter\n" |
12590 | "JavaScript Object Notation\n") | |
718e3744 | 12591 | |
12592 | /* old command */ | |
50ef26d4 | 12593 | ALIAS (show_bgp_neighbor_received_routes, |
718e3744 | 12594 | ipv6_bgp_neighbor_received_routes_cmd, |
856ca177 | 12595 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 12596 | SHOW_STR |
12597 | IPV6_STR | |
12598 | BGP_STR | |
12599 | "Detailed information on TCP and BGP neighbor connections\n" | |
12600 | "Neighbor to display information about\n" | |
12601 | "Neighbor to display information about\n" | |
a80beece | 12602 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12603 | "Display the received routes from neighbor\n" |
12604 | "JavaScript Object Notation\n") | |
718e3744 | 12605 | |
12606 | /* old command */ | |
12607 | DEFUN (ipv6_mbgp_neighbor_received_routes, | |
12608 | ipv6_mbgp_neighbor_received_routes_cmd, | |
856ca177 | 12609 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 12610 | SHOW_STR |
12611 | IPV6_STR | |
12612 | MBGP_STR | |
12613 | "Detailed information on TCP and BGP neighbor connections\n" | |
12614 | "Neighbor to display information about\n" | |
12615 | "Neighbor to display information about\n" | |
a80beece | 12616 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12617 | "Display the received routes from neighbor\n" |
12618 | "JavaScript Object Notation\n") | |
718e3744 | 12619 | { |
bb46e94f | 12620 | struct peer *peer; |
db7c8528 | 12621 | u_char uj = use_json(argc, argv); |
bb46e94f | 12622 | |
db7c8528 | 12623 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 12624 | if (! peer) |
12625 | return CMD_WARNING; | |
12626 | ||
47e9b292 | 12627 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 12628 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1, NULL, uj); |
bb46e94f | 12629 | } |
12630 | ||
8386ac43 | 12631 | DEFUN (show_bgp_instance_neighbor_received_prefix_filter, |
12632 | show_bgp_instance_neighbor_received_prefix_filter_cmd, | |
12633 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", | |
bb46e94f | 12634 | SHOW_STR |
12635 | BGP_STR | |
8386ac43 | 12636 | BGP_INSTANCE_HELP_STR |
bb46e94f | 12637 | "Detailed information on TCP and BGP neighbor connections\n" |
12638 | "Neighbor to display information about\n" | |
12639 | "Neighbor to display information about\n" | |
a80beece | 12640 | "Neighbor on bgp configured interface\n" |
bb46e94f | 12641 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12642 | "Display the prefixlist filter\n" |
12643 | "JavaScript Object Notation\n") | |
bb46e94f | 12644 | { |
12645 | char name[BUFSIZ]; | |
c63b83fe | 12646 | union sockunion su; |
bb46e94f | 12647 | struct peer *peer; |
12648 | struct bgp *bgp; | |
c63b83fe | 12649 | int count, ret; |
db7c8528 | 12650 | u_char uj = use_json(argc, argv); |
bb46e94f | 12651 | |
12652 | /* BGP structure lookup. */ | |
6aeb9e78 | 12653 | bgp = bgp_lookup_by_name (argv[1]); |
bb46e94f | 12654 | if (bgp == NULL) |
856ca177 | 12655 | { |
db7c8528 | 12656 | if (uj) |
856ca177 MS |
12657 | { |
12658 | json_object *json_no = NULL; | |
12659 | json_no = json_object_new_object(); | |
12660 | json_object_string_add(json_no, "warning", "Can't find BGP view"); | |
12661 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12662 | json_object_free(json_no); | |
12663 | } | |
12664 | else | |
6aeb9e78 | 12665 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
856ca177 MS |
12666 | return CMD_WARNING; |
12667 | } | |
12668 | ||
6aeb9e78 | 12669 | ret = str2sockunion (argv[2], &su); |
c63b83fe JBD |
12670 | if (ret < 0) |
12671 | { | |
6aeb9e78 | 12672 | peer = peer_lookup_by_conf_if (bgp, argv[2]); |
856ca177 | 12673 | if (! peer) |
a80beece | 12674 | { |
db7c8528 | 12675 | if (uj) |
856ca177 MS |
12676 | { |
12677 | json_object *json_no = NULL; | |
12678 | json_object *json_sub = NULL; | |
12679 | json_no = json_object_new_object(); | |
12680 | json_sub = json_object_new_object(); | |
12681 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
6aeb9e78 | 12682 | json_object_string_add(json_sub, "warningCause", argv[2]); |
856ca177 MS |
12683 | json_object_object_add(json_no, "detail", json_sub); |
12684 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12685 | json_object_free(json_no); | |
12686 | } | |
12687 | else | |
6aeb9e78 | 12688 | vty_out (vty, "%% Malformed address or name: %s%s", argv[2], VTY_NEWLINE); |
a80beece DS |
12689 | return CMD_WARNING; |
12690 | } | |
12691 | } | |
12692 | else | |
12693 | { | |
12694 | peer = peer_lookup (bgp, &su); | |
12695 | if (! peer) | |
856ca177 | 12696 | { |
db7c8528 | 12697 | if (uj) |
856ca177 MS |
12698 | { |
12699 | json_object *json_no = NULL; | |
12700 | json_no = json_object_new_object(); | |
12701 | json_object_boolean_true_add(json_no, "noPeer"); | |
12702 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12703 | json_object_free(json_no); | |
12704 | } | |
12705 | else | |
12706 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
12707 | return CMD_WARNING; | |
12708 | } | |
12709 | ||
c63b83fe | 12710 | } |
bb46e94f | 12711 | |
12712 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
db7c8528 | 12713 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name, uj); |
bb46e94f | 12714 | if (count) |
12715 | { | |
db7c8528 | 12716 | if (!uj) |
856ca177 | 12717 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
db7c8528 | 12718 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name, uj); |
bb46e94f | 12719 | } |
12720 | ||
12721 | return CMD_SUCCESS; | |
718e3744 | 12722 | } |
8386ac43 | 12723 | ALIAS (show_bgp_instance_neighbor_received_prefix_filter, |
12724 | show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd, | |
12725 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", | |
bb46e94f | 12726 | SHOW_STR |
12727 | BGP_STR | |
8386ac43 | 12728 | BGP_INSTANCE_HELP_STR |
bb46e94f | 12729 | "Address family\n" |
12730 | "Detailed information on TCP and BGP neighbor connections\n" | |
12731 | "Neighbor to display information about\n" | |
12732 | "Neighbor to display information about\n" | |
a80beece | 12733 | "Neighbor on bgp configured interface\n" |
bb46e94f | 12734 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12735 | "Display the prefixlist filter\n" |
12736 | "JavaScript Object NOtation\n") | |
718e3744 | 12737 | #endif /* HAVE_IPV6 */ |
6b0655a2 | 12738 | |
94f2b392 | 12739 | static int |
bb46e94f | 12740 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
856ca177 | 12741 | safi_t safi, enum bgp_show_type type, u_char use_json) |
718e3744 | 12742 | { |
718e3744 | 12743 | if (! peer || ! peer->afc[afi][safi]) |
12744 | { | |
856ca177 MS |
12745 | if (use_json) |
12746 | { | |
12747 | json_object *json_no = NULL; | |
12748 | json_no = json_object_new_object(); | |
12749 | json_object_string_add(json_no, "warning", "No such neighbor or address family"); | |
12750 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12751 | json_object_free(json_no); | |
12752 | } | |
12753 | else | |
12754 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
718e3744 | 12755 | return CMD_WARNING; |
12756 | } | |
47fc97cc | 12757 | |
856ca177 | 12758 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su, use_json); |
718e3744 | 12759 | } |
12760 | ||
12761 | DEFUN (show_ip_bgp_neighbor_routes, | |
12762 | show_ip_bgp_neighbor_routes_cmd, | |
856ca177 | 12763 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 12764 | SHOW_STR |
12765 | IP_STR | |
12766 | BGP_STR | |
12767 | "Detailed information on TCP and BGP neighbor connections\n" | |
12768 | "Neighbor to display information about\n" | |
12769 | "Neighbor to display information about\n" | |
a80beece | 12770 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12771 | "Display routes learned from neighbor\n" |
12772 | "JavaScript Object Notation\n") | |
718e3744 | 12773 | { |
bb46e94f | 12774 | struct peer *peer; |
db7c8528 | 12775 | u_char uj = use_json(argc, argv); |
856ca177 | 12776 | |
db7c8528 | 12777 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 12778 | if (! peer) |
12779 | return CMD_WARNING; | |
12780 | ||
12781 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
db7c8528 | 12782 | bgp_show_type_neighbor, uj); |
718e3744 | 12783 | } |
12784 | ||
8386ac43 | 12785 | DEFUN (show_ip_bgp_instance_neighbor_routes, |
12786 | show_ip_bgp_instance_neighbor_routes_cmd, | |
12787 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", | |
50ef26d4 | 12788 | SHOW_STR |
12789 | IP_STR | |
12790 | BGP_STR | |
8386ac43 | 12791 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 12792 | "Detailed information on TCP and BGP neighbor connections\n" |
12793 | "Neighbor to display information about\n" | |
12794 | "Neighbor to display information about\n" | |
12795 | "Neighbor on bgp configured interface\n" | |
12796 | "Display routes learned from neighbor\n" | |
12797 | "JavaScript Object Notation\n") | |
12798 | { | |
12799 | struct peer *peer; | |
12800 | u_char uj = use_json(argc, argv); | |
12801 | ||
12802 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
12803 | if (! peer) | |
12804 | return CMD_WARNING; | |
12805 | ||
12806 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
12807 | bgp_show_type_neighbor, uj); | |
12808 | } | |
12809 | ||
718e3744 | 12810 | DEFUN (show_ip_bgp_neighbor_flap, |
12811 | show_ip_bgp_neighbor_flap_cmd, | |
856ca177 | 12812 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", |
718e3744 | 12813 | SHOW_STR |
12814 | IP_STR | |
12815 | BGP_STR | |
12816 | "Detailed information on TCP and BGP neighbor connections\n" | |
12817 | "Neighbor to display information about\n" | |
12818 | "Neighbor to display information about\n" | |
a80beece | 12819 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12820 | "Display flap statistics of the routes learned from neighbor\n" |
12821 | "JavaScript Object Notation\n") | |
718e3744 | 12822 | { |
bb46e94f | 12823 | struct peer *peer; |
db7c8528 | 12824 | u_char uj = use_json(argc, argv); |
856ca177 | 12825 | |
db7c8528 | 12826 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 12827 | if (! peer) |
12828 | return CMD_WARNING; | |
12829 | ||
12830 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
db7c8528 | 12831 | bgp_show_type_flap_neighbor, uj); |
718e3744 | 12832 | } |
12833 | ||
12834 | DEFUN (show_ip_bgp_neighbor_damp, | |
12835 | show_ip_bgp_neighbor_damp_cmd, | |
856ca177 | 12836 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", |
718e3744 | 12837 | SHOW_STR |
12838 | IP_STR | |
12839 | BGP_STR | |
12840 | "Detailed information on TCP and BGP neighbor connections\n" | |
12841 | "Neighbor to display information about\n" | |
12842 | "Neighbor to display information about\n" | |
a80beece | 12843 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12844 | "Display the dampened routes received from neighbor\n" |
12845 | "JavaScript Object Notation\n") | |
718e3744 | 12846 | { |
bb46e94f | 12847 | struct peer *peer; |
db7c8528 | 12848 | u_char uj = use_json(argc, argv); |
856ca177 | 12849 | |
db7c8528 | 12850 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 12851 | if (! peer) |
12852 | return CMD_WARNING; | |
12853 | ||
12854 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
db7c8528 | 12855 | bgp_show_type_damp_neighbor, uj); |
718e3744 | 12856 | } |
12857 | ||
12858 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, | |
12859 | show_ip_bgp_ipv4_neighbor_routes_cmd, | |
856ca177 | 12860 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 12861 | SHOW_STR |
12862 | IP_STR | |
12863 | BGP_STR | |
12864 | "Address family\n" | |
12865 | "Address Family modifier\n" | |
12866 | "Address Family modifier\n" | |
12867 | "Detailed information on TCP and BGP neighbor connections\n" | |
12868 | "Neighbor to display information about\n" | |
12869 | "Neighbor to display information about\n" | |
a80beece | 12870 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12871 | "Display routes learned from neighbor\n" |
12872 | "JavaScript Object Notation\n") | |
718e3744 | 12873 | { |
bb46e94f | 12874 | struct peer *peer; |
db7c8528 | 12875 | u_char uj = use_json(argc, argv); |
bb46e94f | 12876 | |
db7c8528 | 12877 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12878 | if (! peer) |
12879 | return CMD_WARNING; | |
12880 | ||
718e3744 | 12881 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 12882 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
db7c8528 | 12883 | bgp_show_type_neighbor, uj); |
718e3744 | 12884 | |
bb46e94f | 12885 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
db7c8528 | 12886 | bgp_show_type_neighbor, uj); |
718e3744 | 12887 | } |
bb46e94f | 12888 | |
2a3d5731 | 12889 | #ifdef HAVE_IPV6 |
8386ac43 | 12890 | DEFUN (show_bgp_instance_neighbor_routes, |
12891 | show_bgp_instance_neighbor_routes_cmd, | |
12892 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", | |
fee0f4c6 | 12893 | SHOW_STR |
fee0f4c6 | 12894 | BGP_STR |
8386ac43 | 12895 | BGP_INSTANCE_HELP_STR |
2a3d5731 DW |
12896 | "Detailed information on TCP and BGP neighbor connections\n" |
12897 | "Neighbor to display information about\n" | |
12898 | "Neighbor to display information about\n" | |
12899 | "Neighbor on bgp configured interface\n" | |
12900 | "Display routes learned from neighbor\n" | |
12901 | "JavaScript Object Notation\n") | |
fee0f4c6 | 12902 | { |
fee0f4c6 | 12903 | struct peer *peer; |
db7c8528 | 12904 | u_char uj = use_json(argc, argv); |
fee0f4c6 | 12905 | |
50ef26d4 | 12906 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); |
fee0f4c6 | 12907 | if (! peer) |
12908 | return CMD_WARNING; | |
12909 | ||
2a3d5731 | 12910 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
db7c8528 | 12911 | bgp_show_type_neighbor, uj); |
fee0f4c6 | 12912 | } |
12913 | ||
8386ac43 | 12914 | ALIAS (show_bgp_instance_neighbor_routes, |
12915 | show_bgp_instance_ipv6_neighbor_routes_cmd, | |
12916 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", | |
fee0f4c6 | 12917 | SHOW_STR |
fee0f4c6 | 12918 | BGP_STR |
8386ac43 | 12919 | BGP_INSTANCE_HELP_STR |
2a3d5731 DW |
12920 | "Address family\n" |
12921 | "Detailed information on TCP and BGP neighbor connections\n" | |
12922 | "Neighbor to display information about\n" | |
12923 | "Neighbor to display information about\n" | |
12924 | "Neighbor on bgp configured interface\n" | |
12925 | "Display routes learned from neighbor\n" | |
12926 | "JavaScript Object Notation\n") | |
fee0f4c6 | 12927 | |
8386ac43 | 12928 | DEFUN (show_bgp_instance_neighbor_damp, |
12929 | show_bgp_instance_neighbor_damp_cmd, | |
12930 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", | |
fee0f4c6 | 12931 | SHOW_STR |
fee0f4c6 | 12932 | BGP_STR |
8386ac43 | 12933 | BGP_INSTANCE_HELP_STR |
2a3d5731 DW |
12934 | "Detailed information on TCP and BGP neighbor connections\n" |
12935 | "Neighbor to display information about\n" | |
12936 | "Neighbor to display information about\n" | |
12937 | "Neighbor on bgp configured interface\n" | |
12938 | "Display the dampened routes received from neighbor\n" | |
12939 | "JavaScript Object Notation\n") | |
bb46e94f | 12940 | { |
12941 | struct peer *peer; | |
db7c8528 | 12942 | u_char uj = use_json(argc, argv); |
856ca177 | 12943 | |
6aeb9e78 DS |
12944 | if ((argc == 4 && argv[3] && strcmp(argv[3], "json") == 0) |
12945 | || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) | |
12946 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
bb46e94f | 12947 | else |
6aeb9e78 | 12948 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12949 | |
12950 | if (! peer) | |
12951 | return CMD_WARNING; | |
12952 | ||
12953 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
db7c8528 | 12954 | bgp_show_type_damp_neighbor, uj); |
bb46e94f | 12955 | } |
12956 | ||
8386ac43 | 12957 | ALIAS (show_bgp_instance_neighbor_damp, |
12958 | show_bgp_instance_ipv6_neighbor_damp_cmd, | |
12959 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", | |
bb46e94f | 12960 | SHOW_STR |
12961 | BGP_STR | |
8386ac43 | 12962 | BGP_INSTANCE_HELP_STR |
bb46e94f | 12963 | "Address family\n" |
12964 | "Detailed information on TCP and BGP neighbor connections\n" | |
12965 | "Neighbor to display information about\n" | |
12966 | "Neighbor to display information about\n" | |
a80beece | 12967 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12968 | "Display the dampened routes received from neighbor\n" |
12969 | "JavaScript Object Notation\n") | |
bb46e94f | 12970 | |
8386ac43 | 12971 | DEFUN (show_bgp_instance_neighbor_flap, |
12972 | show_bgp_instance_neighbor_flap_cmd, | |
12973 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", | |
bb46e94f | 12974 | SHOW_STR |
12975 | BGP_STR | |
8386ac43 | 12976 | BGP_INSTANCE_HELP_STR |
bb46e94f | 12977 | "Detailed information on TCP and BGP neighbor connections\n" |
12978 | "Neighbor to display information about\n" | |
12979 | "Neighbor to display information about\n" | |
a80beece | 12980 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12981 | "Display flap statistics of the routes learned from neighbor\n" |
12982 | "JavaScript Object Notation\n") | |
bb46e94f | 12983 | { |
12984 | struct peer *peer; | |
db7c8528 | 12985 | u_char uj = use_json(argc, argv); |
856ca177 | 12986 | |
6aeb9e78 DS |
12987 | if ((argc == 4 && argv[3] && strcmp(argv[3], "json") == 0) |
12988 | || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) | |
12989 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
bb46e94f | 12990 | else |
6aeb9e78 | 12991 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12992 | |
12993 | if (! peer) | |
12994 | return CMD_WARNING; | |
12995 | ||
12996 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
db7c8528 | 12997 | bgp_show_type_flap_neighbor, uj); |
bb46e94f | 12998 | } |
12999 | ||
8386ac43 | 13000 | ALIAS (show_bgp_instance_neighbor_flap, |
13001 | show_bgp_instance_ipv6_neighbor_flap_cmd, | |
13002 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", | |
bb46e94f | 13003 | SHOW_STR |
13004 | BGP_STR | |
8386ac43 | 13005 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13006 | "Address family\n" |
13007 | "Detailed information on TCP and BGP neighbor connections\n" | |
13008 | "Neighbor to display information about\n" | |
13009 | "Neighbor to display information about\n" | |
a80beece | 13010 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13011 | "Display flap statistics of the routes learned from neighbor\n" |
13012 | "JavaScript Object Notation\n") | |
bb46e94f | 13013 | |
50ef26d4 | 13014 | DEFUN (show_bgp_neighbor_routes, |
bb46e94f | 13015 | show_bgp_neighbor_routes_cmd, |
856ca177 | 13016 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
bb46e94f | 13017 | SHOW_STR |
13018 | BGP_STR | |
13019 | "Detailed information on TCP and BGP neighbor connections\n" | |
13020 | "Neighbor to display information about\n" | |
13021 | "Neighbor to display information about\n" | |
a80beece | 13022 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13023 | "Display routes learned from neighbor\n" |
13024 | "JavaScript Object Notation\n") | |
50ef26d4 | 13025 | { |
13026 | struct peer *peer; | |
13027 | u_char uj = use_json(argc, argv); | |
bb46e94f | 13028 | |
50ef26d4 | 13029 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
13030 | if (! peer) | |
13031 | return CMD_WARNING; | |
bb46e94f | 13032 | |
50ef26d4 | 13033 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
13034 | bgp_show_type_neighbor, uj); | |
13035 | } | |
13036 | ||
13037 | ||
13038 | ALIAS (show_bgp_neighbor_routes, | |
718e3744 | 13039 | show_bgp_ipv6_neighbor_routes_cmd, |
856ca177 | 13040 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13041 | SHOW_STR |
13042 | BGP_STR | |
13043 | "Address family\n" | |
13044 | "Detailed information on TCP and BGP neighbor connections\n" | |
13045 | "Neighbor to display information about\n" | |
13046 | "Neighbor to display information about\n" | |
a80beece | 13047 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13048 | "Display routes learned from neighbor\n" |
13049 | "JavaScript Object Notation\n") | |
718e3744 | 13050 | |
13051 | /* old command */ | |
50ef26d4 | 13052 | ALIAS (show_bgp_neighbor_routes, |
718e3744 | 13053 | ipv6_bgp_neighbor_routes_cmd, |
856ca177 | 13054 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13055 | SHOW_STR |
13056 | IPV6_STR | |
13057 | BGP_STR | |
13058 | "Detailed information on TCP and BGP neighbor connections\n" | |
13059 | "Neighbor to display information about\n" | |
13060 | "Neighbor to display information about\n" | |
a80beece | 13061 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13062 | "Display routes learned from neighbor\n" |
13063 | "JavaScript Object Notation\n") | |
718e3744 | 13064 | |
13065 | /* old command */ | |
13066 | DEFUN (ipv6_mbgp_neighbor_routes, | |
13067 | ipv6_mbgp_neighbor_routes_cmd, | |
856ca177 | 13068 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13069 | SHOW_STR |
13070 | IPV6_STR | |
13071 | MBGP_STR | |
13072 | "Detailed information on TCP and BGP neighbor connections\n" | |
13073 | "Neighbor to display information about\n" | |
13074 | "Neighbor to display information about\n" | |
a80beece | 13075 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13076 | "Display routes learned from neighbor\n" |
13077 | "JavaScript Object Notation\n") | |
718e3744 | 13078 | { |
bb46e94f | 13079 | struct peer *peer; |
db7c8528 | 13080 | u_char uj = use_json(argc, argv); |
bb46e94f | 13081 | |
db7c8528 | 13082 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13083 | if (! peer) |
13084 | return CMD_WARNING; | |
13085 | ||
47e9b292 | 13086 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
bb46e94f | 13087 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
db7c8528 | 13088 | bgp_show_type_neighbor, uj); |
718e3744 | 13089 | } |
bb46e94f | 13090 | |
8386ac43 | 13091 | ALIAS (show_bgp_instance_neighbor_flap, |
bb46e94f | 13092 | show_bgp_neighbor_flap_cmd, |
856ca177 | 13093 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", |
bb46e94f | 13094 | SHOW_STR |
13095 | BGP_STR | |
13096 | "Detailed information on TCP and BGP neighbor connections\n" | |
13097 | "Neighbor to display information about\n" | |
13098 | "Neighbor to display information about\n" | |
a80beece | 13099 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13100 | "Display flap statistics of the routes learned from neighbor\n" |
13101 | "JavaScript Object Notation\n") | |
bb46e94f | 13102 | |
8386ac43 | 13103 | ALIAS (show_bgp_instance_neighbor_flap, |
bb46e94f | 13104 | show_bgp_ipv6_neighbor_flap_cmd, |
856ca177 | 13105 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", |
bb46e94f | 13106 | SHOW_STR |
13107 | BGP_STR | |
13108 | "Address family\n" | |
13109 | "Detailed information on TCP and BGP neighbor connections\n" | |
13110 | "Neighbor to display information about\n" | |
13111 | "Neighbor to display information about\n" | |
a80beece | 13112 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13113 | "Display flap statistics of the routes learned from neighbor\n" |
13114 | "JavaScript Object Notation\n") | |
bb46e94f | 13115 | |
8386ac43 | 13116 | ALIAS (show_bgp_instance_neighbor_damp, |
bb46e94f | 13117 | show_bgp_neighbor_damp_cmd, |
856ca177 | 13118 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", |
bb46e94f | 13119 | SHOW_STR |
13120 | BGP_STR | |
13121 | "Detailed information on TCP and BGP neighbor connections\n" | |
13122 | "Neighbor to display information about\n" | |
13123 | "Neighbor to display information about\n" | |
a80beece | 13124 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13125 | "Display the dampened routes received from neighbor\n" |
13126 | "JavaScript Object Notation\n") | |
bb46e94f | 13127 | |
8386ac43 | 13128 | ALIAS (show_bgp_instance_neighbor_damp, |
bb46e94f | 13129 | show_bgp_ipv6_neighbor_damp_cmd, |
856ca177 | 13130 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", |
bb46e94f | 13131 | SHOW_STR |
13132 | BGP_STR | |
13133 | "Address family\n" | |
13134 | "Detailed information on TCP and BGP neighbor connections\n" | |
13135 | "Neighbor to display information about\n" | |
13136 | "Neighbor to display information about\n" | |
a80beece | 13137 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13138 | "Display the dampened routes received from neighbor\n" |
13139 | "JavaScript Object Notation\n") | |
fee0f4c6 | 13140 | |
718e3744 | 13141 | #endif /* HAVE_IPV6 */ |
6b0655a2 | 13142 | |
718e3744 | 13143 | struct bgp_table *bgp_distance_table; |
13144 | ||
13145 | struct bgp_distance | |
13146 | { | |
13147 | /* Distance value for the IP source prefix. */ | |
13148 | u_char distance; | |
13149 | ||
13150 | /* Name of the access-list to be matched. */ | |
13151 | char *access_list; | |
13152 | }; | |
13153 | ||
94f2b392 | 13154 | static struct bgp_distance * |
66e5cd87 | 13155 | bgp_distance_new (void) |
718e3744 | 13156 | { |
393deb9b | 13157 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
718e3744 | 13158 | } |
13159 | ||
94f2b392 | 13160 | static void |
718e3744 | 13161 | bgp_distance_free (struct bgp_distance *bdistance) |
13162 | { | |
13163 | XFREE (MTYPE_BGP_DISTANCE, bdistance); | |
13164 | } | |
13165 | ||
94f2b392 | 13166 | static int |
fd79ac91 | 13167 | bgp_distance_set (struct vty *vty, const char *distance_str, |
13168 | const char *ip_str, const char *access_list_str) | |
718e3744 | 13169 | { |
13170 | int ret; | |
13171 | struct prefix_ipv4 p; | |
13172 | u_char distance; | |
13173 | struct bgp_node *rn; | |
13174 | struct bgp_distance *bdistance; | |
13175 | ||
13176 | ret = str2prefix_ipv4 (ip_str, &p); | |
13177 | if (ret == 0) | |
13178 | { | |
13179 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
13180 | return CMD_WARNING; | |
13181 | } | |
13182 | ||
13183 | distance = atoi (distance_str); | |
13184 | ||
13185 | /* Get BGP distance node. */ | |
13186 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); | |
13187 | if (rn->info) | |
13188 | { | |
13189 | bdistance = rn->info; | |
13190 | bgp_unlock_node (rn); | |
13191 | } | |
13192 | else | |
13193 | { | |
13194 | bdistance = bgp_distance_new (); | |
13195 | rn->info = bdistance; | |
13196 | } | |
13197 | ||
13198 | /* Set distance value. */ | |
13199 | bdistance->distance = distance; | |
13200 | ||
13201 | /* Reset access-list configuration. */ | |
13202 | if (bdistance->access_list) | |
13203 | { | |
6e919709 | 13204 | XFREE(MTYPE_AS_LIST, bdistance->access_list); |
718e3744 | 13205 | bdistance->access_list = NULL; |
13206 | } | |
13207 | if (access_list_str) | |
6e919709 | 13208 | bdistance->access_list = XSTRDUP(MTYPE_AS_LIST, access_list_str); |
718e3744 | 13209 | |
13210 | return CMD_SUCCESS; | |
13211 | } | |
13212 | ||
94f2b392 | 13213 | static int |
fd79ac91 | 13214 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
13215 | const char *ip_str, const char *access_list_str) | |
718e3744 | 13216 | { |
13217 | int ret; | |
13218 | struct prefix_ipv4 p; | |
718e3744 | 13219 | struct bgp_node *rn; |
13220 | struct bgp_distance *bdistance; | |
13221 | ||
13222 | ret = str2prefix_ipv4 (ip_str, &p); | |
13223 | if (ret == 0) | |
13224 | { | |
13225 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
13226 | return CMD_WARNING; | |
13227 | } | |
13228 | ||
718e3744 | 13229 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
13230 | if (! rn) | |
13231 | { | |
13232 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); | |
13233 | return CMD_WARNING; | |
13234 | } | |
13235 | ||
13236 | bdistance = rn->info; | |
13237 | ||
13238 | if (bdistance->access_list) | |
6e919709 | 13239 | XFREE(MTYPE_AS_LIST, bdistance->access_list); |
718e3744 | 13240 | bgp_distance_free (bdistance); |
13241 | ||
13242 | rn->info = NULL; | |
13243 | bgp_unlock_node (rn); | |
13244 | bgp_unlock_node (rn); | |
13245 | ||
13246 | return CMD_SUCCESS; | |
13247 | } | |
13248 | ||
718e3744 | 13249 | /* Apply BGP information to distance method. */ |
13250 | u_char | |
13251 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) | |
13252 | { | |
13253 | struct bgp_node *rn; | |
13254 | struct prefix_ipv4 q; | |
13255 | struct peer *peer; | |
13256 | struct bgp_distance *bdistance; | |
13257 | struct access_list *alist; | |
13258 | struct bgp_static *bgp_static; | |
13259 | ||
13260 | if (! bgp) | |
13261 | return 0; | |
13262 | ||
13263 | if (p->family != AF_INET) | |
13264 | return 0; | |
13265 | ||
13266 | peer = rinfo->peer; | |
13267 | ||
13268 | if (peer->su.sa.sa_family != AF_INET) | |
13269 | return 0; | |
13270 | ||
13271 | memset (&q, 0, sizeof (struct prefix_ipv4)); | |
13272 | q.family = AF_INET; | |
13273 | q.prefix = peer->su.sin.sin_addr; | |
13274 | q.prefixlen = IPV4_MAX_BITLEN; | |
13275 | ||
13276 | /* Check source address. */ | |
13277 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); | |
13278 | if (rn) | |
13279 | { | |
13280 | bdistance = rn->info; | |
13281 | bgp_unlock_node (rn); | |
13282 | ||
13283 | if (bdistance->access_list) | |
13284 | { | |
13285 | alist = access_list_lookup (AFI_IP, bdistance->access_list); | |
13286 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) | |
13287 | return bdistance->distance; | |
13288 | } | |
13289 | else | |
13290 | return bdistance->distance; | |
13291 | } | |
13292 | ||
13293 | /* Backdoor check. */ | |
13294 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); | |
13295 | if (rn) | |
13296 | { | |
13297 | bgp_static = rn->info; | |
13298 | bgp_unlock_node (rn); | |
13299 | ||
13300 | if (bgp_static->backdoor) | |
13301 | { | |
13302 | if (bgp->distance_local) | |
13303 | return bgp->distance_local; | |
13304 | else | |
13305 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
13306 | } | |
13307 | } | |
13308 | ||
6d85b15b | 13309 | if (peer->sort == BGP_PEER_EBGP) |
718e3744 | 13310 | { |
13311 | if (bgp->distance_ebgp) | |
13312 | return bgp->distance_ebgp; | |
13313 | return ZEBRA_EBGP_DISTANCE_DEFAULT; | |
13314 | } | |
13315 | else | |
13316 | { | |
13317 | if (bgp->distance_ibgp) | |
13318 | return bgp->distance_ibgp; | |
13319 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
13320 | } | |
13321 | } | |
13322 | ||
13323 | DEFUN (bgp_distance, | |
13324 | bgp_distance_cmd, | |
13325 | "distance bgp <1-255> <1-255> <1-255>", | |
13326 | "Define an administrative distance\n" | |
13327 | "BGP distance\n" | |
13328 | "Distance for routes external to the AS\n" | |
13329 | "Distance for routes internal to the AS\n" | |
13330 | "Distance for local routes\n") | |
13331 | { | |
13332 | struct bgp *bgp; | |
13333 | ||
13334 | bgp = vty->index; | |
13335 | ||
13336 | bgp->distance_ebgp = atoi (argv[0]); | |
13337 | bgp->distance_ibgp = atoi (argv[1]); | |
13338 | bgp->distance_local = atoi (argv[2]); | |
13339 | return CMD_SUCCESS; | |
13340 | } | |
13341 | ||
13342 | DEFUN (no_bgp_distance, | |
13343 | no_bgp_distance_cmd, | |
13344 | "no distance bgp <1-255> <1-255> <1-255>", | |
13345 | NO_STR | |
13346 | "Define an administrative distance\n" | |
13347 | "BGP distance\n" | |
13348 | "Distance for routes external to the AS\n" | |
13349 | "Distance for routes internal to the AS\n" | |
13350 | "Distance for local routes\n") | |
13351 | { | |
13352 | struct bgp *bgp; | |
13353 | ||
13354 | bgp = vty->index; | |
13355 | ||
13356 | bgp->distance_ebgp= 0; | |
13357 | bgp->distance_ibgp = 0; | |
13358 | bgp->distance_local = 0; | |
13359 | return CMD_SUCCESS; | |
13360 | } | |
13361 | ||
13362 | ALIAS (no_bgp_distance, | |
13363 | no_bgp_distance2_cmd, | |
13364 | "no distance bgp", | |
13365 | NO_STR | |
13366 | "Define an administrative distance\n" | |
13367 | "BGP distance\n") | |
13368 | ||
13369 | DEFUN (bgp_distance_source, | |
13370 | bgp_distance_source_cmd, | |
13371 | "distance <1-255> A.B.C.D/M", | |
13372 | "Define an administrative distance\n" | |
13373 | "Administrative distance\n" | |
13374 | "IP source prefix\n") | |
13375 | { | |
13376 | bgp_distance_set (vty, argv[0], argv[1], NULL); | |
13377 | return CMD_SUCCESS; | |
13378 | } | |
13379 | ||
13380 | DEFUN (no_bgp_distance_source, | |
13381 | no_bgp_distance_source_cmd, | |
13382 | "no distance <1-255> A.B.C.D/M", | |
13383 | NO_STR | |
13384 | "Define an administrative distance\n" | |
13385 | "Administrative distance\n" | |
13386 | "IP source prefix\n") | |
13387 | { | |
13388 | bgp_distance_unset (vty, argv[0], argv[1], NULL); | |
13389 | return CMD_SUCCESS; | |
13390 | } | |
13391 | ||
13392 | DEFUN (bgp_distance_source_access_list, | |
13393 | bgp_distance_source_access_list_cmd, | |
13394 | "distance <1-255> A.B.C.D/M WORD", | |
13395 | "Define an administrative distance\n" | |
13396 | "Administrative distance\n" | |
13397 | "IP source prefix\n" | |
13398 | "Access list name\n") | |
13399 | { | |
13400 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); | |
13401 | return CMD_SUCCESS; | |
13402 | } | |
13403 | ||
13404 | DEFUN (no_bgp_distance_source_access_list, | |
13405 | no_bgp_distance_source_access_list_cmd, | |
13406 | "no distance <1-255> A.B.C.D/M WORD", | |
13407 | NO_STR | |
13408 | "Define an administrative distance\n" | |
13409 | "Administrative distance\n" | |
13410 | "IP source prefix\n" | |
13411 | "Access list name\n") | |
13412 | { | |
13413 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); | |
13414 | return CMD_SUCCESS; | |
13415 | } | |
6b0655a2 | 13416 | |
718e3744 | 13417 | DEFUN (bgp_damp_set, |
13418 | bgp_damp_set_cmd, | |
13419 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
13420 | "BGP Specific commands\n" | |
13421 | "Enable route-flap dampening\n" | |
13422 | "Half-life time for the penalty\n" | |
13423 | "Value to start reusing a route\n" | |
13424 | "Value to start suppressing a route\n" | |
13425 | "Maximum duration to suppress a stable route\n") | |
13426 | { | |
13427 | struct bgp *bgp; | |
13428 | int half = DEFAULT_HALF_LIFE * 60; | |
13429 | int reuse = DEFAULT_REUSE; | |
13430 | int suppress = DEFAULT_SUPPRESS; | |
13431 | int max = 4 * half; | |
13432 | ||
13433 | if (argc == 4) | |
13434 | { | |
13435 | half = atoi (argv[0]) * 60; | |
13436 | reuse = atoi (argv[1]); | |
13437 | suppress = atoi (argv[2]); | |
13438 | max = atoi (argv[3]) * 60; | |
13439 | } | |
13440 | else if (argc == 1) | |
13441 | { | |
13442 | half = atoi (argv[0]) * 60; | |
13443 | max = 4 * half; | |
13444 | } | |
13445 | ||
13446 | bgp = vty->index; | |
13447 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), | |
13448 | half, reuse, suppress, max); | |
13449 | } | |
13450 | ||
13451 | ALIAS (bgp_damp_set, | |
13452 | bgp_damp_set2_cmd, | |
13453 | "bgp dampening <1-45>", | |
13454 | "BGP Specific commands\n" | |
13455 | "Enable route-flap dampening\n" | |
13456 | "Half-life time for the penalty\n") | |
13457 | ||
13458 | ALIAS (bgp_damp_set, | |
13459 | bgp_damp_set3_cmd, | |
13460 | "bgp dampening", | |
13461 | "BGP Specific commands\n" | |
13462 | "Enable route-flap dampening\n") | |
13463 | ||
13464 | DEFUN (bgp_damp_unset, | |
13465 | bgp_damp_unset_cmd, | |
13466 | "no bgp dampening", | |
13467 | NO_STR | |
13468 | "BGP Specific commands\n" | |
13469 | "Enable route-flap dampening\n") | |
13470 | { | |
13471 | struct bgp *bgp; | |
13472 | ||
13473 | bgp = vty->index; | |
13474 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); | |
13475 | } | |
13476 | ||
13477 | ALIAS (bgp_damp_unset, | |
13478 | bgp_damp_unset2_cmd, | |
13479 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
13480 | NO_STR | |
13481 | "BGP Specific commands\n" | |
13482 | "Enable route-flap dampening\n" | |
13483 | "Half-life time for the penalty\n" | |
13484 | "Value to start reusing a route\n" | |
13485 | "Value to start suppressing a route\n" | |
13486 | "Maximum duration to suppress a stable route\n") | |
13487 | ||
813d4307 DW |
13488 | ALIAS (bgp_damp_unset, |
13489 | bgp_damp_unset3_cmd, | |
13490 | "no bgp dampening <1-45>", | |
13491 | NO_STR | |
13492 | "BGP Specific commands\n" | |
13493 | "Enable route-flap dampening\n" | |
13494 | "Half-life time for the penalty\n") | |
13495 | ||
718e3744 | 13496 | DEFUN (show_ip_bgp_dampened_paths, |
13497 | show_ip_bgp_dampened_paths_cmd, | |
13498 | "show ip bgp dampened-paths", | |
13499 | SHOW_STR | |
13500 | IP_STR | |
13501 | BGP_STR | |
13502 | "Display paths suppressed due to dampening\n") | |
13503 | { | |
5a646650 | 13504 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
b05a1c8b | 13505 | NULL, 0); |
718e3744 | 13506 | } |
13507 | ||
13508 | DEFUN (show_ip_bgp_flap_statistics, | |
13509 | show_ip_bgp_flap_statistics_cmd, | |
13510 | "show ip bgp flap-statistics", | |
13511 | SHOW_STR | |
13512 | IP_STR | |
13513 | BGP_STR | |
13514 | "Display flap statistics of routes\n") | |
13515 | { | |
5a646650 | 13516 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
b05a1c8b | 13517 | bgp_show_type_flap_statistics, NULL, 0); |
718e3744 | 13518 | } |
6b0655a2 | 13519 | |
718e3744 | 13520 | /* Display specified route of BGP table. */ |
94f2b392 | 13521 | static int |
fd79ac91 | 13522 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
13523 | const char *ip_str, afi_t afi, safi_t safi, | |
13524 | struct prefix_rd *prd, int prefix_check) | |
718e3744 | 13525 | { |
13526 | int ret; | |
13527 | struct prefix match; | |
13528 | struct bgp_node *rn; | |
13529 | struct bgp_node *rm; | |
13530 | struct bgp_info *ri; | |
13531 | struct bgp_info *ri_temp; | |
13532 | struct bgp *bgp; | |
13533 | struct bgp_table *table; | |
13534 | ||
13535 | /* BGP structure lookup. */ | |
13536 | if (view_name) | |
13537 | { | |
13538 | bgp = bgp_lookup_by_name (view_name); | |
13539 | if (bgp == NULL) | |
13540 | { | |
6aeb9e78 | 13541 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
718e3744 | 13542 | return CMD_WARNING; |
13543 | } | |
13544 | } | |
13545 | else | |
13546 | { | |
13547 | bgp = bgp_get_default (); | |
13548 | if (bgp == NULL) | |
13549 | { | |
13550 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
13551 | return CMD_WARNING; | |
13552 | } | |
13553 | } | |
13554 | ||
13555 | /* Check IP address argument. */ | |
13556 | ret = str2prefix (ip_str, &match); | |
13557 | if (! ret) | |
13558 | { | |
13559 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
13560 | return CMD_WARNING; | |
13561 | } | |
13562 | ||
13563 | match.family = afi2family (afi); | |
13564 | ||
13565 | if (safi == SAFI_MPLS_VPN) | |
13566 | { | |
13567 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) | |
13568 | { | |
13569 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
13570 | continue; | |
13571 | ||
13572 | if ((table = rn->info) != NULL) | |
13573 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6c88b44d CC |
13574 | { |
13575 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) | |
13576 | { | |
13577 | ri = rm->info; | |
13578 | while (ri) | |
13579 | { | |
13580 | if (ri->extra && ri->extra->damp_info) | |
13581 | { | |
13582 | ri_temp = ri->next; | |
13583 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
13584 | ri = ri_temp; | |
13585 | } | |
13586 | else | |
13587 | ri = ri->next; | |
13588 | } | |
13589 | } | |
13590 | ||
13591 | bgp_unlock_node (rm); | |
13592 | } | |
718e3744 | 13593 | } |
13594 | } | |
13595 | else | |
13596 | { | |
13597 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) | |
6c88b44d CC |
13598 | { |
13599 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
13600 | { | |
13601 | ri = rn->info; | |
13602 | while (ri) | |
13603 | { | |
13604 | if (ri->extra && ri->extra->damp_info) | |
13605 | { | |
13606 | ri_temp = ri->next; | |
13607 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
13608 | ri = ri_temp; | |
13609 | } | |
13610 | else | |
13611 | ri = ri->next; | |
13612 | } | |
13613 | } | |
13614 | ||
13615 | bgp_unlock_node (rn); | |
13616 | } | |
718e3744 | 13617 | } |
13618 | ||
13619 | return CMD_SUCCESS; | |
13620 | } | |
13621 | ||
13622 | DEFUN (clear_ip_bgp_dampening, | |
13623 | clear_ip_bgp_dampening_cmd, | |
13624 | "clear ip bgp dampening", | |
13625 | CLEAR_STR | |
13626 | IP_STR | |
13627 | BGP_STR | |
13628 | "Clear route flap dampening information\n") | |
13629 | { | |
13630 | bgp_damp_info_clean (); | |
13631 | return CMD_SUCCESS; | |
13632 | } | |
13633 | ||
13634 | DEFUN (clear_ip_bgp_dampening_prefix, | |
13635 | clear_ip_bgp_dampening_prefix_cmd, | |
13636 | "clear ip bgp dampening A.B.C.D/M", | |
13637 | CLEAR_STR | |
13638 | IP_STR | |
13639 | BGP_STR | |
13640 | "Clear route flap dampening information\n" | |
13641 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
13642 | { | |
13643 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
13644 | SAFI_UNICAST, NULL, 1); | |
13645 | } | |
13646 | ||
13647 | DEFUN (clear_ip_bgp_dampening_address, | |
13648 | clear_ip_bgp_dampening_address_cmd, | |
13649 | "clear ip bgp dampening A.B.C.D", | |
13650 | CLEAR_STR | |
13651 | IP_STR | |
13652 | BGP_STR | |
13653 | "Clear route flap dampening information\n" | |
13654 | "Network to clear damping information\n") | |
13655 | { | |
13656 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
13657 | SAFI_UNICAST, NULL, 0); | |
13658 | } | |
13659 | ||
13660 | DEFUN (clear_ip_bgp_dampening_address_mask, | |
13661 | clear_ip_bgp_dampening_address_mask_cmd, | |
13662 | "clear ip bgp dampening A.B.C.D A.B.C.D", | |
13663 | CLEAR_STR | |
13664 | IP_STR | |
13665 | BGP_STR | |
13666 | "Clear route flap dampening information\n" | |
13667 | "Network to clear damping information\n" | |
13668 | "Network mask\n") | |
13669 | { | |
13670 | int ret; | |
13671 | char prefix_str[BUFSIZ]; | |
13672 | ||
13673 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
13674 | if (! ret) | |
13675 | { | |
13676 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
13677 | return CMD_WARNING; | |
13678 | } | |
13679 | ||
13680 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, | |
13681 | SAFI_UNICAST, NULL, 0); | |
13682 | } | |
6b0655a2 | 13683 | |
94f2b392 | 13684 | static int |
718e3744 | 13685 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
13686 | afi_t afi, safi_t safi, int *write) | |
13687 | { | |
13688 | struct bgp_node *prn; | |
13689 | struct bgp_node *rn; | |
13690 | struct bgp_table *table; | |
13691 | struct prefix *p; | |
13692 | struct prefix_rd *prd; | |
13693 | struct bgp_static *bgp_static; | |
13694 | u_int32_t label; | |
13695 | char buf[SU_ADDRSTRLEN]; | |
13696 | char rdbuf[RD_ADDRSTRLEN]; | |
13697 | ||
13698 | /* Network configuration. */ | |
13699 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) | |
13700 | if ((table = prn->info) != NULL) | |
13701 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
13702 | if ((bgp_static = rn->info) != NULL) | |
13703 | { | |
13704 | p = &rn->p; | |
13705 | prd = (struct prefix_rd *) &prn->p; | |
13706 | ||
13707 | /* "address-family" display. */ | |
13708 | bgp_config_write_family_header (vty, afi, safi, write); | |
13709 | ||
13710 | /* "network" configuration display. */ | |
13711 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); | |
13712 | label = decode_label (bgp_static->tag); | |
13713 | ||
0b960b4d | 13714 | vty_out (vty, " network %s/%d rd %s tag %d", |
718e3744 | 13715 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
13716 | p->prefixlen, | |
13717 | rdbuf, label); | |
13718 | vty_out (vty, "%s", VTY_NEWLINE); | |
13719 | } | |
13720 | return 0; | |
13721 | } | |
13722 | ||
13723 | /* Configuration of static route announcement and aggregate | |
13724 | information. */ | |
13725 | int | |
13726 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, | |
13727 | afi_t afi, safi_t safi, int *write) | |
13728 | { | |
13729 | struct bgp_node *rn; | |
13730 | struct prefix *p; | |
13731 | struct bgp_static *bgp_static; | |
13732 | struct bgp_aggregate *bgp_aggregate; | |
13733 | char buf[SU_ADDRSTRLEN]; | |
13734 | ||
13735 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
13736 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); | |
13737 | ||
13738 | /* Network configuration. */ | |
13739 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
13740 | if ((bgp_static = rn->info) != NULL) | |
13741 | { | |
13742 | p = &rn->p; | |
13743 | ||
13744 | /* "address-family" display. */ | |
13745 | bgp_config_write_family_header (vty, afi, safi, write); | |
13746 | ||
13747 | /* "network" configuration display. */ | |
13748 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
13749 | { | |
13750 | u_int32_t destination; | |
13751 | struct in_addr netmask; | |
13752 | ||
13753 | destination = ntohl (p->u.prefix4.s_addr); | |
13754 | masklen2ip (p->prefixlen, &netmask); | |
0b960b4d | 13755 | vty_out (vty, " network %s", |
718e3744 | 13756 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
13757 | ||
13758 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
13759 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
13760 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
13761 | || p->u.prefix4.s_addr == 0) | |
13762 | { | |
13763 | /* Natural mask is not display. */ | |
13764 | } | |
13765 | else | |
13766 | vty_out (vty, " mask %s", inet_ntoa (netmask)); | |
13767 | } | |
13768 | else | |
13769 | { | |
0b960b4d | 13770 | vty_out (vty, " network %s/%d", |
718e3744 | 13771 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
13772 | p->prefixlen); | |
13773 | } | |
13774 | ||
13775 | if (bgp_static->rmap.name) | |
13776 | vty_out (vty, " route-map %s", bgp_static->rmap.name); | |
41367172 PJ |
13777 | else |
13778 | { | |
13779 | if (bgp_static->backdoor) | |
13780 | vty_out (vty, " backdoor"); | |
41367172 | 13781 | } |
718e3744 | 13782 | |
13783 | vty_out (vty, "%s", VTY_NEWLINE); | |
13784 | } | |
13785 | ||
13786 | /* Aggregate-address configuration. */ | |
13787 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) | |
13788 | if ((bgp_aggregate = rn->info) != NULL) | |
13789 | { | |
13790 | p = &rn->p; | |
13791 | ||
13792 | /* "address-family" display. */ | |
13793 | bgp_config_write_family_header (vty, afi, safi, write); | |
13794 | ||
13795 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
13796 | { | |
13797 | struct in_addr netmask; | |
13798 | ||
13799 | masklen2ip (p->prefixlen, &netmask); | |
0b960b4d | 13800 | vty_out (vty, " aggregate-address %s %s", |
718e3744 | 13801 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
13802 | inet_ntoa (netmask)); | |
13803 | } | |
13804 | else | |
13805 | { | |
0b960b4d | 13806 | vty_out (vty, " aggregate-address %s/%d", |
718e3744 | 13807 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
13808 | p->prefixlen); | |
13809 | } | |
13810 | ||
13811 | if (bgp_aggregate->as_set) | |
13812 | vty_out (vty, " as-set"); | |
13813 | ||
13814 | if (bgp_aggregate->summary_only) | |
13815 | vty_out (vty, " summary-only"); | |
13816 | ||
13817 | vty_out (vty, "%s", VTY_NEWLINE); | |
13818 | } | |
13819 | ||
13820 | return 0; | |
13821 | } | |
13822 | ||
13823 | int | |
13824 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) | |
13825 | { | |
13826 | struct bgp_node *rn; | |
13827 | struct bgp_distance *bdistance; | |
13828 | ||
13829 | /* Distance configuration. */ | |
13830 | if (bgp->distance_ebgp | |
13831 | && bgp->distance_ibgp | |
13832 | && bgp->distance_local | |
13833 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT | |
13834 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT | |
13835 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) | |
13836 | vty_out (vty, " distance bgp %d %d %d%s", | |
13837 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, | |
13838 | VTY_NEWLINE); | |
13839 | ||
13840 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) | |
13841 | if ((bdistance = rn->info) != NULL) | |
13842 | { | |
13843 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, | |
13844 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
13845 | bdistance->access_list ? bdistance->access_list : "", | |
13846 | VTY_NEWLINE); | |
13847 | } | |
13848 | ||
13849 | return 0; | |
13850 | } | |
13851 | ||
13852 | /* Allocate routing table structure and install commands. */ | |
13853 | void | |
66e5cd87 | 13854 | bgp_route_init (void) |
718e3744 | 13855 | { |
13856 | /* Init BGP distance table. */ | |
64e580a7 | 13857 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
718e3744 | 13858 | |
13859 | /* IPv4 BGP commands. */ | |
73ac8160 | 13860 | install_element (BGP_NODE, &bgp_table_map_cmd); |
718e3744 | 13861 | install_element (BGP_NODE, &bgp_network_cmd); |
13862 | install_element (BGP_NODE, &bgp_network_mask_cmd); | |
13863 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); | |
13864 | install_element (BGP_NODE, &bgp_network_route_map_cmd); | |
13865 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); | |
13866 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); | |
13867 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); | |
13868 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); | |
13869 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); | |
73ac8160 | 13870 | install_element (BGP_NODE, &no_bgp_table_map_cmd); |
718e3744 | 13871 | install_element (BGP_NODE, &no_bgp_network_cmd); |
13872 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); | |
13873 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); | |
13874 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); | |
13875 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); | |
13876 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
13877 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); | |
13878 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); | |
13879 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); | |
13880 | ||
13881 | install_element (BGP_NODE, &aggregate_address_cmd); | |
13882 | install_element (BGP_NODE, &aggregate_address_mask_cmd); | |
13883 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); | |
13884 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); | |
13885 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); | |
13886 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); | |
13887 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); | |
13888 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
13889 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); | |
13890 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
13891 | install_element (BGP_NODE, &no_aggregate_address_cmd); | |
13892 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); | |
13893 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); | |
13894 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); | |
13895 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); | |
13896 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); | |
13897 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
13898 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); | |
13899 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
13900 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
13901 | ||
13902 | /* IPv4 unicast configuration. */ | |
73ac8160 | 13903 | install_element (BGP_IPV4_NODE, &bgp_table_map_cmd); |
718e3744 | 13904 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
13905 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); | |
13906 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); | |
13907 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); | |
13908 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); | |
13909 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); | |
73ac8160 | 13910 | install_element (BGP_IPV4_NODE, &no_bgp_table_map_cmd); |
c8f3fe30 | 13911 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
718e3744 | 13912 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
13913 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); | |
13914 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); | |
13915 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); | |
13916 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
c8f3fe30 | 13917 | |
718e3744 | 13918 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
13919 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); | |
13920 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); | |
13921 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); | |
13922 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); | |
13923 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); | |
13924 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); | |
13925 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
13926 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); | |
13927 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
13928 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); | |
13929 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); | |
13930 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); | |
13931 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); | |
13932 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); | |
13933 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); | |
13934 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
13935 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); | |
13936 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
13937 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
13938 | ||
13939 | /* IPv4 multicast configuration. */ | |
73ac8160 | 13940 | install_element (BGP_IPV4M_NODE, &bgp_table_map_cmd); |
718e3744 | 13941 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
13942 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); | |
13943 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); | |
13944 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); | |
13945 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); | |
13946 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); | |
73ac8160 | 13947 | install_element (BGP_IPV4M_NODE, &no_bgp_table_map_cmd); |
718e3744 | 13948 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
13949 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); | |
13950 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); | |
13951 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); | |
13952 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); | |
13953 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
13954 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); | |
13955 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); | |
13956 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); | |
13957 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); | |
13958 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); | |
13959 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); | |
13960 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); | |
13961 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
13962 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); | |
13963 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
13964 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); | |
13965 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); | |
13966 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); | |
13967 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); | |
13968 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); | |
13969 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); | |
13970 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
13971 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); | |
13972 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
13973 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
13974 | ||
13975 | install_element (VIEW_NODE, &show_ip_bgp_cmd); | |
8386ac43 | 13976 | install_element (VIEW_NODE, &show_ip_bgp_instance_cmd); |
718e3744 | 13977 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
95cbbd2a | 13978 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 13979 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
8386ac43 | 13980 | install_element (VIEW_NODE, &show_ip_bgp_instance_route_cmd); |
4092b06c | 13981 | install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); |
8386ac43 | 13982 | install_element (VIEW_NODE, &show_ip_bgp_instance_route_pathtype_cmd); |
4092b06c | 13983 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
718e3744 | 13984 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
95cbbd2a | 13985 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 13986 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
13987 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
13988 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); | |
8386ac43 | 13989 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_cmd); |
718e3744 | 13990 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
4092b06c DS |
13991 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
13992 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); | |
95cbbd2a | 13993 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
4092b06c | 13994 | install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
8386ac43 | 13995 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); |
718e3744 | 13996 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
13997 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
50ef26d4 | 13998 | |
718e3744 | 13999 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
14000 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
14001 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); | |
8386ac43 | 14002 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_list_cmd); |
718e3744 | 14003 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
14004 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); | |
8386ac43 | 14005 | install_element (VIEW_NODE, &show_ip_bgp_instance_filter_list_cmd); |
718e3744 | 14006 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
14007 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); | |
8386ac43 | 14008 | install_element (VIEW_NODE, &show_ip_bgp_instance_route_map_cmd); |
718e3744 | 14009 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
14010 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); | |
14011 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
14012 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); | |
14013 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
14014 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); | |
14015 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); | |
14016 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); | |
14017 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); | |
14018 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); | |
14019 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
14020 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
14021 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
8386ac43 | 14022 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_all_cmd); |
14023 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_cmd); | |
14024 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community2_cmd); | |
14025 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community3_cmd); | |
14026 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community4_cmd); | |
718e3744 | 14027 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
14028 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); | |
14029 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); | |
14030 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); | |
14031 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
14032 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
14033 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
14034 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
14035 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); | |
8386ac43 | 14036 | install_element (VIEW_NODE, &show_ip_bgp_instance_community_list_cmd); |
718e3744 | 14037 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
14038 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); | |
14039 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
14040 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); | |
8386ac43 | 14041 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_longer_cmd); |
718e3744 | 14042 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
14043 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
8386ac43 | 14044 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); |
0b16f239 | 14045 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_rmap_cmd); |
8386ac43 | 14046 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14047 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
0b16f239 | 14048 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14049 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
8386ac43 | 14050 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd); |
0b16f239 | 14051 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14052 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd); |
718e3744 | 14053 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
0b16f239 | 14054 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14055 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 14056 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
8386ac43 | 14057 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_routes_cmd); |
718e3744 | 14058 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
14059 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
14060 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
14061 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); | |
14062 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); | |
14063 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); | |
14064 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); | |
14065 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
14066 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); | |
14067 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
14068 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
14069 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
14070 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); | |
14071 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
14072 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
62687ff1 PJ |
14073 | |
14074 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ | |
14075 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); | |
8386ac43 | 14076 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd); |
4092b06c | 14077 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd); |
8386ac43 | 14078 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_pathtype_cmd); |
4092b06c | 14079 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
62687ff1 | 14080 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
95cbbd2a | 14081 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
62687ff1 PJ |
14082 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
14083 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); | |
8386ac43 | 14084 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd); |
62687ff1 | 14085 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
4092b06c DS |
14086 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
14087 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); | |
95cbbd2a | 14088 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
4092b06c | 14089 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
8386ac43 | 14090 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); |
62687ff1 PJ |
14091 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
14092 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
8386ac43 | 14093 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd); |
14094 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd); | |
62687ff1 PJ |
14095 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
14096 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); | |
14097 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); | |
14098 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); | |
14099 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); | |
14100 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
14101 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
14102 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
8386ac43 | 14103 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_all_cmd); |
14104 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_cmd); | |
14105 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community2_cmd); | |
14106 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community3_cmd); | |
14107 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community4_cmd); | |
62687ff1 PJ |
14108 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
14109 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); | |
14110 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); | |
14111 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); | |
14112 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
14113 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
14114 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
14115 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
718e3744 | 14116 | |
14117 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); | |
8386ac43 | 14118 | install_element (ENABLE_NODE, &show_ip_bgp_instance_cmd); |
718e3744 | 14119 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
95cbbd2a | 14120 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 14121 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
8386ac43 | 14122 | install_element (ENABLE_NODE, &show_ip_bgp_instance_route_cmd); |
4092b06c | 14123 | install_element (ENABLE_NODE, &show_ip_bgp_route_pathtype_cmd); |
8386ac43 | 14124 | install_element (ENABLE_NODE, &show_ip_bgp_instance_route_pathtype_cmd); |
4092b06c | 14125 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
718e3744 | 14126 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
95cbbd2a | 14127 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 14128 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
14129 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
14130 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); | |
8386ac43 | 14131 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_cmd); |
718e3744 | 14132 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
4092b06c DS |
14133 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
14134 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); | |
95cbbd2a | 14135 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
4092b06c | 14136 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
8386ac43 | 14137 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); |
718e3744 | 14138 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
14139 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
50ef26d4 | 14140 | |
718e3744 | 14141 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
14142 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
14143 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); | |
8386ac43 | 14144 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_list_cmd); |
718e3744 | 14145 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
14146 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); | |
8386ac43 | 14147 | install_element (ENABLE_NODE, &show_ip_bgp_instance_filter_list_cmd); |
718e3744 | 14148 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
14149 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); | |
8386ac43 | 14150 | install_element (ENABLE_NODE, &show_ip_bgp_instance_route_map_cmd); |
718e3744 | 14151 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
14152 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); | |
14153 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
14154 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); | |
14155 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
14156 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); | |
14157 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); | |
14158 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); | |
14159 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); | |
14160 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); | |
14161 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
14162 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
14163 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
8386ac43 | 14164 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_all_cmd); |
14165 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_cmd); | |
14166 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community2_cmd); | |
14167 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community3_cmd); | |
14168 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community4_cmd); | |
718e3744 | 14169 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
14170 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); | |
14171 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); | |
14172 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); | |
14173 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
14174 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
14175 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
14176 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
14177 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); | |
8386ac43 | 14178 | install_element (ENABLE_NODE, &show_ip_bgp_instance_community_list_cmd); |
718e3744 | 14179 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
14180 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); | |
14181 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
14182 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); | |
8386ac43 | 14183 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_longer_cmd); |
718e3744 | 14184 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
14185 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
8386ac43 | 14186 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); |
0b16f239 | 14187 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_rmap_cmd); |
8386ac43 | 14188 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14189 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
0b16f239 | 14190 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14191 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
8386ac43 | 14192 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd); |
0b16f239 | 14193 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14194 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd); |
718e3744 | 14195 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
0b16f239 | 14196 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14197 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 14198 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
8386ac43 | 14199 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_routes_cmd); |
718e3744 | 14200 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
14201 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
14202 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
14203 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); | |
14204 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); | |
14205 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); | |
14206 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); | |
14207 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
14208 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); | |
14209 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
14210 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
14211 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
14212 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); | |
14213 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
14214 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
14215 | ||
14216 | /* BGP dampening clear commands */ | |
14217 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); | |
14218 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); | |
14219 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); | |
14220 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); | |
14221 | ||
ff7924f6 PJ |
14222 | /* prefix count */ |
14223 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); | |
8386ac43 | 14224 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_prefix_counts_cmd); |
ff7924f6 PJ |
14225 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
14226 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); | |
718e3744 | 14227 | #ifdef HAVE_IPV6 |
ff7924f6 | 14228 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
8386ac43 | 14229 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd); |
ff7924f6 | 14230 | |
718e3744 | 14231 | /* New config IPv6 BGP commands. */ |
73ac8160 | 14232 | install_element (BGP_IPV6_NODE, &bgp_table_map_cmd); |
718e3744 | 14233 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
14234 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); | |
73ac8160 | 14235 | install_element (BGP_IPV6_NODE, &no_bgp_table_map_cmd); |
718e3744 | 14236 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
14237 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); | |
14238 | ||
14239 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); | |
14240 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); | |
14241 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); | |
14242 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); | |
73bfe0bd B |
14243 | |
14244 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); | |
14245 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); | |
718e3744 | 14246 | |
14247 | /* Old config IPv6 BGP commands. */ | |
14248 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); | |
14249 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); | |
14250 | ||
14251 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); | |
14252 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); | |
14253 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); | |
14254 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); | |
14255 | ||
14256 | install_element (VIEW_NODE, &show_bgp_cmd); | |
14257 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 14258 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 14259 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
14260 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 14261 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
4092b06c DS |
14262 | install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd); |
14263 | install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd); | |
14264 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); | |
718e3744 | 14265 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
14266 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 14267 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
4092b06c DS |
14268 | install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd); |
14269 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); | |
14270 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); | |
718e3744 | 14271 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
14272 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); | |
14273 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); | |
14274 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
14275 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); | |
14276 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); | |
14277 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); | |
14278 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); | |
14279 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); | |
14280 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); | |
14281 | install_element (VIEW_NODE, &show_bgp_community_cmd); | |
14282 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); | |
14283 | install_element (VIEW_NODE, &show_bgp_community2_cmd); | |
14284 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); | |
14285 | install_element (VIEW_NODE, &show_bgp_community3_cmd); | |
14286 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); | |
14287 | install_element (VIEW_NODE, &show_bgp_community4_cmd); | |
14288 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); | |
14289 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); | |
14290 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); | |
14291 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); | |
14292 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
14293 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); | |
14294 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
14295 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); | |
14296 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
14297 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); | |
14298 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); | |
14299 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); | |
14300 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
14301 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); | |
14302 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
14303 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
14304 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
14305 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); | |
14306 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
14307 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); | |
14308 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
14309 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
14310 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 14311 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
14312 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
14313 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); | |
14314 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
8386ac43 | 14315 | install_element (VIEW_NODE, &show_bgp_instance_cmd); |
14316 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_cmd); | |
14317 | install_element (VIEW_NODE, &show_bgp_instance_route_cmd); | |
14318 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_cmd); | |
14319 | install_element (VIEW_NODE, &show_bgp_instance_route_pathtype_cmd); | |
14320 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); | |
14321 | install_element (VIEW_NODE, &show_bgp_instance_prefix_cmd); | |
14322 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_cmd); | |
14323 | install_element (VIEW_NODE, &show_bgp_instance_prefix_pathtype_cmd); | |
14324 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_pathtype_cmd); | |
14325 | install_element (VIEW_NODE, &show_bgp_instance_prefix_list_cmd); | |
14326 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_list_cmd); | |
14327 | install_element (VIEW_NODE, &show_bgp_instance_filter_list_cmd); | |
14328 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_filter_list_cmd); | |
14329 | install_element (VIEW_NODE, &show_bgp_instance_route_map_cmd); | |
14330 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_map_cmd); | |
14331 | install_element (VIEW_NODE, &show_bgp_instance_community_list_cmd); | |
14332 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_community_list_cmd); | |
14333 | install_element (VIEW_NODE, &show_bgp_instance_prefix_longer_cmd); | |
14334 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_longer_cmd); | |
14335 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_advertised_route_cmd); | |
14336 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd); | |
14337 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_routes_cmd); | |
14338 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_received_routes_cmd); | |
14339 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_routes_cmd); | |
14340 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_routes_cmd); | |
14341 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); | |
14342 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); | |
14343 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_flap_cmd); | |
14344 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_flap_cmd); | |
14345 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_damp_cmd); | |
14346 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_damp_cmd); | |
62687ff1 PJ |
14347 | |
14348 | /* Restricted: | |
14349 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) | |
14350 | */ | |
14351 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); | |
14352 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 14353 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
4092b06c DS |
14354 | install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd); |
14355 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd); | |
14356 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); | |
62687ff1 PJ |
14357 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
14358 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 14359 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
4092b06c DS |
14360 | install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd); |
14361 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); | |
14362 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); | |
62687ff1 PJ |
14363 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
14364 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); | |
14365 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); | |
14366 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); | |
14367 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); | |
14368 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); | |
14369 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); | |
14370 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); | |
14371 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); | |
14372 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); | |
14373 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); | |
14374 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
14375 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); | |
14376 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
14377 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); | |
14378 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
8386ac43 | 14379 | install_element (RESTRICTED_NODE, &show_bgp_instance_route_cmd); |
14380 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_route_cmd); | |
14381 | install_element (RESTRICTED_NODE, &show_bgp_instance_route_pathtype_cmd); | |
14382 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); | |
14383 | install_element (RESTRICTED_NODE, &show_bgp_instance_prefix_cmd); | |
14384 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_prefix_cmd); | |
14385 | install_element (RESTRICTED_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); | |
14386 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); | |
718e3744 | 14387 | |
14388 | install_element (ENABLE_NODE, &show_bgp_cmd); | |
14389 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 14390 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 14391 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
14392 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 14393 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
4092b06c DS |
14394 | install_element (ENABLE_NODE, &show_bgp_route_pathtype_cmd); |
14395 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_pathtype_cmd); | |
14396 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); | |
718e3744 | 14397 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
4092b06c DS |
14398 | install_element (ENABLE_NODE, &show_bgp_prefix_pathtype_cmd); |
14399 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); | |
14400 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); | |
718e3744 | 14401 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
95cbbd2a | 14402 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
718e3744 | 14403 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
14404 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); | |
14405 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); | |
14406 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
14407 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); | |
14408 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); | |
14409 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); | |
14410 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); | |
14411 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); | |
14412 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); | |
14413 | install_element (ENABLE_NODE, &show_bgp_community_cmd); | |
14414 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); | |
14415 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); | |
14416 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); | |
14417 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); | |
14418 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); | |
14419 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); | |
14420 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); | |
14421 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); | |
14422 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); | |
14423 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); | |
14424 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
14425 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); | |
14426 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
14427 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); | |
14428 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
14429 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); | |
14430 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); | |
14431 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); | |
14432 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
14433 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); | |
14434 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
14435 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
14436 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
14437 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); | |
14438 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
14439 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); | |
14440 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
14441 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
14442 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 14443 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
14444 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
14445 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); | |
14446 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
8386ac43 | 14447 | install_element (ENABLE_NODE, &show_bgp_instance_cmd); |
14448 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_cmd); | |
14449 | install_element (ENABLE_NODE, &show_bgp_instance_route_cmd); | |
14450 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_cmd); | |
14451 | install_element (ENABLE_NODE, &show_bgp_instance_route_pathtype_cmd); | |
14452 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); | |
14453 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_cmd); | |
14454 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_cmd); | |
14455 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_pathtype_cmd); | |
14456 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_pathtype_cmd); | |
14457 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_list_cmd); | |
14458 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_list_cmd); | |
14459 | install_element (ENABLE_NODE, &show_bgp_instance_filter_list_cmd); | |
14460 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_filter_list_cmd); | |
14461 | install_element (ENABLE_NODE, &show_bgp_instance_route_map_cmd); | |
14462 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_map_cmd); | |
14463 | install_element (ENABLE_NODE, &show_bgp_instance_community_list_cmd); | |
14464 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_community_list_cmd); | |
14465 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_longer_cmd); | |
14466 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_longer_cmd); | |
14467 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_advertised_route_cmd); | |
14468 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd); | |
14469 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_routes_cmd); | |
14470 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_received_routes_cmd); | |
14471 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_routes_cmd); | |
14472 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_routes_cmd); | |
14473 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); | |
14474 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); | |
14475 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_flap_cmd); | |
14476 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_flap_cmd); | |
14477 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_damp_cmd); | |
14478 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_damp_cmd); | |
50ef26d4 | 14479 | |
2815e61f PJ |
14480 | /* Statistics */ |
14481 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); | |
14482 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); | |
14483 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); | |
14484 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); | |
14485 | ||
718e3744 | 14486 | /* old command */ |
14487 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); | |
14488 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); | |
14489 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); | |
14490 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); | |
14491 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
14492 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); | |
14493 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); | |
14494 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); | |
14495 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); | |
14496 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); | |
14497 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); | |
14498 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); | |
14499 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
14500 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
14501 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
14502 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); | |
14503 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
14504 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
14505 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); | |
14506 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); | |
14507 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); | |
14508 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); | |
14509 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
14510 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
14511 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); | |
14512 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); | |
14513 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); | |
14514 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); | |
14515 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); | |
14516 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
14517 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
14518 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
14519 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
14520 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); | |
14521 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
14522 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
bb46e94f | 14523 | |
718e3744 | 14524 | /* old command */ |
14525 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); | |
14526 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); | |
14527 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); | |
14528 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); | |
14529 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
14530 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); | |
14531 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); | |
14532 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); | |
14533 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); | |
14534 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); | |
14535 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); | |
14536 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); | |
14537 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
14538 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
14539 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
14540 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); | |
14541 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
14542 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
14543 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); | |
14544 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); | |
14545 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); | |
14546 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); | |
14547 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
14548 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
14549 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); | |
14550 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); | |
14551 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); | |
14552 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); | |
14553 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); | |
14554 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
14555 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
14556 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
14557 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
14558 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); | |
14559 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
14560 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
14561 | ||
14562 | /* old command */ | |
14563 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
14564 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
14565 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
14566 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
14567 | ||
14568 | /* old command */ | |
14569 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
14570 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
14571 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
14572 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
14573 | ||
14574 | /* old command */ | |
14575 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
14576 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
14577 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
14578 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
14579 | #endif /* HAVE_IPV6 */ | |
14580 | ||
14581 | install_element (BGP_NODE, &bgp_distance_cmd); | |
14582 | install_element (BGP_NODE, &no_bgp_distance_cmd); | |
14583 | install_element (BGP_NODE, &no_bgp_distance2_cmd); | |
14584 | install_element (BGP_NODE, &bgp_distance_source_cmd); | |
14585 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); | |
14586 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); | |
14587 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); | |
14588 | ||
14589 | install_element (BGP_NODE, &bgp_damp_set_cmd); | |
14590 | install_element (BGP_NODE, &bgp_damp_set2_cmd); | |
14591 | install_element (BGP_NODE, &bgp_damp_set3_cmd); | |
14592 | install_element (BGP_NODE, &bgp_damp_unset_cmd); | |
14593 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); | |
813d4307 | 14594 | install_element (BGP_NODE, &bgp_damp_unset3_cmd); |
718e3744 | 14595 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
14596 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); | |
14597 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); | |
14598 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); | |
14599 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); | |
813d4307 | 14600 | install_element (BGP_IPV4_NODE, &bgp_damp_unset3_cmd); |
718e3744 | 14601 | } |
228da428 CC |
14602 | |
14603 | void | |
14604 | bgp_route_finish (void) | |
14605 | { | |
14606 | bgp_table_unlock (bgp_distance_table); | |
14607 | bgp_distance_table = NULL; | |
14608 | } |