]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP routing information |
2 | Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro | |
3 | ||
4 | This file is part of GNU Zebra. | |
5 | ||
6 | GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU General Public License as published by the | |
8 | Free Software Foundation; either version 2, or (at your option) any | |
9 | later version. | |
10 | ||
11 | GNU Zebra is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU Zebra; see the file COPYING. If not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | 02111-1307, USA. */ | |
20 | ||
21 | #include <zebra.h> | |
22 | ||
856ca177 | 23 | #include "lib/json.h" |
718e3744 | 24 | #include "prefix.h" |
25 | #include "linklist.h" | |
26 | #include "memory.h" | |
27 | #include "command.h" | |
28 | #include "stream.h" | |
29 | #include "filter.h" | |
30 | #include "str.h" | |
31 | #include "log.h" | |
32 | #include "routemap.h" | |
33 | #include "buffer.h" | |
34 | #include "sockunion.h" | |
35 | #include "plist.h" | |
36 | #include "thread.h" | |
200df115 | 37 | #include "workqueue.h" |
3f9c7369 | 38 | #include "queue.h" |
6e919709 | 39 | #include "memory.h" |
718e3744 | 40 | |
41 | #include "bgpd/bgpd.h" | |
42 | #include "bgpd/bgp_table.h" | |
43 | #include "bgpd/bgp_route.h" | |
44 | #include "bgpd/bgp_attr.h" | |
45 | #include "bgpd/bgp_debug.h" | |
46 | #include "bgpd/bgp_aspath.h" | |
47 | #include "bgpd/bgp_regex.h" | |
48 | #include "bgpd/bgp_community.h" | |
49 | #include "bgpd/bgp_ecommunity.h" | |
50 | #include "bgpd/bgp_clist.h" | |
51 | #include "bgpd/bgp_packet.h" | |
52 | #include "bgpd/bgp_filter.h" | |
53 | #include "bgpd/bgp_fsm.h" | |
54 | #include "bgpd/bgp_mplsvpn.h" | |
55 | #include "bgpd/bgp_nexthop.h" | |
56 | #include "bgpd/bgp_damp.h" | |
57 | #include "bgpd/bgp_advertise.h" | |
58 | #include "bgpd/bgp_zebra.h" | |
0a486e5f | 59 | #include "bgpd/bgp_vty.h" |
96450faf | 60 | #include "bgpd/bgp_mpath.h" |
fc9a856f | 61 | #include "bgpd/bgp_nht.h" |
3f9c7369 | 62 | #include "bgpd/bgp_updgrp.h" |
8386ac43 | 63 | #include "bgpd/bgp_vty.h" |
718e3744 | 64 | |
65 | /* Extern from bgp_dump.c */ | |
dde72586 SH |
66 | extern const char *bgp_origin_str[]; |
67 | extern const char *bgp_origin_long_str[]; | |
6b0655a2 | 68 | |
4125bb67 | 69 | struct bgp_node * |
fee0f4c6 | 70 | bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, |
718e3744 | 71 | struct prefix_rd *prd) |
72 | { | |
73 | struct bgp_node *rn; | |
74 | struct bgp_node *prn = NULL; | |
da5b30f6 PJ |
75 | |
76 | assert (table); | |
77 | if (!table) | |
78 | return NULL; | |
79 | ||
587ff0fd | 80 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 81 | { |
fee0f4c6 | 82 | prn = bgp_node_get (table, (struct prefix *) prd); |
718e3744 | 83 | |
84 | if (prn->info == NULL) | |
64e580a7 | 85 | prn->info = bgp_table_init (afi, safi); |
718e3744 | 86 | else |
87 | bgp_unlock_node (prn); | |
88 | table = prn->info; | |
89 | } | |
718e3744 | 90 | |
91 | rn = bgp_node_get (table, p); | |
92 | ||
587ff0fd | 93 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 94 | rn->prn = prn; |
95 | ||
96 | return rn; | |
97 | } | |
6b0655a2 | 98 | |
fb982c25 PJ |
99 | /* Allocate bgp_info_extra */ |
100 | static struct bgp_info_extra * | |
101 | bgp_info_extra_new (void) | |
102 | { | |
103 | struct bgp_info_extra *new; | |
104 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); | |
105 | return new; | |
106 | } | |
107 | ||
108 | static void | |
109 | bgp_info_extra_free (struct bgp_info_extra **extra) | |
110 | { | |
111 | if (extra && *extra) | |
112 | { | |
113 | if ((*extra)->damp_info) | |
114 | bgp_damp_info_free ((*extra)->damp_info, 0); | |
115 | ||
116 | (*extra)->damp_info = NULL; | |
117 | ||
118 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); | |
119 | ||
120 | *extra = NULL; | |
121 | } | |
122 | } | |
123 | ||
124 | /* Get bgp_info extra information for the given bgp_info, lazy allocated | |
125 | * if required. | |
126 | */ | |
127 | struct bgp_info_extra * | |
128 | bgp_info_extra_get (struct bgp_info *ri) | |
129 | { | |
130 | if (!ri->extra) | |
131 | ri->extra = bgp_info_extra_new(); | |
132 | return ri->extra; | |
133 | } | |
134 | ||
718e3744 | 135 | /* Free bgp route information. */ |
200df115 | 136 | static void |
718e3744 | 137 | bgp_info_free (struct bgp_info *binfo) |
138 | { | |
139 | if (binfo->attr) | |
f6f434b2 | 140 | bgp_attr_unintern (&binfo->attr); |
fb018d25 DS |
141 | |
142 | bgp_unlink_nexthop(binfo); | |
fb982c25 | 143 | bgp_info_extra_free (&binfo->extra); |
de8d5dff | 144 | bgp_info_mpath_free (&binfo->mpath); |
718e3744 | 145 | |
200df115 | 146 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
147 | ||
718e3744 | 148 | XFREE (MTYPE_BGP_ROUTE, binfo); |
149 | } | |
150 | ||
200df115 | 151 | struct bgp_info * |
152 | bgp_info_lock (struct bgp_info *binfo) | |
153 | { | |
154 | binfo->lock++; | |
155 | return binfo; | |
156 | } | |
157 | ||
158 | struct bgp_info * | |
159 | bgp_info_unlock (struct bgp_info *binfo) | |
160 | { | |
161 | assert (binfo && binfo->lock > 0); | |
162 | binfo->lock--; | |
163 | ||
164 | if (binfo->lock == 0) | |
165 | { | |
166 | #if 0 | |
167 | zlog_debug ("%s: unlocked and freeing", __func__); | |
168 | zlog_backtrace (LOG_DEBUG); | |
169 | #endif | |
170 | bgp_info_free (binfo); | |
171 | return NULL; | |
172 | } | |
173 | ||
174 | #if 0 | |
175 | if (binfo->lock == 1) | |
176 | { | |
177 | zlog_debug ("%s: unlocked to 1", __func__); | |
178 | zlog_backtrace (LOG_DEBUG); | |
179 | } | |
180 | #endif | |
181 | ||
182 | return binfo; | |
183 | } | |
184 | ||
718e3744 | 185 | void |
186 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) | |
187 | { | |
188 | struct bgp_info *top; | |
189 | ||
190 | top = rn->info; | |
200df115 | 191 | |
718e3744 | 192 | ri->next = rn->info; |
193 | ri->prev = NULL; | |
194 | if (top) | |
195 | top->prev = ri; | |
196 | rn->info = ri; | |
200df115 | 197 | |
198 | bgp_info_lock (ri); | |
199 | bgp_lock_node (rn); | |
200 | peer_lock (ri->peer); /* bgp_info peer reference */ | |
718e3744 | 201 | } |
202 | ||
b40d939b | 203 | /* Do the actual removal of info from RIB, for use by bgp_process |
204 | completion callback *only* */ | |
205 | static void | |
206 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) | |
718e3744 | 207 | { |
208 | if (ri->next) | |
209 | ri->next->prev = ri->prev; | |
210 | if (ri->prev) | |
211 | ri->prev->next = ri->next; | |
212 | else | |
213 | rn->info = ri->next; | |
200df115 | 214 | |
de8d5dff | 215 | bgp_info_mpath_dequeue (ri); |
200df115 | 216 | bgp_info_unlock (ri); |
217 | bgp_unlock_node (rn); | |
718e3744 | 218 | } |
219 | ||
b40d939b | 220 | void |
221 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) | |
222 | { | |
1a392d46 PJ |
223 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
224 | /* set of previous already took care of pcount */ | |
b40d939b | 225 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
226 | } | |
227 | ||
8d45210e AS |
228 | /* undo the effects of a previous call to bgp_info_delete; typically |
229 | called when a route is deleted and then quickly re-added before the | |
230 | deletion has been processed */ | |
231 | static void | |
232 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) | |
233 | { | |
234 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); | |
235 | /* unset of previous already took care of pcount */ | |
236 | SET_FLAG (ri->flags, BGP_INFO_VALID); | |
237 | } | |
238 | ||
1a392d46 PJ |
239 | /* Adjust pcount as required */ |
240 | static void | |
241 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) | |
242 | { | |
67174041 AS |
243 | struct bgp_table *table; |
244 | ||
245 | assert (rn && bgp_node_table (rn)); | |
6f58544d PJ |
246 | assert (ri && ri->peer && ri->peer->bgp); |
247 | ||
67174041 AS |
248 | table = bgp_node_table (rn); |
249 | ||
2a3d5731 | 250 | if (ri->peer == ri->peer->bgp->peer_self) |
1a392d46 PJ |
251 | return; |
252 | ||
80e0ad24 | 253 | if (!BGP_INFO_COUNTABLE (ri) |
1a392d46 PJ |
254 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
255 | { | |
256 | ||
257 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
258 | ||
259 | /* slight hack, but more robust against errors. */ | |
67174041 AS |
260 | if (ri->peer->pcount[table->afi][table->safi]) |
261 | ri->peer->pcount[table->afi][table->safi]--; | |
1a392d46 PJ |
262 | else |
263 | { | |
264 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", | |
265 | __func__, ri->peer->host); | |
266 | zlog_backtrace (LOG_WARNING); | |
267 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); | |
268 | } | |
269 | } | |
80e0ad24 | 270 | else if (BGP_INFO_COUNTABLE (ri) |
1a392d46 PJ |
271 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
272 | { | |
273 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
67174041 | 274 | ri->peer->pcount[table->afi][table->safi]++; |
1a392d46 PJ |
275 | } |
276 | } | |
277 | ||
278 | ||
279 | /* Set/unset bgp_info flags, adjusting any other state as needed. | |
280 | * This is here primarily to keep prefix-count in check. | |
281 | */ | |
282 | void | |
283 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
284 | { | |
285 | SET_FLAG (ri->flags, flag); | |
286 | ||
80e0ad24 DS |
287 | /* early bath if we know it's not a flag that changes countability state */ |
288 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED)) | |
1a392d46 PJ |
289 | return; |
290 | ||
291 | bgp_pcount_adjust (rn, ri); | |
292 | } | |
293 | ||
294 | void | |
295 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
296 | { | |
297 | UNSET_FLAG (ri->flags, flag); | |
298 | ||
80e0ad24 DS |
299 | /* early bath if we know it's not a flag that changes countability state */ |
300 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED)) | |
1a392d46 PJ |
301 | return; |
302 | ||
303 | bgp_pcount_adjust (rn, ri); | |
304 | } | |
305 | ||
718e3744 | 306 | /* Get MED value. If MED value is missing and "bgp bestpath |
307 | missing-as-worst" is specified, treat it as the worst value. */ | |
94f2b392 | 308 | static u_int32_t |
718e3744 | 309 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
310 | { | |
311 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
312 | return attr->med; | |
313 | else | |
314 | { | |
315 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
3b424979 | 316 | return BGP_MED_MAX; |
718e3744 | 317 | else |
318 | return 0; | |
319 | } | |
320 | } | |
321 | ||
2ec1e66f DW |
322 | void |
323 | bgp_info_path_with_addpath_rx_str (struct bgp_info *ri, char *buf) | |
324 | { | |
325 | if (ri->addpath_rx_id) | |
326 | sprintf(buf, "path %s (addpath rxid %d)", ri->peer->host, ri->addpath_rx_id); | |
327 | else | |
328 | sprintf(buf, "path %s", ri->peer->host); | |
329 | } | |
330 | ||
9fbdd100 | 331 | /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */ |
94f2b392 | 332 | static int |
96450faf | 333 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
9fbdd100 DS |
334 | int *paths_eq, struct bgp_maxpaths_cfg *mpath_cfg, int debug, |
335 | char *pfx_buf) | |
718e3744 | 336 | { |
8ff56318 JBD |
337 | struct attr *newattr, *existattr; |
338 | struct attr_extra *newattre, *existattre; | |
339 | bgp_peer_sort_t new_sort; | |
340 | bgp_peer_sort_t exist_sort; | |
718e3744 | 341 | u_int32_t new_pref; |
342 | u_int32_t exist_pref; | |
343 | u_int32_t new_med; | |
344 | u_int32_t exist_med; | |
8ff56318 JBD |
345 | u_int32_t new_weight; |
346 | u_int32_t exist_weight; | |
347 | uint32_t newm, existm; | |
718e3744 | 348 | struct in_addr new_id; |
349 | struct in_addr exist_id; | |
350 | int new_cluster; | |
351 | int exist_cluster; | |
8ff56318 JBD |
352 | int internal_as_route; |
353 | int confed_as_route; | |
718e3744 | 354 | int ret; |
2ec1e66f DW |
355 | char new_buf[PATH_ADDPATH_STR_BUFFER]; |
356 | char exist_buf[PATH_ADDPATH_STR_BUFFER]; | |
96450faf JB |
357 | |
358 | *paths_eq = 0; | |
718e3744 | 359 | |
360 | /* 0. Null check. */ | |
361 | if (new == NULL) | |
9fbdd100 DS |
362 | { |
363 | if (debug) | |
364 | zlog_debug("%s: new is NULL", pfx_buf); | |
365 | return 0; | |
366 | } | |
367 | ||
2ec1e66f DW |
368 | if (debug) |
369 | bgp_info_path_with_addpath_rx_str (new, new_buf); | |
370 | ||
718e3744 | 371 | if (exist == NULL) |
9fbdd100 DS |
372 | { |
373 | if (debug) | |
2ec1e66f | 374 | zlog_debug("%s: %s is the initial bestpath", pfx_buf, new_buf); |
9fbdd100 DS |
375 | return 1; |
376 | } | |
718e3744 | 377 | |
2ec1e66f DW |
378 | if (debug) |
379 | bgp_info_path_with_addpath_rx_str (exist, exist_buf); | |
380 | ||
8ff56318 JBD |
381 | newattr = new->attr; |
382 | existattr = exist->attr; | |
383 | newattre = newattr->extra; | |
384 | existattre = existattr->extra; | |
385 | ||
718e3744 | 386 | /* 1. Weight check. */ |
8ff56318 JBD |
387 | new_weight = exist_weight = 0; |
388 | ||
389 | if (newattre) | |
390 | new_weight = newattre->weight; | |
391 | if (existattre) | |
392 | exist_weight = existattre->weight; | |
393 | ||
fb982c25 | 394 | if (new_weight > exist_weight) |
9fbdd100 DS |
395 | { |
396 | if (debug) | |
2ec1e66f DW |
397 | zlog_debug("%s: %s wins over %s due to weight %d > %d", |
398 | pfx_buf, new_buf, exist_buf, new_weight, exist_weight); | |
9fbdd100 DS |
399 | return 1; |
400 | } | |
401 | ||
fb982c25 | 402 | if (new_weight < exist_weight) |
9fbdd100 DS |
403 | { |
404 | if (debug) | |
2ec1e66f DW |
405 | zlog_debug("%s: %s loses to %s due to weight %d < %d", |
406 | pfx_buf, new_buf, exist_buf, new_weight, exist_weight); | |
9fbdd100 DS |
407 | return 0; |
408 | } | |
718e3744 | 409 | |
410 | /* 2. Local preference check. */ | |
8ff56318 JBD |
411 | new_pref = exist_pref = bgp->default_local_pref; |
412 | ||
413 | if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
414 | new_pref = newattr->local_pref; | |
415 | if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
416 | exist_pref = existattr->local_pref; | |
718e3744 | 417 | |
718e3744 | 418 | if (new_pref > exist_pref) |
9fbdd100 DS |
419 | { |
420 | if (debug) | |
2ec1e66f DW |
421 | zlog_debug("%s: %s wins over %s due to localpref %d > %d", |
422 | pfx_buf, new_buf, exist_buf, new_pref, exist_pref); | |
9fbdd100 DS |
423 | return 1; |
424 | } | |
425 | ||
718e3744 | 426 | if (new_pref < exist_pref) |
9fbdd100 DS |
427 | { |
428 | if (debug) | |
2ec1e66f DW |
429 | zlog_debug("%s: %s loses to %s due to localpref %d < %d", |
430 | pfx_buf, new_buf, exist_buf, new_pref, exist_pref); | |
9fbdd100 DS |
431 | return 0; |
432 | } | |
718e3744 | 433 | |
8ff56318 JBD |
434 | /* 3. Local route check. We prefer: |
435 | * - BGP_ROUTE_STATIC | |
436 | * - BGP_ROUTE_AGGREGATE | |
437 | * - BGP_ROUTE_REDISTRIBUTE | |
438 | */ | |
439 | if (! (new->sub_type == BGP_ROUTE_NORMAL)) | |
9fbdd100 DS |
440 | { |
441 | if (debug) | |
2ec1e66f DW |
442 | zlog_debug("%s: %s wins over %s due to preferred BGP_ROUTE type", |
443 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
444 | return 1; |
445 | } | |
446 | ||
8ff56318 | 447 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
9fbdd100 DS |
448 | { |
449 | if (debug) | |
2ec1e66f DW |
450 | zlog_debug("%s: %s loses to %s due to preferred BGP_ROUTE type", |
451 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
452 | return 0; |
453 | } | |
718e3744 | 454 | |
455 | /* 4. AS path length check. */ | |
456 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) | |
457 | { | |
8ff56318 JBD |
458 | int exist_hops = aspath_count_hops (existattr->aspath); |
459 | int exist_confeds = aspath_count_confeds (existattr->aspath); | |
fe69a505 | 460 | |
6811845b | 461 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
462 | { | |
fe69a505 | 463 | int aspath_hops; |
464 | ||
8ff56318 JBD |
465 | aspath_hops = aspath_count_hops (newattr->aspath); |
466 | aspath_hops += aspath_count_confeds (newattr->aspath); | |
fe69a505 | 467 | |
468 | if ( aspath_hops < (exist_hops + exist_confeds)) | |
9fbdd100 DS |
469 | { |
470 | if (debug) | |
2ec1e66f DW |
471 | zlog_debug("%s: %s wins over %s due to aspath (with confeds) hopcount %d < %d", |
472 | pfx_buf, new_buf, exist_buf, | |
9fbdd100 DS |
473 | aspath_hops, (exist_hops + exist_confeds)); |
474 | return 1; | |
475 | } | |
476 | ||
fe69a505 | 477 | if ( aspath_hops > (exist_hops + exist_confeds)) |
9fbdd100 DS |
478 | { |
479 | if (debug) | |
2ec1e66f DW |
480 | zlog_debug("%s: %s loses to %s due to aspath (with confeds) hopcount %d > %d", |
481 | pfx_buf, new_buf, exist_buf, | |
9fbdd100 DS |
482 | aspath_hops, (exist_hops + exist_confeds)); |
483 | return 0; | |
484 | } | |
6811845b | 485 | } |
486 | else | |
487 | { | |
8ff56318 | 488 | int newhops = aspath_count_hops (newattr->aspath); |
fe69a505 | 489 | |
490 | if (newhops < exist_hops) | |
9fbdd100 DS |
491 | { |
492 | if (debug) | |
2ec1e66f DW |
493 | zlog_debug("%s: %s wins over %s due to aspath hopcount %d < %d", |
494 | pfx_buf, new_buf, exist_buf, newhops, exist_hops); | |
9fbdd100 DS |
495 | return 1; |
496 | } | |
497 | ||
fe69a505 | 498 | if (newhops > exist_hops) |
9fbdd100 DS |
499 | { |
500 | if (debug) | |
2ec1e66f DW |
501 | zlog_debug("%s: %s loses to %s due to aspath hopcount %d > %d", |
502 | pfx_buf, new_buf, exist_buf, newhops, exist_hops); | |
9fbdd100 DS |
503 | return 0; |
504 | } | |
6811845b | 505 | } |
718e3744 | 506 | } |
507 | ||
508 | /* 5. Origin check. */ | |
8ff56318 | 509 | if (newattr->origin < existattr->origin) |
9fbdd100 DS |
510 | { |
511 | if (debug) | |
2ec1e66f DW |
512 | zlog_debug("%s: %s wins over %s due to ORIGIN %s < %s", |
513 | pfx_buf, new_buf, exist_buf, | |
9fbdd100 DS |
514 | bgp_origin_long_str[newattr->origin], |
515 | bgp_origin_long_str[existattr->origin]); | |
516 | return 1; | |
517 | } | |
518 | ||
8ff56318 | 519 | if (newattr->origin > existattr->origin) |
9fbdd100 DS |
520 | { |
521 | if (debug) | |
2ec1e66f DW |
522 | zlog_debug("%s: %s loses to %s due to ORIGIN %s > %s", |
523 | pfx_buf, new_buf, exist_buf, | |
9fbdd100 DS |
524 | bgp_origin_long_str[newattr->origin], |
525 | bgp_origin_long_str[existattr->origin]); | |
526 | return 0; | |
527 | } | |
718e3744 | 528 | |
529 | /* 6. MED check. */ | |
8ff56318 JBD |
530 | internal_as_route = (aspath_count_hops (newattr->aspath) == 0 |
531 | && aspath_count_hops (existattr->aspath) == 0); | |
532 | confed_as_route = (aspath_count_confeds (newattr->aspath) > 0 | |
533 | && aspath_count_confeds (existattr->aspath) > 0 | |
534 | && aspath_count_hops (newattr->aspath) == 0 | |
535 | && aspath_count_hops (existattr->aspath) == 0); | |
718e3744 | 536 | |
537 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) | |
538 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) | |
539 | && confed_as_route) | |
8ff56318 JBD |
540 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
541 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) | |
718e3744 | 542 | || internal_as_route) |
543 | { | |
544 | new_med = bgp_med_value (new->attr, bgp); | |
545 | exist_med = bgp_med_value (exist->attr, bgp); | |
546 | ||
547 | if (new_med < exist_med) | |
9fbdd100 DS |
548 | { |
549 | if (debug) | |
2ec1e66f DW |
550 | zlog_debug("%s: %s wins over %s due to MED %d < %d", |
551 | pfx_buf, new_buf, exist_buf, new_med, exist_med); | |
9fbdd100 DS |
552 | return 1; |
553 | } | |
554 | ||
718e3744 | 555 | if (new_med > exist_med) |
9fbdd100 DS |
556 | { |
557 | if (debug) | |
2ec1e66f DW |
558 | zlog_debug("%s: %s loses to %s due to MED %d > %d", |
559 | pfx_buf, new_buf, exist_buf, new_med, exist_med); | |
9fbdd100 DS |
560 | return 0; |
561 | } | |
718e3744 | 562 | } |
563 | ||
564 | /* 7. Peer type check. */ | |
8ff56318 JBD |
565 | new_sort = new->peer->sort; |
566 | exist_sort = exist->peer->sort; | |
567 | ||
568 | if (new_sort == BGP_PEER_EBGP | |
569 | && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) | |
9fbdd100 DS |
570 | { |
571 | if (debug) | |
2ec1e66f DW |
572 | zlog_debug("%s: %s wins over %s due to eBGP peer > iBGP peer", |
573 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
574 | return 1; |
575 | } | |
576 | ||
8ff56318 JBD |
577 | if (exist_sort == BGP_PEER_EBGP |
578 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) | |
9fbdd100 DS |
579 | { |
580 | if (debug) | |
2ec1e66f DW |
581 | zlog_debug("%s: %s loses to %s due to iBGP peer < eBGP peer", |
582 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
583 | return 0; |
584 | } | |
718e3744 | 585 | |
586 | /* 8. IGP metric check. */ | |
8ff56318 JBD |
587 | newm = existm = 0; |
588 | ||
589 | if (new->extra) | |
590 | newm = new->extra->igpmetric; | |
591 | if (exist->extra) | |
592 | existm = exist->extra->igpmetric; | |
593 | ||
96450faf | 594 | if (newm < existm) |
9fbdd100 DS |
595 | { |
596 | if (debug) | |
2ec1e66f DW |
597 | zlog_debug("%s: %s wins over %s due to IGP metric %d < %d", |
598 | pfx_buf, new_buf, exist_buf, newm, existm); | |
9fbdd100 DS |
599 | ret = 1; |
600 | } | |
601 | ||
96450faf | 602 | if (newm > existm) |
9fbdd100 DS |
603 | { |
604 | if (debug) | |
2ec1e66f DW |
605 | zlog_debug("%s: %s loses to %s due to IGP metric %d > %d", |
606 | pfx_buf, new_buf, exist_buf, newm, existm); | |
9fbdd100 DS |
607 | ret = 0; |
608 | } | |
718e3744 | 609 | |
31a4638f | 610 | /* 9. Same IGP metric. Compare the cluster list length as |
5e242b0d DS |
611 | representative of IGP hops metric. Rewrite the metric value |
612 | pair (newm, existm) with the cluster list length. Prefer the | |
613 | path with smaller cluster list length. */ | |
614 | if (newm == existm) | |
615 | { | |
616 | if (peer_sort (new->peer) == BGP_PEER_IBGP | |
617 | && peer_sort (exist->peer) == BGP_PEER_IBGP | |
618 | && CHECK_FLAG (mpath_cfg->ibgp_flags, | |
619 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
620 | { | |
621 | newm = BGP_CLUSTER_LIST_LENGTH(new->attr); | |
622 | existm = BGP_CLUSTER_LIST_LENGTH(exist->attr); | |
9fbdd100 | 623 | |
5e242b0d | 624 | if (newm < existm) |
9fbdd100 DS |
625 | { |
626 | if (debug) | |
2ec1e66f DW |
627 | zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d", |
628 | pfx_buf, new_buf, exist_buf, newm, existm); | |
9fbdd100 DS |
629 | ret = 1; |
630 | } | |
631 | ||
5e242b0d | 632 | if (newm > existm) |
9fbdd100 DS |
633 | { |
634 | if (debug) | |
2ec1e66f DW |
635 | zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d", |
636 | pfx_buf, new_buf, exist_buf, newm, existm); | |
9fbdd100 DS |
637 | ret = 0; |
638 | } | |
5e242b0d DS |
639 | } |
640 | } | |
641 | ||
31a4638f DS |
642 | /* 10. confed-external vs. confed-internal */ |
643 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
644 | { | |
645 | if (new_sort == BGP_PEER_CONFED && exist_sort == BGP_PEER_IBGP) | |
646 | { | |
647 | if (debug) | |
2ec1e66f DW |
648 | zlog_debug("%s: %s wins over %s due to confed-external peer > confed-internal peer", |
649 | pfx_buf, new_buf, exist_buf); | |
31a4638f DS |
650 | return 1; |
651 | } | |
652 | ||
653 | if (exist_sort == BGP_PEER_CONFED && new_sort == BGP_PEER_IBGP) | |
654 | { | |
655 | if (debug) | |
2ec1e66f DW |
656 | zlog_debug("%s: %s loses to %s due to confed-internal peer < confed-external peer", |
657 | pfx_buf, new_buf, exist_buf); | |
31a4638f DS |
658 | return 0; |
659 | } | |
660 | } | |
661 | ||
662 | /* 11. Maximum path check. */ | |
96450faf JB |
663 | if (newm == existm) |
664 | { | |
2fdd455c PM |
665 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) |
666 | { | |
667 | ||
668 | /* | |
669 | * For the two paths, all comparison steps till IGP metric | |
670 | * have succeeded - including AS_PATH hop count. Since 'bgp | |
671 | * bestpath as-path multipath-relax' knob is on, we don't need | |
672 | * an exact match of AS_PATH. Thus, mark the paths are equal. | |
673 | * That will trigger both these paths to get into the multipath | |
674 | * array. | |
675 | */ | |
676 | *paths_eq = 1; | |
9fbdd100 DS |
677 | |
678 | if (debug) | |
2ec1e66f DW |
679 | zlog_debug("%s: %s and %s are equal via multipath-relax", |
680 | pfx_buf, new_buf, exist_buf); | |
2fdd455c PM |
681 | } |
682 | else if (new->peer->sort == BGP_PEER_IBGP) | |
96450faf JB |
683 | { |
684 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) | |
9fbdd100 DS |
685 | { |
686 | *paths_eq = 1; | |
687 | ||
688 | if (debug) | |
2ec1e66f DW |
689 | zlog_debug("%s: %s and %s are equal via matching aspaths", |
690 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 | 691 | } |
96450faf JB |
692 | } |
693 | else if (new->peer->as == exist->peer->as) | |
9fbdd100 DS |
694 | { |
695 | *paths_eq = 1; | |
696 | ||
697 | if (debug) | |
2ec1e66f DW |
698 | zlog_debug("%s: %s and %s are equal via same remote-as", |
699 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 | 700 | } |
96450faf JB |
701 | } |
702 | else | |
703 | { | |
704 | /* | |
705 | * TODO: If unequal cost ibgp multipath is enabled we can | |
706 | * mark the paths as equal here instead of returning | |
707 | */ | |
708 | return ret; | |
709 | } | |
718e3744 | 710 | |
31a4638f | 711 | /* 12. If both paths are external, prefer the path that was received |
718e3744 | 712 | first (the oldest one). This step minimizes route-flap, since a |
713 | newer path won't displace an older one, even if it was the | |
714 | preferred route based on the additional decision criteria below. */ | |
715 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) | |
8ff56318 JBD |
716 | && new_sort == BGP_PEER_EBGP |
717 | && exist_sort == BGP_PEER_EBGP) | |
718e3744 | 718 | { |
719 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) | |
9fbdd100 DS |
720 | { |
721 | if (debug) | |
2ec1e66f DW |
722 | zlog_debug("%s: %s wins over %s due to oldest external", |
723 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
724 | return 1; |
725 | } | |
726 | ||
718e3744 | 727 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
9fbdd100 DS |
728 | { |
729 | if (debug) | |
2ec1e66f DW |
730 | zlog_debug("%s: %s loses to %s due to oldest external", |
731 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
732 | return 0; |
733 | } | |
718e3744 | 734 | } |
735 | ||
31a4638f | 736 | /* 13. Router-ID comparision. */ |
0de5153c DS |
737 | /* If one of the paths is "stale", the corresponding peer router-id will |
738 | * be 0 and would always win over the other path. If originator id is | |
739 | * used for the comparision, it will decide which path is better. | |
740 | */ | |
8ff56318 JBD |
741 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
742 | new_id.s_addr = newattre->originator_id.s_addr; | |
718e3744 | 743 | else |
744 | new_id.s_addr = new->peer->remote_id.s_addr; | |
8ff56318 JBD |
745 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
746 | exist_id.s_addr = existattre->originator_id.s_addr; | |
718e3744 | 747 | else |
748 | exist_id.s_addr = exist->peer->remote_id.s_addr; | |
749 | ||
750 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) | |
9fbdd100 DS |
751 | { |
752 | if (debug) | |
2ec1e66f DW |
753 | zlog_debug("%s: %s wins over %s due to Router-ID comparison", |
754 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
755 | return 1; |
756 | } | |
757 | ||
718e3744 | 758 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
9fbdd100 DS |
759 | { |
760 | if (debug) | |
2ec1e66f DW |
761 | zlog_debug("%s: %s loses to %s due to Router-ID comparison", |
762 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
763 | return 0; |
764 | } | |
718e3744 | 765 | |
31a4638f | 766 | /* 14. Cluster length comparision. */ |
5e242b0d DS |
767 | new_cluster = BGP_CLUSTER_LIST_LENGTH(new->attr); |
768 | exist_cluster = BGP_CLUSTER_LIST_LENGTH(exist->attr); | |
718e3744 | 769 | |
770 | if (new_cluster < exist_cluster) | |
9fbdd100 DS |
771 | { |
772 | if (debug) | |
2ec1e66f DW |
773 | zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d", |
774 | pfx_buf, new_buf, exist_buf, new_cluster, exist_cluster); | |
9fbdd100 DS |
775 | return 1; |
776 | } | |
777 | ||
718e3744 | 778 | if (new_cluster > exist_cluster) |
9fbdd100 DS |
779 | { |
780 | if (debug) | |
2ec1e66f DW |
781 | zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d", |
782 | pfx_buf, new_buf, exist_buf, new_cluster, exist_cluster); | |
9fbdd100 DS |
783 | return 0; |
784 | } | |
718e3744 | 785 | |
31a4638f | 786 | /* 15. Neighbor address comparision. */ |
0de5153c DS |
787 | /* Do this only if neither path is "stale" as stale paths do not have |
788 | * valid peer information (as the connection may or may not be up). | |
789 | */ | |
790 | if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) | |
9fbdd100 DS |
791 | { |
792 | if (debug) | |
2ec1e66f DW |
793 | zlog_debug("%s: %s wins over %s due to latter path being STALE", |
794 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
795 | return 1; |
796 | } | |
797 | ||
0de5153c | 798 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
9fbdd100 DS |
799 | { |
800 | if (debug) | |
2ec1e66f DW |
801 | zlog_debug("%s: %s loses to %s due to former path being STALE", |
802 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
803 | return 0; |
804 | } | |
0de5153c | 805 | |
43ed4fe5 TT |
806 | /* locally configured routes to advertise do not have su_remote */ |
807 | if (new->peer->su_remote == NULL) | |
808 | return 0; | |
809 | if (exist->peer->su_remote == NULL) | |
810 | return 1; | |
811 | ||
718e3744 | 812 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
813 | ||
814 | if (ret == 1) | |
9fbdd100 DS |
815 | { |
816 | if (debug) | |
2ec1e66f DW |
817 | zlog_debug("%s: %s loses to %s due to Neighor IP comparison", |
818 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
819 | return 0; |
820 | } | |
821 | ||
718e3744 | 822 | if (ret == -1) |
9fbdd100 DS |
823 | { |
824 | if (debug) | |
2ec1e66f DW |
825 | zlog_debug("%s: %s wins over %s due to Neighor IP comparison", |
826 | pfx_buf, new_buf, exist_buf); | |
9fbdd100 DS |
827 | return 1; |
828 | } | |
829 | ||
830 | if (debug) | |
2ec1e66f DW |
831 | zlog_debug("%s: %s wins over %s due to nothing left to compare", |
832 | pfx_buf, new_buf, exist_buf); | |
718e3744 | 833 | |
834 | return 1; | |
835 | } | |
836 | ||
94f2b392 | 837 | static enum filter_type |
718e3744 | 838 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
839 | afi_t afi, safi_t safi) | |
840 | { | |
841 | struct bgp_filter *filter; | |
842 | ||
843 | filter = &peer->filter[afi][safi]; | |
844 | ||
650f76c2 PJ |
845 | #define FILTER_EXIST_WARN(F,f,filter) \ |
846 | if (BGP_DEBUG (update, UPDATE_IN) \ | |
847 | && !(F ## _IN (filter))) \ | |
16286195 | 848 | zlog_warn ("%s: Could not find configured input %s-list %s!", \ |
650f76c2 PJ |
849 | peer->host, #f, F ## _IN_NAME(filter)); |
850 | ||
851 | if (DISTRIBUTE_IN_NAME (filter)) { | |
852 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
853 | ||
718e3744 | 854 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
855 | return FILTER_DENY; | |
650f76c2 | 856 | } |
718e3744 | 857 | |
650f76c2 PJ |
858 | if (PREFIX_LIST_IN_NAME (filter)) { |
859 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
860 | ||
718e3744 | 861 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
862 | return FILTER_DENY; | |
650f76c2 | 863 | } |
718e3744 | 864 | |
650f76c2 PJ |
865 | if (FILTER_LIST_IN_NAME (filter)) { |
866 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
867 | ||
718e3744 | 868 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
869 | return FILTER_DENY; | |
650f76c2 PJ |
870 | } |
871 | ||
718e3744 | 872 | return FILTER_PERMIT; |
650f76c2 | 873 | #undef FILTER_EXIST_WARN |
718e3744 | 874 | } |
875 | ||
94f2b392 | 876 | static enum filter_type |
718e3744 | 877 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
878 | afi_t afi, safi_t safi) | |
879 | { | |
880 | struct bgp_filter *filter; | |
881 | ||
882 | filter = &peer->filter[afi][safi]; | |
883 | ||
650f76c2 PJ |
884 | #define FILTER_EXIST_WARN(F,f,filter) \ |
885 | if (BGP_DEBUG (update, UPDATE_OUT) \ | |
886 | && !(F ## _OUT (filter))) \ | |
16286195 | 887 | zlog_warn ("%s: Could not find configured output %s-list %s!", \ |
650f76c2 PJ |
888 | peer->host, #f, F ## _OUT_NAME(filter)); |
889 | ||
890 | if (DISTRIBUTE_OUT_NAME (filter)) { | |
891 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
892 | ||
718e3744 | 893 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
894 | return FILTER_DENY; | |
650f76c2 | 895 | } |
718e3744 | 896 | |
650f76c2 PJ |
897 | if (PREFIX_LIST_OUT_NAME (filter)) { |
898 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
899 | ||
718e3744 | 900 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
901 | return FILTER_DENY; | |
650f76c2 | 902 | } |
718e3744 | 903 | |
650f76c2 PJ |
904 | if (FILTER_LIST_OUT_NAME (filter)) { |
905 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
906 | ||
718e3744 | 907 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
908 | return FILTER_DENY; | |
650f76c2 | 909 | } |
718e3744 | 910 | |
911 | return FILTER_PERMIT; | |
650f76c2 | 912 | #undef FILTER_EXIST_WARN |
718e3744 | 913 | } |
914 | ||
915 | /* If community attribute includes no_export then return 1. */ | |
94f2b392 | 916 | static int |
718e3744 | 917 | bgp_community_filter (struct peer *peer, struct attr *attr) |
918 | { | |
919 | if (attr->community) | |
920 | { | |
921 | /* NO_ADVERTISE check. */ | |
922 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) | |
923 | return 1; | |
924 | ||
925 | /* NO_EXPORT check. */ | |
6d85b15b | 926 | if (peer->sort == BGP_PEER_EBGP && |
718e3744 | 927 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
928 | return 1; | |
929 | ||
930 | /* NO_EXPORT_SUBCONFED check. */ | |
6d85b15b JBD |
931 | if (peer->sort == BGP_PEER_EBGP |
932 | || peer->sort == BGP_PEER_CONFED) | |
718e3744 | 933 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
934 | return 1; | |
935 | } | |
936 | return 0; | |
937 | } | |
938 | ||
939 | /* Route reflection loop check. */ | |
940 | static int | |
941 | bgp_cluster_filter (struct peer *peer, struct attr *attr) | |
942 | { | |
943 | struct in_addr cluster_id; | |
944 | ||
fb982c25 | 945 | if (attr->extra && attr->extra->cluster) |
718e3744 | 946 | { |
947 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) | |
948 | cluster_id = peer->bgp->cluster_id; | |
949 | else | |
950 | cluster_id = peer->bgp->router_id; | |
951 | ||
fb982c25 | 952 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
718e3744 | 953 | return 1; |
954 | } | |
955 | return 0; | |
956 | } | |
6b0655a2 | 957 | |
94f2b392 | 958 | static int |
718e3744 | 959 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
ffd0c037 | 960 | afi_t afi, safi_t safi, const char *rmap_name) |
718e3744 | 961 | { |
962 | struct bgp_filter *filter; | |
963 | struct bgp_info info; | |
964 | route_map_result_t ret; | |
0b16f239 | 965 | struct route_map *rmap = NULL; |
718e3744 | 966 | |
967 | filter = &peer->filter[afi][safi]; | |
968 | ||
969 | /* Apply default weight value. */ | |
fb982c25 PJ |
970 | if (peer->weight) |
971 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
718e3744 | 972 | |
0b16f239 DS |
973 | if (rmap_name) |
974 | { | |
975 | rmap = route_map_lookup_by_name(rmap_name); | |
98a4a44e DS |
976 | |
977 | if (rmap == NULL) | |
978 | return RMAP_DENY; | |
0b16f239 DS |
979 | } |
980 | else | |
981 | { | |
982 | if (ROUTE_MAP_IN_NAME(filter)) | |
98a4a44e DS |
983 | { |
984 | rmap = ROUTE_MAP_IN (filter); | |
985 | ||
986 | if (rmap == NULL) | |
987 | return RMAP_DENY; | |
988 | } | |
0b16f239 DS |
989 | } |
990 | ||
718e3744 | 991 | /* Route map apply. */ |
0b16f239 | 992 | if (rmap) |
718e3744 | 993 | { |
994 | /* Duplicate current value to new strucutre for modification. */ | |
995 | info.peer = peer; | |
996 | info.attr = attr; | |
997 | ||
ac41b2a2 | 998 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
999 | ||
718e3744 | 1000 | /* Apply BGP route map to the attribute. */ |
0b16f239 DS |
1001 | ret = route_map_apply (rmap, p, RMAP_BGP, &info); |
1002 | ||
1003 | peer->rmap_type = 0; | |
1004 | ||
1005 | if (ret == RMAP_DENYMATCH) | |
1006 | { | |
1007 | /* Free newly generated AS path and community by route-map. */ | |
1008 | bgp_attr_flush (attr); | |
1009 | return RMAP_DENY; | |
1010 | } | |
1011 | } | |
1012 | return RMAP_PERMIT; | |
1013 | } | |
1014 | ||
1015 | static int | |
1016 | bgp_output_modifier (struct peer *peer, struct prefix *p, struct attr *attr, | |
ffd0c037 | 1017 | afi_t afi, safi_t safi, const char *rmap_name) |
0b16f239 DS |
1018 | { |
1019 | struct bgp_filter *filter; | |
1020 | struct bgp_info info; | |
1021 | route_map_result_t ret; | |
1022 | struct route_map *rmap = NULL; | |
1023 | ||
1024 | filter = &peer->filter[afi][safi]; | |
1025 | ||
1026 | /* Apply default weight value. */ | |
1027 | if (peer->weight) | |
1028 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
1029 | ||
1030 | if (rmap_name) | |
1031 | { | |
1032 | rmap = route_map_lookup_by_name(rmap_name); | |
98a4a44e DS |
1033 | |
1034 | if (rmap == NULL) | |
1035 | return RMAP_DENY; | |
0b16f239 DS |
1036 | } |
1037 | else | |
1038 | { | |
1039 | if (ROUTE_MAP_OUT_NAME(filter)) | |
98a4a44e DS |
1040 | { |
1041 | rmap = ROUTE_MAP_OUT (filter); | |
1042 | ||
1043 | if (rmap == NULL) | |
1044 | return RMAP_DENY; | |
1045 | } | |
0b16f239 DS |
1046 | } |
1047 | ||
1048 | /* Route map apply. */ | |
1049 | if (rmap) | |
1050 | { | |
1051 | /* Duplicate current value to new strucutre for modification. */ | |
1052 | info.peer = peer; | |
1053 | info.attr = attr; | |
1054 | ||
1055 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1056 | ||
1057 | /* Apply BGP route map to the attribute. */ | |
1058 | ret = route_map_apply (rmap, p, RMAP_BGP, &info); | |
ac41b2a2 | 1059 | |
1060 | peer->rmap_type = 0; | |
1061 | ||
718e3744 | 1062 | if (ret == RMAP_DENYMATCH) |
c460e572 DL |
1063 | /* caller has multiple error paths with bgp_attr_flush() */ |
1064 | return RMAP_DENY; | |
718e3744 | 1065 | } |
1066 | return RMAP_PERMIT; | |
1067 | } | |
6b0655a2 | 1068 | |
5000f21c | 1069 | /* If this is an EBGP peer with remove-private-AS */ |
ffd0c037 | 1070 | static void |
5000f21c DS |
1071 | bgp_peer_remove_private_as(struct bgp *bgp, afi_t afi, safi_t safi, |
1072 | struct peer *peer, struct attr *attr) | |
1073 | { | |
1074 | if (peer->sort == BGP_PEER_EBGP && | |
88b8ed8d DW |
1075 | (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE) || |
1076 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE) || | |
1077 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL) || | |
1078 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS))) | |
5000f21c DS |
1079 | { |
1080 | // Take action on the entire aspath | |
88b8ed8d DW |
1081 | if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE) || |
1082 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
5000f21c | 1083 | { |
88b8ed8d | 1084 | if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
5000f21c DS |
1085 | attr->aspath = aspath_replace_private_asns (attr->aspath, bgp->as); |
1086 | ||
1087 | // The entire aspath consists of private ASNs so create an empty aspath | |
1088 | else if (aspath_private_as_check (attr->aspath)) | |
1089 | attr->aspath = aspath_empty_get (); | |
1090 | ||
1091 | // There are some public and some private ASNs, remove the private ASNs | |
1092 | else | |
1093 | attr->aspath = aspath_remove_private_asns (attr->aspath); | |
1094 | } | |
1095 | ||
1096 | // 'all' was not specified so the entire aspath must be private ASNs | |
1097 | // for us to do anything | |
1098 | else if (aspath_private_as_check (attr->aspath)) | |
1099 | { | |
1100 | if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
1101 | attr->aspath = aspath_replace_private_asns (attr->aspath, bgp->as); | |
1102 | else | |
1103 | attr->aspath = aspath_empty_get (); | |
1104 | } | |
1105 | } | |
1106 | } | |
1107 | ||
c7122e14 DS |
1108 | /* If this is an EBGP peer with as-override */ |
1109 | static void | |
1110 | bgp_peer_as_override(struct bgp *bgp, afi_t afi, safi_t safi, | |
1111 | struct peer *peer, struct attr *attr) | |
1112 | { | |
1113 | if (peer->sort == BGP_PEER_EBGP && | |
1114 | peer_af_flag_check (peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) | |
1115 | { | |
1116 | if (aspath_single_asn_check (attr->aspath, peer->as)) | |
1117 | attr->aspath = aspath_replace_specific_asn (attr->aspath, peer->as, bgp->as); | |
1118 | } | |
1119 | } | |
1120 | ||
3f9c7369 DS |
1121 | static void |
1122 | subgroup_announce_reset_nhop (u_char family, struct attr *attr) | |
1123 | { | |
1124 | if (family == AF_INET) | |
1125 | attr->nexthop.s_addr = 0; | |
1126 | #ifdef HAVE_IPV6 | |
1127 | if (family == AF_INET6) | |
1128 | memset (&attr->extra->mp_nexthop_global, 0, IPV6_MAX_BYTELEN); | |
1129 | #endif | |
1130 | } | |
1131 | ||
1132 | int | |
1133 | subgroup_announce_check (struct bgp_info *ri, struct update_subgroup *subgrp, | |
1134 | struct prefix *p, struct attr *attr) | |
1135 | { | |
1136 | struct bgp_filter *filter; | |
1137 | struct peer *from; | |
1138 | struct peer *peer; | |
1139 | struct peer *onlypeer; | |
1140 | struct bgp *bgp; | |
1141 | struct attr *riattr; | |
1142 | struct peer_af *paf; | |
1143 | char buf[SU_ADDRSTRLEN]; | |
1144 | int ret; | |
1145 | int transparent; | |
1146 | int reflect; | |
1147 | afi_t afi; | |
1148 | safi_t safi; | |
1149 | ||
1150 | if (DISABLE_BGP_ANNOUNCE) | |
1151 | return 0; | |
1152 | ||
1153 | afi = SUBGRP_AFI(subgrp); | |
1154 | safi = SUBGRP_SAFI(subgrp); | |
1155 | peer = SUBGRP_PEER(subgrp); | |
1156 | onlypeer = NULL; | |
1157 | if (CHECK_FLAG (peer->flags, PEER_FLAG_LONESOUL)) | |
1158 | onlypeer = SUBGRP_PFIRST(subgrp)->peer; | |
1159 | ||
1160 | from = ri->peer; | |
1161 | filter = &peer->filter[afi][safi]; | |
1162 | bgp = SUBGRP_INST(subgrp); | |
1163 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; | |
1164 | ||
adbac85e DW |
1165 | /* With addpath we may be asked to TX all kinds of paths so make sure |
1166 | * ri is valid */ | |
1167 | if (!CHECK_FLAG (ri->flags, BGP_INFO_VALID) || | |
1168 | CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) || | |
1169 | CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) | |
1170 | { | |
1171 | return 0; | |
1172 | } | |
1173 | ||
06370dac DW |
1174 | /* If this is not the bestpath then check to see if there is an enabled addpath |
1175 | * feature that requires us to advertise it */ | |
1176 | if (! CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1177 | { | |
1178 | if (! bgp_addpath_tx_path(peer, afi, safi, ri)) | |
1179 | { | |
1180 | return 0; | |
1181 | } | |
1182 | } | |
1183 | ||
3f9c7369 DS |
1184 | /* Aggregate-address suppress check. */ |
1185 | if (ri->extra && ri->extra->suppress) | |
1186 | if (! UNSUPPRESS_MAP_NAME (filter)) | |
1187 | { | |
1188 | return 0; | |
1189 | } | |
1190 | ||
3f9c7369 DS |
1191 | /* Do not send back route to sender. */ |
1192 | if (onlypeer && from == onlypeer) | |
1193 | { | |
1194 | return 0; | |
1195 | } | |
1196 | ||
4125bb67 DS |
1197 | /* Do not send the default route in the BGP table if the neighbor is |
1198 | * configured for default-originate */ | |
1199 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
1200 | { | |
1201 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
1202 | return 0; | |
1203 | #ifdef HAVE_IPV6 | |
1204 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
1205 | return 0; | |
1206 | #endif /* HAVE_IPV6 */ | |
1207 | } | |
1208 | ||
3f9c7369 DS |
1209 | /* Transparency check. */ |
1210 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) | |
1211 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
1212 | transparent = 1; | |
1213 | else | |
1214 | transparent = 0; | |
1215 | ||
1216 | /* If community is not disabled check the no-export and local. */ | |
1217 | if (! transparent && bgp_community_filter (peer, riattr)) | |
1218 | { | |
1219 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1220 | zlog_debug ("subgrpannouncecheck: community filter check fail"); | |
1221 | return 0; | |
1222 | } | |
1223 | ||
1224 | /* If the attribute has originator-id and it is same as remote | |
1225 | peer's id. */ | |
1226 | if (onlypeer && | |
1227 | riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) && | |
1228 | (IPV4_ADDR_SAME (&onlypeer->remote_id, &riattr->extra->originator_id))) | |
1229 | { | |
1230 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1231 | zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as " | |
1232 | "remote router-id", | |
1233 | onlypeer->host, | |
1234 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1235 | p->prefixlen); | |
1236 | return 0; | |
1237 | } | |
1238 | ||
1239 | /* ORF prefix-list filter check */ | |
1240 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
1241 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
1242 | || CHECK_FLAG (peer->af_cap[afi][safi], | |
1243 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
1244 | if (peer->orf_plist[afi][safi]) | |
1245 | { | |
1246 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) | |
1247 | { | |
40d2700d DW |
1248 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) |
1249 | zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF", | |
1250 | peer->host, | |
1251 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1252 | p->prefixlen); | |
3f9c7369 DS |
1253 | return 0; |
1254 | } | |
1255 | } | |
1256 | ||
1257 | /* Output filter check. */ | |
1258 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) | |
1259 | { | |
1260 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1261 | zlog_debug ("%s [Update:SEND] %s/%d is filtered", | |
1262 | peer->host, | |
1263 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1264 | p->prefixlen); | |
1265 | return 0; | |
1266 | } | |
1267 | ||
1268 | #ifdef BGP_SEND_ASPATH_CHECK | |
1269 | /* AS path loop check. */ | |
1270 | if (onlypeer && aspath_loop_check (riattr->aspath, onlypeer->as)) | |
1271 | { | |
1272 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1273 | zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u " | |
1274 | "that is part of AS path.", | |
1275 | onlypeer->host, onlypeer->as); | |
1276 | return 0; | |
1277 | } | |
1278 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
1279 | ||
1280 | /* If we're a CONFED we need to loop check the CONFED ID too */ | |
1281 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
1282 | { | |
1283 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) | |
1284 | { | |
1285 | if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) | |
1286 | zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u" | |
1287 | " is AS path.", | |
1288 | peer->host, | |
1289 | bgp->confed_id); | |
1290 | return 0; | |
1291 | } | |
1292 | } | |
1293 | ||
1294 | /* Route-Reflect check. */ | |
1295 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) | |
1296 | reflect = 1; | |
1297 | else | |
1298 | reflect = 0; | |
1299 | ||
1300 | /* IBGP reflection check. */ | |
1301 | if (reflect) | |
1302 | { | |
1303 | /* A route from a Client peer. */ | |
1304 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
1305 | { | |
1306 | /* Reflect to all the Non-Client peers and also to the | |
1307 | Client peers other than the originator. Originator check | |
1308 | is already done. So there is noting to do. */ | |
1309 | /* no bgp client-to-client reflection check. */ | |
1310 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
1311 | if (CHECK_FLAG (peer->af_flags[afi][safi], | |
1312 | PEER_FLAG_REFLECTOR_CLIENT)) | |
1313 | return 0; | |
1314 | } | |
1315 | else | |
1316 | { | |
1317 | /* A route from a Non-client peer. Reflect to all other | |
1318 | clients. */ | |
1319 | if (! CHECK_FLAG (peer->af_flags[afi][safi], | |
1320 | PEER_FLAG_REFLECTOR_CLIENT)) | |
1321 | return 0; | |
1322 | } | |
1323 | } | |
1324 | ||
1325 | /* For modify attribute, copy it to temporary structure. */ | |
1326 | bgp_attr_dup (attr, riattr); | |
1327 | ||
1328 | /* If local-preference is not set. */ | |
1329 | if ((peer->sort == BGP_PEER_IBGP | |
1330 | || peer->sort == BGP_PEER_CONFED) | |
1331 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) | |
1332 | { | |
1333 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); | |
1334 | attr->local_pref = bgp->default_local_pref; | |
1335 | } | |
1336 | ||
1337 | /* If originator-id is not set and the route is to be reflected, | |
1338 | set the originator id */ | |
1339 | if (reflect && (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) | |
1340 | { | |
1341 | attr->extra = bgp_attr_extra_get(attr); | |
1342 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); | |
1343 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); | |
1344 | } | |
1345 | ||
1346 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ | |
1347 | if (peer->sort == BGP_PEER_EBGP | |
1348 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
1349 | { | |
003c1ba0 | 1350 | if (from != bgp->peer_self && ! transparent |
3f9c7369 DS |
1351 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
1352 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); | |
1353 | } | |
1354 | ||
1355 | /* Since the nexthop attribute can vary per peer, it is not explicitly set | |
1356 | * in announce check, only certain flags and length (or number of nexthops | |
1357 | * -- for IPv6/MP_REACH) are set here in order to guide the update formation | |
1358 | * code in setting the nexthop(s) on a per peer basis in reformat_peer(). | |
1359 | * Typically, the source nexthop in the attribute is preserved but in the | |
1360 | * scenarios where we know it will always be overwritten, we reset the | |
1361 | * nexthop to "0" in an attempt to achieve better Update packing. An | |
1362 | * example of this is when a prefix from each of 2 IBGP peers needs to be | |
1363 | * announced to an EBGP peer (and they have the same attributes barring | |
1364 | * their nexthop). | |
1365 | */ | |
1366 | if (reflect) | |
1367 | SET_FLAG(attr->rmap_change_flags, BATTR_REFLECTED); | |
1368 | ||
1369 | #ifdef HAVE_IPV6 | |
587ff0fd LB |
1370 | #define NEXTHOP_IS_V6 (\ |
1371 | (safi != SAFI_ENCAP && \ | |
1372 | (p->family == AF_INET6 || peer_cap_enhe(peer))) || \ | |
1373 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16)) | |
1374 | ||
3811f1e2 DS |
1375 | /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if |
1376 | * the peer (group) is configured to receive link-local nexthop unchanged | |
1377 | * and it is available in the prefix OR we're not reflecting the route and | |
1378 | * the peer (group) to whom we're going to announce is on a shared network | |
003c1ba0 | 1379 | * and this is either a self-originated route or the peer is EBGP. |
3f9c7369 | 1380 | */ |
587ff0fd | 1381 | if (NEXTHOP_IS_V6) |
3f9c7369 | 1382 | { |
801a9bcc | 1383 | attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; |
3811f1e2 DS |
1384 | if ((CHECK_FLAG (peer->af_flags[afi][safi], |
1385 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) && | |
1386 | IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local)) || | |
003c1ba0 | 1387 | (!reflect && peer->shared_network && |
1388 | (from == bgp->peer_self || peer->sort == BGP_PEER_EBGP))) | |
3f9c7369 | 1389 | { |
3811f1e2 | 1390 | attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; |
3f9c7369 DS |
1391 | } |
1392 | ||
3811f1e2 DS |
1393 | /* Clear off link-local nexthop in source, whenever it is not needed to |
1394 | * ensure more prefixes share the same attribute for announcement. | |
3f9c7369 DS |
1395 | */ |
1396 | if (!(CHECK_FLAG (peer->af_flags[afi][safi], | |
1397 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED))) | |
1398 | memset (&attr->extra->mp_nexthop_local, 0, IPV6_MAX_BYTELEN); | |
1399 | } | |
1400 | #endif /* HAVE_IPV6 */ | |
1401 | ||
1402 | bgp_peer_remove_private_as(bgp, afi, safi, peer, attr); | |
1403 | bgp_peer_as_override(bgp, afi, safi, peer, attr); | |
1404 | ||
1405 | /* Route map & unsuppress-map apply. */ | |
1406 | if (ROUTE_MAP_OUT_NAME (filter) | |
1407 | || (ri->extra && ri->extra->suppress) ) | |
1408 | { | |
1409 | struct bgp_info info; | |
1410 | struct attr dummy_attr; | |
1411 | struct attr_extra dummy_extra; | |
1412 | ||
1413 | dummy_attr.extra = &dummy_extra; | |
1414 | ||
1415 | info.peer = peer; | |
1416 | info.attr = attr; | |
316e074d DS |
1417 | /* don't confuse inbound and outbound setting */ |
1418 | RESET_FLAG(attr->rmap_change_flags); | |
3f9c7369 DS |
1419 | |
1420 | /* | |
1421 | * The route reflector is not allowed to modify the attributes | |
1422 | * of the reflected IBGP routes unless explicitly allowed. | |
1423 | */ | |
1424 | if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) | |
1425 | && !bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
1426 | { | |
1427 | bgp_attr_dup (&dummy_attr, attr); | |
1428 | info.attr = &dummy_attr; | |
1429 | } | |
1430 | ||
1431 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1432 | ||
1433 | if (ri->extra && ri->extra->suppress) | |
1434 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); | |
1435 | else | |
1436 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1437 | ||
1438 | peer->rmap_type = 0; | |
1439 | ||
1440 | if (ret == RMAP_DENYMATCH) | |
1441 | { | |
1442 | bgp_attr_flush (attr); | |
1443 | return 0; | |
1444 | } | |
1445 | } | |
1446 | ||
1447 | /* After route-map has been applied, we check to see if the nexthop to | |
1448 | * be carried in the attribute (that is used for the announcement) can | |
1449 | * be cleared off or not. We do this in all cases where we would be | |
1450 | * setting the nexthop to "ourselves". For IPv6, we only need to consider | |
1451 | * the global nexthop here; the link-local nexthop would have been cleared | |
1452 | * already, and if not, it is required by the update formation code. | |
1453 | * Also see earlier comments in this function. | |
43fdf718 | 1454 | */ |
3811f1e2 DS |
1455 | /* |
1456 | * If route-map has performed some operation on the nexthop or the peer | |
1457 | * configuration says to pass it unchanged, we cannot reset the nexthop | |
1458 | * here, so only attempt to do it if these aren't true. Note that the | |
1459 | * route-map handler itself might have cleared the nexthop, if for example, | |
1460 | * it is configured as 'peer-address'. | |
3f9c7369 | 1461 | */ |
3811f1e2 DS |
1462 | if (!bgp_rmap_nhop_changed(attr->rmap_change_flags, |
1463 | riattr->rmap_change_flags) && | |
1464 | !transparent && | |
1465 | !CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
3f9c7369 | 1466 | { |
3811f1e2 | 1467 | /* We can reset the nexthop, if setting (or forcing) it to 'self' */ |
88b8ed8d DW |
1468 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || |
1469 | CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
3f9c7369 DS |
1470 | { |
1471 | if (!reflect || | |
1472 | CHECK_FLAG (peer->af_flags[afi][safi], | |
43fdf718 | 1473 | PEER_FLAG_FORCE_NEXTHOP_SELF)) |
3811f1e2 DS |
1474 | subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ? |
1475 | AF_INET6 : p->family), attr); | |
3f9c7369 DS |
1476 | } |
1477 | else if (peer->sort == BGP_PEER_EBGP) | |
1478 | { | |
3811f1e2 DS |
1479 | /* Can also reset the nexthop if announcing to EBGP, but only if |
1480 | * no peer in the subgroup is on a shared subnet. | |
1481 | * Note: 3rd party nexthop currently implemented for IPv4 only. | |
1482 | */ | |
3f9c7369 DS |
1483 | SUBGRP_FOREACH_PEER (subgrp, paf) |
1484 | { | |
1485 | if (bgp_multiaccess_check_v4 (riattr->nexthop, paf->peer)) | |
1486 | break; | |
1487 | } | |
1488 | if (!paf) | |
8a92a8a0 | 1489 | subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ? AF_INET6 : p->family), attr); |
3f9c7369 | 1490 | } |
003c1ba0 | 1491 | /* If IPv6/MP and nexthop does not have any override and happens to |
1492 | * be a link-local address, reset it so that we don't pass along the | |
1493 | * source's link-local IPv6 address to recipients who may not be on | |
1494 | * the same interface. | |
1495 | */ | |
1496 | if (p->family == AF_INET6 || peer_cap_enhe(peer)) | |
1497 | { | |
1498 | if (IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_global)) | |
1499 | subgroup_announce_reset_nhop (AF_INET6, attr); | |
1500 | } | |
3f9c7369 DS |
1501 | } |
1502 | ||
1503 | return 1; | |
1504 | } | |
1505 | ||
fee0f4c6 | 1506 | struct bgp_info_pair |
1507 | { | |
1508 | struct bgp_info *old; | |
1509 | struct bgp_info *new; | |
1510 | }; | |
1511 | ||
94f2b392 | 1512 | static void |
96450faf JB |
1513 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
1514 | struct bgp_maxpaths_cfg *mpath_cfg, | |
1515 | struct bgp_info_pair *result) | |
718e3744 | 1516 | { |
718e3744 | 1517 | struct bgp_info *new_select; |
1518 | struct bgp_info *old_select; | |
fee0f4c6 | 1519 | struct bgp_info *ri; |
718e3744 | 1520 | struct bgp_info *ri1; |
1521 | struct bgp_info *ri2; | |
b40d939b | 1522 | struct bgp_info *nextri = NULL; |
9fbdd100 | 1523 | int paths_eq, do_mpath, debug; |
96450faf | 1524 | struct list mp_list; |
4690c7d7 | 1525 | char pfx_buf[PREFIX2STR_BUFFER]; |
2ec1e66f | 1526 | char path_buf[PATH_ADDPATH_STR_BUFFER]; |
96450faf JB |
1527 | |
1528 | bgp_mp_list_init (&mp_list); | |
99030da1 | 1529 | do_mpath = (mpath_cfg->maxpaths_ebgp > 1 || mpath_cfg->maxpaths_ibgp > 1); |
96450faf | 1530 | |
9fbdd100 DS |
1531 | debug = bgp_debug_bestpath(&rn->p); |
1532 | ||
1533 | if (debug) | |
1534 | prefix2str (&rn->p, pfx_buf, sizeof (pfx_buf)); | |
1535 | ||
718e3744 | 1536 | /* bgp deterministic-med */ |
1537 | new_select = NULL; | |
1538 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
06370dac DW |
1539 | { |
1540 | ||
1541 | /* Clear BGP_INFO_DMED_SELECTED for all paths */ | |
1542 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1543 | bgp_info_unset_flag (rn, ri1, BGP_INFO_DMED_SELECTED); | |
1544 | ||
1545 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1546 | { | |
1547 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) | |
1548 | continue; | |
1549 | if (BGP_INFO_HOLDDOWN (ri1)) | |
2fed8887 | 1550 | continue; |
06370dac DW |
1551 | if (ri1->peer && ri1->peer != bgp->peer_self) |
1552 | if (ri1->peer->status != Established) | |
1553 | continue; | |
718e3744 | 1554 | |
06370dac | 1555 | new_select = ri1; |
06370dac DW |
1556 | if (ri1->next) |
1557 | { | |
1558 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) | |
1559 | { | |
1560 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) | |
1561 | continue; | |
1562 | if (BGP_INFO_HOLDDOWN (ri2)) | |
1563 | continue; | |
1564 | if (ri2->peer && | |
1565 | ri2->peer != bgp->peer_self && | |
1566 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) | |
1567 | if (ri2->peer->status != Established) | |
1568 | continue; | |
1569 | ||
1570 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) | |
1571 | || aspath_cmp_left_confed (ri1->attr->aspath, | |
1572 | ri2->attr->aspath)) | |
1573 | { | |
06370dac DW |
1574 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq, |
1575 | mpath_cfg, debug, pfx_buf)) | |
1576 | { | |
1577 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
1578 | new_select = ri2; | |
1579 | } | |
1580 | ||
1581 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); | |
1582 | } | |
1583 | } | |
1584 | } | |
1585 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); | |
1586 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1587 | |
06370dac | 1588 | if (debug) |
2ec1e66f DW |
1589 | { |
1590 | bgp_info_path_with_addpath_rx_str (new_select, path_buf); | |
1591 | zlog_debug("%s: %s is the bestpath from AS %d", | |
1592 | pfx_buf, path_buf, aspath_get_firstas(new_select->attr->aspath)); | |
1593 | } | |
06370dac DW |
1594 | } |
1595 | } | |
718e3744 | 1596 | |
1597 | /* Check old selected route and new selected route. */ | |
1598 | old_select = NULL; | |
1599 | new_select = NULL; | |
b40d939b | 1600 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
718e3744 | 1601 | { |
1602 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1603 | old_select = ri; | |
1604 | ||
1605 | if (BGP_INFO_HOLDDOWN (ri)) | |
b40d939b | 1606 | { |
1607 | /* reap REMOVED routes, if needs be | |
1608 | * selected route must stay for a while longer though | |
1609 | */ | |
1610 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) | |
1611 | && (ri != old_select)) | |
1612 | bgp_info_reap (rn, ri); | |
1613 | ||
1614 | continue; | |
1615 | } | |
718e3744 | 1616 | |
2fed8887 DS |
1617 | if (ri->peer && |
1618 | ri->peer != bgp->peer_self && | |
1619 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) | |
1620 | if (ri->peer->status != Established) | |
1621 | continue; | |
1622 | ||
718e3744 | 1623 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
1624 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) | |
1625 | { | |
1a392d46 | 1626 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1627 | continue; |
1628 | } | |
06370dac | 1629 | |
1a392d46 | 1630 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1631 | |
9fbdd100 | 1632 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, debug, pfx_buf)) |
96450faf JB |
1633 | { |
1634 | new_select = ri; | |
96450faf | 1635 | } |
718e3744 | 1636 | } |
b40d939b | 1637 | |
f4eeff72 DS |
1638 | /* Now that we know which path is the bestpath see if any of the other paths |
1639 | * qualify as multipaths | |
1640 | */ | |
1641 | if (do_mpath && new_select) | |
1642 | { | |
9fbdd100 | 1643 | if (debug) |
2ec1e66f DW |
1644 | { |
1645 | bgp_info_path_with_addpath_rx_str (new_select, path_buf); | |
1646 | zlog_debug("%s: %s is the bestpath, now find multipaths", pfx_buf, path_buf); | |
1647 | } | |
9fbdd100 | 1648 | |
f4eeff72 DS |
1649 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
1650 | { | |
2ec1e66f DW |
1651 | |
1652 | if (debug) | |
1653 | bgp_info_path_with_addpath_rx_str (ri, path_buf); | |
1654 | ||
f4eeff72 DS |
1655 | if (ri == new_select) |
1656 | { | |
9fbdd100 | 1657 | if (debug) |
2ec1e66f DW |
1658 | zlog_debug("%s: %s is the bestpath, add to the multipath list", |
1659 | pfx_buf, path_buf); | |
3064bf43 | 1660 | bgp_mp_list_add (&mp_list, ri); |
f4eeff72 DS |
1661 | continue; |
1662 | } | |
1663 | ||
1664 | if (BGP_INFO_HOLDDOWN (ri)) | |
1665 | continue; | |
1666 | ||
1667 | if (ri->peer && | |
1668 | ri->peer != bgp->peer_self && | |
1669 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) | |
1670 | if (ri->peer->status != Established) | |
1671 | continue; | |
1672 | ||
7dc9d4e4 DW |
1673 | if (!bgp_info_nexthop_cmp (ri, new_select)) |
1674 | { | |
1675 | if (debug) | |
2ec1e66f DW |
1676 | zlog_debug("%s: %s has the same nexthop as the bestpath, skip it", |
1677 | pfx_buf, path_buf); | |
7dc9d4e4 DW |
1678 | continue; |
1679 | } | |
1680 | ||
9fbdd100 | 1681 | bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, debug, pfx_buf); |
f4eeff72 DS |
1682 | |
1683 | if (paths_eq) | |
1684 | { | |
9fbdd100 | 1685 | if (debug) |
2ec1e66f DW |
1686 | zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list", |
1687 | pfx_buf, path_buf); | |
f4eeff72 DS |
1688 | bgp_mp_list_add (&mp_list, ri); |
1689 | } | |
1690 | } | |
1691 | } | |
fee0f4c6 | 1692 | |
b354c427 | 1693 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
0b597ef0 | 1694 | bgp_info_mpath_aggregate_update (new_select, old_select); |
96450faf JB |
1695 | bgp_mp_list_clear (&mp_list); |
1696 | ||
1697 | result->old = old_select; | |
1698 | result->new = new_select; | |
1699 | ||
1700 | return; | |
fee0f4c6 | 1701 | } |
1702 | ||
3f9c7369 DS |
1703 | /* |
1704 | * A new route/change in bestpath of an existing route. Evaluate the path | |
1705 | * for advertisement to the subgroup. | |
1706 | */ | |
1707 | int | |
1708 | subgroup_process_announce_selected (struct update_subgroup *subgrp, | |
1709 | struct bgp_info *selected, | |
adbac85e DW |
1710 | struct bgp_node *rn, |
1711 | u_int32_t addpath_tx_id) | |
9eda90ce | 1712 | { |
fee0f4c6 | 1713 | struct prefix *p; |
3f9c7369 | 1714 | struct peer *onlypeer; |
558d1fec JBD |
1715 | struct attr attr; |
1716 | struct attr_extra extra; | |
3f9c7369 DS |
1717 | afi_t afi; |
1718 | safi_t safi; | |
fee0f4c6 | 1719 | |
1720 | p = &rn->p; | |
3f9c7369 DS |
1721 | afi = SUBGRP_AFI(subgrp); |
1722 | safi = SUBGRP_SAFI(subgrp); | |
1723 | onlypeer = ((SUBGRP_PCOUNT(subgrp) == 1) ? | |
1724 | (SUBGRP_PFIRST(subgrp))->peer : NULL); | |
718e3744 | 1725 | |
9eda90ce | 1726 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
3f9c7369 DS |
1727 | if (onlypeer && CHECK_FLAG (onlypeer->af_sflags[afi][safi], |
1728 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
fee0f4c6 | 1729 | return 0; |
718e3744 | 1730 | |
2a3d5731 | 1731 | /* It's initialized in bgp_announce_check() */ |
558d1fec JBD |
1732 | attr.extra = &extra; |
1733 | ||
2a3d5731 DW |
1734 | /* Announcement to the subgroup. If the route is filtered withdraw it. */ |
1735 | if (selected) | |
fee0f4c6 | 1736 | { |
2a3d5731 DW |
1737 | if (subgroup_announce_check(selected, subgrp, p, &attr)) |
1738 | bgp_adj_out_set_subgroup(rn, subgrp, &attr, selected); | |
1739 | else | |
1740 | bgp_adj_out_unset_subgroup(rn, subgrp, 1, selected->addpath_tx_id); | |
1741 | } | |
adbac85e | 1742 | |
2a3d5731 DW |
1743 | /* If selected is NULL we must withdraw the path using addpath_tx_id */ |
1744 | else | |
1745 | { | |
1746 | bgp_adj_out_unset_subgroup(rn, subgrp, 1, addpath_tx_id); | |
fee0f4c6 | 1747 | } |
558d1fec | 1748 | |
fee0f4c6 | 1749 | return 0; |
200df115 | 1750 | } |
fee0f4c6 | 1751 | |
3064bf43 | 1752 | /* |
1753 | * Clear IGP changed flag for a route (all paths). This is called at | |
1754 | * the end of route processing. | |
1755 | */ | |
1756 | static void | |
1757 | bgp_zebra_clear_route_change_flags (struct bgp_node *rn) | |
1758 | { | |
1759 | struct bgp_info *ri; | |
1760 | ||
1761 | for (ri = rn->info; ri; ri = ri->next) | |
1762 | { | |
1763 | if (BGP_INFO_HOLDDOWN (ri)) | |
1764 | continue; | |
1765 | UNSET_FLAG (ri->flags, BGP_INFO_IGP_CHANGED); | |
1766 | } | |
1767 | } | |
1768 | ||
1769 | /* | |
1770 | * Has the route changed from the RIB's perspective? This is invoked only | |
1771 | * if the route selection returns the same best route as earlier - to | |
1772 | * determine if we need to update zebra or not. | |
1773 | */ | |
1774 | static int | |
1775 | bgp_zebra_has_route_changed (struct bgp_node *rn, struct bgp_info *selected) | |
1776 | { | |
1777 | struct bgp_info *mpinfo; | |
1778 | ||
1779 | /* There is a multipath change or best path has some nexthop change. */ | |
1780 | if (CHECK_FLAG (selected->flags, BGP_INFO_IGP_CHANGED) || | |
1781 | CHECK_FLAG (selected->flags, BGP_INFO_MULTIPATH_CHG)) | |
1782 | return 1; | |
1783 | ||
1784 | /* If this is multipath, check all selected paths for any nexthop change */ | |
1785 | for (mpinfo = bgp_info_mpath_first (selected); mpinfo; | |
1786 | mpinfo = bgp_info_mpath_next (mpinfo)) | |
1787 | { | |
1788 | if (CHECK_FLAG (mpinfo->flags, BGP_INFO_IGP_CHANGED)) | |
1789 | return 1; | |
1790 | } | |
1791 | ||
1792 | /* Nothing has changed from the RIB's perspective. */ | |
1793 | return 0; | |
1794 | } | |
1795 | ||
3f9c7369 | 1796 | struct bgp_process_queue |
fee0f4c6 | 1797 | { |
200df115 | 1798 | struct bgp *bgp; |
1799 | struct bgp_node *rn; | |
1800 | afi_t afi; | |
1801 | safi_t safi; | |
1802 | }; | |
1803 | ||
200df115 | 1804 | static wq_item_status |
0fb58d5d | 1805 | bgp_process_main (struct work_queue *wq, void *data) |
200df115 | 1806 | { |
0fb58d5d | 1807 | struct bgp_process_queue *pq = data; |
200df115 | 1808 | struct bgp *bgp = pq->bgp; |
1809 | struct bgp_node *rn = pq->rn; | |
1810 | afi_t afi = pq->afi; | |
1811 | safi_t safi = pq->safi; | |
1812 | struct prefix *p = &rn->p; | |
fee0f4c6 | 1813 | struct bgp_info *new_select; |
1814 | struct bgp_info *old_select; | |
1815 | struct bgp_info_pair old_and_new; | |
cb1faec9 DS |
1816 | |
1817 | /* Is it end of initial update? (after startup) */ | |
1818 | if (!rn) | |
1819 | { | |
4a16ae86 DS |
1820 | quagga_timestamp(3, bgp->update_delay_zebra_resume_time, |
1821 | sizeof(bgp->update_delay_zebra_resume_time)); | |
1822 | ||
1823 | bgp->main_zebra_update_hold = 0; | |
1824 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1825 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1826 | { | |
1827 | bgp_zebra_announce_table(bgp, afi, safi); | |
1828 | } | |
1829 | bgp->main_peers_update_hold = 0; | |
1830 | ||
cb1faec9 DS |
1831 | bgp_start_routeadv(bgp); |
1832 | return WQ_SUCCESS; | |
1833 | } | |
1834 | ||
fee0f4c6 | 1835 | /* Best path selection. */ |
96450faf | 1836 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
fee0f4c6 | 1837 | old_select = old_and_new.old; |
1838 | new_select = old_and_new.new; | |
1839 | ||
1840 | /* Nothing to do. */ | |
adbac85e DW |
1841 | if (old_select && old_select == new_select && |
1842 | !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR) && | |
1843 | !CHECK_FLAG(old_select->flags, BGP_INFO_ATTR_CHANGED) && | |
1844 | !bgp->addpath_tx_used[afi][safi]) | |
1845 | { | |
3064bf43 | 1846 | if (bgp_zebra_has_route_changed (rn, old_select)) |
adbac85e | 1847 | bgp_zebra_announce (p, old_select, bgp, afi, safi); |
200df115 | 1848 | |
adbac85e | 1849 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
3064bf43 | 1850 | bgp_zebra_clear_route_change_flags (rn); |
adbac85e DW |
1851 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1852 | return WQ_SUCCESS; | |
fee0f4c6 | 1853 | } |
1854 | ||
8ad7271d DS |
1855 | /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */ |
1856 | UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
1857 | ||
3f9c7369 DS |
1858 | /* bestpath has changed; bump version */ |
1859 | if (old_select || new_select) | |
0de4848d DS |
1860 | { |
1861 | bgp_bump_version(rn); | |
1862 | ||
1863 | if (!bgp->t_rmap_def_originate_eval) | |
1864 | { | |
1865 | bgp_lock (bgp); | |
9229d914 | 1866 | THREAD_TIMER_ON(bm->master, bgp->t_rmap_def_originate_eval, |
0de4848d DS |
1867 | update_group_refresh_default_originate_route_map, |
1868 | bgp, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER); | |
1869 | } | |
1870 | } | |
3f9c7369 | 1871 | |
338b3424 | 1872 | if (old_select) |
1a392d46 | 1873 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
338b3424 | 1874 | if (new_select) |
1875 | { | |
1a392d46 PJ |
1876 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1877 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
8196f13d | 1878 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
338b3424 | 1879 | } |
1880 | ||
3f9c7369 | 1881 | group_announce_route(bgp, afi, safi, rn, new_select); |
718e3744 | 1882 | |
1883 | /* FIB update. */ | |
ad4cbda1 | 1884 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && |
1885 | (bgp->inst_type != BGP_INSTANCE_TYPE_VIEW) && | |
1886 | !bgp_option_check (BGP_OPT_NO_FIB)) | |
718e3744 | 1887 | { |
1888 | if (new_select | |
1889 | && new_select->type == ZEBRA_ROUTE_BGP | |
f992e2a9 DS |
1890 | && (new_select->sub_type == BGP_ROUTE_NORMAL || |
1891 | new_select->sub_type == BGP_ROUTE_AGGREGATE)) | |
73ac8160 | 1892 | bgp_zebra_announce (p, new_select, bgp, afi, safi); |
718e3744 | 1893 | else |
1894 | { | |
1895 | /* Withdraw the route from the kernel. */ | |
1896 | if (old_select | |
1897 | && old_select->type == ZEBRA_ROUTE_BGP | |
f992e2a9 DS |
1898 | && (old_select->sub_type == BGP_ROUTE_NORMAL || |
1899 | old_select->sub_type == BGP_ROUTE_AGGREGATE)) | |
5a616c08 | 1900 | bgp_zebra_withdraw (p, old_select, safi); |
718e3744 | 1901 | } |
1902 | } | |
3064bf43 | 1903 | |
1904 | /* Clear any route change flags. */ | |
1905 | bgp_zebra_clear_route_change_flags (rn); | |
1906 | ||
adbac85e | 1907 | /* Reap old select bgp_info, if it has been removed */ |
b40d939b | 1908 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
1909 | bgp_info_reap (rn, old_select); | |
1910 | ||
200df115 | 1911 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1912 | return WQ_SUCCESS; | |
718e3744 | 1913 | } |
1914 | ||
200df115 | 1915 | static void |
0fb58d5d | 1916 | bgp_processq_del (struct work_queue *wq, void *data) |
200df115 | 1917 | { |
0fb58d5d | 1918 | struct bgp_process_queue *pq = data; |
cb1faec9 DS |
1919 | struct bgp_table *table; |
1920 | ||
228da428 | 1921 | bgp_unlock (pq->bgp); |
cb1faec9 DS |
1922 | if (pq->rn) |
1923 | { | |
1924 | table = bgp_node_table (pq->rn); | |
1925 | bgp_unlock_node (pq->rn); | |
1926 | bgp_table_unlock (table); | |
1927 | } | |
200df115 | 1928 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
1929 | } | |
1930 | ||
f188f2c4 | 1931 | void |
200df115 | 1932 | bgp_process_queue_init (void) |
1933 | { | |
495f0b13 DS |
1934 | if (!bm->process_main_queue) |
1935 | { | |
1936 | bm->process_main_queue | |
87d4a781 | 1937 | = work_queue_new (bm->master, "process_main_queue"); |
495f0b13 | 1938 | |
2a3d5731 DW |
1939 | if ( !bm->process_main_queue) |
1940 | { | |
1941 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
1942 | exit (1); | |
1943 | } | |
200df115 | 1944 | } |
1945 | ||
1946 | bm->process_main_queue->spec.workfunc = &bgp_process_main; | |
200df115 | 1947 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
838bbde0 PJ |
1948 | bm->process_main_queue->spec.max_retries = 0; |
1949 | bm->process_main_queue->spec.hold = 50; | |
d889623f DS |
1950 | /* Use a higher yield value of 50ms for main queue processing */ |
1951 | bm->process_main_queue->spec.yield = 50 * 1000L; | |
200df115 | 1952 | } |
1953 | ||
1954 | void | |
fee0f4c6 | 1955 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
1956 | { | |
200df115 | 1957 | struct bgp_process_queue *pqnode; |
1958 | ||
1959 | /* already scheduled for processing? */ | |
1960 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) | |
1961 | return; | |
495f0b13 | 1962 | |
2a3d5731 | 1963 | if (bm->process_main_queue == NULL) |
2e02b9b2 DS |
1964 | bgp_process_queue_init (); |
1965 | ||
200df115 | 1966 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
1967 | sizeof (struct bgp_process_queue)); | |
1968 | if (!pqnode) | |
1969 | return; | |
228da428 CC |
1970 | |
1971 | /* all unlocked in bgp_processq_del */ | |
67174041 | 1972 | bgp_table_lock (bgp_node_table (rn)); |
228da428 | 1973 | pqnode->rn = bgp_lock_node (rn); |
200df115 | 1974 | pqnode->bgp = bgp; |
228da428 | 1975 | bgp_lock (bgp); |
200df115 | 1976 | pqnode->afi = afi; |
1977 | pqnode->safi = safi; | |
2a3d5731 | 1978 | work_queue_add (bm->process_main_queue, pqnode); |
07ff4dc4 | 1979 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
200df115 | 1980 | return; |
fee0f4c6 | 1981 | } |
0a486e5f | 1982 | |
cb1faec9 | 1983 | void |
2a3d5731 | 1984 | bgp_add_eoiu_mark (struct bgp *bgp) |
cb1faec9 DS |
1985 | { |
1986 | struct bgp_process_queue *pqnode; | |
1987 | ||
2a3d5731 | 1988 | if (bm->process_main_queue == NULL) |
2e02b9b2 DS |
1989 | bgp_process_queue_init (); |
1990 | ||
cb1faec9 DS |
1991 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
1992 | sizeof (struct bgp_process_queue)); | |
1993 | if (!pqnode) | |
1994 | return; | |
1995 | ||
1996 | pqnode->rn = NULL; | |
1997 | pqnode->bgp = bgp; | |
1998 | bgp_lock (bgp); | |
2a3d5731 | 1999 | work_queue_add (bm->process_main_queue, pqnode); |
cb1faec9 DS |
2000 | } |
2001 | ||
94f2b392 | 2002 | static int |
0a486e5f | 2003 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
2004 | { | |
2005 | struct peer *peer; | |
2006 | ||
2007 | peer = THREAD_ARG (thread); | |
2008 | peer->t_pmax_restart = NULL; | |
2009 | ||
16286195 | 2010 | if (bgp_debug_neighbor_events(peer)) |
0a486e5f | 2011 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
2012 | peer->host); | |
2013 | ||
1ff9a340 | 2014 | peer_clear (peer, NULL); |
0a486e5f | 2015 | |
2016 | return 0; | |
2017 | } | |
2018 | ||
718e3744 | 2019 | int |
5228ad27 | 2020 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
2021 | safi_t safi, int always) | |
718e3744 | 2022 | { |
e0701b79 | 2023 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
2024 | return 0; | |
2025 | ||
2026 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) | |
718e3744 | 2027 | { |
e0701b79 | 2028 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
2029 | && ! always) | |
2030 | return 0; | |
2031 | ||
16286195 DS |
2032 | zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
2033 | "limit %ld", afi_safi_print (afi, safi), peer->host, | |
2034 | peer->pcount[afi][safi], peer->pmax[afi][safi]); | |
e0701b79 | 2035 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
2036 | ||
2037 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
2038 | return 0; | |
2039 | ||
2040 | { | |
5228ad27 | 2041 | u_int8_t ndata[7]; |
e0701b79 | 2042 | |
2043 | if (safi == SAFI_MPLS_VPN) | |
42e6d745 | 2044 | safi = SAFI_MPLS_LABELED_VPN; |
5228ad27 | 2045 | |
2046 | ndata[0] = (afi >> 8); | |
2047 | ndata[1] = afi; | |
2048 | ndata[2] = safi; | |
2049 | ndata[3] = (peer->pmax[afi][safi] >> 24); | |
2050 | ndata[4] = (peer->pmax[afi][safi] >> 16); | |
2051 | ndata[5] = (peer->pmax[afi][safi] >> 8); | |
2052 | ndata[6] = (peer->pmax[afi][safi]); | |
e0701b79 | 2053 | |
2054 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); | |
2055 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, | |
2056 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); | |
2057 | } | |
0a486e5f | 2058 | |
f14e6fdb DS |
2059 | /* Dynamic peers will just close their connection. */ |
2060 | if (peer_dynamic_neighbor (peer)) | |
2061 | return 1; | |
2062 | ||
0a486e5f | 2063 | /* restart timer start */ |
2064 | if (peer->pmax_restart[afi][safi]) | |
2065 | { | |
2066 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; | |
2067 | ||
16286195 | 2068 | if (bgp_debug_neighbor_events(peer)) |
0a486e5f | 2069 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
2070 | peer->host, peer->v_pmax_restart); | |
2071 | ||
2072 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, | |
2073 | peer->v_pmax_restart); | |
2074 | } | |
2075 | ||
e0701b79 | 2076 | return 1; |
2077 | } | |
2078 | else | |
2079 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); | |
2080 | ||
2081 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) | |
2082 | { | |
2083 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) | |
2084 | && ! always) | |
2085 | return 0; | |
2086 | ||
16286195 DS |
2087 | zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
2088 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], | |
2089 | peer->pmax[afi][safi]); | |
e0701b79 | 2090 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
718e3744 | 2091 | } |
e0701b79 | 2092 | else |
2093 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); | |
718e3744 | 2094 | return 0; |
2095 | } | |
2096 | ||
b40d939b | 2097 | /* Unconditionally remove the route from the RIB, without taking |
2098 | * damping into consideration (eg, because the session went down) | |
2099 | */ | |
94f2b392 | 2100 | static void |
718e3744 | 2101 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
2102 | afi_t afi, safi_t safi) | |
2103 | { | |
902212c3 | 2104 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
2105 | ||
2106 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2107 | bgp_info_delete (rn, ri); /* keep historical info */ | |
2108 | ||
b40d939b | 2109 | bgp_process (peer->bgp, rn, afi, safi); |
718e3744 | 2110 | } |
2111 | ||
94f2b392 | 2112 | static void |
718e3744 | 2113 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
b40d939b | 2114 | afi_t afi, safi_t safi) |
718e3744 | 2115 | { |
718e3744 | 2116 | int status = BGP_DAMP_NONE; |
2117 | ||
b40d939b | 2118 | /* apply dampening, if result is suppressed, we'll be retaining |
2119 | * the bgp_info in the RIB for historical reference. | |
2120 | */ | |
2121 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2122 | && peer->sort == BGP_PEER_EBGP) |
b40d939b | 2123 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
2124 | == BGP_DAMP_SUPPRESSED) | |
902212c3 | 2125 | { |
902212c3 | 2126 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
2127 | return; | |
2128 | } | |
2129 | ||
2130 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
718e3744 | 2131 | } |
2132 | ||
fb018d25 | 2133 | static struct bgp_info * |
7c8ff89e | 2134 | info_make (int type, int sub_type, u_short instance, struct peer *peer, struct attr *attr, |
fb018d25 DS |
2135 | struct bgp_node *rn) |
2136 | { | |
2137 | struct bgp_info *new; | |
2138 | ||
2139 | /* Make new BGP info. */ | |
2140 | new = XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); | |
2141 | new->type = type; | |
7c8ff89e | 2142 | new->instance = instance; |
fb018d25 DS |
2143 | new->sub_type = sub_type; |
2144 | new->peer = peer; | |
2145 | new->attr = attr; | |
2146 | new->uptime = bgp_clock (); | |
2147 | new->net = rn; | |
adbac85e | 2148 | new->addpath_tx_id = ++peer->bgp->addpath_tx_id; |
fb018d25 DS |
2149 | return new; |
2150 | } | |
2151 | ||
94f2b392 | 2152 | static void |
2ec1e66f | 2153 | bgp_info_addpath_rx_str(u_int32_t addpath_id, char *buf) |
cd808e74 | 2154 | { |
2ec1e66f DW |
2155 | if (addpath_id) |
2156 | sprintf(buf, " with addpath ID %d", addpath_id); | |
cd808e74 DS |
2157 | } |
2158 | ||
2ec1e66f | 2159 | |
c265ee22 DS |
2160 | /* Check if received nexthop is valid or not. */ |
2161 | static int | |
6aeb9e78 | 2162 | bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr *attr) |
c265ee22 DS |
2163 | { |
2164 | struct attr_extra *attre = attr->extra; | |
2165 | int ret = 0; | |
2166 | ||
2167 | /* Only validated for unicast and multicast currently. */ | |
2168 | if (safi != SAFI_UNICAST && safi != SAFI_MULTICAST) | |
2169 | return 0; | |
2170 | ||
2171 | /* If NEXT_HOP is present, validate it. */ | |
2172 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)) | |
2173 | { | |
2174 | if (attr->nexthop.s_addr == 0 || | |
2175 | IPV4_CLASS_DE (ntohl (attr->nexthop.s_addr)) || | |
6aeb9e78 | 2176 | bgp_nexthop_self (bgp, attr)) |
c265ee22 DS |
2177 | ret = 1; |
2178 | } | |
2179 | ||
2180 | /* If MP_NEXTHOP is present, validate it. */ | |
2181 | /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop; | |
2182 | * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if | |
2183 | * it is not an IPv6 link-local address. | |
2184 | */ | |
2185 | if (attre && attre->mp_nexthop_len) | |
2186 | { | |
2187 | switch (attre->mp_nexthop_len) | |
2188 | { | |
2189 | case BGP_ATTR_NHLEN_IPV4: | |
2190 | case BGP_ATTR_NHLEN_VPNV4: | |
2191 | ret = (attre->mp_nexthop_global_in.s_addr == 0 || | |
2192 | IPV4_CLASS_DE (ntohl (attre->mp_nexthop_global_in.s_addr))); | |
2193 | break; | |
2194 | ||
2195 | #ifdef HAVE_IPV6 | |
2196 | case BGP_ATTR_NHLEN_IPV6_GLOBAL: | |
2197 | case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: | |
2198 | ret = (IN6_IS_ADDR_UNSPECIFIED(&attre->mp_nexthop_global) || | |
2199 | IN6_IS_ADDR_LOOPBACK(&attre->mp_nexthop_global) || | |
2200 | IN6_IS_ADDR_MULTICAST(&attre->mp_nexthop_global)); | |
2201 | break; | |
2202 | #endif /* HAVE_IPV6 */ | |
2203 | ||
2204 | default: | |
2205 | ret = 1; | |
2206 | break; | |
2207 | } | |
2208 | } | |
2209 | ||
2210 | return ret; | |
2211 | } | |
2212 | ||
a7ee645d DS |
2213 | int |
2214 | bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, | |
2215 | struct attr *attr, afi_t afi, safi_t safi, int type, | |
2216 | int sub_type, struct prefix_rd *prd, u_char *tag, | |
2217 | int soft_reconfig) | |
718e3744 | 2218 | { |
2219 | int ret; | |
2220 | int aspath_loop_count = 0; | |
2221 | struct bgp_node *rn; | |
2222 | struct bgp *bgp; | |
558d1fec JBD |
2223 | struct attr new_attr; |
2224 | struct attr_extra new_extra; | |
718e3744 | 2225 | struct attr *attr_new; |
2226 | struct bgp_info *ri; | |
2227 | struct bgp_info *new; | |
fd79ac91 | 2228 | const char *reason; |
718e3744 | 2229 | char buf[SU_ADDRSTRLEN]; |
cd808e74 | 2230 | char buf2[30]; |
fc9a856f | 2231 | int connected = 0; |
718e3744 | 2232 | |
2233 | bgp = peer->bgp; | |
fee0f4c6 | 2234 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
fb982c25 | 2235 | |
718e3744 | 2236 | /* When peer's soft reconfiguration enabled. Record input packet in |
2237 | Adj-RIBs-In. */ | |
343aa822 JBD |
2238 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
2239 | && peer != bgp->peer_self) | |
43143c8f | 2240 | bgp_adj_in_set (rn, peer, attr, addpath_id); |
718e3744 | 2241 | |
2242 | /* Check previously received route. */ | |
2243 | for (ri = rn->info; ri; ri = ri->next) | |
a82478b9 DS |
2244 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type && |
2245 | ri->addpath_rx_id == addpath_id) | |
718e3744 | 2246 | break; |
2247 | ||
2248 | /* AS path local-as loop check. */ | |
2249 | if (peer->change_local_as) | |
2250 | { | |
2251 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
2252 | aspath_loop_count = 1; | |
2253 | ||
2254 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) | |
2255 | { | |
2256 | reason = "as-path contains our own AS;"; | |
2257 | goto filtered; | |
2258 | } | |
2259 | } | |
2260 | ||
2261 | /* AS path loop check. */ | |
2262 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] | |
2263 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
2264 | && aspath_loop_check(attr->aspath, bgp->confed_id) | |
2265 | > peer->allowas_in[afi][safi])) | |
2266 | { | |
2267 | reason = "as-path contains our own AS;"; | |
2268 | goto filtered; | |
2269 | } | |
2270 | ||
2271 | /* Route reflector originator ID check. */ | |
2272 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 2273 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
718e3744 | 2274 | { |
2275 | reason = "originator is us;"; | |
2276 | goto filtered; | |
2277 | } | |
2278 | ||
2279 | /* Route reflector cluster ID check. */ | |
2280 | if (bgp_cluster_filter (peer, attr)) | |
2281 | { | |
2282 | reason = "reflected from the same cluster;"; | |
2283 | goto filtered; | |
2284 | } | |
2285 | ||
2286 | /* Apply incoming filter. */ | |
2287 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) | |
2288 | { | |
2289 | reason = "filter;"; | |
2290 | goto filtered; | |
2291 | } | |
2292 | ||
558d1fec | 2293 | new_attr.extra = &new_extra; |
fb982c25 | 2294 | bgp_attr_dup (&new_attr, attr); |
718e3744 | 2295 | |
c460e572 DL |
2296 | /* Apply incoming route-map. |
2297 | * NB: new_attr may now contain newly allocated values from route-map "set" | |
2298 | * commands, so we need bgp_attr_flush in the error paths, until we intern | |
2299 | * the attr (which takes over the memory references) */ | |
0b16f239 | 2300 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi, NULL) == RMAP_DENY) |
718e3744 | 2301 | { |
2302 | reason = "route-map;"; | |
c460e572 | 2303 | bgp_attr_flush (&new_attr); |
718e3744 | 2304 | goto filtered; |
2305 | } | |
2306 | ||
c265ee22 | 2307 | /* next hop check. */ |
6aeb9e78 | 2308 | if (bgp_update_martian_nexthop (bgp, afi, safi, &new_attr)) |
718e3744 | 2309 | { |
c265ee22 DS |
2310 | reason = "martian or self next-hop;"; |
2311 | bgp_attr_flush (&new_attr); | |
2312 | goto filtered; | |
718e3744 | 2313 | } |
2314 | ||
2315 | attr_new = bgp_attr_intern (&new_attr); | |
2316 | ||
2317 | /* If the update is implicit withdraw. */ | |
2318 | if (ri) | |
2319 | { | |
65957886 | 2320 | ri->uptime = bgp_clock (); |
718e3744 | 2321 | |
2322 | /* Same attribute comes in. */ | |
16d2e241 PJ |
2323 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
2324 | && attrhash_cmp (ri->attr, attr_new)) | |
718e3744 | 2325 | { |
718e3744 | 2326 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
6d85b15b | 2327 | && peer->sort == BGP_PEER_EBGP |
718e3744 | 2328 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2329 | { | |
3f9c7369 | 2330 | if (bgp_debug_update(peer, p, NULL, 1)) |
cd808e74 | 2331 | { |
2ec1e66f | 2332 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2333 | zlog_debug ("%s rcvd %s/%d%s", |
16286195 DS |
2334 | peer->host, |
2335 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 DS |
2336 | p->prefixlen, buf2); |
2337 | } | |
718e3744 | 2338 | |
902212c3 | 2339 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
2340 | { | |
2341 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2342 | bgp_process (bgp, rn, afi, safi); | |
2343 | } | |
718e3744 | 2344 | } |
16d2e241 | 2345 | else /* Duplicate - odd */ |
718e3744 | 2346 | { |
3f9c7369 | 2347 | if (bgp_debug_update(peer, p, NULL, 1)) |
16286195 DS |
2348 | { |
2349 | if (!peer->rcvd_attr_printed) | |
2350 | { | |
2351 | zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str); | |
2352 | peer->rcvd_attr_printed = 1; | |
2353 | } | |
2354 | ||
2ec1e66f | 2355 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2356 | zlog_debug ("%s rcvd %s/%d%s...duplicate ignored", |
16286195 DS |
2357 | peer->host, |
2358 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 | 2359 | p->prefixlen, buf2); |
16286195 | 2360 | } |
93406d87 | 2361 | |
2362 | /* graceful restart STALE flag unset. */ | |
2363 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2364 | { | |
1a392d46 | 2365 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
902212c3 | 2366 | bgp_process (bgp, rn, afi, safi); |
93406d87 | 2367 | } |
718e3744 | 2368 | } |
2369 | ||
2370 | bgp_unlock_node (rn); | |
f6f434b2 | 2371 | bgp_attr_unintern (&attr_new); |
558d1fec | 2372 | |
718e3744 | 2373 | return 0; |
2374 | } | |
2375 | ||
16d2e241 PJ |
2376 | /* Withdraw/Announce before we fully processed the withdraw */ |
2377 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
2378 | { | |
3f9c7369 | 2379 | if (bgp_debug_update(peer, p, NULL, 1)) |
cd808e74 | 2380 | { |
2ec1e66f | 2381 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 DS |
2382 | zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing", |
2383 | peer->host, | |
2384 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2385 | p->prefixlen, buf2); | |
2386 | } | |
16d2e241 PJ |
2387 | bgp_info_restore (rn, ri); |
2388 | } | |
2389 | ||
718e3744 | 2390 | /* Received Logging. */ |
3f9c7369 | 2391 | if (bgp_debug_update(peer, p, NULL, 1)) |
cd808e74 | 2392 | { |
2ec1e66f | 2393 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2394 | zlog_debug ("%s rcvd %s/%d%s", |
16286195 DS |
2395 | peer->host, |
2396 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 DS |
2397 | p->prefixlen, buf2); |
2398 | } | |
718e3744 | 2399 | |
93406d87 | 2400 | /* graceful restart STALE flag unset. */ |
2401 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
1a392d46 | 2402 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
93406d87 | 2403 | |
718e3744 | 2404 | /* The attribute is changed. */ |
1a392d46 | 2405 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
902212c3 | 2406 | |
2407 | /* implicit withdraw, decrement aggregate and pcount here. | |
2408 | * only if update is accepted, they'll increment below. | |
2409 | */ | |
902212c3 | 2410 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
2411 | ||
718e3744 | 2412 | /* Update bgp route dampening information. */ |
2413 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2414 | && peer->sort == BGP_PEER_EBGP) |
718e3744 | 2415 | { |
2416 | /* This is implicit withdraw so we should update dampening | |
2417 | information. */ | |
2418 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2419 | bgp_damp_withdraw (ri, rn, afi, safi, 1); | |
718e3744 | 2420 | } |
2421 | ||
718e3744 | 2422 | /* Update to new attribute. */ |
f6f434b2 | 2423 | bgp_attr_unintern (&ri->attr); |
718e3744 | 2424 | ri->attr = attr_new; |
2425 | ||
2426 | /* Update MPLS tag. */ | |
2427 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2428 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
718e3744 | 2429 | |
2430 | /* Update bgp route dampening information. */ | |
2431 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
6d85b15b | 2432 | && peer->sort == BGP_PEER_EBGP) |
718e3744 | 2433 | { |
2434 | /* Now we do normal update dampening. */ | |
2435 | ret = bgp_damp_update (ri, rn, afi, safi); | |
2436 | if (ret == BGP_DAMP_SUPPRESSED) | |
2437 | { | |
2438 | bgp_unlock_node (rn); | |
2439 | return 0; | |
2440 | } | |
2441 | } | |
2442 | ||
2443 | /* Nexthop reachability check. */ | |
fc9a856f | 2444 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
718e3744 | 2445 | { |
fc9a856f | 2446 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 && |
907f92c8 DS |
2447 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) |
2448 | && ! bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
fc9a856f DS |
2449 | connected = 1; |
2450 | else | |
2451 | connected = 0; | |
2452 | ||
75aead62 | 2453 | if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, connected)) |
1a392d46 | 2454 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2455 | else |
fc9a856f DS |
2456 | { |
2457 | if (BGP_DEBUG(nht, NHT)) | |
2458 | { | |
2459 | char buf1[INET6_ADDRSTRLEN]; | |
2460 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN); | |
2461 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); | |
2462 | } | |
2463 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); | |
2464 | } | |
718e3744 | 2465 | } |
2466 | else | |
fc9a856f | 2467 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2468 | |
2469 | /* Process change. */ | |
2470 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2471 | ||
2472 | bgp_process (bgp, rn, afi, safi); | |
2473 | bgp_unlock_node (rn); | |
558d1fec | 2474 | |
718e3744 | 2475 | return 0; |
a82478b9 | 2476 | } // End of implicit withdraw |
718e3744 | 2477 | |
2478 | /* Received Logging. */ | |
3f9c7369 | 2479 | if (bgp_debug_update(peer, p, NULL, 1)) |
718e3744 | 2480 | { |
16286195 DS |
2481 | if (!peer->rcvd_attr_printed) |
2482 | { | |
2483 | zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str); | |
2484 | peer->rcvd_attr_printed = 1; | |
2485 | } | |
2486 | ||
2ec1e66f | 2487 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2488 | zlog_debug ("%s rcvd %s/%d%s", |
16286195 DS |
2489 | peer->host, |
2490 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 | 2491 | p->prefixlen, buf2); |
718e3744 | 2492 | } |
2493 | ||
718e3744 | 2494 | /* Make new BGP info. */ |
7c8ff89e | 2495 | new = info_make(type, sub_type, 0, peer, attr_new, rn); |
718e3744 | 2496 | |
2497 | /* Update MPLS tag. */ | |
2498 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2499 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
718e3744 | 2500 | |
2501 | /* Nexthop reachability check. */ | |
fc9a856f DS |
2502 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
2503 | { | |
2504 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 && | |
907f92c8 DS |
2505 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK) |
2506 | && ! bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
fc9a856f DS |
2507 | connected = 1; |
2508 | else | |
2509 | connected = 0; | |
2510 | ||
75aead62 | 2511 | if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, connected)) |
1a392d46 | 2512 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2513 | else |
fc9a856f DS |
2514 | { |
2515 | if (BGP_DEBUG(nht, NHT)) | |
2516 | { | |
2517 | char buf1[INET6_ADDRSTRLEN]; | |
2518 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN); | |
2519 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); | |
2520 | } | |
2521 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); | |
2522 | } | |
718e3744 | 2523 | } |
2524 | else | |
1a392d46 | 2525 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2526 | |
a82478b9 DS |
2527 | /* Addpath ID */ |
2528 | new->addpath_rx_id = addpath_id; | |
a82478b9 | 2529 | |
902212c3 | 2530 | /* Increment prefix */ |
718e3744 | 2531 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
2532 | ||
2533 | /* Register new BGP information. */ | |
2534 | bgp_info_add (rn, new); | |
200df115 | 2535 | |
2536 | /* route_node_get lock */ | |
2537 | bgp_unlock_node (rn); | |
558d1fec | 2538 | |
718e3744 | 2539 | /* If maximum prefix count is configured and current prefix |
2540 | count exeed it. */ | |
e0701b79 | 2541 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
2542 | return -1; | |
718e3744 | 2543 | |
2544 | /* Process change. */ | |
2545 | bgp_process (bgp, rn, afi, safi); | |
2546 | ||
2547 | return 0; | |
2548 | ||
2549 | /* This BGP update is filtered. Log the reason then update BGP | |
2550 | entry. */ | |
2551 | filtered: | |
3f9c7369 | 2552 | if (bgp_debug_update(peer, p, NULL, 1)) |
16286195 DS |
2553 | { |
2554 | if (!peer->rcvd_attr_printed) | |
2555 | { | |
2556 | zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str); | |
2557 | peer->rcvd_attr_printed = 1; | |
2558 | } | |
2559 | ||
2ec1e66f | 2560 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 | 2561 | zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s", |
16286195 DS |
2562 | peer->host, |
2563 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
cd808e74 | 2564 | p->prefixlen, buf2, reason); |
16286195 | 2565 | } |
718e3744 | 2566 | |
2567 | if (ri) | |
b40d939b | 2568 | bgp_rib_remove (rn, ri, peer, afi, safi); |
718e3744 | 2569 | |
2570 | bgp_unlock_node (rn); | |
558d1fec | 2571 | |
718e3744 | 2572 | return 0; |
2573 | } | |
2574 | ||
2575 | int | |
a82478b9 DS |
2576 | bgp_withdraw (struct peer *peer, struct prefix *p, u_int32_t addpath_id, |
2577 | struct attr *attr, afi_t afi, safi_t safi, int type, int sub_type, | |
2578 | struct prefix_rd *prd, u_char *tag) | |
718e3744 | 2579 | { |
2580 | struct bgp *bgp; | |
2581 | char buf[SU_ADDRSTRLEN]; | |
cd808e74 | 2582 | char buf2[30]; |
718e3744 | 2583 | struct bgp_node *rn; |
2584 | struct bgp_info *ri; | |
2585 | ||
2586 | bgp = peer->bgp; | |
2587 | ||
718e3744 | 2588 | /* Lookup node. */ |
fee0f4c6 | 2589 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 2590 | |
2591 | /* If peer is soft reconfiguration enabled. Record input packet for | |
6b87f736 DL |
2592 | * further calculation. |
2593 | * | |
2594 | * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all | |
2595 | * routes that are filtered. This tanks out Quagga RS pretty badly due to | |
2596 | * the iteration over all RS clients. | |
2597 | * Since we need to remove the entry from adj_in anyway, do that first and | |
2598 | * if there was no entry, we don't need to do anything more. | |
2599 | */ | |
718e3744 | 2600 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
2601 | && peer != bgp->peer_self) | |
6b87f736 DL |
2602 | if (!bgp_adj_in_unset (rn, peer, addpath_id)) |
2603 | { | |
2604 | if (bgp_debug_update (peer, p, NULL, 1)) | |
2605 | zlog_debug ("%s withdrawing route %s/%d " | |
2606 | "not in adj-in", peer->host, | |
2607 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2608 | p->prefixlen); | |
2609 | bgp_unlock_node (rn); | |
2610 | return 0; | |
2611 | } | |
718e3744 | 2612 | |
2613 | /* Lookup withdrawn route. */ | |
2614 | for (ri = rn->info; ri; ri = ri->next) | |
a82478b9 DS |
2615 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type && |
2616 | ri->addpath_rx_id == addpath_id) | |
718e3744 | 2617 | break; |
2618 | ||
cd808e74 DS |
2619 | /* Logging. */ |
2620 | if (bgp_debug_update(peer, p, NULL, 1)) | |
2621 | { | |
2ec1e66f | 2622 | bgp_info_addpath_rx_str(addpath_id, buf2); |
cd808e74 DS |
2623 | zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn", |
2624 | peer->host, | |
2625 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2626 | p->prefixlen, buf2); | |
2627 | } | |
2628 | ||
718e3744 | 2629 | /* Withdraw specified route from routing table. */ |
2630 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2631 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
3f9c7369 | 2632 | else if (bgp_debug_update(peer, p, NULL, 1)) |
16286195 DS |
2633 | zlog_debug ("%s Can't find the route %s/%d", peer->host, |
2634 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2635 | p->prefixlen); | |
718e3744 | 2636 | |
2637 | /* Unlock bgp_node_get() lock. */ | |
2638 | bgp_unlock_node (rn); | |
2639 | ||
2640 | return 0; | |
2641 | } | |
6b0655a2 | 2642 | |
718e3744 | 2643 | void |
2644 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) | |
2645 | { | |
3f9c7369 DS |
2646 | struct update_subgroup *subgrp; |
2647 | subgrp = peer_subgroup(peer, afi, safi); | |
2648 | subgroup_default_originate(subgrp, withdraw); | |
2649 | } | |
6182d65b | 2650 | |
718e3744 | 2651 | |
3f9c7369 DS |
2652 | /* |
2653 | * bgp_stop_announce_route_timer | |
2654 | */ | |
2655 | void | |
2656 | bgp_stop_announce_route_timer (struct peer_af *paf) | |
2657 | { | |
2658 | if (!paf->t_announce_route) | |
2659 | return; | |
718e3744 | 2660 | |
3f9c7369 | 2661 | THREAD_TIMER_OFF (paf->t_announce_route); |
718e3744 | 2662 | } |
6b0655a2 | 2663 | |
3f9c7369 DS |
2664 | /* |
2665 | * bgp_announce_route_timer_expired | |
2666 | * | |
2667 | * Callback that is invoked when the route announcement timer for a | |
2668 | * peer_af expires. | |
2669 | */ | |
2670 | static int | |
2671 | bgp_announce_route_timer_expired (struct thread *t) | |
718e3744 | 2672 | { |
3f9c7369 DS |
2673 | struct peer_af *paf; |
2674 | struct peer *peer; | |
558d1fec | 2675 | |
3f9c7369 DS |
2676 | paf = THREAD_ARG (t); |
2677 | peer = paf->peer; | |
718e3744 | 2678 | |
3f9c7369 DS |
2679 | assert (paf->t_announce_route); |
2680 | paf->t_announce_route = NULL; | |
558d1fec | 2681 | |
3f9c7369 DS |
2682 | if (peer->status != Established) |
2683 | return 0; | |
2684 | ||
2685 | if (!peer->afc_nego[paf->afi][paf->safi]) | |
2686 | return 0; | |
2687 | ||
2688 | peer_af_announce_route (paf, 1); | |
2689 | return 0; | |
718e3744 | 2690 | } |
2691 | ||
3f9c7369 DS |
2692 | /* |
2693 | * bgp_announce_route | |
2694 | * | |
2695 | * *Triggers* announcement of routes of a given AFI/SAFI to a peer. | |
2696 | */ | |
718e3744 | 2697 | void |
2698 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) | |
2699 | { | |
3f9c7369 DS |
2700 | struct peer_af *paf; |
2701 | struct update_subgroup *subgrp; | |
718e3744 | 2702 | |
3f9c7369 DS |
2703 | paf = peer_af_find (peer, afi, safi); |
2704 | if (!paf) | |
718e3744 | 2705 | return; |
3f9c7369 | 2706 | subgrp = PAF_SUBGRP(paf); |
718e3744 | 2707 | |
3f9c7369 DS |
2708 | /* |
2709 | * Ignore if subgroup doesn't exist (implies AF is not negotiated) | |
2710 | * or a refresh has already been triggered. | |
2711 | */ | |
2712 | if (!subgrp || paf->t_announce_route) | |
718e3744 | 2713 | return; |
2714 | ||
d889623f | 2715 | /* |
3f9c7369 DS |
2716 | * Start a timer to stagger/delay the announce. This serves |
2717 | * two purposes - announcement can potentially be combined for | |
2718 | * multiple peers and the announcement doesn't happen in the | |
2719 | * vty context. | |
d889623f | 2720 | */ |
9229d914 | 2721 | THREAD_TIMER_MSEC_ON (bm->master, paf->t_announce_route, |
3f9c7369 DS |
2722 | bgp_announce_route_timer_expired, paf, |
2723 | (subgrp->peer_count == 1) ? | |
2724 | BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS : | |
2725 | BGP_ANNOUNCE_ROUTE_DELAY_MS); | |
2726 | } | |
2727 | ||
2728 | /* | |
2729 | * Announce routes from all AF tables to a peer. | |
2730 | * | |
2731 | * This should ONLY be called when there is a need to refresh the | |
2732 | * routes to the peer based on a policy change for this peer alone | |
2733 | * or a route refresh request received from the peer. | |
2734 | * The operation will result in splitting the peer from its existing | |
2735 | * subgroups and putting it in new subgroups. | |
2736 | */ | |
718e3744 | 2737 | void |
2738 | bgp_announce_route_all (struct peer *peer) | |
2739 | { | |
2740 | afi_t afi; | |
2741 | safi_t safi; | |
2742 | ||
2743 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2744 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2745 | bgp_announce_route (peer, afi, safi); | |
2746 | } | |
6b0655a2 | 2747 | |
fee0f4c6 | 2748 | static void |
718e3744 | 2749 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
8692c506 | 2750 | struct bgp_table *table, struct prefix_rd *prd) |
718e3744 | 2751 | { |
2752 | int ret; | |
2753 | struct bgp_node *rn; | |
2754 | struct bgp_adj_in *ain; | |
2755 | ||
2756 | if (! table) | |
2757 | table = peer->bgp->rib[afi][safi]; | |
2758 | ||
2759 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2760 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2761 | { | |
2762 | if (ain->peer == peer) | |
2763 | { | |
8692c506 | 2764 | struct bgp_info *ri = rn->info; |
d53d8fda | 2765 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
8692c506 | 2766 | |
43143c8f | 2767 | ret = bgp_update (peer, &rn->p, ain->addpath_rx_id, ain->attr, |
a82478b9 | 2768 | afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
d53d8fda | 2769 | prd, tag, 1); |
8692c506 | 2770 | |
718e3744 | 2771 | if (ret < 0) |
2772 | { | |
2773 | bgp_unlock_node (rn); | |
2774 | return; | |
2775 | } | |
718e3744 | 2776 | } |
2777 | } | |
2778 | } | |
2779 | ||
2780 | void | |
2781 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) | |
2782 | { | |
2783 | struct bgp_node *rn; | |
2784 | struct bgp_table *table; | |
2785 | ||
2786 | if (peer->status != Established) | |
2787 | return; | |
2788 | ||
587ff0fd | 2789 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
8692c506 | 2790 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
718e3744 | 2791 | else |
2792 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2793 | rn = bgp_route_next (rn)) | |
2794 | if ((table = rn->info) != NULL) | |
8692c506 JBD |
2795 | { |
2796 | struct prefix_rd prd; | |
2797 | prd.family = AF_UNSPEC; | |
2798 | prd.prefixlen = 64; | |
2799 | memcpy(&prd.val, rn->p.u.val, 8); | |
2800 | ||
2801 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); | |
2802 | } | |
718e3744 | 2803 | } |
6b0655a2 | 2804 | |
228da428 CC |
2805 | |
2806 | struct bgp_clear_node_queue | |
2807 | { | |
2808 | struct bgp_node *rn; | |
228da428 CC |
2809 | }; |
2810 | ||
200df115 | 2811 | static wq_item_status |
0fb58d5d | 2812 | bgp_clear_route_node (struct work_queue *wq, void *data) |
200df115 | 2813 | { |
228da428 CC |
2814 | struct bgp_clear_node_queue *cnq = data; |
2815 | struct bgp_node *rn = cnq->rn; | |
64e580a7 | 2816 | struct peer *peer = wq->spec.data; |
718e3744 | 2817 | struct bgp_info *ri; |
67174041 AS |
2818 | afi_t afi = bgp_node_table (rn)->afi; |
2819 | safi_t safi = bgp_node_table (rn)->safi; | |
200df115 | 2820 | |
64e580a7 | 2821 | assert (rn && peer); |
200df115 | 2822 | |
43143c8f DS |
2823 | /* It is possible that we have multiple paths for a prefix from a peer |
2824 | * if that peer is using AddPath. | |
2825 | */ | |
64e580a7 | 2826 | for (ri = rn->info; ri; ri = ri->next) |
2a3d5731 | 2827 | if (ri->peer == peer) |
200df115 | 2828 | { |
2829 | /* graceful restart STALE flag set. */ | |
64e580a7 PJ |
2830 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
2831 | && peer->nsf[afi][safi] | |
200df115 | 2832 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
1a392d46 PJ |
2833 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2834 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); | |
200df115 | 2835 | else |
64e580a7 | 2836 | bgp_rib_remove (rn, ri, peer, afi, safi); |
200df115 | 2837 | } |
200df115 | 2838 | return WQ_SUCCESS; |
2839 | } | |
2840 | ||
2841 | static void | |
0fb58d5d | 2842 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
200df115 | 2843 | { |
228da428 CC |
2844 | struct bgp_clear_node_queue *cnq = data; |
2845 | struct bgp_node *rn = cnq->rn; | |
67174041 | 2846 | struct bgp_table *table = bgp_node_table (rn); |
64e580a7 PJ |
2847 | |
2848 | bgp_unlock_node (rn); | |
228da428 CC |
2849 | bgp_table_unlock (table); |
2850 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); | |
200df115 | 2851 | } |
2852 | ||
2853 | static void | |
94f2b392 | 2854 | bgp_clear_node_complete (struct work_queue *wq) |
200df115 | 2855 | { |
64e580a7 PJ |
2856 | struct peer *peer = wq->spec.data; |
2857 | ||
3e0c78ef | 2858 | /* Tickle FSM to start moving again */ |
ca058a30 | 2859 | BGP_EVENT_ADD (peer, Clearing_Completed); |
228da428 CC |
2860 | |
2861 | peer_unlock (peer); /* bgp_clear_route */ | |
200df115 | 2862 | } |
2863 | ||
2864 | static void | |
64e580a7 | 2865 | bgp_clear_node_queue_init (struct peer *peer) |
200df115 | 2866 | { |
a2943657 | 2867 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
64e580a7 | 2868 | |
a2943657 | 2869 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
64e580a7 PJ |
2870 | #undef CLEAR_QUEUE_NAME_LEN |
2871 | ||
87d4a781 | 2872 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
200df115 | 2873 | { |
2874 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
2875 | exit (1); | |
2876 | } | |
64e580a7 PJ |
2877 | peer->clear_node_queue->spec.hold = 10; |
2878 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; | |
2879 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; | |
2880 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; | |
2881 | peer->clear_node_queue->spec.max_retries = 0; | |
2882 | ||
2883 | /* we only 'lock' this peer reference when the queue is actually active */ | |
2884 | peer->clear_node_queue->spec.data = peer; | |
200df115 | 2885 | } |
718e3744 | 2886 | |
200df115 | 2887 | static void |
2888 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, | |
2a3d5731 | 2889 | struct bgp_table *table) |
200df115 | 2890 | { |
200df115 | 2891 | struct bgp_node *rn; |
2892 | ||
f2c31acb | 2893 | |
718e3744 | 2894 | if (! table) |
2a3d5731 | 2895 | table = peer->bgp->rib[afi][safi]; |
64e580a7 | 2896 | |
6cf159b9 | 2897 | /* If still no table => afi/safi isn't configured at all or smth. */ |
2898 | if (! table) | |
2899 | return; | |
65ca75e0 PJ |
2900 | |
2901 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2902 | { | |
f2c31acb PJ |
2903 | struct bgp_info *ri; |
2904 | struct bgp_adj_in *ain; | |
43143c8f | 2905 | struct bgp_adj_in *ain_next; |
f2c31acb PJ |
2906 | |
2907 | /* XXX:TODO: This is suboptimal, every non-empty route_node is | |
2908 | * queued for every clearing peer, regardless of whether it is | |
2909 | * relevant to the peer at hand. | |
2910 | * | |
2911 | * Overview: There are 3 different indices which need to be | |
2912 | * scrubbed, potentially, when a peer is removed: | |
2913 | * | |
2914 | * 1 peer's routes visible via the RIB (ie accepted routes) | |
2915 | * 2 peer's routes visible by the (optional) peer's adj-in index | |
2916 | * 3 other routes visible by the peer's adj-out index | |
2917 | * | |
2918 | * 3 there is no hurry in scrubbing, once the struct peer is | |
2919 | * removed from bgp->peer, we could just GC such deleted peer's | |
2920 | * adj-outs at our leisure. | |
2921 | * | |
2922 | * 1 and 2 must be 'scrubbed' in some way, at least made | |
2923 | * invisible via RIB index before peer session is allowed to be | |
2924 | * brought back up. So one needs to know when such a 'search' is | |
2925 | * complete. | |
2926 | * | |
2927 | * Ideally: | |
2928 | * | |
2929 | * - there'd be a single global queue or a single RIB walker | |
2930 | * - rather than tracking which route_nodes still need to be | |
2931 | * examined on a peer basis, we'd track which peers still | |
2932 | * aren't cleared | |
2933 | * | |
2934 | * Given that our per-peer prefix-counts now should be reliable, | |
2935 | * this may actually be achievable. It doesn't seem to be a huge | |
2936 | * problem at this time, | |
43143c8f DS |
2937 | * |
2938 | * It is possible that we have multiple paths for a prefix from a peer | |
2939 | * if that peer is using AddPath. | |
f2c31acb | 2940 | */ |
43143c8f DS |
2941 | ain = rn->adj_in; |
2942 | while (ain) | |
2943 | { | |
2944 | ain_next = ain->next; | |
2945 | ||
2a3d5731 | 2946 | if (ain->peer == peer) |
43143c8f DS |
2947 | { |
2948 | bgp_adj_in_remove (rn, ain); | |
2949 | bgp_unlock_node (rn); | |
2950 | } | |
2951 | ||
2952 | ain = ain_next; | |
2953 | } | |
3f9c7369 | 2954 | |
f2c31acb | 2955 | for (ri = rn->info; ri; ri = ri->next) |
2a3d5731 | 2956 | if (ri->peer == peer) |
f2c31acb | 2957 | { |
228da428 CC |
2958 | struct bgp_clear_node_queue *cnq; |
2959 | ||
2960 | /* both unlocked in bgp_clear_node_queue_del */ | |
67174041 | 2961 | bgp_table_lock (bgp_node_table (rn)); |
228da428 CC |
2962 | bgp_lock_node (rn); |
2963 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, | |
2964 | sizeof (struct bgp_clear_node_queue)); | |
2965 | cnq->rn = rn; | |
228da428 CC |
2966 | work_queue_add (peer->clear_node_queue, cnq); |
2967 | break; | |
f2c31acb | 2968 | } |
65ca75e0 PJ |
2969 | } |
2970 | return; | |
2971 | } | |
2972 | ||
2973 | void | |
2a3d5731 | 2974 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
65ca75e0 PJ |
2975 | { |
2976 | struct bgp_node *rn; | |
2977 | struct bgp_table *table; | |
6cf159b9 | 2978 | |
64e580a7 PJ |
2979 | if (peer->clear_node_queue == NULL) |
2980 | bgp_clear_node_queue_init (peer); | |
200df115 | 2981 | |
ca058a30 PJ |
2982 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
2983 | * Idle until it receives a Clearing_Completed event. This protects | |
2984 | * against peers which flap faster than we can we clear, which could | |
2985 | * lead to: | |
64e580a7 PJ |
2986 | * |
2987 | * a) race with routes from the new session being installed before | |
2988 | * clear_route_node visits the node (to delete the route of that | |
2989 | * peer) | |
2990 | * b) resource exhaustion, clear_route_node likely leads to an entry | |
2991 | * on the process_main queue. Fast-flapping could cause that queue | |
2992 | * to grow and grow. | |
200df115 | 2993 | */ |
dc83d712 DS |
2994 | |
2995 | /* lock peer in assumption that clear-node-queue will get nodes; if so, | |
2996 | * the unlock will happen upon work-queue completion; other wise, the | |
2997 | * unlock happens at the end of this function. | |
2998 | */ | |
ca058a30 | 2999 | if (!peer->clear_node_queue->thread) |
dc83d712 | 3000 | peer_lock (peer); |
fee0f4c6 | 3001 | |
587ff0fd | 3002 | if (safi != SAFI_MPLS_VPN && safi != SAFI_ENCAP) |
2a3d5731 DW |
3003 | bgp_clear_route_table (peer, afi, safi, NULL); |
3004 | else | |
3005 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
3006 | rn = bgp_route_next (rn)) | |
3007 | if ((table = rn->info) != NULL) | |
3008 | bgp_clear_route_table (peer, afi, safi, table); | |
dc83d712 DS |
3009 | |
3010 | /* unlock if no nodes got added to the clear-node-queue. */ | |
65ca75e0 | 3011 | if (!peer->clear_node_queue->thread) |
dc83d712 DS |
3012 | peer_unlock (peer); |
3013 | ||
718e3744 | 3014 | } |
3015 | ||
3016 | void | |
3017 | bgp_clear_route_all (struct peer *peer) | |
3018 | { | |
3019 | afi_t afi; | |
3020 | safi_t safi; | |
3021 | ||
3022 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3023 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2a3d5731 | 3024 | bgp_clear_route (peer, afi, safi); |
718e3744 | 3025 | } |
3026 | ||
3027 | void | |
3028 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) | |
3029 | { | |
3030 | struct bgp_table *table; | |
3031 | struct bgp_node *rn; | |
3032 | struct bgp_adj_in *ain; | |
43143c8f | 3033 | struct bgp_adj_in *ain_next; |
718e3744 | 3034 | |
3035 | table = peer->bgp->rib[afi][safi]; | |
3036 | ||
43143c8f DS |
3037 | /* It is possible that we have multiple paths for a prefix from a peer |
3038 | * if that peer is using AddPath. | |
3039 | */ | |
718e3744 | 3040 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
43143c8f DS |
3041 | { |
3042 | ain = rn->adj_in; | |
3043 | ||
3044 | while (ain) | |
3045 | { | |
3046 | ain_next = ain->next; | |
3047 | ||
3048 | if (ain->peer == peer) | |
3049 | { | |
3050 | bgp_adj_in_remove (rn, ain); | |
3051 | bgp_unlock_node (rn); | |
3052 | } | |
3053 | ||
3054 | ain = ain_next; | |
3055 | } | |
3056 | } | |
718e3744 | 3057 | } |
93406d87 | 3058 | |
3059 | void | |
3060 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) | |
3061 | { | |
3062 | struct bgp_node *rn; | |
3063 | struct bgp_info *ri; | |
3064 | struct bgp_table *table; | |
3065 | ||
3066 | table = peer->bgp->rib[afi][safi]; | |
3067 | ||
3068 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3069 | { | |
3070 | for (ri = rn->info; ri; ri = ri->next) | |
3071 | if (ri->peer == peer) | |
3072 | { | |
3073 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
3074 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
3075 | break; | |
3076 | } | |
3077 | } | |
3078 | } | |
6b0655a2 | 3079 | |
bb86c601 LB |
3080 | static void |
3081 | bgp_cleanup_table(struct bgp_table *table, safi_t safi) | |
3082 | { | |
3083 | struct bgp_node *rn; | |
3084 | struct bgp_info *ri; | |
3085 | struct bgp_info *next; | |
3086 | ||
3087 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3088 | for (ri = rn->info; ri; ri = next) | |
3089 | { | |
3090 | next = ri->next; | |
3091 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
3092 | && ri->type == ZEBRA_ROUTE_BGP | |
3093 | && (ri->sub_type == BGP_ROUTE_NORMAL || | |
3094 | ri->sub_type == BGP_ROUTE_AGGREGATE)) | |
3095 | bgp_zebra_withdraw (&rn->p, ri, safi); | |
3096 | } | |
3097 | } | |
3098 | ||
718e3744 | 3099 | /* Delete all kernel routes. */ |
3100 | void | |
66e5cd87 | 3101 | bgp_cleanup_routes (void) |
718e3744 | 3102 | { |
3103 | struct bgp *bgp; | |
1eb8ef25 | 3104 | struct listnode *node, *nnode; |
bb86c601 | 3105 | afi_t afi; |
718e3744 | 3106 | |
1eb8ef25 | 3107 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 3108 | { |
bb86c601 LB |
3109 | for (afi = AFI_IP; afi < AFI_MAX; ++afi) |
3110 | { | |
3111 | struct bgp_node *rn; | |
3112 | ||
3113 | bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST); | |
3114 | ||
3115 | /* | |
3116 | * VPN and ENCAP tables are two-level (RD is top level) | |
3117 | */ | |
3118 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn; | |
3119 | rn = bgp_route_next (rn)) | |
587ff0fd LB |
3120 | { |
3121 | if (rn->info) | |
bb86c601 | 3122 | { |
587ff0fd LB |
3123 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN); |
3124 | bgp_table_finish ((struct bgp_table **)&(rn->info)); | |
3125 | rn->info = NULL; | |
3126 | bgp_unlock_node(rn); | |
bb86c601 | 3127 | } |
587ff0fd LB |
3128 | } |
3129 | ||
3130 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn; | |
3131 | rn = bgp_route_next (rn)) | |
3132 | { | |
3133 | if (rn->info) | |
3134 | { | |
3135 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP); | |
3136 | bgp_table_finish ((struct bgp_table **)&(rn->info)); | |
3137 | rn->info = NULL; | |
3138 | bgp_unlock_node(rn); | |
3139 | } | |
3140 | } | |
bb86c601 | 3141 | } |
718e3744 | 3142 | } |
3143 | } | |
3144 | ||
3145 | void | |
66e5cd87 | 3146 | bgp_reset (void) |
718e3744 | 3147 | { |
3148 | vty_reset (); | |
3149 | bgp_zclient_reset (); | |
3150 | access_list_reset (); | |
3151 | prefix_list_reset (); | |
3152 | } | |
6b0655a2 | 3153 | |
adbac85e DW |
3154 | static int |
3155 | bgp_addpath_encode_rx (struct peer *peer, afi_t afi, safi_t safi) | |
3156 | { | |
3157 | return (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) && | |
3158 | CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)); | |
3159 | } | |
3160 | ||
718e3744 | 3161 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
3162 | value. */ | |
3163 | int | |
3164 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) | |
3165 | { | |
3166 | u_char *pnt; | |
3167 | u_char *lim; | |
3168 | struct prefix p; | |
3169 | int psize; | |
3170 | int ret; | |
a82478b9 DS |
3171 | afi_t afi; |
3172 | safi_t safi; | |
adbac85e | 3173 | int addpath_encoded; |
a82478b9 | 3174 | u_int32_t addpath_id; |
718e3744 | 3175 | |
3176 | /* Check peer status. */ | |
3177 | if (peer->status != Established) | |
3178 | return 0; | |
3179 | ||
3180 | pnt = packet->nlri; | |
3181 | lim = pnt + packet->length; | |
a82478b9 DS |
3182 | afi = packet->afi; |
3183 | safi = packet->safi; | |
3184 | addpath_id = 0; | |
adbac85e | 3185 | addpath_encoded = bgp_addpath_encode_rx (peer, afi, safi); |
718e3744 | 3186 | |
3187 | for (; pnt < lim; pnt += psize) | |
3188 | { | |
3189 | /* Clear prefix structure. */ | |
3190 | memset (&p, 0, sizeof (struct prefix)); | |
3191 | ||
a82478b9 DS |
3192 | if (addpath_encoded) |
3193 | { | |
cd808e74 DS |
3194 | |
3195 | /* When packet overflow occurs return immediately. */ | |
3196 | if (pnt + BGP_ADDPATH_ID_LEN > lim) | |
3197 | return -1; | |
3198 | ||
a82478b9 DS |
3199 | addpath_id = ntohl(*((uint32_t*) pnt)); |
3200 | pnt += BGP_ADDPATH_ID_LEN; | |
3201 | } | |
3202 | ||
718e3744 | 3203 | /* Fetch prefix length. */ |
3204 | p.prefixlen = *pnt++; | |
a82478b9 | 3205 | p.family = afi2family (afi); |
718e3744 | 3206 | |
3207 | /* Already checked in nlri_sanity_check(). We do double check | |
3208 | here. */ | |
a82478b9 DS |
3209 | if ((afi == AFI_IP && p.prefixlen > 32) |
3210 | || (afi == AFI_IP6 && p.prefixlen > 128)) | |
718e3744 | 3211 | return -1; |
3212 | ||
3213 | /* Packet size overflow check. */ | |
3214 | psize = PSIZE (p.prefixlen); | |
3215 | ||
3216 | /* When packet overflow occur return immediately. */ | |
3217 | if (pnt + psize > lim) | |
3218 | return -1; | |
3219 | ||
3220 | /* Fetch prefix from NLRI packet. */ | |
3221 | memcpy (&p.u.prefix, pnt, psize); | |
3222 | ||
3223 | /* Check address. */ | |
a82478b9 | 3224 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
718e3744 | 3225 | { |
3226 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) | |
3227 | { | |
f5ba3874 | 3228 | /* |
3229 | * From draft-ietf-idr-bgp4-22, Section 6.3: | |
3230 | * If a BGP router receives an UPDATE message with a | |
3231 | * semantically incorrect NLRI field, in which a prefix is | |
3232 | * semantically incorrect (eg. an unexpected multicast IP | |
3233 | * address), it should ignore the prefix. | |
3234 | */ | |
16286195 DS |
3235 | zlog_err ("IPv4 unicast NLRI is multicast address %s", |
3236 | inet_ntoa (p.u.prefix4)); | |
f5ba3874 | 3237 | |
718e3744 | 3238 | return -1; |
3239 | } | |
3240 | } | |
3241 | ||
3242 | #ifdef HAVE_IPV6 | |
3243 | /* Check address. */ | |
a82478b9 | 3244 | if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
718e3744 | 3245 | { |
3246 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3247 | { | |
3248 | char buf[BUFSIZ]; | |
3249 | ||
16286195 DS |
3250 | zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI", |
3251 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); | |
718e3744 | 3252 | |
3253 | continue; | |
3254 | } | |
3255 | } | |
3256 | #endif /* HAVE_IPV6 */ | |
3257 | ||
3258 | /* Normal process. */ | |
3259 | if (attr) | |
a82478b9 | 3260 | ret = bgp_update (peer, &p, addpath_id, attr, afi, safi, |
718e3744 | 3261 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
3262 | else | |
a82478b9 | 3263 | ret = bgp_withdraw (peer, &p, addpath_id, attr, afi, safi, |
718e3744 | 3264 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
3265 | ||
3266 | /* Address family configuration mismatch or maximum-prefix count | |
3267 | overflow. */ | |
3268 | if (ret < 0) | |
3269 | return -1; | |
3270 | } | |
3271 | ||
3272 | /* Packet length consistency check. */ | |
3273 | if (pnt != lim) | |
3274 | return -1; | |
3275 | ||
3276 | return 0; | |
3277 | } | |
3278 | ||
3279 | /* NLRI encode syntax check routine. */ | |
3280 | int | |
a82478b9 | 3281 | bgp_nlri_sanity_check (struct peer *peer, int afi, safi_t safi, u_char *pnt, |
d889623f | 3282 | bgp_size_t length, int *numpfx) |
718e3744 | 3283 | { |
3284 | u_char *end; | |
3285 | u_char prefixlen; | |
3286 | int psize; | |
adbac85e | 3287 | int addpath_encoded; |
718e3744 | 3288 | |
d889623f | 3289 | *numpfx = 0; |
718e3744 | 3290 | end = pnt + length; |
adbac85e | 3291 | addpath_encoded = bgp_addpath_encode_rx (peer, afi, safi); |
a82478b9 | 3292 | |
718e3744 | 3293 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
3294 | syntactic validity. If the field is syntactically incorrect, | |
3295 | then the Error Subcode is set to Invalid Network Field. */ | |
3296 | ||
3297 | while (pnt < end) | |
3298 | { | |
587ff0fd | 3299 | int badlength; |
cd808e74 | 3300 | |
a82478b9 DS |
3301 | /* If the NLRI is encoded using addpath then the first 4 bytes are |
3302 | * the addpath ID. */ | |
3303 | if (addpath_encoded) | |
cd808e74 DS |
3304 | { |
3305 | if (pnt + BGP_ADDPATH_ID_LEN > end) | |
3306 | { | |
3307 | zlog_err ("%s [Error] Update packet error" | |
3308 | " (prefix data addpath overflow)", | |
3309 | peer->host); | |
3310 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3311 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3312 | return -1; | |
3313 | } | |
3314 | pnt += BGP_ADDPATH_ID_LEN; | |
3315 | } | |
a82478b9 | 3316 | |
718e3744 | 3317 | prefixlen = *pnt++; |
3318 | ||
3319 | /* Prefix length check. */ | |
587ff0fd LB |
3320 | badlength = 0; |
3321 | if (safi == SAFI_ENCAP) { | |
3322 | if (prefixlen > 128) | |
3323 | badlength = 1; | |
3324 | } else { | |
3325 | if ((afi == AFI_IP && prefixlen > 32) || | |
3326 | (afi == AFI_IP6 && prefixlen > 128)) { | |
3327 | ||
3328 | badlength = 1; | |
3329 | } | |
3330 | } | |
3331 | if (badlength) | |
718e3744 | 3332 | { |
16286195 | 3333 | zlog_err ("%s [Error] Update packet error (wrong prefix length %d)", |
718e3744 | 3334 | peer->host, prefixlen); |
3335 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3336 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3337 | return -1; | |
3338 | } | |
3339 | ||
3340 | /* Packet size overflow check. */ | |
3341 | psize = PSIZE (prefixlen); | |
3342 | ||
3343 | if (pnt + psize > end) | |
3344 | { | |
16286195 | 3345 | zlog_err ("%s [Error] Update packet error" |
718e3744 | 3346 | " (prefix data overflow prefix size is %d)", |
3347 | peer->host, psize); | |
3348 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3349 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3350 | return -1; | |
3351 | } | |
3352 | ||
3353 | pnt += psize; | |
d889623f | 3354 | (*numpfx)++; |
718e3744 | 3355 | } |
3356 | ||
3357 | /* Packet length consistency check. */ | |
3358 | if (pnt != end) | |
3359 | { | |
16286195 | 3360 | zlog_err ("%s [Error] Update packet error" |
718e3744 | 3361 | " (prefix length mismatch with total length)", |
3362 | peer->host); | |
3363 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3364 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3365 | return -1; | |
3366 | } | |
3367 | return 0; | |
3368 | } | |
6b0655a2 | 3369 | |
94f2b392 | 3370 | static struct bgp_static * |
66e5cd87 | 3371 | bgp_static_new (void) |
718e3744 | 3372 | { |
393deb9b | 3373 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
718e3744 | 3374 | } |
3375 | ||
94f2b392 | 3376 | static void |
718e3744 | 3377 | bgp_static_free (struct bgp_static *bgp_static) |
3378 | { | |
3379 | if (bgp_static->rmap.name) | |
6e919709 | 3380 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
718e3744 | 3381 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
3382 | } | |
3383 | ||
94f2b392 | 3384 | static void |
2a3d5731 DW |
3385 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
3386 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
fee0f4c6 | 3387 | { |
3388 | struct bgp_node *rn; | |
3389 | struct bgp_info *ri; | |
2a3d5731 DW |
3390 | struct bgp_info *new; |
3391 | struct bgp_info info; | |
3392 | struct attr attr; | |
3393 | struct attr *attr_new; | |
3394 | int ret; | |
fee0f4c6 | 3395 | |
2a3d5731 DW |
3396 | assert (bgp_static); |
3397 | if (!bgp_static) | |
3398 | return; | |
dd8103a9 | 3399 | |
fee0f4c6 | 3400 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3401 | |
3402 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
dd8103a9 PJ |
3403 | |
3404 | attr.nexthop = bgp_static->igpnexthop; | |
3405 | attr.med = bgp_static->igpmetric; | |
3406 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
718e3744 | 3407 | |
41367172 PJ |
3408 | if (bgp_static->atomic) |
3409 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3410 | ||
718e3744 | 3411 | /* Apply route-map. */ |
3412 | if (bgp_static->rmap.name) | |
3413 | { | |
fb982c25 | 3414 | struct attr attr_tmp = attr; |
718e3744 | 3415 | info.peer = bgp->peer_self; |
286e1e71 | 3416 | info.attr = &attr_tmp; |
718e3744 | 3417 | |
fee0f4c6 | 3418 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3419 | ||
718e3744 | 3420 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
286e1e71 | 3421 | |
fee0f4c6 | 3422 | bgp->peer_self->rmap_type = 0; |
3423 | ||
718e3744 | 3424 | if (ret == RMAP_DENYMATCH) |
3425 | { | |
3426 | /* Free uninterned attribute. */ | |
286e1e71 | 3427 | bgp_attr_flush (&attr_tmp); |
718e3744 | 3428 | |
3429 | /* Unintern original. */ | |
f6f434b2 | 3430 | aspath_unintern (&attr.aspath); |
fb982c25 | 3431 | bgp_attr_extra_free (&attr); |
718e3744 | 3432 | bgp_static_withdraw (bgp, p, afi, safi); |
3433 | return; | |
3434 | } | |
286e1e71 | 3435 | attr_new = bgp_attr_intern (&attr_tmp); |
718e3744 | 3436 | } |
286e1e71 | 3437 | else |
3438 | attr_new = bgp_attr_intern (&attr); | |
718e3744 | 3439 | |
3440 | for (ri = rn->info; ri; ri = ri->next) | |
3441 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3442 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3443 | break; | |
3444 | ||
3445 | if (ri) | |
3446 | { | |
8d45210e | 3447 | if (attrhash_cmp (ri->attr, attr_new) && |
078430f6 DS |
3448 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) && |
3449 | !bgp_flag_check(bgp, BGP_FLAG_FORCE_STATIC_PROCESS)) | |
718e3744 | 3450 | { |
3451 | bgp_unlock_node (rn); | |
f6f434b2 PJ |
3452 | bgp_attr_unintern (&attr_new); |
3453 | aspath_unintern (&attr.aspath); | |
fb982c25 | 3454 | bgp_attr_extra_free (&attr); |
718e3744 | 3455 | return; |
3456 | } | |
3457 | else | |
3458 | { | |
3459 | /* The attribute is changed. */ | |
1a392d46 | 3460 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 3461 | |
3462 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3463 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3464 | bgp_info_restore(rn, ri); | |
3465 | else | |
3466 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
f6f434b2 | 3467 | bgp_attr_unintern (&ri->attr); |
718e3744 | 3468 | ri->attr = attr_new; |
65957886 | 3469 | ri->uptime = bgp_clock (); |
718e3744 | 3470 | |
fc9a856f DS |
3471 | /* Nexthop reachability check. */ |
3472 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3473 | { | |
75aead62 | 3474 | if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, 0)) |
fc9a856f DS |
3475 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
3476 | else | |
3477 | { | |
3478 | if (BGP_DEBUG(nht, NHT)) | |
3479 | { | |
3480 | char buf1[INET6_ADDRSTRLEN]; | |
078430f6 DS |
3481 | inet_ntop(p->family, &p->u.prefix, buf1, |
3482 | INET6_ADDRSTRLEN); | |
3483 | zlog_debug("%s(%s): Route not in table, not advertising", | |
3484 | __FUNCTION__, buf1); | |
fc9a856f DS |
3485 | } |
3486 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); | |
3487 | } | |
3488 | } | |
078430f6 DS |
3489 | else |
3490 | { | |
3491 | /* Delete the NHT structure if any, if we're toggling between | |
3492 | * enabling/disabling import check. We deregister the route | |
3493 | * from NHT to avoid overloading NHT and the process interaction | |
3494 | */ | |
3495 | bgp_unlink_nexthop(ri); | |
3496 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); | |
3497 | } | |
718e3744 | 3498 | /* Process change. */ |
3499 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
3500 | bgp_process (bgp, rn, afi, safi); | |
3501 | bgp_unlock_node (rn); | |
f6f434b2 | 3502 | aspath_unintern (&attr.aspath); |
fb982c25 | 3503 | bgp_attr_extra_free (&attr); |
718e3744 | 3504 | return; |
3505 | } | |
3506 | } | |
3507 | ||
3508 | /* Make new BGP info. */ | |
7c8ff89e | 3509 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self, attr_new, |
fb018d25 | 3510 | rn); |
fc9a856f DS |
3511 | /* Nexthop reachability check. */ |
3512 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3513 | { | |
75aead62 | 3514 | if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, 0)) |
fc9a856f DS |
3515 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
3516 | else | |
3517 | { | |
3518 | if (BGP_DEBUG(nht, NHT)) | |
3519 | { | |
3520 | char buf1[INET6_ADDRSTRLEN]; | |
078430f6 | 3521 | inet_ntop(p->family, &p->u.prefix, buf1, |
fc9a856f | 3522 | INET6_ADDRSTRLEN); |
078430f6 DS |
3523 | zlog_debug("%s(%s): Route not in table, not advertising", |
3524 | __FUNCTION__, buf1); | |
fc9a856f DS |
3525 | } |
3526 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); | |
3527 | } | |
3528 | } | |
3529 | else | |
078430f6 DS |
3530 | { |
3531 | /* Delete the NHT structure if any, if we're toggling between | |
3532 | * enabling/disabling import check. We deregister the route | |
3533 | * from NHT to avoid overloading NHT and the process interaction | |
3534 | */ | |
3535 | bgp_unlink_nexthop(new); | |
3536 | ||
3537 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); | |
3538 | } | |
718e3744 | 3539 | |
3540 | /* Aggregate address increment. */ | |
3541 | bgp_aggregate_increment (bgp, p, new, afi, safi); | |
3542 | ||
3543 | /* Register new BGP information. */ | |
3544 | bgp_info_add (rn, new); | |
200df115 | 3545 | |
3546 | /* route_node_get lock */ | |
3547 | bgp_unlock_node (rn); | |
3548 | ||
718e3744 | 3549 | /* Process change. */ |
3550 | bgp_process (bgp, rn, afi, safi); | |
3551 | ||
3552 | /* Unintern original. */ | |
f6f434b2 | 3553 | aspath_unintern (&attr.aspath); |
fb982c25 | 3554 | bgp_attr_extra_free (&attr); |
718e3744 | 3555 | } |
3556 | ||
fee0f4c6 | 3557 | void |
3558 | bgp_static_update (struct bgp *bgp, struct prefix *p, | |
3559 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
3560 | { | |
fee0f4c6 | 3561 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
fee0f4c6 | 3562 | } |
3563 | ||
718e3744 | 3564 | void |
3565 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, | |
3566 | safi_t safi) | |
3567 | { | |
3568 | struct bgp_node *rn; | |
3569 | struct bgp_info *ri; | |
3570 | ||
fee0f4c6 | 3571 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3572 | |
3573 | /* Check selected route and self inserted route. */ | |
3574 | for (ri = rn->info; ri; ri = ri->next) | |
3575 | if (ri->peer == bgp->peer_self | |
3576 | && ri->type == ZEBRA_ROUTE_BGP | |
3577 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3578 | break; | |
3579 | ||
3580 | /* Withdraw static BGP route from routing table. */ | |
3581 | if (ri) | |
3582 | { | |
3583 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
fc9a856f | 3584 | bgp_unlink_nexthop(ri); |
718e3744 | 3585 | bgp_info_delete (rn, ri); |
1a392d46 | 3586 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3587 | } |
3588 | ||
3589 | /* Unlock bgp_node_lookup. */ | |
3590 | bgp_unlock_node (rn); | |
3591 | } | |
3592 | ||
137446f9 LB |
3593 | /* |
3594 | * Used for SAFI_MPLS_VPN and SAFI_ENCAP | |
3595 | */ | |
94f2b392 | 3596 | static void |
137446f9 LB |
3597 | bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi, |
3598 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3599 | { |
3600 | struct bgp_node *rn; | |
3601 | struct bgp_info *ri; | |
3602 | ||
fee0f4c6 | 3603 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3604 | |
3605 | /* Check selected route and self inserted route. */ | |
3606 | for (ri = rn->info; ri; ri = ri->next) | |
3607 | if (ri->peer == bgp->peer_self | |
3608 | && ri->type == ZEBRA_ROUTE_BGP | |
3609 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3610 | break; | |
3611 | ||
3612 | /* Withdraw static BGP route from routing table. */ | |
3613 | if (ri) | |
3614 | { | |
3615 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3616 | bgp_info_delete (rn, ri); |
1a392d46 | 3617 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3618 | } |
3619 | ||
3620 | /* Unlock bgp_node_lookup. */ | |
3621 | bgp_unlock_node (rn); | |
3622 | } | |
3623 | ||
137446f9 LB |
3624 | static void |
3625 | bgp_static_update_safi (struct bgp *bgp, struct prefix *p, | |
3626 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
3627 | { | |
3628 | struct bgp_node *rn; | |
3629 | struct bgp_info *new; | |
3630 | struct attr *attr_new; | |
3631 | struct attr attr = { 0 }; | |
3632 | struct bgp_info *ri; | |
3633 | ||
3634 | assert (bgp_static); | |
3635 | ||
3636 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd); | |
3637 | ||
3638 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
3639 | ||
3640 | attr.nexthop = bgp_static->igpnexthop; | |
3641 | attr.med = bgp_static->igpmetric; | |
3642 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
3643 | ||
3644 | /* Apply route-map. */ | |
3645 | if (bgp_static->rmap.name) | |
3646 | { | |
3647 | struct attr attr_tmp = attr; | |
3648 | struct bgp_info info; | |
3649 | int ret; | |
3650 | ||
3651 | info.peer = bgp->peer_self; | |
3652 | info.attr = &attr_tmp; | |
3653 | ||
3654 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); | |
3655 | ||
3656 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); | |
3657 | ||
3658 | bgp->peer_self->rmap_type = 0; | |
3659 | ||
3660 | if (ret == RMAP_DENYMATCH) | |
3661 | { | |
3662 | /* Free uninterned attribute. */ | |
3663 | bgp_attr_flush (&attr_tmp); | |
3664 | ||
3665 | /* Unintern original. */ | |
3666 | aspath_unintern (&attr.aspath); | |
3667 | bgp_attr_extra_free (&attr); | |
3668 | bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd, | |
3669 | bgp_static->tag); | |
3670 | return; | |
3671 | } | |
3672 | ||
3673 | attr_new = bgp_attr_intern (&attr_tmp); | |
3674 | } | |
3675 | else | |
3676 | { | |
3677 | attr_new = bgp_attr_intern (&attr); | |
3678 | } | |
3679 | ||
3680 | for (ri = rn->info; ri; ri = ri->next) | |
3681 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3682 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3683 | break; | |
3684 | ||
3685 | if (ri) | |
3686 | { | |
3687 | if (attrhash_cmp (ri->attr, attr_new) && | |
3688 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
3689 | { | |
3690 | bgp_unlock_node (rn); | |
3691 | bgp_attr_unintern (&attr_new); | |
3692 | aspath_unintern (&attr.aspath); | |
3693 | bgp_attr_extra_free (&attr); | |
3694 | return; | |
3695 | } | |
3696 | else | |
3697 | { | |
3698 | /* The attribute is changed. */ | |
3699 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); | |
3700 | ||
3701 | /* Rewrite BGP route information. */ | |
3702 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
3703 | bgp_info_restore(rn, ri); | |
3704 | else | |
3705 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
3706 | bgp_attr_unintern (&ri->attr); | |
3707 | ri->attr = attr_new; | |
3708 | ri->uptime = bgp_clock (); | |
3709 | ||
3710 | /* Process change. */ | |
3711 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
3712 | bgp_process (bgp, rn, afi, safi); | |
3713 | bgp_unlock_node (rn); | |
3714 | aspath_unintern (&attr.aspath); | |
3715 | bgp_attr_extra_free (&attr); | |
3716 | return; | |
3717 | } | |
3718 | } | |
3719 | ||
3720 | ||
3721 | /* Make new BGP info. */ | |
3722 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self, attr_new, | |
3723 | rn); | |
3724 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3725 | new->extra = bgp_info_extra_new(); | |
3726 | memcpy (new->extra->tag, bgp_static->tag, 3); | |
3727 | ||
3728 | /* Aggregate address increment. */ | |
3729 | bgp_aggregate_increment (bgp, p, new, afi, safi); | |
3730 | ||
3731 | /* Register new BGP information. */ | |
3732 | bgp_info_add (rn, new); | |
3733 | ||
3734 | /* route_node_get lock */ | |
3735 | bgp_unlock_node (rn); | |
3736 | ||
3737 | /* Process change. */ | |
3738 | bgp_process (bgp, rn, afi, safi); | |
3739 | ||
3740 | /* Unintern original. */ | |
3741 | aspath_unintern (&attr.aspath); | |
3742 | bgp_attr_extra_free (&attr); | |
3743 | } | |
3744 | ||
718e3744 | 3745 | /* Configure static BGP network. When user don't run zebra, static |
3746 | route should be installed as valid. */ | |
94f2b392 | 3747 | static int |
fd79ac91 | 3748 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
c8f3fe30 | 3749 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
718e3744 | 3750 | { |
3751 | int ret; | |
3752 | struct prefix p; | |
3753 | struct bgp_static *bgp_static; | |
3754 | struct bgp_node *rn; | |
41367172 | 3755 | u_char need_update = 0; |
718e3744 | 3756 | |
3757 | /* Convert IP prefix string to struct prefix. */ | |
3758 | ret = str2prefix (ip_str, &p); | |
3759 | if (! ret) | |
3760 | { | |
3761 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3762 | return CMD_WARNING; | |
3763 | } | |
3764 | #ifdef HAVE_IPV6 | |
3765 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3766 | { | |
3767 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3768 | VTY_NEWLINE); | |
3769 | return CMD_WARNING; | |
3770 | } | |
3771 | #endif /* HAVE_IPV6 */ | |
3772 | ||
3773 | apply_mask (&p); | |
3774 | ||
3775 | /* Set BGP static route configuration. */ | |
3776 | rn = bgp_node_get (bgp->route[afi][safi], &p); | |
3777 | ||
3778 | if (rn->info) | |
3779 | { | |
3780 | /* Configuration change. */ | |
3781 | bgp_static = rn->info; | |
3782 | ||
3783 | /* Check previous routes are installed into BGP. */ | |
c8f3fe30 PJ |
3784 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
3785 | need_update = 1; | |
41367172 | 3786 | |
718e3744 | 3787 | bgp_static->backdoor = backdoor; |
41367172 | 3788 | |
718e3744 | 3789 | if (rmap) |
3790 | { | |
3791 | if (bgp_static->rmap.name) | |
6e919709 DS |
3792 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
3793 | bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap); | |
718e3744 | 3794 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
3795 | } | |
3796 | else | |
3797 | { | |
3798 | if (bgp_static->rmap.name) | |
6e919709 | 3799 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
718e3744 | 3800 | bgp_static->rmap.name = NULL; |
3801 | bgp_static->rmap.map = NULL; | |
3802 | bgp_static->valid = 0; | |
3803 | } | |
3804 | bgp_unlock_node (rn); | |
3805 | } | |
3806 | else | |
3807 | { | |
3808 | /* New configuration. */ | |
3809 | bgp_static = bgp_static_new (); | |
3810 | bgp_static->backdoor = backdoor; | |
3811 | bgp_static->valid = 0; | |
3812 | bgp_static->igpmetric = 0; | |
3813 | bgp_static->igpnexthop.s_addr = 0; | |
41367172 | 3814 | |
718e3744 | 3815 | if (rmap) |
3816 | { | |
3817 | if (bgp_static->rmap.name) | |
6e919709 DS |
3818 | XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); |
3819 | bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap); | |
718e3744 | 3820 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
3821 | } | |
3822 | rn->info = bgp_static; | |
3823 | } | |
3824 | ||
fc9a856f DS |
3825 | bgp_static->valid = 1; |
3826 | if (need_update) | |
3827 | bgp_static_withdraw (bgp, &p, afi, safi); | |
718e3744 | 3828 | |
fc9a856f DS |
3829 | if (! bgp_static->backdoor) |
3830 | bgp_static_update (bgp, &p, bgp_static, afi, safi); | |
718e3744 | 3831 | |
3832 | return CMD_SUCCESS; | |
3833 | } | |
3834 | ||
3835 | /* Configure static BGP network. */ | |
94f2b392 | 3836 | static int |
fd79ac91 | 3837 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
4c9641ba | 3838 | afi_t afi, safi_t safi) |
718e3744 | 3839 | { |
3840 | int ret; | |
3841 | struct prefix p; | |
3842 | struct bgp_static *bgp_static; | |
3843 | struct bgp_node *rn; | |
3844 | ||
3845 | /* Convert IP prefix string to struct prefix. */ | |
3846 | ret = str2prefix (ip_str, &p); | |
3847 | if (! ret) | |
3848 | { | |
3849 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3850 | return CMD_WARNING; | |
3851 | } | |
3852 | #ifdef HAVE_IPV6 | |
3853 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3854 | { | |
3855 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3856 | VTY_NEWLINE); | |
3857 | return CMD_WARNING; | |
3858 | } | |
3859 | #endif /* HAVE_IPV6 */ | |
3860 | ||
3861 | apply_mask (&p); | |
3862 | ||
3863 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); | |
3864 | if (! rn) | |
3865 | { | |
3866 | vty_out (vty, "%% Can't find specified static route configuration.%s", | |
3867 | VTY_NEWLINE); | |
3868 | return CMD_WARNING; | |
3869 | } | |
3870 | ||
3871 | bgp_static = rn->info; | |
41367172 | 3872 | |
718e3744 | 3873 | /* Update BGP RIB. */ |
3874 | if (! bgp_static->backdoor) | |
3875 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3876 | ||
3877 | /* Clear configuration. */ | |
3878 | bgp_static_free (bgp_static); | |
3879 | rn->info = NULL; | |
3880 | bgp_unlock_node (rn); | |
3881 | bgp_unlock_node (rn); | |
3882 | ||
3883 | return CMD_SUCCESS; | |
3884 | } | |
3885 | ||
6aeb9e78 DS |
3886 | void |
3887 | bgp_static_add (struct bgp *bgp) | |
3888 | { | |
3889 | afi_t afi; | |
3890 | safi_t safi; | |
3891 | struct bgp_node *rn; | |
3892 | struct bgp_node *rm; | |
3893 | struct bgp_table *table; | |
3894 | struct bgp_static *bgp_static; | |
3895 | ||
3896 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3897 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3898 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3899 | if (rn->info != NULL) | |
3900 | { | |
3901 | if (safi == SAFI_MPLS_VPN) | |
3902 | { | |
3903 | table = rn->info; | |
3904 | ||
3905 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3906 | { | |
3907 | bgp_static = rn->info; | |
137446f9 | 3908 | bgp_static_update_safi (bgp, &rm->p, bgp_static, afi, safi); |
6aeb9e78 DS |
3909 | } |
3910 | } | |
3911 | else | |
3912 | { | |
3913 | bgp_static_update (bgp, &rn->p, rn->info, afi, safi); | |
3914 | } | |
3915 | } | |
3916 | } | |
3917 | ||
718e3744 | 3918 | /* Called from bgp_delete(). Delete all static routes from the BGP |
3919 | instance. */ | |
3920 | void | |
3921 | bgp_static_delete (struct bgp *bgp) | |
3922 | { | |
3923 | afi_t afi; | |
3924 | safi_t safi; | |
3925 | struct bgp_node *rn; | |
3926 | struct bgp_node *rm; | |
3927 | struct bgp_table *table; | |
3928 | struct bgp_static *bgp_static; | |
3929 | ||
3930 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3931 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3932 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3933 | if (rn->info != NULL) | |
3934 | { | |
587ff0fd | 3935 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 3936 | { |
3937 | table = rn->info; | |
3938 | ||
3939 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3940 | { | |
3941 | bgp_static = rn->info; | |
137446f9 LB |
3942 | bgp_static_withdraw_safi (bgp, &rm->p, |
3943 | AFI_IP, safi, | |
718e3744 | 3944 | (struct prefix_rd *)&rn->p, |
3945 | bgp_static->tag); | |
3946 | bgp_static_free (bgp_static); | |
3947 | rn->info = NULL; | |
3948 | bgp_unlock_node (rn); | |
3949 | } | |
3950 | } | |
3951 | else | |
3952 | { | |
3953 | bgp_static = rn->info; | |
3954 | bgp_static_withdraw (bgp, &rn->p, afi, safi); | |
3955 | bgp_static_free (bgp_static); | |
3956 | rn->info = NULL; | |
3957 | bgp_unlock_node (rn); | |
3958 | } | |
3959 | } | |
3960 | } | |
3961 | ||
078430f6 DS |
3962 | void |
3963 | bgp_static_redo_import_check (struct bgp *bgp) | |
3964 | { | |
3965 | afi_t afi; | |
3966 | safi_t safi; | |
3967 | struct bgp_node *rn; | |
078430f6 DS |
3968 | struct bgp_static *bgp_static; |
3969 | ||
3970 | /* Use this flag to force reprocessing of the route */ | |
3971 | bgp_flag_set(bgp, BGP_FLAG_FORCE_STATIC_PROCESS); | |
3972 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3973 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3974 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3975 | if (rn->info != NULL) | |
3976 | { | |
3977 | bgp_static = rn->info; | |
3978 | bgp_static_update (bgp, &rn->p, bgp_static, afi, safi); | |
3979 | } | |
3980 | bgp_flag_unset(bgp, BGP_FLAG_FORCE_STATIC_PROCESS); | |
3981 | } | |
3982 | ||
ad4cbda1 | 3983 | static void |
3984 | bgp_purge_af_static_redist_routes (struct bgp *bgp, afi_t afi, safi_t safi) | |
3985 | { | |
3986 | struct bgp_table *table; | |
3987 | struct bgp_node *rn; | |
3988 | struct bgp_info *ri; | |
3989 | ||
3990 | table = bgp->rib[afi][safi]; | |
3991 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
3992 | { | |
3993 | for (ri = rn->info; ri; ri = ri->next) | |
3994 | { | |
3995 | if (ri->peer == bgp->peer_self && | |
3996 | ((ri->type == ZEBRA_ROUTE_BGP && | |
3997 | ri->sub_type == BGP_ROUTE_STATIC) || | |
3998 | (ri->type != ZEBRA_ROUTE_BGP && | |
3999 | ri->sub_type == BGP_ROUTE_REDISTRIBUTE))) | |
4000 | { | |
4001 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, safi); | |
4002 | bgp_unlink_nexthop(ri); | |
4003 | bgp_info_delete (rn, ri); | |
4004 | bgp_process (bgp, rn, afi, safi); | |
4005 | } | |
4006 | } | |
4007 | } | |
4008 | } | |
4009 | ||
4010 | /* | |
4011 | * Purge all networks and redistributed routes from routing table. | |
4012 | * Invoked upon the instance going down. | |
4013 | */ | |
4014 | void | |
4015 | bgp_purge_static_redist_routes (struct bgp *bgp) | |
4016 | { | |
4017 | afi_t afi; | |
4018 | safi_t safi; | |
4019 | ||
4020 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
4021 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
4022 | bgp_purge_af_static_redist_routes (bgp, afi, safi); | |
4023 | } | |
4024 | ||
137446f9 LB |
4025 | /* |
4026 | * gpz 110624 | |
4027 | * Currently this is used to set static routes for VPN and ENCAP. | |
4028 | * I think it can probably be factored with bgp_static_set. | |
4029 | */ | |
718e3744 | 4030 | int |
137446f9 LB |
4031 | bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, |
4032 | const char *rd_str, const char *tag_str, | |
4033 | const char *rmap_str) | |
718e3744 | 4034 | { |
4035 | int ret; | |
4036 | struct prefix p; | |
4037 | struct prefix_rd prd; | |
4038 | struct bgp *bgp; | |
4039 | struct bgp_node *prn; | |
4040 | struct bgp_node *rn; | |
4041 | struct bgp_table *table; | |
4042 | struct bgp_static *bgp_static; | |
4043 | u_char tag[3]; | |
4044 | ||
4045 | bgp = vty->index; | |
4046 | ||
4047 | ret = str2prefix (ip_str, &p); | |
4048 | if (! ret) | |
4049 | { | |
4050 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
4051 | return CMD_WARNING; | |
4052 | } | |
4053 | apply_mask (&p); | |
4054 | ||
4055 | ret = str2prefix_rd (rd_str, &prd); | |
4056 | if (! ret) | |
4057 | { | |
4058 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
4059 | return CMD_WARNING; | |
4060 | } | |
4061 | ||
4062 | ret = str2tag (tag_str, tag); | |
4063 | if (! ret) | |
4064 | { | |
4065 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
4066 | return CMD_WARNING; | |
4067 | } | |
4068 | ||
137446f9 | 4069 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
718e3744 | 4070 | (struct prefix *)&prd); |
4071 | if (prn->info == NULL) | |
137446f9 | 4072 | prn->info = bgp_table_init (AFI_IP, safi); |
718e3744 | 4073 | else |
4074 | bgp_unlock_node (prn); | |
4075 | table = prn->info; | |
4076 | ||
4077 | rn = bgp_node_get (table, &p); | |
4078 | ||
4079 | if (rn->info) | |
4080 | { | |
4081 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); | |
4082 | bgp_unlock_node (rn); | |
4083 | } | |
4084 | else | |
4085 | { | |
4086 | /* New configuration. */ | |
4087 | bgp_static = bgp_static_new (); | |
137446f9 LB |
4088 | bgp_static->backdoor = 0; |
4089 | bgp_static->valid = 0; | |
4090 | bgp_static->igpmetric = 0; | |
4091 | bgp_static->igpnexthop.s_addr = 0; | |
4092 | memcpy(bgp_static->tag, tag, 3); | |
4093 | bgp_static->prd = prd; | |
4094 | ||
4095 | if (rmap_str) | |
4096 | { | |
4097 | if (bgp_static->rmap.name) | |
4098 | free (bgp_static->rmap.name); | |
4099 | bgp_static->rmap.name = strdup (rmap_str); | |
4100 | bgp_static->rmap.map = route_map_lookup_by_name (rmap_str); | |
4101 | } | |
718e3744 | 4102 | rn->info = bgp_static; |
4103 | ||
137446f9 LB |
4104 | bgp_static->valid = 1; |
4105 | bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); | |
718e3744 | 4106 | } |
4107 | ||
4108 | return CMD_SUCCESS; | |
4109 | } | |
4110 | ||
4111 | /* Configure static BGP network. */ | |
4112 | int | |
137446f9 LB |
4113 | bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str, |
4114 | const char *rd_str, const char *tag_str) | |
718e3744 | 4115 | { |
4116 | int ret; | |
4117 | struct bgp *bgp; | |
4118 | struct prefix p; | |
4119 | struct prefix_rd prd; | |
4120 | struct bgp_node *prn; | |
4121 | struct bgp_node *rn; | |
4122 | struct bgp_table *table; | |
4123 | struct bgp_static *bgp_static; | |
4124 | u_char tag[3]; | |
4125 | ||
4126 | bgp = vty->index; | |
4127 | ||
4128 | /* Convert IP prefix string to struct prefix. */ | |
4129 | ret = str2prefix (ip_str, &p); | |
4130 | if (! ret) | |
4131 | { | |
4132 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
4133 | return CMD_WARNING; | |
4134 | } | |
4135 | apply_mask (&p); | |
4136 | ||
4137 | ret = str2prefix_rd (rd_str, &prd); | |
4138 | if (! ret) | |
4139 | { | |
4140 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
4141 | return CMD_WARNING; | |
4142 | } | |
4143 | ||
4144 | ret = str2tag (tag_str, tag); | |
4145 | if (! ret) | |
4146 | { | |
4147 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
4148 | return CMD_WARNING; | |
4149 | } | |
4150 | ||
137446f9 | 4151 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
718e3744 | 4152 | (struct prefix *)&prd); |
4153 | if (prn->info == NULL) | |
137446f9 | 4154 | prn->info = bgp_table_init (AFI_IP, safi); |
718e3744 | 4155 | else |
4156 | bgp_unlock_node (prn); | |
4157 | table = prn->info; | |
4158 | ||
4159 | rn = bgp_node_lookup (table, &p); | |
4160 | ||
4161 | if (rn) | |
4162 | { | |
137446f9 | 4163 | bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag); |
718e3744 | 4164 | |
4165 | bgp_static = rn->info; | |
4166 | bgp_static_free (bgp_static); | |
4167 | rn->info = NULL; | |
4168 | bgp_unlock_node (rn); | |
4169 | bgp_unlock_node (rn); | |
4170 | } | |
4171 | else | |
4172 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); | |
4173 | ||
4174 | return CMD_SUCCESS; | |
4175 | } | |
6b0655a2 | 4176 | |
73ac8160 DS |
4177 | static int |
4178 | bgp_table_map_set (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
4179 | const char *rmap_name) | |
4180 | { | |
4181 | struct bgp_rmap *rmap; | |
4182 | ||
4183 | rmap = &bgp->table_map[afi][safi]; | |
4184 | if (rmap_name) | |
4185 | { | |
4186 | if (rmap->name) | |
6e919709 DS |
4187 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); |
4188 | rmap->name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_name); | |
73ac8160 DS |
4189 | rmap->map = route_map_lookup_by_name (rmap_name); |
4190 | } | |
4191 | else | |
4192 | { | |
4193 | if (rmap->name) | |
6e919709 | 4194 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); |
73ac8160 DS |
4195 | rmap->name = NULL; |
4196 | rmap->map = NULL; | |
4197 | } | |
4198 | ||
4199 | bgp_zebra_announce_table(bgp, afi, safi); | |
4200 | ||
4201 | return CMD_SUCCESS; | |
4202 | } | |
4203 | ||
4204 | static int | |
4205 | bgp_table_map_unset (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
4206 | const char *rmap_name) | |
4207 | { | |
4208 | struct bgp_rmap *rmap; | |
4209 | ||
4210 | rmap = &bgp->table_map[afi][safi]; | |
4211 | if (rmap->name) | |
6e919709 | 4212 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name); |
73ac8160 DS |
4213 | rmap->name = NULL; |
4214 | rmap->map = NULL; | |
4215 | ||
4216 | bgp_zebra_announce_table(bgp, afi, safi); | |
4217 | ||
4218 | return CMD_SUCCESS; | |
4219 | } | |
4220 | ||
4221 | int | |
4222 | bgp_config_write_table_map (struct vty *vty, struct bgp *bgp, afi_t afi, | |
4223 | safi_t safi, int *write) | |
4224 | { | |
4225 | if (bgp->table_map[afi][safi].name) | |
4226 | { | |
4227 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 4228 | vty_out (vty, " table-map %s%s", |
73ac8160 DS |
4229 | bgp->table_map[afi][safi].name, VTY_NEWLINE); |
4230 | } | |
4231 | ||
4232 | return 0; | |
4233 | } | |
4234 | ||
4235 | ||
4236 | DEFUN (bgp_table_map, | |
4237 | bgp_table_map_cmd, | |
4238 | "table-map WORD", | |
4239 | "BGP table to RIB route download filter\n" | |
4240 | "Name of the route map\n") | |
4241 | { | |
4242 | return bgp_table_map_set (vty, vty->index, | |
4243 | bgp_node_afi (vty), bgp_node_safi (vty), argv[0]); | |
4244 | } | |
4245 | DEFUN (no_bgp_table_map, | |
4246 | no_bgp_table_map_cmd, | |
4247 | "no table-map WORD", | |
4248 | "BGP table to RIB route download filter\n" | |
4249 | "Name of the route map\n") | |
4250 | { | |
4251 | return bgp_table_map_unset (vty, vty->index, | |
4252 | bgp_node_afi (vty), bgp_node_safi (vty), argv[0]); | |
4253 | } | |
4254 | ||
718e3744 | 4255 | DEFUN (bgp_network, |
4256 | bgp_network_cmd, | |
4257 | "network A.B.C.D/M", | |
4258 | "Specify a network to announce via BGP\n" | |
4259 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4260 | { | |
4261 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 4262 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4263 | } |
4264 | ||
4265 | DEFUN (bgp_network_route_map, | |
4266 | bgp_network_route_map_cmd, | |
4267 | "network A.B.C.D/M route-map WORD", | |
4268 | "Specify a network to announce via BGP\n" | |
4269 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4270 | "Route-map to modify the attributes\n" | |
4271 | "Name of the route map\n") | |
4272 | { | |
4273 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 4274 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4275 | } |
4276 | ||
4277 | DEFUN (bgp_network_backdoor, | |
4278 | bgp_network_backdoor_cmd, | |
4279 | "network A.B.C.D/M backdoor", | |
4280 | "Specify a network to announce via BGP\n" | |
4281 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4282 | "Specify a BGP backdoor route\n") | |
4283 | { | |
41367172 | 4284 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4285 | NULL, 1); |
718e3744 | 4286 | } |
4287 | ||
4288 | DEFUN (bgp_network_mask, | |
4289 | bgp_network_mask_cmd, | |
4290 | "network A.B.C.D mask A.B.C.D", | |
4291 | "Specify a network to announce via BGP\n" | |
4292 | "Network number\n" | |
4293 | "Network mask\n" | |
4294 | "Network mask\n") | |
4295 | { | |
4296 | int ret; | |
4297 | char prefix_str[BUFSIZ]; | |
41367172 | 4298 | |
718e3744 | 4299 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4300 | if (! ret) | |
4301 | { | |
4302 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4303 | return CMD_WARNING; | |
4304 | } | |
4305 | ||
4306 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4307 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4308 | } |
4309 | ||
4310 | DEFUN (bgp_network_mask_route_map, | |
4311 | bgp_network_mask_route_map_cmd, | |
4312 | "network A.B.C.D mask A.B.C.D route-map WORD", | |
4313 | "Specify a network to announce via BGP\n" | |
4314 | "Network number\n" | |
4315 | "Network mask\n" | |
4316 | "Network mask\n" | |
4317 | "Route-map to modify the attributes\n" | |
4318 | "Name of the route map\n") | |
4319 | { | |
4320 | int ret; | |
4321 | char prefix_str[BUFSIZ]; | |
41367172 | 4322 | |
718e3744 | 4323 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4324 | if (! ret) | |
4325 | { | |
4326 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4327 | return CMD_WARNING; | |
4328 | } | |
4329 | ||
4330 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4331 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
718e3744 | 4332 | } |
4333 | ||
4334 | DEFUN (bgp_network_mask_backdoor, | |
4335 | bgp_network_mask_backdoor_cmd, | |
4336 | "network A.B.C.D mask A.B.C.D backdoor", | |
4337 | "Specify a network to announce via BGP\n" | |
4338 | "Network number\n" | |
4339 | "Network mask\n" | |
4340 | "Network mask\n" | |
4341 | "Specify a BGP backdoor route\n") | |
4342 | { | |
4343 | int ret; | |
4344 | char prefix_str[BUFSIZ]; | |
41367172 | 4345 | |
718e3744 | 4346 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4347 | if (! ret) | |
4348 | { | |
4349 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4350 | return CMD_WARNING; | |
4351 | } | |
4352 | ||
41367172 | 4353 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4354 | NULL, 1); |
718e3744 | 4355 | } |
4356 | ||
4357 | DEFUN (bgp_network_mask_natural, | |
4358 | bgp_network_mask_natural_cmd, | |
4359 | "network A.B.C.D", | |
4360 | "Specify a network to announce via BGP\n" | |
4361 | "Network number\n") | |
4362 | { | |
4363 | int ret; | |
4364 | char prefix_str[BUFSIZ]; | |
4365 | ||
4366 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4367 | if (! ret) | |
4368 | { | |
4369 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4370 | return CMD_WARNING; | |
4371 | } | |
4372 | ||
4373 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4374 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4375 | } |
4376 | ||
4377 | DEFUN (bgp_network_mask_natural_route_map, | |
4378 | bgp_network_mask_natural_route_map_cmd, | |
4379 | "network A.B.C.D route-map WORD", | |
4380 | "Specify a network to announce via BGP\n" | |
4381 | "Network number\n" | |
4382 | "Route-map to modify the attributes\n" | |
4383 | "Name of the route map\n") | |
4384 | { | |
4385 | int ret; | |
4386 | char prefix_str[BUFSIZ]; | |
4387 | ||
4388 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4389 | if (! ret) | |
4390 | { | |
4391 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4392 | return CMD_WARNING; | |
4393 | } | |
4394 | ||
4395 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4396 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4397 | } |
4398 | ||
4399 | DEFUN (bgp_network_mask_natural_backdoor, | |
4400 | bgp_network_mask_natural_backdoor_cmd, | |
4401 | "network A.B.C.D backdoor", | |
4402 | "Specify a network to announce via BGP\n" | |
4403 | "Network number\n" | |
4404 | "Specify a BGP backdoor route\n") | |
4405 | { | |
4406 | int ret; | |
4407 | char prefix_str[BUFSIZ]; | |
4408 | ||
4409 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4410 | if (! ret) | |
4411 | { | |
4412 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4413 | return CMD_WARNING; | |
4414 | } | |
4415 | ||
41367172 | 4416 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4417 | NULL, 1); |
718e3744 | 4418 | } |
4419 | ||
4420 | DEFUN (no_bgp_network, | |
4421 | no_bgp_network_cmd, | |
4422 | "no network A.B.C.D/M", | |
4423 | NO_STR | |
4424 | "Specify a network to announce via BGP\n" | |
4425 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4426 | { | |
4427 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, | |
4428 | bgp_node_safi (vty)); | |
4429 | } | |
4430 | ||
4431 | ALIAS (no_bgp_network, | |
4432 | no_bgp_network_route_map_cmd, | |
4433 | "no network A.B.C.D/M route-map WORD", | |
4434 | NO_STR | |
4435 | "Specify a network to announce via BGP\n" | |
4436 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4437 | "Route-map to modify the attributes\n" | |
4438 | "Name of the route map\n") | |
4439 | ||
4440 | ALIAS (no_bgp_network, | |
4441 | no_bgp_network_backdoor_cmd, | |
4442 | "no network A.B.C.D/M backdoor", | |
4443 | NO_STR | |
4444 | "Specify a network to announce via BGP\n" | |
4445 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4446 | "Specify a BGP backdoor route\n") | |
4447 | ||
4448 | DEFUN (no_bgp_network_mask, | |
4449 | no_bgp_network_mask_cmd, | |
4450 | "no network A.B.C.D mask A.B.C.D", | |
4451 | NO_STR | |
4452 | "Specify a network to announce via BGP\n" | |
4453 | "Network number\n" | |
4454 | "Network mask\n" | |
4455 | "Network mask\n") | |
4456 | { | |
4457 | int ret; | |
4458 | char prefix_str[BUFSIZ]; | |
4459 | ||
4460 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4461 | if (! ret) | |
4462 | { | |
4463 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4464 | return CMD_WARNING; | |
4465 | } | |
4466 | ||
4467 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4468 | bgp_node_safi (vty)); | |
4469 | } | |
4470 | ||
4471 | ALIAS (no_bgp_network_mask, | |
4472 | no_bgp_network_mask_route_map_cmd, | |
4473 | "no network A.B.C.D mask A.B.C.D route-map WORD", | |
4474 | NO_STR | |
4475 | "Specify a network to announce via BGP\n" | |
4476 | "Network number\n" | |
4477 | "Network mask\n" | |
4478 | "Network mask\n" | |
4479 | "Route-map to modify the attributes\n" | |
4480 | "Name of the route map\n") | |
4481 | ||
4482 | ALIAS (no_bgp_network_mask, | |
4483 | no_bgp_network_mask_backdoor_cmd, | |
4484 | "no network A.B.C.D mask A.B.C.D backdoor", | |
4485 | NO_STR | |
4486 | "Specify a network to announce via BGP\n" | |
4487 | "Network number\n" | |
4488 | "Network mask\n" | |
4489 | "Network mask\n" | |
4490 | "Specify a BGP backdoor route\n") | |
4491 | ||
4492 | DEFUN (no_bgp_network_mask_natural, | |
4493 | no_bgp_network_mask_natural_cmd, | |
4494 | "no network A.B.C.D", | |
4495 | NO_STR | |
4496 | "Specify a network to announce via BGP\n" | |
4497 | "Network number\n") | |
4498 | { | |
4499 | int ret; | |
4500 | char prefix_str[BUFSIZ]; | |
4501 | ||
4502 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4503 | if (! ret) | |
4504 | { | |
4505 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4506 | return CMD_WARNING; | |
4507 | } | |
4508 | ||
4509 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4510 | bgp_node_safi (vty)); | |
4511 | } | |
4512 | ||
4513 | ALIAS (no_bgp_network_mask_natural, | |
4514 | no_bgp_network_mask_natural_route_map_cmd, | |
4515 | "no network A.B.C.D route-map WORD", | |
4516 | NO_STR | |
4517 | "Specify a network to announce via BGP\n" | |
4518 | "Network number\n" | |
4519 | "Route-map to modify the attributes\n" | |
4520 | "Name of the route map\n") | |
4521 | ||
4522 | ALIAS (no_bgp_network_mask_natural, | |
4523 | no_bgp_network_mask_natural_backdoor_cmd, | |
4524 | "no network A.B.C.D backdoor", | |
4525 | NO_STR | |
4526 | "Specify a network to announce via BGP\n" | |
4527 | "Network number\n" | |
4528 | "Specify a BGP backdoor route\n") | |
4529 | ||
4530 | #ifdef HAVE_IPV6 | |
4531 | DEFUN (ipv6_bgp_network, | |
4532 | ipv6_bgp_network_cmd, | |
4533 | "network X:X::X:X/M", | |
4534 | "Specify a network to announce via BGP\n" | |
4535 | "IPv6 prefix <network>/<length>\n") | |
4536 | { | |
73bfe0bd | 4537 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty), |
c8f3fe30 | 4538 | NULL, 0); |
718e3744 | 4539 | } |
4540 | ||
4541 | DEFUN (ipv6_bgp_network_route_map, | |
4542 | ipv6_bgp_network_route_map_cmd, | |
4543 | "network X:X::X:X/M route-map WORD", | |
4544 | "Specify a network to announce via BGP\n" | |
4545 | "IPv6 prefix <network>/<length>\n" | |
4546 | "Route-map to modify the attributes\n" | |
4547 | "Name of the route map\n") | |
4548 | { | |
4549 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, | |
c8f3fe30 | 4550 | bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4551 | } |
4552 | ||
4553 | DEFUN (no_ipv6_bgp_network, | |
4554 | no_ipv6_bgp_network_cmd, | |
4555 | "no network X:X::X:X/M", | |
4556 | NO_STR | |
4557 | "Specify a network to announce via BGP\n" | |
4558 | "IPv6 prefix <network>/<length>\n") | |
4559 | { | |
73bfe0bd | 4560 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty)); |
718e3744 | 4561 | } |
4562 | ||
4563 | ALIAS (no_ipv6_bgp_network, | |
4564 | no_ipv6_bgp_network_route_map_cmd, | |
4565 | "no network X:X::X:X/M route-map WORD", | |
4566 | NO_STR | |
4567 | "Specify a network to announce via BGP\n" | |
4568 | "IPv6 prefix <network>/<length>\n" | |
4569 | "Route-map to modify the attributes\n" | |
4570 | "Name of the route map\n") | |
4571 | ||
4572 | ALIAS (ipv6_bgp_network, | |
4573 | old_ipv6_bgp_network_cmd, | |
4574 | "ipv6 bgp network X:X::X:X/M", | |
4575 | IPV6_STR | |
4576 | BGP_STR | |
4577 | "Specify a network to announce via BGP\n" | |
4578 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4579 | ||
4580 | ALIAS (no_ipv6_bgp_network, | |
4581 | old_no_ipv6_bgp_network_cmd, | |
4582 | "no ipv6 bgp network X:X::X:X/M", | |
4583 | NO_STR | |
4584 | IPV6_STR | |
4585 | BGP_STR | |
4586 | "Specify a network to announce via BGP\n" | |
4587 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4588 | #endif /* HAVE_IPV6 */ | |
c8f3fe30 | 4589 | |
718e3744 | 4590 | /* Aggreagete address: |
4591 | ||
4592 | advertise-map Set condition to advertise attribute | |
4593 | as-set Generate AS set path information | |
4594 | attribute-map Set attributes of aggregate | |
4595 | route-map Set parameters of aggregate | |
4596 | summary-only Filter more specific routes from updates | |
4597 | suppress-map Conditionally filter more specific routes from updates | |
4598 | <cr> | |
4599 | */ | |
4600 | struct bgp_aggregate | |
4601 | { | |
4602 | /* Summary-only flag. */ | |
4603 | u_char summary_only; | |
4604 | ||
4605 | /* AS set generation. */ | |
4606 | u_char as_set; | |
4607 | ||
4608 | /* Route-map for aggregated route. */ | |
4609 | struct route_map *map; | |
4610 | ||
4611 | /* Suppress-count. */ | |
4612 | unsigned long count; | |
4613 | ||
4614 | /* SAFI configuration. */ | |
4615 | safi_t safi; | |
4616 | }; | |
4617 | ||
94f2b392 | 4618 | static struct bgp_aggregate * |
66e5cd87 | 4619 | bgp_aggregate_new (void) |
718e3744 | 4620 | { |
393deb9b | 4621 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
718e3744 | 4622 | } |
4623 | ||
94f2b392 | 4624 | static void |
718e3744 | 4625 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
4626 | { | |
4627 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); | |
4628 | } | |
4629 | ||
b5d58c32 | 4630 | /* Update an aggregate as routes are added/removed from the BGP table */ |
94f2b392 | 4631 | static void |
718e3744 | 4632 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
4633 | afi_t afi, safi_t safi, struct bgp_info *del, | |
4634 | struct bgp_aggregate *aggregate) | |
4635 | { | |
4636 | struct bgp_table *table; | |
4637 | struct bgp_node *top; | |
4638 | struct bgp_node *rn; | |
4639 | u_char origin; | |
4640 | struct aspath *aspath = NULL; | |
4641 | struct aspath *asmerge = NULL; | |
4642 | struct community *community = NULL; | |
4643 | struct community *commerge = NULL; | |
ffd0c037 | 4644 | #if defined(AGGREGATE_NEXTHOP_CHECK) |
718e3744 | 4645 | struct in_addr nexthop; |
4646 | u_int32_t med = 0; | |
ffd0c037 | 4647 | #endif |
718e3744 | 4648 | struct bgp_info *ri; |
4649 | struct bgp_info *new; | |
4650 | int first = 1; | |
4651 | unsigned long match = 0; | |
42f7e184 | 4652 | u_char atomic_aggregate = 0; |
718e3744 | 4653 | |
4654 | /* Record adding route's nexthop and med. */ | |
ffd0c037 DS |
4655 | if (rinew) |
4656 | { | |
4657 | #if defined(AGGREGATE_NEXTHOP_CHECK) | |
4658 | nexthop = rinew->attr->nexthop; | |
4659 | med = rinew->attr->med; | |
4660 | #endif | |
4661 | } | |
718e3744 | 4662 | |
4663 | /* ORIGIN attribute: If at least one route among routes that are | |
4664 | aggregated has ORIGIN with the value INCOMPLETE, then the | |
4665 | aggregated route must have the ORIGIN attribute with the value | |
4666 | INCOMPLETE. Otherwise, if at least one route among routes that | |
4667 | are aggregated has ORIGIN with the value EGP, then the aggregated | |
4668 | route must have the origin attribute with the value EGP. In all | |
4669 | other case the value of the ORIGIN attribute of the aggregated | |
4670 | route is INTERNAL. */ | |
4671 | origin = BGP_ORIGIN_IGP; | |
4672 | ||
4673 | table = bgp->rib[afi][safi]; | |
4674 | ||
4675 | top = bgp_node_get (table, p); | |
4676 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4677 | if (rn->p.prefixlen > p->prefixlen) | |
4678 | { | |
4679 | match = 0; | |
4680 | ||
4681 | for (ri = rn->info; ri; ri = ri->next) | |
4682 | { | |
4683 | if (BGP_INFO_HOLDDOWN (ri)) | |
4684 | continue; | |
4685 | ||
4686 | if (del && ri == del) | |
4687 | continue; | |
4688 | ||
4689 | if (! rinew && first) | |
4690 | { | |
ffd0c037 | 4691 | #if defined(AGGREGATE_NEXTHOP_CHECK) |
718e3744 | 4692 | nexthop = ri->attr->nexthop; |
4693 | med = ri->attr->med; | |
ffd0c037 | 4694 | #endif |
718e3744 | 4695 | first = 0; |
4696 | } | |
4697 | ||
4698 | #ifdef AGGREGATE_NEXTHOP_CHECK | |
4699 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) | |
4700 | || ri->attr->med != med) | |
4701 | { | |
4702 | if (aspath) | |
4703 | aspath_free (aspath); | |
4704 | if (community) | |
4705 | community_free (community); | |
4706 | bgp_unlock_node (rn); | |
4707 | bgp_unlock_node (top); | |
4708 | return; | |
4709 | } | |
4710 | #endif /* AGGREGATE_NEXTHOP_CHECK */ | |
4711 | ||
42f7e184 DS |
4712 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
4713 | atomic_aggregate = 1; | |
4714 | ||
718e3744 | 4715 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
4716 | { | |
4717 | if (aggregate->summary_only) | |
4718 | { | |
fb982c25 | 4719 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4720 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4721 | match++; |
4722 | } | |
4723 | ||
4724 | aggregate->count++; | |
4725 | ||
b5d58c32 DS |
4726 | if (origin < ri->attr->origin) |
4727 | origin = ri->attr->origin; | |
4728 | ||
718e3744 | 4729 | if (aggregate->as_set) |
4730 | { | |
718e3744 | 4731 | if (aspath) |
4732 | { | |
4733 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4734 | aspath_free (aspath); | |
4735 | aspath = asmerge; | |
4736 | } | |
4737 | else | |
4738 | aspath = aspath_dup (ri->attr->aspath); | |
4739 | ||
4740 | if (ri->attr->community) | |
4741 | { | |
4742 | if (community) | |
4743 | { | |
4744 | commerge = community_merge (community, | |
4745 | ri->attr->community); | |
4746 | community = community_uniq_sort (commerge); | |
4747 | community_free (commerge); | |
4748 | } | |
4749 | else | |
4750 | community = community_dup (ri->attr->community); | |
4751 | } | |
4752 | } | |
4753 | } | |
4754 | } | |
4755 | if (match) | |
4756 | bgp_process (bgp, rn, afi, safi); | |
4757 | } | |
4758 | bgp_unlock_node (top); | |
4759 | ||
4760 | if (rinew) | |
4761 | { | |
4762 | aggregate->count++; | |
4763 | ||
4764 | if (aggregate->summary_only) | |
fb982c25 | 4765 | (bgp_info_extra_get (rinew))->suppress++; |
718e3744 | 4766 | |
b5d58c32 DS |
4767 | if (origin < rinew->attr->origin) |
4768 | origin = rinew->attr->origin; | |
4769 | ||
718e3744 | 4770 | if (aggregate->as_set) |
4771 | { | |
718e3744 | 4772 | if (aspath) |
4773 | { | |
4774 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); | |
4775 | aspath_free (aspath); | |
4776 | aspath = asmerge; | |
4777 | } | |
4778 | else | |
4779 | aspath = aspath_dup (rinew->attr->aspath); | |
4780 | ||
4781 | if (rinew->attr->community) | |
4782 | { | |
4783 | if (community) | |
4784 | { | |
4785 | commerge = community_merge (community, | |
4786 | rinew->attr->community); | |
4787 | community = community_uniq_sort (commerge); | |
4788 | community_free (commerge); | |
4789 | } | |
4790 | else | |
4791 | community = community_dup (rinew->attr->community); | |
4792 | } | |
4793 | } | |
4794 | } | |
4795 | ||
4796 | if (aggregate->count > 0) | |
4797 | { | |
4798 | rn = bgp_node_get (table, p); | |
7c8ff89e | 4799 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self, |
fb018d25 | 4800 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
42f7e184 DS |
4801 | aggregate->as_set, |
4802 | atomic_aggregate), rn); | |
718e3744 | 4803 | SET_FLAG (new->flags, BGP_INFO_VALID); |
718e3744 | 4804 | |
4805 | bgp_info_add (rn, new); | |
200df115 | 4806 | bgp_unlock_node (rn); |
718e3744 | 4807 | bgp_process (bgp, rn, afi, safi); |
4808 | } | |
4809 | else | |
4810 | { | |
4811 | if (aspath) | |
4812 | aspath_free (aspath); | |
4813 | if (community) | |
4814 | community_free (community); | |
4815 | } | |
4816 | } | |
4817 | ||
4818 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, | |
4819 | struct bgp_aggregate *); | |
4820 | ||
4821 | void | |
4822 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, | |
4823 | struct bgp_info *ri, afi_t afi, safi_t safi) | |
4824 | { | |
4825 | struct bgp_node *child; | |
4826 | struct bgp_node *rn; | |
4827 | struct bgp_aggregate *aggregate; | |
f018db83 | 4828 | struct bgp_table *table; |
718e3744 | 4829 | |
4830 | /* MPLS-VPN aggregation is not yet supported. */ | |
587ff0fd | 4831 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 4832 | return; |
4833 | ||
f018db83 JBD |
4834 | table = bgp->aggregate[afi][safi]; |
4835 | ||
4836 | /* No aggregates configured. */ | |
67174041 | 4837 | if (bgp_table_top_nolock (table) == NULL) |
f018db83 JBD |
4838 | return; |
4839 | ||
718e3744 | 4840 | if (p->prefixlen == 0) |
4841 | return; | |
4842 | ||
4843 | if (BGP_INFO_HOLDDOWN (ri)) | |
4844 | return; | |
4845 | ||
bb782fb5 | 4846 | child = bgp_node_get (table, p); |
718e3744 | 4847 | |
4848 | /* Aggregate address configuration check. */ | |
67174041 | 4849 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
718e3744 | 4850 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
4851 | { | |
4852 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4853 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
718e3744 | 4854 | } |
4855 | bgp_unlock_node (child); | |
4856 | } | |
4857 | ||
4858 | void | |
4859 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, | |
4860 | struct bgp_info *del, afi_t afi, safi_t safi) | |
4861 | { | |
4862 | struct bgp_node *child; | |
4863 | struct bgp_node *rn; | |
4864 | struct bgp_aggregate *aggregate; | |
f018db83 | 4865 | struct bgp_table *table; |
718e3744 | 4866 | |
4867 | /* MPLS-VPN aggregation is not yet supported. */ | |
587ff0fd | 4868 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 4869 | return; |
4870 | ||
f018db83 JBD |
4871 | table = bgp->aggregate[afi][safi]; |
4872 | ||
4873 | /* No aggregates configured. */ | |
67174041 | 4874 | if (bgp_table_top_nolock (table) == NULL) |
f018db83 JBD |
4875 | return; |
4876 | ||
718e3744 | 4877 | if (p->prefixlen == 0) |
4878 | return; | |
4879 | ||
bb782fb5 | 4880 | child = bgp_node_get (table, p); |
718e3744 | 4881 | |
4882 | /* Aggregate address configuration check. */ | |
67174041 | 4883 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
718e3744 | 4884 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
4885 | { | |
4886 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4887 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
718e3744 | 4888 | } |
4889 | bgp_unlock_node (child); | |
4890 | } | |
4891 | ||
b5d58c32 | 4892 | /* Called via bgp_aggregate_set when the user configures aggregate-address */ |
94f2b392 | 4893 | static void |
718e3744 | 4894 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
4895 | struct bgp_aggregate *aggregate) | |
4896 | { | |
4897 | struct bgp_table *table; | |
4898 | struct bgp_node *top; | |
4899 | struct bgp_node *rn; | |
4900 | struct bgp_info *new; | |
4901 | struct bgp_info *ri; | |
4902 | unsigned long match; | |
4903 | u_char origin = BGP_ORIGIN_IGP; | |
4904 | struct aspath *aspath = NULL; | |
4905 | struct aspath *asmerge = NULL; | |
4906 | struct community *community = NULL; | |
4907 | struct community *commerge = NULL; | |
42f7e184 | 4908 | u_char atomic_aggregate = 0; |
718e3744 | 4909 | |
4910 | table = bgp->rib[afi][safi]; | |
4911 | ||
4912 | /* Sanity check. */ | |
4913 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4914 | return; | |
4915 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4916 | return; | |
4917 | ||
4918 | /* If routes exists below this node, generate aggregate routes. */ | |
4919 | top = bgp_node_get (table, p); | |
4920 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4921 | if (rn->p.prefixlen > p->prefixlen) | |
4922 | { | |
4923 | match = 0; | |
4924 | ||
4925 | for (ri = rn->info; ri; ri = ri->next) | |
4926 | { | |
4927 | if (BGP_INFO_HOLDDOWN (ri)) | |
4928 | continue; | |
4929 | ||
42f7e184 DS |
4930 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
4931 | atomic_aggregate = 1; | |
4932 | ||
718e3744 | 4933 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
4934 | { | |
4935 | /* summary-only aggregate route suppress aggregated | |
4936 | route announcement. */ | |
4937 | if (aggregate->summary_only) | |
4938 | { | |
fb982c25 | 4939 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4940 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4941 | match++; |
4942 | } | |
b5d58c32 DS |
4943 | |
4944 | /* If at least one route among routes that are aggregated has | |
4945 | * ORIGIN with the value INCOMPLETE, then the aggregated route | |
4946 | * MUST have the ORIGIN attribute with the value INCOMPLETE. | |
4947 | * Otherwise, if at least one route among routes that are | |
4948 | * aggregated has ORIGIN with the value EGP, then the aggregated | |
4949 | * route MUST have the ORIGIN attribute with the value EGP. | |
4950 | */ | |
4951 | if (origin < ri->attr->origin) | |
4952 | origin = ri->attr->origin; | |
4953 | ||
718e3744 | 4954 | /* as-set aggregate route generate origin, as path, |
4955 | community aggregation. */ | |
4956 | if (aggregate->as_set) | |
4957 | { | |
718e3744 | 4958 | if (aspath) |
4959 | { | |
4960 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4961 | aspath_free (aspath); | |
4962 | aspath = asmerge; | |
4963 | } | |
4964 | else | |
4965 | aspath = aspath_dup (ri->attr->aspath); | |
4966 | ||
4967 | if (ri->attr->community) | |
4968 | { | |
4969 | if (community) | |
4970 | { | |
4971 | commerge = community_merge (community, | |
4972 | ri->attr->community); | |
4973 | community = community_uniq_sort (commerge); | |
4974 | community_free (commerge); | |
4975 | } | |
4976 | else | |
4977 | community = community_dup (ri->attr->community); | |
4978 | } | |
4979 | } | |
4980 | aggregate->count++; | |
4981 | } | |
4982 | } | |
4983 | ||
4984 | /* If this node is suppressed, process the change. */ | |
4985 | if (match) | |
4986 | bgp_process (bgp, rn, afi, safi); | |
4987 | } | |
4988 | bgp_unlock_node (top); | |
4989 | ||
4990 | /* Add aggregate route to BGP table. */ | |
4991 | if (aggregate->count) | |
4992 | { | |
4993 | rn = bgp_node_get (table, p); | |
7c8ff89e | 4994 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self, |
fb018d25 | 4995 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
42f7e184 DS |
4996 | aggregate->as_set, |
4997 | atomic_aggregate), rn); | |
718e3744 | 4998 | SET_FLAG (new->flags, BGP_INFO_VALID); |
718e3744 | 4999 | |
5000 | bgp_info_add (rn, new); | |
200df115 | 5001 | bgp_unlock_node (rn); |
5002 | ||
718e3744 | 5003 | /* Process change. */ |
5004 | bgp_process (bgp, rn, afi, safi); | |
5005 | } | |
610f23cf DV |
5006 | else |
5007 | { | |
5008 | if (aspath) | |
5009 | aspath_free (aspath); | |
5010 | if (community) | |
5011 | community_free (community); | |
5012 | } | |
718e3744 | 5013 | } |
5014 | ||
5015 | void | |
5016 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, | |
5017 | safi_t safi, struct bgp_aggregate *aggregate) | |
5018 | { | |
5019 | struct bgp_table *table; | |
5020 | struct bgp_node *top; | |
5021 | struct bgp_node *rn; | |
5022 | struct bgp_info *ri; | |
5023 | unsigned long match; | |
5024 | ||
5025 | table = bgp->rib[afi][safi]; | |
5026 | ||
5027 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
5028 | return; | |
5029 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
5030 | return; | |
5031 | ||
5032 | /* If routes exists below this node, generate aggregate routes. */ | |
5033 | top = bgp_node_get (table, p); | |
5034 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
5035 | if (rn->p.prefixlen > p->prefixlen) | |
5036 | { | |
5037 | match = 0; | |
5038 | ||
5039 | for (ri = rn->info; ri; ri = ri->next) | |
5040 | { | |
5041 | if (BGP_INFO_HOLDDOWN (ri)) | |
5042 | continue; | |
5043 | ||
5044 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
5045 | { | |
fb982c25 | 5046 | if (aggregate->summary_only && ri->extra) |
718e3744 | 5047 | { |
fb982c25 | 5048 | ri->extra->suppress--; |
718e3744 | 5049 | |
fb982c25 | 5050 | if (ri->extra->suppress == 0) |
718e3744 | 5051 | { |
1a392d46 | 5052 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 5053 | match++; |
5054 | } | |
5055 | } | |
5056 | aggregate->count--; | |
5057 | } | |
5058 | } | |
5059 | ||
fb982c25 | 5060 | /* If this node was suppressed, process the change. */ |
718e3744 | 5061 | if (match) |
5062 | bgp_process (bgp, rn, afi, safi); | |
5063 | } | |
5064 | bgp_unlock_node (top); | |
5065 | ||
5066 | /* Delete aggregate route from BGP table. */ | |
5067 | rn = bgp_node_get (table, p); | |
5068 | ||
5069 | for (ri = rn->info; ri; ri = ri->next) | |
5070 | if (ri->peer == bgp->peer_self | |
5071 | && ri->type == ZEBRA_ROUTE_BGP | |
5072 | && ri->sub_type == BGP_ROUTE_AGGREGATE) | |
5073 | break; | |
5074 | ||
5075 | /* Withdraw static BGP route from routing table. */ | |
5076 | if (ri) | |
5077 | { | |
718e3744 | 5078 | bgp_info_delete (rn, ri); |
1a392d46 | 5079 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 5080 | } |
5081 | ||
5082 | /* Unlock bgp_node_lookup. */ | |
5083 | bgp_unlock_node (rn); | |
5084 | } | |
5085 | ||
5086 | /* Aggregate route attribute. */ | |
5087 | #define AGGREGATE_SUMMARY_ONLY 1 | |
5088 | #define AGGREGATE_AS_SET 1 | |
5089 | ||
94f2b392 | 5090 | static int |
f6269b4f RB |
5091 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
5092 | afi_t afi, safi_t safi) | |
718e3744 | 5093 | { |
5094 | int ret; | |
5095 | struct prefix p; | |
5096 | struct bgp_node *rn; | |
5097 | struct bgp *bgp; | |
5098 | struct bgp_aggregate *aggregate; | |
5099 | ||
5100 | /* Convert string to prefix structure. */ | |
5101 | ret = str2prefix (prefix_str, &p); | |
5102 | if (!ret) | |
5103 | { | |
5104 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
5105 | return CMD_WARNING; | |
5106 | } | |
5107 | apply_mask (&p); | |
5108 | ||
5109 | /* Get BGP structure. */ | |
5110 | bgp = vty->index; | |
5111 | ||
5112 | /* Old configuration check. */ | |
f6269b4f RB |
5113 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
5114 | if (! rn) | |
718e3744 | 5115 | { |
f6269b4f RB |
5116 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
5117 | VTY_NEWLINE); | |
718e3744 | 5118 | return CMD_WARNING; |
5119 | } | |
5120 | ||
f6269b4f RB |
5121 | aggregate = rn->info; |
5122 | if (aggregate->safi & SAFI_UNICAST) | |
5123 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
5124 | if (aggregate->safi & SAFI_MULTICAST) | |
5125 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 5126 | |
f6269b4f RB |
5127 | /* Unlock aggregate address configuration. */ |
5128 | rn->info = NULL; | |
5129 | bgp_aggregate_free (aggregate); | |
5130 | bgp_unlock_node (rn); | |
5131 | bgp_unlock_node (rn); | |
718e3744 | 5132 | |
5133 | return CMD_SUCCESS; | |
5134 | } | |
5135 | ||
94f2b392 | 5136 | static int |
f6269b4f RB |
5137 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
5138 | afi_t afi, safi_t safi, | |
5139 | u_char summary_only, u_char as_set) | |
718e3744 | 5140 | { |
5141 | int ret; | |
5142 | struct prefix p; | |
5143 | struct bgp_node *rn; | |
5144 | struct bgp *bgp; | |
5145 | struct bgp_aggregate *aggregate; | |
5146 | ||
5147 | /* Convert string to prefix structure. */ | |
5148 | ret = str2prefix (prefix_str, &p); | |
5149 | if (!ret) | |
5150 | { | |
5151 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
5152 | return CMD_WARNING; | |
5153 | } | |
5154 | apply_mask (&p); | |
5155 | ||
5156 | /* Get BGP structure. */ | |
5157 | bgp = vty->index; | |
5158 | ||
5159 | /* Old configuration check. */ | |
f6269b4f RB |
5160 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
5161 | ||
5162 | if (rn->info) | |
718e3744 | 5163 | { |
f6269b4f | 5164 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
368473f6 | 5165 | /* try to remove the old entry */ |
f6269b4f RB |
5166 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
5167 | if (ret) | |
5168 | { | |
368473f6 RB |
5169 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
5170 | bgp_unlock_node (rn); | |
f6269b4f RB |
5171 | return CMD_WARNING; |
5172 | } | |
718e3744 | 5173 | } |
5174 | ||
f6269b4f RB |
5175 | /* Make aggregate address structure. */ |
5176 | aggregate = bgp_aggregate_new (); | |
5177 | aggregate->summary_only = summary_only; | |
5178 | aggregate->as_set = as_set; | |
5179 | aggregate->safi = safi; | |
5180 | rn->info = aggregate; | |
718e3744 | 5181 | |
f6269b4f RB |
5182 | /* Aggregate address insert into BGP routing table. */ |
5183 | if (safi & SAFI_UNICAST) | |
5184 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
5185 | if (safi & SAFI_MULTICAST) | |
5186 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 5187 | |
5188 | return CMD_SUCCESS; | |
5189 | } | |
5190 | ||
5191 | DEFUN (aggregate_address, | |
5192 | aggregate_address_cmd, | |
5193 | "aggregate-address A.B.C.D/M", | |
5194 | "Configure BGP aggregate entries\n" | |
5195 | "Aggregate prefix\n") | |
5196 | { | |
5197 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); | |
5198 | } | |
5199 | ||
5200 | DEFUN (aggregate_address_mask, | |
5201 | aggregate_address_mask_cmd, | |
5202 | "aggregate-address A.B.C.D A.B.C.D", | |
5203 | "Configure BGP aggregate entries\n" | |
5204 | "Aggregate address\n" | |
5205 | "Aggregate mask\n") | |
5206 | { | |
5207 | int ret; | |
5208 | char prefix_str[BUFSIZ]; | |
5209 | ||
5210 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5211 | ||
5212 | if (! ret) | |
5213 | { | |
5214 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5215 | return CMD_WARNING; | |
5216 | } | |
5217 | ||
5218 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5219 | 0, 0); | |
5220 | } | |
5221 | ||
5222 | DEFUN (aggregate_address_summary_only, | |
5223 | aggregate_address_summary_only_cmd, | |
5224 | "aggregate-address A.B.C.D/M summary-only", | |
5225 | "Configure BGP aggregate entries\n" | |
5226 | "Aggregate prefix\n" | |
5227 | "Filter more specific routes from updates\n") | |
5228 | { | |
5229 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5230 | AGGREGATE_SUMMARY_ONLY, 0); | |
5231 | } | |
5232 | ||
5233 | DEFUN (aggregate_address_mask_summary_only, | |
5234 | aggregate_address_mask_summary_only_cmd, | |
5235 | "aggregate-address A.B.C.D A.B.C.D summary-only", | |
5236 | "Configure BGP aggregate entries\n" | |
5237 | "Aggregate address\n" | |
5238 | "Aggregate mask\n" | |
5239 | "Filter more specific routes from updates\n") | |
5240 | { | |
5241 | int ret; | |
5242 | char prefix_str[BUFSIZ]; | |
5243 | ||
5244 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5245 | ||
5246 | if (! ret) | |
5247 | { | |
5248 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5249 | return CMD_WARNING; | |
5250 | } | |
5251 | ||
5252 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5253 | AGGREGATE_SUMMARY_ONLY, 0); | |
5254 | } | |
5255 | ||
5256 | DEFUN (aggregate_address_as_set, | |
5257 | aggregate_address_as_set_cmd, | |
5258 | "aggregate-address A.B.C.D/M as-set", | |
5259 | "Configure BGP aggregate entries\n" | |
5260 | "Aggregate prefix\n" | |
5261 | "Generate AS set path information\n") | |
5262 | { | |
5263 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5264 | 0, AGGREGATE_AS_SET); | |
5265 | } | |
5266 | ||
5267 | DEFUN (aggregate_address_mask_as_set, | |
5268 | aggregate_address_mask_as_set_cmd, | |
5269 | "aggregate-address A.B.C.D A.B.C.D as-set", | |
5270 | "Configure BGP aggregate entries\n" | |
5271 | "Aggregate address\n" | |
5272 | "Aggregate mask\n" | |
5273 | "Generate AS set path information\n") | |
5274 | { | |
5275 | int ret; | |
5276 | char prefix_str[BUFSIZ]; | |
5277 | ||
5278 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5279 | ||
5280 | if (! ret) | |
5281 | { | |
5282 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5283 | return CMD_WARNING; | |
5284 | } | |
5285 | ||
5286 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5287 | 0, AGGREGATE_AS_SET); | |
5288 | } | |
5289 | ||
5290 | ||
5291 | DEFUN (aggregate_address_as_set_summary, | |
5292 | aggregate_address_as_set_summary_cmd, | |
5293 | "aggregate-address A.B.C.D/M as-set summary-only", | |
5294 | "Configure BGP aggregate entries\n" | |
5295 | "Aggregate prefix\n" | |
5296 | "Generate AS set path information\n" | |
5297 | "Filter more specific routes from updates\n") | |
5298 | { | |
5299 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5300 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5301 | } | |
5302 | ||
5303 | ALIAS (aggregate_address_as_set_summary, | |
5304 | aggregate_address_summary_as_set_cmd, | |
5305 | "aggregate-address A.B.C.D/M summary-only as-set", | |
5306 | "Configure BGP aggregate entries\n" | |
5307 | "Aggregate prefix\n" | |
5308 | "Filter more specific routes from updates\n" | |
5309 | "Generate AS set path information\n") | |
5310 | ||
5311 | DEFUN (aggregate_address_mask_as_set_summary, | |
5312 | aggregate_address_mask_as_set_summary_cmd, | |
5313 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5314 | "Configure BGP aggregate entries\n" | |
5315 | "Aggregate address\n" | |
5316 | "Aggregate mask\n" | |
5317 | "Generate AS set path information\n" | |
5318 | "Filter more specific routes from updates\n") | |
5319 | { | |
5320 | int ret; | |
5321 | char prefix_str[BUFSIZ]; | |
5322 | ||
5323 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5324 | ||
5325 | if (! ret) | |
5326 | { | |
5327 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5328 | return CMD_WARNING; | |
5329 | } | |
5330 | ||
5331 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5332 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5333 | } | |
5334 | ||
5335 | ALIAS (aggregate_address_mask_as_set_summary, | |
5336 | aggregate_address_mask_summary_as_set_cmd, | |
5337 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5338 | "Configure BGP aggregate entries\n" | |
5339 | "Aggregate address\n" | |
5340 | "Aggregate mask\n" | |
5341 | "Filter more specific routes from updates\n" | |
5342 | "Generate AS set path information\n") | |
5343 | ||
5344 | DEFUN (no_aggregate_address, | |
5345 | no_aggregate_address_cmd, | |
5346 | "no aggregate-address A.B.C.D/M", | |
5347 | NO_STR | |
5348 | "Configure BGP aggregate entries\n" | |
5349 | "Aggregate prefix\n") | |
5350 | { | |
5351 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); | |
5352 | } | |
5353 | ||
5354 | ALIAS (no_aggregate_address, | |
5355 | no_aggregate_address_summary_only_cmd, | |
5356 | "no aggregate-address A.B.C.D/M summary-only", | |
5357 | NO_STR | |
5358 | "Configure BGP aggregate entries\n" | |
5359 | "Aggregate prefix\n" | |
5360 | "Filter more specific routes from updates\n") | |
5361 | ||
5362 | ALIAS (no_aggregate_address, | |
5363 | no_aggregate_address_as_set_cmd, | |
5364 | "no aggregate-address A.B.C.D/M as-set", | |
5365 | NO_STR | |
5366 | "Configure BGP aggregate entries\n" | |
5367 | "Aggregate prefix\n" | |
5368 | "Generate AS set path information\n") | |
5369 | ||
5370 | ALIAS (no_aggregate_address, | |
5371 | no_aggregate_address_as_set_summary_cmd, | |
5372 | "no aggregate-address A.B.C.D/M as-set summary-only", | |
5373 | NO_STR | |
5374 | "Configure BGP aggregate entries\n" | |
5375 | "Aggregate prefix\n" | |
5376 | "Generate AS set path information\n" | |
5377 | "Filter more specific routes from updates\n") | |
5378 | ||
5379 | ALIAS (no_aggregate_address, | |
5380 | no_aggregate_address_summary_as_set_cmd, | |
5381 | "no aggregate-address A.B.C.D/M summary-only as-set", | |
5382 | NO_STR | |
5383 | "Configure BGP aggregate entries\n" | |
5384 | "Aggregate prefix\n" | |
5385 | "Filter more specific routes from updates\n" | |
5386 | "Generate AS set path information\n") | |
5387 | ||
5388 | DEFUN (no_aggregate_address_mask, | |
5389 | no_aggregate_address_mask_cmd, | |
5390 | "no aggregate-address A.B.C.D A.B.C.D", | |
5391 | NO_STR | |
5392 | "Configure BGP aggregate entries\n" | |
5393 | "Aggregate address\n" | |
5394 | "Aggregate mask\n") | |
5395 | { | |
5396 | int ret; | |
5397 | char prefix_str[BUFSIZ]; | |
5398 | ||
5399 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5400 | ||
5401 | if (! ret) | |
5402 | { | |
5403 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5404 | return CMD_WARNING; | |
5405 | } | |
5406 | ||
5407 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); | |
5408 | } | |
5409 | ||
5410 | ALIAS (no_aggregate_address_mask, | |
5411 | no_aggregate_address_mask_summary_only_cmd, | |
5412 | "no aggregate-address A.B.C.D A.B.C.D summary-only", | |
5413 | NO_STR | |
5414 | "Configure BGP aggregate entries\n" | |
5415 | "Aggregate address\n" | |
5416 | "Aggregate mask\n" | |
5417 | "Filter more specific routes from updates\n") | |
5418 | ||
5419 | ALIAS (no_aggregate_address_mask, | |
5420 | no_aggregate_address_mask_as_set_cmd, | |
5421 | "no aggregate-address A.B.C.D A.B.C.D as-set", | |
5422 | NO_STR | |
5423 | "Configure BGP aggregate entries\n" | |
5424 | "Aggregate address\n" | |
5425 | "Aggregate mask\n" | |
5426 | "Generate AS set path information\n") | |
5427 | ||
5428 | ALIAS (no_aggregate_address_mask, | |
5429 | no_aggregate_address_mask_as_set_summary_cmd, | |
5430 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5431 | NO_STR | |
5432 | "Configure BGP aggregate entries\n" | |
5433 | "Aggregate address\n" | |
5434 | "Aggregate mask\n" | |
5435 | "Generate AS set path information\n" | |
5436 | "Filter more specific routes from updates\n") | |
5437 | ||
5438 | ALIAS (no_aggregate_address_mask, | |
5439 | no_aggregate_address_mask_summary_as_set_cmd, | |
5440 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5441 | NO_STR | |
5442 | "Configure BGP aggregate entries\n" | |
5443 | "Aggregate address\n" | |
5444 | "Aggregate mask\n" | |
5445 | "Filter more specific routes from updates\n" | |
5446 | "Generate AS set path information\n") | |
5447 | ||
5448 | #ifdef HAVE_IPV6 | |
5449 | DEFUN (ipv6_aggregate_address, | |
5450 | ipv6_aggregate_address_cmd, | |
5451 | "aggregate-address X:X::X:X/M", | |
5452 | "Configure BGP aggregate entries\n" | |
5453 | "Aggregate prefix\n") | |
5454 | { | |
5455 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); | |
5456 | } | |
5457 | ||
5458 | DEFUN (ipv6_aggregate_address_summary_only, | |
5459 | ipv6_aggregate_address_summary_only_cmd, | |
5460 | "aggregate-address X:X::X:X/M summary-only", | |
5461 | "Configure BGP aggregate entries\n" | |
5462 | "Aggregate prefix\n" | |
5463 | "Filter more specific routes from updates\n") | |
5464 | { | |
5465 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
5466 | AGGREGATE_SUMMARY_ONLY, 0); | |
5467 | } | |
5468 | ||
5469 | DEFUN (no_ipv6_aggregate_address, | |
5470 | no_ipv6_aggregate_address_cmd, | |
5471 | "no aggregate-address X:X::X:X/M", | |
5472 | NO_STR | |
5473 | "Configure BGP aggregate entries\n" | |
5474 | "Aggregate prefix\n") | |
5475 | { | |
5476 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5477 | } | |
5478 | ||
5479 | DEFUN (no_ipv6_aggregate_address_summary_only, | |
5480 | no_ipv6_aggregate_address_summary_only_cmd, | |
5481 | "no aggregate-address X:X::X:X/M summary-only", | |
5482 | NO_STR | |
5483 | "Configure BGP aggregate entries\n" | |
5484 | "Aggregate prefix\n" | |
5485 | "Filter more specific routes from updates\n") | |
5486 | { | |
5487 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5488 | } | |
5489 | ||
5490 | ALIAS (ipv6_aggregate_address, | |
5491 | old_ipv6_aggregate_address_cmd, | |
5492 | "ipv6 bgp aggregate-address X:X::X:X/M", | |
5493 | IPV6_STR | |
5494 | BGP_STR | |
5495 | "Configure BGP aggregate entries\n" | |
5496 | "Aggregate prefix\n") | |
5497 | ||
5498 | ALIAS (ipv6_aggregate_address_summary_only, | |
5499 | old_ipv6_aggregate_address_summary_only_cmd, | |
5500 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5501 | IPV6_STR | |
5502 | BGP_STR | |
5503 | "Configure BGP aggregate entries\n" | |
5504 | "Aggregate prefix\n" | |
5505 | "Filter more specific routes from updates\n") | |
5506 | ||
5507 | ALIAS (no_ipv6_aggregate_address, | |
5508 | old_no_ipv6_aggregate_address_cmd, | |
5509 | "no ipv6 bgp aggregate-address X:X::X:X/M", | |
5510 | NO_STR | |
5511 | IPV6_STR | |
5512 | BGP_STR | |
5513 | "Configure BGP aggregate entries\n" | |
5514 | "Aggregate prefix\n") | |
5515 | ||
5516 | ALIAS (no_ipv6_aggregate_address_summary_only, | |
5517 | old_no_ipv6_aggregate_address_summary_only_cmd, | |
5518 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5519 | NO_STR | |
5520 | IPV6_STR | |
5521 | BGP_STR | |
5522 | "Configure BGP aggregate entries\n" | |
5523 | "Aggregate prefix\n" | |
5524 | "Filter more specific routes from updates\n") | |
5525 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 5526 | |
718e3744 | 5527 | /* Redistribute route treatment. */ |
5528 | void | |
6aeb9e78 | 5529 | bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *nexthop, |
bc413143 | 5530 | const struct in6_addr *nexthop6, unsigned int ifindex, |
7c8ff89e | 5531 | u_int32_t metric, u_char type, u_short instance, u_short tag) |
718e3744 | 5532 | { |
718e3744 | 5533 | struct bgp_info *new; |
5534 | struct bgp_info *bi; | |
5535 | struct bgp_info info; | |
5536 | struct bgp_node *bn; | |
e16a4133 | 5537 | struct attr attr; |
718e3744 | 5538 | struct attr *new_attr; |
5539 | afi_t afi; | |
5540 | int ret; | |
7c8ff89e | 5541 | struct bgp_redist *red; |
718e3744 | 5542 | |
5543 | /* Make default attribute. */ | |
5544 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); | |
5545 | if (nexthop) | |
5546 | attr.nexthop = *nexthop; | |
bc413143 | 5547 | attr.nh_ifindex = ifindex; |
718e3744 | 5548 | |
f04a80a5 SH |
5549 | #ifdef HAVE_IPV6 |
5550 | if (nexthop6) | |
5551 | { | |
5552 | struct attr_extra *extra = bgp_attr_extra_get(&attr); | |
5553 | extra->mp_nexthop_global = *nexthop6; | |
801a9bcc | 5554 | extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; |
f04a80a5 SH |
5555 | } |
5556 | #endif | |
5557 | ||
718e3744 | 5558 | attr.med = metric; |
5559 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
0d9551dc | 5560 | attr.extra->tag = tag; |
718e3744 | 5561 | |
6aeb9e78 DS |
5562 | afi = family2afi (p->family); |
5563 | ||
5564 | red = bgp_redist_lookup(bgp, afi, type, instance); | |
5565 | if (red) | |
718e3744 | 5566 | { |
6aeb9e78 DS |
5567 | struct attr attr_new; |
5568 | struct attr_extra extra_new; | |
718e3744 | 5569 | |
6aeb9e78 DS |
5570 | /* Copy attribute for modification. */ |
5571 | attr_new.extra = &extra_new; | |
5572 | bgp_attr_dup (&attr_new, &attr); | |
558d1fec | 5573 | |
6aeb9e78 DS |
5574 | if (red->redist_metric_flag) |
5575 | attr_new.med = red->redist_metric; | |
718e3744 | 5576 | |
6aeb9e78 DS |
5577 | /* Apply route-map. */ |
5578 | if (red->rmap.name) | |
5579 | { | |
5580 | info.peer = bgp->peer_self; | |
5581 | info.attr = &attr_new; | |
718e3744 | 5582 | |
6aeb9e78 | 5583 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
718e3744 | 5584 | |
6aeb9e78 | 5585 | ret = route_map_apply (red->rmap.map, p, RMAP_BGP, &info); |
fee0f4c6 | 5586 | |
6aeb9e78 | 5587 | bgp->peer_self->rmap_type = 0; |
fee0f4c6 | 5588 | |
6aeb9e78 DS |
5589 | if (ret == RMAP_DENYMATCH) |
5590 | { | |
5591 | /* Free uninterned attribute. */ | |
5592 | bgp_attr_flush (&attr_new); | |
5593 | ||
5594 | /* Unintern original. */ | |
5595 | aspath_unintern (&attr.aspath); | |
5596 | bgp_attr_extra_free (&attr); | |
5597 | bgp_redistribute_delete (bgp, p, type, instance); | |
5598 | return; | |
5599 | } | |
5600 | } | |
fee0f4c6 | 5601 | |
6aeb9e78 DS |
5602 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
5603 | afi, SAFI_UNICAST, p, NULL); | |
718e3744 | 5604 | |
6aeb9e78 | 5605 | new_attr = bgp_attr_intern (&attr_new); |
558d1fec | 5606 | |
6aeb9e78 DS |
5607 | for (bi = bn->info; bi; bi = bi->next) |
5608 | if (bi->peer == bgp->peer_self | |
5609 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
5610 | break; | |
5611 | ||
5612 | if (bi) | |
5613 | { | |
5614 | /* Ensure the (source route) type is updated. */ | |
5615 | bi->type = type; | |
5616 | if (attrhash_cmp (bi->attr, new_attr) && | |
5617 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
5618 | { | |
5619 | bgp_attr_unintern (&new_attr); | |
5620 | aspath_unintern (&attr.aspath); | |
5621 | bgp_attr_extra_free (&attr); | |
5622 | bgp_unlock_node (bn); | |
5623 | return; | |
5624 | } | |
5625 | else | |
5626 | { | |
5627 | /* The attribute is changed. */ | |
5628 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); | |
718e3744 | 5629 | |
6aeb9e78 DS |
5630 | /* Rewrite BGP route information. */ |
5631 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
5632 | bgp_info_restore(bn, bi); | |
5633 | else | |
5634 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); | |
5635 | bgp_attr_unintern (&bi->attr); | |
5636 | bi->attr = new_attr; | |
5637 | bi->uptime = bgp_clock (); | |
5638 | ||
5639 | /* Process change. */ | |
5640 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); | |
5641 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
5642 | bgp_unlock_node (bn); | |
5643 | aspath_unintern (&attr.aspath); | |
5644 | bgp_attr_extra_free (&attr); | |
5645 | return; | |
5646 | } | |
5647 | } | |
718e3744 | 5648 | |
6aeb9e78 DS |
5649 | new = info_make(type, BGP_ROUTE_REDISTRIBUTE, instance, bgp->peer_self, |
5650 | new_attr, bn); | |
5651 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
5652 | ||
5653 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); | |
5654 | bgp_info_add (bn, new); | |
5655 | bgp_unlock_node (bn); | |
5656 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
718e3744 | 5657 | } |
5658 | ||
5659 | /* Unintern original. */ | |
f6f434b2 | 5660 | aspath_unintern (&attr.aspath); |
fb982c25 | 5661 | bgp_attr_extra_free (&attr); |
718e3744 | 5662 | } |
5663 | ||
5664 | void | |
6aeb9e78 | 5665 | bgp_redistribute_delete (struct bgp *bgp, struct prefix *p, u_char type, u_short instance) |
718e3744 | 5666 | { |
718e3744 | 5667 | afi_t afi; |
5668 | struct bgp_node *rn; | |
5669 | struct bgp_info *ri; | |
7c8ff89e | 5670 | struct bgp_redist *red; |
718e3744 | 5671 | |
6aeb9e78 | 5672 | afi = family2afi (p->family); |
718e3744 | 5673 | |
6aeb9e78 DS |
5674 | red = bgp_redist_lookup(bgp, afi, type, instance); |
5675 | if (red) | |
5676 | { | |
5677 | rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); | |
718e3744 | 5678 | |
6aeb9e78 DS |
5679 | for (ri = rn->info; ri; ri = ri->next) |
5680 | if (ri->peer == bgp->peer_self | |
5681 | && ri->type == type) | |
5682 | break; | |
718e3744 | 5683 | |
6aeb9e78 DS |
5684 | if (ri) |
5685 | { | |
5686 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); | |
5687 | bgp_info_delete (rn, ri); | |
5688 | bgp_process (bgp, rn, afi, SAFI_UNICAST); | |
5689 | } | |
5690 | bgp_unlock_node (rn); | |
718e3744 | 5691 | } |
5692 | } | |
5693 | ||
5694 | /* Withdraw specified route type's route. */ | |
5695 | void | |
7c8ff89e | 5696 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type, u_short instance) |
718e3744 | 5697 | { |
5698 | struct bgp_node *rn; | |
5699 | struct bgp_info *ri; | |
5700 | struct bgp_table *table; | |
5701 | ||
5702 | table = bgp->rib[afi][SAFI_UNICAST]; | |
5703 | ||
5704 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
5705 | { | |
5706 | for (ri = rn->info; ri; ri = ri->next) | |
5707 | if (ri->peer == bgp->peer_self | |
7c8ff89e DS |
5708 | && ri->type == type |
5709 | && ri->instance == instance) | |
718e3744 | 5710 | break; |
5711 | ||
5712 | if (ri) | |
5713 | { | |
5714 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5715 | bgp_info_delete (rn, ri); |
1a392d46 | 5716 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5717 | } |
5718 | } | |
5719 | } | |
6b0655a2 | 5720 | |
718e3744 | 5721 | /* Static function to display route. */ |
94f2b392 | 5722 | static void |
718e3744 | 5723 | route_vty_out_route (struct prefix *p, struct vty *vty) |
5724 | { | |
5725 | int len; | |
5726 | u_int32_t destination; | |
5727 | char buf[BUFSIZ]; | |
5728 | ||
5729 | if (p->family == AF_INET) | |
5730 | { | |
5731 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); | |
5732 | destination = ntohl (p->u.prefix4.s_addr); | |
5733 | ||
5734 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
856ca177 MS |
5735 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
5736 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
5737 | || p->u.prefix4.s_addr == 0) | |
5738 | { | |
5739 | /* When mask is natural, mask is not displayed. */ | |
5740 | } | |
718e3744 | 5741 | else |
856ca177 | 5742 | len += vty_out (vty, "/%d", p->prefixlen); |
718e3744 | 5743 | } |
5744 | else | |
5745 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), | |
5746 | p->prefixlen); | |
5747 | ||
5748 | len = 17 - len; | |
5749 | if (len < 1) | |
5750 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); | |
5751 | else | |
5752 | vty_out (vty, "%*s", len, " "); | |
5753 | } | |
5754 | ||
718e3744 | 5755 | enum bgp_display_type |
5756 | { | |
5757 | normal_list, | |
5758 | }; | |
5759 | ||
b40d939b | 5760 | /* Print the short form route status for a bgp_info */ |
5761 | static void | |
b05a1c8b DS |
5762 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo, |
5763 | json_object *json_path) | |
718e3744 | 5764 | { |
b05a1c8b DS |
5765 | if (json_path) |
5766 | { | |
b05a1c8b DS |
5767 | |
5768 | /* Route status display. */ | |
5769 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
f1aa5d8a | 5770 | json_object_boolean_true_add(json_path, "removed"); |
b05a1c8b DS |
5771 | |
5772 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
f1aa5d8a | 5773 | json_object_boolean_true_add(json_path, "stale"); |
b05a1c8b DS |
5774 | |
5775 | if (binfo->extra && binfo->extra->suppress) | |
f1aa5d8a | 5776 | json_object_boolean_true_add(json_path, "suppressed"); |
b05a1c8b DS |
5777 | |
5778 | if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && | |
5779 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
f1aa5d8a | 5780 | json_object_boolean_true_add(json_path, "valid"); |
b05a1c8b DS |
5781 | |
5782 | /* Selected */ | |
5783 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
f1aa5d8a | 5784 | json_object_boolean_true_add(json_path, "history"); |
b05a1c8b DS |
5785 | |
5786 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
f1aa5d8a | 5787 | json_object_boolean_true_add(json_path, "damped"); |
b05a1c8b DS |
5788 | |
5789 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
f1aa5d8a | 5790 | json_object_boolean_true_add(json_path, "bestpath"); |
b05a1c8b DS |
5791 | |
5792 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) | |
f1aa5d8a | 5793 | json_object_boolean_true_add(json_path, "multipath"); |
b05a1c8b DS |
5794 | |
5795 | /* Internal route. */ | |
5796 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) | |
62d6dca0 | 5797 | json_object_string_add(json_path, "pathFrom", "internal"); |
b05a1c8b | 5798 | else |
62d6dca0 | 5799 | json_object_string_add(json_path, "pathFrom", "external"); |
b05a1c8b DS |
5800 | |
5801 | return; | |
5802 | } | |
5803 | ||
b40d939b | 5804 | /* Route status display. */ |
5805 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
5806 | vty_out (vty, "R"); | |
5807 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
93406d87 | 5808 | vty_out (vty, "S"); |
fb982c25 | 5809 | else if (binfo->extra && binfo->extra->suppress) |
718e3744 | 5810 | vty_out (vty, "s"); |
31eba040 DS |
5811 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && |
5812 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
718e3744 | 5813 | vty_out (vty, "*"); |
5814 | else | |
5815 | vty_out (vty, " "); | |
5816 | ||
5817 | /* Selected */ | |
5818 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5819 | vty_out (vty, "h"); | |
5820 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5821 | vty_out (vty, "d"); | |
5822 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
5823 | vty_out (vty, ">"); | |
b366b518 BB |
5824 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
5825 | vty_out (vty, "="); | |
718e3744 | 5826 | else |
5827 | vty_out (vty, " "); | |
5828 | ||
5829 | /* Internal route. */ | |
b05a1c8b DS |
5830 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
5831 | vty_out (vty, "i"); | |
5832 | else | |
5833 | vty_out (vty, " "); | |
b40d939b | 5834 | } |
5835 | ||
5836 | /* called from terminal list command */ | |
5837 | void | |
5838 | route_vty_out (struct vty *vty, struct prefix *p, | |
b05a1c8b DS |
5839 | struct bgp_info *binfo, int display, safi_t safi, |
5840 | json_object *json_paths) | |
b40d939b | 5841 | { |
5842 | struct attr *attr; | |
f1aa5d8a DS |
5843 | json_object *json_path = NULL; |
5844 | json_object *json_nexthops = NULL; | |
5845 | json_object *json_nexthop_global = NULL; | |
5846 | json_object *json_nexthop_ll = NULL; | |
47fc97cc | 5847 | |
b05a1c8b DS |
5848 | if (json_paths) |
5849 | json_path = json_object_new_object(); | |
b05a1c8b DS |
5850 | |
5851 | /* short status lead text */ | |
5852 | route_vty_short_status_out (vty, binfo, json_path); | |
718e3744 | 5853 | |
b05a1c8b DS |
5854 | if (!json_paths) |
5855 | { | |
5856 | /* print prefix and mask */ | |
5857 | if (! display) | |
5858 | route_vty_out_route (p, vty); | |
5859 | else | |
5860 | vty_out (vty, "%*s", 17, " "); | |
5861 | } | |
47fc97cc | 5862 | |
718e3744 | 5863 | /* Print attribute */ |
5864 | attr = binfo->attr; | |
5865 | if (attr) | |
5866 | { | |
587ff0fd LB |
5867 | /* |
5868 | * For ENCAP routes, nexthop address family is not | |
5869 | * neccessarily the same as the prefix address family. | |
5870 | * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field | |
5871 | */ | |
5872 | if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) | |
5873 | { | |
5874 | if (attr->extra) | |
5875 | { | |
5876 | char buf[BUFSIZ]; | |
5877 | int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); | |
b05a1c8b | 5878 | |
587ff0fd LB |
5879 | switch (af) |
5880 | { | |
5881 | case AF_INET: | |
5882 | vty_out (vty, "%s", inet_ntop(af, | |
5883 | &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); | |
5884 | break; | |
5885 | #if HAVE_IPV6 | |
5886 | case AF_INET6: | |
5887 | vty_out (vty, "%s", inet_ntop(af, | |
5888 | &attr->extra->mp_nexthop_global, buf, BUFSIZ)); | |
5889 | break; | |
5890 | #endif | |
5891 | default: | |
5892 | vty_out(vty, "?"); | |
5893 | break; | |
5894 | } | |
5895 | } | |
5896 | else | |
5897 | vty_out(vty, "?"); | |
5898 | } | |
b05a1c8b | 5899 | /* IPv4 Next Hop */ |
587ff0fd | 5900 | else if (p->family == AF_INET || !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) |
718e3744 | 5901 | { |
b05a1c8b DS |
5902 | if (json_paths) |
5903 | { | |
f1aa5d8a DS |
5904 | json_nexthop_global = json_object_new_object(); |
5905 | ||
b05a1c8b | 5906 | if (safi == SAFI_MPLS_VPN) |
f1aa5d8a | 5907 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->extra->mp_nexthop_global_in)); |
b05a1c8b | 5908 | else |
f1aa5d8a DS |
5909 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->nexthop)); |
5910 | ||
5911 | json_object_string_add(json_nexthop_global, "afi", "ipv4"); | |
5912 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
b05a1c8b DS |
5913 | } |
5914 | else | |
5915 | { | |
5916 | if (safi == SAFI_MPLS_VPN) | |
5917 | vty_out (vty, "%-16s", | |
5918 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
5919 | else | |
5920 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5921 | } | |
718e3744 | 5922 | } |
161995ea | 5923 | |
b05a1c8b | 5924 | /* IPv6 Next Hop */ |
8a92a8a0 | 5925 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) |
718e3744 | 5926 | { |
5927 | int len; | |
5928 | char buf[BUFSIZ]; | |
5929 | ||
b05a1c8b DS |
5930 | if (json_paths) |
5931 | { | |
f1aa5d8a DS |
5932 | json_nexthop_global = json_object_new_object(); |
5933 | json_object_string_add(json_nexthop_global, "ip", | |
5934 | inet_ntop (AF_INET6, | |
5935 | &attr->extra->mp_nexthop_global, | |
5936 | buf, BUFSIZ)); | |
5937 | json_object_string_add(json_nexthop_global, "afi", "ipv6"); | |
5938 | json_object_string_add(json_nexthop_global, "scope", "global"); | |
5939 | ||
5940 | /* We display both LL & GL if both have been received */ | |
5941 | if ((attr->extra->mp_nexthop_len == 32) || (binfo->peer->conf_if)) | |
5942 | { | |
5943 | json_nexthop_ll = json_object_new_object(); | |
5944 | json_object_string_add(json_nexthop_ll, "ip", | |
5945 | inet_ntop (AF_INET6, | |
5946 | &attr->extra->mp_nexthop_local, | |
5947 | buf, BUFSIZ)); | |
5948 | json_object_string_add(json_nexthop_ll, "afi", "ipv6"); | |
5949 | json_object_string_add(json_nexthop_ll, "scope", "link-local"); | |
5950 | ||
161995ea DS |
5951 | if ((IPV6_ADDR_CMP (&attr->extra->mp_nexthop_global, |
5952 | &attr->extra->mp_nexthop_local) != 0) && | |
5953 | !attr->extra->mp_nexthop_prefer_global) | |
f1aa5d8a DS |
5954 | json_object_boolean_true_add(json_nexthop_ll, "used"); |
5955 | else | |
5956 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
5957 | } | |
5958 | else | |
5959 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
b05a1c8b DS |
5960 | } |
5961 | else | |
5962 | { | |
161995ea DS |
5963 | /* Display LL if LL/Global both in table unless prefer-global is set */ |
5964 | if (((attr->extra->mp_nexthop_len == 32) && | |
5965 | !attr->extra->mp_nexthop_prefer_global) || | |
5966 | (binfo->peer->conf_if)) | |
433e8b67 DS |
5967 | { |
5968 | if (binfo->peer->conf_if) | |
5969 | { | |
5970 | len = vty_out (vty, "%s", | |
5971 | binfo->peer->conf_if); | |
5972 | len = 7 - len; /* len of IPv6 addr + max len of def ifname */ | |
5973 | ||
5974 | if (len < 1) | |
5975 | vty_out (vty, "%s%*s", VTY_NEWLINE, 45, " "); | |
5976 | else | |
5977 | vty_out (vty, "%*s", len, " "); | |
5978 | } | |
5979 | else | |
5980 | { | |
5981 | len = vty_out (vty, "%s", | |
5982 | inet_ntop (AF_INET6, | |
5983 | &attr->extra->mp_nexthop_local, | |
5984 | buf, BUFSIZ)); | |
5985 | len = 16 - len; | |
5986 | ||
5987 | if (len < 1) | |
5988 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5989 | else | |
5990 | vty_out (vty, "%*s", len, " "); | |
5991 | } | |
5992 | } | |
5993 | else | |
5994 | { | |
5995 | len = vty_out (vty, "%s", | |
5996 | inet_ntop (AF_INET6, | |
5997 | &attr->extra->mp_nexthop_global, | |
5998 | buf, BUFSIZ)); | |
5999 | len = 16 - len; | |
6000 | ||
6001 | if (len < 1) | |
6002 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
6003 | else | |
6004 | vty_out (vty, "%*s", len, " "); | |
6005 | } | |
b05a1c8b | 6006 | } |
718e3744 | 6007 | } |
718e3744 | 6008 | |
b05a1c8b | 6009 | /* MED/Metric */ |
718e3744 | 6010 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
b05a1c8b | 6011 | if (json_paths) |
f1aa5d8a | 6012 | json_object_int_add(json_path, "med", attr->med); |
b05a1c8b DS |
6013 | else |
6014 | vty_out (vty, "%10u", attr->med); | |
718e3744 | 6015 | else |
b05a1c8b DS |
6016 | if (!json_paths) |
6017 | vty_out (vty, " "); | |
47fc97cc | 6018 | |
b05a1c8b | 6019 | /* Local Pref */ |
718e3744 | 6020 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
b05a1c8b | 6021 | if (json_paths) |
f1aa5d8a | 6022 | json_object_int_add(json_path, "localpref", attr->local_pref); |
b05a1c8b DS |
6023 | else |
6024 | vty_out (vty, "%7u", attr->local_pref); | |
718e3744 | 6025 | else |
b05a1c8b DS |
6026 | if (!json_paths) |
6027 | vty_out (vty, " "); | |
718e3744 | 6028 | |
b05a1c8b DS |
6029 | if (json_paths) |
6030 | { | |
6031 | if (attr->extra) | |
f1aa5d8a | 6032 | json_object_int_add(json_path, "weight", attr->extra->weight); |
b05a1c8b | 6033 | else |
f1aa5d8a | 6034 | json_object_int_add(json_path, "weight", 0); |
b05a1c8b DS |
6035 | } |
6036 | else | |
6037 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); | |
47fc97cc | 6038 | |
39e871e6 ST |
6039 | if (json_paths) { |
6040 | char buf[BUFSIZ]; | |
6041 | json_object_string_add(json_path, "peerId", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); | |
6042 | } | |
6043 | ||
b2518c1e PJ |
6044 | /* Print aspath */ |
6045 | if (attr->aspath) | |
b05a1c8b DS |
6046 | { |
6047 | if (json_paths) | |
f1aa5d8a | 6048 | json_object_string_add(json_path, "aspath", attr->aspath->str); |
b05a1c8b | 6049 | else |
f1aa5d8a | 6050 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
b05a1c8b | 6051 | } |
47fc97cc | 6052 | |
b2518c1e | 6053 | /* Print origin */ |
b05a1c8b | 6054 | if (json_paths) |
f1aa5d8a | 6055 | json_object_string_add(json_path, "origin", bgp_origin_long_str[attr->origin]); |
b05a1c8b DS |
6056 | else |
6057 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
b2518c1e | 6058 | } |
856ca177 MS |
6059 | else |
6060 | { | |
6061 | if (json_paths) | |
6062 | json_object_string_add(json_path, "alert", "No attributes"); | |
6063 | else | |
6064 | vty_out (vty, "No attributes to print%s", VTY_NEWLINE); | |
6065 | } | |
b05a1c8b DS |
6066 | |
6067 | if (json_paths) | |
f1aa5d8a DS |
6068 | { |
6069 | if (json_nexthop_global || json_nexthop_ll) | |
6070 | { | |
6071 | json_nexthops = json_object_new_array(); | |
6072 | ||
6073 | if (json_nexthop_global) | |
6074 | json_object_array_add(json_nexthops, json_nexthop_global); | |
6075 | ||
6076 | if (json_nexthop_ll) | |
6077 | json_object_array_add(json_nexthops, json_nexthop_ll); | |
6078 | ||
6079 | json_object_object_add(json_path, "nexthops", json_nexthops); | |
6080 | } | |
6081 | ||
6082 | json_object_array_add(json_paths, json_path); | |
6083 | } | |
b05a1c8b DS |
6084 | else |
6085 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6086 | } |
6087 | ||
6088 | /* called from terminal list command */ | |
6089 | void | |
856ca177 MS |
6090 | route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t safi, |
6091 | u_char use_json, json_object *json_ar) | |
718e3744 | 6092 | { |
856ca177 MS |
6093 | json_object *json_status = NULL; |
6094 | json_object *json_net = NULL; | |
6095 | char buff[BUFSIZ]; | |
718e3744 | 6096 | /* Route status display. */ |
856ca177 MS |
6097 | if (use_json) |
6098 | { | |
6099 | json_status = json_object_new_object(); | |
6100 | json_net = json_object_new_object(); | |
6101 | } | |
6102 | else | |
6103 | { | |
6104 | vty_out (vty, "*"); | |
6105 | vty_out (vty, ">"); | |
6106 | vty_out (vty, " "); | |
6107 | } | |
718e3744 | 6108 | |
6109 | /* print prefix and mask */ | |
856ca177 MS |
6110 | if (use_json) |
6111 | json_object_string_add(json_net, "addrPrefix", inet_ntop (p->family, &p->u.prefix, buff, BUFSIZ)); | |
6112 | else | |
6113 | route_vty_out_route (p, vty); | |
718e3744 | 6114 | |
6115 | /* Print attribute */ | |
6116 | if (attr) | |
6117 | { | |
856ca177 | 6118 | if (use_json) |
718e3744 | 6119 | { |
587ff0fd LB |
6120 | if (p->family == AF_INET && |
6121 | (safi == SAFI_MPLS_VPN || | |
6122 | safi == SAFI_ENCAP || | |
6123 | !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
856ca177 | 6124 | { |
587ff0fd | 6125 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
856ca177 MS |
6126 | json_object_string_add(json_net, "nextHop", inet_ntoa (attr->extra->mp_nexthop_global_in)); |
6127 | else | |
6128 | json_object_string_add(json_net, "nextHop", inet_ntoa (attr->nexthop)); | |
6129 | } | |
6130 | #ifdef HAVE_IPV6 | |
6131 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) | |
6132 | { | |
6133 | char buf[BUFSIZ]; | |
718e3744 | 6134 | |
856ca177 MS |
6135 | json_object_string_add(json_net, "netHopGloabal", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
6136 | buf, BUFSIZ)); | |
6137 | } | |
6138 | #endif /* HAVE_IPV6 */ | |
6139 | ||
6140 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
6141 | json_object_int_add(json_net, "metric", attr->med); | |
6142 | ||
6143 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
6144 | json_object_int_add(json_net, "localPref", attr->local_pref); | |
6145 | ||
6146 | if (attr->extra) | |
6147 | json_object_int_add(json_net, "weight", attr->extra->weight); | |
718e3744 | 6148 | else |
856ca177 MS |
6149 | json_object_int_add(json_net, "weight", 0); |
6150 | ||
6151 | /* Print aspath */ | |
6152 | if (attr->aspath) | |
6153 | json_object_string_add(json_net, "asPath", attr->aspath->str); | |
6154 | ||
6155 | /* Print origin */ | |
6156 | json_object_string_add(json_net, "bgpOriginCode", bgp_origin_str[attr->origin]); | |
718e3744 | 6157 | } |
856ca177 MS |
6158 | else |
6159 | { | |
587ff0fd LB |
6160 | if (p->family == AF_INET && |
6161 | (safi == SAFI_MPLS_VPN || | |
6162 | safi == SAFI_ENCAP || | |
6163 | !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
856ca177 | 6164 | { |
587ff0fd | 6165 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
856ca177 MS |
6166 | vty_out (vty, "%-16s", |
6167 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
6168 | else | |
6169 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
6170 | } | |
6171 | #ifdef HAVE_IPV6 | |
6172 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) | |
6173 | { | |
6174 | int len; | |
6175 | char buf[BUFSIZ]; | |
6176 | ||
6177 | assert (attr->extra); | |
6178 | ||
6179 | len = vty_out (vty, "%s", | |
6180 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6181 | buf, BUFSIZ)); | |
6182 | len = 16 - len; | |
6183 | if (len < 1) | |
6184 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
6185 | else | |
6186 | vty_out (vty, "%*s", len, " "); | |
6187 | } | |
718e3744 | 6188 | #endif /* HAVE_IPV6 */ |
856ca177 MS |
6189 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
6190 | vty_out (vty, "%10u", attr->med); | |
6191 | else | |
6192 | vty_out (vty, " "); | |
718e3744 | 6193 | |
856ca177 MS |
6194 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
6195 | vty_out (vty, "%7u", attr->local_pref); | |
6196 | else | |
6197 | vty_out (vty, " "); | |
718e3744 | 6198 | |
856ca177 | 6199 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
718e3744 | 6200 | |
856ca177 MS |
6201 | /* Print aspath */ |
6202 | if (attr->aspath) | |
6203 | aspath_print_vty (vty, "%s", attr->aspath, " "); | |
718e3744 | 6204 | |
856ca177 MS |
6205 | /* Print origin */ |
6206 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
6207 | } | |
6208 | } | |
6209 | if (use_json) | |
6210 | { | |
6211 | json_object_boolean_true_add(json_status, "*"); | |
6212 | json_object_boolean_true_add(json_status, ">"); | |
6213 | json_object_object_add(json_net, "appliedStatusSymbols", json_status); | |
6214 | char buf_cut[BUFSIZ]; | |
6215 | json_object_object_add(json_ar, inet_ntop (p->family, &p->u.prefix, buf_cut, BUFSIZ), json_net); | |
6216 | } | |
6217 | else | |
6218 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6219 | } |
6220 | ||
5a646650 | 6221 | void |
718e3744 | 6222 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
856ca177 | 6223 | struct bgp_info *binfo, int display, safi_t safi, json_object *json) |
718e3744 | 6224 | { |
856ca177 | 6225 | json_object *json_out = NULL; |
718e3744 | 6226 | struct attr *attr; |
718e3744 | 6227 | u_int32_t label = 0; |
fb982c25 PJ |
6228 | |
6229 | if (!binfo->extra) | |
6230 | return; | |
856ca177 MS |
6231 | |
6232 | if (json) | |
6233 | json_out = json_object_new_object(); | |
fb982c25 | 6234 | |
b40d939b | 6235 | /* short status lead text */ |
856ca177 | 6236 | route_vty_short_status_out (vty, binfo, json_out); |
b40d939b | 6237 | |
718e3744 | 6238 | /* print prefix and mask */ |
856ca177 MS |
6239 | if (json == NULL) |
6240 | { | |
6241 | if (! display) | |
6242 | route_vty_out_route (p, vty); | |
6243 | else | |
6244 | vty_out (vty, "%*s", 17, " "); | |
6245 | } | |
718e3744 | 6246 | |
6247 | /* Print attribute */ | |
6248 | attr = binfo->attr; | |
6249 | if (attr) | |
6250 | { | |
8a92a8a0 DS |
6251 | if (p->family == AF_INET |
6252 | && (safi == SAFI_MPLS_VPN || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
718e3744 | 6253 | { |
587ff0fd | 6254 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
856ca177 MS |
6255 | { |
6256 | if (json) | |
6257 | json_object_string_add(json_out, "mpNexthopGlobalIn", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
6258 | else | |
6259 | vty_out (vty, "%-16s", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
6260 | } | |
718e3744 | 6261 | else |
856ca177 MS |
6262 | { |
6263 | if (json) | |
6264 | json_object_string_add(json_out, "nexthop", inet_ntoa (attr->nexthop)); | |
6265 | else | |
6266 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
6267 | } | |
718e3744 | 6268 | } |
6269 | #ifdef HAVE_IPV6 | |
8a92a8a0 | 6270 | else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) |
718e3744 | 6271 | { |
fb982c25 | 6272 | assert (attr->extra); |
856ca177 MS |
6273 | char buf_a[BUFSIZ]; |
6274 | char buf_b[BUFSIZ]; | |
6275 | char buf_c[BUFSIZ]; | |
801a9bcc | 6276 | if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) |
856ca177 MS |
6277 | { |
6278 | if (json) | |
6279 | json_object_string_add(json_out, "mpNexthopGlobalIn", | |
6280 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, buf_a, BUFSIZ)); | |
6281 | else | |
6282 | vty_out (vty, "%s", | |
6283 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6284 | buf_a, BUFSIZ)); | |
6285 | } | |
801a9bcc | 6286 | else if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) |
856ca177 MS |
6287 | { |
6288 | if (json) | |
6289 | { | |
6290 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6291 | buf_a, BUFSIZ); | |
6292 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
6293 | buf_b, BUFSIZ); | |
6294 | sprintf(buf_c, "%s(%s)", buf_a, buf_b); | |
6295 | json_object_string_add(json_out, "mpNexthopGlobalLocal", buf_c); | |
6296 | } | |
6297 | else | |
6298 | vty_out (vty, "%s(%s)", | |
6299 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6300 | buf_a, BUFSIZ), | |
6301 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
6302 | buf_b, BUFSIZ)); | |
6303 | } | |
6304 | ||
718e3744 | 6305 | } |
6306 | #endif /* HAVE_IPV6 */ | |
6307 | } | |
6308 | ||
fb982c25 | 6309 | label = decode_label (binfo->extra->tag); |
718e3744 | 6310 | |
856ca177 MS |
6311 | if (json) |
6312 | { | |
6313 | if (label) | |
6314 | json_object_int_add(json_out, "notag", label); | |
6315 | json_object_array_add(json, json_out); | |
6316 | } | |
6317 | else | |
6318 | { | |
6319 | vty_out (vty, "notag/%d", label); | |
6320 | vty_out (vty, "%s", VTY_NEWLINE); | |
6321 | } | |
718e3744 | 6322 | } |
6323 | ||
6324 | /* dampening route */ | |
5a646650 | 6325 | static void |
856ca177 MS |
6326 | damp_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, |
6327 | int display, safi_t safi, u_char use_json, json_object *json) | |
718e3744 | 6328 | { |
6329 | struct attr *attr; | |
718e3744 | 6330 | int len; |
50aef6f3 | 6331 | char timebuf[BGP_UPTIME_LEN]; |
718e3744 | 6332 | |
b40d939b | 6333 | /* short status lead text */ |
856ca177 | 6334 | route_vty_short_status_out (vty, binfo, json); |
b40d939b | 6335 | |
718e3744 | 6336 | /* print prefix and mask */ |
856ca177 MS |
6337 | if (!use_json) |
6338 | { | |
6339 | if (! display) | |
6340 | route_vty_out_route (p, vty); | |
6341 | else | |
6342 | vty_out (vty, "%*s", 17, " "); | |
6343 | } | |
718e3744 | 6344 | |
6345 | len = vty_out (vty, "%s", binfo->peer->host); | |
6346 | len = 17 - len; | |
6347 | if (len < 1) | |
856ca177 MS |
6348 | { |
6349 | if (!use_json) | |
6350 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); | |
6351 | } | |
718e3744 | 6352 | else |
856ca177 MS |
6353 | { |
6354 | if (use_json) | |
6355 | json_object_int_add(json, "peerHost", len); | |
6356 | else | |
6357 | vty_out (vty, "%*s", len, " "); | |
6358 | } | |
718e3744 | 6359 | |
856ca177 MS |
6360 | if (use_json) |
6361 | bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json); | |
6362 | else | |
6363 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json)); | |
718e3744 | 6364 | |
6365 | /* Print attribute */ | |
6366 | attr = binfo->attr; | |
6367 | if (attr) | |
6368 | { | |
6369 | /* Print aspath */ | |
6370 | if (attr->aspath) | |
856ca177 MS |
6371 | { |
6372 | if (use_json) | |
6373 | json_object_string_add(json, "asPath", attr->aspath->str); | |
6374 | else | |
6375 | aspath_print_vty (vty, "%s", attr->aspath, " "); | |
6376 | } | |
718e3744 | 6377 | |
6378 | /* Print origin */ | |
856ca177 MS |
6379 | if (use_json) |
6380 | json_object_string_add(json, "origin", bgp_origin_str[attr->origin]); | |
6381 | else | |
6382 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
718e3744 | 6383 | } |
856ca177 MS |
6384 | if (!use_json) |
6385 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6386 | } |
6387 | ||
718e3744 | 6388 | /* flap route */ |
5a646650 | 6389 | static void |
856ca177 MS |
6390 | flap_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, |
6391 | int display, safi_t safi, u_char use_json, json_object *json) | |
718e3744 | 6392 | { |
6393 | struct attr *attr; | |
6394 | struct bgp_damp_info *bdi; | |
718e3744 | 6395 | char timebuf[BGP_UPTIME_LEN]; |
6396 | int len; | |
fb982c25 PJ |
6397 | |
6398 | if (!binfo->extra) | |
6399 | return; | |
6400 | ||
6401 | bdi = binfo->extra->damp_info; | |
718e3744 | 6402 | |
b40d939b | 6403 | /* short status lead text */ |
856ca177 | 6404 | route_vty_short_status_out (vty, binfo, json); |
b40d939b | 6405 | |
718e3744 | 6406 | /* print prefix and mask */ |
856ca177 MS |
6407 | if (!use_json) |
6408 | { | |
6409 | if (! display) | |
6410 | route_vty_out_route (p, vty); | |
6411 | else | |
6412 | vty_out (vty, "%*s", 17, " "); | |
6413 | } | |
718e3744 | 6414 | |
6415 | len = vty_out (vty, "%s", binfo->peer->host); | |
6416 | len = 16 - len; | |
6417 | if (len < 1) | |
856ca177 MS |
6418 | { |
6419 | if (!use_json) | |
6420 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); | |
6421 | } | |
718e3744 | 6422 | else |
856ca177 MS |
6423 | { |
6424 | if (use_json) | |
6425 | json_object_int_add(json, "peerHost", len); | |
6426 | else | |
6427 | vty_out (vty, "%*s", len, " "); | |
6428 | } | |
718e3744 | 6429 | |
6430 | len = vty_out (vty, "%d", bdi->flap); | |
6431 | len = 5 - len; | |
6432 | if (len < 1) | |
856ca177 MS |
6433 | { |
6434 | if (!use_json) | |
6435 | vty_out (vty, " "); | |
6436 | } | |
718e3744 | 6437 | else |
856ca177 MS |
6438 | { |
6439 | if (use_json) | |
6440 | json_object_int_add(json, "bdiFlap", len); | |
6441 | else | |
6442 | vty_out (vty, "%*s", len, " "); | |
6443 | } | |
6444 | ||
6445 | if (use_json) | |
6446 | peer_uptime (bdi->start_time, timebuf, BGP_UPTIME_LEN, use_json, json); | |
6447 | else | |
6448 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, | |
6449 | timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
718e3744 | 6450 | |
6451 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) | |
6452 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
856ca177 MS |
6453 | { |
6454 | if (use_json) | |
6455 | bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json); | |
6456 | else | |
6457 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json)); | |
6458 | } | |
718e3744 | 6459 | else |
856ca177 MS |
6460 | { |
6461 | if (!use_json) | |
6462 | vty_out (vty, "%*s ", 8, " "); | |
6463 | } | |
718e3744 | 6464 | |
6465 | /* Print attribute */ | |
6466 | attr = binfo->attr; | |
6467 | if (attr) | |
6468 | { | |
6469 | /* Print aspath */ | |
6470 | if (attr->aspath) | |
856ca177 MS |
6471 | { |
6472 | if (use_json) | |
6473 | json_object_string_add(json, "asPath", attr->aspath->str); | |
6474 | else | |
6475 | aspath_print_vty (vty, "%s", attr->aspath, " "); | |
6476 | } | |
718e3744 | 6477 | |
6478 | /* Print origin */ | |
856ca177 MS |
6479 | if (use_json) |
6480 | json_object_string_add(json, "origin", bgp_origin_str[attr->origin]); | |
6481 | else | |
6482 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); | |
718e3744 | 6483 | } |
856ca177 MS |
6484 | if (!use_json) |
6485 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6486 | } |
6487 | ||
adbac85e DW |
6488 | static void |
6489 | route_vty_out_advertised_to (struct vty *vty, struct peer *peer, int *first, | |
6490 | const char *header, json_object *json_adv_to) | |
6491 | { | |
6492 | char buf1[INET6_ADDRSTRLEN]; | |
6493 | json_object *json_peer = NULL; | |
6494 | ||
6495 | if (json_adv_to) | |
6496 | { | |
6497 | /* 'advertised-to' is a dictionary of peers we have advertised this | |
6498 | * prefix too. The key is the peer's IP or swpX, the value is the | |
6499 | * hostname if we know it and "" if not. | |
6500 | */ | |
6501 | json_peer = json_object_new_object(); | |
6502 | ||
6503 | if (peer->hostname) | |
6504 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6505 | ||
6506 | if (peer->conf_if) | |
6507 | json_object_object_add(json_adv_to, peer->conf_if, json_peer); | |
6508 | else | |
6509 | json_object_object_add(json_adv_to, | |
6510 | sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN), | |
6511 | json_peer); | |
6512 | } | |
6513 | else | |
6514 | { | |
6515 | if (*first) | |
6516 | { | |
6517 | vty_out (vty, "%s", header); | |
6518 | *first = 0; | |
6519 | } | |
6520 | ||
6521 | if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6522 | { | |
6523 | if (peer->conf_if) | |
6524 | vty_out (vty, " %s(%s)", peer->hostname, peer->conf_if); | |
6525 | else | |
6526 | vty_out (vty, " %s(%s)", peer->hostname, | |
6527 | sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6528 | } | |
6529 | else | |
6530 | { | |
6531 | if (peer->conf_if) | |
6532 | vty_out (vty, " %s", peer->conf_if); | |
6533 | else | |
6534 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6535 | } | |
6536 | } | |
6537 | } | |
6538 | ||
94f2b392 | 6539 | static void |
718e3744 | 6540 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
b05a1c8b DS |
6541 | struct bgp_info *binfo, afi_t afi, safi_t safi, |
6542 | json_object *json_paths) | |
718e3744 | 6543 | { |
6544 | char buf[INET6_ADDRSTRLEN]; | |
6545 | char buf1[BUFSIZ]; | |
6546 | struct attr *attr; | |
6547 | int sockunion_vty_out (struct vty *, union sockunion *); | |
30b00176 JK |
6548 | #ifdef HAVE_CLOCK_MONOTONIC |
6549 | time_t tbuf; | |
6550 | #endif | |
f1aa5d8a | 6551 | json_object *json_bestpath = NULL; |
ffd0c037 | 6552 | json_object *json_cluster_list = NULL; |
f1aa5d8a DS |
6553 | json_object *json_cluster_list_list = NULL; |
6554 | json_object *json_ext_community = NULL; | |
6555 | json_object *json_last_update = NULL; | |
6556 | json_object *json_nexthop_global = NULL; | |
6557 | json_object *json_nexthop_ll = NULL; | |
6558 | json_object *json_nexthops = NULL; | |
6559 | json_object *json_path = NULL; | |
6560 | json_object *json_peer = NULL; | |
6561 | json_object *json_string = NULL; | |
adbac85e DW |
6562 | json_object *json_adv_to = NULL; |
6563 | int first = 0; | |
6564 | struct listnode *node, *nnode; | |
6565 | struct peer *peer; | |
6566 | int addpath_capable; | |
6567 | int has_adj; | |
06370dac | 6568 | int first_as; |
b05a1c8b DS |
6569 | |
6570 | if (json_paths) | |
6571 | { | |
6572 | json_path = json_object_new_object(); | |
f1aa5d8a DS |
6573 | json_peer = json_object_new_object(); |
6574 | json_nexthop_global = json_object_new_object(); | |
b05a1c8b DS |
6575 | } |
6576 | ||
718e3744 | 6577 | attr = binfo->attr; |
6578 | ||
6579 | if (attr) | |
6580 | { | |
6581 | /* Line1 display AS-path, Aggregator */ | |
6582 | if (attr->aspath) | |
6583 | { | |
f1aa5d8a DS |
6584 | if (json_paths) |
6585 | { | |
6586 | json_object_lock(attr->aspath->json); | |
6587 | json_object_object_add(json_path, "aspath", attr->aspath->json); | |
6588 | } | |
6589 | else | |
b05a1c8b | 6590 | { |
f1aa5d8a DS |
6591 | if (attr->aspath->segments) |
6592 | aspath_print_vty (vty, " %s", attr->aspath, ""); | |
b05a1c8b | 6593 | else |
f1aa5d8a | 6594 | vty_out (vty, " Local"); |
b05a1c8b | 6595 | } |
718e3744 | 6596 | } |
6597 | ||
b40d939b | 6598 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
b05a1c8b DS |
6599 | { |
6600 | if (json_paths) | |
f1aa5d8a | 6601 | json_object_boolean_true_add(json_path, "removed"); |
b05a1c8b DS |
6602 | else |
6603 | vty_out (vty, ", (removed)"); | |
6604 | } | |
6605 | ||
93406d87 | 6606 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
b05a1c8b DS |
6607 | { |
6608 | if (json_paths) | |
f1aa5d8a | 6609 | json_object_boolean_true_add(json_path, "stale"); |
b05a1c8b DS |
6610 | else |
6611 | vty_out (vty, ", (stale)"); | |
6612 | } | |
6613 | ||
93406d87 | 6614 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
b05a1c8b DS |
6615 | { |
6616 | if (json_paths) | |
6617 | { | |
62d6dca0 DS |
6618 | json_object_int_add(json_path, "aggregatorAs", attr->extra->aggregator_as); |
6619 | json_object_string_add(json_path, "aggregatorId", inet_ntoa (attr->extra->aggregator_addr)); | |
b05a1c8b DS |
6620 | } |
6621 | else | |
6622 | { | |
6623 | vty_out (vty, ", (aggregated by %u %s)", | |
6624 | attr->extra->aggregator_as, | |
6625 | inet_ntoa (attr->extra->aggregator_addr)); | |
6626 | } | |
6627 | } | |
6628 | ||
93406d87 | 6629 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
b05a1c8b DS |
6630 | { |
6631 | if (json_paths) | |
62d6dca0 | 6632 | json_object_boolean_true_add(json_path, "rxedFromRrClient"); |
b05a1c8b DS |
6633 | else |
6634 | vty_out (vty, ", (Received from a RR-client)"); | |
6635 | } | |
6636 | ||
93406d87 | 6637 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
b05a1c8b DS |
6638 | { |
6639 | if (json_paths) | |
62d6dca0 | 6640 | json_object_boolean_true_add(json_path, "rxedFromRsClient"); |
b05a1c8b DS |
6641 | else |
6642 | vty_out (vty, ", (Received from a RS-client)"); | |
6643 | } | |
6644 | ||
93406d87 | 6645 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
b05a1c8b DS |
6646 | { |
6647 | if (json_paths) | |
62d6dca0 | 6648 | json_object_boolean_true_add(json_path, "dampeningHistoryEntry"); |
b05a1c8b DS |
6649 | else |
6650 | vty_out (vty, ", (history entry)"); | |
6651 | } | |
93406d87 | 6652 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
b05a1c8b DS |
6653 | { |
6654 | if (json_paths) | |
62d6dca0 | 6655 | json_object_boolean_true_add(json_path, "dampeningSuppressed"); |
b05a1c8b DS |
6656 | else |
6657 | vty_out (vty, ", (suppressed due to dampening)"); | |
6658 | } | |
6659 | ||
6660 | if (!json_paths) | |
6661 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6662 | |
6663 | /* Line2 display Next-hop, Neighbor, Router-id */ | |
f1aa5d8a | 6664 | /* Display the nexthop */ |
587ff0fd LB |
6665 | if (p->family == AF_INET && |
6666 | (safi == SAFI_MPLS_VPN || | |
6667 | safi == SAFI_ENCAP || | |
6668 | !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) | |
718e3744 | 6669 | { |
587ff0fd | 6670 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
b05a1c8b DS |
6671 | { |
6672 | if (json_paths) | |
f1aa5d8a | 6673 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->extra->mp_nexthop_global_in)); |
b05a1c8b DS |
6674 | else |
6675 | vty_out (vty, " %s", inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
6676 | } | |
6677 | else | |
6678 | { | |
6679 | if (json_paths) | |
f1aa5d8a | 6680 | json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->nexthop)); |
b05a1c8b DS |
6681 | else |
6682 | vty_out (vty, " %s", inet_ntoa (attr->nexthop)); | |
6683 | } | |
6684 | ||
6685 | if (json_paths) | |
f1aa5d8a | 6686 | json_object_string_add(json_nexthop_global, "afi", "ipv4"); |
718e3744 | 6687 | } |
718e3744 | 6688 | else |
6689 | { | |
fb982c25 | 6690 | assert (attr->extra); |
b05a1c8b DS |
6691 | if (json_paths) |
6692 | { | |
f1aa5d8a DS |
6693 | json_object_string_add(json_nexthop_global, "ip", |
6694 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6695 | buf, INET6_ADDRSTRLEN)); | |
6696 | json_object_string_add(json_nexthop_global, "afi", "ipv6"); | |
6697 | json_object_string_add(json_nexthop_global, "scope", "global"); | |
b05a1c8b DS |
6698 | } |
6699 | else | |
6700 | { | |
6701 | vty_out (vty, " %s", | |
6702 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, | |
6703 | buf, INET6_ADDRSTRLEN)); | |
6704 | } | |
718e3744 | 6705 | } |
b05a1c8b | 6706 | |
f1aa5d8a DS |
6707 | /* Display the IGP cost or 'inaccessible' */ |
6708 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) | |
6709 | { | |
6710 | if (json_paths) | |
6711 | json_object_boolean_false_add(json_nexthop_global, "accessible"); | |
6712 | else | |
6713 | vty_out (vty, " (inaccessible)"); | |
6714 | } | |
6715 | else | |
6716 | { | |
6717 | if (binfo->extra && binfo->extra->igpmetric) | |
b05a1c8b DS |
6718 | { |
6719 | if (json_paths) | |
f1aa5d8a | 6720 | json_object_int_add(json_nexthop_global, "metric", binfo->extra->igpmetric); |
b05a1c8b | 6721 | else |
f1aa5d8a | 6722 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
b05a1c8b | 6723 | } |
f1aa5d8a DS |
6724 | |
6725 | /* IGP cost is 0, display this only for json */ | |
b05a1c8b DS |
6726 | else |
6727 | { | |
6728 | if (json_paths) | |
f1aa5d8a | 6729 | json_object_int_add(json_nexthop_global, "metric", 0); |
b05a1c8b DS |
6730 | } |
6731 | ||
6732 | if (json_paths) | |
f1aa5d8a DS |
6733 | json_object_boolean_true_add(json_nexthop_global, "accessible"); |
6734 | } | |
6735 | ||
6736 | /* Display peer "from" output */ | |
6737 | /* This path was originated locally */ | |
6738 | if (binfo->peer == bgp->peer_self) | |
718e3744 | 6739 | { |
f1aa5d8a DS |
6740 | |
6741 | if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) | |
b05a1c8b DS |
6742 | { |
6743 | if (json_paths) | |
62d6dca0 | 6744 | json_object_string_add(json_peer, "peerId", "0.0.0.0"); |
b05a1c8b | 6745 | else |
f1aa5d8a | 6746 | vty_out (vty, " from 0.0.0.0 "); |
b05a1c8b | 6747 | } |
f1aa5d8a | 6748 | else |
b05a1c8b DS |
6749 | { |
6750 | if (json_paths) | |
62d6dca0 | 6751 | json_object_string_add(json_peer, "peerId", "::"); |
b05a1c8b | 6752 | else |
f1aa5d8a | 6753 | vty_out (vty, " from :: "); |
b05a1c8b DS |
6754 | } |
6755 | ||
f1aa5d8a | 6756 | if (json_paths) |
62d6dca0 | 6757 | json_object_string_add(json_peer, "routerId", inet_ntoa(bgp->router_id)); |
b05a1c8b | 6758 | else |
f1aa5d8a DS |
6759 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
6760 | } | |
6761 | ||
6762 | /* We RXed this path from one of our peers */ | |
6763 | else | |
6764 | { | |
b05a1c8b DS |
6765 | |
6766 | if (json_paths) | |
6767 | { | |
62d6dca0 DS |
6768 | json_object_string_add(json_peer, "peerId", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
6769 | json_object_string_add(json_peer, "routerId", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
f1aa5d8a | 6770 | |
04b6bdc0 DW |
6771 | if (binfo->peer->hostname) |
6772 | json_object_string_add(json_peer, "hostname", binfo->peer->hostname); | |
6773 | ||
6774 | if (binfo->peer->domainname) | |
6775 | json_object_string_add(json_peer, "domainname", binfo->peer->domainname); | |
6776 | ||
036a4e7d | 6777 | if (binfo->peer->conf_if) |
f1aa5d8a | 6778 | json_object_string_add(json_peer, "interface", binfo->peer->conf_if); |
b05a1c8b DS |
6779 | } |
6780 | else | |
6781 | { | |
036a4e7d | 6782 | if (binfo->peer->conf_if) |
04b6bdc0 DW |
6783 | { |
6784 | if (binfo->peer->hostname && | |
6785 | bgp_flag_check(binfo->peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6786 | vty_out (vty, " from %s(%s)", binfo->peer->hostname, | |
6787 | binfo->peer->conf_if); | |
6788 | else | |
6789 | vty_out (vty, " from %s", binfo->peer->conf_if); | |
6790 | } | |
036a4e7d | 6791 | else |
04b6bdc0 DW |
6792 | { |
6793 | if (binfo->peer->hostname && | |
6794 | bgp_flag_check(binfo->peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6795 | vty_out (vty, " from %s(%s)", binfo->peer->hostname, | |
6796 | binfo->peer->host); | |
6797 | else | |
6798 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); | |
6799 | } | |
b05a1c8b | 6800 | |
f1aa5d8a DS |
6801 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
6802 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); | |
6803 | else | |
6804 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
b05a1c8b | 6805 | } |
718e3744 | 6806 | } |
b05a1c8b DS |
6807 | |
6808 | if (!json_paths) | |
6809 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 6810 | |
f1aa5d8a | 6811 | /* display the link-local nexthop */ |
801a9bcc | 6812 | if (attr->extra && attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) |
718e3744 | 6813 | { |
b05a1c8b DS |
6814 | if (json_paths) |
6815 | { | |
f1aa5d8a DS |
6816 | json_nexthop_ll = json_object_new_object(); |
6817 | json_object_string_add(json_nexthop_ll, "ip", | |
6818 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
6819 | buf, INET6_ADDRSTRLEN)); | |
6820 | json_object_string_add(json_nexthop_ll, "afi", "ipv6"); | |
6821 | json_object_string_add(json_nexthop_ll, "scope", "link-local"); | |
6822 | ||
6823 | json_object_boolean_true_add(json_nexthop_ll, "accessible"); | |
161995ea DS |
6824 | |
6825 | if (!attr->extra->mp_nexthop_prefer_global) | |
6826 | json_object_boolean_true_add(json_nexthop_ll, "used"); | |
6827 | else | |
6828 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
b05a1c8b DS |
6829 | } |
6830 | else | |
6831 | { | |
161995ea DS |
6832 | vty_out (vty, " (%s) %s%s", |
6833 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
b05a1c8b | 6834 | buf, INET6_ADDRSTRLEN), |
161995ea DS |
6835 | attr->extra->mp_nexthop_prefer_global ? |
6836 | "(prefer-global)" : "(used)", | |
b05a1c8b DS |
6837 | VTY_NEWLINE); |
6838 | } | |
718e3744 | 6839 | } |
f1aa5d8a DS |
6840 | /* If we do not have a link-local nexthop then we must flag the global as "used" */ |
6841 | else | |
6842 | { | |
6843 | if (json_paths) | |
6844 | json_object_boolean_true_add(json_nexthop_global, "used"); | |
6845 | } | |
718e3744 | 6846 | |
0d9551dc | 6847 | /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */ |
b05a1c8b | 6848 | if (json_paths) |
f1aa5d8a | 6849 | json_object_string_add(json_path, "origin", bgp_origin_long_str[attr->origin]); |
b05a1c8b | 6850 | else |
f1aa5d8a | 6851 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
718e3744 | 6852 | |
6853 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) | |
b05a1c8b DS |
6854 | { |
6855 | if (json_paths) | |
f1aa5d8a | 6856 | json_object_int_add(json_path, "med", attr->med); |
b05a1c8b | 6857 | else |
f1aa5d8a | 6858 | vty_out (vty, ", metric %u", attr->med); |
b05a1c8b | 6859 | } |
718e3744 | 6860 | |
6861 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) | |
b05a1c8b DS |
6862 | { |
6863 | if (json_paths) | |
f1aa5d8a | 6864 | json_object_int_add(json_path, "localpref", attr->local_pref); |
b05a1c8b | 6865 | else |
f1aa5d8a | 6866 | vty_out (vty, ", localpref %u", attr->local_pref); |
b05a1c8b | 6867 | } |
718e3744 | 6868 | else |
b05a1c8b DS |
6869 | { |
6870 | if (json_paths) | |
f1aa5d8a | 6871 | json_object_int_add(json_path, "localpref", bgp->default_local_pref); |
b05a1c8b | 6872 | else |
f1aa5d8a | 6873 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
b05a1c8b | 6874 | } |
718e3744 | 6875 | |
fb982c25 | 6876 | if (attr->extra && attr->extra->weight != 0) |
b05a1c8b DS |
6877 | { |
6878 | if (json_paths) | |
f1aa5d8a | 6879 | json_object_int_add(json_path, "weight", attr->extra->weight); |
b05a1c8b | 6880 | else |
f1aa5d8a | 6881 | vty_out (vty, ", weight %u", attr->extra->weight); |
b05a1c8b | 6882 | } |
0d9551dc DS |
6883 | |
6884 | if (attr->extra && attr->extra->tag != 0) | |
b05a1c8b DS |
6885 | { |
6886 | if (json_paths) | |
f1aa5d8a | 6887 | json_object_int_add(json_path, "tag", attr->extra->tag); |
b05a1c8b | 6888 | else |
f1aa5d8a | 6889 | vty_out (vty, ", tag %d", attr->extra->tag); |
b05a1c8b | 6890 | } |
718e3744 | 6891 | |
31eba040 | 6892 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
b05a1c8b DS |
6893 | { |
6894 | if (json_paths) | |
f1aa5d8a | 6895 | json_object_boolean_false_add(json_path, "valid"); |
b05a1c8b DS |
6896 | else |
6897 | vty_out (vty, ", invalid"); | |
6898 | } | |
31eba040 | 6899 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
b05a1c8b DS |
6900 | { |
6901 | if (json_paths) | |
f1aa5d8a | 6902 | json_object_boolean_true_add(json_path, "valid"); |
b05a1c8b DS |
6903 | else |
6904 | vty_out (vty, ", valid"); | |
6905 | } | |
718e3744 | 6906 | |
6907 | if (binfo->peer != bgp->peer_self) | |
6908 | { | |
f1aa5d8a | 6909 | if (binfo->peer->as == binfo->peer->local_as) |
b05a1c8b | 6910 | { |
66b199b2 DS |
6911 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
6912 | { | |
6913 | if (json_paths) | |
f1aa5d8a | 6914 | json_object_string_add(json_peer, "type", "confed-internal"); |
66b199b2 | 6915 | else |
f1aa5d8a | 6916 | vty_out (vty, ", confed-internal"); |
66b199b2 | 6917 | } |
b05a1c8b | 6918 | else |
66b199b2 DS |
6919 | { |
6920 | if (json_paths) | |
f1aa5d8a | 6921 | json_object_string_add(json_peer, "type", "internal"); |
66b199b2 | 6922 | else |
f1aa5d8a | 6923 | vty_out (vty, ", internal"); |
66b199b2 | 6924 | } |
b05a1c8b | 6925 | } |
f1aa5d8a | 6926 | else |
b05a1c8b DS |
6927 | { |
6928 | if (bgp_confederation_peers_check(bgp, binfo->peer->as)) | |
6929 | { | |
6930 | if (json_paths) | |
f1aa5d8a | 6931 | json_object_string_add(json_peer, "type", "confed-external"); |
b05a1c8b | 6932 | else |
f1aa5d8a | 6933 | vty_out (vty, ", confed-external"); |
b05a1c8b DS |
6934 | } |
6935 | else | |
6936 | { | |
6937 | if (json_paths) | |
f1aa5d8a | 6938 | json_object_string_add(json_peer, "type", "external"); |
b05a1c8b | 6939 | else |
f1aa5d8a | 6940 | vty_out (vty, ", external"); |
b05a1c8b DS |
6941 | } |
6942 | } | |
718e3744 | 6943 | } |
6944 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) | |
b05a1c8b DS |
6945 | { |
6946 | if (json_paths) | |
6947 | { | |
f1aa5d8a DS |
6948 | json_object_boolean_true_add(json_path, "aggregated"); |
6949 | json_object_boolean_true_add(json_path, "local"); | |
b05a1c8b DS |
6950 | } |
6951 | else | |
6952 | { | |
6953 | vty_out (vty, ", aggregated, local"); | |
6954 | } | |
6955 | } | |
718e3744 | 6956 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
b05a1c8b DS |
6957 | { |
6958 | if (json_paths) | |
f1aa5d8a | 6959 | json_object_boolean_true_add(json_path, "sourced"); |
b05a1c8b DS |
6960 | else |
6961 | vty_out (vty, ", sourced"); | |
6962 | } | |
718e3744 | 6963 | else |
b05a1c8b DS |
6964 | { |
6965 | if (json_paths) | |
6966 | { | |
f1aa5d8a DS |
6967 | json_object_boolean_true_add(json_path, "sourced"); |
6968 | json_object_boolean_true_add(json_path, "local"); | |
b05a1c8b DS |
6969 | } |
6970 | else | |
6971 | { | |
6972 | vty_out (vty, ", sourced, local"); | |
6973 | } | |
6974 | } | |
718e3744 | 6975 | |
6976 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) | |
b05a1c8b DS |
6977 | { |
6978 | if (json_paths) | |
62d6dca0 | 6979 | json_object_boolean_true_add(json_path, "atomicAggregate"); |
b05a1c8b DS |
6980 | else |
6981 | vty_out (vty, ", atomic-aggregate"); | |
6982 | } | |
718e3744 | 6983 | |
de8d5dff JB |
6984 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
6985 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && | |
6986 | bgp_info_mpath_count (binfo))) | |
b05a1c8b DS |
6987 | { |
6988 | if (json_paths) | |
f1aa5d8a | 6989 | json_object_boolean_true_add(json_path, "multipath"); |
b05a1c8b DS |
6990 | else |
6991 | vty_out (vty, ", multipath"); | |
6992 | } | |
de8d5dff | 6993 | |
06370dac DW |
6994 | // Mark the bestpath(s) |
6995 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DMED_SELECTED)) | |
6996 | { | |
6997 | first_as = aspath_get_firstas(attr->aspath); | |
6998 | ||
6999 | if (json_paths) | |
7000 | { | |
7001 | if (!json_bestpath) | |
7002 | json_bestpath = json_object_new_object(); | |
7003 | json_object_int_add(json_bestpath, "bestpathFromAs", first_as); | |
7004 | } | |
7005 | else | |
7006 | { | |
7007 | if (first_as) | |
7008 | vty_out (vty, ", bestpath-from-AS %d", first_as); | |
7009 | else | |
7010 | vty_out (vty, ", bestpath-from-AS Local"); | |
7011 | } | |
7012 | } | |
7013 | ||
718e3744 | 7014 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
b05a1c8b DS |
7015 | { |
7016 | if (json_paths) | |
f1aa5d8a | 7017 | { |
06370dac DW |
7018 | if (!json_bestpath) |
7019 | json_bestpath = json_object_new_object(); | |
f1aa5d8a | 7020 | json_object_boolean_true_add(json_bestpath, "overall"); |
f1aa5d8a | 7021 | } |
b05a1c8b DS |
7022 | else |
7023 | vty_out (vty, ", best"); | |
7024 | } | |
718e3744 | 7025 | |
06370dac DW |
7026 | if (json_bestpath) |
7027 | json_object_object_add(json_path, "bestpath", json_bestpath); | |
7028 | ||
b05a1c8b DS |
7029 | if (!json_paths) |
7030 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 7031 | |
7032 | /* Line 4 display Community */ | |
7033 | if (attr->community) | |
b05a1c8b DS |
7034 | { |
7035 | if (json_paths) | |
7036 | { | |
f1aa5d8a DS |
7037 | json_object_lock(attr->community->json); |
7038 | json_object_object_add(json_path, "community", attr->community->json); | |
b05a1c8b DS |
7039 | } |
7040 | else | |
7041 | { | |
7042 | vty_out (vty, " Community: %s%s", attr->community->str, | |
7043 | VTY_NEWLINE); | |
7044 | } | |
7045 | } | |
718e3744 | 7046 | |
7047 | /* Line 5 display Extended-community */ | |
7048 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) | |
b05a1c8b DS |
7049 | { |
7050 | if (json_paths) | |
7051 | { | |
f1aa5d8a DS |
7052 | json_ext_community = json_object_new_object(); |
7053 | json_object_string_add(json_ext_community, "string", attr->extra->ecommunity->str); | |
62d6dca0 | 7054 | json_object_object_add(json_path, "extendedCommunity", json_ext_community); |
b05a1c8b DS |
7055 | } |
7056 | else | |
7057 | { | |
7058 | vty_out (vty, " Extended Community: %s%s", | |
7059 | attr->extra->ecommunity->str, VTY_NEWLINE); | |
7060 | } | |
7061 | } | |
7062 | ||
718e3744 | 7063 | /* Line 6 display Originator, Cluster-id */ |
7064 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || | |
7065 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) | |
7066 | { | |
fb982c25 | 7067 | assert (attr->extra); |
718e3744 | 7068 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
b05a1c8b DS |
7069 | { |
7070 | if (json_paths) | |
62d6dca0 | 7071 | json_object_string_add(json_path, "originatorId", inet_ntoa (attr->extra->originator_id)); |
b05a1c8b | 7072 | else |
f1aa5d8a DS |
7073 | vty_out (vty, " Originator: %s", |
7074 | inet_ntoa (attr->extra->originator_id)); | |
b05a1c8b | 7075 | } |
718e3744 | 7076 | |
7077 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
7078 | { | |
7079 | int i; | |
b05a1c8b DS |
7080 | |
7081 | if (json_paths) | |
7082 | { | |
f1aa5d8a DS |
7083 | json_cluster_list = json_object_new_object(); |
7084 | json_cluster_list_list = json_object_new_array(); | |
7085 | ||
b05a1c8b DS |
7086 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
7087 | { | |
7088 | json_string = json_object_new_string(inet_ntoa (attr->extra->cluster->list[i])); | |
f1aa5d8a | 7089 | json_object_array_add(json_cluster_list_list, json_string); |
b05a1c8b | 7090 | } |
f1aa5d8a DS |
7091 | |
7092 | /* struct cluster_list does not have "str" variable like | |
7093 | * aspath and community do. Add this someday if someone | |
7094 | * asks for it. | |
7095 | json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str); | |
7096 | */ | |
7097 | json_object_object_add(json_cluster_list, "list", json_cluster_list_list); | |
62d6dca0 | 7098 | json_object_object_add(json_path, "clusterList", json_cluster_list); |
b05a1c8b DS |
7099 | } |
7100 | else | |
7101 | { | |
7102 | vty_out (vty, ", Cluster list: "); | |
7103 | ||
7104 | for (i = 0; i < attr->extra->cluster->length / 4; i++) | |
7105 | { | |
7106 | vty_out (vty, "%s ", | |
7107 | inet_ntoa (attr->extra->cluster->list[i])); | |
7108 | } | |
7109 | } | |
718e3744 | 7110 | } |
b05a1c8b DS |
7111 | |
7112 | if (!json_paths) | |
7113 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 7114 | } |
b05a1c8b | 7115 | |
fb982c25 | 7116 | if (binfo->extra && binfo->extra->damp_info) |
b05a1c8b | 7117 | bgp_damp_info_vty (vty, binfo, json_path); |
718e3744 | 7118 | |
a82478b9 DS |
7119 | /* Line 7 display Addpath IDs */ |
7120 | if (binfo->addpath_rx_id || binfo->addpath_tx_id) | |
b05a1c8b DS |
7121 | { |
7122 | if (json_paths) | |
7123 | { | |
62d6dca0 DS |
7124 | json_object_int_add(json_path, "addpathRxId", binfo->addpath_rx_id); |
7125 | json_object_int_add(json_path, "addpathTxId", binfo->addpath_tx_id); | |
b05a1c8b DS |
7126 | } |
7127 | else | |
7128 | { | |
7129 | vty_out (vty, " AddPath ID: RX %u, TX %u%s", | |
7130 | binfo->addpath_rx_id, binfo->addpath_tx_id, | |
7131 | VTY_NEWLINE); | |
7132 | } | |
7133 | } | |
a82478b9 | 7134 | |
adbac85e DW |
7135 | /* If we used addpath to TX a non-bestpath we need to display |
7136 | * "Advertised to" on a path-by-path basis */ | |
7137 | if (bgp->addpath_tx_used[afi][safi]) | |
7138 | { | |
7139 | first = 1; | |
7140 | ||
7141 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
7142 | { | |
7143 | addpath_capable = bgp_addpath_encode_tx (peer, afi, safi); | |
7144 | has_adj = bgp_adj_out_lookup (peer, binfo->net, binfo->addpath_tx_id); | |
7145 | ||
7146 | if ((addpath_capable && has_adj) || | |
7147 | (!addpath_capable && has_adj && CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))) | |
7148 | { | |
7149 | if (json_path && !json_adv_to) | |
7150 | json_adv_to = json_object_new_object(); | |
7151 | ||
7152 | route_vty_out_advertised_to(vty, peer, &first, | |
7153 | " Advertised to:", | |
7154 | json_adv_to); | |
7155 | } | |
7156 | } | |
7157 | ||
7158 | if (json_path) | |
7159 | { | |
7160 | if (json_adv_to) | |
7161 | { | |
7162 | json_object_object_add(json_path, "advertisedTo", json_adv_to); | |
7163 | } | |
7164 | } | |
7165 | else | |
7166 | { | |
7167 | if (!first) | |
7168 | { | |
7169 | vty_out (vty, "%s", VTY_NEWLINE); | |
7170 | } | |
7171 | } | |
7172 | } | |
7173 | ||
a82478b9 | 7174 | /* Line 8 display Uptime */ |
30b00176 JK |
7175 | #ifdef HAVE_CLOCK_MONOTONIC |
7176 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); | |
b05a1c8b | 7177 | if (json_paths) |
f1aa5d8a DS |
7178 | { |
7179 | json_last_update = json_object_new_object(); | |
7180 | json_object_int_add(json_last_update, "epoch", tbuf); | |
7181 | json_object_string_add(json_last_update, "string", ctime(&tbuf)); | |
62d6dca0 | 7182 | json_object_object_add(json_path, "lastUpdate", json_last_update); |
f1aa5d8a | 7183 | } |
b05a1c8b DS |
7184 | else |
7185 | vty_out (vty, " Last update: %s", ctime(&tbuf)); | |
30b00176 | 7186 | #else |
b05a1c8b | 7187 | if (json_paths) |
f1aa5d8a DS |
7188 | { |
7189 | json_last_update = json_object_new_object(); | |
7190 | json_object_int_add(json_last_update, "epoch", tbuf); | |
7191 | json_object_string_add(json_last_update, "string", ctime(&binfo->uptime)); | |
62d6dca0 | 7192 | json_object_object_add(json_path, "lastUpdate", json_last_update); |
f1aa5d8a | 7193 | } |
b05a1c8b DS |
7194 | else |
7195 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); | |
30b00176 | 7196 | #endif /* HAVE_CLOCK_MONOTONIC */ |
718e3744 | 7197 | } |
b05a1c8b DS |
7198 | |
7199 | /* We've constructed the json object for this path, add it to the json | |
7200 | * array of paths | |
7201 | */ | |
7202 | if (json_paths) | |
f1aa5d8a DS |
7203 | { |
7204 | if (json_nexthop_global || json_nexthop_ll) | |
7205 | { | |
7206 | json_nexthops = json_object_new_array(); | |
7207 | ||
7208 | if (json_nexthop_global) | |
7209 | json_object_array_add(json_nexthops, json_nexthop_global); | |
7210 | ||
7211 | if (json_nexthop_ll) | |
7212 | json_object_array_add(json_nexthops, json_nexthop_ll); | |
7213 | ||
7214 | json_object_object_add(json_path, "nexthops", json_nexthops); | |
7215 | } | |
7216 | ||
7217 | json_object_object_add(json_path, "peer", json_peer); | |
7218 | json_object_array_add(json_paths, json_path); | |
7219 | } | |
b05a1c8b DS |
7220 | else |
7221 | vty_out (vty, "%s", VTY_NEWLINE); | |
b366b518 BB |
7222 | } |
7223 | ||
47fc97cc | 7224 | #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s" |
718e3744 | 7225 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
7226 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" | |
7227 | ||
7228 | enum bgp_show_type | |
7229 | { | |
7230 | bgp_show_type_normal, | |
7231 | bgp_show_type_regexp, | |
7232 | bgp_show_type_prefix_list, | |
7233 | bgp_show_type_filter_list, | |
7234 | bgp_show_type_route_map, | |
7235 | bgp_show_type_neighbor, | |
7236 | bgp_show_type_cidr_only, | |
7237 | bgp_show_type_prefix_longer, | |
7238 | bgp_show_type_community_all, | |
7239 | bgp_show_type_community, | |
7240 | bgp_show_type_community_exact, | |
7241 | bgp_show_type_community_list, | |
7242 | bgp_show_type_community_list_exact, | |
7243 | bgp_show_type_flap_statistics, | |
7244 | bgp_show_type_flap_address, | |
7245 | bgp_show_type_flap_prefix, | |
7246 | bgp_show_type_flap_cidr_only, | |
7247 | bgp_show_type_flap_regexp, | |
7248 | bgp_show_type_flap_filter_list, | |
7249 | bgp_show_type_flap_prefix_list, | |
7250 | bgp_show_type_flap_prefix_longer, | |
7251 | bgp_show_type_flap_route_map, | |
7252 | bgp_show_type_flap_neighbor, | |
7253 | bgp_show_type_dampend_paths, | |
7254 | bgp_show_type_damp_neighbor | |
7255 | }; | |
7256 | ||
50ef26d4 | 7257 | static int |
7258 | bgp_show_prefix_list (struct vty *vty, const char *name, | |
7259 | const char *prefix_list_str, afi_t afi, | |
7260 | safi_t safi, enum bgp_show_type type); | |
7261 | static int | |
7262 | bgp_show_filter_list (struct vty *vty, const char *name, | |
7263 | const char *filter, afi_t afi, | |
7264 | safi_t safi, enum bgp_show_type type); | |
7265 | static int | |
7266 | bgp_show_route_map (struct vty *vty, const char *name, | |
7267 | const char *rmap_str, afi_t afi, | |
7268 | safi_t safi, enum bgp_show_type type); | |
7269 | static int | |
7270 | bgp_show_community_list (struct vty *vty, const char *name, | |
7271 | const char *com, int exact, | |
7272 | afi_t afi, safi_t safi); | |
7273 | static int | |
7274 | bgp_show_prefix_longer (struct vty *vty, const char *name, | |
7275 | const char *prefix, afi_t afi, | |
7276 | safi_t safi, enum bgp_show_type type); | |
7277 | ||
5a646650 | 7278 | static int |
9f689658 DD |
7279 | bgp_show_table (struct vty *vty, struct bgp_table *table, |
7280 | struct in_addr *router_id, enum bgp_show_type type, | |
7281 | void *output_arg, u_char use_json, json_object *json) | |
718e3744 | 7282 | { |
718e3744 | 7283 | struct bgp_info *ri; |
7284 | struct bgp_node *rn; | |
718e3744 | 7285 | int header = 1; |
718e3744 | 7286 | int display; |
5a646650 | 7287 | unsigned long output_count; |
b05a1c8b DS |
7288 | struct prefix *p; |
7289 | char buf[BUFSIZ]; | |
7290 | char buf2[BUFSIZ]; | |
f1aa5d8a DS |
7291 | json_object *json_paths = NULL; |
7292 | json_object *json_routes = NULL; | |
b05a1c8b DS |
7293 | |
7294 | if (use_json) | |
7295 | { | |
9f689658 DD |
7296 | if (json == NULL) |
7297 | json = json_object_new_object(); | |
7298 | ||
62d6dca0 DS |
7299 | json_object_int_add(json, "tableVersion", table->version); |
7300 | json_object_string_add(json, "routerId", inet_ntoa (*router_id)); | |
b05a1c8b DS |
7301 | json_routes = json_object_new_object(); |
7302 | } | |
718e3744 | 7303 | |
7304 | /* This is first entry point, so reset total line. */ | |
5a646650 | 7305 | output_count = 0; |
718e3744 | 7306 | |
718e3744 | 7307 | /* Start processing of routes. */ |
7308 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
7309 | if (rn->info != NULL) | |
7310 | { | |
856ca177 | 7311 | display = 0; |
718e3744 | 7312 | |
b05a1c8b DS |
7313 | if (use_json) |
7314 | json_paths = json_object_new_array(); | |
7315 | else | |
7316 | json_paths = NULL; | |
7317 | ||
856ca177 MS |
7318 | for (ri = rn->info; ri; ri = ri->next) |
7319 | { | |
7320 | if (type == bgp_show_type_flap_statistics | |
7321 | || type == bgp_show_type_flap_address | |
7322 | || type == bgp_show_type_flap_prefix | |
7323 | || type == bgp_show_type_flap_cidr_only | |
7324 | || type == bgp_show_type_flap_regexp | |
7325 | || type == bgp_show_type_flap_filter_list | |
7326 | || type == bgp_show_type_flap_prefix_list | |
7327 | || type == bgp_show_type_flap_prefix_longer | |
7328 | || type == bgp_show_type_flap_route_map | |
7329 | || type == bgp_show_type_flap_neighbor | |
7330 | || type == bgp_show_type_dampend_paths | |
7331 | || type == bgp_show_type_damp_neighbor) | |
7332 | { | |
7333 | if (!(ri->extra && ri->extra->damp_info)) | |
7334 | continue; | |
7335 | } | |
7336 | if (type == bgp_show_type_regexp | |
7337 | || type == bgp_show_type_flap_regexp) | |
7338 | { | |
7339 | regex_t *regex = output_arg; | |
718e3744 | 7340 | |
856ca177 MS |
7341 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
7342 | continue; | |
7343 | } | |
7344 | if (type == bgp_show_type_prefix_list | |
7345 | || type == bgp_show_type_flap_prefix_list) | |
7346 | { | |
7347 | struct prefix_list *plist = output_arg; | |
718e3744 | 7348 | |
856ca177 MS |
7349 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
7350 | continue; | |
7351 | } | |
7352 | if (type == bgp_show_type_filter_list | |
7353 | || type == bgp_show_type_flap_filter_list) | |
7354 | { | |
7355 | struct as_list *as_list = output_arg; | |
558d1fec | 7356 | |
856ca177 MS |
7357 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
7358 | continue; | |
7359 | } | |
7360 | if (type == bgp_show_type_route_map | |
7361 | || type == bgp_show_type_flap_route_map) | |
7362 | { | |
7363 | struct route_map *rmap = output_arg; | |
7364 | struct bgp_info binfo; | |
7365 | struct attr dummy_attr; | |
7366 | struct attr_extra dummy_extra; | |
7367 | int ret; | |
718e3744 | 7368 | |
856ca177 MS |
7369 | dummy_attr.extra = &dummy_extra; |
7370 | bgp_attr_dup (&dummy_attr, ri->attr); | |
718e3744 | 7371 | |
856ca177 MS |
7372 | binfo.peer = ri->peer; |
7373 | binfo.attr = &dummy_attr; | |
718e3744 | 7374 | |
856ca177 MS |
7375 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
7376 | if (ret == RMAP_DENYMATCH) | |
7377 | continue; | |
7378 | } | |
7379 | if (type == bgp_show_type_neighbor | |
7380 | || type == bgp_show_type_flap_neighbor | |
7381 | || type == bgp_show_type_damp_neighbor) | |
7382 | { | |
7383 | union sockunion *su = output_arg; | |
718e3744 | 7384 | |
856ca177 MS |
7385 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
7386 | continue; | |
7387 | } | |
7388 | if (type == bgp_show_type_cidr_only | |
7389 | || type == bgp_show_type_flap_cidr_only) | |
7390 | { | |
7391 | u_int32_t destination; | |
718e3744 | 7392 | |
856ca177 MS |
7393 | destination = ntohl (rn->p.u.prefix4.s_addr); |
7394 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) | |
7395 | continue; | |
7396 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) | |
7397 | continue; | |
7398 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) | |
7399 | continue; | |
7400 | } | |
7401 | if (type == bgp_show_type_prefix_longer | |
7402 | || type == bgp_show_type_flap_prefix_longer) | |
7403 | { | |
7404 | struct prefix *p = output_arg; | |
718e3744 | 7405 | |
856ca177 MS |
7406 | if (! prefix_match (p, &rn->p)) |
7407 | continue; | |
7408 | } | |
7409 | if (type == bgp_show_type_community_all) | |
7410 | { | |
7411 | if (! ri->attr->community) | |
7412 | continue; | |
7413 | } | |
7414 | if (type == bgp_show_type_community) | |
7415 | { | |
7416 | struct community *com = output_arg; | |
718e3744 | 7417 | |
856ca177 MS |
7418 | if (! ri->attr->community || |
7419 | ! community_match (ri->attr->community, com)) | |
7420 | continue; | |
7421 | } | |
7422 | if (type == bgp_show_type_community_exact) | |
7423 | { | |
7424 | struct community *com = output_arg; | |
718e3744 | 7425 | |
856ca177 MS |
7426 | if (! ri->attr->community || |
7427 | ! community_cmp (ri->attr->community, com)) | |
7428 | continue; | |
7429 | } | |
7430 | if (type == bgp_show_type_community_list) | |
7431 | { | |
7432 | struct community_list *list = output_arg; | |
718e3744 | 7433 | |
856ca177 MS |
7434 | if (! community_list_match (ri->attr->community, list)) |
7435 | continue; | |
7436 | } | |
7437 | if (type == bgp_show_type_community_list_exact) | |
7438 | { | |
7439 | struct community_list *list = output_arg; | |
718e3744 | 7440 | |
856ca177 MS |
7441 | if (! community_list_exact_match (ri->attr->community, list)) |
7442 | continue; | |
7443 | } | |
7444 | if (type == bgp_show_type_flap_address | |
7445 | || type == bgp_show_type_flap_prefix) | |
7446 | { | |
7447 | struct prefix *p = output_arg; | |
718e3744 | 7448 | |
856ca177 MS |
7449 | if (! prefix_match (&rn->p, p)) |
7450 | continue; | |
b05a1c8b | 7451 | |
856ca177 MS |
7452 | if (type == bgp_show_type_flap_prefix) |
7453 | if (p->prefixlen != rn->p.prefixlen) | |
7454 | continue; | |
7455 | } | |
7456 | if (type == bgp_show_type_dampend_paths | |
7457 | || type == bgp_show_type_damp_neighbor) | |
7458 | { | |
7459 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) | |
7460 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
7461 | continue; | |
7462 | } | |
7463 | ||
7464 | if (!use_json && header) | |
7465 | { | |
7466 | vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (*router_id), VTY_NEWLINE); | |
7467 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
7468 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
7469 | if (type == bgp_show_type_dampend_paths | |
7470 | || type == bgp_show_type_damp_neighbor) | |
7471 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); | |
7472 | else if (type == bgp_show_type_flap_statistics | |
7473 | || type == bgp_show_type_flap_address | |
7474 | || type == bgp_show_type_flap_prefix | |
7475 | || type == bgp_show_type_flap_cidr_only | |
7476 | || type == bgp_show_type_flap_regexp | |
7477 | || type == bgp_show_type_flap_filter_list | |
7478 | || type == bgp_show_type_flap_prefix_list | |
7479 | || type == bgp_show_type_flap_prefix_longer | |
7480 | || type == bgp_show_type_flap_route_map | |
7481 | || type == bgp_show_type_flap_neighbor) | |
7482 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); | |
7483 | else | |
7484 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
7485 | header = 0; | |
7486 | } | |
7487 | ||
7488 | if (type == bgp_show_type_dampend_paths | |
7489 | || type == bgp_show_type_damp_neighbor) | |
7490 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); | |
7491 | else if (type == bgp_show_type_flap_statistics | |
7492 | || type == bgp_show_type_flap_address | |
7493 | || type == bgp_show_type_flap_prefix | |
7494 | || type == bgp_show_type_flap_cidr_only | |
7495 | || type == bgp_show_type_flap_regexp | |
7496 | || type == bgp_show_type_flap_filter_list | |
7497 | || type == bgp_show_type_flap_prefix_list | |
7498 | || type == bgp_show_type_flap_prefix_longer | |
7499 | || type == bgp_show_type_flap_route_map | |
7500 | || type == bgp_show_type_flap_neighbor) | |
7501 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); | |
7502 | else | |
7503 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, json_paths); | |
7504 | display++; | |
b05a1c8b DS |
7505 | } |
7506 | ||
856ca177 MS |
7507 | if (display) |
7508 | { | |
7509 | output_count++; | |
7510 | if (use_json) | |
7511 | { | |
7512 | p = &rn->p; | |
7513 | sprintf(buf2, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen); | |
7514 | json_object_object_add(json_routes, buf2, json_paths); | |
7515 | } | |
7516 | } | |
9f689658 | 7517 | } |
718e3744 | 7518 | |
b05a1c8b | 7519 | if (use_json) |
718e3744 | 7520 | { |
d1d16a96 | 7521 | json_object_object_add(json, "routes", json_routes); |
b05a1c8b | 7522 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); |
f1aa5d8a | 7523 | json_object_free(json); |
718e3744 | 7524 | } |
7525 | else | |
b05a1c8b DS |
7526 | { |
7527 | /* No route is displayed */ | |
7528 | if (output_count == 0) | |
7529 | { | |
7530 | if (type == bgp_show_type_normal) | |
856ca177 | 7531 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
b05a1c8b DS |
7532 | } |
7533 | else | |
7534 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
856ca177 | 7535 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
b05a1c8b | 7536 | } |
718e3744 | 7537 | |
7538 | return CMD_SUCCESS; | |
7539 | } | |
7540 | ||
5a646650 | 7541 | static int |
fee0f4c6 | 7542 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
856ca177 | 7543 | enum bgp_show_type type, void *output_arg, u_char use_json) |
fee0f4c6 | 7544 | { |
7545 | struct bgp_table *table; | |
7546 | ||
856ca177 MS |
7547 | if (bgp == NULL) |
7548 | { | |
7549 | bgp = bgp_get_default (); | |
7550 | } | |
fee0f4c6 | 7551 | |
7552 | if (bgp == NULL) | |
7553 | { | |
856ca177 MS |
7554 | if (!use_json) |
7555 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
fee0f4c6 | 7556 | return CMD_WARNING; |
7557 | } | |
7558 | ||
fee0f4c6 | 7559 | table = bgp->rib[afi][safi]; |
7560 | ||
9f689658 DD |
7561 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg, |
7562 | use_json, NULL); | |
fee0f4c6 | 7563 | } |
7564 | ||
f186de26 | 7565 | static void |
7566 | bgp_show_all_instances_routes_vty (struct vty *vty, afi_t afi, safi_t safi, | |
7567 | u_char use_json) | |
7568 | { | |
7569 | struct listnode *node, *nnode; | |
7570 | struct bgp *bgp; | |
7571 | struct bgp_table *table; | |
9f689658 DD |
7572 | json_object *json = NULL; |
7573 | int is_first = 1; | |
7574 | ||
7575 | if (use_json) | |
7576 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 7577 | |
7578 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
7579 | { | |
9f689658 DD |
7580 | if (use_json) |
7581 | { | |
7582 | if (!(json = json_object_new_object())) | |
7583 | { | |
7584 | zlog_err("Unable to allocate memory for JSON object"); | |
7585 | vty_out (vty, | |
7586 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
7587 | VTY_NEWLINE); | |
7588 | return; | |
7589 | } | |
7590 | json_object_int_add(json, "vrfId", | |
7591 | (bgp->vrf_id == VRF_UNKNOWN) | |
7592 | ? -1 : bgp->vrf_id); | |
7593 | json_object_string_add(json, "vrfName", | |
7594 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7595 | ? "Default" : bgp->name); | |
7596 | if (! is_first) | |
7597 | vty_out (vty, ",%s", VTY_NEWLINE); | |
7598 | else | |
7599 | is_first = 0; | |
7600 | ||
7601 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7602 | ? "Default" : bgp->name); | |
7603 | } | |
7604 | else | |
7605 | { | |
7606 | vty_out (vty, "%sInstance %s:%s", | |
7607 | VTY_NEWLINE, | |
7608 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7609 | ? "Default" : bgp->name, | |
7610 | VTY_NEWLINE); | |
7611 | } | |
f186de26 | 7612 | table = bgp->rib[afi][safi]; |
7613 | bgp_show_table (vty, table, &bgp->router_id, | |
9f689658 DD |
7614 | bgp_show_type_normal, NULL, use_json, json); |
7615 | ||
f186de26 | 7616 | } |
9f689658 DD |
7617 | |
7618 | if (use_json) | |
7619 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 7620 | } |
7621 | ||
718e3744 | 7622 | /* Header of detailed BGP route information */ |
94f2b392 | 7623 | static void |
718e3744 | 7624 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
7625 | struct bgp_node *rn, | |
b05a1c8b DS |
7626 | struct prefix_rd *prd, afi_t afi, safi_t safi, |
7627 | json_object *json) | |
718e3744 | 7628 | { |
7629 | struct bgp_info *ri; | |
7630 | struct prefix *p; | |
7631 | struct peer *peer; | |
1eb8ef25 | 7632 | struct listnode *node, *nnode; |
718e3744 | 7633 | char buf1[INET6_ADDRSTRLEN]; |
7634 | char buf2[INET6_ADDRSTRLEN]; | |
7635 | int count = 0; | |
7636 | int best = 0; | |
7637 | int suppress = 0; | |
7638 | int no_export = 0; | |
7639 | int no_advertise = 0; | |
7640 | int local_as = 0; | |
adbac85e | 7641 | int first = 1; |
ffd0c037 | 7642 | json_object *json_adv_to = NULL; |
718e3744 | 7643 | |
7644 | p = &rn->p; | |
b05a1c8b DS |
7645 | |
7646 | if (json) | |
7647 | { | |
f1aa5d8a DS |
7648 | json_object_string_add(json, "prefix", inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN)); |
7649 | json_object_int_add(json, "prefixlen", p->prefixlen); | |
b05a1c8b DS |
7650 | } |
7651 | else | |
7652 | { | |
7653 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", | |
587ff0fd | 7654 | ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) ? |
b05a1c8b DS |
7655 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
7656 | safi == SAFI_MPLS_VPN ? ":" : "", | |
7657 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), | |
7658 | p->prefixlen, VTY_NEWLINE); | |
7659 | } | |
718e3744 | 7660 | |
7661 | for (ri = rn->info; ri; ri = ri->next) | |
7662 | { | |
7663 | count++; | |
7664 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
7665 | { | |
7666 | best = count; | |
fb982c25 | 7667 | if (ri->extra && ri->extra->suppress) |
718e3744 | 7668 | suppress = 1; |
7669 | if (ri->attr->community != NULL) | |
7670 | { | |
7671 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) | |
7672 | no_advertise = 1; | |
7673 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) | |
7674 | no_export = 1; | |
7675 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) | |
7676 | local_as = 1; | |
7677 | } | |
7678 | } | |
7679 | } | |
7680 | ||
b05a1c8b | 7681 | if (!json) |
718e3744 | 7682 | { |
b05a1c8b DS |
7683 | vty_out (vty, "Paths: (%d available", count); |
7684 | if (best) | |
7685 | { | |
7686 | vty_out (vty, ", best #%d", best); | |
7687 | if (safi == SAFI_UNICAST) | |
46827ae9 DS |
7688 | vty_out (vty, ", table %s", |
7689 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7690 | ? "Default-IP-Routing-Table" : bgp->name); | |
b05a1c8b DS |
7691 | } |
7692 | else | |
7693 | vty_out (vty, ", no best path"); | |
7694 | ||
7695 | if (no_advertise) | |
7696 | vty_out (vty, ", not advertised to any peer"); | |
7697 | else if (no_export) | |
7698 | vty_out (vty, ", not advertised to EBGP peer"); | |
7699 | else if (local_as) | |
7700 | vty_out (vty, ", not advertised outside local AS"); | |
7701 | ||
7702 | if (suppress) | |
7703 | vty_out (vty, ", Advertisements suppressed by an aggregate."); | |
7704 | vty_out (vty, ")%s", VTY_NEWLINE); | |
718e3744 | 7705 | } |
718e3744 | 7706 | |
adbac85e DW |
7707 | /* If we are not using addpath then we can display Advertised to and that will |
7708 | * show what peers we advertised the bestpath to. If we are using addpath | |
7709 | * though then we must display Advertised to on a path-by-path basis. */ | |
7710 | if (!bgp->addpath_tx_used[afi][safi]) | |
718e3744 | 7711 | { |
adbac85e DW |
7712 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
7713 | { | |
7714 | if (bgp_adj_out_lookup (peer, rn, 0)) | |
b05a1c8b | 7715 | { |
adbac85e | 7716 | if (json && !json_adv_to) |
f1aa5d8a | 7717 | json_adv_to = json_object_new_object(); |
6410e93a | 7718 | |
adbac85e DW |
7719 | route_vty_out_advertised_to(vty, peer, &first, |
7720 | " Advertised to non peer-group peers:\n ", | |
7721 | json_adv_to); | |
b05a1c8b | 7722 | } |
adbac85e | 7723 | } |
036a4e7d | 7724 | |
adbac85e DW |
7725 | if (json) |
7726 | { | |
7727 | if (json_adv_to) | |
7728 | { | |
7729 | json_object_object_add(json, "advertisedTo", json_adv_to); | |
b05a1c8b | 7730 | } |
adbac85e DW |
7731 | } |
7732 | else | |
b05a1c8b | 7733 | { |
adbac85e DW |
7734 | if (first) |
7735 | vty_out (vty, " Not advertised to any peer"); | |
7736 | vty_out (vty, "%s", VTY_NEWLINE); | |
b05a1c8b DS |
7737 | } |
7738 | } | |
718e3744 | 7739 | } |
7740 | ||
7741 | /* Display specified route of BGP table. */ | |
94f2b392 | 7742 | static int |
fee0f4c6 | 7743 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
fd79ac91 | 7744 | struct bgp_table *rib, const char *ip_str, |
7745 | afi_t afi, safi_t safi, struct prefix_rd *prd, | |
b05a1c8b DS |
7746 | int prefix_check, enum bgp_path_type pathtype, |
7747 | u_char use_json) | |
718e3744 | 7748 | { |
7749 | int ret; | |
7750 | int header; | |
7751 | int display = 0; | |
7752 | struct prefix match; | |
7753 | struct bgp_node *rn; | |
7754 | struct bgp_node *rm; | |
7755 | struct bgp_info *ri; | |
718e3744 | 7756 | struct bgp_table *table; |
f1aa5d8a DS |
7757 | json_object *json = NULL; |
7758 | json_object *json_paths = NULL; | |
718e3744 | 7759 | |
718e3744 | 7760 | /* Check IP address argument. */ |
7761 | ret = str2prefix (ip_str, &match); | |
7762 | if (! ret) | |
7763 | { | |
7764 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); | |
7765 | return CMD_WARNING; | |
7766 | } | |
7767 | ||
7768 | match.family = afi2family (afi); | |
7769 | ||
b05a1c8b DS |
7770 | if (use_json) |
7771 | { | |
7772 | json = json_object_new_object(); | |
7773 | json_paths = json_object_new_array(); | |
7774 | } | |
b05a1c8b | 7775 | |
587ff0fd | 7776 | if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) |
718e3744 | 7777 | { |
fee0f4c6 | 7778 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
718e3744 | 7779 | { |
7780 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
7781 | continue; | |
7782 | ||
7783 | if ((table = rn->info) != NULL) | |
7784 | { | |
7785 | header = 1; | |
7786 | ||
7787 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
7788 | { | |
7789 | if (prefix_check && rm->p.prefixlen != match.prefixlen) | |
6c88b44d CC |
7790 | { |
7791 | bgp_unlock_node (rm); | |
7792 | continue; | |
7793 | } | |
718e3744 | 7794 | |
7795 | for (ri = rm->info; ri; ri = ri->next) | |
7796 | { | |
7797 | if (header) | |
7798 | { | |
7799 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, | |
587ff0fd | 7800 | AFI_IP, safi, json); |
718e3744 | 7801 | header = 0; |
7802 | } | |
7803 | display++; | |
4092b06c DS |
7804 | |
7805 | if (pathtype == BGP_PATH_ALL || | |
7806 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || | |
7807 | (pathtype == BGP_PATH_MULTIPATH && | |
7808 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) | |
587ff0fd | 7809 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi, json_paths); |
718e3744 | 7810 | } |
6c88b44d CC |
7811 | |
7812 | bgp_unlock_node (rm); | |
718e3744 | 7813 | } |
7814 | } | |
7815 | } | |
7816 | } | |
7817 | else | |
7818 | { | |
7819 | header = 1; | |
7820 | ||
fee0f4c6 | 7821 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
718e3744 | 7822 | { |
7823 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
7824 | { | |
7825 | for (ri = rn->info; ri; ri = ri->next) | |
7826 | { | |
7827 | if (header) | |
7828 | { | |
b05a1c8b | 7829 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi, json); |
718e3744 | 7830 | header = 0; |
7831 | } | |
7832 | display++; | |
4092b06c DS |
7833 | |
7834 | if (pathtype == BGP_PATH_ALL || | |
7835 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || | |
7836 | (pathtype == BGP_PATH_MULTIPATH && | |
7837 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) | |
b05a1c8b | 7838 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, json_paths); |
718e3744 | 7839 | } |
7840 | } | |
6c88b44d CC |
7841 | |
7842 | bgp_unlock_node (rn); | |
718e3744 | 7843 | } |
7844 | } | |
7845 | ||
e5eee9af | 7846 | if (use_json) |
718e3744 | 7847 | { |
e5eee9af DS |
7848 | if (display) |
7849 | json_object_object_add(json, "paths", json_paths); | |
7850 | ||
7851 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
f1aa5d8a | 7852 | json_object_free(json); |
b05a1c8b DS |
7853 | } |
7854 | else | |
7855 | { | |
e5eee9af | 7856 | if (!display) |
b05a1c8b DS |
7857 | { |
7858 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); | |
7859 | return CMD_WARNING; | |
7860 | } | |
7861 | } | |
7862 | ||
718e3744 | 7863 | return CMD_SUCCESS; |
7864 | } | |
7865 | ||
fee0f4c6 | 7866 | /* Display specified route of Main RIB */ |
94f2b392 | 7867 | static int |
fd79ac91 | 7868 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
fee0f4c6 | 7869 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
b05a1c8b DS |
7870 | int prefix_check, enum bgp_path_type pathtype, |
7871 | u_char use_json) | |
fee0f4c6 | 7872 | { |
7873 | struct bgp *bgp; | |
7874 | ||
7875 | /* BGP structure lookup. */ | |
7876 | if (view_name) | |
7877 | { | |
7878 | bgp = bgp_lookup_by_name (view_name); | |
7879 | if (bgp == NULL) | |
7880 | { | |
6aeb9e78 | 7881 | vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
fee0f4c6 | 7882 | return CMD_WARNING; |
7883 | } | |
7884 | } | |
7885 | else | |
7886 | { | |
7887 | bgp = bgp_get_default (); | |
7888 | if (bgp == NULL) | |
7889 | { | |
7890 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
7891 | return CMD_WARNING; | |
7892 | } | |
7893 | } | |
7894 | ||
7895 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, | |
b05a1c8b DS |
7896 | afi, safi, prd, prefix_check, pathtype, |
7897 | use_json); | |
fee0f4c6 | 7898 | } |
7899 | ||
718e3744 | 7900 | /* BGP route print out function. */ |
7901 | DEFUN (show_ip_bgp, | |
7902 | show_ip_bgp_cmd, | |
b05a1c8b | 7903 | "show ip bgp {json}", |
47fc97cc DS |
7904 | SHOW_STR |
7905 | IP_STR | |
b05a1c8b DS |
7906 | BGP_STR |
7907 | "JavaScript Object Notation\n") | |
47fc97cc | 7908 | { |
db7c8528 | 7909 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); |
718e3744 | 7910 | } |
7911 | ||
7912 | DEFUN (show_ip_bgp_ipv4, | |
7913 | show_ip_bgp_ipv4_cmd, | |
b05a1c8b | 7914 | "show ip bgp ipv4 (unicast|multicast) {json}", |
718e3744 | 7915 | SHOW_STR |
7916 | IP_STR | |
7917 | BGP_STR | |
7918 | "Address family\n" | |
7919 | "Address Family modifier\n" | |
b05a1c8b DS |
7920 | "Address Family modifier\n" |
7921 | "JavaScript Object Notation\n") | |
718e3744 | 7922 | { |
db7c8528 | 7923 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7924 | |
718e3744 | 7925 | if (strncmp (argv[0], "m", 1) == 0) |
5a646650 | 7926 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
db7c8528 | 7927 | NULL, uj); |
718e3744 | 7928 | |
db7c8528 | 7929 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); |
718e3744 | 7930 | } |
7931 | ||
95cbbd2a ML |
7932 | ALIAS (show_ip_bgp_ipv4, |
7933 | show_bgp_ipv4_safi_cmd, | |
b05a1c8b | 7934 | "show bgp ipv4 (unicast|multicast) {json}", |
95cbbd2a ML |
7935 | SHOW_STR |
7936 | BGP_STR | |
7937 | "Address family\n" | |
7938 | "Address Family modifier\n" | |
47fc97cc | 7939 | "Address Family modifier\n" |
b05a1c8b | 7940 | "JavaScript Object Notation\n") |
47fc97cc | 7941 | |
718e3744 | 7942 | DEFUN (show_ip_bgp_route, |
7943 | show_ip_bgp_route_cmd, | |
b05a1c8b | 7944 | "show ip bgp A.B.C.D {json}", |
718e3744 | 7945 | SHOW_STR |
7946 | IP_STR | |
7947 | BGP_STR | |
b05a1c8b DS |
7948 | "Network in the BGP routing table to display\n" |
7949 | "JavaScript Object Notation\n") | |
718e3744 | 7950 | { |
db7c8528 | 7951 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
4092b06c DS |
7952 | } |
7953 | ||
7954 | DEFUN (show_ip_bgp_route_pathtype, | |
7955 | show_ip_bgp_route_pathtype_cmd, | |
b05a1c8b | 7956 | "show ip bgp A.B.C.D (bestpath|multipath) {json}", |
4092b06c DS |
7957 | SHOW_STR |
7958 | IP_STR | |
7959 | BGP_STR | |
7960 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
7961 | "Display only the bestpath\n" | |
b05a1c8b DS |
7962 | "Display only multipaths\n" |
7963 | "JavaScript Object Notation\n") | |
4092b06c | 7964 | { |
db7c8528 | 7965 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7966 | |
4092b06c | 7967 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 7968 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 7969 | else |
db7c8528 | 7970 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
7971 | } |
7972 | ||
7973 | DEFUN (show_bgp_ipv4_safi_route_pathtype, | |
7974 | show_bgp_ipv4_safi_route_pathtype_cmd, | |
b05a1c8b | 7975 | "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}", |
4092b06c DS |
7976 | SHOW_STR |
7977 | BGP_STR | |
7978 | "Address family\n" | |
7979 | "Address Family modifier\n" | |
7980 | "Address Family modifier\n" | |
7981 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
7982 | "Display only the bestpath\n" | |
b05a1c8b DS |
7983 | "Display only multipaths\n" |
7984 | "JavaScript Object Notation\n") | |
4092b06c | 7985 | { |
db7c8528 | 7986 | u_char uj = use_json(argc, argv); |
b05a1c8b | 7987 | |
4092b06c DS |
7988 | if (strncmp (argv[0], "m", 1) == 0) |
7989 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 7990 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 7991 | else |
db7c8528 | 7992 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
7993 | else |
7994 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 7995 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 7996 | else |
db7c8528 | 7997 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
718e3744 | 7998 | } |
7999 | ||
8000 | DEFUN (show_ip_bgp_ipv4_route, | |
8001 | show_ip_bgp_ipv4_route_cmd, | |
b05a1c8b | 8002 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}", |
718e3744 | 8003 | SHOW_STR |
8004 | IP_STR | |
8005 | BGP_STR | |
8006 | "Address family\n" | |
8007 | "Address Family modifier\n" | |
8008 | "Address Family modifier\n" | |
b05a1c8b DS |
8009 | "Network in the BGP routing table to display\n" |
8010 | "JavaScript Object Notation\n") | |
718e3744 | 8011 | { |
db7c8528 | 8012 | u_char uj = use_json(argc, argv); |
b05a1c8b | 8013 | |
718e3744 | 8014 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8015 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); |
718e3744 | 8016 | |
db7c8528 | 8017 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); |
718e3744 | 8018 | } |
8019 | ||
95cbbd2a ML |
8020 | ALIAS (show_ip_bgp_ipv4_route, |
8021 | show_bgp_ipv4_safi_route_cmd, | |
b05a1c8b | 8022 | "show bgp ipv4 (unicast|multicast) A.B.C.D {json}", |
95cbbd2a ML |
8023 | SHOW_STR |
8024 | BGP_STR | |
8025 | "Address family\n" | |
8026 | "Address Family modifier\n" | |
8027 | "Address Family modifier\n" | |
b05a1c8b DS |
8028 | "Network in the BGP routing table to display\n" |
8029 | "JavaScript Object Notation\n") | |
95cbbd2a | 8030 | |
718e3744 | 8031 | DEFUN (show_ip_bgp_vpnv4_all_route, |
8032 | show_ip_bgp_vpnv4_all_route_cmd, | |
b05a1c8b | 8033 | "show ip bgp vpnv4 all A.B.C.D {json}", |
718e3744 | 8034 | SHOW_STR |
8035 | IP_STR | |
8036 | BGP_STR | |
8037 | "Display VPNv4 NLRI specific information\n" | |
8038 | "Display information about all VPNv4 NLRIs\n" | |
b05a1c8b DS |
8039 | "Network in the BGP routing table to display\n" |
8040 | "JavaScript Object Notation\n") | |
718e3744 | 8041 | { |
db7c8528 | 8042 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8043 | } |
8044 | ||
4092b06c | 8045 | |
718e3744 | 8046 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
8047 | show_ip_bgp_vpnv4_rd_route_cmd, | |
b05a1c8b | 8048 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}", |
718e3744 | 8049 | SHOW_STR |
8050 | IP_STR | |
8051 | BGP_STR | |
8052 | "Display VPNv4 NLRI specific information\n" | |
8053 | "Display information for a route distinguisher\n" | |
8054 | "VPN Route Distinguisher\n" | |
b05a1c8b DS |
8055 | "Network in the BGP routing table to display\n" |
8056 | "JavaScript Object Notation\n") | |
718e3744 | 8057 | { |
8058 | int ret; | |
8059 | struct prefix_rd prd; | |
db7c8528 | 8060 | u_char uj= use_json(argc, argv); |
718e3744 | 8061 | |
8062 | ret = str2prefix_rd (argv[0], &prd); | |
8063 | if (! ret) | |
8064 | { | |
8065 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
8066 | return CMD_WARNING; | |
8067 | } | |
db7c8528 | 8068 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); |
718e3744 | 8069 | } |
8070 | ||
8071 | DEFUN (show_ip_bgp_prefix, | |
8072 | show_ip_bgp_prefix_cmd, | |
b05a1c8b | 8073 | "show ip bgp A.B.C.D/M {json}", |
718e3744 | 8074 | SHOW_STR |
8075 | IP_STR | |
8076 | BGP_STR | |
b05a1c8b DS |
8077 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8078 | "JavaScript Object Notation\n") | |
718e3744 | 8079 | { |
db7c8528 | 8080 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
4092b06c DS |
8081 | } |
8082 | ||
8083 | DEFUN (show_ip_bgp_prefix_pathtype, | |
8084 | show_ip_bgp_prefix_pathtype_cmd, | |
b05a1c8b | 8085 | "show ip bgp A.B.C.D/M (bestpath|multipath) {json}", |
4092b06c DS |
8086 | SHOW_STR |
8087 | IP_STR | |
8088 | BGP_STR | |
8089 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8090 | "Display only the bestpath\n" | |
b05a1c8b DS |
8091 | "Display only multipaths\n" |
8092 | "JavaScript Object Notation\n") | |
4092b06c | 8093 | { |
db7c8528 | 8094 | u_char uj = use_json(argc, argv); |
4092b06c | 8095 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 8096 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8097 | else |
db7c8528 | 8098 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
718e3744 | 8099 | } |
8100 | ||
8101 | DEFUN (show_ip_bgp_ipv4_prefix, | |
8102 | show_ip_bgp_ipv4_prefix_cmd, | |
b05a1c8b | 8103 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", |
718e3744 | 8104 | SHOW_STR |
8105 | IP_STR | |
8106 | BGP_STR | |
8107 | "Address family\n" | |
8108 | "Address Family modifier\n" | |
8109 | "Address Family modifier\n" | |
b05a1c8b DS |
8110 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8111 | "JavaScript Object Notation\n") | |
718e3744 | 8112 | { |
db7c8528 | 8113 | u_char uj = use_json(argc, argv); |
b05a1c8b | 8114 | |
718e3744 | 8115 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8116 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); |
718e3744 | 8117 | |
db7c8528 | 8118 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); |
718e3744 | 8119 | } |
8120 | ||
95cbbd2a ML |
8121 | ALIAS (show_ip_bgp_ipv4_prefix, |
8122 | show_bgp_ipv4_safi_prefix_cmd, | |
b05a1c8b | 8123 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", |
95cbbd2a ML |
8124 | SHOW_STR |
8125 | BGP_STR | |
8126 | "Address family\n" | |
8127 | "Address Family modifier\n" | |
8128 | "Address Family modifier\n" | |
b05a1c8b DS |
8129 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8130 | "JavaScript Object Notation\n") | |
95cbbd2a | 8131 | |
4092b06c DS |
8132 | DEFUN (show_ip_bgp_ipv4_prefix_pathtype, |
8133 | show_ip_bgp_ipv4_prefix_pathtype_cmd, | |
b05a1c8b | 8134 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", |
4092b06c DS |
8135 | SHOW_STR |
8136 | IP_STR | |
8137 | BGP_STR | |
8138 | "Address family\n" | |
8139 | "Address Family modifier\n" | |
8140 | "Address Family modifier\n" | |
8141 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8142 | "Display only the bestpath\n" | |
b05a1c8b DS |
8143 | "Display only multipaths\n" |
8144 | "JavaScript Object Notation\n") | |
4092b06c | 8145 | { |
db7c8528 | 8146 | u_char uj = use_json(argc, argv); |
b05a1c8b | 8147 | |
4092b06c DS |
8148 | if (strncmp (argv[0], "m", 1) == 0) |
8149 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8150 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8151 | else |
db7c8528 | 8152 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8153 | else |
8154 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8155 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8156 | else |
db7c8528 | 8157 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8158 | } |
8159 | ||
8160 | ALIAS (show_ip_bgp_ipv4_prefix_pathtype, | |
8161 | show_bgp_ipv4_safi_prefix_pathtype_cmd, | |
b05a1c8b | 8162 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", |
4092b06c DS |
8163 | SHOW_STR |
8164 | BGP_STR | |
8165 | "Address family\n" | |
8166 | "Address Family modifier\n" | |
8167 | "Address Family modifier\n" | |
8168 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8169 | "Display only the bestpath\n" | |
b05a1c8b DS |
8170 | "Display only multipaths\n" |
8171 | "JavaScript Object Notation\n") | |
4092b06c | 8172 | |
718e3744 | 8173 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
8174 | show_ip_bgp_vpnv4_all_prefix_cmd, | |
b05a1c8b | 8175 | "show ip bgp vpnv4 all A.B.C.D/M {json}", |
718e3744 | 8176 | SHOW_STR |
8177 | IP_STR | |
8178 | BGP_STR | |
8179 | "Display VPNv4 NLRI specific information\n" | |
8180 | "Display information about all VPNv4 NLRIs\n" | |
b05a1c8b DS |
8181 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8182 | "JavaScript Object Notation\n") | |
718e3744 | 8183 | { |
db7c8528 | 8184 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8185 | } |
8186 | ||
8187 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, | |
8188 | show_ip_bgp_vpnv4_rd_prefix_cmd, | |
b05a1c8b | 8189 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}", |
718e3744 | 8190 | SHOW_STR |
8191 | IP_STR | |
8192 | BGP_STR | |
8193 | "Display VPNv4 NLRI specific information\n" | |
8194 | "Display information for a route distinguisher\n" | |
8195 | "VPN Route Distinguisher\n" | |
b05a1c8b DS |
8196 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8197 | "JavaScript Object Notation\n") | |
718e3744 | 8198 | { |
8199 | int ret; | |
8200 | struct prefix_rd prd; | |
8201 | ||
8202 | ret = str2prefix_rd (argv[0], &prd); | |
8203 | if (! ret) | |
8204 | { | |
8205 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
8206 | return CMD_WARNING; | |
8207 | } | |
db7c8528 | 8208 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8209 | } |
8210 | ||
8211 | DEFUN (show_ip_bgp_view, | |
8386ac43 | 8212 | show_ip_bgp_instance_cmd, |
8213 | "show ip bgp " BGP_INSTANCE_CMD " {json}", | |
718e3744 | 8214 | SHOW_STR |
8215 | IP_STR | |
8216 | BGP_STR | |
8386ac43 | 8217 | BGP_INSTANCE_HELP_STR |
b05a1c8b | 8218 | "JavaScript Object Notation\n") |
718e3744 | 8219 | { |
bb46e94f | 8220 | struct bgp *bgp; |
8221 | ||
8222 | /* BGP structure lookup. */ | |
6aeb9e78 | 8223 | bgp = bgp_lookup_by_name (argv[1]); |
bb46e94f | 8224 | if (bgp == NULL) |
8225 | { | |
6aeb9e78 | 8226 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
bb46e94f | 8227 | return CMD_WARNING; |
8228 | } | |
8229 | ||
db7c8528 | 8230 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); |
718e3744 | 8231 | } |
8232 | ||
f186de26 | 8233 | DEFUN (show_ip_bgp_instance_all, |
8234 | show_ip_bgp_instance_all_cmd, | |
8235 | "show ip bgp " BGP_INSTANCE_ALL_CMD " {json}", | |
8236 | SHOW_STR | |
8237 | IP_STR | |
8238 | BGP_STR | |
8239 | BGP_INSTANCE_ALL_HELP_STR | |
8240 | "JavaScript Object Notation\n") | |
8241 | { | |
8242 | u_char uj = use_json(argc, argv); | |
8243 | ||
8244 | bgp_show_all_instances_routes_vty (vty, AFI_IP, SAFI_UNICAST, uj); | |
8245 | return CMD_SUCCESS; | |
8246 | } | |
8247 | ||
8386ac43 | 8248 | DEFUN (show_ip_bgp_instance_route, |
8249 | show_ip_bgp_instance_route_cmd, | |
8250 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D {json}", | |
718e3744 | 8251 | SHOW_STR |
8252 | IP_STR | |
8253 | BGP_STR | |
8386ac43 | 8254 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8255 | "Network in the BGP routing table to display\n" |
8256 | "JavaScript Object Notation\n") | |
718e3744 | 8257 | { |
6aeb9e78 | 8258 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8259 | } |
8260 | ||
8386ac43 | 8261 | DEFUN (show_ip_bgp_instance_route_pathtype, |
8262 | show_ip_bgp_instance_route_pathtype_cmd, | |
8263 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D (bestpath|multipath) {json}", | |
50ef26d4 | 8264 | SHOW_STR |
8265 | IP_STR | |
8266 | BGP_STR | |
8386ac43 | 8267 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8268 | "Network in the BGP routing table to display\n" |
8269 | "Display only the bestpath\n" | |
8270 | "Display only multipaths\n" | |
8271 | "JavaScript Object Notation\n") | |
8272 | { | |
8273 | u_char uj = use_json(argc, argv); | |
8274 | ||
8275 | if (strncmp (argv[3], "b", 1) == 0) | |
8276 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); | |
8277 | else | |
8278 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); | |
8279 | } | |
8280 | ||
8386ac43 | 8281 | DEFUN (show_ip_bgp_instance_prefix, |
8282 | show_ip_bgp_instance_prefix_cmd, | |
8283 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M {json}", | |
718e3744 | 8284 | SHOW_STR |
8285 | IP_STR | |
8286 | BGP_STR | |
8386ac43 | 8287 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8288 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8289 | "JavaScript Object Notation\n") | |
718e3744 | 8290 | { |
6aeb9e78 | 8291 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8292 | } |
8293 | ||
8386ac43 | 8294 | DEFUN (show_ip_bgp_instance_prefix_pathtype, |
8295 | show_ip_bgp_instance_prefix_pathtype_cmd, | |
8296 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M (bestpath|multipath) {json}", | |
50ef26d4 | 8297 | SHOW_STR |
8298 | IP_STR | |
8299 | BGP_STR | |
8386ac43 | 8300 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8301 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
8302 | "Display only the bestpath\n" | |
8303 | "Display only multipaths\n" | |
8304 | "JavaScript Object Notation\n") | |
8305 | { | |
8306 | u_char uj = use_json(argc, argv); | |
8307 | if (strncmp (argv[3], "b", 1) == 0) | |
8308 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); | |
8309 | else | |
8310 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); | |
8311 | } | |
8312 | ||
718e3744 | 8313 | #ifdef HAVE_IPV6 |
8314 | DEFUN (show_bgp, | |
8315 | show_bgp_cmd, | |
b05a1c8b | 8316 | "show bgp {json}", |
718e3744 | 8317 | SHOW_STR |
b05a1c8b DS |
8318 | BGP_STR |
8319 | "JavaScript Object Notation\n") | |
718e3744 | 8320 | { |
5a646650 | 8321 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
db7c8528 | 8322 | NULL, use_json(argc, argv)); |
718e3744 | 8323 | } |
8324 | ||
8325 | ALIAS (show_bgp, | |
8326 | show_bgp_ipv6_cmd, | |
b05a1c8b | 8327 | "show bgp ipv6 {json}", |
718e3744 | 8328 | SHOW_STR |
8329 | BGP_STR | |
b05a1c8b DS |
8330 | "Address family\n" |
8331 | "JavaScript Object Notation\n") | |
718e3744 | 8332 | |
95cbbd2a ML |
8333 | DEFUN (show_bgp_ipv6_safi, |
8334 | show_bgp_ipv6_safi_cmd, | |
b05a1c8b | 8335 | "show bgp ipv6 (unicast|multicast) {json}", |
95cbbd2a ML |
8336 | SHOW_STR |
8337 | BGP_STR | |
8338 | "Address family\n" | |
8339 | "Address Family modifier\n" | |
47fc97cc | 8340 | "Address Family modifier\n" |
b05a1c8b | 8341 | "JavaScript Object Notation\n") |
47fc97cc | 8342 | { |
db7c8528 | 8343 | u_char uj = use_json(argc, argv); |
47fc97cc DS |
8344 | if (strncmp (argv[0], "m", 1) == 0) |
8345 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, | |
db7c8528 | 8346 | NULL, uj); |
47fc97cc | 8347 | |
db7c8528 | 8348 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); |
95cbbd2a ML |
8349 | } |
8350 | ||
47e9b292 DW |
8351 | static void |
8352 | bgp_show_ipv6_bgp_deprecate_warning (struct vty *vty) | |
8353 | { | |
8354 | vty_out (vty, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our" | |
8355 | " next release%sPlese use 'show bgp ipv6' instead%s%s", | |
8356 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
8357 | } | |
8358 | ||
718e3744 | 8359 | /* old command */ |
8360 | DEFUN (show_ipv6_bgp, | |
8361 | show_ipv6_bgp_cmd, | |
b05a1c8b | 8362 | "show ipv6 bgp {json}", |
718e3744 | 8363 | SHOW_STR |
8364 | IP_STR | |
b05a1c8b DS |
8365 | BGP_STR |
8366 | "JavaScript Object Notation\n") | |
718e3744 | 8367 | { |
47e9b292 | 8368 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
5a646650 | 8369 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
db7c8528 | 8370 | NULL, use_json(argc, argv)); |
718e3744 | 8371 | } |
8372 | ||
8373 | DEFUN (show_bgp_route, | |
8374 | show_bgp_route_cmd, | |
b05a1c8b | 8375 | "show bgp X:X::X:X {json}", |
718e3744 | 8376 | SHOW_STR |
8377 | BGP_STR | |
b05a1c8b DS |
8378 | "Network in the BGP routing table to display\n" |
8379 | "JavaScript Object Notation\n") | |
718e3744 | 8380 | { |
db7c8528 | 8381 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8382 | } |
8383 | ||
8384 | ALIAS (show_bgp_route, | |
8385 | show_bgp_ipv6_route_cmd, | |
b05a1c8b | 8386 | "show bgp ipv6 X:X::X:X {json}", |
718e3744 | 8387 | SHOW_STR |
8388 | BGP_STR | |
8389 | "Address family\n" | |
b05a1c8b DS |
8390 | "Network in the BGP routing table to display\n" |
8391 | "JavaScript Object Notation\n") | |
718e3744 | 8392 | |
95cbbd2a ML |
8393 | DEFUN (show_bgp_ipv6_safi_route, |
8394 | show_bgp_ipv6_safi_route_cmd, | |
b05a1c8b | 8395 | "show bgp ipv6 (unicast|multicast) X:X::X:X {json}", |
95cbbd2a ML |
8396 | SHOW_STR |
8397 | BGP_STR | |
8398 | "Address family\n" | |
8399 | "Address Family modifier\n" | |
8400 | "Address Family modifier\n" | |
b05a1c8b DS |
8401 | "Network in the BGP routing table to display\n" |
8402 | "JavaScript Object Notation\n") | |
95cbbd2a | 8403 | { |
db7c8528 | 8404 | u_char uj = use_json(argc, argv); |
95cbbd2a | 8405 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8406 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); |
95cbbd2a | 8407 | |
db7c8528 | 8408 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); |
4092b06c DS |
8409 | } |
8410 | ||
8411 | DEFUN (show_bgp_route_pathtype, | |
8412 | show_bgp_route_pathtype_cmd, | |
b05a1c8b | 8413 | "show bgp X:X::X:X (bestpath|multipath) {json}", |
4092b06c DS |
8414 | SHOW_STR |
8415 | BGP_STR | |
8416 | "Network in the BGP routing table to display\n" | |
8417 | "Display only the bestpath\n" | |
b05a1c8b DS |
8418 | "Display only multipaths\n" |
8419 | "JavaScript Object Notation\n") | |
4092b06c | 8420 | { |
db7c8528 | 8421 | u_char uj = use_json(argc, argv); |
4092b06c | 8422 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 8423 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8424 | else |
db7c8528 | 8425 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8426 | } |
8427 | ||
8428 | ALIAS (show_bgp_route_pathtype, | |
8429 | show_bgp_ipv6_route_pathtype_cmd, | |
b05a1c8b | 8430 | "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}", |
4092b06c DS |
8431 | SHOW_STR |
8432 | BGP_STR | |
8433 | "Address family\n" | |
8434 | "Network in the BGP routing table to display\n" | |
8435 | "Display only the bestpath\n" | |
b05a1c8b DS |
8436 | "Display only multipaths\n" |
8437 | "JavaScript Object Notation\n") | |
4092b06c DS |
8438 | |
8439 | DEFUN (show_bgp_ipv6_safi_route_pathtype, | |
8440 | show_bgp_ipv6_safi_route_pathtype_cmd, | |
b05a1c8b | 8441 | "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}", |
4092b06c DS |
8442 | SHOW_STR |
8443 | BGP_STR | |
8444 | "Address family\n" | |
8445 | "Address Family modifier\n" | |
8446 | "Address Family modifier\n" | |
8447 | "Network in the BGP routing table to display\n" | |
8448 | "Display only the bestpath\n" | |
b05a1c8b DS |
8449 | "Display only multipaths\n" |
8450 | "JavaScript Object Notation\n") | |
4092b06c | 8451 | { |
db7c8528 | 8452 | u_char uj = use_json(argc, argv); |
4092b06c DS |
8453 | if (strncmp (argv[0], "m", 1) == 0) |
8454 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8455 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8456 | else |
db7c8528 | 8457 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8458 | else |
8459 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8460 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); |
4092b06c | 8461 | else |
db7c8528 | 8462 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); |
95cbbd2a ML |
8463 | } |
8464 | ||
718e3744 | 8465 | /* old command */ |
8466 | DEFUN (show_ipv6_bgp_route, | |
8467 | show_ipv6_bgp_route_cmd, | |
b05a1c8b | 8468 | "show ipv6 bgp X:X::X:X {json}", |
718e3744 | 8469 | SHOW_STR |
8470 | IP_STR | |
8471 | BGP_STR | |
b05a1c8b DS |
8472 | "Network in the BGP routing table to display\n" |
8473 | "JavaScript Object Notation\n") | |
718e3744 | 8474 | { |
47e9b292 | 8475 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8476 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8477 | } |
8478 | ||
8479 | DEFUN (show_bgp_prefix, | |
8480 | show_bgp_prefix_cmd, | |
b05a1c8b | 8481 | "show bgp X:X::X:X/M {json}", |
718e3744 | 8482 | SHOW_STR |
8483 | BGP_STR | |
b05a1c8b DS |
8484 | "IPv6 prefix <network>/<length>\n" |
8485 | "JavaScript Object Notation\n") | |
718e3744 | 8486 | { |
db7c8528 | 8487 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8488 | } |
8489 | ||
8490 | ALIAS (show_bgp_prefix, | |
8491 | show_bgp_ipv6_prefix_cmd, | |
b05a1c8b | 8492 | "show bgp ipv6 X:X::X:X/M {json}", |
718e3744 | 8493 | SHOW_STR |
8494 | BGP_STR | |
8495 | "Address family\n" | |
b05a1c8b DS |
8496 | "IPv6 prefix <network>/<length>\n" |
8497 | "JavaScript Object Notation\n") | |
718e3744 | 8498 | |
95cbbd2a ML |
8499 | DEFUN (show_bgp_ipv6_safi_prefix, |
8500 | show_bgp_ipv6_safi_prefix_cmd, | |
b05a1c8b | 8501 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}", |
95cbbd2a ML |
8502 | SHOW_STR |
8503 | BGP_STR | |
8504 | "Address family\n" | |
8505 | "Address Family modifier\n" | |
8506 | "Address Family modifier\n" | |
b05a1c8b DS |
8507 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
8508 | "JavaScript Object Notation\n") | |
95cbbd2a | 8509 | { |
db7c8528 | 8510 | u_char uj = use_json(argc, argv); |
95cbbd2a | 8511 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 8512 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); |
95cbbd2a | 8513 | |
db7c8528 | 8514 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); |
4092b06c DS |
8515 | } |
8516 | ||
8517 | DEFUN (show_bgp_prefix_pathtype, | |
8518 | show_bgp_prefix_pathtype_cmd, | |
b05a1c8b | 8519 | "show bgp X:X::X:X/M (bestpath|multipath) {json}", |
4092b06c DS |
8520 | SHOW_STR |
8521 | BGP_STR | |
8522 | "IPv6 prefix <network>/<length>\n" | |
8523 | "Display only the bestpath\n" | |
b05a1c8b DS |
8524 | "Display only multipaths\n" |
8525 | "JavaScript Object Notation\n") | |
4092b06c | 8526 | { |
db7c8528 | 8527 | u_char uj = use_json(argc, argv); |
4092b06c | 8528 | if (strncmp (argv[1], "b", 1) == 0) |
db7c8528 | 8529 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8530 | else |
db7c8528 | 8531 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8532 | } |
8533 | ||
8534 | ALIAS (show_bgp_prefix_pathtype, | |
8535 | show_bgp_ipv6_prefix_pathtype_cmd, | |
b05a1c8b | 8536 | "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}", |
4092b06c DS |
8537 | SHOW_STR |
8538 | BGP_STR | |
8539 | "Address family\n" | |
8540 | "IPv6 prefix <network>/<length>\n" | |
8541 | "Display only the bestpath\n" | |
b05a1c8b DS |
8542 | "Display only multipaths\n" |
8543 | "JavaScript Object Notation\n") | |
4092b06c DS |
8544 | |
8545 | DEFUN (show_bgp_ipv6_safi_prefix_pathtype, | |
8546 | show_bgp_ipv6_safi_prefix_pathtype_cmd, | |
b05a1c8b | 8547 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}", |
4092b06c DS |
8548 | SHOW_STR |
8549 | BGP_STR | |
8550 | "Address family\n" | |
8551 | "Address Family modifier\n" | |
8552 | "Address Family modifier\n" | |
8553 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
8554 | "Display only the bestpath\n" | |
b05a1c8b DS |
8555 | "Display only multipaths\n" |
8556 | "JavaScript Object Notation\n") | |
4092b06c | 8557 | { |
db7c8528 | 8558 | u_char uj = use_json(argc, argv); |
4092b06c DS |
8559 | if (strncmp (argv[0], "m", 1) == 0) |
8560 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8561 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8562 | else |
db7c8528 | 8563 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
4092b06c DS |
8564 | else |
8565 | if (strncmp (argv[2], "b", 1) == 0) | |
db7c8528 | 8566 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); |
4092b06c | 8567 | else |
db7c8528 | 8568 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); |
95cbbd2a ML |
8569 | } |
8570 | ||
718e3744 | 8571 | /* old command */ |
8572 | DEFUN (show_ipv6_bgp_prefix, | |
8573 | show_ipv6_bgp_prefix_cmd, | |
b05a1c8b | 8574 | "show ipv6 bgp X:X::X:X/M {json}", |
718e3744 | 8575 | SHOW_STR |
8576 | IP_STR | |
8577 | BGP_STR | |
b05a1c8b DS |
8578 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
8579 | "JavaScript Object Notation\n") | |
718e3744 | 8580 | { |
47e9b292 | 8581 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8582 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8583 | } |
8584 | ||
bb46e94f | 8585 | DEFUN (show_bgp_view, |
8386ac43 | 8586 | show_bgp_instance_cmd, |
8587 | "show bgp " BGP_INSTANCE_CMD " {json}", | |
bb46e94f | 8588 | SHOW_STR |
8589 | BGP_STR | |
8386ac43 | 8590 | BGP_INSTANCE_HELP_STR |
b05a1c8b | 8591 | "JavaScript Object Notation\n") |
bb46e94f | 8592 | { |
8593 | struct bgp *bgp; | |
8594 | ||
8595 | /* BGP structure lookup. */ | |
6aeb9e78 | 8596 | bgp = bgp_lookup_by_name (argv[1]); |
bb46e94f | 8597 | if (bgp == NULL) |
db7c8528 | 8598 | { |
6aeb9e78 | 8599 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
db7c8528 DS |
8600 | return CMD_WARNING; |
8601 | } | |
8602 | ||
8603 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); | |
bb46e94f | 8604 | } |
8605 | ||
f186de26 | 8606 | DEFUN (show_bgp_instance_all, |
8607 | show_bgp_instance_all_cmd, | |
8608 | "show bgp " BGP_INSTANCE_ALL_CMD " {json}", | |
8609 | SHOW_STR | |
8610 | BGP_STR | |
8611 | BGP_INSTANCE_ALL_HELP_STR | |
8612 | "JavaScript Object Notation\n") | |
8613 | { | |
8614 | u_char uj = use_json(argc, argv); | |
8615 | ||
8616 | bgp_show_all_instances_routes_vty (vty, AFI_IP6, SAFI_UNICAST, uj); | |
8617 | return CMD_SUCCESS; | |
8618 | } | |
8619 | ||
bb46e94f | 8620 | ALIAS (show_bgp_view, |
8386ac43 | 8621 | show_bgp_instance_ipv6_cmd, |
8622 | "show bgp " BGP_INSTANCE_CMD " ipv6 {json}", | |
bb46e94f | 8623 | SHOW_STR |
8624 | BGP_STR | |
8386ac43 | 8625 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8626 | "Address family\n" |
8627 | "JavaScript Object Notation\n") | |
bb46e94f | 8628 | |
8386ac43 | 8629 | DEFUN (show_bgp_instance_route, |
8630 | show_bgp_instance_route_cmd, | |
8631 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X {json}", | |
bb46e94f | 8632 | SHOW_STR |
8633 | BGP_STR | |
8386ac43 | 8634 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8635 | "Network in the BGP routing table to display\n" |
8636 | "JavaScript Object Notation\n") | |
bb46e94f | 8637 | { |
6aeb9e78 | 8638 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
bb46e94f | 8639 | } |
8640 | ||
8386ac43 | 8641 | ALIAS (show_bgp_instance_route, |
8642 | show_bgp_instance_ipv6_route_cmd, | |
8643 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X {json}", | |
bb46e94f | 8644 | SHOW_STR |
8645 | BGP_STR | |
8386ac43 | 8646 | BGP_INSTANCE_HELP_STR |
bb46e94f | 8647 | "Address family\n" |
b05a1c8b DS |
8648 | "Network in the BGP routing table to display\n" |
8649 | "JavaScript Object Notation\n") | |
bb46e94f | 8650 | |
8386ac43 | 8651 | DEFUN (show_bgp_instance_route_pathtype, |
8652 | show_bgp_instance_route_pathtype_cmd, | |
8653 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X (bestpath|multipath) {json}", | |
50ef26d4 | 8654 | SHOW_STR |
8655 | BGP_STR | |
8386ac43 | 8656 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8657 | "Network in the BGP routing table to display\n" |
8658 | "Display only the bestpath\n" | |
8659 | "Display only multipaths\n" | |
8660 | "JavaScript Object Notation\n") | |
8661 | { | |
8662 | u_char uj = use_json(argc, argv); | |
8663 | if (strncmp (argv[3], "b", 1) == 0) | |
8664 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); | |
8665 | else | |
8666 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); | |
8667 | } | |
8668 | ||
8386ac43 | 8669 | ALIAS (show_bgp_instance_route_pathtype, |
8670 | show_bgp_instance_ipv6_route_pathtype_cmd, | |
8671 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X (bestpath|multipath) {json}", | |
50ef26d4 | 8672 | SHOW_STR |
8673 | BGP_STR | |
8386ac43 | 8674 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8675 | "Address family\n" |
8676 | "Network in the BGP routing table to display\n" | |
8677 | "Display only the bestpath\n" | |
8678 | "Display only multipaths\n" | |
8679 | "JavaScript Object Notation\n") | |
8680 | ||
8386ac43 | 8681 | DEFUN (show_bgp_instance_prefix, |
8682 | show_bgp_instance_prefix_cmd, | |
8683 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M {json}", | |
bb46e94f | 8684 | SHOW_STR |
8685 | BGP_STR | |
8386ac43 | 8686 | BGP_INSTANCE_HELP_STR |
b05a1c8b DS |
8687 | "IPv6 prefix <network>/<length>\n" |
8688 | "JavaScript Object Notation\n") | |
bb46e94f | 8689 | { |
6aeb9e78 | 8690 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
bb46e94f | 8691 | } |
8692 | ||
8386ac43 | 8693 | ALIAS (show_bgp_instance_prefix, |
8694 | show_bgp_instance_ipv6_prefix_cmd, | |
8695 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M {json}", | |
bb46e94f | 8696 | SHOW_STR |
8697 | BGP_STR | |
8386ac43 | 8698 | BGP_INSTANCE_HELP_STR |
bb46e94f | 8699 | "Address family\n" |
b05a1c8b DS |
8700 | "IPv6 prefix <network>/<length>\n" |
8701 | "JavaScript Object Notation\n") | |
bb46e94f | 8702 | |
8386ac43 | 8703 | DEFUN (show_bgp_instance_prefix_pathtype, |
8704 | show_bgp_instance_prefix_pathtype_cmd, | |
8705 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M (bestpath|multipath) {json}", | |
50ef26d4 | 8706 | SHOW_STR |
8707 | BGP_STR | |
8386ac43 | 8708 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8709 | "IPv6 prefix <network>/<length>\n" |
8710 | "Display only the bestpath\n" | |
8711 | "Display only multipaths\n" | |
8712 | "JavaScript Object Notation\n") | |
8713 | { | |
8714 | u_char uj = use_json(argc, argv); | |
8715 | if (strncmp (argv[3], "b", 1) == 0) | |
8716 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); | |
8717 | else | |
8718 | return bgp_show_route (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); | |
8719 | } | |
8720 | ||
8386ac43 | 8721 | ALIAS (show_bgp_instance_prefix_pathtype, |
8722 | show_bgp_instance_ipv6_prefix_pathtype_cmd, | |
8723 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M (bestpath|multipath) {json}", | |
50ef26d4 | 8724 | SHOW_STR |
8725 | BGP_STR | |
8386ac43 | 8726 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8727 | "Address family\n" |
8728 | "IPv6 prefix <network>/<length>\n" | |
8729 | "Display only the bestpath\n" | |
8730 | "Display only multipaths\n" | |
8731 | "JavaScript Object Notation\n") | |
8732 | ||
8386ac43 | 8733 | DEFUN (show_bgp_instance_prefix_list, |
8734 | show_bgp_instance_prefix_list_cmd, | |
8735 | "show bgp " BGP_INSTANCE_CMD " prefix-list WORD", | |
50ef26d4 | 8736 | SHOW_STR |
8737 | BGP_STR | |
8386ac43 | 8738 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8739 | "Display routes conforming to the prefix-list\n" |
8740 | "IPv6 prefix-list name\n") | |
8741 | { | |
8742 | return bgp_show_prefix_list (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8743 | bgp_show_type_prefix_list); | |
8744 | } | |
8745 | ||
8386ac43 | 8746 | ALIAS (show_bgp_instance_prefix_list, |
8747 | show_bgp_instance_ipv6_prefix_list_cmd, | |
8748 | "show bgp " BGP_INSTANCE_CMD " ipv6 prefix-list WORD", | |
50ef26d4 | 8749 | SHOW_STR |
8750 | BGP_STR | |
8386ac43 | 8751 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8752 | "Address family\n" |
8753 | "Display routes conforming to the prefix-list\n" | |
8754 | "IPv6 prefix-list name\n") | |
8755 | ||
8386ac43 | 8756 | DEFUN (show_bgp_instance_filter_list, |
8757 | show_bgp_instance_filter_list_cmd, | |
8758 | "show bgp " BGP_INSTANCE_CMD " filter-list WORD", | |
50ef26d4 | 8759 | SHOW_STR |
8760 | BGP_STR | |
8386ac43 | 8761 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8762 | "Display routes conforming to the filter-list\n" |
8763 | "Regular expression access list name\n") | |
8764 | { | |
8765 | return bgp_show_filter_list (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8766 | bgp_show_type_filter_list); | |
8767 | } | |
8768 | ||
8386ac43 | 8769 | ALIAS (show_bgp_instance_filter_list, |
8770 | show_bgp_instance_ipv6_filter_list_cmd, | |
8771 | "show bgp " BGP_INSTANCE_CMD " ipv6 filter-list WORD", | |
50ef26d4 | 8772 | SHOW_STR |
8773 | BGP_STR | |
8386ac43 | 8774 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8775 | "Address family\n" |
8776 | "Display routes conforming to the filter-list\n" | |
8777 | "Regular expression access list name\n") | |
8778 | ||
8386ac43 | 8779 | DEFUN (show_bgp_instance_route_map, |
8780 | show_bgp_instance_route_map_cmd, | |
8781 | "show bgp " BGP_INSTANCE_CMD " route-map WORD", | |
50ef26d4 | 8782 | SHOW_STR |
8783 | BGP_STR | |
8386ac43 | 8784 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8785 | "Display routes matching the route-map\n" |
8786 | "A route-map to match on\n") | |
8787 | { | |
8788 | return bgp_show_route_map (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8789 | bgp_show_type_route_map); | |
8790 | } | |
8791 | ||
8386ac43 | 8792 | ALIAS (show_bgp_instance_route_map, |
8793 | show_bgp_instance_ipv6_route_map_cmd, | |
8794 | "show bgp " BGP_INSTANCE_CMD " ipv6 route-map WORD", | |
50ef26d4 | 8795 | SHOW_STR |
8796 | BGP_STR | |
8386ac43 | 8797 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8798 | "Address family\n" |
8799 | "Display routes matching the route-map\n" | |
8800 | "A route-map to match on\n") | |
8801 | ||
8386ac43 | 8802 | DEFUN (show_bgp_instance_community_list, |
8803 | show_bgp_instance_community_list_cmd, | |
8804 | "show bgp " BGP_INSTANCE_CMD " community-list (<1-500>|WORD)", | |
50ef26d4 | 8805 | SHOW_STR |
8806 | BGP_STR | |
8386ac43 | 8807 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8808 | "Display routes matching the community-list\n" |
8809 | "community-list number\n" | |
8810 | "community-list name\n") | |
8811 | { | |
8812 | return bgp_show_community_list (vty, argv[1], argv[2], 0, AFI_IP6, SAFI_UNICAST); | |
8813 | } | |
8814 | ||
8386ac43 | 8815 | ALIAS (show_bgp_instance_community_list, |
8816 | show_bgp_instance_ipv6_community_list_cmd, | |
8817 | "show bgp " BGP_INSTANCE_CMD " ipv6 community-list (<1-500>|WORD)", | |
50ef26d4 | 8818 | SHOW_STR |
8819 | BGP_STR | |
8386ac43 | 8820 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8821 | "Address family\n" |
8822 | "Display routes matching the community-list\n" | |
8823 | "community-list number\n" | |
8824 | "community-list name\n") | |
8825 | ||
8386ac43 | 8826 | DEFUN (show_bgp_instance_prefix_longer, |
8827 | show_bgp_instance_prefix_longer_cmd, | |
8828 | "show bgp " BGP_INSTANCE_CMD " X:X::X:X/M longer-prefixes", | |
50ef26d4 | 8829 | SHOW_STR |
8830 | BGP_STR | |
8386ac43 | 8831 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8832 | "IPv6 prefix <network>/<length>\n" |
8833 | "Display route and more specific routes\n") | |
8834 | { | |
8835 | return bgp_show_prefix_longer (vty, argv[1], argv[2], AFI_IP6, SAFI_UNICAST, | |
8836 | bgp_show_type_prefix_longer); | |
8837 | } | |
8838 | ||
8386ac43 | 8839 | ALIAS (show_bgp_instance_prefix_longer, |
8840 | show_bgp_instance_ipv6_prefix_longer_cmd, | |
8841 | "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M longer-prefixes", | |
50ef26d4 | 8842 | SHOW_STR |
8843 | BGP_STR | |
8386ac43 | 8844 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 8845 | "Address family\n" |
8846 | "IPv6 prefix <network>/<length>\n" | |
8847 | "Display route and more specific routes\n") | |
8848 | ||
718e3744 | 8849 | /* old command */ |
8850 | DEFUN (show_ipv6_mbgp, | |
8851 | show_ipv6_mbgp_cmd, | |
b05a1c8b | 8852 | "show ipv6 mbgp {json}", |
718e3744 | 8853 | SHOW_STR |
8854 | IP_STR | |
b05a1c8b DS |
8855 | MBGP_STR |
8856 | "JavaScript Object Notation\n") | |
718e3744 | 8857 | { |
47e9b292 | 8858 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
5a646650 | 8859 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
db7c8528 | 8860 | NULL, use_json(argc, argv)); |
718e3744 | 8861 | } |
8862 | ||
8863 | /* old command */ | |
8864 | DEFUN (show_ipv6_mbgp_route, | |
8865 | show_ipv6_mbgp_route_cmd, | |
b05a1c8b | 8866 | "show ipv6 mbgp X:X::X:X {json}", |
718e3744 | 8867 | SHOW_STR |
8868 | IP_STR | |
8869 | MBGP_STR | |
b05a1c8b DS |
8870 | "Network in the MBGP routing table to display\n" |
8871 | "JavaScript Object Notation\n") | |
718e3744 | 8872 | { |
47e9b292 | 8873 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8874 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8875 | } |
8876 | ||
8877 | /* old command */ | |
8878 | DEFUN (show_ipv6_mbgp_prefix, | |
8879 | show_ipv6_mbgp_prefix_cmd, | |
b05a1c8b | 8880 | "show ipv6 mbgp X:X::X:X/M {json}", |
718e3744 | 8881 | SHOW_STR |
8882 | IP_STR | |
8883 | MBGP_STR | |
b05a1c8b DS |
8884 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
8885 | "JavaScript Object Notation\n") | |
718e3744 | 8886 | { |
47e9b292 | 8887 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 8888 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); |
718e3744 | 8889 | } |
8890 | #endif | |
6b0655a2 | 8891 | |
718e3744 | 8892 | |
94f2b392 | 8893 | static int |
fd79ac91 | 8894 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
718e3744 | 8895 | safi_t safi, enum bgp_show_type type) |
8896 | { | |
8897 | int i; | |
8898 | struct buffer *b; | |
8899 | char *regstr; | |
8900 | int first; | |
8901 | regex_t *regex; | |
5a646650 | 8902 | int rc; |
718e3744 | 8903 | |
8904 | first = 0; | |
8905 | b = buffer_new (1024); | |
8906 | for (i = 0; i < argc; i++) | |
8907 | { | |
8908 | if (first) | |
8909 | buffer_putc (b, ' '); | |
8910 | else | |
8911 | { | |
8912 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
8913 | continue; | |
8914 | first = 1; | |
8915 | } | |
8916 | ||
8917 | buffer_putstr (b, argv[i]); | |
8918 | } | |
8919 | buffer_putc (b, '\0'); | |
8920 | ||
8921 | regstr = buffer_getstr (b); | |
8922 | buffer_free (b); | |
8923 | ||
8924 | regex = bgp_regcomp (regstr); | |
3b8b1855 | 8925 | XFREE(MTYPE_TMP, regstr); |
718e3744 | 8926 | if (! regex) |
8927 | { | |
8928 | vty_out (vty, "Can't compile regexp %s%s", argv[0], | |
8929 | VTY_NEWLINE); | |
8930 | return CMD_WARNING; | |
8931 | } | |
8932 | ||
b05a1c8b | 8933 | rc = bgp_show (vty, NULL, afi, safi, type, regex, 0); |
5a646650 | 8934 | bgp_regex_free (regex); |
8935 | return rc; | |
718e3744 | 8936 | } |
8937 | ||
8938 | DEFUN (show_ip_bgp_regexp, | |
8939 | show_ip_bgp_regexp_cmd, | |
8940 | "show ip bgp regexp .LINE", | |
8941 | SHOW_STR | |
8942 | IP_STR | |
8943 | BGP_STR | |
8944 | "Display routes matching the AS path regular expression\n" | |
8945 | "A regular-expression to match the BGP AS paths\n") | |
8946 | { | |
8947 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
8948 | bgp_show_type_regexp); | |
8949 | } | |
8950 | ||
8951 | DEFUN (show_ip_bgp_flap_regexp, | |
8952 | show_ip_bgp_flap_regexp_cmd, | |
8953 | "show ip bgp flap-statistics regexp .LINE", | |
8954 | SHOW_STR | |
8955 | IP_STR | |
8956 | BGP_STR | |
8957 | "Display flap statistics of routes\n" | |
8958 | "Display routes matching the AS path regular expression\n" | |
8959 | "A regular-expression to match the BGP AS paths\n") | |
8960 | { | |
8961 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
8962 | bgp_show_type_flap_regexp); | |
8963 | } | |
8964 | ||
81304aaf B |
8965 | ALIAS (show_ip_bgp_flap_regexp, |
8966 | show_ip_bgp_damp_flap_regexp_cmd, | |
8967 | "show ip bgp dampening flap-statistics regexp .LINE", | |
8968 | SHOW_STR | |
8969 | IP_STR | |
8970 | BGP_STR | |
8971 | "Display detailed information about dampening\n" | |
8972 | "Display flap statistics of routes\n" | |
8973 | "Display routes matching the AS path regular expression\n" | |
8974 | "A regular-expression to match the BGP AS paths\n") | |
8975 | ||
718e3744 | 8976 | DEFUN (show_ip_bgp_ipv4_regexp, |
8977 | show_ip_bgp_ipv4_regexp_cmd, | |
8978 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", | |
8979 | SHOW_STR | |
8980 | IP_STR | |
8981 | BGP_STR | |
8982 | "Address family\n" | |
8983 | "Address Family modifier\n" | |
8984 | "Address Family modifier\n" | |
8985 | "Display routes matching the AS path regular expression\n" | |
8986 | "A regular-expression to match the BGP AS paths\n") | |
8987 | { | |
8988 | if (strncmp (argv[0], "m", 1) == 0) | |
8989 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, | |
8990 | bgp_show_type_regexp); | |
8991 | ||
8992 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
8993 | bgp_show_type_regexp); | |
8994 | } | |
8995 | ||
8996 | #ifdef HAVE_IPV6 | |
8997 | DEFUN (show_bgp_regexp, | |
8998 | show_bgp_regexp_cmd, | |
8999 | "show bgp regexp .LINE", | |
9000 | SHOW_STR | |
9001 | BGP_STR | |
9002 | "Display routes matching the AS path regular expression\n" | |
9003 | "A regular-expression to match the BGP AS paths\n") | |
9004 | { | |
9005 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
9006 | bgp_show_type_regexp); | |
9007 | } | |
9008 | ||
9009 | ALIAS (show_bgp_regexp, | |
9010 | show_bgp_ipv6_regexp_cmd, | |
9011 | "show bgp ipv6 regexp .LINE", | |
9012 | SHOW_STR | |
9013 | BGP_STR | |
9014 | "Address family\n" | |
9015 | "Display routes matching the AS path regular expression\n" | |
9016 | "A regular-expression to match the BGP AS paths\n") | |
9017 | ||
9018 | /* old command */ | |
9019 | DEFUN (show_ipv6_bgp_regexp, | |
9020 | show_ipv6_bgp_regexp_cmd, | |
9021 | "show ipv6 bgp regexp .LINE", | |
9022 | SHOW_STR | |
9023 | IP_STR | |
9024 | BGP_STR | |
9025 | "Display routes matching the AS path regular expression\n" | |
9026 | "A regular-expression to match the BGP AS paths\n") | |
9027 | { | |
47e9b292 | 9028 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9029 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
9030 | bgp_show_type_regexp); | |
9031 | } | |
9032 | ||
9033 | /* old command */ | |
9034 | DEFUN (show_ipv6_mbgp_regexp, | |
9035 | show_ipv6_mbgp_regexp_cmd, | |
9036 | "show ipv6 mbgp regexp .LINE", | |
9037 | SHOW_STR | |
9038 | IP_STR | |
9039 | BGP_STR | |
9040 | "Display routes matching the AS path regular expression\n" | |
9041 | "A regular-expression to match the MBGP AS paths\n") | |
9042 | { | |
47e9b292 | 9043 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9044 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
9045 | bgp_show_type_regexp); | |
9046 | } | |
9047 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 9048 | |
94f2b392 | 9049 | static int |
50ef26d4 | 9050 | bgp_show_prefix_list (struct vty *vty, const char *name, |
9051 | const char *prefix_list_str, afi_t afi, | |
718e3744 | 9052 | safi_t safi, enum bgp_show_type type) |
9053 | { | |
9054 | struct prefix_list *plist; | |
50ef26d4 | 9055 | struct bgp *bgp = NULL; |
9056 | ||
9057 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
9058 | { | |
9059 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
9060 | return CMD_WARNING; | |
9061 | } | |
718e3744 | 9062 | |
9063 | plist = prefix_list_lookup (afi, prefix_list_str); | |
9064 | if (plist == NULL) | |
9065 | { | |
9066 | vty_out (vty, "%% %s is not a valid prefix-list name%s", | |
9067 | prefix_list_str, VTY_NEWLINE); | |
9068 | return CMD_WARNING; | |
9069 | } | |
9070 | ||
50ef26d4 | 9071 | return bgp_show (vty, bgp, afi, safi, type, plist, 0); |
718e3744 | 9072 | } |
9073 | ||
9074 | DEFUN (show_ip_bgp_prefix_list, | |
9075 | show_ip_bgp_prefix_list_cmd, | |
9076 | "show ip bgp prefix-list WORD", | |
9077 | SHOW_STR | |
9078 | IP_STR | |
9079 | BGP_STR | |
9080 | "Display routes conforming to the prefix-list\n" | |
9081 | "IP prefix-list name\n") | |
9082 | { | |
50ef26d4 | 9083 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
9084 | bgp_show_type_prefix_list); | |
9085 | } | |
9086 | ||
8386ac43 | 9087 | DEFUN (show_ip_bgp_instance_prefix_list, |
9088 | show_ip_bgp_instance_prefix_list_cmd, | |
9089 | "show ip bgp " BGP_INSTANCE_CMD " prefix-list WORD", | |
50ef26d4 | 9090 | SHOW_STR |
9091 | IP_STR | |
9092 | BGP_STR | |
8386ac43 | 9093 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 9094 | "Display routes conforming to the prefix-list\n" |
9095 | "IP prefix-list name\n") | |
9096 | { | |
9097 | return bgp_show_prefix_list (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 9098 | bgp_show_type_prefix_list); |
9099 | } | |
9100 | ||
9101 | DEFUN (show_ip_bgp_flap_prefix_list, | |
9102 | show_ip_bgp_flap_prefix_list_cmd, | |
9103 | "show ip bgp flap-statistics prefix-list WORD", | |
9104 | SHOW_STR | |
9105 | IP_STR | |
9106 | BGP_STR | |
9107 | "Display flap statistics of routes\n" | |
9108 | "Display routes conforming to the prefix-list\n" | |
9109 | "IP prefix-list name\n") | |
9110 | { | |
50ef26d4 | 9111 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 9112 | bgp_show_type_flap_prefix_list); |
9113 | } | |
9114 | ||
81304aaf B |
9115 | ALIAS (show_ip_bgp_flap_prefix_list, |
9116 | show_ip_bgp_damp_flap_prefix_list_cmd, | |
9117 | "show ip bgp dampening flap-statistics prefix-list WORD", | |
9118 | SHOW_STR | |
9119 | IP_STR | |
9120 | BGP_STR | |
9121 | "Display detailed information about dampening\n" | |
9122 | "Display flap statistics of routes\n" | |
9123 | "Display routes conforming to the prefix-list\n" | |
9124 | "IP prefix-list name\n") | |
9125 | ||
718e3744 | 9126 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
9127 | show_ip_bgp_ipv4_prefix_list_cmd, | |
9128 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", | |
9129 | SHOW_STR | |
9130 | IP_STR | |
9131 | BGP_STR | |
9132 | "Address family\n" | |
9133 | "Address Family modifier\n" | |
9134 | "Address Family modifier\n" | |
9135 | "Display routes conforming to the prefix-list\n" | |
9136 | "IP prefix-list name\n") | |
9137 | { | |
9138 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 9139 | return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 9140 | bgp_show_type_prefix_list); |
9141 | ||
50ef26d4 | 9142 | return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 9143 | bgp_show_type_prefix_list); |
9144 | } | |
9145 | ||
9146 | #ifdef HAVE_IPV6 | |
9147 | DEFUN (show_bgp_prefix_list, | |
9148 | show_bgp_prefix_list_cmd, | |
9149 | "show bgp prefix-list WORD", | |
9150 | SHOW_STR | |
9151 | BGP_STR | |
9152 | "Display routes conforming to the prefix-list\n" | |
9153 | "IPv6 prefix-list name\n") | |
9154 | { | |
50ef26d4 | 9155 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9156 | bgp_show_type_prefix_list); |
9157 | } | |
9158 | ||
9159 | ALIAS (show_bgp_prefix_list, | |
9160 | show_bgp_ipv6_prefix_list_cmd, | |
9161 | "show bgp ipv6 prefix-list WORD", | |
9162 | SHOW_STR | |
9163 | BGP_STR | |
9164 | "Address family\n" | |
9165 | "Display routes conforming to the prefix-list\n" | |
9166 | "IPv6 prefix-list name\n") | |
9167 | ||
9168 | /* old command */ | |
9169 | DEFUN (show_ipv6_bgp_prefix_list, | |
9170 | show_ipv6_bgp_prefix_list_cmd, | |
9171 | "show ipv6 bgp prefix-list WORD", | |
9172 | SHOW_STR | |
9173 | IPV6_STR | |
9174 | BGP_STR | |
9175 | "Display routes matching the prefix-list\n" | |
9176 | "IPv6 prefix-list name\n") | |
9177 | { | |
47e9b292 | 9178 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 9179 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9180 | bgp_show_type_prefix_list); |
9181 | } | |
9182 | ||
9183 | /* old command */ | |
9184 | DEFUN (show_ipv6_mbgp_prefix_list, | |
9185 | show_ipv6_mbgp_prefix_list_cmd, | |
9186 | "show ipv6 mbgp prefix-list WORD", | |
9187 | SHOW_STR | |
9188 | IPV6_STR | |
9189 | MBGP_STR | |
9190 | "Display routes matching the prefix-list\n" | |
9191 | "IPv6 prefix-list name\n") | |
9192 | { | |
47e9b292 | 9193 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 9194 | return bgp_show_prefix_list (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, |
718e3744 | 9195 | bgp_show_type_prefix_list); |
9196 | } | |
9197 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 9198 | |
94f2b392 | 9199 | static int |
50ef26d4 | 9200 | bgp_show_filter_list (struct vty *vty, const char *name, |
9201 | const char *filter, afi_t afi, | |
718e3744 | 9202 | safi_t safi, enum bgp_show_type type) |
9203 | { | |
9204 | struct as_list *as_list; | |
50ef26d4 | 9205 | struct bgp *bgp = NULL; |
9206 | ||
9207 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
9208 | { | |
9209 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
9210 | return CMD_WARNING; | |
9211 | } | |
718e3744 | 9212 | |
9213 | as_list = as_list_lookup (filter); | |
9214 | if (as_list == NULL) | |
9215 | { | |
9216 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); | |
9217 | return CMD_WARNING; | |
9218 | } | |
9219 | ||
50ef26d4 | 9220 | return bgp_show (vty, bgp, afi, safi, type, as_list, 0); |
718e3744 | 9221 | } |
9222 | ||
9223 | DEFUN (show_ip_bgp_filter_list, | |
9224 | show_ip_bgp_filter_list_cmd, | |
9225 | "show ip bgp filter-list WORD", | |
9226 | SHOW_STR | |
9227 | IP_STR | |
9228 | BGP_STR | |
9229 | "Display routes conforming to the filter-list\n" | |
9230 | "Regular expression access list name\n") | |
9231 | { | |
50ef26d4 | 9232 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
9233 | bgp_show_type_filter_list); | |
9234 | } | |
9235 | ||
8386ac43 | 9236 | DEFUN (show_ip_bgp_instance_filter_list, |
9237 | show_ip_bgp_instance_filter_list_cmd, | |
9238 | "show ip bgp " BGP_INSTANCE_CMD " filter-list WORD", | |
50ef26d4 | 9239 | SHOW_STR |
9240 | IP_STR | |
9241 | BGP_STR | |
8386ac43 | 9242 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 9243 | "Display routes conforming to the filter-list\n" |
9244 | "Regular expression access list name\n") | |
9245 | { | |
9246 | return bgp_show_filter_list (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 9247 | bgp_show_type_filter_list); |
9248 | } | |
9249 | ||
9250 | DEFUN (show_ip_bgp_flap_filter_list, | |
9251 | show_ip_bgp_flap_filter_list_cmd, | |
9252 | "show ip bgp flap-statistics filter-list WORD", | |
9253 | SHOW_STR | |
9254 | IP_STR | |
9255 | BGP_STR | |
9256 | "Display flap statistics of routes\n" | |
9257 | "Display routes conforming to the filter-list\n" | |
9258 | "Regular expression access list name\n") | |
9259 | { | |
50ef26d4 | 9260 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 9261 | bgp_show_type_flap_filter_list); |
9262 | } | |
9263 | ||
81304aaf B |
9264 | ALIAS (show_ip_bgp_flap_filter_list, |
9265 | show_ip_bgp_damp_flap_filter_list_cmd, | |
9266 | "show ip bgp dampening flap-statistics filter-list WORD", | |
9267 | SHOW_STR | |
9268 | IP_STR | |
9269 | BGP_STR | |
9270 | "Display detailed information about dampening\n" | |
9271 | "Display flap statistics of routes\n" | |
9272 | "Display routes conforming to the filter-list\n" | |
9273 | "Regular expression access list name\n") | |
9274 | ||
718e3744 | 9275 | DEFUN (show_ip_bgp_ipv4_filter_list, |
9276 | show_ip_bgp_ipv4_filter_list_cmd, | |
9277 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", | |
9278 | SHOW_STR | |
9279 | IP_STR | |
9280 | BGP_STR | |
9281 | "Address family\n" | |
9282 | "Address Family modifier\n" | |
9283 | "Address Family modifier\n" | |
9284 | "Display routes conforming to the filter-list\n" | |
9285 | "Regular expression access list name\n") | |
9286 | { | |
9287 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 9288 | return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 9289 | bgp_show_type_filter_list); |
9290 | ||
50ef26d4 | 9291 | return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 9292 | bgp_show_type_filter_list); |
9293 | } | |
9294 | ||
9295 | #ifdef HAVE_IPV6 | |
9296 | DEFUN (show_bgp_filter_list, | |
9297 | show_bgp_filter_list_cmd, | |
9298 | "show bgp filter-list WORD", | |
9299 | SHOW_STR | |
9300 | BGP_STR | |
9301 | "Display routes conforming to the filter-list\n" | |
9302 | "Regular expression access list name\n") | |
9303 | { | |
50ef26d4 | 9304 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9305 | bgp_show_type_filter_list); |
9306 | } | |
9307 | ||
9308 | ALIAS (show_bgp_filter_list, | |
9309 | show_bgp_ipv6_filter_list_cmd, | |
9310 | "show bgp ipv6 filter-list WORD", | |
9311 | SHOW_STR | |
9312 | BGP_STR | |
9313 | "Address family\n" | |
9314 | "Display routes conforming to the filter-list\n" | |
9315 | "Regular expression access list name\n") | |
9316 | ||
9317 | /* old command */ | |
9318 | DEFUN (show_ipv6_bgp_filter_list, | |
9319 | show_ipv6_bgp_filter_list_cmd, | |
9320 | "show ipv6 bgp filter-list WORD", | |
9321 | SHOW_STR | |
9322 | IPV6_STR | |
9323 | BGP_STR | |
9324 | "Display routes conforming to the filter-list\n" | |
9325 | "Regular expression access list name\n") | |
9326 | { | |
47e9b292 | 9327 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 9328 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9329 | bgp_show_type_filter_list); |
9330 | } | |
9331 | ||
9332 | /* old command */ | |
9333 | DEFUN (show_ipv6_mbgp_filter_list, | |
9334 | show_ipv6_mbgp_filter_list_cmd, | |
9335 | "show ipv6 mbgp filter-list WORD", | |
9336 | SHOW_STR | |
9337 | IPV6_STR | |
9338 | MBGP_STR | |
9339 | "Display routes conforming to the filter-list\n" | |
9340 | "Regular expression access list name\n") | |
9341 | { | |
47e9b292 | 9342 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 9343 | return bgp_show_filter_list (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, |
718e3744 | 9344 | bgp_show_type_filter_list); |
9345 | } | |
9346 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 9347 | |
81304aaf B |
9348 | DEFUN (show_ip_bgp_dampening_info, |
9349 | show_ip_bgp_dampening_params_cmd, | |
9350 | "show ip bgp dampening parameters", | |
9351 | SHOW_STR | |
9352 | IP_STR | |
9353 | BGP_STR | |
9354 | "Display detailed information about dampening\n" | |
9355 | "Display detail of configured dampening parameters\n") | |
9356 | { | |
9357 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); | |
9358 | } | |
9359 | ||
58a90275 B |
9360 | |
9361 | DEFUN (show_ip_bgp_ipv4_dampening_parameters, | |
9362 | show_ip_bgp_ipv4_dampening_parameters_cmd, | |
9363 | "show ip bgp ipv4 (unicast|multicast) dampening parameters", | |
9364 | SHOW_STR | |
9365 | IP_STR | |
9366 | BGP_STR | |
9367 | "Address family\n" | |
9368 | "Address Family modifier\n" | |
9369 | "Address Family modifier\n" | |
9370 | "Display detailed information about dampening\n" | |
9371 | "Display detail of configured dampening parameters\n") | |
9372 | { | |
9373 | if (strncmp(argv[0], "m", 1) == 0) | |
9374 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); | |
9375 | ||
9376 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); | |
9377 | } | |
9378 | ||
9379 | ||
9380 | DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, | |
9381 | show_ip_bgp_ipv4_dampening_flap_stats_cmd, | |
9382 | "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics", | |
9383 | SHOW_STR | |
9384 | IP_STR | |
9385 | BGP_STR | |
9386 | "Address family\n" | |
9387 | "Address Family modifier\n" | |
9388 | "Address Family modifier\n" | |
9389 | "Display detailed information about dampening\n" | |
9390 | "Display flap statistics of routes\n") | |
9391 | { | |
9392 | if (strncmp(argv[0], "m", 1) == 0) | |
9393 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
9394 | bgp_show_type_flap_statistics, NULL, 0); | |
9395 | ||
9396 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
9397 | bgp_show_type_flap_statistics, NULL, 0); | |
9398 | } | |
9399 | ||
9400 | DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, | |
9401 | show_ip_bgp_ipv4_dampening_dampd_paths_cmd, | |
9402 | "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths", | |
9403 | SHOW_STR | |
9404 | IP_STR | |
9405 | BGP_STR | |
9406 | "Address family\n" | |
9407 | "Address Family modifier\n" | |
9408 | "Address Family modifier\n" | |
9409 | "Display detailed information about dampening\n" | |
9410 | "Display paths suppressed due to dampening\n") | |
9411 | { | |
9412 | if (strncmp(argv[0], "m", 1) == 0) | |
9413 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
9414 | bgp_show_type_dampend_paths, NULL, 0); | |
9415 | ||
9416 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
9417 | bgp_show_type_dampend_paths, NULL, 0); | |
9418 | } | |
9419 | ||
94f2b392 | 9420 | static int |
50ef26d4 | 9421 | bgp_show_route_map (struct vty *vty, const char *name, |
9422 | const char *rmap_str, afi_t afi, | |
718e3744 | 9423 | safi_t safi, enum bgp_show_type type) |
9424 | { | |
9425 | struct route_map *rmap; | |
50ef26d4 | 9426 | struct bgp *bgp = NULL; |
9427 | ||
9428 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
9429 | { | |
9430 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
9431 | return CMD_WARNING; | |
9432 | } | |
718e3744 | 9433 | |
9434 | rmap = route_map_lookup_by_name (rmap_str); | |
9435 | if (! rmap) | |
9436 | { | |
9437 | vty_out (vty, "%% %s is not a valid route-map name%s", | |
9438 | rmap_str, VTY_NEWLINE); | |
9439 | return CMD_WARNING; | |
9440 | } | |
9441 | ||
50ef26d4 | 9442 | return bgp_show (vty, bgp, afi, safi, type, rmap, 0); |
718e3744 | 9443 | } |
9444 | ||
9445 | DEFUN (show_ip_bgp_route_map, | |
9446 | show_ip_bgp_route_map_cmd, | |
9447 | "show ip bgp route-map WORD", | |
9448 | SHOW_STR | |
9449 | IP_STR | |
9450 | BGP_STR | |
9451 | "Display routes matching the route-map\n" | |
9452 | "A route-map to match on\n") | |
9453 | { | |
50ef26d4 | 9454 | return bgp_show_route_map (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
9455 | bgp_show_type_route_map); | |
9456 | } | |
9457 | ||
8386ac43 | 9458 | DEFUN (show_ip_bgp_instance_route_map, |
9459 | show_ip_bgp_instance_route_map_cmd, | |
9460 | "show ip bgp " BGP_INSTANCE_CMD " route-map WORD", | |
50ef26d4 | 9461 | SHOW_STR |
9462 | IP_STR | |
9463 | BGP_STR | |
8386ac43 | 9464 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 9465 | "Display routes matching the route-map\n" |
9466 | "A route-map to match on\n") | |
9467 | { | |
9468 | return bgp_show_route_map (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 9469 | bgp_show_type_route_map); |
9470 | } | |
9471 | ||
9472 | DEFUN (show_ip_bgp_flap_route_map, | |
9473 | show_ip_bgp_flap_route_map_cmd, | |
9474 | "show ip bgp flap-statistics route-map WORD", | |
9475 | SHOW_STR | |
9476 | IP_STR | |
9477 | BGP_STR | |
9478 | "Display flap statistics of routes\n" | |
9479 | "Display routes matching the route-map\n" | |
9480 | "A route-map to match on\n") | |
9481 | { | |
50ef26d4 | 9482 | return bgp_show_route_map (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 9483 | bgp_show_type_flap_route_map); |
9484 | } | |
9485 | ||
81304aaf B |
9486 | ALIAS (show_ip_bgp_flap_route_map, |
9487 | show_ip_bgp_damp_flap_route_map_cmd, | |
9488 | "show ip bgp dampening flap-statistics route-map WORD", | |
9489 | SHOW_STR | |
9490 | IP_STR | |
9491 | BGP_STR | |
9492 | "Display detailed information about dampening\n" | |
9493 | "Display flap statistics of routes\n" | |
9494 | "Display routes matching the route-map\n" | |
9495 | "A route-map to match on\n") | |
9496 | ||
718e3744 | 9497 | DEFUN (show_ip_bgp_ipv4_route_map, |
9498 | show_ip_bgp_ipv4_route_map_cmd, | |
9499 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", | |
9500 | SHOW_STR | |
9501 | IP_STR | |
9502 | BGP_STR | |
9503 | "Address family\n" | |
9504 | "Address Family modifier\n" | |
9505 | "Address Family modifier\n" | |
9506 | "Display routes matching the route-map\n" | |
9507 | "A route-map to match on\n") | |
9508 | { | |
9509 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 9510 | return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 9511 | bgp_show_type_route_map); |
9512 | ||
50ef26d4 | 9513 | return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 9514 | bgp_show_type_route_map); |
9515 | } | |
9516 | ||
9517 | DEFUN (show_bgp_route_map, | |
9518 | show_bgp_route_map_cmd, | |
9519 | "show bgp route-map WORD", | |
9520 | SHOW_STR | |
9521 | BGP_STR | |
9522 | "Display routes matching the route-map\n" | |
9523 | "A route-map to match on\n") | |
9524 | { | |
50ef26d4 | 9525 | return bgp_show_route_map (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 9526 | bgp_show_type_route_map); |
9527 | } | |
9528 | ||
9529 | ALIAS (show_bgp_route_map, | |
9530 | show_bgp_ipv6_route_map_cmd, | |
9531 | "show bgp ipv6 route-map WORD", | |
9532 | SHOW_STR | |
9533 | BGP_STR | |
9534 | "Address family\n" | |
9535 | "Display routes matching the route-map\n" | |
9536 | "A route-map to match on\n") | |
6b0655a2 | 9537 | |
718e3744 | 9538 | DEFUN (show_ip_bgp_cidr_only, |
9539 | show_ip_bgp_cidr_only_cmd, | |
9540 | "show ip bgp cidr-only", | |
9541 | SHOW_STR | |
9542 | IP_STR | |
9543 | BGP_STR | |
9544 | "Display only routes with non-natural netmasks\n") | |
9545 | { | |
9546 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9547 | bgp_show_type_cidr_only, NULL, 0); |
718e3744 | 9548 | } |
9549 | ||
9550 | DEFUN (show_ip_bgp_flap_cidr_only, | |
9551 | show_ip_bgp_flap_cidr_only_cmd, | |
9552 | "show ip bgp flap-statistics cidr-only", | |
9553 | SHOW_STR | |
9554 | IP_STR | |
9555 | BGP_STR | |
9556 | "Display flap statistics of routes\n" | |
9557 | "Display only routes with non-natural netmasks\n") | |
9558 | { | |
9559 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9560 | bgp_show_type_flap_cidr_only, NULL, 0); |
718e3744 | 9561 | } |
9562 | ||
81304aaf B |
9563 | ALIAS (show_ip_bgp_flap_cidr_only, |
9564 | show_ip_bgp_damp_flap_cidr_only_cmd, | |
9565 | "show ip bgp dampening flap-statistics cidr-only", | |
9566 | SHOW_STR | |
9567 | IP_STR | |
9568 | BGP_STR | |
9569 | "Display detailed information about dampening\n" | |
9570 | "Display flap statistics of routes\n" | |
9571 | "Display only routes with non-natural netmasks\n") | |
9572 | ||
718e3744 | 9573 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
9574 | show_ip_bgp_ipv4_cidr_only_cmd, | |
9575 | "show ip bgp ipv4 (unicast|multicast) cidr-only", | |
9576 | SHOW_STR | |
9577 | IP_STR | |
9578 | BGP_STR | |
9579 | "Address family\n" | |
9580 | "Address Family modifier\n" | |
9581 | "Address Family modifier\n" | |
9582 | "Display only routes with non-natural netmasks\n") | |
9583 | { | |
9584 | if (strncmp (argv[0], "m", 1) == 0) | |
9585 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
b05a1c8b | 9586 | bgp_show_type_cidr_only, NULL, 0); |
718e3744 | 9587 | |
9588 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9589 | bgp_show_type_cidr_only, NULL, 0); |
718e3744 | 9590 | } |
6b0655a2 | 9591 | |
718e3744 | 9592 | DEFUN (show_ip_bgp_community_all, |
9593 | show_ip_bgp_community_all_cmd, | |
9594 | "show ip bgp community", | |
9595 | SHOW_STR | |
9596 | IP_STR | |
9597 | BGP_STR | |
9598 | "Display routes matching the communities\n") | |
9599 | { | |
9600 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9601 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9602 | } |
9603 | ||
9604 | DEFUN (show_ip_bgp_ipv4_community_all, | |
9605 | show_ip_bgp_ipv4_community_all_cmd, | |
9606 | "show ip bgp ipv4 (unicast|multicast) community", | |
9607 | SHOW_STR | |
9608 | IP_STR | |
9609 | BGP_STR | |
9610 | "Address family\n" | |
9611 | "Address Family modifier\n" | |
9612 | "Address Family modifier\n" | |
9613 | "Display routes matching the communities\n") | |
9614 | { | |
9615 | if (strncmp (argv[0], "m", 1) == 0) | |
9616 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
b05a1c8b | 9617 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9618 | |
9619 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
b05a1c8b | 9620 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9621 | } |
9622 | ||
9623 | #ifdef HAVE_IPV6 | |
9624 | DEFUN (show_bgp_community_all, | |
9625 | show_bgp_community_all_cmd, | |
9626 | "show bgp community", | |
9627 | SHOW_STR | |
9628 | BGP_STR | |
9629 | "Display routes matching the communities\n") | |
9630 | { | |
9631 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
b05a1c8b | 9632 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9633 | } |
9634 | ||
9635 | ALIAS (show_bgp_community_all, | |
9636 | show_bgp_ipv6_community_all_cmd, | |
9637 | "show bgp ipv6 community", | |
9638 | SHOW_STR | |
9639 | BGP_STR | |
9640 | "Address family\n" | |
9641 | "Display routes matching the communities\n") | |
9642 | ||
9643 | /* old command */ | |
9644 | DEFUN (show_ipv6_bgp_community_all, | |
9645 | show_ipv6_bgp_community_all_cmd, | |
9646 | "show ipv6 bgp community", | |
9647 | SHOW_STR | |
9648 | IPV6_STR | |
9649 | BGP_STR | |
9650 | "Display routes matching the communities\n") | |
9651 | { | |
47e9b292 | 9652 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9653 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
b05a1c8b | 9654 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9655 | } |
9656 | ||
9657 | /* old command */ | |
9658 | DEFUN (show_ipv6_mbgp_community_all, | |
9659 | show_ipv6_mbgp_community_all_cmd, | |
9660 | "show ipv6 mbgp community", | |
9661 | SHOW_STR | |
9662 | IPV6_STR | |
9663 | MBGP_STR | |
9664 | "Display routes matching the communities\n") | |
9665 | { | |
47e9b292 | 9666 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
718e3744 | 9667 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
b05a1c8b | 9668 | bgp_show_type_community_all, NULL, 0); |
718e3744 | 9669 | } |
9670 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 9671 | |
94f2b392 | 9672 | static int |
95cbbd2a ML |
9673 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
9674 | const char **argv, int exact, afi_t afi, safi_t safi) | |
718e3744 | 9675 | { |
9676 | struct community *com; | |
9677 | struct buffer *b; | |
95cbbd2a | 9678 | struct bgp *bgp; |
718e3744 | 9679 | int i; |
9680 | char *str; | |
9681 | int first = 0; | |
9682 | ||
95cbbd2a ML |
9683 | /* BGP structure lookup */ |
9684 | if (view_name) | |
9685 | { | |
9686 | bgp = bgp_lookup_by_name (view_name); | |
9687 | if (bgp == NULL) | |
9688 | { | |
6aeb9e78 | 9689 | vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
95cbbd2a ML |
9690 | return CMD_WARNING; |
9691 | } | |
9692 | } | |
9693 | else | |
9694 | { | |
9695 | bgp = bgp_get_default (); | |
9696 | if (bgp == NULL) | |
9697 | { | |
9698 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
9699 | return CMD_WARNING; | |
9700 | } | |
9701 | } | |
9702 | ||
718e3744 | 9703 | b = buffer_new (1024); |
9704 | for (i = 0; i < argc; i++) | |
9705 | { | |
9706 | if (first) | |
9707 | buffer_putc (b, ' '); | |
9708 | else | |
9709 | { | |
9710 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
9711 | continue; | |
9712 | first = 1; | |
9713 | } | |
9714 | ||
9715 | buffer_putstr (b, argv[i]); | |
9716 | } | |
9717 | buffer_putc (b, '\0'); | |
9718 | ||
9719 | str = buffer_getstr (b); | |
9720 | buffer_free (b); | |
9721 | ||
9722 | com = community_str2com (str); | |
3b8b1855 | 9723 | XFREE (MTYPE_TMP, str); |
718e3744 | 9724 | if (! com) |
9725 | { | |
9726 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); | |
9727 | return CMD_WARNING; | |
9728 | } | |
9729 | ||
95cbbd2a | 9730 | return bgp_show (vty, bgp, afi, safi, |
5a646650 | 9731 | (exact ? bgp_show_type_community_exact : |
b05a1c8b | 9732 | bgp_show_type_community), com, 0); |
718e3744 | 9733 | } |
9734 | ||
9735 | DEFUN (show_ip_bgp_community, | |
9736 | show_ip_bgp_community_cmd, | |
9737 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
9738 | SHOW_STR | |
9739 | IP_STR | |
9740 | BGP_STR | |
9741 | "Display routes matching the communities\n" | |
859d388e | 9742 | COMMUNITY_AANN_STR |
718e3744 | 9743 | "Do not send outside local AS (well-known community)\n" |
9744 | "Do not advertise to any peer (well-known community)\n" | |
9745 | "Do not export to next AS (well-known community)\n") | |
9746 | { | |
95cbbd2a | 9747 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 9748 | } |
9749 | ||
9750 | ALIAS (show_ip_bgp_community, | |
9751 | show_ip_bgp_community2_cmd, | |
9752 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9753 | SHOW_STR | |
9754 | IP_STR | |
9755 | BGP_STR | |
9756 | "Display routes matching the communities\n" | |
859d388e | 9757 | COMMUNITY_AANN_STR |
718e3744 | 9758 | "Do not send outside local AS (well-known community)\n" |
9759 | "Do not advertise to any peer (well-known community)\n" | |
9760 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9761 | COMMUNITY_AANN_STR |
718e3744 | 9762 | "Do not send outside local AS (well-known community)\n" |
9763 | "Do not advertise to any peer (well-known community)\n" | |
9764 | "Do not export to next AS (well-known community)\n") | |
9765 | ||
9766 | ALIAS (show_ip_bgp_community, | |
9767 | show_ip_bgp_community3_cmd, | |
9768 | "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)", | |
9769 | SHOW_STR | |
9770 | IP_STR | |
9771 | BGP_STR | |
9772 | "Display routes matching the communities\n" | |
859d388e | 9773 | COMMUNITY_AANN_STR |
718e3744 | 9774 | "Do not send outside local AS (well-known community)\n" |
9775 | "Do not advertise to any peer (well-known community)\n" | |
9776 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9777 | COMMUNITY_AANN_STR |
718e3744 | 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" | |
859d388e | 9781 | COMMUNITY_AANN_STR |
718e3744 | 9782 | "Do not send outside local AS (well-known community)\n" |
9783 | "Do not advertise to any peer (well-known community)\n" | |
9784 | "Do not export to next AS (well-known community)\n") | |
9785 | ||
9786 | ALIAS (show_ip_bgp_community, | |
9787 | show_ip_bgp_community4_cmd, | |
9788 | "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)", | |
9789 | SHOW_STR | |
9790 | IP_STR | |
9791 | BGP_STR | |
9792 | "Display routes matching the communities\n" | |
859d388e | 9793 | COMMUNITY_AANN_STR |
718e3744 | 9794 | "Do not send outside local AS (well-known community)\n" |
9795 | "Do not advertise to any peer (well-known community)\n" | |
9796 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9797 | COMMUNITY_AANN_STR |
718e3744 | 9798 | "Do not send outside local AS (well-known community)\n" |
9799 | "Do not advertise to any peer (well-known community)\n" | |
9800 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9801 | COMMUNITY_AANN_STR |
718e3744 | 9802 | "Do not send outside local AS (well-known community)\n" |
9803 | "Do not advertise to any peer (well-known community)\n" | |
9804 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9805 | COMMUNITY_AANN_STR |
718e3744 | 9806 | "Do not send outside local AS (well-known community)\n" |
9807 | "Do not advertise to any peer (well-known community)\n" | |
9808 | "Do not export to next AS (well-known community)\n") | |
9809 | ||
9810 | DEFUN (show_ip_bgp_ipv4_community, | |
9811 | show_ip_bgp_ipv4_community_cmd, | |
9812 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
9813 | SHOW_STR | |
9814 | IP_STR | |
9815 | BGP_STR | |
9816 | "Address family\n" | |
9817 | "Address Family modifier\n" | |
9818 | "Address Family modifier\n" | |
9819 | "Display routes matching the communities\n" | |
859d388e | 9820 | COMMUNITY_AANN_STR |
718e3744 | 9821 | "Do not send outside local AS (well-known community)\n" |
9822 | "Do not advertise to any peer (well-known community)\n" | |
9823 | "Do not export to next AS (well-known community)\n") | |
9824 | { | |
9825 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 9826 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
718e3744 | 9827 | |
95cbbd2a | 9828 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 9829 | } |
9830 | ||
9831 | ALIAS (show_ip_bgp_ipv4_community, | |
9832 | show_ip_bgp_ipv4_community2_cmd, | |
9833 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
9834 | SHOW_STR | |
9835 | IP_STR | |
9836 | BGP_STR | |
9837 | "Address family\n" | |
9838 | "Address Family modifier\n" | |
9839 | "Address Family modifier\n" | |
9840 | "Display routes matching the communities\n" | |
859d388e | 9841 | COMMUNITY_AANN_STR |
718e3744 | 9842 | "Do not send outside local AS (well-known community)\n" |
9843 | "Do not advertise to any peer (well-known community)\n" | |
9844 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9845 | COMMUNITY_AANN_STR |
718e3744 | 9846 | "Do not send outside local AS (well-known community)\n" |
9847 | "Do not advertise to any peer (well-known community)\n" | |
9848 | "Do not export to next AS (well-known community)\n") | |
9849 | ||
9850 | ALIAS (show_ip_bgp_ipv4_community, | |
9851 | show_ip_bgp_ipv4_community3_cmd, | |
9852 | "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)", | |
9853 | SHOW_STR | |
9854 | IP_STR | |
9855 | BGP_STR | |
9856 | "Address family\n" | |
9857 | "Address Family modifier\n" | |
9858 | "Address Family modifier\n" | |
9859 | "Display routes matching the communities\n" | |
859d388e | 9860 | COMMUNITY_AANN_STR |
718e3744 | 9861 | "Do not send outside local AS (well-known community)\n" |
9862 | "Do not advertise to any peer (well-known community)\n" | |
9863 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9864 | COMMUNITY_AANN_STR |
718e3744 | 9865 | "Do not send outside local AS (well-known community)\n" |
9866 | "Do not advertise to any peer (well-known community)\n" | |
9867 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9868 | COMMUNITY_AANN_STR |
718e3744 | 9869 | "Do not send outside local AS (well-known community)\n" |
9870 | "Do not advertise to any peer (well-known community)\n" | |
9871 | "Do not export to next AS (well-known community)\n") | |
9872 | ||
9873 | ALIAS (show_ip_bgp_ipv4_community, | |
9874 | show_ip_bgp_ipv4_community4_cmd, | |
9875 | "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)", | |
9876 | SHOW_STR | |
9877 | IP_STR | |
9878 | BGP_STR | |
9879 | "Address family\n" | |
9880 | "Address Family modifier\n" | |
9881 | "Address Family modifier\n" | |
9882 | "Display routes matching the communities\n" | |
859d388e | 9883 | COMMUNITY_AANN_STR |
718e3744 | 9884 | "Do not send outside local AS (well-known community)\n" |
9885 | "Do not advertise to any peer (well-known community)\n" | |
9886 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9887 | COMMUNITY_AANN_STR |
718e3744 | 9888 | "Do not send outside local AS (well-known community)\n" |
9889 | "Do not advertise to any peer (well-known community)\n" | |
9890 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9891 | COMMUNITY_AANN_STR |
718e3744 | 9892 | "Do not send outside local AS (well-known community)\n" |
9893 | "Do not advertise to any peer (well-known community)\n" | |
9894 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9895 | COMMUNITY_AANN_STR |
718e3744 | 9896 | "Do not send outside local AS (well-known community)\n" |
9897 | "Do not advertise to any peer (well-known community)\n" | |
9898 | "Do not export to next AS (well-known community)\n") | |
9899 | ||
8386ac43 | 9900 | DEFUN (show_bgp_instance_afi_safi_community_all, |
9901 | show_bgp_instance_afi_safi_community_all_cmd, | |
8386ac43 | 9902 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community", |
95cbbd2a ML |
9903 | SHOW_STR |
9904 | BGP_STR | |
8386ac43 | 9905 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 9906 | "Address family\n" |
95cbbd2a | 9907 | "Address family\n" |
95cbbd2a ML |
9908 | "Address Family modifier\n" |
9909 | "Address Family modifier\n" | |
2b00515a | 9910 | "Display routes matching the communities\n") |
95cbbd2a ML |
9911 | { |
9912 | int afi; | |
9913 | int safi; | |
9914 | struct bgp *bgp; | |
9915 | ||
9916 | /* BGP structure lookup. */ | |
6aeb9e78 | 9917 | bgp = bgp_lookup_by_name (argv[1]); |
95cbbd2a ML |
9918 | if (bgp == NULL) |
9919 | { | |
6aeb9e78 | 9920 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
95cbbd2a ML |
9921 | return CMD_WARNING; |
9922 | } | |
9923 | ||
6aeb9e78 DS |
9924 | afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
9925 | safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
b05a1c8b | 9926 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, 0); |
95cbbd2a ML |
9927 | } |
9928 | ||
8386ac43 | 9929 | DEFUN (show_bgp_instance_afi_safi_community, |
9930 | show_bgp_instance_afi_safi_community_cmd, | |
8386ac43 | 9931 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
9932 | SHOW_STR |
9933 | BGP_STR | |
8386ac43 | 9934 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 9935 | "Address family\n" |
95cbbd2a | 9936 | "Address family\n" |
95cbbd2a ML |
9937 | "Address family modifier\n" |
9938 | "Address family modifier\n" | |
9939 | "Display routes matching the communities\n" | |
859d388e | 9940 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9941 | "Do not send outside local AS (well-known community)\n" |
9942 | "Do not advertise to any peer (well-known community)\n" | |
9943 | "Do not export to next AS (well-known community)\n") | |
9944 | { | |
9945 | int afi; | |
9946 | int safi; | |
9947 | ||
6aeb9e78 DS |
9948 | afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
9949 | safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
9950 | return bgp_show_community (vty, argv[1], argc-4, &argv[4], 0, afi, safi); | |
95cbbd2a ML |
9951 | } |
9952 | ||
8386ac43 | 9953 | ALIAS (show_bgp_instance_afi_safi_community, |
9954 | show_bgp_instance_afi_safi_community2_cmd, | |
8386ac43 | 9955 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
9956 | SHOW_STR |
9957 | BGP_STR | |
8386ac43 | 9958 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 9959 | "Address family\n" |
95cbbd2a | 9960 | "Address family\n" |
95cbbd2a ML |
9961 | "Address family modifier\n" |
9962 | "Address family modifier\n" | |
9963 | "Display routes matching the communities\n" | |
859d388e | 9964 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9965 | "Do not send outside local AS (well-known community)\n" |
9966 | "Do not advertise to any peer (well-known community)\n" | |
9967 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9968 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9969 | "Do not send outside local AS (well-known community)\n" |
9970 | "Do not advertise to any peer (well-known community)\n" | |
9971 | "Do not export to next AS (well-known community)\n") | |
9972 | ||
8386ac43 | 9973 | ALIAS (show_bgp_instance_afi_safi_community, |
9974 | show_bgp_instance_afi_safi_community3_cmd, | |
8386ac43 | 9975 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
9976 | SHOW_STR |
9977 | BGP_STR | |
8386ac43 | 9978 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 9979 | "Address family\n" |
95cbbd2a | 9980 | "Address family\n" |
95cbbd2a ML |
9981 | "Address family modifier\n" |
9982 | "Address family modifier\n" | |
9983 | "Display routes matching the communities\n" | |
859d388e | 9984 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9985 | "Do not send outside local AS (well-known community)\n" |
9986 | "Do not advertise to any peer (well-known community)\n" | |
9987 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9988 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9989 | "Do not send outside local AS (well-known community)\n" |
9990 | "Do not advertise to any peer (well-known community)\n" | |
9991 | "Do not export to next AS (well-known community)\n" | |
859d388e | 9992 | COMMUNITY_AANN_STR |
95cbbd2a ML |
9993 | "Do not send outside local AS (well-known community)\n" |
9994 | "Do not advertise to any peer (well-known community)\n" | |
9995 | "Do not export to next AS (well-known community)\n") | |
9996 | ||
8386ac43 | 9997 | ALIAS (show_bgp_instance_afi_safi_community, |
9998 | show_bgp_instance_afi_safi_community4_cmd, | |
8386ac43 | 9999 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
95cbbd2a ML |
10000 | SHOW_STR |
10001 | BGP_STR | |
8386ac43 | 10002 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 10003 | "Address family\n" |
95cbbd2a | 10004 | "Address family\n" |
95cbbd2a ML |
10005 | "Address family modifier\n" |
10006 | "Address family modifier\n" | |
10007 | "Display routes matching the communities\n" | |
859d388e | 10008 | COMMUNITY_AANN_STR |
95cbbd2a ML |
10009 | "Do not send outside local AS (well-known community)\n" |
10010 | "Do not advertise to any peer (well-known community)\n" | |
10011 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10012 | COMMUNITY_AANN_STR |
95cbbd2a ML |
10013 | "Do not send outside local AS (well-known community)\n" |
10014 | "Do not advertise to any peer (well-known community)\n" | |
10015 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10016 | COMMUNITY_AANN_STR |
95cbbd2a ML |
10017 | "Do not send outside local AS (well-known community)\n" |
10018 | "Do not advertise to any peer (well-known community)\n" | |
10019 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10020 | COMMUNITY_AANN_STR |
95cbbd2a ML |
10021 | "Do not send outside local AS (well-known community)\n" |
10022 | "Do not advertise to any peer (well-known community)\n" | |
10023 | "Do not export to next AS (well-known community)\n") | |
10024 | ||
718e3744 | 10025 | DEFUN (show_ip_bgp_community_exact, |
10026 | show_ip_bgp_community_exact_cmd, | |
10027 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10028 | SHOW_STR | |
10029 | IP_STR | |
10030 | BGP_STR | |
10031 | "Display routes matching the communities\n" | |
859d388e | 10032 | COMMUNITY_AANN_STR |
718e3744 | 10033 | "Do not send outside local AS (well-known community)\n" |
10034 | "Do not advertise to any peer (well-known community)\n" | |
10035 | "Do not export to next AS (well-known community)\n" | |
10036 | "Exact match of the communities") | |
10037 | { | |
95cbbd2a | 10038 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10039 | } |
10040 | ||
10041 | ALIAS (show_ip_bgp_community_exact, | |
10042 | show_ip_bgp_community2_exact_cmd, | |
10043 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10044 | SHOW_STR | |
10045 | IP_STR | |
10046 | BGP_STR | |
10047 | "Display routes matching the communities\n" | |
859d388e | 10048 | COMMUNITY_AANN_STR |
718e3744 | 10049 | "Do not send outside local AS (well-known community)\n" |
10050 | "Do not advertise to any peer (well-known community)\n" | |
10051 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10052 | COMMUNITY_AANN_STR |
718e3744 | 10053 | "Do not send outside local AS (well-known community)\n" |
10054 | "Do not advertise to any peer (well-known community)\n" | |
10055 | "Do not export to next AS (well-known community)\n" | |
10056 | "Exact match of the communities") | |
10057 | ||
10058 | ALIAS (show_ip_bgp_community_exact, | |
10059 | show_ip_bgp_community3_exact_cmd, | |
10060 | "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", | |
10061 | SHOW_STR | |
10062 | IP_STR | |
10063 | BGP_STR | |
10064 | "Display routes matching the communities\n" | |
859d388e | 10065 | COMMUNITY_AANN_STR |
718e3744 | 10066 | "Do not send outside local AS (well-known community)\n" |
10067 | "Do not advertise to any peer (well-known community)\n" | |
10068 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10069 | COMMUNITY_AANN_STR |
718e3744 | 10070 | "Do not send outside local AS (well-known community)\n" |
10071 | "Do not advertise to any peer (well-known community)\n" | |
10072 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10073 | COMMUNITY_AANN_STR |
718e3744 | 10074 | "Do not send outside local AS (well-known community)\n" |
10075 | "Do not advertise to any peer (well-known community)\n" | |
10076 | "Do not export to next AS (well-known community)\n" | |
10077 | "Exact match of the communities") | |
10078 | ||
10079 | ALIAS (show_ip_bgp_community_exact, | |
10080 | show_ip_bgp_community4_exact_cmd, | |
10081 | "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", | |
10082 | SHOW_STR | |
10083 | IP_STR | |
10084 | BGP_STR | |
10085 | "Display routes matching the communities\n" | |
859d388e | 10086 | COMMUNITY_AANN_STR |
718e3744 | 10087 | "Do not send outside local AS (well-known community)\n" |
10088 | "Do not advertise to any peer (well-known community)\n" | |
10089 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10090 | COMMUNITY_AANN_STR |
718e3744 | 10091 | "Do not send outside local AS (well-known community)\n" |
10092 | "Do not advertise to any peer (well-known community)\n" | |
10093 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10094 | COMMUNITY_AANN_STR |
718e3744 | 10095 | "Do not send outside local AS (well-known community)\n" |
10096 | "Do not advertise to any peer (well-known community)\n" | |
10097 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10098 | COMMUNITY_AANN_STR |
718e3744 | 10099 | "Do not send outside local AS (well-known community)\n" |
10100 | "Do not advertise to any peer (well-known community)\n" | |
10101 | "Do not export to next AS (well-known community)\n" | |
10102 | "Exact match of the communities") | |
10103 | ||
10104 | DEFUN (show_ip_bgp_ipv4_community_exact, | |
10105 | show_ip_bgp_ipv4_community_exact_cmd, | |
10106 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10107 | SHOW_STR | |
10108 | IP_STR | |
10109 | BGP_STR | |
10110 | "Address family\n" | |
10111 | "Address Family modifier\n" | |
10112 | "Address Family modifier\n" | |
10113 | "Display routes matching the communities\n" | |
859d388e | 10114 | COMMUNITY_AANN_STR |
718e3744 | 10115 | "Do not send outside local AS (well-known community)\n" |
10116 | "Do not advertise to any peer (well-known community)\n" | |
10117 | "Do not export to next AS (well-known community)\n" | |
10118 | "Exact match of the communities") | |
10119 | { | |
10120 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 10121 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
718e3744 | 10122 | |
95cbbd2a | 10123 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10124 | } |
10125 | ||
10126 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
10127 | show_ip_bgp_ipv4_community2_exact_cmd, | |
10128 | "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", | |
10129 | SHOW_STR | |
10130 | IP_STR | |
10131 | BGP_STR | |
10132 | "Address family\n" | |
10133 | "Address Family modifier\n" | |
10134 | "Address Family modifier\n" | |
10135 | "Display routes matching the communities\n" | |
859d388e | 10136 | COMMUNITY_AANN_STR |
718e3744 | 10137 | "Do not send outside local AS (well-known community)\n" |
10138 | "Do not advertise to any peer (well-known community)\n" | |
10139 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10140 | COMMUNITY_AANN_STR |
718e3744 | 10141 | "Do not send outside local AS (well-known community)\n" |
10142 | "Do not advertise to any peer (well-known community)\n" | |
10143 | "Do not export to next AS (well-known community)\n" | |
10144 | "Exact match of the communities") | |
10145 | ||
10146 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
10147 | show_ip_bgp_ipv4_community3_exact_cmd, | |
10148 | "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", | |
10149 | SHOW_STR | |
10150 | IP_STR | |
10151 | BGP_STR | |
10152 | "Address family\n" | |
10153 | "Address Family modifier\n" | |
10154 | "Address Family modifier\n" | |
10155 | "Display routes matching the communities\n" | |
859d388e | 10156 | COMMUNITY_AANN_STR |
718e3744 | 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" | |
859d388e | 10160 | COMMUNITY_AANN_STR |
718e3744 | 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" | |
859d388e | 10164 | COMMUNITY_AANN_STR |
718e3744 | 10165 | "Do not send outside local AS (well-known community)\n" |
10166 | "Do not advertise to any peer (well-known community)\n" | |
10167 | "Do not export to next AS (well-known community)\n" | |
10168 | "Exact match of the communities") | |
10169 | ||
10170 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
10171 | show_ip_bgp_ipv4_community4_exact_cmd, | |
10172 | "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", | |
10173 | SHOW_STR | |
10174 | IP_STR | |
10175 | BGP_STR | |
10176 | "Address family\n" | |
10177 | "Address Family modifier\n" | |
10178 | "Address Family modifier\n" | |
10179 | "Display routes matching the communities\n" | |
859d388e | 10180 | COMMUNITY_AANN_STR |
718e3744 | 10181 | "Do not send outside local AS (well-known community)\n" |
10182 | "Do not advertise to any peer (well-known community)\n" | |
10183 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10184 | COMMUNITY_AANN_STR |
718e3744 | 10185 | "Do not send outside local AS (well-known community)\n" |
10186 | "Do not advertise to any peer (well-known community)\n" | |
10187 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10188 | COMMUNITY_AANN_STR |
718e3744 | 10189 | "Do not send outside local AS (well-known community)\n" |
10190 | "Do not advertise to any peer (well-known community)\n" | |
10191 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10192 | COMMUNITY_AANN_STR |
718e3744 | 10193 | "Do not send outside local AS (well-known community)\n" |
10194 | "Do not advertise to any peer (well-known community)\n" | |
10195 | "Do not export to next AS (well-known community)\n" | |
10196 | "Exact match of the communities") | |
10197 | ||
10198 | #ifdef HAVE_IPV6 | |
10199 | DEFUN (show_bgp_community, | |
10200 | show_bgp_community_cmd, | |
10201 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
10202 | SHOW_STR | |
10203 | BGP_STR | |
10204 | "Display routes matching the communities\n" | |
859d388e | 10205 | COMMUNITY_AANN_STR |
718e3744 | 10206 | "Do not send outside local AS (well-known community)\n" |
10207 | "Do not advertise to any peer (well-known community)\n" | |
10208 | "Do not export to next AS (well-known community)\n") | |
10209 | { | |
95cbbd2a | 10210 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10211 | } |
10212 | ||
10213 | ALIAS (show_bgp_community, | |
10214 | show_bgp_ipv6_community_cmd, | |
10215 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", | |
10216 | SHOW_STR | |
10217 | BGP_STR | |
10218 | "Address family\n" | |
10219 | "Display routes matching the communities\n" | |
859d388e | 10220 | COMMUNITY_AANN_STR |
718e3744 | 10221 | "Do not send outside local AS (well-known community)\n" |
10222 | "Do not advertise to any peer (well-known community)\n" | |
10223 | "Do not export to next AS (well-known community)\n") | |
10224 | ||
10225 | ALIAS (show_bgp_community, | |
10226 | show_bgp_community2_cmd, | |
10227 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10228 | SHOW_STR | |
10229 | BGP_STR | |
10230 | "Display routes matching the communities\n" | |
859d388e | 10231 | COMMUNITY_AANN_STR |
718e3744 | 10232 | "Do not send outside local AS (well-known community)\n" |
10233 | "Do not advertise to any peer (well-known community)\n" | |
10234 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10235 | COMMUNITY_AANN_STR |
718e3744 | 10236 | "Do not send outside local AS (well-known community)\n" |
10237 | "Do not advertise to any peer (well-known community)\n" | |
10238 | "Do not export to next AS (well-known community)\n") | |
10239 | ||
10240 | ALIAS (show_bgp_community, | |
10241 | show_bgp_ipv6_community2_cmd, | |
10242 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10243 | SHOW_STR | |
10244 | BGP_STR | |
10245 | "Address family\n" | |
10246 | "Display routes matching the communities\n" | |
859d388e | 10247 | COMMUNITY_AANN_STR |
718e3744 | 10248 | "Do not send outside local AS (well-known community)\n" |
10249 | "Do not advertise to any peer (well-known community)\n" | |
10250 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10251 | COMMUNITY_AANN_STR |
718e3744 | 10252 | "Do not send outside local AS (well-known community)\n" |
10253 | "Do not advertise to any peer (well-known community)\n" | |
10254 | "Do not export to next AS (well-known community)\n") | |
10255 | ||
10256 | ALIAS (show_bgp_community, | |
10257 | show_bgp_community3_cmd, | |
10258 | "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)", | |
10259 | SHOW_STR | |
10260 | BGP_STR | |
10261 | "Display routes matching the communities\n" | |
859d388e | 10262 | COMMUNITY_AANN_STR |
718e3744 | 10263 | "Do not send outside local AS (well-known community)\n" |
10264 | "Do not advertise to any peer (well-known community)\n" | |
10265 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10266 | COMMUNITY_AANN_STR |
718e3744 | 10267 | "Do not send outside local AS (well-known community)\n" |
10268 | "Do not advertise to any peer (well-known community)\n" | |
10269 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10270 | COMMUNITY_AANN_STR |
718e3744 | 10271 | "Do not send outside local AS (well-known community)\n" |
10272 | "Do not advertise to any peer (well-known community)\n" | |
10273 | "Do not export to next AS (well-known community)\n") | |
10274 | ||
10275 | ALIAS (show_bgp_community, | |
10276 | show_bgp_ipv6_community3_cmd, | |
10277 | "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)", | |
10278 | SHOW_STR | |
10279 | BGP_STR | |
10280 | "Address family\n" | |
10281 | "Display routes matching the communities\n" | |
859d388e | 10282 | COMMUNITY_AANN_STR |
718e3744 | 10283 | "Do not send outside local AS (well-known community)\n" |
10284 | "Do not advertise to any peer (well-known community)\n" | |
10285 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10286 | COMMUNITY_AANN_STR |
718e3744 | 10287 | "Do not send outside local AS (well-known community)\n" |
10288 | "Do not advertise to any peer (well-known community)\n" | |
10289 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10290 | COMMUNITY_AANN_STR |
718e3744 | 10291 | "Do not send outside local AS (well-known community)\n" |
10292 | "Do not advertise to any peer (well-known community)\n" | |
10293 | "Do not export to next AS (well-known community)\n") | |
10294 | ||
10295 | ALIAS (show_bgp_community, | |
10296 | show_bgp_community4_cmd, | |
10297 | "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)", | |
10298 | SHOW_STR | |
10299 | BGP_STR | |
10300 | "Display routes matching the communities\n" | |
859d388e | 10301 | COMMUNITY_AANN_STR |
718e3744 | 10302 | "Do not send outside local AS (well-known community)\n" |
10303 | "Do not advertise to any peer (well-known community)\n" | |
10304 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10305 | COMMUNITY_AANN_STR |
718e3744 | 10306 | "Do not send outside local AS (well-known community)\n" |
10307 | "Do not advertise to any peer (well-known community)\n" | |
10308 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10309 | COMMUNITY_AANN_STR |
718e3744 | 10310 | "Do not send outside local AS (well-known community)\n" |
10311 | "Do not advertise to any peer (well-known community)\n" | |
10312 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10313 | COMMUNITY_AANN_STR |
718e3744 | 10314 | "Do not send outside local AS (well-known community)\n" |
10315 | "Do not advertise to any peer (well-known community)\n" | |
10316 | "Do not export to next AS (well-known community)\n") | |
10317 | ||
10318 | ALIAS (show_bgp_community, | |
10319 | show_bgp_ipv6_community4_cmd, | |
10320 | "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)", | |
10321 | SHOW_STR | |
10322 | BGP_STR | |
10323 | "Address family\n" | |
10324 | "Display routes matching the communities\n" | |
859d388e | 10325 | COMMUNITY_AANN_STR |
718e3744 | 10326 | "Do not send outside local AS (well-known community)\n" |
10327 | "Do not advertise to any peer (well-known community)\n" | |
10328 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10329 | COMMUNITY_AANN_STR |
718e3744 | 10330 | "Do not send outside local AS (well-known community)\n" |
10331 | "Do not advertise to any peer (well-known community)\n" | |
10332 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10333 | COMMUNITY_AANN_STR |
718e3744 | 10334 | "Do not send outside local AS (well-known community)\n" |
10335 | "Do not advertise to any peer (well-known community)\n" | |
10336 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10337 | COMMUNITY_AANN_STR |
718e3744 | 10338 | "Do not send outside local AS (well-known community)\n" |
10339 | "Do not advertise to any peer (well-known community)\n" | |
10340 | "Do not export to next AS (well-known community)\n") | |
10341 | ||
10342 | /* old command */ | |
10343 | DEFUN (show_ipv6_bgp_community, | |
10344 | show_ipv6_bgp_community_cmd, | |
10345 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
10346 | SHOW_STR | |
10347 | IPV6_STR | |
10348 | BGP_STR | |
10349 | "Display routes matching the communities\n" | |
859d388e | 10350 | COMMUNITY_AANN_STR |
718e3744 | 10351 | "Do not send outside local AS (well-known community)\n" |
10352 | "Do not advertise to any peer (well-known community)\n" | |
10353 | "Do not export to next AS (well-known community)\n") | |
10354 | { | |
47e9b292 | 10355 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10356 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10357 | } |
10358 | ||
10359 | /* old command */ | |
10360 | ALIAS (show_ipv6_bgp_community, | |
10361 | show_ipv6_bgp_community2_cmd, | |
10362 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10363 | SHOW_STR | |
10364 | IPV6_STR | |
10365 | BGP_STR | |
10366 | "Display routes matching the communities\n" | |
859d388e | 10367 | COMMUNITY_AANN_STR |
718e3744 | 10368 | "Do not send outside local AS (well-known community)\n" |
10369 | "Do not advertise to any peer (well-known community)\n" | |
10370 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10371 | COMMUNITY_AANN_STR |
718e3744 | 10372 | "Do not send outside local AS (well-known community)\n" |
10373 | "Do not advertise to any peer (well-known community)\n" | |
10374 | "Do not export to next AS (well-known community)\n") | |
10375 | ||
10376 | /* old command */ | |
10377 | ALIAS (show_ipv6_bgp_community, | |
10378 | show_ipv6_bgp_community3_cmd, | |
10379 | "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)", | |
10380 | SHOW_STR | |
10381 | IPV6_STR | |
10382 | BGP_STR | |
10383 | "Display routes matching the communities\n" | |
859d388e | 10384 | COMMUNITY_AANN_STR |
718e3744 | 10385 | "Do not send outside local AS (well-known community)\n" |
10386 | "Do not advertise to any peer (well-known community)\n" | |
10387 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10388 | COMMUNITY_AANN_STR |
718e3744 | 10389 | "Do not send outside local AS (well-known community)\n" |
10390 | "Do not advertise to any peer (well-known community)\n" | |
10391 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10392 | COMMUNITY_AANN_STR |
718e3744 | 10393 | "Do not send outside local AS (well-known community)\n" |
10394 | "Do not advertise to any peer (well-known community)\n" | |
10395 | "Do not export to next AS (well-known community)\n") | |
10396 | ||
10397 | /* old command */ | |
10398 | ALIAS (show_ipv6_bgp_community, | |
10399 | show_ipv6_bgp_community4_cmd, | |
10400 | "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)", | |
10401 | SHOW_STR | |
10402 | IPV6_STR | |
10403 | BGP_STR | |
10404 | "Display routes matching the communities\n" | |
859d388e | 10405 | COMMUNITY_AANN_STR |
718e3744 | 10406 | "Do not send outside local AS (well-known community)\n" |
10407 | "Do not advertise to any peer (well-known community)\n" | |
10408 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10409 | COMMUNITY_AANN_STR |
718e3744 | 10410 | "Do not send outside local AS (well-known community)\n" |
10411 | "Do not advertise to any peer (well-known community)\n" | |
10412 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10413 | COMMUNITY_AANN_STR |
718e3744 | 10414 | "Do not send outside local AS (well-known community)\n" |
10415 | "Do not advertise to any peer (well-known community)\n" | |
10416 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10417 | COMMUNITY_AANN_STR |
718e3744 | 10418 | "Do not send outside local AS (well-known community)\n" |
10419 | "Do not advertise to any peer (well-known community)\n" | |
10420 | "Do not export to next AS (well-known community)\n") | |
10421 | ||
10422 | DEFUN (show_bgp_community_exact, | |
10423 | show_bgp_community_exact_cmd, | |
10424 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10425 | SHOW_STR | |
10426 | BGP_STR | |
10427 | "Display routes matching the communities\n" | |
859d388e | 10428 | COMMUNITY_AANN_STR |
718e3744 | 10429 | "Do not send outside local AS (well-known community)\n" |
10430 | "Do not advertise to any peer (well-known community)\n" | |
10431 | "Do not export to next AS (well-known community)\n" | |
10432 | "Exact match of the communities") | |
10433 | { | |
95cbbd2a | 10434 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10435 | } |
10436 | ||
10437 | ALIAS (show_bgp_community_exact, | |
10438 | show_bgp_ipv6_community_exact_cmd, | |
10439 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10440 | SHOW_STR | |
10441 | BGP_STR | |
10442 | "Address family\n" | |
10443 | "Display routes matching the communities\n" | |
859d388e | 10444 | COMMUNITY_AANN_STR |
718e3744 | 10445 | "Do not send outside local AS (well-known community)\n" |
10446 | "Do not advertise to any peer (well-known community)\n" | |
10447 | "Do not export to next AS (well-known community)\n" | |
10448 | "Exact match of the communities") | |
10449 | ||
10450 | ALIAS (show_bgp_community_exact, | |
10451 | show_bgp_community2_exact_cmd, | |
10452 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10453 | SHOW_STR | |
10454 | BGP_STR | |
10455 | "Display routes matching the communities\n" | |
859d388e | 10456 | COMMUNITY_AANN_STR |
718e3744 | 10457 | "Do not send outside local AS (well-known community)\n" |
10458 | "Do not advertise to any peer (well-known community)\n" | |
10459 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10460 | COMMUNITY_AANN_STR |
718e3744 | 10461 | "Do not send outside local AS (well-known community)\n" |
10462 | "Do not advertise to any peer (well-known community)\n" | |
10463 | "Do not export to next AS (well-known community)\n" | |
10464 | "Exact match of the communities") | |
10465 | ||
10466 | ALIAS (show_bgp_community_exact, | |
10467 | show_bgp_ipv6_community2_exact_cmd, | |
10468 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10469 | SHOW_STR | |
10470 | BGP_STR | |
10471 | "Address family\n" | |
10472 | "Display routes matching the communities\n" | |
859d388e | 10473 | COMMUNITY_AANN_STR |
718e3744 | 10474 | "Do not send outside local AS (well-known community)\n" |
10475 | "Do not advertise to any peer (well-known community)\n" | |
10476 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10477 | COMMUNITY_AANN_STR |
718e3744 | 10478 | "Do not send outside local AS (well-known community)\n" |
10479 | "Do not advertise to any peer (well-known community)\n" | |
10480 | "Do not export to next AS (well-known community)\n" | |
10481 | "Exact match of the communities") | |
10482 | ||
10483 | ALIAS (show_bgp_community_exact, | |
10484 | show_bgp_community3_exact_cmd, | |
10485 | "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", | |
10486 | SHOW_STR | |
10487 | BGP_STR | |
10488 | "Display routes matching the communities\n" | |
859d388e | 10489 | COMMUNITY_AANN_STR |
718e3744 | 10490 | "Do not send outside local AS (well-known community)\n" |
10491 | "Do not advertise to any peer (well-known community)\n" | |
10492 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10493 | COMMUNITY_AANN_STR |
718e3744 | 10494 | "Do not send outside local AS (well-known community)\n" |
10495 | "Do not advertise to any peer (well-known community)\n" | |
10496 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10497 | COMMUNITY_AANN_STR |
718e3744 | 10498 | "Do not send outside local AS (well-known community)\n" |
10499 | "Do not advertise to any peer (well-known community)\n" | |
10500 | "Do not export to next AS (well-known community)\n" | |
10501 | "Exact match of the communities") | |
10502 | ||
10503 | ALIAS (show_bgp_community_exact, | |
10504 | show_bgp_ipv6_community3_exact_cmd, | |
10505 | "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", | |
10506 | SHOW_STR | |
10507 | BGP_STR | |
10508 | "Address family\n" | |
10509 | "Display routes matching the communities\n" | |
859d388e | 10510 | COMMUNITY_AANN_STR |
718e3744 | 10511 | "Do not send outside local AS (well-known community)\n" |
10512 | "Do not advertise to any peer (well-known community)\n" | |
10513 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10514 | COMMUNITY_AANN_STR |
718e3744 | 10515 | "Do not send outside local AS (well-known community)\n" |
10516 | "Do not advertise to any peer (well-known community)\n" | |
10517 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10518 | COMMUNITY_AANN_STR |
718e3744 | 10519 | "Do not send outside local AS (well-known community)\n" |
10520 | "Do not advertise to any peer (well-known community)\n" | |
10521 | "Do not export to next AS (well-known community)\n" | |
10522 | "Exact match of the communities") | |
10523 | ||
10524 | ALIAS (show_bgp_community_exact, | |
10525 | show_bgp_community4_exact_cmd, | |
10526 | "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", | |
10527 | SHOW_STR | |
10528 | BGP_STR | |
10529 | "Display routes matching the communities\n" | |
859d388e | 10530 | COMMUNITY_AANN_STR |
718e3744 | 10531 | "Do not send outside local AS (well-known community)\n" |
10532 | "Do not advertise to any peer (well-known community)\n" | |
10533 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10534 | COMMUNITY_AANN_STR |
718e3744 | 10535 | "Do not send outside local AS (well-known community)\n" |
10536 | "Do not advertise to any peer (well-known community)\n" | |
10537 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10538 | COMMUNITY_AANN_STR |
718e3744 | 10539 | "Do not send outside local AS (well-known community)\n" |
10540 | "Do not advertise to any peer (well-known community)\n" | |
10541 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10542 | COMMUNITY_AANN_STR |
718e3744 | 10543 | "Do not send outside local AS (well-known community)\n" |
10544 | "Do not advertise to any peer (well-known community)\n" | |
10545 | "Do not export to next AS (well-known community)\n" | |
10546 | "Exact match of the communities") | |
10547 | ||
10548 | ALIAS (show_bgp_community_exact, | |
10549 | show_bgp_ipv6_community4_exact_cmd, | |
10550 | "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", | |
10551 | SHOW_STR | |
10552 | BGP_STR | |
10553 | "Address family\n" | |
10554 | "Display routes matching the communities\n" | |
859d388e | 10555 | COMMUNITY_AANN_STR |
718e3744 | 10556 | "Do not send outside local AS (well-known community)\n" |
10557 | "Do not advertise to any peer (well-known community)\n" | |
10558 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10559 | COMMUNITY_AANN_STR |
718e3744 | 10560 | "Do not send outside local AS (well-known community)\n" |
10561 | "Do not advertise to any peer (well-known community)\n" | |
10562 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10563 | COMMUNITY_AANN_STR |
718e3744 | 10564 | "Do not send outside local AS (well-known community)\n" |
10565 | "Do not advertise to any peer (well-known community)\n" | |
10566 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10567 | COMMUNITY_AANN_STR |
718e3744 | 10568 | "Do not send outside local AS (well-known community)\n" |
10569 | "Do not advertise to any peer (well-known community)\n" | |
10570 | "Do not export to next AS (well-known community)\n" | |
10571 | "Exact match of the communities") | |
10572 | ||
10573 | /* old command */ | |
10574 | DEFUN (show_ipv6_bgp_community_exact, | |
10575 | show_ipv6_bgp_community_exact_cmd, | |
10576 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10577 | SHOW_STR | |
10578 | IPV6_STR | |
10579 | BGP_STR | |
10580 | "Display routes matching the communities\n" | |
859d388e | 10581 | COMMUNITY_AANN_STR |
718e3744 | 10582 | "Do not send outside local AS (well-known community)\n" |
10583 | "Do not advertise to any peer (well-known community)\n" | |
10584 | "Do not export to next AS (well-known community)\n" | |
10585 | "Exact match of the communities") | |
10586 | { | |
47e9b292 | 10587 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10588 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10589 | } |
10590 | ||
10591 | /* old command */ | |
10592 | ALIAS (show_ipv6_bgp_community_exact, | |
10593 | show_ipv6_bgp_community2_exact_cmd, | |
10594 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10595 | SHOW_STR | |
10596 | IPV6_STR | |
10597 | BGP_STR | |
10598 | "Display routes matching the communities\n" | |
859d388e | 10599 | COMMUNITY_AANN_STR |
718e3744 | 10600 | "Do not send outside local AS (well-known community)\n" |
10601 | "Do not advertise to any peer (well-known community)\n" | |
10602 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10603 | COMMUNITY_AANN_STR |
718e3744 | 10604 | "Do not send outside local AS (well-known community)\n" |
10605 | "Do not advertise to any peer (well-known community)\n" | |
10606 | "Do not export to next AS (well-known community)\n" | |
10607 | "Exact match of the communities") | |
10608 | ||
10609 | /* old command */ | |
10610 | ALIAS (show_ipv6_bgp_community_exact, | |
10611 | show_ipv6_bgp_community3_exact_cmd, | |
10612 | "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", | |
10613 | SHOW_STR | |
10614 | IPV6_STR | |
10615 | BGP_STR | |
10616 | "Display routes matching the communities\n" | |
859d388e | 10617 | COMMUNITY_AANN_STR |
718e3744 | 10618 | "Do not send outside local AS (well-known community)\n" |
10619 | "Do not advertise to any peer (well-known community)\n" | |
10620 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10621 | COMMUNITY_AANN_STR |
718e3744 | 10622 | "Do not send outside local AS (well-known community)\n" |
10623 | "Do not advertise to any peer (well-known community)\n" | |
10624 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10625 | COMMUNITY_AANN_STR |
718e3744 | 10626 | "Do not send outside local AS (well-known community)\n" |
10627 | "Do not advertise to any peer (well-known community)\n" | |
10628 | "Do not export to next AS (well-known community)\n" | |
10629 | "Exact match of the communities") | |
10630 | ||
10631 | /* old command */ | |
10632 | ALIAS (show_ipv6_bgp_community_exact, | |
10633 | show_ipv6_bgp_community4_exact_cmd, | |
10634 | "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", | |
10635 | SHOW_STR | |
10636 | IPV6_STR | |
10637 | BGP_STR | |
10638 | "Display routes matching the communities\n" | |
859d388e | 10639 | COMMUNITY_AANN_STR |
718e3744 | 10640 | "Do not send outside local AS (well-known community)\n" |
10641 | "Do not advertise to any peer (well-known community)\n" | |
10642 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10643 | COMMUNITY_AANN_STR |
718e3744 | 10644 | "Do not send outside local AS (well-known community)\n" |
10645 | "Do not advertise to any peer (well-known community)\n" | |
10646 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10647 | COMMUNITY_AANN_STR |
718e3744 | 10648 | "Do not send outside local AS (well-known community)\n" |
10649 | "Do not advertise to any peer (well-known community)\n" | |
10650 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10651 | COMMUNITY_AANN_STR |
718e3744 | 10652 | "Do not send outside local AS (well-known community)\n" |
10653 | "Do not advertise to any peer (well-known community)\n" | |
10654 | "Do not export to next AS (well-known community)\n" | |
10655 | "Exact match of the communities") | |
10656 | ||
10657 | /* old command */ | |
10658 | DEFUN (show_ipv6_mbgp_community, | |
10659 | show_ipv6_mbgp_community_cmd, | |
10660 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", | |
10661 | SHOW_STR | |
10662 | IPV6_STR | |
10663 | MBGP_STR | |
10664 | "Display routes matching the communities\n" | |
859d388e | 10665 | COMMUNITY_AANN_STR |
718e3744 | 10666 | "Do not send outside local AS (well-known community)\n" |
10667 | "Do not advertise to any peer (well-known community)\n" | |
10668 | "Do not export to next AS (well-known community)\n") | |
10669 | { | |
47e9b292 | 10670 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10671 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10672 | } |
10673 | ||
10674 | /* old command */ | |
10675 | ALIAS (show_ipv6_mbgp_community, | |
10676 | show_ipv6_mbgp_community2_cmd, | |
10677 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
10678 | SHOW_STR | |
10679 | IPV6_STR | |
10680 | MBGP_STR | |
10681 | "Display routes matching the communities\n" | |
859d388e | 10682 | COMMUNITY_AANN_STR |
718e3744 | 10683 | "Do not send outside local AS (well-known community)\n" |
10684 | "Do not advertise to any peer (well-known community)\n" | |
10685 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10686 | COMMUNITY_AANN_STR |
718e3744 | 10687 | "Do not send outside local AS (well-known community)\n" |
10688 | "Do not advertise to any peer (well-known community)\n" | |
10689 | "Do not export to next AS (well-known community)\n") | |
10690 | ||
10691 | /* old command */ | |
10692 | ALIAS (show_ipv6_mbgp_community, | |
10693 | show_ipv6_mbgp_community3_cmd, | |
10694 | "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)", | |
10695 | SHOW_STR | |
10696 | IPV6_STR | |
10697 | MBGP_STR | |
10698 | "Display routes matching the communities\n" | |
859d388e | 10699 | COMMUNITY_AANN_STR |
718e3744 | 10700 | "Do not send outside local AS (well-known community)\n" |
10701 | "Do not advertise to any peer (well-known community)\n" | |
10702 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10703 | COMMUNITY_AANN_STR |
718e3744 | 10704 | "Do not send outside local AS (well-known community)\n" |
10705 | "Do not advertise to any peer (well-known community)\n" | |
10706 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10707 | COMMUNITY_AANN_STR |
718e3744 | 10708 | "Do not send outside local AS (well-known community)\n" |
10709 | "Do not advertise to any peer (well-known community)\n" | |
10710 | "Do not export to next AS (well-known community)\n") | |
10711 | ||
10712 | /* old command */ | |
10713 | ALIAS (show_ipv6_mbgp_community, | |
10714 | show_ipv6_mbgp_community4_cmd, | |
10715 | "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)", | |
10716 | SHOW_STR | |
10717 | IPV6_STR | |
10718 | MBGP_STR | |
10719 | "Display routes matching the communities\n" | |
859d388e | 10720 | COMMUNITY_AANN_STR |
718e3744 | 10721 | "Do not send outside local AS (well-known community)\n" |
10722 | "Do not advertise to any peer (well-known community)\n" | |
10723 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10724 | COMMUNITY_AANN_STR |
718e3744 | 10725 | "Do not send outside local AS (well-known community)\n" |
10726 | "Do not advertise to any peer (well-known community)\n" | |
10727 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10728 | COMMUNITY_AANN_STR |
718e3744 | 10729 | "Do not send outside local AS (well-known community)\n" |
10730 | "Do not advertise to any peer (well-known community)\n" | |
10731 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10732 | COMMUNITY_AANN_STR |
718e3744 | 10733 | "Do not send outside local AS (well-known community)\n" |
10734 | "Do not advertise to any peer (well-known community)\n" | |
10735 | "Do not export to next AS (well-known community)\n") | |
10736 | ||
10737 | /* old command */ | |
10738 | DEFUN (show_ipv6_mbgp_community_exact, | |
10739 | show_ipv6_mbgp_community_exact_cmd, | |
10740 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10741 | SHOW_STR | |
10742 | IPV6_STR | |
10743 | MBGP_STR | |
10744 | "Display routes matching the communities\n" | |
859d388e | 10745 | COMMUNITY_AANN_STR |
718e3744 | 10746 | "Do not send outside local AS (well-known community)\n" |
10747 | "Do not advertise to any peer (well-known community)\n" | |
10748 | "Do not export to next AS (well-known community)\n" | |
10749 | "Exact match of the communities") | |
10750 | { | |
47e9b292 | 10751 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
95cbbd2a | 10752 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10753 | } |
10754 | ||
10755 | /* old command */ | |
10756 | ALIAS (show_ipv6_mbgp_community_exact, | |
10757 | show_ipv6_mbgp_community2_exact_cmd, | |
10758 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
10759 | SHOW_STR | |
10760 | IPV6_STR | |
10761 | MBGP_STR | |
10762 | "Display routes matching the communities\n" | |
859d388e | 10763 | COMMUNITY_AANN_STR |
718e3744 | 10764 | "Do not send outside local AS (well-known community)\n" |
10765 | "Do not advertise to any peer (well-known community)\n" | |
10766 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10767 | COMMUNITY_AANN_STR |
718e3744 | 10768 | "Do not send outside local AS (well-known community)\n" |
10769 | "Do not advertise to any peer (well-known community)\n" | |
10770 | "Do not export to next AS (well-known community)\n" | |
10771 | "Exact match of the communities") | |
10772 | ||
10773 | /* old command */ | |
10774 | ALIAS (show_ipv6_mbgp_community_exact, | |
10775 | show_ipv6_mbgp_community3_exact_cmd, | |
10776 | "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", | |
10777 | SHOW_STR | |
10778 | IPV6_STR | |
10779 | MBGP_STR | |
10780 | "Display routes matching the communities\n" | |
859d388e | 10781 | COMMUNITY_AANN_STR |
718e3744 | 10782 | "Do not send outside local AS (well-known community)\n" |
10783 | "Do not advertise to any peer (well-known community)\n" | |
10784 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10785 | COMMUNITY_AANN_STR |
718e3744 | 10786 | "Do not send outside local AS (well-known community)\n" |
10787 | "Do not advertise to any peer (well-known community)\n" | |
10788 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10789 | COMMUNITY_AANN_STR |
718e3744 | 10790 | "Do not send outside local AS (well-known community)\n" |
10791 | "Do not advertise to any peer (well-known community)\n" | |
10792 | "Do not export to next AS (well-known community)\n" | |
10793 | "Exact match of the communities") | |
10794 | ||
10795 | /* old command */ | |
10796 | ALIAS (show_ipv6_mbgp_community_exact, | |
10797 | show_ipv6_mbgp_community4_exact_cmd, | |
10798 | "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", | |
10799 | SHOW_STR | |
10800 | IPV6_STR | |
10801 | MBGP_STR | |
10802 | "Display routes matching the communities\n" | |
859d388e | 10803 | COMMUNITY_AANN_STR |
718e3744 | 10804 | "Do not send outside local AS (well-known community)\n" |
10805 | "Do not advertise to any peer (well-known community)\n" | |
10806 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10807 | COMMUNITY_AANN_STR |
718e3744 | 10808 | "Do not send outside local AS (well-known community)\n" |
10809 | "Do not advertise to any peer (well-known community)\n" | |
10810 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10811 | COMMUNITY_AANN_STR |
718e3744 | 10812 | "Do not send outside local AS (well-known community)\n" |
10813 | "Do not advertise to any peer (well-known community)\n" | |
10814 | "Do not export to next AS (well-known community)\n" | |
859d388e | 10815 | COMMUNITY_AANN_STR |
718e3744 | 10816 | "Do not send outside local AS (well-known community)\n" |
10817 | "Do not advertise to any peer (well-known community)\n" | |
10818 | "Do not export to next AS (well-known community)\n" | |
10819 | "Exact match of the communities") | |
10820 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 10821 | |
94f2b392 | 10822 | static int |
50ef26d4 | 10823 | bgp_show_community_list (struct vty *vty, const char *name, |
10824 | const char *com, int exact, | |
4c9641ba | 10825 | afi_t afi, safi_t safi) |
718e3744 | 10826 | { |
10827 | struct community_list *list; | |
50ef26d4 | 10828 | struct bgp *bgp = NULL; |
10829 | ||
10830 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
10831 | { | |
10832 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
10833 | return CMD_WARNING; | |
10834 | } | |
718e3744 | 10835 | |
fee6e4e4 | 10836 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
718e3744 | 10837 | if (list == NULL) |
10838 | { | |
10839 | vty_out (vty, "%% %s is not a valid community-list name%s", com, | |
10840 | VTY_NEWLINE); | |
10841 | return CMD_WARNING; | |
10842 | } | |
10843 | ||
50ef26d4 | 10844 | return bgp_show (vty, bgp, afi, safi, |
5a646650 | 10845 | (exact ? bgp_show_type_community_list_exact : |
b05a1c8b | 10846 | bgp_show_type_community_list), list, 0); |
718e3744 | 10847 | } |
10848 | ||
10849 | DEFUN (show_ip_bgp_community_list, | |
10850 | show_ip_bgp_community_list_cmd, | |
fee6e4e4 | 10851 | "show ip bgp community-list (<1-500>|WORD)", |
718e3744 | 10852 | SHOW_STR |
10853 | IP_STR | |
10854 | BGP_STR | |
10855 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10856 | "community-list number\n" |
718e3744 | 10857 | "community-list name\n") |
10858 | { | |
50ef26d4 | 10859 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP, SAFI_UNICAST); |
10860 | } | |
10861 | ||
8386ac43 | 10862 | DEFUN (show_ip_bgp_instance_community_list, |
10863 | show_ip_bgp_instance_community_list_cmd, | |
10864 | "show ip bgp " BGP_INSTANCE_CMD " community-list (<1-500>|WORD)", | |
50ef26d4 | 10865 | SHOW_STR |
10866 | IP_STR | |
10867 | BGP_STR | |
8386ac43 | 10868 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 10869 | "Display routes matching the community-list\n" |
10870 | "community-list number\n" | |
10871 | "community-list name\n") | |
10872 | { | |
10873 | return bgp_show_community_list (vty, argv[1], argv[2], 0, AFI_IP, SAFI_UNICAST); | |
718e3744 | 10874 | } |
10875 | ||
10876 | DEFUN (show_ip_bgp_ipv4_community_list, | |
10877 | show_ip_bgp_ipv4_community_list_cmd, | |
fee6e4e4 | 10878 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
718e3744 | 10879 | SHOW_STR |
10880 | IP_STR | |
10881 | BGP_STR | |
10882 | "Address family\n" | |
10883 | "Address Family modifier\n" | |
10884 | "Address Family modifier\n" | |
10885 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10886 | "community-list number\n" |
718e3744 | 10887 | "community-list name\n") |
10888 | { | |
10889 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 10890 | return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
718e3744 | 10891 | |
50ef26d4 | 10892 | return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 10893 | } |
10894 | ||
10895 | DEFUN (show_ip_bgp_community_list_exact, | |
10896 | show_ip_bgp_community_list_exact_cmd, | |
fee6e4e4 | 10897 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 10898 | SHOW_STR |
10899 | IP_STR | |
10900 | BGP_STR | |
10901 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10902 | "community-list number\n" |
718e3744 | 10903 | "community-list name\n" |
10904 | "Exact match of the communities\n") | |
10905 | { | |
50ef26d4 | 10906 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10907 | } |
10908 | ||
10909 | DEFUN (show_ip_bgp_ipv4_community_list_exact, | |
10910 | show_ip_bgp_ipv4_community_list_exact_cmd, | |
fee6e4e4 | 10911 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
718e3744 | 10912 | SHOW_STR |
10913 | IP_STR | |
10914 | BGP_STR | |
10915 | "Address family\n" | |
10916 | "Address Family modifier\n" | |
10917 | "Address Family modifier\n" | |
10918 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10919 | "community-list number\n" |
718e3744 | 10920 | "community-list name\n" |
10921 | "Exact match of the communities\n") | |
10922 | { | |
10923 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 10924 | return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
718e3744 | 10925 | |
50ef26d4 | 10926 | return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 10927 | } |
10928 | ||
10929 | #ifdef HAVE_IPV6 | |
10930 | DEFUN (show_bgp_community_list, | |
10931 | show_bgp_community_list_cmd, | |
fee6e4e4 | 10932 | "show bgp community-list (<1-500>|WORD)", |
718e3744 | 10933 | SHOW_STR |
10934 | BGP_STR | |
10935 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10936 | "community-list number\n" |
718e3744 | 10937 | "community-list name\n") |
10938 | { | |
50ef26d4 | 10939 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10940 | } |
10941 | ||
10942 | ALIAS (show_bgp_community_list, | |
10943 | show_bgp_ipv6_community_list_cmd, | |
fee6e4e4 | 10944 | "show bgp ipv6 community-list (<1-500>|WORD)", |
718e3744 | 10945 | SHOW_STR |
10946 | BGP_STR | |
10947 | "Address family\n" | |
10948 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10949 | "community-list number\n" |
e8e1946e | 10950 | "community-list name\n") |
718e3744 | 10951 | |
10952 | /* old command */ | |
10953 | DEFUN (show_ipv6_bgp_community_list, | |
10954 | show_ipv6_bgp_community_list_cmd, | |
10955 | "show ipv6 bgp community-list WORD", | |
10956 | SHOW_STR | |
10957 | IPV6_STR | |
10958 | BGP_STR | |
10959 | "Display routes matching the community-list\n" | |
10960 | "community-list name\n") | |
10961 | { | |
47e9b292 | 10962 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10963 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10964 | } |
10965 | ||
10966 | /* old command */ | |
10967 | DEFUN (show_ipv6_mbgp_community_list, | |
10968 | show_ipv6_mbgp_community_list_cmd, | |
10969 | "show ipv6 mbgp community-list WORD", | |
10970 | SHOW_STR | |
10971 | IPV6_STR | |
10972 | MBGP_STR | |
10973 | "Display routes matching the community-list\n" | |
10974 | "community-list name\n") | |
10975 | { | |
47e9b292 | 10976 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 10977 | return bgp_show_community_list (vty, NULL, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 10978 | } |
10979 | ||
10980 | DEFUN (show_bgp_community_list_exact, | |
10981 | show_bgp_community_list_exact_cmd, | |
fee6e4e4 | 10982 | "show bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 10983 | SHOW_STR |
10984 | BGP_STR | |
10985 | "Display routes matching the community-list\n" | |
fee6e4e4 | 10986 | "community-list number\n" |
718e3744 | 10987 | "community-list name\n" |
10988 | "Exact match of the communities\n") | |
10989 | { | |
50ef26d4 | 10990 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 10991 | } |
10992 | ||
10993 | ALIAS (show_bgp_community_list_exact, | |
10994 | show_bgp_ipv6_community_list_exact_cmd, | |
fee6e4e4 | 10995 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
718e3744 | 10996 | SHOW_STR |
10997 | BGP_STR | |
10998 | "Address family\n" | |
10999 | "Display routes matching the community-list\n" | |
fee6e4e4 | 11000 | "community-list number\n" |
718e3744 | 11001 | "community-list name\n" |
11002 | "Exact match of the communities\n") | |
11003 | ||
11004 | /* old command */ | |
11005 | DEFUN (show_ipv6_bgp_community_list_exact, | |
11006 | show_ipv6_bgp_community_list_exact_cmd, | |
11007 | "show ipv6 bgp community-list WORD exact-match", | |
11008 | SHOW_STR | |
11009 | IPV6_STR | |
11010 | BGP_STR | |
11011 | "Display routes matching the community-list\n" | |
11012 | "community-list name\n" | |
11013 | "Exact match of the communities\n") | |
11014 | { | |
47e9b292 | 11015 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 11016 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 11017 | } |
11018 | ||
11019 | /* old command */ | |
11020 | DEFUN (show_ipv6_mbgp_community_list_exact, | |
11021 | show_ipv6_mbgp_community_list_exact_cmd, | |
11022 | "show ipv6 mbgp community-list WORD exact-match", | |
11023 | SHOW_STR | |
11024 | IPV6_STR | |
11025 | MBGP_STR | |
11026 | "Display routes matching the community-list\n" | |
11027 | "community-list name\n" | |
11028 | "Exact match of the communities\n") | |
11029 | { | |
47e9b292 | 11030 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 11031 | return bgp_show_community_list (vty, NULL, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 11032 | } |
11033 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 11034 | |
94f2b392 | 11035 | static int |
50ef26d4 | 11036 | bgp_show_prefix_longer (struct vty *vty, const char *name, |
11037 | const char *prefix, afi_t afi, | |
718e3744 | 11038 | safi_t safi, enum bgp_show_type type) |
11039 | { | |
11040 | int ret; | |
11041 | struct prefix *p; | |
50ef26d4 | 11042 | struct bgp *bgp = NULL; |
11043 | ||
11044 | if (name && !(bgp = bgp_lookup_by_name(name))) | |
11045 | { | |
11046 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); | |
11047 | return CMD_WARNING; | |
11048 | } | |
718e3744 | 11049 | |
11050 | p = prefix_new(); | |
11051 | ||
11052 | ret = str2prefix (prefix, p); | |
11053 | if (! ret) | |
11054 | { | |
11055 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); | |
11056 | return CMD_WARNING; | |
11057 | } | |
11058 | ||
50ef26d4 | 11059 | ret = bgp_show (vty, bgp, afi, safi, type, p, 0); |
5a646650 | 11060 | prefix_free(p); |
11061 | return ret; | |
718e3744 | 11062 | } |
11063 | ||
11064 | DEFUN (show_ip_bgp_prefix_longer, | |
11065 | show_ip_bgp_prefix_longer_cmd, | |
11066 | "show ip bgp A.B.C.D/M longer-prefixes", | |
11067 | SHOW_STR | |
11068 | IP_STR | |
11069 | BGP_STR | |
11070 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
11071 | "Display route and more specific routes\n") | |
11072 | { | |
50ef26d4 | 11073 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
11074 | bgp_show_type_prefix_longer); | |
11075 | } | |
11076 | ||
8386ac43 | 11077 | DEFUN (show_ip_bgp_instance_prefix_longer, |
11078 | show_ip_bgp_instance_prefix_longer_cmd, | |
11079 | "show ip bgp " BGP_INSTANCE_CMD " A.B.C.D/M longer-prefixes", | |
50ef26d4 | 11080 | SHOW_STR |
11081 | IP_STR | |
11082 | BGP_STR | |
8386ac43 | 11083 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 11084 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
11085 | "Display route and more specific routes\n") | |
11086 | { | |
11087 | return bgp_show_prefix_longer (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, | |
718e3744 | 11088 | bgp_show_type_prefix_longer); |
11089 | } | |
11090 | ||
11091 | DEFUN (show_ip_bgp_flap_prefix_longer, | |
11092 | show_ip_bgp_flap_prefix_longer_cmd, | |
11093 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", | |
11094 | SHOW_STR | |
11095 | IP_STR | |
11096 | BGP_STR | |
11097 | "Display flap statistics of routes\n" | |
11098 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
11099 | "Display route and more specific routes\n") | |
11100 | { | |
50ef26d4 | 11101 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 11102 | bgp_show_type_flap_prefix_longer); |
11103 | } | |
11104 | ||
81304aaf B |
11105 | ALIAS (show_ip_bgp_flap_prefix_longer, |
11106 | show_ip_bgp_damp_flap_prefix_longer_cmd, | |
11107 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", | |
11108 | SHOW_STR | |
11109 | IP_STR | |
11110 | BGP_STR | |
11111 | "Display detailed information about dampening\n" | |
11112 | "Display flap statistics of routes\n" | |
11113 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
11114 | "Display route and more specific routes\n") | |
11115 | ||
718e3744 | 11116 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
11117 | show_ip_bgp_ipv4_prefix_longer_cmd, | |
11118 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", | |
11119 | SHOW_STR | |
11120 | IP_STR | |
11121 | BGP_STR | |
11122 | "Address family\n" | |
11123 | "Address Family modifier\n" | |
11124 | "Address Family modifier\n" | |
11125 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
11126 | "Display route and more specific routes\n") | |
11127 | { | |
11128 | if (strncmp (argv[0], "m", 1) == 0) | |
50ef26d4 | 11129 | return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, |
718e3744 | 11130 | bgp_show_type_prefix_longer); |
11131 | ||
50ef26d4 | 11132 | return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, |
718e3744 | 11133 | bgp_show_type_prefix_longer); |
11134 | } | |
11135 | ||
11136 | DEFUN (show_ip_bgp_flap_address, | |
11137 | show_ip_bgp_flap_address_cmd, | |
11138 | "show ip bgp flap-statistics A.B.C.D", | |
11139 | SHOW_STR | |
11140 | IP_STR | |
11141 | BGP_STR | |
11142 | "Display flap statistics of routes\n" | |
11143 | "Network in the BGP routing table to display\n") | |
11144 | { | |
50ef26d4 | 11145 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 11146 | bgp_show_type_flap_address); |
11147 | } | |
11148 | ||
81304aaf B |
11149 | ALIAS (show_ip_bgp_flap_address, |
11150 | show_ip_bgp_damp_flap_address_cmd, | |
11151 | "show ip bgp dampening flap-statistics A.B.C.D", | |
11152 | SHOW_STR | |
11153 | IP_STR | |
11154 | BGP_STR | |
11155 | "Display detailed information about dampening\n" | |
11156 | "Display flap statistics of routes\n" | |
11157 | "Network in the BGP routing table to display\n") | |
11158 | ||
718e3744 | 11159 | DEFUN (show_ip_bgp_flap_prefix, |
11160 | show_ip_bgp_flap_prefix_cmd, | |
11161 | "show ip bgp flap-statistics A.B.C.D/M", | |
11162 | SHOW_STR | |
11163 | IP_STR | |
11164 | BGP_STR | |
11165 | "Display flap statistics of routes\n" | |
11166 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
11167 | { | |
50ef26d4 | 11168 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, |
718e3744 | 11169 | bgp_show_type_flap_prefix); |
11170 | } | |
81304aaf B |
11171 | |
11172 | ALIAS (show_ip_bgp_flap_prefix, | |
11173 | show_ip_bgp_damp_flap_prefix_cmd, | |
11174 | "show ip bgp dampening flap-statistics A.B.C.D/M", | |
11175 | SHOW_STR | |
11176 | IP_STR | |
11177 | BGP_STR | |
11178 | "Display detailed information about dampening\n" | |
11179 | "Display flap statistics of routes\n" | |
11180 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
11181 | ||
718e3744 | 11182 | #ifdef HAVE_IPV6 |
11183 | DEFUN (show_bgp_prefix_longer, | |
11184 | show_bgp_prefix_longer_cmd, | |
11185 | "show bgp X:X::X:X/M longer-prefixes", | |
11186 | SHOW_STR | |
11187 | BGP_STR | |
11188 | "IPv6 prefix <network>/<length>\n" | |
11189 | "Display route and more specific routes\n") | |
11190 | { | |
50ef26d4 | 11191 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 11192 | bgp_show_type_prefix_longer); |
11193 | } | |
11194 | ||
11195 | ALIAS (show_bgp_prefix_longer, | |
11196 | show_bgp_ipv6_prefix_longer_cmd, | |
11197 | "show bgp ipv6 X:X::X:X/M longer-prefixes", | |
11198 | SHOW_STR | |
11199 | BGP_STR | |
11200 | "Address family\n" | |
11201 | "IPv6 prefix <network>/<length>\n" | |
11202 | "Display route and more specific routes\n") | |
11203 | ||
11204 | /* old command */ | |
11205 | DEFUN (show_ipv6_bgp_prefix_longer, | |
11206 | show_ipv6_bgp_prefix_longer_cmd, | |
11207 | "show ipv6 bgp X:X::X:X/M longer-prefixes", | |
11208 | SHOW_STR | |
11209 | IPV6_STR | |
11210 | BGP_STR | |
11211 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
11212 | "Display route and more specific routes\n") | |
11213 | { | |
47e9b292 | 11214 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 11215 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, |
718e3744 | 11216 | bgp_show_type_prefix_longer); |
11217 | } | |
11218 | ||
11219 | /* old command */ | |
11220 | DEFUN (show_ipv6_mbgp_prefix_longer, | |
11221 | show_ipv6_mbgp_prefix_longer_cmd, | |
11222 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", | |
11223 | SHOW_STR | |
11224 | IPV6_STR | |
11225 | MBGP_STR | |
11226 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
11227 | "Display route and more specific routes\n") | |
11228 | { | |
47e9b292 | 11229 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
50ef26d4 | 11230 | return bgp_show_prefix_longer (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, |
718e3744 | 11231 | bgp_show_type_prefix_longer); |
11232 | } | |
11233 | #endif /* HAVE_IPV6 */ | |
bb46e94f | 11234 | |
94f2b392 | 11235 | static struct peer * |
fd79ac91 | 11236 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
856ca177 | 11237 | const char *ip_str, u_char use_json) |
bb46e94f | 11238 | { |
11239 | int ret; | |
11240 | struct bgp *bgp; | |
11241 | struct peer *peer; | |
11242 | union sockunion su; | |
11243 | ||
11244 | /* BGP structure lookup. */ | |
11245 | if (view_name) | |
11246 | { | |
11247 | bgp = bgp_lookup_by_name (view_name); | |
11248 | if (! bgp) | |
11249 | { | |
856ca177 MS |
11250 | if (use_json) |
11251 | { | |
11252 | json_object *json_no = NULL; | |
11253 | json_no = json_object_new_object(); | |
11254 | json_object_string_add(json_no, "warning", "Can't find BGP view"); | |
11255 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
11256 | json_object_free(json_no); | |
11257 | } | |
11258 | else | |
6aeb9e78 | 11259 | vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
bb46e94f | 11260 | return NULL; |
11261 | } | |
11262 | } | |
5228ad27 | 11263 | else |
bb46e94f | 11264 | { |
11265 | bgp = bgp_get_default (); | |
11266 | if (! bgp) | |
11267 | { | |
856ca177 MS |
11268 | if (use_json) |
11269 | { | |
11270 | json_object *json_no = NULL; | |
11271 | json_no = json_object_new_object(); | |
11272 | json_object_string_add(json_no, "warning", "No BGP process configured"); | |
11273 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
11274 | json_object_free(json_no); | |
11275 | } | |
11276 | else | |
11277 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
bb46e94f | 11278 | return NULL; |
11279 | } | |
11280 | } | |
11281 | ||
11282 | /* Get peer sockunion. */ | |
11283 | ret = str2sockunion (ip_str, &su); | |
11284 | if (ret < 0) | |
11285 | { | |
a80beece DS |
11286 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
11287 | if (!peer) | |
11288 | { | |
04b6bdc0 DW |
11289 | peer = peer_lookup_by_hostname(bgp, ip_str); |
11290 | ||
11291 | if (!peer) | |
856ca177 | 11292 | { |
04b6bdc0 DW |
11293 | if (use_json) |
11294 | { | |
11295 | json_object *json_no = NULL; | |
11296 | json_no = json_object_new_object(); | |
11297 | json_object_string_add(json_no, "malformedAddressOrName", ip_str); | |
11298 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
11299 | json_object_free(json_no); | |
11300 | } | |
11301 | else | |
11302 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
11303 | return NULL; | |
856ca177 | 11304 | } |
a80beece DS |
11305 | } |
11306 | return peer; | |
bb46e94f | 11307 | } |
11308 | ||
11309 | /* Peer structure lookup. */ | |
11310 | peer = peer_lookup (bgp, &su); | |
11311 | if (! peer) | |
11312 | { | |
856ca177 MS |
11313 | if (use_json) |
11314 | { | |
11315 | json_object *json_no = NULL; | |
11316 | json_no = json_object_new_object(); | |
11317 | json_object_string_add(json_no, "warning","No such neighbor"); | |
11318 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
11319 | json_object_free(json_no); | |
11320 | } | |
11321 | else | |
11322 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); | |
bb46e94f | 11323 | return NULL; |
11324 | } | |
11325 | ||
11326 | return peer; | |
11327 | } | |
6b0655a2 | 11328 | |
2815e61f PJ |
11329 | enum bgp_stats |
11330 | { | |
11331 | BGP_STATS_MAXBITLEN = 0, | |
11332 | BGP_STATS_RIB, | |
11333 | BGP_STATS_PREFIXES, | |
11334 | BGP_STATS_TOTPLEN, | |
11335 | BGP_STATS_UNAGGREGATEABLE, | |
11336 | BGP_STATS_MAX_AGGREGATEABLE, | |
11337 | BGP_STATS_AGGREGATES, | |
11338 | BGP_STATS_SPACE, | |
11339 | BGP_STATS_ASPATH_COUNT, | |
11340 | BGP_STATS_ASPATH_MAXHOPS, | |
11341 | BGP_STATS_ASPATH_TOTHOPS, | |
11342 | BGP_STATS_ASPATH_MAXSIZE, | |
11343 | BGP_STATS_ASPATH_TOTSIZE, | |
11344 | BGP_STATS_ASN_HIGHEST, | |
11345 | BGP_STATS_MAX, | |
11346 | }; | |
11347 | ||
11348 | static const char *table_stats_strs[] = | |
11349 | { | |
11350 | [BGP_STATS_PREFIXES] = "Total Prefixes", | |
11351 | [BGP_STATS_TOTPLEN] = "Average prefix length", | |
11352 | [BGP_STATS_RIB] = "Total Advertisements", | |
11353 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", | |
11354 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", | |
11355 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", | |
11356 | [BGP_STATS_SPACE] = "Address space advertised", | |
11357 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", | |
11358 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", | |
11359 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", | |
11360 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", | |
11361 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", | |
11362 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", | |
11363 | [BGP_STATS_MAX] = NULL, | |
11364 | }; | |
11365 | ||
11366 | struct bgp_table_stats | |
11367 | { | |
11368 | struct bgp_table *table; | |
11369 | unsigned long long counts[BGP_STATS_MAX]; | |
11370 | }; | |
11371 | ||
11372 | #if 0 | |
11373 | #define TALLY_SIGFIG 100000 | |
11374 | static unsigned long | |
11375 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) | |
11376 | { | |
11377 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); | |
11378 | unsigned long res = (newtot * TALLY_SIGFIG) / count; | |
11379 | unsigned long ret = newtot / count; | |
11380 | ||
11381 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) | |
11382 | return ret + 1; | |
11383 | else | |
11384 | return ret; | |
11385 | } | |
11386 | #endif | |
11387 | ||
11388 | static int | |
11389 | bgp_table_stats_walker (struct thread *t) | |
11390 | { | |
11391 | struct bgp_node *rn; | |
11392 | struct bgp_node *top; | |
11393 | struct bgp_table_stats *ts = THREAD_ARG (t); | |
11394 | unsigned int space = 0; | |
11395 | ||
53d9f67a PJ |
11396 | if (!(top = bgp_table_top (ts->table))) |
11397 | return 0; | |
2815e61f PJ |
11398 | |
11399 | switch (top->p.family) | |
11400 | { | |
11401 | case AF_INET: | |
11402 | space = IPV4_MAX_BITLEN; | |
11403 | break; | |
11404 | case AF_INET6: | |
11405 | space = IPV6_MAX_BITLEN; | |
11406 | break; | |
11407 | } | |
11408 | ||
11409 | ts->counts[BGP_STATS_MAXBITLEN] = space; | |
11410 | ||
11411 | for (rn = top; rn; rn = bgp_route_next (rn)) | |
11412 | { | |
11413 | struct bgp_info *ri; | |
67174041 | 11414 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
2815e61f PJ |
11415 | unsigned int rinum = 0; |
11416 | ||
11417 | if (rn == top) | |
11418 | continue; | |
11419 | ||
11420 | if (!rn->info) | |
11421 | continue; | |
11422 | ||
11423 | ts->counts[BGP_STATS_PREFIXES]++; | |
11424 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; | |
11425 | ||
11426 | #if 0 | |
11427 | ts->counts[BGP_STATS_AVGPLEN] | |
11428 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], | |
11429 | ts->counts[BGP_STATS_AVGPLEN], | |
11430 | rn->p.prefixlen); | |
11431 | #endif | |
11432 | ||
11433 | /* check if the prefix is included by any other announcements */ | |
11434 | while (prn && !prn->info) | |
67174041 | 11435 | prn = bgp_node_parent_nolock (prn); |
2815e61f PJ |
11436 | |
11437 | if (prn == NULL || prn == top) | |
8383a9bd PJ |
11438 | { |
11439 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; | |
11440 | /* announced address space */ | |
11441 | if (space) | |
11442 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); | |
11443 | } | |
2815e61f PJ |
11444 | else if (prn->info) |
11445 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; | |
11446 | ||
2815e61f PJ |
11447 | for (ri = rn->info; ri; ri = ri->next) |
11448 | { | |
11449 | rinum++; | |
11450 | ts->counts[BGP_STATS_RIB]++; | |
11451 | ||
11452 | if (ri->attr && | |
11453 | (CHECK_FLAG (ri->attr->flag, | |
11454 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) | |
11455 | ts->counts[BGP_STATS_AGGREGATES]++; | |
11456 | ||
11457 | /* as-path stats */ | |
11458 | if (ri->attr && ri->attr->aspath) | |
11459 | { | |
11460 | unsigned int hops = aspath_count_hops (ri->attr->aspath); | |
11461 | unsigned int size = aspath_size (ri->attr->aspath); | |
11462 | as_t highest = aspath_highest (ri->attr->aspath); | |
11463 | ||
11464 | ts->counts[BGP_STATS_ASPATH_COUNT]++; | |
11465 | ||
11466 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) | |
11467 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; | |
11468 | ||
11469 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) | |
11470 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; | |
11471 | ||
11472 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; | |
11473 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; | |
11474 | #if 0 | |
11475 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] | |
11476 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
11477 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], | |
11478 | hops); | |
11479 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] | |
11480 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
11481 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], | |
11482 | size); | |
11483 | #endif | |
11484 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) | |
11485 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; | |
11486 | } | |
11487 | } | |
11488 | } | |
11489 | return 0; | |
11490 | } | |
11491 | ||
11492 | static int | |
11493 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) | |
11494 | { | |
11495 | struct bgp_table_stats ts; | |
11496 | unsigned int i; | |
11497 | ||
11498 | if (!bgp->rib[afi][safi]) | |
11499 | { | |
06da0daf DS |
11500 | vty_out (vty, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s", |
11501 | afi, safi, VTY_NEWLINE); | |
2815e61f PJ |
11502 | return CMD_WARNING; |
11503 | } | |
11504 | ||
11505 | memset (&ts, 0, sizeof (ts)); | |
11506 | ts.table = bgp->rib[afi][safi]; | |
87d4a781 | 11507 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
bb46e94f | 11508 | |
2815e61f PJ |
11509 | vty_out (vty, "BGP %s RIB statistics%s%s", |
11510 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); | |
11511 | ||
11512 | for (i = 0; i < BGP_STATS_MAX; i++) | |
11513 | { | |
11514 | if (!table_stats_strs[i]) | |
11515 | continue; | |
11516 | ||
11517 | switch (i) | |
11518 | { | |
11519 | #if 0 | |
11520 | case BGP_STATS_ASPATH_AVGHOPS: | |
11521 | case BGP_STATS_ASPATH_AVGSIZE: | |
11522 | case BGP_STATS_AVGPLEN: | |
11523 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11524 | vty_out (vty, "%12.2f", | |
11525 | (float)ts.counts[i] / (float)TALLY_SIGFIG); | |
11526 | break; | |
11527 | #endif | |
11528 | case BGP_STATS_ASPATH_TOTHOPS: | |
11529 | case BGP_STATS_ASPATH_TOTSIZE: | |
11530 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11531 | vty_out (vty, "%12.2f", | |
11532 | ts.counts[i] ? | |
11533 | (float)ts.counts[i] / | |
11534 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] | |
11535 | : 0); | |
11536 | break; | |
11537 | case BGP_STATS_TOTPLEN: | |
11538 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11539 | vty_out (vty, "%12.2f", | |
11540 | ts.counts[i] ? | |
11541 | (float)ts.counts[i] / | |
11542 | (float)ts.counts[BGP_STATS_PREFIXES] | |
11543 | : 0); | |
11544 | break; | |
11545 | case BGP_STATS_SPACE: | |
11546 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11547 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); | |
11548 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) | |
11549 | break; | |
30a2231a | 11550 | vty_out (vty, "%30s: ", "%% announced "); |
2815e61f PJ |
11551 | vty_out (vty, "%12.2f%s", |
11552 | 100 * (float)ts.counts[BGP_STATS_SPACE] / | |
56395af7 | 11553 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
2815e61f PJ |
11554 | VTY_NEWLINE); |
11555 | vty_out (vty, "%30s: ", "/8 equivalent "); | |
11556 | vty_out (vty, "%12.2f%s", | |
11557 | (float)ts.counts[BGP_STATS_SPACE] / | |
11558 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), | |
11559 | VTY_NEWLINE); | |
11560 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) | |
11561 | break; | |
11562 | vty_out (vty, "%30s: ", "/24 equivalent "); | |
11563 | vty_out (vty, "%12.2f", | |
11564 | (float)ts.counts[BGP_STATS_SPACE] / | |
11565 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); | |
11566 | break; | |
11567 | default: | |
11568 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
11569 | vty_out (vty, "%12llu", ts.counts[i]); | |
11570 | } | |
11571 | ||
11572 | vty_out (vty, "%s", VTY_NEWLINE); | |
11573 | } | |
11574 | return CMD_SUCCESS; | |
11575 | } | |
11576 | ||
11577 | static int | |
11578 | bgp_table_stats_vty (struct vty *vty, const char *name, | |
11579 | const char *afi_str, const char *safi_str) | |
11580 | { | |
11581 | struct bgp *bgp; | |
11582 | afi_t afi; | |
11583 | safi_t safi; | |
11584 | ||
11585 | if (name) | |
11586 | bgp = bgp_lookup_by_name (name); | |
11587 | else | |
11588 | bgp = bgp_get_default (); | |
11589 | ||
11590 | if (!bgp) | |
11591 | { | |
11592 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
11593 | return CMD_WARNING; | |
11594 | } | |
11595 | if (strncmp (afi_str, "ipv", 3) == 0) | |
11596 | { | |
11597 | if (strncmp (afi_str, "ipv4", 4) == 0) | |
11598 | afi = AFI_IP; | |
11599 | else if (strncmp (afi_str, "ipv6", 4) == 0) | |
11600 | afi = AFI_IP6; | |
11601 | else | |
11602 | { | |
11603 | vty_out (vty, "%% Invalid address family %s%s", | |
11604 | afi_str, VTY_NEWLINE); | |
11605 | return CMD_WARNING; | |
11606 | } | |
11607 | if (strncmp (safi_str, "m", 1) == 0) | |
11608 | safi = SAFI_MULTICAST; | |
11609 | else if (strncmp (safi_str, "u", 1) == 0) | |
11610 | safi = SAFI_UNICAST; | |
587ff0fd LB |
11611 | else if (strncmp (safi_str, "e", 1) == 0) |
11612 | safi = SAFI_ENCAP; | |
42e6d745 | 11613 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
06da0daf | 11614 | safi = SAFI_MPLS_VPN; |
2815e61f PJ |
11615 | else |
11616 | { | |
11617 | vty_out (vty, "%% Invalid subsequent address family %s%s", | |
11618 | safi_str, VTY_NEWLINE); | |
587ff0fd LB |
11619 | return CMD_WARNING; |
11620 | } | |
2815e61f PJ |
11621 | } |
11622 | else | |
11623 | { | |
587ff0fd | 11624 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
2815e61f PJ |
11625 | afi_str, VTY_NEWLINE); |
11626 | return CMD_WARNING; | |
11627 | } | |
11628 | ||
2815e61f PJ |
11629 | return bgp_table_stats (vty, bgp, afi, safi); |
11630 | } | |
11631 | ||
11632 | DEFUN (show_bgp_statistics, | |
11633 | show_bgp_statistics_cmd, | |
587ff0fd | 11634 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
2815e61f PJ |
11635 | SHOW_STR |
11636 | BGP_STR | |
11637 | "Address family\n" | |
11638 | "Address family\n" | |
11639 | "Address Family modifier\n" | |
11640 | "Address Family modifier\n" | |
587ff0fd LB |
11641 | "Address Family modifier\n" |
11642 | "Address Family modifier\n" | |
2815e61f PJ |
11643 | "BGP RIB advertisement statistics\n") |
11644 | { | |
11645 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
11646 | } | |
11647 | ||
2815e61f PJ |
11648 | DEFUN (show_bgp_statistics_view, |
11649 | show_bgp_statistics_view_cmd, | |
587ff0fd | 11650 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics", |
2815e61f PJ |
11651 | SHOW_STR |
11652 | BGP_STR | |
8386ac43 | 11653 | BGP_INSTANCE_HELP_STR |
2815e61f PJ |
11654 | "Address family\n" |
11655 | "Address family\n" | |
11656 | "Address Family modifier\n" | |
11657 | "Address Family modifier\n" | |
587ff0fd LB |
11658 | "Address Family modifier\n" |
11659 | "Address Family modifier\n" | |
2815e61f PJ |
11660 | "BGP RIB advertisement statistics\n") |
11661 | { | |
6aeb9e78 | 11662 | return bgp_table_stats_vty (vty, NULL, argv[1], argv[2]); |
2815e61f PJ |
11663 | } |
11664 | ||
ff7924f6 PJ |
11665 | enum bgp_pcounts |
11666 | { | |
11667 | PCOUNT_ADJ_IN = 0, | |
11668 | PCOUNT_DAMPED, | |
11669 | PCOUNT_REMOVED, | |
11670 | PCOUNT_HISTORY, | |
11671 | PCOUNT_STALE, | |
11672 | PCOUNT_VALID, | |
11673 | PCOUNT_ALL, | |
11674 | PCOUNT_COUNTED, | |
11675 | PCOUNT_PFCNT, /* the figure we display to users */ | |
11676 | PCOUNT_MAX, | |
11677 | }; | |
11678 | ||
11679 | static const char *pcount_strs[] = | |
11680 | { | |
11681 | [PCOUNT_ADJ_IN] = "Adj-in", | |
11682 | [PCOUNT_DAMPED] = "Damped", | |
11683 | [PCOUNT_REMOVED] = "Removed", | |
11684 | [PCOUNT_HISTORY] = "History", | |
11685 | [PCOUNT_STALE] = "Stale", | |
11686 | [PCOUNT_VALID] = "Valid", | |
11687 | [PCOUNT_ALL] = "All RIB", | |
11688 | [PCOUNT_COUNTED] = "PfxCt counted", | |
11689 | [PCOUNT_PFCNT] = "Useable", | |
11690 | [PCOUNT_MAX] = NULL, | |
11691 | }; | |
11692 | ||
2815e61f PJ |
11693 | struct peer_pcounts |
11694 | { | |
11695 | unsigned int count[PCOUNT_MAX]; | |
11696 | const struct peer *peer; | |
11697 | const struct bgp_table *table; | |
11698 | }; | |
11699 | ||
ff7924f6 | 11700 | static int |
2815e61f | 11701 | bgp_peer_count_walker (struct thread *t) |
ff7924f6 PJ |
11702 | { |
11703 | struct bgp_node *rn; | |
2815e61f PJ |
11704 | struct peer_pcounts *pc = THREAD_ARG (t); |
11705 | const struct peer *peer = pc->peer; | |
ff7924f6 | 11706 | |
2815e61f | 11707 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
ff7924f6 PJ |
11708 | { |
11709 | struct bgp_adj_in *ain; | |
2815e61f | 11710 | struct bgp_info *ri; |
ff7924f6 PJ |
11711 | |
11712 | for (ain = rn->adj_in; ain; ain = ain->next) | |
11713 | if (ain->peer == peer) | |
2815e61f | 11714 | pc->count[PCOUNT_ADJ_IN]++; |
ff7924f6 | 11715 | |
ff7924f6 PJ |
11716 | for (ri = rn->info; ri; ri = ri->next) |
11717 | { | |
11718 | char buf[SU_ADDRSTRLEN]; | |
11719 | ||
11720 | if (ri->peer != peer) | |
11721 | continue; | |
11722 | ||
2815e61f | 11723 | pc->count[PCOUNT_ALL]++; |
ff7924f6 PJ |
11724 | |
11725 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) | |
2815e61f | 11726 | pc->count[PCOUNT_DAMPED]++; |
ff7924f6 | 11727 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2815e61f | 11728 | pc->count[PCOUNT_HISTORY]++; |
ff7924f6 | 11729 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
2815e61f | 11730 | pc->count[PCOUNT_REMOVED]++; |
ff7924f6 | 11731 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
2815e61f | 11732 | pc->count[PCOUNT_STALE]++; |
ff7924f6 | 11733 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
2815e61f | 11734 | pc->count[PCOUNT_VALID]++; |
1a392d46 | 11735 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2815e61f | 11736 | pc->count[PCOUNT_PFCNT]++; |
ff7924f6 PJ |
11737 | |
11738 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
11739 | { | |
2815e61f | 11740 | pc->count[PCOUNT_COUNTED]++; |
1a392d46 | 11741 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
16286195 | 11742 | zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x", |
ff7924f6 PJ |
11743 | peer->host, |
11744 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
11745 | buf, SU_ADDRSTRLEN), | |
11746 | rn->p.prefixlen, | |
11747 | ri->flags); | |
11748 | } | |
11749 | else | |
11750 | { | |
1a392d46 | 11751 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
16286195 | 11752 | zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x", |
ff7924f6 PJ |
11753 | peer->host, |
11754 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
11755 | buf, SU_ADDRSTRLEN), | |
11756 | rn->p.prefixlen, | |
11757 | ri->flags); | |
11758 | } | |
11759 | } | |
11760 | } | |
2815e61f PJ |
11761 | return 0; |
11762 | } | |
ff7924f6 | 11763 | |
2815e61f | 11764 | static int |
856ca177 | 11765 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_char use_json) |
2815e61f PJ |
11766 | { |
11767 | struct peer_pcounts pcounts = { .peer = peer }; | |
11768 | unsigned int i; | |
856ca177 MS |
11769 | json_object *json = NULL; |
11770 | json_object *json_loop = NULL; | |
11771 | ||
11772 | if (use_json) | |
11773 | { | |
11774 | json = json_object_new_object(); | |
11775 | json_loop = json_object_new_object(); | |
11776 | } | |
2815e61f PJ |
11777 | |
11778 | if (!peer || !peer->bgp || !peer->afc[afi][safi] | |
11779 | || !peer->bgp->rib[afi][safi]) | |
11780 | { | |
856ca177 MS |
11781 | if (use_json) |
11782 | { | |
11783 | json_object_string_add(json, "warning", "No such neighbor or address family"); | |
11784 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11785 | json_object_free(json); | |
11786 | } | |
11787 | else | |
11788 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
11789 | ||
2815e61f PJ |
11790 | return CMD_WARNING; |
11791 | } | |
11792 | ||
11793 | memset (&pcounts, 0, sizeof(pcounts)); | |
11794 | pcounts.peer = peer; | |
11795 | pcounts.table = peer->bgp->rib[afi][safi]; | |
11796 | ||
11797 | /* in-place call via thread subsystem so as to record execution time | |
856ca177 MS |
11798 | * * stats for the thread-walk (i.e. ensure this can't be blamed on |
11799 | * * on just vty_read()). | |
11800 | * */ | |
87d4a781 | 11801 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
6410e93a | 11802 | |
856ca177 MS |
11803 | if (use_json) |
11804 | { | |
11805 | json_object_string_add(json, "prefixCountsFor", peer->host); | |
11806 | json_object_string_add(json, "multiProtocol", afi_safi_print (afi, safi)); | |
11807 | json_object_int_add(json, "pfxCounter", peer->pcount[afi][safi]); | |
11808 | ||
11809 | for (i = 0; i < PCOUNT_MAX; i++) | |
11810 | json_object_int_add(json_loop, pcount_strs[i], pcounts.count[i]); | |
ff7924f6 | 11811 | |
856ca177 | 11812 | json_object_object_add(json, "ribTableWalkCounters", json_loop); |
ff7924f6 | 11813 | |
856ca177 MS |
11814 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
11815 | { | |
11816 | json_object_string_add(json, "pfxctDriftFor", peer->host); | |
11817 | json_object_string_add(json, "recommended", "Please report this bug, with the above command output"); | |
11818 | } | |
11819 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
11820 | json_object_free(json); | |
11821 | } | |
11822 | else | |
ff7924f6 | 11823 | { |
04b6bdc0 DW |
11824 | |
11825 | if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
11826 | { | |
11827 | vty_out (vty, "Prefix counts for %s/%s, %s%s", | |
11828 | peer->hostname, peer->host, afi_safi_print (afi, safi), | |
11829 | VTY_NEWLINE); | |
11830 | } | |
11831 | else | |
11832 | { | |
11833 | vty_out (vty, "Prefix counts for %s, %s%s", | |
11834 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); | |
11835 | } | |
11836 | ||
856ca177 MS |
11837 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
11838 | vty_out (vty, "%sCounts from RIB table walk:%s%s", | |
11839 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
11840 | ||
11841 | for (i = 0; i < PCOUNT_MAX; i++) | |
11842 | vty_out (vty, "%20s: %-10d%s", pcount_strs[i], pcounts.count[i], VTY_NEWLINE); | |
11843 | ||
11844 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) | |
11845 | { | |
11846 | vty_out (vty, "%s [pcount] PfxCt drift!%s", | |
11847 | peer->host, VTY_NEWLINE); | |
11848 | vty_out (vty, "Please report this bug, with the above command output%s", | |
11849 | VTY_NEWLINE); | |
11850 | } | |
ff7924f6 PJ |
11851 | } |
11852 | ||
11853 | return CMD_SUCCESS; | |
11854 | } | |
11855 | ||
11856 | DEFUN (show_ip_bgp_neighbor_prefix_counts, | |
11857 | show_ip_bgp_neighbor_prefix_counts_cmd, | |
856ca177 | 11858 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11859 | SHOW_STR |
11860 | IP_STR | |
11861 | BGP_STR | |
11862 | "Detailed information on TCP and BGP neighbor connections\n" | |
11863 | "Neighbor to display information about\n" | |
11864 | "Neighbor to display information about\n" | |
a80beece | 11865 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11866 | "Display detailed prefix count information\n" |
11867 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11868 | { |
11869 | struct peer *peer; | |
db7c8528 | 11870 | u_char uj = use_json(argc, argv); |
ff7924f6 | 11871 | |
db7c8528 | 11872 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
ff7924f6 PJ |
11873 | if (! peer) |
11874 | return CMD_WARNING; | |
11875 | ||
db7c8528 | 11876 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); |
ff7924f6 PJ |
11877 | } |
11878 | ||
8386ac43 | 11879 | DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, |
11880 | show_ip_bgp_instance_neighbor_prefix_counts_cmd, | |
11881 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", | |
50ef26d4 | 11882 | SHOW_STR |
11883 | IP_STR | |
11884 | BGP_STR | |
8386ac43 | 11885 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 11886 | "Detailed information on TCP and BGP neighbor connections\n" |
11887 | "Neighbor to display information about\n" | |
11888 | "Neighbor to display information about\n" | |
11889 | "Neighbor on bgp configured interface\n" | |
11890 | "Display detailed prefix count information\n" | |
11891 | "JavaScript Object Notation\n") | |
11892 | { | |
11893 | struct peer *peer; | |
11894 | u_char uj = use_json(argc, argv); | |
11895 | ||
11896 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
11897 | if (! peer) | |
11898 | return CMD_WARNING; | |
11899 | ||
11900 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); | |
11901 | } | |
11902 | ||
ff7924f6 PJ |
11903 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
11904 | show_bgp_ipv6_neighbor_prefix_counts_cmd, | |
856ca177 | 11905 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11906 | SHOW_STR |
11907 | BGP_STR | |
11908 | "Address family\n" | |
11909 | "Detailed information on TCP and BGP neighbor connections\n" | |
11910 | "Neighbor to display information about\n" | |
11911 | "Neighbor to display information about\n" | |
a80beece | 11912 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11913 | "Display detailed prefix count information\n" |
11914 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11915 | { |
11916 | struct peer *peer; | |
db7c8528 | 11917 | u_char uj = use_json(argc, argv); |
856ca177 | 11918 | |
db7c8528 | 11919 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
ff7924f6 PJ |
11920 | if (! peer) |
11921 | return CMD_WARNING; | |
11922 | ||
db7c8528 | 11923 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); |
ff7924f6 PJ |
11924 | } |
11925 | ||
8386ac43 | 11926 | DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, |
11927 | show_bgp_instance_ipv6_neighbor_prefix_counts_cmd, | |
11928 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", | |
50ef26d4 | 11929 | SHOW_STR |
11930 | BGP_STR | |
8386ac43 | 11931 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 11932 | "Address family\n" |
11933 | "Detailed information on TCP and BGP neighbor connections\n" | |
11934 | "Neighbor to display information about\n" | |
11935 | "Neighbor to display information about\n" | |
11936 | "Neighbor on bgp configured interface\n" | |
11937 | "Display detailed prefix count information\n" | |
11938 | "JavaScript Object Notation\n") | |
11939 | { | |
11940 | struct peer *peer; | |
11941 | u_char uj = use_json(argc, argv); | |
11942 | ||
11943 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
11944 | if (! peer) | |
11945 | return CMD_WARNING; | |
11946 | ||
11947 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); | |
11948 | } | |
11949 | ||
ff7924f6 PJ |
11950 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
11951 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, | |
856ca177 | 11952 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11953 | SHOW_STR |
11954 | IP_STR | |
11955 | BGP_STR | |
11956 | "Address family\n" | |
11957 | "Address Family modifier\n" | |
11958 | "Address Family modifier\n" | |
11959 | "Detailed information on TCP and BGP neighbor connections\n" | |
11960 | "Neighbor to display information about\n" | |
11961 | "Neighbor to display information about\n" | |
a80beece | 11962 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11963 | "Display detailed prefix count information\n" |
11964 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11965 | { |
11966 | struct peer *peer; | |
db7c8528 | 11967 | u_char uj = use_json(argc, argv); |
ff7924f6 | 11968 | |
db7c8528 | 11969 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
ff7924f6 PJ |
11970 | if (! peer) |
11971 | return CMD_WARNING; | |
11972 | ||
11973 | if (strncmp (argv[0], "m", 1) == 0) | |
db7c8528 | 11974 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj); |
ff7924f6 | 11975 | |
db7c8528 | 11976 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); |
ff7924f6 PJ |
11977 | } |
11978 | ||
11979 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, | |
11980 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, | |
856ca177 | 11981 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", |
ff7924f6 PJ |
11982 | SHOW_STR |
11983 | IP_STR | |
11984 | BGP_STR | |
11985 | "Address family\n" | |
11986 | "Address Family modifier\n" | |
11987 | "Address Family modifier\n" | |
11988 | "Detailed information on TCP and BGP neighbor connections\n" | |
11989 | "Neighbor to display information about\n" | |
11990 | "Neighbor to display information about\n" | |
a80beece | 11991 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
11992 | "Display detailed prefix count information\n" |
11993 | "JavaScript Object Notation\n") | |
ff7924f6 PJ |
11994 | { |
11995 | struct peer *peer; | |
db7c8528 | 11996 | u_char uj = use_json(argc, argv); |
856ca177 | 11997 | |
db7c8528 | 11998 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
ff7924f6 PJ |
11999 | if (! peer) |
12000 | return CMD_WARNING; | |
12001 | ||
db7c8528 | 12002 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN, uj); |
ff7924f6 PJ |
12003 | } |
12004 | ||
94f2b392 | 12005 | static void |
718e3744 | 12006 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
856ca177 | 12007 | int in, const char *rmap_name, u_char use_json, json_object *json) |
718e3744 | 12008 | { |
12009 | struct bgp_table *table; | |
12010 | struct bgp_adj_in *ain; | |
12011 | struct bgp_adj_out *adj; | |
12012 | unsigned long output_count; | |
0b16f239 | 12013 | unsigned long filtered_count; |
718e3744 | 12014 | struct bgp_node *rn; |
12015 | int header1 = 1; | |
12016 | struct bgp *bgp; | |
12017 | int header2 = 1; | |
0b16f239 DS |
12018 | struct attr attr; |
12019 | struct attr_extra extra; | |
12020 | int ret; | |
840fced9 | 12021 | struct update_subgroup *subgrp; |
856ca177 MS |
12022 | json_object *json_scode = NULL; |
12023 | json_object *json_ocode = NULL; | |
12024 | json_object *json_ar = NULL; | |
adbac85e | 12025 | struct peer_af *paf; |
856ca177 MS |
12026 | |
12027 | if (use_json) | |
12028 | { | |
12029 | json_scode = json_object_new_object(); | |
12030 | json_ocode = json_object_new_object(); | |
12031 | json_ar = json_object_new_object(); | |
12032 | ||
12033 | json_object_string_add(json_scode, "suppressed", "s"); | |
12034 | json_object_string_add(json_scode, "damped", "d"); | |
12035 | json_object_string_add(json_scode, "history", "h"); | |
12036 | json_object_string_add(json_scode, "valid", "*"); | |
12037 | json_object_string_add(json_scode, "best", ">"); | |
12038 | json_object_string_add(json_scode, "multipath", "="); | |
12039 | json_object_string_add(json_scode, "internal", "i"); | |
12040 | json_object_string_add(json_scode, "ribFailure", "r"); | |
12041 | json_object_string_add(json_scode, "stale", "S"); | |
12042 | json_object_string_add(json_scode, "removed", "R"); | |
12043 | ||
12044 | json_object_string_add(json_ocode, "igp", "i"); | |
12045 | json_object_string_add(json_ocode, "egp", "e"); | |
12046 | json_object_string_add(json_ocode, "incomplete", "?"); | |
12047 | } | |
718e3744 | 12048 | |
bb46e94f | 12049 | bgp = peer->bgp; |
718e3744 | 12050 | |
12051 | if (! bgp) | |
856ca177 MS |
12052 | { |
12053 | if (use_json) | |
12054 | { | |
12055 | json_object_string_add(json, "alert", "no BGP"); | |
12056 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
12057 | json_object_free(json); | |
12058 | } | |
12059 | else | |
12060 | vty_out (vty, "%% No bgp%s", VTY_NEWLINE); | |
12061 | return; | |
12062 | } | |
718e3744 | 12063 | |
12064 | table = bgp->rib[afi][safi]; | |
12065 | ||
0b16f239 | 12066 | output_count = filtered_count = 0; |
840fced9 | 12067 | subgrp = peer_subgroup(peer, afi, safi); |
47fc97cc | 12068 | |
840fced9 | 12069 | if (!in && subgrp && CHECK_FLAG (subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) |
718e3744 | 12070 | { |
856ca177 MS |
12071 | if (use_json) |
12072 | { | |
12073 | json_object_int_add(json, "bgpTableVersion", table->version); | |
12074 | json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); | |
12075 | json_object_object_add(json, "bgpStatusCodes", json_scode); | |
12076 | json_object_object_add(json, "bgpOriginCodes", json_ocode); | |
12077 | json_object_string_add(json, "bgpOriginatingDefaultNetwork", "0.0.0.0"); | |
12078 | } | |
12079 | else | |
12080 | { | |
12081 | vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
12082 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12083 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 12084 | |
856ca177 MS |
12085 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
12086 | VTY_NEWLINE, VTY_NEWLINE); | |
12087 | } | |
718e3744 | 12088 | header1 = 0; |
12089 | } | |
12090 | ||
0b16f239 | 12091 | attr.extra = &extra; |
718e3744 | 12092 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
856ca177 MS |
12093 | { |
12094 | if (in) | |
12095 | { | |
12096 | for (ain = rn->adj_in; ain; ain = ain->next) | |
12097 | { | |
12098 | if (ain->peer == peer) | |
12099 | { | |
12100 | if (header1) | |
12101 | { | |
12102 | if (use_json) | |
12103 | { | |
12104 | json_object_int_add(json, "bgpTableVersion", 0); | |
12105 | json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); | |
12106 | json_object_object_add(json, "bgpStatusCodes", json_scode); | |
12107 | json_object_object_add(json, "bgpOriginCodes", json_ocode); | |
12108 | } | |
12109 | else | |
12110 | { | |
12111 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
12112 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12113 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12114 | } | |
12115 | header1 = 0; | |
12116 | } | |
12117 | if (header2) | |
12118 | { | |
12119 | if (!use_json) | |
12120 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
12121 | header2 = 0; | |
12122 | } | |
12123 | if (ain->attr) | |
12124 | { | |
12125 | bgp_attr_dup(&attr, ain->attr); | |
12126 | if (bgp_input_modifier(peer, &rn->p, &attr, afi, safi, rmap_name) != RMAP_DENY) | |
12127 | { | |
12128 | route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); | |
12129 | output_count++; | |
12130 | } | |
12131 | else | |
12132 | filtered_count++; | |
12133 | } | |
12134 | } | |
12135 | } | |
12136 | } | |
12137 | else | |
12138 | { | |
adbac85e DW |
12139 | for (adj = rn->adj_out; adj; adj = adj->next) |
12140 | SUBGRP_FOREACH_PEER(adj->subgroup, paf) | |
12141 | if (paf->peer == peer) | |
856ca177 | 12142 | { |
adbac85e | 12143 | if (header1) |
856ca177 | 12144 | { |
adbac85e DW |
12145 | if (use_json) |
12146 | { | |
12147 | json_object_int_add(json, "bgpTableVersion", table->version); | |
12148 | json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); | |
12149 | json_object_object_add(json, "bgpStatusCodes", json_scode); | |
12150 | json_object_object_add(json, "bgpOriginCodes", json_ocode); | |
12151 | } | |
12152 | else | |
12153 | { | |
12154 | vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, | |
12155 | inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
12156 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12157 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
12158 | } | |
12159 | header1 = 0; | |
856ca177 | 12160 | } |
adbac85e DW |
12161 | |
12162 | if (header2) | |
856ca177 | 12163 | { |
adbac85e DW |
12164 | if (!use_json) |
12165 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
12166 | header2 = 0; | |
856ca177 | 12167 | } |
adbac85e DW |
12168 | |
12169 | if (adj->attr) | |
856ca177 | 12170 | { |
adbac85e DW |
12171 | bgp_attr_dup(&attr, adj->attr); |
12172 | ret = bgp_output_modifier(peer, &rn->p, &attr, afi, safi, rmap_name); | |
12173 | if (ret != RMAP_DENY) | |
12174 | { | |
12175 | route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); | |
12176 | output_count++; | |
12177 | } | |
12178 | else | |
12179 | filtered_count++; | |
856ca177 | 12180 | } |
856ca177 | 12181 | } |
856ca177 MS |
12182 | } |
12183 | } | |
12184 | if (use_json) | |
12185 | json_object_object_add(json, "advertisedRoutes", json_ar); | |
47fc97cc | 12186 | |
718e3744 | 12187 | if (output_count != 0) |
856ca177 MS |
12188 | { |
12189 | if (use_json) | |
12190 | json_object_int_add(json, "totalPrefixCounter", output_count); | |
12191 | else | |
12192 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
12193 | VTY_NEWLINE, output_count, VTY_NEWLINE); | |
12194 | } | |
12195 | if (use_json) | |
12196 | { | |
12197 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
12198 | json_object_free(json); | |
12199 | } | |
12200 | ||
718e3744 | 12201 | } |
12202 | ||
94f2b392 | 12203 | static int |
47fc97cc | 12204 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
856ca177 MS |
12205 | int in, const char *rmap_name, u_char use_json) |
12206 | { | |
12207 | json_object *json = NULL; | |
12208 | ||
12209 | if (use_json) | |
12210 | json = json_object_new_object(); | |
12211 | ||
12212 | if (!peer || !peer->afc[afi][safi]) | |
718e3744 | 12213 | { |
856ca177 MS |
12214 | if (use_json) |
12215 | { | |
12216 | json_object_string_add(json, "warning", "No such neighbor or address family"); | |
12217 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
12218 | json_object_free(json); | |
12219 | } | |
12220 | else | |
12221 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
12222 | ||
718e3744 | 12223 | return CMD_WARNING; |
12224 | } | |
12225 | ||
856ca177 | 12226 | if (in && !CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
718e3744 | 12227 | { |
856ca177 MS |
12228 | if (use_json) |
12229 | { | |
12230 | json_object_string_add(json, "warning", "Inbound soft reconfiguration not enabled"); | |
12231 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
12232 | json_object_free(json); | |
12233 | } | |
12234 | else | |
12235 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE); | |
12236 | ||
718e3744 | 12237 | return CMD_WARNING; |
12238 | } | |
12239 | ||
856ca177 | 12240 | show_adj_route (vty, peer, afi, safi, in, rmap_name, use_json, json); |
718e3744 | 12241 | |
12242 | return CMD_SUCCESS; | |
12243 | } | |
12244 | ||
8386ac43 | 12245 | DEFUN (show_ip_bgp_instance_neighbor_advertised_route, |
12246 | show_ip_bgp_instance_neighbor_advertised_route_cmd, | |
12247 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", | |
718e3744 | 12248 | SHOW_STR |
12249 | IP_STR | |
12250 | BGP_STR | |
8386ac43 | 12251 | BGP_INSTANCE_HELP_STR |
718e3744 | 12252 | "Detailed information on TCP and BGP neighbor connections\n" |
12253 | "Neighbor to display information about\n" | |
12254 | "Neighbor to display information about\n" | |
856ca177 MS |
12255 | "Display the routes advertised to a BGP neighbor\n" |
12256 | "JavaScript Object Notation\n") | |
718e3744 | 12257 | { |
bb46e94f | 12258 | struct peer *peer; |
db7c8528 | 12259 | u_char uj = use_json(argc, argv); |
856ca177 | 12260 | |
6aeb9e78 DS |
12261 | if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
12262 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
2a71e9ce | 12263 | else |
6aeb9e78 | 12264 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
2a71e9ce | 12265 | |
bb46e94f | 12266 | if (! peer) |
12267 | return CMD_WARNING; | |
0b16f239 | 12268 | |
db7c8528 | 12269 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, NULL, uj); |
718e3744 | 12270 | } |
12271 | ||
0b16f239 | 12272 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
2a71e9ce | 12273 | show_ip_bgp_neighbor_advertised_route_cmd, |
856ca177 | 12274 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
2a71e9ce TP |
12275 | SHOW_STR |
12276 | IP_STR | |
12277 | BGP_STR | |
12278 | "Detailed information on TCP and BGP neighbor connections\n" | |
12279 | "Neighbor to display information about\n" | |
12280 | "Neighbor to display information about\n" | |
a80beece | 12281 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12282 | "Display the routes advertised to a BGP neighbor\n" |
12283 | "JavaScript Object Notation\n") | |
2a71e9ce | 12284 | |
0b16f239 DS |
12285 | { |
12286 | struct peer *peer; | |
ffd0c037 | 12287 | const char *rmap_name = NULL; |
db7c8528 | 12288 | u_char uj = use_json(argc, argv); |
0b16f239 | 12289 | |
db7c8528 | 12290 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
0b16f239 DS |
12291 | |
12292 | if (! peer) | |
12293 | return CMD_WARNING; | |
12294 | ||
856ca177 MS |
12295 | if ((argc == 2 && argv[1] && strcmp(argv[1], "json") != 0) |
12296 | || (argc == 3)) | |
0b16f239 DS |
12297 | rmap_name = argv[1]; |
12298 | ||
db7c8528 | 12299 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); |
0b16f239 DS |
12300 | } |
12301 | ||
12302 | ALIAS (show_ip_bgp_neighbor_advertised_route, | |
12303 | show_ip_bgp_neighbor_advertised_route_rmap_cmd, | |
856ca177 | 12304 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", |
0b16f239 DS |
12305 | SHOW_STR |
12306 | IP_STR | |
12307 | BGP_STR | |
12308 | "Detailed information on TCP and BGP neighbor connections\n" | |
12309 | "Neighbor to display information about\n" | |
12310 | "Neighbor to display information about\n" | |
12311 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12312 | "Display the routes advertised to a BGP neighbor\n" |
12313 | "JavaScript Object Notation\n") | |
0b16f239 | 12314 | |
8386ac43 | 12315 | ALIAS (show_ip_bgp_instance_neighbor_advertised_route, |
12316 | show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd, | |
12317 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", | |
50ef26d4 | 12318 | SHOW_STR |
12319 | IP_STR | |
12320 | BGP_STR | |
8386ac43 | 12321 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 12322 | "Detailed information on TCP and BGP neighbor connections\n" |
12323 | "Neighbor to display information about\n" | |
12324 | "Neighbor to display information about\n" | |
12325 | "Neighbor on bgp configured interface\n" | |
12326 | "Display the routes advertised to a BGP neighbor\n" | |
12327 | "JavaScript Object Notation\n") | |
718e3744 | 12328 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
12329 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, | |
856ca177 | 12330 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12331 | SHOW_STR |
12332 | IP_STR | |
12333 | BGP_STR | |
12334 | "Address family\n" | |
12335 | "Address Family modifier\n" | |
12336 | "Address Family modifier\n" | |
12337 | "Detailed information on TCP and BGP neighbor connections\n" | |
12338 | "Neighbor to display information about\n" | |
12339 | "Neighbor to display information about\n" | |
a80beece | 12340 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12341 | "Display the routes advertised to a BGP neighbor\n" |
12342 | "JavaScript Object Notation\n") | |
718e3744 | 12343 | { |
bb46e94f | 12344 | struct peer *peer; |
ffd0c037 | 12345 | const char *rmap_name = NULL; |
db7c8528 | 12346 | u_char uj = use_json(argc, argv); |
856ca177 | 12347 | |
db7c8528 | 12348 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12349 | if (! peer) |
12350 | return CMD_WARNING; | |
12351 | ||
856ca177 | 12352 | if ((argc == 4) || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
0b16f239 DS |
12353 | rmap_name = argv[2]; |
12354 | ||
718e3744 | 12355 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 12356 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0, rmap_name, uj); |
856ca177 | 12357 | else |
db7c8528 | 12358 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); |
718e3744 | 12359 | } |
12360 | ||
0b16f239 DS |
12361 | ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route, |
12362 | show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd, | |
856ca177 | 12363 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", |
0b16f239 DS |
12364 | SHOW_STR |
12365 | IP_STR | |
12366 | BGP_STR | |
12367 | "Address family\n" | |
12368 | "Address Family modifier\n" | |
12369 | "Address Family modifier\n" | |
12370 | "Detailed information on TCP and BGP neighbor connections\n" | |
12371 | "Neighbor to display information about\n" | |
12372 | "Neighbor to display information about\n" | |
12373 | "Neighbor on bgp configured interface\n" | |
12374 | "Display the routes advertised to a BGP neighbor\n" | |
856ca177 MS |
12375 | "Route-map to control what is displayed\n" |
12376 | "JavaScript Object Notation\n") | |
0b16f239 | 12377 | |
718e3744 | 12378 | #ifdef HAVE_IPV6 |
8386ac43 | 12379 | DEFUN (show_bgp_instance_neighbor_advertised_route, |
12380 | show_bgp_instance_neighbor_advertised_route_cmd, | |
12381 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", | |
718e3744 | 12382 | SHOW_STR |
12383 | BGP_STR | |
8386ac43 | 12384 | BGP_INSTANCE_HELP_STR |
718e3744 | 12385 | "Detailed information on TCP and BGP neighbor connections\n" |
12386 | "Neighbor to display information about\n" | |
12387 | "Neighbor to display information about\n" | |
a80beece | 12388 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12389 | "Display the routes advertised to a BGP neighbor\n" |
12390 | "JavaScript Object Notation\n") | |
718e3744 | 12391 | { |
bb46e94f | 12392 | struct peer *peer; |
db7c8528 | 12393 | u_char uj = use_json(argc, argv); |
856ca177 | 12394 | |
6aeb9e78 DS |
12395 | if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
12396 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
bb46e94f | 12397 | else |
6aeb9e78 | 12398 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12399 | |
12400 | if (! peer) | |
0b16f239 | 12401 | return CMD_WARNING; |
bb46e94f | 12402 | |
db7c8528 | 12403 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, NULL, uj); |
47fc97cc DS |
12404 | } |
12405 | ||
8386ac43 | 12406 | ALIAS (show_bgp_instance_neighbor_advertised_route, |
12407 | show_bgp_instance_ipv6_neighbor_advertised_route_cmd, | |
12408 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", | |
0b16f239 DS |
12409 | SHOW_STR |
12410 | BGP_STR | |
8386ac43 | 12411 | BGP_INSTANCE_HELP_STR |
0b16f239 DS |
12412 | "Address family\n" |
12413 | "Detailed information on TCP and BGP neighbor connections\n" | |
12414 | "Neighbor to display information about\n" | |
12415 | "Neighbor to display information about\n" | |
12416 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12417 | "Display the routes advertised to a BGP neighbor\n" |
12418 | "JavaScript Object Notation\n") | |
0b16f239 | 12419 | |
0b16f239 DS |
12420 | DEFUN (show_bgp_neighbor_advertised_route, |
12421 | show_bgp_neighbor_advertised_route_cmd, | |
856ca177 | 12422 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
bb46e94f | 12423 | SHOW_STR |
12424 | BGP_STR | |
bb46e94f | 12425 | "Detailed information on TCP and BGP neighbor connections\n" |
12426 | "Neighbor to display information about\n" | |
12427 | "Neighbor to display information about\n" | |
a80beece | 12428 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12429 | "Display the routes advertised to a BGP neighbor\n" |
12430 | "JavaScript Object Notation\n") | |
0b16f239 | 12431 | |
bb46e94f | 12432 | { |
12433 | struct peer *peer; | |
ffd0c037 | 12434 | const char *rmap_name = NULL; |
db7c8528 | 12435 | u_char uj = use_json(argc, argv); |
bb46e94f | 12436 | |
db7c8528 | 12437 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
856ca177 MS |
12438 | |
12439 | if (!peer) | |
bb46e94f | 12440 | return CMD_WARNING; |
12441 | ||
856ca177 | 12442 | if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) |
0b16f239 DS |
12443 | rmap_name = argv[1]; |
12444 | ||
db7c8528 | 12445 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, rmap_name, uj); |
718e3744 | 12446 | } |
12447 | ||
0b16f239 DS |
12448 | ALIAS (show_bgp_neighbor_advertised_route, |
12449 | show_bgp_ipv6_neighbor_advertised_route_cmd, | |
856ca177 | 12450 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12451 | SHOW_STR |
12452 | BGP_STR | |
12453 | "Address family\n" | |
12454 | "Detailed information on TCP and BGP neighbor connections\n" | |
12455 | "Neighbor to display information about\n" | |
12456 | "Neighbor to display information about\n" | |
a80beece | 12457 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12458 | "Display the routes advertised to a BGP neighbor\n" |
12459 | "JavaScript Object Notation\n") | |
718e3744 | 12460 | |
12461 | /* old command */ | |
0b16f239 | 12462 | ALIAS (show_bgp_neighbor_advertised_route, |
718e3744 | 12463 | ipv6_bgp_neighbor_advertised_route_cmd, |
856ca177 | 12464 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12465 | SHOW_STR |
12466 | IPV6_STR | |
12467 | BGP_STR | |
12468 | "Detailed information on TCP and BGP neighbor connections\n" | |
12469 | "Neighbor to display information about\n" | |
12470 | "Neighbor to display information about\n" | |
a80beece | 12471 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12472 | "Display the routes advertised to a BGP neighbor\n" |
12473 | "JavaScript Object Notation\n") | |
bb46e94f | 12474 | |
718e3744 | 12475 | /* old command */ |
12476 | DEFUN (ipv6_mbgp_neighbor_advertised_route, | |
12477 | ipv6_mbgp_neighbor_advertised_route_cmd, | |
856ca177 | 12478 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", |
718e3744 | 12479 | SHOW_STR |
12480 | IPV6_STR | |
12481 | MBGP_STR | |
12482 | "Detailed information on TCP and BGP neighbor connections\n" | |
12483 | "Neighbor to display information about\n" | |
12484 | "Neighbor to display information about\n" | |
a80beece DS |
12485 | "Neighbor on bgp configured interface\n" |
12486 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12487 | "Display the routes advertised to a BGP neighbor\n" |
12488 | "JavaScript Object Notation\n") | |
718e3744 | 12489 | { |
bb46e94f | 12490 | struct peer *peer; |
db7c8528 | 12491 | u_char uj = use_json(argc, argv); |
856ca177 | 12492 | |
db7c8528 | 12493 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 12494 | if (! peer) |
856ca177 | 12495 | return CMD_WARNING; |
bb46e94f | 12496 | |
47e9b292 | 12497 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 12498 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0, NULL, uj); |
718e3744 | 12499 | } |
12500 | #endif /* HAVE_IPV6 */ | |
6b0655a2 | 12501 | |
8386ac43 | 12502 | DEFUN (show_bgp_instance_neighbor_received_routes, |
12503 | show_bgp_instance_neighbor_received_routes_cmd, | |
12504 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", | |
0b16f239 DS |
12505 | SHOW_STR |
12506 | BGP_STR | |
8386ac43 | 12507 | BGP_INSTANCE_HELP_STR |
0b16f239 DS |
12508 | "Detailed information on TCP and BGP neighbor connections\n" |
12509 | "Neighbor to display information about\n" | |
12510 | "Neighbor to display information about\n" | |
12511 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12512 | "Display the received routes from neighbor\n" |
12513 | "JavaScript Object Notation\n") | |
0b16f239 DS |
12514 | { |
12515 | struct peer *peer; | |
db7c8528 | 12516 | u_char uj = use_json(argc, argv); |
856ca177 | 12517 | |
50ef26d4 | 12518 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); |
0b16f239 DS |
12519 | if (! peer) |
12520 | return CMD_WARNING; | |
12521 | ||
db7c8528 | 12522 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, NULL, uj); |
0b16f239 DS |
12523 | } |
12524 | ||
8386ac43 | 12525 | DEFUN (show_ip_bgp_instance_neighbor_received_routes, |
12526 | show_ip_bgp_instance_neighbor_received_routes_cmd, | |
12527 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", | |
718e3744 | 12528 | SHOW_STR |
12529 | IP_STR | |
12530 | BGP_STR | |
8386ac43 | 12531 | BGP_INSTANCE_HELP_STR |
718e3744 | 12532 | "Detailed information on TCP and BGP neighbor connections\n" |
12533 | "Neighbor to display information about\n" | |
12534 | "Neighbor to display information about\n" | |
a80beece | 12535 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12536 | "Display the received routes from neighbor\n" |
12537 | "JavaScript Object Notation\n") | |
718e3744 | 12538 | { |
bb46e94f | 12539 | struct peer *peer; |
db7c8528 | 12540 | u_char uj = use_json(argc, argv); |
856ca177 | 12541 | |
50ef26d4 | 12542 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); |
bb46e94f | 12543 | if (! peer) |
12544 | return CMD_WARNING; | |
12545 | ||
db7c8528 | 12546 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, NULL, uj); |
718e3744 | 12547 | } |
12548 | ||
8386ac43 | 12549 | ALIAS (show_bgp_instance_neighbor_received_routes, |
12550 | show_bgp_instance_ipv6_neighbor_received_routes_cmd, | |
12551 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", | |
0b16f239 DS |
12552 | SHOW_STR |
12553 | BGP_STR | |
8386ac43 | 12554 | BGP_INSTANCE_HELP_STR |
0b16f239 DS |
12555 | "Address family\n" |
12556 | "Detailed information on TCP and BGP neighbor connections\n" | |
12557 | "Neighbor to display information about\n" | |
12558 | "Neighbor to display information about\n" | |
12559 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12560 | "Display the received routes from neighbor\n" |
12561 | "JavaScript Object Notation\n") | |
0b16f239 DS |
12562 | |
12563 | DEFUN (show_ip_bgp_neighbor_received_routes, | |
2a71e9ce | 12564 | show_ip_bgp_neighbor_received_routes_cmd, |
856ca177 | 12565 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
2a71e9ce TP |
12566 | SHOW_STR |
12567 | IP_STR | |
12568 | BGP_STR | |
12569 | "Detailed information on TCP and BGP neighbor connections\n" | |
12570 | "Neighbor to display information about\n" | |
12571 | "Neighbor to display information about\n" | |
a80beece | 12572 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12573 | "Display the received routes from neighbor\n" |
12574 | "JavaScript Object Notation\n") | |
2a71e9ce | 12575 | |
0b16f239 DS |
12576 | { |
12577 | struct peer *peer; | |
ffd0c037 | 12578 | const char *rmap_name = NULL; |
db7c8528 | 12579 | u_char uj = use_json(argc, argv); |
0b16f239 | 12580 | |
db7c8528 | 12581 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
0b16f239 DS |
12582 | |
12583 | if (! peer) | |
12584 | return CMD_WARNING; | |
12585 | ||
856ca177 | 12586 | if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) |
0b16f239 DS |
12587 | rmap_name = argv[1]; |
12588 | ||
db7c8528 | 12589 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); |
0b16f239 DS |
12590 | } |
12591 | ||
12592 | ALIAS (show_ip_bgp_neighbor_received_routes, | |
12593 | show_ip_bgp_neighbor_received_routes_rmap_cmd, | |
856ca177 | 12594 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", |
0b16f239 DS |
12595 | SHOW_STR |
12596 | IP_STR | |
12597 | BGP_STR | |
12598 | "Detailed information on TCP and BGP neighbor connections\n" | |
12599 | "Neighbor to display information about\n" | |
12600 | "Neighbor to display information about\n" | |
12601 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12602 | "Display the received routes from neighbor\n" |
12603 | "JavaScript Object Notation\n") | |
0b16f239 | 12604 | |
8386ac43 | 12605 | ALIAS (show_ip_bgp_instance_neighbor_received_routes, |
12606 | show_ip_bgp_instance_neighbor_received_routes_rmap_cmd, | |
12607 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", | |
50ef26d4 | 12608 | SHOW_STR |
12609 | IP_STR | |
12610 | BGP_STR | |
8386ac43 | 12611 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 12612 | "Detailed information on TCP and BGP neighbor connections\n" |
12613 | "Neighbor to display information about\n" | |
12614 | "Neighbor to display information about\n" | |
12615 | "Neighbor on bgp configured interface\n" | |
12616 | "Display the received routes from neighbor\n" | |
12617 | "JavaScript Object Notation\n") | |
12618 | ||
718e3744 | 12619 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
12620 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, | |
856ca177 | 12621 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 12622 | SHOW_STR |
12623 | IP_STR | |
12624 | BGP_STR | |
12625 | "Address family\n" | |
12626 | "Address Family modifier\n" | |
12627 | "Address Family modifier\n" | |
12628 | "Detailed information on TCP and BGP neighbor connections\n" | |
12629 | "Neighbor to display information about\n" | |
12630 | "Neighbor to display information about\n" | |
a80beece | 12631 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12632 | "Display the received routes from neighbor\n" |
12633 | "JavaScript Object Notation\n") | |
718e3744 | 12634 | { |
bb46e94f | 12635 | struct peer *peer; |
ffd0c037 | 12636 | const char *rmap_name = NULL; |
db7c8528 | 12637 | u_char uj = use_json(argc, argv); |
bb46e94f | 12638 | |
db7c8528 | 12639 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 12640 | if (! peer) |
12641 | return CMD_WARNING; | |
0b16f239 | 12642 | |
856ca177 | 12643 | if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) |
0b16f239 DS |
12644 | rmap_name = argv[2]; |
12645 | ||
718e3744 | 12646 | if (strncmp (argv[0], "m", 1) == 0) |
db7c8528 | 12647 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1, rmap_name, uj); |
856ca177 | 12648 | else |
db7c8528 | 12649 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); |
718e3744 | 12650 | } |
12651 | ||
0b16f239 DS |
12652 | ALIAS (show_ip_bgp_ipv4_neighbor_received_routes, |
12653 | show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd, | |
856ca177 | 12654 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", |
0b16f239 DS |
12655 | SHOW_STR |
12656 | IP_STR | |
12657 | BGP_STR | |
12658 | "Address family\n" | |
12659 | "Address Family modifier\n" | |
12660 | "Address Family modifier\n" | |
12661 | "Detailed information on TCP and BGP neighbor connections\n" | |
12662 | "Neighbor to display information about\n" | |
12663 | "Neighbor to display information about\n" | |
12664 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12665 | "Display the received routes from neighbor\n" |
12666 | "JavaScript Object Notation\n") | |
0b16f239 | 12667 | |
8386ac43 | 12668 | DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, |
12669 | show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd, | |
8386ac43 | 12670 | "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}", |
95cbbd2a ML |
12671 | SHOW_STR |
12672 | BGP_STR | |
8386ac43 | 12673 | BGP_INSTANCE_HELP_STR |
95cbbd2a | 12674 | "Address family\n" |
95cbbd2a | 12675 | "Address family\n" |
95cbbd2a ML |
12676 | "Address family modifier\n" |
12677 | "Address family modifier\n" | |
12678 | "Detailed information on TCP and BGP neighbor connections\n" | |
12679 | "Neighbor to display information about\n" | |
12680 | "Neighbor to display information about\n" | |
a80beece | 12681 | "Neighbor on bgp configured interface\n" |
95cbbd2a | 12682 | "Display the advertised routes to neighbor\n" |
856ca177 MS |
12683 | "Display the received routes from neighbor\n" |
12684 | "JavaScript Object Notation\n") | |
95cbbd2a ML |
12685 | { |
12686 | int afi; | |
12687 | int safi; | |
12688 | int in; | |
12689 | struct peer *peer; | |
db7c8528 | 12690 | u_char uj = use_json(argc, argv); |
856ca177 | 12691 | |
6aeb9e78 | 12692 | peer = peer_lookup_in_view (vty, argv[1], argv[4], uj); |
95cbbd2a ML |
12693 | |
12694 | if (! peer) | |
12695 | return CMD_WARNING; | |
12696 | ||
6aeb9e78 DS |
12697 | afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
12698 | safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
12699 | in = (strncmp (argv[5], "r", 1) == 0) ? 1 : 0; | |
95cbbd2a | 12700 | |
db7c8528 | 12701 | return peer_adj_routes (vty, peer, afi, safi, in, NULL, uj); |
95cbbd2a ML |
12702 | } |
12703 | ||
718e3744 | 12704 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
12705 | show_ip_bgp_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12706 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 12707 | SHOW_STR |
12708 | IP_STR | |
12709 | BGP_STR | |
12710 | "Detailed information on TCP and BGP neighbor connections\n" | |
12711 | "Neighbor to display information about\n" | |
12712 | "Neighbor to display information about\n" | |
a80beece | 12713 | "Neighbor on bgp configured interface\n" |
718e3744 | 12714 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12715 | "Display the prefixlist filter\n" |
12716 | "JavaScript Object Notation\n") | |
718e3744 | 12717 | { |
12718 | char name[BUFSIZ]; | |
c63b83fe | 12719 | union sockunion su; |
718e3744 | 12720 | struct peer *peer; |
c63b83fe | 12721 | int count, ret; |
db7c8528 | 12722 | u_char uj = use_json(argc, argv); |
718e3744 | 12723 | |
c63b83fe JBD |
12724 | ret = str2sockunion (argv[0], &su); |
12725 | if (ret < 0) | |
12726 | { | |
a80beece | 12727 | peer = peer_lookup_by_conf_if (NULL, argv[0]); |
856ca177 | 12728 | if (! peer) |
a80beece | 12729 | { |
db7c8528 | 12730 | if (uj) |
856ca177 MS |
12731 | { |
12732 | json_object *json_no = NULL; | |
12733 | json_object *json_sub = NULL; | |
12734 | json_no = json_object_new_object(); | |
12735 | json_sub = json_object_new_object(); | |
12736 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
12737 | json_object_string_add(json_sub, "warningCause", argv[0]); | |
12738 | json_object_object_add(json_no, "detail", json_sub); | |
12739 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12740 | json_object_free(json_no); | |
12741 | } | |
12742 | else | |
12743 | vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE); | |
a80beece DS |
12744 | return CMD_WARNING; |
12745 | } | |
12746 | } | |
12747 | else | |
12748 | { | |
12749 | peer = peer_lookup (NULL, &su); | |
12750 | if (! peer) | |
856ca177 | 12751 | { |
db7c8528 | 12752 | if (uj) |
856ca177 MS |
12753 | { |
12754 | json_object *json_no = NULL; | |
12755 | json_no = json_object_new_object(); | |
12756 | json_object_string_add(json_no, "warning", "Peer not found"); | |
12757 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12758 | json_object_free(json_no); | |
12759 | } | |
12760 | else | |
12761 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
12762 | return CMD_WARNING; | |
12763 | } | |
c63b83fe | 12764 | } |
718e3744 | 12765 | |
12766 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
db7c8528 | 12767 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); |
718e3744 | 12768 | if (count) |
12769 | { | |
db7c8528 | 12770 | if (!uj) |
856ca177 | 12771 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
db7c8528 | 12772 | prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); |
856ca177 MS |
12773 | } |
12774 | else | |
12775 | { | |
db7c8528 | 12776 | if (uj) |
856ca177 MS |
12777 | { |
12778 | json_object *json_no = NULL; | |
12779 | json_no = json_object_new_object(); | |
12780 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12781 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12782 | json_object_free(json_no); | |
12783 | } | |
12784 | else | |
12785 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
718e3744 | 12786 | } |
12787 | ||
12788 | return CMD_SUCCESS; | |
12789 | } | |
12790 | ||
12791 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, | |
12792 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12793 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 12794 | SHOW_STR |
12795 | IP_STR | |
12796 | BGP_STR | |
12797 | "Address family\n" | |
12798 | "Address Family modifier\n" | |
12799 | "Address Family modifier\n" | |
12800 | "Detailed information on TCP and BGP neighbor connections\n" | |
12801 | "Neighbor to display information about\n" | |
12802 | "Neighbor to display information about\n" | |
a80beece | 12803 | "Neighbor on bgp configured interface\n" |
718e3744 | 12804 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12805 | "Display the prefixlist filter\n" |
12806 | "JavaScript Object Notation\n") | |
718e3744 | 12807 | { |
12808 | char name[BUFSIZ]; | |
c63b83fe | 12809 | union sockunion su; |
718e3744 | 12810 | struct peer *peer; |
c63b83fe | 12811 | int count, ret; |
db7c8528 | 12812 | u_char uj = use_json(argc, argv); |
718e3744 | 12813 | |
c63b83fe JBD |
12814 | ret = str2sockunion (argv[1], &su); |
12815 | if (ret < 0) | |
12816 | { | |
a80beece | 12817 | peer = peer_lookup_by_conf_if (NULL, argv[1]); |
856ca177 | 12818 | if (! peer) |
a80beece | 12819 | { |
db7c8528 | 12820 | if (uj) |
856ca177 MS |
12821 | { |
12822 | json_object *json_no = NULL; | |
12823 | json_object *json_sub = NULL; | |
12824 | json_no = json_object_new_object(); | |
12825 | json_sub = json_object_new_object(); | |
12826 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
12827 | json_object_string_add(json_sub, "warningCause", argv[1]); | |
12828 | json_object_object_add(json_no, "detail", json_sub); | |
12829 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12830 | json_object_free(json_no); | |
12831 | } | |
12832 | else | |
12833 | vty_out (vty, "%% Malformed address or name: %s%s", argv[1], VTY_NEWLINE); | |
a80beece DS |
12834 | return CMD_WARNING; |
12835 | } | |
12836 | } | |
12837 | else | |
12838 | { | |
12839 | peer = peer_lookup (NULL, &su); | |
12840 | if (! peer) | |
856ca177 | 12841 | { |
db7c8528 | 12842 | if (uj) |
856ca177 MS |
12843 | { |
12844 | json_object *json_no = NULL; | |
12845 | json_no = json_object_new_object(); | |
12846 | json_object_string_add(json_no, "warning", "Peer not found"); | |
12847 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12848 | json_object_free(json_no); | |
12849 | } | |
12850 | else | |
12851 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
12852 | return CMD_WARNING; | |
12853 | } | |
c63b83fe | 12854 | } |
718e3744 | 12855 | |
12856 | if (strncmp (argv[0], "m", 1) == 0) | |
12857 | { | |
12858 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); | |
db7c8528 | 12859 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); |
718e3744 | 12860 | if (count) |
856ca177 | 12861 | { |
db7c8528 | 12862 | if (!uj) |
856ca177 | 12863 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
db7c8528 | 12864 | prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); |
856ca177 MS |
12865 | } |
12866 | else | |
12867 | { | |
db7c8528 | 12868 | if (uj) |
856ca177 MS |
12869 | { |
12870 | json_object *json_no = NULL; | |
12871 | json_no = json_object_new_object(); | |
12872 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12873 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12874 | json_object_free(json_no); | |
12875 | } | |
12876 | else | |
12877 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
12878 | } | |
718e3744 | 12879 | } |
12880 | else | |
12881 | { | |
12882 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
db7c8528 | 12883 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); |
718e3744 | 12884 | if (count) |
856ca177 | 12885 | { |
db7c8528 | 12886 | if (!uj) |
856ca177 | 12887 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
db7c8528 | 12888 | prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); |
856ca177 MS |
12889 | } |
12890 | else | |
12891 | { | |
db7c8528 | 12892 | if (uj) |
856ca177 MS |
12893 | { |
12894 | json_object *json_no = NULL; | |
12895 | json_no = json_object_new_object(); | |
12896 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
12897 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12898 | json_object_free(json_no); | |
12899 | } | |
12900 | else | |
12901 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
12902 | } | |
718e3744 | 12903 | } |
12904 | ||
12905 | return CMD_SUCCESS; | |
12906 | } | |
718e3744 | 12907 | #ifdef HAVE_IPV6 |
50ef26d4 | 12908 | DEFUN (show_bgp_neighbor_received_routes, |
718e3744 | 12909 | show_bgp_neighbor_received_routes_cmd, |
856ca177 | 12910 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 12911 | SHOW_STR |
12912 | BGP_STR | |
12913 | "Detailed information on TCP and BGP neighbor connections\n" | |
12914 | "Neighbor to display information about\n" | |
12915 | "Neighbor to display information about\n" | |
a80beece | 12916 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
12917 | "Display the received routes from neighbor\n" |
12918 | "JavaScript Object Notation\n") | |
50ef26d4 | 12919 | { |
12920 | struct peer *peer; | |
12921 | const char *rmap_name = NULL; | |
12922 | u_char uj = use_json(argc, argv); | |
718e3744 | 12923 | |
50ef26d4 | 12924 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
12925 | ||
12926 | if (! peer) | |
12927 | return CMD_WARNING; | |
12928 | ||
12929 | if (argc == 3 || (argc == 2 && argv[1] && strcmp(argv[1], "json") != 0)) | |
12930 | rmap_name = argv[1]; | |
12931 | ||
12932 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, rmap_name, uj); | |
12933 | } | |
12934 | ||
12935 | ALIAS (show_bgp_neighbor_received_routes, | |
718e3744 | 12936 | show_bgp_ipv6_neighbor_received_routes_cmd, |
856ca177 | 12937 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
0b16f239 DS |
12938 | SHOW_STR |
12939 | BGP_STR | |
12940 | "Address family\n" | |
12941 | "Detailed information on TCP and BGP neighbor connections\n" | |
12942 | "Neighbor to display information about\n" | |
12943 | "Neighbor to display information about\n" | |
12944 | "Neighbor on bgp configured interface\n" | |
856ca177 MS |
12945 | "Display the received routes from neighbor\n" |
12946 | "JavaScript Object Notation\n") | |
0b16f239 | 12947 | |
718e3744 | 12948 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
12949 | show_bgp_neighbor_received_prefix_filter_cmd, | |
856ca177 | 12950 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 12951 | SHOW_STR |
12952 | BGP_STR | |
12953 | "Detailed information on TCP and BGP neighbor connections\n" | |
12954 | "Neighbor to display information about\n" | |
12955 | "Neighbor to display information about\n" | |
a80beece | 12956 | "Neighbor on bgp configured interface\n" |
718e3744 | 12957 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
12958 | "Display the prefixlist filter\n" |
12959 | "JavaScript Object Notation\n") | |
718e3744 | 12960 | { |
12961 | char name[BUFSIZ]; | |
c63b83fe | 12962 | union sockunion su; |
718e3744 | 12963 | struct peer *peer; |
c63b83fe | 12964 | int count, ret; |
db7c8528 | 12965 | u_char uj = use_json(argc, argv); |
718e3744 | 12966 | |
c63b83fe JBD |
12967 | ret = str2sockunion (argv[0], &su); |
12968 | if (ret < 0) | |
12969 | { | |
a80beece | 12970 | peer = peer_lookup_by_conf_if (NULL, argv[0]); |
856ca177 | 12971 | if (! peer) |
a80beece | 12972 | { |
db7c8528 | 12973 | if (uj) |
856ca177 MS |
12974 | { |
12975 | json_object *json_no = NULL; | |
12976 | json_object *json_sub = NULL; | |
12977 | json_no = json_object_new_object(); | |
12978 | json_sub = json_object_new_object(); | |
12979 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
12980 | json_object_string_add(json_sub, "warningCause", argv[0]); | |
12981 | json_object_object_add(json_no, "detail", json_sub); | |
12982 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
12983 | json_object_free(json_no); | |
12984 | } | |
12985 | else | |
12986 | vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE); | |
a80beece DS |
12987 | return CMD_WARNING; |
12988 | } | |
12989 | } | |
12990 | else | |
12991 | { | |
12992 | peer = peer_lookup (NULL, &su); | |
12993 | if (! peer) | |
856ca177 | 12994 | { |
db7c8528 | 12995 | if (uj) |
856ca177 MS |
12996 | { |
12997 | json_object *json_no = NULL; | |
12998 | json_no = json_object_new_object(); | |
12999 | json_object_string_add(json_no, "warning", "No Peer"); | |
13000 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13001 | json_object_free(json_no); | |
13002 | } | |
13003 | else | |
13004 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
13005 | return CMD_WARNING; | |
13006 | } | |
c63b83fe | 13007 | } |
718e3744 | 13008 | |
13009 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
db7c8528 | 13010 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name, uj); |
718e3744 | 13011 | if (count) |
13012 | { | |
db7c8528 | 13013 | if (!uj) |
856ca177 | 13014 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
db7c8528 | 13015 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name, uj); |
856ca177 MS |
13016 | } |
13017 | else | |
13018 | { | |
db7c8528 | 13019 | if (uj) |
856ca177 MS |
13020 | { |
13021 | json_object *json_no = NULL; | |
13022 | json_no = json_object_new_object(); | |
13023 | json_object_boolean_true_add(json_no, "noFuntionalOutput"); | |
13024 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13025 | json_object_free(json_no); | |
13026 | } | |
13027 | else | |
13028 | vty_out (vty, "No functional output%s", VTY_NEWLINE); | |
718e3744 | 13029 | } |
13030 | ||
13031 | return CMD_SUCCESS; | |
13032 | } | |
13033 | ||
13034 | ALIAS (show_bgp_neighbor_received_prefix_filter, | |
13035 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, | |
856ca177 | 13036 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", |
718e3744 | 13037 | SHOW_STR |
13038 | BGP_STR | |
13039 | "Address family\n" | |
13040 | "Detailed information on TCP and BGP neighbor connections\n" | |
13041 | "Neighbor to display information about\n" | |
13042 | "Neighbor to display information about\n" | |
a80beece | 13043 | "Neighbor on bgp configured interface\n" |
718e3744 | 13044 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
13045 | "Display the prefixlist filter\n" |
13046 | "JavaScript Object Notation\n") | |
718e3744 | 13047 | |
13048 | /* old command */ | |
50ef26d4 | 13049 | ALIAS (show_bgp_neighbor_received_routes, |
718e3744 | 13050 | ipv6_bgp_neighbor_received_routes_cmd, |
856ca177 | 13051 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 13052 | SHOW_STR |
13053 | IPV6_STR | |
13054 | BGP_STR | |
13055 | "Detailed information on TCP and BGP neighbor connections\n" | |
13056 | "Neighbor to display information about\n" | |
13057 | "Neighbor to display information about\n" | |
a80beece | 13058 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13059 | "Display the received routes from neighbor\n" |
13060 | "JavaScript Object Notation\n") | |
718e3744 | 13061 | |
13062 | /* old command */ | |
13063 | DEFUN (ipv6_mbgp_neighbor_received_routes, | |
13064 | ipv6_mbgp_neighbor_received_routes_cmd, | |
856ca177 | 13065 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", |
718e3744 | 13066 | SHOW_STR |
13067 | IPV6_STR | |
13068 | MBGP_STR | |
13069 | "Detailed information on TCP and BGP neighbor connections\n" | |
13070 | "Neighbor to display information about\n" | |
13071 | "Neighbor to display information about\n" | |
a80beece | 13072 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13073 | "Display the received routes from neighbor\n" |
13074 | "JavaScript Object Notation\n") | |
718e3744 | 13075 | { |
bb46e94f | 13076 | struct peer *peer; |
db7c8528 | 13077 | u_char uj = use_json(argc, argv); |
bb46e94f | 13078 | |
db7c8528 | 13079 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13080 | if (! peer) |
13081 | return CMD_WARNING; | |
13082 | ||
47e9b292 | 13083 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
db7c8528 | 13084 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1, NULL, uj); |
bb46e94f | 13085 | } |
13086 | ||
8386ac43 | 13087 | DEFUN (show_bgp_instance_neighbor_received_prefix_filter, |
13088 | show_bgp_instance_neighbor_received_prefix_filter_cmd, | |
13089 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", | |
bb46e94f | 13090 | SHOW_STR |
13091 | BGP_STR | |
8386ac43 | 13092 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13093 | "Detailed information on TCP and BGP neighbor connections\n" |
13094 | "Neighbor to display information about\n" | |
13095 | "Neighbor to display information about\n" | |
a80beece | 13096 | "Neighbor on bgp configured interface\n" |
bb46e94f | 13097 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
13098 | "Display the prefixlist filter\n" |
13099 | "JavaScript Object Notation\n") | |
bb46e94f | 13100 | { |
13101 | char name[BUFSIZ]; | |
c63b83fe | 13102 | union sockunion su; |
bb46e94f | 13103 | struct peer *peer; |
13104 | struct bgp *bgp; | |
c63b83fe | 13105 | int count, ret; |
db7c8528 | 13106 | u_char uj = use_json(argc, argv); |
bb46e94f | 13107 | |
13108 | /* BGP structure lookup. */ | |
6aeb9e78 | 13109 | bgp = bgp_lookup_by_name (argv[1]); |
bb46e94f | 13110 | if (bgp == NULL) |
856ca177 | 13111 | { |
db7c8528 | 13112 | if (uj) |
856ca177 MS |
13113 | { |
13114 | json_object *json_no = NULL; | |
13115 | json_no = json_object_new_object(); | |
13116 | json_object_string_add(json_no, "warning", "Can't find BGP view"); | |
13117 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13118 | json_object_free(json_no); | |
13119 | } | |
13120 | else | |
6aeb9e78 | 13121 | vty_out (vty, "Can't find BGP instance %s%s", argv[1], VTY_NEWLINE); |
856ca177 MS |
13122 | return CMD_WARNING; |
13123 | } | |
13124 | ||
6aeb9e78 | 13125 | ret = str2sockunion (argv[2], &su); |
c63b83fe JBD |
13126 | if (ret < 0) |
13127 | { | |
6aeb9e78 | 13128 | peer = peer_lookup_by_conf_if (bgp, argv[2]); |
856ca177 | 13129 | if (! peer) |
a80beece | 13130 | { |
db7c8528 | 13131 | if (uj) |
856ca177 MS |
13132 | { |
13133 | json_object *json_no = NULL; | |
13134 | json_object *json_sub = NULL; | |
13135 | json_no = json_object_new_object(); | |
13136 | json_sub = json_object_new_object(); | |
13137 | json_object_string_add(json_no, "warning", "Malformed address or name"); | |
6aeb9e78 | 13138 | json_object_string_add(json_sub, "warningCause", argv[2]); |
856ca177 MS |
13139 | json_object_object_add(json_no, "detail", json_sub); |
13140 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13141 | json_object_free(json_no); | |
13142 | } | |
13143 | else | |
6aeb9e78 | 13144 | vty_out (vty, "%% Malformed address or name: %s%s", argv[2], VTY_NEWLINE); |
a80beece DS |
13145 | return CMD_WARNING; |
13146 | } | |
13147 | } | |
13148 | else | |
13149 | { | |
13150 | peer = peer_lookup (bgp, &su); | |
13151 | if (! peer) | |
856ca177 | 13152 | { |
db7c8528 | 13153 | if (uj) |
856ca177 MS |
13154 | { |
13155 | json_object *json_no = NULL; | |
13156 | json_no = json_object_new_object(); | |
13157 | json_object_boolean_true_add(json_no, "noPeer"); | |
13158 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13159 | json_object_free(json_no); | |
13160 | } | |
13161 | else | |
13162 | vty_out (vty, "No peer%s", VTY_NEWLINE); | |
13163 | return CMD_WARNING; | |
13164 | } | |
13165 | ||
c63b83fe | 13166 | } |
bb46e94f | 13167 | |
13168 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
db7c8528 | 13169 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name, uj); |
bb46e94f | 13170 | if (count) |
13171 | { | |
db7c8528 | 13172 | if (!uj) |
856ca177 | 13173 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
db7c8528 | 13174 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name, uj); |
bb46e94f | 13175 | } |
13176 | ||
13177 | return CMD_SUCCESS; | |
718e3744 | 13178 | } |
8386ac43 | 13179 | ALIAS (show_bgp_instance_neighbor_received_prefix_filter, |
13180 | show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd, | |
13181 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", | |
bb46e94f | 13182 | SHOW_STR |
13183 | BGP_STR | |
8386ac43 | 13184 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13185 | "Address family\n" |
13186 | "Detailed information on TCP and BGP neighbor connections\n" | |
13187 | "Neighbor to display information about\n" | |
13188 | "Neighbor to display information about\n" | |
a80beece | 13189 | "Neighbor on bgp configured interface\n" |
bb46e94f | 13190 | "Display information received from a BGP neighbor\n" |
856ca177 MS |
13191 | "Display the prefixlist filter\n" |
13192 | "JavaScript Object NOtation\n") | |
718e3744 | 13193 | #endif /* HAVE_IPV6 */ |
6b0655a2 | 13194 | |
94f2b392 | 13195 | static int |
bb46e94f | 13196 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
856ca177 | 13197 | safi_t safi, enum bgp_show_type type, u_char use_json) |
718e3744 | 13198 | { |
718e3744 | 13199 | if (! peer || ! peer->afc[afi][safi]) |
13200 | { | |
856ca177 MS |
13201 | if (use_json) |
13202 | { | |
13203 | json_object *json_no = NULL; | |
13204 | json_no = json_object_new_object(); | |
13205 | json_object_string_add(json_no, "warning", "No such neighbor or address family"); | |
13206 | vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); | |
13207 | json_object_free(json_no); | |
13208 | } | |
13209 | else | |
13210 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
718e3744 | 13211 | return CMD_WARNING; |
13212 | } | |
47fc97cc | 13213 | |
856ca177 | 13214 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su, use_json); |
718e3744 | 13215 | } |
13216 | ||
13217 | DEFUN (show_ip_bgp_neighbor_routes, | |
13218 | show_ip_bgp_neighbor_routes_cmd, | |
856ca177 | 13219 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13220 | SHOW_STR |
13221 | IP_STR | |
13222 | BGP_STR | |
13223 | "Detailed information on TCP and BGP neighbor connections\n" | |
13224 | "Neighbor to display information about\n" | |
13225 | "Neighbor to display information about\n" | |
a80beece | 13226 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13227 | "Display routes learned from neighbor\n" |
13228 | "JavaScript Object Notation\n") | |
718e3744 | 13229 | { |
bb46e94f | 13230 | struct peer *peer; |
db7c8528 | 13231 | u_char uj = use_json(argc, argv); |
856ca177 | 13232 | |
db7c8528 | 13233 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13234 | if (! peer) |
13235 | return CMD_WARNING; | |
13236 | ||
13237 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
db7c8528 | 13238 | bgp_show_type_neighbor, uj); |
718e3744 | 13239 | } |
13240 | ||
8386ac43 | 13241 | DEFUN (show_ip_bgp_instance_neighbor_routes, |
13242 | show_ip_bgp_instance_neighbor_routes_cmd, | |
13243 | "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", | |
50ef26d4 | 13244 | SHOW_STR |
13245 | IP_STR | |
13246 | BGP_STR | |
8386ac43 | 13247 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 13248 | "Detailed information on TCP and BGP neighbor connections\n" |
13249 | "Neighbor to display information about\n" | |
13250 | "Neighbor to display information about\n" | |
13251 | "Neighbor on bgp configured interface\n" | |
13252 | "Display routes learned from neighbor\n" | |
13253 | "JavaScript Object Notation\n") | |
13254 | { | |
13255 | struct peer *peer; | |
13256 | u_char uj = use_json(argc, argv); | |
13257 | ||
13258 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
13259 | if (! peer) | |
13260 | return CMD_WARNING; | |
13261 | ||
13262 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
13263 | bgp_show_type_neighbor, uj); | |
13264 | } | |
13265 | ||
718e3744 | 13266 | DEFUN (show_ip_bgp_neighbor_flap, |
13267 | show_ip_bgp_neighbor_flap_cmd, | |
856ca177 | 13268 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", |
718e3744 | 13269 | SHOW_STR |
13270 | IP_STR | |
13271 | BGP_STR | |
13272 | "Detailed information on TCP and BGP neighbor connections\n" | |
13273 | "Neighbor to display information about\n" | |
13274 | "Neighbor to display information about\n" | |
a80beece | 13275 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13276 | "Display flap statistics of the routes learned from neighbor\n" |
13277 | "JavaScript Object Notation\n") | |
718e3744 | 13278 | { |
bb46e94f | 13279 | struct peer *peer; |
db7c8528 | 13280 | u_char uj = use_json(argc, argv); |
856ca177 | 13281 | |
db7c8528 | 13282 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13283 | if (! peer) |
13284 | return CMD_WARNING; | |
13285 | ||
13286 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
db7c8528 | 13287 | bgp_show_type_flap_neighbor, uj); |
718e3744 | 13288 | } |
13289 | ||
13290 | DEFUN (show_ip_bgp_neighbor_damp, | |
13291 | show_ip_bgp_neighbor_damp_cmd, | |
856ca177 | 13292 | "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", |
718e3744 | 13293 | SHOW_STR |
13294 | IP_STR | |
13295 | BGP_STR | |
13296 | "Detailed information on TCP and BGP neighbor connections\n" | |
13297 | "Neighbor to display information about\n" | |
13298 | "Neighbor to display information about\n" | |
a80beece | 13299 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13300 | "Display the dampened routes received from neighbor\n" |
13301 | "JavaScript Object Notation\n") | |
718e3744 | 13302 | { |
bb46e94f | 13303 | struct peer *peer; |
db7c8528 | 13304 | u_char uj = use_json(argc, argv); |
856ca177 | 13305 | |
db7c8528 | 13306 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13307 | if (! peer) |
13308 | return CMD_WARNING; | |
13309 | ||
13310 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
db7c8528 | 13311 | bgp_show_type_damp_neighbor, uj); |
718e3744 | 13312 | } |
13313 | ||
13314 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, | |
13315 | show_ip_bgp_ipv4_neighbor_routes_cmd, | |
856ca177 | 13316 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13317 | SHOW_STR |
13318 | IP_STR | |
13319 | BGP_STR | |
13320 | "Address family\n" | |
13321 | "Address Family modifier\n" | |
13322 | "Address Family modifier\n" | |
13323 | "Detailed information on TCP and BGP neighbor connections\n" | |
13324 | "Neighbor to display information about\n" | |
13325 | "Neighbor to display information about\n" | |
a80beece | 13326 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13327 | "Display routes learned from neighbor\n" |
13328 | "JavaScript Object Notation\n") | |
718e3744 | 13329 | { |
bb46e94f | 13330 | struct peer *peer; |
db7c8528 | 13331 | u_char uj = use_json(argc, argv); |
bb46e94f | 13332 | |
db7c8528 | 13333 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 13334 | if (! peer) |
13335 | return CMD_WARNING; | |
13336 | ||
718e3744 | 13337 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 13338 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
db7c8528 | 13339 | bgp_show_type_neighbor, uj); |
718e3744 | 13340 | |
bb46e94f | 13341 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
db7c8528 | 13342 | bgp_show_type_neighbor, uj); |
718e3744 | 13343 | } |
bb46e94f | 13344 | |
2a3d5731 | 13345 | #ifdef HAVE_IPV6 |
8386ac43 | 13346 | DEFUN (show_bgp_instance_neighbor_routes, |
13347 | show_bgp_instance_neighbor_routes_cmd, | |
13348 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", | |
fee0f4c6 | 13349 | SHOW_STR |
fee0f4c6 | 13350 | BGP_STR |
8386ac43 | 13351 | BGP_INSTANCE_HELP_STR |
2a3d5731 DW |
13352 | "Detailed information on TCP and BGP neighbor connections\n" |
13353 | "Neighbor to display information about\n" | |
13354 | "Neighbor to display information about\n" | |
13355 | "Neighbor on bgp configured interface\n" | |
13356 | "Display routes learned from neighbor\n" | |
13357 | "JavaScript Object Notation\n") | |
fee0f4c6 | 13358 | { |
fee0f4c6 | 13359 | struct peer *peer; |
db7c8528 | 13360 | u_char uj = use_json(argc, argv); |
fee0f4c6 | 13361 | |
50ef26d4 | 13362 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); |
fee0f4c6 | 13363 | if (! peer) |
13364 | return CMD_WARNING; | |
13365 | ||
2a3d5731 | 13366 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
db7c8528 | 13367 | bgp_show_type_neighbor, uj); |
fee0f4c6 | 13368 | } |
13369 | ||
8386ac43 | 13370 | ALIAS (show_bgp_instance_neighbor_routes, |
13371 | show_bgp_instance_ipv6_neighbor_routes_cmd, | |
13372 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", | |
fee0f4c6 | 13373 | SHOW_STR |
fee0f4c6 | 13374 | BGP_STR |
8386ac43 | 13375 | BGP_INSTANCE_HELP_STR |
2a3d5731 DW |
13376 | "Address family\n" |
13377 | "Detailed information on TCP and BGP neighbor connections\n" | |
13378 | "Neighbor to display information about\n" | |
13379 | "Neighbor to display information about\n" | |
13380 | "Neighbor on bgp configured interface\n" | |
13381 | "Display routes learned from neighbor\n" | |
13382 | "JavaScript Object Notation\n") | |
fee0f4c6 | 13383 | |
8386ac43 | 13384 | DEFUN (show_bgp_instance_neighbor_damp, |
13385 | show_bgp_instance_neighbor_damp_cmd, | |
13386 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", | |
fee0f4c6 | 13387 | SHOW_STR |
fee0f4c6 | 13388 | BGP_STR |
8386ac43 | 13389 | BGP_INSTANCE_HELP_STR |
2a3d5731 DW |
13390 | "Detailed information on TCP and BGP neighbor connections\n" |
13391 | "Neighbor to display information about\n" | |
13392 | "Neighbor to display information about\n" | |
13393 | "Neighbor on bgp configured interface\n" | |
13394 | "Display the dampened routes received from neighbor\n" | |
13395 | "JavaScript Object Notation\n") | |
bb46e94f | 13396 | { |
13397 | struct peer *peer; | |
db7c8528 | 13398 | u_char uj = use_json(argc, argv); |
856ca177 | 13399 | |
6aeb9e78 DS |
13400 | if ((argc == 4 && argv[3] && strcmp(argv[3], "json") == 0) |
13401 | || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) | |
13402 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
bb46e94f | 13403 | else |
6aeb9e78 | 13404 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 13405 | |
13406 | if (! peer) | |
13407 | return CMD_WARNING; | |
13408 | ||
13409 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
db7c8528 | 13410 | bgp_show_type_damp_neighbor, uj); |
bb46e94f | 13411 | } |
13412 | ||
8386ac43 | 13413 | ALIAS (show_bgp_instance_neighbor_damp, |
13414 | show_bgp_instance_ipv6_neighbor_damp_cmd, | |
13415 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", | |
bb46e94f | 13416 | SHOW_STR |
13417 | BGP_STR | |
8386ac43 | 13418 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13419 | "Address family\n" |
13420 | "Detailed information on TCP and BGP neighbor connections\n" | |
13421 | "Neighbor to display information about\n" | |
13422 | "Neighbor to display information about\n" | |
a80beece | 13423 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13424 | "Display the dampened routes received from neighbor\n" |
13425 | "JavaScript Object Notation\n") | |
bb46e94f | 13426 | |
8386ac43 | 13427 | DEFUN (show_bgp_instance_neighbor_flap, |
13428 | show_bgp_instance_neighbor_flap_cmd, | |
13429 | "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", | |
bb46e94f | 13430 | SHOW_STR |
13431 | BGP_STR | |
8386ac43 | 13432 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13433 | "Detailed information on TCP and BGP neighbor connections\n" |
13434 | "Neighbor to display information about\n" | |
13435 | "Neighbor to display information about\n" | |
a80beece | 13436 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13437 | "Display flap statistics of the routes learned from neighbor\n" |
13438 | "JavaScript Object Notation\n") | |
bb46e94f | 13439 | { |
13440 | struct peer *peer; | |
db7c8528 | 13441 | u_char uj = use_json(argc, argv); |
856ca177 | 13442 | |
6aeb9e78 DS |
13443 | if ((argc == 4 && argv[3] && strcmp(argv[3], "json") == 0) |
13444 | || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) | |
13445 | peer = peer_lookup_in_view (vty, argv[1], argv[2], uj); | |
bb46e94f | 13446 | else |
6aeb9e78 | 13447 | peer = peer_lookup_in_view (vty, NULL, argv[1], uj); |
bb46e94f | 13448 | |
13449 | if (! peer) | |
13450 | return CMD_WARNING; | |
13451 | ||
13452 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
db7c8528 | 13453 | bgp_show_type_flap_neighbor, uj); |
bb46e94f | 13454 | } |
13455 | ||
8386ac43 | 13456 | ALIAS (show_bgp_instance_neighbor_flap, |
13457 | show_bgp_instance_ipv6_neighbor_flap_cmd, | |
13458 | "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", | |
bb46e94f | 13459 | SHOW_STR |
13460 | BGP_STR | |
8386ac43 | 13461 | BGP_INSTANCE_HELP_STR |
bb46e94f | 13462 | "Address family\n" |
13463 | "Detailed information on TCP and BGP neighbor connections\n" | |
13464 | "Neighbor to display information about\n" | |
13465 | "Neighbor to display information about\n" | |
a80beece | 13466 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13467 | "Display flap statistics of the routes learned from neighbor\n" |
13468 | "JavaScript Object Notation\n") | |
bb46e94f | 13469 | |
50ef26d4 | 13470 | DEFUN (show_bgp_neighbor_routes, |
bb46e94f | 13471 | show_bgp_neighbor_routes_cmd, |
856ca177 | 13472 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
bb46e94f | 13473 | SHOW_STR |
13474 | BGP_STR | |
13475 | "Detailed information on TCP and BGP neighbor connections\n" | |
13476 | "Neighbor to display information about\n" | |
13477 | "Neighbor to display information about\n" | |
a80beece | 13478 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13479 | "Display routes learned from neighbor\n" |
13480 | "JavaScript Object Notation\n") | |
50ef26d4 | 13481 | { |
13482 | struct peer *peer; | |
13483 | u_char uj = use_json(argc, argv); | |
bb46e94f | 13484 | |
50ef26d4 | 13485 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
13486 | if (! peer) | |
13487 | return CMD_WARNING; | |
bb46e94f | 13488 | |
50ef26d4 | 13489 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
13490 | bgp_show_type_neighbor, uj); | |
13491 | } | |
13492 | ||
13493 | ||
13494 | ALIAS (show_bgp_neighbor_routes, | |
718e3744 | 13495 | show_bgp_ipv6_neighbor_routes_cmd, |
856ca177 | 13496 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13497 | SHOW_STR |
13498 | BGP_STR | |
13499 | "Address family\n" | |
13500 | "Detailed information on TCP and BGP neighbor connections\n" | |
13501 | "Neighbor to display information about\n" | |
13502 | "Neighbor to display information about\n" | |
a80beece | 13503 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13504 | "Display routes learned from neighbor\n" |
13505 | "JavaScript Object Notation\n") | |
718e3744 | 13506 | |
13507 | /* old command */ | |
50ef26d4 | 13508 | ALIAS (show_bgp_neighbor_routes, |
718e3744 | 13509 | ipv6_bgp_neighbor_routes_cmd, |
856ca177 | 13510 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13511 | SHOW_STR |
13512 | IPV6_STR | |
13513 | BGP_STR | |
13514 | "Detailed information on TCP and BGP neighbor connections\n" | |
13515 | "Neighbor to display information about\n" | |
13516 | "Neighbor to display information about\n" | |
a80beece | 13517 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13518 | "Display routes learned from neighbor\n" |
13519 | "JavaScript Object Notation\n") | |
718e3744 | 13520 | |
13521 | /* old command */ | |
13522 | DEFUN (ipv6_mbgp_neighbor_routes, | |
13523 | ipv6_mbgp_neighbor_routes_cmd, | |
856ca177 | 13524 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", |
718e3744 | 13525 | SHOW_STR |
13526 | IPV6_STR | |
13527 | MBGP_STR | |
13528 | "Detailed information on TCP and BGP neighbor connections\n" | |
13529 | "Neighbor to display information about\n" | |
13530 | "Neighbor to display information about\n" | |
a80beece | 13531 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13532 | "Display routes learned from neighbor\n" |
13533 | "JavaScript Object Notation\n") | |
718e3744 | 13534 | { |
bb46e94f | 13535 | struct peer *peer; |
db7c8528 | 13536 | u_char uj = use_json(argc, argv); |
bb46e94f | 13537 | |
db7c8528 | 13538 | peer = peer_lookup_in_view (vty, NULL, argv[0], uj); |
bb46e94f | 13539 | if (! peer) |
13540 | return CMD_WARNING; | |
13541 | ||
47e9b292 | 13542 | bgp_show_ipv6_bgp_deprecate_warning(vty); |
bb46e94f | 13543 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
db7c8528 | 13544 | bgp_show_type_neighbor, uj); |
718e3744 | 13545 | } |
bb46e94f | 13546 | |
8386ac43 | 13547 | ALIAS (show_bgp_instance_neighbor_flap, |
bb46e94f | 13548 | show_bgp_neighbor_flap_cmd, |
856ca177 | 13549 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", |
bb46e94f | 13550 | SHOW_STR |
13551 | BGP_STR | |
13552 | "Detailed information on TCP and BGP neighbor connections\n" | |
13553 | "Neighbor to display information about\n" | |
13554 | "Neighbor to display information about\n" | |
a80beece | 13555 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13556 | "Display flap statistics of the routes learned from neighbor\n" |
13557 | "JavaScript Object Notation\n") | |
bb46e94f | 13558 | |
8386ac43 | 13559 | ALIAS (show_bgp_instance_neighbor_flap, |
bb46e94f | 13560 | show_bgp_ipv6_neighbor_flap_cmd, |
856ca177 | 13561 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}", |
bb46e94f | 13562 | SHOW_STR |
13563 | BGP_STR | |
13564 | "Address family\n" | |
13565 | "Detailed information on TCP and BGP neighbor connections\n" | |
13566 | "Neighbor to display information about\n" | |
13567 | "Neighbor to display information about\n" | |
a80beece | 13568 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13569 | "Display flap statistics of the routes learned from neighbor\n" |
13570 | "JavaScript Object Notation\n") | |
bb46e94f | 13571 | |
8386ac43 | 13572 | ALIAS (show_bgp_instance_neighbor_damp, |
bb46e94f | 13573 | show_bgp_neighbor_damp_cmd, |
856ca177 | 13574 | "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", |
bb46e94f | 13575 | SHOW_STR |
13576 | BGP_STR | |
13577 | "Detailed information on TCP and BGP neighbor connections\n" | |
13578 | "Neighbor to display information about\n" | |
13579 | "Neighbor to display information about\n" | |
a80beece | 13580 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13581 | "Display the dampened routes received from neighbor\n" |
13582 | "JavaScript Object Notation\n") | |
bb46e94f | 13583 | |
8386ac43 | 13584 | ALIAS (show_bgp_instance_neighbor_damp, |
bb46e94f | 13585 | show_bgp_ipv6_neighbor_damp_cmd, |
856ca177 | 13586 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}", |
bb46e94f | 13587 | SHOW_STR |
13588 | BGP_STR | |
13589 | "Address family\n" | |
13590 | "Detailed information on TCP and BGP neighbor connections\n" | |
13591 | "Neighbor to display information about\n" | |
13592 | "Neighbor to display information about\n" | |
a80beece | 13593 | "Neighbor on bgp configured interface\n" |
856ca177 MS |
13594 | "Display the dampened routes received from neighbor\n" |
13595 | "JavaScript Object Notation\n") | |
fee0f4c6 | 13596 | |
718e3744 | 13597 | #endif /* HAVE_IPV6 */ |
6b0655a2 | 13598 | |
718e3744 | 13599 | struct bgp_table *bgp_distance_table; |
13600 | ||
13601 | struct bgp_distance | |
13602 | { | |
13603 | /* Distance value for the IP source prefix. */ | |
13604 | u_char distance; | |
13605 | ||
13606 | /* Name of the access-list to be matched. */ | |
13607 | char *access_list; | |
13608 | }; | |
13609 | ||
94f2b392 | 13610 | static struct bgp_distance * |
66e5cd87 | 13611 | bgp_distance_new (void) |
718e3744 | 13612 | { |
393deb9b | 13613 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
718e3744 | 13614 | } |
13615 | ||
94f2b392 | 13616 | static void |
718e3744 | 13617 | bgp_distance_free (struct bgp_distance *bdistance) |
13618 | { | |
13619 | XFREE (MTYPE_BGP_DISTANCE, bdistance); | |
13620 | } | |
13621 | ||
94f2b392 | 13622 | static int |
fd79ac91 | 13623 | bgp_distance_set (struct vty *vty, const char *distance_str, |
13624 | const char *ip_str, const char *access_list_str) | |
718e3744 | 13625 | { |
13626 | int ret; | |
13627 | struct prefix_ipv4 p; | |
13628 | u_char distance; | |
13629 | struct bgp_node *rn; | |
13630 | struct bgp_distance *bdistance; | |
13631 | ||
13632 | ret = str2prefix_ipv4 (ip_str, &p); | |
13633 | if (ret == 0) | |
13634 | { | |
13635 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
13636 | return CMD_WARNING; | |
13637 | } | |
13638 | ||
13639 | distance = atoi (distance_str); | |
13640 | ||
13641 | /* Get BGP distance node. */ | |
13642 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); | |
13643 | if (rn->info) | |
13644 | { | |
13645 | bdistance = rn->info; | |
13646 | bgp_unlock_node (rn); | |
13647 | } | |
13648 | else | |
13649 | { | |
13650 | bdistance = bgp_distance_new (); | |
13651 | rn->info = bdistance; | |
13652 | } | |
13653 | ||
13654 | /* Set distance value. */ | |
13655 | bdistance->distance = distance; | |
13656 | ||
13657 | /* Reset access-list configuration. */ | |
13658 | if (bdistance->access_list) | |
13659 | { | |
6e919709 | 13660 | XFREE(MTYPE_AS_LIST, bdistance->access_list); |
718e3744 | 13661 | bdistance->access_list = NULL; |
13662 | } | |
13663 | if (access_list_str) | |
6e919709 | 13664 | bdistance->access_list = XSTRDUP(MTYPE_AS_LIST, access_list_str); |
718e3744 | 13665 | |
13666 | return CMD_SUCCESS; | |
13667 | } | |
13668 | ||
94f2b392 | 13669 | static int |
fd79ac91 | 13670 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
13671 | const char *ip_str, const char *access_list_str) | |
718e3744 | 13672 | { |
13673 | int ret; | |
1f9a9fff | 13674 | int distance; |
718e3744 | 13675 | struct prefix_ipv4 p; |
718e3744 | 13676 | struct bgp_node *rn; |
13677 | struct bgp_distance *bdistance; | |
13678 | ||
13679 | ret = str2prefix_ipv4 (ip_str, &p); | |
13680 | if (ret == 0) | |
13681 | { | |
13682 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
13683 | return CMD_WARNING; | |
13684 | } | |
13685 | ||
718e3744 | 13686 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
13687 | if (! rn) | |
13688 | { | |
13689 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); | |
13690 | return CMD_WARNING; | |
13691 | } | |
13692 | ||
13693 | bdistance = rn->info; | |
1f9a9fff PJ |
13694 | distance = atoi(distance_str); |
13695 | ||
13696 | if (bdistance->distance != distance) | |
13697 | { | |
13698 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); | |
13699 | return CMD_WARNING; | |
13700 | } | |
718e3744 | 13701 | |
13702 | if (bdistance->access_list) | |
6e919709 | 13703 | XFREE(MTYPE_AS_LIST, bdistance->access_list); |
718e3744 | 13704 | bgp_distance_free (bdistance); |
13705 | ||
13706 | rn->info = NULL; | |
13707 | bgp_unlock_node (rn); | |
13708 | bgp_unlock_node (rn); | |
13709 | ||
13710 | return CMD_SUCCESS; | |
13711 | } | |
13712 | ||
718e3744 | 13713 | /* Apply BGP information to distance method. */ |
13714 | u_char | |
13715 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) | |
13716 | { | |
13717 | struct bgp_node *rn; | |
13718 | struct prefix_ipv4 q; | |
13719 | struct peer *peer; | |
13720 | struct bgp_distance *bdistance; | |
13721 | struct access_list *alist; | |
13722 | struct bgp_static *bgp_static; | |
13723 | ||
13724 | if (! bgp) | |
13725 | return 0; | |
13726 | ||
13727 | if (p->family != AF_INET) | |
13728 | return 0; | |
13729 | ||
13730 | peer = rinfo->peer; | |
13731 | ||
13732 | if (peer->su.sa.sa_family != AF_INET) | |
13733 | return 0; | |
13734 | ||
13735 | memset (&q, 0, sizeof (struct prefix_ipv4)); | |
13736 | q.family = AF_INET; | |
13737 | q.prefix = peer->su.sin.sin_addr; | |
13738 | q.prefixlen = IPV4_MAX_BITLEN; | |
13739 | ||
13740 | /* Check source address. */ | |
13741 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); | |
13742 | if (rn) | |
13743 | { | |
13744 | bdistance = rn->info; | |
13745 | bgp_unlock_node (rn); | |
13746 | ||
13747 | if (bdistance->access_list) | |
13748 | { | |
13749 | alist = access_list_lookup (AFI_IP, bdistance->access_list); | |
13750 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) | |
13751 | return bdistance->distance; | |
13752 | } | |
13753 | else | |
13754 | return bdistance->distance; | |
13755 | } | |
13756 | ||
13757 | /* Backdoor check. */ | |
13758 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); | |
13759 | if (rn) | |
13760 | { | |
13761 | bgp_static = rn->info; | |
13762 | bgp_unlock_node (rn); | |
13763 | ||
13764 | if (bgp_static->backdoor) | |
13765 | { | |
13766 | if (bgp->distance_local) | |
13767 | return bgp->distance_local; | |
13768 | else | |
13769 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
13770 | } | |
13771 | } | |
13772 | ||
6d85b15b | 13773 | if (peer->sort == BGP_PEER_EBGP) |
718e3744 | 13774 | { |
13775 | if (bgp->distance_ebgp) | |
13776 | return bgp->distance_ebgp; | |
13777 | return ZEBRA_EBGP_DISTANCE_DEFAULT; | |
13778 | } | |
13779 | else | |
13780 | { | |
13781 | if (bgp->distance_ibgp) | |
13782 | return bgp->distance_ibgp; | |
13783 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
13784 | } | |
13785 | } | |
13786 | ||
13787 | DEFUN (bgp_distance, | |
13788 | bgp_distance_cmd, | |
13789 | "distance bgp <1-255> <1-255> <1-255>", | |
13790 | "Define an administrative distance\n" | |
13791 | "BGP distance\n" | |
13792 | "Distance for routes external to the AS\n" | |
13793 | "Distance for routes internal to the AS\n" | |
13794 | "Distance for local routes\n") | |
13795 | { | |
13796 | struct bgp *bgp; | |
13797 | ||
13798 | bgp = vty->index; | |
13799 | ||
13800 | bgp->distance_ebgp = atoi (argv[0]); | |
13801 | bgp->distance_ibgp = atoi (argv[1]); | |
13802 | bgp->distance_local = atoi (argv[2]); | |
13803 | return CMD_SUCCESS; | |
13804 | } | |
13805 | ||
13806 | DEFUN (no_bgp_distance, | |
13807 | no_bgp_distance_cmd, | |
13808 | "no distance bgp <1-255> <1-255> <1-255>", | |
13809 | NO_STR | |
13810 | "Define an administrative distance\n" | |
13811 | "BGP distance\n" | |
13812 | "Distance for routes external to the AS\n" | |
13813 | "Distance for routes internal to the AS\n" | |
13814 | "Distance for local routes\n") | |
13815 | { | |
13816 | struct bgp *bgp; | |
13817 | ||
13818 | bgp = vty->index; | |
13819 | ||
13820 | bgp->distance_ebgp= 0; | |
13821 | bgp->distance_ibgp = 0; | |
13822 | bgp->distance_local = 0; | |
13823 | return CMD_SUCCESS; | |
13824 | } | |
13825 | ||
13826 | ALIAS (no_bgp_distance, | |
13827 | no_bgp_distance2_cmd, | |
13828 | "no distance bgp", | |
13829 | NO_STR | |
13830 | "Define an administrative distance\n" | |
13831 | "BGP distance\n") | |
13832 | ||
13833 | DEFUN (bgp_distance_source, | |
13834 | bgp_distance_source_cmd, | |
13835 | "distance <1-255> A.B.C.D/M", | |
13836 | "Define an administrative distance\n" | |
13837 | "Administrative distance\n" | |
13838 | "IP source prefix\n") | |
13839 | { | |
13840 | bgp_distance_set (vty, argv[0], argv[1], NULL); | |
13841 | return CMD_SUCCESS; | |
13842 | } | |
13843 | ||
13844 | DEFUN (no_bgp_distance_source, | |
13845 | no_bgp_distance_source_cmd, | |
13846 | "no distance <1-255> A.B.C.D/M", | |
13847 | NO_STR | |
13848 | "Define an administrative distance\n" | |
13849 | "Administrative distance\n" | |
13850 | "IP source prefix\n") | |
13851 | { | |
13852 | bgp_distance_unset (vty, argv[0], argv[1], NULL); | |
13853 | return CMD_SUCCESS; | |
13854 | } | |
13855 | ||
13856 | DEFUN (bgp_distance_source_access_list, | |
13857 | bgp_distance_source_access_list_cmd, | |
13858 | "distance <1-255> A.B.C.D/M WORD", | |
13859 | "Define an administrative distance\n" | |
13860 | "Administrative distance\n" | |
13861 | "IP source prefix\n" | |
13862 | "Access list name\n") | |
13863 | { | |
13864 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); | |
13865 | return CMD_SUCCESS; | |
13866 | } | |
13867 | ||
13868 | DEFUN (no_bgp_distance_source_access_list, | |
13869 | no_bgp_distance_source_access_list_cmd, | |
13870 | "no distance <1-255> A.B.C.D/M WORD", | |
13871 | NO_STR | |
13872 | "Define an administrative distance\n" | |
13873 | "Administrative distance\n" | |
13874 | "IP source prefix\n" | |
13875 | "Access list name\n") | |
13876 | { | |
13877 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); | |
13878 | return CMD_SUCCESS; | |
13879 | } | |
6b0655a2 | 13880 | |
718e3744 | 13881 | DEFUN (bgp_damp_set, |
13882 | bgp_damp_set_cmd, | |
13883 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
13884 | "BGP Specific commands\n" | |
13885 | "Enable route-flap dampening\n" | |
13886 | "Half-life time for the penalty\n" | |
13887 | "Value to start reusing a route\n" | |
13888 | "Value to start suppressing a route\n" | |
13889 | "Maximum duration to suppress a stable route\n") | |
13890 | { | |
13891 | struct bgp *bgp; | |
13892 | int half = DEFAULT_HALF_LIFE * 60; | |
13893 | int reuse = DEFAULT_REUSE; | |
13894 | int suppress = DEFAULT_SUPPRESS; | |
13895 | int max = 4 * half; | |
13896 | ||
13897 | if (argc == 4) | |
13898 | { | |
13899 | half = atoi (argv[0]) * 60; | |
13900 | reuse = atoi (argv[1]); | |
13901 | suppress = atoi (argv[2]); | |
13902 | max = atoi (argv[3]) * 60; | |
13903 | } | |
13904 | else if (argc == 1) | |
13905 | { | |
13906 | half = atoi (argv[0]) * 60; | |
13907 | max = 4 * half; | |
13908 | } | |
13909 | ||
13910 | bgp = vty->index; | |
7ebe9748 B |
13911 | |
13912 | if (suppress < reuse) | |
13913 | { | |
13914 | vty_out (vty, "Suppress value cannot be less than reuse value %s", | |
13915 | VTY_NEWLINE); | |
13916 | return 0; | |
13917 | } | |
13918 | ||
718e3744 | 13919 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
13920 | half, reuse, suppress, max); | |
13921 | } | |
13922 | ||
13923 | ALIAS (bgp_damp_set, | |
13924 | bgp_damp_set2_cmd, | |
13925 | "bgp dampening <1-45>", | |
13926 | "BGP Specific commands\n" | |
13927 | "Enable route-flap dampening\n" | |
13928 | "Half-life time for the penalty\n") | |
13929 | ||
13930 | ALIAS (bgp_damp_set, | |
13931 | bgp_damp_set3_cmd, | |
13932 | "bgp dampening", | |
13933 | "BGP Specific commands\n" | |
13934 | "Enable route-flap dampening\n") | |
13935 | ||
13936 | DEFUN (bgp_damp_unset, | |
13937 | bgp_damp_unset_cmd, | |
13938 | "no bgp dampening", | |
13939 | NO_STR | |
13940 | "BGP Specific commands\n" | |
13941 | "Enable route-flap dampening\n") | |
13942 | { | |
13943 | struct bgp *bgp; | |
13944 | ||
13945 | bgp = vty->index; | |
13946 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); | |
13947 | } | |
13948 | ||
13949 | ALIAS (bgp_damp_unset, | |
13950 | bgp_damp_unset2_cmd, | |
13951 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
13952 | NO_STR | |
13953 | "BGP Specific commands\n" | |
13954 | "Enable route-flap dampening\n" | |
13955 | "Half-life time for the penalty\n" | |
13956 | "Value to start reusing a route\n" | |
13957 | "Value to start suppressing a route\n" | |
13958 | "Maximum duration to suppress a stable route\n") | |
13959 | ||
813d4307 DW |
13960 | ALIAS (bgp_damp_unset, |
13961 | bgp_damp_unset3_cmd, | |
13962 | "no bgp dampening <1-45>", | |
13963 | NO_STR | |
13964 | "BGP Specific commands\n" | |
13965 | "Enable route-flap dampening\n" | |
13966 | "Half-life time for the penalty\n") | |
13967 | ||
718e3744 | 13968 | DEFUN (show_ip_bgp_dampened_paths, |
13969 | show_ip_bgp_dampened_paths_cmd, | |
13970 | "show ip bgp dampened-paths", | |
13971 | SHOW_STR | |
13972 | IP_STR | |
13973 | BGP_STR | |
13974 | "Display paths suppressed due to dampening\n") | |
13975 | { | |
5a646650 | 13976 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
b05a1c8b | 13977 | NULL, 0); |
718e3744 | 13978 | } |
13979 | ||
81304aaf B |
13980 | ALIAS (show_ip_bgp_dampened_paths, |
13981 | show_ip_bgp_damp_dampened_paths_cmd, | |
13982 | "show ip bgp dampening dampened-paths", | |
13983 | SHOW_STR | |
13984 | IP_STR | |
13985 | BGP_STR | |
13986 | "Display detailed information about dampening\n" | |
13987 | "Display paths suppressed due to dampening\n") | |
13988 | ||
718e3744 | 13989 | DEFUN (show_ip_bgp_flap_statistics, |
13990 | show_ip_bgp_flap_statistics_cmd, | |
13991 | "show ip bgp flap-statistics", | |
13992 | SHOW_STR | |
13993 | IP_STR | |
13994 | BGP_STR | |
13995 | "Display flap statistics of routes\n") | |
13996 | { | |
5a646650 | 13997 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
b05a1c8b | 13998 | bgp_show_type_flap_statistics, NULL, 0); |
718e3744 | 13999 | } |
6b0655a2 | 14000 | |
81304aaf B |
14001 | ALIAS (show_ip_bgp_flap_statistics, |
14002 | show_ip_bgp_damp_flap_statistics_cmd, | |
14003 | "show ip bgp dampening flap-statistics", | |
14004 | SHOW_STR | |
14005 | IP_STR | |
14006 | BGP_STR | |
14007 | "Display detailed information about dampening\n" | |
14008 | "Display flap statistics of routes\n") | |
14009 | ||
718e3744 | 14010 | /* Display specified route of BGP table. */ |
94f2b392 | 14011 | static int |
fd79ac91 | 14012 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
14013 | const char *ip_str, afi_t afi, safi_t safi, | |
14014 | struct prefix_rd *prd, int prefix_check) | |
718e3744 | 14015 | { |
14016 | int ret; | |
14017 | struct prefix match; | |
14018 | struct bgp_node *rn; | |
14019 | struct bgp_node *rm; | |
14020 | struct bgp_info *ri; | |
14021 | struct bgp_info *ri_temp; | |
14022 | struct bgp *bgp; | |
14023 | struct bgp_table *table; | |
14024 | ||
14025 | /* BGP structure lookup. */ | |
14026 | if (view_name) | |
14027 | { | |
14028 | bgp = bgp_lookup_by_name (view_name); | |
14029 | if (bgp == NULL) | |
14030 | { | |
6aeb9e78 | 14031 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
718e3744 | 14032 | return CMD_WARNING; |
14033 | } | |
14034 | } | |
14035 | else | |
14036 | { | |
14037 | bgp = bgp_get_default (); | |
14038 | if (bgp == NULL) | |
14039 | { | |
14040 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
14041 | return CMD_WARNING; | |
14042 | } | |
14043 | } | |
14044 | ||
14045 | /* Check IP address argument. */ | |
14046 | ret = str2prefix (ip_str, &match); | |
14047 | if (! ret) | |
14048 | { | |
14049 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
14050 | return CMD_WARNING; | |
14051 | } | |
14052 | ||
14053 | match.family = afi2family (afi); | |
14054 | ||
587ff0fd | 14055 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
718e3744 | 14056 | { |
587ff0fd | 14057 | for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn)) |
718e3744 | 14058 | { |
14059 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
14060 | continue; | |
14061 | ||
14062 | if ((table = rn->info) != NULL) | |
14063 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6c88b44d CC |
14064 | { |
14065 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) | |
14066 | { | |
14067 | ri = rm->info; | |
14068 | while (ri) | |
14069 | { | |
14070 | if (ri->extra && ri->extra->damp_info) | |
14071 | { | |
14072 | ri_temp = ri->next; | |
14073 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
14074 | ri = ri_temp; | |
14075 | } | |
14076 | else | |
14077 | ri = ri->next; | |
14078 | } | |
14079 | } | |
14080 | ||
14081 | bgp_unlock_node (rm); | |
14082 | } | |
718e3744 | 14083 | } |
14084 | } | |
14085 | else | |
14086 | { | |
14087 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) | |
6c88b44d CC |
14088 | { |
14089 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
14090 | { | |
14091 | ri = rn->info; | |
14092 | while (ri) | |
14093 | { | |
14094 | if (ri->extra && ri->extra->damp_info) | |
14095 | { | |
14096 | ri_temp = ri->next; | |
14097 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
14098 | ri = ri_temp; | |
14099 | } | |
14100 | else | |
14101 | ri = ri->next; | |
14102 | } | |
14103 | } | |
14104 | ||
14105 | bgp_unlock_node (rn); | |
14106 | } | |
718e3744 | 14107 | } |
14108 | ||
14109 | return CMD_SUCCESS; | |
14110 | } | |
14111 | ||
14112 | DEFUN (clear_ip_bgp_dampening, | |
14113 | clear_ip_bgp_dampening_cmd, | |
14114 | "clear ip bgp dampening", | |
14115 | CLEAR_STR | |
14116 | IP_STR | |
14117 | BGP_STR | |
14118 | "Clear route flap dampening information\n") | |
14119 | { | |
14120 | bgp_damp_info_clean (); | |
14121 | return CMD_SUCCESS; | |
14122 | } | |
14123 | ||
14124 | DEFUN (clear_ip_bgp_dampening_prefix, | |
14125 | clear_ip_bgp_dampening_prefix_cmd, | |
14126 | "clear ip bgp dampening A.B.C.D/M", | |
14127 | CLEAR_STR | |
14128 | IP_STR | |
14129 | BGP_STR | |
14130 | "Clear route flap dampening information\n" | |
14131 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
14132 | { | |
14133 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
14134 | SAFI_UNICAST, NULL, 1); | |
14135 | } | |
14136 | ||
14137 | DEFUN (clear_ip_bgp_dampening_address, | |
14138 | clear_ip_bgp_dampening_address_cmd, | |
14139 | "clear ip bgp dampening A.B.C.D", | |
14140 | CLEAR_STR | |
14141 | IP_STR | |
14142 | BGP_STR | |
14143 | "Clear route flap dampening information\n" | |
14144 | "Network to clear damping information\n") | |
14145 | { | |
14146 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
14147 | SAFI_UNICAST, NULL, 0); | |
14148 | } | |
14149 | ||
14150 | DEFUN (clear_ip_bgp_dampening_address_mask, | |
14151 | clear_ip_bgp_dampening_address_mask_cmd, | |
14152 | "clear ip bgp dampening A.B.C.D A.B.C.D", | |
14153 | CLEAR_STR | |
14154 | IP_STR | |
14155 | BGP_STR | |
14156 | "Clear route flap dampening information\n" | |
14157 | "Network to clear damping information\n" | |
14158 | "Network mask\n") | |
14159 | { | |
14160 | int ret; | |
14161 | char prefix_str[BUFSIZ]; | |
14162 | ||
14163 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
14164 | if (! ret) | |
14165 | { | |
14166 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
14167 | return CMD_WARNING; | |
14168 | } | |
14169 | ||
14170 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, | |
14171 | SAFI_UNICAST, NULL, 0); | |
14172 | } | |
6b0655a2 | 14173 | |
587ff0fd | 14174 | /* also used for encap safi */ |
94f2b392 | 14175 | static int |
718e3744 | 14176 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
14177 | afi_t afi, safi_t safi, int *write) | |
14178 | { | |
14179 | struct bgp_node *prn; | |
14180 | struct bgp_node *rn; | |
14181 | struct bgp_table *table; | |
14182 | struct prefix *p; | |
14183 | struct prefix_rd *prd; | |
14184 | struct bgp_static *bgp_static; | |
14185 | u_int32_t label; | |
14186 | char buf[SU_ADDRSTRLEN]; | |
14187 | char rdbuf[RD_ADDRSTRLEN]; | |
14188 | ||
14189 | /* Network configuration. */ | |
14190 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) | |
14191 | if ((table = prn->info) != NULL) | |
14192 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
14193 | if ((bgp_static = rn->info) != NULL) | |
14194 | { | |
14195 | p = &rn->p; | |
14196 | prd = (struct prefix_rd *) &prn->p; | |
14197 | ||
14198 | /* "address-family" display. */ | |
14199 | bgp_config_write_family_header (vty, afi, safi, write); | |
14200 | ||
14201 | /* "network" configuration display. */ | |
14202 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); | |
14203 | label = decode_label (bgp_static->tag); | |
14204 | ||
0b960b4d | 14205 | vty_out (vty, " network %s/%d rd %s tag %d", |
718e3744 | 14206 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
14207 | p->prefixlen, | |
14208 | rdbuf, label); | |
14209 | vty_out (vty, "%s", VTY_NEWLINE); | |
14210 | } | |
14211 | return 0; | |
14212 | } | |
14213 | ||
14214 | /* Configuration of static route announcement and aggregate | |
14215 | information. */ | |
14216 | int | |
14217 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, | |
14218 | afi_t afi, safi_t safi, int *write) | |
14219 | { | |
14220 | struct bgp_node *rn; | |
14221 | struct prefix *p; | |
14222 | struct bgp_static *bgp_static; | |
14223 | struct bgp_aggregate *bgp_aggregate; | |
14224 | char buf[SU_ADDRSTRLEN]; | |
14225 | ||
587ff0fd | 14226 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
718e3744 | 14227 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
14228 | ||
14229 | /* Network configuration. */ | |
14230 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
14231 | if ((bgp_static = rn->info) != NULL) | |
14232 | { | |
14233 | p = &rn->p; | |
14234 | ||
14235 | /* "address-family" display. */ | |
14236 | bgp_config_write_family_header (vty, afi, safi, write); | |
14237 | ||
14238 | /* "network" configuration display. */ | |
14239 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
14240 | { | |
14241 | u_int32_t destination; | |
14242 | struct in_addr netmask; | |
14243 | ||
14244 | destination = ntohl (p->u.prefix4.s_addr); | |
14245 | masklen2ip (p->prefixlen, &netmask); | |
0b960b4d | 14246 | vty_out (vty, " network %s", |
718e3744 | 14247 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
14248 | ||
14249 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
14250 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
14251 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
14252 | || p->u.prefix4.s_addr == 0) | |
14253 | { | |
14254 | /* Natural mask is not display. */ | |
14255 | } | |
14256 | else | |
14257 | vty_out (vty, " mask %s", inet_ntoa (netmask)); | |
14258 | } | |
14259 | else | |
14260 | { | |
0b960b4d | 14261 | vty_out (vty, " network %s/%d", |
718e3744 | 14262 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
14263 | p->prefixlen); | |
14264 | } | |
14265 | ||
14266 | if (bgp_static->rmap.name) | |
14267 | vty_out (vty, " route-map %s", bgp_static->rmap.name); | |
41367172 PJ |
14268 | else |
14269 | { | |
14270 | if (bgp_static->backdoor) | |
14271 | vty_out (vty, " backdoor"); | |
41367172 | 14272 | } |
718e3744 | 14273 | |
14274 | vty_out (vty, "%s", VTY_NEWLINE); | |
14275 | } | |
14276 | ||
14277 | /* Aggregate-address configuration. */ | |
14278 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) | |
14279 | if ((bgp_aggregate = rn->info) != NULL) | |
14280 | { | |
14281 | p = &rn->p; | |
14282 | ||
14283 | /* "address-family" display. */ | |
14284 | bgp_config_write_family_header (vty, afi, safi, write); | |
14285 | ||
14286 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
14287 | { | |
14288 | struct in_addr netmask; | |
14289 | ||
14290 | masklen2ip (p->prefixlen, &netmask); | |
0b960b4d | 14291 | vty_out (vty, " aggregate-address %s %s", |
718e3744 | 14292 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
14293 | inet_ntoa (netmask)); | |
14294 | } | |
14295 | else | |
14296 | { | |
0b960b4d | 14297 | vty_out (vty, " aggregate-address %s/%d", |
718e3744 | 14298 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
14299 | p->prefixlen); | |
14300 | } | |
14301 | ||
14302 | if (bgp_aggregate->as_set) | |
14303 | vty_out (vty, " as-set"); | |
14304 | ||
14305 | if (bgp_aggregate->summary_only) | |
14306 | vty_out (vty, " summary-only"); | |
14307 | ||
14308 | vty_out (vty, "%s", VTY_NEWLINE); | |
14309 | } | |
14310 | ||
14311 | return 0; | |
14312 | } | |
14313 | ||
14314 | int | |
14315 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) | |
14316 | { | |
14317 | struct bgp_node *rn; | |
14318 | struct bgp_distance *bdistance; | |
14319 | ||
14320 | /* Distance configuration. */ | |
14321 | if (bgp->distance_ebgp | |
14322 | && bgp->distance_ibgp | |
14323 | && bgp->distance_local | |
14324 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT | |
14325 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT | |
14326 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) | |
14327 | vty_out (vty, " distance bgp %d %d %d%s", | |
14328 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, | |
14329 | VTY_NEWLINE); | |
14330 | ||
14331 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) | |
14332 | if ((bdistance = rn->info) != NULL) | |
14333 | { | |
14334 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, | |
14335 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
14336 | bdistance->access_list ? bdistance->access_list : "", | |
14337 | VTY_NEWLINE); | |
14338 | } | |
14339 | ||
14340 | return 0; | |
14341 | } | |
14342 | ||
14343 | /* Allocate routing table structure and install commands. */ | |
14344 | void | |
66e5cd87 | 14345 | bgp_route_init (void) |
718e3744 | 14346 | { |
14347 | /* Init BGP distance table. */ | |
64e580a7 | 14348 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
718e3744 | 14349 | |
14350 | /* IPv4 BGP commands. */ | |
73ac8160 | 14351 | install_element (BGP_NODE, &bgp_table_map_cmd); |
718e3744 | 14352 | install_element (BGP_NODE, &bgp_network_cmd); |
14353 | install_element (BGP_NODE, &bgp_network_mask_cmd); | |
14354 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); | |
14355 | install_element (BGP_NODE, &bgp_network_route_map_cmd); | |
14356 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); | |
14357 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); | |
14358 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); | |
14359 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); | |
14360 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); | |
73ac8160 | 14361 | install_element (BGP_NODE, &no_bgp_table_map_cmd); |
718e3744 | 14362 | install_element (BGP_NODE, &no_bgp_network_cmd); |
14363 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); | |
14364 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); | |
14365 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); | |
14366 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); | |
14367 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
14368 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); | |
14369 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); | |
14370 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); | |
14371 | ||
14372 | install_element (BGP_NODE, &aggregate_address_cmd); | |
14373 | install_element (BGP_NODE, &aggregate_address_mask_cmd); | |
14374 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); | |
14375 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); | |
14376 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); | |
14377 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); | |
14378 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); | |
14379 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
14380 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); | |
14381 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
14382 | install_element (BGP_NODE, &no_aggregate_address_cmd); | |
14383 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); | |
14384 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); | |
14385 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); | |
14386 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); | |
14387 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); | |
14388 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
14389 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); | |
14390 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
14391 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
14392 | ||
14393 | /* IPv4 unicast configuration. */ | |
73ac8160 | 14394 | install_element (BGP_IPV4_NODE, &bgp_table_map_cmd); |
718e3744 | 14395 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
14396 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); | |
14397 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); | |
14398 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); | |
14399 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); | |
14400 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); | |
73ac8160 | 14401 | install_element (BGP_IPV4_NODE, &no_bgp_table_map_cmd); |
c8f3fe30 | 14402 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
718e3744 | 14403 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
14404 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); | |
14405 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); | |
14406 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); | |
14407 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
c8f3fe30 | 14408 | |
718e3744 | 14409 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
14410 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); | |
14411 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); | |
14412 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); | |
14413 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); | |
14414 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); | |
14415 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); | |
14416 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
14417 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); | |
14418 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
14419 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); | |
14420 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); | |
14421 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); | |
14422 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); | |
14423 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); | |
14424 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); | |
14425 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
14426 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); | |
14427 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
14428 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
14429 | ||
14430 | /* IPv4 multicast configuration. */ | |
73ac8160 | 14431 | install_element (BGP_IPV4M_NODE, &bgp_table_map_cmd); |
718e3744 | 14432 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
14433 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); | |
14434 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); | |
14435 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); | |
14436 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); | |
14437 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); | |
73ac8160 | 14438 | install_element (BGP_IPV4M_NODE, &no_bgp_table_map_cmd); |
718e3744 | 14439 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
14440 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); | |
14441 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); | |
14442 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); | |
14443 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); | |
14444 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
14445 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); | |
14446 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); | |
14447 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); | |
14448 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); | |
14449 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); | |
14450 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); | |
14451 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); | |
14452 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
14453 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); | |
14454 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
14455 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); | |
14456 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); | |
14457 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); | |
14458 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); | |
14459 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); | |
14460 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); | |
14461 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
14462 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); | |
14463 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
14464 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
14465 | ||
14466 | install_element (VIEW_NODE, &show_ip_bgp_cmd); | |
8386ac43 | 14467 | install_element (VIEW_NODE, &show_ip_bgp_instance_cmd); |
f186de26 | 14468 | install_element (VIEW_NODE, &show_ip_bgp_instance_all_cmd); |
718e3744 | 14469 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
95cbbd2a | 14470 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 14471 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
8386ac43 | 14472 | install_element (VIEW_NODE, &show_ip_bgp_instance_route_cmd); |
4092b06c | 14473 | install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); |
8386ac43 | 14474 | install_element (VIEW_NODE, &show_ip_bgp_instance_route_pathtype_cmd); |
4092b06c | 14475 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
718e3744 | 14476 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
95cbbd2a | 14477 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 14478 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
14479 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
14480 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); | |
8386ac43 | 14481 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_cmd); |
718e3744 | 14482 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
4092b06c DS |
14483 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
14484 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); | |
95cbbd2a | 14485 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
4092b06c | 14486 | install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
8386ac43 | 14487 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); |
718e3744 | 14488 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
14489 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
50ef26d4 | 14490 | |
718e3744 | 14491 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
14492 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
14493 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); | |
8386ac43 | 14494 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_list_cmd); |
718e3744 | 14495 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
14496 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); | |
8386ac43 | 14497 | install_element (VIEW_NODE, &show_ip_bgp_instance_filter_list_cmd); |
718e3744 | 14498 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
14499 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); | |
8386ac43 | 14500 | install_element (VIEW_NODE, &show_ip_bgp_instance_route_map_cmd); |
718e3744 | 14501 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
14502 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); | |
14503 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
14504 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); | |
14505 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
14506 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); | |
14507 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); | |
14508 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); | |
14509 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); | |
14510 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); | |
14511 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
14512 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
14513 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
8386ac43 | 14514 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_all_cmd); |
14515 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_cmd); | |
14516 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community2_cmd); | |
14517 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community3_cmd); | |
14518 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community4_cmd); | |
718e3744 | 14519 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
14520 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); | |
14521 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); | |
14522 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); | |
14523 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
14524 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
14525 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
14526 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
14527 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); | |
8386ac43 | 14528 | install_element (VIEW_NODE, &show_ip_bgp_instance_community_list_cmd); |
718e3744 | 14529 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
14530 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); | |
14531 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
14532 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); | |
8386ac43 | 14533 | install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_longer_cmd); |
718e3744 | 14534 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
14535 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
8386ac43 | 14536 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); |
0b16f239 | 14537 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_rmap_cmd); |
8386ac43 | 14538 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14539 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
0b16f239 | 14540 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14541 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
8386ac43 | 14542 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd); |
0b16f239 | 14543 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14544 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd); |
718e3744 | 14545 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
0b16f239 | 14546 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14547 | install_element (VIEW_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 14548 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
8386ac43 | 14549 | install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_routes_cmd); |
718e3744 | 14550 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
14551 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
14552 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
81304aaf | 14553 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
58a90275 | 14554 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
718e3744 | 14555 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
58a90275 B |
14556 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); |
14557 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); | |
81304aaf | 14558 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
718e3744 | 14559 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
81304aaf | 14560 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
718e3744 | 14561 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
81304aaf | 14562 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
718e3744 | 14563 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
14564 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
81304aaf | 14565 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
718e3744 | 14566 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
14567 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
81304aaf | 14568 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
718e3744 | 14569 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
81304aaf | 14570 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
718e3744 | 14571 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
81304aaf | 14572 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
718e3744 | 14573 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
81304aaf | 14574 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
718e3744 | 14575 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
14576 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
62687ff1 PJ |
14577 | |
14578 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ | |
14579 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); | |
8386ac43 | 14580 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd); |
4092b06c | 14581 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd); |
8386ac43 | 14582 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_pathtype_cmd); |
4092b06c | 14583 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
62687ff1 | 14584 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
95cbbd2a | 14585 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
62687ff1 PJ |
14586 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
14587 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); | |
8386ac43 | 14588 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd); |
62687ff1 | 14589 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
4092b06c DS |
14590 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
14591 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); | |
95cbbd2a | 14592 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
4092b06c | 14593 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
8386ac43 | 14594 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); |
62687ff1 PJ |
14595 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
14596 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
8386ac43 | 14597 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd); |
14598 | install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd); | |
62687ff1 PJ |
14599 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
14600 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); | |
14601 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); | |
14602 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); | |
14603 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); | |
14604 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
14605 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
14606 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
8386ac43 | 14607 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_all_cmd); |
14608 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_cmd); | |
14609 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community2_cmd); | |
14610 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community3_cmd); | |
14611 | install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community4_cmd); | |
62687ff1 PJ |
14612 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
14613 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); | |
14614 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); | |
14615 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); | |
14616 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
14617 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
14618 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
14619 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
718e3744 | 14620 | |
14621 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); | |
8386ac43 | 14622 | install_element (ENABLE_NODE, &show_ip_bgp_instance_cmd); |
f186de26 | 14623 | install_element (ENABLE_NODE, &show_ip_bgp_instance_all_cmd); |
718e3744 | 14624 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
95cbbd2a | 14625 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 14626 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
8386ac43 | 14627 | install_element (ENABLE_NODE, &show_ip_bgp_instance_route_cmd); |
4092b06c | 14628 | install_element (ENABLE_NODE, &show_ip_bgp_route_pathtype_cmd); |
8386ac43 | 14629 | install_element (ENABLE_NODE, &show_ip_bgp_instance_route_pathtype_cmd); |
4092b06c | 14630 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
718e3744 | 14631 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
95cbbd2a | 14632 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 14633 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
14634 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
14635 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); | |
8386ac43 | 14636 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_cmd); |
718e3744 | 14637 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
4092b06c DS |
14638 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
14639 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); | |
95cbbd2a | 14640 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
4092b06c | 14641 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
8386ac43 | 14642 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); |
718e3744 | 14643 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
14644 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
50ef26d4 | 14645 | |
718e3744 | 14646 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
14647 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
14648 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); | |
8386ac43 | 14649 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_list_cmd); |
718e3744 | 14650 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
14651 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); | |
8386ac43 | 14652 | install_element (ENABLE_NODE, &show_ip_bgp_instance_filter_list_cmd); |
718e3744 | 14653 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
14654 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); | |
8386ac43 | 14655 | install_element (ENABLE_NODE, &show_ip_bgp_instance_route_map_cmd); |
718e3744 | 14656 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
14657 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); | |
14658 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
14659 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); | |
14660 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
14661 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); | |
14662 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); | |
14663 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); | |
14664 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); | |
14665 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); | |
14666 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
14667 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
14668 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
8386ac43 | 14669 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_all_cmd); |
14670 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_cmd); | |
14671 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community2_cmd); | |
14672 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community3_cmd); | |
14673 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community4_cmd); | |
718e3744 | 14674 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
14675 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); | |
14676 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); | |
14677 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); | |
14678 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
14679 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
14680 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
14681 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
14682 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); | |
8386ac43 | 14683 | install_element (ENABLE_NODE, &show_ip_bgp_instance_community_list_cmd); |
718e3744 | 14684 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
14685 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); | |
14686 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
14687 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); | |
8386ac43 | 14688 | install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_longer_cmd); |
718e3744 | 14689 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
14690 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
8386ac43 | 14691 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); |
0b16f239 | 14692 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_rmap_cmd); |
8386ac43 | 14693 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14694 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
0b16f239 | 14695 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd); |
718e3744 | 14696 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
8386ac43 | 14697 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd); |
0b16f239 | 14698 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14699 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd); |
718e3744 | 14700 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
0b16f239 | 14701 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd); |
8386ac43 | 14702 | install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 14703 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
8386ac43 | 14704 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_routes_cmd); |
718e3744 | 14705 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
14706 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
14707 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
81304aaf | 14708 | install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd); |
718e3744 | 14709 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
58a90275 B |
14710 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
14711 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); | |
14712 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); | |
81304aaf | 14713 | install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
718e3744 | 14714 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
81304aaf | 14715 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
718e3744 | 14716 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
81304aaf | 14717 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd); |
718e3744 | 14718 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
14719 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
81304aaf | 14720 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
718e3744 | 14721 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
81304aaf | 14722 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd); |
718e3744 | 14723 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
81304aaf | 14724 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
718e3744 | 14725 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
81304aaf B |
14726 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
14727 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); | |
718e3744 | 14728 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
81304aaf | 14729 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
718e3744 | 14730 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
81304aaf | 14731 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
718e3744 | 14732 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
14733 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
14734 | ||
14735 | /* BGP dampening clear commands */ | |
14736 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); | |
14737 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); | |
14738 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); | |
14739 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); | |
14740 | ||
ff7924f6 PJ |
14741 | /* prefix count */ |
14742 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); | |
8386ac43 | 14743 | install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_prefix_counts_cmd); |
ff7924f6 PJ |
14744 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
14745 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); | |
718e3744 | 14746 | #ifdef HAVE_IPV6 |
ff7924f6 | 14747 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
8386ac43 | 14748 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd); |
ff7924f6 | 14749 | |
718e3744 | 14750 | /* New config IPv6 BGP commands. */ |
73ac8160 | 14751 | install_element (BGP_IPV6_NODE, &bgp_table_map_cmd); |
718e3744 | 14752 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
14753 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); | |
73ac8160 | 14754 | install_element (BGP_IPV6_NODE, &no_bgp_table_map_cmd); |
718e3744 | 14755 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
14756 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); | |
14757 | ||
14758 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); | |
14759 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); | |
14760 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); | |
14761 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); | |
73bfe0bd B |
14762 | |
14763 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); | |
14764 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); | |
718e3744 | 14765 | |
14766 | /* Old config IPv6 BGP commands. */ | |
14767 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); | |
14768 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); | |
14769 | ||
14770 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); | |
14771 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); | |
14772 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); | |
14773 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); | |
14774 | ||
14775 | install_element (VIEW_NODE, &show_bgp_cmd); | |
14776 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 14777 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 14778 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
14779 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 14780 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
4092b06c DS |
14781 | install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd); |
14782 | install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd); | |
14783 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); | |
718e3744 | 14784 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
14785 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 14786 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
4092b06c DS |
14787 | install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd); |
14788 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); | |
14789 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); | |
718e3744 | 14790 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
14791 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); | |
14792 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); | |
14793 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
14794 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); | |
14795 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); | |
14796 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); | |
14797 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); | |
14798 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); | |
14799 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); | |
14800 | install_element (VIEW_NODE, &show_bgp_community_cmd); | |
14801 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); | |
14802 | install_element (VIEW_NODE, &show_bgp_community2_cmd); | |
14803 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); | |
14804 | install_element (VIEW_NODE, &show_bgp_community3_cmd); | |
14805 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); | |
14806 | install_element (VIEW_NODE, &show_bgp_community4_cmd); | |
14807 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); | |
14808 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); | |
14809 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); | |
14810 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); | |
14811 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
14812 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); | |
14813 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
14814 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); | |
14815 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
14816 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); | |
14817 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); | |
14818 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); | |
14819 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
14820 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); | |
14821 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
14822 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
14823 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
14824 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); | |
14825 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
14826 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); | |
14827 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
14828 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
14829 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 14830 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
14831 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
14832 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); | |
14833 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
8386ac43 | 14834 | install_element (VIEW_NODE, &show_bgp_instance_cmd); |
f186de26 | 14835 | install_element (VIEW_NODE, &show_bgp_instance_all_cmd); |
8386ac43 | 14836 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_cmd); |
14837 | install_element (VIEW_NODE, &show_bgp_instance_route_cmd); | |
14838 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_cmd); | |
14839 | install_element (VIEW_NODE, &show_bgp_instance_route_pathtype_cmd); | |
14840 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); | |
14841 | install_element (VIEW_NODE, &show_bgp_instance_prefix_cmd); | |
14842 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_cmd); | |
14843 | install_element (VIEW_NODE, &show_bgp_instance_prefix_pathtype_cmd); | |
14844 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_pathtype_cmd); | |
14845 | install_element (VIEW_NODE, &show_bgp_instance_prefix_list_cmd); | |
14846 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_list_cmd); | |
14847 | install_element (VIEW_NODE, &show_bgp_instance_filter_list_cmd); | |
14848 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_filter_list_cmd); | |
14849 | install_element (VIEW_NODE, &show_bgp_instance_route_map_cmd); | |
14850 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_route_map_cmd); | |
14851 | install_element (VIEW_NODE, &show_bgp_instance_community_list_cmd); | |
14852 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_community_list_cmd); | |
14853 | install_element (VIEW_NODE, &show_bgp_instance_prefix_longer_cmd); | |
14854 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_prefix_longer_cmd); | |
14855 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_advertised_route_cmd); | |
14856 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd); | |
14857 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_routes_cmd); | |
14858 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_received_routes_cmd); | |
14859 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_routes_cmd); | |
14860 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_routes_cmd); | |
14861 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); | |
14862 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); | |
14863 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_flap_cmd); | |
14864 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_flap_cmd); | |
14865 | install_element (VIEW_NODE, &show_bgp_instance_neighbor_damp_cmd); | |
14866 | install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_damp_cmd); | |
62687ff1 PJ |
14867 | |
14868 | /* Restricted: | |
14869 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) | |
14870 | */ | |
14871 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); | |
14872 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 14873 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
4092b06c DS |
14874 | install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd); |
14875 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd); | |
14876 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); | |
62687ff1 PJ |
14877 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
14878 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 14879 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
4092b06c DS |
14880 | install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd); |
14881 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); | |
14882 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); | |
62687ff1 PJ |
14883 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
14884 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); | |
14885 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); | |
14886 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); | |
14887 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); | |
14888 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); | |
14889 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); | |
14890 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); | |
14891 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); | |
14892 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); | |
14893 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); | |
14894 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
14895 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); | |
14896 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
14897 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); | |
14898 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
8386ac43 | 14899 | install_element (RESTRICTED_NODE, &show_bgp_instance_route_cmd); |
14900 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_route_cmd); | |
14901 | install_element (RESTRICTED_NODE, &show_bgp_instance_route_pathtype_cmd); | |
14902 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); | |
14903 | install_element (RESTRICTED_NODE, &show_bgp_instance_prefix_cmd); | |
14904 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_prefix_cmd); | |
14905 | install_element (RESTRICTED_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); | |
14906 | install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); | |
718e3744 | 14907 | |
14908 | install_element (ENABLE_NODE, &show_bgp_cmd); | |
14909 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 14910 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 14911 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
14912 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 14913 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
4092b06c DS |
14914 | install_element (ENABLE_NODE, &show_bgp_route_pathtype_cmd); |
14915 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_pathtype_cmd); | |
14916 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); | |
718e3744 | 14917 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
4092b06c DS |
14918 | install_element (ENABLE_NODE, &show_bgp_prefix_pathtype_cmd); |
14919 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); | |
14920 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); | |
718e3744 | 14921 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
95cbbd2a | 14922 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
718e3744 | 14923 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
14924 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); | |
14925 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); | |
14926 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
14927 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); | |
14928 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); | |
14929 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); | |
14930 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); | |
14931 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); | |
14932 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); | |
14933 | install_element (ENABLE_NODE, &show_bgp_community_cmd); | |
14934 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); | |
14935 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); | |
14936 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); | |
14937 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); | |
14938 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); | |
14939 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); | |
14940 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); | |
14941 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); | |
14942 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); | |
14943 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); | |
14944 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
14945 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); | |
14946 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
14947 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); | |
14948 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
14949 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); | |
14950 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); | |
14951 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); | |
14952 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
14953 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); | |
14954 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
14955 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
14956 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
14957 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); | |
14958 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
14959 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); | |
14960 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
14961 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
14962 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 14963 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
14964 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
14965 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); | |
14966 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
8386ac43 | 14967 | install_element (ENABLE_NODE, &show_bgp_instance_cmd); |
f186de26 | 14968 | install_element (ENABLE_NODE, &show_bgp_instance_all_cmd); |
8386ac43 | 14969 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_cmd); |
14970 | install_element (ENABLE_NODE, &show_bgp_instance_route_cmd); | |
14971 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_cmd); | |
14972 | install_element (ENABLE_NODE, &show_bgp_instance_route_pathtype_cmd); | |
14973 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd); | |
14974 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_cmd); | |
14975 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_cmd); | |
14976 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_pathtype_cmd); | |
14977 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_pathtype_cmd); | |
14978 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_list_cmd); | |
14979 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_list_cmd); | |
14980 | install_element (ENABLE_NODE, &show_bgp_instance_filter_list_cmd); | |
14981 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_filter_list_cmd); | |
14982 | install_element (ENABLE_NODE, &show_bgp_instance_route_map_cmd); | |
14983 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_map_cmd); | |
14984 | install_element (ENABLE_NODE, &show_bgp_instance_community_list_cmd); | |
14985 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_community_list_cmd); | |
14986 | install_element (ENABLE_NODE, &show_bgp_instance_prefix_longer_cmd); | |
14987 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_longer_cmd); | |
14988 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_advertised_route_cmd); | |
14989 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd); | |
14990 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_routes_cmd); | |
14991 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_received_routes_cmd); | |
14992 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_routes_cmd); | |
14993 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_routes_cmd); | |
14994 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); | |
14995 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd); | |
14996 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_flap_cmd); | |
14997 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_flap_cmd); | |
14998 | install_element (ENABLE_NODE, &show_bgp_instance_neighbor_damp_cmd); | |
14999 | install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_damp_cmd); | |
50ef26d4 | 15000 | |
2815e61f PJ |
15001 | /* Statistics */ |
15002 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); | |
587ff0fd | 15003 | //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
2815e61f | 15004 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
587ff0fd | 15005 | //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
2815e61f | 15006 | |
718e3744 | 15007 | /* old command */ |
15008 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); | |
15009 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); | |
15010 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); | |
15011 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); | |
15012 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
15013 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); | |
15014 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); | |
15015 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); | |
15016 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); | |
15017 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); | |
15018 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); | |
15019 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); | |
15020 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
15021 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
15022 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
15023 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); | |
15024 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
15025 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
15026 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); | |
15027 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); | |
15028 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); | |
15029 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); | |
15030 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
15031 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
15032 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); | |
15033 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); | |
15034 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); | |
15035 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); | |
15036 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); | |
15037 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
15038 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
15039 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
15040 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
15041 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); | |
15042 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
15043 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
bb46e94f | 15044 | |
718e3744 | 15045 | /* old command */ |
15046 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); | |
15047 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); | |
15048 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); | |
15049 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); | |
15050 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
15051 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); | |
15052 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); | |
15053 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); | |
15054 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); | |
15055 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); | |
15056 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); | |
15057 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); | |
15058 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
15059 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
15060 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
15061 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); | |
15062 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
15063 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
15064 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); | |
15065 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); | |
15066 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); | |
15067 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); | |
15068 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
15069 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
15070 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); | |
15071 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); | |
15072 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); | |
15073 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); | |
15074 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); | |
15075 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
15076 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
15077 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
15078 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
15079 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); | |
15080 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
15081 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
15082 | ||
15083 | /* old command */ | |
15084 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
15085 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
15086 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
15087 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
15088 | ||
15089 | /* old command */ | |
15090 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
15091 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
15092 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
15093 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
15094 | ||
15095 | /* old command */ | |
15096 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
15097 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
15098 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
15099 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
15100 | #endif /* HAVE_IPV6 */ | |
15101 | ||
15102 | install_element (BGP_NODE, &bgp_distance_cmd); | |
15103 | install_element (BGP_NODE, &no_bgp_distance_cmd); | |
15104 | install_element (BGP_NODE, &no_bgp_distance2_cmd); | |
15105 | install_element (BGP_NODE, &bgp_distance_source_cmd); | |
15106 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); | |
15107 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); | |
15108 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); | |
15109 | ||
15110 | install_element (BGP_NODE, &bgp_damp_set_cmd); | |
15111 | install_element (BGP_NODE, &bgp_damp_set2_cmd); | |
15112 | install_element (BGP_NODE, &bgp_damp_set3_cmd); | |
15113 | install_element (BGP_NODE, &bgp_damp_unset_cmd); | |
15114 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); | |
813d4307 | 15115 | install_element (BGP_NODE, &bgp_damp_unset3_cmd); |
718e3744 | 15116 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
15117 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); | |
15118 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); | |
15119 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); | |
15120 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); | |
813d4307 | 15121 | install_element (BGP_IPV4_NODE, &bgp_damp_unset3_cmd); |
5c9e5a8d B |
15122 | |
15123 | /* IPv4 Multicast Mode */ | |
15124 | install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd); | |
15125 | install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd); | |
15126 | install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd); | |
15127 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd); | |
15128 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd); | |
718e3744 | 15129 | } |
228da428 CC |
15130 | |
15131 | void | |
15132 | bgp_route_finish (void) | |
15133 | { | |
15134 | bgp_table_unlock (bgp_distance_table); | |
15135 | bgp_distance_table = NULL; | |
15136 | } |