]>
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 | ||
23 | #include "prefix.h" | |
24 | #include "linklist.h" | |
25 | #include "memory.h" | |
26 | #include "command.h" | |
27 | #include "stream.h" | |
28 | #include "filter.h" | |
29 | #include "str.h" | |
30 | #include "log.h" | |
31 | #include "routemap.h" | |
32 | #include "buffer.h" | |
33 | #include "sockunion.h" | |
34 | #include "plist.h" | |
35 | #include "thread.h" | |
200df115 | 36 | #include "workqueue.h" |
718e3744 | 37 | |
38 | #include "bgpd/bgpd.h" | |
39 | #include "bgpd/bgp_table.h" | |
40 | #include "bgpd/bgp_route.h" | |
41 | #include "bgpd/bgp_attr.h" | |
42 | #include "bgpd/bgp_debug.h" | |
43 | #include "bgpd/bgp_aspath.h" | |
44 | #include "bgpd/bgp_regex.h" | |
45 | #include "bgpd/bgp_community.h" | |
46 | #include "bgpd/bgp_ecommunity.h" | |
47 | #include "bgpd/bgp_clist.h" | |
48 | #include "bgpd/bgp_packet.h" | |
49 | #include "bgpd/bgp_filter.h" | |
50 | #include "bgpd/bgp_fsm.h" | |
51 | #include "bgpd/bgp_mplsvpn.h" | |
52 | #include "bgpd/bgp_nexthop.h" | |
53 | #include "bgpd/bgp_damp.h" | |
54 | #include "bgpd/bgp_advertise.h" | |
55 | #include "bgpd/bgp_zebra.h" | |
0a486e5f | 56 | #include "bgpd/bgp_vty.h" |
96450faf | 57 | #include "bgpd/bgp_mpath.h" |
718e3744 | 58 | |
59 | /* Extern from bgp_dump.c */ | |
dde72586 SH |
60 | extern const char *bgp_origin_str[]; |
61 | extern const char *bgp_origin_long_str[]; | |
718e3744 | 62 | \f |
94f2b392 | 63 | static struct bgp_node * |
fee0f4c6 | 64 | bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, |
718e3744 | 65 | struct prefix_rd *prd) |
66 | { | |
67 | struct bgp_node *rn; | |
68 | struct bgp_node *prn = NULL; | |
da5b30f6 PJ |
69 | |
70 | assert (table); | |
71 | if (!table) | |
72 | return NULL; | |
73 | ||
718e3744 | 74 | if (safi == SAFI_MPLS_VPN) |
75 | { | |
fee0f4c6 | 76 | prn = bgp_node_get (table, (struct prefix *) prd); |
718e3744 | 77 | |
78 | if (prn->info == NULL) | |
64e580a7 | 79 | prn->info = bgp_table_init (afi, safi); |
718e3744 | 80 | else |
81 | bgp_unlock_node (prn); | |
82 | table = prn->info; | |
83 | } | |
718e3744 | 84 | |
85 | rn = bgp_node_get (table, p); | |
86 | ||
87 | if (safi == SAFI_MPLS_VPN) | |
88 | rn->prn = prn; | |
89 | ||
90 | return rn; | |
91 | } | |
92 | \f | |
fb982c25 PJ |
93 | /* Allocate bgp_info_extra */ |
94 | static struct bgp_info_extra * | |
95 | bgp_info_extra_new (void) | |
96 | { | |
97 | struct bgp_info_extra *new; | |
98 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); | |
99 | return new; | |
100 | } | |
101 | ||
102 | static void | |
103 | bgp_info_extra_free (struct bgp_info_extra **extra) | |
104 | { | |
105 | if (extra && *extra) | |
106 | { | |
107 | if ((*extra)->damp_info) | |
108 | bgp_damp_info_free ((*extra)->damp_info, 0); | |
109 | ||
110 | (*extra)->damp_info = NULL; | |
111 | ||
112 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); | |
113 | ||
114 | *extra = NULL; | |
115 | } | |
116 | } | |
117 | ||
118 | /* Get bgp_info extra information for the given bgp_info, lazy allocated | |
119 | * if required. | |
120 | */ | |
121 | struct bgp_info_extra * | |
122 | bgp_info_extra_get (struct bgp_info *ri) | |
123 | { | |
124 | if (!ri->extra) | |
125 | ri->extra = bgp_info_extra_new(); | |
126 | return ri->extra; | |
127 | } | |
128 | ||
718e3744 | 129 | /* Allocate new bgp info structure. */ |
200df115 | 130 | static struct bgp_info * |
66e5cd87 | 131 | bgp_info_new (void) |
718e3744 | 132 | { |
393deb9b | 133 | return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
718e3744 | 134 | } |
135 | ||
136 | /* Free bgp route information. */ | |
200df115 | 137 | static void |
718e3744 | 138 | bgp_info_free (struct bgp_info *binfo) |
139 | { | |
140 | if (binfo->attr) | |
141 | bgp_attr_unintern (binfo->attr); | |
fb982c25 PJ |
142 | |
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 | { | |
6f58544d PJ |
243 | assert (rn && rn->table); |
244 | assert (ri && ri->peer && ri->peer->bgp); | |
245 | ||
1a392d46 PJ |
246 | /* Ignore 'pcount' for RS-client tables */ |
247 | if (rn->table->type != BGP_TABLE_MAIN | |
248 | || ri->peer == ri->peer->bgp->peer_self) | |
249 | return; | |
250 | ||
251 | if (BGP_INFO_HOLDDOWN (ri) | |
252 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
253 | { | |
254 | ||
255 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
256 | ||
257 | /* slight hack, but more robust against errors. */ | |
258 | if (ri->peer->pcount[rn->table->afi][rn->table->safi]) | |
259 | ri->peer->pcount[rn->table->afi][rn->table->safi]--; | |
260 | else | |
261 | { | |
262 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", | |
263 | __func__, ri->peer->host); | |
264 | zlog_backtrace (LOG_WARNING); | |
265 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); | |
266 | } | |
267 | } | |
268 | else if (!BGP_INFO_HOLDDOWN (ri) | |
269 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
270 | { | |
271 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
272 | ri->peer->pcount[rn->table->afi][rn->table->safi]++; | |
273 | } | |
274 | } | |
275 | ||
276 | ||
277 | /* Set/unset bgp_info flags, adjusting any other state as needed. | |
278 | * This is here primarily to keep prefix-count in check. | |
279 | */ | |
280 | void | |
281 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
282 | { | |
283 | SET_FLAG (ri->flags, flag); | |
284 | ||
285 | /* early bath if we know it's not a flag that changes useability state */ | |
286 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) | |
287 | return; | |
288 | ||
289 | bgp_pcount_adjust (rn, ri); | |
290 | } | |
291 | ||
292 | void | |
293 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
294 | { | |
295 | UNSET_FLAG (ri->flags, flag); | |
296 | ||
297 | /* early bath if we know it's not a flag that changes useability state */ | |
298 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) | |
299 | return; | |
300 | ||
301 | bgp_pcount_adjust (rn, ri); | |
302 | } | |
303 | ||
718e3744 | 304 | /* Get MED value. If MED value is missing and "bgp bestpath |
305 | missing-as-worst" is specified, treat it as the worst value. */ | |
94f2b392 | 306 | static u_int32_t |
718e3744 | 307 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
308 | { | |
309 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
310 | return attr->med; | |
311 | else | |
312 | { | |
313 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
3b424979 | 314 | return BGP_MED_MAX; |
718e3744 | 315 | else |
316 | return 0; | |
317 | } | |
318 | } | |
319 | ||
320 | /* Compare two bgp route entity. br is preferable then return 1. */ | |
94f2b392 | 321 | static int |
96450faf JB |
322 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
323 | int *paths_eq) | |
718e3744 | 324 | { |
325 | u_int32_t new_pref; | |
326 | u_int32_t exist_pref; | |
327 | u_int32_t new_med; | |
328 | u_int32_t exist_med; | |
fb982c25 PJ |
329 | u_int32_t new_weight = 0; |
330 | u_int32_t exist_weight = 0; | |
718e3744 | 331 | struct in_addr new_id; |
332 | struct in_addr exist_id; | |
333 | int new_cluster; | |
334 | int exist_cluster; | |
335 | int internal_as_route = 0; | |
336 | int confed_as_route = 0; | |
337 | int ret; | |
96450faf JB |
338 | uint32_t newm, existm; |
339 | ||
340 | *paths_eq = 0; | |
718e3744 | 341 | |
342 | /* 0. Null check. */ | |
343 | if (new == NULL) | |
344 | return 0; | |
345 | if (exist == NULL) | |
346 | return 1; | |
347 | ||
348 | /* 1. Weight check. */ | |
fb982c25 PJ |
349 | if (new->attr->extra) |
350 | new_weight = new->attr->extra->weight; | |
351 | if (exist->attr->extra) | |
352 | exist_weight = exist->attr->extra->weight; | |
353 | if (new_weight > exist_weight) | |
718e3744 | 354 | return 1; |
fb982c25 | 355 | if (new_weight < exist_weight) |
718e3744 | 356 | return 0; |
357 | ||
358 | /* 2. Local preference check. */ | |
359 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
360 | new_pref = new->attr->local_pref; | |
361 | else | |
362 | new_pref = bgp->default_local_pref; | |
363 | ||
364 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
365 | exist_pref = exist->attr->local_pref; | |
366 | else | |
367 | exist_pref = bgp->default_local_pref; | |
368 | ||
369 | if (new_pref > exist_pref) | |
370 | return 1; | |
371 | if (new_pref < exist_pref) | |
372 | return 0; | |
373 | ||
374 | /* 3. Local route check. */ | |
375 | if (new->sub_type == BGP_ROUTE_STATIC) | |
376 | return 1; | |
377 | if (exist->sub_type == BGP_ROUTE_STATIC) | |
378 | return 0; | |
379 | ||
380 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
381 | return 1; | |
382 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
383 | return 0; | |
384 | ||
385 | if (new->sub_type == BGP_ROUTE_AGGREGATE) | |
386 | return 1; | |
387 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) | |
388 | return 0; | |
389 | ||
390 | /* 4. AS path length check. */ | |
391 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) | |
392 | { | |
fe69a505 | 393 | int exist_hops = aspath_count_hops (exist->attr->aspath); |
394 | int exist_confeds = aspath_count_confeds (exist->attr->aspath); | |
395 | ||
6811845b | 396 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
397 | { | |
fe69a505 | 398 | int aspath_hops; |
399 | ||
400 | aspath_hops = aspath_count_hops (new->attr->aspath); | |
401 | aspath_hops += aspath_count_confeds (new->attr->aspath); | |
402 | ||
403 | if ( aspath_hops < (exist_hops + exist_confeds)) | |
6811845b | 404 | return 1; |
fe69a505 | 405 | if ( aspath_hops > (exist_hops + exist_confeds)) |
6811845b | 406 | return 0; |
407 | } | |
408 | else | |
409 | { | |
fe69a505 | 410 | int newhops = aspath_count_hops (new->attr->aspath); |
411 | ||
412 | if (newhops < exist_hops) | |
6811845b | 413 | return 1; |
fe69a505 | 414 | if (newhops > exist_hops) |
6811845b | 415 | return 0; |
416 | } | |
718e3744 | 417 | } |
418 | ||
419 | /* 5. Origin check. */ | |
420 | if (new->attr->origin < exist->attr->origin) | |
421 | return 1; | |
422 | if (new->attr->origin > exist->attr->origin) | |
423 | return 0; | |
424 | ||
425 | /* 6. MED check. */ | |
fe69a505 | 426 | internal_as_route = (aspath_count_hops (new->attr->aspath) == 0 |
427 | && aspath_count_hops (exist->attr->aspath) == 0); | |
428 | confed_as_route = (aspath_count_confeds (new->attr->aspath) > 0 | |
429 | && aspath_count_confeds (exist->attr->aspath) > 0 | |
430 | && aspath_count_hops (new->attr->aspath) == 0 | |
431 | && aspath_count_hops (exist->attr->aspath) == 0); | |
718e3744 | 432 | |
433 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) | |
434 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) | |
435 | && confed_as_route) | |
436 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) | |
437 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) | |
438 | || internal_as_route) | |
439 | { | |
440 | new_med = bgp_med_value (new->attr, bgp); | |
441 | exist_med = bgp_med_value (exist->attr, bgp); | |
442 | ||
443 | if (new_med < exist_med) | |
444 | return 1; | |
445 | if (new_med > exist_med) | |
446 | return 0; | |
447 | } | |
448 | ||
449 | /* 7. Peer type check. */ | |
450 | if (peer_sort (new->peer) == BGP_PEER_EBGP | |
451 | && peer_sort (exist->peer) == BGP_PEER_IBGP) | |
452 | return 1; | |
453 | if (peer_sort (new->peer) == BGP_PEER_EBGP | |
454 | && peer_sort (exist->peer) == BGP_PEER_CONFED) | |
455 | return 1; | |
456 | if (peer_sort (new->peer) == BGP_PEER_IBGP | |
457 | && peer_sort (exist->peer) == BGP_PEER_EBGP) | |
458 | return 0; | |
459 | if (peer_sort (new->peer) == BGP_PEER_CONFED | |
460 | && peer_sort (exist->peer) == BGP_PEER_EBGP) | |
461 | return 0; | |
462 | ||
463 | /* 8. IGP metric check. */ | |
96450faf JB |
464 | newm = (new->extra ? new->extra->igpmetric : 0); |
465 | existm = (exist->extra ? exist->extra->igpmetric : 0); | |
466 | if (newm < existm) | |
467 | ret = 1; | |
468 | if (newm > existm) | |
469 | ret = 0; | |
718e3744 | 470 | |
471 | /* 9. Maximum path check. */ | |
96450faf JB |
472 | if (newm == existm) |
473 | { | |
474 | if ((peer_sort (new->peer) == BGP_PEER_IBGP)) | |
475 | { | |
476 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) | |
477 | *paths_eq = 1; | |
478 | } | |
479 | else if (new->peer->as == exist->peer->as) | |
480 | *paths_eq = 1; | |
481 | } | |
482 | else | |
483 | { | |
484 | /* | |
485 | * TODO: If unequal cost ibgp multipath is enabled we can | |
486 | * mark the paths as equal here instead of returning | |
487 | */ | |
488 | return ret; | |
489 | } | |
718e3744 | 490 | |
491 | /* 10. If both paths are external, prefer the path that was received | |
492 | first (the oldest one). This step minimizes route-flap, since a | |
493 | newer path won't displace an older one, even if it was the | |
494 | preferred route based on the additional decision criteria below. */ | |
495 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) | |
496 | && peer_sort (new->peer) == BGP_PEER_EBGP | |
497 | && peer_sort (exist->peer) == BGP_PEER_EBGP) | |
498 | { | |
499 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) | |
500 | return 1; | |
501 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) | |
502 | return 0; | |
503 | } | |
504 | ||
505 | /* 11. Rourter-ID comparision. */ | |
506 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) | |
fb982c25 | 507 | new_id.s_addr = new->attr->extra->originator_id.s_addr; |
718e3744 | 508 | else |
509 | new_id.s_addr = new->peer->remote_id.s_addr; | |
510 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) | |
fb982c25 | 511 | exist_id.s_addr = exist->attr->extra->originator_id.s_addr; |
718e3744 | 512 | else |
513 | exist_id.s_addr = exist->peer->remote_id.s_addr; | |
514 | ||
515 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) | |
516 | return 1; | |
517 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) | |
518 | return 0; | |
519 | ||
520 | /* 12. Cluster length comparision. */ | |
521 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
fb982c25 | 522 | new_cluster = new->attr->extra->cluster->length; |
718e3744 | 523 | else |
524 | new_cluster = 0; | |
525 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
fb982c25 | 526 | exist_cluster = exist->attr->extra->cluster->length; |
718e3744 | 527 | else |
528 | exist_cluster = 0; | |
529 | ||
530 | if (new_cluster < exist_cluster) | |
531 | return 1; | |
532 | if (new_cluster > exist_cluster) | |
533 | return 0; | |
534 | ||
535 | /* 13. Neighbor address comparision. */ | |
536 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); | |
537 | ||
538 | if (ret == 1) | |
539 | return 0; | |
540 | if (ret == -1) | |
541 | return 1; | |
542 | ||
543 | return 1; | |
544 | } | |
545 | ||
94f2b392 | 546 | static enum filter_type |
718e3744 | 547 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
548 | afi_t afi, safi_t safi) | |
549 | { | |
550 | struct bgp_filter *filter; | |
551 | ||
552 | filter = &peer->filter[afi][safi]; | |
553 | ||
650f76c2 PJ |
554 | #define FILTER_EXIST_WARN(F,f,filter) \ |
555 | if (BGP_DEBUG (update, UPDATE_IN) \ | |
556 | && !(F ## _IN (filter))) \ | |
557 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ | |
558 | peer->host, #f, F ## _IN_NAME(filter)); | |
559 | ||
560 | if (DISTRIBUTE_IN_NAME (filter)) { | |
561 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
562 | ||
718e3744 | 563 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
564 | return FILTER_DENY; | |
650f76c2 | 565 | } |
718e3744 | 566 | |
650f76c2 PJ |
567 | if (PREFIX_LIST_IN_NAME (filter)) { |
568 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
569 | ||
718e3744 | 570 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
571 | return FILTER_DENY; | |
650f76c2 | 572 | } |
718e3744 | 573 | |
650f76c2 PJ |
574 | if (FILTER_LIST_IN_NAME (filter)) { |
575 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
576 | ||
718e3744 | 577 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
578 | return FILTER_DENY; | |
650f76c2 PJ |
579 | } |
580 | ||
718e3744 | 581 | return FILTER_PERMIT; |
650f76c2 | 582 | #undef FILTER_EXIST_WARN |
718e3744 | 583 | } |
584 | ||
94f2b392 | 585 | static enum filter_type |
718e3744 | 586 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
587 | afi_t afi, safi_t safi) | |
588 | { | |
589 | struct bgp_filter *filter; | |
590 | ||
591 | filter = &peer->filter[afi][safi]; | |
592 | ||
650f76c2 PJ |
593 | #define FILTER_EXIST_WARN(F,f,filter) \ |
594 | if (BGP_DEBUG (update, UPDATE_OUT) \ | |
595 | && !(F ## _OUT (filter))) \ | |
596 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ | |
597 | peer->host, #f, F ## _OUT_NAME(filter)); | |
598 | ||
599 | if (DISTRIBUTE_OUT_NAME (filter)) { | |
600 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
601 | ||
718e3744 | 602 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
603 | return FILTER_DENY; | |
650f76c2 | 604 | } |
718e3744 | 605 | |
650f76c2 PJ |
606 | if (PREFIX_LIST_OUT_NAME (filter)) { |
607 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
608 | ||
718e3744 | 609 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
610 | return FILTER_DENY; | |
650f76c2 | 611 | } |
718e3744 | 612 | |
650f76c2 PJ |
613 | if (FILTER_LIST_OUT_NAME (filter)) { |
614 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
615 | ||
718e3744 | 616 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
617 | return FILTER_DENY; | |
650f76c2 | 618 | } |
718e3744 | 619 | |
620 | return FILTER_PERMIT; | |
650f76c2 | 621 | #undef FILTER_EXIST_WARN |
718e3744 | 622 | } |
623 | ||
624 | /* If community attribute includes no_export then return 1. */ | |
94f2b392 | 625 | static int |
718e3744 | 626 | bgp_community_filter (struct peer *peer, struct attr *attr) |
627 | { | |
628 | if (attr->community) | |
629 | { | |
630 | /* NO_ADVERTISE check. */ | |
631 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) | |
632 | return 1; | |
633 | ||
634 | /* NO_EXPORT check. */ | |
635 | if (peer_sort (peer) == BGP_PEER_EBGP && | |
636 | community_include (attr->community, COMMUNITY_NO_EXPORT)) | |
637 | return 1; | |
638 | ||
639 | /* NO_EXPORT_SUBCONFED check. */ | |
640 | if (peer_sort (peer) == BGP_PEER_EBGP | |
641 | || peer_sort (peer) == BGP_PEER_CONFED) | |
642 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) | |
643 | return 1; | |
644 | } | |
645 | return 0; | |
646 | } | |
647 | ||
648 | /* Route reflection loop check. */ | |
649 | static int | |
650 | bgp_cluster_filter (struct peer *peer, struct attr *attr) | |
651 | { | |
652 | struct in_addr cluster_id; | |
653 | ||
fb982c25 | 654 | if (attr->extra && attr->extra->cluster) |
718e3744 | 655 | { |
656 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) | |
657 | cluster_id = peer->bgp->cluster_id; | |
658 | else | |
659 | cluster_id = peer->bgp->router_id; | |
660 | ||
fb982c25 | 661 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
718e3744 | 662 | return 1; |
663 | } | |
664 | return 0; | |
665 | } | |
666 | \f | |
94f2b392 | 667 | static int |
718e3744 | 668 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
669 | afi_t afi, safi_t safi) | |
670 | { | |
671 | struct bgp_filter *filter; | |
672 | struct bgp_info info; | |
673 | route_map_result_t ret; | |
674 | ||
675 | filter = &peer->filter[afi][safi]; | |
676 | ||
677 | /* Apply default weight value. */ | |
fb982c25 PJ |
678 | if (peer->weight) |
679 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
718e3744 | 680 | |
681 | /* Route map apply. */ | |
682 | if (ROUTE_MAP_IN_NAME (filter)) | |
683 | { | |
684 | /* Duplicate current value to new strucutre for modification. */ | |
685 | info.peer = peer; | |
686 | info.attr = attr; | |
687 | ||
ac41b2a2 | 688 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
689 | ||
718e3744 | 690 | /* Apply BGP route map to the attribute. */ |
691 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); | |
ac41b2a2 | 692 | |
693 | peer->rmap_type = 0; | |
694 | ||
718e3744 | 695 | if (ret == RMAP_DENYMATCH) |
696 | { | |
697 | /* Free newly generated AS path and community by route-map. */ | |
698 | bgp_attr_flush (attr); | |
699 | return RMAP_DENY; | |
700 | } | |
701 | } | |
702 | return RMAP_PERMIT; | |
703 | } | |
704 | \f | |
94f2b392 | 705 | static int |
fee0f4c6 | 706 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
707 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
708 | { | |
709 | struct bgp_filter *filter; | |
710 | struct bgp_info info; | |
711 | route_map_result_t ret; | |
712 | ||
713 | filter = &peer->filter[afi][safi]; | |
714 | ||
715 | /* Route map apply. */ | |
716 | if (ROUTE_MAP_EXPORT_NAME (filter)) | |
717 | { | |
718 | /* Duplicate current value to new strucutre for modification. */ | |
719 | info.peer = rsclient; | |
720 | info.attr = attr; | |
721 | ||
722 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); | |
723 | ||
724 | /* Apply BGP route map to the attribute. */ | |
725 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); | |
726 | ||
727 | rsclient->rmap_type = 0; | |
728 | ||
729 | if (ret == RMAP_DENYMATCH) | |
730 | { | |
731 | /* Free newly generated AS path and community by route-map. */ | |
732 | bgp_attr_flush (attr); | |
733 | return RMAP_DENY; | |
734 | } | |
735 | } | |
736 | return RMAP_PERMIT; | |
737 | } | |
738 | ||
94f2b392 | 739 | static int |
fee0f4c6 | 740 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
741 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
742 | { | |
743 | struct bgp_filter *filter; | |
744 | struct bgp_info info; | |
745 | route_map_result_t ret; | |
746 | ||
747 | filter = &rsclient->filter[afi][safi]; | |
748 | ||
749 | /* Apply default weight value. */ | |
fb982c25 PJ |
750 | if (peer->weight) |
751 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
fee0f4c6 | 752 | |
753 | /* Route map apply. */ | |
754 | if (ROUTE_MAP_IMPORT_NAME (filter)) | |
755 | { | |
756 | /* Duplicate current value to new strucutre for modification. */ | |
757 | info.peer = peer; | |
758 | info.attr = attr; | |
759 | ||
760 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); | |
761 | ||
762 | /* Apply BGP route map to the attribute. */ | |
763 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); | |
764 | ||
765 | peer->rmap_type = 0; | |
766 | ||
767 | if (ret == RMAP_DENYMATCH) | |
768 | { | |
769 | /* Free newly generated AS path and community by route-map. */ | |
770 | bgp_attr_flush (attr); | |
771 | return RMAP_DENY; | |
772 | } | |
773 | } | |
774 | return RMAP_PERMIT; | |
775 | } | |
776 | \f | |
94f2b392 | 777 | static int |
718e3744 | 778 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
779 | struct attr *attr, afi_t afi, safi_t safi) | |
780 | { | |
781 | int ret; | |
782 | char buf[SU_ADDRSTRLEN]; | |
783 | struct bgp_filter *filter; | |
718e3744 | 784 | struct peer *from; |
785 | struct bgp *bgp; | |
718e3744 | 786 | int transparent; |
787 | int reflect; | |
788 | ||
789 | from = ri->peer; | |
790 | filter = &peer->filter[afi][safi]; | |
791 | bgp = peer->bgp; | |
792 | ||
750e8146 PJ |
793 | if (DISABLE_BGP_ANNOUNCE) |
794 | return 0; | |
718e3744 | 795 | |
fee0f4c6 | 796 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
797 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
798 | return 0; | |
799 | ||
718e3744 | 800 | /* Do not send back route to sender. */ |
801 | if (from == peer) | |
802 | return 0; | |
803 | ||
35be31b6 | 804 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
805 | if (p->family == AF_INET | |
806 | && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) | |
807 | return 0; | |
808 | #ifdef HAVE_IPV6 | |
809 | if (p->family == AF_INET6 | |
810 | && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) | |
811 | return 0; | |
812 | #endif | |
813 | ||
718e3744 | 814 | /* Aggregate-address suppress check. */ |
fb982c25 | 815 | if (ri->extra && ri->extra->suppress) |
718e3744 | 816 | if (! UNSUPPRESS_MAP_NAME (filter)) |
817 | return 0; | |
818 | ||
819 | /* Default route check. */ | |
820 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) | |
821 | { | |
822 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
823 | return 0; | |
824 | #ifdef HAVE_IPV6 | |
825 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
826 | return 0; | |
827 | #endif /* HAVE_IPV6 */ | |
828 | } | |
829 | ||
286e1e71 | 830 | /* Transparency check. */ |
831 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) | |
832 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
833 | transparent = 1; | |
834 | else | |
835 | transparent = 0; | |
836 | ||
718e3744 | 837 | /* If community is not disabled check the no-export and local. */ |
286e1e71 | 838 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
718e3744 | 839 | return 0; |
840 | ||
841 | /* If the attribute has originator-id and it is same as remote | |
842 | peer's id. */ | |
843 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) | |
844 | { | |
fb982c25 | 845 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->extra->originator_id)) |
718e3744 | 846 | { |
847 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 848 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 849 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
850 | peer->host, | |
851 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
852 | p->prefixlen); | |
853 | return 0; | |
854 | } | |
855 | } | |
856 | ||
857 | /* ORF prefix-list filter check */ | |
858 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
859 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
860 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
861 | if (peer->orf_plist[afi][safi]) | |
862 | { | |
863 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) | |
864 | return 0; | |
865 | } | |
866 | ||
867 | /* Output filter check. */ | |
868 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) | |
869 | { | |
870 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 871 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 872 | "%s [Update:SEND] %s/%d is filtered", |
873 | peer->host, | |
874 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
875 | p->prefixlen); | |
876 | return 0; | |
877 | } | |
878 | ||
879 | #ifdef BGP_SEND_ASPATH_CHECK | |
880 | /* AS path loop check. */ | |
881 | if (aspath_loop_check (ri->attr->aspath, peer->as)) | |
882 | { | |
883 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 884 | zlog (peer->log, LOG_DEBUG, |
aea339f7 | 885 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
718e3744 | 886 | peer->host, peer->as); |
887 | return 0; | |
888 | } | |
889 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
890 | ||
891 | /* If we're a CONFED we need to loop check the CONFED ID too */ | |
892 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
893 | { | |
894 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) | |
895 | { | |
896 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 897 | zlog (peer->log, LOG_DEBUG, |
aea339f7 | 898 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
718e3744 | 899 | peer->host, |
900 | bgp->confed_id); | |
901 | return 0; | |
902 | } | |
903 | } | |
904 | ||
905 | /* Route-Reflect check. */ | |
906 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) | |
907 | reflect = 1; | |
908 | else | |
909 | reflect = 0; | |
910 | ||
911 | /* IBGP reflection check. */ | |
912 | if (reflect) | |
913 | { | |
914 | /* A route from a Client peer. */ | |
915 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
916 | { | |
917 | /* Reflect to all the Non-Client peers and also to the | |
918 | Client peers other than the originator. Originator check | |
919 | is already done. So there is noting to do. */ | |
920 | /* no bgp client-to-client reflection check. */ | |
921 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
922 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
923 | return 0; | |
924 | } | |
925 | else | |
926 | { | |
927 | /* A route from a Non-client peer. Reflect to all other | |
928 | clients. */ | |
929 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
930 | return 0; | |
931 | } | |
932 | } | |
41367172 | 933 | |
718e3744 | 934 | /* For modify attribute, copy it to temporary structure. */ |
fb982c25 PJ |
935 | bgp_attr_dup (attr, ri->attr); |
936 | ||
718e3744 | 937 | /* If local-preference is not set. */ |
938 | if ((peer_sort (peer) == BGP_PEER_IBGP | |
939 | || peer_sort (peer) == BGP_PEER_CONFED) | |
940 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) | |
941 | { | |
942 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); | |
943 | attr->local_pref = bgp->default_local_pref; | |
944 | } | |
945 | ||
718e3744 | 946 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
947 | if (peer_sort (peer) == BGP_PEER_EBGP | |
948 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
949 | { | |
950 | if (ri->peer != bgp->peer_self && ! transparent | |
951 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
952 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); | |
953 | } | |
954 | ||
955 | /* next-hop-set */ | |
956 | if (transparent || reflect | |
957 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) | |
958 | && ((p->family == AF_INET && attr->nexthop.s_addr) | |
286e1e71 | 959 | #ifdef HAVE_IPV6 |
fee0f4c6 | 960 | || (p->family == AF_INET6 && |
fb982c25 | 961 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
286e1e71 | 962 | #endif /* HAVE_IPV6 */ |
963 | ))) | |
718e3744 | 964 | { |
965 | /* NEXT-HOP Unchanged. */ | |
966 | } | |
967 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
968 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) | |
969 | #ifdef HAVE_IPV6 | |
fee0f4c6 | 970 | || (p->family == AF_INET6 && |
fb982c25 | 971 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
718e3744 | 972 | #endif /* HAVE_IPV6 */ |
973 | || (peer_sort (peer) == BGP_PEER_EBGP | |
974 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) | |
975 | { | |
976 | /* Set IPv4 nexthop. */ | |
977 | if (p->family == AF_INET) | |
978 | { | |
979 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
980 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
981 | IPV4_MAX_BYTELEN); | |
718e3744 | 982 | else |
983 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); | |
984 | } | |
985 | #ifdef HAVE_IPV6 | |
986 | /* Set IPv6 nexthop. */ | |
987 | if (p->family == AF_INET6) | |
988 | { | |
989 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 990 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
718e3744 | 991 | IPV6_MAX_BYTELEN); |
fb982c25 | 992 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 993 | } |
994 | #endif /* HAVE_IPV6 */ | |
995 | } | |
996 | ||
997 | #ifdef HAVE_IPV6 | |
998 | if (p->family == AF_INET6) | |
999 | { | |
fee0f4c6 | 1000 | /* Left nexthop_local unchanged if so configured. */ |
1001 | if ( CHECK_FLAG (peer->af_flags[afi][safi], | |
1002 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) | |
1003 | { | |
fb982c25 PJ |
1004 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
1005 | attr->extra->mp_nexthop_len=32; | |
fee0f4c6 | 1006 | else |
fb982c25 | 1007 | attr->extra->mp_nexthop_len=16; |
fee0f4c6 | 1008 | } |
1009 | ||
1010 | /* Default nexthop_local treatment for non-RS-Clients */ | |
1011 | else | |
1012 | { | |
718e3744 | 1013 | /* Link-local address should not be transit to different peer. */ |
fb982c25 | 1014 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1015 | |
1016 | /* Set link-local address for shared network peer. */ | |
1017 | if (peer->shared_network | |
1018 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) | |
1019 | { | |
fb982c25 | 1020 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
718e3744 | 1021 | IPV6_MAX_BYTELEN); |
fb982c25 | 1022 | attr->extra->mp_nexthop_len = 32; |
718e3744 | 1023 | } |
1024 | ||
1025 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local | |
1026 | address.*/ | |
1027 | if (reflect) | |
fb982c25 | 1028 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1029 | |
1030 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ | |
1031 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) | |
fb982c25 | 1032 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1033 | } |
fee0f4c6 | 1034 | |
1035 | } | |
718e3744 | 1036 | #endif /* HAVE_IPV6 */ |
1037 | ||
1038 | /* If this is EBGP peer and remove-private-AS is set. */ | |
1039 | if (peer_sort (peer) == BGP_PEER_EBGP | |
1040 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) | |
1041 | && aspath_private_as_check (attr->aspath)) | |
1042 | attr->aspath = aspath_empty_get (); | |
1043 | ||
1044 | /* Route map & unsuppress-map apply. */ | |
1045 | if (ROUTE_MAP_OUT_NAME (filter) | |
fb982c25 | 1046 | || (ri->extra && ri->extra->suppress) ) |
718e3744 | 1047 | { |
7c7fa1b4 | 1048 | struct bgp_info info; |
9eda90ce | 1049 | struct attr dummy_attr = { 0 }; |
7c7fa1b4 | 1050 | |
718e3744 | 1051 | info.peer = peer; |
1052 | info.attr = attr; | |
1053 | ||
1054 | /* The route reflector is not allowed to modify the attributes | |
1055 | of the reflected IBGP routes. */ | |
1056 | if (peer_sort (from) == BGP_PEER_IBGP | |
1057 | && peer_sort (peer) == BGP_PEER_IBGP) | |
1058 | { | |
fb982c25 | 1059 | bgp_attr_dup (&dummy_attr, attr); |
9eda90ce | 1060 | info.attr = &dummy_attr; |
718e3744 | 1061 | } |
ac41b2a2 | 1062 | |
1063 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1064 | ||
fb982c25 | 1065 | if (ri->extra && ri->extra->suppress) |
718e3744 | 1066 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
1067 | else | |
1068 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1069 | ||
ac41b2a2 | 1070 | peer->rmap_type = 0; |
fb982c25 | 1071 | |
9eda90ce PJ |
1072 | if (dummy_attr.extra) |
1073 | bgp_attr_extra_free (&dummy_attr); | |
fb982c25 | 1074 | |
718e3744 | 1075 | if (ret == RMAP_DENYMATCH) |
1076 | { | |
1077 | bgp_attr_flush (attr); | |
1078 | return 0; | |
1079 | } | |
1080 | } | |
1081 | return 1; | |
1082 | } | |
1083 | ||
94f2b392 | 1084 | static int |
fee0f4c6 | 1085 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
1086 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
1087 | { | |
1088 | int ret; | |
1089 | char buf[SU_ADDRSTRLEN]; | |
1090 | struct bgp_filter *filter; | |
1091 | struct bgp_info info; | |
1092 | struct peer *from; | |
1093 | struct bgp *bgp; | |
1094 | ||
1095 | from = ri->peer; | |
1096 | filter = &rsclient->filter[afi][safi]; | |
1097 | bgp = rsclient->bgp; | |
1098 | ||
750e8146 PJ |
1099 | if (DISABLE_BGP_ANNOUNCE) |
1100 | return 0; | |
fee0f4c6 | 1101 | |
1102 | /* Do not send back route to sender. */ | |
1103 | if (from == rsclient) | |
1104 | return 0; | |
1105 | ||
1106 | /* Aggregate-address suppress check. */ | |
fb982c25 | 1107 | if (ri->extra && ri->extra->suppress) |
fee0f4c6 | 1108 | if (! UNSUPPRESS_MAP_NAME (filter)) |
1109 | return 0; | |
1110 | ||
1111 | /* Default route check. */ | |
1112 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], | |
1113 | PEER_STATUS_DEFAULT_ORIGINATE)) | |
1114 | { | |
1115 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
1116 | return 0; | |
1117 | #ifdef HAVE_IPV6 | |
1118 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
1119 | return 0; | |
1120 | #endif /* HAVE_IPV6 */ | |
1121 | } | |
1122 | ||
1123 | /* If the attribute has originator-id and it is same as remote | |
1124 | peer's id. */ | |
1125 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) | |
1126 | { | |
fb982c25 PJ |
1127 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
1128 | &ri->attr->extra->originator_id)) | |
fee0f4c6 | 1129 | { |
1130 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1131 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 1132 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
1133 | rsclient->host, | |
1134 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1135 | p->prefixlen); | |
1136 | return 0; | |
1137 | } | |
1138 | } | |
1139 | ||
1140 | /* ORF prefix-list filter check */ | |
1141 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
1142 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
1143 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
1144 | if (rsclient->orf_plist[afi][safi]) | |
1145 | { | |
1146 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) | |
1147 | return 0; | |
1148 | } | |
1149 | ||
1150 | /* Output filter check. */ | |
1151 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) | |
1152 | { | |
1153 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1154 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 1155 | "%s [Update:SEND] %s/%d is filtered", |
1156 | rsclient->host, | |
1157 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1158 | p->prefixlen); | |
1159 | return 0; | |
1160 | } | |
1161 | ||
1162 | #ifdef BGP_SEND_ASPATH_CHECK | |
1163 | /* AS path loop check. */ | |
1164 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) | |
1165 | { | |
1166 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1167 | zlog (rsclient->log, LOG_DEBUG, |
aea339f7 | 1168 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
fee0f4c6 | 1169 | rsclient->host, rsclient->as); |
1170 | return 0; | |
1171 | } | |
1172 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
1173 | ||
1174 | /* For modify attribute, copy it to temporary structure. */ | |
9eda90ce | 1175 | bgp_attr_dup (attr, ri->attr); |
fee0f4c6 | 1176 | |
1177 | /* next-hop-set */ | |
1178 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) | |
1179 | #ifdef HAVE_IPV6 | |
1180 | || (p->family == AF_INET6 && | |
fb982c25 | 1181 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
fee0f4c6 | 1182 | #endif /* HAVE_IPV6 */ |
1183 | ) | |
1184 | { | |
1185 | /* Set IPv4 nexthop. */ | |
1186 | if (p->family == AF_INET) | |
1187 | { | |
1188 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1189 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
fee0f4c6 | 1190 | IPV4_MAX_BYTELEN); |
1191 | else | |
1192 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); | |
1193 | } | |
1194 | #ifdef HAVE_IPV6 | |
1195 | /* Set IPv6 nexthop. */ | |
1196 | if (p->family == AF_INET6) | |
1197 | { | |
1198 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 1199 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
fee0f4c6 | 1200 | IPV6_MAX_BYTELEN); |
fb982c25 | 1201 | attr->extra->mp_nexthop_len = 16; |
fee0f4c6 | 1202 | } |
1203 | #endif /* HAVE_IPV6 */ | |
1204 | } | |
1205 | ||
1206 | #ifdef HAVE_IPV6 | |
1207 | if (p->family == AF_INET6) | |
1208 | { | |
fb982c25 PJ |
1209 | struct attr_extra *attre = attr->extra; |
1210 | ||
1211 | assert (attr->extra); | |
1212 | ||
fee0f4c6 | 1213 | /* Left nexthop_local unchanged if so configured. */ |
1214 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], | |
1215 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) | |
1216 | { | |
fb982c25 PJ |
1217 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
1218 | attre->mp_nexthop_len=32; | |
fee0f4c6 | 1219 | else |
fb982c25 | 1220 | attre->mp_nexthop_len=16; |
fee0f4c6 | 1221 | } |
1222 | ||
1223 | /* Default nexthop_local treatment for RS-Clients */ | |
1224 | else | |
1225 | { | |
1226 | /* Announcer and RS-Client are both in the same network */ | |
1227 | if (rsclient->shared_network && from->shared_network && | |
1228 | (rsclient->ifindex == from->ifindex)) | |
1229 | { | |
fb982c25 PJ |
1230 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
1231 | attre->mp_nexthop_len=32; | |
fee0f4c6 | 1232 | else |
fb982c25 | 1233 | attre->mp_nexthop_len=16; |
fee0f4c6 | 1234 | } |
1235 | ||
1236 | /* Set link-local address for shared network peer. */ | |
1237 | else if (rsclient->shared_network | |
1238 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) | |
1239 | { | |
fb982c25 | 1240 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
fee0f4c6 | 1241 | IPV6_MAX_BYTELEN); |
fb982c25 | 1242 | attre->mp_nexthop_len = 32; |
fee0f4c6 | 1243 | } |
1244 | ||
1245 | else | |
fb982c25 | 1246 | attre->mp_nexthop_len = 16; |
fee0f4c6 | 1247 | } |
1248 | ||
1249 | } | |
1250 | #endif /* HAVE_IPV6 */ | |
1251 | ||
1252 | ||
1253 | /* If this is EBGP peer and remove-private-AS is set. */ | |
1254 | if (peer_sort (rsclient) == BGP_PEER_EBGP | |
1255 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) | |
1256 | && aspath_private_as_check (attr->aspath)) | |
1257 | attr->aspath = aspath_empty_get (); | |
1258 | ||
1259 | /* Route map & unsuppress-map apply. */ | |
fb982c25 | 1260 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
fee0f4c6 | 1261 | { |
1262 | info.peer = rsclient; | |
1263 | info.attr = attr; | |
1264 | ||
1265 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); | |
1266 | ||
fb982c25 | 1267 | if (ri->extra && ri->extra->suppress) |
fee0f4c6 | 1268 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
1269 | else | |
1270 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1271 | ||
1272 | rsclient->rmap_type = 0; | |
1273 | ||
1274 | if (ret == RMAP_DENYMATCH) | |
1275 | { | |
1276 | bgp_attr_flush (attr); | |
1277 | return 0; | |
1278 | } | |
1279 | } | |
1280 | ||
1281 | return 1; | |
1282 | } | |
1283 | ||
1284 | struct bgp_info_pair | |
1285 | { | |
1286 | struct bgp_info *old; | |
1287 | struct bgp_info *new; | |
1288 | }; | |
1289 | ||
94f2b392 | 1290 | static void |
96450faf JB |
1291 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
1292 | struct bgp_maxpaths_cfg *mpath_cfg, | |
1293 | struct bgp_info_pair *result) | |
718e3744 | 1294 | { |
718e3744 | 1295 | struct bgp_info *new_select; |
1296 | struct bgp_info *old_select; | |
fee0f4c6 | 1297 | struct bgp_info *ri; |
718e3744 | 1298 | struct bgp_info *ri1; |
1299 | struct bgp_info *ri2; | |
b40d939b | 1300 | struct bgp_info *nextri = NULL; |
96450faf JB |
1301 | int paths_eq, do_mpath; |
1302 | struct list mp_list; | |
1303 | ||
1304 | bgp_mp_list_init (&mp_list); | |
1305 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || | |
1306 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); | |
1307 | ||
718e3744 | 1308 | /* bgp deterministic-med */ |
1309 | new_select = NULL; | |
1310 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1311 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1312 | { | |
1313 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) | |
1314 | continue; | |
1315 | if (BGP_INFO_HOLDDOWN (ri1)) | |
1316 | continue; | |
1317 | ||
1318 | new_select = ri1; | |
1319 | if (ri1->next) | |
1320 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) | |
1321 | { | |
1322 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) | |
1323 | continue; | |
1324 | if (BGP_INFO_HOLDDOWN (ri2)) | |
1325 | continue; | |
1326 | ||
1327 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) | |
1328 | || aspath_cmp_left_confed (ri1->attr->aspath, | |
1329 | ri2->attr->aspath)) | |
1330 | { | |
96450faf | 1331 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
718e3744 | 1332 | { |
1a392d46 | 1333 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
718e3744 | 1334 | new_select = ri2; |
1335 | } | |
1336 | ||
1a392d46 | 1337 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
718e3744 | 1338 | } |
1339 | } | |
1a392d46 PJ |
1340 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
1341 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1342 | } |
1343 | ||
1344 | /* Check old selected route and new selected route. */ | |
1345 | old_select = NULL; | |
1346 | new_select = NULL; | |
b40d939b | 1347 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
718e3744 | 1348 | { |
1349 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1350 | old_select = ri; | |
1351 | ||
1352 | if (BGP_INFO_HOLDDOWN (ri)) | |
b40d939b | 1353 | { |
1354 | /* reap REMOVED routes, if needs be | |
1355 | * selected route must stay for a while longer though | |
1356 | */ | |
1357 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) | |
1358 | && (ri != old_select)) | |
1359 | bgp_info_reap (rn, ri); | |
1360 | ||
1361 | continue; | |
1362 | } | |
718e3744 | 1363 | |
1364 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) | |
1365 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) | |
1366 | { | |
1a392d46 | 1367 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1368 | continue; |
1369 | } | |
1a392d46 PJ |
1370 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
1371 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1372 | |
96450faf JB |
1373 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
1374 | { | |
1375 | new_select = ri; | |
1376 | ||
1377 | if (do_mpath && !paths_eq) | |
1378 | { | |
1379 | bgp_mp_list_clear (&mp_list); | |
1380 | bgp_mp_list_add (&mp_list, ri); | |
1381 | } | |
1382 | } | |
1383 | ||
1384 | if (do_mpath && paths_eq) | |
1385 | bgp_mp_list_add (&mp_list, ri); | |
718e3744 | 1386 | } |
b40d939b | 1387 | |
fee0f4c6 | 1388 | |
de8d5dff | 1389 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
96450faf JB |
1390 | |
1391 | bgp_mp_list_clear (&mp_list); | |
1392 | ||
1393 | result->old = old_select; | |
1394 | result->new = new_select; | |
1395 | ||
1396 | return; | |
fee0f4c6 | 1397 | } |
1398 | ||
94f2b392 | 1399 | static int |
fee0f4c6 | 1400 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
9eda90ce PJ |
1401 | struct bgp_node *rn, afi_t afi, safi_t safi) |
1402 | { | |
fee0f4c6 | 1403 | struct prefix *p; |
9eda90ce | 1404 | struct attr attr = { 0 }; |
fee0f4c6 | 1405 | |
1406 | p = &rn->p; | |
1407 | ||
9eda90ce PJ |
1408 | /* Announce route to Established peer. */ |
1409 | if (peer->status != Established) | |
fee0f4c6 | 1410 | return 0; |
718e3744 | 1411 | |
9eda90ce PJ |
1412 | /* Address family configuration check. */ |
1413 | if (! peer->afc_nego[afi][safi]) | |
fee0f4c6 | 1414 | return 0; |
718e3744 | 1415 | |
9eda90ce | 1416 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
fee0f4c6 | 1417 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
1418 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
1419 | return 0; | |
718e3744 | 1420 | |
fee0f4c6 | 1421 | switch (rn->table->type) |
1422 | { | |
1423 | case BGP_TABLE_MAIN: | |
718e3744 | 1424 | /* Announcement to peer->conf. If the route is filtered, |
1425 | withdraw it. */ | |
9eda90ce PJ |
1426 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
1427 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); | |
fee0f4c6 | 1428 | else |
1429 | bgp_adj_out_unset (rn, peer, p, afi, safi); | |
1430 | break; | |
1431 | case BGP_TABLE_RSCLIENT: | |
1432 | /* Announcement to peer->conf. If the route is filtered, | |
1433 | withdraw it. */ | |
9eda90ce PJ |
1434 | if (selected && |
1435 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) | |
1436 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); | |
1437 | else | |
1438 | bgp_adj_out_unset (rn, peer, p, afi, safi); | |
fee0f4c6 | 1439 | break; |
1440 | } | |
9eda90ce PJ |
1441 | |
1442 | bgp_attr_extra_free (&attr); | |
1443 | ||
fee0f4c6 | 1444 | return 0; |
200df115 | 1445 | } |
fee0f4c6 | 1446 | |
200df115 | 1447 | struct bgp_process_queue |
fee0f4c6 | 1448 | { |
200df115 | 1449 | struct bgp *bgp; |
1450 | struct bgp_node *rn; | |
1451 | afi_t afi; | |
1452 | safi_t safi; | |
1453 | }; | |
1454 | ||
1455 | static wq_item_status | |
0fb58d5d | 1456 | bgp_process_rsclient (struct work_queue *wq, void *data) |
200df115 | 1457 | { |
0fb58d5d | 1458 | struct bgp_process_queue *pq = data; |
200df115 | 1459 | struct bgp *bgp = pq->bgp; |
1460 | struct bgp_node *rn = pq->rn; | |
1461 | afi_t afi = pq->afi; | |
1462 | safi_t safi = pq->safi; | |
fee0f4c6 | 1463 | struct bgp_info *new_select; |
1464 | struct bgp_info *old_select; | |
1465 | struct bgp_info_pair old_and_new; | |
1eb8ef25 | 1466 | struct listnode *node, *nnode; |
200df115 | 1467 | struct peer *rsclient = rn->table->owner; |
1468 | ||
fee0f4c6 | 1469 | /* Best path selection. */ |
96450faf | 1470 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
fee0f4c6 | 1471 | new_select = old_and_new.new; |
1472 | old_select = old_and_new.old; | |
1473 | ||
200df115 | 1474 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
1475 | { | |
228da428 CC |
1476 | if (rsclient->group) |
1477 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) | |
1478 | { | |
1479 | /* Nothing to do. */ | |
1480 | if (old_select && old_select == new_select) | |
1481 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) | |
1482 | continue; | |
1483 | ||
1484 | if (old_select) | |
1485 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); | |
1486 | if (new_select) | |
1487 | { | |
1488 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); | |
1489 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
1490 | } | |
1491 | ||
1492 | bgp_process_announce_selected (rsclient, new_select, rn, | |
1493 | afi, safi); | |
1494 | } | |
200df115 | 1495 | } |
1496 | else | |
1497 | { | |
b7395791 | 1498 | if (old_select) |
1a392d46 | 1499 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
b7395791 | 1500 | if (new_select) |
1501 | { | |
1a392d46 PJ |
1502 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1503 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
b7395791 | 1504 | } |
9eda90ce | 1505 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
200df115 | 1506 | } |
1507 | ||
b40d939b | 1508 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
1509 | bgp_info_reap (rn, old_select); | |
1510 | ||
200df115 | 1511 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1512 | return WQ_SUCCESS; | |
fee0f4c6 | 1513 | } |
1514 | ||
200df115 | 1515 | static wq_item_status |
0fb58d5d | 1516 | bgp_process_main (struct work_queue *wq, void *data) |
200df115 | 1517 | { |
0fb58d5d | 1518 | struct bgp_process_queue *pq = data; |
200df115 | 1519 | struct bgp *bgp = pq->bgp; |
1520 | struct bgp_node *rn = pq->rn; | |
1521 | afi_t afi = pq->afi; | |
1522 | safi_t safi = pq->safi; | |
1523 | struct prefix *p = &rn->p; | |
fee0f4c6 | 1524 | struct bgp_info *new_select; |
1525 | struct bgp_info *old_select; | |
1526 | struct bgp_info_pair old_and_new; | |
1eb8ef25 | 1527 | struct listnode *node, *nnode; |
fee0f4c6 | 1528 | struct peer *peer; |
fb982c25 | 1529 | |
fee0f4c6 | 1530 | /* Best path selection. */ |
96450faf | 1531 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
fee0f4c6 | 1532 | old_select = old_and_new.old; |
1533 | new_select = old_and_new.new; | |
1534 | ||
1535 | /* Nothing to do. */ | |
1536 | if (old_select && old_select == new_select) | |
1537 | { | |
1538 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) | |
200df115 | 1539 | { |
1540 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) | |
1541 | bgp_zebra_announce (p, old_select, bgp); | |
1542 | ||
1543 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); | |
1544 | return WQ_SUCCESS; | |
1545 | } | |
fee0f4c6 | 1546 | } |
1547 | ||
338b3424 | 1548 | if (old_select) |
1a392d46 | 1549 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
338b3424 | 1550 | if (new_select) |
1551 | { | |
1a392d46 PJ |
1552 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1553 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
338b3424 | 1554 | } |
1555 | ||
1556 | ||
fee0f4c6 | 1557 | /* Check each BGP peer. */ |
1eb8ef25 | 1558 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
fee0f4c6 | 1559 | { |
9eda90ce | 1560 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
718e3744 | 1561 | } |
1562 | ||
1563 | /* FIB update. */ | |
1564 | if (safi == SAFI_UNICAST && ! bgp->name && | |
1565 | ! bgp_option_check (BGP_OPT_NO_FIB)) | |
1566 | { | |
1567 | if (new_select | |
1568 | && new_select->type == ZEBRA_ROUTE_BGP | |
1569 | && new_select->sub_type == BGP_ROUTE_NORMAL) | |
1570 | bgp_zebra_announce (p, new_select, bgp); | |
1571 | else | |
1572 | { | |
1573 | /* Withdraw the route from the kernel. */ | |
1574 | if (old_select | |
1575 | && old_select->type == ZEBRA_ROUTE_BGP | |
1576 | && old_select->sub_type == BGP_ROUTE_NORMAL) | |
1577 | bgp_zebra_withdraw (p, old_select); | |
1578 | } | |
1579 | } | |
b40d939b | 1580 | |
1581 | /* Reap old select bgp_info, it it has been removed */ | |
1582 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) | |
1583 | bgp_info_reap (rn, old_select); | |
1584 | ||
200df115 | 1585 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1586 | return WQ_SUCCESS; | |
718e3744 | 1587 | } |
1588 | ||
200df115 | 1589 | static void |
0fb58d5d | 1590 | bgp_processq_del (struct work_queue *wq, void *data) |
200df115 | 1591 | { |
0fb58d5d | 1592 | struct bgp_process_queue *pq = data; |
228da428 | 1593 | struct bgp_table *table = pq->rn->table; |
0fb58d5d | 1594 | |
228da428 | 1595 | bgp_unlock (pq->bgp); |
200df115 | 1596 | bgp_unlock_node (pq->rn); |
228da428 | 1597 | bgp_table_unlock (table); |
200df115 | 1598 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
1599 | } | |
1600 | ||
1601 | static void | |
1602 | bgp_process_queue_init (void) | |
1603 | { | |
1604 | bm->process_main_queue | |
1605 | = work_queue_new (bm->master, "process_main_queue"); | |
1606 | bm->process_rsclient_queue | |
1607 | = work_queue_new (bm->master, "process_rsclient_queue"); | |
1608 | ||
1609 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) | |
1610 | { | |
1611 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
1612 | exit (1); | |
1613 | } | |
1614 | ||
1615 | bm->process_main_queue->spec.workfunc = &bgp_process_main; | |
200df115 | 1616 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
838bbde0 PJ |
1617 | bm->process_main_queue->spec.max_retries = 0; |
1618 | bm->process_main_queue->spec.hold = 50; | |
1619 | ||
1620 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, | |
1621 | sizeof (struct work_queue *)); | |
1622 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; | |
200df115 | 1623 | } |
1624 | ||
1625 | void | |
fee0f4c6 | 1626 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
1627 | { | |
200df115 | 1628 | struct bgp_process_queue *pqnode; |
1629 | ||
1630 | /* already scheduled for processing? */ | |
1631 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) | |
1632 | return; | |
1633 | ||
1634 | if ( (bm->process_main_queue == NULL) || | |
1635 | (bm->process_rsclient_queue == NULL) ) | |
1636 | bgp_process_queue_init (); | |
1637 | ||
1638 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, | |
1639 | sizeof (struct bgp_process_queue)); | |
1640 | if (!pqnode) | |
1641 | return; | |
228da428 CC |
1642 | |
1643 | /* all unlocked in bgp_processq_del */ | |
1644 | bgp_table_lock (rn->table); | |
1645 | pqnode->rn = bgp_lock_node (rn); | |
200df115 | 1646 | pqnode->bgp = bgp; |
228da428 | 1647 | bgp_lock (bgp); |
200df115 | 1648 | pqnode->afi = afi; |
1649 | pqnode->safi = safi; | |
1650 | ||
fee0f4c6 | 1651 | switch (rn->table->type) |
1652 | { | |
200df115 | 1653 | case BGP_TABLE_MAIN: |
1654 | work_queue_add (bm->process_main_queue, pqnode); | |
1655 | break; | |
1656 | case BGP_TABLE_RSCLIENT: | |
1657 | work_queue_add (bm->process_rsclient_queue, pqnode); | |
1658 | break; | |
fee0f4c6 | 1659 | } |
200df115 | 1660 | |
1661 | return; | |
fee0f4c6 | 1662 | } |
0a486e5f | 1663 | |
94f2b392 | 1664 | static int |
0a486e5f | 1665 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
1666 | { | |
1667 | struct peer *peer; | |
1668 | ||
1669 | peer = THREAD_ARG (thread); | |
1670 | peer->t_pmax_restart = NULL; | |
1671 | ||
1672 | if (BGP_DEBUG (events, EVENTS)) | |
1673 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", | |
1674 | peer->host); | |
1675 | ||
1676 | peer_clear (peer); | |
1677 | ||
1678 | return 0; | |
1679 | } | |
1680 | ||
718e3744 | 1681 | int |
5228ad27 | 1682 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
1683 | safi_t safi, int always) | |
718e3744 | 1684 | { |
e0701b79 | 1685 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
1686 | return 0; | |
1687 | ||
1688 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) | |
718e3744 | 1689 | { |
e0701b79 | 1690 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
1691 | && ! always) | |
1692 | return 0; | |
1693 | ||
1694 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1695 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
1696 | "limit %ld", afi_safi_print (afi, safi), peer->host, | |
1697 | peer->pcount[afi][safi], peer->pmax[afi][safi]); | |
e0701b79 | 1698 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
1699 | ||
1700 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
1701 | return 0; | |
1702 | ||
1703 | { | |
5228ad27 | 1704 | u_int8_t ndata[7]; |
e0701b79 | 1705 | |
1706 | if (safi == SAFI_MPLS_VPN) | |
1707 | safi = BGP_SAFI_VPNV4; | |
5228ad27 | 1708 | |
1709 | ndata[0] = (afi >> 8); | |
1710 | ndata[1] = afi; | |
1711 | ndata[2] = safi; | |
1712 | ndata[3] = (peer->pmax[afi][safi] >> 24); | |
1713 | ndata[4] = (peer->pmax[afi][safi] >> 16); | |
1714 | ndata[5] = (peer->pmax[afi][safi] >> 8); | |
1715 | ndata[6] = (peer->pmax[afi][safi]); | |
e0701b79 | 1716 | |
1717 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); | |
1718 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, | |
1719 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); | |
1720 | } | |
0a486e5f | 1721 | |
1722 | /* restart timer start */ | |
1723 | if (peer->pmax_restart[afi][safi]) | |
1724 | { | |
1725 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; | |
1726 | ||
1727 | if (BGP_DEBUG (events, EVENTS)) | |
1728 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", | |
1729 | peer->host, peer->v_pmax_restart); | |
1730 | ||
1731 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, | |
1732 | peer->v_pmax_restart); | |
1733 | } | |
1734 | ||
e0701b79 | 1735 | return 1; |
1736 | } | |
1737 | else | |
1738 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); | |
1739 | ||
1740 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) | |
1741 | { | |
1742 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) | |
1743 | && ! always) | |
1744 | return 0; | |
1745 | ||
1746 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1747 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
1748 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], | |
1749 | peer->pmax[afi][safi]); | |
e0701b79 | 1750 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
718e3744 | 1751 | } |
e0701b79 | 1752 | else |
1753 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); | |
718e3744 | 1754 | return 0; |
1755 | } | |
1756 | ||
b40d939b | 1757 | /* Unconditionally remove the route from the RIB, without taking |
1758 | * damping into consideration (eg, because the session went down) | |
1759 | */ | |
94f2b392 | 1760 | static void |
718e3744 | 1761 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
1762 | afi_t afi, safi_t safi) | |
1763 | { | |
902212c3 | 1764 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1765 | ||
1766 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
1767 | bgp_info_delete (rn, ri); /* keep historical info */ | |
1768 | ||
b40d939b | 1769 | bgp_process (peer->bgp, rn, afi, safi); |
718e3744 | 1770 | } |
1771 | ||
94f2b392 | 1772 | static void |
718e3744 | 1773 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
b40d939b | 1774 | afi_t afi, safi_t safi) |
718e3744 | 1775 | { |
718e3744 | 1776 | int status = BGP_DAMP_NONE; |
1777 | ||
b40d939b | 1778 | /* apply dampening, if result is suppressed, we'll be retaining |
1779 | * the bgp_info in the RIB for historical reference. | |
1780 | */ | |
1781 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
1782 | && peer_sort (peer) == BGP_PEER_EBGP) | |
1783 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) | |
1784 | == BGP_DAMP_SUPPRESSED) | |
902212c3 | 1785 | { |
902212c3 | 1786 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1787 | return; | |
1788 | } | |
1789 | ||
1790 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
718e3744 | 1791 | } |
1792 | ||
94f2b392 | 1793 | static void |
fee0f4c6 | 1794 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
1795 | struct attr *attr, struct peer *peer, struct prefix *p, int type, | |
1796 | int sub_type, struct prefix_rd *prd, u_char *tag) | |
1797 | { | |
1798 | struct bgp_node *rn; | |
1799 | struct bgp *bgp; | |
fb982c25 | 1800 | struct attr new_attr = { 0 }; |
fee0f4c6 | 1801 | struct attr *attr_new; |
1802 | struct attr *attr_new2; | |
1803 | struct bgp_info *ri; | |
1804 | struct bgp_info *new; | |
fd79ac91 | 1805 | const char *reason; |
fee0f4c6 | 1806 | char buf[SU_ADDRSTRLEN]; |
1807 | ||
1808 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ | |
1809 | if (peer == rsclient) | |
1810 | return; | |
1811 | ||
1812 | bgp = peer->bgp; | |
1813 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
1814 | ||
1815 | /* Check previously received route. */ | |
1816 | for (ri = rn->info; ri; ri = ri->next) | |
1817 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
1818 | break; | |
1819 | ||
1820 | /* AS path loop check. */ | |
1821 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) | |
1822 | { | |
1823 | reason = "as-path contains our own AS;"; | |
1824 | goto filtered; | |
1825 | } | |
1826 | ||
1827 | /* Route reflector originator ID check. */ | |
1828 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 1829 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
fee0f4c6 | 1830 | { |
1831 | reason = "originator is us;"; | |
1832 | goto filtered; | |
1833 | } | |
fb982c25 PJ |
1834 | |
1835 | bgp_attr_dup (&new_attr, attr); | |
fee0f4c6 | 1836 | |
1837 | /* Apply export policy. */ | |
1838 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && | |
1839 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1840 | { | |
1841 | reason = "export-policy;"; | |
1842 | goto filtered; | |
1843 | } | |
1844 | ||
1845 | attr_new2 = bgp_attr_intern (&new_attr); | |
fb982c25 | 1846 | |
fee0f4c6 | 1847 | /* Apply import policy. */ |
1848 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1849 | { | |
1850 | bgp_attr_unintern (attr_new2); | |
1851 | ||
1852 | reason = "import-policy;"; | |
1853 | goto filtered; | |
1854 | } | |
1855 | ||
1856 | attr_new = bgp_attr_intern (&new_attr); | |
1857 | bgp_attr_unintern (attr_new2); | |
1858 | ||
1859 | /* IPv4 unicast next hop check. */ | |
1860 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
1861 | { | |
1862 | /* Next hop must not be 0.0.0.0 nor Class E address. */ | |
1863 | if (new_attr.nexthop.s_addr == 0 | |
1864 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) | |
1865 | { | |
1866 | bgp_attr_unintern (attr_new); | |
1867 | ||
1868 | reason = "martian next-hop;"; | |
1869 | goto filtered; | |
1870 | } | |
1871 | } | |
fb982c25 PJ |
1872 | |
1873 | /* new_attr isn't passed to any functions after here */ | |
1874 | bgp_attr_extra_free (&new_attr); | |
1875 | ||
fee0f4c6 | 1876 | /* If the update is implicit withdraw. */ |
1877 | if (ri) | |
1878 | { | |
65957886 | 1879 | ri->uptime = bgp_clock (); |
fee0f4c6 | 1880 | |
1881 | /* Same attribute comes in. */ | |
16d2e241 PJ |
1882 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
1883 | && attrhash_cmp (ri->attr, attr_new)) | |
fee0f4c6 | 1884 | { |
1885 | ||
1a392d46 | 1886 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1887 | |
1888 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1889 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1890 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
1891 | peer->host, | |
1892 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1893 | p->prefixlen, rsclient->host); | |
1894 | ||
228da428 CC |
1895 | bgp_unlock_node (rn); |
1896 | bgp_attr_unintern (attr_new); | |
fee0f4c6 | 1897 | |
228da428 | 1898 | return; |
fee0f4c6 | 1899 | } |
1900 | ||
16d2e241 PJ |
1901 | /* Withdraw/Announce before we fully processed the withdraw */ |
1902 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
1903 | bgp_info_restore (rn, ri); | |
1904 | ||
fee0f4c6 | 1905 | /* Received Logging. */ |
1906 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1907 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1908 | peer->host, |
1909 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1910 | p->prefixlen, rsclient->host); | |
1911 | ||
1912 | /* The attribute is changed. */ | |
1a392d46 | 1913 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1914 | |
1915 | /* Update to new attribute. */ | |
1916 | bgp_attr_unintern (ri->attr); | |
1917 | ri->attr = attr_new; | |
1918 | ||
1919 | /* Update MPLS tag. */ | |
1920 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1921 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
fee0f4c6 | 1922 | |
1a392d46 | 1923 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
fee0f4c6 | 1924 | |
1925 | /* Process change. */ | |
1926 | bgp_process (bgp, rn, afi, safi); | |
1927 | bgp_unlock_node (rn); | |
1928 | ||
1929 | return; | |
1930 | } | |
1931 | ||
1932 | /* Received Logging. */ | |
1933 | if (BGP_DEBUG (update, UPDATE_IN)) | |
1934 | { | |
d2c1f16b | 1935 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1936 | peer->host, |
1937 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1938 | p->prefixlen, rsclient->host); | |
1939 | } | |
1940 | ||
1941 | /* Make new BGP info. */ | |
1942 | new = bgp_info_new (); | |
1943 | new->type = type; | |
1944 | new->sub_type = sub_type; | |
1945 | new->peer = peer; | |
1946 | new->attr = attr_new; | |
65957886 | 1947 | new->uptime = bgp_clock (); |
fee0f4c6 | 1948 | |
1949 | /* Update MPLS tag. */ | |
1950 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1951 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
fee0f4c6 | 1952 | |
1a392d46 | 1953 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
fee0f4c6 | 1954 | |
1955 | /* Register new BGP information. */ | |
1956 | bgp_info_add (rn, new); | |
200df115 | 1957 | |
1958 | /* route_node_get lock */ | |
1959 | bgp_unlock_node (rn); | |
1960 | ||
fee0f4c6 | 1961 | /* Process change. */ |
1962 | bgp_process (bgp, rn, afi, safi); | |
fb982c25 PJ |
1963 | |
1964 | bgp_attr_extra_free (&new_attr); | |
1965 | ||
fee0f4c6 | 1966 | return; |
1967 | ||
1968 | filtered: | |
1969 | ||
1970 | /* This BGP update is filtered. Log the reason then update BGP entry. */ | |
1971 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1972 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1973 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
1974 | peer->host, | |
1975 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1976 | p->prefixlen, rsclient->host, reason); | |
1977 | ||
1978 | if (ri) | |
b40d939b | 1979 | bgp_rib_remove (rn, ri, peer, afi, safi); |
fee0f4c6 | 1980 | |
1981 | bgp_unlock_node (rn); | |
fb982c25 PJ |
1982 | |
1983 | if (new_attr.extra) | |
1984 | bgp_attr_extra_free (&new_attr); | |
1985 | ||
fee0f4c6 | 1986 | return; |
1987 | } | |
1988 | ||
94f2b392 | 1989 | static void |
fee0f4c6 | 1990 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
1991 | struct peer *peer, struct prefix *p, int type, int sub_type, | |
1992 | struct prefix_rd *prd, u_char *tag) | |
228da428 | 1993 | { |
fee0f4c6 | 1994 | struct bgp_node *rn; |
1995 | struct bgp_info *ri; | |
1996 | char buf[SU_ADDRSTRLEN]; | |
1997 | ||
1998 | if (rsclient == peer) | |
228da428 | 1999 | return; |
fee0f4c6 | 2000 | |
2001 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
2002 | ||
2003 | /* Lookup withdrawn route. */ | |
2004 | for (ri = rn->info; ri; ri = ri->next) | |
2005 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2006 | break; | |
2007 | ||
2008 | /* Withdraw specified route from routing table. */ | |
2009 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2010 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
fee0f4c6 | 2011 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 2012 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 2013 | "%s Can't find the route %s/%d", peer->host, |
2014 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2015 | p->prefixlen); | |
2016 | ||
2017 | /* Unlock bgp_node_get() lock. */ | |
228da428 CC |
2018 | bgp_unlock_node (rn); |
2019 | } | |
fee0f4c6 | 2020 | |
94f2b392 | 2021 | static int |
fee0f4c6 | 2022 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
718e3744 | 2023 | afi_t afi, safi_t safi, int type, int sub_type, |
2024 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
2025 | { | |
2026 | int ret; | |
2027 | int aspath_loop_count = 0; | |
2028 | struct bgp_node *rn; | |
2029 | struct bgp *bgp; | |
fb982c25 | 2030 | struct attr new_attr = { 0 }; |
718e3744 | 2031 | struct attr *attr_new; |
2032 | struct bgp_info *ri; | |
2033 | struct bgp_info *new; | |
fd79ac91 | 2034 | const char *reason; |
718e3744 | 2035 | char buf[SU_ADDRSTRLEN]; |
2036 | ||
2037 | bgp = peer->bgp; | |
fee0f4c6 | 2038 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
fb982c25 | 2039 | |
718e3744 | 2040 | /* When peer's soft reconfiguration enabled. Record input packet in |
2041 | Adj-RIBs-In. */ | |
2042 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2043 | && peer != bgp->peer_self && ! soft_reconfig) | |
2044 | bgp_adj_in_set (rn, peer, attr); | |
2045 | ||
2046 | /* Check previously received route. */ | |
2047 | for (ri = rn->info; ri; ri = ri->next) | |
2048 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2049 | break; | |
2050 | ||
2051 | /* AS path local-as loop check. */ | |
2052 | if (peer->change_local_as) | |
2053 | { | |
2054 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
2055 | aspath_loop_count = 1; | |
2056 | ||
2057 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) | |
2058 | { | |
2059 | reason = "as-path contains our own AS;"; | |
2060 | goto filtered; | |
2061 | } | |
2062 | } | |
2063 | ||
2064 | /* AS path loop check. */ | |
2065 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] | |
2066 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
2067 | && aspath_loop_check(attr->aspath, bgp->confed_id) | |
2068 | > peer->allowas_in[afi][safi])) | |
2069 | { | |
2070 | reason = "as-path contains our own AS;"; | |
2071 | goto filtered; | |
2072 | } | |
2073 | ||
2074 | /* Route reflector originator ID check. */ | |
2075 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 2076 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
718e3744 | 2077 | { |
2078 | reason = "originator is us;"; | |
2079 | goto filtered; | |
2080 | } | |
2081 | ||
2082 | /* Route reflector cluster ID check. */ | |
2083 | if (bgp_cluster_filter (peer, attr)) | |
2084 | { | |
2085 | reason = "reflected from the same cluster;"; | |
2086 | goto filtered; | |
2087 | } | |
2088 | ||
2089 | /* Apply incoming filter. */ | |
2090 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) | |
2091 | { | |
2092 | reason = "filter;"; | |
2093 | goto filtered; | |
2094 | } | |
2095 | ||
2096 | /* Apply incoming route-map. */ | |
fb982c25 | 2097 | bgp_attr_dup (&new_attr, attr); |
718e3744 | 2098 | |
2099 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
2100 | { | |
2101 | reason = "route-map;"; | |
2102 | goto filtered; | |
2103 | } | |
2104 | ||
2105 | /* IPv4 unicast next hop check. */ | |
2106 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
2107 | { | |
2108 | /* If the peer is EBGP and nexthop is not on connected route, | |
2109 | discard it. */ | |
2110 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 | |
2111 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) | |
6ffd2079 | 2112 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
718e3744 | 2113 | { |
2114 | reason = "non-connected next-hop;"; | |
2115 | goto filtered; | |
2116 | } | |
2117 | ||
2118 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop | |
2119 | must not be my own address. */ | |
2120 | if (bgp_nexthop_self (afi, &new_attr) | |
2121 | || new_attr.nexthop.s_addr == 0 | |
2122 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) | |
2123 | { | |
2124 | reason = "martian next-hop;"; | |
2125 | goto filtered; | |
2126 | } | |
2127 | } | |
2128 | ||
2129 | attr_new = bgp_attr_intern (&new_attr); | |
2130 | ||
2131 | /* If the update is implicit withdraw. */ | |
2132 | if (ri) | |
2133 | { | |
65957886 | 2134 | ri->uptime = bgp_clock (); |
718e3744 | 2135 | |
2136 | /* Same attribute comes in. */ | |
16d2e241 PJ |
2137 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
2138 | && attrhash_cmp (ri->attr, attr_new)) | |
718e3744 | 2139 | { |
1a392d46 | 2140 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 2141 | |
2142 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2143 | && peer_sort (peer) == BGP_PEER_EBGP | |
2144 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2145 | { | |
2146 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2147 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2148 | peer->host, |
2149 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2150 | p->prefixlen); | |
2151 | ||
902212c3 | 2152 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
2153 | { | |
2154 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2155 | bgp_process (bgp, rn, afi, safi); | |
2156 | } | |
718e3744 | 2157 | } |
16d2e241 | 2158 | else /* Duplicate - odd */ |
718e3744 | 2159 | { |
2160 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2161 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2162 | "%s rcvd %s/%d...duplicate ignored", |
2163 | peer->host, | |
2164 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2165 | p->prefixlen); | |
93406d87 | 2166 | |
2167 | /* graceful restart STALE flag unset. */ | |
2168 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2169 | { | |
1a392d46 | 2170 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
902212c3 | 2171 | bgp_process (bgp, rn, afi, safi); |
93406d87 | 2172 | } |
718e3744 | 2173 | } |
2174 | ||
2175 | bgp_unlock_node (rn); | |
2176 | bgp_attr_unintern (attr_new); | |
fb982c25 PJ |
2177 | bgp_attr_extra_free (&new_attr); |
2178 | ||
718e3744 | 2179 | return 0; |
2180 | } | |
2181 | ||
16d2e241 PJ |
2182 | /* Withdraw/Announce before we fully processed the withdraw */ |
2183 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
2184 | { | |
2185 | if (BGP_DEBUG (update, UPDATE_IN)) | |
2186 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", | |
2187 | peer->host, | |
2188 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2189 | p->prefixlen); | |
2190 | bgp_info_restore (rn, ri); | |
2191 | } | |
2192 | ||
718e3744 | 2193 | /* Received Logging. */ |
2194 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2195 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2196 | peer->host, |
2197 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2198 | p->prefixlen); | |
2199 | ||
93406d87 | 2200 | /* graceful restart STALE flag unset. */ |
2201 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
1a392d46 | 2202 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
93406d87 | 2203 | |
718e3744 | 2204 | /* The attribute is changed. */ |
1a392d46 | 2205 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
902212c3 | 2206 | |
2207 | /* implicit withdraw, decrement aggregate and pcount here. | |
2208 | * only if update is accepted, they'll increment below. | |
2209 | */ | |
902212c3 | 2210 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
2211 | ||
718e3744 | 2212 | /* Update bgp route dampening information. */ |
2213 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2214 | && peer_sort (peer) == BGP_PEER_EBGP) | |
2215 | { | |
2216 | /* This is implicit withdraw so we should update dampening | |
2217 | information. */ | |
2218 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2219 | bgp_damp_withdraw (ri, rn, afi, safi, 1); | |
718e3744 | 2220 | } |
2221 | ||
718e3744 | 2222 | /* Update to new attribute. */ |
2223 | bgp_attr_unintern (ri->attr); | |
2224 | ri->attr = attr_new; | |
2225 | ||
2226 | /* Update MPLS tag. */ | |
2227 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2228 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
718e3744 | 2229 | |
2230 | /* Update bgp route dampening information. */ | |
2231 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2232 | && peer_sort (peer) == BGP_PEER_EBGP) | |
2233 | { | |
2234 | /* Now we do normal update dampening. */ | |
2235 | ret = bgp_damp_update (ri, rn, afi, safi); | |
2236 | if (ret == BGP_DAMP_SUPPRESSED) | |
2237 | { | |
2238 | bgp_unlock_node (rn); | |
fb982c25 | 2239 | bgp_attr_extra_free (&new_attr); |
718e3744 | 2240 | return 0; |
2241 | } | |
2242 | } | |
2243 | ||
2244 | /* Nexthop reachability check. */ | |
2245 | if ((afi == AFI_IP || afi == AFI_IP6) | |
2246 | && safi == SAFI_UNICAST | |
2247 | && (peer_sort (peer) == BGP_PEER_IBGP | |
638b70ba | 2248 | || peer_sort (peer) == BGP_PEER_CONFED |
718e3744 | 2249 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
6ffd2079 | 2250 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
718e3744 | 2251 | { |
2252 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) | |
1a392d46 | 2253 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2254 | else |
1a392d46 | 2255 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2256 | } |
2257 | else | |
1a392d46 | 2258 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2259 | |
2260 | /* Process change. */ | |
2261 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2262 | ||
2263 | bgp_process (bgp, rn, afi, safi); | |
2264 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2265 | bgp_attr_extra_free (&new_attr); |
2266 | ||
718e3744 | 2267 | return 0; |
2268 | } | |
2269 | ||
2270 | /* Received Logging. */ | |
2271 | if (BGP_DEBUG (update, UPDATE_IN)) | |
2272 | { | |
d2c1f16b | 2273 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2274 | peer->host, |
2275 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2276 | p->prefixlen); | |
2277 | } | |
2278 | ||
718e3744 | 2279 | /* Make new BGP info. */ |
2280 | new = bgp_info_new (); | |
2281 | new->type = type; | |
2282 | new->sub_type = sub_type; | |
2283 | new->peer = peer; | |
2284 | new->attr = attr_new; | |
65957886 | 2285 | new->uptime = bgp_clock (); |
718e3744 | 2286 | |
2287 | /* Update MPLS tag. */ | |
2288 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2289 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
718e3744 | 2290 | |
2291 | /* Nexthop reachability check. */ | |
2292 | if ((afi == AFI_IP || afi == AFI_IP6) | |
2293 | && safi == SAFI_UNICAST | |
2294 | && (peer_sort (peer) == BGP_PEER_IBGP | |
638b70ba | 2295 | || peer_sort (peer) == BGP_PEER_CONFED |
718e3744 | 2296 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
6ffd2079 | 2297 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
718e3744 | 2298 | { |
2299 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) | |
1a392d46 | 2300 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2301 | else |
1a392d46 | 2302 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2303 | } |
2304 | else | |
1a392d46 | 2305 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2306 | |
902212c3 | 2307 | /* Increment prefix */ |
718e3744 | 2308 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
2309 | ||
2310 | /* Register new BGP information. */ | |
2311 | bgp_info_add (rn, new); | |
200df115 | 2312 | |
2313 | /* route_node_get lock */ | |
2314 | bgp_unlock_node (rn); | |
2315 | ||
fb982c25 PJ |
2316 | bgp_attr_extra_free (&new_attr); |
2317 | ||
718e3744 | 2318 | /* If maximum prefix count is configured and current prefix |
2319 | count exeed it. */ | |
e0701b79 | 2320 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
2321 | return -1; | |
718e3744 | 2322 | |
2323 | /* Process change. */ | |
2324 | bgp_process (bgp, rn, afi, safi); | |
2325 | ||
2326 | return 0; | |
2327 | ||
2328 | /* This BGP update is filtered. Log the reason then update BGP | |
2329 | entry. */ | |
2330 | filtered: | |
2331 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2332 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2333 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
2334 | peer->host, | |
2335 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2336 | p->prefixlen, reason); | |
2337 | ||
2338 | if (ri) | |
b40d939b | 2339 | bgp_rib_remove (rn, ri, peer, afi, safi); |
718e3744 | 2340 | |
2341 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2342 | |
2343 | bgp_attr_extra_free (&new_attr); | |
2344 | ||
718e3744 | 2345 | return 0; |
2346 | } | |
2347 | ||
fee0f4c6 | 2348 | int |
2349 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, | |
2350 | afi_t afi, safi_t safi, int type, int sub_type, | |
2351 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
2352 | { | |
2353 | struct peer *rsclient; | |
1eb8ef25 | 2354 | struct listnode *node, *nnode; |
fee0f4c6 | 2355 | struct bgp *bgp; |
2356 | int ret; | |
2357 | ||
2358 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, | |
2359 | soft_reconfig); | |
2360 | ||
2361 | bgp = peer->bgp; | |
2362 | ||
2363 | /* Process the update for each RS-client. */ | |
1eb8ef25 | 2364 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2365 | { |
2366 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2367 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, | |
2368 | sub_type, prd, tag); | |
2369 | } | |
2370 | ||
2371 | return ret; | |
2372 | } | |
2373 | ||
718e3744 | 2374 | int |
2375 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, | |
94f2b392 | 2376 | afi_t afi, safi_t safi, int type, int sub_type, |
2377 | struct prefix_rd *prd, u_char *tag) | |
718e3744 | 2378 | { |
2379 | struct bgp *bgp; | |
2380 | char buf[SU_ADDRSTRLEN]; | |
2381 | struct bgp_node *rn; | |
2382 | struct bgp_info *ri; | |
fee0f4c6 | 2383 | struct peer *rsclient; |
1eb8ef25 | 2384 | struct listnode *node, *nnode; |
718e3744 | 2385 | |
2386 | bgp = peer->bgp; | |
2387 | ||
fee0f4c6 | 2388 | /* Process the withdraw for each RS-client. */ |
1eb8ef25 | 2389 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2390 | { |
2391 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2392 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); | |
2393 | } | |
2394 | ||
718e3744 | 2395 | /* Logging. */ |
2396 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2397 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
718e3744 | 2398 | peer->host, |
2399 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2400 | p->prefixlen); | |
2401 | ||
2402 | /* Lookup node. */ | |
fee0f4c6 | 2403 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 2404 | |
2405 | /* If peer is soft reconfiguration enabled. Record input packet for | |
2406 | further calculation. */ | |
2407 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2408 | && peer != bgp->peer_self) | |
2409 | bgp_adj_in_unset (rn, peer); | |
2410 | ||
2411 | /* Lookup withdrawn route. */ | |
2412 | for (ri = rn->info; ri; ri = ri->next) | |
2413 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2414 | break; | |
2415 | ||
2416 | /* Withdraw specified route from routing table. */ | |
2417 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2418 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
718e3744 | 2419 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 2420 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2421 | "%s Can't find the route %s/%d", peer->host, |
2422 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2423 | p->prefixlen); | |
2424 | ||
2425 | /* Unlock bgp_node_get() lock. */ | |
2426 | bgp_unlock_node (rn); | |
2427 | ||
2428 | return 0; | |
2429 | } | |
2430 | \f | |
2431 | void | |
2432 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) | |
2433 | { | |
2434 | struct bgp *bgp; | |
228da428 | 2435 | struct attr attr = { 0 }; |
fb982c25 | 2436 | struct aspath *aspath = { 0 }; |
718e3744 | 2437 | struct prefix p; |
2438 | struct bgp_info binfo; | |
2439 | struct peer *from; | |
2440 | int ret = RMAP_DENYMATCH; | |
fb982c25 | 2441 | |
b2497024 | 2442 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
fb982c25 PJ |
2443 | return; |
2444 | ||
718e3744 | 2445 | bgp = peer->bgp; |
2446 | from = bgp->peer_self; | |
fb982c25 | 2447 | |
718e3744 | 2448 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
2449 | aspath = attr.aspath; | |
2450 | attr.local_pref = bgp->default_local_pref; | |
2451 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); | |
2452 | ||
2453 | if (afi == AFI_IP) | |
2454 | str2prefix ("0.0.0.0/0", &p); | |
2455 | #ifdef HAVE_IPV6 | |
2456 | else if (afi == AFI_IP6) | |
2457 | { | |
fb982c25 PJ |
2458 | struct attr_extra *ae; |
2459 | attr.extra = NULL; | |
2460 | ||
2461 | ae = bgp_attr_extra_get (&attr); | |
2462 | attr.extra = ae; | |
2463 | ||
718e3744 | 2464 | str2prefix ("::/0", &p); |
2465 | ||
2466 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 2467 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
718e3744 | 2468 | IPV6_MAX_BYTELEN); |
fb982c25 | 2469 | ae->mp_nexthop_len = 16; |
718e3744 | 2470 | |
2471 | /* If the peer is on shared nextwork and we have link-local | |
2472 | nexthop set it. */ | |
2473 | if (peer->shared_network | |
2474 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) | |
2475 | { | |
fb982c25 | 2476 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
718e3744 | 2477 | IPV6_MAX_BYTELEN); |
fb982c25 | 2478 | ae->mp_nexthop_len = 32; |
718e3744 | 2479 | } |
2480 | } | |
2481 | #endif /* HAVE_IPV6 */ | |
718e3744 | 2482 | |
2483 | if (peer->default_rmap[afi][safi].name) | |
2484 | { | |
2485 | binfo.peer = bgp->peer_self; | |
2486 | binfo.attr = &attr; | |
2487 | ||
fee0f4c6 | 2488 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
2489 | ||
718e3744 | 2490 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
2491 | RMAP_BGP, &binfo); | |
2492 | ||
fee0f4c6 | 2493 | bgp->peer_self->rmap_type = 0; |
2494 | ||
718e3744 | 2495 | if (ret == RMAP_DENYMATCH) |
2496 | { | |
2497 | bgp_attr_flush (&attr); | |
2498 | withdraw = 1; | |
2499 | } | |
2500 | } | |
2501 | ||
2502 | if (withdraw) | |
2503 | { | |
2504 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) | |
2505 | bgp_default_withdraw_send (peer, afi, safi); | |
2506 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2507 | } | |
2508 | else | |
2509 | { | |
2510 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2511 | bgp_default_update_send (peer, &attr, afi, safi, from); | |
2512 | } | |
fb982c25 PJ |
2513 | |
2514 | bgp_attr_extra_free (&attr); | |
718e3744 | 2515 | aspath_unintern (aspath); |
2516 | } | |
2517 | \f | |
2518 | static void | |
2519 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, | |
fee0f4c6 | 2520 | struct bgp_table *table, int rsclient) |
718e3744 | 2521 | { |
2522 | struct bgp_node *rn; | |
2523 | struct bgp_info *ri; | |
228da428 | 2524 | struct attr attr = { 0 }; |
fb982c25 | 2525 | |
718e3744 | 2526 | if (! table) |
fee0f4c6 | 2527 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
718e3744 | 2528 | |
2529 | if (safi != SAFI_MPLS_VPN | |
2530 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
2531 | bgp_default_originate (peer, afi, safi, 0); | |
2532 | ||
2533 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) | |
2534 | for (ri = rn->info; ri; ri = ri->next) | |
2535 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) | |
2536 | { | |
fee0f4c6 | 2537 | if ( (rsclient) ? |
2538 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) | |
2539 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) | |
718e3744 | 2540 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
2541 | else | |
2542 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); | |
fb982c25 PJ |
2543 | |
2544 | bgp_attr_extra_free (&attr); | |
718e3744 | 2545 | } |
2546 | } | |
2547 | ||
2548 | void | |
2549 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) | |
2550 | { | |
2551 | struct bgp_node *rn; | |
2552 | struct bgp_table *table; | |
2553 | ||
2554 | if (peer->status != Established) | |
2555 | return; | |
2556 | ||
2557 | if (! peer->afc_nego[afi][safi]) | |
2558 | return; | |
2559 | ||
2560 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ | |
2561 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
2562 | return; | |
2563 | ||
2564 | if (safi != SAFI_MPLS_VPN) | |
fee0f4c6 | 2565 | bgp_announce_table (peer, afi, safi, NULL, 0); |
718e3744 | 2566 | else |
2567 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2568 | rn = bgp_route_next(rn)) | |
2569 | if ((table = (rn->info)) != NULL) | |
fee0f4c6 | 2570 | bgp_announce_table (peer, afi, safi, table, 0); |
2571 | ||
2572 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2573 | bgp_announce_table (peer, afi, safi, NULL, 1); | |
718e3744 | 2574 | } |
2575 | ||
2576 | void | |
2577 | bgp_announce_route_all (struct peer *peer) | |
2578 | { | |
2579 | afi_t afi; | |
2580 | safi_t safi; | |
2581 | ||
2582 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2583 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2584 | bgp_announce_route (peer, afi, safi); | |
2585 | } | |
2586 | \f | |
2587 | static void | |
fee0f4c6 | 2588 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
2589 | safi_t safi, struct bgp_table *table) | |
2590 | { | |
2591 | struct bgp_node *rn; | |
2592 | struct bgp_adj_in *ain; | |
2593 | ||
2594 | if (! table) | |
2595 | table = rsclient->bgp->rib[afi][safi]; | |
2596 | ||
2597 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2598 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2599 | { | |
2600 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, | |
2601 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); | |
2602 | } | |
2603 | } | |
2604 | ||
2605 | void | |
2606 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) | |
2607 | { | |
2608 | struct bgp_table *table; | |
2609 | struct bgp_node *rn; | |
2610 | ||
2611 | if (safi != SAFI_MPLS_VPN) | |
2612 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); | |
2613 | ||
2614 | else | |
2615 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; | |
2616 | rn = bgp_route_next (rn)) | |
2617 | if ((table = rn->info) != NULL) | |
2618 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); | |
2619 | } | |
2620 | \f | |
2621 | static void | |
718e3744 | 2622 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
2623 | struct bgp_table *table) | |
2624 | { | |
2625 | int ret; | |
2626 | struct bgp_node *rn; | |
2627 | struct bgp_adj_in *ain; | |
2628 | ||
2629 | if (! table) | |
2630 | table = peer->bgp->rib[afi][safi]; | |
2631 | ||
2632 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2633 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2634 | { | |
2635 | if (ain->peer == peer) | |
2636 | { | |
2637 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, | |
2638 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, | |
2639 | NULL, NULL, 1); | |
2640 | if (ret < 0) | |
2641 | { | |
2642 | bgp_unlock_node (rn); | |
2643 | return; | |
2644 | } | |
2645 | continue; | |
2646 | } | |
2647 | } | |
2648 | } | |
2649 | ||
2650 | void | |
2651 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) | |
2652 | { | |
2653 | struct bgp_node *rn; | |
2654 | struct bgp_table *table; | |
2655 | ||
2656 | if (peer->status != Established) | |
2657 | return; | |
2658 | ||
2659 | if (safi != SAFI_MPLS_VPN) | |
2660 | bgp_soft_reconfig_table (peer, afi, safi, NULL); | |
2661 | else | |
2662 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2663 | rn = bgp_route_next (rn)) | |
2664 | if ((table = rn->info) != NULL) | |
2665 | bgp_soft_reconfig_table (peer, afi, safi, table); | |
2666 | } | |
2667 | \f | |
228da428 CC |
2668 | |
2669 | struct bgp_clear_node_queue | |
2670 | { | |
2671 | struct bgp_node *rn; | |
2672 | enum bgp_clear_route_type purpose; | |
2673 | }; | |
2674 | ||
200df115 | 2675 | static wq_item_status |
0fb58d5d | 2676 | bgp_clear_route_node (struct work_queue *wq, void *data) |
200df115 | 2677 | { |
228da428 CC |
2678 | struct bgp_clear_node_queue *cnq = data; |
2679 | struct bgp_node *rn = cnq->rn; | |
64e580a7 | 2680 | struct peer *peer = wq->spec.data; |
718e3744 | 2681 | struct bgp_info *ri; |
64e580a7 PJ |
2682 | afi_t afi = rn->table->afi; |
2683 | safi_t safi = rn->table->safi; | |
200df115 | 2684 | |
64e580a7 | 2685 | assert (rn && peer); |
200df115 | 2686 | |
64e580a7 | 2687 | for (ri = rn->info; ri; ri = ri->next) |
228da428 | 2688 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
200df115 | 2689 | { |
2690 | /* graceful restart STALE flag set. */ | |
64e580a7 PJ |
2691 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
2692 | && peer->nsf[afi][safi] | |
200df115 | 2693 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
1a392d46 PJ |
2694 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2695 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); | |
200df115 | 2696 | else |
64e580a7 | 2697 | bgp_rib_remove (rn, ri, peer, afi, safi); |
200df115 | 2698 | break; |
2699 | } | |
200df115 | 2700 | return WQ_SUCCESS; |
2701 | } | |
2702 | ||
2703 | static void | |
0fb58d5d | 2704 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
200df115 | 2705 | { |
228da428 CC |
2706 | struct bgp_clear_node_queue *cnq = data; |
2707 | struct bgp_node *rn = cnq->rn; | |
2708 | struct bgp_table *table = rn->table; | |
64e580a7 PJ |
2709 | |
2710 | bgp_unlock_node (rn); | |
228da428 CC |
2711 | bgp_table_unlock (table); |
2712 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); | |
200df115 | 2713 | } |
2714 | ||
2715 | static void | |
94f2b392 | 2716 | bgp_clear_node_complete (struct work_queue *wq) |
200df115 | 2717 | { |
64e580a7 PJ |
2718 | struct peer *peer = wq->spec.data; |
2719 | ||
3e0c78ef | 2720 | /* Tickle FSM to start moving again */ |
ca058a30 | 2721 | BGP_EVENT_ADD (peer, Clearing_Completed); |
228da428 CC |
2722 | |
2723 | peer_unlock (peer); /* bgp_clear_route */ | |
200df115 | 2724 | } |
2725 | ||
2726 | static void | |
64e580a7 | 2727 | bgp_clear_node_queue_init (struct peer *peer) |
200df115 | 2728 | { |
a2943657 | 2729 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
64e580a7 | 2730 | |
a2943657 | 2731 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
64e580a7 PJ |
2732 | #undef CLEAR_QUEUE_NAME_LEN |
2733 | ||
2734 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) | |
200df115 | 2735 | { |
2736 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
2737 | exit (1); | |
2738 | } | |
64e580a7 PJ |
2739 | peer->clear_node_queue->spec.hold = 10; |
2740 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; | |
2741 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; | |
2742 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; | |
2743 | peer->clear_node_queue->spec.max_retries = 0; | |
2744 | ||
2745 | /* we only 'lock' this peer reference when the queue is actually active */ | |
2746 | peer->clear_node_queue->spec.data = peer; | |
200df115 | 2747 | } |
718e3744 | 2748 | |
200df115 | 2749 | static void |
2750 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, | |
228da428 CC |
2751 | struct bgp_table *table, struct peer *rsclient, |
2752 | enum bgp_clear_route_type purpose) | |
200df115 | 2753 | { |
200df115 | 2754 | struct bgp_node *rn; |
2755 | ||
f2c31acb | 2756 | |
718e3744 | 2757 | if (! table) |
fee0f4c6 | 2758 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
64e580a7 | 2759 | |
6cf159b9 | 2760 | /* If still no table => afi/safi isn't configured at all or smth. */ |
2761 | if (! table) | |
2762 | return; | |
65ca75e0 PJ |
2763 | |
2764 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2765 | { | |
f2c31acb PJ |
2766 | struct bgp_info *ri; |
2767 | struct bgp_adj_in *ain; | |
2768 | struct bgp_adj_out *aout; | |
2769 | ||
65ca75e0 PJ |
2770 | if (rn->info == NULL) |
2771 | continue; | |
f2c31acb PJ |
2772 | |
2773 | /* XXX:TODO: This is suboptimal, every non-empty route_node is | |
2774 | * queued for every clearing peer, regardless of whether it is | |
2775 | * relevant to the peer at hand. | |
2776 | * | |
2777 | * Overview: There are 3 different indices which need to be | |
2778 | * scrubbed, potentially, when a peer is removed: | |
2779 | * | |
2780 | * 1 peer's routes visible via the RIB (ie accepted routes) | |
2781 | * 2 peer's routes visible by the (optional) peer's adj-in index | |
2782 | * 3 other routes visible by the peer's adj-out index | |
2783 | * | |
2784 | * 3 there is no hurry in scrubbing, once the struct peer is | |
2785 | * removed from bgp->peer, we could just GC such deleted peer's | |
2786 | * adj-outs at our leisure. | |
2787 | * | |
2788 | * 1 and 2 must be 'scrubbed' in some way, at least made | |
2789 | * invisible via RIB index before peer session is allowed to be | |
2790 | * brought back up. So one needs to know when such a 'search' is | |
2791 | * complete. | |
2792 | * | |
2793 | * Ideally: | |
2794 | * | |
2795 | * - there'd be a single global queue or a single RIB walker | |
2796 | * - rather than tracking which route_nodes still need to be | |
2797 | * examined on a peer basis, we'd track which peers still | |
2798 | * aren't cleared | |
2799 | * | |
2800 | * Given that our per-peer prefix-counts now should be reliable, | |
2801 | * this may actually be achievable. It doesn't seem to be a huge | |
2802 | * problem at this time, | |
2803 | */ | |
2804 | for (ri = rn->info; ri; ri = ri->next) | |
228da428 | 2805 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb | 2806 | { |
228da428 CC |
2807 | struct bgp_clear_node_queue *cnq; |
2808 | ||
2809 | /* both unlocked in bgp_clear_node_queue_del */ | |
2810 | bgp_table_lock (rn->table); | |
2811 | bgp_lock_node (rn); | |
2812 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, | |
2813 | sizeof (struct bgp_clear_node_queue)); | |
2814 | cnq->rn = rn; | |
2815 | cnq->purpose = purpose; | |
2816 | work_queue_add (peer->clear_node_queue, cnq); | |
2817 | break; | |
f2c31acb PJ |
2818 | } |
2819 | ||
2820 | for (ain = rn->adj_in; ain; ain = ain->next) | |
228da428 | 2821 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb PJ |
2822 | { |
2823 | bgp_adj_in_remove (rn, ain); | |
2824 | bgp_unlock_node (rn); | |
2825 | break; | |
2826 | } | |
2827 | for (aout = rn->adj_out; aout; aout = aout->next) | |
228da428 | 2828 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb PJ |
2829 | { |
2830 | bgp_adj_out_remove (rn, aout, peer, afi, safi); | |
2831 | bgp_unlock_node (rn); | |
2832 | break; | |
2833 | } | |
65ca75e0 PJ |
2834 | } |
2835 | return; | |
2836 | } | |
2837 | ||
2838 | void | |
228da428 CC |
2839 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
2840 | enum bgp_clear_route_type purpose) | |
65ca75e0 PJ |
2841 | { |
2842 | struct bgp_node *rn; | |
2843 | struct bgp_table *table; | |
2844 | struct peer *rsclient; | |
2845 | struct listnode *node, *nnode; | |
6cf159b9 | 2846 | |
64e580a7 PJ |
2847 | if (peer->clear_node_queue == NULL) |
2848 | bgp_clear_node_queue_init (peer); | |
200df115 | 2849 | |
ca058a30 PJ |
2850 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
2851 | * Idle until it receives a Clearing_Completed event. This protects | |
2852 | * against peers which flap faster than we can we clear, which could | |
2853 | * lead to: | |
64e580a7 PJ |
2854 | * |
2855 | * a) race with routes from the new session being installed before | |
2856 | * clear_route_node visits the node (to delete the route of that | |
2857 | * peer) | |
2858 | * b) resource exhaustion, clear_route_node likely leads to an entry | |
2859 | * on the process_main queue. Fast-flapping could cause that queue | |
2860 | * to grow and grow. | |
200df115 | 2861 | */ |
ca058a30 PJ |
2862 | if (!peer->clear_node_queue->thread) |
2863 | peer_lock (peer); /* bgp_clear_node_complete */ | |
fee0f4c6 | 2864 | |
228da428 | 2865 | switch (purpose) |
fee0f4c6 | 2866 | { |
228da428 CC |
2867 | case BGP_CLEAR_ROUTE_NORMAL: |
2868 | if (safi != SAFI_MPLS_VPN) | |
2869 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); | |
2870 | else | |
2871 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2872 | rn = bgp_route_next (rn)) | |
2873 | if ((table = rn->info) != NULL) | |
2874 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); | |
2875 | ||
2876 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) | |
2877 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], | |
2878 | PEER_FLAG_RSERVER_CLIENT)) | |
2879 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); | |
2880 | break; | |
2881 | ||
2882 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: | |
2883 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); | |
2884 | break; | |
2885 | ||
2886 | default: | |
2887 | assert (0); | |
2888 | break; | |
fee0f4c6 | 2889 | } |
65ca75e0 | 2890 | |
ca058a30 | 2891 | /* If no routes were cleared, nothing was added to workqueue, the |
f2c31acb PJ |
2892 | * completion function won't be run by workqueue code - call it here. |
2893 | * XXX: Actually, this assumption doesn't hold, see | |
2894 | * bgp_clear_route_table(), we queue all non-empty nodes. | |
ca058a30 PJ |
2895 | * |
2896 | * Additionally, there is a presumption in FSM that clearing is only | |
f2c31acb PJ |
2897 | * really needed if peer state is Established - peers in |
2898 | * pre-Established states shouldn't have any route-update state | |
2899 | * associated with them (in or out). | |
ca058a30 | 2900 | * |
f2c31acb PJ |
2901 | * We still can get here in pre-Established though, through |
2902 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity | |
2903 | * check to ensure the assumption above holds. | |
ca058a30 PJ |
2904 | * |
2905 | * At some future point, this check could be move to the top of the | |
2906 | * function, and do a quick early-return when state is | |
2907 | * pre-Established, avoiding above list and table scans. Once we're | |
2908 | * sure it is safe.. | |
65ca75e0 PJ |
2909 | */ |
2910 | if (!peer->clear_node_queue->thread) | |
2911 | bgp_clear_node_complete (peer->clear_node_queue); | |
718e3744 | 2912 | } |
2913 | ||
2914 | void | |
2915 | bgp_clear_route_all (struct peer *peer) | |
2916 | { | |
2917 | afi_t afi; | |
2918 | safi_t safi; | |
2919 | ||
2920 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2921 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
228da428 | 2922 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
718e3744 | 2923 | } |
2924 | ||
2925 | void | |
2926 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) | |
2927 | { | |
2928 | struct bgp_table *table; | |
2929 | struct bgp_node *rn; | |
2930 | struct bgp_adj_in *ain; | |
2931 | ||
2932 | table = peer->bgp->rib[afi][safi]; | |
2933 | ||
2934 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2935 | for (ain = rn->adj_in; ain ; ain = ain->next) | |
2936 | if (ain->peer == peer) | |
2937 | { | |
2938 | bgp_adj_in_remove (rn, ain); | |
2939 | bgp_unlock_node (rn); | |
2940 | break; | |
2941 | } | |
2942 | } | |
93406d87 | 2943 | |
2944 | void | |
2945 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) | |
2946 | { | |
2947 | struct bgp_node *rn; | |
2948 | struct bgp_info *ri; | |
2949 | struct bgp_table *table; | |
2950 | ||
2951 | table = peer->bgp->rib[afi][safi]; | |
2952 | ||
2953 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2954 | { | |
2955 | for (ri = rn->info; ri; ri = ri->next) | |
2956 | if (ri->peer == peer) | |
2957 | { | |
2958 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2959 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
2960 | break; | |
2961 | } | |
2962 | } | |
2963 | } | |
718e3744 | 2964 | \f |
2965 | /* Delete all kernel routes. */ | |
2966 | void | |
66e5cd87 | 2967 | bgp_cleanup_routes (void) |
718e3744 | 2968 | { |
2969 | struct bgp *bgp; | |
1eb8ef25 | 2970 | struct listnode *node, *nnode; |
718e3744 | 2971 | struct bgp_node *rn; |
2972 | struct bgp_table *table; | |
2973 | struct bgp_info *ri; | |
2974 | ||
1eb8ef25 | 2975 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 2976 | { |
2977 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; | |
2978 | ||
2979 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2980 | for (ri = rn->info; ri; ri = ri->next) | |
2981 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
2982 | && ri->type == ZEBRA_ROUTE_BGP | |
2983 | && ri->sub_type == BGP_ROUTE_NORMAL) | |
2984 | bgp_zebra_withdraw (&rn->p, ri); | |
2985 | ||
2986 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; | |
2987 | ||
2988 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2989 | for (ri = rn->info; ri; ri = ri->next) | |
2990 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
2991 | && ri->type == ZEBRA_ROUTE_BGP | |
2992 | && ri->sub_type == BGP_ROUTE_NORMAL) | |
2993 | bgp_zebra_withdraw (&rn->p, ri); | |
2994 | } | |
2995 | } | |
2996 | ||
2997 | void | |
66e5cd87 | 2998 | bgp_reset (void) |
718e3744 | 2999 | { |
3000 | vty_reset (); | |
3001 | bgp_zclient_reset (); | |
3002 | access_list_reset (); | |
3003 | prefix_list_reset (); | |
3004 | } | |
3005 | \f | |
3006 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr | |
3007 | value. */ | |
3008 | int | |
3009 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) | |
3010 | { | |
3011 | u_char *pnt; | |
3012 | u_char *lim; | |
3013 | struct prefix p; | |
3014 | int psize; | |
3015 | int ret; | |
3016 | ||
3017 | /* Check peer status. */ | |
3018 | if (peer->status != Established) | |
3019 | return 0; | |
3020 | ||
3021 | pnt = packet->nlri; | |
3022 | lim = pnt + packet->length; | |
3023 | ||
3024 | for (; pnt < lim; pnt += psize) | |
3025 | { | |
3026 | /* Clear prefix structure. */ | |
3027 | memset (&p, 0, sizeof (struct prefix)); | |
3028 | ||
3029 | /* Fetch prefix length. */ | |
3030 | p.prefixlen = *pnt++; | |
3031 | p.family = afi2family (packet->afi); | |
3032 | ||
3033 | /* Already checked in nlri_sanity_check(). We do double check | |
3034 | here. */ | |
3035 | if ((packet->afi == AFI_IP && p.prefixlen > 32) | |
3036 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) | |
3037 | return -1; | |
3038 | ||
3039 | /* Packet size overflow check. */ | |
3040 | psize = PSIZE (p.prefixlen); | |
3041 | ||
3042 | /* When packet overflow occur return immediately. */ | |
3043 | if (pnt + psize > lim) | |
3044 | return -1; | |
3045 | ||
3046 | /* Fetch prefix from NLRI packet. */ | |
3047 | memcpy (&p.u.prefix, pnt, psize); | |
3048 | ||
3049 | /* Check address. */ | |
3050 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) | |
3051 | { | |
3052 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) | |
3053 | { | |
f5ba3874 | 3054 | /* |
3055 | * From draft-ietf-idr-bgp4-22, Section 6.3: | |
3056 | * If a BGP router receives an UPDATE message with a | |
3057 | * semantically incorrect NLRI field, in which a prefix is | |
3058 | * semantically incorrect (eg. an unexpected multicast IP | |
3059 | * address), it should ignore the prefix. | |
3060 | */ | |
718e3744 | 3061 | zlog (peer->log, LOG_ERR, |
3062 | "IPv4 unicast NLRI is multicast address %s", | |
3063 | inet_ntoa (p.u.prefix4)); | |
f5ba3874 | 3064 | |
718e3744 | 3065 | return -1; |
3066 | } | |
3067 | } | |
3068 | ||
3069 | #ifdef HAVE_IPV6 | |
3070 | /* Check address. */ | |
3071 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) | |
3072 | { | |
3073 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3074 | { | |
3075 | char buf[BUFSIZ]; | |
3076 | ||
3077 | zlog (peer->log, LOG_WARNING, | |
3078 | "IPv6 link-local NLRI received %s ignore this NLRI", | |
3079 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); | |
3080 | ||
3081 | continue; | |
3082 | } | |
3083 | } | |
3084 | #endif /* HAVE_IPV6 */ | |
3085 | ||
3086 | /* Normal process. */ | |
3087 | if (attr) | |
3088 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, | |
3089 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); | |
3090 | else | |
3091 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, | |
3092 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); | |
3093 | ||
3094 | /* Address family configuration mismatch or maximum-prefix count | |
3095 | overflow. */ | |
3096 | if (ret < 0) | |
3097 | return -1; | |
3098 | } | |
3099 | ||
3100 | /* Packet length consistency check. */ | |
3101 | if (pnt != lim) | |
3102 | return -1; | |
3103 | ||
3104 | return 0; | |
3105 | } | |
3106 | ||
3107 | /* NLRI encode syntax check routine. */ | |
3108 | int | |
3109 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, | |
3110 | bgp_size_t length) | |
3111 | { | |
3112 | u_char *end; | |
3113 | u_char prefixlen; | |
3114 | int psize; | |
3115 | ||
3116 | end = pnt + length; | |
3117 | ||
3118 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for | |
3119 | syntactic validity. If the field is syntactically incorrect, | |
3120 | then the Error Subcode is set to Invalid Network Field. */ | |
3121 | ||
3122 | while (pnt < end) | |
3123 | { | |
3124 | prefixlen = *pnt++; | |
3125 | ||
3126 | /* Prefix length check. */ | |
3127 | if ((afi == AFI_IP && prefixlen > 32) | |
3128 | || (afi == AFI_IP6 && prefixlen > 128)) | |
3129 | { | |
3130 | plog_err (peer->log, | |
3131 | "%s [Error] Update packet error (wrong prefix length %d)", | |
3132 | peer->host, prefixlen); | |
3133 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3134 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3135 | return -1; | |
3136 | } | |
3137 | ||
3138 | /* Packet size overflow check. */ | |
3139 | psize = PSIZE (prefixlen); | |
3140 | ||
3141 | if (pnt + psize > end) | |
3142 | { | |
3143 | plog_err (peer->log, | |
3144 | "%s [Error] Update packet error" | |
3145 | " (prefix data overflow prefix size is %d)", | |
3146 | peer->host, psize); | |
3147 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3148 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3149 | return -1; | |
3150 | } | |
3151 | ||
3152 | pnt += psize; | |
3153 | } | |
3154 | ||
3155 | /* Packet length consistency check. */ | |
3156 | if (pnt != end) | |
3157 | { | |
3158 | plog_err (peer->log, | |
3159 | "%s [Error] Update packet error" | |
3160 | " (prefix length mismatch with total length)", | |
3161 | peer->host); | |
3162 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3163 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3164 | return -1; | |
3165 | } | |
3166 | return 0; | |
3167 | } | |
3168 | \f | |
94f2b392 | 3169 | static struct bgp_static * |
66e5cd87 | 3170 | bgp_static_new (void) |
718e3744 | 3171 | { |
393deb9b | 3172 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
718e3744 | 3173 | } |
3174 | ||
94f2b392 | 3175 | static void |
718e3744 | 3176 | bgp_static_free (struct bgp_static *bgp_static) |
3177 | { | |
3178 | if (bgp_static->rmap.name) | |
3179 | free (bgp_static->rmap.name); | |
3180 | XFREE (MTYPE_BGP_STATIC, bgp_static); | |
3181 | } | |
3182 | ||
94f2b392 | 3183 | static void |
fee0f4c6 | 3184 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
3185 | struct prefix *p, afi_t afi, safi_t safi) | |
3186 | { | |
3187 | struct bgp_node *rn; | |
3188 | struct bgp_info *ri; | |
3189 | ||
3190 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); | |
3191 | ||
3192 | /* Check selected route and self inserted route. */ | |
3193 | for (ri = rn->info; ri; ri = ri->next) | |
3194 | if (ri->peer == bgp->peer_self | |
3195 | && ri->type == ZEBRA_ROUTE_BGP | |
3196 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3197 | break; | |
3198 | ||
3199 | /* Withdraw static BGP route from routing table. */ | |
3200 | if (ri) | |
3201 | { | |
fee0f4c6 | 3202 | bgp_info_delete (rn, ri); |
1a392d46 | 3203 | bgp_process (bgp, rn, afi, safi); |
fee0f4c6 | 3204 | } |
3205 | ||
3206 | /* Unlock bgp_node_lookup. */ | |
3207 | bgp_unlock_node (rn); | |
3208 | } | |
3209 | ||
94f2b392 | 3210 | static void |
fee0f4c6 | 3211 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
fb982c25 PJ |
3212 | struct bgp_static *bgp_static, |
3213 | afi_t afi, safi_t safi) | |
fee0f4c6 | 3214 | { |
3215 | struct bgp_node *rn; | |
3216 | struct bgp_info *ri; | |
3217 | struct bgp_info *new; | |
3218 | struct bgp_info info; | |
fee0f4c6 | 3219 | struct attr *attr_new; |
fb982c25 PJ |
3220 | struct attr attr = {0 }; |
3221 | struct attr new_attr = { .extra = 0 }; | |
fee0f4c6 | 3222 | struct bgp *bgp; |
3223 | int ret; | |
3224 | char buf[SU_ADDRSTRLEN]; | |
3225 | ||
3226 | bgp = rsclient->bgp; | |
3227 | ||
06e110f9 PJ |
3228 | assert (bgp_static); |
3229 | if (!bgp_static) | |
3230 | return; | |
3231 | ||
fee0f4c6 | 3232 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
3233 | ||
3234 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
06e110f9 PJ |
3235 | |
3236 | attr.nexthop = bgp_static->igpnexthop; | |
3237 | attr.med = bgp_static->igpmetric; | |
3238 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
41367172 | 3239 | |
41367172 PJ |
3240 | if (bgp_static->atomic) |
3241 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3242 | ||
fee0f4c6 | 3243 | /* Apply network route-map for export to this rsclient. */ |
3244 | if (bgp_static->rmap.name) | |
3245 | { | |
fb982c25 | 3246 | struct attr attr_tmp = attr; |
fee0f4c6 | 3247 | info.peer = rsclient; |
fb982c25 PJ |
3248 | info.attr = &attr_tmp; |
3249 | ||
fee0f4c6 | 3250 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
3251 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); | |
3252 | ||
3253 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); | |
3254 | ||
3255 | rsclient->rmap_type = 0; | |
3256 | ||
3257 | if (ret == RMAP_DENYMATCH) | |
3258 | { | |
3259 | /* Free uninterned attribute. */ | |
fb982c25 | 3260 | bgp_attr_flush (&attr_tmp); |
fee0f4c6 | 3261 | |
3262 | /* Unintern original. */ | |
3263 | aspath_unintern (attr.aspath); | |
3264 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); | |
fb982c25 PJ |
3265 | bgp_attr_extra_free (&attr); |
3266 | ||
fee0f4c6 | 3267 | return; |
3268 | } | |
fb982c25 | 3269 | attr_new = bgp_attr_intern (&attr_tmp); |
fee0f4c6 | 3270 | } |
3271 | else | |
3272 | attr_new = bgp_attr_intern (&attr); | |
fb982c25 | 3273 | |
7badc263 | 3274 | bgp_attr_dup(&new_attr, attr_new); |
fb982c25 | 3275 | |
fee0f4c6 | 3276 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3277 | ||
fb982c25 PJ |
3278 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
3279 | == RMAP_DENY) | |
3280 | { | |
fee0f4c6 | 3281 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
3282 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 3283 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 3284 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
3285 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
3286 | p->prefixlen, rsclient->host); | |
3287 | ||
3288 | bgp->peer_self->rmap_type = 0; | |
3289 | ||
3290 | bgp_attr_unintern (attr_new); | |
3291 | aspath_unintern (attr.aspath); | |
fb982c25 | 3292 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3293 | |
3294 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); | |
3295 | ||
3296 | return; | |
fb982c25 | 3297 | } |
fee0f4c6 | 3298 | |
3299 | bgp->peer_self->rmap_type = 0; | |
3300 | ||
3301 | bgp_attr_unintern (attr_new); | |
3302 | attr_new = bgp_attr_intern (&new_attr); | |
7badc263 | 3303 | bgp_attr_extra_free (&new_attr); |
fee0f4c6 | 3304 | |
3305 | for (ri = rn->info; ri; ri = ri->next) | |
3306 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3307 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3308 | break; | |
3309 | ||
3310 | if (ri) | |
3311 | { | |
8d45210e AS |
3312 | if (attrhash_cmp (ri->attr, attr_new) && |
3313 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
fee0f4c6 | 3314 | { |
3315 | bgp_unlock_node (rn); | |
3316 | bgp_attr_unintern (attr_new); | |
3317 | aspath_unintern (attr.aspath); | |
fb982c25 | 3318 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3319 | return; |
3320 | } | |
3321 | else | |
3322 | { | |
3323 | /* The attribute is changed. */ | |
1a392d46 | 3324 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 3325 | |
3326 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3327 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3328 | bgp_info_restore(rn, ri); | |
fee0f4c6 | 3329 | bgp_attr_unintern (ri->attr); |
3330 | ri->attr = attr_new; | |
65957886 | 3331 | ri->uptime = bgp_clock (); |
fee0f4c6 | 3332 | |
3333 | /* Process change. */ | |
3334 | bgp_process (bgp, rn, afi, safi); | |
3335 | bgp_unlock_node (rn); | |
3336 | aspath_unintern (attr.aspath); | |
fb982c25 | 3337 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3338 | return; |
fb982c25 | 3339 | } |
fee0f4c6 | 3340 | } |
fb982c25 | 3341 | |
fee0f4c6 | 3342 | /* Make new BGP info. */ |
3343 | new = bgp_info_new (); | |
3344 | new->type = ZEBRA_ROUTE_BGP; | |
3345 | new->sub_type = BGP_ROUTE_STATIC; | |
3346 | new->peer = bgp->peer_self; | |
3347 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3348 | new->attr = attr_new; | |
65957886 | 3349 | new->uptime = bgp_clock (); |
fee0f4c6 | 3350 | |
3351 | /* Register new BGP information. */ | |
3352 | bgp_info_add (rn, new); | |
200df115 | 3353 | |
3354 | /* route_node_get lock */ | |
3355 | bgp_unlock_node (rn); | |
3356 | ||
fee0f4c6 | 3357 | /* Process change. */ |
3358 | bgp_process (bgp, rn, afi, safi); | |
3359 | ||
3360 | /* Unintern original. */ | |
3361 | aspath_unintern (attr.aspath); | |
fb982c25 | 3362 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3363 | } |
3364 | ||
94f2b392 | 3365 | static void |
fee0f4c6 | 3366 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
718e3744 | 3367 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
3368 | { | |
3369 | struct bgp_node *rn; | |
3370 | struct bgp_info *ri; | |
3371 | struct bgp_info *new; | |
3372 | struct bgp_info info; | |
fb982c25 | 3373 | struct attr attr = { 0 }; |
718e3744 | 3374 | struct attr *attr_new; |
3375 | int ret; | |
3376 | ||
dd8103a9 PJ |
3377 | assert (bgp_static); |
3378 | if (!bgp_static) | |
3379 | return; | |
3380 | ||
fee0f4c6 | 3381 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3382 | |
3383 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
dd8103a9 PJ |
3384 | |
3385 | attr.nexthop = bgp_static->igpnexthop; | |
3386 | attr.med = bgp_static->igpmetric; | |
3387 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
718e3744 | 3388 | |
41367172 PJ |
3389 | if (bgp_static->atomic) |
3390 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3391 | ||
718e3744 | 3392 | /* Apply route-map. */ |
3393 | if (bgp_static->rmap.name) | |
3394 | { | |
fb982c25 | 3395 | struct attr attr_tmp = attr; |
718e3744 | 3396 | info.peer = bgp->peer_self; |
286e1e71 | 3397 | info.attr = &attr_tmp; |
718e3744 | 3398 | |
fee0f4c6 | 3399 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3400 | ||
718e3744 | 3401 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
286e1e71 | 3402 | |
fee0f4c6 | 3403 | bgp->peer_self->rmap_type = 0; |
3404 | ||
718e3744 | 3405 | if (ret == RMAP_DENYMATCH) |
3406 | { | |
3407 | /* Free uninterned attribute. */ | |
286e1e71 | 3408 | bgp_attr_flush (&attr_tmp); |
718e3744 | 3409 | |
3410 | /* Unintern original. */ | |
3411 | aspath_unintern (attr.aspath); | |
fb982c25 | 3412 | bgp_attr_extra_free (&attr); |
718e3744 | 3413 | bgp_static_withdraw (bgp, p, afi, safi); |
3414 | return; | |
3415 | } | |
286e1e71 | 3416 | attr_new = bgp_attr_intern (&attr_tmp); |
718e3744 | 3417 | } |
286e1e71 | 3418 | else |
3419 | attr_new = bgp_attr_intern (&attr); | |
718e3744 | 3420 | |
3421 | for (ri = rn->info; ri; ri = ri->next) | |
3422 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3423 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3424 | break; | |
3425 | ||
3426 | if (ri) | |
3427 | { | |
8d45210e AS |
3428 | if (attrhash_cmp (ri->attr, attr_new) && |
3429 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
718e3744 | 3430 | { |
3431 | bgp_unlock_node (rn); | |
3432 | bgp_attr_unintern (attr_new); | |
3433 | aspath_unintern (attr.aspath); | |
fb982c25 | 3434 | bgp_attr_extra_free (&attr); |
718e3744 | 3435 | return; |
3436 | } | |
3437 | else | |
3438 | { | |
3439 | /* The attribute is changed. */ | |
1a392d46 | 3440 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 3441 | |
3442 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3443 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3444 | bgp_info_restore(rn, ri); | |
3445 | else | |
3446 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3447 | bgp_attr_unintern (ri->attr); |
3448 | ri->attr = attr_new; | |
65957886 | 3449 | ri->uptime = bgp_clock (); |
718e3744 | 3450 | |
3451 | /* Process change. */ | |
3452 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
3453 | bgp_process (bgp, rn, afi, safi); | |
3454 | bgp_unlock_node (rn); | |
3455 | aspath_unintern (attr.aspath); | |
fb982c25 | 3456 | bgp_attr_extra_free (&attr); |
718e3744 | 3457 | return; |
3458 | } | |
3459 | } | |
3460 | ||
3461 | /* Make new BGP info. */ | |
3462 | new = bgp_info_new (); | |
3463 | new->type = ZEBRA_ROUTE_BGP; | |
3464 | new->sub_type = BGP_ROUTE_STATIC; | |
3465 | new->peer = bgp->peer_self; | |
3466 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3467 | new->attr = attr_new; | |
65957886 | 3468 | new->uptime = bgp_clock (); |
718e3744 | 3469 | |
3470 | /* Aggregate address increment. */ | |
3471 | bgp_aggregate_increment (bgp, p, new, afi, safi); | |
3472 | ||
3473 | /* Register new BGP information. */ | |
3474 | bgp_info_add (rn, new); | |
200df115 | 3475 | |
3476 | /* route_node_get lock */ | |
3477 | bgp_unlock_node (rn); | |
3478 | ||
718e3744 | 3479 | /* Process change. */ |
3480 | bgp_process (bgp, rn, afi, safi); | |
3481 | ||
3482 | /* Unintern original. */ | |
3483 | aspath_unintern (attr.aspath); | |
fb982c25 | 3484 | bgp_attr_extra_free (&attr); |
718e3744 | 3485 | } |
3486 | ||
fee0f4c6 | 3487 | void |
3488 | bgp_static_update (struct bgp *bgp, struct prefix *p, | |
3489 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
3490 | { | |
3491 | struct peer *rsclient; | |
1eb8ef25 | 3492 | struct listnode *node, *nnode; |
fee0f4c6 | 3493 | |
3494 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); | |
3495 | ||
1eb8ef25 | 3496 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 3497 | { |
da5b30f6 PJ |
3498 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
3499 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); | |
fee0f4c6 | 3500 | } |
3501 | } | |
3502 | ||
94f2b392 | 3503 | static void |
4c9641ba ML |
3504 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3505 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3506 | { |
3507 | struct bgp_node *rn; | |
3508 | struct bgp_info *new; | |
fb982c25 | 3509 | |
fee0f4c6 | 3510 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3511 | |
3512 | /* Make new BGP info. */ | |
3513 | new = bgp_info_new (); | |
3514 | new->type = ZEBRA_ROUTE_BGP; | |
3515 | new->sub_type = BGP_ROUTE_STATIC; | |
3516 | new->peer = bgp->peer_self; | |
3517 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); | |
3518 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
65957886 | 3519 | new->uptime = bgp_clock (); |
fb982c25 PJ |
3520 | new->extra = bgp_info_extra_new(); |
3521 | memcpy (new->extra->tag, tag, 3); | |
718e3744 | 3522 | |
3523 | /* Aggregate address increment. */ | |
200df115 | 3524 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
718e3744 | 3525 | |
3526 | /* Register new BGP information. */ | |
200df115 | 3527 | bgp_info_add (rn, new); |
718e3744 | 3528 | |
200df115 | 3529 | /* route_node_get lock */ |
3530 | bgp_unlock_node (rn); | |
3531 | ||
718e3744 | 3532 | /* Process change. */ |
3533 | bgp_process (bgp, rn, afi, safi); | |
3534 | } | |
3535 | ||
3536 | void | |
3537 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, | |
3538 | safi_t safi) | |
3539 | { | |
3540 | struct bgp_node *rn; | |
3541 | struct bgp_info *ri; | |
3542 | ||
fee0f4c6 | 3543 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3544 | |
3545 | /* Check selected route and self inserted route. */ | |
3546 | for (ri = rn->info; ri; ri = ri->next) | |
3547 | if (ri->peer == bgp->peer_self | |
3548 | && ri->type == ZEBRA_ROUTE_BGP | |
3549 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3550 | break; | |
3551 | ||
3552 | /* Withdraw static BGP route from routing table. */ | |
3553 | if (ri) | |
3554 | { | |
3555 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3556 | bgp_info_delete (rn, ri); |
1a392d46 | 3557 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3558 | } |
3559 | ||
3560 | /* Unlock bgp_node_lookup. */ | |
3561 | bgp_unlock_node (rn); | |
3562 | } | |
3563 | ||
fee0f4c6 | 3564 | void |
3565 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) | |
3566 | { | |
3567 | struct bgp_static *bgp_static; | |
3568 | struct bgp *bgp; | |
3569 | struct bgp_node *rn; | |
3570 | struct prefix *p; | |
3571 | ||
3572 | bgp = rsclient->bgp; | |
3573 | ||
3574 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3575 | if ((bgp_static = rn->info) != NULL) | |
3576 | { | |
3577 | p = &rn->p; | |
3578 | ||
3579 | bgp_static_update_rsclient (rsclient, p, bgp_static, | |
3580 | afi, safi); | |
3581 | } | |
3582 | } | |
3583 | ||
94f2b392 | 3584 | static void |
4c9641ba ML |
3585 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3586 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3587 | { |
3588 | struct bgp_node *rn; | |
3589 | struct bgp_info *ri; | |
3590 | ||
fee0f4c6 | 3591 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3592 | |
3593 | /* Check selected route and self inserted route. */ | |
3594 | for (ri = rn->info; ri; ri = ri->next) | |
3595 | if (ri->peer == bgp->peer_self | |
3596 | && ri->type == ZEBRA_ROUTE_BGP | |
3597 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3598 | break; | |
3599 | ||
3600 | /* Withdraw static BGP route from routing table. */ | |
3601 | if (ri) | |
3602 | { | |
3603 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3604 | bgp_info_delete (rn, ri); |
1a392d46 | 3605 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3606 | } |
3607 | ||
3608 | /* Unlock bgp_node_lookup. */ | |
3609 | bgp_unlock_node (rn); | |
3610 | } | |
3611 | ||
3612 | /* Configure static BGP network. When user don't run zebra, static | |
3613 | route should be installed as valid. */ | |
94f2b392 | 3614 | static int |
fd79ac91 | 3615 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
c8f3fe30 | 3616 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
718e3744 | 3617 | { |
3618 | int ret; | |
3619 | struct prefix p; | |
3620 | struct bgp_static *bgp_static; | |
3621 | struct bgp_node *rn; | |
41367172 | 3622 | u_char need_update = 0; |
718e3744 | 3623 | |
3624 | /* Convert IP prefix string to struct prefix. */ | |
3625 | ret = str2prefix (ip_str, &p); | |
3626 | if (! ret) | |
3627 | { | |
3628 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3629 | return CMD_WARNING; | |
3630 | } | |
3631 | #ifdef HAVE_IPV6 | |
3632 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3633 | { | |
3634 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3635 | VTY_NEWLINE); | |
3636 | return CMD_WARNING; | |
3637 | } | |
3638 | #endif /* HAVE_IPV6 */ | |
3639 | ||
3640 | apply_mask (&p); | |
3641 | ||
3642 | /* Set BGP static route configuration. */ | |
3643 | rn = bgp_node_get (bgp->route[afi][safi], &p); | |
3644 | ||
3645 | if (rn->info) | |
3646 | { | |
3647 | /* Configuration change. */ | |
3648 | bgp_static = rn->info; | |
3649 | ||
3650 | /* Check previous routes are installed into BGP. */ | |
c8f3fe30 PJ |
3651 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
3652 | need_update = 1; | |
41367172 | 3653 | |
718e3744 | 3654 | bgp_static->backdoor = backdoor; |
41367172 | 3655 | |
718e3744 | 3656 | if (rmap) |
3657 | { | |
3658 | if (bgp_static->rmap.name) | |
3659 | free (bgp_static->rmap.name); | |
3660 | bgp_static->rmap.name = strdup (rmap); | |
3661 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); | |
3662 | } | |
3663 | else | |
3664 | { | |
3665 | if (bgp_static->rmap.name) | |
3666 | free (bgp_static->rmap.name); | |
3667 | bgp_static->rmap.name = NULL; | |
3668 | bgp_static->rmap.map = NULL; | |
3669 | bgp_static->valid = 0; | |
3670 | } | |
3671 | bgp_unlock_node (rn); | |
3672 | } | |
3673 | else | |
3674 | { | |
3675 | /* New configuration. */ | |
3676 | bgp_static = bgp_static_new (); | |
3677 | bgp_static->backdoor = backdoor; | |
3678 | bgp_static->valid = 0; | |
3679 | bgp_static->igpmetric = 0; | |
3680 | bgp_static->igpnexthop.s_addr = 0; | |
41367172 | 3681 | |
718e3744 | 3682 | if (rmap) |
3683 | { | |
3684 | if (bgp_static->rmap.name) | |
3685 | free (bgp_static->rmap.name); | |
3686 | bgp_static->rmap.name = strdup (rmap); | |
3687 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); | |
3688 | } | |
3689 | rn->info = bgp_static; | |
3690 | } | |
3691 | ||
3692 | /* If BGP scan is not enabled, we should install this route here. */ | |
3693 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3694 | { | |
3695 | bgp_static->valid = 1; | |
3696 | ||
3697 | if (need_update) | |
3698 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3699 | ||
3700 | if (! bgp_static->backdoor) | |
3701 | bgp_static_update (bgp, &p, bgp_static, afi, safi); | |
3702 | } | |
3703 | ||
3704 | return CMD_SUCCESS; | |
3705 | } | |
3706 | ||
3707 | /* Configure static BGP network. */ | |
94f2b392 | 3708 | static int |
fd79ac91 | 3709 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
4c9641ba | 3710 | afi_t afi, safi_t safi) |
718e3744 | 3711 | { |
3712 | int ret; | |
3713 | struct prefix p; | |
3714 | struct bgp_static *bgp_static; | |
3715 | struct bgp_node *rn; | |
3716 | ||
3717 | /* Convert IP prefix string to struct prefix. */ | |
3718 | ret = str2prefix (ip_str, &p); | |
3719 | if (! ret) | |
3720 | { | |
3721 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3722 | return CMD_WARNING; | |
3723 | } | |
3724 | #ifdef HAVE_IPV6 | |
3725 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3726 | { | |
3727 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3728 | VTY_NEWLINE); | |
3729 | return CMD_WARNING; | |
3730 | } | |
3731 | #endif /* HAVE_IPV6 */ | |
3732 | ||
3733 | apply_mask (&p); | |
3734 | ||
3735 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); | |
3736 | if (! rn) | |
3737 | { | |
3738 | vty_out (vty, "%% Can't find specified static route configuration.%s", | |
3739 | VTY_NEWLINE); | |
3740 | return CMD_WARNING; | |
3741 | } | |
3742 | ||
3743 | bgp_static = rn->info; | |
41367172 | 3744 | |
718e3744 | 3745 | /* Update BGP RIB. */ |
3746 | if (! bgp_static->backdoor) | |
3747 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3748 | ||
3749 | /* Clear configuration. */ | |
3750 | bgp_static_free (bgp_static); | |
3751 | rn->info = NULL; | |
3752 | bgp_unlock_node (rn); | |
3753 | bgp_unlock_node (rn); | |
3754 | ||
3755 | return CMD_SUCCESS; | |
3756 | } | |
3757 | ||
3758 | /* Called from bgp_delete(). Delete all static routes from the BGP | |
3759 | instance. */ | |
3760 | void | |
3761 | bgp_static_delete (struct bgp *bgp) | |
3762 | { | |
3763 | afi_t afi; | |
3764 | safi_t safi; | |
3765 | struct bgp_node *rn; | |
3766 | struct bgp_node *rm; | |
3767 | struct bgp_table *table; | |
3768 | struct bgp_static *bgp_static; | |
3769 | ||
3770 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3771 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3772 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3773 | if (rn->info != NULL) | |
3774 | { | |
3775 | if (safi == SAFI_MPLS_VPN) | |
3776 | { | |
3777 | table = rn->info; | |
3778 | ||
3779 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3780 | { | |
3781 | bgp_static = rn->info; | |
3782 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, | |
3783 | AFI_IP, SAFI_MPLS_VPN, | |
3784 | (struct prefix_rd *)&rn->p, | |
3785 | bgp_static->tag); | |
3786 | bgp_static_free (bgp_static); | |
3787 | rn->info = NULL; | |
3788 | bgp_unlock_node (rn); | |
3789 | } | |
3790 | } | |
3791 | else | |
3792 | { | |
3793 | bgp_static = rn->info; | |
3794 | bgp_static_withdraw (bgp, &rn->p, afi, safi); | |
3795 | bgp_static_free (bgp_static); | |
3796 | rn->info = NULL; | |
3797 | bgp_unlock_node (rn); | |
3798 | } | |
3799 | } | |
3800 | } | |
3801 | ||
3802 | int | |
fd79ac91 | 3803 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
3804 | const char *tag_str) | |
718e3744 | 3805 | { |
3806 | int ret; | |
3807 | struct prefix p; | |
3808 | struct prefix_rd prd; | |
3809 | struct bgp *bgp; | |
3810 | struct bgp_node *prn; | |
3811 | struct bgp_node *rn; | |
3812 | struct bgp_table *table; | |
3813 | struct bgp_static *bgp_static; | |
3814 | u_char tag[3]; | |
3815 | ||
3816 | bgp = vty->index; | |
3817 | ||
3818 | ret = str2prefix (ip_str, &p); | |
3819 | if (! ret) | |
3820 | { | |
3821 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3822 | return CMD_WARNING; | |
3823 | } | |
3824 | apply_mask (&p); | |
3825 | ||
3826 | ret = str2prefix_rd (rd_str, &prd); | |
3827 | if (! ret) | |
3828 | { | |
3829 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3830 | return CMD_WARNING; | |
3831 | } | |
3832 | ||
3833 | ret = str2tag (tag_str, tag); | |
3834 | if (! ret) | |
3835 | { | |
3836 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3837 | return CMD_WARNING; | |
3838 | } | |
3839 | ||
3840 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
3841 | (struct prefix *)&prd); | |
3842 | if (prn->info == NULL) | |
64e580a7 | 3843 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 3844 | else |
3845 | bgp_unlock_node (prn); | |
3846 | table = prn->info; | |
3847 | ||
3848 | rn = bgp_node_get (table, &p); | |
3849 | ||
3850 | if (rn->info) | |
3851 | { | |
3852 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); | |
3853 | bgp_unlock_node (rn); | |
3854 | } | |
3855 | else | |
3856 | { | |
3857 | /* New configuration. */ | |
3858 | bgp_static = bgp_static_new (); | |
3859 | bgp_static->valid = 1; | |
3860 | memcpy (bgp_static->tag, tag, 3); | |
3861 | rn->info = bgp_static; | |
3862 | ||
3863 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
3864 | } | |
3865 | ||
3866 | return CMD_SUCCESS; | |
3867 | } | |
3868 | ||
3869 | /* Configure static BGP network. */ | |
3870 | int | |
fd79ac91 | 3871 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
3872 | const char *rd_str, const char *tag_str) | |
718e3744 | 3873 | { |
3874 | int ret; | |
3875 | struct bgp *bgp; | |
3876 | struct prefix p; | |
3877 | struct prefix_rd prd; | |
3878 | struct bgp_node *prn; | |
3879 | struct bgp_node *rn; | |
3880 | struct bgp_table *table; | |
3881 | struct bgp_static *bgp_static; | |
3882 | u_char tag[3]; | |
3883 | ||
3884 | bgp = vty->index; | |
3885 | ||
3886 | /* Convert IP prefix string to struct prefix. */ | |
3887 | ret = str2prefix (ip_str, &p); | |
3888 | if (! ret) | |
3889 | { | |
3890 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3891 | return CMD_WARNING; | |
3892 | } | |
3893 | apply_mask (&p); | |
3894 | ||
3895 | ret = str2prefix_rd (rd_str, &prd); | |
3896 | if (! ret) | |
3897 | { | |
3898 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3899 | return CMD_WARNING; | |
3900 | } | |
3901 | ||
3902 | ret = str2tag (tag_str, tag); | |
3903 | if (! ret) | |
3904 | { | |
3905 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3906 | return CMD_WARNING; | |
3907 | } | |
3908 | ||
3909 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
3910 | (struct prefix *)&prd); | |
3911 | if (prn->info == NULL) | |
64e580a7 | 3912 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 3913 | else |
3914 | bgp_unlock_node (prn); | |
3915 | table = prn->info; | |
3916 | ||
3917 | rn = bgp_node_lookup (table, &p); | |
3918 | ||
3919 | if (rn) | |
3920 | { | |
3921 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
3922 | ||
3923 | bgp_static = rn->info; | |
3924 | bgp_static_free (bgp_static); | |
3925 | rn->info = NULL; | |
3926 | bgp_unlock_node (rn); | |
3927 | bgp_unlock_node (rn); | |
3928 | } | |
3929 | else | |
3930 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); | |
3931 | ||
3932 | return CMD_SUCCESS; | |
3933 | } | |
3934 | \f | |
3935 | DEFUN (bgp_network, | |
3936 | bgp_network_cmd, | |
3937 | "network A.B.C.D/M", | |
3938 | "Specify a network to announce via BGP\n" | |
3939 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
3940 | { | |
3941 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 3942 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 3943 | } |
3944 | ||
3945 | DEFUN (bgp_network_route_map, | |
3946 | bgp_network_route_map_cmd, | |
3947 | "network A.B.C.D/M route-map WORD", | |
3948 | "Specify a network to announce via BGP\n" | |
3949 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
3950 | "Route-map to modify the attributes\n" | |
3951 | "Name of the route map\n") | |
3952 | { | |
3953 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 3954 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 3955 | } |
3956 | ||
3957 | DEFUN (bgp_network_backdoor, | |
3958 | bgp_network_backdoor_cmd, | |
3959 | "network A.B.C.D/M backdoor", | |
3960 | "Specify a network to announce via BGP\n" | |
3961 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
3962 | "Specify a BGP backdoor route\n") | |
3963 | { | |
41367172 | 3964 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 3965 | NULL, 1); |
718e3744 | 3966 | } |
3967 | ||
3968 | DEFUN (bgp_network_mask, | |
3969 | bgp_network_mask_cmd, | |
3970 | "network A.B.C.D mask A.B.C.D", | |
3971 | "Specify a network to announce via BGP\n" | |
3972 | "Network number\n" | |
3973 | "Network mask\n" | |
3974 | "Network mask\n") | |
3975 | { | |
3976 | int ret; | |
3977 | char prefix_str[BUFSIZ]; | |
41367172 | 3978 | |
718e3744 | 3979 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
3980 | if (! ret) | |
3981 | { | |
3982 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
3983 | return CMD_WARNING; | |
3984 | } | |
3985 | ||
3986 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 3987 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 3988 | } |
3989 | ||
3990 | DEFUN (bgp_network_mask_route_map, | |
3991 | bgp_network_mask_route_map_cmd, | |
3992 | "network A.B.C.D mask A.B.C.D route-map WORD", | |
3993 | "Specify a network to announce via BGP\n" | |
3994 | "Network number\n" | |
3995 | "Network mask\n" | |
3996 | "Network mask\n" | |
3997 | "Route-map to modify the attributes\n" | |
3998 | "Name of the route map\n") | |
3999 | { | |
4000 | int ret; | |
4001 | char prefix_str[BUFSIZ]; | |
41367172 | 4002 | |
718e3744 | 4003 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4004 | if (! ret) | |
4005 | { | |
4006 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4007 | return CMD_WARNING; | |
4008 | } | |
4009 | ||
4010 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4011 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
718e3744 | 4012 | } |
4013 | ||
4014 | DEFUN (bgp_network_mask_backdoor, | |
4015 | bgp_network_mask_backdoor_cmd, | |
4016 | "network A.B.C.D mask A.B.C.D backdoor", | |
4017 | "Specify a network to announce via BGP\n" | |
4018 | "Network number\n" | |
4019 | "Network mask\n" | |
4020 | "Network mask\n" | |
4021 | "Specify a BGP backdoor route\n") | |
4022 | { | |
4023 | int ret; | |
4024 | char prefix_str[BUFSIZ]; | |
41367172 | 4025 | |
718e3744 | 4026 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4027 | if (! ret) | |
4028 | { | |
4029 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4030 | return CMD_WARNING; | |
4031 | } | |
4032 | ||
41367172 | 4033 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4034 | NULL, 1); |
718e3744 | 4035 | } |
4036 | ||
4037 | DEFUN (bgp_network_mask_natural, | |
4038 | bgp_network_mask_natural_cmd, | |
4039 | "network A.B.C.D", | |
4040 | "Specify a network to announce via BGP\n" | |
4041 | "Network number\n") | |
4042 | { | |
4043 | int ret; | |
4044 | char prefix_str[BUFSIZ]; | |
4045 | ||
4046 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4047 | if (! ret) | |
4048 | { | |
4049 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4050 | return CMD_WARNING; | |
4051 | } | |
4052 | ||
4053 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4054 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4055 | } |
4056 | ||
4057 | DEFUN (bgp_network_mask_natural_route_map, | |
4058 | bgp_network_mask_natural_route_map_cmd, | |
4059 | "network A.B.C.D route-map WORD", | |
4060 | "Specify a network to announce via BGP\n" | |
4061 | "Network number\n" | |
4062 | "Route-map to modify the attributes\n" | |
4063 | "Name of the route map\n") | |
4064 | { | |
4065 | int ret; | |
4066 | char prefix_str[BUFSIZ]; | |
4067 | ||
4068 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4069 | if (! ret) | |
4070 | { | |
4071 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4072 | return CMD_WARNING; | |
4073 | } | |
4074 | ||
4075 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4076 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4077 | } |
4078 | ||
4079 | DEFUN (bgp_network_mask_natural_backdoor, | |
4080 | bgp_network_mask_natural_backdoor_cmd, | |
4081 | "network A.B.C.D backdoor", | |
4082 | "Specify a network to announce via BGP\n" | |
4083 | "Network number\n" | |
4084 | "Specify a BGP backdoor route\n") | |
4085 | { | |
4086 | int ret; | |
4087 | char prefix_str[BUFSIZ]; | |
4088 | ||
4089 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4090 | if (! ret) | |
4091 | { | |
4092 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4093 | return CMD_WARNING; | |
4094 | } | |
4095 | ||
41367172 | 4096 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4097 | NULL, 1); |
718e3744 | 4098 | } |
4099 | ||
4100 | DEFUN (no_bgp_network, | |
4101 | no_bgp_network_cmd, | |
4102 | "no network A.B.C.D/M", | |
4103 | NO_STR | |
4104 | "Specify a network to announce via BGP\n" | |
4105 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4106 | { | |
4107 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, | |
4108 | bgp_node_safi (vty)); | |
4109 | } | |
4110 | ||
4111 | ALIAS (no_bgp_network, | |
4112 | no_bgp_network_route_map_cmd, | |
4113 | "no network A.B.C.D/M route-map WORD", | |
4114 | NO_STR | |
4115 | "Specify a network to announce via BGP\n" | |
4116 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4117 | "Route-map to modify the attributes\n" | |
4118 | "Name of the route map\n") | |
4119 | ||
4120 | ALIAS (no_bgp_network, | |
4121 | no_bgp_network_backdoor_cmd, | |
4122 | "no network A.B.C.D/M backdoor", | |
4123 | NO_STR | |
4124 | "Specify a network to announce via BGP\n" | |
4125 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4126 | "Specify a BGP backdoor route\n") | |
4127 | ||
4128 | DEFUN (no_bgp_network_mask, | |
4129 | no_bgp_network_mask_cmd, | |
4130 | "no network A.B.C.D mask A.B.C.D", | |
4131 | NO_STR | |
4132 | "Specify a network to announce via BGP\n" | |
4133 | "Network number\n" | |
4134 | "Network mask\n" | |
4135 | "Network mask\n") | |
4136 | { | |
4137 | int ret; | |
4138 | char prefix_str[BUFSIZ]; | |
4139 | ||
4140 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4141 | if (! ret) | |
4142 | { | |
4143 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4144 | return CMD_WARNING; | |
4145 | } | |
4146 | ||
4147 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4148 | bgp_node_safi (vty)); | |
4149 | } | |
4150 | ||
4151 | ALIAS (no_bgp_network_mask, | |
4152 | no_bgp_network_mask_route_map_cmd, | |
4153 | "no network A.B.C.D mask A.B.C.D route-map WORD", | |
4154 | NO_STR | |
4155 | "Specify a network to announce via BGP\n" | |
4156 | "Network number\n" | |
4157 | "Network mask\n" | |
4158 | "Network mask\n" | |
4159 | "Route-map to modify the attributes\n" | |
4160 | "Name of the route map\n") | |
4161 | ||
4162 | ALIAS (no_bgp_network_mask, | |
4163 | no_bgp_network_mask_backdoor_cmd, | |
4164 | "no network A.B.C.D mask A.B.C.D backdoor", | |
4165 | NO_STR | |
4166 | "Specify a network to announce via BGP\n" | |
4167 | "Network number\n" | |
4168 | "Network mask\n" | |
4169 | "Network mask\n" | |
4170 | "Specify a BGP backdoor route\n") | |
4171 | ||
4172 | DEFUN (no_bgp_network_mask_natural, | |
4173 | no_bgp_network_mask_natural_cmd, | |
4174 | "no network A.B.C.D", | |
4175 | NO_STR | |
4176 | "Specify a network to announce via BGP\n" | |
4177 | "Network number\n") | |
4178 | { | |
4179 | int ret; | |
4180 | char prefix_str[BUFSIZ]; | |
4181 | ||
4182 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4183 | if (! ret) | |
4184 | { | |
4185 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4186 | return CMD_WARNING; | |
4187 | } | |
4188 | ||
4189 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4190 | bgp_node_safi (vty)); | |
4191 | } | |
4192 | ||
4193 | ALIAS (no_bgp_network_mask_natural, | |
4194 | no_bgp_network_mask_natural_route_map_cmd, | |
4195 | "no network A.B.C.D route-map WORD", | |
4196 | NO_STR | |
4197 | "Specify a network to announce via BGP\n" | |
4198 | "Network number\n" | |
4199 | "Route-map to modify the attributes\n" | |
4200 | "Name of the route map\n") | |
4201 | ||
4202 | ALIAS (no_bgp_network_mask_natural, | |
4203 | no_bgp_network_mask_natural_backdoor_cmd, | |
4204 | "no network A.B.C.D backdoor", | |
4205 | NO_STR | |
4206 | "Specify a network to announce via BGP\n" | |
4207 | "Network number\n" | |
4208 | "Specify a BGP backdoor route\n") | |
4209 | ||
4210 | #ifdef HAVE_IPV6 | |
4211 | DEFUN (ipv6_bgp_network, | |
4212 | ipv6_bgp_network_cmd, | |
4213 | "network X:X::X:X/M", | |
4214 | "Specify a network to announce via BGP\n" | |
4215 | "IPv6 prefix <network>/<length>\n") | |
4216 | { | |
41367172 | 4217 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, |
c8f3fe30 | 4218 | NULL, 0); |
718e3744 | 4219 | } |
4220 | ||
4221 | DEFUN (ipv6_bgp_network_route_map, | |
4222 | ipv6_bgp_network_route_map_cmd, | |
4223 | "network X:X::X:X/M route-map WORD", | |
4224 | "Specify a network to announce via BGP\n" | |
4225 | "IPv6 prefix <network>/<length>\n" | |
4226 | "Route-map to modify the attributes\n" | |
4227 | "Name of the route map\n") | |
4228 | { | |
4229 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, | |
c8f3fe30 | 4230 | bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4231 | } |
4232 | ||
4233 | DEFUN (no_ipv6_bgp_network, | |
4234 | no_ipv6_bgp_network_cmd, | |
4235 | "no network X:X::X:X/M", | |
4236 | NO_STR | |
4237 | "Specify a network to announce via BGP\n" | |
4238 | "IPv6 prefix <network>/<length>\n") | |
4239 | { | |
4240 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); | |
4241 | } | |
4242 | ||
4243 | ALIAS (no_ipv6_bgp_network, | |
4244 | no_ipv6_bgp_network_route_map_cmd, | |
4245 | "no network X:X::X:X/M route-map WORD", | |
4246 | NO_STR | |
4247 | "Specify a network to announce via BGP\n" | |
4248 | "IPv6 prefix <network>/<length>\n" | |
4249 | "Route-map to modify the attributes\n" | |
4250 | "Name of the route map\n") | |
4251 | ||
4252 | ALIAS (ipv6_bgp_network, | |
4253 | old_ipv6_bgp_network_cmd, | |
4254 | "ipv6 bgp network X:X::X:X/M", | |
4255 | IPV6_STR | |
4256 | BGP_STR | |
4257 | "Specify a network to announce via BGP\n" | |
4258 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4259 | ||
4260 | ALIAS (no_ipv6_bgp_network, | |
4261 | old_no_ipv6_bgp_network_cmd, | |
4262 | "no ipv6 bgp network X:X::X:X/M", | |
4263 | NO_STR | |
4264 | IPV6_STR | |
4265 | BGP_STR | |
4266 | "Specify a network to announce via BGP\n" | |
4267 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4268 | #endif /* HAVE_IPV6 */ | |
c8f3fe30 PJ |
4269 | |
4270 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ | |
4271 | ALIAS_DEPRECATED (bgp_network, | |
4272 | bgp_network_ttl_cmd, | |
4273 | "network A.B.C.D/M pathlimit <0-255>", | |
4274 | "Specify a network to announce via BGP\n" | |
4275 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4276 | "AS-Path hopcount limit attribute\n" | |
4277 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4278 | ALIAS_DEPRECATED (bgp_network_backdoor, | |
4279 | bgp_network_backdoor_ttl_cmd, | |
4280 | "network A.B.C.D/M backdoor pathlimit <0-255>", | |
4281 | "Specify a network to announce via BGP\n" | |
4282 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4283 | "Specify a BGP backdoor route\n" | |
4284 | "AS-Path hopcount limit attribute\n" | |
4285 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4286 | ALIAS_DEPRECATED (bgp_network_mask, | |
4287 | bgp_network_mask_ttl_cmd, | |
4288 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", | |
4289 | "Specify a network to announce via BGP\n" | |
4290 | "Network number\n" | |
4291 | "Network mask\n" | |
4292 | "Network mask\n" | |
4293 | "AS-Path hopcount limit attribute\n" | |
4294 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4295 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, | |
4296 | bgp_network_mask_backdoor_ttl_cmd, | |
4297 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", | |
4298 | "Specify a network to announce via BGP\n" | |
4299 | "Network number\n" | |
4300 | "Network mask\n" | |
4301 | "Network mask\n" | |
4302 | "Specify a BGP backdoor route\n" | |
4303 | "AS-Path hopcount limit attribute\n" | |
4304 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4305 | ALIAS_DEPRECATED (bgp_network_mask_natural, | |
4306 | bgp_network_mask_natural_ttl_cmd, | |
4307 | "network A.B.C.D pathlimit <0-255>", | |
4308 | "Specify a network to announce via BGP\n" | |
4309 | "Network number\n" | |
4310 | "AS-Path hopcount limit attribute\n" | |
4311 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4312 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, | |
4313 | bgp_network_mask_natural_backdoor_ttl_cmd, | |
4314 | "network A.B.C.D backdoor pathlimit (1-255>", | |
4315 | "Specify a network to announce via BGP\n" | |
4316 | "Network number\n" | |
4317 | "Specify a BGP backdoor route\n" | |
4318 | "AS-Path hopcount limit attribute\n" | |
4319 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4320 | ALIAS_DEPRECATED (no_bgp_network, | |
4321 | no_bgp_network_ttl_cmd, | |
4322 | "no network A.B.C.D/M pathlimit <0-255>", | |
4323 | NO_STR | |
4324 | "Specify a network to announce via BGP\n" | |
4325 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4326 | "AS-Path hopcount limit attribute\n" | |
4327 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4328 | ALIAS_DEPRECATED (no_bgp_network, | |
4329 | no_bgp_network_backdoor_ttl_cmd, | |
4330 | "no network A.B.C.D/M backdoor pathlimit <0-255>", | |
4331 | NO_STR | |
4332 | "Specify a network to announce via BGP\n" | |
4333 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4334 | "Specify a BGP backdoor route\n" | |
4335 | "AS-Path hopcount limit attribute\n" | |
4336 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4337 | ALIAS_DEPRECATED (no_bgp_network, | |
4338 | no_bgp_network_mask_ttl_cmd, | |
4339 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", | |
4340 | NO_STR | |
4341 | "Specify a network to announce via BGP\n" | |
4342 | "Network number\n" | |
4343 | "Network mask\n" | |
4344 | "Network mask\n" | |
4345 | "AS-Path hopcount limit attribute\n" | |
4346 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4347 | ALIAS_DEPRECATED (no_bgp_network_mask, | |
4348 | no_bgp_network_mask_backdoor_ttl_cmd, | |
4349 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", | |
4350 | NO_STR | |
4351 | "Specify a network to announce via BGP\n" | |
4352 | "Network number\n" | |
4353 | "Network mask\n" | |
4354 | "Network mask\n" | |
4355 | "Specify a BGP backdoor route\n" | |
4356 | "AS-Path hopcount limit attribute\n" | |
4357 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4358 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, | |
4359 | no_bgp_network_mask_natural_ttl_cmd, | |
4360 | "no network A.B.C.D pathlimit <0-255>", | |
4361 | NO_STR | |
4362 | "Specify a network to announce via BGP\n" | |
4363 | "Network number\n" | |
4364 | "AS-Path hopcount limit attribute\n" | |
4365 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4366 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, | |
4367 | no_bgp_network_mask_natural_backdoor_ttl_cmd, | |
4368 | "no network A.B.C.D backdoor pathlimit <0-255>", | |
4369 | NO_STR | |
4370 | "Specify a network to announce via BGP\n" | |
4371 | "Network number\n" | |
4372 | "Specify a BGP backdoor route\n" | |
4373 | "AS-Path hopcount limit attribute\n" | |
4374 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
3bde17f1 | 4375 | #ifdef HAVE_IPV6 |
c8f3fe30 PJ |
4376 | ALIAS_DEPRECATED (ipv6_bgp_network, |
4377 | ipv6_bgp_network_ttl_cmd, | |
4378 | "network X:X::X:X/M pathlimit <0-255>", | |
4379 | "Specify a network to announce via BGP\n" | |
4380 | "IPv6 prefix <network>/<length>\n" | |
4381 | "AS-Path hopcount limit attribute\n" | |
4382 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4383 | ALIAS_DEPRECATED (no_ipv6_bgp_network, | |
4384 | no_ipv6_bgp_network_ttl_cmd, | |
4385 | "no network X:X::X:X/M pathlimit <0-255>", | |
4386 | NO_STR | |
4387 | "Specify a network to announce via BGP\n" | |
4388 | "IPv6 prefix <network>/<length>\n" | |
4389 | "AS-Path hopcount limit attribute\n" | |
4390 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
3bde17f1 | 4391 | #endif /* HAVE_IPV6 */ |
718e3744 | 4392 | \f |
4393 | /* Aggreagete address: | |
4394 | ||
4395 | advertise-map Set condition to advertise attribute | |
4396 | as-set Generate AS set path information | |
4397 | attribute-map Set attributes of aggregate | |
4398 | route-map Set parameters of aggregate | |
4399 | summary-only Filter more specific routes from updates | |
4400 | suppress-map Conditionally filter more specific routes from updates | |
4401 | <cr> | |
4402 | */ | |
4403 | struct bgp_aggregate | |
4404 | { | |
4405 | /* Summary-only flag. */ | |
4406 | u_char summary_only; | |
4407 | ||
4408 | /* AS set generation. */ | |
4409 | u_char as_set; | |
4410 | ||
4411 | /* Route-map for aggregated route. */ | |
4412 | struct route_map *map; | |
4413 | ||
4414 | /* Suppress-count. */ | |
4415 | unsigned long count; | |
4416 | ||
4417 | /* SAFI configuration. */ | |
4418 | safi_t safi; | |
4419 | }; | |
4420 | ||
94f2b392 | 4421 | static struct bgp_aggregate * |
66e5cd87 | 4422 | bgp_aggregate_new (void) |
718e3744 | 4423 | { |
393deb9b | 4424 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
718e3744 | 4425 | } |
4426 | ||
94f2b392 | 4427 | static void |
718e3744 | 4428 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
4429 | { | |
4430 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); | |
4431 | } | |
4432 | ||
94f2b392 | 4433 | static void |
718e3744 | 4434 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
4435 | afi_t afi, safi_t safi, struct bgp_info *del, | |
4436 | struct bgp_aggregate *aggregate) | |
4437 | { | |
4438 | struct bgp_table *table; | |
4439 | struct bgp_node *top; | |
4440 | struct bgp_node *rn; | |
4441 | u_char origin; | |
4442 | struct aspath *aspath = NULL; | |
4443 | struct aspath *asmerge = NULL; | |
4444 | struct community *community = NULL; | |
4445 | struct community *commerge = NULL; | |
4446 | struct in_addr nexthop; | |
4447 | u_int32_t med = 0; | |
4448 | struct bgp_info *ri; | |
4449 | struct bgp_info *new; | |
4450 | int first = 1; | |
4451 | unsigned long match = 0; | |
4452 | ||
4453 | /* Record adding route's nexthop and med. */ | |
4454 | if (rinew) | |
4455 | { | |
4456 | nexthop = rinew->attr->nexthop; | |
4457 | med = rinew->attr->med; | |
4458 | } | |
4459 | ||
4460 | /* ORIGIN attribute: If at least one route among routes that are | |
4461 | aggregated has ORIGIN with the value INCOMPLETE, then the | |
4462 | aggregated route must have the ORIGIN attribute with the value | |
4463 | INCOMPLETE. Otherwise, if at least one route among routes that | |
4464 | are aggregated has ORIGIN with the value EGP, then the aggregated | |
4465 | route must have the origin attribute with the value EGP. In all | |
4466 | other case the value of the ORIGIN attribute of the aggregated | |
4467 | route is INTERNAL. */ | |
4468 | origin = BGP_ORIGIN_IGP; | |
4469 | ||
4470 | table = bgp->rib[afi][safi]; | |
4471 | ||
4472 | top = bgp_node_get (table, p); | |
4473 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4474 | if (rn->p.prefixlen > p->prefixlen) | |
4475 | { | |
4476 | match = 0; | |
4477 | ||
4478 | for (ri = rn->info; ri; ri = ri->next) | |
4479 | { | |
4480 | if (BGP_INFO_HOLDDOWN (ri)) | |
4481 | continue; | |
4482 | ||
4483 | if (del && ri == del) | |
4484 | continue; | |
4485 | ||
4486 | if (! rinew && first) | |
4487 | { | |
4488 | nexthop = ri->attr->nexthop; | |
4489 | med = ri->attr->med; | |
4490 | first = 0; | |
4491 | } | |
4492 | ||
4493 | #ifdef AGGREGATE_NEXTHOP_CHECK | |
4494 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) | |
4495 | || ri->attr->med != med) | |
4496 | { | |
4497 | if (aspath) | |
4498 | aspath_free (aspath); | |
4499 | if (community) | |
4500 | community_free (community); | |
4501 | bgp_unlock_node (rn); | |
4502 | bgp_unlock_node (top); | |
4503 | return; | |
4504 | } | |
4505 | #endif /* AGGREGATE_NEXTHOP_CHECK */ | |
4506 | ||
4507 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4508 | { | |
4509 | if (aggregate->summary_only) | |
4510 | { | |
fb982c25 | 4511 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4512 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4513 | match++; |
4514 | } | |
4515 | ||
4516 | aggregate->count++; | |
4517 | ||
4518 | if (aggregate->as_set) | |
4519 | { | |
4520 | if (origin < ri->attr->origin) | |
4521 | origin = ri->attr->origin; | |
4522 | ||
4523 | if (aspath) | |
4524 | { | |
4525 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4526 | aspath_free (aspath); | |
4527 | aspath = asmerge; | |
4528 | } | |
4529 | else | |
4530 | aspath = aspath_dup (ri->attr->aspath); | |
4531 | ||
4532 | if (ri->attr->community) | |
4533 | { | |
4534 | if (community) | |
4535 | { | |
4536 | commerge = community_merge (community, | |
4537 | ri->attr->community); | |
4538 | community = community_uniq_sort (commerge); | |
4539 | community_free (commerge); | |
4540 | } | |
4541 | else | |
4542 | community = community_dup (ri->attr->community); | |
4543 | } | |
4544 | } | |
4545 | } | |
4546 | } | |
4547 | if (match) | |
4548 | bgp_process (bgp, rn, afi, safi); | |
4549 | } | |
4550 | bgp_unlock_node (top); | |
4551 | ||
4552 | if (rinew) | |
4553 | { | |
4554 | aggregate->count++; | |
4555 | ||
4556 | if (aggregate->summary_only) | |
fb982c25 | 4557 | (bgp_info_extra_get (rinew))->suppress++; |
718e3744 | 4558 | |
4559 | if (aggregate->as_set) | |
4560 | { | |
4561 | if (origin < rinew->attr->origin) | |
4562 | origin = rinew->attr->origin; | |
4563 | ||
4564 | if (aspath) | |
4565 | { | |
4566 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); | |
4567 | aspath_free (aspath); | |
4568 | aspath = asmerge; | |
4569 | } | |
4570 | else | |
4571 | aspath = aspath_dup (rinew->attr->aspath); | |
4572 | ||
4573 | if (rinew->attr->community) | |
4574 | { | |
4575 | if (community) | |
4576 | { | |
4577 | commerge = community_merge (community, | |
4578 | rinew->attr->community); | |
4579 | community = community_uniq_sort (commerge); | |
4580 | community_free (commerge); | |
4581 | } | |
4582 | else | |
4583 | community = community_dup (rinew->attr->community); | |
4584 | } | |
4585 | } | |
4586 | } | |
4587 | ||
4588 | if (aggregate->count > 0) | |
4589 | { | |
4590 | rn = bgp_node_get (table, p); | |
4591 | new = bgp_info_new (); | |
4592 | new->type = ZEBRA_ROUTE_BGP; | |
4593 | new->sub_type = BGP_ROUTE_AGGREGATE; | |
4594 | new->peer = bgp->peer_self; | |
4595 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
4596 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); | |
65957886 | 4597 | new->uptime = bgp_clock (); |
718e3744 | 4598 | |
4599 | bgp_info_add (rn, new); | |
200df115 | 4600 | bgp_unlock_node (rn); |
718e3744 | 4601 | bgp_process (bgp, rn, afi, safi); |
4602 | } | |
4603 | else | |
4604 | { | |
4605 | if (aspath) | |
4606 | aspath_free (aspath); | |
4607 | if (community) | |
4608 | community_free (community); | |
4609 | } | |
4610 | } | |
4611 | ||
4612 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, | |
4613 | struct bgp_aggregate *); | |
4614 | ||
4615 | void | |
4616 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, | |
4617 | struct bgp_info *ri, afi_t afi, safi_t safi) | |
4618 | { | |
4619 | struct bgp_node *child; | |
4620 | struct bgp_node *rn; | |
4621 | struct bgp_aggregate *aggregate; | |
4622 | ||
4623 | /* MPLS-VPN aggregation is not yet supported. */ | |
4624 | if (safi == SAFI_MPLS_VPN) | |
4625 | return; | |
4626 | ||
4627 | if (p->prefixlen == 0) | |
4628 | return; | |
4629 | ||
4630 | if (BGP_INFO_HOLDDOWN (ri)) | |
4631 | return; | |
4632 | ||
4633 | child = bgp_node_get (bgp->aggregate[afi][safi], p); | |
4634 | ||
4635 | /* Aggregate address configuration check. */ | |
4636 | for (rn = child; rn; rn = rn->parent) | |
4637 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) | |
4638 | { | |
4639 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4640 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
718e3744 | 4641 | } |
4642 | bgp_unlock_node (child); | |
4643 | } | |
4644 | ||
4645 | void | |
4646 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, | |
4647 | struct bgp_info *del, afi_t afi, safi_t safi) | |
4648 | { | |
4649 | struct bgp_node *child; | |
4650 | struct bgp_node *rn; | |
4651 | struct bgp_aggregate *aggregate; | |
4652 | ||
4653 | /* MPLS-VPN aggregation is not yet supported. */ | |
4654 | if (safi == SAFI_MPLS_VPN) | |
4655 | return; | |
4656 | ||
4657 | if (p->prefixlen == 0) | |
4658 | return; | |
4659 | ||
4660 | child = bgp_node_get (bgp->aggregate[afi][safi], p); | |
4661 | ||
4662 | /* Aggregate address configuration check. */ | |
4663 | for (rn = child; rn; rn = rn->parent) | |
4664 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) | |
4665 | { | |
4666 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4667 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
718e3744 | 4668 | } |
4669 | bgp_unlock_node (child); | |
4670 | } | |
4671 | ||
94f2b392 | 4672 | static void |
718e3744 | 4673 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
4674 | struct bgp_aggregate *aggregate) | |
4675 | { | |
4676 | struct bgp_table *table; | |
4677 | struct bgp_node *top; | |
4678 | struct bgp_node *rn; | |
4679 | struct bgp_info *new; | |
4680 | struct bgp_info *ri; | |
4681 | unsigned long match; | |
4682 | u_char origin = BGP_ORIGIN_IGP; | |
4683 | struct aspath *aspath = NULL; | |
4684 | struct aspath *asmerge = NULL; | |
4685 | struct community *community = NULL; | |
4686 | struct community *commerge = NULL; | |
4687 | ||
4688 | table = bgp->rib[afi][safi]; | |
4689 | ||
4690 | /* Sanity check. */ | |
4691 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4692 | return; | |
4693 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4694 | return; | |
4695 | ||
4696 | /* If routes exists below this node, generate aggregate routes. */ | |
4697 | top = bgp_node_get (table, p); | |
4698 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4699 | if (rn->p.prefixlen > p->prefixlen) | |
4700 | { | |
4701 | match = 0; | |
4702 | ||
4703 | for (ri = rn->info; ri; ri = ri->next) | |
4704 | { | |
4705 | if (BGP_INFO_HOLDDOWN (ri)) | |
4706 | continue; | |
4707 | ||
4708 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4709 | { | |
4710 | /* summary-only aggregate route suppress aggregated | |
4711 | route announcement. */ | |
4712 | if (aggregate->summary_only) | |
4713 | { | |
fb982c25 | 4714 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4715 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4716 | match++; |
4717 | } | |
4718 | /* as-set aggregate route generate origin, as path, | |
4719 | community aggregation. */ | |
4720 | if (aggregate->as_set) | |
4721 | { | |
4722 | if (origin < ri->attr->origin) | |
4723 | origin = ri->attr->origin; | |
4724 | ||
4725 | if (aspath) | |
4726 | { | |
4727 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4728 | aspath_free (aspath); | |
4729 | aspath = asmerge; | |
4730 | } | |
4731 | else | |
4732 | aspath = aspath_dup (ri->attr->aspath); | |
4733 | ||
4734 | if (ri->attr->community) | |
4735 | { | |
4736 | if (community) | |
4737 | { | |
4738 | commerge = community_merge (community, | |
4739 | ri->attr->community); | |
4740 | community = community_uniq_sort (commerge); | |
4741 | community_free (commerge); | |
4742 | } | |
4743 | else | |
4744 | community = community_dup (ri->attr->community); | |
4745 | } | |
4746 | } | |
4747 | aggregate->count++; | |
4748 | } | |
4749 | } | |
4750 | ||
4751 | /* If this node is suppressed, process the change. */ | |
4752 | if (match) | |
4753 | bgp_process (bgp, rn, afi, safi); | |
4754 | } | |
4755 | bgp_unlock_node (top); | |
4756 | ||
4757 | /* Add aggregate route to BGP table. */ | |
4758 | if (aggregate->count) | |
4759 | { | |
4760 | rn = bgp_node_get (table, p); | |
4761 | ||
4762 | new = bgp_info_new (); | |
4763 | new->type = ZEBRA_ROUTE_BGP; | |
4764 | new->sub_type = BGP_ROUTE_AGGREGATE; | |
4765 | new->peer = bgp->peer_self; | |
4766 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
4767 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); | |
65957886 | 4768 | new->uptime = bgp_clock (); |
718e3744 | 4769 | |
4770 | bgp_info_add (rn, new); | |
200df115 | 4771 | bgp_unlock_node (rn); |
4772 | ||
718e3744 | 4773 | /* Process change. */ |
4774 | bgp_process (bgp, rn, afi, safi); | |
4775 | } | |
4776 | } | |
4777 | ||
4778 | void | |
4779 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, | |
4780 | safi_t safi, struct bgp_aggregate *aggregate) | |
4781 | { | |
4782 | struct bgp_table *table; | |
4783 | struct bgp_node *top; | |
4784 | struct bgp_node *rn; | |
4785 | struct bgp_info *ri; | |
4786 | unsigned long match; | |
4787 | ||
4788 | table = bgp->rib[afi][safi]; | |
4789 | ||
4790 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4791 | return; | |
4792 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4793 | return; | |
4794 | ||
4795 | /* If routes exists below this node, generate aggregate routes. */ | |
4796 | top = bgp_node_get (table, p); | |
4797 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4798 | if (rn->p.prefixlen > p->prefixlen) | |
4799 | { | |
4800 | match = 0; | |
4801 | ||
4802 | for (ri = rn->info; ri; ri = ri->next) | |
4803 | { | |
4804 | if (BGP_INFO_HOLDDOWN (ri)) | |
4805 | continue; | |
4806 | ||
4807 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4808 | { | |
fb982c25 | 4809 | if (aggregate->summary_only && ri->extra) |
718e3744 | 4810 | { |
fb982c25 | 4811 | ri->extra->suppress--; |
718e3744 | 4812 | |
fb982c25 | 4813 | if (ri->extra->suppress == 0) |
718e3744 | 4814 | { |
1a392d46 | 4815 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4816 | match++; |
4817 | } | |
4818 | } | |
4819 | aggregate->count--; | |
4820 | } | |
4821 | } | |
4822 | ||
fb982c25 | 4823 | /* If this node was suppressed, process the change. */ |
718e3744 | 4824 | if (match) |
4825 | bgp_process (bgp, rn, afi, safi); | |
4826 | } | |
4827 | bgp_unlock_node (top); | |
4828 | ||
4829 | /* Delete aggregate route from BGP table. */ | |
4830 | rn = bgp_node_get (table, p); | |
4831 | ||
4832 | for (ri = rn->info; ri; ri = ri->next) | |
4833 | if (ri->peer == bgp->peer_self | |
4834 | && ri->type == ZEBRA_ROUTE_BGP | |
4835 | && ri->sub_type == BGP_ROUTE_AGGREGATE) | |
4836 | break; | |
4837 | ||
4838 | /* Withdraw static BGP route from routing table. */ | |
4839 | if (ri) | |
4840 | { | |
718e3744 | 4841 | bgp_info_delete (rn, ri); |
1a392d46 | 4842 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 4843 | } |
4844 | ||
4845 | /* Unlock bgp_node_lookup. */ | |
4846 | bgp_unlock_node (rn); | |
4847 | } | |
4848 | ||
4849 | /* Aggregate route attribute. */ | |
4850 | #define AGGREGATE_SUMMARY_ONLY 1 | |
4851 | #define AGGREGATE_AS_SET 1 | |
4852 | ||
94f2b392 | 4853 | static int |
f6269b4f RB |
4854 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
4855 | afi_t afi, safi_t safi) | |
718e3744 | 4856 | { |
4857 | int ret; | |
4858 | struct prefix p; | |
4859 | struct bgp_node *rn; | |
4860 | struct bgp *bgp; | |
4861 | struct bgp_aggregate *aggregate; | |
4862 | ||
4863 | /* Convert string to prefix structure. */ | |
4864 | ret = str2prefix (prefix_str, &p); | |
4865 | if (!ret) | |
4866 | { | |
4867 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
4868 | return CMD_WARNING; | |
4869 | } | |
4870 | apply_mask (&p); | |
4871 | ||
4872 | /* Get BGP structure. */ | |
4873 | bgp = vty->index; | |
4874 | ||
4875 | /* Old configuration check. */ | |
f6269b4f RB |
4876 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
4877 | if (! rn) | |
718e3744 | 4878 | { |
f6269b4f RB |
4879 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
4880 | VTY_NEWLINE); | |
718e3744 | 4881 | return CMD_WARNING; |
4882 | } | |
4883 | ||
f6269b4f RB |
4884 | aggregate = rn->info; |
4885 | if (aggregate->safi & SAFI_UNICAST) | |
4886 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
4887 | if (aggregate->safi & SAFI_MULTICAST) | |
4888 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 4889 | |
f6269b4f RB |
4890 | /* Unlock aggregate address configuration. */ |
4891 | rn->info = NULL; | |
4892 | bgp_aggregate_free (aggregate); | |
4893 | bgp_unlock_node (rn); | |
4894 | bgp_unlock_node (rn); | |
718e3744 | 4895 | |
4896 | return CMD_SUCCESS; | |
4897 | } | |
4898 | ||
94f2b392 | 4899 | static int |
f6269b4f RB |
4900 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
4901 | afi_t afi, safi_t safi, | |
4902 | u_char summary_only, u_char as_set) | |
718e3744 | 4903 | { |
4904 | int ret; | |
4905 | struct prefix p; | |
4906 | struct bgp_node *rn; | |
4907 | struct bgp *bgp; | |
4908 | struct bgp_aggregate *aggregate; | |
4909 | ||
4910 | /* Convert string to prefix structure. */ | |
4911 | ret = str2prefix (prefix_str, &p); | |
4912 | if (!ret) | |
4913 | { | |
4914 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
4915 | return CMD_WARNING; | |
4916 | } | |
4917 | apply_mask (&p); | |
4918 | ||
4919 | /* Get BGP structure. */ | |
4920 | bgp = vty->index; | |
4921 | ||
4922 | /* Old configuration check. */ | |
f6269b4f RB |
4923 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
4924 | ||
4925 | if (rn->info) | |
718e3744 | 4926 | { |
f6269b4f | 4927 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
368473f6 | 4928 | /* try to remove the old entry */ |
f6269b4f RB |
4929 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
4930 | if (ret) | |
4931 | { | |
368473f6 RB |
4932 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
4933 | bgp_unlock_node (rn); | |
f6269b4f RB |
4934 | return CMD_WARNING; |
4935 | } | |
718e3744 | 4936 | } |
4937 | ||
f6269b4f RB |
4938 | /* Make aggregate address structure. */ |
4939 | aggregate = bgp_aggregate_new (); | |
4940 | aggregate->summary_only = summary_only; | |
4941 | aggregate->as_set = as_set; | |
4942 | aggregate->safi = safi; | |
4943 | rn->info = aggregate; | |
718e3744 | 4944 | |
f6269b4f RB |
4945 | /* Aggregate address insert into BGP routing table. */ |
4946 | if (safi & SAFI_UNICAST) | |
4947 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
4948 | if (safi & SAFI_MULTICAST) | |
4949 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 4950 | |
4951 | return CMD_SUCCESS; | |
4952 | } | |
4953 | ||
4954 | DEFUN (aggregate_address, | |
4955 | aggregate_address_cmd, | |
4956 | "aggregate-address A.B.C.D/M", | |
4957 | "Configure BGP aggregate entries\n" | |
4958 | "Aggregate prefix\n") | |
4959 | { | |
4960 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); | |
4961 | } | |
4962 | ||
4963 | DEFUN (aggregate_address_mask, | |
4964 | aggregate_address_mask_cmd, | |
4965 | "aggregate-address A.B.C.D A.B.C.D", | |
4966 | "Configure BGP aggregate entries\n" | |
4967 | "Aggregate address\n" | |
4968 | "Aggregate mask\n") | |
4969 | { | |
4970 | int ret; | |
4971 | char prefix_str[BUFSIZ]; | |
4972 | ||
4973 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4974 | ||
4975 | if (! ret) | |
4976 | { | |
4977 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4978 | return CMD_WARNING; | |
4979 | } | |
4980 | ||
4981 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
4982 | 0, 0); | |
4983 | } | |
4984 | ||
4985 | DEFUN (aggregate_address_summary_only, | |
4986 | aggregate_address_summary_only_cmd, | |
4987 | "aggregate-address A.B.C.D/M summary-only", | |
4988 | "Configure BGP aggregate entries\n" | |
4989 | "Aggregate prefix\n" | |
4990 | "Filter more specific routes from updates\n") | |
4991 | { | |
4992 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
4993 | AGGREGATE_SUMMARY_ONLY, 0); | |
4994 | } | |
4995 | ||
4996 | DEFUN (aggregate_address_mask_summary_only, | |
4997 | aggregate_address_mask_summary_only_cmd, | |
4998 | "aggregate-address A.B.C.D A.B.C.D summary-only", | |
4999 | "Configure BGP aggregate entries\n" | |
5000 | "Aggregate address\n" | |
5001 | "Aggregate mask\n" | |
5002 | "Filter more specific routes from updates\n") | |
5003 | { | |
5004 | int ret; | |
5005 | char prefix_str[BUFSIZ]; | |
5006 | ||
5007 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5008 | ||
5009 | if (! ret) | |
5010 | { | |
5011 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5012 | return CMD_WARNING; | |
5013 | } | |
5014 | ||
5015 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5016 | AGGREGATE_SUMMARY_ONLY, 0); | |
5017 | } | |
5018 | ||
5019 | DEFUN (aggregate_address_as_set, | |
5020 | aggregate_address_as_set_cmd, | |
5021 | "aggregate-address A.B.C.D/M as-set", | |
5022 | "Configure BGP aggregate entries\n" | |
5023 | "Aggregate prefix\n" | |
5024 | "Generate AS set path information\n") | |
5025 | { | |
5026 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5027 | 0, AGGREGATE_AS_SET); | |
5028 | } | |
5029 | ||
5030 | DEFUN (aggregate_address_mask_as_set, | |
5031 | aggregate_address_mask_as_set_cmd, | |
5032 | "aggregate-address A.B.C.D A.B.C.D as-set", | |
5033 | "Configure BGP aggregate entries\n" | |
5034 | "Aggregate address\n" | |
5035 | "Aggregate mask\n" | |
5036 | "Generate AS set path information\n") | |
5037 | { | |
5038 | int ret; | |
5039 | char prefix_str[BUFSIZ]; | |
5040 | ||
5041 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5042 | ||
5043 | if (! ret) | |
5044 | { | |
5045 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5046 | return CMD_WARNING; | |
5047 | } | |
5048 | ||
5049 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5050 | 0, AGGREGATE_AS_SET); | |
5051 | } | |
5052 | ||
5053 | ||
5054 | DEFUN (aggregate_address_as_set_summary, | |
5055 | aggregate_address_as_set_summary_cmd, | |
5056 | "aggregate-address A.B.C.D/M as-set summary-only", | |
5057 | "Configure BGP aggregate entries\n" | |
5058 | "Aggregate prefix\n" | |
5059 | "Generate AS set path information\n" | |
5060 | "Filter more specific routes from updates\n") | |
5061 | { | |
5062 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5063 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5064 | } | |
5065 | ||
5066 | ALIAS (aggregate_address_as_set_summary, | |
5067 | aggregate_address_summary_as_set_cmd, | |
5068 | "aggregate-address A.B.C.D/M summary-only as-set", | |
5069 | "Configure BGP aggregate entries\n" | |
5070 | "Aggregate prefix\n" | |
5071 | "Filter more specific routes from updates\n" | |
5072 | "Generate AS set path information\n") | |
5073 | ||
5074 | DEFUN (aggregate_address_mask_as_set_summary, | |
5075 | aggregate_address_mask_as_set_summary_cmd, | |
5076 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5077 | "Configure BGP aggregate entries\n" | |
5078 | "Aggregate address\n" | |
5079 | "Aggregate mask\n" | |
5080 | "Generate AS set path information\n" | |
5081 | "Filter more specific routes from updates\n") | |
5082 | { | |
5083 | int ret; | |
5084 | char prefix_str[BUFSIZ]; | |
5085 | ||
5086 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5087 | ||
5088 | if (! ret) | |
5089 | { | |
5090 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5091 | return CMD_WARNING; | |
5092 | } | |
5093 | ||
5094 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5095 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5096 | } | |
5097 | ||
5098 | ALIAS (aggregate_address_mask_as_set_summary, | |
5099 | aggregate_address_mask_summary_as_set_cmd, | |
5100 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5101 | "Configure BGP aggregate entries\n" | |
5102 | "Aggregate address\n" | |
5103 | "Aggregate mask\n" | |
5104 | "Filter more specific routes from updates\n" | |
5105 | "Generate AS set path information\n") | |
5106 | ||
5107 | DEFUN (no_aggregate_address, | |
5108 | no_aggregate_address_cmd, | |
5109 | "no aggregate-address A.B.C.D/M", | |
5110 | NO_STR | |
5111 | "Configure BGP aggregate entries\n" | |
5112 | "Aggregate prefix\n") | |
5113 | { | |
5114 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); | |
5115 | } | |
5116 | ||
5117 | ALIAS (no_aggregate_address, | |
5118 | no_aggregate_address_summary_only_cmd, | |
5119 | "no aggregate-address A.B.C.D/M summary-only", | |
5120 | NO_STR | |
5121 | "Configure BGP aggregate entries\n" | |
5122 | "Aggregate prefix\n" | |
5123 | "Filter more specific routes from updates\n") | |
5124 | ||
5125 | ALIAS (no_aggregate_address, | |
5126 | no_aggregate_address_as_set_cmd, | |
5127 | "no aggregate-address A.B.C.D/M as-set", | |
5128 | NO_STR | |
5129 | "Configure BGP aggregate entries\n" | |
5130 | "Aggregate prefix\n" | |
5131 | "Generate AS set path information\n") | |
5132 | ||
5133 | ALIAS (no_aggregate_address, | |
5134 | no_aggregate_address_as_set_summary_cmd, | |
5135 | "no aggregate-address A.B.C.D/M as-set summary-only", | |
5136 | NO_STR | |
5137 | "Configure BGP aggregate entries\n" | |
5138 | "Aggregate prefix\n" | |
5139 | "Generate AS set path information\n" | |
5140 | "Filter more specific routes from updates\n") | |
5141 | ||
5142 | ALIAS (no_aggregate_address, | |
5143 | no_aggregate_address_summary_as_set_cmd, | |
5144 | "no aggregate-address A.B.C.D/M summary-only as-set", | |
5145 | NO_STR | |
5146 | "Configure BGP aggregate entries\n" | |
5147 | "Aggregate prefix\n" | |
5148 | "Filter more specific routes from updates\n" | |
5149 | "Generate AS set path information\n") | |
5150 | ||
5151 | DEFUN (no_aggregate_address_mask, | |
5152 | no_aggregate_address_mask_cmd, | |
5153 | "no aggregate-address A.B.C.D A.B.C.D", | |
5154 | NO_STR | |
5155 | "Configure BGP aggregate entries\n" | |
5156 | "Aggregate address\n" | |
5157 | "Aggregate mask\n") | |
5158 | { | |
5159 | int ret; | |
5160 | char prefix_str[BUFSIZ]; | |
5161 | ||
5162 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5163 | ||
5164 | if (! ret) | |
5165 | { | |
5166 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5167 | return CMD_WARNING; | |
5168 | } | |
5169 | ||
5170 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); | |
5171 | } | |
5172 | ||
5173 | ALIAS (no_aggregate_address_mask, | |
5174 | no_aggregate_address_mask_summary_only_cmd, | |
5175 | "no aggregate-address A.B.C.D A.B.C.D summary-only", | |
5176 | NO_STR | |
5177 | "Configure BGP aggregate entries\n" | |
5178 | "Aggregate address\n" | |
5179 | "Aggregate mask\n" | |
5180 | "Filter more specific routes from updates\n") | |
5181 | ||
5182 | ALIAS (no_aggregate_address_mask, | |
5183 | no_aggregate_address_mask_as_set_cmd, | |
5184 | "no aggregate-address A.B.C.D A.B.C.D as-set", | |
5185 | NO_STR | |
5186 | "Configure BGP aggregate entries\n" | |
5187 | "Aggregate address\n" | |
5188 | "Aggregate mask\n" | |
5189 | "Generate AS set path information\n") | |
5190 | ||
5191 | ALIAS (no_aggregate_address_mask, | |
5192 | no_aggregate_address_mask_as_set_summary_cmd, | |
5193 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5194 | NO_STR | |
5195 | "Configure BGP aggregate entries\n" | |
5196 | "Aggregate address\n" | |
5197 | "Aggregate mask\n" | |
5198 | "Generate AS set path information\n" | |
5199 | "Filter more specific routes from updates\n") | |
5200 | ||
5201 | ALIAS (no_aggregate_address_mask, | |
5202 | no_aggregate_address_mask_summary_as_set_cmd, | |
5203 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5204 | NO_STR | |
5205 | "Configure BGP aggregate entries\n" | |
5206 | "Aggregate address\n" | |
5207 | "Aggregate mask\n" | |
5208 | "Filter more specific routes from updates\n" | |
5209 | "Generate AS set path information\n") | |
5210 | ||
5211 | #ifdef HAVE_IPV6 | |
5212 | DEFUN (ipv6_aggregate_address, | |
5213 | ipv6_aggregate_address_cmd, | |
5214 | "aggregate-address X:X::X:X/M", | |
5215 | "Configure BGP aggregate entries\n" | |
5216 | "Aggregate prefix\n") | |
5217 | { | |
5218 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); | |
5219 | } | |
5220 | ||
5221 | DEFUN (ipv6_aggregate_address_summary_only, | |
5222 | ipv6_aggregate_address_summary_only_cmd, | |
5223 | "aggregate-address X:X::X:X/M summary-only", | |
5224 | "Configure BGP aggregate entries\n" | |
5225 | "Aggregate prefix\n" | |
5226 | "Filter more specific routes from updates\n") | |
5227 | { | |
5228 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
5229 | AGGREGATE_SUMMARY_ONLY, 0); | |
5230 | } | |
5231 | ||
5232 | DEFUN (no_ipv6_aggregate_address, | |
5233 | no_ipv6_aggregate_address_cmd, | |
5234 | "no aggregate-address X:X::X:X/M", | |
5235 | NO_STR | |
5236 | "Configure BGP aggregate entries\n" | |
5237 | "Aggregate prefix\n") | |
5238 | { | |
5239 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5240 | } | |
5241 | ||
5242 | DEFUN (no_ipv6_aggregate_address_summary_only, | |
5243 | no_ipv6_aggregate_address_summary_only_cmd, | |
5244 | "no aggregate-address X:X::X:X/M summary-only", | |
5245 | NO_STR | |
5246 | "Configure BGP aggregate entries\n" | |
5247 | "Aggregate prefix\n" | |
5248 | "Filter more specific routes from updates\n") | |
5249 | { | |
5250 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5251 | } | |
5252 | ||
5253 | ALIAS (ipv6_aggregate_address, | |
5254 | old_ipv6_aggregate_address_cmd, | |
5255 | "ipv6 bgp aggregate-address X:X::X:X/M", | |
5256 | IPV6_STR | |
5257 | BGP_STR | |
5258 | "Configure BGP aggregate entries\n" | |
5259 | "Aggregate prefix\n") | |
5260 | ||
5261 | ALIAS (ipv6_aggregate_address_summary_only, | |
5262 | old_ipv6_aggregate_address_summary_only_cmd, | |
5263 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5264 | IPV6_STR | |
5265 | BGP_STR | |
5266 | "Configure BGP aggregate entries\n" | |
5267 | "Aggregate prefix\n" | |
5268 | "Filter more specific routes from updates\n") | |
5269 | ||
5270 | ALIAS (no_ipv6_aggregate_address, | |
5271 | old_no_ipv6_aggregate_address_cmd, | |
5272 | "no ipv6 bgp aggregate-address X:X::X:X/M", | |
5273 | NO_STR | |
5274 | IPV6_STR | |
5275 | BGP_STR | |
5276 | "Configure BGP aggregate entries\n" | |
5277 | "Aggregate prefix\n") | |
5278 | ||
5279 | ALIAS (no_ipv6_aggregate_address_summary_only, | |
5280 | old_no_ipv6_aggregate_address_summary_only_cmd, | |
5281 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5282 | NO_STR | |
5283 | IPV6_STR | |
5284 | BGP_STR | |
5285 | "Configure BGP aggregate entries\n" | |
5286 | "Aggregate prefix\n" | |
5287 | "Filter more specific routes from updates\n") | |
5288 | #endif /* HAVE_IPV6 */ | |
5289 | \f | |
5290 | /* Redistribute route treatment. */ | |
5291 | void | |
5292 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, | |
5293 | u_int32_t metric, u_char type) | |
5294 | { | |
5295 | struct bgp *bgp; | |
1eb8ef25 | 5296 | struct listnode *node, *nnode; |
718e3744 | 5297 | struct bgp_info *new; |
5298 | struct bgp_info *bi; | |
5299 | struct bgp_info info; | |
5300 | struct bgp_node *bn; | |
fb982c25 PJ |
5301 | struct attr attr = { 0 }; |
5302 | struct attr attr_new = { 0 }; | |
718e3744 | 5303 | struct attr *new_attr; |
5304 | afi_t afi; | |
5305 | int ret; | |
5306 | ||
5307 | /* Make default attribute. */ | |
5308 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); | |
5309 | if (nexthop) | |
5310 | attr.nexthop = *nexthop; | |
5311 | ||
5312 | attr.med = metric; | |
5313 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
5314 | ||
1eb8ef25 | 5315 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 5316 | { |
5317 | afi = family2afi (p->family); | |
5318 | ||
5319 | if (bgp->redist[afi][type]) | |
5320 | { | |
5321 | /* Copy attribute for modification. */ | |
fb982c25 | 5322 | bgp_attr_dup (&attr_new, &attr); |
718e3744 | 5323 | |
5324 | if (bgp->redist_metric_flag[afi][type]) | |
5325 | attr_new.med = bgp->redist_metric[afi][type]; | |
5326 | ||
5327 | /* Apply route-map. */ | |
5328 | if (bgp->rmap[afi][type].map) | |
5329 | { | |
5330 | info.peer = bgp->peer_self; | |
5331 | info.attr = &attr_new; | |
5332 | ||
fee0f4c6 | 5333 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
5334 | ||
718e3744 | 5335 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
5336 | &info); | |
fee0f4c6 | 5337 | |
5338 | bgp->peer_self->rmap_type = 0; | |
5339 | ||
718e3744 | 5340 | if (ret == RMAP_DENYMATCH) |
5341 | { | |
5342 | /* Free uninterned attribute. */ | |
5343 | bgp_attr_flush (&attr_new); | |
fb982c25 PJ |
5344 | bgp_attr_extra_free (&attr_new); |
5345 | ||
718e3744 | 5346 | /* Unintern original. */ |
5347 | aspath_unintern (attr.aspath); | |
fb982c25 | 5348 | bgp_attr_extra_free (&attr); |
718e3744 | 5349 | bgp_redistribute_delete (p, type); |
5350 | return; | |
5351 | } | |
5352 | } | |
5353 | ||
fb982c25 PJ |
5354 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
5355 | afi, SAFI_UNICAST, p, NULL); | |
5356 | ||
718e3744 | 5357 | new_attr = bgp_attr_intern (&attr_new); |
fb982c25 PJ |
5358 | bgp_attr_extra_free (&attr_new); |
5359 | ||
718e3744 | 5360 | for (bi = bn->info; bi; bi = bi->next) |
5361 | if (bi->peer == bgp->peer_self | |
5362 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
5363 | break; | |
5364 | ||
5365 | if (bi) | |
5366 | { | |
8d45210e AS |
5367 | if (attrhash_cmp (bi->attr, new_attr) && |
5368 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
718e3744 | 5369 | { |
5370 | bgp_attr_unintern (new_attr); | |
5371 | aspath_unintern (attr.aspath); | |
fb982c25 | 5372 | bgp_attr_extra_free (&attr); |
718e3744 | 5373 | bgp_unlock_node (bn); |
5374 | return; | |
5375 | } | |
5376 | else | |
5377 | { | |
5378 | /* The attribute is changed. */ | |
1a392d46 | 5379 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
718e3744 | 5380 | |
5381 | /* Rewrite BGP route information. */ | |
8d45210e AS |
5382 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
5383 | bgp_info_restore(bn, bi); | |
5384 | else | |
5385 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); | |
718e3744 | 5386 | bgp_attr_unintern (bi->attr); |
5387 | bi->attr = new_attr; | |
65957886 | 5388 | bi->uptime = bgp_clock (); |
718e3744 | 5389 | |
5390 | /* Process change. */ | |
5391 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); | |
5392 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
5393 | bgp_unlock_node (bn); | |
5394 | aspath_unintern (attr.aspath); | |
fb982c25 | 5395 | bgp_attr_extra_free (&attr); |
718e3744 | 5396 | return; |
5397 | } | |
5398 | } | |
5399 | ||
5400 | new = bgp_info_new (); | |
5401 | new->type = type; | |
5402 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; | |
5403 | new->peer = bgp->peer_self; | |
5404 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
5405 | new->attr = new_attr; | |
65957886 | 5406 | new->uptime = bgp_clock (); |
718e3744 | 5407 | |
5408 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); | |
5409 | bgp_info_add (bn, new); | |
200df115 | 5410 | bgp_unlock_node (bn); |
718e3744 | 5411 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
5412 | } | |
5413 | } | |
5414 | ||
5415 | /* Unintern original. */ | |
5416 | aspath_unintern (attr.aspath); | |
fb982c25 | 5417 | bgp_attr_extra_free (&attr); |
718e3744 | 5418 | } |
5419 | ||
5420 | void | |
5421 | bgp_redistribute_delete (struct prefix *p, u_char type) | |
5422 | { | |
5423 | struct bgp *bgp; | |
1eb8ef25 | 5424 | struct listnode *node, *nnode; |
718e3744 | 5425 | afi_t afi; |
5426 | struct bgp_node *rn; | |
5427 | struct bgp_info *ri; | |
5428 | ||
1eb8ef25 | 5429 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 5430 | { |
5431 | afi = family2afi (p->family); | |
5432 | ||
5433 | if (bgp->redist[afi][type]) | |
5434 | { | |
fee0f4c6 | 5435 | rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); |
718e3744 | 5436 | |
5437 | for (ri = rn->info; ri; ri = ri->next) | |
5438 | if (ri->peer == bgp->peer_self | |
5439 | && ri->type == type) | |
5440 | break; | |
5441 | ||
5442 | if (ri) | |
5443 | { | |
5444 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5445 | bgp_info_delete (rn, ri); |
1a392d46 | 5446 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5447 | } |
5448 | bgp_unlock_node (rn); | |
5449 | } | |
5450 | } | |
5451 | } | |
5452 | ||
5453 | /* Withdraw specified route type's route. */ | |
5454 | void | |
5455 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) | |
5456 | { | |
5457 | struct bgp_node *rn; | |
5458 | struct bgp_info *ri; | |
5459 | struct bgp_table *table; | |
5460 | ||
5461 | table = bgp->rib[afi][SAFI_UNICAST]; | |
5462 | ||
5463 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
5464 | { | |
5465 | for (ri = rn->info; ri; ri = ri->next) | |
5466 | if (ri->peer == bgp->peer_self | |
5467 | && ri->type == type) | |
5468 | break; | |
5469 | ||
5470 | if (ri) | |
5471 | { | |
5472 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5473 | bgp_info_delete (rn, ri); |
1a392d46 | 5474 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5475 | } |
5476 | } | |
5477 | } | |
5478 | \f | |
5479 | /* Static function to display route. */ | |
94f2b392 | 5480 | static void |
718e3744 | 5481 | route_vty_out_route (struct prefix *p, struct vty *vty) |
5482 | { | |
5483 | int len; | |
5484 | u_int32_t destination; | |
5485 | char buf[BUFSIZ]; | |
5486 | ||
5487 | if (p->family == AF_INET) | |
5488 | { | |
5489 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); | |
5490 | destination = ntohl (p->u.prefix4.s_addr); | |
5491 | ||
5492 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
5493 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
5494 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
5495 | || p->u.prefix4.s_addr == 0) | |
5496 | { | |
5497 | /* When mask is natural, mask is not displayed. */ | |
5498 | } | |
5499 | else | |
5500 | len += vty_out (vty, "/%d", p->prefixlen); | |
5501 | } | |
5502 | else | |
5503 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), | |
5504 | p->prefixlen); | |
5505 | ||
5506 | len = 17 - len; | |
5507 | if (len < 1) | |
5508 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); | |
5509 | else | |
5510 | vty_out (vty, "%*s", len, " "); | |
5511 | } | |
5512 | ||
718e3744 | 5513 | enum bgp_display_type |
5514 | { | |
5515 | normal_list, | |
5516 | }; | |
5517 | ||
b40d939b | 5518 | /* Print the short form route status for a bgp_info */ |
5519 | static void | |
5520 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) | |
718e3744 | 5521 | { |
b40d939b | 5522 | /* Route status display. */ |
5523 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
5524 | vty_out (vty, "R"); | |
5525 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
93406d87 | 5526 | vty_out (vty, "S"); |
fb982c25 | 5527 | else if (binfo->extra && binfo->extra->suppress) |
718e3744 | 5528 | vty_out (vty, "s"); |
5529 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5530 | vty_out (vty, "*"); | |
5531 | else | |
5532 | vty_out (vty, " "); | |
5533 | ||
5534 | /* Selected */ | |
5535 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5536 | vty_out (vty, "h"); | |
5537 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5538 | vty_out (vty, "d"); | |
5539 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
5540 | vty_out (vty, ">"); | |
5541 | else | |
5542 | vty_out (vty, " "); | |
5543 | ||
5544 | /* Internal route. */ | |
5545 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) | |
5546 | vty_out (vty, "i"); | |
5547 | else | |
b40d939b | 5548 | vty_out (vty, " "); |
5549 | } | |
5550 | ||
5551 | /* called from terminal list command */ | |
5552 | void | |
5553 | route_vty_out (struct vty *vty, struct prefix *p, | |
5554 | struct bgp_info *binfo, int display, safi_t safi) | |
5555 | { | |
5556 | struct attr *attr; | |
5557 | ||
5558 | /* short status lead text */ | |
5559 | route_vty_short_status_out (vty, binfo); | |
718e3744 | 5560 | |
5561 | /* print prefix and mask */ | |
5562 | if (! display) | |
5563 | route_vty_out_route (p, vty); | |
5564 | else | |
5565 | vty_out (vty, "%*s", 17, " "); | |
5566 | ||
5567 | /* Print attribute */ | |
5568 | attr = binfo->attr; | |
5569 | if (attr) | |
5570 | { | |
5571 | if (p->family == AF_INET) | |
5572 | { | |
5573 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5574 | vty_out (vty, "%-16s", |
5575 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5576 | else |
5577 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5578 | } | |
5579 | #ifdef HAVE_IPV6 | |
5580 | else if (p->family == AF_INET6) | |
5581 | { | |
5582 | int len; | |
5583 | char buf[BUFSIZ]; | |
5584 | ||
5585 | len = vty_out (vty, "%s", | |
fb982c25 PJ |
5586 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5587 | buf, BUFSIZ)); | |
718e3744 | 5588 | len = 16 - len; |
5589 | if (len < 1) | |
5590 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5591 | else | |
5592 | vty_out (vty, "%*s", len, " "); | |
5593 | } | |
5594 | #endif /* HAVE_IPV6 */ | |
5595 | ||
5596 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
c099baf6 | 5597 | vty_out (vty, "%10u", attr->med); |
718e3744 | 5598 | else |
5599 | vty_out (vty, " "); | |
5600 | ||
5601 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
c099baf6 | 5602 | vty_out (vty, "%7u", attr->local_pref); |
718e3744 | 5603 | else |
5604 | vty_out (vty, " "); | |
5605 | ||
fb982c25 | 5606 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
718e3744 | 5607 | |
b2518c1e PJ |
5608 | /* Print aspath */ |
5609 | if (attr->aspath) | |
841f7a57 | 5610 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5611 | |
b2518c1e | 5612 | /* Print origin */ |
718e3744 | 5613 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
b2518c1e | 5614 | } |
718e3744 | 5615 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5616 | } |
5617 | ||
5618 | /* called from terminal list command */ | |
5619 | void | |
5620 | route_vty_out_tmp (struct vty *vty, struct prefix *p, | |
5621 | struct attr *attr, safi_t safi) | |
5622 | { | |
5623 | /* Route status display. */ | |
5624 | vty_out (vty, "*"); | |
5625 | vty_out (vty, ">"); | |
5626 | vty_out (vty, " "); | |
5627 | ||
5628 | /* print prefix and mask */ | |
5629 | route_vty_out_route (p, vty); | |
5630 | ||
5631 | /* Print attribute */ | |
5632 | if (attr) | |
5633 | { | |
5634 | if (p->family == AF_INET) | |
5635 | { | |
5636 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5637 | vty_out (vty, "%-16s", |
5638 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5639 | else |
5640 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5641 | } | |
5642 | #ifdef HAVE_IPV6 | |
5643 | else if (p->family == AF_INET6) | |
5644 | { | |
5645 | int len; | |
5646 | char buf[BUFSIZ]; | |
fb982c25 PJ |
5647 | |
5648 | assert (attr->extra); | |
718e3744 | 5649 | |
5650 | len = vty_out (vty, "%s", | |
fb982c25 PJ |
5651 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5652 | buf, BUFSIZ)); | |
718e3744 | 5653 | len = 16 - len; |
5654 | if (len < 1) | |
5655 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5656 | else | |
5657 | vty_out (vty, "%*s", len, " "); | |
5658 | } | |
5659 | #endif /* HAVE_IPV6 */ | |
5660 | ||
5661 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
c099baf6 | 5662 | vty_out (vty, "%10u", attr->med); |
718e3744 | 5663 | else |
5664 | vty_out (vty, " "); | |
5665 | ||
5666 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
c099baf6 | 5667 | vty_out (vty, "%7u", attr->local_pref); |
718e3744 | 5668 | else |
5669 | vty_out (vty, " "); | |
fb982c25 | 5670 | |
c099baf6 | 5671 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
fb982c25 | 5672 | |
b2518c1e PJ |
5673 | /* Print aspath */ |
5674 | if (attr->aspath) | |
841f7a57 | 5675 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5676 | |
b2518c1e | 5677 | /* Print origin */ |
718e3744 | 5678 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
b2518c1e | 5679 | } |
718e3744 | 5680 | |
5681 | vty_out (vty, "%s", VTY_NEWLINE); | |
5682 | } | |
5683 | ||
5a646650 | 5684 | void |
718e3744 | 5685 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
5686 | struct bgp_info *binfo, int display, safi_t safi) | |
5687 | { | |
5688 | struct attr *attr; | |
718e3744 | 5689 | u_int32_t label = 0; |
fb982c25 PJ |
5690 | |
5691 | if (!binfo->extra) | |
5692 | return; | |
5693 | ||
b40d939b | 5694 | /* short status lead text */ |
5695 | route_vty_short_status_out (vty, binfo); | |
5696 | ||
718e3744 | 5697 | /* print prefix and mask */ |
5698 | if (! display) | |
5699 | route_vty_out_route (p, vty); | |
5700 | else | |
5701 | vty_out (vty, "%*s", 17, " "); | |
5702 | ||
5703 | /* Print attribute */ | |
5704 | attr = binfo->attr; | |
5705 | if (attr) | |
5706 | { | |
5707 | if (p->family == AF_INET) | |
5708 | { | |
5709 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5710 | vty_out (vty, "%-16s", |
5711 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5712 | else |
5713 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5714 | } | |
5715 | #ifdef HAVE_IPV6 | |
5716 | else if (p->family == AF_INET6) | |
5717 | { | |
fb982c25 | 5718 | assert (attr->extra); |
718e3744 | 5719 | char buf[BUFSIZ]; |
5720 | char buf1[BUFSIZ]; | |
fb982c25 | 5721 | if (attr->extra->mp_nexthop_len == 16) |
718e3744 | 5722 | vty_out (vty, "%s", |
fb982c25 PJ |
5723 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5724 | buf, BUFSIZ)); | |
5725 | else if (attr->extra->mp_nexthop_len == 32) | |
718e3744 | 5726 | vty_out (vty, "%s(%s)", |
fb982c25 PJ |
5727 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5728 | buf, BUFSIZ), | |
5729 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
5730 | buf1, BUFSIZ)); | |
718e3744 | 5731 | |
5732 | } | |
5733 | #endif /* HAVE_IPV6 */ | |
5734 | } | |
5735 | ||
fb982c25 | 5736 | label = decode_label (binfo->extra->tag); |
718e3744 | 5737 | |
5738 | vty_out (vty, "notag/%d", label); | |
5739 | ||
5740 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5741 | } |
5742 | ||
5743 | /* dampening route */ | |
5a646650 | 5744 | static void |
718e3744 | 5745 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
5746 | struct bgp_info *binfo, int display, safi_t safi) | |
5747 | { | |
5748 | struct attr *attr; | |
718e3744 | 5749 | int len; |
50aef6f3 | 5750 | char timebuf[BGP_UPTIME_LEN]; |
718e3744 | 5751 | |
b40d939b | 5752 | /* short status lead text */ |
5753 | route_vty_short_status_out (vty, binfo); | |
5754 | ||
718e3744 | 5755 | /* print prefix and mask */ |
5756 | if (! display) | |
5757 | route_vty_out_route (p, vty); | |
5758 | else | |
5759 | vty_out (vty, "%*s", 17, " "); | |
5760 | ||
5761 | len = vty_out (vty, "%s", binfo->peer->host); | |
5762 | len = 17 - len; | |
5763 | if (len < 1) | |
5764 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); | |
5765 | else | |
5766 | vty_out (vty, "%*s", len, " "); | |
5767 | ||
50aef6f3 | 5768 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
718e3744 | 5769 | |
5770 | /* Print attribute */ | |
5771 | attr = binfo->attr; | |
5772 | if (attr) | |
5773 | { | |
5774 | /* Print aspath */ | |
5775 | if (attr->aspath) | |
841f7a57 | 5776 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5777 | |
5778 | /* Print origin */ | |
b2518c1e | 5779 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
718e3744 | 5780 | } |
5781 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5782 | } |
5783 | ||
718e3744 | 5784 | /* flap route */ |
5a646650 | 5785 | static void |
718e3744 | 5786 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
5787 | struct bgp_info *binfo, int display, safi_t safi) | |
5788 | { | |
5789 | struct attr *attr; | |
5790 | struct bgp_damp_info *bdi; | |
718e3744 | 5791 | char timebuf[BGP_UPTIME_LEN]; |
5792 | int len; | |
fb982c25 PJ |
5793 | |
5794 | if (!binfo->extra) | |
5795 | return; | |
5796 | ||
5797 | bdi = binfo->extra->damp_info; | |
718e3744 | 5798 | |
b40d939b | 5799 | /* short status lead text */ |
5800 | route_vty_short_status_out (vty, binfo); | |
5801 | ||
718e3744 | 5802 | /* print prefix and mask */ |
5803 | if (! display) | |
5804 | route_vty_out_route (p, vty); | |
5805 | else | |
5806 | vty_out (vty, "%*s", 17, " "); | |
5807 | ||
5808 | len = vty_out (vty, "%s", binfo->peer->host); | |
5809 | len = 16 - len; | |
5810 | if (len < 1) | |
5811 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); | |
5812 | else | |
5813 | vty_out (vty, "%*s", len, " "); | |
5814 | ||
5815 | len = vty_out (vty, "%d", bdi->flap); | |
5816 | len = 5 - len; | |
5817 | if (len < 1) | |
5818 | vty_out (vty, " "); | |
5819 | else | |
5820 | vty_out (vty, "%*s ", len, " "); | |
5821 | ||
5822 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, | |
5823 | timebuf, BGP_UPTIME_LEN)); | |
5824 | ||
5825 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) | |
5826 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
50aef6f3 | 5827 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
718e3744 | 5828 | else |
5829 | vty_out (vty, "%*s ", 8, " "); | |
5830 | ||
5831 | /* Print attribute */ | |
5832 | attr = binfo->attr; | |
5833 | if (attr) | |
5834 | { | |
5835 | /* Print aspath */ | |
5836 | if (attr->aspath) | |
841f7a57 | 5837 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5838 | |
5839 | /* Print origin */ | |
b2518c1e | 5840 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
718e3744 | 5841 | } |
5842 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5843 | } |
5844 | ||
94f2b392 | 5845 | static void |
718e3744 | 5846 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
5847 | struct bgp_info *binfo, afi_t afi, safi_t safi) | |
5848 | { | |
5849 | char buf[INET6_ADDRSTRLEN]; | |
5850 | char buf1[BUFSIZ]; | |
5851 | struct attr *attr; | |
5852 | int sockunion_vty_out (struct vty *, union sockunion *); | |
30b00176 JK |
5853 | #ifdef HAVE_CLOCK_MONOTONIC |
5854 | time_t tbuf; | |
5855 | #endif | |
718e3744 | 5856 | |
5857 | attr = binfo->attr; | |
5858 | ||
5859 | if (attr) | |
5860 | { | |
5861 | /* Line1 display AS-path, Aggregator */ | |
5862 | if (attr->aspath) | |
5863 | { | |
5864 | vty_out (vty, " "); | |
fe69a505 | 5865 | if (aspath_count_hops (attr->aspath) == 0) |
718e3744 | 5866 | vty_out (vty, "Local"); |
5867 | else | |
841f7a57 | 5868 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
718e3744 | 5869 | } |
5870 | ||
b40d939b | 5871 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
5872 | vty_out (vty, ", (removed)"); | |
93406d87 | 5873 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
5874 | vty_out (vty, ", (stale)"); | |
5875 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) | |
aea339f7 | 5876 | vty_out (vty, ", (aggregated by %u %s)", |
fb982c25 PJ |
5877 | attr->extra->aggregator_as, |
5878 | inet_ntoa (attr->extra->aggregator_addr)); | |
93406d87 | 5879 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
5880 | vty_out (vty, ", (Received from a RR-client)"); | |
5881 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
5882 | vty_out (vty, ", (Received from a RS-client)"); | |
5883 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5884 | vty_out (vty, ", (history entry)"); | |
5885 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5886 | vty_out (vty, ", (suppressed due to dampening)"); | |
718e3744 | 5887 | vty_out (vty, "%s", VTY_NEWLINE); |
5888 | ||
5889 | /* Line2 display Next-hop, Neighbor, Router-id */ | |
5890 | if (p->family == AF_INET) | |
5891 | { | |
5892 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? | |
fb982c25 | 5893 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
718e3744 | 5894 | inet_ntoa (attr->nexthop)); |
5895 | } | |
5896 | #ifdef HAVE_IPV6 | |
5897 | else | |
5898 | { | |
fb982c25 | 5899 | assert (attr->extra); |
718e3744 | 5900 | vty_out (vty, " %s", |
fb982c25 | 5901 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
718e3744 | 5902 | buf, INET6_ADDRSTRLEN)); |
5903 | } | |
5904 | #endif /* HAVE_IPV6 */ | |
5905 | ||
5906 | if (binfo->peer == bgp->peer_self) | |
5907 | { | |
5908 | vty_out (vty, " from %s ", | |
5909 | p->family == AF_INET ? "0.0.0.0" : "::"); | |
5910 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); | |
5911 | } | |
5912 | else | |
5913 | { | |
5914 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) | |
5915 | vty_out (vty, " (inaccessible)"); | |
fb982c25 PJ |
5916 | else if (binfo->extra && binfo->extra->igpmetric) |
5917 | vty_out (vty, " (metric %d)", binfo->extra->igpmetric); | |
eb821189 | 5918 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
718e3744 | 5919 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 | 5920 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
718e3744 | 5921 | else |
5922 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
5923 | } | |
5924 | vty_out (vty, "%s", VTY_NEWLINE); | |
5925 | ||
5926 | #ifdef HAVE_IPV6 | |
5927 | /* display nexthop local */ | |
fb982c25 | 5928 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
718e3744 | 5929 | { |
5930 | vty_out (vty, " (%s)%s", | |
fb982c25 | 5931 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
718e3744 | 5932 | buf, INET6_ADDRSTRLEN), |
5933 | VTY_NEWLINE); | |
5934 | } | |
5935 | #endif /* HAVE_IPV6 */ | |
5936 | ||
5937 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ | |
5938 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); | |
5939 | ||
5940 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) | |
c099baf6 | 5941 | vty_out (vty, ", metric %u", attr->med); |
718e3744 | 5942 | |
5943 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) | |
c099baf6 | 5944 | vty_out (vty, ", localpref %u", attr->local_pref); |
718e3744 | 5945 | else |
c099baf6 | 5946 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
718e3744 | 5947 | |
fb982c25 | 5948 | if (attr->extra && attr->extra->weight != 0) |
c099baf6 | 5949 | vty_out (vty, ", weight %u", attr->extra->weight); |
718e3744 | 5950 | |
5951 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5952 | vty_out (vty, ", valid"); | |
5953 | ||
5954 | if (binfo->peer != bgp->peer_self) | |
5955 | { | |
5956 | if (binfo->peer->as == binfo->peer->local_as) | |
5957 | vty_out (vty, ", internal"); | |
5958 | else | |
5959 | vty_out (vty, ", %s", | |
5960 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); | |
5961 | } | |
5962 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) | |
5963 | vty_out (vty, ", aggregated, local"); | |
5964 | else if (binfo->type != ZEBRA_ROUTE_BGP) | |
5965 | vty_out (vty, ", sourced"); | |
5966 | else | |
5967 | vty_out (vty, ", sourced, local"); | |
5968 | ||
5969 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) | |
5970 | vty_out (vty, ", atomic-aggregate"); | |
5971 | ||
de8d5dff JB |
5972 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
5973 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && | |
5974 | bgp_info_mpath_count (binfo))) | |
5975 | vty_out (vty, ", multipath"); | |
5976 | ||
718e3744 | 5977 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
5978 | vty_out (vty, ", best"); | |
5979 | ||
5980 | vty_out (vty, "%s", VTY_NEWLINE); | |
5981 | ||
5982 | /* Line 4 display Community */ | |
5983 | if (attr->community) | |
5984 | vty_out (vty, " Community: %s%s", attr->community->str, | |
5985 | VTY_NEWLINE); | |
5986 | ||
5987 | /* Line 5 display Extended-community */ | |
5988 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) | |
fb982c25 PJ |
5989 | vty_out (vty, " Extended Community: %s%s", |
5990 | attr->extra->ecommunity->str, VTY_NEWLINE); | |
718e3744 | 5991 | |
5992 | /* Line 6 display Originator, Cluster-id */ | |
5993 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || | |
5994 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) | |
5995 | { | |
fb982c25 | 5996 | assert (attr->extra); |
718e3744 | 5997 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 PJ |
5998 | vty_out (vty, " Originator: %s", |
5999 | inet_ntoa (attr->extra->originator_id)); | |
718e3744 | 6000 | |
6001 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
6002 | { | |
6003 | int i; | |
6004 | vty_out (vty, ", Cluster list: "); | |
fb982c25 PJ |
6005 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
6006 | vty_out (vty, "%s ", | |
6007 | inet_ntoa (attr->extra->cluster->list[i])); | |
718e3744 | 6008 | } |
6009 | vty_out (vty, "%s", VTY_NEWLINE); | |
6010 | } | |
41367172 | 6011 | |
fb982c25 | 6012 | if (binfo->extra && binfo->extra->damp_info) |
718e3744 | 6013 | bgp_damp_info_vty (vty, binfo); |
6014 | ||
6015 | /* Line 7 display Uptime */ | |
30b00176 JK |
6016 | #ifdef HAVE_CLOCK_MONOTONIC |
6017 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); | |
213b6cd9 | 6018 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
30b00176 JK |
6019 | #else |
6020 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); | |
6021 | #endif /* HAVE_CLOCK_MONOTONIC */ | |
718e3744 | 6022 | } |
6023 | vty_out (vty, "%s", VTY_NEWLINE); | |
6024 | } | |
6025 | \f | |
b40d939b | 6026 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale, R Removed%s" |
93406d87 | 6027 | #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s" |
718e3744 | 6028 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
6029 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" | |
6030 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" | |
6031 | ||
6032 | enum bgp_show_type | |
6033 | { | |
6034 | bgp_show_type_normal, | |
6035 | bgp_show_type_regexp, | |
6036 | bgp_show_type_prefix_list, | |
6037 | bgp_show_type_filter_list, | |
6038 | bgp_show_type_route_map, | |
6039 | bgp_show_type_neighbor, | |
6040 | bgp_show_type_cidr_only, | |
6041 | bgp_show_type_prefix_longer, | |
6042 | bgp_show_type_community_all, | |
6043 | bgp_show_type_community, | |
6044 | bgp_show_type_community_exact, | |
6045 | bgp_show_type_community_list, | |
6046 | bgp_show_type_community_list_exact, | |
6047 | bgp_show_type_flap_statistics, | |
6048 | bgp_show_type_flap_address, | |
6049 | bgp_show_type_flap_prefix, | |
6050 | bgp_show_type_flap_cidr_only, | |
6051 | bgp_show_type_flap_regexp, | |
6052 | bgp_show_type_flap_filter_list, | |
6053 | bgp_show_type_flap_prefix_list, | |
6054 | bgp_show_type_flap_prefix_longer, | |
6055 | bgp_show_type_flap_route_map, | |
6056 | bgp_show_type_flap_neighbor, | |
6057 | bgp_show_type_dampend_paths, | |
6058 | bgp_show_type_damp_neighbor | |
6059 | }; | |
6060 | ||
5a646650 | 6061 | static int |
fee0f4c6 | 6062 | bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id, |
5a646650 | 6063 | enum bgp_show_type type, void *output_arg) |
718e3744 | 6064 | { |
718e3744 | 6065 | struct bgp_info *ri; |
6066 | struct bgp_node *rn; | |
718e3744 | 6067 | int header = 1; |
718e3744 | 6068 | int display; |
5a646650 | 6069 | unsigned long output_count; |
718e3744 | 6070 | |
6071 | /* This is first entry point, so reset total line. */ | |
5a646650 | 6072 | output_count = 0; |
718e3744 | 6073 | |
718e3744 | 6074 | /* Start processing of routes. */ |
6075 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
6076 | if (rn->info != NULL) | |
6077 | { | |
6078 | display = 0; | |
6079 | ||
6080 | for (ri = rn->info; ri; ri = ri->next) | |
6081 | { | |
5a646650 | 6082 | if (type == bgp_show_type_flap_statistics |
718e3744 | 6083 | || type == bgp_show_type_flap_address |
6084 | || type == bgp_show_type_flap_prefix | |
6085 | || type == bgp_show_type_flap_cidr_only | |
6086 | || type == bgp_show_type_flap_regexp | |
6087 | || type == bgp_show_type_flap_filter_list | |
6088 | || type == bgp_show_type_flap_prefix_list | |
6089 | || type == bgp_show_type_flap_prefix_longer | |
6090 | || type == bgp_show_type_flap_route_map | |
6091 | || type == bgp_show_type_flap_neighbor | |
6092 | || type == bgp_show_type_dampend_paths | |
6093 | || type == bgp_show_type_damp_neighbor) | |
6094 | { | |
fb982c25 | 6095 | if (!(ri->extra && ri->extra->damp_info)) |
718e3744 | 6096 | continue; |
6097 | } | |
6098 | if (type == bgp_show_type_regexp | |
6099 | || type == bgp_show_type_flap_regexp) | |
6100 | { | |
5a646650 | 6101 | regex_t *regex = output_arg; |
718e3744 | 6102 | |
6103 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) | |
6104 | continue; | |
6105 | } | |
6106 | if (type == bgp_show_type_prefix_list | |
6107 | || type == bgp_show_type_flap_prefix_list) | |
6108 | { | |
5a646650 | 6109 | struct prefix_list *plist = output_arg; |
718e3744 | 6110 | |
6111 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) | |
6112 | continue; | |
6113 | } | |
6114 | if (type == bgp_show_type_filter_list | |
6115 | || type == bgp_show_type_flap_filter_list) | |
6116 | { | |
5a646650 | 6117 | struct as_list *as_list = output_arg; |
718e3744 | 6118 | |
6119 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) | |
6120 | continue; | |
6121 | } | |
6122 | if (type == bgp_show_type_route_map | |
6123 | || type == bgp_show_type_flap_route_map) | |
6124 | { | |
5a646650 | 6125 | struct route_map *rmap = output_arg; |
718e3744 | 6126 | struct bgp_info binfo; |
9eda90ce | 6127 | struct attr dummy_attr = { 0 }; |
718e3744 | 6128 | int ret; |
6129 | ||
fb982c25 | 6130 | bgp_attr_dup (&dummy_attr, ri->attr); |
718e3744 | 6131 | binfo.peer = ri->peer; |
6132 | binfo.attr = &dummy_attr; | |
6133 | ||
6134 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); | |
fb982c25 PJ |
6135 | |
6136 | bgp_attr_extra_free (&dummy_attr); | |
6137 | ||
718e3744 | 6138 | if (ret == RMAP_DENYMATCH) |
6139 | continue; | |
6140 | } | |
6141 | if (type == bgp_show_type_neighbor | |
6142 | || type == bgp_show_type_flap_neighbor | |
6143 | || type == bgp_show_type_damp_neighbor) | |
6144 | { | |
5a646650 | 6145 | union sockunion *su = output_arg; |
718e3744 | 6146 | |
6147 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) | |
6148 | continue; | |
6149 | } | |
6150 | if (type == bgp_show_type_cidr_only | |
6151 | || type == bgp_show_type_flap_cidr_only) | |
6152 | { | |
6153 | u_int32_t destination; | |
6154 | ||
6155 | destination = ntohl (rn->p.u.prefix4.s_addr); | |
6156 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) | |
6157 | continue; | |
6158 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) | |
6159 | continue; | |
6160 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) | |
6161 | continue; | |
6162 | } | |
6163 | if (type == bgp_show_type_prefix_longer | |
6164 | || type == bgp_show_type_flap_prefix_longer) | |
6165 | { | |
5a646650 | 6166 | struct prefix *p = output_arg; |
718e3744 | 6167 | |
6168 | if (! prefix_match (p, &rn->p)) | |
6169 | continue; | |
6170 | } | |
6171 | if (type == bgp_show_type_community_all) | |
6172 | { | |
6173 | if (! ri->attr->community) | |
6174 | continue; | |
6175 | } | |
6176 | if (type == bgp_show_type_community) | |
6177 | { | |
5a646650 | 6178 | struct community *com = output_arg; |
718e3744 | 6179 | |
6180 | if (! ri->attr->community || | |
6181 | ! community_match (ri->attr->community, com)) | |
6182 | continue; | |
6183 | } | |
6184 | if (type == bgp_show_type_community_exact) | |
6185 | { | |
5a646650 | 6186 | struct community *com = output_arg; |
718e3744 | 6187 | |
6188 | if (! ri->attr->community || | |
6189 | ! community_cmp (ri->attr->community, com)) | |
6190 | continue; | |
6191 | } | |
6192 | if (type == bgp_show_type_community_list) | |
6193 | { | |
5a646650 | 6194 | struct community_list *list = output_arg; |
718e3744 | 6195 | |
6196 | if (! community_list_match (ri->attr->community, list)) | |
6197 | continue; | |
6198 | } | |
6199 | if (type == bgp_show_type_community_list_exact) | |
6200 | { | |
5a646650 | 6201 | struct community_list *list = output_arg; |
718e3744 | 6202 | |
6203 | if (! community_list_exact_match (ri->attr->community, list)) | |
6204 | continue; | |
6205 | } | |
6206 | if (type == bgp_show_type_flap_address | |
6207 | || type == bgp_show_type_flap_prefix) | |
6208 | { | |
5a646650 | 6209 | struct prefix *p = output_arg; |
718e3744 | 6210 | |
6211 | if (! prefix_match (&rn->p, p)) | |
6212 | continue; | |
6213 | ||
6214 | if (type == bgp_show_type_flap_prefix) | |
6215 | if (p->prefixlen != rn->p.prefixlen) | |
6216 | continue; | |
6217 | } | |
6218 | if (type == bgp_show_type_dampend_paths | |
6219 | || type == bgp_show_type_damp_neighbor) | |
6220 | { | |
6221 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) | |
6222 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
6223 | continue; | |
6224 | } | |
6225 | ||
6226 | if (header) | |
6227 | { | |
93406d87 | 6228 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
6229 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
6230 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 6231 | if (type == bgp_show_type_dampend_paths |
6232 | || type == bgp_show_type_damp_neighbor) | |
6233 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); | |
6234 | else if (type == bgp_show_type_flap_statistics | |
6235 | || type == bgp_show_type_flap_address | |
6236 | || type == bgp_show_type_flap_prefix | |
6237 | || type == bgp_show_type_flap_cidr_only | |
6238 | || type == bgp_show_type_flap_regexp | |
6239 | || type == bgp_show_type_flap_filter_list | |
6240 | || type == bgp_show_type_flap_prefix_list | |
6241 | || type == bgp_show_type_flap_prefix_longer | |
6242 | || type == bgp_show_type_flap_route_map | |
6243 | || type == bgp_show_type_flap_neighbor) | |
6244 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); | |
6245 | else | |
6246 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
718e3744 | 6247 | header = 0; |
6248 | } | |
6249 | ||
6250 | if (type == bgp_show_type_dampend_paths | |
6251 | || type == bgp_show_type_damp_neighbor) | |
5a646650 | 6252 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6253 | else if (type == bgp_show_type_flap_statistics |
6254 | || type == bgp_show_type_flap_address | |
6255 | || type == bgp_show_type_flap_prefix | |
6256 | || type == bgp_show_type_flap_cidr_only | |
6257 | || type == bgp_show_type_flap_regexp | |
6258 | || type == bgp_show_type_flap_filter_list | |
6259 | || type == bgp_show_type_flap_prefix_list | |
6260 | || type == bgp_show_type_flap_prefix_longer | |
6261 | || type == bgp_show_type_flap_route_map | |
6262 | || type == bgp_show_type_flap_neighbor) | |
5a646650 | 6263 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6264 | else |
5a646650 | 6265 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6266 | display++; |
6267 | } | |
6268 | if (display) | |
5a646650 | 6269 | output_count++; |
718e3744 | 6270 | } |
6271 | ||
6272 | /* No route is displayed */ | |
5a646650 | 6273 | if (output_count == 0) |
718e3744 | 6274 | { |
6275 | if (type == bgp_show_type_normal) | |
6276 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); | |
6277 | } | |
6278 | else | |
6279 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
5a646650 | 6280 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
718e3744 | 6281 | |
6282 | return CMD_SUCCESS; | |
6283 | } | |
6284 | ||
5a646650 | 6285 | static int |
fee0f4c6 | 6286 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
5a646650 | 6287 | enum bgp_show_type type, void *output_arg) |
fee0f4c6 | 6288 | { |
6289 | struct bgp_table *table; | |
6290 | ||
6291 | if (bgp == NULL) { | |
6292 | bgp = bgp_get_default (); | |
6293 | } | |
6294 | ||
6295 | if (bgp == NULL) | |
6296 | { | |
6297 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6298 | return CMD_WARNING; | |
6299 | } | |
6300 | ||
6301 | ||
6302 | table = bgp->rib[afi][safi]; | |
6303 | ||
5a646650 | 6304 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
fee0f4c6 | 6305 | } |
6306 | ||
718e3744 | 6307 | /* Header of detailed BGP route information */ |
94f2b392 | 6308 | static void |
718e3744 | 6309 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
6310 | struct bgp_node *rn, | |
6311 | struct prefix_rd *prd, afi_t afi, safi_t safi) | |
6312 | { | |
6313 | struct bgp_info *ri; | |
6314 | struct prefix *p; | |
6315 | struct peer *peer; | |
1eb8ef25 | 6316 | struct listnode *node, *nnode; |
718e3744 | 6317 | char buf1[INET6_ADDRSTRLEN]; |
6318 | char buf2[INET6_ADDRSTRLEN]; | |
6319 | int count = 0; | |
6320 | int best = 0; | |
6321 | int suppress = 0; | |
6322 | int no_export = 0; | |
6323 | int no_advertise = 0; | |
6324 | int local_as = 0; | |
6325 | int first = 0; | |
6326 | ||
6327 | p = &rn->p; | |
6328 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", | |
6329 | (safi == SAFI_MPLS_VPN ? | |
6330 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), | |
6331 | safi == SAFI_MPLS_VPN ? ":" : "", | |
6332 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), | |
6333 | p->prefixlen, VTY_NEWLINE); | |
6334 | ||
6335 | for (ri = rn->info; ri; ri = ri->next) | |
6336 | { | |
6337 | count++; | |
6338 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
6339 | { | |
6340 | best = count; | |
fb982c25 | 6341 | if (ri->extra && ri->extra->suppress) |
718e3744 | 6342 | suppress = 1; |
6343 | if (ri->attr->community != NULL) | |
6344 | { | |
6345 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) | |
6346 | no_advertise = 1; | |
6347 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) | |
6348 | no_export = 1; | |
6349 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) | |
6350 | local_as = 1; | |
6351 | } | |
6352 | } | |
6353 | } | |
6354 | ||
6355 | vty_out (vty, "Paths: (%d available", count); | |
6356 | if (best) | |
6357 | { | |
6358 | vty_out (vty, ", best #%d", best); | |
6359 | if (safi == SAFI_UNICAST) | |
6360 | vty_out (vty, ", table Default-IP-Routing-Table"); | |
6361 | } | |
6362 | else | |
6363 | vty_out (vty, ", no best path"); | |
6364 | if (no_advertise) | |
6365 | vty_out (vty, ", not advertised to any peer"); | |
6366 | else if (no_export) | |
6367 | vty_out (vty, ", not advertised to EBGP peer"); | |
6368 | else if (local_as) | |
6369 | vty_out (vty, ", not advertised outside local AS"); | |
6370 | if (suppress) | |
6371 | vty_out (vty, ", Advertisements suppressed by an aggregate."); | |
6372 | vty_out (vty, ")%s", VTY_NEWLINE); | |
6373 | ||
6374 | /* advertised peer */ | |
1eb8ef25 | 6375 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6376 | { |
6377 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) | |
6378 | { | |
6379 | if (! first) | |
6380 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); | |
6381 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6382 | first = 1; | |
6383 | } | |
6384 | } | |
6385 | if (! first) | |
6386 | vty_out (vty, " Not advertised to any peer"); | |
6387 | vty_out (vty, "%s", VTY_NEWLINE); | |
6388 | } | |
6389 | ||
6390 | /* Display specified route of BGP table. */ | |
94f2b392 | 6391 | static int |
fee0f4c6 | 6392 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
fd79ac91 | 6393 | struct bgp_table *rib, const char *ip_str, |
6394 | afi_t afi, safi_t safi, struct prefix_rd *prd, | |
6395 | int prefix_check) | |
718e3744 | 6396 | { |
6397 | int ret; | |
6398 | int header; | |
6399 | int display = 0; | |
6400 | struct prefix match; | |
6401 | struct bgp_node *rn; | |
6402 | struct bgp_node *rm; | |
6403 | struct bgp_info *ri; | |
718e3744 | 6404 | struct bgp_table *table; |
6405 | ||
718e3744 | 6406 | /* Check IP address argument. */ |
6407 | ret = str2prefix (ip_str, &match); | |
6408 | if (! ret) | |
6409 | { | |
6410 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); | |
6411 | return CMD_WARNING; | |
6412 | } | |
6413 | ||
6414 | match.family = afi2family (afi); | |
6415 | ||
6416 | if (safi == SAFI_MPLS_VPN) | |
6417 | { | |
fee0f4c6 | 6418 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
718e3744 | 6419 | { |
6420 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
6421 | continue; | |
6422 | ||
6423 | if ((table = rn->info) != NULL) | |
6424 | { | |
6425 | header = 1; | |
6426 | ||
6427 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6428 | { | |
6429 | if (prefix_check && rm->p.prefixlen != match.prefixlen) | |
6c88b44d CC |
6430 | { |
6431 | bgp_unlock_node (rm); | |
6432 | continue; | |
6433 | } | |
718e3744 | 6434 | |
6435 | for (ri = rm->info; ri; ri = ri->next) | |
6436 | { | |
6437 | if (header) | |
6438 | { | |
6439 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, | |
6440 | AFI_IP, SAFI_MPLS_VPN); | |
6441 | ||
6442 | header = 0; | |
6443 | } | |
6444 | display++; | |
6445 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); | |
6446 | } | |
6c88b44d CC |
6447 | |
6448 | bgp_unlock_node (rm); | |
718e3744 | 6449 | } |
6450 | } | |
6451 | } | |
6452 | } | |
6453 | else | |
6454 | { | |
6455 | header = 1; | |
6456 | ||
fee0f4c6 | 6457 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
718e3744 | 6458 | { |
6459 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
6460 | { | |
6461 | for (ri = rn->info; ri; ri = ri->next) | |
6462 | { | |
6463 | if (header) | |
6464 | { | |
6465 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); | |
6466 | header = 0; | |
6467 | } | |
6468 | display++; | |
6469 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); | |
6470 | } | |
6471 | } | |
6c88b44d CC |
6472 | |
6473 | bgp_unlock_node (rn); | |
718e3744 | 6474 | } |
6475 | } | |
6476 | ||
6477 | if (! display) | |
6478 | { | |
6479 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); | |
6480 | return CMD_WARNING; | |
6481 | } | |
6482 | ||
6483 | return CMD_SUCCESS; | |
6484 | } | |
6485 | ||
fee0f4c6 | 6486 | /* Display specified route of Main RIB */ |
94f2b392 | 6487 | static int |
fd79ac91 | 6488 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
fee0f4c6 | 6489 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
6490 | int prefix_check) | |
6491 | { | |
6492 | struct bgp *bgp; | |
6493 | ||
6494 | /* BGP structure lookup. */ | |
6495 | if (view_name) | |
6496 | { | |
6497 | bgp = bgp_lookup_by_name (view_name); | |
6498 | if (bgp == NULL) | |
6499 | { | |
6500 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
6501 | return CMD_WARNING; | |
6502 | } | |
6503 | } | |
6504 | else | |
6505 | { | |
6506 | bgp = bgp_get_default (); | |
6507 | if (bgp == NULL) | |
6508 | { | |
6509 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6510 | return CMD_WARNING; | |
6511 | } | |
6512 | } | |
6513 | ||
6514 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, | |
6515 | afi, safi, prd, prefix_check); | |
6516 | } | |
6517 | ||
718e3744 | 6518 | /* BGP route print out function. */ |
6519 | DEFUN (show_ip_bgp, | |
6520 | show_ip_bgp_cmd, | |
6521 | "show ip bgp", | |
6522 | SHOW_STR | |
6523 | IP_STR | |
6524 | BGP_STR) | |
6525 | { | |
5a646650 | 6526 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6527 | } |
6528 | ||
6529 | DEFUN (show_ip_bgp_ipv4, | |
6530 | show_ip_bgp_ipv4_cmd, | |
6531 | "show ip bgp ipv4 (unicast|multicast)", | |
6532 | SHOW_STR | |
6533 | IP_STR | |
6534 | BGP_STR | |
6535 | "Address family\n" | |
6536 | "Address Family modifier\n" | |
6537 | "Address Family modifier\n") | |
6538 | { | |
6539 | if (strncmp (argv[0], "m", 1) == 0) | |
5a646650 | 6540 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
6541 | NULL); | |
718e3744 | 6542 | |
5a646650 | 6543 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6544 | } |
6545 | ||
95cbbd2a ML |
6546 | ALIAS (show_ip_bgp_ipv4, |
6547 | show_bgp_ipv4_safi_cmd, | |
6548 | "show bgp ipv4 (unicast|multicast)", | |
6549 | SHOW_STR | |
6550 | BGP_STR | |
6551 | "Address family\n" | |
6552 | "Address Family modifier\n" | |
6553 | "Address Family modifier\n") | |
6554 | ||
718e3744 | 6555 | DEFUN (show_ip_bgp_route, |
6556 | show_ip_bgp_route_cmd, | |
6557 | "show ip bgp A.B.C.D", | |
6558 | SHOW_STR | |
6559 | IP_STR | |
6560 | BGP_STR | |
6561 | "Network in the BGP routing table to display\n") | |
6562 | { | |
6563 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6564 | } | |
6565 | ||
6566 | DEFUN (show_ip_bgp_ipv4_route, | |
6567 | show_ip_bgp_ipv4_route_cmd, | |
6568 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", | |
6569 | SHOW_STR | |
6570 | IP_STR | |
6571 | BGP_STR | |
6572 | "Address family\n" | |
6573 | "Address Family modifier\n" | |
6574 | "Address Family modifier\n" | |
6575 | "Network in the BGP routing table to display\n") | |
6576 | { | |
6577 | if (strncmp (argv[0], "m", 1) == 0) | |
6578 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); | |
6579 | ||
6580 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6581 | } | |
6582 | ||
95cbbd2a ML |
6583 | ALIAS (show_ip_bgp_ipv4_route, |
6584 | show_bgp_ipv4_safi_route_cmd, | |
6585 | "show bgp ipv4 (unicast|multicast) A.B.C.D", | |
6586 | SHOW_STR | |
6587 | BGP_STR | |
6588 | "Address family\n" | |
6589 | "Address Family modifier\n" | |
6590 | "Address Family modifier\n" | |
6591 | "Network in the BGP routing table to display\n") | |
6592 | ||
718e3744 | 6593 | DEFUN (show_ip_bgp_vpnv4_all_route, |
6594 | show_ip_bgp_vpnv4_all_route_cmd, | |
6595 | "show ip bgp vpnv4 all A.B.C.D", | |
6596 | SHOW_STR | |
6597 | IP_STR | |
6598 | BGP_STR | |
6599 | "Display VPNv4 NLRI specific information\n" | |
6600 | "Display information about all VPNv4 NLRIs\n" | |
6601 | "Network in the BGP routing table to display\n") | |
6602 | { | |
6603 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); | |
6604 | } | |
6605 | ||
6606 | DEFUN (show_ip_bgp_vpnv4_rd_route, | |
6607 | show_ip_bgp_vpnv4_rd_route_cmd, | |
6608 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", | |
6609 | SHOW_STR | |
6610 | IP_STR | |
6611 | BGP_STR | |
6612 | "Display VPNv4 NLRI specific information\n" | |
6613 | "Display information for a route distinguisher\n" | |
6614 | "VPN Route Distinguisher\n" | |
6615 | "Network in the BGP routing table to display\n") | |
6616 | { | |
6617 | int ret; | |
6618 | struct prefix_rd prd; | |
6619 | ||
6620 | ret = str2prefix_rd (argv[0], &prd); | |
6621 | if (! ret) | |
6622 | { | |
6623 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6624 | return CMD_WARNING; | |
6625 | } | |
6626 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); | |
6627 | } | |
6628 | ||
6629 | DEFUN (show_ip_bgp_prefix, | |
6630 | show_ip_bgp_prefix_cmd, | |
6631 | "show ip bgp A.B.C.D/M", | |
6632 | SHOW_STR | |
6633 | IP_STR | |
6634 | BGP_STR | |
6635 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6636 | { | |
6637 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6638 | } | |
6639 | ||
6640 | DEFUN (show_ip_bgp_ipv4_prefix, | |
6641 | show_ip_bgp_ipv4_prefix_cmd, | |
6642 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", | |
6643 | SHOW_STR | |
6644 | IP_STR | |
6645 | BGP_STR | |
6646 | "Address family\n" | |
6647 | "Address Family modifier\n" | |
6648 | "Address Family modifier\n" | |
6649 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6650 | { | |
6651 | if (strncmp (argv[0], "m", 1) == 0) | |
6652 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); | |
6653 | ||
6654 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6655 | } | |
6656 | ||
95cbbd2a ML |
6657 | ALIAS (show_ip_bgp_ipv4_prefix, |
6658 | show_bgp_ipv4_safi_prefix_cmd, | |
6659 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", | |
6660 | SHOW_STR | |
6661 | BGP_STR | |
6662 | "Address family\n" | |
6663 | "Address Family modifier\n" | |
6664 | "Address Family modifier\n" | |
6665 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6666 | ||
718e3744 | 6667 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
6668 | show_ip_bgp_vpnv4_all_prefix_cmd, | |
6669 | "show ip bgp vpnv4 all A.B.C.D/M", | |
6670 | SHOW_STR | |
6671 | IP_STR | |
6672 | BGP_STR | |
6673 | "Display VPNv4 NLRI specific information\n" | |
6674 | "Display information about all VPNv4 NLRIs\n" | |
6675 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6676 | { | |
6677 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); | |
6678 | } | |
6679 | ||
6680 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, | |
6681 | show_ip_bgp_vpnv4_rd_prefix_cmd, | |
6682 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", | |
6683 | SHOW_STR | |
6684 | IP_STR | |
6685 | BGP_STR | |
6686 | "Display VPNv4 NLRI specific information\n" | |
6687 | "Display information for a route distinguisher\n" | |
6688 | "VPN Route Distinguisher\n" | |
6689 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6690 | { | |
6691 | int ret; | |
6692 | struct prefix_rd prd; | |
6693 | ||
6694 | ret = str2prefix_rd (argv[0], &prd); | |
6695 | if (! ret) | |
6696 | { | |
6697 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6698 | return CMD_WARNING; | |
6699 | } | |
6700 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); | |
6701 | } | |
6702 | ||
6703 | DEFUN (show_ip_bgp_view, | |
6704 | show_ip_bgp_view_cmd, | |
6705 | "show ip bgp view WORD", | |
6706 | SHOW_STR | |
6707 | IP_STR | |
6708 | BGP_STR | |
6709 | "BGP view\n" | |
6710 | "BGP view name\n") | |
6711 | { | |
bb46e94f | 6712 | struct bgp *bgp; |
6713 | ||
6714 | /* BGP structure lookup. */ | |
6715 | bgp = bgp_lookup_by_name (argv[0]); | |
6716 | if (bgp == NULL) | |
6717 | { | |
6718 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6719 | return CMD_WARNING; | |
6720 | } | |
6721 | ||
5a646650 | 6722 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6723 | } |
6724 | ||
6725 | DEFUN (show_ip_bgp_view_route, | |
6726 | show_ip_bgp_view_route_cmd, | |
6727 | "show ip bgp view WORD A.B.C.D", | |
6728 | SHOW_STR | |
6729 | IP_STR | |
6730 | BGP_STR | |
6731 | "BGP view\n" | |
6732 | "BGP view name\n" | |
6733 | "Network in the BGP routing table to display\n") | |
6734 | { | |
6735 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6736 | } | |
6737 | ||
6738 | DEFUN (show_ip_bgp_view_prefix, | |
6739 | show_ip_bgp_view_prefix_cmd, | |
6740 | "show ip bgp view WORD A.B.C.D/M", | |
6741 | SHOW_STR | |
6742 | IP_STR | |
6743 | BGP_STR | |
6744 | "BGP view\n" | |
6745 | "BGP view name\n" | |
6746 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6747 | { | |
6748 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6749 | } | |
6750 | ||
6751 | #ifdef HAVE_IPV6 | |
6752 | DEFUN (show_bgp, | |
6753 | show_bgp_cmd, | |
6754 | "show bgp", | |
6755 | SHOW_STR | |
6756 | BGP_STR) | |
6757 | { | |
5a646650 | 6758 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6759 | NULL); | |
718e3744 | 6760 | } |
6761 | ||
6762 | ALIAS (show_bgp, | |
6763 | show_bgp_ipv6_cmd, | |
6764 | "show bgp ipv6", | |
6765 | SHOW_STR | |
6766 | BGP_STR | |
6767 | "Address family\n") | |
6768 | ||
95cbbd2a ML |
6769 | DEFUN (show_bgp_ipv6_safi, |
6770 | show_bgp_ipv6_safi_cmd, | |
6771 | "show bgp ipv6 (unicast|multicast)", | |
6772 | SHOW_STR | |
6773 | BGP_STR | |
6774 | "Address family\n" | |
6775 | "Address Family modifier\n" | |
6776 | "Address Family modifier\n") | |
6777 | { | |
6778 | if (strncmp (argv[0], "m", 1) == 0) | |
6779 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, | |
6780 | NULL); | |
6781 | ||
6782 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); | |
6783 | } | |
6784 | ||
718e3744 | 6785 | /* old command */ |
6786 | DEFUN (show_ipv6_bgp, | |
6787 | show_ipv6_bgp_cmd, | |
6788 | "show ipv6 bgp", | |
6789 | SHOW_STR | |
6790 | IP_STR | |
6791 | BGP_STR) | |
6792 | { | |
5a646650 | 6793 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6794 | NULL); | |
718e3744 | 6795 | } |
6796 | ||
6797 | DEFUN (show_bgp_route, | |
6798 | show_bgp_route_cmd, | |
6799 | "show bgp X:X::X:X", | |
6800 | SHOW_STR | |
6801 | BGP_STR | |
6802 | "Network in the BGP routing table to display\n") | |
6803 | { | |
6804 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6805 | } | |
6806 | ||
6807 | ALIAS (show_bgp_route, | |
6808 | show_bgp_ipv6_route_cmd, | |
6809 | "show bgp ipv6 X:X::X:X", | |
6810 | SHOW_STR | |
6811 | BGP_STR | |
6812 | "Address family\n" | |
6813 | "Network in the BGP routing table to display\n") | |
6814 | ||
95cbbd2a ML |
6815 | DEFUN (show_bgp_ipv6_safi_route, |
6816 | show_bgp_ipv6_safi_route_cmd, | |
6817 | "show bgp ipv6 (unicast|multicast) X:X::X:X", | |
6818 | SHOW_STR | |
6819 | BGP_STR | |
6820 | "Address family\n" | |
6821 | "Address Family modifier\n" | |
6822 | "Address Family modifier\n" | |
6823 | "Network in the BGP routing table to display\n") | |
6824 | { | |
6825 | if (strncmp (argv[0], "m", 1) == 0) | |
6826 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); | |
6827 | ||
6828 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6829 | } | |
6830 | ||
718e3744 | 6831 | /* old command */ |
6832 | DEFUN (show_ipv6_bgp_route, | |
6833 | show_ipv6_bgp_route_cmd, | |
6834 | "show ipv6 bgp X:X::X:X", | |
6835 | SHOW_STR | |
6836 | IP_STR | |
6837 | BGP_STR | |
6838 | "Network in the BGP routing table to display\n") | |
6839 | { | |
6840 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6841 | } | |
6842 | ||
6843 | DEFUN (show_bgp_prefix, | |
6844 | show_bgp_prefix_cmd, | |
6845 | "show bgp X:X::X:X/M", | |
6846 | SHOW_STR | |
6847 | BGP_STR | |
6848 | "IPv6 prefix <network>/<length>\n") | |
6849 | { | |
6850 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6851 | } | |
6852 | ||
6853 | ALIAS (show_bgp_prefix, | |
6854 | show_bgp_ipv6_prefix_cmd, | |
6855 | "show bgp ipv6 X:X::X:X/M", | |
6856 | SHOW_STR | |
6857 | BGP_STR | |
6858 | "Address family\n" | |
6859 | "IPv6 prefix <network>/<length>\n") | |
6860 | ||
95cbbd2a ML |
6861 | DEFUN (show_bgp_ipv6_safi_prefix, |
6862 | show_bgp_ipv6_safi_prefix_cmd, | |
6863 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", | |
6864 | SHOW_STR | |
6865 | BGP_STR | |
6866 | "Address family\n" | |
6867 | "Address Family modifier\n" | |
6868 | "Address Family modifier\n" | |
6869 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6870 | { | |
6871 | if (strncmp (argv[0], "m", 1) == 0) | |
6872 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); | |
6873 | ||
6874 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6875 | } | |
6876 | ||
718e3744 | 6877 | /* old command */ |
6878 | DEFUN (show_ipv6_bgp_prefix, | |
6879 | show_ipv6_bgp_prefix_cmd, | |
6880 | "show ipv6 bgp X:X::X:X/M", | |
6881 | SHOW_STR | |
6882 | IP_STR | |
6883 | BGP_STR | |
6884 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6885 | { | |
6886 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6887 | } | |
6888 | ||
bb46e94f | 6889 | DEFUN (show_bgp_view, |
6890 | show_bgp_view_cmd, | |
6891 | "show bgp view WORD", | |
6892 | SHOW_STR | |
6893 | BGP_STR | |
6894 | "BGP view\n" | |
6895 | "View name\n") | |
6896 | { | |
6897 | struct bgp *bgp; | |
6898 | ||
6899 | /* BGP structure lookup. */ | |
6900 | bgp = bgp_lookup_by_name (argv[0]); | |
6901 | if (bgp == NULL) | |
6902 | { | |
6903 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6904 | return CMD_WARNING; | |
6905 | } | |
6906 | ||
5a646650 | 6907 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
bb46e94f | 6908 | } |
6909 | ||
6910 | ALIAS (show_bgp_view, | |
6911 | show_bgp_view_ipv6_cmd, | |
6912 | "show bgp view WORD ipv6", | |
6913 | SHOW_STR | |
6914 | BGP_STR | |
6915 | "BGP view\n" | |
6916 | "View name\n" | |
6917 | "Address family\n") | |
6918 | ||
6919 | DEFUN (show_bgp_view_route, | |
6920 | show_bgp_view_route_cmd, | |
6921 | "show bgp view WORD X:X::X:X", | |
6922 | SHOW_STR | |
6923 | BGP_STR | |
6924 | "BGP view\n" | |
6925 | "View name\n" | |
6926 | "Network in the BGP routing table to display\n") | |
6927 | { | |
6928 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6929 | } | |
6930 | ||
6931 | ALIAS (show_bgp_view_route, | |
6932 | show_bgp_view_ipv6_route_cmd, | |
6933 | "show bgp view WORD ipv6 X:X::X:X", | |
6934 | SHOW_STR | |
6935 | BGP_STR | |
6936 | "BGP view\n" | |
6937 | "View name\n" | |
6938 | "Address family\n" | |
6939 | "Network in the BGP routing table to display\n") | |
6940 | ||
6941 | DEFUN (show_bgp_view_prefix, | |
6942 | show_bgp_view_prefix_cmd, | |
6943 | "show bgp view WORD X:X::X:X/M", | |
6944 | SHOW_STR | |
6945 | BGP_STR | |
6946 | "BGP view\n" | |
6947 | "View name\n" | |
6948 | "IPv6 prefix <network>/<length>\n") | |
6949 | { | |
6950 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6951 | } | |
6952 | ||
6953 | ALIAS (show_bgp_view_prefix, | |
6954 | show_bgp_view_ipv6_prefix_cmd, | |
6955 | "show bgp view WORD ipv6 X:X::X:X/M", | |
6956 | SHOW_STR | |
6957 | BGP_STR | |
6958 | "BGP view\n" | |
6959 | "View name\n" | |
6960 | "Address family\n" | |
6961 | "IPv6 prefix <network>/<length>\n") | |
6962 | ||
718e3744 | 6963 | /* old command */ |
6964 | DEFUN (show_ipv6_mbgp, | |
6965 | show_ipv6_mbgp_cmd, | |
6966 | "show ipv6 mbgp", | |
6967 | SHOW_STR | |
6968 | IP_STR | |
6969 | MBGP_STR) | |
6970 | { | |
5a646650 | 6971 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
6972 | NULL); | |
718e3744 | 6973 | } |
6974 | ||
6975 | /* old command */ | |
6976 | DEFUN (show_ipv6_mbgp_route, | |
6977 | show_ipv6_mbgp_route_cmd, | |
6978 | "show ipv6 mbgp X:X::X:X", | |
6979 | SHOW_STR | |
6980 | IP_STR | |
6981 | MBGP_STR | |
6982 | "Network in the MBGP routing table to display\n") | |
6983 | { | |
6984 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); | |
6985 | } | |
6986 | ||
6987 | /* old command */ | |
6988 | DEFUN (show_ipv6_mbgp_prefix, | |
6989 | show_ipv6_mbgp_prefix_cmd, | |
6990 | "show ipv6 mbgp X:X::X:X/M", | |
6991 | SHOW_STR | |
6992 | IP_STR | |
6993 | MBGP_STR | |
6994 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6995 | { | |
6996 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); | |
6997 | } | |
6998 | #endif | |
6999 | \f | |
718e3744 | 7000 | |
94f2b392 | 7001 | static int |
fd79ac91 | 7002 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
718e3744 | 7003 | safi_t safi, enum bgp_show_type type) |
7004 | { | |
7005 | int i; | |
7006 | struct buffer *b; | |
7007 | char *regstr; | |
7008 | int first; | |
7009 | regex_t *regex; | |
5a646650 | 7010 | int rc; |
718e3744 | 7011 | |
7012 | first = 0; | |
7013 | b = buffer_new (1024); | |
7014 | for (i = 0; i < argc; i++) | |
7015 | { | |
7016 | if (first) | |
7017 | buffer_putc (b, ' '); | |
7018 | else | |
7019 | { | |
7020 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
7021 | continue; | |
7022 | first = 1; | |
7023 | } | |
7024 | ||
7025 | buffer_putstr (b, argv[i]); | |
7026 | } | |
7027 | buffer_putc (b, '\0'); | |
7028 | ||
7029 | regstr = buffer_getstr (b); | |
7030 | buffer_free (b); | |
7031 | ||
7032 | regex = bgp_regcomp (regstr); | |
3b8b1855 | 7033 | XFREE(MTYPE_TMP, regstr); |
718e3744 | 7034 | if (! regex) |
7035 | { | |
7036 | vty_out (vty, "Can't compile regexp %s%s", argv[0], | |
7037 | VTY_NEWLINE); | |
7038 | return CMD_WARNING; | |
7039 | } | |
7040 | ||
5a646650 | 7041 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
7042 | bgp_regex_free (regex); | |
7043 | return rc; | |
718e3744 | 7044 | } |
7045 | ||
7046 | DEFUN (show_ip_bgp_regexp, | |
7047 | show_ip_bgp_regexp_cmd, | |
7048 | "show ip bgp regexp .LINE", | |
7049 | SHOW_STR | |
7050 | IP_STR | |
7051 | BGP_STR | |
7052 | "Display routes matching the AS path regular expression\n" | |
7053 | "A regular-expression to match the BGP AS paths\n") | |
7054 | { | |
7055 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7056 | bgp_show_type_regexp); | |
7057 | } | |
7058 | ||
7059 | DEFUN (show_ip_bgp_flap_regexp, | |
7060 | show_ip_bgp_flap_regexp_cmd, | |
7061 | "show ip bgp flap-statistics regexp .LINE", | |
7062 | SHOW_STR | |
7063 | IP_STR | |
7064 | BGP_STR | |
7065 | "Display flap statistics of routes\n" | |
7066 | "Display routes matching the AS path regular expression\n" | |
7067 | "A regular-expression to match the BGP AS paths\n") | |
7068 | { | |
7069 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7070 | bgp_show_type_flap_regexp); | |
7071 | } | |
7072 | ||
7073 | DEFUN (show_ip_bgp_ipv4_regexp, | |
7074 | show_ip_bgp_ipv4_regexp_cmd, | |
7075 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", | |
7076 | SHOW_STR | |
7077 | IP_STR | |
7078 | BGP_STR | |
7079 | "Address family\n" | |
7080 | "Address Family modifier\n" | |
7081 | "Address Family modifier\n" | |
7082 | "Display routes matching the AS path regular expression\n" | |
7083 | "A regular-expression to match the BGP AS paths\n") | |
7084 | { | |
7085 | if (strncmp (argv[0], "m", 1) == 0) | |
7086 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, | |
7087 | bgp_show_type_regexp); | |
7088 | ||
7089 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7090 | bgp_show_type_regexp); | |
7091 | } | |
7092 | ||
7093 | #ifdef HAVE_IPV6 | |
7094 | DEFUN (show_bgp_regexp, | |
7095 | show_bgp_regexp_cmd, | |
7096 | "show bgp regexp .LINE", | |
7097 | SHOW_STR | |
7098 | BGP_STR | |
7099 | "Display routes matching the AS path regular expression\n" | |
7100 | "A regular-expression to match the BGP AS paths\n") | |
7101 | { | |
7102 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7103 | bgp_show_type_regexp); | |
7104 | } | |
7105 | ||
7106 | ALIAS (show_bgp_regexp, | |
7107 | show_bgp_ipv6_regexp_cmd, | |
7108 | "show bgp ipv6 regexp .LINE", | |
7109 | SHOW_STR | |
7110 | BGP_STR | |
7111 | "Address family\n" | |
7112 | "Display routes matching the AS path regular expression\n" | |
7113 | "A regular-expression to match the BGP AS paths\n") | |
7114 | ||
7115 | /* old command */ | |
7116 | DEFUN (show_ipv6_bgp_regexp, | |
7117 | show_ipv6_bgp_regexp_cmd, | |
7118 | "show ipv6 bgp regexp .LINE", | |
7119 | SHOW_STR | |
7120 | IP_STR | |
7121 | BGP_STR | |
7122 | "Display routes matching the AS path regular expression\n" | |
7123 | "A regular-expression to match the BGP AS paths\n") | |
7124 | { | |
7125 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7126 | bgp_show_type_regexp); | |
7127 | } | |
7128 | ||
7129 | /* old command */ | |
7130 | DEFUN (show_ipv6_mbgp_regexp, | |
7131 | show_ipv6_mbgp_regexp_cmd, | |
7132 | "show ipv6 mbgp regexp .LINE", | |
7133 | SHOW_STR | |
7134 | IP_STR | |
7135 | BGP_STR | |
7136 | "Display routes matching the AS path regular expression\n" | |
7137 | "A regular-expression to match the MBGP AS paths\n") | |
7138 | { | |
7139 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, | |
7140 | bgp_show_type_regexp); | |
7141 | } | |
7142 | #endif /* HAVE_IPV6 */ | |
7143 | \f | |
94f2b392 | 7144 | static int |
fd79ac91 | 7145 | bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi, |
718e3744 | 7146 | safi_t safi, enum bgp_show_type type) |
7147 | { | |
7148 | struct prefix_list *plist; | |
7149 | ||
7150 | plist = prefix_list_lookup (afi, prefix_list_str); | |
7151 | if (plist == NULL) | |
7152 | { | |
7153 | vty_out (vty, "%% %s is not a valid prefix-list name%s", | |
7154 | prefix_list_str, VTY_NEWLINE); | |
7155 | return CMD_WARNING; | |
7156 | } | |
7157 | ||
5a646650 | 7158 | return bgp_show (vty, NULL, afi, safi, type, plist); |
718e3744 | 7159 | } |
7160 | ||
7161 | DEFUN (show_ip_bgp_prefix_list, | |
7162 | show_ip_bgp_prefix_list_cmd, | |
7163 | "show ip bgp prefix-list WORD", | |
7164 | SHOW_STR | |
7165 | IP_STR | |
7166 | BGP_STR | |
7167 | "Display routes conforming to the prefix-list\n" | |
7168 | "IP prefix-list name\n") | |
7169 | { | |
7170 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7171 | bgp_show_type_prefix_list); | |
7172 | } | |
7173 | ||
7174 | DEFUN (show_ip_bgp_flap_prefix_list, | |
7175 | show_ip_bgp_flap_prefix_list_cmd, | |
7176 | "show ip bgp flap-statistics prefix-list WORD", | |
7177 | SHOW_STR | |
7178 | IP_STR | |
7179 | BGP_STR | |
7180 | "Display flap statistics of routes\n" | |
7181 | "Display routes conforming to the prefix-list\n" | |
7182 | "IP prefix-list name\n") | |
7183 | { | |
7184 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7185 | bgp_show_type_flap_prefix_list); | |
7186 | } | |
7187 | ||
7188 | DEFUN (show_ip_bgp_ipv4_prefix_list, | |
7189 | show_ip_bgp_ipv4_prefix_list_cmd, | |
7190 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", | |
7191 | SHOW_STR | |
7192 | IP_STR | |
7193 | BGP_STR | |
7194 | "Address family\n" | |
7195 | "Address Family modifier\n" | |
7196 | "Address Family modifier\n" | |
7197 | "Display routes conforming to the prefix-list\n" | |
7198 | "IP prefix-list name\n") | |
7199 | { | |
7200 | if (strncmp (argv[0], "m", 1) == 0) | |
7201 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7202 | bgp_show_type_prefix_list); | |
7203 | ||
7204 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7205 | bgp_show_type_prefix_list); | |
7206 | } | |
7207 | ||
7208 | #ifdef HAVE_IPV6 | |
7209 | DEFUN (show_bgp_prefix_list, | |
7210 | show_bgp_prefix_list_cmd, | |
7211 | "show bgp prefix-list WORD", | |
7212 | SHOW_STR | |
7213 | BGP_STR | |
7214 | "Display routes conforming to the prefix-list\n" | |
7215 | "IPv6 prefix-list name\n") | |
7216 | { | |
7217 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7218 | bgp_show_type_prefix_list); | |
7219 | } | |
7220 | ||
7221 | ALIAS (show_bgp_prefix_list, | |
7222 | show_bgp_ipv6_prefix_list_cmd, | |
7223 | "show bgp ipv6 prefix-list WORD", | |
7224 | SHOW_STR | |
7225 | BGP_STR | |
7226 | "Address family\n" | |
7227 | "Display routes conforming to the prefix-list\n" | |
7228 | "IPv6 prefix-list name\n") | |
7229 | ||
7230 | /* old command */ | |
7231 | DEFUN (show_ipv6_bgp_prefix_list, | |
7232 | show_ipv6_bgp_prefix_list_cmd, | |
7233 | "show ipv6 bgp prefix-list WORD", | |
7234 | SHOW_STR | |
7235 | IPV6_STR | |
7236 | BGP_STR | |
7237 | "Display routes matching the prefix-list\n" | |
7238 | "IPv6 prefix-list name\n") | |
7239 | { | |
7240 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7241 | bgp_show_type_prefix_list); | |
7242 | } | |
7243 | ||
7244 | /* old command */ | |
7245 | DEFUN (show_ipv6_mbgp_prefix_list, | |
7246 | show_ipv6_mbgp_prefix_list_cmd, | |
7247 | "show ipv6 mbgp prefix-list WORD", | |
7248 | SHOW_STR | |
7249 | IPV6_STR | |
7250 | MBGP_STR | |
7251 | "Display routes matching the prefix-list\n" | |
7252 | "IPv6 prefix-list name\n") | |
7253 | { | |
7254 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7255 | bgp_show_type_prefix_list); | |
7256 | } | |
7257 | #endif /* HAVE_IPV6 */ | |
7258 | \f | |
94f2b392 | 7259 | static int |
fd79ac91 | 7260 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
718e3744 | 7261 | safi_t safi, enum bgp_show_type type) |
7262 | { | |
7263 | struct as_list *as_list; | |
7264 | ||
7265 | as_list = as_list_lookup (filter); | |
7266 | if (as_list == NULL) | |
7267 | { | |
7268 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); | |
7269 | return CMD_WARNING; | |
7270 | } | |
7271 | ||
5a646650 | 7272 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
718e3744 | 7273 | } |
7274 | ||
7275 | DEFUN (show_ip_bgp_filter_list, | |
7276 | show_ip_bgp_filter_list_cmd, | |
7277 | "show ip bgp filter-list WORD", | |
7278 | SHOW_STR | |
7279 | IP_STR | |
7280 | BGP_STR | |
7281 | "Display routes conforming to the filter-list\n" | |
7282 | "Regular expression access list name\n") | |
7283 | { | |
7284 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7285 | bgp_show_type_filter_list); | |
7286 | } | |
7287 | ||
7288 | DEFUN (show_ip_bgp_flap_filter_list, | |
7289 | show_ip_bgp_flap_filter_list_cmd, | |
7290 | "show ip bgp flap-statistics filter-list WORD", | |
7291 | SHOW_STR | |
7292 | IP_STR | |
7293 | BGP_STR | |
7294 | "Display flap statistics of routes\n" | |
7295 | "Display routes conforming to the filter-list\n" | |
7296 | "Regular expression access list name\n") | |
7297 | { | |
7298 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7299 | bgp_show_type_flap_filter_list); | |
7300 | } | |
7301 | ||
7302 | DEFUN (show_ip_bgp_ipv4_filter_list, | |
7303 | show_ip_bgp_ipv4_filter_list_cmd, | |
7304 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", | |
7305 | SHOW_STR | |
7306 | IP_STR | |
7307 | BGP_STR | |
7308 | "Address family\n" | |
7309 | "Address Family modifier\n" | |
7310 | "Address Family modifier\n" | |
7311 | "Display routes conforming to the filter-list\n" | |
7312 | "Regular expression access list name\n") | |
7313 | { | |
7314 | if (strncmp (argv[0], "m", 1) == 0) | |
7315 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7316 | bgp_show_type_filter_list); | |
7317 | ||
7318 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7319 | bgp_show_type_filter_list); | |
7320 | } | |
7321 | ||
7322 | #ifdef HAVE_IPV6 | |
7323 | DEFUN (show_bgp_filter_list, | |
7324 | show_bgp_filter_list_cmd, | |
7325 | "show bgp filter-list WORD", | |
7326 | SHOW_STR | |
7327 | BGP_STR | |
7328 | "Display routes conforming to the filter-list\n" | |
7329 | "Regular expression access list name\n") | |
7330 | { | |
7331 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7332 | bgp_show_type_filter_list); | |
7333 | } | |
7334 | ||
7335 | ALIAS (show_bgp_filter_list, | |
7336 | show_bgp_ipv6_filter_list_cmd, | |
7337 | "show bgp ipv6 filter-list WORD", | |
7338 | SHOW_STR | |
7339 | BGP_STR | |
7340 | "Address family\n" | |
7341 | "Display routes conforming to the filter-list\n" | |
7342 | "Regular expression access list name\n") | |
7343 | ||
7344 | /* old command */ | |
7345 | DEFUN (show_ipv6_bgp_filter_list, | |
7346 | show_ipv6_bgp_filter_list_cmd, | |
7347 | "show ipv6 bgp filter-list WORD", | |
7348 | SHOW_STR | |
7349 | IPV6_STR | |
7350 | BGP_STR | |
7351 | "Display routes conforming to the filter-list\n" | |
7352 | "Regular expression access list name\n") | |
7353 | { | |
7354 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7355 | bgp_show_type_filter_list); | |
7356 | } | |
7357 | ||
7358 | /* old command */ | |
7359 | DEFUN (show_ipv6_mbgp_filter_list, | |
7360 | show_ipv6_mbgp_filter_list_cmd, | |
7361 | "show ipv6 mbgp filter-list WORD", | |
7362 | SHOW_STR | |
7363 | IPV6_STR | |
7364 | MBGP_STR | |
7365 | "Display routes conforming to the filter-list\n" | |
7366 | "Regular expression access list name\n") | |
7367 | { | |
7368 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7369 | bgp_show_type_filter_list); | |
7370 | } | |
7371 | #endif /* HAVE_IPV6 */ | |
7372 | \f | |
94f2b392 | 7373 | static int |
fd79ac91 | 7374 | bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi, |
718e3744 | 7375 | safi_t safi, enum bgp_show_type type) |
7376 | { | |
7377 | struct route_map *rmap; | |
7378 | ||
7379 | rmap = route_map_lookup_by_name (rmap_str); | |
7380 | if (! rmap) | |
7381 | { | |
7382 | vty_out (vty, "%% %s is not a valid route-map name%s", | |
7383 | rmap_str, VTY_NEWLINE); | |
7384 | return CMD_WARNING; | |
7385 | } | |
7386 | ||
5a646650 | 7387 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
718e3744 | 7388 | } |
7389 | ||
7390 | DEFUN (show_ip_bgp_route_map, | |
7391 | show_ip_bgp_route_map_cmd, | |
7392 | "show ip bgp route-map WORD", | |
7393 | SHOW_STR | |
7394 | IP_STR | |
7395 | BGP_STR | |
7396 | "Display routes matching the route-map\n" | |
7397 | "A route-map to match on\n") | |
7398 | { | |
7399 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7400 | bgp_show_type_route_map); | |
7401 | } | |
7402 | ||
7403 | DEFUN (show_ip_bgp_flap_route_map, | |
7404 | show_ip_bgp_flap_route_map_cmd, | |
7405 | "show ip bgp flap-statistics route-map WORD", | |
7406 | SHOW_STR | |
7407 | IP_STR | |
7408 | BGP_STR | |
7409 | "Display flap statistics of routes\n" | |
7410 | "Display routes matching the route-map\n" | |
7411 | "A route-map to match on\n") | |
7412 | { | |
7413 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7414 | bgp_show_type_flap_route_map); | |
7415 | } | |
7416 | ||
7417 | DEFUN (show_ip_bgp_ipv4_route_map, | |
7418 | show_ip_bgp_ipv4_route_map_cmd, | |
7419 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", | |
7420 | SHOW_STR | |
7421 | IP_STR | |
7422 | BGP_STR | |
7423 | "Address family\n" | |
7424 | "Address Family modifier\n" | |
7425 | "Address Family modifier\n" | |
7426 | "Display routes matching the route-map\n" | |
7427 | "A route-map to match on\n") | |
7428 | { | |
7429 | if (strncmp (argv[0], "m", 1) == 0) | |
7430 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7431 | bgp_show_type_route_map); | |
7432 | ||
7433 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7434 | bgp_show_type_route_map); | |
7435 | } | |
7436 | ||
7437 | DEFUN (show_bgp_route_map, | |
7438 | show_bgp_route_map_cmd, | |
7439 | "show bgp route-map WORD", | |
7440 | SHOW_STR | |
7441 | BGP_STR | |
7442 | "Display routes matching the route-map\n" | |
7443 | "A route-map to match on\n") | |
7444 | { | |
7445 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7446 | bgp_show_type_route_map); | |
7447 | } | |
7448 | ||
7449 | ALIAS (show_bgp_route_map, | |
7450 | show_bgp_ipv6_route_map_cmd, | |
7451 | "show bgp ipv6 route-map WORD", | |
7452 | SHOW_STR | |
7453 | BGP_STR | |
7454 | "Address family\n" | |
7455 | "Display routes matching the route-map\n" | |
7456 | "A route-map to match on\n") | |
7457 | \f | |
7458 | DEFUN (show_ip_bgp_cidr_only, | |
7459 | show_ip_bgp_cidr_only_cmd, | |
7460 | "show ip bgp cidr-only", | |
7461 | SHOW_STR | |
7462 | IP_STR | |
7463 | BGP_STR | |
7464 | "Display only routes with non-natural netmasks\n") | |
7465 | { | |
7466 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7467 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7468 | } |
7469 | ||
7470 | DEFUN (show_ip_bgp_flap_cidr_only, | |
7471 | show_ip_bgp_flap_cidr_only_cmd, | |
7472 | "show ip bgp flap-statistics cidr-only", | |
7473 | SHOW_STR | |
7474 | IP_STR | |
7475 | BGP_STR | |
7476 | "Display flap statistics of routes\n" | |
7477 | "Display only routes with non-natural netmasks\n") | |
7478 | { | |
7479 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7480 | bgp_show_type_flap_cidr_only, NULL); |
718e3744 | 7481 | } |
7482 | ||
7483 | DEFUN (show_ip_bgp_ipv4_cidr_only, | |
7484 | show_ip_bgp_ipv4_cidr_only_cmd, | |
7485 | "show ip bgp ipv4 (unicast|multicast) cidr-only", | |
7486 | SHOW_STR | |
7487 | IP_STR | |
7488 | BGP_STR | |
7489 | "Address family\n" | |
7490 | "Address Family modifier\n" | |
7491 | "Address Family modifier\n" | |
7492 | "Display only routes with non-natural netmasks\n") | |
7493 | { | |
7494 | if (strncmp (argv[0], "m", 1) == 0) | |
7495 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7496 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7497 | |
7498 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7499 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7500 | } |
7501 | \f | |
7502 | DEFUN (show_ip_bgp_community_all, | |
7503 | show_ip_bgp_community_all_cmd, | |
7504 | "show ip bgp community", | |
7505 | SHOW_STR | |
7506 | IP_STR | |
7507 | BGP_STR | |
7508 | "Display routes matching the communities\n") | |
7509 | { | |
7510 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7511 | bgp_show_type_community_all, NULL); |
718e3744 | 7512 | } |
7513 | ||
7514 | DEFUN (show_ip_bgp_ipv4_community_all, | |
7515 | show_ip_bgp_ipv4_community_all_cmd, | |
7516 | "show ip bgp ipv4 (unicast|multicast) community", | |
7517 | SHOW_STR | |
7518 | IP_STR | |
7519 | BGP_STR | |
7520 | "Address family\n" | |
7521 | "Address Family modifier\n" | |
7522 | "Address Family modifier\n" | |
7523 | "Display routes matching the communities\n") | |
7524 | { | |
7525 | if (strncmp (argv[0], "m", 1) == 0) | |
7526 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7527 | bgp_show_type_community_all, NULL); |
718e3744 | 7528 | |
7529 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7530 | bgp_show_type_community_all, NULL); |
718e3744 | 7531 | } |
7532 | ||
7533 | #ifdef HAVE_IPV6 | |
7534 | DEFUN (show_bgp_community_all, | |
7535 | show_bgp_community_all_cmd, | |
7536 | "show bgp community", | |
7537 | SHOW_STR | |
7538 | BGP_STR | |
7539 | "Display routes matching the communities\n") | |
7540 | { | |
7541 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
5a646650 | 7542 | bgp_show_type_community_all, NULL); |
718e3744 | 7543 | } |
7544 | ||
7545 | ALIAS (show_bgp_community_all, | |
7546 | show_bgp_ipv6_community_all_cmd, | |
7547 | "show bgp ipv6 community", | |
7548 | SHOW_STR | |
7549 | BGP_STR | |
7550 | "Address family\n" | |
7551 | "Display routes matching the communities\n") | |
7552 | ||
7553 | /* old command */ | |
7554 | DEFUN (show_ipv6_bgp_community_all, | |
7555 | show_ipv6_bgp_community_all_cmd, | |
7556 | "show ipv6 bgp community", | |
7557 | SHOW_STR | |
7558 | IPV6_STR | |
7559 | BGP_STR | |
7560 | "Display routes matching the communities\n") | |
7561 | { | |
7562 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
5a646650 | 7563 | bgp_show_type_community_all, NULL); |
718e3744 | 7564 | } |
7565 | ||
7566 | /* old command */ | |
7567 | DEFUN (show_ipv6_mbgp_community_all, | |
7568 | show_ipv6_mbgp_community_all_cmd, | |
7569 | "show ipv6 mbgp community", | |
7570 | SHOW_STR | |
7571 | IPV6_STR | |
7572 | MBGP_STR | |
7573 | "Display routes matching the communities\n") | |
7574 | { | |
7575 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, | |
5a646650 | 7576 | bgp_show_type_community_all, NULL); |
718e3744 | 7577 | } |
7578 | #endif /* HAVE_IPV6 */ | |
7579 | \f | |
94f2b392 | 7580 | static int |
95cbbd2a ML |
7581 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
7582 | const char **argv, int exact, afi_t afi, safi_t safi) | |
718e3744 | 7583 | { |
7584 | struct community *com; | |
7585 | struct buffer *b; | |
95cbbd2a | 7586 | struct bgp *bgp; |
718e3744 | 7587 | int i; |
7588 | char *str; | |
7589 | int first = 0; | |
7590 | ||
95cbbd2a ML |
7591 | /* BGP structure lookup */ |
7592 | if (view_name) | |
7593 | { | |
7594 | bgp = bgp_lookup_by_name (view_name); | |
7595 | if (bgp == NULL) | |
7596 | { | |
7597 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
7598 | return CMD_WARNING; | |
7599 | } | |
7600 | } | |
7601 | else | |
7602 | { | |
7603 | bgp = bgp_get_default (); | |
7604 | if (bgp == NULL) | |
7605 | { | |
7606 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
7607 | return CMD_WARNING; | |
7608 | } | |
7609 | } | |
7610 | ||
718e3744 | 7611 | b = buffer_new (1024); |
7612 | for (i = 0; i < argc; i++) | |
7613 | { | |
7614 | if (first) | |
7615 | buffer_putc (b, ' '); | |
7616 | else | |
7617 | { | |
7618 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
7619 | continue; | |
7620 | first = 1; | |
7621 | } | |
7622 | ||
7623 | buffer_putstr (b, argv[i]); | |
7624 | } | |
7625 | buffer_putc (b, '\0'); | |
7626 | ||
7627 | str = buffer_getstr (b); | |
7628 | buffer_free (b); | |
7629 | ||
7630 | com = community_str2com (str); | |
3b8b1855 | 7631 | XFREE (MTYPE_TMP, str); |
718e3744 | 7632 | if (! com) |
7633 | { | |
7634 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); | |
7635 | return CMD_WARNING; | |
7636 | } | |
7637 | ||
95cbbd2a | 7638 | return bgp_show (vty, bgp, afi, safi, |
5a646650 | 7639 | (exact ? bgp_show_type_community_exact : |
7640 | bgp_show_type_community), com); | |
718e3744 | 7641 | } |
7642 | ||
7643 | DEFUN (show_ip_bgp_community, | |
7644 | show_ip_bgp_community_cmd, | |
7645 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
7646 | SHOW_STR | |
7647 | IP_STR | |
7648 | BGP_STR | |
7649 | "Display routes matching the communities\n" | |
7650 | "community number\n" | |
7651 | "Do not send outside local AS (well-known community)\n" | |
7652 | "Do not advertise to any peer (well-known community)\n" | |
7653 | "Do not export to next AS (well-known community)\n") | |
7654 | { | |
95cbbd2a | 7655 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 7656 | } |
7657 | ||
7658 | ALIAS (show_ip_bgp_community, | |
7659 | show_ip_bgp_community2_cmd, | |
7660 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7661 | SHOW_STR | |
7662 | IP_STR | |
7663 | BGP_STR | |
7664 | "Display routes matching the communities\n" | |
7665 | "community number\n" | |
7666 | "Do not send outside local AS (well-known community)\n" | |
7667 | "Do not advertise to any peer (well-known community)\n" | |
7668 | "Do not export to next AS (well-known community)\n" | |
7669 | "community number\n" | |
7670 | "Do not send outside local AS (well-known community)\n" | |
7671 | "Do not advertise to any peer (well-known community)\n" | |
7672 | "Do not export to next AS (well-known community)\n") | |
7673 | ||
7674 | ALIAS (show_ip_bgp_community, | |
7675 | show_ip_bgp_community3_cmd, | |
7676 | "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)", | |
7677 | SHOW_STR | |
7678 | IP_STR | |
7679 | BGP_STR | |
7680 | "Display routes matching the communities\n" | |
7681 | "community number\n" | |
7682 | "Do not send outside local AS (well-known community)\n" | |
7683 | "Do not advertise to any peer (well-known community)\n" | |
7684 | "Do not export to next AS (well-known community)\n" | |
7685 | "community number\n" | |
7686 | "Do not send outside local AS (well-known community)\n" | |
7687 | "Do not advertise to any peer (well-known community)\n" | |
7688 | "Do not export to next AS (well-known community)\n" | |
7689 | "community number\n" | |
7690 | "Do not send outside local AS (well-known community)\n" | |
7691 | "Do not advertise to any peer (well-known community)\n" | |
7692 | "Do not export to next AS (well-known community)\n") | |
7693 | ||
7694 | ALIAS (show_ip_bgp_community, | |
7695 | show_ip_bgp_community4_cmd, | |
7696 | "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)", | |
7697 | SHOW_STR | |
7698 | IP_STR | |
7699 | BGP_STR | |
7700 | "Display routes matching the communities\n" | |
7701 | "community number\n" | |
7702 | "Do not send outside local AS (well-known community)\n" | |
7703 | "Do not advertise to any peer (well-known community)\n" | |
7704 | "Do not export to next AS (well-known community)\n" | |
7705 | "community number\n" | |
7706 | "Do not send outside local AS (well-known community)\n" | |
7707 | "Do not advertise to any peer (well-known community)\n" | |
7708 | "Do not export to next AS (well-known community)\n" | |
7709 | "community number\n" | |
7710 | "Do not send outside local AS (well-known community)\n" | |
7711 | "Do not advertise to any peer (well-known community)\n" | |
7712 | "Do not export to next AS (well-known community)\n" | |
7713 | "community number\n" | |
7714 | "Do not send outside local AS (well-known community)\n" | |
7715 | "Do not advertise to any peer (well-known community)\n" | |
7716 | "Do not export to next AS (well-known community)\n") | |
7717 | ||
7718 | DEFUN (show_ip_bgp_ipv4_community, | |
7719 | show_ip_bgp_ipv4_community_cmd, | |
7720 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7721 | SHOW_STR | |
7722 | IP_STR | |
7723 | BGP_STR | |
7724 | "Address family\n" | |
7725 | "Address Family modifier\n" | |
7726 | "Address Family modifier\n" | |
7727 | "Display routes matching the communities\n" | |
7728 | "community number\n" | |
7729 | "Do not send outside local AS (well-known community)\n" | |
7730 | "Do not advertise to any peer (well-known community)\n" | |
7731 | "Do not export to next AS (well-known community)\n") | |
7732 | { | |
7733 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 7734 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
718e3744 | 7735 | |
95cbbd2a | 7736 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 7737 | } |
7738 | ||
7739 | ALIAS (show_ip_bgp_ipv4_community, | |
7740 | show_ip_bgp_ipv4_community2_cmd, | |
7741 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7742 | SHOW_STR | |
7743 | IP_STR | |
7744 | BGP_STR | |
7745 | "Address family\n" | |
7746 | "Address Family modifier\n" | |
7747 | "Address Family modifier\n" | |
7748 | "Display routes matching the communities\n" | |
7749 | "community number\n" | |
7750 | "Do not send outside local AS (well-known community)\n" | |
7751 | "Do not advertise to any peer (well-known community)\n" | |
7752 | "Do not export to next AS (well-known community)\n" | |
7753 | "community number\n" | |
7754 | "Do not send outside local AS (well-known community)\n" | |
7755 | "Do not advertise to any peer (well-known community)\n" | |
7756 | "Do not export to next AS (well-known community)\n") | |
7757 | ||
7758 | ALIAS (show_ip_bgp_ipv4_community, | |
7759 | show_ip_bgp_ipv4_community3_cmd, | |
7760 | "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)", | |
7761 | SHOW_STR | |
7762 | IP_STR | |
7763 | BGP_STR | |
7764 | "Address family\n" | |
7765 | "Address Family modifier\n" | |
7766 | "Address Family modifier\n" | |
7767 | "Display routes matching the communities\n" | |
7768 | "community number\n" | |
7769 | "Do not send outside local AS (well-known community)\n" | |
7770 | "Do not advertise to any peer (well-known community)\n" | |
7771 | "Do not export to next AS (well-known community)\n" | |
7772 | "community number\n" | |
7773 | "Do not send outside local AS (well-known community)\n" | |
7774 | "Do not advertise to any peer (well-known community)\n" | |
7775 | "Do not export to next AS (well-known community)\n" | |
7776 | "community number\n" | |
7777 | "Do not send outside local AS (well-known community)\n" | |
7778 | "Do not advertise to any peer (well-known community)\n" | |
7779 | "Do not export to next AS (well-known community)\n") | |
7780 | ||
7781 | ALIAS (show_ip_bgp_ipv4_community, | |
7782 | show_ip_bgp_ipv4_community4_cmd, | |
7783 | "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)", | |
7784 | SHOW_STR | |
7785 | IP_STR | |
7786 | BGP_STR | |
7787 | "Address family\n" | |
7788 | "Address Family modifier\n" | |
7789 | "Address Family modifier\n" | |
7790 | "Display routes matching the communities\n" | |
7791 | "community number\n" | |
7792 | "Do not send outside local AS (well-known community)\n" | |
7793 | "Do not advertise to any peer (well-known community)\n" | |
7794 | "Do not export to next AS (well-known community)\n" | |
7795 | "community number\n" | |
7796 | "Do not send outside local AS (well-known community)\n" | |
7797 | "Do not advertise to any peer (well-known community)\n" | |
7798 | "Do not export to next AS (well-known community)\n" | |
7799 | "community number\n" | |
7800 | "Do not send outside local AS (well-known community)\n" | |
7801 | "Do not advertise to any peer (well-known community)\n" | |
7802 | "Do not export to next AS (well-known community)\n" | |
7803 | "community number\n" | |
7804 | "Do not send outside local AS (well-known community)\n" | |
7805 | "Do not advertise to any peer (well-known community)\n" | |
7806 | "Do not export to next AS (well-known community)\n") | |
7807 | ||
95cbbd2a ML |
7808 | DEFUN (show_bgp_view_afi_safi_community_all, |
7809 | show_bgp_view_afi_safi_community_all_cmd, | |
7810 | #ifdef HAVE_IPV6 | |
7811 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", | |
7812 | #else | |
7813 | "show bgp view WORD ipv4 (unicast|multicast) community", | |
7814 | #endif | |
7815 | SHOW_STR | |
7816 | BGP_STR | |
7817 | "BGP view\n" | |
7818 | "BGP view name\n" | |
7819 | "Address family\n" | |
7820 | #ifdef HAVE_IPV6 | |
7821 | "Address family\n" | |
7822 | #endif | |
7823 | "Address Family modifier\n" | |
7824 | "Address Family modifier\n" | |
7825 | "Display routes containing communities\n") | |
7826 | { | |
7827 | int afi; | |
7828 | int safi; | |
7829 | struct bgp *bgp; | |
7830 | ||
7831 | /* BGP structure lookup. */ | |
7832 | bgp = bgp_lookup_by_name (argv[0]); | |
7833 | if (bgp == NULL) | |
7834 | { | |
7835 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
7836 | return CMD_WARNING; | |
7837 | } | |
7838 | ||
7839 | #ifdef HAVE_IPV6 | |
7840 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; | |
7841 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7842 | #else | |
7843 | afi = AFI_IP; | |
7844 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7845 | #endif | |
7846 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); | |
7847 | } | |
7848 | ||
7849 | DEFUN (show_bgp_view_afi_safi_community, | |
7850 | show_bgp_view_afi_safi_community_cmd, | |
7851 | #ifdef HAVE_IPV6 | |
7852 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7853 | #else | |
7854 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7855 | #endif | |
7856 | SHOW_STR | |
7857 | BGP_STR | |
7858 | "BGP view\n" | |
7859 | "BGP view name\n" | |
7860 | "Address family\n" | |
7861 | #ifdef HAVE_IPV6 | |
7862 | "Address family\n" | |
7863 | #endif | |
7864 | "Address family modifier\n" | |
7865 | "Address family modifier\n" | |
7866 | "Display routes matching the communities\n" | |
7867 | "community number\n" | |
7868 | "Do not send outside local AS (well-known community)\n" | |
7869 | "Do not advertise to any peer (well-known community)\n" | |
7870 | "Do not export to next AS (well-known community)\n") | |
7871 | { | |
7872 | int afi; | |
7873 | int safi; | |
7874 | ||
7875 | #ifdef HAVE_IPV6 | |
7876 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; | |
7877 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7878 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); | |
7879 | #else | |
7880 | afi = AFI_IP; | |
7881 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7882 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); | |
7883 | #endif | |
7884 | } | |
7885 | ||
7886 | ALIAS (show_bgp_view_afi_safi_community, | |
7887 | show_bgp_view_afi_safi_community2_cmd, | |
7888 | #ifdef HAVE_IPV6 | |
7889 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7890 | #else | |
7891 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7892 | #endif | |
7893 | SHOW_STR | |
7894 | BGP_STR | |
7895 | "BGP view\n" | |
7896 | "BGP view name\n" | |
7897 | "Address family\n" | |
7898 | #ifdef HAVE_IPV6 | |
7899 | "Address family\n" | |
7900 | #endif | |
7901 | "Address family modifier\n" | |
7902 | "Address family modifier\n" | |
7903 | "Display routes matching the communities\n" | |
7904 | "community number\n" | |
7905 | "Do not send outside local AS (well-known community)\n" | |
7906 | "Do not advertise to any peer (well-known community)\n" | |
7907 | "Do not export to next AS (well-known community)\n" | |
7908 | "community number\n" | |
7909 | "Do not send outside local AS (well-known community)\n" | |
7910 | "Do not advertise to any peer (well-known community)\n" | |
7911 | "Do not export to next AS (well-known community)\n") | |
7912 | ||
7913 | ALIAS (show_bgp_view_afi_safi_community, | |
7914 | show_bgp_view_afi_safi_community3_cmd, | |
7915 | #ifdef HAVE_IPV6 | |
7916 | "show bgp view WORD (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)", | |
7917 | #else | |
7918 | "show bgp view WORD 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)", | |
7919 | #endif | |
7920 | SHOW_STR | |
7921 | BGP_STR | |
7922 | "BGP view\n" | |
7923 | "BGP view name\n" | |
7924 | "Address family\n" | |
7925 | #ifdef HAVE_IPV6 | |
7926 | "Address family\n" | |
7927 | #endif | |
7928 | "Address family modifier\n" | |
7929 | "Address family modifier\n" | |
7930 | "Display routes matching the communities\n" | |
7931 | "community number\n" | |
7932 | "Do not send outside local AS (well-known community)\n" | |
7933 | "Do not advertise to any peer (well-known community)\n" | |
7934 | "Do not export to next AS (well-known community)\n" | |
7935 | "community number\n" | |
7936 | "Do not send outside local AS (well-known community)\n" | |
7937 | "Do not advertise to any peer (well-known community)\n" | |
7938 | "Do not export to next AS (well-known community)\n" | |
7939 | "community number\n" | |
7940 | "Do not send outside local AS (well-known community)\n" | |
7941 | "Do not advertise to any peer (well-known community)\n" | |
7942 | "Do not export to next AS (well-known community)\n") | |
7943 | ||
7944 | ALIAS (show_bgp_view_afi_safi_community, | |
7945 | show_bgp_view_afi_safi_community4_cmd, | |
7946 | #ifdef HAVE_IPV6 | |
7947 | "show bgp view WORD (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)", | |
7948 | #else | |
7949 | "show bgp view WORD 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)", | |
7950 | #endif | |
7951 | SHOW_STR | |
7952 | BGP_STR | |
7953 | "BGP view\n" | |
7954 | "BGP view name\n" | |
7955 | "Address family\n" | |
7956 | #ifdef HAVE_IPV6 | |
7957 | "Address family\n" | |
7958 | #endif | |
7959 | "Address family modifier\n" | |
7960 | "Address family modifier\n" | |
7961 | "Display routes matching the communities\n" | |
7962 | "community number\n" | |
7963 | "Do not send outside local AS (well-known community)\n" | |
7964 | "Do not advertise to any peer (well-known community)\n" | |
7965 | "Do not export to next AS (well-known community)\n" | |
7966 | "community number\n" | |
7967 | "Do not send outside local AS (well-known community)\n" | |
7968 | "Do not advertise to any peer (well-known community)\n" | |
7969 | "Do not export to next AS (well-known community)\n" | |
7970 | "community number\n" | |
7971 | "Do not send outside local AS (well-known community)\n" | |
7972 | "Do not advertise to any peer (well-known community)\n" | |
7973 | "Do not export to next AS (well-known community)\n" | |
7974 | "community number\n" | |
7975 | "Do not send outside local AS (well-known community)\n" | |
7976 | "Do not advertise to any peer (well-known community)\n" | |
7977 | "Do not export to next AS (well-known community)\n") | |
7978 | ||
718e3744 | 7979 | DEFUN (show_ip_bgp_community_exact, |
7980 | show_ip_bgp_community_exact_cmd, | |
7981 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7982 | SHOW_STR | |
7983 | IP_STR | |
7984 | BGP_STR | |
7985 | "Display routes matching the communities\n" | |
7986 | "community number\n" | |
7987 | "Do not send outside local AS (well-known community)\n" | |
7988 | "Do not advertise to any peer (well-known community)\n" | |
7989 | "Do not export to next AS (well-known community)\n" | |
7990 | "Exact match of the communities") | |
7991 | { | |
95cbbd2a | 7992 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 7993 | } |
7994 | ||
7995 | ALIAS (show_ip_bgp_community_exact, | |
7996 | show_ip_bgp_community2_exact_cmd, | |
7997 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7998 | SHOW_STR | |
7999 | IP_STR | |
8000 | BGP_STR | |
8001 | "Display routes matching the communities\n" | |
8002 | "community number\n" | |
8003 | "Do not send outside local AS (well-known community)\n" | |
8004 | "Do not advertise to any peer (well-known community)\n" | |
8005 | "Do not export to next AS (well-known community)\n" | |
8006 | "community number\n" | |
8007 | "Do not send outside local AS (well-known community)\n" | |
8008 | "Do not advertise to any peer (well-known community)\n" | |
8009 | "Do not export to next AS (well-known community)\n" | |
8010 | "Exact match of the communities") | |
8011 | ||
8012 | ALIAS (show_ip_bgp_community_exact, | |
8013 | show_ip_bgp_community3_exact_cmd, | |
8014 | "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", | |
8015 | SHOW_STR | |
8016 | IP_STR | |
8017 | BGP_STR | |
8018 | "Display routes matching the communities\n" | |
8019 | "community number\n" | |
8020 | "Do not send outside local AS (well-known community)\n" | |
8021 | "Do not advertise to any peer (well-known community)\n" | |
8022 | "Do not export to next AS (well-known community)\n" | |
8023 | "community number\n" | |
8024 | "Do not send outside local AS (well-known community)\n" | |
8025 | "Do not advertise to any peer (well-known community)\n" | |
8026 | "Do not export to next AS (well-known community)\n" | |
8027 | "community number\n" | |
8028 | "Do not send outside local AS (well-known community)\n" | |
8029 | "Do not advertise to any peer (well-known community)\n" | |
8030 | "Do not export to next AS (well-known community)\n" | |
8031 | "Exact match of the communities") | |
8032 | ||
8033 | ALIAS (show_ip_bgp_community_exact, | |
8034 | show_ip_bgp_community4_exact_cmd, | |
8035 | "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", | |
8036 | SHOW_STR | |
8037 | IP_STR | |
8038 | BGP_STR | |
8039 | "Display routes matching the communities\n" | |
8040 | "community number\n" | |
8041 | "Do not send outside local AS (well-known community)\n" | |
8042 | "Do not advertise to any peer (well-known community)\n" | |
8043 | "Do not export to next AS (well-known community)\n" | |
8044 | "community number\n" | |
8045 | "Do not send outside local AS (well-known community)\n" | |
8046 | "Do not advertise to any peer (well-known community)\n" | |
8047 | "Do not export to next AS (well-known community)\n" | |
8048 | "community number\n" | |
8049 | "Do not send outside local AS (well-known community)\n" | |
8050 | "Do not advertise to any peer (well-known community)\n" | |
8051 | "Do not export to next AS (well-known community)\n" | |
8052 | "community number\n" | |
8053 | "Do not send outside local AS (well-known community)\n" | |
8054 | "Do not advertise to any peer (well-known community)\n" | |
8055 | "Do not export to next AS (well-known community)\n" | |
8056 | "Exact match of the communities") | |
8057 | ||
8058 | DEFUN (show_ip_bgp_ipv4_community_exact, | |
8059 | show_ip_bgp_ipv4_community_exact_cmd, | |
8060 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8061 | SHOW_STR | |
8062 | IP_STR | |
8063 | BGP_STR | |
8064 | "Address family\n" | |
8065 | "Address Family modifier\n" | |
8066 | "Address Family modifier\n" | |
8067 | "Display routes matching the communities\n" | |
8068 | "community number\n" | |
8069 | "Do not send outside local AS (well-known community)\n" | |
8070 | "Do not advertise to any peer (well-known community)\n" | |
8071 | "Do not export to next AS (well-known community)\n" | |
8072 | "Exact match of the communities") | |
8073 | { | |
8074 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 8075 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
718e3744 | 8076 | |
95cbbd2a | 8077 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 8078 | } |
8079 | ||
8080 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
8081 | show_ip_bgp_ipv4_community2_exact_cmd, | |
8082 | "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", | |
8083 | SHOW_STR | |
8084 | IP_STR | |
8085 | BGP_STR | |
8086 | "Address family\n" | |
8087 | "Address Family modifier\n" | |
8088 | "Address Family modifier\n" | |
8089 | "Display routes matching the communities\n" | |
8090 | "community number\n" | |
8091 | "Do not send outside local AS (well-known community)\n" | |
8092 | "Do not advertise to any peer (well-known community)\n" | |
8093 | "Do not export to next AS (well-known community)\n" | |
8094 | "community number\n" | |
8095 | "Do not send outside local AS (well-known community)\n" | |
8096 | "Do not advertise to any peer (well-known community)\n" | |
8097 | "Do not export to next AS (well-known community)\n" | |
8098 | "Exact match of the communities") | |
8099 | ||
8100 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
8101 | show_ip_bgp_ipv4_community3_exact_cmd, | |
8102 | "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", | |
8103 | SHOW_STR | |
8104 | IP_STR | |
8105 | BGP_STR | |
8106 | "Address family\n" | |
8107 | "Address Family modifier\n" | |
8108 | "Address Family modifier\n" | |
8109 | "Display routes matching the communities\n" | |
8110 | "community number\n" | |
8111 | "Do not send outside local AS (well-known community)\n" | |
8112 | "Do not advertise to any peer (well-known community)\n" | |
8113 | "Do not export to next AS (well-known community)\n" | |
8114 | "community number\n" | |
8115 | "Do not send outside local AS (well-known community)\n" | |
8116 | "Do not advertise to any peer (well-known community)\n" | |
8117 | "Do not export to next AS (well-known community)\n" | |
8118 | "community number\n" | |
8119 | "Do not send outside local AS (well-known community)\n" | |
8120 | "Do not advertise to any peer (well-known community)\n" | |
8121 | "Do not export to next AS (well-known community)\n" | |
8122 | "Exact match of the communities") | |
8123 | ||
8124 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
8125 | show_ip_bgp_ipv4_community4_exact_cmd, | |
8126 | "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", | |
8127 | SHOW_STR | |
8128 | IP_STR | |
8129 | BGP_STR | |
8130 | "Address family\n" | |
8131 | "Address Family modifier\n" | |
8132 | "Address Family modifier\n" | |
8133 | "Display routes matching the communities\n" | |
8134 | "community number\n" | |
8135 | "Do not send outside local AS (well-known community)\n" | |
8136 | "Do not advertise to any peer (well-known community)\n" | |
8137 | "Do not export to next AS (well-known community)\n" | |
8138 | "community number\n" | |
8139 | "Do not send outside local AS (well-known community)\n" | |
8140 | "Do not advertise to any peer (well-known community)\n" | |
8141 | "Do not export to next AS (well-known community)\n" | |
8142 | "community number\n" | |
8143 | "Do not send outside local AS (well-known community)\n" | |
8144 | "Do not advertise to any peer (well-known community)\n" | |
8145 | "Do not export to next AS (well-known community)\n" | |
8146 | "community number\n" | |
8147 | "Do not send outside local AS (well-known community)\n" | |
8148 | "Do not advertise to any peer (well-known community)\n" | |
8149 | "Do not export to next AS (well-known community)\n" | |
8150 | "Exact match of the communities") | |
8151 | ||
8152 | #ifdef HAVE_IPV6 | |
8153 | DEFUN (show_bgp_community, | |
8154 | show_bgp_community_cmd, | |
8155 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8156 | SHOW_STR | |
8157 | BGP_STR | |
8158 | "Display routes matching the communities\n" | |
8159 | "community number\n" | |
8160 | "Do not send outside local AS (well-known community)\n" | |
8161 | "Do not advertise to any peer (well-known community)\n" | |
8162 | "Do not export to next AS (well-known community)\n") | |
8163 | { | |
95cbbd2a | 8164 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8165 | } |
8166 | ||
8167 | ALIAS (show_bgp_community, | |
8168 | show_bgp_ipv6_community_cmd, | |
8169 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", | |
8170 | SHOW_STR | |
8171 | BGP_STR | |
8172 | "Address family\n" | |
8173 | "Display routes matching the communities\n" | |
8174 | "community number\n" | |
8175 | "Do not send outside local AS (well-known community)\n" | |
8176 | "Do not advertise to any peer (well-known community)\n" | |
8177 | "Do not export to next AS (well-known community)\n") | |
8178 | ||
8179 | ALIAS (show_bgp_community, | |
8180 | show_bgp_community2_cmd, | |
8181 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8182 | SHOW_STR | |
8183 | BGP_STR | |
8184 | "Display routes matching the communities\n" | |
8185 | "community number\n" | |
8186 | "Do not send outside local AS (well-known community)\n" | |
8187 | "Do not advertise to any peer (well-known community)\n" | |
8188 | "Do not export to next AS (well-known community)\n" | |
8189 | "community number\n" | |
8190 | "Do not send outside local AS (well-known community)\n" | |
8191 | "Do not advertise to any peer (well-known community)\n" | |
8192 | "Do not export to next AS (well-known community)\n") | |
8193 | ||
8194 | ALIAS (show_bgp_community, | |
8195 | show_bgp_ipv6_community2_cmd, | |
8196 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8197 | SHOW_STR | |
8198 | BGP_STR | |
8199 | "Address family\n" | |
8200 | "Display routes matching the communities\n" | |
8201 | "community number\n" | |
8202 | "Do not send outside local AS (well-known community)\n" | |
8203 | "Do not advertise to any peer (well-known community)\n" | |
8204 | "Do not export to next AS (well-known community)\n" | |
8205 | "community number\n" | |
8206 | "Do not send outside local AS (well-known community)\n" | |
8207 | "Do not advertise to any peer (well-known community)\n" | |
8208 | "Do not export to next AS (well-known community)\n") | |
8209 | ||
8210 | ALIAS (show_bgp_community, | |
8211 | show_bgp_community3_cmd, | |
8212 | "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)", | |
8213 | SHOW_STR | |
8214 | BGP_STR | |
8215 | "Display routes matching the communities\n" | |
8216 | "community number\n" | |
8217 | "Do not send outside local AS (well-known community)\n" | |
8218 | "Do not advertise to any peer (well-known community)\n" | |
8219 | "Do not export to next AS (well-known community)\n" | |
8220 | "community number\n" | |
8221 | "Do not send outside local AS (well-known community)\n" | |
8222 | "Do not advertise to any peer (well-known community)\n" | |
8223 | "Do not export to next AS (well-known community)\n" | |
8224 | "community number\n" | |
8225 | "Do not send outside local AS (well-known community)\n" | |
8226 | "Do not advertise to any peer (well-known community)\n" | |
8227 | "Do not export to next AS (well-known community)\n") | |
8228 | ||
8229 | ALIAS (show_bgp_community, | |
8230 | show_bgp_ipv6_community3_cmd, | |
8231 | "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)", | |
8232 | SHOW_STR | |
8233 | BGP_STR | |
8234 | "Address family\n" | |
8235 | "Display routes matching the communities\n" | |
8236 | "community number\n" | |
8237 | "Do not send outside local AS (well-known community)\n" | |
8238 | "Do not advertise to any peer (well-known community)\n" | |
8239 | "Do not export to next AS (well-known community)\n" | |
8240 | "community number\n" | |
8241 | "Do not send outside local AS (well-known community)\n" | |
8242 | "Do not advertise to any peer (well-known community)\n" | |
8243 | "Do not export to next AS (well-known community)\n" | |
8244 | "community number\n" | |
8245 | "Do not send outside local AS (well-known community)\n" | |
8246 | "Do not advertise to any peer (well-known community)\n" | |
8247 | "Do not export to next AS (well-known community)\n") | |
8248 | ||
8249 | ALIAS (show_bgp_community, | |
8250 | show_bgp_community4_cmd, | |
8251 | "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)", | |
8252 | SHOW_STR | |
8253 | BGP_STR | |
8254 | "Display routes matching the communities\n" | |
8255 | "community number\n" | |
8256 | "Do not send outside local AS (well-known community)\n" | |
8257 | "Do not advertise to any peer (well-known community)\n" | |
8258 | "Do not export to next AS (well-known community)\n" | |
8259 | "community number\n" | |
8260 | "Do not send outside local AS (well-known community)\n" | |
8261 | "Do not advertise to any peer (well-known community)\n" | |
8262 | "Do not export to next AS (well-known community)\n" | |
8263 | "community number\n" | |
8264 | "Do not send outside local AS (well-known community)\n" | |
8265 | "Do not advertise to any peer (well-known community)\n" | |
8266 | "Do not export to next AS (well-known community)\n" | |
8267 | "community number\n" | |
8268 | "Do not send outside local AS (well-known community)\n" | |
8269 | "Do not advertise to any peer (well-known community)\n" | |
8270 | "Do not export to next AS (well-known community)\n") | |
8271 | ||
8272 | ALIAS (show_bgp_community, | |
8273 | show_bgp_ipv6_community4_cmd, | |
8274 | "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)", | |
8275 | SHOW_STR | |
8276 | BGP_STR | |
8277 | "Address family\n" | |
8278 | "Display routes matching the communities\n" | |
8279 | "community number\n" | |
8280 | "Do not send outside local AS (well-known community)\n" | |
8281 | "Do not advertise to any peer (well-known community)\n" | |
8282 | "Do not export to next AS (well-known community)\n" | |
8283 | "community number\n" | |
8284 | "Do not send outside local AS (well-known community)\n" | |
8285 | "Do not advertise to any peer (well-known community)\n" | |
8286 | "Do not export to next AS (well-known community)\n" | |
8287 | "community number\n" | |
8288 | "Do not send outside local AS (well-known community)\n" | |
8289 | "Do not advertise to any peer (well-known community)\n" | |
8290 | "Do not export to next AS (well-known community)\n" | |
8291 | "community number\n" | |
8292 | "Do not send outside local AS (well-known community)\n" | |
8293 | "Do not advertise to any peer (well-known community)\n" | |
8294 | "Do not export to next AS (well-known community)\n") | |
8295 | ||
8296 | /* old command */ | |
8297 | DEFUN (show_ipv6_bgp_community, | |
8298 | show_ipv6_bgp_community_cmd, | |
8299 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8300 | SHOW_STR | |
8301 | IPV6_STR | |
8302 | BGP_STR | |
8303 | "Display routes matching the communities\n" | |
8304 | "community number\n" | |
8305 | "Do not send outside local AS (well-known community)\n" | |
8306 | "Do not advertise to any peer (well-known community)\n" | |
8307 | "Do not export to next AS (well-known community)\n") | |
8308 | { | |
95cbbd2a | 8309 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8310 | } |
8311 | ||
8312 | /* old command */ | |
8313 | ALIAS (show_ipv6_bgp_community, | |
8314 | show_ipv6_bgp_community2_cmd, | |
8315 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8316 | SHOW_STR | |
8317 | IPV6_STR | |
8318 | BGP_STR | |
8319 | "Display routes matching the communities\n" | |
8320 | "community number\n" | |
8321 | "Do not send outside local AS (well-known community)\n" | |
8322 | "Do not advertise to any peer (well-known community)\n" | |
8323 | "Do not export to next AS (well-known community)\n" | |
8324 | "community number\n" | |
8325 | "Do not send outside local AS (well-known community)\n" | |
8326 | "Do not advertise to any peer (well-known community)\n" | |
8327 | "Do not export to next AS (well-known community)\n") | |
8328 | ||
8329 | /* old command */ | |
8330 | ALIAS (show_ipv6_bgp_community, | |
8331 | show_ipv6_bgp_community3_cmd, | |
8332 | "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)", | |
8333 | SHOW_STR | |
8334 | IPV6_STR | |
8335 | BGP_STR | |
8336 | "Display routes matching the communities\n" | |
8337 | "community number\n" | |
8338 | "Do not send outside local AS (well-known community)\n" | |
8339 | "Do not advertise to any peer (well-known community)\n" | |
8340 | "Do not export to next AS (well-known community)\n" | |
8341 | "community number\n" | |
8342 | "Do not send outside local AS (well-known community)\n" | |
8343 | "Do not advertise to any peer (well-known community)\n" | |
8344 | "Do not export to next AS (well-known community)\n" | |
8345 | "community number\n" | |
8346 | "Do not send outside local AS (well-known community)\n" | |
8347 | "Do not advertise to any peer (well-known community)\n" | |
8348 | "Do not export to next AS (well-known community)\n") | |
8349 | ||
8350 | /* old command */ | |
8351 | ALIAS (show_ipv6_bgp_community, | |
8352 | show_ipv6_bgp_community4_cmd, | |
8353 | "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)", | |
8354 | SHOW_STR | |
8355 | IPV6_STR | |
8356 | BGP_STR | |
8357 | "Display routes matching the communities\n" | |
8358 | "community number\n" | |
8359 | "Do not send outside local AS (well-known community)\n" | |
8360 | "Do not advertise to any peer (well-known community)\n" | |
8361 | "Do not export to next AS (well-known community)\n" | |
8362 | "community number\n" | |
8363 | "Do not send outside local AS (well-known community)\n" | |
8364 | "Do not advertise to any peer (well-known community)\n" | |
8365 | "Do not export to next AS (well-known community)\n" | |
8366 | "community number\n" | |
8367 | "Do not send outside local AS (well-known community)\n" | |
8368 | "Do not advertise to any peer (well-known community)\n" | |
8369 | "Do not export to next AS (well-known community)\n" | |
8370 | "community number\n" | |
8371 | "Do not send outside local AS (well-known community)\n" | |
8372 | "Do not advertise to any peer (well-known community)\n" | |
8373 | "Do not export to next AS (well-known community)\n") | |
8374 | ||
8375 | DEFUN (show_bgp_community_exact, | |
8376 | show_bgp_community_exact_cmd, | |
8377 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8378 | SHOW_STR | |
8379 | BGP_STR | |
8380 | "Display routes matching the communities\n" | |
8381 | "community number\n" | |
8382 | "Do not send outside local AS (well-known community)\n" | |
8383 | "Do not advertise to any peer (well-known community)\n" | |
8384 | "Do not export to next AS (well-known community)\n" | |
8385 | "Exact match of the communities") | |
8386 | { | |
95cbbd2a | 8387 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8388 | } |
8389 | ||
8390 | ALIAS (show_bgp_community_exact, | |
8391 | show_bgp_ipv6_community_exact_cmd, | |
8392 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8393 | SHOW_STR | |
8394 | BGP_STR | |
8395 | "Address family\n" | |
8396 | "Display routes matching the communities\n" | |
8397 | "community number\n" | |
8398 | "Do not send outside local AS (well-known community)\n" | |
8399 | "Do not advertise to any peer (well-known community)\n" | |
8400 | "Do not export to next AS (well-known community)\n" | |
8401 | "Exact match of the communities") | |
8402 | ||
8403 | ALIAS (show_bgp_community_exact, | |
8404 | show_bgp_community2_exact_cmd, | |
8405 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8406 | SHOW_STR | |
8407 | BGP_STR | |
8408 | "Display routes matching the communities\n" | |
8409 | "community number\n" | |
8410 | "Do not send outside local AS (well-known community)\n" | |
8411 | "Do not advertise to any peer (well-known community)\n" | |
8412 | "Do not export to next AS (well-known community)\n" | |
8413 | "community number\n" | |
8414 | "Do not send outside local AS (well-known community)\n" | |
8415 | "Do not advertise to any peer (well-known community)\n" | |
8416 | "Do not export to next AS (well-known community)\n" | |
8417 | "Exact match of the communities") | |
8418 | ||
8419 | ALIAS (show_bgp_community_exact, | |
8420 | show_bgp_ipv6_community2_exact_cmd, | |
8421 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8422 | SHOW_STR | |
8423 | BGP_STR | |
8424 | "Address family\n" | |
8425 | "Display routes matching the communities\n" | |
8426 | "community number\n" | |
8427 | "Do not send outside local AS (well-known community)\n" | |
8428 | "Do not advertise to any peer (well-known community)\n" | |
8429 | "Do not export to next AS (well-known community)\n" | |
8430 | "community number\n" | |
8431 | "Do not send outside local AS (well-known community)\n" | |
8432 | "Do not advertise to any peer (well-known community)\n" | |
8433 | "Do not export to next AS (well-known community)\n" | |
8434 | "Exact match of the communities") | |
8435 | ||
8436 | ALIAS (show_bgp_community_exact, | |
8437 | show_bgp_community3_exact_cmd, | |
8438 | "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", | |
8439 | SHOW_STR | |
8440 | BGP_STR | |
8441 | "Display routes matching the communities\n" | |
8442 | "community number\n" | |
8443 | "Do not send outside local AS (well-known community)\n" | |
8444 | "Do not advertise to any peer (well-known community)\n" | |
8445 | "Do not export to next AS (well-known community)\n" | |
8446 | "community number\n" | |
8447 | "Do not send outside local AS (well-known community)\n" | |
8448 | "Do not advertise to any peer (well-known community)\n" | |
8449 | "Do not export to next AS (well-known community)\n" | |
8450 | "community number\n" | |
8451 | "Do not send outside local AS (well-known community)\n" | |
8452 | "Do not advertise to any peer (well-known community)\n" | |
8453 | "Do not export to next AS (well-known community)\n" | |
8454 | "Exact match of the communities") | |
8455 | ||
8456 | ALIAS (show_bgp_community_exact, | |
8457 | show_bgp_ipv6_community3_exact_cmd, | |
8458 | "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", | |
8459 | SHOW_STR | |
8460 | BGP_STR | |
8461 | "Address family\n" | |
8462 | "Display routes matching the communities\n" | |
8463 | "community number\n" | |
8464 | "Do not send outside local AS (well-known community)\n" | |
8465 | "Do not advertise to any peer (well-known community)\n" | |
8466 | "Do not export to next AS (well-known community)\n" | |
8467 | "community number\n" | |
8468 | "Do not send outside local AS (well-known community)\n" | |
8469 | "Do not advertise to any peer (well-known community)\n" | |
8470 | "Do not export to next AS (well-known community)\n" | |
8471 | "community number\n" | |
8472 | "Do not send outside local AS (well-known community)\n" | |
8473 | "Do not advertise to any peer (well-known community)\n" | |
8474 | "Do not export to next AS (well-known community)\n" | |
8475 | "Exact match of the communities") | |
8476 | ||
8477 | ALIAS (show_bgp_community_exact, | |
8478 | show_bgp_community4_exact_cmd, | |
8479 | "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", | |
8480 | SHOW_STR | |
8481 | BGP_STR | |
8482 | "Display routes matching the communities\n" | |
8483 | "community number\n" | |
8484 | "Do not send outside local AS (well-known community)\n" | |
8485 | "Do not advertise to any peer (well-known community)\n" | |
8486 | "Do not export to next AS (well-known community)\n" | |
8487 | "community number\n" | |
8488 | "Do not send outside local AS (well-known community)\n" | |
8489 | "Do not advertise to any peer (well-known community)\n" | |
8490 | "Do not export to next AS (well-known community)\n" | |
8491 | "community number\n" | |
8492 | "Do not send outside local AS (well-known community)\n" | |
8493 | "Do not advertise to any peer (well-known community)\n" | |
8494 | "Do not export to next AS (well-known community)\n" | |
8495 | "community number\n" | |
8496 | "Do not send outside local AS (well-known community)\n" | |
8497 | "Do not advertise to any peer (well-known community)\n" | |
8498 | "Do not export to next AS (well-known community)\n" | |
8499 | "Exact match of the communities") | |
8500 | ||
8501 | ALIAS (show_bgp_community_exact, | |
8502 | show_bgp_ipv6_community4_exact_cmd, | |
8503 | "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", | |
8504 | SHOW_STR | |
8505 | BGP_STR | |
8506 | "Address family\n" | |
8507 | "Display routes matching the communities\n" | |
8508 | "community number\n" | |
8509 | "Do not send outside local AS (well-known community)\n" | |
8510 | "Do not advertise to any peer (well-known community)\n" | |
8511 | "Do not export to next AS (well-known community)\n" | |
8512 | "community number\n" | |
8513 | "Do not send outside local AS (well-known community)\n" | |
8514 | "Do not advertise to any peer (well-known community)\n" | |
8515 | "Do not export to next AS (well-known community)\n" | |
8516 | "community number\n" | |
8517 | "Do not send outside local AS (well-known community)\n" | |
8518 | "Do not advertise to any peer (well-known community)\n" | |
8519 | "Do not export to next AS (well-known community)\n" | |
8520 | "community number\n" | |
8521 | "Do not send outside local AS (well-known community)\n" | |
8522 | "Do not advertise to any peer (well-known community)\n" | |
8523 | "Do not export to next AS (well-known community)\n" | |
8524 | "Exact match of the communities") | |
8525 | ||
8526 | /* old command */ | |
8527 | DEFUN (show_ipv6_bgp_community_exact, | |
8528 | show_ipv6_bgp_community_exact_cmd, | |
8529 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8530 | SHOW_STR | |
8531 | IPV6_STR | |
8532 | BGP_STR | |
8533 | "Display routes matching the communities\n" | |
8534 | "community number\n" | |
8535 | "Do not send outside local AS (well-known community)\n" | |
8536 | "Do not advertise to any peer (well-known community)\n" | |
8537 | "Do not export to next AS (well-known community)\n" | |
8538 | "Exact match of the communities") | |
8539 | { | |
95cbbd2a | 8540 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8541 | } |
8542 | ||
8543 | /* old command */ | |
8544 | ALIAS (show_ipv6_bgp_community_exact, | |
8545 | show_ipv6_bgp_community2_exact_cmd, | |
8546 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8547 | SHOW_STR | |
8548 | IPV6_STR | |
8549 | BGP_STR | |
8550 | "Display routes matching the communities\n" | |
8551 | "community number\n" | |
8552 | "Do not send outside local AS (well-known community)\n" | |
8553 | "Do not advertise to any peer (well-known community)\n" | |
8554 | "Do not export to next AS (well-known community)\n" | |
8555 | "community number\n" | |
8556 | "Do not send outside local AS (well-known community)\n" | |
8557 | "Do not advertise to any peer (well-known community)\n" | |
8558 | "Do not export to next AS (well-known community)\n" | |
8559 | "Exact match of the communities") | |
8560 | ||
8561 | /* old command */ | |
8562 | ALIAS (show_ipv6_bgp_community_exact, | |
8563 | show_ipv6_bgp_community3_exact_cmd, | |
8564 | "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", | |
8565 | SHOW_STR | |
8566 | IPV6_STR | |
8567 | BGP_STR | |
8568 | "Display routes matching the communities\n" | |
8569 | "community number\n" | |
8570 | "Do not send outside local AS (well-known community)\n" | |
8571 | "Do not advertise to any peer (well-known community)\n" | |
8572 | "Do not export to next AS (well-known community)\n" | |
8573 | "community number\n" | |
8574 | "Do not send outside local AS (well-known community)\n" | |
8575 | "Do not advertise to any peer (well-known community)\n" | |
8576 | "Do not export to next AS (well-known community)\n" | |
8577 | "community number\n" | |
8578 | "Do not send outside local AS (well-known community)\n" | |
8579 | "Do not advertise to any peer (well-known community)\n" | |
8580 | "Do not export to next AS (well-known community)\n" | |
8581 | "Exact match of the communities") | |
8582 | ||
8583 | /* old command */ | |
8584 | ALIAS (show_ipv6_bgp_community_exact, | |
8585 | show_ipv6_bgp_community4_exact_cmd, | |
8586 | "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", | |
8587 | SHOW_STR | |
8588 | IPV6_STR | |
8589 | BGP_STR | |
8590 | "Display routes matching the communities\n" | |
8591 | "community number\n" | |
8592 | "Do not send outside local AS (well-known community)\n" | |
8593 | "Do not advertise to any peer (well-known community)\n" | |
8594 | "Do not export to next AS (well-known community)\n" | |
8595 | "community number\n" | |
8596 | "Do not send outside local AS (well-known community)\n" | |
8597 | "Do not advertise to any peer (well-known community)\n" | |
8598 | "Do not export to next AS (well-known community)\n" | |
8599 | "community number\n" | |
8600 | "Do not send outside local AS (well-known community)\n" | |
8601 | "Do not advertise to any peer (well-known community)\n" | |
8602 | "Do not export to next AS (well-known community)\n" | |
8603 | "community number\n" | |
8604 | "Do not send outside local AS (well-known community)\n" | |
8605 | "Do not advertise to any peer (well-known community)\n" | |
8606 | "Do not export to next AS (well-known community)\n" | |
8607 | "Exact match of the communities") | |
8608 | ||
8609 | /* old command */ | |
8610 | DEFUN (show_ipv6_mbgp_community, | |
8611 | show_ipv6_mbgp_community_cmd, | |
8612 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8613 | SHOW_STR | |
8614 | IPV6_STR | |
8615 | MBGP_STR | |
8616 | "Display routes matching the communities\n" | |
8617 | "community number\n" | |
8618 | "Do not send outside local AS (well-known community)\n" | |
8619 | "Do not advertise to any peer (well-known community)\n" | |
8620 | "Do not export to next AS (well-known community)\n") | |
8621 | { | |
95cbbd2a | 8622 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 8623 | } |
8624 | ||
8625 | /* old command */ | |
8626 | ALIAS (show_ipv6_mbgp_community, | |
8627 | show_ipv6_mbgp_community2_cmd, | |
8628 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8629 | SHOW_STR | |
8630 | IPV6_STR | |
8631 | MBGP_STR | |
8632 | "Display routes matching the communities\n" | |
8633 | "community number\n" | |
8634 | "Do not send outside local AS (well-known community)\n" | |
8635 | "Do not advertise to any peer (well-known community)\n" | |
8636 | "Do not export to next AS (well-known community)\n" | |
8637 | "community number\n" | |
8638 | "Do not send outside local AS (well-known community)\n" | |
8639 | "Do not advertise to any peer (well-known community)\n" | |
8640 | "Do not export to next AS (well-known community)\n") | |
8641 | ||
8642 | /* old command */ | |
8643 | ALIAS (show_ipv6_mbgp_community, | |
8644 | show_ipv6_mbgp_community3_cmd, | |
8645 | "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)", | |
8646 | SHOW_STR | |
8647 | IPV6_STR | |
8648 | MBGP_STR | |
8649 | "Display routes matching the communities\n" | |
8650 | "community number\n" | |
8651 | "Do not send outside local AS (well-known community)\n" | |
8652 | "Do not advertise to any peer (well-known community)\n" | |
8653 | "Do not export to next AS (well-known community)\n" | |
8654 | "community number\n" | |
8655 | "Do not send outside local AS (well-known community)\n" | |
8656 | "Do not advertise to any peer (well-known community)\n" | |
8657 | "Do not export to next AS (well-known community)\n" | |
8658 | "community number\n" | |
8659 | "Do not send outside local AS (well-known community)\n" | |
8660 | "Do not advertise to any peer (well-known community)\n" | |
8661 | "Do not export to next AS (well-known community)\n") | |
8662 | ||
8663 | /* old command */ | |
8664 | ALIAS (show_ipv6_mbgp_community, | |
8665 | show_ipv6_mbgp_community4_cmd, | |
8666 | "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)", | |
8667 | SHOW_STR | |
8668 | IPV6_STR | |
8669 | MBGP_STR | |
8670 | "Display routes matching the communities\n" | |
8671 | "community number\n" | |
8672 | "Do not send outside local AS (well-known community)\n" | |
8673 | "Do not advertise to any peer (well-known community)\n" | |
8674 | "Do not export to next AS (well-known community)\n" | |
8675 | "community number\n" | |
8676 | "Do not send outside local AS (well-known community)\n" | |
8677 | "Do not advertise to any peer (well-known community)\n" | |
8678 | "Do not export to next AS (well-known community)\n" | |
8679 | "community number\n" | |
8680 | "Do not send outside local AS (well-known community)\n" | |
8681 | "Do not advertise to any peer (well-known community)\n" | |
8682 | "Do not export to next AS (well-known community)\n" | |
8683 | "community number\n" | |
8684 | "Do not send outside local AS (well-known community)\n" | |
8685 | "Do not advertise to any peer (well-known community)\n" | |
8686 | "Do not export to next AS (well-known community)\n") | |
8687 | ||
8688 | /* old command */ | |
8689 | DEFUN (show_ipv6_mbgp_community_exact, | |
8690 | show_ipv6_mbgp_community_exact_cmd, | |
8691 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8692 | SHOW_STR | |
8693 | IPV6_STR | |
8694 | MBGP_STR | |
8695 | "Display routes matching the communities\n" | |
8696 | "community number\n" | |
8697 | "Do not send outside local AS (well-known community)\n" | |
8698 | "Do not advertise to any peer (well-known community)\n" | |
8699 | "Do not export to next AS (well-known community)\n" | |
8700 | "Exact match of the communities") | |
8701 | { | |
95cbbd2a | 8702 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 8703 | } |
8704 | ||
8705 | /* old command */ | |
8706 | ALIAS (show_ipv6_mbgp_community_exact, | |
8707 | show_ipv6_mbgp_community2_exact_cmd, | |
8708 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8709 | SHOW_STR | |
8710 | IPV6_STR | |
8711 | MBGP_STR | |
8712 | "Display routes matching the communities\n" | |
8713 | "community number\n" | |
8714 | "Do not send outside local AS (well-known community)\n" | |
8715 | "Do not advertise to any peer (well-known community)\n" | |
8716 | "Do not export to next AS (well-known community)\n" | |
8717 | "community number\n" | |
8718 | "Do not send outside local AS (well-known community)\n" | |
8719 | "Do not advertise to any peer (well-known community)\n" | |
8720 | "Do not export to next AS (well-known community)\n" | |
8721 | "Exact match of the communities") | |
8722 | ||
8723 | /* old command */ | |
8724 | ALIAS (show_ipv6_mbgp_community_exact, | |
8725 | show_ipv6_mbgp_community3_exact_cmd, | |
8726 | "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", | |
8727 | SHOW_STR | |
8728 | IPV6_STR | |
8729 | MBGP_STR | |
8730 | "Display routes matching the communities\n" | |
8731 | "community number\n" | |
8732 | "Do not send outside local AS (well-known community)\n" | |
8733 | "Do not advertise to any peer (well-known community)\n" | |
8734 | "Do not export to next AS (well-known community)\n" | |
8735 | "community number\n" | |
8736 | "Do not send outside local AS (well-known community)\n" | |
8737 | "Do not advertise to any peer (well-known community)\n" | |
8738 | "Do not export to next AS (well-known community)\n" | |
8739 | "community number\n" | |
8740 | "Do not send outside local AS (well-known community)\n" | |
8741 | "Do not advertise to any peer (well-known community)\n" | |
8742 | "Do not export to next AS (well-known community)\n" | |
8743 | "Exact match of the communities") | |
8744 | ||
8745 | /* old command */ | |
8746 | ALIAS (show_ipv6_mbgp_community_exact, | |
8747 | show_ipv6_mbgp_community4_exact_cmd, | |
8748 | "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", | |
8749 | SHOW_STR | |
8750 | IPV6_STR | |
8751 | MBGP_STR | |
8752 | "Display routes matching the communities\n" | |
8753 | "community number\n" | |
8754 | "Do not send outside local AS (well-known community)\n" | |
8755 | "Do not advertise to any peer (well-known community)\n" | |
8756 | "Do not export to next AS (well-known community)\n" | |
8757 | "community number\n" | |
8758 | "Do not send outside local AS (well-known community)\n" | |
8759 | "Do not advertise to any peer (well-known community)\n" | |
8760 | "Do not export to next AS (well-known community)\n" | |
8761 | "community number\n" | |
8762 | "Do not send outside local AS (well-known community)\n" | |
8763 | "Do not advertise to any peer (well-known community)\n" | |
8764 | "Do not export to next AS (well-known community)\n" | |
8765 | "community number\n" | |
8766 | "Do not send outside local AS (well-known community)\n" | |
8767 | "Do not advertise to any peer (well-known community)\n" | |
8768 | "Do not export to next AS (well-known community)\n" | |
8769 | "Exact match of the communities") | |
8770 | #endif /* HAVE_IPV6 */ | |
8771 | \f | |
94f2b392 | 8772 | static int |
fd79ac91 | 8773 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
4c9641ba | 8774 | afi_t afi, safi_t safi) |
718e3744 | 8775 | { |
8776 | struct community_list *list; | |
8777 | ||
fee6e4e4 | 8778 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
718e3744 | 8779 | if (list == NULL) |
8780 | { | |
8781 | vty_out (vty, "%% %s is not a valid community-list name%s", com, | |
8782 | VTY_NEWLINE); | |
8783 | return CMD_WARNING; | |
8784 | } | |
8785 | ||
5a646650 | 8786 | return bgp_show (vty, NULL, afi, safi, |
8787 | (exact ? bgp_show_type_community_list_exact : | |
8788 | bgp_show_type_community_list), list); | |
718e3744 | 8789 | } |
8790 | ||
8791 | DEFUN (show_ip_bgp_community_list, | |
8792 | show_ip_bgp_community_list_cmd, | |
fee6e4e4 | 8793 | "show ip bgp community-list (<1-500>|WORD)", |
718e3744 | 8794 | SHOW_STR |
8795 | IP_STR | |
8796 | BGP_STR | |
8797 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8798 | "community-list number\n" |
718e3744 | 8799 | "community-list name\n") |
8800 | { | |
8801 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); | |
8802 | } | |
8803 | ||
8804 | DEFUN (show_ip_bgp_ipv4_community_list, | |
8805 | show_ip_bgp_ipv4_community_list_cmd, | |
fee6e4e4 | 8806 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
718e3744 | 8807 | SHOW_STR |
8808 | IP_STR | |
8809 | BGP_STR | |
8810 | "Address family\n" | |
8811 | "Address Family modifier\n" | |
8812 | "Address Family modifier\n" | |
8813 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8814 | "community-list number\n" |
718e3744 | 8815 | "community-list name\n") |
8816 | { | |
8817 | if (strncmp (argv[0], "m", 1) == 0) | |
8818 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); | |
8819 | ||
8820 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); | |
8821 | } | |
8822 | ||
8823 | DEFUN (show_ip_bgp_community_list_exact, | |
8824 | show_ip_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8825 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8826 | SHOW_STR |
8827 | IP_STR | |
8828 | BGP_STR | |
8829 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8830 | "community-list number\n" |
718e3744 | 8831 | "community-list name\n" |
8832 | "Exact match of the communities\n") | |
8833 | { | |
8834 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); | |
8835 | } | |
8836 | ||
8837 | DEFUN (show_ip_bgp_ipv4_community_list_exact, | |
8838 | show_ip_bgp_ipv4_community_list_exact_cmd, | |
fee6e4e4 | 8839 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
718e3744 | 8840 | SHOW_STR |
8841 | IP_STR | |
8842 | BGP_STR | |
8843 | "Address family\n" | |
8844 | "Address Family modifier\n" | |
8845 | "Address Family modifier\n" | |
8846 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8847 | "community-list number\n" |
718e3744 | 8848 | "community-list name\n" |
8849 | "Exact match of the communities\n") | |
8850 | { | |
8851 | if (strncmp (argv[0], "m", 1) == 0) | |
8852 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); | |
8853 | ||
8854 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); | |
8855 | } | |
8856 | ||
8857 | #ifdef HAVE_IPV6 | |
8858 | DEFUN (show_bgp_community_list, | |
8859 | show_bgp_community_list_cmd, | |
fee6e4e4 | 8860 | "show bgp community-list (<1-500>|WORD)", |
718e3744 | 8861 | SHOW_STR |
8862 | BGP_STR | |
8863 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8864 | "community-list number\n" |
718e3744 | 8865 | "community-list name\n") |
8866 | { | |
8867 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8868 | } | |
8869 | ||
8870 | ALIAS (show_bgp_community_list, | |
8871 | show_bgp_ipv6_community_list_cmd, | |
fee6e4e4 | 8872 | "show bgp ipv6 community-list (<1-500>|WORD)", |
718e3744 | 8873 | SHOW_STR |
8874 | BGP_STR | |
8875 | "Address family\n" | |
8876 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8877 | "community-list number\n" |
e8e1946e | 8878 | "community-list name\n") |
718e3744 | 8879 | |
8880 | /* old command */ | |
8881 | DEFUN (show_ipv6_bgp_community_list, | |
8882 | show_ipv6_bgp_community_list_cmd, | |
8883 | "show ipv6 bgp community-list WORD", | |
8884 | SHOW_STR | |
8885 | IPV6_STR | |
8886 | BGP_STR | |
8887 | "Display routes matching the community-list\n" | |
8888 | "community-list name\n") | |
8889 | { | |
8890 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8891 | } | |
8892 | ||
8893 | /* old command */ | |
8894 | DEFUN (show_ipv6_mbgp_community_list, | |
8895 | show_ipv6_mbgp_community_list_cmd, | |
8896 | "show ipv6 mbgp community-list WORD", | |
8897 | SHOW_STR | |
8898 | IPV6_STR | |
8899 | MBGP_STR | |
8900 | "Display routes matching the community-list\n" | |
8901 | "community-list name\n") | |
8902 | { | |
8903 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); | |
8904 | } | |
8905 | ||
8906 | DEFUN (show_bgp_community_list_exact, | |
8907 | show_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8908 | "show bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8909 | SHOW_STR |
8910 | BGP_STR | |
8911 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8912 | "community-list number\n" |
718e3744 | 8913 | "community-list name\n" |
8914 | "Exact match of the communities\n") | |
8915 | { | |
8916 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
8917 | } | |
8918 | ||
8919 | ALIAS (show_bgp_community_list_exact, | |
8920 | show_bgp_ipv6_community_list_exact_cmd, | |
fee6e4e4 | 8921 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
718e3744 | 8922 | SHOW_STR |
8923 | BGP_STR | |
8924 | "Address family\n" | |
8925 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8926 | "community-list number\n" |
718e3744 | 8927 | "community-list name\n" |
8928 | "Exact match of the communities\n") | |
8929 | ||
8930 | /* old command */ | |
8931 | DEFUN (show_ipv6_bgp_community_list_exact, | |
8932 | show_ipv6_bgp_community_list_exact_cmd, | |
8933 | "show ipv6 bgp community-list WORD exact-match", | |
8934 | SHOW_STR | |
8935 | IPV6_STR | |
8936 | BGP_STR | |
8937 | "Display routes matching the community-list\n" | |
8938 | "community-list name\n" | |
8939 | "Exact match of the communities\n") | |
8940 | { | |
8941 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
8942 | } | |
8943 | ||
8944 | /* old command */ | |
8945 | DEFUN (show_ipv6_mbgp_community_list_exact, | |
8946 | show_ipv6_mbgp_community_list_exact_cmd, | |
8947 | "show ipv6 mbgp community-list WORD exact-match", | |
8948 | SHOW_STR | |
8949 | IPV6_STR | |
8950 | MBGP_STR | |
8951 | "Display routes matching the community-list\n" | |
8952 | "community-list name\n" | |
8953 | "Exact match of the communities\n") | |
8954 | { | |
8955 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); | |
8956 | } | |
8957 | #endif /* HAVE_IPV6 */ | |
8958 | \f | |
94f2b392 | 8959 | static int |
fd79ac91 | 8960 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
718e3744 | 8961 | safi_t safi, enum bgp_show_type type) |
8962 | { | |
8963 | int ret; | |
8964 | struct prefix *p; | |
8965 | ||
8966 | p = prefix_new(); | |
8967 | ||
8968 | ret = str2prefix (prefix, p); | |
8969 | if (! ret) | |
8970 | { | |
8971 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); | |
8972 | return CMD_WARNING; | |
8973 | } | |
8974 | ||
5a646650 | 8975 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
8976 | prefix_free(p); | |
8977 | return ret; | |
718e3744 | 8978 | } |
8979 | ||
8980 | DEFUN (show_ip_bgp_prefix_longer, | |
8981 | show_ip_bgp_prefix_longer_cmd, | |
8982 | "show ip bgp A.B.C.D/M longer-prefixes", | |
8983 | SHOW_STR | |
8984 | IP_STR | |
8985 | BGP_STR | |
8986 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8987 | "Display route and more specific routes\n") | |
8988 | { | |
8989 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8990 | bgp_show_type_prefix_longer); | |
8991 | } | |
8992 | ||
8993 | DEFUN (show_ip_bgp_flap_prefix_longer, | |
8994 | show_ip_bgp_flap_prefix_longer_cmd, | |
8995 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", | |
8996 | SHOW_STR | |
8997 | IP_STR | |
8998 | BGP_STR | |
8999 | "Display flap statistics of routes\n" | |
9000 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
9001 | "Display route and more specific routes\n") | |
9002 | { | |
9003 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
9004 | bgp_show_type_flap_prefix_longer); | |
9005 | } | |
9006 | ||
9007 | DEFUN (show_ip_bgp_ipv4_prefix_longer, | |
9008 | show_ip_bgp_ipv4_prefix_longer_cmd, | |
9009 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", | |
9010 | SHOW_STR | |
9011 | IP_STR | |
9012 | BGP_STR | |
9013 | "Address family\n" | |
9014 | "Address Family modifier\n" | |
9015 | "Address Family modifier\n" | |
9016 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
9017 | "Display route and more specific routes\n") | |
9018 | { | |
9019 | if (strncmp (argv[0], "m", 1) == 0) | |
9020 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
9021 | bgp_show_type_prefix_longer); | |
9022 | ||
9023 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
9024 | bgp_show_type_prefix_longer); | |
9025 | } | |
9026 | ||
9027 | DEFUN (show_ip_bgp_flap_address, | |
9028 | show_ip_bgp_flap_address_cmd, | |
9029 | "show ip bgp flap-statistics A.B.C.D", | |
9030 | SHOW_STR | |
9031 | IP_STR | |
9032 | BGP_STR | |
9033 | "Display flap statistics of routes\n" | |
9034 | "Network in the BGP routing table to display\n") | |
9035 | { | |
9036 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
9037 | bgp_show_type_flap_address); | |
9038 | } | |
9039 | ||
9040 | DEFUN (show_ip_bgp_flap_prefix, | |
9041 | show_ip_bgp_flap_prefix_cmd, | |
9042 | "show ip bgp flap-statistics A.B.C.D/M", | |
9043 | SHOW_STR | |
9044 | IP_STR | |
9045 | BGP_STR | |
9046 | "Display flap statistics of routes\n" | |
9047 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
9048 | { | |
9049 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
9050 | bgp_show_type_flap_prefix); | |
9051 | } | |
9052 | #ifdef HAVE_IPV6 | |
9053 | DEFUN (show_bgp_prefix_longer, | |
9054 | show_bgp_prefix_longer_cmd, | |
9055 | "show bgp X:X::X:X/M longer-prefixes", | |
9056 | SHOW_STR | |
9057 | BGP_STR | |
9058 | "IPv6 prefix <network>/<length>\n" | |
9059 | "Display route and more specific routes\n") | |
9060 | { | |
9061 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
9062 | bgp_show_type_prefix_longer); | |
9063 | } | |
9064 | ||
9065 | ALIAS (show_bgp_prefix_longer, | |
9066 | show_bgp_ipv6_prefix_longer_cmd, | |
9067 | "show bgp ipv6 X:X::X:X/M longer-prefixes", | |
9068 | SHOW_STR | |
9069 | BGP_STR | |
9070 | "Address family\n" | |
9071 | "IPv6 prefix <network>/<length>\n" | |
9072 | "Display route and more specific routes\n") | |
9073 | ||
9074 | /* old command */ | |
9075 | DEFUN (show_ipv6_bgp_prefix_longer, | |
9076 | show_ipv6_bgp_prefix_longer_cmd, | |
9077 | "show ipv6 bgp X:X::X:X/M longer-prefixes", | |
9078 | SHOW_STR | |
9079 | IPV6_STR | |
9080 | BGP_STR | |
9081 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
9082 | "Display route and more specific routes\n") | |
9083 | { | |
9084 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
9085 | bgp_show_type_prefix_longer); | |
9086 | } | |
9087 | ||
9088 | /* old command */ | |
9089 | DEFUN (show_ipv6_mbgp_prefix_longer, | |
9090 | show_ipv6_mbgp_prefix_longer_cmd, | |
9091 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", | |
9092 | SHOW_STR | |
9093 | IPV6_STR | |
9094 | MBGP_STR | |
9095 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
9096 | "Display route and more specific routes\n") | |
9097 | { | |
9098 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
9099 | bgp_show_type_prefix_longer); | |
9100 | } | |
9101 | #endif /* HAVE_IPV6 */ | |
bb46e94f | 9102 | |
94f2b392 | 9103 | static struct peer * |
fd79ac91 | 9104 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
9105 | const char *ip_str) | |
bb46e94f | 9106 | { |
9107 | int ret; | |
9108 | struct bgp *bgp; | |
9109 | struct peer *peer; | |
9110 | union sockunion su; | |
9111 | ||
9112 | /* BGP structure lookup. */ | |
9113 | if (view_name) | |
9114 | { | |
9115 | bgp = bgp_lookup_by_name (view_name); | |
9116 | if (! bgp) | |
9117 | { | |
9118 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
9119 | return NULL; | |
9120 | } | |
9121 | } | |
5228ad27 | 9122 | else |
bb46e94f | 9123 | { |
9124 | bgp = bgp_get_default (); | |
9125 | if (! bgp) | |
9126 | { | |
9127 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
9128 | return NULL; | |
9129 | } | |
9130 | } | |
9131 | ||
9132 | /* Get peer sockunion. */ | |
9133 | ret = str2sockunion (ip_str, &su); | |
9134 | if (ret < 0) | |
9135 | { | |
9136 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); | |
9137 | return NULL; | |
9138 | } | |
9139 | ||
9140 | /* Peer structure lookup. */ | |
9141 | peer = peer_lookup (bgp, &su); | |
9142 | if (! peer) | |
9143 | { | |
9144 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); | |
9145 | return NULL; | |
9146 | } | |
9147 | ||
9148 | return peer; | |
9149 | } | |
2815e61f PJ |
9150 | \f |
9151 | enum bgp_stats | |
9152 | { | |
9153 | BGP_STATS_MAXBITLEN = 0, | |
9154 | BGP_STATS_RIB, | |
9155 | BGP_STATS_PREFIXES, | |
9156 | BGP_STATS_TOTPLEN, | |
9157 | BGP_STATS_UNAGGREGATEABLE, | |
9158 | BGP_STATS_MAX_AGGREGATEABLE, | |
9159 | BGP_STATS_AGGREGATES, | |
9160 | BGP_STATS_SPACE, | |
9161 | BGP_STATS_ASPATH_COUNT, | |
9162 | BGP_STATS_ASPATH_MAXHOPS, | |
9163 | BGP_STATS_ASPATH_TOTHOPS, | |
9164 | BGP_STATS_ASPATH_MAXSIZE, | |
9165 | BGP_STATS_ASPATH_TOTSIZE, | |
9166 | BGP_STATS_ASN_HIGHEST, | |
9167 | BGP_STATS_MAX, | |
9168 | }; | |
9169 | ||
9170 | static const char *table_stats_strs[] = | |
9171 | { | |
9172 | [BGP_STATS_PREFIXES] = "Total Prefixes", | |
9173 | [BGP_STATS_TOTPLEN] = "Average prefix length", | |
9174 | [BGP_STATS_RIB] = "Total Advertisements", | |
9175 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", | |
9176 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", | |
9177 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", | |
9178 | [BGP_STATS_SPACE] = "Address space advertised", | |
9179 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", | |
9180 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", | |
9181 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", | |
9182 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", | |
9183 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", | |
9184 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", | |
9185 | [BGP_STATS_MAX] = NULL, | |
9186 | }; | |
9187 | ||
9188 | struct bgp_table_stats | |
9189 | { | |
9190 | struct bgp_table *table; | |
9191 | unsigned long long counts[BGP_STATS_MAX]; | |
9192 | }; | |
9193 | ||
9194 | #if 0 | |
9195 | #define TALLY_SIGFIG 100000 | |
9196 | static unsigned long | |
9197 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) | |
9198 | { | |
9199 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); | |
9200 | unsigned long res = (newtot * TALLY_SIGFIG) / count; | |
9201 | unsigned long ret = newtot / count; | |
9202 | ||
9203 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) | |
9204 | return ret + 1; | |
9205 | else | |
9206 | return ret; | |
9207 | } | |
9208 | #endif | |
9209 | ||
9210 | static int | |
9211 | bgp_table_stats_walker (struct thread *t) | |
9212 | { | |
9213 | struct bgp_node *rn; | |
9214 | struct bgp_node *top; | |
9215 | struct bgp_table_stats *ts = THREAD_ARG (t); | |
9216 | unsigned int space = 0; | |
9217 | ||
53d9f67a PJ |
9218 | if (!(top = bgp_table_top (ts->table))) |
9219 | return 0; | |
2815e61f PJ |
9220 | |
9221 | switch (top->p.family) | |
9222 | { | |
9223 | case AF_INET: | |
9224 | space = IPV4_MAX_BITLEN; | |
9225 | break; | |
9226 | case AF_INET6: | |
9227 | space = IPV6_MAX_BITLEN; | |
9228 | break; | |
9229 | } | |
9230 | ||
9231 | ts->counts[BGP_STATS_MAXBITLEN] = space; | |
9232 | ||
9233 | for (rn = top; rn; rn = bgp_route_next (rn)) | |
9234 | { | |
9235 | struct bgp_info *ri; | |
9236 | struct bgp_node *prn = rn->parent; | |
9237 | unsigned int rinum = 0; | |
9238 | ||
9239 | if (rn == top) | |
9240 | continue; | |
9241 | ||
9242 | if (!rn->info) | |
9243 | continue; | |
9244 | ||
9245 | ts->counts[BGP_STATS_PREFIXES]++; | |
9246 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; | |
9247 | ||
9248 | #if 0 | |
9249 | ts->counts[BGP_STATS_AVGPLEN] | |
9250 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], | |
9251 | ts->counts[BGP_STATS_AVGPLEN], | |
9252 | rn->p.prefixlen); | |
9253 | #endif | |
9254 | ||
9255 | /* check if the prefix is included by any other announcements */ | |
9256 | while (prn && !prn->info) | |
9257 | prn = prn->parent; | |
9258 | ||
9259 | if (prn == NULL || prn == top) | |
8383a9bd PJ |
9260 | { |
9261 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; | |
9262 | /* announced address space */ | |
9263 | if (space) | |
9264 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); | |
9265 | } | |
2815e61f PJ |
9266 | else if (prn->info) |
9267 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; | |
9268 | ||
2815e61f PJ |
9269 | for (ri = rn->info; ri; ri = ri->next) |
9270 | { | |
9271 | rinum++; | |
9272 | ts->counts[BGP_STATS_RIB]++; | |
9273 | ||
9274 | if (ri->attr && | |
9275 | (CHECK_FLAG (ri->attr->flag, | |
9276 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) | |
9277 | ts->counts[BGP_STATS_AGGREGATES]++; | |
9278 | ||
9279 | /* as-path stats */ | |
9280 | if (ri->attr && ri->attr->aspath) | |
9281 | { | |
9282 | unsigned int hops = aspath_count_hops (ri->attr->aspath); | |
9283 | unsigned int size = aspath_size (ri->attr->aspath); | |
9284 | as_t highest = aspath_highest (ri->attr->aspath); | |
9285 | ||
9286 | ts->counts[BGP_STATS_ASPATH_COUNT]++; | |
9287 | ||
9288 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) | |
9289 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; | |
9290 | ||
9291 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) | |
9292 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; | |
9293 | ||
9294 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; | |
9295 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; | |
9296 | #if 0 | |
9297 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] | |
9298 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9299 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], | |
9300 | hops); | |
9301 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] | |
9302 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9303 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], | |
9304 | size); | |
9305 | #endif | |
9306 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) | |
9307 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; | |
9308 | } | |
9309 | } | |
9310 | } | |
9311 | return 0; | |
9312 | } | |
9313 | ||
9314 | static int | |
9315 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) | |
9316 | { | |
9317 | struct bgp_table_stats ts; | |
9318 | unsigned int i; | |
9319 | ||
9320 | if (!bgp->rib[afi][safi]) | |
9321 | { | |
9322 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); | |
9323 | return CMD_WARNING; | |
9324 | } | |
9325 | ||
9326 | memset (&ts, 0, sizeof (ts)); | |
9327 | ts.table = bgp->rib[afi][safi]; | |
9328 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); | |
bb46e94f | 9329 | |
2815e61f PJ |
9330 | vty_out (vty, "BGP %s RIB statistics%s%s", |
9331 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); | |
9332 | ||
9333 | for (i = 0; i < BGP_STATS_MAX; i++) | |
9334 | { | |
9335 | if (!table_stats_strs[i]) | |
9336 | continue; | |
9337 | ||
9338 | switch (i) | |
9339 | { | |
9340 | #if 0 | |
9341 | case BGP_STATS_ASPATH_AVGHOPS: | |
9342 | case BGP_STATS_ASPATH_AVGSIZE: | |
9343 | case BGP_STATS_AVGPLEN: | |
9344 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9345 | vty_out (vty, "%12.2f", | |
9346 | (float)ts.counts[i] / (float)TALLY_SIGFIG); | |
9347 | break; | |
9348 | #endif | |
9349 | case BGP_STATS_ASPATH_TOTHOPS: | |
9350 | case BGP_STATS_ASPATH_TOTSIZE: | |
9351 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9352 | vty_out (vty, "%12.2f", | |
9353 | ts.counts[i] ? | |
9354 | (float)ts.counts[i] / | |
9355 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] | |
9356 | : 0); | |
9357 | break; | |
9358 | case BGP_STATS_TOTPLEN: | |
9359 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9360 | vty_out (vty, "%12.2f", | |
9361 | ts.counts[i] ? | |
9362 | (float)ts.counts[i] / | |
9363 | (float)ts.counts[BGP_STATS_PREFIXES] | |
9364 | : 0); | |
9365 | break; | |
9366 | case BGP_STATS_SPACE: | |
9367 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9368 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); | |
9369 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) | |
9370 | break; | |
30a2231a | 9371 | vty_out (vty, "%30s: ", "%% announced "); |
2815e61f PJ |
9372 | vty_out (vty, "%12.2f%s", |
9373 | 100 * (float)ts.counts[BGP_STATS_SPACE] / | |
56395af7 | 9374 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
2815e61f PJ |
9375 | VTY_NEWLINE); |
9376 | vty_out (vty, "%30s: ", "/8 equivalent "); | |
9377 | vty_out (vty, "%12.2f%s", | |
9378 | (float)ts.counts[BGP_STATS_SPACE] / | |
9379 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), | |
9380 | VTY_NEWLINE); | |
9381 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) | |
9382 | break; | |
9383 | vty_out (vty, "%30s: ", "/24 equivalent "); | |
9384 | vty_out (vty, "%12.2f", | |
9385 | (float)ts.counts[BGP_STATS_SPACE] / | |
9386 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); | |
9387 | break; | |
9388 | default: | |
9389 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9390 | vty_out (vty, "%12llu", ts.counts[i]); | |
9391 | } | |
9392 | ||
9393 | vty_out (vty, "%s", VTY_NEWLINE); | |
9394 | } | |
9395 | return CMD_SUCCESS; | |
9396 | } | |
9397 | ||
9398 | static int | |
9399 | bgp_table_stats_vty (struct vty *vty, const char *name, | |
9400 | const char *afi_str, const char *safi_str) | |
9401 | { | |
9402 | struct bgp *bgp; | |
9403 | afi_t afi; | |
9404 | safi_t safi; | |
9405 | ||
9406 | if (name) | |
9407 | bgp = bgp_lookup_by_name (name); | |
9408 | else | |
9409 | bgp = bgp_get_default (); | |
9410 | ||
9411 | if (!bgp) | |
9412 | { | |
9413 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9414 | return CMD_WARNING; | |
9415 | } | |
9416 | if (strncmp (afi_str, "ipv", 3) == 0) | |
9417 | { | |
9418 | if (strncmp (afi_str, "ipv4", 4) == 0) | |
9419 | afi = AFI_IP; | |
9420 | else if (strncmp (afi_str, "ipv6", 4) == 0) | |
9421 | afi = AFI_IP6; | |
9422 | else | |
9423 | { | |
9424 | vty_out (vty, "%% Invalid address family %s%s", | |
9425 | afi_str, VTY_NEWLINE); | |
9426 | return CMD_WARNING; | |
9427 | } | |
9428 | if (strncmp (safi_str, "m", 1) == 0) | |
9429 | safi = SAFI_MULTICAST; | |
9430 | else if (strncmp (safi_str, "u", 1) == 0) | |
9431 | safi = SAFI_UNICAST; | |
9432 | else if (strncmp (safi_str, "vpnv4", 5) == 0) | |
9433 | safi = BGP_SAFI_VPNV4; | |
9434 | else if (strncmp (safi_str, "vpnv6", 6) == 0) | |
9435 | safi = BGP_SAFI_VPNV6; | |
9436 | else | |
9437 | { | |
9438 | vty_out (vty, "%% Invalid subsequent address family %s%s", | |
9439 | safi_str, VTY_NEWLINE); | |
9440 | return CMD_WARNING; | |
9441 | } | |
9442 | } | |
9443 | else | |
9444 | { | |
9445 | vty_out (vty, "%% Invalid address family %s%s", | |
9446 | afi_str, VTY_NEWLINE); | |
9447 | return CMD_WARNING; | |
9448 | } | |
9449 | ||
9450 | if ((afi == AFI_IP && safi == BGP_SAFI_VPNV6) | |
9451 | || (afi == AFI_IP6 && safi == BGP_SAFI_VPNV4)) | |
9452 | { | |
9453 | vty_out (vty, "%% Invalid subsequent address family %s for %s%s", | |
9454 | afi_str, safi_str, VTY_NEWLINE); | |
9455 | return CMD_WARNING; | |
9456 | } | |
9457 | return bgp_table_stats (vty, bgp, afi, safi); | |
9458 | } | |
9459 | ||
9460 | DEFUN (show_bgp_statistics, | |
9461 | show_bgp_statistics_cmd, | |
9462 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", | |
9463 | SHOW_STR | |
9464 | BGP_STR | |
9465 | "Address family\n" | |
9466 | "Address family\n" | |
9467 | "Address Family modifier\n" | |
9468 | "Address Family modifier\n" | |
9469 | "BGP RIB advertisement statistics\n") | |
9470 | { | |
9471 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9472 | } | |
9473 | ||
9474 | ALIAS (show_bgp_statistics, | |
9475 | show_bgp_statistics_vpnv4_cmd, | |
9476 | "show bgp (ipv4) (vpnv4) statistics", | |
9477 | SHOW_STR | |
9478 | BGP_STR | |
9479 | "Address family\n" | |
9480 | "Address Family modifier\n" | |
9481 | "BGP RIB advertisement statistics\n") | |
9482 | ||
9483 | DEFUN (show_bgp_statistics_view, | |
9484 | show_bgp_statistics_view_cmd, | |
9485 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", | |
9486 | SHOW_STR | |
9487 | BGP_STR | |
9488 | "BGP view\n" | |
9489 | "Address family\n" | |
9490 | "Address family\n" | |
9491 | "Address Family modifier\n" | |
9492 | "Address Family modifier\n" | |
9493 | "BGP RIB advertisement statistics\n") | |
9494 | { | |
9495 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9496 | } | |
9497 | ||
9498 | ALIAS (show_bgp_statistics_view, | |
9499 | show_bgp_statistics_view_vpnv4_cmd, | |
9500 | "show bgp view WORD (ipv4) (vpnv4) statistics", | |
9501 | SHOW_STR | |
9502 | BGP_STR | |
9503 | "BGP view\n" | |
9504 | "Address family\n" | |
9505 | "Address Family modifier\n" | |
9506 | "BGP RIB advertisement statistics\n") | |
9507 | \f | |
ff7924f6 PJ |
9508 | enum bgp_pcounts |
9509 | { | |
9510 | PCOUNT_ADJ_IN = 0, | |
9511 | PCOUNT_DAMPED, | |
9512 | PCOUNT_REMOVED, | |
9513 | PCOUNT_HISTORY, | |
9514 | PCOUNT_STALE, | |
9515 | PCOUNT_VALID, | |
9516 | PCOUNT_ALL, | |
9517 | PCOUNT_COUNTED, | |
9518 | PCOUNT_PFCNT, /* the figure we display to users */ | |
9519 | PCOUNT_MAX, | |
9520 | }; | |
9521 | ||
9522 | static const char *pcount_strs[] = | |
9523 | { | |
9524 | [PCOUNT_ADJ_IN] = "Adj-in", | |
9525 | [PCOUNT_DAMPED] = "Damped", | |
9526 | [PCOUNT_REMOVED] = "Removed", | |
9527 | [PCOUNT_HISTORY] = "History", | |
9528 | [PCOUNT_STALE] = "Stale", | |
9529 | [PCOUNT_VALID] = "Valid", | |
9530 | [PCOUNT_ALL] = "All RIB", | |
9531 | [PCOUNT_COUNTED] = "PfxCt counted", | |
9532 | [PCOUNT_PFCNT] = "Useable", | |
9533 | [PCOUNT_MAX] = NULL, | |
9534 | }; | |
9535 | ||
2815e61f PJ |
9536 | struct peer_pcounts |
9537 | { | |
9538 | unsigned int count[PCOUNT_MAX]; | |
9539 | const struct peer *peer; | |
9540 | const struct bgp_table *table; | |
9541 | }; | |
9542 | ||
ff7924f6 | 9543 | static int |
2815e61f | 9544 | bgp_peer_count_walker (struct thread *t) |
ff7924f6 PJ |
9545 | { |
9546 | struct bgp_node *rn; | |
2815e61f PJ |
9547 | struct peer_pcounts *pc = THREAD_ARG (t); |
9548 | const struct peer *peer = pc->peer; | |
ff7924f6 | 9549 | |
2815e61f | 9550 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
ff7924f6 PJ |
9551 | { |
9552 | struct bgp_adj_in *ain; | |
2815e61f | 9553 | struct bgp_info *ri; |
ff7924f6 PJ |
9554 | |
9555 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9556 | if (ain->peer == peer) | |
2815e61f | 9557 | pc->count[PCOUNT_ADJ_IN]++; |
ff7924f6 | 9558 | |
ff7924f6 PJ |
9559 | for (ri = rn->info; ri; ri = ri->next) |
9560 | { | |
9561 | char buf[SU_ADDRSTRLEN]; | |
9562 | ||
9563 | if (ri->peer != peer) | |
9564 | continue; | |
9565 | ||
2815e61f | 9566 | pc->count[PCOUNT_ALL]++; |
ff7924f6 PJ |
9567 | |
9568 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) | |
2815e61f | 9569 | pc->count[PCOUNT_DAMPED]++; |
ff7924f6 | 9570 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2815e61f | 9571 | pc->count[PCOUNT_HISTORY]++; |
ff7924f6 | 9572 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
2815e61f | 9573 | pc->count[PCOUNT_REMOVED]++; |
ff7924f6 | 9574 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
2815e61f | 9575 | pc->count[PCOUNT_STALE]++; |
ff7924f6 | 9576 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
2815e61f | 9577 | pc->count[PCOUNT_VALID]++; |
1a392d46 | 9578 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2815e61f | 9579 | pc->count[PCOUNT_PFCNT]++; |
ff7924f6 PJ |
9580 | |
9581 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
9582 | { | |
2815e61f | 9583 | pc->count[PCOUNT_COUNTED]++; |
1a392d46 | 9584 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9585 | plog_warn (peer->log, |
9586 | "%s [pcount] %s/%d is counted but flags 0x%x", | |
9587 | peer->host, | |
9588 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9589 | buf, SU_ADDRSTRLEN), | |
9590 | rn->p.prefixlen, | |
9591 | ri->flags); | |
9592 | } | |
9593 | else | |
9594 | { | |
1a392d46 | 9595 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9596 | plog_warn (peer->log, |
9597 | "%s [pcount] %s/%d not counted but flags 0x%x", | |
9598 | peer->host, | |
9599 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9600 | buf, SU_ADDRSTRLEN), | |
9601 | rn->p.prefixlen, | |
9602 | ri->flags); | |
9603 | } | |
9604 | } | |
9605 | } | |
2815e61f PJ |
9606 | return 0; |
9607 | } | |
ff7924f6 | 9608 | |
2815e61f PJ |
9609 | static int |
9610 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) | |
9611 | { | |
9612 | struct peer_pcounts pcounts = { .peer = peer }; | |
9613 | unsigned int i; | |
9614 | ||
9615 | if (!peer || !peer->bgp || !peer->afc[afi][safi] | |
9616 | || !peer->bgp->rib[afi][safi]) | |
9617 | { | |
9618 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9619 | return CMD_WARNING; | |
9620 | } | |
9621 | ||
9622 | memset (&pcounts, 0, sizeof(pcounts)); | |
9623 | pcounts.peer = peer; | |
9624 | pcounts.table = peer->bgp->rib[afi][safi]; | |
9625 | ||
9626 | /* in-place call via thread subsystem so as to record execution time | |
9627 | * stats for the thread-walk (i.e. ensure this can't be blamed on | |
9628 | * on just vty_read()). | |
9629 | */ | |
9630 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); | |
9631 | ||
ff7924f6 PJ |
9632 | vty_out (vty, "Prefix counts for %s, %s%s", |
9633 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); | |
9634 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); | |
9635 | vty_out (vty, "%sCounts from RIB table walk:%s%s", | |
9636 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
9637 | ||
9638 | for (i = 0; i < PCOUNT_MAX; i++) | |
2815e61f PJ |
9639 | vty_out (vty, "%20s: %-10d%s", |
9640 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); | |
ff7924f6 | 9641 | |
2815e61f | 9642 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
ff7924f6 PJ |
9643 | { |
9644 | vty_out (vty, "%s [pcount] PfxCt drift!%s", | |
9645 | peer->host, VTY_NEWLINE); | |
9646 | vty_out (vty, "Please report this bug, with the above command output%s", | |
9647 | VTY_NEWLINE); | |
9648 | } | |
9649 | ||
9650 | return CMD_SUCCESS; | |
9651 | } | |
9652 | ||
9653 | DEFUN (show_ip_bgp_neighbor_prefix_counts, | |
9654 | show_ip_bgp_neighbor_prefix_counts_cmd, | |
9655 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9656 | SHOW_STR | |
9657 | IP_STR | |
9658 | BGP_STR | |
9659 | "Detailed information on TCP and BGP neighbor connections\n" | |
9660 | "Neighbor to display information about\n" | |
9661 | "Neighbor to display information about\n" | |
9662 | "Display detailed prefix count information\n") | |
9663 | { | |
9664 | struct peer *peer; | |
9665 | ||
9666 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9667 | if (! peer) | |
9668 | return CMD_WARNING; | |
9669 | ||
9670 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9671 | } | |
9672 | ||
9673 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, | |
9674 | show_bgp_ipv6_neighbor_prefix_counts_cmd, | |
9675 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9676 | SHOW_STR | |
9677 | BGP_STR | |
9678 | "Address family\n" | |
9679 | "Detailed information on TCP and BGP neighbor connections\n" | |
9680 | "Neighbor to display information about\n" | |
9681 | "Neighbor to display information about\n" | |
9682 | "Display detailed prefix count information\n") | |
9683 | { | |
9684 | struct peer *peer; | |
9685 | ||
9686 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9687 | if (! peer) | |
9688 | return CMD_WARNING; | |
9689 | ||
9690 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); | |
9691 | } | |
9692 | ||
9693 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, | |
9694 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, | |
9695 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9696 | SHOW_STR | |
9697 | IP_STR | |
9698 | BGP_STR | |
9699 | "Address family\n" | |
9700 | "Address Family modifier\n" | |
9701 | "Address Family modifier\n" | |
9702 | "Detailed information on TCP and BGP neighbor connections\n" | |
9703 | "Neighbor to display information about\n" | |
9704 | "Neighbor to display information about\n" | |
9705 | "Display detailed prefix count information\n") | |
9706 | { | |
9707 | struct peer *peer; | |
9708 | ||
9709 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9710 | if (! peer) | |
9711 | return CMD_WARNING; | |
9712 | ||
9713 | if (strncmp (argv[0], "m", 1) == 0) | |
9714 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); | |
9715 | ||
9716 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9717 | } | |
9718 | ||
9719 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, | |
9720 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, | |
9721 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9722 | SHOW_STR | |
9723 | IP_STR | |
9724 | BGP_STR | |
9725 | "Address family\n" | |
9726 | "Address Family modifier\n" | |
9727 | "Address Family modifier\n" | |
9728 | "Detailed information on TCP and BGP neighbor connections\n" | |
9729 | "Neighbor to display information about\n" | |
9730 | "Neighbor to display information about\n" | |
9731 | "Display detailed prefix count information\n") | |
9732 | { | |
9733 | struct peer *peer; | |
9734 | ||
9735 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9736 | if (! peer) | |
9737 | return CMD_WARNING; | |
9738 | ||
9739 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); | |
9740 | } | |
9741 | ||
9742 | ||
94f2b392 | 9743 | static void |
718e3744 | 9744 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
9745 | int in) | |
9746 | { | |
9747 | struct bgp_table *table; | |
9748 | struct bgp_adj_in *ain; | |
9749 | struct bgp_adj_out *adj; | |
9750 | unsigned long output_count; | |
9751 | struct bgp_node *rn; | |
9752 | int header1 = 1; | |
9753 | struct bgp *bgp; | |
9754 | int header2 = 1; | |
9755 | ||
bb46e94f | 9756 | bgp = peer->bgp; |
718e3744 | 9757 | |
9758 | if (! bgp) | |
9759 | return; | |
9760 | ||
9761 | table = bgp->rib[afi][safi]; | |
9762 | ||
9763 | output_count = 0; | |
9764 | ||
9765 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], | |
9766 | PEER_STATUS_DEFAULT_ORIGINATE)) | |
9767 | { | |
9768 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9769 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9770 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9771 | |
9772 | vty_out (vty, "Originating default network 0.0.0.0%s%s", | |
9773 | VTY_NEWLINE, VTY_NEWLINE); | |
9774 | header1 = 0; | |
9775 | } | |
9776 | ||
9777 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
9778 | if (in) | |
9779 | { | |
9780 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9781 | if (ain->peer == peer) | |
9782 | { | |
9783 | if (header1) | |
9784 | { | |
9785 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9786 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9787 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9788 | header1 = 0; |
9789 | } | |
9790 | if (header2) | |
9791 | { | |
9792 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9793 | header2 = 0; | |
9794 | } | |
9795 | if (ain->attr) | |
9796 | { | |
9797 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); | |
9798 | output_count++; | |
9799 | } | |
9800 | } | |
9801 | } | |
9802 | else | |
9803 | { | |
9804 | for (adj = rn->adj_out; adj; adj = adj->next) | |
9805 | if (adj->peer == peer) | |
9806 | { | |
9807 | if (header1) | |
9808 | { | |
9809 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9810 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9811 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9812 | header1 = 0; |
9813 | } | |
9814 | if (header2) | |
9815 | { | |
9816 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9817 | header2 = 0; | |
9818 | } | |
9819 | if (adj->attr) | |
9820 | { | |
9821 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); | |
9822 | output_count++; | |
9823 | } | |
9824 | } | |
9825 | } | |
9826 | ||
9827 | if (output_count != 0) | |
9828 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
9829 | VTY_NEWLINE, output_count, VTY_NEWLINE); | |
9830 | } | |
9831 | ||
94f2b392 | 9832 | static int |
bb46e94f | 9833 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
9834 | { | |
718e3744 | 9835 | if (! peer || ! peer->afc[afi][safi]) |
9836 | { | |
9837 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9838 | return CMD_WARNING; | |
9839 | } | |
9840 | ||
9841 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9842 | { | |
9843 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", | |
9844 | VTY_NEWLINE); | |
9845 | return CMD_WARNING; | |
9846 | } | |
9847 | ||
9848 | show_adj_route (vty, peer, afi, safi, in); | |
9849 | ||
9850 | return CMD_SUCCESS; | |
9851 | } | |
9852 | ||
2a71e9ce TP |
9853 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
9854 | show_ip_bgp_view_neighbor_advertised_route_cmd, | |
9855 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9856 | SHOW_STR |
9857 | IP_STR | |
9858 | BGP_STR | |
2a71e9ce TP |
9859 | "BGP view\n" |
9860 | "View name\n" | |
718e3744 | 9861 | "Detailed information on TCP and BGP neighbor connections\n" |
9862 | "Neighbor to display information about\n" | |
9863 | "Neighbor to display information about\n" | |
9864 | "Display the routes advertised to a BGP neighbor\n") | |
9865 | { | |
bb46e94f | 9866 | struct peer *peer; |
9867 | ||
2a71e9ce TP |
9868 | if (argc == 2) |
9869 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9870 | else | |
9871 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9872 | ||
bb46e94f | 9873 | if (! peer) |
9874 | return CMD_WARNING; | |
9875 | ||
9876 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); | |
718e3744 | 9877 | } |
9878 | ||
2a71e9ce TP |
9879 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
9880 | show_ip_bgp_neighbor_advertised_route_cmd, | |
9881 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9882 | SHOW_STR | |
9883 | IP_STR | |
9884 | BGP_STR | |
9885 | "Detailed information on TCP and BGP neighbor connections\n" | |
9886 | "Neighbor to display information about\n" | |
9887 | "Neighbor to display information about\n" | |
9888 | "Display the routes advertised to a BGP neighbor\n") | |
9889 | ||
718e3744 | 9890 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
9891 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, | |
9892 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9893 | SHOW_STR | |
9894 | IP_STR | |
9895 | BGP_STR | |
9896 | "Address family\n" | |
9897 | "Address Family modifier\n" | |
9898 | "Address Family modifier\n" | |
9899 | "Detailed information on TCP and BGP neighbor connections\n" | |
9900 | "Neighbor to display information about\n" | |
9901 | "Neighbor to display information about\n" | |
9902 | "Display the routes advertised to a BGP neighbor\n") | |
9903 | { | |
bb46e94f | 9904 | struct peer *peer; |
9905 | ||
9906 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9907 | if (! peer) | |
9908 | return CMD_WARNING; | |
9909 | ||
718e3744 | 9910 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 9911 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
718e3744 | 9912 | |
bb46e94f | 9913 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
718e3744 | 9914 | } |
9915 | ||
9916 | #ifdef HAVE_IPV6 | |
bb46e94f | 9917 | DEFUN (show_bgp_view_neighbor_advertised_route, |
9918 | show_bgp_view_neighbor_advertised_route_cmd, | |
9919 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9920 | SHOW_STR |
9921 | BGP_STR | |
bb46e94f | 9922 | "BGP view\n" |
9923 | "View name\n" | |
718e3744 | 9924 | "Detailed information on TCP and BGP neighbor connections\n" |
9925 | "Neighbor to display information about\n" | |
9926 | "Neighbor to display information about\n" | |
9927 | "Display the routes advertised to a BGP neighbor\n") | |
9928 | { | |
bb46e94f | 9929 | struct peer *peer; |
9930 | ||
9931 | if (argc == 2) | |
9932 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9933 | else | |
9934 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9935 | ||
9936 | if (! peer) | |
9937 | return CMD_WARNING; | |
9938 | ||
9939 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); | |
9940 | } | |
9941 | ||
9942 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
9943 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, | |
9944 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9945 | SHOW_STR | |
9946 | BGP_STR | |
9947 | "BGP view\n" | |
9948 | "View name\n" | |
9949 | "Address family\n" | |
9950 | "Detailed information on TCP and BGP neighbor connections\n" | |
9951 | "Neighbor to display information about\n" | |
9952 | "Neighbor to display information about\n" | |
9953 | "Display the routes advertised to a BGP neighbor\n") | |
9954 | ||
9955 | DEFUN (show_bgp_view_neighbor_received_routes, | |
9956 | show_bgp_view_neighbor_received_routes_cmd, | |
9957 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9958 | SHOW_STR | |
9959 | BGP_STR | |
9960 | "BGP view\n" | |
9961 | "View name\n" | |
9962 | "Detailed information on TCP and BGP neighbor connections\n" | |
9963 | "Neighbor to display information about\n" | |
9964 | "Neighbor to display information about\n" | |
9965 | "Display the received routes from neighbor\n") | |
9966 | { | |
9967 | struct peer *peer; | |
9968 | ||
9969 | if (argc == 2) | |
9970 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9971 | else | |
9972 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9973 | ||
9974 | if (! peer) | |
9975 | return CMD_WARNING; | |
9976 | ||
9977 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); | |
718e3744 | 9978 | } |
9979 | ||
bb46e94f | 9980 | ALIAS (show_bgp_view_neighbor_received_routes, |
9981 | show_bgp_view_ipv6_neighbor_received_routes_cmd, | |
9982 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9983 | SHOW_STR | |
9984 | BGP_STR | |
9985 | "BGP view\n" | |
9986 | "View name\n" | |
9987 | "Address family\n" | |
9988 | "Detailed information on TCP and BGP neighbor connections\n" | |
9989 | "Neighbor to display information about\n" | |
9990 | "Neighbor to display information about\n" | |
9991 | "Display the received routes from neighbor\n") | |
9992 | ||
9993 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
9994 | show_bgp_neighbor_advertised_route_cmd, | |
9995 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9996 | SHOW_STR | |
9997 | BGP_STR | |
9998 | "Detailed information on TCP and BGP neighbor connections\n" | |
9999 | "Neighbor to display information about\n" | |
10000 | "Neighbor to display information about\n" | |
10001 | "Display the routes advertised to a BGP neighbor\n") | |
10002 | ||
10003 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
718e3744 | 10004 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
10005 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
10006 | SHOW_STR | |
10007 | BGP_STR | |
10008 | "Address family\n" | |
10009 | "Detailed information on TCP and BGP neighbor connections\n" | |
10010 | "Neighbor to display information about\n" | |
10011 | "Neighbor to display information about\n" | |
10012 | "Display the routes advertised to a BGP neighbor\n") | |
10013 | ||
10014 | /* old command */ | |
bb46e94f | 10015 | ALIAS (show_bgp_view_neighbor_advertised_route, |
718e3744 | 10016 | ipv6_bgp_neighbor_advertised_route_cmd, |
10017 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
10018 | SHOW_STR | |
10019 | IPV6_STR | |
10020 | BGP_STR | |
10021 | "Detailed information on TCP and BGP neighbor connections\n" | |
10022 | "Neighbor to display information about\n" | |
10023 | "Neighbor to display information about\n" | |
10024 | "Display the routes advertised to a BGP neighbor\n") | |
bb46e94f | 10025 | |
718e3744 | 10026 | /* old command */ |
10027 | DEFUN (ipv6_mbgp_neighbor_advertised_route, | |
10028 | ipv6_mbgp_neighbor_advertised_route_cmd, | |
10029 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
10030 | SHOW_STR | |
10031 | IPV6_STR | |
10032 | MBGP_STR | |
10033 | "Detailed information on TCP and BGP neighbor connections\n" | |
10034 | "Neighbor to display information about\n" | |
10035 | "Neighbor to display information about\n" | |
10036 | "Display the routes advertised to a BGP neighbor\n") | |
10037 | { | |
bb46e94f | 10038 | struct peer *peer; |
10039 | ||
10040 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10041 | if (! peer) | |
10042 | return CMD_WARNING; | |
10043 | ||
10044 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); | |
718e3744 | 10045 | } |
10046 | #endif /* HAVE_IPV6 */ | |
10047 | \f | |
2a71e9ce TP |
10048 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
10049 | show_ip_bgp_view_neighbor_received_routes_cmd, | |
10050 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
718e3744 | 10051 | SHOW_STR |
10052 | IP_STR | |
10053 | BGP_STR | |
2a71e9ce TP |
10054 | "BGP view\n" |
10055 | "View name\n" | |
718e3744 | 10056 | "Detailed information on TCP and BGP neighbor connections\n" |
10057 | "Neighbor to display information about\n" | |
10058 | "Neighbor to display information about\n" | |
10059 | "Display the received routes from neighbor\n") | |
10060 | { | |
bb46e94f | 10061 | struct peer *peer; |
10062 | ||
2a71e9ce TP |
10063 | if (argc == 2) |
10064 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10065 | else | |
10066 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10067 | ||
bb46e94f | 10068 | if (! peer) |
10069 | return CMD_WARNING; | |
10070 | ||
10071 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); | |
718e3744 | 10072 | } |
10073 | ||
2a71e9ce TP |
10074 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
10075 | show_ip_bgp_neighbor_received_routes_cmd, | |
10076 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10077 | SHOW_STR | |
10078 | IP_STR | |
10079 | BGP_STR | |
10080 | "Detailed information on TCP and BGP neighbor connections\n" | |
10081 | "Neighbor to display information about\n" | |
10082 | "Neighbor to display information about\n" | |
10083 | "Display the received routes from neighbor\n") | |
10084 | ||
718e3744 | 10085 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
10086 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, | |
10087 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10088 | SHOW_STR | |
10089 | IP_STR | |
10090 | BGP_STR | |
10091 | "Address family\n" | |
10092 | "Address Family modifier\n" | |
10093 | "Address Family modifier\n" | |
10094 | "Detailed information on TCP and BGP neighbor connections\n" | |
10095 | "Neighbor to display information about\n" | |
10096 | "Neighbor to display information about\n" | |
10097 | "Display the received routes from neighbor\n") | |
10098 | { | |
bb46e94f | 10099 | struct peer *peer; |
10100 | ||
10101 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10102 | if (! peer) | |
10103 | return CMD_WARNING; | |
10104 | ||
718e3744 | 10105 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 10106 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
718e3744 | 10107 | |
bb46e94f | 10108 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
718e3744 | 10109 | } |
10110 | ||
95cbbd2a ML |
10111 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
10112 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, | |
10113 | #ifdef HAVE_IPV6 | |
10114 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", | |
10115 | #else | |
10116 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", | |
10117 | #endif | |
10118 | SHOW_STR | |
10119 | BGP_STR | |
10120 | "BGP view\n" | |
10121 | "BGP view name\n" | |
10122 | "Address family\n" | |
10123 | #ifdef HAVE_IPV6 | |
10124 | "Address family\n" | |
10125 | #endif | |
10126 | "Address family modifier\n" | |
10127 | "Address family modifier\n" | |
10128 | "Detailed information on TCP and BGP neighbor connections\n" | |
10129 | "Neighbor to display information about\n" | |
10130 | "Neighbor to display information about\n" | |
10131 | "Display the advertised routes to neighbor\n" | |
10132 | "Display the received routes from neighbor\n") | |
10133 | { | |
10134 | int afi; | |
10135 | int safi; | |
10136 | int in; | |
10137 | struct peer *peer; | |
10138 | ||
10139 | #ifdef HAVE_IPV6 | |
10140 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); | |
10141 | #else | |
10142 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10143 | #endif | |
10144 | ||
10145 | if (! peer) | |
10146 | return CMD_WARNING; | |
10147 | ||
10148 | #ifdef HAVE_IPV6 | |
10149 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; | |
10150 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10151 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; | |
10152 | #else | |
10153 | afi = AFI_IP; | |
10154 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10155 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; | |
10156 | #endif | |
10157 | ||
10158 | return peer_adj_routes (vty, peer, afi, safi, in); | |
10159 | } | |
10160 | ||
718e3744 | 10161 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
10162 | show_ip_bgp_neighbor_received_prefix_filter_cmd, | |
10163 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10164 | SHOW_STR | |
10165 | IP_STR | |
10166 | BGP_STR | |
10167 | "Detailed information on TCP and BGP neighbor connections\n" | |
10168 | "Neighbor to display information about\n" | |
10169 | "Neighbor to display information about\n" | |
10170 | "Display information received from a BGP neighbor\n" | |
10171 | "Display the prefixlist filter\n") | |
10172 | { | |
10173 | char name[BUFSIZ]; | |
10174 | union sockunion *su; | |
10175 | struct peer *peer; | |
10176 | int count; | |
10177 | ||
10178 | su = sockunion_str2su (argv[0]); | |
10179 | if (su == NULL) | |
10180 | return CMD_WARNING; | |
10181 | ||
10182 | peer = peer_lookup (NULL, su); | |
10183 | if (! peer) | |
10184 | return CMD_WARNING; | |
10185 | ||
10186 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
10187 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10188 | if (count) | |
10189 | { | |
10190 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
10191 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10192 | } | |
10193 | ||
10194 | return CMD_SUCCESS; | |
10195 | } | |
10196 | ||
10197 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, | |
10198 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, | |
10199 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10200 | SHOW_STR | |
10201 | IP_STR | |
10202 | BGP_STR | |
10203 | "Address family\n" | |
10204 | "Address Family modifier\n" | |
10205 | "Address Family modifier\n" | |
10206 | "Detailed information on TCP and BGP neighbor connections\n" | |
10207 | "Neighbor to display information about\n" | |
10208 | "Neighbor to display information about\n" | |
10209 | "Display information received from a BGP neighbor\n" | |
10210 | "Display the prefixlist filter\n") | |
10211 | { | |
10212 | char name[BUFSIZ]; | |
10213 | union sockunion *su; | |
10214 | struct peer *peer; | |
10215 | int count; | |
10216 | ||
10217 | su = sockunion_str2su (argv[1]); | |
10218 | if (su == NULL) | |
10219 | return CMD_WARNING; | |
10220 | ||
10221 | peer = peer_lookup (NULL, su); | |
10222 | if (! peer) | |
10223 | return CMD_WARNING; | |
10224 | ||
10225 | if (strncmp (argv[0], "m", 1) == 0) | |
10226 | { | |
10227 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); | |
10228 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10229 | if (count) | |
10230 | { | |
10231 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); | |
10232 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10233 | } | |
10234 | } | |
10235 | else | |
10236 | { | |
10237 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
10238 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10239 | if (count) | |
10240 | { | |
10241 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
10242 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10243 | } | |
10244 | } | |
10245 | ||
10246 | return CMD_SUCCESS; | |
10247 | } | |
10248 | ||
10249 | ||
10250 | #ifdef HAVE_IPV6 | |
bb46e94f | 10251 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10252 | show_bgp_neighbor_received_routes_cmd, |
10253 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10254 | SHOW_STR | |
10255 | BGP_STR | |
10256 | "Detailed information on TCP and BGP neighbor connections\n" | |
10257 | "Neighbor to display information about\n" | |
10258 | "Neighbor to display information about\n" | |
10259 | "Display the received routes from neighbor\n") | |
718e3744 | 10260 | |
bb46e94f | 10261 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10262 | show_bgp_ipv6_neighbor_received_routes_cmd, |
10263 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10264 | SHOW_STR | |
10265 | BGP_STR | |
10266 | "Address family\n" | |
10267 | "Detailed information on TCP and BGP neighbor connections\n" | |
10268 | "Neighbor to display information about\n" | |
10269 | "Neighbor to display information about\n" | |
10270 | "Display the received routes from neighbor\n") | |
10271 | ||
10272 | DEFUN (show_bgp_neighbor_received_prefix_filter, | |
10273 | show_bgp_neighbor_received_prefix_filter_cmd, | |
10274 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10275 | SHOW_STR | |
10276 | BGP_STR | |
10277 | "Detailed information on TCP and BGP neighbor connections\n" | |
10278 | "Neighbor to display information about\n" | |
10279 | "Neighbor to display information about\n" | |
10280 | "Display information received from a BGP neighbor\n" | |
10281 | "Display the prefixlist filter\n") | |
10282 | { | |
10283 | char name[BUFSIZ]; | |
10284 | union sockunion *su; | |
10285 | struct peer *peer; | |
10286 | int count; | |
10287 | ||
10288 | su = sockunion_str2su (argv[0]); | |
10289 | if (su == NULL) | |
10290 | return CMD_WARNING; | |
10291 | ||
10292 | peer = peer_lookup (NULL, su); | |
10293 | if (! peer) | |
10294 | return CMD_WARNING; | |
10295 | ||
10296 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10297 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10298 | if (count) | |
10299 | { | |
10300 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10301 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10302 | } | |
10303 | ||
10304 | return CMD_SUCCESS; | |
10305 | } | |
10306 | ||
10307 | ALIAS (show_bgp_neighbor_received_prefix_filter, | |
10308 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, | |
10309 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10310 | SHOW_STR | |
10311 | BGP_STR | |
10312 | "Address family\n" | |
10313 | "Detailed information on TCP and BGP neighbor connections\n" | |
10314 | "Neighbor to display information about\n" | |
10315 | "Neighbor to display information about\n" | |
10316 | "Display information received from a BGP neighbor\n" | |
10317 | "Display the prefixlist filter\n") | |
10318 | ||
10319 | /* old command */ | |
bb46e94f | 10320 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10321 | ipv6_bgp_neighbor_received_routes_cmd, |
10322 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10323 | SHOW_STR | |
10324 | IPV6_STR | |
10325 | BGP_STR | |
10326 | "Detailed information on TCP and BGP neighbor connections\n" | |
10327 | "Neighbor to display information about\n" | |
10328 | "Neighbor to display information about\n" | |
10329 | "Display the received routes from neighbor\n") | |
718e3744 | 10330 | |
10331 | /* old command */ | |
10332 | DEFUN (ipv6_mbgp_neighbor_received_routes, | |
10333 | ipv6_mbgp_neighbor_received_routes_cmd, | |
10334 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10335 | SHOW_STR | |
10336 | IPV6_STR | |
10337 | MBGP_STR | |
10338 | "Detailed information on TCP and BGP neighbor connections\n" | |
10339 | "Neighbor to display information about\n" | |
10340 | "Neighbor to display information about\n" | |
10341 | "Display the received routes from neighbor\n") | |
10342 | { | |
bb46e94f | 10343 | struct peer *peer; |
10344 | ||
10345 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10346 | if (! peer) | |
10347 | return CMD_WARNING; | |
10348 | ||
10349 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); | |
10350 | } | |
10351 | ||
10352 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, | |
10353 | show_bgp_view_neighbor_received_prefix_filter_cmd, | |
10354 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10355 | SHOW_STR | |
10356 | BGP_STR | |
10357 | "BGP view\n" | |
10358 | "View name\n" | |
10359 | "Detailed information on TCP and BGP neighbor connections\n" | |
10360 | "Neighbor to display information about\n" | |
10361 | "Neighbor to display information about\n" | |
10362 | "Display information received from a BGP neighbor\n" | |
10363 | "Display the prefixlist filter\n") | |
10364 | { | |
10365 | char name[BUFSIZ]; | |
10366 | union sockunion *su; | |
10367 | struct peer *peer; | |
10368 | struct bgp *bgp; | |
10369 | int count; | |
10370 | ||
10371 | /* BGP structure lookup. */ | |
10372 | bgp = bgp_lookup_by_name (argv[0]); | |
10373 | if (bgp == NULL) | |
10374 | { | |
10375 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10376 | return CMD_WARNING; | |
10377 | } | |
10378 | ||
10379 | su = sockunion_str2su (argv[1]); | |
10380 | if (su == NULL) | |
10381 | return CMD_WARNING; | |
10382 | ||
10383 | peer = peer_lookup (bgp, su); | |
10384 | if (! peer) | |
10385 | return CMD_WARNING; | |
10386 | ||
10387 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10388 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10389 | if (count) | |
10390 | { | |
10391 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10392 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10393 | } | |
10394 | ||
10395 | return CMD_SUCCESS; | |
718e3744 | 10396 | } |
bb46e94f | 10397 | |
10398 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, | |
10399 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, | |
10400 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10401 | SHOW_STR | |
10402 | BGP_STR | |
10403 | "BGP view\n" | |
10404 | "View name\n" | |
10405 | "Address family\n" | |
10406 | "Detailed information on TCP and BGP neighbor connections\n" | |
10407 | "Neighbor to display information about\n" | |
10408 | "Neighbor to display information about\n" | |
10409 | "Display information received from a BGP neighbor\n" | |
10410 | "Display the prefixlist filter\n") | |
718e3744 | 10411 | #endif /* HAVE_IPV6 */ |
10412 | \f | |
94f2b392 | 10413 | static int |
bb46e94f | 10414 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
718e3744 | 10415 | safi_t safi, enum bgp_show_type type) |
10416 | { | |
718e3744 | 10417 | if (! peer || ! peer->afc[afi][safi]) |
10418 | { | |
10419 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
718e3744 | 10420 | return CMD_WARNING; |
10421 | } | |
10422 | ||
5a646650 | 10423 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
718e3744 | 10424 | } |
10425 | ||
10426 | DEFUN (show_ip_bgp_neighbor_routes, | |
10427 | show_ip_bgp_neighbor_routes_cmd, | |
10428 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10429 | SHOW_STR | |
10430 | IP_STR | |
10431 | BGP_STR | |
10432 | "Detailed information on TCP and BGP neighbor connections\n" | |
10433 | "Neighbor to display information about\n" | |
10434 | "Neighbor to display information about\n" | |
10435 | "Display routes learned from neighbor\n") | |
10436 | { | |
bb46e94f | 10437 | struct peer *peer; |
10438 | ||
10439 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10440 | if (! peer) | |
10441 | return CMD_WARNING; | |
10442 | ||
10443 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10444 | bgp_show_type_neighbor); |
10445 | } | |
10446 | ||
10447 | DEFUN (show_ip_bgp_neighbor_flap, | |
10448 | show_ip_bgp_neighbor_flap_cmd, | |
10449 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10450 | SHOW_STR | |
10451 | IP_STR | |
10452 | BGP_STR | |
10453 | "Detailed information on TCP and BGP neighbor connections\n" | |
10454 | "Neighbor to display information about\n" | |
10455 | "Neighbor to display information about\n" | |
10456 | "Display flap statistics of the routes learned from neighbor\n") | |
10457 | { | |
bb46e94f | 10458 | struct peer *peer; |
10459 | ||
10460 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10461 | if (! peer) | |
10462 | return CMD_WARNING; | |
10463 | ||
10464 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10465 | bgp_show_type_flap_neighbor); |
10466 | } | |
10467 | ||
10468 | DEFUN (show_ip_bgp_neighbor_damp, | |
10469 | show_ip_bgp_neighbor_damp_cmd, | |
10470 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10471 | SHOW_STR | |
10472 | IP_STR | |
10473 | BGP_STR | |
10474 | "Detailed information on TCP and BGP neighbor connections\n" | |
10475 | "Neighbor to display information about\n" | |
10476 | "Neighbor to display information about\n" | |
10477 | "Display the dampened routes received from neighbor\n") | |
10478 | { | |
bb46e94f | 10479 | struct peer *peer; |
10480 | ||
10481 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10482 | if (! peer) | |
10483 | return CMD_WARNING; | |
10484 | ||
10485 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10486 | bgp_show_type_damp_neighbor); |
10487 | } | |
10488 | ||
10489 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, | |
10490 | show_ip_bgp_ipv4_neighbor_routes_cmd, | |
10491 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", | |
10492 | SHOW_STR | |
10493 | IP_STR | |
10494 | BGP_STR | |
10495 | "Address family\n" | |
10496 | "Address Family modifier\n" | |
10497 | "Address Family modifier\n" | |
10498 | "Detailed information on TCP and BGP neighbor connections\n" | |
10499 | "Neighbor to display information about\n" | |
10500 | "Neighbor to display information about\n" | |
10501 | "Display routes learned from neighbor\n") | |
10502 | { | |
bb46e94f | 10503 | struct peer *peer; |
10504 | ||
10505 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10506 | if (! peer) | |
10507 | return CMD_WARNING; | |
10508 | ||
718e3744 | 10509 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 10510 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
718e3744 | 10511 | bgp_show_type_neighbor); |
10512 | ||
bb46e94f | 10513 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
718e3744 | 10514 | bgp_show_type_neighbor); |
10515 | } | |
bb46e94f | 10516 | |
fee0f4c6 | 10517 | DEFUN (show_ip_bgp_view_rsclient, |
10518 | show_ip_bgp_view_rsclient_cmd, | |
10519 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
10520 | SHOW_STR | |
10521 | IP_STR | |
10522 | BGP_STR | |
10523 | "BGP view\n" | |
10524 | "BGP view name\n" | |
10525 | "Information about Route Server Client\n" | |
10526 | NEIGHBOR_ADDR_STR) | |
10527 | { | |
10528 | struct bgp_table *table; | |
10529 | struct peer *peer; | |
10530 | ||
10531 | if (argc == 2) | |
10532 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10533 | else | |
10534 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10535 | ||
10536 | if (! peer) | |
10537 | return CMD_WARNING; | |
10538 | ||
10539 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10540 | { | |
10541 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10542 | VTY_NEWLINE); | |
10543 | return CMD_WARNING; | |
10544 | } | |
10545 | ||
10546 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10547 | PEER_FLAG_RSERVER_CLIENT)) | |
10548 | { | |
10549 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10550 | VTY_NEWLINE); | |
10551 | return CMD_WARNING; | |
10552 | } | |
10553 | ||
10554 | table = peer->rib[AFI_IP][SAFI_UNICAST]; | |
10555 | ||
5a646650 | 10556 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 10557 | } |
10558 | ||
10559 | ALIAS (show_ip_bgp_view_rsclient, | |
10560 | show_ip_bgp_rsclient_cmd, | |
10561 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", | |
10562 | SHOW_STR | |
10563 | IP_STR | |
10564 | BGP_STR | |
10565 | "Information about Route Server Client\n" | |
10566 | NEIGHBOR_ADDR_STR) | |
10567 | ||
95cbbd2a ML |
10568 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
10569 | show_bgp_view_ipv4_safi_rsclient_cmd, | |
10570 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
fee0f4c6 | 10571 | SHOW_STR |
fee0f4c6 | 10572 | BGP_STR |
10573 | "BGP view\n" | |
10574 | "BGP view name\n" | |
95cbbd2a ML |
10575 | "Address family\n" |
10576 | "Address Family modifier\n" | |
10577 | "Address Family modifier\n" | |
fee0f4c6 | 10578 | "Information about Route Server Client\n" |
95cbbd2a | 10579 | NEIGHBOR_ADDR_STR) |
fee0f4c6 | 10580 | { |
95cbbd2a | 10581 | struct bgp_table *table; |
fee0f4c6 | 10582 | struct peer *peer; |
95cbbd2a | 10583 | safi_t safi; |
fee0f4c6 | 10584 | |
95cbbd2a ML |
10585 | if (argc == 3) { |
10586 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10587 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10588 | } else { | |
10589 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10590 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10591 | } | |
10592 | ||
10593 | if (! peer) | |
10594 | return CMD_WARNING; | |
10595 | ||
10596 | if (! peer->afc[AFI_IP][safi]) | |
fee0f4c6 | 10597 | { |
95cbbd2a ML |
10598 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
10599 | VTY_NEWLINE); | |
10600 | return CMD_WARNING; | |
10601 | } | |
10602 | ||
10603 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], | |
10604 | PEER_FLAG_RSERVER_CLIENT)) | |
10605 | { | |
10606 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10607 | VTY_NEWLINE); | |
10608 | return CMD_WARNING; | |
10609 | } | |
10610 | ||
10611 | table = peer->rib[AFI_IP][safi]; | |
10612 | ||
10613 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); | |
10614 | } | |
10615 | ||
10616 | ALIAS (show_bgp_view_ipv4_safi_rsclient, | |
10617 | show_bgp_ipv4_safi_rsclient_cmd, | |
10618 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
10619 | SHOW_STR | |
10620 | BGP_STR | |
10621 | "Address family\n" | |
10622 | "Address Family modifier\n" | |
10623 | "Address Family modifier\n" | |
10624 | "Information about Route Server Client\n" | |
10625 | NEIGHBOR_ADDR_STR) | |
10626 | ||
10627 | DEFUN (show_ip_bgp_view_rsclient_route, | |
10628 | show_ip_bgp_view_rsclient_route_cmd, | |
10629 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10630 | SHOW_STR | |
10631 | IP_STR | |
10632 | BGP_STR | |
10633 | "BGP view\n" | |
10634 | "BGP view name\n" | |
10635 | "Information about Route Server Client\n" | |
10636 | NEIGHBOR_ADDR_STR | |
10637 | "Network in the BGP routing table to display\n") | |
10638 | { | |
10639 | struct bgp *bgp; | |
10640 | struct peer *peer; | |
10641 | ||
10642 | /* BGP structure lookup. */ | |
10643 | if (argc == 3) | |
10644 | { | |
10645 | bgp = bgp_lookup_by_name (argv[0]); | |
10646 | if (bgp == NULL) | |
10647 | { | |
10648 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10649 | return CMD_WARNING; | |
fee0f4c6 | 10650 | } |
10651 | } | |
10652 | else | |
10653 | { | |
10654 | bgp = bgp_get_default (); | |
10655 | if (bgp == NULL) | |
10656 | { | |
10657 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10658 | return CMD_WARNING; | |
10659 | } | |
10660 | } | |
10661 | ||
10662 | if (argc == 3) | |
10663 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10664 | else | |
10665 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10666 | ||
10667 | if (! peer) | |
10668 | return CMD_WARNING; | |
10669 | ||
10670 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10671 | { | |
10672 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10673 | VTY_NEWLINE); | |
10674 | return CMD_WARNING; | |
10675 | } | |
10676 | ||
10677 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10678 | PEER_FLAG_RSERVER_CLIENT)) | |
10679 | { | |
10680 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10681 | VTY_NEWLINE); | |
10682 | return CMD_WARNING; | |
10683 | } | |
10684 | ||
10685 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10686 | (argc == 3) ? argv[2] : argv[1], | |
10687 | AFI_IP, SAFI_UNICAST, NULL, 0); | |
10688 | } | |
10689 | ||
10690 | ALIAS (show_ip_bgp_view_rsclient_route, | |
10691 | show_ip_bgp_rsclient_route_cmd, | |
10692 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10693 | SHOW_STR | |
10694 | IP_STR | |
10695 | BGP_STR | |
10696 | "Information about Route Server Client\n" | |
10697 | NEIGHBOR_ADDR_STR | |
10698 | "Network in the BGP routing table to display\n") | |
10699 | ||
95cbbd2a ML |
10700 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
10701 | show_bgp_view_ipv4_safi_rsclient_route_cmd, | |
10702 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10703 | SHOW_STR | |
10704 | BGP_STR | |
10705 | "BGP view\n" | |
10706 | "BGP view name\n" | |
10707 | "Address family\n" | |
10708 | "Address Family modifier\n" | |
10709 | "Address Family modifier\n" | |
10710 | "Information about Route Server Client\n" | |
10711 | NEIGHBOR_ADDR_STR | |
10712 | "Network in the BGP routing table to display\n") | |
10713 | { | |
10714 | struct bgp *bgp; | |
10715 | struct peer *peer; | |
10716 | safi_t safi; | |
10717 | ||
10718 | /* BGP structure lookup. */ | |
10719 | if (argc == 4) | |
10720 | { | |
10721 | bgp = bgp_lookup_by_name (argv[0]); | |
10722 | if (bgp == NULL) | |
10723 | { | |
10724 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10725 | return CMD_WARNING; | |
10726 | } | |
10727 | } | |
10728 | else | |
10729 | { | |
10730 | bgp = bgp_get_default (); | |
10731 | if (bgp == NULL) | |
10732 | { | |
10733 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10734 | return CMD_WARNING; | |
10735 | } | |
10736 | } | |
10737 | ||
10738 | if (argc == 4) { | |
10739 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10740 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10741 | } else { | |
10742 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10743 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10744 | } | |
10745 | ||
10746 | if (! peer) | |
10747 | return CMD_WARNING; | |
10748 | ||
10749 | if (! peer->afc[AFI_IP][safi]) | |
10750 | { | |
10751 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10752 | VTY_NEWLINE); | |
10753 | return CMD_WARNING; | |
10754 | } | |
10755 | ||
10756 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], | |
10757 | PEER_FLAG_RSERVER_CLIENT)) | |
10758 | { | |
10759 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10760 | VTY_NEWLINE); | |
10761 | return CMD_WARNING; | |
10762 | } | |
10763 | ||
10764 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], | |
10765 | (argc == 4) ? argv[3] : argv[2], | |
10766 | AFI_IP, safi, NULL, 0); | |
10767 | } | |
10768 | ||
10769 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, | |
10770 | show_bgp_ipv4_safi_rsclient_route_cmd, | |
10771 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10772 | SHOW_STR | |
10773 | BGP_STR | |
10774 | "Address family\n" | |
10775 | "Address Family modifier\n" | |
10776 | "Address Family modifier\n" | |
10777 | "Information about Route Server Client\n" | |
10778 | NEIGHBOR_ADDR_STR | |
10779 | "Network in the BGP routing table to display\n") | |
10780 | ||
fee0f4c6 | 10781 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
10782 | show_ip_bgp_view_rsclient_prefix_cmd, | |
10783 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10784 | SHOW_STR | |
10785 | IP_STR | |
10786 | BGP_STR | |
10787 | "BGP view\n" | |
10788 | "BGP view name\n" | |
10789 | "Information about Route Server Client\n" | |
10790 | NEIGHBOR_ADDR_STR | |
10791 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10792 | { | |
10793 | struct bgp *bgp; | |
10794 | struct peer *peer; | |
10795 | ||
10796 | /* BGP structure lookup. */ | |
10797 | if (argc == 3) | |
10798 | { | |
10799 | bgp = bgp_lookup_by_name (argv[0]); | |
10800 | if (bgp == NULL) | |
10801 | { | |
10802 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10803 | return CMD_WARNING; | |
10804 | } | |
10805 | } | |
10806 | else | |
10807 | { | |
10808 | bgp = bgp_get_default (); | |
10809 | if (bgp == NULL) | |
10810 | { | |
10811 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10812 | return CMD_WARNING; | |
10813 | } | |
10814 | } | |
10815 | ||
10816 | if (argc == 3) | |
10817 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10818 | else | |
10819 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10820 | ||
10821 | if (! peer) | |
10822 | return CMD_WARNING; | |
10823 | ||
10824 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10825 | { | |
10826 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10827 | VTY_NEWLINE); | |
10828 | return CMD_WARNING; | |
10829 | } | |
10830 | ||
10831 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10832 | PEER_FLAG_RSERVER_CLIENT)) | |
10833 | { | |
10834 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10835 | VTY_NEWLINE); | |
10836 | return CMD_WARNING; | |
10837 | } | |
10838 | ||
10839 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10840 | (argc == 3) ? argv[2] : argv[1], | |
10841 | AFI_IP, SAFI_UNICAST, NULL, 1); | |
10842 | } | |
10843 | ||
10844 | ALIAS (show_ip_bgp_view_rsclient_prefix, | |
10845 | show_ip_bgp_rsclient_prefix_cmd, | |
10846 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10847 | SHOW_STR | |
10848 | IP_STR | |
10849 | BGP_STR | |
10850 | "Information about Route Server Client\n" | |
10851 | NEIGHBOR_ADDR_STR | |
10852 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10853 | ||
95cbbd2a ML |
10854 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
10855 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, | |
10856 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10857 | SHOW_STR | |
10858 | BGP_STR | |
10859 | "BGP view\n" | |
10860 | "BGP view name\n" | |
10861 | "Address family\n" | |
10862 | "Address Family modifier\n" | |
10863 | "Address Family modifier\n" | |
10864 | "Information about Route Server Client\n" | |
10865 | NEIGHBOR_ADDR_STR | |
10866 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10867 | { | |
10868 | struct bgp *bgp; | |
10869 | struct peer *peer; | |
10870 | safi_t safi; | |
10871 | ||
10872 | /* BGP structure lookup. */ | |
10873 | if (argc == 4) | |
10874 | { | |
10875 | bgp = bgp_lookup_by_name (argv[0]); | |
10876 | if (bgp == NULL) | |
10877 | { | |
10878 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10879 | return CMD_WARNING; | |
10880 | } | |
10881 | } | |
10882 | else | |
10883 | { | |
10884 | bgp = bgp_get_default (); | |
10885 | if (bgp == NULL) | |
10886 | { | |
10887 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10888 | return CMD_WARNING; | |
10889 | } | |
10890 | } | |
10891 | ||
10892 | if (argc == 4) { | |
10893 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10894 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10895 | } else { | |
10896 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10897 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10898 | } | |
10899 | ||
10900 | if (! peer) | |
10901 | return CMD_WARNING; | |
10902 | ||
10903 | if (! peer->afc[AFI_IP][safi]) | |
10904 | { | |
10905 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10906 | VTY_NEWLINE); | |
10907 | return CMD_WARNING; | |
10908 | } | |
10909 | ||
10910 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], | |
10911 | PEER_FLAG_RSERVER_CLIENT)) | |
10912 | { | |
10913 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10914 | VTY_NEWLINE); | |
10915 | return CMD_WARNING; | |
10916 | } | |
10917 | ||
10918 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], | |
10919 | (argc == 4) ? argv[3] : argv[2], | |
10920 | AFI_IP, safi, NULL, 1); | |
10921 | } | |
10922 | ||
10923 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, | |
10924 | show_bgp_ipv4_safi_rsclient_prefix_cmd, | |
10925 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10926 | SHOW_STR | |
10927 | BGP_STR | |
10928 | "Address family\n" | |
10929 | "Address Family modifier\n" | |
10930 | "Address Family modifier\n" | |
10931 | "Information about Route Server Client\n" | |
10932 | NEIGHBOR_ADDR_STR | |
10933 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
fee0f4c6 | 10934 | |
718e3744 | 10935 | #ifdef HAVE_IPV6 |
bb46e94f | 10936 | DEFUN (show_bgp_view_neighbor_routes, |
10937 | show_bgp_view_neighbor_routes_cmd, | |
10938 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", | |
718e3744 | 10939 | SHOW_STR |
10940 | BGP_STR | |
bb46e94f | 10941 | "BGP view\n" |
10942 | "BGP view name\n" | |
718e3744 | 10943 | "Detailed information on TCP and BGP neighbor connections\n" |
10944 | "Neighbor to display information about\n" | |
10945 | "Neighbor to display information about\n" | |
10946 | "Display routes learned from neighbor\n") | |
10947 | { | |
bb46e94f | 10948 | struct peer *peer; |
10949 | ||
10950 | if (argc == 2) | |
10951 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10952 | else | |
10953 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10954 | ||
10955 | if (! peer) | |
10956 | return CMD_WARNING; | |
10957 | ||
10958 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
718e3744 | 10959 | bgp_show_type_neighbor); |
10960 | } | |
10961 | ||
bb46e94f | 10962 | ALIAS (show_bgp_view_neighbor_routes, |
10963 | show_bgp_view_ipv6_neighbor_routes_cmd, | |
10964 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
10965 | SHOW_STR | |
10966 | BGP_STR | |
10967 | "BGP view\n" | |
10968 | "BGP view name\n" | |
10969 | "Address family\n" | |
10970 | "Detailed information on TCP and BGP neighbor connections\n" | |
10971 | "Neighbor to display information about\n" | |
10972 | "Neighbor to display information about\n" | |
10973 | "Display routes learned from neighbor\n") | |
10974 | ||
10975 | DEFUN (show_bgp_view_neighbor_damp, | |
10976 | show_bgp_view_neighbor_damp_cmd, | |
10977 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10978 | SHOW_STR | |
10979 | BGP_STR | |
10980 | "BGP view\n" | |
10981 | "BGP view name\n" | |
10982 | "Detailed information on TCP and BGP neighbor connections\n" | |
10983 | "Neighbor to display information about\n" | |
10984 | "Neighbor to display information about\n" | |
10985 | "Display the dampened routes received from neighbor\n") | |
10986 | { | |
10987 | struct peer *peer; | |
10988 | ||
10989 | if (argc == 2) | |
10990 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10991 | else | |
10992 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10993 | ||
10994 | if (! peer) | |
10995 | return CMD_WARNING; | |
10996 | ||
10997 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
10998 | bgp_show_type_damp_neighbor); | |
10999 | } | |
11000 | ||
11001 | ALIAS (show_bgp_view_neighbor_damp, | |
11002 | show_bgp_view_ipv6_neighbor_damp_cmd, | |
11003 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
11004 | SHOW_STR | |
11005 | BGP_STR | |
11006 | "BGP view\n" | |
11007 | "BGP view name\n" | |
11008 | "Address family\n" | |
11009 | "Detailed information on TCP and BGP neighbor connections\n" | |
11010 | "Neighbor to display information about\n" | |
11011 | "Neighbor to display information about\n" | |
11012 | "Display the dampened routes received from neighbor\n") | |
11013 | ||
11014 | DEFUN (show_bgp_view_neighbor_flap, | |
11015 | show_bgp_view_neighbor_flap_cmd, | |
11016 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11017 | SHOW_STR | |
11018 | BGP_STR | |
11019 | "BGP view\n" | |
11020 | "BGP view name\n" | |
11021 | "Detailed information on TCP and BGP neighbor connections\n" | |
11022 | "Neighbor to display information about\n" | |
11023 | "Neighbor to display information about\n" | |
11024 | "Display flap statistics of the routes learned from neighbor\n") | |
11025 | { | |
11026 | struct peer *peer; | |
11027 | ||
11028 | if (argc == 2) | |
11029 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11030 | else | |
11031 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11032 | ||
11033 | if (! peer) | |
11034 | return CMD_WARNING; | |
11035 | ||
11036 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
11037 | bgp_show_type_flap_neighbor); | |
11038 | } | |
11039 | ||
11040 | ALIAS (show_bgp_view_neighbor_flap, | |
11041 | show_bgp_view_ipv6_neighbor_flap_cmd, | |
11042 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11043 | SHOW_STR | |
11044 | BGP_STR | |
11045 | "BGP view\n" | |
11046 | "BGP view name\n" | |
11047 | "Address family\n" | |
11048 | "Detailed information on TCP and BGP neighbor connections\n" | |
11049 | "Neighbor to display information about\n" | |
11050 | "Neighbor to display information about\n" | |
11051 | "Display flap statistics of the routes learned from neighbor\n") | |
11052 | ||
11053 | ALIAS (show_bgp_view_neighbor_routes, | |
11054 | show_bgp_neighbor_routes_cmd, | |
11055 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
11056 | SHOW_STR | |
11057 | BGP_STR | |
11058 | "Detailed information on TCP and BGP neighbor connections\n" | |
11059 | "Neighbor to display information about\n" | |
11060 | "Neighbor to display information about\n" | |
11061 | "Display routes learned from neighbor\n") | |
11062 | ||
11063 | ||
11064 | ALIAS (show_bgp_view_neighbor_routes, | |
718e3744 | 11065 | show_bgp_ipv6_neighbor_routes_cmd, |
11066 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
11067 | SHOW_STR | |
11068 | BGP_STR | |
11069 | "Address family\n" | |
11070 | "Detailed information on TCP and BGP neighbor connections\n" | |
11071 | "Neighbor to display information about\n" | |
11072 | "Neighbor to display information about\n" | |
11073 | "Display routes learned from neighbor\n") | |
11074 | ||
11075 | /* old command */ | |
bb46e94f | 11076 | ALIAS (show_bgp_view_neighbor_routes, |
718e3744 | 11077 | ipv6_bgp_neighbor_routes_cmd, |
11078 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
11079 | SHOW_STR | |
11080 | IPV6_STR | |
11081 | BGP_STR | |
11082 | "Detailed information on TCP and BGP neighbor connections\n" | |
11083 | "Neighbor to display information about\n" | |
11084 | "Neighbor to display information about\n" | |
11085 | "Display routes learned from neighbor\n") | |
718e3744 | 11086 | |
11087 | /* old command */ | |
11088 | DEFUN (ipv6_mbgp_neighbor_routes, | |
11089 | ipv6_mbgp_neighbor_routes_cmd, | |
11090 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", | |
11091 | SHOW_STR | |
11092 | IPV6_STR | |
11093 | MBGP_STR | |
11094 | "Detailed information on TCP and BGP neighbor connections\n" | |
11095 | "Neighbor to display information about\n" | |
11096 | "Neighbor to display information about\n" | |
11097 | "Display routes learned from neighbor\n") | |
11098 | { | |
bb46e94f | 11099 | struct peer *peer; |
11100 | ||
11101 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11102 | if (! peer) | |
11103 | return CMD_WARNING; | |
11104 | ||
11105 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, | |
718e3744 | 11106 | bgp_show_type_neighbor); |
11107 | } | |
bb46e94f | 11108 | |
11109 | ALIAS (show_bgp_view_neighbor_flap, | |
11110 | show_bgp_neighbor_flap_cmd, | |
11111 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11112 | SHOW_STR | |
11113 | BGP_STR | |
11114 | "Detailed information on TCP and BGP neighbor connections\n" | |
11115 | "Neighbor to display information about\n" | |
11116 | "Neighbor to display information about\n" | |
11117 | "Display flap statistics of the routes learned from neighbor\n") | |
11118 | ||
11119 | ALIAS (show_bgp_view_neighbor_flap, | |
11120 | show_bgp_ipv6_neighbor_flap_cmd, | |
11121 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11122 | SHOW_STR | |
11123 | BGP_STR | |
11124 | "Address family\n" | |
11125 | "Detailed information on TCP and BGP neighbor connections\n" | |
11126 | "Neighbor to display information about\n" | |
11127 | "Neighbor to display information about\n" | |
11128 | "Display flap statistics of the routes learned from neighbor\n") | |
11129 | ||
11130 | ALIAS (show_bgp_view_neighbor_damp, | |
11131 | show_bgp_neighbor_damp_cmd, | |
11132 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
11133 | SHOW_STR | |
11134 | BGP_STR | |
11135 | "Detailed information on TCP and BGP neighbor connections\n" | |
11136 | "Neighbor to display information about\n" | |
11137 | "Neighbor to display information about\n" | |
11138 | "Display the dampened routes received from neighbor\n") | |
11139 | ||
11140 | ALIAS (show_bgp_view_neighbor_damp, | |
11141 | show_bgp_ipv6_neighbor_damp_cmd, | |
11142 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
11143 | SHOW_STR | |
11144 | BGP_STR | |
11145 | "Address family\n" | |
11146 | "Detailed information on TCP and BGP neighbor connections\n" | |
11147 | "Neighbor to display information about\n" | |
11148 | "Neighbor to display information about\n" | |
c001ae62 | 11149 | "Display the dampened routes received from neighbor\n") |
fee0f4c6 | 11150 | |
11151 | DEFUN (show_bgp_view_rsclient, | |
11152 | show_bgp_view_rsclient_cmd, | |
11153 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
11154 | SHOW_STR | |
11155 | BGP_STR | |
11156 | "BGP view\n" | |
11157 | "BGP view name\n" | |
11158 | "Information about Route Server Client\n" | |
11159 | NEIGHBOR_ADDR_STR) | |
11160 | { | |
11161 | struct bgp_table *table; | |
11162 | struct peer *peer; | |
11163 | ||
11164 | if (argc == 2) | |
11165 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11166 | else | |
11167 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11168 | ||
11169 | if (! peer) | |
11170 | return CMD_WARNING; | |
11171 | ||
11172 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
11173 | { | |
11174 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11175 | VTY_NEWLINE); | |
11176 | return CMD_WARNING; | |
11177 | } | |
11178 | ||
11179 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
11180 | PEER_FLAG_RSERVER_CLIENT)) | |
11181 | { | |
11182 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11183 | VTY_NEWLINE); | |
11184 | return CMD_WARNING; | |
11185 | } | |
11186 | ||
11187 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; | |
11188 | ||
5a646650 | 11189 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 11190 | } |
11191 | ||
11192 | ALIAS (show_bgp_view_rsclient, | |
11193 | show_bgp_rsclient_cmd, | |
11194 | "show bgp rsclient (A.B.C.D|X:X::X:X)", | |
11195 | SHOW_STR | |
11196 | BGP_STR | |
11197 | "Information about Route Server Client\n" | |
11198 | NEIGHBOR_ADDR_STR) | |
11199 | ||
95cbbd2a ML |
11200 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
11201 | show_bgp_view_ipv6_safi_rsclient_cmd, | |
11202 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
11203 | SHOW_STR | |
11204 | BGP_STR | |
11205 | "BGP view\n" | |
11206 | "BGP view name\n" | |
11207 | "Address family\n" | |
11208 | "Address Family modifier\n" | |
11209 | "Address Family modifier\n" | |
11210 | "Information about Route Server Client\n" | |
11211 | NEIGHBOR_ADDR_STR) | |
11212 | { | |
11213 | struct bgp_table *table; | |
11214 | struct peer *peer; | |
11215 | safi_t safi; | |
11216 | ||
11217 | if (argc == 3) { | |
11218 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
11219 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11220 | } else { | |
11221 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
11222 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11223 | } | |
11224 | ||
11225 | if (! peer) | |
11226 | return CMD_WARNING; | |
11227 | ||
11228 | if (! peer->afc[AFI_IP6][safi]) | |
11229 | { | |
11230 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11231 | VTY_NEWLINE); | |
11232 | return CMD_WARNING; | |
11233 | } | |
11234 | ||
11235 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], | |
11236 | PEER_FLAG_RSERVER_CLIENT)) | |
11237 | { | |
11238 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11239 | VTY_NEWLINE); | |
11240 | return CMD_WARNING; | |
11241 | } | |
11242 | ||
11243 | table = peer->rib[AFI_IP6][safi]; | |
11244 | ||
11245 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); | |
11246 | } | |
11247 | ||
11248 | ALIAS (show_bgp_view_ipv6_safi_rsclient, | |
11249 | show_bgp_ipv6_safi_rsclient_cmd, | |
11250 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
11251 | SHOW_STR | |
11252 | BGP_STR | |
11253 | "Address family\n" | |
11254 | "Address Family modifier\n" | |
11255 | "Address Family modifier\n" | |
11256 | "Information about Route Server Client\n" | |
11257 | NEIGHBOR_ADDR_STR) | |
11258 | ||
fee0f4c6 | 11259 | DEFUN (show_bgp_view_rsclient_route, |
11260 | show_bgp_view_rsclient_route_cmd, | |
11261 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11262 | SHOW_STR | |
11263 | BGP_STR | |
11264 | "BGP view\n" | |
11265 | "BGP view name\n" | |
11266 | "Information about Route Server Client\n" | |
11267 | NEIGHBOR_ADDR_STR | |
11268 | "Network in the BGP routing table to display\n") | |
11269 | { | |
11270 | struct bgp *bgp; | |
11271 | struct peer *peer; | |
11272 | ||
11273 | /* BGP structure lookup. */ | |
11274 | if (argc == 3) | |
11275 | { | |
11276 | bgp = bgp_lookup_by_name (argv[0]); | |
11277 | if (bgp == NULL) | |
11278 | { | |
11279 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11280 | return CMD_WARNING; | |
11281 | } | |
11282 | } | |
11283 | else | |
11284 | { | |
11285 | bgp = bgp_get_default (); | |
11286 | if (bgp == NULL) | |
11287 | { | |
11288 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11289 | return CMD_WARNING; | |
11290 | } | |
11291 | } | |
11292 | ||
11293 | if (argc == 3) | |
11294 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11295 | else | |
11296 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11297 | ||
11298 | if (! peer) | |
11299 | return CMD_WARNING; | |
11300 | ||
11301 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
11302 | { | |
11303 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11304 | VTY_NEWLINE); | |
11305 | return CMD_WARNING; | |
11306 | } | |
11307 | ||
11308 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
11309 | PEER_FLAG_RSERVER_CLIENT)) | |
11310 | { | |
11311 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11312 | VTY_NEWLINE); | |
11313 | return CMD_WARNING; | |
11314 | } | |
11315 | ||
11316 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
11317 | (argc == 3) ? argv[2] : argv[1], | |
11318 | AFI_IP6, SAFI_UNICAST, NULL, 0); | |
11319 | } | |
11320 | ||
11321 | ALIAS (show_bgp_view_rsclient_route, | |
11322 | show_bgp_rsclient_route_cmd, | |
11323 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11324 | SHOW_STR | |
11325 | BGP_STR | |
11326 | "Information about Route Server Client\n" | |
11327 | NEIGHBOR_ADDR_STR | |
11328 | "Network in the BGP routing table to display\n") | |
11329 | ||
95cbbd2a ML |
11330 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
11331 | show_bgp_view_ipv6_safi_rsclient_route_cmd, | |
11332 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11333 | SHOW_STR | |
11334 | BGP_STR | |
11335 | "BGP view\n" | |
11336 | "BGP view name\n" | |
11337 | "Address family\n" | |
11338 | "Address Family modifier\n" | |
11339 | "Address Family modifier\n" | |
11340 | "Information about Route Server Client\n" | |
11341 | NEIGHBOR_ADDR_STR | |
11342 | "Network in the BGP routing table to display\n") | |
11343 | { | |
11344 | struct bgp *bgp; | |
11345 | struct peer *peer; | |
11346 | safi_t safi; | |
11347 | ||
11348 | /* BGP structure lookup. */ | |
11349 | if (argc == 4) | |
11350 | { | |
11351 | bgp = bgp_lookup_by_name (argv[0]); | |
11352 | if (bgp == NULL) | |
11353 | { | |
11354 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11355 | return CMD_WARNING; | |
11356 | } | |
11357 | } | |
11358 | else | |
11359 | { | |
11360 | bgp = bgp_get_default (); | |
11361 | if (bgp == NULL) | |
11362 | { | |
11363 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11364 | return CMD_WARNING; | |
11365 | } | |
11366 | } | |
11367 | ||
11368 | if (argc == 4) { | |
11369 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
11370 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11371 | } else { | |
11372 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
11373 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11374 | } | |
11375 | ||
11376 | if (! peer) | |
11377 | return CMD_WARNING; | |
11378 | ||
11379 | if (! peer->afc[AFI_IP6][safi]) | |
11380 | { | |
11381 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11382 | VTY_NEWLINE); | |
11383 | return CMD_WARNING; | |
11384 | } | |
11385 | ||
11386 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], | |
11387 | PEER_FLAG_RSERVER_CLIENT)) | |
11388 | { | |
11389 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11390 | VTY_NEWLINE); | |
11391 | return CMD_WARNING; | |
11392 | } | |
11393 | ||
11394 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], | |
11395 | (argc == 4) ? argv[3] : argv[2], | |
11396 | AFI_IP6, safi, NULL, 0); | |
11397 | } | |
11398 | ||
11399 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, | |
11400 | show_bgp_ipv6_safi_rsclient_route_cmd, | |
11401 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11402 | SHOW_STR | |
11403 | BGP_STR | |
11404 | "Address family\n" | |
11405 | "Address Family modifier\n" | |
11406 | "Address Family modifier\n" | |
11407 | "Information about Route Server Client\n" | |
11408 | NEIGHBOR_ADDR_STR | |
11409 | "Network in the BGP routing table to display\n") | |
11410 | ||
fee0f4c6 | 11411 | DEFUN (show_bgp_view_rsclient_prefix, |
11412 | show_bgp_view_rsclient_prefix_cmd, | |
11413 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11414 | SHOW_STR | |
11415 | BGP_STR | |
11416 | "BGP view\n" | |
11417 | "BGP view name\n" | |
11418 | "Information about Route Server Client\n" | |
11419 | NEIGHBOR_ADDR_STR | |
11420 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11421 | { | |
11422 | struct bgp *bgp; | |
11423 | struct peer *peer; | |
11424 | ||
11425 | /* BGP structure lookup. */ | |
11426 | if (argc == 3) | |
11427 | { | |
11428 | bgp = bgp_lookup_by_name (argv[0]); | |
11429 | if (bgp == NULL) | |
11430 | { | |
11431 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11432 | return CMD_WARNING; | |
11433 | } | |
11434 | } | |
11435 | else | |
11436 | { | |
11437 | bgp = bgp_get_default (); | |
11438 | if (bgp == NULL) | |
11439 | { | |
11440 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11441 | return CMD_WARNING; | |
11442 | } | |
11443 | } | |
11444 | ||
11445 | if (argc == 3) | |
11446 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11447 | else | |
11448 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11449 | ||
11450 | if (! peer) | |
11451 | return CMD_WARNING; | |
11452 | ||
11453 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
11454 | { | |
11455 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11456 | VTY_NEWLINE); | |
11457 | return CMD_WARNING; | |
11458 | } | |
11459 | ||
11460 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
11461 | PEER_FLAG_RSERVER_CLIENT)) | |
11462 | { | |
11463 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11464 | VTY_NEWLINE); | |
11465 | return CMD_WARNING; | |
11466 | } | |
11467 | ||
11468 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
11469 | (argc == 3) ? argv[2] : argv[1], | |
11470 | AFI_IP6, SAFI_UNICAST, NULL, 1); | |
11471 | } | |
11472 | ||
11473 | ALIAS (show_bgp_view_rsclient_prefix, | |
11474 | show_bgp_rsclient_prefix_cmd, | |
11475 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11476 | SHOW_STR | |
11477 | BGP_STR | |
11478 | "Information about Route Server Client\n" | |
11479 | NEIGHBOR_ADDR_STR | |
11480 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11481 | ||
95cbbd2a ML |
11482 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
11483 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, | |
11484 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11485 | SHOW_STR | |
11486 | BGP_STR | |
11487 | "BGP view\n" | |
11488 | "BGP view name\n" | |
11489 | "Address family\n" | |
11490 | "Address Family modifier\n" | |
11491 | "Address Family modifier\n" | |
11492 | "Information about Route Server Client\n" | |
11493 | NEIGHBOR_ADDR_STR | |
11494 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11495 | { | |
11496 | struct bgp *bgp; | |
11497 | struct peer *peer; | |
11498 | safi_t safi; | |
11499 | ||
11500 | /* BGP structure lookup. */ | |
11501 | if (argc == 4) | |
11502 | { | |
11503 | bgp = bgp_lookup_by_name (argv[0]); | |
11504 | if (bgp == NULL) | |
11505 | { | |
11506 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11507 | return CMD_WARNING; | |
11508 | } | |
11509 | } | |
11510 | else | |
11511 | { | |
11512 | bgp = bgp_get_default (); | |
11513 | if (bgp == NULL) | |
11514 | { | |
11515 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11516 | return CMD_WARNING; | |
11517 | } | |
11518 | } | |
11519 | ||
11520 | if (argc == 4) { | |
11521 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
11522 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11523 | } else { | |
11524 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
11525 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11526 | } | |
11527 | ||
11528 | if (! peer) | |
11529 | return CMD_WARNING; | |
11530 | ||
11531 | if (! peer->afc[AFI_IP6][safi]) | |
11532 | { | |
11533 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11534 | VTY_NEWLINE); | |
11535 | return CMD_WARNING; | |
11536 | } | |
11537 | ||
11538 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], | |
11539 | PEER_FLAG_RSERVER_CLIENT)) | |
11540 | { | |
11541 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11542 | VTY_NEWLINE); | |
11543 | return CMD_WARNING; | |
11544 | } | |
11545 | ||
11546 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], | |
11547 | (argc == 4) ? argv[3] : argv[2], | |
11548 | AFI_IP6, safi, NULL, 1); | |
11549 | } | |
11550 | ||
11551 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, | |
11552 | show_bgp_ipv6_safi_rsclient_prefix_cmd, | |
11553 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11554 | SHOW_STR | |
11555 | BGP_STR | |
11556 | "Address family\n" | |
11557 | "Address Family modifier\n" | |
11558 | "Address Family modifier\n" | |
11559 | "Information about Route Server Client\n" | |
11560 | NEIGHBOR_ADDR_STR | |
11561 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11562 | ||
718e3744 | 11563 | #endif /* HAVE_IPV6 */ |
11564 | \f | |
11565 | struct bgp_table *bgp_distance_table; | |
11566 | ||
11567 | struct bgp_distance | |
11568 | { | |
11569 | /* Distance value for the IP source prefix. */ | |
11570 | u_char distance; | |
11571 | ||
11572 | /* Name of the access-list to be matched. */ | |
11573 | char *access_list; | |
11574 | }; | |
11575 | ||
94f2b392 | 11576 | static struct bgp_distance * |
66e5cd87 | 11577 | bgp_distance_new (void) |
718e3744 | 11578 | { |
393deb9b | 11579 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
718e3744 | 11580 | } |
11581 | ||
94f2b392 | 11582 | static void |
718e3744 | 11583 | bgp_distance_free (struct bgp_distance *bdistance) |
11584 | { | |
11585 | XFREE (MTYPE_BGP_DISTANCE, bdistance); | |
11586 | } | |
11587 | ||
94f2b392 | 11588 | static int |
fd79ac91 | 11589 | bgp_distance_set (struct vty *vty, const char *distance_str, |
11590 | const char *ip_str, const char *access_list_str) | |
718e3744 | 11591 | { |
11592 | int ret; | |
11593 | struct prefix_ipv4 p; | |
11594 | u_char distance; | |
11595 | struct bgp_node *rn; | |
11596 | struct bgp_distance *bdistance; | |
11597 | ||
11598 | ret = str2prefix_ipv4 (ip_str, &p); | |
11599 | if (ret == 0) | |
11600 | { | |
11601 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
11602 | return CMD_WARNING; | |
11603 | } | |
11604 | ||
11605 | distance = atoi (distance_str); | |
11606 | ||
11607 | /* Get BGP distance node. */ | |
11608 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); | |
11609 | if (rn->info) | |
11610 | { | |
11611 | bdistance = rn->info; | |
11612 | bgp_unlock_node (rn); | |
11613 | } | |
11614 | else | |
11615 | { | |
11616 | bdistance = bgp_distance_new (); | |
11617 | rn->info = bdistance; | |
11618 | } | |
11619 | ||
11620 | /* Set distance value. */ | |
11621 | bdistance->distance = distance; | |
11622 | ||
11623 | /* Reset access-list configuration. */ | |
11624 | if (bdistance->access_list) | |
11625 | { | |
11626 | free (bdistance->access_list); | |
11627 | bdistance->access_list = NULL; | |
11628 | } | |
11629 | if (access_list_str) | |
11630 | bdistance->access_list = strdup (access_list_str); | |
11631 | ||
11632 | return CMD_SUCCESS; | |
11633 | } | |
11634 | ||
94f2b392 | 11635 | static int |
fd79ac91 | 11636 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
11637 | const char *ip_str, const char *access_list_str) | |
718e3744 | 11638 | { |
11639 | int ret; | |
11640 | struct prefix_ipv4 p; | |
11641 | u_char distance; | |
11642 | struct bgp_node *rn; | |
11643 | struct bgp_distance *bdistance; | |
11644 | ||
11645 | ret = str2prefix_ipv4 (ip_str, &p); | |
11646 | if (ret == 0) | |
11647 | { | |
11648 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
11649 | return CMD_WARNING; | |
11650 | } | |
11651 | ||
11652 | distance = atoi (distance_str); | |
11653 | ||
11654 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); | |
11655 | if (! rn) | |
11656 | { | |
11657 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); | |
11658 | return CMD_WARNING; | |
11659 | } | |
11660 | ||
11661 | bdistance = rn->info; | |
11662 | ||
11663 | if (bdistance->access_list) | |
11664 | free (bdistance->access_list); | |
11665 | bgp_distance_free (bdistance); | |
11666 | ||
11667 | rn->info = NULL; | |
11668 | bgp_unlock_node (rn); | |
11669 | bgp_unlock_node (rn); | |
11670 | ||
11671 | return CMD_SUCCESS; | |
11672 | } | |
11673 | ||
718e3744 | 11674 | /* Apply BGP information to distance method. */ |
11675 | u_char | |
11676 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) | |
11677 | { | |
11678 | struct bgp_node *rn; | |
11679 | struct prefix_ipv4 q; | |
11680 | struct peer *peer; | |
11681 | struct bgp_distance *bdistance; | |
11682 | struct access_list *alist; | |
11683 | struct bgp_static *bgp_static; | |
11684 | ||
11685 | if (! bgp) | |
11686 | return 0; | |
11687 | ||
11688 | if (p->family != AF_INET) | |
11689 | return 0; | |
11690 | ||
11691 | peer = rinfo->peer; | |
11692 | ||
11693 | if (peer->su.sa.sa_family != AF_INET) | |
11694 | return 0; | |
11695 | ||
11696 | memset (&q, 0, sizeof (struct prefix_ipv4)); | |
11697 | q.family = AF_INET; | |
11698 | q.prefix = peer->su.sin.sin_addr; | |
11699 | q.prefixlen = IPV4_MAX_BITLEN; | |
11700 | ||
11701 | /* Check source address. */ | |
11702 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); | |
11703 | if (rn) | |
11704 | { | |
11705 | bdistance = rn->info; | |
11706 | bgp_unlock_node (rn); | |
11707 | ||
11708 | if (bdistance->access_list) | |
11709 | { | |
11710 | alist = access_list_lookup (AFI_IP, bdistance->access_list); | |
11711 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) | |
11712 | return bdistance->distance; | |
11713 | } | |
11714 | else | |
11715 | return bdistance->distance; | |
11716 | } | |
11717 | ||
11718 | /* Backdoor check. */ | |
11719 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); | |
11720 | if (rn) | |
11721 | { | |
11722 | bgp_static = rn->info; | |
11723 | bgp_unlock_node (rn); | |
11724 | ||
11725 | if (bgp_static->backdoor) | |
11726 | { | |
11727 | if (bgp->distance_local) | |
11728 | return bgp->distance_local; | |
11729 | else | |
11730 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11731 | } | |
11732 | } | |
11733 | ||
11734 | if (peer_sort (peer) == BGP_PEER_EBGP) | |
11735 | { | |
11736 | if (bgp->distance_ebgp) | |
11737 | return bgp->distance_ebgp; | |
11738 | return ZEBRA_EBGP_DISTANCE_DEFAULT; | |
11739 | } | |
11740 | else | |
11741 | { | |
11742 | if (bgp->distance_ibgp) | |
11743 | return bgp->distance_ibgp; | |
11744 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11745 | } | |
11746 | } | |
11747 | ||
11748 | DEFUN (bgp_distance, | |
11749 | bgp_distance_cmd, | |
11750 | "distance bgp <1-255> <1-255> <1-255>", | |
11751 | "Define an administrative distance\n" | |
11752 | "BGP distance\n" | |
11753 | "Distance for routes external to the AS\n" | |
11754 | "Distance for routes internal to the AS\n" | |
11755 | "Distance for local routes\n") | |
11756 | { | |
11757 | struct bgp *bgp; | |
11758 | ||
11759 | bgp = vty->index; | |
11760 | ||
11761 | bgp->distance_ebgp = atoi (argv[0]); | |
11762 | bgp->distance_ibgp = atoi (argv[1]); | |
11763 | bgp->distance_local = atoi (argv[2]); | |
11764 | return CMD_SUCCESS; | |
11765 | } | |
11766 | ||
11767 | DEFUN (no_bgp_distance, | |
11768 | no_bgp_distance_cmd, | |
11769 | "no distance bgp <1-255> <1-255> <1-255>", | |
11770 | NO_STR | |
11771 | "Define an administrative distance\n" | |
11772 | "BGP distance\n" | |
11773 | "Distance for routes external to the AS\n" | |
11774 | "Distance for routes internal to the AS\n" | |
11775 | "Distance for local routes\n") | |
11776 | { | |
11777 | struct bgp *bgp; | |
11778 | ||
11779 | bgp = vty->index; | |
11780 | ||
11781 | bgp->distance_ebgp= 0; | |
11782 | bgp->distance_ibgp = 0; | |
11783 | bgp->distance_local = 0; | |
11784 | return CMD_SUCCESS; | |
11785 | } | |
11786 | ||
11787 | ALIAS (no_bgp_distance, | |
11788 | no_bgp_distance2_cmd, | |
11789 | "no distance bgp", | |
11790 | NO_STR | |
11791 | "Define an administrative distance\n" | |
11792 | "BGP distance\n") | |
11793 | ||
11794 | DEFUN (bgp_distance_source, | |
11795 | bgp_distance_source_cmd, | |
11796 | "distance <1-255> A.B.C.D/M", | |
11797 | "Define an administrative distance\n" | |
11798 | "Administrative distance\n" | |
11799 | "IP source prefix\n") | |
11800 | { | |
11801 | bgp_distance_set (vty, argv[0], argv[1], NULL); | |
11802 | return CMD_SUCCESS; | |
11803 | } | |
11804 | ||
11805 | DEFUN (no_bgp_distance_source, | |
11806 | no_bgp_distance_source_cmd, | |
11807 | "no distance <1-255> A.B.C.D/M", | |
11808 | NO_STR | |
11809 | "Define an administrative distance\n" | |
11810 | "Administrative distance\n" | |
11811 | "IP source prefix\n") | |
11812 | { | |
11813 | bgp_distance_unset (vty, argv[0], argv[1], NULL); | |
11814 | return CMD_SUCCESS; | |
11815 | } | |
11816 | ||
11817 | DEFUN (bgp_distance_source_access_list, | |
11818 | bgp_distance_source_access_list_cmd, | |
11819 | "distance <1-255> A.B.C.D/M WORD", | |
11820 | "Define an administrative distance\n" | |
11821 | "Administrative distance\n" | |
11822 | "IP source prefix\n" | |
11823 | "Access list name\n") | |
11824 | { | |
11825 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); | |
11826 | return CMD_SUCCESS; | |
11827 | } | |
11828 | ||
11829 | DEFUN (no_bgp_distance_source_access_list, | |
11830 | no_bgp_distance_source_access_list_cmd, | |
11831 | "no distance <1-255> A.B.C.D/M WORD", | |
11832 | NO_STR | |
11833 | "Define an administrative distance\n" | |
11834 | "Administrative distance\n" | |
11835 | "IP source prefix\n" | |
11836 | "Access list name\n") | |
11837 | { | |
11838 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); | |
11839 | return CMD_SUCCESS; | |
11840 | } | |
11841 | \f | |
11842 | DEFUN (bgp_damp_set, | |
11843 | bgp_damp_set_cmd, | |
11844 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11845 | "BGP Specific commands\n" | |
11846 | "Enable route-flap dampening\n" | |
11847 | "Half-life time for the penalty\n" | |
11848 | "Value to start reusing a route\n" | |
11849 | "Value to start suppressing a route\n" | |
11850 | "Maximum duration to suppress a stable route\n") | |
11851 | { | |
11852 | struct bgp *bgp; | |
11853 | int half = DEFAULT_HALF_LIFE * 60; | |
11854 | int reuse = DEFAULT_REUSE; | |
11855 | int suppress = DEFAULT_SUPPRESS; | |
11856 | int max = 4 * half; | |
11857 | ||
11858 | if (argc == 4) | |
11859 | { | |
11860 | half = atoi (argv[0]) * 60; | |
11861 | reuse = atoi (argv[1]); | |
11862 | suppress = atoi (argv[2]); | |
11863 | max = atoi (argv[3]) * 60; | |
11864 | } | |
11865 | else if (argc == 1) | |
11866 | { | |
11867 | half = atoi (argv[0]) * 60; | |
11868 | max = 4 * half; | |
11869 | } | |
11870 | ||
11871 | bgp = vty->index; | |
11872 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), | |
11873 | half, reuse, suppress, max); | |
11874 | } | |
11875 | ||
11876 | ALIAS (bgp_damp_set, | |
11877 | bgp_damp_set2_cmd, | |
11878 | "bgp dampening <1-45>", | |
11879 | "BGP Specific commands\n" | |
11880 | "Enable route-flap dampening\n" | |
11881 | "Half-life time for the penalty\n") | |
11882 | ||
11883 | ALIAS (bgp_damp_set, | |
11884 | bgp_damp_set3_cmd, | |
11885 | "bgp dampening", | |
11886 | "BGP Specific commands\n" | |
11887 | "Enable route-flap dampening\n") | |
11888 | ||
11889 | DEFUN (bgp_damp_unset, | |
11890 | bgp_damp_unset_cmd, | |
11891 | "no bgp dampening", | |
11892 | NO_STR | |
11893 | "BGP Specific commands\n" | |
11894 | "Enable route-flap dampening\n") | |
11895 | { | |
11896 | struct bgp *bgp; | |
11897 | ||
11898 | bgp = vty->index; | |
11899 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); | |
11900 | } | |
11901 | ||
11902 | ALIAS (bgp_damp_unset, | |
11903 | bgp_damp_unset2_cmd, | |
11904 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11905 | NO_STR | |
11906 | "BGP Specific commands\n" | |
11907 | "Enable route-flap dampening\n" | |
11908 | "Half-life time for the penalty\n" | |
11909 | "Value to start reusing a route\n" | |
11910 | "Value to start suppressing a route\n" | |
11911 | "Maximum duration to suppress a stable route\n") | |
11912 | ||
11913 | DEFUN (show_ip_bgp_dampened_paths, | |
11914 | show_ip_bgp_dampened_paths_cmd, | |
11915 | "show ip bgp dampened-paths", | |
11916 | SHOW_STR | |
11917 | IP_STR | |
11918 | BGP_STR | |
11919 | "Display paths suppressed due to dampening\n") | |
11920 | { | |
5a646650 | 11921 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
11922 | NULL); | |
718e3744 | 11923 | } |
11924 | ||
11925 | DEFUN (show_ip_bgp_flap_statistics, | |
11926 | show_ip_bgp_flap_statistics_cmd, | |
11927 | "show ip bgp flap-statistics", | |
11928 | SHOW_STR | |
11929 | IP_STR | |
11930 | BGP_STR | |
11931 | "Display flap statistics of routes\n") | |
11932 | { | |
5a646650 | 11933 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
11934 | bgp_show_type_flap_statistics, NULL); | |
718e3744 | 11935 | } |
11936 | \f | |
11937 | /* Display specified route of BGP table. */ | |
94f2b392 | 11938 | static int |
fd79ac91 | 11939 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
11940 | const char *ip_str, afi_t afi, safi_t safi, | |
11941 | struct prefix_rd *prd, int prefix_check) | |
718e3744 | 11942 | { |
11943 | int ret; | |
11944 | struct prefix match; | |
11945 | struct bgp_node *rn; | |
11946 | struct bgp_node *rm; | |
11947 | struct bgp_info *ri; | |
11948 | struct bgp_info *ri_temp; | |
11949 | struct bgp *bgp; | |
11950 | struct bgp_table *table; | |
11951 | ||
11952 | /* BGP structure lookup. */ | |
11953 | if (view_name) | |
11954 | { | |
11955 | bgp = bgp_lookup_by_name (view_name); | |
11956 | if (bgp == NULL) | |
11957 | { | |
11958 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
11959 | return CMD_WARNING; | |
11960 | } | |
11961 | } | |
11962 | else | |
11963 | { | |
11964 | bgp = bgp_get_default (); | |
11965 | if (bgp == NULL) | |
11966 | { | |
11967 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
11968 | return CMD_WARNING; | |
11969 | } | |
11970 | } | |
11971 | ||
11972 | /* Check IP address argument. */ | |
11973 | ret = str2prefix (ip_str, &match); | |
11974 | if (! ret) | |
11975 | { | |
11976 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
11977 | return CMD_WARNING; | |
11978 | } | |
11979 | ||
11980 | match.family = afi2family (afi); | |
11981 | ||
11982 | if (safi == SAFI_MPLS_VPN) | |
11983 | { | |
11984 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) | |
11985 | { | |
11986 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
11987 | continue; | |
11988 | ||
11989 | if ((table = rn->info) != NULL) | |
11990 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6c88b44d CC |
11991 | { |
11992 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) | |
11993 | { | |
11994 | ri = rm->info; | |
11995 | while (ri) | |
11996 | { | |
11997 | if (ri->extra && ri->extra->damp_info) | |
11998 | { | |
11999 | ri_temp = ri->next; | |
12000 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
12001 | ri = ri_temp; | |
12002 | } | |
12003 | else | |
12004 | ri = ri->next; | |
12005 | } | |
12006 | } | |
12007 | ||
12008 | bgp_unlock_node (rm); | |
12009 | } | |
718e3744 | 12010 | } |
12011 | } | |
12012 | else | |
12013 | { | |
12014 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) | |
6c88b44d CC |
12015 | { |
12016 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
12017 | { | |
12018 | ri = rn->info; | |
12019 | while (ri) | |
12020 | { | |
12021 | if (ri->extra && ri->extra->damp_info) | |
12022 | { | |
12023 | ri_temp = ri->next; | |
12024 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
12025 | ri = ri_temp; | |
12026 | } | |
12027 | else | |
12028 | ri = ri->next; | |
12029 | } | |
12030 | } | |
12031 | ||
12032 | bgp_unlock_node (rn); | |
12033 | } | |
718e3744 | 12034 | } |
12035 | ||
12036 | return CMD_SUCCESS; | |
12037 | } | |
12038 | ||
12039 | DEFUN (clear_ip_bgp_dampening, | |
12040 | clear_ip_bgp_dampening_cmd, | |
12041 | "clear ip bgp dampening", | |
12042 | CLEAR_STR | |
12043 | IP_STR | |
12044 | BGP_STR | |
12045 | "Clear route flap dampening information\n") | |
12046 | { | |
12047 | bgp_damp_info_clean (); | |
12048 | return CMD_SUCCESS; | |
12049 | } | |
12050 | ||
12051 | DEFUN (clear_ip_bgp_dampening_prefix, | |
12052 | clear_ip_bgp_dampening_prefix_cmd, | |
12053 | "clear ip bgp dampening A.B.C.D/M", | |
12054 | CLEAR_STR | |
12055 | IP_STR | |
12056 | BGP_STR | |
12057 | "Clear route flap dampening information\n" | |
12058 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
12059 | { | |
12060 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
12061 | SAFI_UNICAST, NULL, 1); | |
12062 | } | |
12063 | ||
12064 | DEFUN (clear_ip_bgp_dampening_address, | |
12065 | clear_ip_bgp_dampening_address_cmd, | |
12066 | "clear ip bgp dampening A.B.C.D", | |
12067 | CLEAR_STR | |
12068 | IP_STR | |
12069 | BGP_STR | |
12070 | "Clear route flap dampening information\n" | |
12071 | "Network to clear damping information\n") | |
12072 | { | |
12073 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
12074 | SAFI_UNICAST, NULL, 0); | |
12075 | } | |
12076 | ||
12077 | DEFUN (clear_ip_bgp_dampening_address_mask, | |
12078 | clear_ip_bgp_dampening_address_mask_cmd, | |
12079 | "clear ip bgp dampening A.B.C.D A.B.C.D", | |
12080 | CLEAR_STR | |
12081 | IP_STR | |
12082 | BGP_STR | |
12083 | "Clear route flap dampening information\n" | |
12084 | "Network to clear damping information\n" | |
12085 | "Network mask\n") | |
12086 | { | |
12087 | int ret; | |
12088 | char prefix_str[BUFSIZ]; | |
12089 | ||
12090 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
12091 | if (! ret) | |
12092 | { | |
12093 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
12094 | return CMD_WARNING; | |
12095 | } | |
12096 | ||
12097 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, | |
12098 | SAFI_UNICAST, NULL, 0); | |
12099 | } | |
12100 | \f | |
94f2b392 | 12101 | static int |
718e3744 | 12102 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
12103 | afi_t afi, safi_t safi, int *write) | |
12104 | { | |
12105 | struct bgp_node *prn; | |
12106 | struct bgp_node *rn; | |
12107 | struct bgp_table *table; | |
12108 | struct prefix *p; | |
12109 | struct prefix_rd *prd; | |
12110 | struct bgp_static *bgp_static; | |
12111 | u_int32_t label; | |
12112 | char buf[SU_ADDRSTRLEN]; | |
12113 | char rdbuf[RD_ADDRSTRLEN]; | |
12114 | ||
12115 | /* Network configuration. */ | |
12116 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) | |
12117 | if ((table = prn->info) != NULL) | |
12118 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
12119 | if ((bgp_static = rn->info) != NULL) | |
12120 | { | |
12121 | p = &rn->p; | |
12122 | prd = (struct prefix_rd *) &prn->p; | |
12123 | ||
12124 | /* "address-family" display. */ | |
12125 | bgp_config_write_family_header (vty, afi, safi, write); | |
12126 | ||
12127 | /* "network" configuration display. */ | |
12128 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); | |
12129 | label = decode_label (bgp_static->tag); | |
12130 | ||
12131 | vty_out (vty, " network %s/%d rd %s tag %d", | |
12132 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12133 | p->prefixlen, | |
12134 | rdbuf, label); | |
12135 | vty_out (vty, "%s", VTY_NEWLINE); | |
12136 | } | |
12137 | return 0; | |
12138 | } | |
12139 | ||
12140 | /* Configuration of static route announcement and aggregate | |
12141 | information. */ | |
12142 | int | |
12143 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, | |
12144 | afi_t afi, safi_t safi, int *write) | |
12145 | { | |
12146 | struct bgp_node *rn; | |
12147 | struct prefix *p; | |
12148 | struct bgp_static *bgp_static; | |
12149 | struct bgp_aggregate *bgp_aggregate; | |
12150 | char buf[SU_ADDRSTRLEN]; | |
12151 | ||
12152 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
12153 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); | |
12154 | ||
12155 | /* Network configuration. */ | |
12156 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
12157 | if ((bgp_static = rn->info) != NULL) | |
12158 | { | |
12159 | p = &rn->p; | |
12160 | ||
12161 | /* "address-family" display. */ | |
12162 | bgp_config_write_family_header (vty, afi, safi, write); | |
12163 | ||
12164 | /* "network" configuration display. */ | |
12165 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
12166 | { | |
12167 | u_int32_t destination; | |
12168 | struct in_addr netmask; | |
12169 | ||
12170 | destination = ntohl (p->u.prefix4.s_addr); | |
12171 | masklen2ip (p->prefixlen, &netmask); | |
12172 | vty_out (vty, " network %s", | |
12173 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); | |
12174 | ||
12175 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
12176 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
12177 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
12178 | || p->u.prefix4.s_addr == 0) | |
12179 | { | |
12180 | /* Natural mask is not display. */ | |
12181 | } | |
12182 | else | |
12183 | vty_out (vty, " mask %s", inet_ntoa (netmask)); | |
12184 | } | |
12185 | else | |
12186 | { | |
12187 | vty_out (vty, " network %s/%d", | |
12188 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12189 | p->prefixlen); | |
12190 | } | |
12191 | ||
12192 | if (bgp_static->rmap.name) | |
12193 | vty_out (vty, " route-map %s", bgp_static->rmap.name); | |
41367172 PJ |
12194 | else |
12195 | { | |
12196 | if (bgp_static->backdoor) | |
12197 | vty_out (vty, " backdoor"); | |
41367172 | 12198 | } |
718e3744 | 12199 | |
12200 | vty_out (vty, "%s", VTY_NEWLINE); | |
12201 | } | |
12202 | ||
12203 | /* Aggregate-address configuration. */ | |
12204 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) | |
12205 | if ((bgp_aggregate = rn->info) != NULL) | |
12206 | { | |
12207 | p = &rn->p; | |
12208 | ||
12209 | /* "address-family" display. */ | |
12210 | bgp_config_write_family_header (vty, afi, safi, write); | |
12211 | ||
12212 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
12213 | { | |
12214 | struct in_addr netmask; | |
12215 | ||
12216 | masklen2ip (p->prefixlen, &netmask); | |
12217 | vty_out (vty, " aggregate-address %s %s", | |
12218 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12219 | inet_ntoa (netmask)); | |
12220 | } | |
12221 | else | |
12222 | { | |
12223 | vty_out (vty, " aggregate-address %s/%d", | |
12224 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12225 | p->prefixlen); | |
12226 | } | |
12227 | ||
12228 | if (bgp_aggregate->as_set) | |
12229 | vty_out (vty, " as-set"); | |
12230 | ||
12231 | if (bgp_aggregate->summary_only) | |
12232 | vty_out (vty, " summary-only"); | |
12233 | ||
12234 | vty_out (vty, "%s", VTY_NEWLINE); | |
12235 | } | |
12236 | ||
12237 | return 0; | |
12238 | } | |
12239 | ||
12240 | int | |
12241 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) | |
12242 | { | |
12243 | struct bgp_node *rn; | |
12244 | struct bgp_distance *bdistance; | |
12245 | ||
12246 | /* Distance configuration. */ | |
12247 | if (bgp->distance_ebgp | |
12248 | && bgp->distance_ibgp | |
12249 | && bgp->distance_local | |
12250 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT | |
12251 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT | |
12252 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) | |
12253 | vty_out (vty, " distance bgp %d %d %d%s", | |
12254 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, | |
12255 | VTY_NEWLINE); | |
12256 | ||
12257 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) | |
12258 | if ((bdistance = rn->info) != NULL) | |
12259 | { | |
12260 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, | |
12261 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
12262 | bdistance->access_list ? bdistance->access_list : "", | |
12263 | VTY_NEWLINE); | |
12264 | } | |
12265 | ||
12266 | return 0; | |
12267 | } | |
12268 | ||
12269 | /* Allocate routing table structure and install commands. */ | |
12270 | void | |
66e5cd87 | 12271 | bgp_route_init (void) |
718e3744 | 12272 | { |
12273 | /* Init BGP distance table. */ | |
64e580a7 | 12274 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
718e3744 | 12275 | |
12276 | /* IPv4 BGP commands. */ | |
12277 | install_element (BGP_NODE, &bgp_network_cmd); | |
12278 | install_element (BGP_NODE, &bgp_network_mask_cmd); | |
12279 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); | |
12280 | install_element (BGP_NODE, &bgp_network_route_map_cmd); | |
12281 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); | |
12282 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); | |
12283 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); | |
12284 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); | |
12285 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); | |
12286 | install_element (BGP_NODE, &no_bgp_network_cmd); | |
12287 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); | |
12288 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); | |
12289 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); | |
12290 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); | |
12291 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
12292 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); | |
12293 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); | |
12294 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); | |
12295 | ||
12296 | install_element (BGP_NODE, &aggregate_address_cmd); | |
12297 | install_element (BGP_NODE, &aggregate_address_mask_cmd); | |
12298 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); | |
12299 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); | |
12300 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); | |
12301 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); | |
12302 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); | |
12303 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
12304 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); | |
12305 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
12306 | install_element (BGP_NODE, &no_aggregate_address_cmd); | |
12307 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); | |
12308 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); | |
12309 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); | |
12310 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); | |
12311 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); | |
12312 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
12313 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); | |
12314 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
12315 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
12316 | ||
12317 | /* IPv4 unicast configuration. */ | |
12318 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); | |
12319 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); | |
12320 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); | |
12321 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); | |
12322 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); | |
12323 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); | |
c8f3fe30 | 12324 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
718e3744 | 12325 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
12326 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); | |
12327 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); | |
12328 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); | |
12329 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
c8f3fe30 | 12330 | |
718e3744 | 12331 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
12332 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); | |
12333 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); | |
12334 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); | |
12335 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); | |
12336 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); | |
12337 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); | |
12338 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
12339 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); | |
12340 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
12341 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); | |
12342 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); | |
12343 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); | |
12344 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); | |
12345 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); | |
12346 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); | |
12347 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
12348 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); | |
12349 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
12350 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
12351 | ||
12352 | /* IPv4 multicast configuration. */ | |
12353 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); | |
12354 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); | |
12355 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); | |
12356 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); | |
12357 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); | |
12358 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); | |
12359 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); | |
12360 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); | |
12361 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); | |
12362 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); | |
12363 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); | |
12364 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
12365 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); | |
12366 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); | |
12367 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); | |
12368 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); | |
12369 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); | |
12370 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); | |
12371 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); | |
12372 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
12373 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); | |
12374 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
12375 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); | |
12376 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); | |
12377 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); | |
12378 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); | |
12379 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); | |
12380 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); | |
12381 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
12382 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); | |
12383 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
12384 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
12385 | ||
12386 | install_element (VIEW_NODE, &show_ip_bgp_cmd); | |
12387 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); | |
95cbbd2a | 12388 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 12389 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
12390 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); | |
95cbbd2a | 12391 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 12392 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
12393 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
12394 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); | |
12395 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
95cbbd2a | 12396 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
718e3744 | 12397 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
12398 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
12399 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); | |
12400 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); | |
12401 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); | |
12402 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); | |
12403 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
12404 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); | |
12405 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
12406 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); | |
12407 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
12408 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); | |
12409 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
12410 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); | |
12411 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
12412 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); | |
12413 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
12414 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); | |
12415 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); | |
12416 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); | |
12417 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); | |
12418 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); | |
12419 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
12420 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
12421 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
95cbbd2a ML |
12422 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
12423 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); | |
12424 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); | |
12425 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); | |
12426 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); | |
718e3744 | 12427 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
12428 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); | |
12429 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); | |
12430 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); | |
12431 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
12432 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
12433 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
12434 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
12435 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); | |
12436 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
12437 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); | |
12438 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
12439 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); | |
12440 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
12441 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
12442 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
12443 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
12444 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
95cbbd2a | 12445 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 12446 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
12447 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
12448 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
12449 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
12450 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); | |
12451 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); | |
12452 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); | |
12453 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); | |
12454 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
12455 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); | |
12456 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
12457 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
12458 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
12459 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); | |
12460 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
12461 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 12462 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
95cbbd2a | 12463 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12464 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
95cbbd2a | 12465 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12466 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12467 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
2a71e9ce TP |
12468 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
12469 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 12470 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
95cbbd2a | 12471 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12472 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12473 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12474 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12475 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
62687ff1 PJ |
12476 | |
12477 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ | |
12478 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); | |
12479 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); | |
95cbbd2a | 12480 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
62687ff1 PJ |
12481 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
12482 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); | |
12483 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
95cbbd2a | 12484 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
62687ff1 PJ |
12485 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
12486 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
12487 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); | |
12488 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); | |
12489 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); | |
12490 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); | |
12491 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); | |
12492 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); | |
12493 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); | |
12494 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
12495 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
12496 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
95cbbd2a ML |
12497 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
12498 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); | |
12499 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); | |
12500 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); | |
12501 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); | |
62687ff1 PJ |
12502 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
12503 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); | |
12504 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); | |
12505 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); | |
12506 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
12507 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
12508 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
12509 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
12510 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); | |
95cbbd2a | 12511 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
62687ff1 | 12512 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12513 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
62687ff1 | 12514 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12515 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
62687ff1 | 12516 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12517 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
718e3744 | 12518 | |
12519 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); | |
12520 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); | |
95cbbd2a | 12521 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 12522 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
12523 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); | |
95cbbd2a | 12524 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 12525 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
12526 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
12527 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); | |
12528 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
95cbbd2a | 12529 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
718e3744 | 12530 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
12531 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
12532 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); | |
12533 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); | |
12534 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); | |
12535 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); | |
12536 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
12537 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); | |
12538 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
12539 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); | |
12540 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
12541 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); | |
12542 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
12543 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); | |
12544 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
12545 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); | |
12546 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
12547 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); | |
12548 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); | |
12549 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); | |
12550 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); | |
12551 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); | |
12552 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
12553 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
12554 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
95cbbd2a ML |
12555 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
12556 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); | |
12557 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); | |
12558 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); | |
12559 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); | |
718e3744 | 12560 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
12561 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); | |
12562 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); | |
12563 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); | |
12564 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
12565 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
12566 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
12567 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
12568 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); | |
12569 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
12570 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); | |
12571 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
12572 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); | |
12573 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
12574 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
12575 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
12576 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
12577 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
95cbbd2a | 12578 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 12579 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
12580 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
12581 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
12582 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
12583 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); | |
12584 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); | |
12585 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); | |
12586 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); | |
12587 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
12588 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); | |
12589 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
12590 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
12591 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
12592 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); | |
12593 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
12594 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 12595 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
95cbbd2a | 12596 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12597 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
95cbbd2a | 12598 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12599 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12600 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
2a71e9ce TP |
12601 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
12602 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 12603 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
95cbbd2a | 12604 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12605 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12606 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12607 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12608 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
718e3744 | 12609 | |
12610 | /* BGP dampening clear commands */ | |
12611 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); | |
12612 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); | |
12613 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); | |
12614 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); | |
12615 | ||
ff7924f6 PJ |
12616 | /* prefix count */ |
12617 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); | |
12618 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); | |
12619 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); | |
718e3744 | 12620 | #ifdef HAVE_IPV6 |
ff7924f6 PJ |
12621 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
12622 | ||
718e3744 | 12623 | /* New config IPv6 BGP commands. */ |
12624 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); | |
12625 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); | |
12626 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); | |
12627 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); | |
12628 | ||
12629 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); | |
12630 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); | |
12631 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); | |
12632 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); | |
12633 | ||
12634 | /* Old config IPv6 BGP commands. */ | |
12635 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); | |
12636 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); | |
12637 | ||
12638 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); | |
12639 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); | |
12640 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); | |
12641 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); | |
12642 | ||
12643 | install_element (VIEW_NODE, &show_bgp_cmd); | |
12644 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 12645 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 12646 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
12647 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 12648 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
718e3744 | 12649 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
12650 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 12651 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
718e3744 | 12652 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
12653 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); | |
12654 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); | |
12655 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12656 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); | |
12657 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12658 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); | |
12659 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); | |
12660 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); | |
12661 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); | |
12662 | install_element (VIEW_NODE, &show_bgp_community_cmd); | |
12663 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); | |
12664 | install_element (VIEW_NODE, &show_bgp_community2_cmd); | |
12665 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); | |
12666 | install_element (VIEW_NODE, &show_bgp_community3_cmd); | |
12667 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); | |
12668 | install_element (VIEW_NODE, &show_bgp_community4_cmd); | |
12669 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); | |
12670 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); | |
12671 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12672 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); | |
12673 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12674 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); | |
12675 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12676 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); | |
12677 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12678 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); | |
12679 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); | |
12680 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); | |
12681 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12682 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); | |
12683 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12684 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12685 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12686 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12687 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12688 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); | |
12689 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12690 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12691 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12692 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
12693 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12694 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); | |
12695 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12696 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
95cbbd2a | 12697 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12698 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
95cbbd2a | 12699 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12700 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12701 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
bb46e94f | 12702 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
12703 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); | |
12704 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); | |
12705 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); | |
12706 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); | |
12707 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12708 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12709 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12710 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12711 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12712 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12713 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12714 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12715 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12716 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12717 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12718 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12719 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12720 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
95cbbd2a | 12721 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12722 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12723 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12724 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12725 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
62687ff1 PJ |
12726 | |
12727 | /* Restricted: | |
12728 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) | |
12729 | */ | |
12730 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); | |
12731 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 12732 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
62687ff1 PJ |
12733 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
12734 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 12735 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
62687ff1 PJ |
12736 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
12737 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); | |
12738 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); | |
12739 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); | |
12740 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); | |
12741 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); | |
12742 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); | |
12743 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); | |
12744 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); | |
12745 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12746 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); | |
12747 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12748 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); | |
12749 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12750 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); | |
12751 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12752 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); | |
95cbbd2a | 12753 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
62687ff1 | 12754 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12755 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
62687ff1 PJ |
12756 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
12757 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); | |
12758 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); | |
12759 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12760 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12761 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12762 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); | |
95cbbd2a | 12763 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
62687ff1 | 12764 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12765 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
718e3744 | 12766 | |
12767 | install_element (ENABLE_NODE, &show_bgp_cmd); | |
12768 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 12769 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 12770 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
12771 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 12772 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
718e3744 | 12773 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
12774 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 12775 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
718e3744 | 12776 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
12777 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); | |
12778 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); | |
12779 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12780 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); | |
12781 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12782 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); | |
12783 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); | |
12784 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); | |
12785 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); | |
12786 | install_element (ENABLE_NODE, &show_bgp_community_cmd); | |
12787 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); | |
12788 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); | |
12789 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); | |
12790 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); | |
12791 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); | |
12792 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); | |
12793 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); | |
12794 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); | |
12795 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12796 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); | |
12797 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12798 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); | |
12799 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12800 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); | |
12801 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12802 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); | |
12803 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); | |
12804 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); | |
12805 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12806 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); | |
12807 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12808 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12809 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12810 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12811 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12812 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); | |
12813 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12814 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12815 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12816 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
12817 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12818 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); | |
12819 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12820 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
95cbbd2a | 12821 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12822 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
95cbbd2a | 12823 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12824 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12825 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
bb46e94f | 12826 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
12827 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); | |
12828 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); | |
12829 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); | |
12830 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); | |
12831 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12832 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12833 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12834 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12835 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12836 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12837 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12838 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12839 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12840 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12841 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12842 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12843 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12844 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
95cbbd2a | 12845 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12846 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12847 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12848 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12849 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
2815e61f PJ |
12850 | |
12851 | /* Statistics */ | |
12852 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); | |
12853 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); | |
12854 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); | |
12855 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); | |
12856 | ||
718e3744 | 12857 | /* old command */ |
12858 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); | |
12859 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); | |
12860 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); | |
12861 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); | |
12862 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12863 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12864 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); | |
12865 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); | |
12866 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); | |
12867 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); | |
12868 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); | |
12869 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12870 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12871 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12872 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12873 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); | |
12874 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12875 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12876 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); | |
12877 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); | |
12878 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12879 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12880 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12881 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12882 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12883 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); | |
12884 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); | |
12885 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); | |
12886 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); | |
12887 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12888 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12889 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12890 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12891 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12892 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
12893 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
bb46e94f | 12894 | |
718e3744 | 12895 | /* old command */ |
12896 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); | |
12897 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); | |
12898 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); | |
12899 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); | |
12900 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12901 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12902 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); | |
12903 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); | |
12904 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); | |
12905 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); | |
12906 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); | |
12907 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12908 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12909 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12910 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12911 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); | |
12912 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12913 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12914 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); | |
12915 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); | |
12916 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12917 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12918 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12919 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12920 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12921 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); | |
12922 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); | |
12923 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); | |
12924 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); | |
12925 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12926 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12927 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12928 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12929 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12930 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
12931 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
12932 | ||
12933 | /* old command */ | |
12934 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
12935 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
12936 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
12937 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
12938 | ||
12939 | /* old command */ | |
12940 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
12941 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
12942 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
12943 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
12944 | ||
12945 | /* old command */ | |
12946 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
12947 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
12948 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
12949 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
12950 | #endif /* HAVE_IPV6 */ | |
12951 | ||
12952 | install_element (BGP_NODE, &bgp_distance_cmd); | |
12953 | install_element (BGP_NODE, &no_bgp_distance_cmd); | |
12954 | install_element (BGP_NODE, &no_bgp_distance2_cmd); | |
12955 | install_element (BGP_NODE, &bgp_distance_source_cmd); | |
12956 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); | |
12957 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); | |
12958 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); | |
12959 | ||
12960 | install_element (BGP_NODE, &bgp_damp_set_cmd); | |
12961 | install_element (BGP_NODE, &bgp_damp_set2_cmd); | |
12962 | install_element (BGP_NODE, &bgp_damp_set3_cmd); | |
12963 | install_element (BGP_NODE, &bgp_damp_unset_cmd); | |
12964 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); | |
12965 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); | |
12966 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); | |
12967 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); | |
12968 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); | |
12969 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); | |
c8f3fe30 PJ |
12970 | |
12971 | /* Deprecated AS-Pathlimit commands */ | |
12972 | install_element (BGP_NODE, &bgp_network_ttl_cmd); | |
12973 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); | |
12974 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); | |
12975 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); | |
12976 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
12977 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
12978 | ||
12979 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); | |
12980 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); | |
12981 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
12982 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
12983 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
12984 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
12985 | ||
12986 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); | |
12987 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); | |
12988 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); | |
12989 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); | |
12990 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
12991 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
12992 | ||
12993 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); | |
12994 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); | |
12995 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
12996 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
12997 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
12998 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
12999 | ||
13000 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); | |
13001 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); | |
13002 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); | |
13003 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); | |
13004 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
13005 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
13006 | ||
13007 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); | |
13008 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); | |
13009 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
13010 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
13011 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
13012 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
3bde17f1 PJ |
13013 | |
13014 | #ifdef HAVE_IPV6 | |
c8f3fe30 PJ |
13015 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
13016 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); | |
3bde17f1 | 13017 | #endif |
718e3744 | 13018 | } |
228da428 CC |
13019 | |
13020 | void | |
13021 | bgp_route_finish (void) | |
13022 | { | |
13023 | bgp_table_unlock (bgp_distance_table); | |
13024 | bgp_distance_table = NULL; | |
13025 | } |