]>
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" |
718e3744 | 57 | |
58 | /* Extern from bgp_dump.c */ | |
dde72586 SH |
59 | extern const char *bgp_origin_str[]; |
60 | extern const char *bgp_origin_long_str[]; | |
718e3744 | 61 | \f |
94f2b392 | 62 | static struct bgp_node * |
fee0f4c6 | 63 | bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, |
718e3744 | 64 | struct prefix_rd *prd) |
65 | { | |
66 | struct bgp_node *rn; | |
67 | struct bgp_node *prn = NULL; | |
da5b30f6 PJ |
68 | |
69 | assert (table); | |
70 | if (!table) | |
71 | return NULL; | |
72 | ||
718e3744 | 73 | if (safi == SAFI_MPLS_VPN) |
74 | { | |
fee0f4c6 | 75 | prn = bgp_node_get (table, (struct prefix *) prd); |
718e3744 | 76 | |
77 | if (prn->info == NULL) | |
64e580a7 | 78 | prn->info = bgp_table_init (afi, safi); |
718e3744 | 79 | else |
80 | bgp_unlock_node (prn); | |
81 | table = prn->info; | |
82 | } | |
718e3744 | 83 | |
84 | rn = bgp_node_get (table, p); | |
85 | ||
86 | if (safi == SAFI_MPLS_VPN) | |
87 | rn->prn = prn; | |
88 | ||
89 | return rn; | |
90 | } | |
91 | \f | |
fb982c25 PJ |
92 | /* Allocate bgp_info_extra */ |
93 | static struct bgp_info_extra * | |
94 | bgp_info_extra_new (void) | |
95 | { | |
96 | struct bgp_info_extra *new; | |
97 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); | |
98 | return new; | |
99 | } | |
100 | ||
101 | static void | |
102 | bgp_info_extra_free (struct bgp_info_extra **extra) | |
103 | { | |
104 | if (extra && *extra) | |
105 | { | |
106 | if ((*extra)->damp_info) | |
107 | bgp_damp_info_free ((*extra)->damp_info, 0); | |
108 | ||
109 | (*extra)->damp_info = NULL; | |
110 | ||
111 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); | |
112 | ||
113 | *extra = NULL; | |
114 | } | |
115 | } | |
116 | ||
117 | /* Get bgp_info extra information for the given bgp_info, lazy allocated | |
118 | * if required. | |
119 | */ | |
120 | struct bgp_info_extra * | |
121 | bgp_info_extra_get (struct bgp_info *ri) | |
122 | { | |
123 | if (!ri->extra) | |
124 | ri->extra = bgp_info_extra_new(); | |
125 | return ri->extra; | |
126 | } | |
127 | ||
718e3744 | 128 | /* Allocate new bgp info structure. */ |
200df115 | 129 | static struct bgp_info * |
66e5cd87 | 130 | bgp_info_new (void) |
718e3744 | 131 | { |
393deb9b | 132 | return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
718e3744 | 133 | } |
134 | ||
135 | /* Free bgp route information. */ | |
200df115 | 136 | static void |
718e3744 | 137 | bgp_info_free (struct bgp_info *binfo) |
138 | { | |
139 | if (binfo->attr) | |
f6f434b2 | 140 | bgp_attr_unintern (&binfo->attr); |
fb982c25 PJ |
141 | |
142 | bgp_info_extra_free (&binfo->extra); | |
718e3744 | 143 | |
200df115 | 144 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
145 | ||
718e3744 | 146 | XFREE (MTYPE_BGP_ROUTE, binfo); |
147 | } | |
148 | ||
200df115 | 149 | struct bgp_info * |
150 | bgp_info_lock (struct bgp_info *binfo) | |
151 | { | |
152 | binfo->lock++; | |
153 | return binfo; | |
154 | } | |
155 | ||
156 | struct bgp_info * | |
157 | bgp_info_unlock (struct bgp_info *binfo) | |
158 | { | |
159 | assert (binfo && binfo->lock > 0); | |
160 | binfo->lock--; | |
161 | ||
162 | if (binfo->lock == 0) | |
163 | { | |
164 | #if 0 | |
165 | zlog_debug ("%s: unlocked and freeing", __func__); | |
166 | zlog_backtrace (LOG_DEBUG); | |
167 | #endif | |
168 | bgp_info_free (binfo); | |
169 | return NULL; | |
170 | } | |
171 | ||
172 | #if 0 | |
173 | if (binfo->lock == 1) | |
174 | { | |
175 | zlog_debug ("%s: unlocked to 1", __func__); | |
176 | zlog_backtrace (LOG_DEBUG); | |
177 | } | |
178 | #endif | |
179 | ||
180 | return binfo; | |
181 | } | |
182 | ||
718e3744 | 183 | void |
184 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) | |
185 | { | |
186 | struct bgp_info *top; | |
187 | ||
188 | top = rn->info; | |
200df115 | 189 | |
718e3744 | 190 | ri->next = rn->info; |
191 | ri->prev = NULL; | |
192 | if (top) | |
193 | top->prev = ri; | |
194 | rn->info = ri; | |
200df115 | 195 | |
196 | bgp_info_lock (ri); | |
197 | bgp_lock_node (rn); | |
198 | peer_lock (ri->peer); /* bgp_info peer reference */ | |
718e3744 | 199 | } |
200 | ||
b40d939b | 201 | /* Do the actual removal of info from RIB, for use by bgp_process |
202 | completion callback *only* */ | |
203 | static void | |
204 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) | |
718e3744 | 205 | { |
206 | if (ri->next) | |
207 | ri->next->prev = ri->prev; | |
208 | if (ri->prev) | |
209 | ri->prev->next = ri->next; | |
210 | else | |
211 | rn->info = ri->next; | |
200df115 | 212 | |
213 | bgp_info_unlock (ri); | |
214 | bgp_unlock_node (rn); | |
718e3744 | 215 | } |
216 | ||
b40d939b | 217 | void |
218 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) | |
219 | { | |
1a392d46 PJ |
220 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
221 | /* set of previous already took care of pcount */ | |
b40d939b | 222 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
223 | } | |
224 | ||
8d45210e AS |
225 | /* undo the effects of a previous call to bgp_info_delete; typically |
226 | called when a route is deleted and then quickly re-added before the | |
227 | deletion has been processed */ | |
228 | static void | |
229 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) | |
230 | { | |
231 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); | |
232 | /* unset of previous already took care of pcount */ | |
233 | SET_FLAG (ri->flags, BGP_INFO_VALID); | |
234 | } | |
235 | ||
1a392d46 PJ |
236 | /* Adjust pcount as required */ |
237 | static void | |
238 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) | |
239 | { | |
6f58544d PJ |
240 | assert (rn && rn->table); |
241 | assert (ri && ri->peer && ri->peer->bgp); | |
242 | ||
1a392d46 PJ |
243 | /* Ignore 'pcount' for RS-client tables */ |
244 | if (rn->table->type != BGP_TABLE_MAIN | |
245 | || ri->peer == ri->peer->bgp->peer_self) | |
246 | return; | |
247 | ||
248 | if (BGP_INFO_HOLDDOWN (ri) | |
249 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
250 | { | |
251 | ||
252 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
253 | ||
254 | /* slight hack, but more robust against errors. */ | |
255 | if (ri->peer->pcount[rn->table->afi][rn->table->safi]) | |
256 | ri->peer->pcount[rn->table->afi][rn->table->safi]--; | |
257 | else | |
258 | { | |
259 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", | |
260 | __func__, ri->peer->host); | |
261 | zlog_backtrace (LOG_WARNING); | |
262 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); | |
263 | } | |
264 | } | |
265 | else if (!BGP_INFO_HOLDDOWN (ri) | |
266 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
267 | { | |
268 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); | |
269 | ri->peer->pcount[rn->table->afi][rn->table->safi]++; | |
270 | } | |
271 | } | |
272 | ||
273 | ||
274 | /* Set/unset bgp_info flags, adjusting any other state as needed. | |
275 | * This is here primarily to keep prefix-count in check. | |
276 | */ | |
277 | void | |
278 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
279 | { | |
280 | SET_FLAG (ri->flags, flag); | |
281 | ||
282 | /* early bath if we know it's not a flag that changes useability state */ | |
283 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) | |
284 | return; | |
285 | ||
286 | bgp_pcount_adjust (rn, ri); | |
287 | } | |
288 | ||
289 | void | |
290 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) | |
291 | { | |
292 | UNSET_FLAG (ri->flags, flag); | |
293 | ||
294 | /* early bath if we know it's not a flag that changes useability state */ | |
295 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) | |
296 | return; | |
297 | ||
298 | bgp_pcount_adjust (rn, ri); | |
299 | } | |
300 | ||
718e3744 | 301 | /* Get MED value. If MED value is missing and "bgp bestpath |
302 | missing-as-worst" is specified, treat it as the worst value. */ | |
94f2b392 | 303 | static u_int32_t |
718e3744 | 304 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
305 | { | |
306 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
307 | return attr->med; | |
308 | else | |
309 | { | |
310 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
3b424979 | 311 | return BGP_MED_MAX; |
718e3744 | 312 | else |
313 | return 0; | |
314 | } | |
315 | } | |
316 | ||
317 | /* Compare two bgp route entity. br is preferable then return 1. */ | |
94f2b392 | 318 | static int |
718e3744 | 319 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) |
320 | { | |
321 | u_int32_t new_pref; | |
322 | u_int32_t exist_pref; | |
323 | u_int32_t new_med; | |
324 | u_int32_t exist_med; | |
fb982c25 PJ |
325 | u_int32_t new_weight = 0; |
326 | u_int32_t exist_weight = 0; | |
718e3744 | 327 | struct in_addr new_id; |
328 | struct in_addr exist_id; | |
329 | int new_cluster; | |
330 | int exist_cluster; | |
331 | int internal_as_route = 0; | |
332 | int confed_as_route = 0; | |
333 | int ret; | |
334 | ||
335 | /* 0. Null check. */ | |
336 | if (new == NULL) | |
337 | return 0; | |
338 | if (exist == NULL) | |
339 | return 1; | |
340 | ||
341 | /* 1. Weight check. */ | |
fb982c25 PJ |
342 | if (new->attr->extra) |
343 | new_weight = new->attr->extra->weight; | |
344 | if (exist->attr->extra) | |
345 | exist_weight = exist->attr->extra->weight; | |
346 | if (new_weight > exist_weight) | |
718e3744 | 347 | return 1; |
fb982c25 | 348 | if (new_weight < exist_weight) |
718e3744 | 349 | return 0; |
350 | ||
351 | /* 2. Local preference check. */ | |
352 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
353 | new_pref = new->attr->local_pref; | |
354 | else | |
355 | new_pref = bgp->default_local_pref; | |
356 | ||
357 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
358 | exist_pref = exist->attr->local_pref; | |
359 | else | |
360 | exist_pref = bgp->default_local_pref; | |
361 | ||
362 | if (new_pref > exist_pref) | |
363 | return 1; | |
364 | if (new_pref < exist_pref) | |
365 | return 0; | |
366 | ||
367 | /* 3. Local route check. */ | |
368 | if (new->sub_type == BGP_ROUTE_STATIC) | |
369 | return 1; | |
370 | if (exist->sub_type == BGP_ROUTE_STATIC) | |
371 | return 0; | |
372 | ||
373 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
374 | return 1; | |
375 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
376 | return 0; | |
377 | ||
378 | if (new->sub_type == BGP_ROUTE_AGGREGATE) | |
379 | return 1; | |
380 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) | |
381 | return 0; | |
382 | ||
383 | /* 4. AS path length check. */ | |
384 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) | |
385 | { | |
fe69a505 | 386 | int exist_hops = aspath_count_hops (exist->attr->aspath); |
387 | int exist_confeds = aspath_count_confeds (exist->attr->aspath); | |
388 | ||
6811845b | 389 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
390 | { | |
fe69a505 | 391 | int aspath_hops; |
392 | ||
393 | aspath_hops = aspath_count_hops (new->attr->aspath); | |
394 | aspath_hops += aspath_count_confeds (new->attr->aspath); | |
395 | ||
396 | if ( aspath_hops < (exist_hops + exist_confeds)) | |
6811845b | 397 | return 1; |
fe69a505 | 398 | if ( aspath_hops > (exist_hops + exist_confeds)) |
6811845b | 399 | return 0; |
400 | } | |
401 | else | |
402 | { | |
fe69a505 | 403 | int newhops = aspath_count_hops (new->attr->aspath); |
404 | ||
405 | if (newhops < exist_hops) | |
6811845b | 406 | return 1; |
fe69a505 | 407 | if (newhops > exist_hops) |
6811845b | 408 | return 0; |
409 | } | |
718e3744 | 410 | } |
411 | ||
412 | /* 5. Origin check. */ | |
413 | if (new->attr->origin < exist->attr->origin) | |
414 | return 1; | |
415 | if (new->attr->origin > exist->attr->origin) | |
416 | return 0; | |
417 | ||
418 | /* 6. MED check. */ | |
fe69a505 | 419 | internal_as_route = (aspath_count_hops (new->attr->aspath) == 0 |
420 | && aspath_count_hops (exist->attr->aspath) == 0); | |
421 | confed_as_route = (aspath_count_confeds (new->attr->aspath) > 0 | |
422 | && aspath_count_confeds (exist->attr->aspath) > 0 | |
423 | && aspath_count_hops (new->attr->aspath) == 0 | |
424 | && aspath_count_hops (exist->attr->aspath) == 0); | |
718e3744 | 425 | |
426 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) | |
427 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) | |
428 | && confed_as_route) | |
429 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) | |
430 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) | |
431 | || internal_as_route) | |
432 | { | |
433 | new_med = bgp_med_value (new->attr, bgp); | |
434 | exist_med = bgp_med_value (exist->attr, bgp); | |
435 | ||
436 | if (new_med < exist_med) | |
437 | return 1; | |
438 | if (new_med > exist_med) | |
439 | return 0; | |
440 | } | |
441 | ||
442 | /* 7. Peer type check. */ | |
443 | if (peer_sort (new->peer) == BGP_PEER_EBGP | |
444 | && peer_sort (exist->peer) == BGP_PEER_IBGP) | |
445 | return 1; | |
446 | if (peer_sort (new->peer) == BGP_PEER_EBGP | |
447 | && peer_sort (exist->peer) == BGP_PEER_CONFED) | |
448 | return 1; | |
449 | if (peer_sort (new->peer) == BGP_PEER_IBGP | |
450 | && peer_sort (exist->peer) == BGP_PEER_EBGP) | |
451 | return 0; | |
452 | if (peer_sort (new->peer) == BGP_PEER_CONFED | |
453 | && peer_sort (exist->peer) == BGP_PEER_EBGP) | |
454 | return 0; | |
455 | ||
456 | /* 8. IGP metric check. */ | |
fb982c25 PJ |
457 | if (new->extra || exist->extra) |
458 | { | |
459 | uint32_t newm = (new->extra ? new->extra->igpmetric : 0); | |
460 | uint32_t existm = (exist->extra ? exist->extra->igpmetric : 0); | |
461 | ||
462 | if (newm < existm) | |
463 | return 1; | |
464 | if (newm > existm) | |
465 | return 0; | |
466 | } | |
718e3744 | 467 | |
468 | /* 9. Maximum path check. */ | |
469 | ||
470 | /* 10. If both paths are external, prefer the path that was received | |
471 | first (the oldest one). This step minimizes route-flap, since a | |
472 | newer path won't displace an older one, even if it was the | |
473 | preferred route based on the additional decision criteria below. */ | |
474 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) | |
475 | && peer_sort (new->peer) == BGP_PEER_EBGP | |
476 | && peer_sort (exist->peer) == BGP_PEER_EBGP) | |
477 | { | |
478 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) | |
479 | return 1; | |
480 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) | |
481 | return 0; | |
482 | } | |
483 | ||
484 | /* 11. Rourter-ID comparision. */ | |
485 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) | |
fb982c25 | 486 | new_id.s_addr = new->attr->extra->originator_id.s_addr; |
718e3744 | 487 | else |
488 | new_id.s_addr = new->peer->remote_id.s_addr; | |
489 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) | |
fb982c25 | 490 | exist_id.s_addr = exist->attr->extra->originator_id.s_addr; |
718e3744 | 491 | else |
492 | exist_id.s_addr = exist->peer->remote_id.s_addr; | |
493 | ||
494 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) | |
495 | return 1; | |
496 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) | |
497 | return 0; | |
498 | ||
499 | /* 12. Cluster length comparision. */ | |
500 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
fb982c25 | 501 | new_cluster = new->attr->extra->cluster->length; |
718e3744 | 502 | else |
503 | new_cluster = 0; | |
504 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
fb982c25 | 505 | exist_cluster = exist->attr->extra->cluster->length; |
718e3744 | 506 | else |
507 | exist_cluster = 0; | |
508 | ||
509 | if (new_cluster < exist_cluster) | |
510 | return 1; | |
511 | if (new_cluster > exist_cluster) | |
512 | return 0; | |
513 | ||
514 | /* 13. Neighbor address comparision. */ | |
515 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); | |
516 | ||
517 | if (ret == 1) | |
518 | return 0; | |
519 | if (ret == -1) | |
520 | return 1; | |
521 | ||
522 | return 1; | |
523 | } | |
524 | ||
94f2b392 | 525 | static enum filter_type |
718e3744 | 526 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
527 | afi_t afi, safi_t safi) | |
528 | { | |
529 | struct bgp_filter *filter; | |
530 | ||
531 | filter = &peer->filter[afi][safi]; | |
532 | ||
650f76c2 PJ |
533 | #define FILTER_EXIST_WARN(F,f,filter) \ |
534 | if (BGP_DEBUG (update, UPDATE_IN) \ | |
535 | && !(F ## _IN (filter))) \ | |
536 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ | |
537 | peer->host, #f, F ## _IN_NAME(filter)); | |
538 | ||
539 | if (DISTRIBUTE_IN_NAME (filter)) { | |
540 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
541 | ||
718e3744 | 542 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
543 | return FILTER_DENY; | |
650f76c2 | 544 | } |
718e3744 | 545 | |
650f76c2 PJ |
546 | if (PREFIX_LIST_IN_NAME (filter)) { |
547 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
548 | ||
718e3744 | 549 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
550 | return FILTER_DENY; | |
650f76c2 | 551 | } |
718e3744 | 552 | |
650f76c2 PJ |
553 | if (FILTER_LIST_IN_NAME (filter)) { |
554 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
555 | ||
718e3744 | 556 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
557 | return FILTER_DENY; | |
650f76c2 PJ |
558 | } |
559 | ||
718e3744 | 560 | return FILTER_PERMIT; |
650f76c2 | 561 | #undef FILTER_EXIST_WARN |
718e3744 | 562 | } |
563 | ||
94f2b392 | 564 | static enum filter_type |
718e3744 | 565 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
566 | afi_t afi, safi_t safi) | |
567 | { | |
568 | struct bgp_filter *filter; | |
569 | ||
570 | filter = &peer->filter[afi][safi]; | |
571 | ||
650f76c2 PJ |
572 | #define FILTER_EXIST_WARN(F,f,filter) \ |
573 | if (BGP_DEBUG (update, UPDATE_OUT) \ | |
574 | && !(F ## _OUT (filter))) \ | |
575 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ | |
576 | peer->host, #f, F ## _OUT_NAME(filter)); | |
577 | ||
578 | if (DISTRIBUTE_OUT_NAME (filter)) { | |
579 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); | |
580 | ||
718e3744 | 581 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
582 | return FILTER_DENY; | |
650f76c2 | 583 | } |
718e3744 | 584 | |
650f76c2 PJ |
585 | if (PREFIX_LIST_OUT_NAME (filter)) { |
586 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); | |
587 | ||
718e3744 | 588 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
589 | return FILTER_DENY; | |
650f76c2 | 590 | } |
718e3744 | 591 | |
650f76c2 PJ |
592 | if (FILTER_LIST_OUT_NAME (filter)) { |
593 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); | |
594 | ||
718e3744 | 595 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
596 | return FILTER_DENY; | |
650f76c2 | 597 | } |
718e3744 | 598 | |
599 | return FILTER_PERMIT; | |
650f76c2 | 600 | #undef FILTER_EXIST_WARN |
718e3744 | 601 | } |
602 | ||
603 | /* If community attribute includes no_export then return 1. */ | |
94f2b392 | 604 | static int |
718e3744 | 605 | bgp_community_filter (struct peer *peer, struct attr *attr) |
606 | { | |
607 | if (attr->community) | |
608 | { | |
609 | /* NO_ADVERTISE check. */ | |
610 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) | |
611 | return 1; | |
612 | ||
613 | /* NO_EXPORT check. */ | |
614 | if (peer_sort (peer) == BGP_PEER_EBGP && | |
615 | community_include (attr->community, COMMUNITY_NO_EXPORT)) | |
616 | return 1; | |
617 | ||
618 | /* NO_EXPORT_SUBCONFED check. */ | |
619 | if (peer_sort (peer) == BGP_PEER_EBGP | |
620 | || peer_sort (peer) == BGP_PEER_CONFED) | |
621 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) | |
622 | return 1; | |
623 | } | |
624 | return 0; | |
625 | } | |
626 | ||
627 | /* Route reflection loop check. */ | |
628 | static int | |
629 | bgp_cluster_filter (struct peer *peer, struct attr *attr) | |
630 | { | |
631 | struct in_addr cluster_id; | |
632 | ||
fb982c25 | 633 | if (attr->extra && attr->extra->cluster) |
718e3744 | 634 | { |
635 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) | |
636 | cluster_id = peer->bgp->cluster_id; | |
637 | else | |
638 | cluster_id = peer->bgp->router_id; | |
639 | ||
fb982c25 | 640 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
718e3744 | 641 | return 1; |
642 | } | |
643 | return 0; | |
644 | } | |
645 | \f | |
94f2b392 | 646 | static int |
718e3744 | 647 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
648 | afi_t afi, safi_t safi) | |
649 | { | |
650 | struct bgp_filter *filter; | |
651 | struct bgp_info info; | |
652 | route_map_result_t ret; | |
653 | ||
654 | filter = &peer->filter[afi][safi]; | |
655 | ||
656 | /* Apply default weight value. */ | |
fb982c25 PJ |
657 | if (peer->weight) |
658 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
718e3744 | 659 | |
660 | /* Route map apply. */ | |
661 | if (ROUTE_MAP_IN_NAME (filter)) | |
662 | { | |
663 | /* Duplicate current value to new strucutre for modification. */ | |
664 | info.peer = peer; | |
665 | info.attr = attr; | |
666 | ||
ac41b2a2 | 667 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
668 | ||
718e3744 | 669 | /* Apply BGP route map to the attribute. */ |
670 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); | |
ac41b2a2 | 671 | |
672 | peer->rmap_type = 0; | |
673 | ||
718e3744 | 674 | if (ret == RMAP_DENYMATCH) |
675 | { | |
676 | /* Free newly generated AS path and community by route-map. */ | |
677 | bgp_attr_flush (attr); | |
678 | return RMAP_DENY; | |
679 | } | |
680 | } | |
681 | return RMAP_PERMIT; | |
682 | } | |
683 | \f | |
94f2b392 | 684 | static int |
fee0f4c6 | 685 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
686 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
687 | { | |
688 | struct bgp_filter *filter; | |
689 | struct bgp_info info; | |
690 | route_map_result_t ret; | |
691 | ||
692 | filter = &peer->filter[afi][safi]; | |
693 | ||
694 | /* Route map apply. */ | |
695 | if (ROUTE_MAP_EXPORT_NAME (filter)) | |
696 | { | |
697 | /* Duplicate current value to new strucutre for modification. */ | |
698 | info.peer = rsclient; | |
699 | info.attr = attr; | |
700 | ||
701 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); | |
702 | ||
703 | /* Apply BGP route map to the attribute. */ | |
704 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); | |
705 | ||
706 | rsclient->rmap_type = 0; | |
707 | ||
708 | if (ret == RMAP_DENYMATCH) | |
709 | { | |
710 | /* Free newly generated AS path and community by route-map. */ | |
711 | bgp_attr_flush (attr); | |
712 | return RMAP_DENY; | |
713 | } | |
714 | } | |
715 | return RMAP_PERMIT; | |
716 | } | |
717 | ||
94f2b392 | 718 | static int |
fee0f4c6 | 719 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
720 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
721 | { | |
722 | struct bgp_filter *filter; | |
723 | struct bgp_info info; | |
724 | route_map_result_t ret; | |
725 | ||
726 | filter = &rsclient->filter[afi][safi]; | |
727 | ||
728 | /* Apply default weight value. */ | |
fb982c25 PJ |
729 | if (peer->weight) |
730 | (bgp_attr_extra_get (attr))->weight = peer->weight; | |
fee0f4c6 | 731 | |
732 | /* Route map apply. */ | |
733 | if (ROUTE_MAP_IMPORT_NAME (filter)) | |
734 | { | |
735 | /* Duplicate current value to new strucutre for modification. */ | |
736 | info.peer = peer; | |
737 | info.attr = attr; | |
738 | ||
739 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); | |
740 | ||
741 | /* Apply BGP route map to the attribute. */ | |
742 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); | |
743 | ||
744 | peer->rmap_type = 0; | |
745 | ||
746 | if (ret == RMAP_DENYMATCH) | |
747 | { | |
748 | /* Free newly generated AS path and community by route-map. */ | |
749 | bgp_attr_flush (attr); | |
750 | return RMAP_DENY; | |
751 | } | |
752 | } | |
753 | return RMAP_PERMIT; | |
754 | } | |
755 | \f | |
94f2b392 | 756 | static int |
718e3744 | 757 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
758 | struct attr *attr, afi_t afi, safi_t safi) | |
759 | { | |
760 | int ret; | |
761 | char buf[SU_ADDRSTRLEN]; | |
762 | struct bgp_filter *filter; | |
718e3744 | 763 | struct peer *from; |
764 | struct bgp *bgp; | |
718e3744 | 765 | int transparent; |
766 | int reflect; | |
767 | ||
768 | from = ri->peer; | |
769 | filter = &peer->filter[afi][safi]; | |
770 | bgp = peer->bgp; | |
771 | ||
750e8146 PJ |
772 | if (DISABLE_BGP_ANNOUNCE) |
773 | return 0; | |
718e3744 | 774 | |
fee0f4c6 | 775 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
776 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
777 | return 0; | |
778 | ||
718e3744 | 779 | /* Do not send back route to sender. */ |
780 | if (from == peer) | |
781 | return 0; | |
782 | ||
35be31b6 | 783 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
784 | if (p->family == AF_INET | |
785 | && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) | |
786 | return 0; | |
787 | #ifdef HAVE_IPV6 | |
788 | if (p->family == AF_INET6 | |
789 | && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) | |
790 | return 0; | |
791 | #endif | |
792 | ||
718e3744 | 793 | /* Aggregate-address suppress check. */ |
fb982c25 | 794 | if (ri->extra && ri->extra->suppress) |
718e3744 | 795 | if (! UNSUPPRESS_MAP_NAME (filter)) |
796 | return 0; | |
797 | ||
798 | /* Default route check. */ | |
799 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) | |
800 | { | |
801 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
802 | return 0; | |
803 | #ifdef HAVE_IPV6 | |
804 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
805 | return 0; | |
806 | #endif /* HAVE_IPV6 */ | |
807 | } | |
808 | ||
286e1e71 | 809 | /* Transparency check. */ |
810 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) | |
811 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
812 | transparent = 1; | |
813 | else | |
814 | transparent = 0; | |
815 | ||
718e3744 | 816 | /* If community is not disabled check the no-export and local. */ |
286e1e71 | 817 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
718e3744 | 818 | return 0; |
819 | ||
820 | /* If the attribute has originator-id and it is same as remote | |
821 | peer's id. */ | |
822 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) | |
823 | { | |
fb982c25 | 824 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->extra->originator_id)) |
718e3744 | 825 | { |
826 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 827 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 828 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
829 | peer->host, | |
830 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
831 | p->prefixlen); | |
832 | return 0; | |
833 | } | |
834 | } | |
835 | ||
836 | /* ORF prefix-list filter check */ | |
837 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
838 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
839 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
840 | if (peer->orf_plist[afi][safi]) | |
841 | { | |
842 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) | |
843 | return 0; | |
844 | } | |
845 | ||
846 | /* Output filter check. */ | |
847 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) | |
848 | { | |
849 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 850 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 851 | "%s [Update:SEND] %s/%d is filtered", |
852 | peer->host, | |
853 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
854 | p->prefixlen); | |
855 | return 0; | |
856 | } | |
857 | ||
858 | #ifdef BGP_SEND_ASPATH_CHECK | |
859 | /* AS path loop check. */ | |
860 | if (aspath_loop_check (ri->attr->aspath, peer->as)) | |
861 | { | |
862 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 863 | zlog (peer->log, LOG_DEBUG, |
aea339f7 | 864 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
718e3744 | 865 | peer->host, peer->as); |
866 | return 0; | |
867 | } | |
868 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
869 | ||
870 | /* If we're a CONFED we need to loop check the CONFED ID too */ | |
871 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
872 | { | |
873 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) | |
874 | { | |
875 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 876 | zlog (peer->log, LOG_DEBUG, |
aea339f7 | 877 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
718e3744 | 878 | peer->host, |
879 | bgp->confed_id); | |
880 | return 0; | |
881 | } | |
882 | } | |
883 | ||
884 | /* Route-Reflect check. */ | |
885 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) | |
886 | reflect = 1; | |
887 | else | |
888 | reflect = 0; | |
889 | ||
890 | /* IBGP reflection check. */ | |
891 | if (reflect) | |
892 | { | |
893 | /* A route from a Client peer. */ | |
894 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
895 | { | |
896 | /* Reflect to all the Non-Client peers and also to the | |
897 | Client peers other than the originator. Originator check | |
898 | is already done. So there is noting to do. */ | |
899 | /* no bgp client-to-client reflection check. */ | |
900 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
901 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
902 | return 0; | |
903 | } | |
904 | else | |
905 | { | |
906 | /* A route from a Non-client peer. Reflect to all other | |
907 | clients. */ | |
908 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
909 | return 0; | |
910 | } | |
911 | } | |
41367172 | 912 | |
718e3744 | 913 | /* For modify attribute, copy it to temporary structure. */ |
fb982c25 PJ |
914 | bgp_attr_dup (attr, ri->attr); |
915 | ||
718e3744 | 916 | /* If local-preference is not set. */ |
917 | if ((peer_sort (peer) == BGP_PEER_IBGP | |
918 | || peer_sort (peer) == BGP_PEER_CONFED) | |
919 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) | |
920 | { | |
921 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); | |
922 | attr->local_pref = bgp->default_local_pref; | |
923 | } | |
924 | ||
718e3744 | 925 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
926 | if (peer_sort (peer) == BGP_PEER_EBGP | |
927 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
928 | { | |
929 | if (ri->peer != bgp->peer_self && ! transparent | |
930 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
931 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); | |
932 | } | |
933 | ||
934 | /* next-hop-set */ | |
935 | if (transparent || reflect | |
936 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) | |
937 | && ((p->family == AF_INET && attr->nexthop.s_addr) | |
286e1e71 | 938 | #ifdef HAVE_IPV6 |
fee0f4c6 | 939 | || (p->family == AF_INET6 && |
fb982c25 | 940 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
286e1e71 | 941 | #endif /* HAVE_IPV6 */ |
942 | ))) | |
718e3744 | 943 | { |
944 | /* NEXT-HOP Unchanged. */ | |
945 | } | |
946 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
947 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) | |
948 | #ifdef HAVE_IPV6 | |
fee0f4c6 | 949 | || (p->family == AF_INET6 && |
fb982c25 | 950 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
718e3744 | 951 | #endif /* HAVE_IPV6 */ |
952 | || (peer_sort (peer) == BGP_PEER_EBGP | |
953 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) | |
954 | { | |
955 | /* Set IPv4 nexthop. */ | |
956 | if (p->family == AF_INET) | |
957 | { | |
958 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
959 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
960 | IPV4_MAX_BYTELEN); | |
718e3744 | 961 | else |
962 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); | |
963 | } | |
964 | #ifdef HAVE_IPV6 | |
965 | /* Set IPv6 nexthop. */ | |
966 | if (p->family == AF_INET6) | |
967 | { | |
968 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 969 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
718e3744 | 970 | IPV6_MAX_BYTELEN); |
fb982c25 | 971 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 972 | } |
973 | #endif /* HAVE_IPV6 */ | |
974 | } | |
975 | ||
976 | #ifdef HAVE_IPV6 | |
977 | if (p->family == AF_INET6) | |
978 | { | |
fee0f4c6 | 979 | /* Left nexthop_local unchanged if so configured. */ |
980 | if ( CHECK_FLAG (peer->af_flags[afi][safi], | |
981 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) | |
982 | { | |
fb982c25 PJ |
983 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
984 | attr->extra->mp_nexthop_len=32; | |
fee0f4c6 | 985 | else |
fb982c25 | 986 | attr->extra->mp_nexthop_len=16; |
fee0f4c6 | 987 | } |
988 | ||
989 | /* Default nexthop_local treatment for non-RS-Clients */ | |
990 | else | |
991 | { | |
718e3744 | 992 | /* Link-local address should not be transit to different peer. */ |
fb982c25 | 993 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 994 | |
995 | /* Set link-local address for shared network peer. */ | |
996 | if (peer->shared_network | |
997 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) | |
998 | { | |
fb982c25 | 999 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
718e3744 | 1000 | IPV6_MAX_BYTELEN); |
fb982c25 | 1001 | attr->extra->mp_nexthop_len = 32; |
718e3744 | 1002 | } |
1003 | ||
1004 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local | |
1005 | address.*/ | |
1006 | if (reflect) | |
fb982c25 | 1007 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1008 | |
1009 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ | |
1010 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) | |
fb982c25 | 1011 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1012 | } |
fee0f4c6 | 1013 | |
1014 | } | |
718e3744 | 1015 | #endif /* HAVE_IPV6 */ |
1016 | ||
1017 | /* If this is EBGP peer and remove-private-AS is set. */ | |
1018 | if (peer_sort (peer) == BGP_PEER_EBGP | |
1019 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) | |
1020 | && aspath_private_as_check (attr->aspath)) | |
1021 | attr->aspath = aspath_empty_get (); | |
1022 | ||
1023 | /* Route map & unsuppress-map apply. */ | |
1024 | if (ROUTE_MAP_OUT_NAME (filter) | |
fb982c25 | 1025 | || (ri->extra && ri->extra->suppress) ) |
718e3744 | 1026 | { |
7c7fa1b4 | 1027 | struct bgp_info info; |
9eda90ce | 1028 | struct attr dummy_attr = { 0 }; |
7c7fa1b4 | 1029 | |
718e3744 | 1030 | info.peer = peer; |
1031 | info.attr = attr; | |
1032 | ||
1033 | /* The route reflector is not allowed to modify the attributes | |
1034 | of the reflected IBGP routes. */ | |
1035 | if (peer_sort (from) == BGP_PEER_IBGP | |
1036 | && peer_sort (peer) == BGP_PEER_IBGP) | |
1037 | { | |
fb982c25 | 1038 | bgp_attr_dup (&dummy_attr, attr); |
9eda90ce | 1039 | info.attr = &dummy_attr; |
718e3744 | 1040 | } |
ac41b2a2 | 1041 | |
1042 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1043 | ||
fb982c25 | 1044 | if (ri->extra && ri->extra->suppress) |
718e3744 | 1045 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
1046 | else | |
1047 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1048 | ||
ac41b2a2 | 1049 | peer->rmap_type = 0; |
fb982c25 | 1050 | |
9eda90ce PJ |
1051 | if (dummy_attr.extra) |
1052 | bgp_attr_extra_free (&dummy_attr); | |
fb982c25 | 1053 | |
718e3744 | 1054 | if (ret == RMAP_DENYMATCH) |
1055 | { | |
1056 | bgp_attr_flush (attr); | |
1057 | return 0; | |
1058 | } | |
1059 | } | |
1060 | return 1; | |
1061 | } | |
1062 | ||
94f2b392 | 1063 | static int |
fee0f4c6 | 1064 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
1065 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
1066 | { | |
1067 | int ret; | |
1068 | char buf[SU_ADDRSTRLEN]; | |
1069 | struct bgp_filter *filter; | |
1070 | struct bgp_info info; | |
1071 | struct peer *from; | |
1072 | struct bgp *bgp; | |
1073 | ||
1074 | from = ri->peer; | |
1075 | filter = &rsclient->filter[afi][safi]; | |
1076 | bgp = rsclient->bgp; | |
1077 | ||
750e8146 PJ |
1078 | if (DISABLE_BGP_ANNOUNCE) |
1079 | return 0; | |
fee0f4c6 | 1080 | |
1081 | /* Do not send back route to sender. */ | |
1082 | if (from == rsclient) | |
1083 | return 0; | |
1084 | ||
1085 | /* Aggregate-address suppress check. */ | |
fb982c25 | 1086 | if (ri->extra && ri->extra->suppress) |
fee0f4c6 | 1087 | if (! UNSUPPRESS_MAP_NAME (filter)) |
1088 | return 0; | |
1089 | ||
1090 | /* Default route check. */ | |
1091 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], | |
1092 | PEER_STATUS_DEFAULT_ORIGINATE)) | |
1093 | { | |
1094 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
1095 | return 0; | |
1096 | #ifdef HAVE_IPV6 | |
1097 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
1098 | return 0; | |
1099 | #endif /* HAVE_IPV6 */ | |
1100 | } | |
1101 | ||
1102 | /* If the attribute has originator-id and it is same as remote | |
1103 | peer's id. */ | |
1104 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) | |
1105 | { | |
fb982c25 PJ |
1106 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
1107 | &ri->attr->extra->originator_id)) | |
fee0f4c6 | 1108 | { |
1109 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1110 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 1111 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
1112 | rsclient->host, | |
1113 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1114 | p->prefixlen); | |
1115 | return 0; | |
1116 | } | |
1117 | } | |
1118 | ||
1119 | /* ORF prefix-list filter check */ | |
1120 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
1121 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
1122 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
1123 | if (rsclient->orf_plist[afi][safi]) | |
1124 | { | |
1125 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) | |
1126 | return 0; | |
1127 | } | |
1128 | ||
1129 | /* Output filter check. */ | |
1130 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) | |
1131 | { | |
1132 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1133 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 1134 | "%s [Update:SEND] %s/%d is filtered", |
1135 | rsclient->host, | |
1136 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1137 | p->prefixlen); | |
1138 | return 0; | |
1139 | } | |
1140 | ||
1141 | #ifdef BGP_SEND_ASPATH_CHECK | |
1142 | /* AS path loop check. */ | |
1143 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) | |
1144 | { | |
1145 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1146 | zlog (rsclient->log, LOG_DEBUG, |
aea339f7 | 1147 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
fee0f4c6 | 1148 | rsclient->host, rsclient->as); |
1149 | return 0; | |
1150 | } | |
1151 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
1152 | ||
1153 | /* For modify attribute, copy it to temporary structure. */ | |
9eda90ce | 1154 | bgp_attr_dup (attr, ri->attr); |
fee0f4c6 | 1155 | |
1156 | /* next-hop-set */ | |
1157 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) | |
1158 | #ifdef HAVE_IPV6 | |
1159 | || (p->family == AF_INET6 && | |
fb982c25 | 1160 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
fee0f4c6 | 1161 | #endif /* HAVE_IPV6 */ |
1162 | ) | |
1163 | { | |
1164 | /* Set IPv4 nexthop. */ | |
1165 | if (p->family == AF_INET) | |
1166 | { | |
1167 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1168 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
fee0f4c6 | 1169 | IPV4_MAX_BYTELEN); |
1170 | else | |
1171 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); | |
1172 | } | |
1173 | #ifdef HAVE_IPV6 | |
1174 | /* Set IPv6 nexthop. */ | |
1175 | if (p->family == AF_INET6) | |
1176 | { | |
1177 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 1178 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
fee0f4c6 | 1179 | IPV6_MAX_BYTELEN); |
fb982c25 | 1180 | attr->extra->mp_nexthop_len = 16; |
fee0f4c6 | 1181 | } |
1182 | #endif /* HAVE_IPV6 */ | |
1183 | } | |
1184 | ||
1185 | #ifdef HAVE_IPV6 | |
1186 | if (p->family == AF_INET6) | |
1187 | { | |
fb982c25 PJ |
1188 | struct attr_extra *attre = attr->extra; |
1189 | ||
1190 | assert (attr->extra); | |
1191 | ||
fee0f4c6 | 1192 | /* Left nexthop_local unchanged if so configured. */ |
1193 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], | |
1194 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) | |
1195 | { | |
fb982c25 PJ |
1196 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
1197 | attre->mp_nexthop_len=32; | |
fee0f4c6 | 1198 | else |
fb982c25 | 1199 | attre->mp_nexthop_len=16; |
fee0f4c6 | 1200 | } |
1201 | ||
1202 | /* Default nexthop_local treatment for RS-Clients */ | |
1203 | else | |
1204 | { | |
1205 | /* Announcer and RS-Client are both in the same network */ | |
1206 | if (rsclient->shared_network && from->shared_network && | |
1207 | (rsclient->ifindex == from->ifindex)) | |
1208 | { | |
fb982c25 PJ |
1209 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
1210 | attre->mp_nexthop_len=32; | |
fee0f4c6 | 1211 | else |
fb982c25 | 1212 | attre->mp_nexthop_len=16; |
fee0f4c6 | 1213 | } |
1214 | ||
1215 | /* Set link-local address for shared network peer. */ | |
1216 | else if (rsclient->shared_network | |
1217 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) | |
1218 | { | |
fb982c25 | 1219 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
fee0f4c6 | 1220 | IPV6_MAX_BYTELEN); |
fb982c25 | 1221 | attre->mp_nexthop_len = 32; |
fee0f4c6 | 1222 | } |
1223 | ||
1224 | else | |
fb982c25 | 1225 | attre->mp_nexthop_len = 16; |
fee0f4c6 | 1226 | } |
1227 | ||
1228 | } | |
1229 | #endif /* HAVE_IPV6 */ | |
1230 | ||
1231 | ||
1232 | /* If this is EBGP peer and remove-private-AS is set. */ | |
1233 | if (peer_sort (rsclient) == BGP_PEER_EBGP | |
1234 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) | |
1235 | && aspath_private_as_check (attr->aspath)) | |
1236 | attr->aspath = aspath_empty_get (); | |
1237 | ||
1238 | /* Route map & unsuppress-map apply. */ | |
fb982c25 | 1239 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
fee0f4c6 | 1240 | { |
1241 | info.peer = rsclient; | |
1242 | info.attr = attr; | |
1243 | ||
1244 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); | |
1245 | ||
fb982c25 | 1246 | if (ri->extra && ri->extra->suppress) |
fee0f4c6 | 1247 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
1248 | else | |
1249 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1250 | ||
1251 | rsclient->rmap_type = 0; | |
1252 | ||
1253 | if (ret == RMAP_DENYMATCH) | |
1254 | { | |
1255 | bgp_attr_flush (attr); | |
1256 | return 0; | |
1257 | } | |
1258 | } | |
1259 | ||
1260 | return 1; | |
1261 | } | |
1262 | ||
1263 | struct bgp_info_pair | |
1264 | { | |
1265 | struct bgp_info *old; | |
1266 | struct bgp_info *new; | |
1267 | }; | |
1268 | ||
94f2b392 | 1269 | static void |
fee0f4c6 | 1270 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result) |
718e3744 | 1271 | { |
718e3744 | 1272 | struct bgp_info *new_select; |
1273 | struct bgp_info *old_select; | |
fee0f4c6 | 1274 | struct bgp_info *ri; |
718e3744 | 1275 | struct bgp_info *ri1; |
1276 | struct bgp_info *ri2; | |
b40d939b | 1277 | struct bgp_info *nextri = NULL; |
1278 | ||
718e3744 | 1279 | /* bgp deterministic-med */ |
1280 | new_select = NULL; | |
1281 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1282 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1283 | { | |
1284 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) | |
1285 | continue; | |
1286 | if (BGP_INFO_HOLDDOWN (ri1)) | |
1287 | continue; | |
1288 | ||
1289 | new_select = ri1; | |
1290 | if (ri1->next) | |
1291 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) | |
1292 | { | |
1293 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) | |
1294 | continue; | |
1295 | if (BGP_INFO_HOLDDOWN (ri2)) | |
1296 | continue; | |
1297 | ||
1298 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) | |
1299 | || aspath_cmp_left_confed (ri1->attr->aspath, | |
1300 | ri2->attr->aspath)) | |
1301 | { | |
1302 | if (bgp_info_cmp (bgp, ri2, new_select)) | |
1303 | { | |
1a392d46 | 1304 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
718e3744 | 1305 | new_select = ri2; |
1306 | } | |
1307 | ||
1a392d46 | 1308 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
718e3744 | 1309 | } |
1310 | } | |
1a392d46 PJ |
1311 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
1312 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1313 | } |
1314 | ||
1315 | /* Check old selected route and new selected route. */ | |
1316 | old_select = NULL; | |
1317 | new_select = NULL; | |
b40d939b | 1318 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
718e3744 | 1319 | { |
1320 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1321 | old_select = ri; | |
1322 | ||
1323 | if (BGP_INFO_HOLDDOWN (ri)) | |
b40d939b | 1324 | { |
1325 | /* reap REMOVED routes, if needs be | |
1326 | * selected route must stay for a while longer though | |
1327 | */ | |
1328 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) | |
1329 | && (ri != old_select)) | |
1330 | bgp_info_reap (rn, ri); | |
1331 | ||
1332 | continue; | |
1333 | } | |
718e3744 | 1334 | |
1335 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) | |
1336 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) | |
1337 | { | |
1a392d46 | 1338 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1339 | continue; |
1340 | } | |
1a392d46 PJ |
1341 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
1342 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1343 | |
1344 | if (bgp_info_cmp (bgp, ri, new_select)) | |
1345 | new_select = ri; | |
1346 | } | |
b40d939b | 1347 | |
fee0f4c6 | 1348 | result->old = old_select; |
1349 | result->new = new_select; | |
1350 | ||
1351 | return; | |
1352 | } | |
1353 | ||
94f2b392 | 1354 | static int |
fee0f4c6 | 1355 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
9eda90ce PJ |
1356 | struct bgp_node *rn, afi_t afi, safi_t safi) |
1357 | { | |
fee0f4c6 | 1358 | struct prefix *p; |
9eda90ce | 1359 | struct attr attr = { 0 }; |
fee0f4c6 | 1360 | |
1361 | p = &rn->p; | |
1362 | ||
9eda90ce PJ |
1363 | /* Announce route to Established peer. */ |
1364 | if (peer->status != Established) | |
fee0f4c6 | 1365 | return 0; |
718e3744 | 1366 | |
9eda90ce PJ |
1367 | /* Address family configuration check. */ |
1368 | if (! peer->afc_nego[afi][safi]) | |
fee0f4c6 | 1369 | return 0; |
718e3744 | 1370 | |
9eda90ce | 1371 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
fee0f4c6 | 1372 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
1373 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
1374 | return 0; | |
718e3744 | 1375 | |
fee0f4c6 | 1376 | switch (rn->table->type) |
1377 | { | |
1378 | case BGP_TABLE_MAIN: | |
718e3744 | 1379 | /* Announcement to peer->conf. If the route is filtered, |
1380 | withdraw it. */ | |
9eda90ce PJ |
1381 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
1382 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); | |
fee0f4c6 | 1383 | else |
1384 | bgp_adj_out_unset (rn, peer, p, afi, safi); | |
1385 | break; | |
1386 | case BGP_TABLE_RSCLIENT: | |
1387 | /* Announcement to peer->conf. If the route is filtered, | |
1388 | withdraw it. */ | |
9eda90ce PJ |
1389 | if (selected && |
1390 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) | |
1391 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); | |
1392 | else | |
1393 | bgp_adj_out_unset (rn, peer, p, afi, safi); | |
fee0f4c6 | 1394 | break; |
1395 | } | |
9eda90ce PJ |
1396 | |
1397 | bgp_attr_extra_free (&attr); | |
1398 | ||
fee0f4c6 | 1399 | return 0; |
200df115 | 1400 | } |
fee0f4c6 | 1401 | |
200df115 | 1402 | struct bgp_process_queue |
fee0f4c6 | 1403 | { |
200df115 | 1404 | struct bgp *bgp; |
1405 | struct bgp_node *rn; | |
1406 | afi_t afi; | |
1407 | safi_t safi; | |
1408 | }; | |
1409 | ||
1410 | static wq_item_status | |
0fb58d5d | 1411 | bgp_process_rsclient (struct work_queue *wq, void *data) |
200df115 | 1412 | { |
0fb58d5d | 1413 | struct bgp_process_queue *pq = data; |
200df115 | 1414 | struct bgp *bgp = pq->bgp; |
1415 | struct bgp_node *rn = pq->rn; | |
1416 | afi_t afi = pq->afi; | |
1417 | safi_t safi = pq->safi; | |
fee0f4c6 | 1418 | struct bgp_info *new_select; |
1419 | struct bgp_info *old_select; | |
1420 | struct bgp_info_pair old_and_new; | |
1eb8ef25 | 1421 | struct listnode *node, *nnode; |
200df115 | 1422 | struct peer *rsclient = rn->table->owner; |
1423 | ||
fee0f4c6 | 1424 | /* Best path selection. */ |
1425 | bgp_best_selection (bgp, rn, &old_and_new); | |
1426 | new_select = old_and_new.new; | |
1427 | old_select = old_and_new.old; | |
1428 | ||
200df115 | 1429 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
1430 | { | |
228da428 CC |
1431 | if (rsclient->group) |
1432 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) | |
1433 | { | |
1434 | /* Nothing to do. */ | |
1435 | if (old_select && old_select == new_select) | |
1436 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) | |
1437 | continue; | |
1438 | ||
1439 | if (old_select) | |
1440 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); | |
1441 | if (new_select) | |
1442 | { | |
1443 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); | |
1444 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
1445 | } | |
1446 | ||
1447 | bgp_process_announce_selected (rsclient, new_select, rn, | |
1448 | afi, safi); | |
1449 | } | |
200df115 | 1450 | } |
1451 | else | |
1452 | { | |
b7395791 | 1453 | if (old_select) |
1a392d46 | 1454 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
b7395791 | 1455 | if (new_select) |
1456 | { | |
1a392d46 PJ |
1457 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1458 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
b7395791 | 1459 | } |
9eda90ce | 1460 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
200df115 | 1461 | } |
1462 | ||
b40d939b | 1463 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
1464 | bgp_info_reap (rn, old_select); | |
1465 | ||
200df115 | 1466 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1467 | return WQ_SUCCESS; | |
fee0f4c6 | 1468 | } |
1469 | ||
200df115 | 1470 | static wq_item_status |
0fb58d5d | 1471 | bgp_process_main (struct work_queue *wq, void *data) |
200df115 | 1472 | { |
0fb58d5d | 1473 | struct bgp_process_queue *pq = data; |
200df115 | 1474 | struct bgp *bgp = pq->bgp; |
1475 | struct bgp_node *rn = pq->rn; | |
1476 | afi_t afi = pq->afi; | |
1477 | safi_t safi = pq->safi; | |
1478 | struct prefix *p = &rn->p; | |
fee0f4c6 | 1479 | struct bgp_info *new_select; |
1480 | struct bgp_info *old_select; | |
1481 | struct bgp_info_pair old_and_new; | |
1eb8ef25 | 1482 | struct listnode *node, *nnode; |
fee0f4c6 | 1483 | struct peer *peer; |
fb982c25 | 1484 | |
fee0f4c6 | 1485 | /* Best path selection. */ |
1486 | bgp_best_selection (bgp, rn, &old_and_new); | |
1487 | old_select = old_and_new.old; | |
1488 | new_select = old_and_new.new; | |
1489 | ||
1490 | /* Nothing to do. */ | |
1491 | if (old_select && old_select == new_select) | |
1492 | { | |
1493 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) | |
200df115 | 1494 | { |
1495 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) | |
1496 | bgp_zebra_announce (p, old_select, bgp); | |
1497 | ||
1498 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); | |
1499 | return WQ_SUCCESS; | |
1500 | } | |
fee0f4c6 | 1501 | } |
1502 | ||
338b3424 | 1503 | if (old_select) |
1a392d46 | 1504 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
338b3424 | 1505 | if (new_select) |
1506 | { | |
1a392d46 PJ |
1507 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1508 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
338b3424 | 1509 | } |
1510 | ||
1511 | ||
fee0f4c6 | 1512 | /* Check each BGP peer. */ |
1eb8ef25 | 1513 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
fee0f4c6 | 1514 | { |
9eda90ce | 1515 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
718e3744 | 1516 | } |
1517 | ||
1518 | /* FIB update. */ | |
1519 | if (safi == SAFI_UNICAST && ! bgp->name && | |
1520 | ! bgp_option_check (BGP_OPT_NO_FIB)) | |
1521 | { | |
1522 | if (new_select | |
1523 | && new_select->type == ZEBRA_ROUTE_BGP | |
1524 | && new_select->sub_type == BGP_ROUTE_NORMAL) | |
1525 | bgp_zebra_announce (p, new_select, bgp); | |
1526 | else | |
1527 | { | |
1528 | /* Withdraw the route from the kernel. */ | |
1529 | if (old_select | |
1530 | && old_select->type == ZEBRA_ROUTE_BGP | |
1531 | && old_select->sub_type == BGP_ROUTE_NORMAL) | |
1532 | bgp_zebra_withdraw (p, old_select); | |
1533 | } | |
1534 | } | |
b40d939b | 1535 | |
1536 | /* Reap old select bgp_info, it it has been removed */ | |
1537 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) | |
1538 | bgp_info_reap (rn, old_select); | |
1539 | ||
200df115 | 1540 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1541 | return WQ_SUCCESS; | |
718e3744 | 1542 | } |
1543 | ||
200df115 | 1544 | static void |
0fb58d5d | 1545 | bgp_processq_del (struct work_queue *wq, void *data) |
200df115 | 1546 | { |
0fb58d5d | 1547 | struct bgp_process_queue *pq = data; |
228da428 | 1548 | struct bgp_table *table = pq->rn->table; |
0fb58d5d | 1549 | |
228da428 | 1550 | bgp_unlock (pq->bgp); |
200df115 | 1551 | bgp_unlock_node (pq->rn); |
228da428 | 1552 | bgp_table_unlock (table); |
200df115 | 1553 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
1554 | } | |
1555 | ||
1556 | static void | |
1557 | bgp_process_queue_init (void) | |
1558 | { | |
1559 | bm->process_main_queue | |
1560 | = work_queue_new (bm->master, "process_main_queue"); | |
1561 | bm->process_rsclient_queue | |
1562 | = work_queue_new (bm->master, "process_rsclient_queue"); | |
1563 | ||
1564 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) | |
1565 | { | |
1566 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
1567 | exit (1); | |
1568 | } | |
1569 | ||
1570 | bm->process_main_queue->spec.workfunc = &bgp_process_main; | |
200df115 | 1571 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
838bbde0 PJ |
1572 | bm->process_main_queue->spec.max_retries = 0; |
1573 | bm->process_main_queue->spec.hold = 50; | |
1574 | ||
1575 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, | |
1576 | sizeof (struct work_queue *)); | |
1577 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; | |
200df115 | 1578 | } |
1579 | ||
1580 | void | |
fee0f4c6 | 1581 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
1582 | { | |
200df115 | 1583 | struct bgp_process_queue *pqnode; |
1584 | ||
1585 | /* already scheduled for processing? */ | |
1586 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) | |
1587 | return; | |
1588 | ||
1589 | if ( (bm->process_main_queue == NULL) || | |
1590 | (bm->process_rsclient_queue == NULL) ) | |
1591 | bgp_process_queue_init (); | |
1592 | ||
1593 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, | |
1594 | sizeof (struct bgp_process_queue)); | |
1595 | if (!pqnode) | |
1596 | return; | |
228da428 CC |
1597 | |
1598 | /* all unlocked in bgp_processq_del */ | |
1599 | bgp_table_lock (rn->table); | |
1600 | pqnode->rn = bgp_lock_node (rn); | |
200df115 | 1601 | pqnode->bgp = bgp; |
228da428 | 1602 | bgp_lock (bgp); |
200df115 | 1603 | pqnode->afi = afi; |
1604 | pqnode->safi = safi; | |
1605 | ||
fee0f4c6 | 1606 | switch (rn->table->type) |
1607 | { | |
200df115 | 1608 | case BGP_TABLE_MAIN: |
1609 | work_queue_add (bm->process_main_queue, pqnode); | |
1610 | break; | |
1611 | case BGP_TABLE_RSCLIENT: | |
1612 | work_queue_add (bm->process_rsclient_queue, pqnode); | |
1613 | break; | |
fee0f4c6 | 1614 | } |
200df115 | 1615 | |
1616 | return; | |
fee0f4c6 | 1617 | } |
0a486e5f | 1618 | |
94f2b392 | 1619 | static int |
0a486e5f | 1620 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
1621 | { | |
1622 | struct peer *peer; | |
1623 | ||
1624 | peer = THREAD_ARG (thread); | |
1625 | peer->t_pmax_restart = NULL; | |
1626 | ||
1627 | if (BGP_DEBUG (events, EVENTS)) | |
1628 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", | |
1629 | peer->host); | |
1630 | ||
1631 | peer_clear (peer); | |
1632 | ||
1633 | return 0; | |
1634 | } | |
1635 | ||
718e3744 | 1636 | int |
5228ad27 | 1637 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
1638 | safi_t safi, int always) | |
718e3744 | 1639 | { |
e0701b79 | 1640 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
1641 | return 0; | |
1642 | ||
1643 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) | |
718e3744 | 1644 | { |
e0701b79 | 1645 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
1646 | && ! always) | |
1647 | return 0; | |
1648 | ||
1649 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1650 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
1651 | "limit %ld", afi_safi_print (afi, safi), peer->host, | |
1652 | peer->pcount[afi][safi], peer->pmax[afi][safi]); | |
e0701b79 | 1653 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
1654 | ||
1655 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
1656 | return 0; | |
1657 | ||
1658 | { | |
5228ad27 | 1659 | u_int8_t ndata[7]; |
e0701b79 | 1660 | |
1661 | if (safi == SAFI_MPLS_VPN) | |
42e6d745 | 1662 | safi = SAFI_MPLS_LABELED_VPN; |
5228ad27 | 1663 | |
1664 | ndata[0] = (afi >> 8); | |
1665 | ndata[1] = afi; | |
1666 | ndata[2] = safi; | |
1667 | ndata[3] = (peer->pmax[afi][safi] >> 24); | |
1668 | ndata[4] = (peer->pmax[afi][safi] >> 16); | |
1669 | ndata[5] = (peer->pmax[afi][safi] >> 8); | |
1670 | ndata[6] = (peer->pmax[afi][safi]); | |
e0701b79 | 1671 | |
1672 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); | |
1673 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, | |
1674 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); | |
1675 | } | |
0a486e5f | 1676 | |
1677 | /* restart timer start */ | |
1678 | if (peer->pmax_restart[afi][safi]) | |
1679 | { | |
1680 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; | |
1681 | ||
1682 | if (BGP_DEBUG (events, EVENTS)) | |
1683 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", | |
1684 | peer->host, peer->v_pmax_restart); | |
1685 | ||
1686 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, | |
1687 | peer->v_pmax_restart); | |
1688 | } | |
1689 | ||
e0701b79 | 1690 | return 1; |
1691 | } | |
1692 | else | |
1693 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); | |
1694 | ||
1695 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) | |
1696 | { | |
1697 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) | |
1698 | && ! always) | |
1699 | return 0; | |
1700 | ||
1701 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1702 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
1703 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], | |
1704 | peer->pmax[afi][safi]); | |
e0701b79 | 1705 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
718e3744 | 1706 | } |
e0701b79 | 1707 | else |
1708 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); | |
718e3744 | 1709 | return 0; |
1710 | } | |
1711 | ||
b40d939b | 1712 | /* Unconditionally remove the route from the RIB, without taking |
1713 | * damping into consideration (eg, because the session went down) | |
1714 | */ | |
94f2b392 | 1715 | static void |
718e3744 | 1716 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
1717 | afi_t afi, safi_t safi) | |
1718 | { | |
902212c3 | 1719 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1720 | ||
1721 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
1722 | bgp_info_delete (rn, ri); /* keep historical info */ | |
1723 | ||
b40d939b | 1724 | bgp_process (peer->bgp, rn, afi, safi); |
718e3744 | 1725 | } |
1726 | ||
94f2b392 | 1727 | static void |
718e3744 | 1728 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
b40d939b | 1729 | afi_t afi, safi_t safi) |
718e3744 | 1730 | { |
718e3744 | 1731 | int status = BGP_DAMP_NONE; |
1732 | ||
b40d939b | 1733 | /* apply dampening, if result is suppressed, we'll be retaining |
1734 | * the bgp_info in the RIB for historical reference. | |
1735 | */ | |
1736 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
1737 | && peer_sort (peer) == BGP_PEER_EBGP) | |
1738 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) | |
1739 | == BGP_DAMP_SUPPRESSED) | |
902212c3 | 1740 | { |
902212c3 | 1741 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1742 | return; | |
1743 | } | |
1744 | ||
1745 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
718e3744 | 1746 | } |
1747 | ||
94f2b392 | 1748 | static void |
fee0f4c6 | 1749 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
1750 | struct attr *attr, struct peer *peer, struct prefix *p, int type, | |
1751 | int sub_type, struct prefix_rd *prd, u_char *tag) | |
1752 | { | |
1753 | struct bgp_node *rn; | |
1754 | struct bgp *bgp; | |
fb982c25 | 1755 | struct attr new_attr = { 0 }; |
fee0f4c6 | 1756 | struct attr *attr_new; |
1757 | struct attr *attr_new2; | |
1758 | struct bgp_info *ri; | |
1759 | struct bgp_info *new; | |
fd79ac91 | 1760 | const char *reason; |
fee0f4c6 | 1761 | char buf[SU_ADDRSTRLEN]; |
1762 | ||
1763 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ | |
1764 | if (peer == rsclient) | |
1765 | return; | |
1766 | ||
1767 | bgp = peer->bgp; | |
1768 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
1769 | ||
1770 | /* Check previously received route. */ | |
1771 | for (ri = rn->info; ri; ri = ri->next) | |
1772 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
1773 | break; | |
1774 | ||
1775 | /* AS path loop check. */ | |
1776 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) | |
1777 | { | |
1778 | reason = "as-path contains our own AS;"; | |
1779 | goto filtered; | |
1780 | } | |
1781 | ||
1782 | /* Route reflector originator ID check. */ | |
1783 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 1784 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
fee0f4c6 | 1785 | { |
1786 | reason = "originator is us;"; | |
1787 | goto filtered; | |
1788 | } | |
fb982c25 PJ |
1789 | |
1790 | bgp_attr_dup (&new_attr, attr); | |
fee0f4c6 | 1791 | |
1792 | /* Apply export policy. */ | |
1793 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && | |
1794 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1795 | { | |
1796 | reason = "export-policy;"; | |
1797 | goto filtered; | |
1798 | } | |
1799 | ||
1800 | attr_new2 = bgp_attr_intern (&new_attr); | |
fb982c25 | 1801 | |
fee0f4c6 | 1802 | /* Apply import policy. */ |
1803 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1804 | { | |
f6f434b2 | 1805 | bgp_attr_unintern (&attr_new2); |
fee0f4c6 | 1806 | |
1807 | reason = "import-policy;"; | |
1808 | goto filtered; | |
1809 | } | |
1810 | ||
1811 | attr_new = bgp_attr_intern (&new_attr); | |
f6f434b2 | 1812 | bgp_attr_unintern (&attr_new2); |
fee0f4c6 | 1813 | |
1814 | /* IPv4 unicast next hop check. */ | |
1815 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
1816 | { | |
1817 | /* Next hop must not be 0.0.0.0 nor Class E address. */ | |
1818 | if (new_attr.nexthop.s_addr == 0 | |
1819 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) | |
1820 | { | |
f6f434b2 | 1821 | bgp_attr_unintern (&attr_new); |
fee0f4c6 | 1822 | |
1823 | reason = "martian next-hop;"; | |
1824 | goto filtered; | |
1825 | } | |
1826 | } | |
fb982c25 PJ |
1827 | |
1828 | /* new_attr isn't passed to any functions after here */ | |
1829 | bgp_attr_extra_free (&new_attr); | |
1830 | ||
fee0f4c6 | 1831 | /* If the update is implicit withdraw. */ |
1832 | if (ri) | |
1833 | { | |
65957886 | 1834 | ri->uptime = bgp_clock (); |
fee0f4c6 | 1835 | |
1836 | /* Same attribute comes in. */ | |
16d2e241 PJ |
1837 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
1838 | && attrhash_cmp (ri->attr, attr_new)) | |
fee0f4c6 | 1839 | { |
1840 | ||
1a392d46 | 1841 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1842 | |
1843 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1844 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1845 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
1846 | peer->host, | |
1847 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1848 | p->prefixlen, rsclient->host); | |
1849 | ||
228da428 | 1850 | bgp_unlock_node (rn); |
f6f434b2 | 1851 | bgp_attr_unintern (&attr_new); |
fee0f4c6 | 1852 | |
228da428 | 1853 | return; |
fee0f4c6 | 1854 | } |
1855 | ||
16d2e241 PJ |
1856 | /* Withdraw/Announce before we fully processed the withdraw */ |
1857 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
1858 | bgp_info_restore (rn, ri); | |
1859 | ||
fee0f4c6 | 1860 | /* Received Logging. */ |
1861 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1862 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1863 | peer->host, |
1864 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1865 | p->prefixlen, rsclient->host); | |
1866 | ||
1867 | /* The attribute is changed. */ | |
1a392d46 | 1868 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1869 | |
1870 | /* Update to new attribute. */ | |
f6f434b2 | 1871 | bgp_attr_unintern (&ri->attr); |
fee0f4c6 | 1872 | ri->attr = attr_new; |
1873 | ||
1874 | /* Update MPLS tag. */ | |
1875 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1876 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
fee0f4c6 | 1877 | |
1a392d46 | 1878 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
fee0f4c6 | 1879 | |
1880 | /* Process change. */ | |
1881 | bgp_process (bgp, rn, afi, safi); | |
1882 | bgp_unlock_node (rn); | |
1883 | ||
1884 | return; | |
1885 | } | |
1886 | ||
1887 | /* Received Logging. */ | |
1888 | if (BGP_DEBUG (update, UPDATE_IN)) | |
1889 | { | |
d2c1f16b | 1890 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1891 | peer->host, |
1892 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1893 | p->prefixlen, rsclient->host); | |
1894 | } | |
1895 | ||
1896 | /* Make new BGP info. */ | |
1897 | new = bgp_info_new (); | |
1898 | new->type = type; | |
1899 | new->sub_type = sub_type; | |
1900 | new->peer = peer; | |
1901 | new->attr = attr_new; | |
65957886 | 1902 | new->uptime = bgp_clock (); |
fee0f4c6 | 1903 | |
1904 | /* Update MPLS tag. */ | |
1905 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1906 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
fee0f4c6 | 1907 | |
1a392d46 | 1908 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
fee0f4c6 | 1909 | |
1910 | /* Register new BGP information. */ | |
1911 | bgp_info_add (rn, new); | |
200df115 | 1912 | |
1913 | /* route_node_get lock */ | |
1914 | bgp_unlock_node (rn); | |
1915 | ||
fee0f4c6 | 1916 | /* Process change. */ |
1917 | bgp_process (bgp, rn, afi, safi); | |
fb982c25 PJ |
1918 | |
1919 | bgp_attr_extra_free (&new_attr); | |
1920 | ||
fee0f4c6 | 1921 | return; |
1922 | ||
1923 | filtered: | |
1924 | ||
1925 | /* This BGP update is filtered. Log the reason then update BGP entry. */ | |
1926 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1927 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1928 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
1929 | peer->host, | |
1930 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1931 | p->prefixlen, rsclient->host, reason); | |
1932 | ||
1933 | if (ri) | |
b40d939b | 1934 | bgp_rib_remove (rn, ri, peer, afi, safi); |
fee0f4c6 | 1935 | |
1936 | bgp_unlock_node (rn); | |
fb982c25 PJ |
1937 | |
1938 | if (new_attr.extra) | |
1939 | bgp_attr_extra_free (&new_attr); | |
1940 | ||
fee0f4c6 | 1941 | return; |
1942 | } | |
1943 | ||
94f2b392 | 1944 | static void |
fee0f4c6 | 1945 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
1946 | struct peer *peer, struct prefix *p, int type, int sub_type, | |
1947 | struct prefix_rd *prd, u_char *tag) | |
228da428 | 1948 | { |
fee0f4c6 | 1949 | struct bgp_node *rn; |
1950 | struct bgp_info *ri; | |
1951 | char buf[SU_ADDRSTRLEN]; | |
1952 | ||
1953 | if (rsclient == peer) | |
228da428 | 1954 | return; |
fee0f4c6 | 1955 | |
1956 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
1957 | ||
1958 | /* Lookup withdrawn route. */ | |
1959 | for (ri = rn->info; ri; ri = ri->next) | |
1960 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
1961 | break; | |
1962 | ||
1963 | /* Withdraw specified route from routing table. */ | |
1964 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 1965 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
fee0f4c6 | 1966 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 1967 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1968 | "%s Can't find the route %s/%d", peer->host, |
1969 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1970 | p->prefixlen); | |
1971 | ||
1972 | /* Unlock bgp_node_get() lock. */ | |
228da428 CC |
1973 | bgp_unlock_node (rn); |
1974 | } | |
fee0f4c6 | 1975 | |
94f2b392 | 1976 | static int |
fee0f4c6 | 1977 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
718e3744 | 1978 | afi_t afi, safi_t safi, int type, int sub_type, |
1979 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
1980 | { | |
1981 | int ret; | |
1982 | int aspath_loop_count = 0; | |
1983 | struct bgp_node *rn; | |
1984 | struct bgp *bgp; | |
fb982c25 | 1985 | struct attr new_attr = { 0 }; |
718e3744 | 1986 | struct attr *attr_new; |
1987 | struct bgp_info *ri; | |
1988 | struct bgp_info *new; | |
fd79ac91 | 1989 | const char *reason; |
718e3744 | 1990 | char buf[SU_ADDRSTRLEN]; |
1991 | ||
1992 | bgp = peer->bgp; | |
fee0f4c6 | 1993 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
fb982c25 | 1994 | |
718e3744 | 1995 | /* When peer's soft reconfiguration enabled. Record input packet in |
1996 | Adj-RIBs-In. */ | |
1997 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
1998 | && peer != bgp->peer_self && ! soft_reconfig) | |
1999 | bgp_adj_in_set (rn, peer, attr); | |
2000 | ||
2001 | /* Check previously received route. */ | |
2002 | for (ri = rn->info; ri; ri = ri->next) | |
2003 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2004 | break; | |
2005 | ||
2006 | /* AS path local-as loop check. */ | |
2007 | if (peer->change_local_as) | |
2008 | { | |
2009 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
2010 | aspath_loop_count = 1; | |
2011 | ||
2012 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) | |
2013 | { | |
2014 | reason = "as-path contains our own AS;"; | |
2015 | goto filtered; | |
2016 | } | |
2017 | } | |
2018 | ||
2019 | /* AS path loop check. */ | |
2020 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] | |
2021 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
2022 | && aspath_loop_check(attr->aspath, bgp->confed_id) | |
2023 | > peer->allowas_in[afi][safi])) | |
2024 | { | |
2025 | reason = "as-path contains our own AS;"; | |
2026 | goto filtered; | |
2027 | } | |
2028 | ||
2029 | /* Route reflector originator ID check. */ | |
2030 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 2031 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
718e3744 | 2032 | { |
2033 | reason = "originator is us;"; | |
2034 | goto filtered; | |
2035 | } | |
2036 | ||
2037 | /* Route reflector cluster ID check. */ | |
2038 | if (bgp_cluster_filter (peer, attr)) | |
2039 | { | |
2040 | reason = "reflected from the same cluster;"; | |
2041 | goto filtered; | |
2042 | } | |
2043 | ||
2044 | /* Apply incoming filter. */ | |
2045 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) | |
2046 | { | |
2047 | reason = "filter;"; | |
2048 | goto filtered; | |
2049 | } | |
2050 | ||
2051 | /* Apply incoming route-map. */ | |
fb982c25 | 2052 | bgp_attr_dup (&new_attr, attr); |
718e3744 | 2053 | |
2054 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
2055 | { | |
2056 | reason = "route-map;"; | |
2057 | goto filtered; | |
2058 | } | |
2059 | ||
2060 | /* IPv4 unicast next hop check. */ | |
2061 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
2062 | { | |
2063 | /* If the peer is EBGP and nexthop is not on connected route, | |
2064 | discard it. */ | |
2065 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 | |
2066 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) | |
6ffd2079 | 2067 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
718e3744 | 2068 | { |
2069 | reason = "non-connected next-hop;"; | |
2070 | goto filtered; | |
2071 | } | |
2072 | ||
2073 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop | |
2074 | must not be my own address. */ | |
2075 | if (bgp_nexthop_self (afi, &new_attr) | |
2076 | || new_attr.nexthop.s_addr == 0 | |
2077 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) | |
2078 | { | |
2079 | reason = "martian next-hop;"; | |
2080 | goto filtered; | |
2081 | } | |
2082 | } | |
2083 | ||
2084 | attr_new = bgp_attr_intern (&new_attr); | |
2085 | ||
2086 | /* If the update is implicit withdraw. */ | |
2087 | if (ri) | |
2088 | { | |
65957886 | 2089 | ri->uptime = bgp_clock (); |
718e3744 | 2090 | |
2091 | /* Same attribute comes in. */ | |
16d2e241 PJ |
2092 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
2093 | && attrhash_cmp (ri->attr, attr_new)) | |
718e3744 | 2094 | { |
1a392d46 | 2095 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 2096 | |
2097 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2098 | && peer_sort (peer) == BGP_PEER_EBGP | |
2099 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2100 | { | |
2101 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2102 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2103 | peer->host, |
2104 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2105 | p->prefixlen); | |
2106 | ||
902212c3 | 2107 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
2108 | { | |
2109 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2110 | bgp_process (bgp, rn, afi, safi); | |
2111 | } | |
718e3744 | 2112 | } |
16d2e241 | 2113 | else /* Duplicate - odd */ |
718e3744 | 2114 | { |
2115 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2116 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2117 | "%s rcvd %s/%d...duplicate ignored", |
2118 | peer->host, | |
2119 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2120 | p->prefixlen); | |
93406d87 | 2121 | |
2122 | /* graceful restart STALE flag unset. */ | |
2123 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2124 | { | |
1a392d46 | 2125 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
902212c3 | 2126 | bgp_process (bgp, rn, afi, safi); |
93406d87 | 2127 | } |
718e3744 | 2128 | } |
2129 | ||
2130 | bgp_unlock_node (rn); | |
f6f434b2 | 2131 | bgp_attr_unintern (&attr_new); |
fb982c25 PJ |
2132 | bgp_attr_extra_free (&new_attr); |
2133 | ||
718e3744 | 2134 | return 0; |
2135 | } | |
2136 | ||
16d2e241 PJ |
2137 | /* Withdraw/Announce before we fully processed the withdraw */ |
2138 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
2139 | { | |
2140 | if (BGP_DEBUG (update, UPDATE_IN)) | |
2141 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", | |
2142 | peer->host, | |
2143 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2144 | p->prefixlen); | |
2145 | bgp_info_restore (rn, ri); | |
2146 | } | |
2147 | ||
718e3744 | 2148 | /* Received Logging. */ |
2149 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2150 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2151 | peer->host, |
2152 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2153 | p->prefixlen); | |
2154 | ||
93406d87 | 2155 | /* graceful restart STALE flag unset. */ |
2156 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
1a392d46 | 2157 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
93406d87 | 2158 | |
718e3744 | 2159 | /* The attribute is changed. */ |
1a392d46 | 2160 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
902212c3 | 2161 | |
2162 | /* implicit withdraw, decrement aggregate and pcount here. | |
2163 | * only if update is accepted, they'll increment below. | |
2164 | */ | |
902212c3 | 2165 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
2166 | ||
718e3744 | 2167 | /* Update bgp route dampening information. */ |
2168 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2169 | && peer_sort (peer) == BGP_PEER_EBGP) | |
2170 | { | |
2171 | /* This is implicit withdraw so we should update dampening | |
2172 | information. */ | |
2173 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2174 | bgp_damp_withdraw (ri, rn, afi, safi, 1); | |
718e3744 | 2175 | } |
2176 | ||
718e3744 | 2177 | /* Update to new attribute. */ |
f6f434b2 | 2178 | bgp_attr_unintern (&ri->attr); |
718e3744 | 2179 | ri->attr = attr_new; |
2180 | ||
2181 | /* Update MPLS tag. */ | |
2182 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2183 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
718e3744 | 2184 | |
2185 | /* Update bgp route dampening information. */ | |
2186 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2187 | && peer_sort (peer) == BGP_PEER_EBGP) | |
2188 | { | |
2189 | /* Now we do normal update dampening. */ | |
2190 | ret = bgp_damp_update (ri, rn, afi, safi); | |
2191 | if (ret == BGP_DAMP_SUPPRESSED) | |
2192 | { | |
2193 | bgp_unlock_node (rn); | |
fb982c25 | 2194 | bgp_attr_extra_free (&new_attr); |
718e3744 | 2195 | return 0; |
2196 | } | |
2197 | } | |
2198 | ||
2199 | /* Nexthop reachability check. */ | |
2200 | if ((afi == AFI_IP || afi == AFI_IP6) | |
2201 | && safi == SAFI_UNICAST | |
2202 | && (peer_sort (peer) == BGP_PEER_IBGP | |
638b70ba | 2203 | || peer_sort (peer) == BGP_PEER_CONFED |
718e3744 | 2204 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
6ffd2079 | 2205 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
718e3744 | 2206 | { |
2207 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) | |
1a392d46 | 2208 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2209 | else |
1a392d46 | 2210 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2211 | } |
2212 | else | |
1a392d46 | 2213 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2214 | |
2215 | /* Process change. */ | |
2216 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2217 | ||
2218 | bgp_process (bgp, rn, afi, safi); | |
2219 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2220 | bgp_attr_extra_free (&new_attr); |
2221 | ||
718e3744 | 2222 | return 0; |
2223 | } | |
2224 | ||
2225 | /* Received Logging. */ | |
2226 | if (BGP_DEBUG (update, UPDATE_IN)) | |
2227 | { | |
d2c1f16b | 2228 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2229 | peer->host, |
2230 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2231 | p->prefixlen); | |
2232 | } | |
2233 | ||
718e3744 | 2234 | /* Make new BGP info. */ |
2235 | new = bgp_info_new (); | |
2236 | new->type = type; | |
2237 | new->sub_type = sub_type; | |
2238 | new->peer = peer; | |
2239 | new->attr = attr_new; | |
65957886 | 2240 | new->uptime = bgp_clock (); |
718e3744 | 2241 | |
2242 | /* Update MPLS tag. */ | |
2243 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2244 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
718e3744 | 2245 | |
2246 | /* Nexthop reachability check. */ | |
2247 | if ((afi == AFI_IP || afi == AFI_IP6) | |
2248 | && safi == SAFI_UNICAST | |
2249 | && (peer_sort (peer) == BGP_PEER_IBGP | |
638b70ba | 2250 | || peer_sort (peer) == BGP_PEER_CONFED |
718e3744 | 2251 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
6ffd2079 | 2252 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
718e3744 | 2253 | { |
2254 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) | |
1a392d46 | 2255 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2256 | else |
1a392d46 | 2257 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2258 | } |
2259 | else | |
1a392d46 | 2260 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2261 | |
902212c3 | 2262 | /* Increment prefix */ |
718e3744 | 2263 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
2264 | ||
2265 | /* Register new BGP information. */ | |
2266 | bgp_info_add (rn, new); | |
200df115 | 2267 | |
2268 | /* route_node_get lock */ | |
2269 | bgp_unlock_node (rn); | |
2270 | ||
fb982c25 PJ |
2271 | bgp_attr_extra_free (&new_attr); |
2272 | ||
718e3744 | 2273 | /* If maximum prefix count is configured and current prefix |
2274 | count exeed it. */ | |
e0701b79 | 2275 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
2276 | return -1; | |
718e3744 | 2277 | |
2278 | /* Process change. */ | |
2279 | bgp_process (bgp, rn, afi, safi); | |
2280 | ||
2281 | return 0; | |
2282 | ||
2283 | /* This BGP update is filtered. Log the reason then update BGP | |
2284 | entry. */ | |
2285 | filtered: | |
2286 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2287 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2288 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
2289 | peer->host, | |
2290 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2291 | p->prefixlen, reason); | |
2292 | ||
2293 | if (ri) | |
b40d939b | 2294 | bgp_rib_remove (rn, ri, peer, afi, safi); |
718e3744 | 2295 | |
2296 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2297 | |
2298 | bgp_attr_extra_free (&new_attr); | |
2299 | ||
718e3744 | 2300 | return 0; |
2301 | } | |
2302 | ||
fee0f4c6 | 2303 | int |
2304 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, | |
2305 | afi_t afi, safi_t safi, int type, int sub_type, | |
2306 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
2307 | { | |
2308 | struct peer *rsclient; | |
1eb8ef25 | 2309 | struct listnode *node, *nnode; |
fee0f4c6 | 2310 | struct bgp *bgp; |
2311 | int ret; | |
2312 | ||
2313 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, | |
2314 | soft_reconfig); | |
2315 | ||
2316 | bgp = peer->bgp; | |
2317 | ||
2318 | /* Process the update for each RS-client. */ | |
1eb8ef25 | 2319 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2320 | { |
2321 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2322 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, | |
2323 | sub_type, prd, tag); | |
2324 | } | |
2325 | ||
2326 | return ret; | |
2327 | } | |
2328 | ||
718e3744 | 2329 | int |
2330 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, | |
94f2b392 | 2331 | afi_t afi, safi_t safi, int type, int sub_type, |
2332 | struct prefix_rd *prd, u_char *tag) | |
718e3744 | 2333 | { |
2334 | struct bgp *bgp; | |
2335 | char buf[SU_ADDRSTRLEN]; | |
2336 | struct bgp_node *rn; | |
2337 | struct bgp_info *ri; | |
fee0f4c6 | 2338 | struct peer *rsclient; |
1eb8ef25 | 2339 | struct listnode *node, *nnode; |
718e3744 | 2340 | |
2341 | bgp = peer->bgp; | |
2342 | ||
fee0f4c6 | 2343 | /* Process the withdraw for each RS-client. */ |
1eb8ef25 | 2344 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2345 | { |
2346 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2347 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); | |
2348 | } | |
2349 | ||
718e3744 | 2350 | /* Logging. */ |
2351 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2352 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
718e3744 | 2353 | peer->host, |
2354 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2355 | p->prefixlen); | |
2356 | ||
2357 | /* Lookup node. */ | |
fee0f4c6 | 2358 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 2359 | |
2360 | /* If peer is soft reconfiguration enabled. Record input packet for | |
2361 | further calculation. */ | |
2362 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2363 | && peer != bgp->peer_self) | |
2364 | bgp_adj_in_unset (rn, peer); | |
2365 | ||
2366 | /* Lookup withdrawn route. */ | |
2367 | for (ri = rn->info; ri; ri = ri->next) | |
2368 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2369 | break; | |
2370 | ||
2371 | /* Withdraw specified route from routing table. */ | |
2372 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2373 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
718e3744 | 2374 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 2375 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2376 | "%s Can't find the route %s/%d", peer->host, |
2377 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2378 | p->prefixlen); | |
2379 | ||
2380 | /* Unlock bgp_node_get() lock. */ | |
2381 | bgp_unlock_node (rn); | |
2382 | ||
2383 | return 0; | |
2384 | } | |
2385 | \f | |
2386 | void | |
2387 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) | |
2388 | { | |
2389 | struct bgp *bgp; | |
228da428 | 2390 | struct attr attr = { 0 }; |
fb982c25 | 2391 | struct aspath *aspath = { 0 }; |
718e3744 | 2392 | struct prefix p; |
2393 | struct bgp_info binfo; | |
2394 | struct peer *from; | |
2395 | int ret = RMAP_DENYMATCH; | |
fb982c25 | 2396 | |
b2497024 | 2397 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
fb982c25 PJ |
2398 | return; |
2399 | ||
718e3744 | 2400 | bgp = peer->bgp; |
2401 | from = bgp->peer_self; | |
fb982c25 | 2402 | |
718e3744 | 2403 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
2404 | aspath = attr.aspath; | |
2405 | attr.local_pref = bgp->default_local_pref; | |
2406 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); | |
2407 | ||
2408 | if (afi == AFI_IP) | |
2409 | str2prefix ("0.0.0.0/0", &p); | |
2410 | #ifdef HAVE_IPV6 | |
2411 | else if (afi == AFI_IP6) | |
2412 | { | |
fb982c25 PJ |
2413 | struct attr_extra *ae; |
2414 | attr.extra = NULL; | |
2415 | ||
2416 | ae = bgp_attr_extra_get (&attr); | |
2417 | attr.extra = ae; | |
2418 | ||
718e3744 | 2419 | str2prefix ("::/0", &p); |
2420 | ||
2421 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 2422 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
718e3744 | 2423 | IPV6_MAX_BYTELEN); |
fb982c25 | 2424 | ae->mp_nexthop_len = 16; |
718e3744 | 2425 | |
2426 | /* If the peer is on shared nextwork and we have link-local | |
2427 | nexthop set it. */ | |
2428 | if (peer->shared_network | |
2429 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) | |
2430 | { | |
fb982c25 | 2431 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
718e3744 | 2432 | IPV6_MAX_BYTELEN); |
fb982c25 | 2433 | ae->mp_nexthop_len = 32; |
718e3744 | 2434 | } |
2435 | } | |
2436 | #endif /* HAVE_IPV6 */ | |
718e3744 | 2437 | |
2438 | if (peer->default_rmap[afi][safi].name) | |
2439 | { | |
2440 | binfo.peer = bgp->peer_self; | |
2441 | binfo.attr = &attr; | |
2442 | ||
fee0f4c6 | 2443 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
2444 | ||
718e3744 | 2445 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
2446 | RMAP_BGP, &binfo); | |
2447 | ||
fee0f4c6 | 2448 | bgp->peer_self->rmap_type = 0; |
2449 | ||
718e3744 | 2450 | if (ret == RMAP_DENYMATCH) |
2451 | { | |
2452 | bgp_attr_flush (&attr); | |
2453 | withdraw = 1; | |
2454 | } | |
2455 | } | |
2456 | ||
2457 | if (withdraw) | |
2458 | { | |
2459 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) | |
2460 | bgp_default_withdraw_send (peer, afi, safi); | |
2461 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2462 | } | |
2463 | else | |
2464 | { | |
2465 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2466 | bgp_default_update_send (peer, &attr, afi, safi, from); | |
2467 | } | |
fb982c25 PJ |
2468 | |
2469 | bgp_attr_extra_free (&attr); | |
f6f434b2 | 2470 | aspath_unintern (&aspath); |
718e3744 | 2471 | } |
2472 | \f | |
2473 | static void | |
2474 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, | |
fee0f4c6 | 2475 | struct bgp_table *table, int rsclient) |
718e3744 | 2476 | { |
2477 | struct bgp_node *rn; | |
2478 | struct bgp_info *ri; | |
228da428 | 2479 | struct attr attr = { 0 }; |
fb982c25 | 2480 | |
718e3744 | 2481 | if (! table) |
fee0f4c6 | 2482 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
718e3744 | 2483 | |
2484 | if (safi != SAFI_MPLS_VPN | |
2485 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
2486 | bgp_default_originate (peer, afi, safi, 0); | |
2487 | ||
2488 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) | |
2489 | for (ri = rn->info; ri; ri = ri->next) | |
2490 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) | |
2491 | { | |
fee0f4c6 | 2492 | if ( (rsclient) ? |
2493 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) | |
2494 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) | |
718e3744 | 2495 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
2496 | else | |
2497 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); | |
fb982c25 PJ |
2498 | |
2499 | bgp_attr_extra_free (&attr); | |
718e3744 | 2500 | } |
2501 | } | |
2502 | ||
2503 | void | |
2504 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) | |
2505 | { | |
2506 | struct bgp_node *rn; | |
2507 | struct bgp_table *table; | |
2508 | ||
2509 | if (peer->status != Established) | |
2510 | return; | |
2511 | ||
2512 | if (! peer->afc_nego[afi][safi]) | |
2513 | return; | |
2514 | ||
2515 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ | |
2516 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
2517 | return; | |
2518 | ||
2519 | if (safi != SAFI_MPLS_VPN) | |
fee0f4c6 | 2520 | bgp_announce_table (peer, afi, safi, NULL, 0); |
718e3744 | 2521 | else |
2522 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2523 | rn = bgp_route_next(rn)) | |
2524 | if ((table = (rn->info)) != NULL) | |
fee0f4c6 | 2525 | bgp_announce_table (peer, afi, safi, table, 0); |
2526 | ||
2527 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2528 | bgp_announce_table (peer, afi, safi, NULL, 1); | |
718e3744 | 2529 | } |
2530 | ||
2531 | void | |
2532 | bgp_announce_route_all (struct peer *peer) | |
2533 | { | |
2534 | afi_t afi; | |
2535 | safi_t safi; | |
2536 | ||
2537 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2538 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2539 | bgp_announce_route (peer, afi, safi); | |
2540 | } | |
2541 | \f | |
2542 | static void | |
fee0f4c6 | 2543 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
2544 | safi_t safi, struct bgp_table *table) | |
2545 | { | |
2546 | struct bgp_node *rn; | |
2547 | struct bgp_adj_in *ain; | |
2548 | ||
2549 | if (! table) | |
2550 | table = rsclient->bgp->rib[afi][safi]; | |
2551 | ||
2552 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2553 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2554 | { | |
2555 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, | |
2556 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); | |
2557 | } | |
2558 | } | |
2559 | ||
2560 | void | |
2561 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) | |
2562 | { | |
2563 | struct bgp_table *table; | |
2564 | struct bgp_node *rn; | |
2565 | ||
2566 | if (safi != SAFI_MPLS_VPN) | |
2567 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); | |
2568 | ||
2569 | else | |
2570 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; | |
2571 | rn = bgp_route_next (rn)) | |
2572 | if ((table = rn->info) != NULL) | |
2573 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); | |
2574 | } | |
2575 | \f | |
2576 | static void | |
718e3744 | 2577 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
2578 | struct bgp_table *table) | |
2579 | { | |
2580 | int ret; | |
2581 | struct bgp_node *rn; | |
2582 | struct bgp_adj_in *ain; | |
2583 | ||
2584 | if (! table) | |
2585 | table = peer->bgp->rib[afi][safi]; | |
2586 | ||
2587 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2588 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2589 | { | |
2590 | if (ain->peer == peer) | |
2591 | { | |
2592 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, | |
2593 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, | |
2594 | NULL, NULL, 1); | |
2595 | if (ret < 0) | |
2596 | { | |
2597 | bgp_unlock_node (rn); | |
2598 | return; | |
2599 | } | |
2600 | continue; | |
2601 | } | |
2602 | } | |
2603 | } | |
2604 | ||
2605 | void | |
2606 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) | |
2607 | { | |
2608 | struct bgp_node *rn; | |
2609 | struct bgp_table *table; | |
2610 | ||
2611 | if (peer->status != Established) | |
2612 | return; | |
2613 | ||
2614 | if (safi != SAFI_MPLS_VPN) | |
2615 | bgp_soft_reconfig_table (peer, afi, safi, NULL); | |
2616 | else | |
2617 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2618 | rn = bgp_route_next (rn)) | |
2619 | if ((table = rn->info) != NULL) | |
2620 | bgp_soft_reconfig_table (peer, afi, safi, table); | |
2621 | } | |
2622 | \f | |
228da428 CC |
2623 | |
2624 | struct bgp_clear_node_queue | |
2625 | { | |
2626 | struct bgp_node *rn; | |
2627 | enum bgp_clear_route_type purpose; | |
2628 | }; | |
2629 | ||
200df115 | 2630 | static wq_item_status |
0fb58d5d | 2631 | bgp_clear_route_node (struct work_queue *wq, void *data) |
200df115 | 2632 | { |
228da428 CC |
2633 | struct bgp_clear_node_queue *cnq = data; |
2634 | struct bgp_node *rn = cnq->rn; | |
64e580a7 | 2635 | struct peer *peer = wq->spec.data; |
718e3744 | 2636 | struct bgp_info *ri; |
64e580a7 PJ |
2637 | afi_t afi = rn->table->afi; |
2638 | safi_t safi = rn->table->safi; | |
200df115 | 2639 | |
64e580a7 | 2640 | assert (rn && peer); |
200df115 | 2641 | |
64e580a7 | 2642 | for (ri = rn->info; ri; ri = ri->next) |
228da428 | 2643 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
200df115 | 2644 | { |
2645 | /* graceful restart STALE flag set. */ | |
64e580a7 PJ |
2646 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
2647 | && peer->nsf[afi][safi] | |
200df115 | 2648 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
1a392d46 PJ |
2649 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2650 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); | |
200df115 | 2651 | else |
64e580a7 | 2652 | bgp_rib_remove (rn, ri, peer, afi, safi); |
200df115 | 2653 | break; |
2654 | } | |
200df115 | 2655 | return WQ_SUCCESS; |
2656 | } | |
2657 | ||
2658 | static void | |
0fb58d5d | 2659 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
200df115 | 2660 | { |
228da428 CC |
2661 | struct bgp_clear_node_queue *cnq = data; |
2662 | struct bgp_node *rn = cnq->rn; | |
2663 | struct bgp_table *table = rn->table; | |
64e580a7 PJ |
2664 | |
2665 | bgp_unlock_node (rn); | |
228da428 CC |
2666 | bgp_table_unlock (table); |
2667 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); | |
200df115 | 2668 | } |
2669 | ||
2670 | static void | |
94f2b392 | 2671 | bgp_clear_node_complete (struct work_queue *wq) |
200df115 | 2672 | { |
64e580a7 PJ |
2673 | struct peer *peer = wq->spec.data; |
2674 | ||
3e0c78ef | 2675 | /* Tickle FSM to start moving again */ |
ca058a30 | 2676 | BGP_EVENT_ADD (peer, Clearing_Completed); |
228da428 CC |
2677 | |
2678 | peer_unlock (peer); /* bgp_clear_route */ | |
200df115 | 2679 | } |
2680 | ||
2681 | static void | |
64e580a7 | 2682 | bgp_clear_node_queue_init (struct peer *peer) |
200df115 | 2683 | { |
a2943657 | 2684 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
64e580a7 | 2685 | |
a2943657 | 2686 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
64e580a7 PJ |
2687 | #undef CLEAR_QUEUE_NAME_LEN |
2688 | ||
2689 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) | |
200df115 | 2690 | { |
2691 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
2692 | exit (1); | |
2693 | } | |
64e580a7 PJ |
2694 | peer->clear_node_queue->spec.hold = 10; |
2695 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; | |
2696 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; | |
2697 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; | |
2698 | peer->clear_node_queue->spec.max_retries = 0; | |
2699 | ||
2700 | /* we only 'lock' this peer reference when the queue is actually active */ | |
2701 | peer->clear_node_queue->spec.data = peer; | |
200df115 | 2702 | } |
718e3744 | 2703 | |
200df115 | 2704 | static void |
2705 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, | |
228da428 CC |
2706 | struct bgp_table *table, struct peer *rsclient, |
2707 | enum bgp_clear_route_type purpose) | |
200df115 | 2708 | { |
200df115 | 2709 | struct bgp_node *rn; |
2710 | ||
f2c31acb | 2711 | |
718e3744 | 2712 | if (! table) |
fee0f4c6 | 2713 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
64e580a7 | 2714 | |
6cf159b9 | 2715 | /* If still no table => afi/safi isn't configured at all or smth. */ |
2716 | if (! table) | |
2717 | return; | |
65ca75e0 PJ |
2718 | |
2719 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2720 | { | |
f2c31acb PJ |
2721 | struct bgp_info *ri; |
2722 | struct bgp_adj_in *ain; | |
2723 | struct bgp_adj_out *aout; | |
2724 | ||
65ca75e0 PJ |
2725 | if (rn->info == NULL) |
2726 | continue; | |
f2c31acb PJ |
2727 | |
2728 | /* XXX:TODO: This is suboptimal, every non-empty route_node is | |
2729 | * queued for every clearing peer, regardless of whether it is | |
2730 | * relevant to the peer at hand. | |
2731 | * | |
2732 | * Overview: There are 3 different indices which need to be | |
2733 | * scrubbed, potentially, when a peer is removed: | |
2734 | * | |
2735 | * 1 peer's routes visible via the RIB (ie accepted routes) | |
2736 | * 2 peer's routes visible by the (optional) peer's adj-in index | |
2737 | * 3 other routes visible by the peer's adj-out index | |
2738 | * | |
2739 | * 3 there is no hurry in scrubbing, once the struct peer is | |
2740 | * removed from bgp->peer, we could just GC such deleted peer's | |
2741 | * adj-outs at our leisure. | |
2742 | * | |
2743 | * 1 and 2 must be 'scrubbed' in some way, at least made | |
2744 | * invisible via RIB index before peer session is allowed to be | |
2745 | * brought back up. So one needs to know when such a 'search' is | |
2746 | * complete. | |
2747 | * | |
2748 | * Ideally: | |
2749 | * | |
2750 | * - there'd be a single global queue or a single RIB walker | |
2751 | * - rather than tracking which route_nodes still need to be | |
2752 | * examined on a peer basis, we'd track which peers still | |
2753 | * aren't cleared | |
2754 | * | |
2755 | * Given that our per-peer prefix-counts now should be reliable, | |
2756 | * this may actually be achievable. It doesn't seem to be a huge | |
2757 | * problem at this time, | |
2758 | */ | |
2759 | for (ri = rn->info; ri; ri = ri->next) | |
228da428 | 2760 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb | 2761 | { |
228da428 CC |
2762 | struct bgp_clear_node_queue *cnq; |
2763 | ||
2764 | /* both unlocked in bgp_clear_node_queue_del */ | |
2765 | bgp_table_lock (rn->table); | |
2766 | bgp_lock_node (rn); | |
2767 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, | |
2768 | sizeof (struct bgp_clear_node_queue)); | |
2769 | cnq->rn = rn; | |
2770 | cnq->purpose = purpose; | |
2771 | work_queue_add (peer->clear_node_queue, cnq); | |
2772 | break; | |
f2c31acb PJ |
2773 | } |
2774 | ||
2775 | for (ain = rn->adj_in; ain; ain = ain->next) | |
228da428 | 2776 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb PJ |
2777 | { |
2778 | bgp_adj_in_remove (rn, ain); | |
2779 | bgp_unlock_node (rn); | |
2780 | break; | |
2781 | } | |
2782 | for (aout = rn->adj_out; aout; aout = aout->next) | |
228da428 | 2783 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb PJ |
2784 | { |
2785 | bgp_adj_out_remove (rn, aout, peer, afi, safi); | |
2786 | bgp_unlock_node (rn); | |
2787 | break; | |
2788 | } | |
65ca75e0 PJ |
2789 | } |
2790 | return; | |
2791 | } | |
2792 | ||
2793 | void | |
228da428 CC |
2794 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
2795 | enum bgp_clear_route_type purpose) | |
65ca75e0 PJ |
2796 | { |
2797 | struct bgp_node *rn; | |
2798 | struct bgp_table *table; | |
2799 | struct peer *rsclient; | |
2800 | struct listnode *node, *nnode; | |
6cf159b9 | 2801 | |
64e580a7 PJ |
2802 | if (peer->clear_node_queue == NULL) |
2803 | bgp_clear_node_queue_init (peer); | |
200df115 | 2804 | |
ca058a30 PJ |
2805 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
2806 | * Idle until it receives a Clearing_Completed event. This protects | |
2807 | * against peers which flap faster than we can we clear, which could | |
2808 | * lead to: | |
64e580a7 PJ |
2809 | * |
2810 | * a) race with routes from the new session being installed before | |
2811 | * clear_route_node visits the node (to delete the route of that | |
2812 | * peer) | |
2813 | * b) resource exhaustion, clear_route_node likely leads to an entry | |
2814 | * on the process_main queue. Fast-flapping could cause that queue | |
2815 | * to grow and grow. | |
200df115 | 2816 | */ |
ca058a30 PJ |
2817 | if (!peer->clear_node_queue->thread) |
2818 | peer_lock (peer); /* bgp_clear_node_complete */ | |
fee0f4c6 | 2819 | |
228da428 | 2820 | switch (purpose) |
fee0f4c6 | 2821 | { |
228da428 CC |
2822 | case BGP_CLEAR_ROUTE_NORMAL: |
2823 | if (safi != SAFI_MPLS_VPN) | |
2824 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); | |
2825 | else | |
2826 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2827 | rn = bgp_route_next (rn)) | |
2828 | if ((table = rn->info) != NULL) | |
2829 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); | |
2830 | ||
2831 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) | |
2832 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], | |
2833 | PEER_FLAG_RSERVER_CLIENT)) | |
2834 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); | |
2835 | break; | |
2836 | ||
2837 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: | |
2838 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); | |
2839 | break; | |
2840 | ||
2841 | default: | |
2842 | assert (0); | |
2843 | break; | |
fee0f4c6 | 2844 | } |
65ca75e0 | 2845 | |
ca058a30 | 2846 | /* If no routes were cleared, nothing was added to workqueue, the |
f2c31acb PJ |
2847 | * completion function won't be run by workqueue code - call it here. |
2848 | * XXX: Actually, this assumption doesn't hold, see | |
2849 | * bgp_clear_route_table(), we queue all non-empty nodes. | |
ca058a30 PJ |
2850 | * |
2851 | * Additionally, there is a presumption in FSM that clearing is only | |
f2c31acb PJ |
2852 | * really needed if peer state is Established - peers in |
2853 | * pre-Established states shouldn't have any route-update state | |
2854 | * associated with them (in or out). | |
ca058a30 | 2855 | * |
f2c31acb PJ |
2856 | * We still can get here in pre-Established though, through |
2857 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity | |
2858 | * check to ensure the assumption above holds. | |
ca058a30 PJ |
2859 | * |
2860 | * At some future point, this check could be move to the top of the | |
2861 | * function, and do a quick early-return when state is | |
2862 | * pre-Established, avoiding above list and table scans. Once we're | |
2863 | * sure it is safe.. | |
65ca75e0 PJ |
2864 | */ |
2865 | if (!peer->clear_node_queue->thread) | |
2866 | bgp_clear_node_complete (peer->clear_node_queue); | |
718e3744 | 2867 | } |
2868 | ||
2869 | void | |
2870 | bgp_clear_route_all (struct peer *peer) | |
2871 | { | |
2872 | afi_t afi; | |
2873 | safi_t safi; | |
2874 | ||
2875 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2876 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
228da428 | 2877 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
718e3744 | 2878 | } |
2879 | ||
2880 | void | |
2881 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) | |
2882 | { | |
2883 | struct bgp_table *table; | |
2884 | struct bgp_node *rn; | |
2885 | struct bgp_adj_in *ain; | |
2886 | ||
2887 | table = peer->bgp->rib[afi][safi]; | |
2888 | ||
2889 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2890 | for (ain = rn->adj_in; ain ; ain = ain->next) | |
2891 | if (ain->peer == peer) | |
2892 | { | |
2893 | bgp_adj_in_remove (rn, ain); | |
2894 | bgp_unlock_node (rn); | |
2895 | break; | |
2896 | } | |
2897 | } | |
93406d87 | 2898 | |
2899 | void | |
2900 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) | |
2901 | { | |
2902 | struct bgp_node *rn; | |
2903 | struct bgp_info *ri; | |
2904 | struct bgp_table *table; | |
2905 | ||
2906 | table = peer->bgp->rib[afi][safi]; | |
2907 | ||
2908 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2909 | { | |
2910 | for (ri = rn->info; ri; ri = ri->next) | |
2911 | if (ri->peer == peer) | |
2912 | { | |
2913 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2914 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
2915 | break; | |
2916 | } | |
2917 | } | |
2918 | } | |
718e3744 | 2919 | \f |
2920 | /* Delete all kernel routes. */ | |
2921 | void | |
66e5cd87 | 2922 | bgp_cleanup_routes (void) |
718e3744 | 2923 | { |
2924 | struct bgp *bgp; | |
1eb8ef25 | 2925 | struct listnode *node, *nnode; |
718e3744 | 2926 | struct bgp_node *rn; |
2927 | struct bgp_table *table; | |
2928 | struct bgp_info *ri; | |
2929 | ||
1eb8ef25 | 2930 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 2931 | { |
2932 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; | |
2933 | ||
2934 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2935 | for (ri = rn->info; ri; ri = ri->next) | |
2936 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
2937 | && ri->type == ZEBRA_ROUTE_BGP | |
2938 | && ri->sub_type == BGP_ROUTE_NORMAL) | |
2939 | bgp_zebra_withdraw (&rn->p, ri); | |
2940 | ||
2941 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; | |
2942 | ||
2943 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2944 | for (ri = rn->info; ri; ri = ri->next) | |
2945 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
2946 | && ri->type == ZEBRA_ROUTE_BGP | |
2947 | && ri->sub_type == BGP_ROUTE_NORMAL) | |
2948 | bgp_zebra_withdraw (&rn->p, ri); | |
2949 | } | |
2950 | } | |
2951 | ||
2952 | void | |
66e5cd87 | 2953 | bgp_reset (void) |
718e3744 | 2954 | { |
2955 | vty_reset (); | |
2956 | bgp_zclient_reset (); | |
2957 | access_list_reset (); | |
2958 | prefix_list_reset (); | |
2959 | } | |
2960 | \f | |
2961 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr | |
2962 | value. */ | |
2963 | int | |
2964 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) | |
2965 | { | |
2966 | u_char *pnt; | |
2967 | u_char *lim; | |
2968 | struct prefix p; | |
2969 | int psize; | |
2970 | int ret; | |
2971 | ||
2972 | /* Check peer status. */ | |
2973 | if (peer->status != Established) | |
2974 | return 0; | |
2975 | ||
2976 | pnt = packet->nlri; | |
2977 | lim = pnt + packet->length; | |
2978 | ||
2979 | for (; pnt < lim; pnt += psize) | |
2980 | { | |
2981 | /* Clear prefix structure. */ | |
2982 | memset (&p, 0, sizeof (struct prefix)); | |
2983 | ||
2984 | /* Fetch prefix length. */ | |
2985 | p.prefixlen = *pnt++; | |
2986 | p.family = afi2family (packet->afi); | |
2987 | ||
2988 | /* Already checked in nlri_sanity_check(). We do double check | |
2989 | here. */ | |
2990 | if ((packet->afi == AFI_IP && p.prefixlen > 32) | |
2991 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) | |
2992 | return -1; | |
2993 | ||
2994 | /* Packet size overflow check. */ | |
2995 | psize = PSIZE (p.prefixlen); | |
2996 | ||
2997 | /* When packet overflow occur return immediately. */ | |
2998 | if (pnt + psize > lim) | |
2999 | return -1; | |
3000 | ||
3001 | /* Fetch prefix from NLRI packet. */ | |
3002 | memcpy (&p.u.prefix, pnt, psize); | |
3003 | ||
3004 | /* Check address. */ | |
3005 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) | |
3006 | { | |
3007 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) | |
3008 | { | |
f5ba3874 | 3009 | /* |
3010 | * From draft-ietf-idr-bgp4-22, Section 6.3: | |
3011 | * If a BGP router receives an UPDATE message with a | |
3012 | * semantically incorrect NLRI field, in which a prefix is | |
3013 | * semantically incorrect (eg. an unexpected multicast IP | |
3014 | * address), it should ignore the prefix. | |
3015 | */ | |
718e3744 | 3016 | zlog (peer->log, LOG_ERR, |
3017 | "IPv4 unicast NLRI is multicast address %s", | |
3018 | inet_ntoa (p.u.prefix4)); | |
f5ba3874 | 3019 | |
718e3744 | 3020 | return -1; |
3021 | } | |
3022 | } | |
3023 | ||
3024 | #ifdef HAVE_IPV6 | |
3025 | /* Check address. */ | |
3026 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) | |
3027 | { | |
3028 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3029 | { | |
3030 | char buf[BUFSIZ]; | |
3031 | ||
3032 | zlog (peer->log, LOG_WARNING, | |
3033 | "IPv6 link-local NLRI received %s ignore this NLRI", | |
3034 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); | |
3035 | ||
3036 | continue; | |
3037 | } | |
3038 | } | |
3039 | #endif /* HAVE_IPV6 */ | |
3040 | ||
3041 | /* Normal process. */ | |
3042 | if (attr) | |
3043 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, | |
3044 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); | |
3045 | else | |
3046 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, | |
3047 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); | |
3048 | ||
3049 | /* Address family configuration mismatch or maximum-prefix count | |
3050 | overflow. */ | |
3051 | if (ret < 0) | |
3052 | return -1; | |
3053 | } | |
3054 | ||
3055 | /* Packet length consistency check. */ | |
3056 | if (pnt != lim) | |
3057 | return -1; | |
3058 | ||
3059 | return 0; | |
3060 | } | |
3061 | ||
3062 | /* NLRI encode syntax check routine. */ | |
3063 | int | |
3064 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, | |
3065 | bgp_size_t length) | |
3066 | { | |
3067 | u_char *end; | |
3068 | u_char prefixlen; | |
3069 | int psize; | |
3070 | ||
3071 | end = pnt + length; | |
3072 | ||
3073 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for | |
3074 | syntactic validity. If the field is syntactically incorrect, | |
3075 | then the Error Subcode is set to Invalid Network Field. */ | |
3076 | ||
3077 | while (pnt < end) | |
3078 | { | |
3079 | prefixlen = *pnt++; | |
3080 | ||
3081 | /* Prefix length check. */ | |
3082 | if ((afi == AFI_IP && prefixlen > 32) | |
3083 | || (afi == AFI_IP6 && prefixlen > 128)) | |
3084 | { | |
3085 | plog_err (peer->log, | |
3086 | "%s [Error] Update packet error (wrong prefix length %d)", | |
3087 | peer->host, prefixlen); | |
3088 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3089 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3090 | return -1; | |
3091 | } | |
3092 | ||
3093 | /* Packet size overflow check. */ | |
3094 | psize = PSIZE (prefixlen); | |
3095 | ||
3096 | if (pnt + psize > end) | |
3097 | { | |
3098 | plog_err (peer->log, | |
3099 | "%s [Error] Update packet error" | |
3100 | " (prefix data overflow prefix size is %d)", | |
3101 | peer->host, psize); | |
3102 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3103 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3104 | return -1; | |
3105 | } | |
3106 | ||
3107 | pnt += psize; | |
3108 | } | |
3109 | ||
3110 | /* Packet length consistency check. */ | |
3111 | if (pnt != end) | |
3112 | { | |
3113 | plog_err (peer->log, | |
3114 | "%s [Error] Update packet error" | |
3115 | " (prefix length mismatch with total length)", | |
3116 | peer->host); | |
3117 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3118 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3119 | return -1; | |
3120 | } | |
3121 | return 0; | |
3122 | } | |
3123 | \f | |
94f2b392 | 3124 | static struct bgp_static * |
66e5cd87 | 3125 | bgp_static_new (void) |
718e3744 | 3126 | { |
393deb9b | 3127 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
718e3744 | 3128 | } |
3129 | ||
94f2b392 | 3130 | static void |
718e3744 | 3131 | bgp_static_free (struct bgp_static *bgp_static) |
3132 | { | |
3133 | if (bgp_static->rmap.name) | |
3134 | free (bgp_static->rmap.name); | |
3135 | XFREE (MTYPE_BGP_STATIC, bgp_static); | |
3136 | } | |
3137 | ||
94f2b392 | 3138 | static void |
fee0f4c6 | 3139 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
3140 | struct prefix *p, afi_t afi, safi_t safi) | |
3141 | { | |
3142 | struct bgp_node *rn; | |
3143 | struct bgp_info *ri; | |
3144 | ||
3145 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); | |
3146 | ||
3147 | /* Check selected route and self inserted route. */ | |
3148 | for (ri = rn->info; ri; ri = ri->next) | |
3149 | if (ri->peer == bgp->peer_self | |
3150 | && ri->type == ZEBRA_ROUTE_BGP | |
3151 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3152 | break; | |
3153 | ||
3154 | /* Withdraw static BGP route from routing table. */ | |
3155 | if (ri) | |
3156 | { | |
fee0f4c6 | 3157 | bgp_info_delete (rn, ri); |
1a392d46 | 3158 | bgp_process (bgp, rn, afi, safi); |
fee0f4c6 | 3159 | } |
3160 | ||
3161 | /* Unlock bgp_node_lookup. */ | |
3162 | bgp_unlock_node (rn); | |
3163 | } | |
3164 | ||
94f2b392 | 3165 | static void |
fee0f4c6 | 3166 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
fb982c25 PJ |
3167 | struct bgp_static *bgp_static, |
3168 | afi_t afi, safi_t safi) | |
fee0f4c6 | 3169 | { |
3170 | struct bgp_node *rn; | |
3171 | struct bgp_info *ri; | |
3172 | struct bgp_info *new; | |
3173 | struct bgp_info info; | |
fee0f4c6 | 3174 | struct attr *attr_new; |
fb982c25 PJ |
3175 | struct attr attr = {0 }; |
3176 | struct attr new_attr = { .extra = 0 }; | |
fee0f4c6 | 3177 | struct bgp *bgp; |
3178 | int ret; | |
3179 | char buf[SU_ADDRSTRLEN]; | |
3180 | ||
3181 | bgp = rsclient->bgp; | |
3182 | ||
06e110f9 PJ |
3183 | assert (bgp_static); |
3184 | if (!bgp_static) | |
3185 | return; | |
3186 | ||
fee0f4c6 | 3187 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
3188 | ||
3189 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
06e110f9 PJ |
3190 | |
3191 | attr.nexthop = bgp_static->igpnexthop; | |
3192 | attr.med = bgp_static->igpmetric; | |
3193 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
41367172 | 3194 | |
41367172 PJ |
3195 | if (bgp_static->atomic) |
3196 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3197 | ||
fee0f4c6 | 3198 | /* Apply network route-map for export to this rsclient. */ |
3199 | if (bgp_static->rmap.name) | |
3200 | { | |
fb982c25 | 3201 | struct attr attr_tmp = attr; |
fee0f4c6 | 3202 | info.peer = rsclient; |
fb982c25 PJ |
3203 | info.attr = &attr_tmp; |
3204 | ||
fee0f4c6 | 3205 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
3206 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); | |
3207 | ||
3208 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); | |
3209 | ||
3210 | rsclient->rmap_type = 0; | |
3211 | ||
3212 | if (ret == RMAP_DENYMATCH) | |
3213 | { | |
3214 | /* Free uninterned attribute. */ | |
fb982c25 | 3215 | bgp_attr_flush (&attr_tmp); |
fee0f4c6 | 3216 | |
3217 | /* Unintern original. */ | |
f6f434b2 | 3218 | aspath_unintern (&attr.aspath); |
fee0f4c6 | 3219 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
fb982c25 PJ |
3220 | bgp_attr_extra_free (&attr); |
3221 | ||
fee0f4c6 | 3222 | return; |
3223 | } | |
fb982c25 | 3224 | attr_new = bgp_attr_intern (&attr_tmp); |
fee0f4c6 | 3225 | } |
3226 | else | |
3227 | attr_new = bgp_attr_intern (&attr); | |
fb982c25 | 3228 | |
7badc263 | 3229 | bgp_attr_dup(&new_attr, attr_new); |
fb982c25 | 3230 | |
fee0f4c6 | 3231 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3232 | ||
fb982c25 PJ |
3233 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
3234 | == RMAP_DENY) | |
3235 | { | |
fee0f4c6 | 3236 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
3237 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 3238 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 3239 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
3240 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
3241 | p->prefixlen, rsclient->host); | |
3242 | ||
3243 | bgp->peer_self->rmap_type = 0; | |
3244 | ||
f6f434b2 PJ |
3245 | bgp_attr_unintern (&attr_new); |
3246 | aspath_unintern (&attr.aspath); | |
fb982c25 | 3247 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3248 | |
3249 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); | |
3250 | ||
3251 | return; | |
fb982c25 | 3252 | } |
fee0f4c6 | 3253 | |
3254 | bgp->peer_self->rmap_type = 0; | |
3255 | ||
f6f434b2 | 3256 | bgp_attr_unintern (&attr_new); |
fee0f4c6 | 3257 | attr_new = bgp_attr_intern (&new_attr); |
7badc263 | 3258 | bgp_attr_extra_free (&new_attr); |
fee0f4c6 | 3259 | |
3260 | for (ri = rn->info; ri; ri = ri->next) | |
3261 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3262 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3263 | break; | |
3264 | ||
3265 | if (ri) | |
3266 | { | |
8d45210e AS |
3267 | if (attrhash_cmp (ri->attr, attr_new) && |
3268 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
fee0f4c6 | 3269 | { |
3270 | bgp_unlock_node (rn); | |
f6f434b2 PJ |
3271 | bgp_attr_unintern (&attr_new); |
3272 | aspath_unintern (&attr.aspath); | |
fb982c25 | 3273 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3274 | return; |
3275 | } | |
3276 | else | |
3277 | { | |
3278 | /* The attribute is changed. */ | |
1a392d46 | 3279 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 3280 | |
3281 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3282 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3283 | bgp_info_restore(rn, ri); | |
f6f434b2 | 3284 | bgp_attr_unintern (&ri->attr); |
fee0f4c6 | 3285 | ri->attr = attr_new; |
65957886 | 3286 | ri->uptime = bgp_clock (); |
fee0f4c6 | 3287 | |
3288 | /* Process change. */ | |
3289 | bgp_process (bgp, rn, afi, safi); | |
3290 | bgp_unlock_node (rn); | |
f6f434b2 | 3291 | aspath_unintern (&attr.aspath); |
fb982c25 | 3292 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3293 | return; |
fb982c25 | 3294 | } |
fee0f4c6 | 3295 | } |
fb982c25 | 3296 | |
fee0f4c6 | 3297 | /* Make new BGP info. */ |
3298 | new = bgp_info_new (); | |
3299 | new->type = ZEBRA_ROUTE_BGP; | |
3300 | new->sub_type = BGP_ROUTE_STATIC; | |
3301 | new->peer = bgp->peer_self; | |
3302 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3303 | new->attr = attr_new; | |
65957886 | 3304 | new->uptime = bgp_clock (); |
fee0f4c6 | 3305 | |
3306 | /* Register new BGP information. */ | |
3307 | bgp_info_add (rn, new); | |
200df115 | 3308 | |
3309 | /* route_node_get lock */ | |
3310 | bgp_unlock_node (rn); | |
3311 | ||
fee0f4c6 | 3312 | /* Process change. */ |
3313 | bgp_process (bgp, rn, afi, safi); | |
3314 | ||
3315 | /* Unintern original. */ | |
f6f434b2 | 3316 | aspath_unintern (&attr.aspath); |
fb982c25 | 3317 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3318 | } |
3319 | ||
94f2b392 | 3320 | static void |
fee0f4c6 | 3321 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
718e3744 | 3322 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
3323 | { | |
3324 | struct bgp_node *rn; | |
3325 | struct bgp_info *ri; | |
3326 | struct bgp_info *new; | |
3327 | struct bgp_info info; | |
fb982c25 | 3328 | struct attr attr = { 0 }; |
718e3744 | 3329 | struct attr *attr_new; |
3330 | int ret; | |
3331 | ||
dd8103a9 PJ |
3332 | assert (bgp_static); |
3333 | if (!bgp_static) | |
3334 | return; | |
3335 | ||
fee0f4c6 | 3336 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3337 | |
3338 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
dd8103a9 PJ |
3339 | |
3340 | attr.nexthop = bgp_static->igpnexthop; | |
3341 | attr.med = bgp_static->igpmetric; | |
3342 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
718e3744 | 3343 | |
41367172 PJ |
3344 | if (bgp_static->atomic) |
3345 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3346 | ||
718e3744 | 3347 | /* Apply route-map. */ |
3348 | if (bgp_static->rmap.name) | |
3349 | { | |
fb982c25 | 3350 | struct attr attr_tmp = attr; |
718e3744 | 3351 | info.peer = bgp->peer_self; |
286e1e71 | 3352 | info.attr = &attr_tmp; |
718e3744 | 3353 | |
fee0f4c6 | 3354 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3355 | ||
718e3744 | 3356 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
286e1e71 | 3357 | |
fee0f4c6 | 3358 | bgp->peer_self->rmap_type = 0; |
3359 | ||
718e3744 | 3360 | if (ret == RMAP_DENYMATCH) |
3361 | { | |
3362 | /* Free uninterned attribute. */ | |
286e1e71 | 3363 | bgp_attr_flush (&attr_tmp); |
718e3744 | 3364 | |
3365 | /* Unintern original. */ | |
f6f434b2 | 3366 | aspath_unintern (&attr.aspath); |
fb982c25 | 3367 | bgp_attr_extra_free (&attr); |
718e3744 | 3368 | bgp_static_withdraw (bgp, p, afi, safi); |
3369 | return; | |
3370 | } | |
286e1e71 | 3371 | attr_new = bgp_attr_intern (&attr_tmp); |
718e3744 | 3372 | } |
286e1e71 | 3373 | else |
3374 | attr_new = bgp_attr_intern (&attr); | |
718e3744 | 3375 | |
3376 | for (ri = rn->info; ri; ri = ri->next) | |
3377 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3378 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3379 | break; | |
3380 | ||
3381 | if (ri) | |
3382 | { | |
8d45210e AS |
3383 | if (attrhash_cmp (ri->attr, attr_new) && |
3384 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
718e3744 | 3385 | { |
3386 | bgp_unlock_node (rn); | |
f6f434b2 PJ |
3387 | bgp_attr_unintern (&attr_new); |
3388 | aspath_unintern (&attr.aspath); | |
fb982c25 | 3389 | bgp_attr_extra_free (&attr); |
718e3744 | 3390 | return; |
3391 | } | |
3392 | else | |
3393 | { | |
3394 | /* The attribute is changed. */ | |
1a392d46 | 3395 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 3396 | |
3397 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3398 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3399 | bgp_info_restore(rn, ri); | |
3400 | else | |
3401 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
f6f434b2 | 3402 | bgp_attr_unintern (&ri->attr); |
718e3744 | 3403 | ri->attr = attr_new; |
65957886 | 3404 | ri->uptime = bgp_clock (); |
718e3744 | 3405 | |
3406 | /* Process change. */ | |
3407 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
3408 | bgp_process (bgp, rn, afi, safi); | |
3409 | bgp_unlock_node (rn); | |
f6f434b2 | 3410 | aspath_unintern (&attr.aspath); |
fb982c25 | 3411 | bgp_attr_extra_free (&attr); |
718e3744 | 3412 | return; |
3413 | } | |
3414 | } | |
3415 | ||
3416 | /* Make new BGP info. */ | |
3417 | new = bgp_info_new (); | |
3418 | new->type = ZEBRA_ROUTE_BGP; | |
3419 | new->sub_type = BGP_ROUTE_STATIC; | |
3420 | new->peer = bgp->peer_self; | |
3421 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3422 | new->attr = attr_new; | |
65957886 | 3423 | new->uptime = bgp_clock (); |
718e3744 | 3424 | |
3425 | /* Aggregate address increment. */ | |
3426 | bgp_aggregate_increment (bgp, p, new, afi, safi); | |
3427 | ||
3428 | /* Register new BGP information. */ | |
3429 | bgp_info_add (rn, new); | |
200df115 | 3430 | |
3431 | /* route_node_get lock */ | |
3432 | bgp_unlock_node (rn); | |
3433 | ||
718e3744 | 3434 | /* Process change. */ |
3435 | bgp_process (bgp, rn, afi, safi); | |
3436 | ||
3437 | /* Unintern original. */ | |
f6f434b2 | 3438 | aspath_unintern (&attr.aspath); |
fb982c25 | 3439 | bgp_attr_extra_free (&attr); |
718e3744 | 3440 | } |
3441 | ||
fee0f4c6 | 3442 | void |
3443 | bgp_static_update (struct bgp *bgp, struct prefix *p, | |
3444 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
3445 | { | |
3446 | struct peer *rsclient; | |
1eb8ef25 | 3447 | struct listnode *node, *nnode; |
fee0f4c6 | 3448 | |
3449 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); | |
3450 | ||
1eb8ef25 | 3451 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 3452 | { |
da5b30f6 PJ |
3453 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
3454 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); | |
fee0f4c6 | 3455 | } |
3456 | } | |
3457 | ||
94f2b392 | 3458 | static void |
4c9641ba ML |
3459 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3460 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3461 | { |
3462 | struct bgp_node *rn; | |
3463 | struct bgp_info *new; | |
fb982c25 | 3464 | |
fee0f4c6 | 3465 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3466 | |
3467 | /* Make new BGP info. */ | |
3468 | new = bgp_info_new (); | |
3469 | new->type = ZEBRA_ROUTE_BGP; | |
3470 | new->sub_type = BGP_ROUTE_STATIC; | |
3471 | new->peer = bgp->peer_self; | |
3472 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); | |
3473 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
65957886 | 3474 | new->uptime = bgp_clock (); |
fb982c25 PJ |
3475 | new->extra = bgp_info_extra_new(); |
3476 | memcpy (new->extra->tag, tag, 3); | |
718e3744 | 3477 | |
3478 | /* Aggregate address increment. */ | |
200df115 | 3479 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
718e3744 | 3480 | |
3481 | /* Register new BGP information. */ | |
200df115 | 3482 | bgp_info_add (rn, new); |
718e3744 | 3483 | |
200df115 | 3484 | /* route_node_get lock */ |
3485 | bgp_unlock_node (rn); | |
3486 | ||
718e3744 | 3487 | /* Process change. */ |
3488 | bgp_process (bgp, rn, afi, safi); | |
3489 | } | |
3490 | ||
3491 | void | |
3492 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, | |
3493 | safi_t safi) | |
3494 | { | |
3495 | struct bgp_node *rn; | |
3496 | struct bgp_info *ri; | |
3497 | ||
fee0f4c6 | 3498 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3499 | |
3500 | /* Check selected route and self inserted route. */ | |
3501 | for (ri = rn->info; ri; ri = ri->next) | |
3502 | if (ri->peer == bgp->peer_self | |
3503 | && ri->type == ZEBRA_ROUTE_BGP | |
3504 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3505 | break; | |
3506 | ||
3507 | /* Withdraw static BGP route from routing table. */ | |
3508 | if (ri) | |
3509 | { | |
3510 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3511 | bgp_info_delete (rn, ri); |
1a392d46 | 3512 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3513 | } |
3514 | ||
3515 | /* Unlock bgp_node_lookup. */ | |
3516 | bgp_unlock_node (rn); | |
3517 | } | |
3518 | ||
fee0f4c6 | 3519 | void |
3520 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) | |
3521 | { | |
3522 | struct bgp_static *bgp_static; | |
3523 | struct bgp *bgp; | |
3524 | struct bgp_node *rn; | |
3525 | struct prefix *p; | |
3526 | ||
3527 | bgp = rsclient->bgp; | |
3528 | ||
3529 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3530 | if ((bgp_static = rn->info) != NULL) | |
3531 | { | |
3532 | p = &rn->p; | |
3533 | ||
3534 | bgp_static_update_rsclient (rsclient, p, bgp_static, | |
3535 | afi, safi); | |
3536 | } | |
3537 | } | |
3538 | ||
94f2b392 | 3539 | static void |
4c9641ba ML |
3540 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3541 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3542 | { |
3543 | struct bgp_node *rn; | |
3544 | struct bgp_info *ri; | |
3545 | ||
fee0f4c6 | 3546 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3547 | |
3548 | /* Check selected route and self inserted route. */ | |
3549 | for (ri = rn->info; ri; ri = ri->next) | |
3550 | if (ri->peer == bgp->peer_self | |
3551 | && ri->type == ZEBRA_ROUTE_BGP | |
3552 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3553 | break; | |
3554 | ||
3555 | /* Withdraw static BGP route from routing table. */ | |
3556 | if (ri) | |
3557 | { | |
3558 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3559 | bgp_info_delete (rn, ri); |
1a392d46 | 3560 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3561 | } |
3562 | ||
3563 | /* Unlock bgp_node_lookup. */ | |
3564 | bgp_unlock_node (rn); | |
3565 | } | |
3566 | ||
3567 | /* Configure static BGP network. When user don't run zebra, static | |
3568 | route should be installed as valid. */ | |
94f2b392 | 3569 | static int |
fd79ac91 | 3570 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
c8f3fe30 | 3571 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
718e3744 | 3572 | { |
3573 | int ret; | |
3574 | struct prefix p; | |
3575 | struct bgp_static *bgp_static; | |
3576 | struct bgp_node *rn; | |
41367172 | 3577 | u_char need_update = 0; |
718e3744 | 3578 | |
3579 | /* Convert IP prefix string to struct prefix. */ | |
3580 | ret = str2prefix (ip_str, &p); | |
3581 | if (! ret) | |
3582 | { | |
3583 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3584 | return CMD_WARNING; | |
3585 | } | |
3586 | #ifdef HAVE_IPV6 | |
3587 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3588 | { | |
3589 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3590 | VTY_NEWLINE); | |
3591 | return CMD_WARNING; | |
3592 | } | |
3593 | #endif /* HAVE_IPV6 */ | |
3594 | ||
3595 | apply_mask (&p); | |
3596 | ||
3597 | /* Set BGP static route configuration. */ | |
3598 | rn = bgp_node_get (bgp->route[afi][safi], &p); | |
3599 | ||
3600 | if (rn->info) | |
3601 | { | |
3602 | /* Configuration change. */ | |
3603 | bgp_static = rn->info; | |
3604 | ||
3605 | /* Check previous routes are installed into BGP. */ | |
c8f3fe30 PJ |
3606 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
3607 | need_update = 1; | |
41367172 | 3608 | |
718e3744 | 3609 | bgp_static->backdoor = backdoor; |
41367172 | 3610 | |
718e3744 | 3611 | if (rmap) |
3612 | { | |
3613 | if (bgp_static->rmap.name) | |
3614 | free (bgp_static->rmap.name); | |
3615 | bgp_static->rmap.name = strdup (rmap); | |
3616 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); | |
3617 | } | |
3618 | else | |
3619 | { | |
3620 | if (bgp_static->rmap.name) | |
3621 | free (bgp_static->rmap.name); | |
3622 | bgp_static->rmap.name = NULL; | |
3623 | bgp_static->rmap.map = NULL; | |
3624 | bgp_static->valid = 0; | |
3625 | } | |
3626 | bgp_unlock_node (rn); | |
3627 | } | |
3628 | else | |
3629 | { | |
3630 | /* New configuration. */ | |
3631 | bgp_static = bgp_static_new (); | |
3632 | bgp_static->backdoor = backdoor; | |
3633 | bgp_static->valid = 0; | |
3634 | bgp_static->igpmetric = 0; | |
3635 | bgp_static->igpnexthop.s_addr = 0; | |
41367172 | 3636 | |
718e3744 | 3637 | if (rmap) |
3638 | { | |
3639 | if (bgp_static->rmap.name) | |
3640 | free (bgp_static->rmap.name); | |
3641 | bgp_static->rmap.name = strdup (rmap); | |
3642 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); | |
3643 | } | |
3644 | rn->info = bgp_static; | |
3645 | } | |
3646 | ||
3647 | /* If BGP scan is not enabled, we should install this route here. */ | |
3648 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3649 | { | |
3650 | bgp_static->valid = 1; | |
3651 | ||
3652 | if (need_update) | |
3653 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3654 | ||
3655 | if (! bgp_static->backdoor) | |
3656 | bgp_static_update (bgp, &p, bgp_static, afi, safi); | |
3657 | } | |
3658 | ||
3659 | return CMD_SUCCESS; | |
3660 | } | |
3661 | ||
3662 | /* Configure static BGP network. */ | |
94f2b392 | 3663 | static int |
fd79ac91 | 3664 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
4c9641ba | 3665 | afi_t afi, safi_t safi) |
718e3744 | 3666 | { |
3667 | int ret; | |
3668 | struct prefix p; | |
3669 | struct bgp_static *bgp_static; | |
3670 | struct bgp_node *rn; | |
3671 | ||
3672 | /* Convert IP prefix string to struct prefix. */ | |
3673 | ret = str2prefix (ip_str, &p); | |
3674 | if (! ret) | |
3675 | { | |
3676 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3677 | return CMD_WARNING; | |
3678 | } | |
3679 | #ifdef HAVE_IPV6 | |
3680 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3681 | { | |
3682 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3683 | VTY_NEWLINE); | |
3684 | return CMD_WARNING; | |
3685 | } | |
3686 | #endif /* HAVE_IPV6 */ | |
3687 | ||
3688 | apply_mask (&p); | |
3689 | ||
3690 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); | |
3691 | if (! rn) | |
3692 | { | |
3693 | vty_out (vty, "%% Can't find specified static route configuration.%s", | |
3694 | VTY_NEWLINE); | |
3695 | return CMD_WARNING; | |
3696 | } | |
3697 | ||
3698 | bgp_static = rn->info; | |
41367172 | 3699 | |
718e3744 | 3700 | /* Update BGP RIB. */ |
3701 | if (! bgp_static->backdoor) | |
3702 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3703 | ||
3704 | /* Clear configuration. */ | |
3705 | bgp_static_free (bgp_static); | |
3706 | rn->info = NULL; | |
3707 | bgp_unlock_node (rn); | |
3708 | bgp_unlock_node (rn); | |
3709 | ||
3710 | return CMD_SUCCESS; | |
3711 | } | |
3712 | ||
3713 | /* Called from bgp_delete(). Delete all static routes from the BGP | |
3714 | instance. */ | |
3715 | void | |
3716 | bgp_static_delete (struct bgp *bgp) | |
3717 | { | |
3718 | afi_t afi; | |
3719 | safi_t safi; | |
3720 | struct bgp_node *rn; | |
3721 | struct bgp_node *rm; | |
3722 | struct bgp_table *table; | |
3723 | struct bgp_static *bgp_static; | |
3724 | ||
3725 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3726 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3727 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3728 | if (rn->info != NULL) | |
3729 | { | |
3730 | if (safi == SAFI_MPLS_VPN) | |
3731 | { | |
3732 | table = rn->info; | |
3733 | ||
3734 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3735 | { | |
3736 | bgp_static = rn->info; | |
3737 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, | |
3738 | AFI_IP, SAFI_MPLS_VPN, | |
3739 | (struct prefix_rd *)&rn->p, | |
3740 | bgp_static->tag); | |
3741 | bgp_static_free (bgp_static); | |
3742 | rn->info = NULL; | |
3743 | bgp_unlock_node (rn); | |
3744 | } | |
3745 | } | |
3746 | else | |
3747 | { | |
3748 | bgp_static = rn->info; | |
3749 | bgp_static_withdraw (bgp, &rn->p, afi, safi); | |
3750 | bgp_static_free (bgp_static); | |
3751 | rn->info = NULL; | |
3752 | bgp_unlock_node (rn); | |
3753 | } | |
3754 | } | |
3755 | } | |
3756 | ||
3757 | int | |
fd79ac91 | 3758 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
3759 | const char *tag_str) | |
718e3744 | 3760 | { |
3761 | int ret; | |
3762 | struct prefix p; | |
3763 | struct prefix_rd prd; | |
3764 | struct bgp *bgp; | |
3765 | struct bgp_node *prn; | |
3766 | struct bgp_node *rn; | |
3767 | struct bgp_table *table; | |
3768 | struct bgp_static *bgp_static; | |
3769 | u_char tag[3]; | |
3770 | ||
3771 | bgp = vty->index; | |
3772 | ||
3773 | ret = str2prefix (ip_str, &p); | |
3774 | if (! ret) | |
3775 | { | |
3776 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3777 | return CMD_WARNING; | |
3778 | } | |
3779 | apply_mask (&p); | |
3780 | ||
3781 | ret = str2prefix_rd (rd_str, &prd); | |
3782 | if (! ret) | |
3783 | { | |
3784 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3785 | return CMD_WARNING; | |
3786 | } | |
3787 | ||
3788 | ret = str2tag (tag_str, tag); | |
3789 | if (! ret) | |
3790 | { | |
3791 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3792 | return CMD_WARNING; | |
3793 | } | |
3794 | ||
3795 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
3796 | (struct prefix *)&prd); | |
3797 | if (prn->info == NULL) | |
64e580a7 | 3798 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 3799 | else |
3800 | bgp_unlock_node (prn); | |
3801 | table = prn->info; | |
3802 | ||
3803 | rn = bgp_node_get (table, &p); | |
3804 | ||
3805 | if (rn->info) | |
3806 | { | |
3807 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); | |
3808 | bgp_unlock_node (rn); | |
3809 | } | |
3810 | else | |
3811 | { | |
3812 | /* New configuration. */ | |
3813 | bgp_static = bgp_static_new (); | |
3814 | bgp_static->valid = 1; | |
3815 | memcpy (bgp_static->tag, tag, 3); | |
3816 | rn->info = bgp_static; | |
3817 | ||
3818 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
3819 | } | |
3820 | ||
3821 | return CMD_SUCCESS; | |
3822 | } | |
3823 | ||
3824 | /* Configure static BGP network. */ | |
3825 | int | |
fd79ac91 | 3826 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
3827 | const char *rd_str, const char *tag_str) | |
718e3744 | 3828 | { |
3829 | int ret; | |
3830 | struct bgp *bgp; | |
3831 | struct prefix p; | |
3832 | struct prefix_rd prd; | |
3833 | struct bgp_node *prn; | |
3834 | struct bgp_node *rn; | |
3835 | struct bgp_table *table; | |
3836 | struct bgp_static *bgp_static; | |
3837 | u_char tag[3]; | |
3838 | ||
3839 | bgp = vty->index; | |
3840 | ||
3841 | /* Convert IP prefix string to struct prefix. */ | |
3842 | ret = str2prefix (ip_str, &p); | |
3843 | if (! ret) | |
3844 | { | |
3845 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3846 | return CMD_WARNING; | |
3847 | } | |
3848 | apply_mask (&p); | |
3849 | ||
3850 | ret = str2prefix_rd (rd_str, &prd); | |
3851 | if (! ret) | |
3852 | { | |
3853 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3854 | return CMD_WARNING; | |
3855 | } | |
3856 | ||
3857 | ret = str2tag (tag_str, tag); | |
3858 | if (! ret) | |
3859 | { | |
3860 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3861 | return CMD_WARNING; | |
3862 | } | |
3863 | ||
3864 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
3865 | (struct prefix *)&prd); | |
3866 | if (prn->info == NULL) | |
64e580a7 | 3867 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 3868 | else |
3869 | bgp_unlock_node (prn); | |
3870 | table = prn->info; | |
3871 | ||
3872 | rn = bgp_node_lookup (table, &p); | |
3873 | ||
3874 | if (rn) | |
3875 | { | |
3876 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
3877 | ||
3878 | bgp_static = rn->info; | |
3879 | bgp_static_free (bgp_static); | |
3880 | rn->info = NULL; | |
3881 | bgp_unlock_node (rn); | |
3882 | bgp_unlock_node (rn); | |
3883 | } | |
3884 | else | |
3885 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); | |
3886 | ||
3887 | return CMD_SUCCESS; | |
3888 | } | |
3889 | \f | |
3890 | DEFUN (bgp_network, | |
3891 | bgp_network_cmd, | |
3892 | "network A.B.C.D/M", | |
3893 | "Specify a network to announce via BGP\n" | |
3894 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
3895 | { | |
3896 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 3897 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 3898 | } |
3899 | ||
3900 | DEFUN (bgp_network_route_map, | |
3901 | bgp_network_route_map_cmd, | |
3902 | "network A.B.C.D/M route-map WORD", | |
3903 | "Specify a network to announce via BGP\n" | |
3904 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
3905 | "Route-map to modify the attributes\n" | |
3906 | "Name of the route map\n") | |
3907 | { | |
3908 | return bgp_static_set (vty, vty->index, argv[0], | |
c8f3fe30 | 3909 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 3910 | } |
3911 | ||
3912 | DEFUN (bgp_network_backdoor, | |
3913 | bgp_network_backdoor_cmd, | |
3914 | "network A.B.C.D/M backdoor", | |
3915 | "Specify a network to announce via BGP\n" | |
3916 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
3917 | "Specify a BGP backdoor route\n") | |
3918 | { | |
41367172 | 3919 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 3920 | NULL, 1); |
718e3744 | 3921 | } |
3922 | ||
3923 | DEFUN (bgp_network_mask, | |
3924 | bgp_network_mask_cmd, | |
3925 | "network A.B.C.D mask A.B.C.D", | |
3926 | "Specify a network to announce via BGP\n" | |
3927 | "Network number\n" | |
3928 | "Network mask\n" | |
3929 | "Network mask\n") | |
3930 | { | |
3931 | int ret; | |
3932 | char prefix_str[BUFSIZ]; | |
41367172 | 3933 | |
718e3744 | 3934 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
3935 | if (! ret) | |
3936 | { | |
3937 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
3938 | return CMD_WARNING; | |
3939 | } | |
3940 | ||
3941 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 3942 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 3943 | } |
3944 | ||
3945 | DEFUN (bgp_network_mask_route_map, | |
3946 | bgp_network_mask_route_map_cmd, | |
3947 | "network A.B.C.D mask A.B.C.D route-map WORD", | |
3948 | "Specify a network to announce via BGP\n" | |
3949 | "Network number\n" | |
3950 | "Network mask\n" | |
3951 | "Network mask\n" | |
3952 | "Route-map to modify the attributes\n" | |
3953 | "Name of the route map\n") | |
3954 | { | |
3955 | int ret; | |
3956 | char prefix_str[BUFSIZ]; | |
41367172 | 3957 | |
718e3744 | 3958 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
3959 | if (! ret) | |
3960 | { | |
3961 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
3962 | return CMD_WARNING; | |
3963 | } | |
3964 | ||
3965 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 3966 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
718e3744 | 3967 | } |
3968 | ||
3969 | DEFUN (bgp_network_mask_backdoor, | |
3970 | bgp_network_mask_backdoor_cmd, | |
3971 | "network A.B.C.D mask A.B.C.D backdoor", | |
3972 | "Specify a network to announce via BGP\n" | |
3973 | "Network number\n" | |
3974 | "Network mask\n" | |
3975 | "Network mask\n" | |
3976 | "Specify a BGP backdoor route\n") | |
3977 | { | |
3978 | int ret; | |
3979 | char prefix_str[BUFSIZ]; | |
41367172 | 3980 | |
718e3744 | 3981 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
3982 | if (! ret) | |
3983 | { | |
3984 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
3985 | return CMD_WARNING; | |
3986 | } | |
3987 | ||
41367172 | 3988 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 3989 | NULL, 1); |
718e3744 | 3990 | } |
3991 | ||
3992 | DEFUN (bgp_network_mask_natural, | |
3993 | bgp_network_mask_natural_cmd, | |
3994 | "network A.B.C.D", | |
3995 | "Specify a network to announce via BGP\n" | |
3996 | "Network number\n") | |
3997 | { | |
3998 | int ret; | |
3999 | char prefix_str[BUFSIZ]; | |
4000 | ||
4001 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4002 | if (! ret) | |
4003 | { | |
4004 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4005 | return CMD_WARNING; | |
4006 | } | |
4007 | ||
4008 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4009 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
718e3744 | 4010 | } |
4011 | ||
4012 | DEFUN (bgp_network_mask_natural_route_map, | |
4013 | bgp_network_mask_natural_route_map_cmd, | |
4014 | "network A.B.C.D route-map WORD", | |
4015 | "Specify a network to announce via BGP\n" | |
4016 | "Network number\n" | |
4017 | "Route-map to modify the attributes\n" | |
4018 | "Name of the route map\n") | |
4019 | { | |
4020 | int ret; | |
4021 | char prefix_str[BUFSIZ]; | |
4022 | ||
4023 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4024 | if (! ret) | |
4025 | { | |
4026 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4027 | return CMD_WARNING; | |
4028 | } | |
4029 | ||
4030 | return bgp_static_set (vty, vty->index, prefix_str, | |
c8f3fe30 | 4031 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4032 | } |
4033 | ||
4034 | DEFUN (bgp_network_mask_natural_backdoor, | |
4035 | bgp_network_mask_natural_backdoor_cmd, | |
4036 | "network A.B.C.D backdoor", | |
4037 | "Specify a network to announce via BGP\n" | |
4038 | "Network number\n" | |
4039 | "Specify a BGP backdoor route\n") | |
4040 | { | |
4041 | int ret; | |
4042 | char prefix_str[BUFSIZ]; | |
4043 | ||
4044 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4045 | if (! ret) | |
4046 | { | |
4047 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4048 | return CMD_WARNING; | |
4049 | } | |
4050 | ||
41367172 | 4051 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
c8f3fe30 | 4052 | NULL, 1); |
718e3744 | 4053 | } |
4054 | ||
4055 | DEFUN (no_bgp_network, | |
4056 | no_bgp_network_cmd, | |
4057 | "no network A.B.C.D/M", | |
4058 | NO_STR | |
4059 | "Specify a network to announce via BGP\n" | |
4060 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4061 | { | |
4062 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, | |
4063 | bgp_node_safi (vty)); | |
4064 | } | |
4065 | ||
4066 | ALIAS (no_bgp_network, | |
4067 | no_bgp_network_route_map_cmd, | |
4068 | "no network A.B.C.D/M route-map WORD", | |
4069 | NO_STR | |
4070 | "Specify a network to announce via BGP\n" | |
4071 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4072 | "Route-map to modify the attributes\n" | |
4073 | "Name of the route map\n") | |
4074 | ||
4075 | ALIAS (no_bgp_network, | |
4076 | no_bgp_network_backdoor_cmd, | |
4077 | "no network A.B.C.D/M backdoor", | |
4078 | NO_STR | |
4079 | "Specify a network to announce via BGP\n" | |
4080 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4081 | "Specify a BGP backdoor route\n") | |
4082 | ||
4083 | DEFUN (no_bgp_network_mask, | |
4084 | no_bgp_network_mask_cmd, | |
4085 | "no network A.B.C.D mask A.B.C.D", | |
4086 | NO_STR | |
4087 | "Specify a network to announce via BGP\n" | |
4088 | "Network number\n" | |
4089 | "Network mask\n" | |
4090 | "Network mask\n") | |
4091 | { | |
4092 | int ret; | |
4093 | char prefix_str[BUFSIZ]; | |
4094 | ||
4095 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4096 | if (! ret) | |
4097 | { | |
4098 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4099 | return CMD_WARNING; | |
4100 | } | |
4101 | ||
4102 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4103 | bgp_node_safi (vty)); | |
4104 | } | |
4105 | ||
4106 | ALIAS (no_bgp_network_mask, | |
4107 | no_bgp_network_mask_route_map_cmd, | |
4108 | "no network A.B.C.D mask A.B.C.D route-map WORD", | |
4109 | NO_STR | |
4110 | "Specify a network to announce via BGP\n" | |
4111 | "Network number\n" | |
4112 | "Network mask\n" | |
4113 | "Network mask\n" | |
4114 | "Route-map to modify the attributes\n" | |
4115 | "Name of the route map\n") | |
4116 | ||
4117 | ALIAS (no_bgp_network_mask, | |
4118 | no_bgp_network_mask_backdoor_cmd, | |
4119 | "no network A.B.C.D mask A.B.C.D backdoor", | |
4120 | NO_STR | |
4121 | "Specify a network to announce via BGP\n" | |
4122 | "Network number\n" | |
4123 | "Network mask\n" | |
4124 | "Network mask\n" | |
4125 | "Specify a BGP backdoor route\n") | |
4126 | ||
4127 | DEFUN (no_bgp_network_mask_natural, | |
4128 | no_bgp_network_mask_natural_cmd, | |
4129 | "no network A.B.C.D", | |
4130 | NO_STR | |
4131 | "Specify a network to announce via BGP\n" | |
4132 | "Network number\n") | |
4133 | { | |
4134 | int ret; | |
4135 | char prefix_str[BUFSIZ]; | |
4136 | ||
4137 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4138 | if (! ret) | |
4139 | { | |
4140 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4141 | return CMD_WARNING; | |
4142 | } | |
4143 | ||
4144 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4145 | bgp_node_safi (vty)); | |
4146 | } | |
4147 | ||
4148 | ALIAS (no_bgp_network_mask_natural, | |
4149 | no_bgp_network_mask_natural_route_map_cmd, | |
4150 | "no network A.B.C.D route-map WORD", | |
4151 | NO_STR | |
4152 | "Specify a network to announce via BGP\n" | |
4153 | "Network number\n" | |
4154 | "Route-map to modify the attributes\n" | |
4155 | "Name of the route map\n") | |
4156 | ||
4157 | ALIAS (no_bgp_network_mask_natural, | |
4158 | no_bgp_network_mask_natural_backdoor_cmd, | |
4159 | "no network A.B.C.D backdoor", | |
4160 | NO_STR | |
4161 | "Specify a network to announce via BGP\n" | |
4162 | "Network number\n" | |
4163 | "Specify a BGP backdoor route\n") | |
4164 | ||
4165 | #ifdef HAVE_IPV6 | |
4166 | DEFUN (ipv6_bgp_network, | |
4167 | ipv6_bgp_network_cmd, | |
4168 | "network X:X::X:X/M", | |
4169 | "Specify a network to announce via BGP\n" | |
4170 | "IPv6 prefix <network>/<length>\n") | |
4171 | { | |
41367172 | 4172 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, |
c8f3fe30 | 4173 | NULL, 0); |
718e3744 | 4174 | } |
4175 | ||
4176 | DEFUN (ipv6_bgp_network_route_map, | |
4177 | ipv6_bgp_network_route_map_cmd, | |
4178 | "network X:X::X:X/M route-map WORD", | |
4179 | "Specify a network to announce via BGP\n" | |
4180 | "IPv6 prefix <network>/<length>\n" | |
4181 | "Route-map to modify the attributes\n" | |
4182 | "Name of the route map\n") | |
4183 | { | |
4184 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, | |
c8f3fe30 | 4185 | bgp_node_safi (vty), argv[1], 0); |
718e3744 | 4186 | } |
4187 | ||
4188 | DEFUN (no_ipv6_bgp_network, | |
4189 | no_ipv6_bgp_network_cmd, | |
4190 | "no network X:X::X:X/M", | |
4191 | NO_STR | |
4192 | "Specify a network to announce via BGP\n" | |
4193 | "IPv6 prefix <network>/<length>\n") | |
4194 | { | |
4195 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); | |
4196 | } | |
4197 | ||
4198 | ALIAS (no_ipv6_bgp_network, | |
4199 | no_ipv6_bgp_network_route_map_cmd, | |
4200 | "no network X:X::X:X/M route-map WORD", | |
4201 | NO_STR | |
4202 | "Specify a network to announce via BGP\n" | |
4203 | "IPv6 prefix <network>/<length>\n" | |
4204 | "Route-map to modify the attributes\n" | |
4205 | "Name of the route map\n") | |
4206 | ||
4207 | ALIAS (ipv6_bgp_network, | |
4208 | old_ipv6_bgp_network_cmd, | |
4209 | "ipv6 bgp network X:X::X:X/M", | |
4210 | IPV6_STR | |
4211 | BGP_STR | |
4212 | "Specify a network to announce via BGP\n" | |
4213 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4214 | ||
4215 | ALIAS (no_ipv6_bgp_network, | |
4216 | old_no_ipv6_bgp_network_cmd, | |
4217 | "no ipv6 bgp network X:X::X:X/M", | |
4218 | NO_STR | |
4219 | IPV6_STR | |
4220 | BGP_STR | |
4221 | "Specify a network to announce via BGP\n" | |
4222 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4223 | #endif /* HAVE_IPV6 */ | |
c8f3fe30 PJ |
4224 | |
4225 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ | |
4226 | ALIAS_DEPRECATED (bgp_network, | |
4227 | bgp_network_ttl_cmd, | |
4228 | "network A.B.C.D/M pathlimit <0-255>", | |
4229 | "Specify a network to announce via BGP\n" | |
4230 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4231 | "AS-Path hopcount limit attribute\n" | |
4232 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4233 | ALIAS_DEPRECATED (bgp_network_backdoor, | |
4234 | bgp_network_backdoor_ttl_cmd, | |
4235 | "network A.B.C.D/M backdoor pathlimit <0-255>", | |
4236 | "Specify a network to announce via BGP\n" | |
4237 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4238 | "Specify a BGP backdoor route\n" | |
4239 | "AS-Path hopcount limit attribute\n" | |
4240 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4241 | ALIAS_DEPRECATED (bgp_network_mask, | |
4242 | bgp_network_mask_ttl_cmd, | |
4243 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", | |
4244 | "Specify a network to announce via BGP\n" | |
4245 | "Network number\n" | |
4246 | "Network mask\n" | |
4247 | "Network mask\n" | |
4248 | "AS-Path hopcount limit attribute\n" | |
4249 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4250 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, | |
4251 | bgp_network_mask_backdoor_ttl_cmd, | |
4252 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", | |
4253 | "Specify a network to announce via BGP\n" | |
4254 | "Network number\n" | |
4255 | "Network mask\n" | |
4256 | "Network mask\n" | |
4257 | "Specify a BGP backdoor route\n" | |
4258 | "AS-Path hopcount limit attribute\n" | |
4259 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4260 | ALIAS_DEPRECATED (bgp_network_mask_natural, | |
4261 | bgp_network_mask_natural_ttl_cmd, | |
4262 | "network A.B.C.D pathlimit <0-255>", | |
4263 | "Specify a network to announce via BGP\n" | |
4264 | "Network number\n" | |
4265 | "AS-Path hopcount limit attribute\n" | |
4266 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4267 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, | |
4268 | bgp_network_mask_natural_backdoor_ttl_cmd, | |
4269 | "network A.B.C.D backdoor pathlimit (1-255>", | |
4270 | "Specify a network to announce via BGP\n" | |
4271 | "Network number\n" | |
4272 | "Specify a BGP backdoor route\n" | |
4273 | "AS-Path hopcount limit attribute\n" | |
4274 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4275 | ALIAS_DEPRECATED (no_bgp_network, | |
4276 | no_bgp_network_ttl_cmd, | |
4277 | "no network A.B.C.D/M pathlimit <0-255>", | |
4278 | NO_STR | |
4279 | "Specify a network to announce via BGP\n" | |
4280 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4281 | "AS-Path hopcount limit attribute\n" | |
4282 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4283 | ALIAS_DEPRECATED (no_bgp_network, | |
4284 | no_bgp_network_backdoor_ttl_cmd, | |
4285 | "no network A.B.C.D/M backdoor pathlimit <0-255>", | |
4286 | NO_STR | |
4287 | "Specify a network to announce via BGP\n" | |
4288 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4289 | "Specify a BGP backdoor route\n" | |
4290 | "AS-Path hopcount limit attribute\n" | |
4291 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4292 | ALIAS_DEPRECATED (no_bgp_network, | |
4293 | no_bgp_network_mask_ttl_cmd, | |
4294 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", | |
4295 | NO_STR | |
4296 | "Specify a network to announce via BGP\n" | |
4297 | "Network number\n" | |
4298 | "Network mask\n" | |
4299 | "Network mask\n" | |
4300 | "AS-Path hopcount limit attribute\n" | |
4301 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4302 | ALIAS_DEPRECATED (no_bgp_network_mask, | |
4303 | no_bgp_network_mask_backdoor_ttl_cmd, | |
4304 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", | |
4305 | NO_STR | |
4306 | "Specify a network to announce via BGP\n" | |
4307 | "Network number\n" | |
4308 | "Network mask\n" | |
4309 | "Network mask\n" | |
4310 | "Specify a BGP backdoor route\n" | |
4311 | "AS-Path hopcount limit attribute\n" | |
4312 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4313 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, | |
4314 | no_bgp_network_mask_natural_ttl_cmd, | |
4315 | "no network A.B.C.D pathlimit <0-255>", | |
4316 | NO_STR | |
4317 | "Specify a network to announce via BGP\n" | |
4318 | "Network number\n" | |
4319 | "AS-Path hopcount limit attribute\n" | |
4320 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4321 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, | |
4322 | no_bgp_network_mask_natural_backdoor_ttl_cmd, | |
4323 | "no network A.B.C.D backdoor pathlimit <0-255>", | |
4324 | NO_STR | |
4325 | "Specify a network to announce via BGP\n" | |
4326 | "Network number\n" | |
4327 | "Specify a BGP backdoor route\n" | |
4328 | "AS-Path hopcount limit attribute\n" | |
4329 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
3bde17f1 | 4330 | #ifdef HAVE_IPV6 |
c8f3fe30 PJ |
4331 | ALIAS_DEPRECATED (ipv6_bgp_network, |
4332 | ipv6_bgp_network_ttl_cmd, | |
4333 | "network X:X::X:X/M pathlimit <0-255>", | |
4334 | "Specify a network to announce via BGP\n" | |
4335 | "IPv6 prefix <network>/<length>\n" | |
4336 | "AS-Path hopcount limit attribute\n" | |
4337 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4338 | ALIAS_DEPRECATED (no_ipv6_bgp_network, | |
4339 | no_ipv6_bgp_network_ttl_cmd, | |
4340 | "no network X:X::X:X/M pathlimit <0-255>", | |
4341 | NO_STR | |
4342 | "Specify a network to announce via BGP\n" | |
4343 | "IPv6 prefix <network>/<length>\n" | |
4344 | "AS-Path hopcount limit attribute\n" | |
4345 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
3bde17f1 | 4346 | #endif /* HAVE_IPV6 */ |
718e3744 | 4347 | \f |
4348 | /* Aggreagete address: | |
4349 | ||
4350 | advertise-map Set condition to advertise attribute | |
4351 | as-set Generate AS set path information | |
4352 | attribute-map Set attributes of aggregate | |
4353 | route-map Set parameters of aggregate | |
4354 | summary-only Filter more specific routes from updates | |
4355 | suppress-map Conditionally filter more specific routes from updates | |
4356 | <cr> | |
4357 | */ | |
4358 | struct bgp_aggregate | |
4359 | { | |
4360 | /* Summary-only flag. */ | |
4361 | u_char summary_only; | |
4362 | ||
4363 | /* AS set generation. */ | |
4364 | u_char as_set; | |
4365 | ||
4366 | /* Route-map for aggregated route. */ | |
4367 | struct route_map *map; | |
4368 | ||
4369 | /* Suppress-count. */ | |
4370 | unsigned long count; | |
4371 | ||
4372 | /* SAFI configuration. */ | |
4373 | safi_t safi; | |
4374 | }; | |
4375 | ||
94f2b392 | 4376 | static struct bgp_aggregate * |
66e5cd87 | 4377 | bgp_aggregate_new (void) |
718e3744 | 4378 | { |
393deb9b | 4379 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
718e3744 | 4380 | } |
4381 | ||
94f2b392 | 4382 | static void |
718e3744 | 4383 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
4384 | { | |
4385 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); | |
4386 | } | |
4387 | ||
94f2b392 | 4388 | static void |
718e3744 | 4389 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
4390 | afi_t afi, safi_t safi, struct bgp_info *del, | |
4391 | struct bgp_aggregate *aggregate) | |
4392 | { | |
4393 | struct bgp_table *table; | |
4394 | struct bgp_node *top; | |
4395 | struct bgp_node *rn; | |
4396 | u_char origin; | |
4397 | struct aspath *aspath = NULL; | |
4398 | struct aspath *asmerge = NULL; | |
4399 | struct community *community = NULL; | |
4400 | struct community *commerge = NULL; | |
4401 | struct in_addr nexthop; | |
4402 | u_int32_t med = 0; | |
4403 | struct bgp_info *ri; | |
4404 | struct bgp_info *new; | |
4405 | int first = 1; | |
4406 | unsigned long match = 0; | |
4407 | ||
4408 | /* Record adding route's nexthop and med. */ | |
4409 | if (rinew) | |
4410 | { | |
4411 | nexthop = rinew->attr->nexthop; | |
4412 | med = rinew->attr->med; | |
4413 | } | |
4414 | ||
4415 | /* ORIGIN attribute: If at least one route among routes that are | |
4416 | aggregated has ORIGIN with the value INCOMPLETE, then the | |
4417 | aggregated route must have the ORIGIN attribute with the value | |
4418 | INCOMPLETE. Otherwise, if at least one route among routes that | |
4419 | are aggregated has ORIGIN with the value EGP, then the aggregated | |
4420 | route must have the origin attribute with the value EGP. In all | |
4421 | other case the value of the ORIGIN attribute of the aggregated | |
4422 | route is INTERNAL. */ | |
4423 | origin = BGP_ORIGIN_IGP; | |
4424 | ||
4425 | table = bgp->rib[afi][safi]; | |
4426 | ||
4427 | top = bgp_node_get (table, p); | |
4428 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4429 | if (rn->p.prefixlen > p->prefixlen) | |
4430 | { | |
4431 | match = 0; | |
4432 | ||
4433 | for (ri = rn->info; ri; ri = ri->next) | |
4434 | { | |
4435 | if (BGP_INFO_HOLDDOWN (ri)) | |
4436 | continue; | |
4437 | ||
4438 | if (del && ri == del) | |
4439 | continue; | |
4440 | ||
4441 | if (! rinew && first) | |
4442 | { | |
4443 | nexthop = ri->attr->nexthop; | |
4444 | med = ri->attr->med; | |
4445 | first = 0; | |
4446 | } | |
4447 | ||
4448 | #ifdef AGGREGATE_NEXTHOP_CHECK | |
4449 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) | |
4450 | || ri->attr->med != med) | |
4451 | { | |
4452 | if (aspath) | |
4453 | aspath_free (aspath); | |
4454 | if (community) | |
4455 | community_free (community); | |
4456 | bgp_unlock_node (rn); | |
4457 | bgp_unlock_node (top); | |
4458 | return; | |
4459 | } | |
4460 | #endif /* AGGREGATE_NEXTHOP_CHECK */ | |
4461 | ||
4462 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4463 | { | |
4464 | if (aggregate->summary_only) | |
4465 | { | |
fb982c25 | 4466 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4467 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4468 | match++; |
4469 | } | |
4470 | ||
4471 | aggregate->count++; | |
4472 | ||
4473 | if (aggregate->as_set) | |
4474 | { | |
4475 | if (origin < ri->attr->origin) | |
4476 | origin = ri->attr->origin; | |
4477 | ||
4478 | if (aspath) | |
4479 | { | |
4480 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4481 | aspath_free (aspath); | |
4482 | aspath = asmerge; | |
4483 | } | |
4484 | else | |
4485 | aspath = aspath_dup (ri->attr->aspath); | |
4486 | ||
4487 | if (ri->attr->community) | |
4488 | { | |
4489 | if (community) | |
4490 | { | |
4491 | commerge = community_merge (community, | |
4492 | ri->attr->community); | |
4493 | community = community_uniq_sort (commerge); | |
4494 | community_free (commerge); | |
4495 | } | |
4496 | else | |
4497 | community = community_dup (ri->attr->community); | |
4498 | } | |
4499 | } | |
4500 | } | |
4501 | } | |
4502 | if (match) | |
4503 | bgp_process (bgp, rn, afi, safi); | |
4504 | } | |
4505 | bgp_unlock_node (top); | |
4506 | ||
4507 | if (rinew) | |
4508 | { | |
4509 | aggregate->count++; | |
4510 | ||
4511 | if (aggregate->summary_only) | |
fb982c25 | 4512 | (bgp_info_extra_get (rinew))->suppress++; |
718e3744 | 4513 | |
4514 | if (aggregate->as_set) | |
4515 | { | |
4516 | if (origin < rinew->attr->origin) | |
4517 | origin = rinew->attr->origin; | |
4518 | ||
4519 | if (aspath) | |
4520 | { | |
4521 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); | |
4522 | aspath_free (aspath); | |
4523 | aspath = asmerge; | |
4524 | } | |
4525 | else | |
4526 | aspath = aspath_dup (rinew->attr->aspath); | |
4527 | ||
4528 | if (rinew->attr->community) | |
4529 | { | |
4530 | if (community) | |
4531 | { | |
4532 | commerge = community_merge (community, | |
4533 | rinew->attr->community); | |
4534 | community = community_uniq_sort (commerge); | |
4535 | community_free (commerge); | |
4536 | } | |
4537 | else | |
4538 | community = community_dup (rinew->attr->community); | |
4539 | } | |
4540 | } | |
4541 | } | |
4542 | ||
4543 | if (aggregate->count > 0) | |
4544 | { | |
4545 | rn = bgp_node_get (table, p); | |
4546 | new = bgp_info_new (); | |
4547 | new->type = ZEBRA_ROUTE_BGP; | |
4548 | new->sub_type = BGP_ROUTE_AGGREGATE; | |
4549 | new->peer = bgp->peer_self; | |
4550 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
4551 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); | |
65957886 | 4552 | new->uptime = bgp_clock (); |
718e3744 | 4553 | |
4554 | bgp_info_add (rn, new); | |
200df115 | 4555 | bgp_unlock_node (rn); |
718e3744 | 4556 | bgp_process (bgp, rn, afi, safi); |
4557 | } | |
4558 | else | |
4559 | { | |
4560 | if (aspath) | |
4561 | aspath_free (aspath); | |
4562 | if (community) | |
4563 | community_free (community); | |
4564 | } | |
4565 | } | |
4566 | ||
4567 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, | |
4568 | struct bgp_aggregate *); | |
4569 | ||
4570 | void | |
4571 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, | |
4572 | struct bgp_info *ri, afi_t afi, safi_t safi) | |
4573 | { | |
4574 | struct bgp_node *child; | |
4575 | struct bgp_node *rn; | |
4576 | struct bgp_aggregate *aggregate; | |
4577 | ||
4578 | /* MPLS-VPN aggregation is not yet supported. */ | |
4579 | if (safi == SAFI_MPLS_VPN) | |
4580 | return; | |
4581 | ||
4582 | if (p->prefixlen == 0) | |
4583 | return; | |
4584 | ||
4585 | if (BGP_INFO_HOLDDOWN (ri)) | |
4586 | return; | |
4587 | ||
4588 | child = bgp_node_get (bgp->aggregate[afi][safi], p); | |
4589 | ||
4590 | /* Aggregate address configuration check. */ | |
4591 | for (rn = child; rn; rn = rn->parent) | |
4592 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) | |
4593 | { | |
4594 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4595 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
718e3744 | 4596 | } |
4597 | bgp_unlock_node (child); | |
4598 | } | |
4599 | ||
4600 | void | |
4601 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, | |
4602 | struct bgp_info *del, afi_t afi, safi_t safi) | |
4603 | { | |
4604 | struct bgp_node *child; | |
4605 | struct bgp_node *rn; | |
4606 | struct bgp_aggregate *aggregate; | |
4607 | ||
4608 | /* MPLS-VPN aggregation is not yet supported. */ | |
4609 | if (safi == SAFI_MPLS_VPN) | |
4610 | return; | |
4611 | ||
4612 | if (p->prefixlen == 0) | |
4613 | return; | |
4614 | ||
4615 | child = bgp_node_get (bgp->aggregate[afi][safi], p); | |
4616 | ||
4617 | /* Aggregate address configuration check. */ | |
4618 | for (rn = child; rn; rn = rn->parent) | |
4619 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) | |
4620 | { | |
4621 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4622 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
718e3744 | 4623 | } |
4624 | bgp_unlock_node (child); | |
4625 | } | |
4626 | ||
94f2b392 | 4627 | static void |
718e3744 | 4628 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
4629 | struct bgp_aggregate *aggregate) | |
4630 | { | |
4631 | struct bgp_table *table; | |
4632 | struct bgp_node *top; | |
4633 | struct bgp_node *rn; | |
4634 | struct bgp_info *new; | |
4635 | struct bgp_info *ri; | |
4636 | unsigned long match; | |
4637 | u_char origin = BGP_ORIGIN_IGP; | |
4638 | struct aspath *aspath = NULL; | |
4639 | struct aspath *asmerge = NULL; | |
4640 | struct community *community = NULL; | |
4641 | struct community *commerge = NULL; | |
4642 | ||
4643 | table = bgp->rib[afi][safi]; | |
4644 | ||
4645 | /* Sanity check. */ | |
4646 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4647 | return; | |
4648 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4649 | return; | |
4650 | ||
4651 | /* If routes exists below this node, generate aggregate routes. */ | |
4652 | top = bgp_node_get (table, p); | |
4653 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4654 | if (rn->p.prefixlen > p->prefixlen) | |
4655 | { | |
4656 | match = 0; | |
4657 | ||
4658 | for (ri = rn->info; ri; ri = ri->next) | |
4659 | { | |
4660 | if (BGP_INFO_HOLDDOWN (ri)) | |
4661 | continue; | |
4662 | ||
4663 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4664 | { | |
4665 | /* summary-only aggregate route suppress aggregated | |
4666 | route announcement. */ | |
4667 | if (aggregate->summary_only) | |
4668 | { | |
fb982c25 | 4669 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4670 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4671 | match++; |
4672 | } | |
4673 | /* as-set aggregate route generate origin, as path, | |
4674 | community aggregation. */ | |
4675 | if (aggregate->as_set) | |
4676 | { | |
4677 | if (origin < ri->attr->origin) | |
4678 | origin = ri->attr->origin; | |
4679 | ||
4680 | if (aspath) | |
4681 | { | |
4682 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4683 | aspath_free (aspath); | |
4684 | aspath = asmerge; | |
4685 | } | |
4686 | else | |
4687 | aspath = aspath_dup (ri->attr->aspath); | |
4688 | ||
4689 | if (ri->attr->community) | |
4690 | { | |
4691 | if (community) | |
4692 | { | |
4693 | commerge = community_merge (community, | |
4694 | ri->attr->community); | |
4695 | community = community_uniq_sort (commerge); | |
4696 | community_free (commerge); | |
4697 | } | |
4698 | else | |
4699 | community = community_dup (ri->attr->community); | |
4700 | } | |
4701 | } | |
4702 | aggregate->count++; | |
4703 | } | |
4704 | } | |
4705 | ||
4706 | /* If this node is suppressed, process the change. */ | |
4707 | if (match) | |
4708 | bgp_process (bgp, rn, afi, safi); | |
4709 | } | |
4710 | bgp_unlock_node (top); | |
4711 | ||
4712 | /* Add aggregate route to BGP table. */ | |
4713 | if (aggregate->count) | |
4714 | { | |
4715 | rn = bgp_node_get (table, p); | |
4716 | ||
4717 | new = bgp_info_new (); | |
4718 | new->type = ZEBRA_ROUTE_BGP; | |
4719 | new->sub_type = BGP_ROUTE_AGGREGATE; | |
4720 | new->peer = bgp->peer_self; | |
4721 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
4722 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); | |
65957886 | 4723 | new->uptime = bgp_clock (); |
718e3744 | 4724 | |
4725 | bgp_info_add (rn, new); | |
200df115 | 4726 | bgp_unlock_node (rn); |
4727 | ||
718e3744 | 4728 | /* Process change. */ |
4729 | bgp_process (bgp, rn, afi, safi); | |
4730 | } | |
4731 | } | |
4732 | ||
4733 | void | |
4734 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, | |
4735 | safi_t safi, struct bgp_aggregate *aggregate) | |
4736 | { | |
4737 | struct bgp_table *table; | |
4738 | struct bgp_node *top; | |
4739 | struct bgp_node *rn; | |
4740 | struct bgp_info *ri; | |
4741 | unsigned long match; | |
4742 | ||
4743 | table = bgp->rib[afi][safi]; | |
4744 | ||
4745 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4746 | return; | |
4747 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4748 | return; | |
4749 | ||
4750 | /* If routes exists below this node, generate aggregate routes. */ | |
4751 | top = bgp_node_get (table, p); | |
4752 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4753 | if (rn->p.prefixlen > p->prefixlen) | |
4754 | { | |
4755 | match = 0; | |
4756 | ||
4757 | for (ri = rn->info; ri; ri = ri->next) | |
4758 | { | |
4759 | if (BGP_INFO_HOLDDOWN (ri)) | |
4760 | continue; | |
4761 | ||
4762 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4763 | { | |
fb982c25 | 4764 | if (aggregate->summary_only && ri->extra) |
718e3744 | 4765 | { |
fb982c25 | 4766 | ri->extra->suppress--; |
718e3744 | 4767 | |
fb982c25 | 4768 | if (ri->extra->suppress == 0) |
718e3744 | 4769 | { |
1a392d46 | 4770 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4771 | match++; |
4772 | } | |
4773 | } | |
4774 | aggregate->count--; | |
4775 | } | |
4776 | } | |
4777 | ||
fb982c25 | 4778 | /* If this node was suppressed, process the change. */ |
718e3744 | 4779 | if (match) |
4780 | bgp_process (bgp, rn, afi, safi); | |
4781 | } | |
4782 | bgp_unlock_node (top); | |
4783 | ||
4784 | /* Delete aggregate route from BGP table. */ | |
4785 | rn = bgp_node_get (table, p); | |
4786 | ||
4787 | for (ri = rn->info; ri; ri = ri->next) | |
4788 | if (ri->peer == bgp->peer_self | |
4789 | && ri->type == ZEBRA_ROUTE_BGP | |
4790 | && ri->sub_type == BGP_ROUTE_AGGREGATE) | |
4791 | break; | |
4792 | ||
4793 | /* Withdraw static BGP route from routing table. */ | |
4794 | if (ri) | |
4795 | { | |
718e3744 | 4796 | bgp_info_delete (rn, ri); |
1a392d46 | 4797 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 4798 | } |
4799 | ||
4800 | /* Unlock bgp_node_lookup. */ | |
4801 | bgp_unlock_node (rn); | |
4802 | } | |
4803 | ||
4804 | /* Aggregate route attribute. */ | |
4805 | #define AGGREGATE_SUMMARY_ONLY 1 | |
4806 | #define AGGREGATE_AS_SET 1 | |
4807 | ||
94f2b392 | 4808 | static int |
f6269b4f RB |
4809 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
4810 | afi_t afi, safi_t safi) | |
718e3744 | 4811 | { |
4812 | int ret; | |
4813 | struct prefix p; | |
4814 | struct bgp_node *rn; | |
4815 | struct bgp *bgp; | |
4816 | struct bgp_aggregate *aggregate; | |
4817 | ||
4818 | /* Convert string to prefix structure. */ | |
4819 | ret = str2prefix (prefix_str, &p); | |
4820 | if (!ret) | |
4821 | { | |
4822 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
4823 | return CMD_WARNING; | |
4824 | } | |
4825 | apply_mask (&p); | |
4826 | ||
4827 | /* Get BGP structure. */ | |
4828 | bgp = vty->index; | |
4829 | ||
4830 | /* Old configuration check. */ | |
f6269b4f RB |
4831 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
4832 | if (! rn) | |
718e3744 | 4833 | { |
f6269b4f RB |
4834 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
4835 | VTY_NEWLINE); | |
718e3744 | 4836 | return CMD_WARNING; |
4837 | } | |
4838 | ||
f6269b4f RB |
4839 | aggregate = rn->info; |
4840 | if (aggregate->safi & SAFI_UNICAST) | |
4841 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
4842 | if (aggregate->safi & SAFI_MULTICAST) | |
4843 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 4844 | |
f6269b4f RB |
4845 | /* Unlock aggregate address configuration. */ |
4846 | rn->info = NULL; | |
4847 | bgp_aggregate_free (aggregate); | |
4848 | bgp_unlock_node (rn); | |
4849 | bgp_unlock_node (rn); | |
718e3744 | 4850 | |
4851 | return CMD_SUCCESS; | |
4852 | } | |
4853 | ||
94f2b392 | 4854 | static int |
f6269b4f RB |
4855 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
4856 | afi_t afi, safi_t safi, | |
4857 | u_char summary_only, u_char as_set) | |
718e3744 | 4858 | { |
4859 | int ret; | |
4860 | struct prefix p; | |
4861 | struct bgp_node *rn; | |
4862 | struct bgp *bgp; | |
4863 | struct bgp_aggregate *aggregate; | |
4864 | ||
4865 | /* Convert string to prefix structure. */ | |
4866 | ret = str2prefix (prefix_str, &p); | |
4867 | if (!ret) | |
4868 | { | |
4869 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
4870 | return CMD_WARNING; | |
4871 | } | |
4872 | apply_mask (&p); | |
4873 | ||
4874 | /* Get BGP structure. */ | |
4875 | bgp = vty->index; | |
4876 | ||
4877 | /* Old configuration check. */ | |
f6269b4f RB |
4878 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
4879 | ||
4880 | if (rn->info) | |
718e3744 | 4881 | { |
f6269b4f | 4882 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
368473f6 | 4883 | /* try to remove the old entry */ |
f6269b4f RB |
4884 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
4885 | if (ret) | |
4886 | { | |
368473f6 RB |
4887 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
4888 | bgp_unlock_node (rn); | |
f6269b4f RB |
4889 | return CMD_WARNING; |
4890 | } | |
718e3744 | 4891 | } |
4892 | ||
f6269b4f RB |
4893 | /* Make aggregate address structure. */ |
4894 | aggregate = bgp_aggregate_new (); | |
4895 | aggregate->summary_only = summary_only; | |
4896 | aggregate->as_set = as_set; | |
4897 | aggregate->safi = safi; | |
4898 | rn->info = aggregate; | |
718e3744 | 4899 | |
f6269b4f RB |
4900 | /* Aggregate address insert into BGP routing table. */ |
4901 | if (safi & SAFI_UNICAST) | |
4902 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
4903 | if (safi & SAFI_MULTICAST) | |
4904 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
718e3744 | 4905 | |
4906 | return CMD_SUCCESS; | |
4907 | } | |
4908 | ||
4909 | DEFUN (aggregate_address, | |
4910 | aggregate_address_cmd, | |
4911 | "aggregate-address A.B.C.D/M", | |
4912 | "Configure BGP aggregate entries\n" | |
4913 | "Aggregate prefix\n") | |
4914 | { | |
4915 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); | |
4916 | } | |
4917 | ||
4918 | DEFUN (aggregate_address_mask, | |
4919 | aggregate_address_mask_cmd, | |
4920 | "aggregate-address A.B.C.D A.B.C.D", | |
4921 | "Configure BGP aggregate entries\n" | |
4922 | "Aggregate address\n" | |
4923 | "Aggregate mask\n") | |
4924 | { | |
4925 | int ret; | |
4926 | char prefix_str[BUFSIZ]; | |
4927 | ||
4928 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4929 | ||
4930 | if (! ret) | |
4931 | { | |
4932 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4933 | return CMD_WARNING; | |
4934 | } | |
4935 | ||
4936 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
4937 | 0, 0); | |
4938 | } | |
4939 | ||
4940 | DEFUN (aggregate_address_summary_only, | |
4941 | aggregate_address_summary_only_cmd, | |
4942 | "aggregate-address A.B.C.D/M summary-only", | |
4943 | "Configure BGP aggregate entries\n" | |
4944 | "Aggregate prefix\n" | |
4945 | "Filter more specific routes from updates\n") | |
4946 | { | |
4947 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
4948 | AGGREGATE_SUMMARY_ONLY, 0); | |
4949 | } | |
4950 | ||
4951 | DEFUN (aggregate_address_mask_summary_only, | |
4952 | aggregate_address_mask_summary_only_cmd, | |
4953 | "aggregate-address A.B.C.D A.B.C.D summary-only", | |
4954 | "Configure BGP aggregate entries\n" | |
4955 | "Aggregate address\n" | |
4956 | "Aggregate mask\n" | |
4957 | "Filter more specific routes from updates\n") | |
4958 | { | |
4959 | int ret; | |
4960 | char prefix_str[BUFSIZ]; | |
4961 | ||
4962 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4963 | ||
4964 | if (! ret) | |
4965 | { | |
4966 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4967 | return CMD_WARNING; | |
4968 | } | |
4969 | ||
4970 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
4971 | AGGREGATE_SUMMARY_ONLY, 0); | |
4972 | } | |
4973 | ||
4974 | DEFUN (aggregate_address_as_set, | |
4975 | aggregate_address_as_set_cmd, | |
4976 | "aggregate-address A.B.C.D/M as-set", | |
4977 | "Configure BGP aggregate entries\n" | |
4978 | "Aggregate prefix\n" | |
4979 | "Generate AS set path information\n") | |
4980 | { | |
4981 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
4982 | 0, AGGREGATE_AS_SET); | |
4983 | } | |
4984 | ||
4985 | DEFUN (aggregate_address_mask_as_set, | |
4986 | aggregate_address_mask_as_set_cmd, | |
4987 | "aggregate-address A.B.C.D A.B.C.D as-set", | |
4988 | "Configure BGP aggregate entries\n" | |
4989 | "Aggregate address\n" | |
4990 | "Aggregate mask\n" | |
4991 | "Generate AS set path information\n") | |
4992 | { | |
4993 | int ret; | |
4994 | char prefix_str[BUFSIZ]; | |
4995 | ||
4996 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4997 | ||
4998 | if (! ret) | |
4999 | { | |
5000 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5001 | return CMD_WARNING; | |
5002 | } | |
5003 | ||
5004 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5005 | 0, AGGREGATE_AS_SET); | |
5006 | } | |
5007 | ||
5008 | ||
5009 | DEFUN (aggregate_address_as_set_summary, | |
5010 | aggregate_address_as_set_summary_cmd, | |
5011 | "aggregate-address A.B.C.D/M as-set summary-only", | |
5012 | "Configure BGP aggregate entries\n" | |
5013 | "Aggregate prefix\n" | |
5014 | "Generate AS set path information\n" | |
5015 | "Filter more specific routes from updates\n") | |
5016 | { | |
5017 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5018 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5019 | } | |
5020 | ||
5021 | ALIAS (aggregate_address_as_set_summary, | |
5022 | aggregate_address_summary_as_set_cmd, | |
5023 | "aggregate-address A.B.C.D/M summary-only as-set", | |
5024 | "Configure BGP aggregate entries\n" | |
5025 | "Aggregate prefix\n" | |
5026 | "Filter more specific routes from updates\n" | |
5027 | "Generate AS set path information\n") | |
5028 | ||
5029 | DEFUN (aggregate_address_mask_as_set_summary, | |
5030 | aggregate_address_mask_as_set_summary_cmd, | |
5031 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5032 | "Configure BGP aggregate entries\n" | |
5033 | "Aggregate address\n" | |
5034 | "Aggregate mask\n" | |
5035 | "Generate AS set path information\n" | |
5036 | "Filter more specific routes from updates\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 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5051 | } | |
5052 | ||
5053 | ALIAS (aggregate_address_mask_as_set_summary, | |
5054 | aggregate_address_mask_summary_as_set_cmd, | |
5055 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5056 | "Configure BGP aggregate entries\n" | |
5057 | "Aggregate address\n" | |
5058 | "Aggregate mask\n" | |
5059 | "Filter more specific routes from updates\n" | |
5060 | "Generate AS set path information\n") | |
5061 | ||
5062 | DEFUN (no_aggregate_address, | |
5063 | no_aggregate_address_cmd, | |
5064 | "no aggregate-address A.B.C.D/M", | |
5065 | NO_STR | |
5066 | "Configure BGP aggregate entries\n" | |
5067 | "Aggregate prefix\n") | |
5068 | { | |
5069 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); | |
5070 | } | |
5071 | ||
5072 | ALIAS (no_aggregate_address, | |
5073 | no_aggregate_address_summary_only_cmd, | |
5074 | "no aggregate-address A.B.C.D/M summary-only", | |
5075 | NO_STR | |
5076 | "Configure BGP aggregate entries\n" | |
5077 | "Aggregate prefix\n" | |
5078 | "Filter more specific routes from updates\n") | |
5079 | ||
5080 | ALIAS (no_aggregate_address, | |
5081 | no_aggregate_address_as_set_cmd, | |
5082 | "no aggregate-address A.B.C.D/M as-set", | |
5083 | NO_STR | |
5084 | "Configure BGP aggregate entries\n" | |
5085 | "Aggregate prefix\n" | |
5086 | "Generate AS set path information\n") | |
5087 | ||
5088 | ALIAS (no_aggregate_address, | |
5089 | no_aggregate_address_as_set_summary_cmd, | |
5090 | "no aggregate-address A.B.C.D/M as-set summary-only", | |
5091 | NO_STR | |
5092 | "Configure BGP aggregate entries\n" | |
5093 | "Aggregate prefix\n" | |
5094 | "Generate AS set path information\n" | |
5095 | "Filter more specific routes from updates\n") | |
5096 | ||
5097 | ALIAS (no_aggregate_address, | |
5098 | no_aggregate_address_summary_as_set_cmd, | |
5099 | "no aggregate-address A.B.C.D/M summary-only as-set", | |
5100 | NO_STR | |
5101 | "Configure BGP aggregate entries\n" | |
5102 | "Aggregate prefix\n" | |
5103 | "Filter more specific routes from updates\n" | |
5104 | "Generate AS set path information\n") | |
5105 | ||
5106 | DEFUN (no_aggregate_address_mask, | |
5107 | no_aggregate_address_mask_cmd, | |
5108 | "no aggregate-address A.B.C.D A.B.C.D", | |
5109 | NO_STR | |
5110 | "Configure BGP aggregate entries\n" | |
5111 | "Aggregate address\n" | |
5112 | "Aggregate mask\n") | |
5113 | { | |
5114 | int ret; | |
5115 | char prefix_str[BUFSIZ]; | |
5116 | ||
5117 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5118 | ||
5119 | if (! ret) | |
5120 | { | |
5121 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5122 | return CMD_WARNING; | |
5123 | } | |
5124 | ||
5125 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); | |
5126 | } | |
5127 | ||
5128 | ALIAS (no_aggregate_address_mask, | |
5129 | no_aggregate_address_mask_summary_only_cmd, | |
5130 | "no aggregate-address A.B.C.D A.B.C.D summary-only", | |
5131 | NO_STR | |
5132 | "Configure BGP aggregate entries\n" | |
5133 | "Aggregate address\n" | |
5134 | "Aggregate mask\n" | |
5135 | "Filter more specific routes from updates\n") | |
5136 | ||
5137 | ALIAS (no_aggregate_address_mask, | |
5138 | no_aggregate_address_mask_as_set_cmd, | |
5139 | "no aggregate-address A.B.C.D A.B.C.D as-set", | |
5140 | NO_STR | |
5141 | "Configure BGP aggregate entries\n" | |
5142 | "Aggregate address\n" | |
5143 | "Aggregate mask\n" | |
5144 | "Generate AS set path information\n") | |
5145 | ||
5146 | ALIAS (no_aggregate_address_mask, | |
5147 | no_aggregate_address_mask_as_set_summary_cmd, | |
5148 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5149 | NO_STR | |
5150 | "Configure BGP aggregate entries\n" | |
5151 | "Aggregate address\n" | |
5152 | "Aggregate mask\n" | |
5153 | "Generate AS set path information\n" | |
5154 | "Filter more specific routes from updates\n") | |
5155 | ||
5156 | ALIAS (no_aggregate_address_mask, | |
5157 | no_aggregate_address_mask_summary_as_set_cmd, | |
5158 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5159 | NO_STR | |
5160 | "Configure BGP aggregate entries\n" | |
5161 | "Aggregate address\n" | |
5162 | "Aggregate mask\n" | |
5163 | "Filter more specific routes from updates\n" | |
5164 | "Generate AS set path information\n") | |
5165 | ||
5166 | #ifdef HAVE_IPV6 | |
5167 | DEFUN (ipv6_aggregate_address, | |
5168 | ipv6_aggregate_address_cmd, | |
5169 | "aggregate-address X:X::X:X/M", | |
5170 | "Configure BGP aggregate entries\n" | |
5171 | "Aggregate prefix\n") | |
5172 | { | |
5173 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); | |
5174 | } | |
5175 | ||
5176 | DEFUN (ipv6_aggregate_address_summary_only, | |
5177 | ipv6_aggregate_address_summary_only_cmd, | |
5178 | "aggregate-address X:X::X:X/M summary-only", | |
5179 | "Configure BGP aggregate entries\n" | |
5180 | "Aggregate prefix\n" | |
5181 | "Filter more specific routes from updates\n") | |
5182 | { | |
5183 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
5184 | AGGREGATE_SUMMARY_ONLY, 0); | |
5185 | } | |
5186 | ||
5187 | DEFUN (no_ipv6_aggregate_address, | |
5188 | no_ipv6_aggregate_address_cmd, | |
5189 | "no aggregate-address X:X::X:X/M", | |
5190 | NO_STR | |
5191 | "Configure BGP aggregate entries\n" | |
5192 | "Aggregate prefix\n") | |
5193 | { | |
5194 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5195 | } | |
5196 | ||
5197 | DEFUN (no_ipv6_aggregate_address_summary_only, | |
5198 | no_ipv6_aggregate_address_summary_only_cmd, | |
5199 | "no aggregate-address X:X::X:X/M summary-only", | |
5200 | NO_STR | |
5201 | "Configure BGP aggregate entries\n" | |
5202 | "Aggregate prefix\n" | |
5203 | "Filter more specific routes from updates\n") | |
5204 | { | |
5205 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5206 | } | |
5207 | ||
5208 | ALIAS (ipv6_aggregate_address, | |
5209 | old_ipv6_aggregate_address_cmd, | |
5210 | "ipv6 bgp aggregate-address X:X::X:X/M", | |
5211 | IPV6_STR | |
5212 | BGP_STR | |
5213 | "Configure BGP aggregate entries\n" | |
5214 | "Aggregate prefix\n") | |
5215 | ||
5216 | ALIAS (ipv6_aggregate_address_summary_only, | |
5217 | old_ipv6_aggregate_address_summary_only_cmd, | |
5218 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5219 | IPV6_STR | |
5220 | BGP_STR | |
5221 | "Configure BGP aggregate entries\n" | |
5222 | "Aggregate prefix\n" | |
5223 | "Filter more specific routes from updates\n") | |
5224 | ||
5225 | ALIAS (no_ipv6_aggregate_address, | |
5226 | old_no_ipv6_aggregate_address_cmd, | |
5227 | "no ipv6 bgp aggregate-address X:X::X:X/M", | |
5228 | NO_STR | |
5229 | IPV6_STR | |
5230 | BGP_STR | |
5231 | "Configure BGP aggregate entries\n" | |
5232 | "Aggregate prefix\n") | |
5233 | ||
5234 | ALIAS (no_ipv6_aggregate_address_summary_only, | |
5235 | old_no_ipv6_aggregate_address_summary_only_cmd, | |
5236 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5237 | NO_STR | |
5238 | IPV6_STR | |
5239 | BGP_STR | |
5240 | "Configure BGP aggregate entries\n" | |
5241 | "Aggregate prefix\n" | |
5242 | "Filter more specific routes from updates\n") | |
5243 | #endif /* HAVE_IPV6 */ | |
5244 | \f | |
5245 | /* Redistribute route treatment. */ | |
5246 | void | |
5247 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, | |
5248 | u_int32_t metric, u_char type) | |
5249 | { | |
5250 | struct bgp *bgp; | |
1eb8ef25 | 5251 | struct listnode *node, *nnode; |
718e3744 | 5252 | struct bgp_info *new; |
5253 | struct bgp_info *bi; | |
5254 | struct bgp_info info; | |
5255 | struct bgp_node *bn; | |
fb982c25 PJ |
5256 | struct attr attr = { 0 }; |
5257 | struct attr attr_new = { 0 }; | |
718e3744 | 5258 | struct attr *new_attr; |
5259 | afi_t afi; | |
5260 | int ret; | |
5261 | ||
5262 | /* Make default attribute. */ | |
5263 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); | |
5264 | if (nexthop) | |
5265 | attr.nexthop = *nexthop; | |
5266 | ||
5267 | attr.med = metric; | |
5268 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
5269 | ||
1eb8ef25 | 5270 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 5271 | { |
5272 | afi = family2afi (p->family); | |
5273 | ||
5274 | if (bgp->redist[afi][type]) | |
5275 | { | |
5276 | /* Copy attribute for modification. */ | |
fb982c25 | 5277 | bgp_attr_dup (&attr_new, &attr); |
718e3744 | 5278 | |
5279 | if (bgp->redist_metric_flag[afi][type]) | |
5280 | attr_new.med = bgp->redist_metric[afi][type]; | |
5281 | ||
5282 | /* Apply route-map. */ | |
5283 | if (bgp->rmap[afi][type].map) | |
5284 | { | |
5285 | info.peer = bgp->peer_self; | |
5286 | info.attr = &attr_new; | |
5287 | ||
fee0f4c6 | 5288 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
5289 | ||
718e3744 | 5290 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
5291 | &info); | |
fee0f4c6 | 5292 | |
5293 | bgp->peer_self->rmap_type = 0; | |
5294 | ||
718e3744 | 5295 | if (ret == RMAP_DENYMATCH) |
5296 | { | |
5297 | /* Free uninterned attribute. */ | |
5298 | bgp_attr_flush (&attr_new); | |
fb982c25 PJ |
5299 | bgp_attr_extra_free (&attr_new); |
5300 | ||
718e3744 | 5301 | /* Unintern original. */ |
f6f434b2 | 5302 | aspath_unintern (&attr.aspath); |
fb982c25 | 5303 | bgp_attr_extra_free (&attr); |
718e3744 | 5304 | bgp_redistribute_delete (p, type); |
5305 | return; | |
5306 | } | |
5307 | } | |
5308 | ||
fb982c25 PJ |
5309 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
5310 | afi, SAFI_UNICAST, p, NULL); | |
5311 | ||
718e3744 | 5312 | new_attr = bgp_attr_intern (&attr_new); |
fb982c25 PJ |
5313 | bgp_attr_extra_free (&attr_new); |
5314 | ||
718e3744 | 5315 | for (bi = bn->info; bi; bi = bi->next) |
5316 | if (bi->peer == bgp->peer_self | |
5317 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
5318 | break; | |
5319 | ||
5320 | if (bi) | |
5321 | { | |
8d45210e AS |
5322 | if (attrhash_cmp (bi->attr, new_attr) && |
5323 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
718e3744 | 5324 | { |
f6f434b2 PJ |
5325 | bgp_attr_unintern (&new_attr); |
5326 | aspath_unintern (&attr.aspath); | |
fb982c25 | 5327 | bgp_attr_extra_free (&attr); |
718e3744 | 5328 | bgp_unlock_node (bn); |
5329 | return; | |
5330 | } | |
5331 | else | |
5332 | { | |
5333 | /* The attribute is changed. */ | |
1a392d46 | 5334 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
718e3744 | 5335 | |
5336 | /* Rewrite BGP route information. */ | |
8d45210e AS |
5337 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
5338 | bgp_info_restore(bn, bi); | |
5339 | else | |
5340 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); | |
f6f434b2 | 5341 | bgp_attr_unintern (&bi->attr); |
718e3744 | 5342 | bi->attr = new_attr; |
65957886 | 5343 | bi->uptime = bgp_clock (); |
718e3744 | 5344 | |
5345 | /* Process change. */ | |
5346 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); | |
5347 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
5348 | bgp_unlock_node (bn); | |
f6f434b2 | 5349 | aspath_unintern (&attr.aspath); |
fb982c25 | 5350 | bgp_attr_extra_free (&attr); |
718e3744 | 5351 | return; |
5352 | } | |
5353 | } | |
5354 | ||
5355 | new = bgp_info_new (); | |
5356 | new->type = type; | |
5357 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; | |
5358 | new->peer = bgp->peer_self; | |
5359 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
5360 | new->attr = new_attr; | |
65957886 | 5361 | new->uptime = bgp_clock (); |
718e3744 | 5362 | |
5363 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); | |
5364 | bgp_info_add (bn, new); | |
200df115 | 5365 | bgp_unlock_node (bn); |
718e3744 | 5366 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
5367 | } | |
5368 | } | |
5369 | ||
5370 | /* Unintern original. */ | |
f6f434b2 | 5371 | aspath_unintern (&attr.aspath); |
fb982c25 | 5372 | bgp_attr_extra_free (&attr); |
718e3744 | 5373 | } |
5374 | ||
5375 | void | |
5376 | bgp_redistribute_delete (struct prefix *p, u_char type) | |
5377 | { | |
5378 | struct bgp *bgp; | |
1eb8ef25 | 5379 | struct listnode *node, *nnode; |
718e3744 | 5380 | afi_t afi; |
5381 | struct bgp_node *rn; | |
5382 | struct bgp_info *ri; | |
5383 | ||
1eb8ef25 | 5384 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 5385 | { |
5386 | afi = family2afi (p->family); | |
5387 | ||
5388 | if (bgp->redist[afi][type]) | |
5389 | { | |
fee0f4c6 | 5390 | rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); |
718e3744 | 5391 | |
5392 | for (ri = rn->info; ri; ri = ri->next) | |
5393 | if (ri->peer == bgp->peer_self | |
5394 | && ri->type == type) | |
5395 | break; | |
5396 | ||
5397 | if (ri) | |
5398 | { | |
5399 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5400 | bgp_info_delete (rn, ri); |
1a392d46 | 5401 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5402 | } |
5403 | bgp_unlock_node (rn); | |
5404 | } | |
5405 | } | |
5406 | } | |
5407 | ||
5408 | /* Withdraw specified route type's route. */ | |
5409 | void | |
5410 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) | |
5411 | { | |
5412 | struct bgp_node *rn; | |
5413 | struct bgp_info *ri; | |
5414 | struct bgp_table *table; | |
5415 | ||
5416 | table = bgp->rib[afi][SAFI_UNICAST]; | |
5417 | ||
5418 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
5419 | { | |
5420 | for (ri = rn->info; ri; ri = ri->next) | |
5421 | if (ri->peer == bgp->peer_self | |
5422 | && ri->type == type) | |
5423 | break; | |
5424 | ||
5425 | if (ri) | |
5426 | { | |
5427 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5428 | bgp_info_delete (rn, ri); |
1a392d46 | 5429 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5430 | } |
5431 | } | |
5432 | } | |
5433 | \f | |
5434 | /* Static function to display route. */ | |
94f2b392 | 5435 | static void |
718e3744 | 5436 | route_vty_out_route (struct prefix *p, struct vty *vty) |
5437 | { | |
5438 | int len; | |
5439 | u_int32_t destination; | |
5440 | char buf[BUFSIZ]; | |
5441 | ||
5442 | if (p->family == AF_INET) | |
5443 | { | |
5444 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); | |
5445 | destination = ntohl (p->u.prefix4.s_addr); | |
5446 | ||
5447 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
5448 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
5449 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
5450 | || p->u.prefix4.s_addr == 0) | |
5451 | { | |
5452 | /* When mask is natural, mask is not displayed. */ | |
5453 | } | |
5454 | else | |
5455 | len += vty_out (vty, "/%d", p->prefixlen); | |
5456 | } | |
5457 | else | |
5458 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), | |
5459 | p->prefixlen); | |
5460 | ||
5461 | len = 17 - len; | |
5462 | if (len < 1) | |
5463 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); | |
5464 | else | |
5465 | vty_out (vty, "%*s", len, " "); | |
5466 | } | |
5467 | ||
718e3744 | 5468 | enum bgp_display_type |
5469 | { | |
5470 | normal_list, | |
5471 | }; | |
5472 | ||
b40d939b | 5473 | /* Print the short form route status for a bgp_info */ |
5474 | static void | |
5475 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) | |
718e3744 | 5476 | { |
b40d939b | 5477 | /* Route status display. */ |
5478 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
5479 | vty_out (vty, "R"); | |
5480 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
93406d87 | 5481 | vty_out (vty, "S"); |
fb982c25 | 5482 | else if (binfo->extra && binfo->extra->suppress) |
718e3744 | 5483 | vty_out (vty, "s"); |
5484 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5485 | vty_out (vty, "*"); | |
5486 | else | |
5487 | vty_out (vty, " "); | |
5488 | ||
5489 | /* Selected */ | |
5490 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5491 | vty_out (vty, "h"); | |
5492 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5493 | vty_out (vty, "d"); | |
5494 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
5495 | vty_out (vty, ">"); | |
5496 | else | |
5497 | vty_out (vty, " "); | |
5498 | ||
5499 | /* Internal route. */ | |
5500 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) | |
5501 | vty_out (vty, "i"); | |
5502 | else | |
b40d939b | 5503 | vty_out (vty, " "); |
5504 | } | |
5505 | ||
5506 | /* called from terminal list command */ | |
5507 | void | |
5508 | route_vty_out (struct vty *vty, struct prefix *p, | |
5509 | struct bgp_info *binfo, int display, safi_t safi) | |
5510 | { | |
5511 | struct attr *attr; | |
5512 | ||
5513 | /* short status lead text */ | |
5514 | route_vty_short_status_out (vty, binfo); | |
718e3744 | 5515 | |
5516 | /* print prefix and mask */ | |
5517 | if (! display) | |
5518 | route_vty_out_route (p, vty); | |
5519 | else | |
5520 | vty_out (vty, "%*s", 17, " "); | |
5521 | ||
5522 | /* Print attribute */ | |
5523 | attr = binfo->attr; | |
5524 | if (attr) | |
5525 | { | |
5526 | if (p->family == AF_INET) | |
5527 | { | |
5528 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5529 | vty_out (vty, "%-16s", |
5530 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5531 | else |
5532 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5533 | } | |
5534 | #ifdef HAVE_IPV6 | |
5535 | else if (p->family == AF_INET6) | |
5536 | { | |
5537 | int len; | |
5538 | char buf[BUFSIZ]; | |
5539 | ||
5540 | len = vty_out (vty, "%s", | |
fb982c25 PJ |
5541 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5542 | buf, BUFSIZ)); | |
718e3744 | 5543 | len = 16 - len; |
5544 | if (len < 1) | |
5545 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5546 | else | |
5547 | vty_out (vty, "%*s", len, " "); | |
5548 | } | |
5549 | #endif /* HAVE_IPV6 */ | |
5550 | ||
5551 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
c099baf6 | 5552 | vty_out (vty, "%10u", attr->med); |
718e3744 | 5553 | else |
5554 | vty_out (vty, " "); | |
5555 | ||
5556 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
c099baf6 | 5557 | vty_out (vty, "%7u", attr->local_pref); |
718e3744 | 5558 | else |
5559 | vty_out (vty, " "); | |
5560 | ||
fb982c25 | 5561 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
718e3744 | 5562 | |
b2518c1e PJ |
5563 | /* Print aspath */ |
5564 | if (attr->aspath) | |
841f7a57 | 5565 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5566 | |
b2518c1e | 5567 | /* Print origin */ |
718e3744 | 5568 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
b2518c1e | 5569 | } |
718e3744 | 5570 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5571 | } |
5572 | ||
5573 | /* called from terminal list command */ | |
5574 | void | |
5575 | route_vty_out_tmp (struct vty *vty, struct prefix *p, | |
5576 | struct attr *attr, safi_t safi) | |
5577 | { | |
5578 | /* Route status display. */ | |
5579 | vty_out (vty, "*"); | |
5580 | vty_out (vty, ">"); | |
5581 | vty_out (vty, " "); | |
5582 | ||
5583 | /* print prefix and mask */ | |
5584 | route_vty_out_route (p, vty); | |
5585 | ||
5586 | /* Print attribute */ | |
5587 | if (attr) | |
5588 | { | |
5589 | if (p->family == AF_INET) | |
5590 | { | |
5591 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5592 | vty_out (vty, "%-16s", |
5593 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5594 | else |
5595 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5596 | } | |
5597 | #ifdef HAVE_IPV6 | |
5598 | else if (p->family == AF_INET6) | |
5599 | { | |
5600 | int len; | |
5601 | char buf[BUFSIZ]; | |
fb982c25 PJ |
5602 | |
5603 | assert (attr->extra); | |
718e3744 | 5604 | |
5605 | len = vty_out (vty, "%s", | |
fb982c25 PJ |
5606 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5607 | buf, BUFSIZ)); | |
718e3744 | 5608 | len = 16 - len; |
5609 | if (len < 1) | |
5610 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5611 | else | |
5612 | vty_out (vty, "%*s", len, " "); | |
5613 | } | |
5614 | #endif /* HAVE_IPV6 */ | |
5615 | ||
5616 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
c099baf6 | 5617 | vty_out (vty, "%10u", attr->med); |
718e3744 | 5618 | else |
5619 | vty_out (vty, " "); | |
5620 | ||
5621 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
c099baf6 | 5622 | vty_out (vty, "%7u", attr->local_pref); |
718e3744 | 5623 | else |
5624 | vty_out (vty, " "); | |
fb982c25 | 5625 | |
c099baf6 | 5626 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
fb982c25 | 5627 | |
b2518c1e PJ |
5628 | /* Print aspath */ |
5629 | if (attr->aspath) | |
841f7a57 | 5630 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5631 | |
b2518c1e | 5632 | /* Print origin */ |
718e3744 | 5633 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
b2518c1e | 5634 | } |
718e3744 | 5635 | |
5636 | vty_out (vty, "%s", VTY_NEWLINE); | |
5637 | } | |
5638 | ||
5a646650 | 5639 | void |
718e3744 | 5640 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
5641 | struct bgp_info *binfo, int display, safi_t safi) | |
5642 | { | |
5643 | struct attr *attr; | |
718e3744 | 5644 | u_int32_t label = 0; |
fb982c25 PJ |
5645 | |
5646 | if (!binfo->extra) | |
5647 | return; | |
5648 | ||
b40d939b | 5649 | /* short status lead text */ |
5650 | route_vty_short_status_out (vty, binfo); | |
5651 | ||
718e3744 | 5652 | /* print prefix and mask */ |
5653 | if (! display) | |
5654 | route_vty_out_route (p, vty); | |
5655 | else | |
5656 | vty_out (vty, "%*s", 17, " "); | |
5657 | ||
5658 | /* Print attribute */ | |
5659 | attr = binfo->attr; | |
5660 | if (attr) | |
5661 | { | |
5662 | if (p->family == AF_INET) | |
5663 | { | |
5664 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5665 | vty_out (vty, "%-16s", |
5666 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5667 | else |
5668 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5669 | } | |
5670 | #ifdef HAVE_IPV6 | |
5671 | else if (p->family == AF_INET6) | |
5672 | { | |
fb982c25 | 5673 | assert (attr->extra); |
718e3744 | 5674 | char buf[BUFSIZ]; |
5675 | char buf1[BUFSIZ]; | |
fb982c25 | 5676 | if (attr->extra->mp_nexthop_len == 16) |
718e3744 | 5677 | vty_out (vty, "%s", |
fb982c25 PJ |
5678 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5679 | buf, BUFSIZ)); | |
5680 | else if (attr->extra->mp_nexthop_len == 32) | |
718e3744 | 5681 | vty_out (vty, "%s(%s)", |
fb982c25 PJ |
5682 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5683 | buf, BUFSIZ), | |
5684 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
5685 | buf1, BUFSIZ)); | |
718e3744 | 5686 | |
5687 | } | |
5688 | #endif /* HAVE_IPV6 */ | |
5689 | } | |
5690 | ||
fb982c25 | 5691 | label = decode_label (binfo->extra->tag); |
718e3744 | 5692 | |
5693 | vty_out (vty, "notag/%d", label); | |
5694 | ||
5695 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5696 | } |
5697 | ||
5698 | /* dampening route */ | |
5a646650 | 5699 | static void |
718e3744 | 5700 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
5701 | struct bgp_info *binfo, int display, safi_t safi) | |
5702 | { | |
5703 | struct attr *attr; | |
718e3744 | 5704 | int len; |
50aef6f3 | 5705 | char timebuf[BGP_UPTIME_LEN]; |
718e3744 | 5706 | |
b40d939b | 5707 | /* short status lead text */ |
5708 | route_vty_short_status_out (vty, binfo); | |
5709 | ||
718e3744 | 5710 | /* print prefix and mask */ |
5711 | if (! display) | |
5712 | route_vty_out_route (p, vty); | |
5713 | else | |
5714 | vty_out (vty, "%*s", 17, " "); | |
5715 | ||
5716 | len = vty_out (vty, "%s", binfo->peer->host); | |
5717 | len = 17 - len; | |
5718 | if (len < 1) | |
5719 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); | |
5720 | else | |
5721 | vty_out (vty, "%*s", len, " "); | |
5722 | ||
50aef6f3 | 5723 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
718e3744 | 5724 | |
5725 | /* Print attribute */ | |
5726 | attr = binfo->attr; | |
5727 | if (attr) | |
5728 | { | |
5729 | /* Print aspath */ | |
5730 | if (attr->aspath) | |
841f7a57 | 5731 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5732 | |
5733 | /* Print origin */ | |
b2518c1e | 5734 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
718e3744 | 5735 | } |
5736 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5737 | } |
5738 | ||
718e3744 | 5739 | /* flap route */ |
5a646650 | 5740 | static void |
718e3744 | 5741 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
5742 | struct bgp_info *binfo, int display, safi_t safi) | |
5743 | { | |
5744 | struct attr *attr; | |
5745 | struct bgp_damp_info *bdi; | |
718e3744 | 5746 | char timebuf[BGP_UPTIME_LEN]; |
5747 | int len; | |
fb982c25 PJ |
5748 | |
5749 | if (!binfo->extra) | |
5750 | return; | |
5751 | ||
5752 | bdi = binfo->extra->damp_info; | |
718e3744 | 5753 | |
b40d939b | 5754 | /* short status lead text */ |
5755 | route_vty_short_status_out (vty, binfo); | |
5756 | ||
718e3744 | 5757 | /* print prefix and mask */ |
5758 | if (! display) | |
5759 | route_vty_out_route (p, vty); | |
5760 | else | |
5761 | vty_out (vty, "%*s", 17, " "); | |
5762 | ||
5763 | len = vty_out (vty, "%s", binfo->peer->host); | |
5764 | len = 16 - len; | |
5765 | if (len < 1) | |
5766 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); | |
5767 | else | |
5768 | vty_out (vty, "%*s", len, " "); | |
5769 | ||
5770 | len = vty_out (vty, "%d", bdi->flap); | |
5771 | len = 5 - len; | |
5772 | if (len < 1) | |
5773 | vty_out (vty, " "); | |
5774 | else | |
5775 | vty_out (vty, "%*s ", len, " "); | |
5776 | ||
5777 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, | |
5778 | timebuf, BGP_UPTIME_LEN)); | |
5779 | ||
5780 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) | |
5781 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
50aef6f3 | 5782 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
718e3744 | 5783 | else |
5784 | vty_out (vty, "%*s ", 8, " "); | |
5785 | ||
5786 | /* Print attribute */ | |
5787 | attr = binfo->attr; | |
5788 | if (attr) | |
5789 | { | |
5790 | /* Print aspath */ | |
5791 | if (attr->aspath) | |
841f7a57 | 5792 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5793 | |
5794 | /* Print origin */ | |
b2518c1e | 5795 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
718e3744 | 5796 | } |
5797 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5798 | } |
5799 | ||
94f2b392 | 5800 | static void |
718e3744 | 5801 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
5802 | struct bgp_info *binfo, afi_t afi, safi_t safi) | |
5803 | { | |
5804 | char buf[INET6_ADDRSTRLEN]; | |
5805 | char buf1[BUFSIZ]; | |
5806 | struct attr *attr; | |
5807 | int sockunion_vty_out (struct vty *, union sockunion *); | |
30b00176 JK |
5808 | #ifdef HAVE_CLOCK_MONOTONIC |
5809 | time_t tbuf; | |
5810 | #endif | |
718e3744 | 5811 | |
5812 | attr = binfo->attr; | |
5813 | ||
5814 | if (attr) | |
5815 | { | |
5816 | /* Line1 display AS-path, Aggregator */ | |
5817 | if (attr->aspath) | |
5818 | { | |
5819 | vty_out (vty, " "); | |
fe69a505 | 5820 | if (aspath_count_hops (attr->aspath) == 0) |
718e3744 | 5821 | vty_out (vty, "Local"); |
5822 | else | |
841f7a57 | 5823 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
718e3744 | 5824 | } |
5825 | ||
b40d939b | 5826 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
5827 | vty_out (vty, ", (removed)"); | |
93406d87 | 5828 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
5829 | vty_out (vty, ", (stale)"); | |
5830 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) | |
aea339f7 | 5831 | vty_out (vty, ", (aggregated by %u %s)", |
fb982c25 PJ |
5832 | attr->extra->aggregator_as, |
5833 | inet_ntoa (attr->extra->aggregator_addr)); | |
93406d87 | 5834 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
5835 | vty_out (vty, ", (Received from a RR-client)"); | |
5836 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
5837 | vty_out (vty, ", (Received from a RS-client)"); | |
5838 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5839 | vty_out (vty, ", (history entry)"); | |
5840 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5841 | vty_out (vty, ", (suppressed due to dampening)"); | |
718e3744 | 5842 | vty_out (vty, "%s", VTY_NEWLINE); |
5843 | ||
5844 | /* Line2 display Next-hop, Neighbor, Router-id */ | |
5845 | if (p->family == AF_INET) | |
5846 | { | |
5847 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? | |
fb982c25 | 5848 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
718e3744 | 5849 | inet_ntoa (attr->nexthop)); |
5850 | } | |
5851 | #ifdef HAVE_IPV6 | |
5852 | else | |
5853 | { | |
fb982c25 | 5854 | assert (attr->extra); |
718e3744 | 5855 | vty_out (vty, " %s", |
fb982c25 | 5856 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
718e3744 | 5857 | buf, INET6_ADDRSTRLEN)); |
5858 | } | |
5859 | #endif /* HAVE_IPV6 */ | |
5860 | ||
5861 | if (binfo->peer == bgp->peer_self) | |
5862 | { | |
5863 | vty_out (vty, " from %s ", | |
5864 | p->family == AF_INET ? "0.0.0.0" : "::"); | |
5865 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); | |
5866 | } | |
5867 | else | |
5868 | { | |
5869 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) | |
5870 | vty_out (vty, " (inaccessible)"); | |
fb982c25 PJ |
5871 | else if (binfo->extra && binfo->extra->igpmetric) |
5872 | vty_out (vty, " (metric %d)", binfo->extra->igpmetric); | |
eb821189 | 5873 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
718e3744 | 5874 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 | 5875 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
718e3744 | 5876 | else |
5877 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
5878 | } | |
5879 | vty_out (vty, "%s", VTY_NEWLINE); | |
5880 | ||
5881 | #ifdef HAVE_IPV6 | |
5882 | /* display nexthop local */ | |
fb982c25 | 5883 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
718e3744 | 5884 | { |
5885 | vty_out (vty, " (%s)%s", | |
fb982c25 | 5886 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
718e3744 | 5887 | buf, INET6_ADDRSTRLEN), |
5888 | VTY_NEWLINE); | |
5889 | } | |
5890 | #endif /* HAVE_IPV6 */ | |
5891 | ||
5892 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ | |
5893 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); | |
5894 | ||
5895 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) | |
c099baf6 | 5896 | vty_out (vty, ", metric %u", attr->med); |
718e3744 | 5897 | |
5898 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) | |
c099baf6 | 5899 | vty_out (vty, ", localpref %u", attr->local_pref); |
718e3744 | 5900 | else |
c099baf6 | 5901 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
718e3744 | 5902 | |
fb982c25 | 5903 | if (attr->extra && attr->extra->weight != 0) |
c099baf6 | 5904 | vty_out (vty, ", weight %u", attr->extra->weight); |
718e3744 | 5905 | |
5906 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5907 | vty_out (vty, ", valid"); | |
5908 | ||
5909 | if (binfo->peer != bgp->peer_self) | |
5910 | { | |
5911 | if (binfo->peer->as == binfo->peer->local_as) | |
5912 | vty_out (vty, ", internal"); | |
5913 | else | |
5914 | vty_out (vty, ", %s", | |
5915 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); | |
5916 | } | |
5917 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) | |
5918 | vty_out (vty, ", aggregated, local"); | |
5919 | else if (binfo->type != ZEBRA_ROUTE_BGP) | |
5920 | vty_out (vty, ", sourced"); | |
5921 | else | |
5922 | vty_out (vty, ", sourced, local"); | |
5923 | ||
5924 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) | |
5925 | vty_out (vty, ", atomic-aggregate"); | |
5926 | ||
5927 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
5928 | vty_out (vty, ", best"); | |
5929 | ||
5930 | vty_out (vty, "%s", VTY_NEWLINE); | |
5931 | ||
5932 | /* Line 4 display Community */ | |
5933 | if (attr->community) | |
5934 | vty_out (vty, " Community: %s%s", attr->community->str, | |
5935 | VTY_NEWLINE); | |
5936 | ||
5937 | /* Line 5 display Extended-community */ | |
5938 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) | |
fb982c25 PJ |
5939 | vty_out (vty, " Extended Community: %s%s", |
5940 | attr->extra->ecommunity->str, VTY_NEWLINE); | |
718e3744 | 5941 | |
5942 | /* Line 6 display Originator, Cluster-id */ | |
5943 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || | |
5944 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) | |
5945 | { | |
fb982c25 | 5946 | assert (attr->extra); |
718e3744 | 5947 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 PJ |
5948 | vty_out (vty, " Originator: %s", |
5949 | inet_ntoa (attr->extra->originator_id)); | |
718e3744 | 5950 | |
5951 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
5952 | { | |
5953 | int i; | |
5954 | vty_out (vty, ", Cluster list: "); | |
fb982c25 PJ |
5955 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
5956 | vty_out (vty, "%s ", | |
5957 | inet_ntoa (attr->extra->cluster->list[i])); | |
718e3744 | 5958 | } |
5959 | vty_out (vty, "%s", VTY_NEWLINE); | |
5960 | } | |
41367172 | 5961 | |
fb982c25 | 5962 | if (binfo->extra && binfo->extra->damp_info) |
718e3744 | 5963 | bgp_damp_info_vty (vty, binfo); |
5964 | ||
5965 | /* Line 7 display Uptime */ | |
30b00176 JK |
5966 | #ifdef HAVE_CLOCK_MONOTONIC |
5967 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); | |
213b6cd9 | 5968 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
30b00176 JK |
5969 | #else |
5970 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); | |
5971 | #endif /* HAVE_CLOCK_MONOTONIC */ | |
718e3744 | 5972 | } |
5973 | vty_out (vty, "%s", VTY_NEWLINE); | |
5974 | } | |
5975 | \f | |
b40d939b | 5976 | #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 | 5977 | #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s" |
718e3744 | 5978 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
5979 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" | |
5980 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" | |
5981 | ||
5982 | enum bgp_show_type | |
5983 | { | |
5984 | bgp_show_type_normal, | |
5985 | bgp_show_type_regexp, | |
5986 | bgp_show_type_prefix_list, | |
5987 | bgp_show_type_filter_list, | |
5988 | bgp_show_type_route_map, | |
5989 | bgp_show_type_neighbor, | |
5990 | bgp_show_type_cidr_only, | |
5991 | bgp_show_type_prefix_longer, | |
5992 | bgp_show_type_community_all, | |
5993 | bgp_show_type_community, | |
5994 | bgp_show_type_community_exact, | |
5995 | bgp_show_type_community_list, | |
5996 | bgp_show_type_community_list_exact, | |
5997 | bgp_show_type_flap_statistics, | |
5998 | bgp_show_type_flap_address, | |
5999 | bgp_show_type_flap_prefix, | |
6000 | bgp_show_type_flap_cidr_only, | |
6001 | bgp_show_type_flap_regexp, | |
6002 | bgp_show_type_flap_filter_list, | |
6003 | bgp_show_type_flap_prefix_list, | |
6004 | bgp_show_type_flap_prefix_longer, | |
6005 | bgp_show_type_flap_route_map, | |
6006 | bgp_show_type_flap_neighbor, | |
6007 | bgp_show_type_dampend_paths, | |
6008 | bgp_show_type_damp_neighbor | |
6009 | }; | |
6010 | ||
5a646650 | 6011 | static int |
fee0f4c6 | 6012 | bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id, |
5a646650 | 6013 | enum bgp_show_type type, void *output_arg) |
718e3744 | 6014 | { |
718e3744 | 6015 | struct bgp_info *ri; |
6016 | struct bgp_node *rn; | |
718e3744 | 6017 | int header = 1; |
718e3744 | 6018 | int display; |
5a646650 | 6019 | unsigned long output_count; |
718e3744 | 6020 | |
6021 | /* This is first entry point, so reset total line. */ | |
5a646650 | 6022 | output_count = 0; |
718e3744 | 6023 | |
718e3744 | 6024 | /* Start processing of routes. */ |
6025 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
6026 | if (rn->info != NULL) | |
6027 | { | |
6028 | display = 0; | |
6029 | ||
6030 | for (ri = rn->info; ri; ri = ri->next) | |
6031 | { | |
5a646650 | 6032 | if (type == bgp_show_type_flap_statistics |
718e3744 | 6033 | || type == bgp_show_type_flap_address |
6034 | || type == bgp_show_type_flap_prefix | |
6035 | || type == bgp_show_type_flap_cidr_only | |
6036 | || type == bgp_show_type_flap_regexp | |
6037 | || type == bgp_show_type_flap_filter_list | |
6038 | || type == bgp_show_type_flap_prefix_list | |
6039 | || type == bgp_show_type_flap_prefix_longer | |
6040 | || type == bgp_show_type_flap_route_map | |
6041 | || type == bgp_show_type_flap_neighbor | |
6042 | || type == bgp_show_type_dampend_paths | |
6043 | || type == bgp_show_type_damp_neighbor) | |
6044 | { | |
fb982c25 | 6045 | if (!(ri->extra && ri->extra->damp_info)) |
718e3744 | 6046 | continue; |
6047 | } | |
6048 | if (type == bgp_show_type_regexp | |
6049 | || type == bgp_show_type_flap_regexp) | |
6050 | { | |
5a646650 | 6051 | regex_t *regex = output_arg; |
718e3744 | 6052 | |
6053 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) | |
6054 | continue; | |
6055 | } | |
6056 | if (type == bgp_show_type_prefix_list | |
6057 | || type == bgp_show_type_flap_prefix_list) | |
6058 | { | |
5a646650 | 6059 | struct prefix_list *plist = output_arg; |
718e3744 | 6060 | |
6061 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) | |
6062 | continue; | |
6063 | } | |
6064 | if (type == bgp_show_type_filter_list | |
6065 | || type == bgp_show_type_flap_filter_list) | |
6066 | { | |
5a646650 | 6067 | struct as_list *as_list = output_arg; |
718e3744 | 6068 | |
6069 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) | |
6070 | continue; | |
6071 | } | |
6072 | if (type == bgp_show_type_route_map | |
6073 | || type == bgp_show_type_flap_route_map) | |
6074 | { | |
5a646650 | 6075 | struct route_map *rmap = output_arg; |
718e3744 | 6076 | struct bgp_info binfo; |
9eda90ce | 6077 | struct attr dummy_attr = { 0 }; |
718e3744 | 6078 | int ret; |
6079 | ||
fb982c25 | 6080 | bgp_attr_dup (&dummy_attr, ri->attr); |
718e3744 | 6081 | binfo.peer = ri->peer; |
6082 | binfo.attr = &dummy_attr; | |
6083 | ||
6084 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); | |
fb982c25 PJ |
6085 | |
6086 | bgp_attr_extra_free (&dummy_attr); | |
6087 | ||
718e3744 | 6088 | if (ret == RMAP_DENYMATCH) |
6089 | continue; | |
6090 | } | |
6091 | if (type == bgp_show_type_neighbor | |
6092 | || type == bgp_show_type_flap_neighbor | |
6093 | || type == bgp_show_type_damp_neighbor) | |
6094 | { | |
5a646650 | 6095 | union sockunion *su = output_arg; |
718e3744 | 6096 | |
6097 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) | |
6098 | continue; | |
6099 | } | |
6100 | if (type == bgp_show_type_cidr_only | |
6101 | || type == bgp_show_type_flap_cidr_only) | |
6102 | { | |
6103 | u_int32_t destination; | |
6104 | ||
6105 | destination = ntohl (rn->p.u.prefix4.s_addr); | |
6106 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) | |
6107 | continue; | |
6108 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) | |
6109 | continue; | |
6110 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) | |
6111 | continue; | |
6112 | } | |
6113 | if (type == bgp_show_type_prefix_longer | |
6114 | || type == bgp_show_type_flap_prefix_longer) | |
6115 | { | |
5a646650 | 6116 | struct prefix *p = output_arg; |
718e3744 | 6117 | |
6118 | if (! prefix_match (p, &rn->p)) | |
6119 | continue; | |
6120 | } | |
6121 | if (type == bgp_show_type_community_all) | |
6122 | { | |
6123 | if (! ri->attr->community) | |
6124 | continue; | |
6125 | } | |
6126 | if (type == bgp_show_type_community) | |
6127 | { | |
5a646650 | 6128 | struct community *com = output_arg; |
718e3744 | 6129 | |
6130 | if (! ri->attr->community || | |
6131 | ! community_match (ri->attr->community, com)) | |
6132 | continue; | |
6133 | } | |
6134 | if (type == bgp_show_type_community_exact) | |
6135 | { | |
5a646650 | 6136 | struct community *com = output_arg; |
718e3744 | 6137 | |
6138 | if (! ri->attr->community || | |
6139 | ! community_cmp (ri->attr->community, com)) | |
6140 | continue; | |
6141 | } | |
6142 | if (type == bgp_show_type_community_list) | |
6143 | { | |
5a646650 | 6144 | struct community_list *list = output_arg; |
718e3744 | 6145 | |
6146 | if (! community_list_match (ri->attr->community, list)) | |
6147 | continue; | |
6148 | } | |
6149 | if (type == bgp_show_type_community_list_exact) | |
6150 | { | |
5a646650 | 6151 | struct community_list *list = output_arg; |
718e3744 | 6152 | |
6153 | if (! community_list_exact_match (ri->attr->community, list)) | |
6154 | continue; | |
6155 | } | |
6156 | if (type == bgp_show_type_flap_address | |
6157 | || type == bgp_show_type_flap_prefix) | |
6158 | { | |
5a646650 | 6159 | struct prefix *p = output_arg; |
718e3744 | 6160 | |
6161 | if (! prefix_match (&rn->p, p)) | |
6162 | continue; | |
6163 | ||
6164 | if (type == bgp_show_type_flap_prefix) | |
6165 | if (p->prefixlen != rn->p.prefixlen) | |
6166 | continue; | |
6167 | } | |
6168 | if (type == bgp_show_type_dampend_paths | |
6169 | || type == bgp_show_type_damp_neighbor) | |
6170 | { | |
6171 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) | |
6172 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
6173 | continue; | |
6174 | } | |
6175 | ||
6176 | if (header) | |
6177 | { | |
93406d87 | 6178 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
6179 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
6180 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 6181 | if (type == bgp_show_type_dampend_paths |
6182 | || type == bgp_show_type_damp_neighbor) | |
6183 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); | |
6184 | else if (type == bgp_show_type_flap_statistics | |
6185 | || type == bgp_show_type_flap_address | |
6186 | || type == bgp_show_type_flap_prefix | |
6187 | || type == bgp_show_type_flap_cidr_only | |
6188 | || type == bgp_show_type_flap_regexp | |
6189 | || type == bgp_show_type_flap_filter_list | |
6190 | || type == bgp_show_type_flap_prefix_list | |
6191 | || type == bgp_show_type_flap_prefix_longer | |
6192 | || type == bgp_show_type_flap_route_map | |
6193 | || type == bgp_show_type_flap_neighbor) | |
6194 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); | |
6195 | else | |
6196 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
718e3744 | 6197 | header = 0; |
6198 | } | |
6199 | ||
6200 | if (type == bgp_show_type_dampend_paths | |
6201 | || type == bgp_show_type_damp_neighbor) | |
5a646650 | 6202 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6203 | else if (type == bgp_show_type_flap_statistics |
6204 | || type == bgp_show_type_flap_address | |
6205 | || type == bgp_show_type_flap_prefix | |
6206 | || type == bgp_show_type_flap_cidr_only | |
6207 | || type == bgp_show_type_flap_regexp | |
6208 | || type == bgp_show_type_flap_filter_list | |
6209 | || type == bgp_show_type_flap_prefix_list | |
6210 | || type == bgp_show_type_flap_prefix_longer | |
6211 | || type == bgp_show_type_flap_route_map | |
6212 | || type == bgp_show_type_flap_neighbor) | |
5a646650 | 6213 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6214 | else |
5a646650 | 6215 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6216 | display++; |
6217 | } | |
6218 | if (display) | |
5a646650 | 6219 | output_count++; |
718e3744 | 6220 | } |
6221 | ||
6222 | /* No route is displayed */ | |
5a646650 | 6223 | if (output_count == 0) |
718e3744 | 6224 | { |
6225 | if (type == bgp_show_type_normal) | |
6226 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); | |
6227 | } | |
6228 | else | |
6229 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
5a646650 | 6230 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
718e3744 | 6231 | |
6232 | return CMD_SUCCESS; | |
6233 | } | |
6234 | ||
5a646650 | 6235 | static int |
fee0f4c6 | 6236 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
5a646650 | 6237 | enum bgp_show_type type, void *output_arg) |
fee0f4c6 | 6238 | { |
6239 | struct bgp_table *table; | |
6240 | ||
6241 | if (bgp == NULL) { | |
6242 | bgp = bgp_get_default (); | |
6243 | } | |
6244 | ||
6245 | if (bgp == NULL) | |
6246 | { | |
6247 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6248 | return CMD_WARNING; | |
6249 | } | |
6250 | ||
6251 | ||
6252 | table = bgp->rib[afi][safi]; | |
6253 | ||
5a646650 | 6254 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
fee0f4c6 | 6255 | } |
6256 | ||
718e3744 | 6257 | /* Header of detailed BGP route information */ |
94f2b392 | 6258 | static void |
718e3744 | 6259 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
6260 | struct bgp_node *rn, | |
6261 | struct prefix_rd *prd, afi_t afi, safi_t safi) | |
6262 | { | |
6263 | struct bgp_info *ri; | |
6264 | struct prefix *p; | |
6265 | struct peer *peer; | |
1eb8ef25 | 6266 | struct listnode *node, *nnode; |
718e3744 | 6267 | char buf1[INET6_ADDRSTRLEN]; |
6268 | char buf2[INET6_ADDRSTRLEN]; | |
6269 | int count = 0; | |
6270 | int best = 0; | |
6271 | int suppress = 0; | |
6272 | int no_export = 0; | |
6273 | int no_advertise = 0; | |
6274 | int local_as = 0; | |
6275 | int first = 0; | |
6276 | ||
6277 | p = &rn->p; | |
6278 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", | |
6279 | (safi == SAFI_MPLS_VPN ? | |
6280 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), | |
6281 | safi == SAFI_MPLS_VPN ? ":" : "", | |
6282 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), | |
6283 | p->prefixlen, VTY_NEWLINE); | |
6284 | ||
6285 | for (ri = rn->info; ri; ri = ri->next) | |
6286 | { | |
6287 | count++; | |
6288 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
6289 | { | |
6290 | best = count; | |
fb982c25 | 6291 | if (ri->extra && ri->extra->suppress) |
718e3744 | 6292 | suppress = 1; |
6293 | if (ri->attr->community != NULL) | |
6294 | { | |
6295 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) | |
6296 | no_advertise = 1; | |
6297 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) | |
6298 | no_export = 1; | |
6299 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) | |
6300 | local_as = 1; | |
6301 | } | |
6302 | } | |
6303 | } | |
6304 | ||
6305 | vty_out (vty, "Paths: (%d available", count); | |
6306 | if (best) | |
6307 | { | |
6308 | vty_out (vty, ", best #%d", best); | |
6309 | if (safi == SAFI_UNICAST) | |
6310 | vty_out (vty, ", table Default-IP-Routing-Table"); | |
6311 | } | |
6312 | else | |
6313 | vty_out (vty, ", no best path"); | |
6314 | if (no_advertise) | |
6315 | vty_out (vty, ", not advertised to any peer"); | |
6316 | else if (no_export) | |
6317 | vty_out (vty, ", not advertised to EBGP peer"); | |
6318 | else if (local_as) | |
6319 | vty_out (vty, ", not advertised outside local AS"); | |
6320 | if (suppress) | |
6321 | vty_out (vty, ", Advertisements suppressed by an aggregate."); | |
6322 | vty_out (vty, ")%s", VTY_NEWLINE); | |
6323 | ||
6324 | /* advertised peer */ | |
1eb8ef25 | 6325 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6326 | { |
6327 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) | |
6328 | { | |
6329 | if (! first) | |
6330 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); | |
6331 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6332 | first = 1; | |
6333 | } | |
6334 | } | |
6335 | if (! first) | |
6336 | vty_out (vty, " Not advertised to any peer"); | |
6337 | vty_out (vty, "%s", VTY_NEWLINE); | |
6338 | } | |
6339 | ||
6340 | /* Display specified route of BGP table. */ | |
94f2b392 | 6341 | static int |
fee0f4c6 | 6342 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
fd79ac91 | 6343 | struct bgp_table *rib, const char *ip_str, |
6344 | afi_t afi, safi_t safi, struct prefix_rd *prd, | |
6345 | int prefix_check) | |
718e3744 | 6346 | { |
6347 | int ret; | |
6348 | int header; | |
6349 | int display = 0; | |
6350 | struct prefix match; | |
6351 | struct bgp_node *rn; | |
6352 | struct bgp_node *rm; | |
6353 | struct bgp_info *ri; | |
718e3744 | 6354 | struct bgp_table *table; |
6355 | ||
718e3744 | 6356 | /* Check IP address argument. */ |
6357 | ret = str2prefix (ip_str, &match); | |
6358 | if (! ret) | |
6359 | { | |
6360 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); | |
6361 | return CMD_WARNING; | |
6362 | } | |
6363 | ||
6364 | match.family = afi2family (afi); | |
6365 | ||
6366 | if (safi == SAFI_MPLS_VPN) | |
6367 | { | |
fee0f4c6 | 6368 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
718e3744 | 6369 | { |
6370 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
6371 | continue; | |
6372 | ||
6373 | if ((table = rn->info) != NULL) | |
6374 | { | |
6375 | header = 1; | |
6376 | ||
6377 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6378 | { | |
6379 | if (prefix_check && rm->p.prefixlen != match.prefixlen) | |
6c88b44d CC |
6380 | { |
6381 | bgp_unlock_node (rm); | |
6382 | continue; | |
6383 | } | |
718e3744 | 6384 | |
6385 | for (ri = rm->info; ri; ri = ri->next) | |
6386 | { | |
6387 | if (header) | |
6388 | { | |
6389 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, | |
6390 | AFI_IP, SAFI_MPLS_VPN); | |
6391 | ||
6392 | header = 0; | |
6393 | } | |
6394 | display++; | |
6395 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); | |
6396 | } | |
6c88b44d CC |
6397 | |
6398 | bgp_unlock_node (rm); | |
718e3744 | 6399 | } |
6400 | } | |
6401 | } | |
6402 | } | |
6403 | else | |
6404 | { | |
6405 | header = 1; | |
6406 | ||
fee0f4c6 | 6407 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
718e3744 | 6408 | { |
6409 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
6410 | { | |
6411 | for (ri = rn->info; ri; ri = ri->next) | |
6412 | { | |
6413 | if (header) | |
6414 | { | |
6415 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); | |
6416 | header = 0; | |
6417 | } | |
6418 | display++; | |
6419 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); | |
6420 | } | |
6421 | } | |
6c88b44d CC |
6422 | |
6423 | bgp_unlock_node (rn); | |
718e3744 | 6424 | } |
6425 | } | |
6426 | ||
6427 | if (! display) | |
6428 | { | |
6429 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); | |
6430 | return CMD_WARNING; | |
6431 | } | |
6432 | ||
6433 | return CMD_SUCCESS; | |
6434 | } | |
6435 | ||
fee0f4c6 | 6436 | /* Display specified route of Main RIB */ |
94f2b392 | 6437 | static int |
fd79ac91 | 6438 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
fee0f4c6 | 6439 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
6440 | int prefix_check) | |
6441 | { | |
6442 | struct bgp *bgp; | |
6443 | ||
6444 | /* BGP structure lookup. */ | |
6445 | if (view_name) | |
6446 | { | |
6447 | bgp = bgp_lookup_by_name (view_name); | |
6448 | if (bgp == NULL) | |
6449 | { | |
6450 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
6451 | return CMD_WARNING; | |
6452 | } | |
6453 | } | |
6454 | else | |
6455 | { | |
6456 | bgp = bgp_get_default (); | |
6457 | if (bgp == NULL) | |
6458 | { | |
6459 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6460 | return CMD_WARNING; | |
6461 | } | |
6462 | } | |
6463 | ||
6464 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, | |
6465 | afi, safi, prd, prefix_check); | |
6466 | } | |
6467 | ||
718e3744 | 6468 | /* BGP route print out function. */ |
6469 | DEFUN (show_ip_bgp, | |
6470 | show_ip_bgp_cmd, | |
6471 | "show ip bgp", | |
6472 | SHOW_STR | |
6473 | IP_STR | |
6474 | BGP_STR) | |
6475 | { | |
5a646650 | 6476 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6477 | } |
6478 | ||
6479 | DEFUN (show_ip_bgp_ipv4, | |
6480 | show_ip_bgp_ipv4_cmd, | |
6481 | "show ip bgp ipv4 (unicast|multicast)", | |
6482 | SHOW_STR | |
6483 | IP_STR | |
6484 | BGP_STR | |
6485 | "Address family\n" | |
6486 | "Address Family modifier\n" | |
6487 | "Address Family modifier\n") | |
6488 | { | |
6489 | if (strncmp (argv[0], "m", 1) == 0) | |
5a646650 | 6490 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
6491 | NULL); | |
718e3744 | 6492 | |
5a646650 | 6493 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6494 | } |
6495 | ||
95cbbd2a ML |
6496 | ALIAS (show_ip_bgp_ipv4, |
6497 | show_bgp_ipv4_safi_cmd, | |
6498 | "show bgp ipv4 (unicast|multicast)", | |
6499 | SHOW_STR | |
6500 | BGP_STR | |
6501 | "Address family\n" | |
6502 | "Address Family modifier\n" | |
6503 | "Address Family modifier\n") | |
6504 | ||
718e3744 | 6505 | DEFUN (show_ip_bgp_route, |
6506 | show_ip_bgp_route_cmd, | |
6507 | "show ip bgp A.B.C.D", | |
6508 | SHOW_STR | |
6509 | IP_STR | |
6510 | BGP_STR | |
6511 | "Network in the BGP routing table to display\n") | |
6512 | { | |
6513 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6514 | } | |
6515 | ||
6516 | DEFUN (show_ip_bgp_ipv4_route, | |
6517 | show_ip_bgp_ipv4_route_cmd, | |
6518 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", | |
6519 | SHOW_STR | |
6520 | IP_STR | |
6521 | BGP_STR | |
6522 | "Address family\n" | |
6523 | "Address Family modifier\n" | |
6524 | "Address Family modifier\n" | |
6525 | "Network in the BGP routing table to display\n") | |
6526 | { | |
6527 | if (strncmp (argv[0], "m", 1) == 0) | |
6528 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); | |
6529 | ||
6530 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6531 | } | |
6532 | ||
95cbbd2a ML |
6533 | ALIAS (show_ip_bgp_ipv4_route, |
6534 | show_bgp_ipv4_safi_route_cmd, | |
6535 | "show bgp ipv4 (unicast|multicast) A.B.C.D", | |
6536 | SHOW_STR | |
6537 | BGP_STR | |
6538 | "Address family\n" | |
6539 | "Address Family modifier\n" | |
6540 | "Address Family modifier\n" | |
6541 | "Network in the BGP routing table to display\n") | |
6542 | ||
718e3744 | 6543 | DEFUN (show_ip_bgp_vpnv4_all_route, |
6544 | show_ip_bgp_vpnv4_all_route_cmd, | |
6545 | "show ip bgp vpnv4 all A.B.C.D", | |
6546 | SHOW_STR | |
6547 | IP_STR | |
6548 | BGP_STR | |
6549 | "Display VPNv4 NLRI specific information\n" | |
6550 | "Display information about all VPNv4 NLRIs\n" | |
6551 | "Network in the BGP routing table to display\n") | |
6552 | { | |
6553 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); | |
6554 | } | |
6555 | ||
6556 | DEFUN (show_ip_bgp_vpnv4_rd_route, | |
6557 | show_ip_bgp_vpnv4_rd_route_cmd, | |
6558 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", | |
6559 | SHOW_STR | |
6560 | IP_STR | |
6561 | BGP_STR | |
6562 | "Display VPNv4 NLRI specific information\n" | |
6563 | "Display information for a route distinguisher\n" | |
6564 | "VPN Route Distinguisher\n" | |
6565 | "Network in the BGP routing table to display\n") | |
6566 | { | |
6567 | int ret; | |
6568 | struct prefix_rd prd; | |
6569 | ||
6570 | ret = str2prefix_rd (argv[0], &prd); | |
6571 | if (! ret) | |
6572 | { | |
6573 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6574 | return CMD_WARNING; | |
6575 | } | |
6576 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); | |
6577 | } | |
6578 | ||
6579 | DEFUN (show_ip_bgp_prefix, | |
6580 | show_ip_bgp_prefix_cmd, | |
6581 | "show ip bgp A.B.C.D/M", | |
6582 | SHOW_STR | |
6583 | IP_STR | |
6584 | BGP_STR | |
6585 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6586 | { | |
6587 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6588 | } | |
6589 | ||
6590 | DEFUN (show_ip_bgp_ipv4_prefix, | |
6591 | show_ip_bgp_ipv4_prefix_cmd, | |
6592 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", | |
6593 | SHOW_STR | |
6594 | IP_STR | |
6595 | BGP_STR | |
6596 | "Address family\n" | |
6597 | "Address Family modifier\n" | |
6598 | "Address Family modifier\n" | |
6599 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6600 | { | |
6601 | if (strncmp (argv[0], "m", 1) == 0) | |
6602 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); | |
6603 | ||
6604 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6605 | } | |
6606 | ||
95cbbd2a ML |
6607 | ALIAS (show_ip_bgp_ipv4_prefix, |
6608 | show_bgp_ipv4_safi_prefix_cmd, | |
6609 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", | |
6610 | SHOW_STR | |
6611 | BGP_STR | |
6612 | "Address family\n" | |
6613 | "Address Family modifier\n" | |
6614 | "Address Family modifier\n" | |
6615 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6616 | ||
718e3744 | 6617 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
6618 | show_ip_bgp_vpnv4_all_prefix_cmd, | |
6619 | "show ip bgp vpnv4 all A.B.C.D/M", | |
6620 | SHOW_STR | |
6621 | IP_STR | |
6622 | BGP_STR | |
6623 | "Display VPNv4 NLRI specific information\n" | |
6624 | "Display information about all VPNv4 NLRIs\n" | |
6625 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6626 | { | |
6627 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); | |
6628 | } | |
6629 | ||
6630 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, | |
6631 | show_ip_bgp_vpnv4_rd_prefix_cmd, | |
6632 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", | |
6633 | SHOW_STR | |
6634 | IP_STR | |
6635 | BGP_STR | |
6636 | "Display VPNv4 NLRI specific information\n" | |
6637 | "Display information for a route distinguisher\n" | |
6638 | "VPN Route Distinguisher\n" | |
6639 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6640 | { | |
6641 | int ret; | |
6642 | struct prefix_rd prd; | |
6643 | ||
6644 | ret = str2prefix_rd (argv[0], &prd); | |
6645 | if (! ret) | |
6646 | { | |
6647 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6648 | return CMD_WARNING; | |
6649 | } | |
6650 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); | |
6651 | } | |
6652 | ||
6653 | DEFUN (show_ip_bgp_view, | |
6654 | show_ip_bgp_view_cmd, | |
6655 | "show ip bgp view WORD", | |
6656 | SHOW_STR | |
6657 | IP_STR | |
6658 | BGP_STR | |
6659 | "BGP view\n" | |
6660 | "BGP view name\n") | |
6661 | { | |
bb46e94f | 6662 | struct bgp *bgp; |
6663 | ||
6664 | /* BGP structure lookup. */ | |
6665 | bgp = bgp_lookup_by_name (argv[0]); | |
6666 | if (bgp == NULL) | |
6667 | { | |
6668 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6669 | return CMD_WARNING; | |
6670 | } | |
6671 | ||
5a646650 | 6672 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6673 | } |
6674 | ||
6675 | DEFUN (show_ip_bgp_view_route, | |
6676 | show_ip_bgp_view_route_cmd, | |
6677 | "show ip bgp view WORD A.B.C.D", | |
6678 | SHOW_STR | |
6679 | IP_STR | |
6680 | BGP_STR | |
6681 | "BGP view\n" | |
6682 | "BGP view name\n" | |
6683 | "Network in the BGP routing table to display\n") | |
6684 | { | |
6685 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6686 | } | |
6687 | ||
6688 | DEFUN (show_ip_bgp_view_prefix, | |
6689 | show_ip_bgp_view_prefix_cmd, | |
6690 | "show ip bgp view WORD A.B.C.D/M", | |
6691 | SHOW_STR | |
6692 | IP_STR | |
6693 | BGP_STR | |
6694 | "BGP view\n" | |
6695 | "BGP view name\n" | |
6696 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6697 | { | |
6698 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6699 | } | |
6700 | ||
6701 | #ifdef HAVE_IPV6 | |
6702 | DEFUN (show_bgp, | |
6703 | show_bgp_cmd, | |
6704 | "show bgp", | |
6705 | SHOW_STR | |
6706 | BGP_STR) | |
6707 | { | |
5a646650 | 6708 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6709 | NULL); | |
718e3744 | 6710 | } |
6711 | ||
6712 | ALIAS (show_bgp, | |
6713 | show_bgp_ipv6_cmd, | |
6714 | "show bgp ipv6", | |
6715 | SHOW_STR | |
6716 | BGP_STR | |
6717 | "Address family\n") | |
6718 | ||
95cbbd2a ML |
6719 | DEFUN (show_bgp_ipv6_safi, |
6720 | show_bgp_ipv6_safi_cmd, | |
6721 | "show bgp ipv6 (unicast|multicast)", | |
6722 | SHOW_STR | |
6723 | BGP_STR | |
6724 | "Address family\n" | |
6725 | "Address Family modifier\n" | |
6726 | "Address Family modifier\n") | |
6727 | { | |
6728 | if (strncmp (argv[0], "m", 1) == 0) | |
6729 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, | |
6730 | NULL); | |
6731 | ||
6732 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); | |
6733 | } | |
6734 | ||
718e3744 | 6735 | /* old command */ |
6736 | DEFUN (show_ipv6_bgp, | |
6737 | show_ipv6_bgp_cmd, | |
6738 | "show ipv6 bgp", | |
6739 | SHOW_STR | |
6740 | IP_STR | |
6741 | BGP_STR) | |
6742 | { | |
5a646650 | 6743 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6744 | NULL); | |
718e3744 | 6745 | } |
6746 | ||
6747 | DEFUN (show_bgp_route, | |
6748 | show_bgp_route_cmd, | |
6749 | "show bgp X:X::X:X", | |
6750 | SHOW_STR | |
6751 | BGP_STR | |
6752 | "Network in the BGP routing table to display\n") | |
6753 | { | |
6754 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6755 | } | |
6756 | ||
6757 | ALIAS (show_bgp_route, | |
6758 | show_bgp_ipv6_route_cmd, | |
6759 | "show bgp ipv6 X:X::X:X", | |
6760 | SHOW_STR | |
6761 | BGP_STR | |
6762 | "Address family\n" | |
6763 | "Network in the BGP routing table to display\n") | |
6764 | ||
95cbbd2a ML |
6765 | DEFUN (show_bgp_ipv6_safi_route, |
6766 | show_bgp_ipv6_safi_route_cmd, | |
6767 | "show bgp ipv6 (unicast|multicast) X:X::X:X", | |
6768 | SHOW_STR | |
6769 | BGP_STR | |
6770 | "Address family\n" | |
6771 | "Address Family modifier\n" | |
6772 | "Address Family modifier\n" | |
6773 | "Network in the BGP routing table to display\n") | |
6774 | { | |
6775 | if (strncmp (argv[0], "m", 1) == 0) | |
6776 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); | |
6777 | ||
6778 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6779 | } | |
6780 | ||
718e3744 | 6781 | /* old command */ |
6782 | DEFUN (show_ipv6_bgp_route, | |
6783 | show_ipv6_bgp_route_cmd, | |
6784 | "show ipv6 bgp X:X::X:X", | |
6785 | SHOW_STR | |
6786 | IP_STR | |
6787 | BGP_STR | |
6788 | "Network in the BGP routing table to display\n") | |
6789 | { | |
6790 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6791 | } | |
6792 | ||
6793 | DEFUN (show_bgp_prefix, | |
6794 | show_bgp_prefix_cmd, | |
6795 | "show bgp X:X::X:X/M", | |
6796 | SHOW_STR | |
6797 | BGP_STR | |
6798 | "IPv6 prefix <network>/<length>\n") | |
6799 | { | |
6800 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6801 | } | |
6802 | ||
6803 | ALIAS (show_bgp_prefix, | |
6804 | show_bgp_ipv6_prefix_cmd, | |
6805 | "show bgp ipv6 X:X::X:X/M", | |
6806 | SHOW_STR | |
6807 | BGP_STR | |
6808 | "Address family\n" | |
6809 | "IPv6 prefix <network>/<length>\n") | |
6810 | ||
95cbbd2a ML |
6811 | DEFUN (show_bgp_ipv6_safi_prefix, |
6812 | show_bgp_ipv6_safi_prefix_cmd, | |
6813 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", | |
6814 | SHOW_STR | |
6815 | BGP_STR | |
6816 | "Address family\n" | |
6817 | "Address Family modifier\n" | |
6818 | "Address Family modifier\n" | |
6819 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6820 | { | |
6821 | if (strncmp (argv[0], "m", 1) == 0) | |
6822 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); | |
6823 | ||
6824 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6825 | } | |
6826 | ||
718e3744 | 6827 | /* old command */ |
6828 | DEFUN (show_ipv6_bgp_prefix, | |
6829 | show_ipv6_bgp_prefix_cmd, | |
6830 | "show ipv6 bgp X:X::X:X/M", | |
6831 | SHOW_STR | |
6832 | IP_STR | |
6833 | BGP_STR | |
6834 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6835 | { | |
6836 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6837 | } | |
6838 | ||
bb46e94f | 6839 | DEFUN (show_bgp_view, |
6840 | show_bgp_view_cmd, | |
6841 | "show bgp view WORD", | |
6842 | SHOW_STR | |
6843 | BGP_STR | |
6844 | "BGP view\n" | |
6845 | "View name\n") | |
6846 | { | |
6847 | struct bgp *bgp; | |
6848 | ||
6849 | /* BGP structure lookup. */ | |
6850 | bgp = bgp_lookup_by_name (argv[0]); | |
6851 | if (bgp == NULL) | |
6852 | { | |
6853 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6854 | return CMD_WARNING; | |
6855 | } | |
6856 | ||
5a646650 | 6857 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
bb46e94f | 6858 | } |
6859 | ||
6860 | ALIAS (show_bgp_view, | |
6861 | show_bgp_view_ipv6_cmd, | |
6862 | "show bgp view WORD ipv6", | |
6863 | SHOW_STR | |
6864 | BGP_STR | |
6865 | "BGP view\n" | |
6866 | "View name\n" | |
6867 | "Address family\n") | |
6868 | ||
6869 | DEFUN (show_bgp_view_route, | |
6870 | show_bgp_view_route_cmd, | |
6871 | "show bgp view WORD X:X::X:X", | |
6872 | SHOW_STR | |
6873 | BGP_STR | |
6874 | "BGP view\n" | |
6875 | "View name\n" | |
6876 | "Network in the BGP routing table to display\n") | |
6877 | { | |
6878 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6879 | } | |
6880 | ||
6881 | ALIAS (show_bgp_view_route, | |
6882 | show_bgp_view_ipv6_route_cmd, | |
6883 | "show bgp view WORD ipv6 X:X::X:X", | |
6884 | SHOW_STR | |
6885 | BGP_STR | |
6886 | "BGP view\n" | |
6887 | "View name\n" | |
6888 | "Address family\n" | |
6889 | "Network in the BGP routing table to display\n") | |
6890 | ||
6891 | DEFUN (show_bgp_view_prefix, | |
6892 | show_bgp_view_prefix_cmd, | |
6893 | "show bgp view WORD X:X::X:X/M", | |
6894 | SHOW_STR | |
6895 | BGP_STR | |
6896 | "BGP view\n" | |
6897 | "View name\n" | |
6898 | "IPv6 prefix <network>/<length>\n") | |
6899 | { | |
6900 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6901 | } | |
6902 | ||
6903 | ALIAS (show_bgp_view_prefix, | |
6904 | show_bgp_view_ipv6_prefix_cmd, | |
6905 | "show bgp view WORD ipv6 X:X::X:X/M", | |
6906 | SHOW_STR | |
6907 | BGP_STR | |
6908 | "BGP view\n" | |
6909 | "View name\n" | |
6910 | "Address family\n" | |
6911 | "IPv6 prefix <network>/<length>\n") | |
6912 | ||
718e3744 | 6913 | /* old command */ |
6914 | DEFUN (show_ipv6_mbgp, | |
6915 | show_ipv6_mbgp_cmd, | |
6916 | "show ipv6 mbgp", | |
6917 | SHOW_STR | |
6918 | IP_STR | |
6919 | MBGP_STR) | |
6920 | { | |
5a646650 | 6921 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
6922 | NULL); | |
718e3744 | 6923 | } |
6924 | ||
6925 | /* old command */ | |
6926 | DEFUN (show_ipv6_mbgp_route, | |
6927 | show_ipv6_mbgp_route_cmd, | |
6928 | "show ipv6 mbgp X:X::X:X", | |
6929 | SHOW_STR | |
6930 | IP_STR | |
6931 | MBGP_STR | |
6932 | "Network in the MBGP routing table to display\n") | |
6933 | { | |
6934 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); | |
6935 | } | |
6936 | ||
6937 | /* old command */ | |
6938 | DEFUN (show_ipv6_mbgp_prefix, | |
6939 | show_ipv6_mbgp_prefix_cmd, | |
6940 | "show ipv6 mbgp X:X::X:X/M", | |
6941 | SHOW_STR | |
6942 | IP_STR | |
6943 | MBGP_STR | |
6944 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6945 | { | |
6946 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); | |
6947 | } | |
6948 | #endif | |
6949 | \f | |
718e3744 | 6950 | |
94f2b392 | 6951 | static int |
fd79ac91 | 6952 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
718e3744 | 6953 | safi_t safi, enum bgp_show_type type) |
6954 | { | |
6955 | int i; | |
6956 | struct buffer *b; | |
6957 | char *regstr; | |
6958 | int first; | |
6959 | regex_t *regex; | |
5a646650 | 6960 | int rc; |
718e3744 | 6961 | |
6962 | first = 0; | |
6963 | b = buffer_new (1024); | |
6964 | for (i = 0; i < argc; i++) | |
6965 | { | |
6966 | if (first) | |
6967 | buffer_putc (b, ' '); | |
6968 | else | |
6969 | { | |
6970 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
6971 | continue; | |
6972 | first = 1; | |
6973 | } | |
6974 | ||
6975 | buffer_putstr (b, argv[i]); | |
6976 | } | |
6977 | buffer_putc (b, '\0'); | |
6978 | ||
6979 | regstr = buffer_getstr (b); | |
6980 | buffer_free (b); | |
6981 | ||
6982 | regex = bgp_regcomp (regstr); | |
3b8b1855 | 6983 | XFREE(MTYPE_TMP, regstr); |
718e3744 | 6984 | if (! regex) |
6985 | { | |
6986 | vty_out (vty, "Can't compile regexp %s%s", argv[0], | |
6987 | VTY_NEWLINE); | |
6988 | return CMD_WARNING; | |
6989 | } | |
6990 | ||
5a646650 | 6991 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
6992 | bgp_regex_free (regex); | |
6993 | return rc; | |
718e3744 | 6994 | } |
6995 | ||
6996 | DEFUN (show_ip_bgp_regexp, | |
6997 | show_ip_bgp_regexp_cmd, | |
6998 | "show ip bgp regexp .LINE", | |
6999 | SHOW_STR | |
7000 | IP_STR | |
7001 | BGP_STR | |
7002 | "Display routes matching the AS path regular expression\n" | |
7003 | "A regular-expression to match the BGP AS paths\n") | |
7004 | { | |
7005 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7006 | bgp_show_type_regexp); | |
7007 | } | |
7008 | ||
7009 | DEFUN (show_ip_bgp_flap_regexp, | |
7010 | show_ip_bgp_flap_regexp_cmd, | |
7011 | "show ip bgp flap-statistics regexp .LINE", | |
7012 | SHOW_STR | |
7013 | IP_STR | |
7014 | BGP_STR | |
7015 | "Display flap statistics of routes\n" | |
7016 | "Display routes matching the AS path regular expression\n" | |
7017 | "A regular-expression to match the BGP AS paths\n") | |
7018 | { | |
7019 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7020 | bgp_show_type_flap_regexp); | |
7021 | } | |
7022 | ||
7023 | DEFUN (show_ip_bgp_ipv4_regexp, | |
7024 | show_ip_bgp_ipv4_regexp_cmd, | |
7025 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", | |
7026 | SHOW_STR | |
7027 | IP_STR | |
7028 | BGP_STR | |
7029 | "Address family\n" | |
7030 | "Address Family modifier\n" | |
7031 | "Address Family modifier\n" | |
7032 | "Display routes matching the AS path regular expression\n" | |
7033 | "A regular-expression to match the BGP AS paths\n") | |
7034 | { | |
7035 | if (strncmp (argv[0], "m", 1) == 0) | |
7036 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, | |
7037 | bgp_show_type_regexp); | |
7038 | ||
7039 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7040 | bgp_show_type_regexp); | |
7041 | } | |
7042 | ||
7043 | #ifdef HAVE_IPV6 | |
7044 | DEFUN (show_bgp_regexp, | |
7045 | show_bgp_regexp_cmd, | |
7046 | "show bgp regexp .LINE", | |
7047 | SHOW_STR | |
7048 | BGP_STR | |
7049 | "Display routes matching the AS path regular expression\n" | |
7050 | "A regular-expression to match the BGP AS paths\n") | |
7051 | { | |
7052 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7053 | bgp_show_type_regexp); | |
7054 | } | |
7055 | ||
7056 | ALIAS (show_bgp_regexp, | |
7057 | show_bgp_ipv6_regexp_cmd, | |
7058 | "show bgp ipv6 regexp .LINE", | |
7059 | SHOW_STR | |
7060 | BGP_STR | |
7061 | "Address family\n" | |
7062 | "Display routes matching the AS path regular expression\n" | |
7063 | "A regular-expression to match the BGP AS paths\n") | |
7064 | ||
7065 | /* old command */ | |
7066 | DEFUN (show_ipv6_bgp_regexp, | |
7067 | show_ipv6_bgp_regexp_cmd, | |
7068 | "show ipv6 bgp regexp .LINE", | |
7069 | SHOW_STR | |
7070 | IP_STR | |
7071 | BGP_STR | |
7072 | "Display routes matching the AS path regular expression\n" | |
7073 | "A regular-expression to match the BGP AS paths\n") | |
7074 | { | |
7075 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7076 | bgp_show_type_regexp); | |
7077 | } | |
7078 | ||
7079 | /* old command */ | |
7080 | DEFUN (show_ipv6_mbgp_regexp, | |
7081 | show_ipv6_mbgp_regexp_cmd, | |
7082 | "show ipv6 mbgp regexp .LINE", | |
7083 | SHOW_STR | |
7084 | IP_STR | |
7085 | BGP_STR | |
7086 | "Display routes matching the AS path regular expression\n" | |
7087 | "A regular-expression to match the MBGP AS paths\n") | |
7088 | { | |
7089 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, | |
7090 | bgp_show_type_regexp); | |
7091 | } | |
7092 | #endif /* HAVE_IPV6 */ | |
7093 | \f | |
94f2b392 | 7094 | static int |
fd79ac91 | 7095 | bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi, |
718e3744 | 7096 | safi_t safi, enum bgp_show_type type) |
7097 | { | |
7098 | struct prefix_list *plist; | |
7099 | ||
7100 | plist = prefix_list_lookup (afi, prefix_list_str); | |
7101 | if (plist == NULL) | |
7102 | { | |
7103 | vty_out (vty, "%% %s is not a valid prefix-list name%s", | |
7104 | prefix_list_str, VTY_NEWLINE); | |
7105 | return CMD_WARNING; | |
7106 | } | |
7107 | ||
5a646650 | 7108 | return bgp_show (vty, NULL, afi, safi, type, plist); |
718e3744 | 7109 | } |
7110 | ||
7111 | DEFUN (show_ip_bgp_prefix_list, | |
7112 | show_ip_bgp_prefix_list_cmd, | |
7113 | "show ip bgp prefix-list WORD", | |
7114 | SHOW_STR | |
7115 | IP_STR | |
7116 | BGP_STR | |
7117 | "Display routes conforming to the prefix-list\n" | |
7118 | "IP prefix-list name\n") | |
7119 | { | |
7120 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7121 | bgp_show_type_prefix_list); | |
7122 | } | |
7123 | ||
7124 | DEFUN (show_ip_bgp_flap_prefix_list, | |
7125 | show_ip_bgp_flap_prefix_list_cmd, | |
7126 | "show ip bgp flap-statistics prefix-list WORD", | |
7127 | SHOW_STR | |
7128 | IP_STR | |
7129 | BGP_STR | |
7130 | "Display flap statistics of routes\n" | |
7131 | "Display routes conforming to the prefix-list\n" | |
7132 | "IP prefix-list name\n") | |
7133 | { | |
7134 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7135 | bgp_show_type_flap_prefix_list); | |
7136 | } | |
7137 | ||
7138 | DEFUN (show_ip_bgp_ipv4_prefix_list, | |
7139 | show_ip_bgp_ipv4_prefix_list_cmd, | |
7140 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", | |
7141 | SHOW_STR | |
7142 | IP_STR | |
7143 | BGP_STR | |
7144 | "Address family\n" | |
7145 | "Address Family modifier\n" | |
7146 | "Address Family modifier\n" | |
7147 | "Display routes conforming to the prefix-list\n" | |
7148 | "IP prefix-list name\n") | |
7149 | { | |
7150 | if (strncmp (argv[0], "m", 1) == 0) | |
7151 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7152 | bgp_show_type_prefix_list); | |
7153 | ||
7154 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7155 | bgp_show_type_prefix_list); | |
7156 | } | |
7157 | ||
7158 | #ifdef HAVE_IPV6 | |
7159 | DEFUN (show_bgp_prefix_list, | |
7160 | show_bgp_prefix_list_cmd, | |
7161 | "show bgp prefix-list WORD", | |
7162 | SHOW_STR | |
7163 | BGP_STR | |
7164 | "Display routes conforming to the prefix-list\n" | |
7165 | "IPv6 prefix-list name\n") | |
7166 | { | |
7167 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7168 | bgp_show_type_prefix_list); | |
7169 | } | |
7170 | ||
7171 | ALIAS (show_bgp_prefix_list, | |
7172 | show_bgp_ipv6_prefix_list_cmd, | |
7173 | "show bgp ipv6 prefix-list WORD", | |
7174 | SHOW_STR | |
7175 | BGP_STR | |
7176 | "Address family\n" | |
7177 | "Display routes conforming to the prefix-list\n" | |
7178 | "IPv6 prefix-list name\n") | |
7179 | ||
7180 | /* old command */ | |
7181 | DEFUN (show_ipv6_bgp_prefix_list, | |
7182 | show_ipv6_bgp_prefix_list_cmd, | |
7183 | "show ipv6 bgp prefix-list WORD", | |
7184 | SHOW_STR | |
7185 | IPV6_STR | |
7186 | BGP_STR | |
7187 | "Display routes matching the prefix-list\n" | |
7188 | "IPv6 prefix-list name\n") | |
7189 | { | |
7190 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7191 | bgp_show_type_prefix_list); | |
7192 | } | |
7193 | ||
7194 | /* old command */ | |
7195 | DEFUN (show_ipv6_mbgp_prefix_list, | |
7196 | show_ipv6_mbgp_prefix_list_cmd, | |
7197 | "show ipv6 mbgp prefix-list WORD", | |
7198 | SHOW_STR | |
7199 | IPV6_STR | |
7200 | MBGP_STR | |
7201 | "Display routes matching the prefix-list\n" | |
7202 | "IPv6 prefix-list name\n") | |
7203 | { | |
7204 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7205 | bgp_show_type_prefix_list); | |
7206 | } | |
7207 | #endif /* HAVE_IPV6 */ | |
7208 | \f | |
94f2b392 | 7209 | static int |
fd79ac91 | 7210 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
718e3744 | 7211 | safi_t safi, enum bgp_show_type type) |
7212 | { | |
7213 | struct as_list *as_list; | |
7214 | ||
7215 | as_list = as_list_lookup (filter); | |
7216 | if (as_list == NULL) | |
7217 | { | |
7218 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); | |
7219 | return CMD_WARNING; | |
7220 | } | |
7221 | ||
5a646650 | 7222 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
718e3744 | 7223 | } |
7224 | ||
7225 | DEFUN (show_ip_bgp_filter_list, | |
7226 | show_ip_bgp_filter_list_cmd, | |
7227 | "show ip bgp filter-list WORD", | |
7228 | SHOW_STR | |
7229 | IP_STR | |
7230 | BGP_STR | |
7231 | "Display routes conforming to the filter-list\n" | |
7232 | "Regular expression access list name\n") | |
7233 | { | |
7234 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7235 | bgp_show_type_filter_list); | |
7236 | } | |
7237 | ||
7238 | DEFUN (show_ip_bgp_flap_filter_list, | |
7239 | show_ip_bgp_flap_filter_list_cmd, | |
7240 | "show ip bgp flap-statistics filter-list WORD", | |
7241 | SHOW_STR | |
7242 | IP_STR | |
7243 | BGP_STR | |
7244 | "Display flap statistics of routes\n" | |
7245 | "Display routes conforming to the filter-list\n" | |
7246 | "Regular expression access list name\n") | |
7247 | { | |
7248 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7249 | bgp_show_type_flap_filter_list); | |
7250 | } | |
7251 | ||
7252 | DEFUN (show_ip_bgp_ipv4_filter_list, | |
7253 | show_ip_bgp_ipv4_filter_list_cmd, | |
7254 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", | |
7255 | SHOW_STR | |
7256 | IP_STR | |
7257 | BGP_STR | |
7258 | "Address family\n" | |
7259 | "Address Family modifier\n" | |
7260 | "Address Family modifier\n" | |
7261 | "Display routes conforming to the filter-list\n" | |
7262 | "Regular expression access list name\n") | |
7263 | { | |
7264 | if (strncmp (argv[0], "m", 1) == 0) | |
7265 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7266 | bgp_show_type_filter_list); | |
7267 | ||
7268 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7269 | bgp_show_type_filter_list); | |
7270 | } | |
7271 | ||
7272 | #ifdef HAVE_IPV6 | |
7273 | DEFUN (show_bgp_filter_list, | |
7274 | show_bgp_filter_list_cmd, | |
7275 | "show bgp filter-list WORD", | |
7276 | SHOW_STR | |
7277 | BGP_STR | |
7278 | "Display routes conforming to the filter-list\n" | |
7279 | "Regular expression access list name\n") | |
7280 | { | |
7281 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7282 | bgp_show_type_filter_list); | |
7283 | } | |
7284 | ||
7285 | ALIAS (show_bgp_filter_list, | |
7286 | show_bgp_ipv6_filter_list_cmd, | |
7287 | "show bgp ipv6 filter-list WORD", | |
7288 | SHOW_STR | |
7289 | BGP_STR | |
7290 | "Address family\n" | |
7291 | "Display routes conforming to the filter-list\n" | |
7292 | "Regular expression access list name\n") | |
7293 | ||
7294 | /* old command */ | |
7295 | DEFUN (show_ipv6_bgp_filter_list, | |
7296 | show_ipv6_bgp_filter_list_cmd, | |
7297 | "show ipv6 bgp filter-list WORD", | |
7298 | SHOW_STR | |
7299 | IPV6_STR | |
7300 | BGP_STR | |
7301 | "Display routes conforming to the filter-list\n" | |
7302 | "Regular expression access list name\n") | |
7303 | { | |
7304 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7305 | bgp_show_type_filter_list); | |
7306 | } | |
7307 | ||
7308 | /* old command */ | |
7309 | DEFUN (show_ipv6_mbgp_filter_list, | |
7310 | show_ipv6_mbgp_filter_list_cmd, | |
7311 | "show ipv6 mbgp filter-list WORD", | |
7312 | SHOW_STR | |
7313 | IPV6_STR | |
7314 | MBGP_STR | |
7315 | "Display routes conforming to the filter-list\n" | |
7316 | "Regular expression access list name\n") | |
7317 | { | |
7318 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7319 | bgp_show_type_filter_list); | |
7320 | } | |
7321 | #endif /* HAVE_IPV6 */ | |
7322 | \f | |
94f2b392 | 7323 | static int |
fd79ac91 | 7324 | bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi, |
718e3744 | 7325 | safi_t safi, enum bgp_show_type type) |
7326 | { | |
7327 | struct route_map *rmap; | |
7328 | ||
7329 | rmap = route_map_lookup_by_name (rmap_str); | |
7330 | if (! rmap) | |
7331 | { | |
7332 | vty_out (vty, "%% %s is not a valid route-map name%s", | |
7333 | rmap_str, VTY_NEWLINE); | |
7334 | return CMD_WARNING; | |
7335 | } | |
7336 | ||
5a646650 | 7337 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
718e3744 | 7338 | } |
7339 | ||
7340 | DEFUN (show_ip_bgp_route_map, | |
7341 | show_ip_bgp_route_map_cmd, | |
7342 | "show ip bgp route-map WORD", | |
7343 | SHOW_STR | |
7344 | IP_STR | |
7345 | BGP_STR | |
7346 | "Display routes matching the route-map\n" | |
7347 | "A route-map to match on\n") | |
7348 | { | |
7349 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7350 | bgp_show_type_route_map); | |
7351 | } | |
7352 | ||
7353 | DEFUN (show_ip_bgp_flap_route_map, | |
7354 | show_ip_bgp_flap_route_map_cmd, | |
7355 | "show ip bgp flap-statistics route-map WORD", | |
7356 | SHOW_STR | |
7357 | IP_STR | |
7358 | BGP_STR | |
7359 | "Display flap statistics of routes\n" | |
7360 | "Display routes matching the route-map\n" | |
7361 | "A route-map to match on\n") | |
7362 | { | |
7363 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7364 | bgp_show_type_flap_route_map); | |
7365 | } | |
7366 | ||
7367 | DEFUN (show_ip_bgp_ipv4_route_map, | |
7368 | show_ip_bgp_ipv4_route_map_cmd, | |
7369 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", | |
7370 | SHOW_STR | |
7371 | IP_STR | |
7372 | BGP_STR | |
7373 | "Address family\n" | |
7374 | "Address Family modifier\n" | |
7375 | "Address Family modifier\n" | |
7376 | "Display routes matching the route-map\n" | |
7377 | "A route-map to match on\n") | |
7378 | { | |
7379 | if (strncmp (argv[0], "m", 1) == 0) | |
7380 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7381 | bgp_show_type_route_map); | |
7382 | ||
7383 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7384 | bgp_show_type_route_map); | |
7385 | } | |
7386 | ||
7387 | DEFUN (show_bgp_route_map, | |
7388 | show_bgp_route_map_cmd, | |
7389 | "show bgp route-map WORD", | |
7390 | SHOW_STR | |
7391 | BGP_STR | |
7392 | "Display routes matching the route-map\n" | |
7393 | "A route-map to match on\n") | |
7394 | { | |
7395 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7396 | bgp_show_type_route_map); | |
7397 | } | |
7398 | ||
7399 | ALIAS (show_bgp_route_map, | |
7400 | show_bgp_ipv6_route_map_cmd, | |
7401 | "show bgp ipv6 route-map WORD", | |
7402 | SHOW_STR | |
7403 | BGP_STR | |
7404 | "Address family\n" | |
7405 | "Display routes matching the route-map\n" | |
7406 | "A route-map to match on\n") | |
7407 | \f | |
7408 | DEFUN (show_ip_bgp_cidr_only, | |
7409 | show_ip_bgp_cidr_only_cmd, | |
7410 | "show ip bgp cidr-only", | |
7411 | SHOW_STR | |
7412 | IP_STR | |
7413 | BGP_STR | |
7414 | "Display only routes with non-natural netmasks\n") | |
7415 | { | |
7416 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7417 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7418 | } |
7419 | ||
7420 | DEFUN (show_ip_bgp_flap_cidr_only, | |
7421 | show_ip_bgp_flap_cidr_only_cmd, | |
7422 | "show ip bgp flap-statistics cidr-only", | |
7423 | SHOW_STR | |
7424 | IP_STR | |
7425 | BGP_STR | |
7426 | "Display flap statistics of routes\n" | |
7427 | "Display only routes with non-natural netmasks\n") | |
7428 | { | |
7429 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7430 | bgp_show_type_flap_cidr_only, NULL); |
718e3744 | 7431 | } |
7432 | ||
7433 | DEFUN (show_ip_bgp_ipv4_cidr_only, | |
7434 | show_ip_bgp_ipv4_cidr_only_cmd, | |
7435 | "show ip bgp ipv4 (unicast|multicast) cidr-only", | |
7436 | SHOW_STR | |
7437 | IP_STR | |
7438 | BGP_STR | |
7439 | "Address family\n" | |
7440 | "Address Family modifier\n" | |
7441 | "Address Family modifier\n" | |
7442 | "Display only routes with non-natural netmasks\n") | |
7443 | { | |
7444 | if (strncmp (argv[0], "m", 1) == 0) | |
7445 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7446 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7447 | |
7448 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7449 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7450 | } |
7451 | \f | |
7452 | DEFUN (show_ip_bgp_community_all, | |
7453 | show_ip_bgp_community_all_cmd, | |
7454 | "show ip bgp community", | |
7455 | SHOW_STR | |
7456 | IP_STR | |
7457 | BGP_STR | |
7458 | "Display routes matching the communities\n") | |
7459 | { | |
7460 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7461 | bgp_show_type_community_all, NULL); |
718e3744 | 7462 | } |
7463 | ||
7464 | DEFUN (show_ip_bgp_ipv4_community_all, | |
7465 | show_ip_bgp_ipv4_community_all_cmd, | |
7466 | "show ip bgp ipv4 (unicast|multicast) community", | |
7467 | SHOW_STR | |
7468 | IP_STR | |
7469 | BGP_STR | |
7470 | "Address family\n" | |
7471 | "Address Family modifier\n" | |
7472 | "Address Family modifier\n" | |
7473 | "Display routes matching the communities\n") | |
7474 | { | |
7475 | if (strncmp (argv[0], "m", 1) == 0) | |
7476 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7477 | bgp_show_type_community_all, NULL); |
718e3744 | 7478 | |
7479 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7480 | bgp_show_type_community_all, NULL); |
718e3744 | 7481 | } |
7482 | ||
7483 | #ifdef HAVE_IPV6 | |
7484 | DEFUN (show_bgp_community_all, | |
7485 | show_bgp_community_all_cmd, | |
7486 | "show bgp community", | |
7487 | SHOW_STR | |
7488 | BGP_STR | |
7489 | "Display routes matching the communities\n") | |
7490 | { | |
7491 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
5a646650 | 7492 | bgp_show_type_community_all, NULL); |
718e3744 | 7493 | } |
7494 | ||
7495 | ALIAS (show_bgp_community_all, | |
7496 | show_bgp_ipv6_community_all_cmd, | |
7497 | "show bgp ipv6 community", | |
7498 | SHOW_STR | |
7499 | BGP_STR | |
7500 | "Address family\n" | |
7501 | "Display routes matching the communities\n") | |
7502 | ||
7503 | /* old command */ | |
7504 | DEFUN (show_ipv6_bgp_community_all, | |
7505 | show_ipv6_bgp_community_all_cmd, | |
7506 | "show ipv6 bgp community", | |
7507 | SHOW_STR | |
7508 | IPV6_STR | |
7509 | BGP_STR | |
7510 | "Display routes matching the communities\n") | |
7511 | { | |
7512 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
5a646650 | 7513 | bgp_show_type_community_all, NULL); |
718e3744 | 7514 | } |
7515 | ||
7516 | /* old command */ | |
7517 | DEFUN (show_ipv6_mbgp_community_all, | |
7518 | show_ipv6_mbgp_community_all_cmd, | |
7519 | "show ipv6 mbgp community", | |
7520 | SHOW_STR | |
7521 | IPV6_STR | |
7522 | MBGP_STR | |
7523 | "Display routes matching the communities\n") | |
7524 | { | |
7525 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, | |
5a646650 | 7526 | bgp_show_type_community_all, NULL); |
718e3744 | 7527 | } |
7528 | #endif /* HAVE_IPV6 */ | |
7529 | \f | |
94f2b392 | 7530 | static int |
95cbbd2a ML |
7531 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
7532 | const char **argv, int exact, afi_t afi, safi_t safi) | |
718e3744 | 7533 | { |
7534 | struct community *com; | |
7535 | struct buffer *b; | |
95cbbd2a | 7536 | struct bgp *bgp; |
718e3744 | 7537 | int i; |
7538 | char *str; | |
7539 | int first = 0; | |
7540 | ||
95cbbd2a ML |
7541 | /* BGP structure lookup */ |
7542 | if (view_name) | |
7543 | { | |
7544 | bgp = bgp_lookup_by_name (view_name); | |
7545 | if (bgp == NULL) | |
7546 | { | |
7547 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
7548 | return CMD_WARNING; | |
7549 | } | |
7550 | } | |
7551 | else | |
7552 | { | |
7553 | bgp = bgp_get_default (); | |
7554 | if (bgp == NULL) | |
7555 | { | |
7556 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
7557 | return CMD_WARNING; | |
7558 | } | |
7559 | } | |
7560 | ||
718e3744 | 7561 | b = buffer_new (1024); |
7562 | for (i = 0; i < argc; i++) | |
7563 | { | |
7564 | if (first) | |
7565 | buffer_putc (b, ' '); | |
7566 | else | |
7567 | { | |
7568 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
7569 | continue; | |
7570 | first = 1; | |
7571 | } | |
7572 | ||
7573 | buffer_putstr (b, argv[i]); | |
7574 | } | |
7575 | buffer_putc (b, '\0'); | |
7576 | ||
7577 | str = buffer_getstr (b); | |
7578 | buffer_free (b); | |
7579 | ||
7580 | com = community_str2com (str); | |
3b8b1855 | 7581 | XFREE (MTYPE_TMP, str); |
718e3744 | 7582 | if (! com) |
7583 | { | |
7584 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); | |
7585 | return CMD_WARNING; | |
7586 | } | |
7587 | ||
95cbbd2a | 7588 | return bgp_show (vty, bgp, afi, safi, |
5a646650 | 7589 | (exact ? bgp_show_type_community_exact : |
7590 | bgp_show_type_community), com); | |
718e3744 | 7591 | } |
7592 | ||
7593 | DEFUN (show_ip_bgp_community, | |
7594 | show_ip_bgp_community_cmd, | |
7595 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
7596 | SHOW_STR | |
7597 | IP_STR | |
7598 | BGP_STR | |
7599 | "Display routes matching the communities\n" | |
7600 | "community number\n" | |
7601 | "Do not send outside local AS (well-known community)\n" | |
7602 | "Do not advertise to any peer (well-known community)\n" | |
7603 | "Do not export to next AS (well-known community)\n") | |
7604 | { | |
95cbbd2a | 7605 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 7606 | } |
7607 | ||
7608 | ALIAS (show_ip_bgp_community, | |
7609 | show_ip_bgp_community2_cmd, | |
7610 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7611 | SHOW_STR | |
7612 | IP_STR | |
7613 | BGP_STR | |
7614 | "Display routes matching the communities\n" | |
7615 | "community number\n" | |
7616 | "Do not send outside local AS (well-known community)\n" | |
7617 | "Do not advertise to any peer (well-known community)\n" | |
7618 | "Do not export to next AS (well-known community)\n" | |
7619 | "community number\n" | |
7620 | "Do not send outside local AS (well-known community)\n" | |
7621 | "Do not advertise to any peer (well-known community)\n" | |
7622 | "Do not export to next AS (well-known community)\n") | |
7623 | ||
7624 | ALIAS (show_ip_bgp_community, | |
7625 | show_ip_bgp_community3_cmd, | |
7626 | "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)", | |
7627 | SHOW_STR | |
7628 | IP_STR | |
7629 | BGP_STR | |
7630 | "Display routes matching the communities\n" | |
7631 | "community number\n" | |
7632 | "Do not send outside local AS (well-known community)\n" | |
7633 | "Do not advertise to any peer (well-known community)\n" | |
7634 | "Do not export to next AS (well-known community)\n" | |
7635 | "community number\n" | |
7636 | "Do not send outside local AS (well-known community)\n" | |
7637 | "Do not advertise to any peer (well-known community)\n" | |
7638 | "Do not export to next AS (well-known community)\n" | |
7639 | "community number\n" | |
7640 | "Do not send outside local AS (well-known community)\n" | |
7641 | "Do not advertise to any peer (well-known community)\n" | |
7642 | "Do not export to next AS (well-known community)\n") | |
7643 | ||
7644 | ALIAS (show_ip_bgp_community, | |
7645 | show_ip_bgp_community4_cmd, | |
7646 | "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)", | |
7647 | SHOW_STR | |
7648 | IP_STR | |
7649 | BGP_STR | |
7650 | "Display routes matching the communities\n" | |
7651 | "community number\n" | |
7652 | "Do not send outside local AS (well-known community)\n" | |
7653 | "Do not advertise to any peer (well-known community)\n" | |
7654 | "Do not export to next AS (well-known community)\n" | |
7655 | "community number\n" | |
7656 | "Do not send outside local AS (well-known community)\n" | |
7657 | "Do not advertise to any peer (well-known community)\n" | |
7658 | "Do not export to next AS (well-known community)\n" | |
7659 | "community number\n" | |
7660 | "Do not send outside local AS (well-known community)\n" | |
7661 | "Do not advertise to any peer (well-known community)\n" | |
7662 | "Do not export to next AS (well-known community)\n" | |
7663 | "community number\n" | |
7664 | "Do not send outside local AS (well-known community)\n" | |
7665 | "Do not advertise to any peer (well-known community)\n" | |
7666 | "Do not export to next AS (well-known community)\n") | |
7667 | ||
7668 | DEFUN (show_ip_bgp_ipv4_community, | |
7669 | show_ip_bgp_ipv4_community_cmd, | |
7670 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7671 | SHOW_STR | |
7672 | IP_STR | |
7673 | BGP_STR | |
7674 | "Address family\n" | |
7675 | "Address Family modifier\n" | |
7676 | "Address Family modifier\n" | |
7677 | "Display routes matching the communities\n" | |
7678 | "community number\n" | |
7679 | "Do not send outside local AS (well-known community)\n" | |
7680 | "Do not advertise to any peer (well-known community)\n" | |
7681 | "Do not export to next AS (well-known community)\n") | |
7682 | { | |
7683 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 7684 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
718e3744 | 7685 | |
95cbbd2a | 7686 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
718e3744 | 7687 | } |
7688 | ||
7689 | ALIAS (show_ip_bgp_ipv4_community, | |
7690 | show_ip_bgp_ipv4_community2_cmd, | |
7691 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7692 | SHOW_STR | |
7693 | IP_STR | |
7694 | BGP_STR | |
7695 | "Address family\n" | |
7696 | "Address Family modifier\n" | |
7697 | "Address Family modifier\n" | |
7698 | "Display routes matching the communities\n" | |
7699 | "community number\n" | |
7700 | "Do not send outside local AS (well-known community)\n" | |
7701 | "Do not advertise to any peer (well-known community)\n" | |
7702 | "Do not export to next AS (well-known community)\n" | |
7703 | "community number\n" | |
7704 | "Do not send outside local AS (well-known community)\n" | |
7705 | "Do not advertise to any peer (well-known community)\n" | |
7706 | "Do not export to next AS (well-known community)\n") | |
7707 | ||
7708 | ALIAS (show_ip_bgp_ipv4_community, | |
7709 | show_ip_bgp_ipv4_community3_cmd, | |
7710 | "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)", | |
7711 | SHOW_STR | |
7712 | IP_STR | |
7713 | BGP_STR | |
7714 | "Address family\n" | |
7715 | "Address Family modifier\n" | |
7716 | "Address Family modifier\n" | |
7717 | "Display routes matching the communities\n" | |
7718 | "community number\n" | |
7719 | "Do not send outside local AS (well-known community)\n" | |
7720 | "Do not advertise to any peer (well-known community)\n" | |
7721 | "Do not export to next AS (well-known community)\n" | |
7722 | "community number\n" | |
7723 | "Do not send outside local AS (well-known community)\n" | |
7724 | "Do not advertise to any peer (well-known community)\n" | |
7725 | "Do not export to next AS (well-known community)\n" | |
7726 | "community number\n" | |
7727 | "Do not send outside local AS (well-known community)\n" | |
7728 | "Do not advertise to any peer (well-known community)\n" | |
7729 | "Do not export to next AS (well-known community)\n") | |
7730 | ||
7731 | ALIAS (show_ip_bgp_ipv4_community, | |
7732 | show_ip_bgp_ipv4_community4_cmd, | |
7733 | "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)", | |
7734 | SHOW_STR | |
7735 | IP_STR | |
7736 | BGP_STR | |
7737 | "Address family\n" | |
7738 | "Address Family modifier\n" | |
7739 | "Address Family modifier\n" | |
7740 | "Display routes matching the communities\n" | |
7741 | "community number\n" | |
7742 | "Do not send outside local AS (well-known community)\n" | |
7743 | "Do not advertise to any peer (well-known community)\n" | |
7744 | "Do not export to next AS (well-known community)\n" | |
7745 | "community number\n" | |
7746 | "Do not send outside local AS (well-known community)\n" | |
7747 | "Do not advertise to any peer (well-known community)\n" | |
7748 | "Do not export to next AS (well-known community)\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 | ||
95cbbd2a ML |
7758 | DEFUN (show_bgp_view_afi_safi_community_all, |
7759 | show_bgp_view_afi_safi_community_all_cmd, | |
7760 | #ifdef HAVE_IPV6 | |
7761 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", | |
7762 | #else | |
7763 | "show bgp view WORD ipv4 (unicast|multicast) community", | |
7764 | #endif | |
7765 | SHOW_STR | |
7766 | BGP_STR | |
7767 | "BGP view\n" | |
7768 | "BGP view name\n" | |
7769 | "Address family\n" | |
7770 | #ifdef HAVE_IPV6 | |
7771 | "Address family\n" | |
7772 | #endif | |
7773 | "Address Family modifier\n" | |
7774 | "Address Family modifier\n" | |
7775 | "Display routes containing communities\n") | |
7776 | { | |
7777 | int afi; | |
7778 | int safi; | |
7779 | struct bgp *bgp; | |
7780 | ||
7781 | /* BGP structure lookup. */ | |
7782 | bgp = bgp_lookup_by_name (argv[0]); | |
7783 | if (bgp == NULL) | |
7784 | { | |
7785 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
7786 | return CMD_WARNING; | |
7787 | } | |
7788 | ||
7789 | #ifdef HAVE_IPV6 | |
7790 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; | |
7791 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7792 | #else | |
7793 | afi = AFI_IP; | |
7794 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7795 | #endif | |
7796 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); | |
7797 | } | |
7798 | ||
7799 | DEFUN (show_bgp_view_afi_safi_community, | |
7800 | show_bgp_view_afi_safi_community_cmd, | |
7801 | #ifdef HAVE_IPV6 | |
7802 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7803 | #else | |
7804 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7805 | #endif | |
7806 | SHOW_STR | |
7807 | BGP_STR | |
7808 | "BGP view\n" | |
7809 | "BGP view name\n" | |
7810 | "Address family\n" | |
7811 | #ifdef HAVE_IPV6 | |
7812 | "Address family\n" | |
7813 | #endif | |
7814 | "Address family modifier\n" | |
7815 | "Address family modifier\n" | |
7816 | "Display routes matching the communities\n" | |
7817 | "community number\n" | |
7818 | "Do not send outside local AS (well-known community)\n" | |
7819 | "Do not advertise to any peer (well-known community)\n" | |
7820 | "Do not export to next AS (well-known community)\n") | |
7821 | { | |
7822 | int afi; | |
7823 | int safi; | |
7824 | ||
7825 | #ifdef HAVE_IPV6 | |
7826 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; | |
7827 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7828 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); | |
7829 | #else | |
7830 | afi = AFI_IP; | |
7831 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
7832 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); | |
7833 | #endif | |
7834 | } | |
7835 | ||
7836 | ALIAS (show_bgp_view_afi_safi_community, | |
7837 | show_bgp_view_afi_safi_community2_cmd, | |
7838 | #ifdef HAVE_IPV6 | |
7839 | "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)", | |
7840 | #else | |
7841 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7842 | #endif | |
7843 | SHOW_STR | |
7844 | BGP_STR | |
7845 | "BGP view\n" | |
7846 | "BGP view name\n" | |
7847 | "Address family\n" | |
7848 | #ifdef HAVE_IPV6 | |
7849 | "Address family\n" | |
7850 | #endif | |
7851 | "Address family modifier\n" | |
7852 | "Address family modifier\n" | |
7853 | "Display routes matching the communities\n" | |
7854 | "community number\n" | |
7855 | "Do not send outside local AS (well-known community)\n" | |
7856 | "Do not advertise to any peer (well-known community)\n" | |
7857 | "Do not export to next AS (well-known community)\n" | |
7858 | "community number\n" | |
7859 | "Do not send outside local AS (well-known community)\n" | |
7860 | "Do not advertise to any peer (well-known community)\n" | |
7861 | "Do not export to next AS (well-known community)\n") | |
7862 | ||
7863 | ALIAS (show_bgp_view_afi_safi_community, | |
7864 | show_bgp_view_afi_safi_community3_cmd, | |
7865 | #ifdef HAVE_IPV6 | |
7866 | "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)", | |
7867 | #else | |
7868 | "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)", | |
7869 | #endif | |
7870 | SHOW_STR | |
7871 | BGP_STR | |
7872 | "BGP view\n" | |
7873 | "BGP view name\n" | |
7874 | "Address family\n" | |
7875 | #ifdef HAVE_IPV6 | |
7876 | "Address family\n" | |
7877 | #endif | |
7878 | "Address family modifier\n" | |
7879 | "Address family modifier\n" | |
7880 | "Display routes matching the communities\n" | |
7881 | "community number\n" | |
7882 | "Do not send outside local AS (well-known community)\n" | |
7883 | "Do not advertise to any peer (well-known community)\n" | |
7884 | "Do not export to next AS (well-known community)\n" | |
7885 | "community number\n" | |
7886 | "Do not send outside local AS (well-known community)\n" | |
7887 | "Do not advertise to any peer (well-known community)\n" | |
7888 | "Do not export to next AS (well-known community)\n" | |
7889 | "community number\n" | |
7890 | "Do not send outside local AS (well-known community)\n" | |
7891 | "Do not advertise to any peer (well-known community)\n" | |
7892 | "Do not export to next AS (well-known community)\n") | |
7893 | ||
7894 | ALIAS (show_bgp_view_afi_safi_community, | |
7895 | show_bgp_view_afi_safi_community4_cmd, | |
7896 | #ifdef HAVE_IPV6 | |
7897 | "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)", | |
7898 | #else | |
7899 | "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)", | |
7900 | #endif | |
7901 | SHOW_STR | |
7902 | BGP_STR | |
7903 | "BGP view\n" | |
7904 | "BGP view name\n" | |
7905 | "Address family\n" | |
7906 | #ifdef HAVE_IPV6 | |
7907 | "Address family\n" | |
7908 | #endif | |
7909 | "Address family modifier\n" | |
7910 | "Address family modifier\n" | |
7911 | "Display routes matching the communities\n" | |
7912 | "community number\n" | |
7913 | "Do not send outside local AS (well-known community)\n" | |
7914 | "Do not advertise to any peer (well-known community)\n" | |
7915 | "Do not export to next AS (well-known community)\n" | |
7916 | "community number\n" | |
7917 | "Do not send outside local AS (well-known community)\n" | |
7918 | "Do not advertise to any peer (well-known community)\n" | |
7919 | "Do not export to next AS (well-known community)\n" | |
7920 | "community number\n" | |
7921 | "Do not send outside local AS (well-known community)\n" | |
7922 | "Do not advertise to any peer (well-known community)\n" | |
7923 | "Do not export to next AS (well-known community)\n" | |
7924 | "community number\n" | |
7925 | "Do not send outside local AS (well-known community)\n" | |
7926 | "Do not advertise to any peer (well-known community)\n" | |
7927 | "Do not export to next AS (well-known community)\n") | |
7928 | ||
718e3744 | 7929 | DEFUN (show_ip_bgp_community_exact, |
7930 | show_ip_bgp_community_exact_cmd, | |
7931 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7932 | SHOW_STR | |
7933 | IP_STR | |
7934 | BGP_STR | |
7935 | "Display routes matching the communities\n" | |
7936 | "community number\n" | |
7937 | "Do not send outside local AS (well-known community)\n" | |
7938 | "Do not advertise to any peer (well-known community)\n" | |
7939 | "Do not export to next AS (well-known community)\n" | |
7940 | "Exact match of the communities") | |
7941 | { | |
95cbbd2a | 7942 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 7943 | } |
7944 | ||
7945 | ALIAS (show_ip_bgp_community_exact, | |
7946 | show_ip_bgp_community2_exact_cmd, | |
7947 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7948 | SHOW_STR | |
7949 | IP_STR | |
7950 | BGP_STR | |
7951 | "Display routes matching the communities\n" | |
7952 | "community number\n" | |
7953 | "Do not send outside local AS (well-known community)\n" | |
7954 | "Do not advertise to any peer (well-known community)\n" | |
7955 | "Do not export to next AS (well-known community)\n" | |
7956 | "community number\n" | |
7957 | "Do not send outside local AS (well-known community)\n" | |
7958 | "Do not advertise to any peer (well-known community)\n" | |
7959 | "Do not export to next AS (well-known community)\n" | |
7960 | "Exact match of the communities") | |
7961 | ||
7962 | ALIAS (show_ip_bgp_community_exact, | |
7963 | show_ip_bgp_community3_exact_cmd, | |
7964 | "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", | |
7965 | SHOW_STR | |
7966 | IP_STR | |
7967 | BGP_STR | |
7968 | "Display routes matching the communities\n" | |
7969 | "community number\n" | |
7970 | "Do not send outside local AS (well-known community)\n" | |
7971 | "Do not advertise to any peer (well-known community)\n" | |
7972 | "Do not export to next AS (well-known community)\n" | |
7973 | "community number\n" | |
7974 | "Do not send outside local AS (well-known community)\n" | |
7975 | "Do not advertise to any peer (well-known community)\n" | |
7976 | "Do not export to next AS (well-known community)\n" | |
7977 | "community number\n" | |
7978 | "Do not send outside local AS (well-known community)\n" | |
7979 | "Do not advertise to any peer (well-known community)\n" | |
7980 | "Do not export to next AS (well-known community)\n" | |
7981 | "Exact match of the communities") | |
7982 | ||
7983 | ALIAS (show_ip_bgp_community_exact, | |
7984 | show_ip_bgp_community4_exact_cmd, | |
7985 | "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", | |
7986 | SHOW_STR | |
7987 | IP_STR | |
7988 | BGP_STR | |
7989 | "Display routes matching the communities\n" | |
7990 | "community number\n" | |
7991 | "Do not send outside local AS (well-known community)\n" | |
7992 | "Do not advertise to any peer (well-known community)\n" | |
7993 | "Do not export to next AS (well-known community)\n" | |
7994 | "community number\n" | |
7995 | "Do not send outside local AS (well-known community)\n" | |
7996 | "Do not advertise to any peer (well-known community)\n" | |
7997 | "Do not export to next AS (well-known community)\n" | |
7998 | "community number\n" | |
7999 | "Do not send outside local AS (well-known community)\n" | |
8000 | "Do not advertise to any peer (well-known community)\n" | |
8001 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") | |
8007 | ||
8008 | DEFUN (show_ip_bgp_ipv4_community_exact, | |
8009 | show_ip_bgp_ipv4_community_exact_cmd, | |
8010 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8011 | SHOW_STR | |
8012 | IP_STR | |
8013 | BGP_STR | |
8014 | "Address family\n" | |
8015 | "Address Family modifier\n" | |
8016 | "Address Family modifier\n" | |
8017 | "Display routes matching the communities\n" | |
8018 | "community number\n" | |
8019 | "Do not send outside local AS (well-known community)\n" | |
8020 | "Do not advertise to any peer (well-known community)\n" | |
8021 | "Do not export to next AS (well-known community)\n" | |
8022 | "Exact match of the communities") | |
8023 | { | |
8024 | if (strncmp (argv[0], "m", 1) == 0) | |
95cbbd2a | 8025 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
718e3744 | 8026 | |
95cbbd2a | 8027 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
718e3744 | 8028 | } |
8029 | ||
8030 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
8031 | show_ip_bgp_ipv4_community2_exact_cmd, | |
8032 | "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", | |
8033 | SHOW_STR | |
8034 | IP_STR | |
8035 | BGP_STR | |
8036 | "Address family\n" | |
8037 | "Address Family modifier\n" | |
8038 | "Address Family modifier\n" | |
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 | "Exact match of the communities") | |
8049 | ||
8050 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
8051 | show_ip_bgp_ipv4_community3_exact_cmd, | |
8052 | "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", | |
8053 | SHOW_STR | |
8054 | IP_STR | |
8055 | BGP_STR | |
8056 | "Address family\n" | |
8057 | "Address Family modifier\n" | |
8058 | "Address Family modifier\n" | |
8059 | "Display routes matching the communities\n" | |
8060 | "community number\n" | |
8061 | "Do not send outside local AS (well-known community)\n" | |
8062 | "Do not advertise to any peer (well-known community)\n" | |
8063 | "Do not export to next AS (well-known community)\n" | |
8064 | "community number\n" | |
8065 | "Do not send outside local AS (well-known community)\n" | |
8066 | "Do not advertise to any peer (well-known community)\n" | |
8067 | "Do not export to next AS (well-known community)\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 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
8075 | show_ip_bgp_ipv4_community4_exact_cmd, | |
8076 | "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", | |
8077 | SHOW_STR | |
8078 | IP_STR | |
8079 | BGP_STR | |
8080 | "Address family\n" | |
8081 | "Address Family modifier\n" | |
8082 | "Address Family modifier\n" | |
8083 | "Display routes matching the communities\n" | |
8084 | "community number\n" | |
8085 | "Do not send outside local AS (well-known community)\n" | |
8086 | "Do not advertise to any peer (well-known community)\n" | |
8087 | "Do not export to next AS (well-known community)\n" | |
8088 | "community number\n" | |
8089 | "Do not send outside local AS (well-known community)\n" | |
8090 | "Do not advertise to any peer (well-known community)\n" | |
8091 | "Do not export to next AS (well-known community)\n" | |
8092 | "community number\n" | |
8093 | "Do not send outside local AS (well-known community)\n" | |
8094 | "Do not advertise to any peer (well-known community)\n" | |
8095 | "Do not export to next AS (well-known community)\n" | |
8096 | "community number\n" | |
8097 | "Do not send outside local AS (well-known community)\n" | |
8098 | "Do not advertise to any peer (well-known community)\n" | |
8099 | "Do not export to next AS (well-known community)\n" | |
8100 | "Exact match of the communities") | |
8101 | ||
8102 | #ifdef HAVE_IPV6 | |
8103 | DEFUN (show_bgp_community, | |
8104 | show_bgp_community_cmd, | |
8105 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8106 | SHOW_STR | |
8107 | BGP_STR | |
8108 | "Display routes matching the communities\n" | |
8109 | "community number\n" | |
8110 | "Do not send outside local AS (well-known community)\n" | |
8111 | "Do not advertise to any peer (well-known community)\n" | |
8112 | "Do not export to next AS (well-known community)\n") | |
8113 | { | |
95cbbd2a | 8114 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8115 | } |
8116 | ||
8117 | ALIAS (show_bgp_community, | |
8118 | show_bgp_ipv6_community_cmd, | |
8119 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", | |
8120 | SHOW_STR | |
8121 | BGP_STR | |
8122 | "Address family\n" | |
8123 | "Display routes matching the communities\n" | |
8124 | "community number\n" | |
8125 | "Do not send outside local AS (well-known community)\n" | |
8126 | "Do not advertise to any peer (well-known community)\n" | |
8127 | "Do not export to next AS (well-known community)\n") | |
8128 | ||
8129 | ALIAS (show_bgp_community, | |
8130 | show_bgp_community2_cmd, | |
8131 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8132 | SHOW_STR | |
8133 | BGP_STR | |
8134 | "Display routes matching the communities\n" | |
8135 | "community number\n" | |
8136 | "Do not send outside local AS (well-known community)\n" | |
8137 | "Do not advertise to any peer (well-known community)\n" | |
8138 | "Do not export to next AS (well-known community)\n" | |
8139 | "community number\n" | |
8140 | "Do not send outside local AS (well-known community)\n" | |
8141 | "Do not advertise to any peer (well-known community)\n" | |
8142 | "Do not export to next AS (well-known community)\n") | |
8143 | ||
8144 | ALIAS (show_bgp_community, | |
8145 | show_bgp_ipv6_community2_cmd, | |
8146 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8147 | SHOW_STR | |
8148 | BGP_STR | |
8149 | "Address family\n" | |
8150 | "Display routes matching the communities\n" | |
8151 | "community number\n" | |
8152 | "Do not send outside local AS (well-known community)\n" | |
8153 | "Do not advertise to any peer (well-known community)\n" | |
8154 | "Do not export to next AS (well-known community)\n" | |
8155 | "community number\n" | |
8156 | "Do not send outside local AS (well-known community)\n" | |
8157 | "Do not advertise to any peer (well-known community)\n" | |
8158 | "Do not export to next AS (well-known community)\n") | |
8159 | ||
8160 | ALIAS (show_bgp_community, | |
8161 | show_bgp_community3_cmd, | |
8162 | "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)", | |
8163 | SHOW_STR | |
8164 | BGP_STR | |
8165 | "Display routes matching the communities\n" | |
8166 | "community number\n" | |
8167 | "Do not send outside local AS (well-known community)\n" | |
8168 | "Do not advertise to any peer (well-known community)\n" | |
8169 | "Do not export to next AS (well-known community)\n" | |
8170 | "community number\n" | |
8171 | "Do not send outside local AS (well-known community)\n" | |
8172 | "Do not advertise to any peer (well-known community)\n" | |
8173 | "Do not export to next AS (well-known community)\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_ipv6_community3_cmd, | |
8181 | "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)", | |
8182 | SHOW_STR | |
8183 | BGP_STR | |
8184 | "Address family\n" | |
8185 | "Display routes matching the communities\n" | |
8186 | "community number\n" | |
8187 | "Do not send outside local AS (well-known community)\n" | |
8188 | "Do not advertise to any peer (well-known community)\n" | |
8189 | "Do not export to next AS (well-known community)\n" | |
8190 | "community number\n" | |
8191 | "Do not send outside local AS (well-known community)\n" | |
8192 | "Do not advertise to any peer (well-known community)\n" | |
8193 | "Do not export to next AS (well-known community)\n" | |
8194 | "community number\n" | |
8195 | "Do not send outside local AS (well-known community)\n" | |
8196 | "Do not advertise to any peer (well-known community)\n" | |
8197 | "Do not export to next AS (well-known community)\n") | |
8198 | ||
8199 | ALIAS (show_bgp_community, | |
8200 | show_bgp_community4_cmd, | |
8201 | "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)", | |
8202 | SHOW_STR | |
8203 | BGP_STR | |
8204 | "Display routes matching the communities\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 | "community number\n" | |
8210 | "Do not send outside local AS (well-known community)\n" | |
8211 | "Do not advertise to any peer (well-known community)\n" | |
8212 | "Do not export to next AS (well-known community)\n" | |
8213 | "community number\n" | |
8214 | "Do not send outside local AS (well-known community)\n" | |
8215 | "Do not advertise to any peer (well-known community)\n" | |
8216 | "Do not export to next AS (well-known community)\n" | |
8217 | "community number\n" | |
8218 | "Do not send outside local AS (well-known community)\n" | |
8219 | "Do not advertise to any peer (well-known community)\n" | |
8220 | "Do not export to next AS (well-known community)\n") | |
8221 | ||
8222 | ALIAS (show_bgp_community, | |
8223 | show_bgp_ipv6_community4_cmd, | |
8224 | "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)", | |
8225 | SHOW_STR | |
8226 | BGP_STR | |
8227 | "Address family\n" | |
8228 | "Display routes matching the communities\n" | |
8229 | "community number\n" | |
8230 | "Do not send outside local AS (well-known community)\n" | |
8231 | "Do not advertise to any peer (well-known community)\n" | |
8232 | "Do not export to next AS (well-known community)\n" | |
8233 | "community number\n" | |
8234 | "Do not send outside local AS (well-known community)\n" | |
8235 | "Do not advertise to any peer (well-known community)\n" | |
8236 | "Do not export to next AS (well-known community)\n" | |
8237 | "community number\n" | |
8238 | "Do not send outside local AS (well-known community)\n" | |
8239 | "Do not advertise to any peer (well-known community)\n" | |
8240 | "Do not export to next AS (well-known community)\n" | |
8241 | "community number\n" | |
8242 | "Do not send outside local AS (well-known community)\n" | |
8243 | "Do not advertise to any peer (well-known community)\n" | |
8244 | "Do not export to next AS (well-known community)\n") | |
8245 | ||
8246 | /* old command */ | |
8247 | DEFUN (show_ipv6_bgp_community, | |
8248 | show_ipv6_bgp_community_cmd, | |
8249 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8250 | SHOW_STR | |
8251 | IPV6_STR | |
8252 | BGP_STR | |
8253 | "Display routes matching the communities\n" | |
8254 | "community number\n" | |
8255 | "Do not send outside local AS (well-known community)\n" | |
8256 | "Do not advertise to any peer (well-known community)\n" | |
8257 | "Do not export to next AS (well-known community)\n") | |
8258 | { | |
95cbbd2a | 8259 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8260 | } |
8261 | ||
8262 | /* old command */ | |
8263 | ALIAS (show_ipv6_bgp_community, | |
8264 | show_ipv6_bgp_community2_cmd, | |
8265 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8266 | SHOW_STR | |
8267 | IPV6_STR | |
8268 | BGP_STR | |
8269 | "Display routes matching the communities\n" | |
8270 | "community number\n" | |
8271 | "Do not send outside local AS (well-known community)\n" | |
8272 | "Do not advertise to any peer (well-known community)\n" | |
8273 | "Do not export to next AS (well-known community)\n" | |
8274 | "community number\n" | |
8275 | "Do not send outside local AS (well-known community)\n" | |
8276 | "Do not advertise to any peer (well-known community)\n" | |
8277 | "Do not export to next AS (well-known community)\n") | |
8278 | ||
8279 | /* old command */ | |
8280 | ALIAS (show_ipv6_bgp_community, | |
8281 | show_ipv6_bgp_community3_cmd, | |
8282 | "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)", | |
8283 | SHOW_STR | |
8284 | IPV6_STR | |
8285 | BGP_STR | |
8286 | "Display routes matching the communities\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 | "community number\n" | |
8296 | "Do not send outside local AS (well-known community)\n" | |
8297 | "Do not advertise to any peer (well-known community)\n" | |
8298 | "Do not export to next AS (well-known community)\n") | |
8299 | ||
8300 | /* old command */ | |
8301 | ALIAS (show_ipv6_bgp_community, | |
8302 | show_ipv6_bgp_community4_cmd, | |
8303 | "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)", | |
8304 | SHOW_STR | |
8305 | IPV6_STR | |
8306 | BGP_STR | |
8307 | "Display routes matching the communities\n" | |
8308 | "community number\n" | |
8309 | "Do not send outside local AS (well-known community)\n" | |
8310 | "Do not advertise to any peer (well-known community)\n" | |
8311 | "Do not export to next AS (well-known community)\n" | |
8312 | "community number\n" | |
8313 | "Do not send outside local AS (well-known community)\n" | |
8314 | "Do not advertise to any peer (well-known community)\n" | |
8315 | "Do not export to next AS (well-known community)\n" | |
8316 | "community number\n" | |
8317 | "Do not send outside local AS (well-known community)\n" | |
8318 | "Do not advertise to any peer (well-known community)\n" | |
8319 | "Do not export to next AS (well-known community)\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 | ||
8325 | DEFUN (show_bgp_community_exact, | |
8326 | show_bgp_community_exact_cmd, | |
8327 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8328 | SHOW_STR | |
8329 | BGP_STR | |
8330 | "Display routes matching the communities\n" | |
8331 | "community number\n" | |
8332 | "Do not send outside local AS (well-known community)\n" | |
8333 | "Do not advertise to any peer (well-known community)\n" | |
8334 | "Do not export to next AS (well-known community)\n" | |
8335 | "Exact match of the communities") | |
8336 | { | |
95cbbd2a | 8337 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8338 | } |
8339 | ||
8340 | ALIAS (show_bgp_community_exact, | |
8341 | show_bgp_ipv6_community_exact_cmd, | |
8342 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8343 | SHOW_STR | |
8344 | BGP_STR | |
8345 | "Address family\n" | |
8346 | "Display routes matching the communities\n" | |
8347 | "community number\n" | |
8348 | "Do not send outside local AS (well-known community)\n" | |
8349 | "Do not advertise to any peer (well-known community)\n" | |
8350 | "Do not export to next AS (well-known community)\n" | |
8351 | "Exact match of the communities") | |
8352 | ||
8353 | ALIAS (show_bgp_community_exact, | |
8354 | show_bgp_community2_exact_cmd, | |
8355 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8356 | SHOW_STR | |
8357 | BGP_STR | |
8358 | "Display routes matching the communities\n" | |
8359 | "community number\n" | |
8360 | "Do not send outside local AS (well-known community)\n" | |
8361 | "Do not advertise to any peer (well-known community)\n" | |
8362 | "Do not export to next AS (well-known community)\n" | |
8363 | "community number\n" | |
8364 | "Do not send outside local AS (well-known community)\n" | |
8365 | "Do not advertise to any peer (well-known community)\n" | |
8366 | "Do not export to next AS (well-known community)\n" | |
8367 | "Exact match of the communities") | |
8368 | ||
8369 | ALIAS (show_bgp_community_exact, | |
8370 | show_bgp_ipv6_community2_exact_cmd, | |
8371 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8372 | SHOW_STR | |
8373 | BGP_STR | |
8374 | "Address family\n" | |
8375 | "Display routes matching the communities\n" | |
8376 | "community number\n" | |
8377 | "Do not send outside local AS (well-known community)\n" | |
8378 | "Do not advertise to any peer (well-known community)\n" | |
8379 | "Do not export to next AS (well-known community)\n" | |
8380 | "community number\n" | |
8381 | "Do not send outside local AS (well-known community)\n" | |
8382 | "Do not advertise to any peer (well-known community)\n" | |
8383 | "Do not export to next AS (well-known community)\n" | |
8384 | "Exact match of the communities") | |
8385 | ||
8386 | ALIAS (show_bgp_community_exact, | |
8387 | show_bgp_community3_exact_cmd, | |
8388 | "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", | |
8389 | SHOW_STR | |
8390 | BGP_STR | |
8391 | "Display routes matching the communities\n" | |
8392 | "community number\n" | |
8393 | "Do not send outside local AS (well-known community)\n" | |
8394 | "Do not advertise to any peer (well-known community)\n" | |
8395 | "Do not export to next AS (well-known community)\n" | |
8396 | "community number\n" | |
8397 | "Do not send outside local AS (well-known community)\n" | |
8398 | "Do not advertise to any peer (well-known community)\n" | |
8399 | "Do not export to next AS (well-known community)\n" | |
8400 | "community number\n" | |
8401 | "Do not send outside local AS (well-known community)\n" | |
8402 | "Do not advertise to any peer (well-known community)\n" | |
8403 | "Do not export to next AS (well-known community)\n" | |
8404 | "Exact match of the communities") | |
8405 | ||
8406 | ALIAS (show_bgp_community_exact, | |
8407 | show_bgp_ipv6_community3_exact_cmd, | |
8408 | "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", | |
8409 | SHOW_STR | |
8410 | BGP_STR | |
8411 | "Address family\n" | |
8412 | "Display routes matching the communities\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 | "community number\n" | |
8418 | "Do not send outside local AS (well-known community)\n" | |
8419 | "Do not advertise to any peer (well-known community)\n" | |
8420 | "Do not export to next AS (well-known community)\n" | |
8421 | "community number\n" | |
8422 | "Do not send outside local AS (well-known community)\n" | |
8423 | "Do not advertise to any peer (well-known community)\n" | |
8424 | "Do not export to next AS (well-known community)\n" | |
8425 | "Exact match of the communities") | |
8426 | ||
8427 | ALIAS (show_bgp_community_exact, | |
8428 | show_bgp_community4_exact_cmd, | |
8429 | "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", | |
8430 | SHOW_STR | |
8431 | BGP_STR | |
8432 | "Display routes matching the communities\n" | |
8433 | "community number\n" | |
8434 | "Do not send outside local AS (well-known community)\n" | |
8435 | "Do not advertise to any peer (well-known community)\n" | |
8436 | "Do not export to next AS (well-known community)\n" | |
8437 | "community number\n" | |
8438 | "Do not send outside local AS (well-known community)\n" | |
8439 | "Do not advertise to any peer (well-known community)\n" | |
8440 | "Do not export to next AS (well-known community)\n" | |
8441 | "community number\n" | |
8442 | "Do not send outside local AS (well-known community)\n" | |
8443 | "Do not advertise to any peer (well-known community)\n" | |
8444 | "Do not export to next AS (well-known community)\n" | |
8445 | "community number\n" | |
8446 | "Do not send outside local AS (well-known community)\n" | |
8447 | "Do not advertise to any peer (well-known community)\n" | |
8448 | "Do not export to next AS (well-known community)\n" | |
8449 | "Exact match of the communities") | |
8450 | ||
8451 | ALIAS (show_bgp_community_exact, | |
8452 | show_bgp_ipv6_community4_exact_cmd, | |
8453 | "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", | |
8454 | SHOW_STR | |
8455 | BGP_STR | |
8456 | "Address family\n" | |
8457 | "Display routes matching the communities\n" | |
8458 | "community number\n" | |
8459 | "Do not send outside local AS (well-known community)\n" | |
8460 | "Do not advertise to any peer (well-known community)\n" | |
8461 | "Do not export to next AS (well-known community)\n" | |
8462 | "community number\n" | |
8463 | "Do not send outside local AS (well-known community)\n" | |
8464 | "Do not advertise to any peer (well-known community)\n" | |
8465 | "Do not export to next AS (well-known community)\n" | |
8466 | "community number\n" | |
8467 | "Do not send outside local AS (well-known community)\n" | |
8468 | "Do not advertise to any peer (well-known community)\n" | |
8469 | "Do not export to next AS (well-known community)\n" | |
8470 | "community number\n" | |
8471 | "Do not send outside local AS (well-known community)\n" | |
8472 | "Do not advertise to any peer (well-known community)\n" | |
8473 | "Do not export to next AS (well-known community)\n" | |
8474 | "Exact match of the communities") | |
8475 | ||
8476 | /* old command */ | |
8477 | DEFUN (show_ipv6_bgp_community_exact, | |
8478 | show_ipv6_bgp_community_exact_cmd, | |
8479 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8480 | SHOW_STR | |
8481 | IPV6_STR | |
8482 | BGP_STR | |
8483 | "Display routes matching the communities\n" | |
8484 | "community number\n" | |
8485 | "Do not send outside local AS (well-known community)\n" | |
8486 | "Do not advertise to any peer (well-known community)\n" | |
8487 | "Do not export to next AS (well-known community)\n" | |
8488 | "Exact match of the communities") | |
8489 | { | |
95cbbd2a | 8490 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
718e3744 | 8491 | } |
8492 | ||
8493 | /* old command */ | |
8494 | ALIAS (show_ipv6_bgp_community_exact, | |
8495 | show_ipv6_bgp_community2_exact_cmd, | |
8496 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8497 | SHOW_STR | |
8498 | IPV6_STR | |
8499 | BGP_STR | |
8500 | "Display routes matching the communities\n" | |
8501 | "community number\n" | |
8502 | "Do not send outside local AS (well-known community)\n" | |
8503 | "Do not advertise to any peer (well-known community)\n" | |
8504 | "Do not export to next AS (well-known community)\n" | |
8505 | "community number\n" | |
8506 | "Do not send outside local AS (well-known community)\n" | |
8507 | "Do not advertise to any peer (well-known community)\n" | |
8508 | "Do not export to next AS (well-known community)\n" | |
8509 | "Exact match of the communities") | |
8510 | ||
8511 | /* old command */ | |
8512 | ALIAS (show_ipv6_bgp_community_exact, | |
8513 | show_ipv6_bgp_community3_exact_cmd, | |
8514 | "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", | |
8515 | SHOW_STR | |
8516 | IPV6_STR | |
8517 | BGP_STR | |
8518 | "Display routes matching the communities\n" | |
8519 | "community number\n" | |
8520 | "Do not send outside local AS (well-known community)\n" | |
8521 | "Do not advertise to any peer (well-known community)\n" | |
8522 | "Do not export to next AS (well-known community)\n" | |
8523 | "community number\n" | |
8524 | "Do not send outside local AS (well-known community)\n" | |
8525 | "Do not advertise to any peer (well-known community)\n" | |
8526 | "Do not export to next AS (well-known community)\n" | |
8527 | "community number\n" | |
8528 | "Do not send outside local AS (well-known community)\n" | |
8529 | "Do not advertise to any peer (well-known community)\n" | |
8530 | "Do not export to next AS (well-known community)\n" | |
8531 | "Exact match of the communities") | |
8532 | ||
8533 | /* old command */ | |
8534 | ALIAS (show_ipv6_bgp_community_exact, | |
8535 | show_ipv6_bgp_community4_exact_cmd, | |
8536 | "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", | |
8537 | SHOW_STR | |
8538 | IPV6_STR | |
8539 | BGP_STR | |
8540 | "Display routes matching the communities\n" | |
8541 | "community number\n" | |
8542 | "Do not send outside local AS (well-known community)\n" | |
8543 | "Do not advertise to any peer (well-known community)\n" | |
8544 | "Do not export to next AS (well-known community)\n" | |
8545 | "community number\n" | |
8546 | "Do not send outside local AS (well-known community)\n" | |
8547 | "Do not advertise to any peer (well-known community)\n" | |
8548 | "Do not export to next AS (well-known community)\n" | |
8549 | "community number\n" | |
8550 | "Do not send outside local AS (well-known community)\n" | |
8551 | "Do not advertise to any peer (well-known community)\n" | |
8552 | "Do not export to next AS (well-known community)\n" | |
8553 | "community number\n" | |
8554 | "Do not send outside local AS (well-known community)\n" | |
8555 | "Do not advertise to any peer (well-known community)\n" | |
8556 | "Do not export to next AS (well-known community)\n" | |
8557 | "Exact match of the communities") | |
8558 | ||
8559 | /* old command */ | |
8560 | DEFUN (show_ipv6_mbgp_community, | |
8561 | show_ipv6_mbgp_community_cmd, | |
8562 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8563 | SHOW_STR | |
8564 | IPV6_STR | |
8565 | MBGP_STR | |
8566 | "Display routes matching the communities\n" | |
8567 | "community number\n" | |
8568 | "Do not send outside local AS (well-known community)\n" | |
8569 | "Do not advertise to any peer (well-known community)\n" | |
8570 | "Do not export to next AS (well-known community)\n") | |
8571 | { | |
95cbbd2a | 8572 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 8573 | } |
8574 | ||
8575 | /* old command */ | |
8576 | ALIAS (show_ipv6_mbgp_community, | |
8577 | show_ipv6_mbgp_community2_cmd, | |
8578 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8579 | SHOW_STR | |
8580 | IPV6_STR | |
8581 | MBGP_STR | |
8582 | "Display routes matching the communities\n" | |
8583 | "community number\n" | |
8584 | "Do not send outside local AS (well-known community)\n" | |
8585 | "Do not advertise to any peer (well-known community)\n" | |
8586 | "Do not export to next AS (well-known community)\n" | |
8587 | "community number\n" | |
8588 | "Do not send outside local AS (well-known community)\n" | |
8589 | "Do not advertise to any peer (well-known community)\n" | |
8590 | "Do not export to next AS (well-known community)\n") | |
8591 | ||
8592 | /* old command */ | |
8593 | ALIAS (show_ipv6_mbgp_community, | |
8594 | show_ipv6_mbgp_community3_cmd, | |
8595 | "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)", | |
8596 | SHOW_STR | |
8597 | IPV6_STR | |
8598 | MBGP_STR | |
8599 | "Display routes matching the communities\n" | |
8600 | "community number\n" | |
8601 | "Do not send outside local AS (well-known community)\n" | |
8602 | "Do not advertise to any peer (well-known community)\n" | |
8603 | "Do not export to next AS (well-known community)\n" | |
8604 | "community number\n" | |
8605 | "Do not send outside local AS (well-known community)\n" | |
8606 | "Do not advertise to any peer (well-known community)\n" | |
8607 | "Do not export to next AS (well-known community)\n" | |
8608 | "community number\n" | |
8609 | "Do not send outside local AS (well-known community)\n" | |
8610 | "Do not advertise to any peer (well-known community)\n" | |
8611 | "Do not export to next AS (well-known community)\n") | |
8612 | ||
8613 | /* old command */ | |
8614 | ALIAS (show_ipv6_mbgp_community, | |
8615 | show_ipv6_mbgp_community4_cmd, | |
8616 | "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)", | |
8617 | SHOW_STR | |
8618 | IPV6_STR | |
8619 | MBGP_STR | |
8620 | "Display routes matching the communities\n" | |
8621 | "community number\n" | |
8622 | "Do not send outside local AS (well-known community)\n" | |
8623 | "Do not advertise to any peer (well-known community)\n" | |
8624 | "Do not export to next AS (well-known community)\n" | |
8625 | "community number\n" | |
8626 | "Do not send outside local AS (well-known community)\n" | |
8627 | "Do not advertise to any peer (well-known community)\n" | |
8628 | "Do not export to next AS (well-known community)\n" | |
8629 | "community number\n" | |
8630 | "Do not send outside local AS (well-known community)\n" | |
8631 | "Do not advertise to any peer (well-known community)\n" | |
8632 | "Do not export to next AS (well-known community)\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 | ||
8638 | /* old command */ | |
8639 | DEFUN (show_ipv6_mbgp_community_exact, | |
8640 | show_ipv6_mbgp_community_exact_cmd, | |
8641 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8642 | SHOW_STR | |
8643 | IPV6_STR | |
8644 | MBGP_STR | |
8645 | "Display routes matching the communities\n" | |
8646 | "community number\n" | |
8647 | "Do not send outside local AS (well-known community)\n" | |
8648 | "Do not advertise to any peer (well-known community)\n" | |
8649 | "Do not export to next AS (well-known community)\n" | |
8650 | "Exact match of the communities") | |
8651 | { | |
95cbbd2a | 8652 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
718e3744 | 8653 | } |
8654 | ||
8655 | /* old command */ | |
8656 | ALIAS (show_ipv6_mbgp_community_exact, | |
8657 | show_ipv6_mbgp_community2_exact_cmd, | |
8658 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8659 | SHOW_STR | |
8660 | IPV6_STR | |
8661 | MBGP_STR | |
8662 | "Display routes matching the communities\n" | |
8663 | "community number\n" | |
8664 | "Do not send outside local AS (well-known community)\n" | |
8665 | "Do not advertise to any peer (well-known community)\n" | |
8666 | "Do not export to next AS (well-known community)\n" | |
8667 | "community number\n" | |
8668 | "Do not send outside local AS (well-known community)\n" | |
8669 | "Do not advertise to any peer (well-known community)\n" | |
8670 | "Do not export to next AS (well-known community)\n" | |
8671 | "Exact match of the communities") | |
8672 | ||
8673 | /* old command */ | |
8674 | ALIAS (show_ipv6_mbgp_community_exact, | |
8675 | show_ipv6_mbgp_community3_exact_cmd, | |
8676 | "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", | |
8677 | SHOW_STR | |
8678 | IPV6_STR | |
8679 | MBGP_STR | |
8680 | "Display routes matching the communities\n" | |
8681 | "community number\n" | |
8682 | "Do not send outside local AS (well-known community)\n" | |
8683 | "Do not advertise to any peer (well-known community)\n" | |
8684 | "Do not export to next AS (well-known community)\n" | |
8685 | "community number\n" | |
8686 | "Do not send outside local AS (well-known community)\n" | |
8687 | "Do not advertise to any peer (well-known community)\n" | |
8688 | "Do not export to next AS (well-known community)\n" | |
8689 | "community number\n" | |
8690 | "Do not send outside local AS (well-known community)\n" | |
8691 | "Do not advertise to any peer (well-known community)\n" | |
8692 | "Do not export to next AS (well-known community)\n" | |
8693 | "Exact match of the communities") | |
8694 | ||
8695 | /* old command */ | |
8696 | ALIAS (show_ipv6_mbgp_community_exact, | |
8697 | show_ipv6_mbgp_community4_exact_cmd, | |
8698 | "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", | |
8699 | SHOW_STR | |
8700 | IPV6_STR | |
8701 | MBGP_STR | |
8702 | "Display routes matching the communities\n" | |
8703 | "community number\n" | |
8704 | "Do not send outside local AS (well-known community)\n" | |
8705 | "Do not advertise to any peer (well-known community)\n" | |
8706 | "Do not export to next AS (well-known community)\n" | |
8707 | "community number\n" | |
8708 | "Do not send outside local AS (well-known community)\n" | |
8709 | "Do not advertise to any peer (well-known community)\n" | |
8710 | "Do not export to next AS (well-known community)\n" | |
8711 | "community number\n" | |
8712 | "Do not send outside local AS (well-known community)\n" | |
8713 | "Do not advertise to any peer (well-known community)\n" | |
8714 | "Do not export to next AS (well-known community)\n" | |
8715 | "community number\n" | |
8716 | "Do not send outside local AS (well-known community)\n" | |
8717 | "Do not advertise to any peer (well-known community)\n" | |
8718 | "Do not export to next AS (well-known community)\n" | |
8719 | "Exact match of the communities") | |
8720 | #endif /* HAVE_IPV6 */ | |
8721 | \f | |
94f2b392 | 8722 | static int |
fd79ac91 | 8723 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
4c9641ba | 8724 | afi_t afi, safi_t safi) |
718e3744 | 8725 | { |
8726 | struct community_list *list; | |
8727 | ||
fee6e4e4 | 8728 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
718e3744 | 8729 | if (list == NULL) |
8730 | { | |
8731 | vty_out (vty, "%% %s is not a valid community-list name%s", com, | |
8732 | VTY_NEWLINE); | |
8733 | return CMD_WARNING; | |
8734 | } | |
8735 | ||
5a646650 | 8736 | return bgp_show (vty, NULL, afi, safi, |
8737 | (exact ? bgp_show_type_community_list_exact : | |
8738 | bgp_show_type_community_list), list); | |
718e3744 | 8739 | } |
8740 | ||
8741 | DEFUN (show_ip_bgp_community_list, | |
8742 | show_ip_bgp_community_list_cmd, | |
fee6e4e4 | 8743 | "show ip bgp community-list (<1-500>|WORD)", |
718e3744 | 8744 | SHOW_STR |
8745 | IP_STR | |
8746 | BGP_STR | |
8747 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8748 | "community-list number\n" |
718e3744 | 8749 | "community-list name\n") |
8750 | { | |
8751 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); | |
8752 | } | |
8753 | ||
8754 | DEFUN (show_ip_bgp_ipv4_community_list, | |
8755 | show_ip_bgp_ipv4_community_list_cmd, | |
fee6e4e4 | 8756 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
718e3744 | 8757 | SHOW_STR |
8758 | IP_STR | |
8759 | BGP_STR | |
8760 | "Address family\n" | |
8761 | "Address Family modifier\n" | |
8762 | "Address Family modifier\n" | |
8763 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8764 | "community-list number\n" |
718e3744 | 8765 | "community-list name\n") |
8766 | { | |
8767 | if (strncmp (argv[0], "m", 1) == 0) | |
8768 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); | |
8769 | ||
8770 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); | |
8771 | } | |
8772 | ||
8773 | DEFUN (show_ip_bgp_community_list_exact, | |
8774 | show_ip_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8775 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8776 | SHOW_STR |
8777 | IP_STR | |
8778 | BGP_STR | |
8779 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8780 | "community-list number\n" |
718e3744 | 8781 | "community-list name\n" |
8782 | "Exact match of the communities\n") | |
8783 | { | |
8784 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); | |
8785 | } | |
8786 | ||
8787 | DEFUN (show_ip_bgp_ipv4_community_list_exact, | |
8788 | show_ip_bgp_ipv4_community_list_exact_cmd, | |
fee6e4e4 | 8789 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
718e3744 | 8790 | SHOW_STR |
8791 | IP_STR | |
8792 | BGP_STR | |
8793 | "Address family\n" | |
8794 | "Address Family modifier\n" | |
8795 | "Address Family modifier\n" | |
8796 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8797 | "community-list number\n" |
718e3744 | 8798 | "community-list name\n" |
8799 | "Exact match of the communities\n") | |
8800 | { | |
8801 | if (strncmp (argv[0], "m", 1) == 0) | |
8802 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); | |
8803 | ||
8804 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); | |
8805 | } | |
8806 | ||
8807 | #ifdef HAVE_IPV6 | |
8808 | DEFUN (show_bgp_community_list, | |
8809 | show_bgp_community_list_cmd, | |
fee6e4e4 | 8810 | "show bgp community-list (<1-500>|WORD)", |
718e3744 | 8811 | SHOW_STR |
8812 | BGP_STR | |
8813 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8814 | "community-list number\n" |
718e3744 | 8815 | "community-list name\n") |
8816 | { | |
8817 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8818 | } | |
8819 | ||
8820 | ALIAS (show_bgp_community_list, | |
8821 | show_bgp_ipv6_community_list_cmd, | |
fee6e4e4 | 8822 | "show bgp ipv6 community-list (<1-500>|WORD)", |
718e3744 | 8823 | SHOW_STR |
8824 | BGP_STR | |
8825 | "Address family\n" | |
8826 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8827 | "community-list number\n" |
e8e1946e | 8828 | "community-list name\n") |
718e3744 | 8829 | |
8830 | /* old command */ | |
8831 | DEFUN (show_ipv6_bgp_community_list, | |
8832 | show_ipv6_bgp_community_list_cmd, | |
8833 | "show ipv6 bgp community-list WORD", | |
8834 | SHOW_STR | |
8835 | IPV6_STR | |
8836 | BGP_STR | |
8837 | "Display routes matching the community-list\n" | |
8838 | "community-list name\n") | |
8839 | { | |
8840 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8841 | } | |
8842 | ||
8843 | /* old command */ | |
8844 | DEFUN (show_ipv6_mbgp_community_list, | |
8845 | show_ipv6_mbgp_community_list_cmd, | |
8846 | "show ipv6 mbgp community-list WORD", | |
8847 | SHOW_STR | |
8848 | IPV6_STR | |
8849 | MBGP_STR | |
8850 | "Display routes matching the community-list\n" | |
8851 | "community-list name\n") | |
8852 | { | |
8853 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); | |
8854 | } | |
8855 | ||
8856 | DEFUN (show_bgp_community_list_exact, | |
8857 | show_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8858 | "show bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8859 | SHOW_STR |
8860 | BGP_STR | |
8861 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8862 | "community-list number\n" |
718e3744 | 8863 | "community-list name\n" |
8864 | "Exact match of the communities\n") | |
8865 | { | |
8866 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
8867 | } | |
8868 | ||
8869 | ALIAS (show_bgp_community_list_exact, | |
8870 | show_bgp_ipv6_community_list_exact_cmd, | |
fee6e4e4 | 8871 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
718e3744 | 8872 | SHOW_STR |
8873 | BGP_STR | |
8874 | "Address family\n" | |
8875 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8876 | "community-list number\n" |
718e3744 | 8877 | "community-list name\n" |
8878 | "Exact match of the communities\n") | |
8879 | ||
8880 | /* old command */ | |
8881 | DEFUN (show_ipv6_bgp_community_list_exact, | |
8882 | show_ipv6_bgp_community_list_exact_cmd, | |
8883 | "show ipv6 bgp community-list WORD exact-match", | |
8884 | SHOW_STR | |
8885 | IPV6_STR | |
8886 | BGP_STR | |
8887 | "Display routes matching the community-list\n" | |
8888 | "community-list name\n" | |
8889 | "Exact match of the communities\n") | |
8890 | { | |
8891 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
8892 | } | |
8893 | ||
8894 | /* old command */ | |
8895 | DEFUN (show_ipv6_mbgp_community_list_exact, | |
8896 | show_ipv6_mbgp_community_list_exact_cmd, | |
8897 | "show ipv6 mbgp community-list WORD exact-match", | |
8898 | SHOW_STR | |
8899 | IPV6_STR | |
8900 | MBGP_STR | |
8901 | "Display routes matching the community-list\n" | |
8902 | "community-list name\n" | |
8903 | "Exact match of the communities\n") | |
8904 | { | |
8905 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); | |
8906 | } | |
8907 | #endif /* HAVE_IPV6 */ | |
8908 | \f | |
94f2b392 | 8909 | static int |
fd79ac91 | 8910 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
718e3744 | 8911 | safi_t safi, enum bgp_show_type type) |
8912 | { | |
8913 | int ret; | |
8914 | struct prefix *p; | |
8915 | ||
8916 | p = prefix_new(); | |
8917 | ||
8918 | ret = str2prefix (prefix, p); | |
8919 | if (! ret) | |
8920 | { | |
8921 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); | |
8922 | return CMD_WARNING; | |
8923 | } | |
8924 | ||
5a646650 | 8925 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
8926 | prefix_free(p); | |
8927 | return ret; | |
718e3744 | 8928 | } |
8929 | ||
8930 | DEFUN (show_ip_bgp_prefix_longer, | |
8931 | show_ip_bgp_prefix_longer_cmd, | |
8932 | "show ip bgp A.B.C.D/M longer-prefixes", | |
8933 | SHOW_STR | |
8934 | IP_STR | |
8935 | BGP_STR | |
8936 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8937 | "Display route and more specific routes\n") | |
8938 | { | |
8939 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8940 | bgp_show_type_prefix_longer); | |
8941 | } | |
8942 | ||
8943 | DEFUN (show_ip_bgp_flap_prefix_longer, | |
8944 | show_ip_bgp_flap_prefix_longer_cmd, | |
8945 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", | |
8946 | SHOW_STR | |
8947 | IP_STR | |
8948 | BGP_STR | |
8949 | "Display flap statistics of routes\n" | |
8950 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8951 | "Display route and more specific routes\n") | |
8952 | { | |
8953 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8954 | bgp_show_type_flap_prefix_longer); | |
8955 | } | |
8956 | ||
8957 | DEFUN (show_ip_bgp_ipv4_prefix_longer, | |
8958 | show_ip_bgp_ipv4_prefix_longer_cmd, | |
8959 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", | |
8960 | SHOW_STR | |
8961 | IP_STR | |
8962 | BGP_STR | |
8963 | "Address family\n" | |
8964 | "Address Family modifier\n" | |
8965 | "Address Family modifier\n" | |
8966 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8967 | "Display route and more specific routes\n") | |
8968 | { | |
8969 | if (strncmp (argv[0], "m", 1) == 0) | |
8970 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
8971 | bgp_show_type_prefix_longer); | |
8972 | ||
8973 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
8974 | bgp_show_type_prefix_longer); | |
8975 | } | |
8976 | ||
8977 | DEFUN (show_ip_bgp_flap_address, | |
8978 | show_ip_bgp_flap_address_cmd, | |
8979 | "show ip bgp flap-statistics A.B.C.D", | |
8980 | SHOW_STR | |
8981 | IP_STR | |
8982 | BGP_STR | |
8983 | "Display flap statistics of routes\n" | |
8984 | "Network in the BGP routing table to display\n") | |
8985 | { | |
8986 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8987 | bgp_show_type_flap_address); | |
8988 | } | |
8989 | ||
8990 | DEFUN (show_ip_bgp_flap_prefix, | |
8991 | show_ip_bgp_flap_prefix_cmd, | |
8992 | "show ip bgp flap-statistics A.B.C.D/M", | |
8993 | SHOW_STR | |
8994 | IP_STR | |
8995 | BGP_STR | |
8996 | "Display flap statistics of routes\n" | |
8997 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
8998 | { | |
8999 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
9000 | bgp_show_type_flap_prefix); | |
9001 | } | |
9002 | #ifdef HAVE_IPV6 | |
9003 | DEFUN (show_bgp_prefix_longer, | |
9004 | show_bgp_prefix_longer_cmd, | |
9005 | "show bgp X:X::X:X/M longer-prefixes", | |
9006 | SHOW_STR | |
9007 | BGP_STR | |
9008 | "IPv6 prefix <network>/<length>\n" | |
9009 | "Display route and more specific routes\n") | |
9010 | { | |
9011 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
9012 | bgp_show_type_prefix_longer); | |
9013 | } | |
9014 | ||
9015 | ALIAS (show_bgp_prefix_longer, | |
9016 | show_bgp_ipv6_prefix_longer_cmd, | |
9017 | "show bgp ipv6 X:X::X:X/M longer-prefixes", | |
9018 | SHOW_STR | |
9019 | BGP_STR | |
9020 | "Address family\n" | |
9021 | "IPv6 prefix <network>/<length>\n" | |
9022 | "Display route and more specific routes\n") | |
9023 | ||
9024 | /* old command */ | |
9025 | DEFUN (show_ipv6_bgp_prefix_longer, | |
9026 | show_ipv6_bgp_prefix_longer_cmd, | |
9027 | "show ipv6 bgp X:X::X:X/M longer-prefixes", | |
9028 | SHOW_STR | |
9029 | IPV6_STR | |
9030 | BGP_STR | |
9031 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
9032 | "Display route and more specific routes\n") | |
9033 | { | |
9034 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
9035 | bgp_show_type_prefix_longer); | |
9036 | } | |
9037 | ||
9038 | /* old command */ | |
9039 | DEFUN (show_ipv6_mbgp_prefix_longer, | |
9040 | show_ipv6_mbgp_prefix_longer_cmd, | |
9041 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", | |
9042 | SHOW_STR | |
9043 | IPV6_STR | |
9044 | MBGP_STR | |
9045 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
9046 | "Display route and more specific routes\n") | |
9047 | { | |
9048 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
9049 | bgp_show_type_prefix_longer); | |
9050 | } | |
9051 | #endif /* HAVE_IPV6 */ | |
bb46e94f | 9052 | |
94f2b392 | 9053 | static struct peer * |
fd79ac91 | 9054 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
9055 | const char *ip_str) | |
bb46e94f | 9056 | { |
9057 | int ret; | |
9058 | struct bgp *bgp; | |
9059 | struct peer *peer; | |
9060 | union sockunion su; | |
9061 | ||
9062 | /* BGP structure lookup. */ | |
9063 | if (view_name) | |
9064 | { | |
9065 | bgp = bgp_lookup_by_name (view_name); | |
9066 | if (! bgp) | |
9067 | { | |
9068 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
9069 | return NULL; | |
9070 | } | |
9071 | } | |
5228ad27 | 9072 | else |
bb46e94f | 9073 | { |
9074 | bgp = bgp_get_default (); | |
9075 | if (! bgp) | |
9076 | { | |
9077 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
9078 | return NULL; | |
9079 | } | |
9080 | } | |
9081 | ||
9082 | /* Get peer sockunion. */ | |
9083 | ret = str2sockunion (ip_str, &su); | |
9084 | if (ret < 0) | |
9085 | { | |
9086 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); | |
9087 | return NULL; | |
9088 | } | |
9089 | ||
9090 | /* Peer structure lookup. */ | |
9091 | peer = peer_lookup (bgp, &su); | |
9092 | if (! peer) | |
9093 | { | |
9094 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); | |
9095 | return NULL; | |
9096 | } | |
9097 | ||
9098 | return peer; | |
9099 | } | |
2815e61f PJ |
9100 | \f |
9101 | enum bgp_stats | |
9102 | { | |
9103 | BGP_STATS_MAXBITLEN = 0, | |
9104 | BGP_STATS_RIB, | |
9105 | BGP_STATS_PREFIXES, | |
9106 | BGP_STATS_TOTPLEN, | |
9107 | BGP_STATS_UNAGGREGATEABLE, | |
9108 | BGP_STATS_MAX_AGGREGATEABLE, | |
9109 | BGP_STATS_AGGREGATES, | |
9110 | BGP_STATS_SPACE, | |
9111 | BGP_STATS_ASPATH_COUNT, | |
9112 | BGP_STATS_ASPATH_MAXHOPS, | |
9113 | BGP_STATS_ASPATH_TOTHOPS, | |
9114 | BGP_STATS_ASPATH_MAXSIZE, | |
9115 | BGP_STATS_ASPATH_TOTSIZE, | |
9116 | BGP_STATS_ASN_HIGHEST, | |
9117 | BGP_STATS_MAX, | |
9118 | }; | |
9119 | ||
9120 | static const char *table_stats_strs[] = | |
9121 | { | |
9122 | [BGP_STATS_PREFIXES] = "Total Prefixes", | |
9123 | [BGP_STATS_TOTPLEN] = "Average prefix length", | |
9124 | [BGP_STATS_RIB] = "Total Advertisements", | |
9125 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", | |
9126 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", | |
9127 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", | |
9128 | [BGP_STATS_SPACE] = "Address space advertised", | |
9129 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", | |
9130 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", | |
9131 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", | |
9132 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", | |
9133 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", | |
9134 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", | |
9135 | [BGP_STATS_MAX] = NULL, | |
9136 | }; | |
9137 | ||
9138 | struct bgp_table_stats | |
9139 | { | |
9140 | struct bgp_table *table; | |
9141 | unsigned long long counts[BGP_STATS_MAX]; | |
9142 | }; | |
9143 | ||
9144 | #if 0 | |
9145 | #define TALLY_SIGFIG 100000 | |
9146 | static unsigned long | |
9147 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) | |
9148 | { | |
9149 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); | |
9150 | unsigned long res = (newtot * TALLY_SIGFIG) / count; | |
9151 | unsigned long ret = newtot / count; | |
9152 | ||
9153 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) | |
9154 | return ret + 1; | |
9155 | else | |
9156 | return ret; | |
9157 | } | |
9158 | #endif | |
9159 | ||
9160 | static int | |
9161 | bgp_table_stats_walker (struct thread *t) | |
9162 | { | |
9163 | struct bgp_node *rn; | |
9164 | struct bgp_node *top; | |
9165 | struct bgp_table_stats *ts = THREAD_ARG (t); | |
9166 | unsigned int space = 0; | |
9167 | ||
53d9f67a PJ |
9168 | if (!(top = bgp_table_top (ts->table))) |
9169 | return 0; | |
2815e61f PJ |
9170 | |
9171 | switch (top->p.family) | |
9172 | { | |
9173 | case AF_INET: | |
9174 | space = IPV4_MAX_BITLEN; | |
9175 | break; | |
9176 | case AF_INET6: | |
9177 | space = IPV6_MAX_BITLEN; | |
9178 | break; | |
9179 | } | |
9180 | ||
9181 | ts->counts[BGP_STATS_MAXBITLEN] = space; | |
9182 | ||
9183 | for (rn = top; rn; rn = bgp_route_next (rn)) | |
9184 | { | |
9185 | struct bgp_info *ri; | |
9186 | struct bgp_node *prn = rn->parent; | |
9187 | unsigned int rinum = 0; | |
9188 | ||
9189 | if (rn == top) | |
9190 | continue; | |
9191 | ||
9192 | if (!rn->info) | |
9193 | continue; | |
9194 | ||
9195 | ts->counts[BGP_STATS_PREFIXES]++; | |
9196 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; | |
9197 | ||
9198 | #if 0 | |
9199 | ts->counts[BGP_STATS_AVGPLEN] | |
9200 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], | |
9201 | ts->counts[BGP_STATS_AVGPLEN], | |
9202 | rn->p.prefixlen); | |
9203 | #endif | |
9204 | ||
9205 | /* check if the prefix is included by any other announcements */ | |
9206 | while (prn && !prn->info) | |
9207 | prn = prn->parent; | |
9208 | ||
9209 | if (prn == NULL || prn == top) | |
8383a9bd PJ |
9210 | { |
9211 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; | |
9212 | /* announced address space */ | |
9213 | if (space) | |
9214 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); | |
9215 | } | |
2815e61f PJ |
9216 | else if (prn->info) |
9217 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; | |
9218 | ||
2815e61f PJ |
9219 | for (ri = rn->info; ri; ri = ri->next) |
9220 | { | |
9221 | rinum++; | |
9222 | ts->counts[BGP_STATS_RIB]++; | |
9223 | ||
9224 | if (ri->attr && | |
9225 | (CHECK_FLAG (ri->attr->flag, | |
9226 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) | |
9227 | ts->counts[BGP_STATS_AGGREGATES]++; | |
9228 | ||
9229 | /* as-path stats */ | |
9230 | if (ri->attr && ri->attr->aspath) | |
9231 | { | |
9232 | unsigned int hops = aspath_count_hops (ri->attr->aspath); | |
9233 | unsigned int size = aspath_size (ri->attr->aspath); | |
9234 | as_t highest = aspath_highest (ri->attr->aspath); | |
9235 | ||
9236 | ts->counts[BGP_STATS_ASPATH_COUNT]++; | |
9237 | ||
9238 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) | |
9239 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; | |
9240 | ||
9241 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) | |
9242 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; | |
9243 | ||
9244 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; | |
9245 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; | |
9246 | #if 0 | |
9247 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] | |
9248 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9249 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], | |
9250 | hops); | |
9251 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] | |
9252 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9253 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], | |
9254 | size); | |
9255 | #endif | |
9256 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) | |
9257 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; | |
9258 | } | |
9259 | } | |
9260 | } | |
9261 | return 0; | |
9262 | } | |
9263 | ||
9264 | static int | |
9265 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) | |
9266 | { | |
9267 | struct bgp_table_stats ts; | |
9268 | unsigned int i; | |
9269 | ||
9270 | if (!bgp->rib[afi][safi]) | |
9271 | { | |
9272 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); | |
9273 | return CMD_WARNING; | |
9274 | } | |
9275 | ||
9276 | memset (&ts, 0, sizeof (ts)); | |
9277 | ts.table = bgp->rib[afi][safi]; | |
9278 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); | |
bb46e94f | 9279 | |
2815e61f PJ |
9280 | vty_out (vty, "BGP %s RIB statistics%s%s", |
9281 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); | |
9282 | ||
9283 | for (i = 0; i < BGP_STATS_MAX; i++) | |
9284 | { | |
9285 | if (!table_stats_strs[i]) | |
9286 | continue; | |
9287 | ||
9288 | switch (i) | |
9289 | { | |
9290 | #if 0 | |
9291 | case BGP_STATS_ASPATH_AVGHOPS: | |
9292 | case BGP_STATS_ASPATH_AVGSIZE: | |
9293 | case BGP_STATS_AVGPLEN: | |
9294 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9295 | vty_out (vty, "%12.2f", | |
9296 | (float)ts.counts[i] / (float)TALLY_SIGFIG); | |
9297 | break; | |
9298 | #endif | |
9299 | case BGP_STATS_ASPATH_TOTHOPS: | |
9300 | case BGP_STATS_ASPATH_TOTSIZE: | |
9301 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9302 | vty_out (vty, "%12.2f", | |
9303 | ts.counts[i] ? | |
9304 | (float)ts.counts[i] / | |
9305 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] | |
9306 | : 0); | |
9307 | break; | |
9308 | case BGP_STATS_TOTPLEN: | |
9309 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9310 | vty_out (vty, "%12.2f", | |
9311 | ts.counts[i] ? | |
9312 | (float)ts.counts[i] / | |
9313 | (float)ts.counts[BGP_STATS_PREFIXES] | |
9314 | : 0); | |
9315 | break; | |
9316 | case BGP_STATS_SPACE: | |
9317 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9318 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); | |
9319 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) | |
9320 | break; | |
30a2231a | 9321 | vty_out (vty, "%30s: ", "%% announced "); |
2815e61f PJ |
9322 | vty_out (vty, "%12.2f%s", |
9323 | 100 * (float)ts.counts[BGP_STATS_SPACE] / | |
56395af7 | 9324 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
2815e61f PJ |
9325 | VTY_NEWLINE); |
9326 | vty_out (vty, "%30s: ", "/8 equivalent "); | |
9327 | vty_out (vty, "%12.2f%s", | |
9328 | (float)ts.counts[BGP_STATS_SPACE] / | |
9329 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), | |
9330 | VTY_NEWLINE); | |
9331 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) | |
9332 | break; | |
9333 | vty_out (vty, "%30s: ", "/24 equivalent "); | |
9334 | vty_out (vty, "%12.2f", | |
9335 | (float)ts.counts[BGP_STATS_SPACE] / | |
9336 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); | |
9337 | break; | |
9338 | default: | |
9339 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9340 | vty_out (vty, "%12llu", ts.counts[i]); | |
9341 | } | |
9342 | ||
9343 | vty_out (vty, "%s", VTY_NEWLINE); | |
9344 | } | |
9345 | return CMD_SUCCESS; | |
9346 | } | |
9347 | ||
9348 | static int | |
9349 | bgp_table_stats_vty (struct vty *vty, const char *name, | |
9350 | const char *afi_str, const char *safi_str) | |
9351 | { | |
9352 | struct bgp *bgp; | |
9353 | afi_t afi; | |
9354 | safi_t safi; | |
9355 | ||
9356 | if (name) | |
9357 | bgp = bgp_lookup_by_name (name); | |
9358 | else | |
9359 | bgp = bgp_get_default (); | |
9360 | ||
9361 | if (!bgp) | |
9362 | { | |
9363 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9364 | return CMD_WARNING; | |
9365 | } | |
9366 | if (strncmp (afi_str, "ipv", 3) == 0) | |
9367 | { | |
9368 | if (strncmp (afi_str, "ipv4", 4) == 0) | |
9369 | afi = AFI_IP; | |
9370 | else if (strncmp (afi_str, "ipv6", 4) == 0) | |
9371 | afi = AFI_IP6; | |
9372 | else | |
9373 | { | |
9374 | vty_out (vty, "%% Invalid address family %s%s", | |
9375 | afi_str, VTY_NEWLINE); | |
9376 | return CMD_WARNING; | |
9377 | } | |
9378 | if (strncmp (safi_str, "m", 1) == 0) | |
9379 | safi = SAFI_MULTICAST; | |
9380 | else if (strncmp (safi_str, "u", 1) == 0) | |
9381 | safi = SAFI_UNICAST; | |
42e6d745 DO |
9382 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
9383 | safi = SAFI_MPLS_LABELED_VPN; | |
2815e61f PJ |
9384 | else |
9385 | { | |
9386 | vty_out (vty, "%% Invalid subsequent address family %s%s", | |
9387 | safi_str, VTY_NEWLINE); | |
9388 | return CMD_WARNING; | |
9389 | } | |
9390 | } | |
9391 | else | |
9392 | { | |
9393 | vty_out (vty, "%% Invalid address family %s%s", | |
9394 | afi_str, VTY_NEWLINE); | |
9395 | return CMD_WARNING; | |
9396 | } | |
9397 | ||
2815e61f PJ |
9398 | return bgp_table_stats (vty, bgp, afi, safi); |
9399 | } | |
9400 | ||
9401 | DEFUN (show_bgp_statistics, | |
9402 | show_bgp_statistics_cmd, | |
9403 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", | |
9404 | SHOW_STR | |
9405 | BGP_STR | |
9406 | "Address family\n" | |
9407 | "Address family\n" | |
9408 | "Address Family modifier\n" | |
9409 | "Address Family modifier\n" | |
9410 | "BGP RIB advertisement statistics\n") | |
9411 | { | |
9412 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9413 | } | |
9414 | ||
9415 | ALIAS (show_bgp_statistics, | |
9416 | show_bgp_statistics_vpnv4_cmd, | |
9417 | "show bgp (ipv4) (vpnv4) statistics", | |
9418 | SHOW_STR | |
9419 | BGP_STR | |
9420 | "Address family\n" | |
9421 | "Address Family modifier\n" | |
9422 | "BGP RIB advertisement statistics\n") | |
9423 | ||
9424 | DEFUN (show_bgp_statistics_view, | |
9425 | show_bgp_statistics_view_cmd, | |
9426 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", | |
9427 | SHOW_STR | |
9428 | BGP_STR | |
9429 | "BGP view\n" | |
9430 | "Address family\n" | |
9431 | "Address family\n" | |
9432 | "Address Family modifier\n" | |
9433 | "Address Family modifier\n" | |
9434 | "BGP RIB advertisement statistics\n") | |
9435 | { | |
9436 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9437 | } | |
9438 | ||
9439 | ALIAS (show_bgp_statistics_view, | |
9440 | show_bgp_statistics_view_vpnv4_cmd, | |
9441 | "show bgp view WORD (ipv4) (vpnv4) statistics", | |
9442 | SHOW_STR | |
9443 | BGP_STR | |
9444 | "BGP view\n" | |
9445 | "Address family\n" | |
9446 | "Address Family modifier\n" | |
9447 | "BGP RIB advertisement statistics\n") | |
9448 | \f | |
ff7924f6 PJ |
9449 | enum bgp_pcounts |
9450 | { | |
9451 | PCOUNT_ADJ_IN = 0, | |
9452 | PCOUNT_DAMPED, | |
9453 | PCOUNT_REMOVED, | |
9454 | PCOUNT_HISTORY, | |
9455 | PCOUNT_STALE, | |
9456 | PCOUNT_VALID, | |
9457 | PCOUNT_ALL, | |
9458 | PCOUNT_COUNTED, | |
9459 | PCOUNT_PFCNT, /* the figure we display to users */ | |
9460 | PCOUNT_MAX, | |
9461 | }; | |
9462 | ||
9463 | static const char *pcount_strs[] = | |
9464 | { | |
9465 | [PCOUNT_ADJ_IN] = "Adj-in", | |
9466 | [PCOUNT_DAMPED] = "Damped", | |
9467 | [PCOUNT_REMOVED] = "Removed", | |
9468 | [PCOUNT_HISTORY] = "History", | |
9469 | [PCOUNT_STALE] = "Stale", | |
9470 | [PCOUNT_VALID] = "Valid", | |
9471 | [PCOUNT_ALL] = "All RIB", | |
9472 | [PCOUNT_COUNTED] = "PfxCt counted", | |
9473 | [PCOUNT_PFCNT] = "Useable", | |
9474 | [PCOUNT_MAX] = NULL, | |
9475 | }; | |
9476 | ||
2815e61f PJ |
9477 | struct peer_pcounts |
9478 | { | |
9479 | unsigned int count[PCOUNT_MAX]; | |
9480 | const struct peer *peer; | |
9481 | const struct bgp_table *table; | |
9482 | }; | |
9483 | ||
ff7924f6 | 9484 | static int |
2815e61f | 9485 | bgp_peer_count_walker (struct thread *t) |
ff7924f6 PJ |
9486 | { |
9487 | struct bgp_node *rn; | |
2815e61f PJ |
9488 | struct peer_pcounts *pc = THREAD_ARG (t); |
9489 | const struct peer *peer = pc->peer; | |
ff7924f6 | 9490 | |
2815e61f | 9491 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
ff7924f6 PJ |
9492 | { |
9493 | struct bgp_adj_in *ain; | |
2815e61f | 9494 | struct bgp_info *ri; |
ff7924f6 PJ |
9495 | |
9496 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9497 | if (ain->peer == peer) | |
2815e61f | 9498 | pc->count[PCOUNT_ADJ_IN]++; |
ff7924f6 | 9499 | |
ff7924f6 PJ |
9500 | for (ri = rn->info; ri; ri = ri->next) |
9501 | { | |
9502 | char buf[SU_ADDRSTRLEN]; | |
9503 | ||
9504 | if (ri->peer != peer) | |
9505 | continue; | |
9506 | ||
2815e61f | 9507 | pc->count[PCOUNT_ALL]++; |
ff7924f6 PJ |
9508 | |
9509 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) | |
2815e61f | 9510 | pc->count[PCOUNT_DAMPED]++; |
ff7924f6 | 9511 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2815e61f | 9512 | pc->count[PCOUNT_HISTORY]++; |
ff7924f6 | 9513 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
2815e61f | 9514 | pc->count[PCOUNT_REMOVED]++; |
ff7924f6 | 9515 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
2815e61f | 9516 | pc->count[PCOUNT_STALE]++; |
ff7924f6 | 9517 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
2815e61f | 9518 | pc->count[PCOUNT_VALID]++; |
1a392d46 | 9519 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2815e61f | 9520 | pc->count[PCOUNT_PFCNT]++; |
ff7924f6 PJ |
9521 | |
9522 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
9523 | { | |
2815e61f | 9524 | pc->count[PCOUNT_COUNTED]++; |
1a392d46 | 9525 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9526 | plog_warn (peer->log, |
9527 | "%s [pcount] %s/%d is counted but flags 0x%x", | |
9528 | peer->host, | |
9529 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9530 | buf, SU_ADDRSTRLEN), | |
9531 | rn->p.prefixlen, | |
9532 | ri->flags); | |
9533 | } | |
9534 | else | |
9535 | { | |
1a392d46 | 9536 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9537 | plog_warn (peer->log, |
9538 | "%s [pcount] %s/%d not counted but flags 0x%x", | |
9539 | peer->host, | |
9540 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9541 | buf, SU_ADDRSTRLEN), | |
9542 | rn->p.prefixlen, | |
9543 | ri->flags); | |
9544 | } | |
9545 | } | |
9546 | } | |
2815e61f PJ |
9547 | return 0; |
9548 | } | |
ff7924f6 | 9549 | |
2815e61f PJ |
9550 | static int |
9551 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) | |
9552 | { | |
9553 | struct peer_pcounts pcounts = { .peer = peer }; | |
9554 | unsigned int i; | |
9555 | ||
9556 | if (!peer || !peer->bgp || !peer->afc[afi][safi] | |
9557 | || !peer->bgp->rib[afi][safi]) | |
9558 | { | |
9559 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9560 | return CMD_WARNING; | |
9561 | } | |
9562 | ||
9563 | memset (&pcounts, 0, sizeof(pcounts)); | |
9564 | pcounts.peer = peer; | |
9565 | pcounts.table = peer->bgp->rib[afi][safi]; | |
9566 | ||
9567 | /* in-place call via thread subsystem so as to record execution time | |
9568 | * stats for the thread-walk (i.e. ensure this can't be blamed on | |
9569 | * on just vty_read()). | |
9570 | */ | |
9571 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); | |
9572 | ||
ff7924f6 PJ |
9573 | vty_out (vty, "Prefix counts for %s, %s%s", |
9574 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); | |
9575 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); | |
9576 | vty_out (vty, "%sCounts from RIB table walk:%s%s", | |
9577 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
9578 | ||
9579 | for (i = 0; i < PCOUNT_MAX; i++) | |
2815e61f PJ |
9580 | vty_out (vty, "%20s: %-10d%s", |
9581 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); | |
ff7924f6 | 9582 | |
2815e61f | 9583 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
ff7924f6 PJ |
9584 | { |
9585 | vty_out (vty, "%s [pcount] PfxCt drift!%s", | |
9586 | peer->host, VTY_NEWLINE); | |
9587 | vty_out (vty, "Please report this bug, with the above command output%s", | |
9588 | VTY_NEWLINE); | |
9589 | } | |
9590 | ||
9591 | return CMD_SUCCESS; | |
9592 | } | |
9593 | ||
9594 | DEFUN (show_ip_bgp_neighbor_prefix_counts, | |
9595 | show_ip_bgp_neighbor_prefix_counts_cmd, | |
9596 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9597 | SHOW_STR | |
9598 | IP_STR | |
9599 | BGP_STR | |
9600 | "Detailed information on TCP and BGP neighbor connections\n" | |
9601 | "Neighbor to display information about\n" | |
9602 | "Neighbor to display information about\n" | |
9603 | "Display detailed prefix count information\n") | |
9604 | { | |
9605 | struct peer *peer; | |
9606 | ||
9607 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9608 | if (! peer) | |
9609 | return CMD_WARNING; | |
9610 | ||
9611 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9612 | } | |
9613 | ||
9614 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, | |
9615 | show_bgp_ipv6_neighbor_prefix_counts_cmd, | |
9616 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9617 | SHOW_STR | |
9618 | BGP_STR | |
9619 | "Address family\n" | |
9620 | "Detailed information on TCP and BGP neighbor connections\n" | |
9621 | "Neighbor to display information about\n" | |
9622 | "Neighbor to display information about\n" | |
9623 | "Display detailed prefix count information\n") | |
9624 | { | |
9625 | struct peer *peer; | |
9626 | ||
9627 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9628 | if (! peer) | |
9629 | return CMD_WARNING; | |
9630 | ||
9631 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); | |
9632 | } | |
9633 | ||
9634 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, | |
9635 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, | |
9636 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9637 | SHOW_STR | |
9638 | IP_STR | |
9639 | BGP_STR | |
9640 | "Address family\n" | |
9641 | "Address Family modifier\n" | |
9642 | "Address Family modifier\n" | |
9643 | "Detailed information on TCP and BGP neighbor connections\n" | |
9644 | "Neighbor to display information about\n" | |
9645 | "Neighbor to display information about\n" | |
9646 | "Display detailed prefix count information\n") | |
9647 | { | |
9648 | struct peer *peer; | |
9649 | ||
9650 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9651 | if (! peer) | |
9652 | return CMD_WARNING; | |
9653 | ||
9654 | if (strncmp (argv[0], "m", 1) == 0) | |
9655 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); | |
9656 | ||
9657 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9658 | } | |
9659 | ||
9660 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, | |
9661 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, | |
9662 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9663 | SHOW_STR | |
9664 | IP_STR | |
9665 | BGP_STR | |
9666 | "Address family\n" | |
9667 | "Address Family modifier\n" | |
9668 | "Address Family modifier\n" | |
9669 | "Detailed information on TCP and BGP neighbor connections\n" | |
9670 | "Neighbor to display information about\n" | |
9671 | "Neighbor to display information about\n" | |
9672 | "Display detailed prefix count information\n") | |
9673 | { | |
9674 | struct peer *peer; | |
9675 | ||
9676 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9677 | if (! peer) | |
9678 | return CMD_WARNING; | |
9679 | ||
9680 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); | |
9681 | } | |
9682 | ||
9683 | ||
94f2b392 | 9684 | static void |
718e3744 | 9685 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
9686 | int in) | |
9687 | { | |
9688 | struct bgp_table *table; | |
9689 | struct bgp_adj_in *ain; | |
9690 | struct bgp_adj_out *adj; | |
9691 | unsigned long output_count; | |
9692 | struct bgp_node *rn; | |
9693 | int header1 = 1; | |
9694 | struct bgp *bgp; | |
9695 | int header2 = 1; | |
9696 | ||
bb46e94f | 9697 | bgp = peer->bgp; |
718e3744 | 9698 | |
9699 | if (! bgp) | |
9700 | return; | |
9701 | ||
9702 | table = bgp->rib[afi][safi]; | |
9703 | ||
9704 | output_count = 0; | |
9705 | ||
9706 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], | |
9707 | PEER_STATUS_DEFAULT_ORIGINATE)) | |
9708 | { | |
9709 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9710 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9711 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9712 | |
9713 | vty_out (vty, "Originating default network 0.0.0.0%s%s", | |
9714 | VTY_NEWLINE, VTY_NEWLINE); | |
9715 | header1 = 0; | |
9716 | } | |
9717 | ||
9718 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
9719 | if (in) | |
9720 | { | |
9721 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9722 | if (ain->peer == peer) | |
9723 | { | |
9724 | if (header1) | |
9725 | { | |
9726 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9727 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9728 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9729 | header1 = 0; |
9730 | } | |
9731 | if (header2) | |
9732 | { | |
9733 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9734 | header2 = 0; | |
9735 | } | |
9736 | if (ain->attr) | |
9737 | { | |
9738 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); | |
9739 | output_count++; | |
9740 | } | |
9741 | } | |
9742 | } | |
9743 | else | |
9744 | { | |
9745 | for (adj = rn->adj_out; adj; adj = adj->next) | |
9746 | if (adj->peer == peer) | |
9747 | { | |
9748 | if (header1) | |
9749 | { | |
9750 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9751 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9752 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9753 | header1 = 0; |
9754 | } | |
9755 | if (header2) | |
9756 | { | |
9757 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9758 | header2 = 0; | |
9759 | } | |
9760 | if (adj->attr) | |
9761 | { | |
9762 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); | |
9763 | output_count++; | |
9764 | } | |
9765 | } | |
9766 | } | |
9767 | ||
9768 | if (output_count != 0) | |
9769 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
9770 | VTY_NEWLINE, output_count, VTY_NEWLINE); | |
9771 | } | |
9772 | ||
94f2b392 | 9773 | static int |
bb46e94f | 9774 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
9775 | { | |
718e3744 | 9776 | if (! peer || ! peer->afc[afi][safi]) |
9777 | { | |
9778 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9779 | return CMD_WARNING; | |
9780 | } | |
9781 | ||
9782 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9783 | { | |
9784 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", | |
9785 | VTY_NEWLINE); | |
9786 | return CMD_WARNING; | |
9787 | } | |
9788 | ||
9789 | show_adj_route (vty, peer, afi, safi, in); | |
9790 | ||
9791 | return CMD_SUCCESS; | |
9792 | } | |
9793 | ||
2a71e9ce TP |
9794 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
9795 | show_ip_bgp_view_neighbor_advertised_route_cmd, | |
9796 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9797 | SHOW_STR |
9798 | IP_STR | |
9799 | BGP_STR | |
2a71e9ce TP |
9800 | "BGP view\n" |
9801 | "View name\n" | |
718e3744 | 9802 | "Detailed information on TCP and BGP neighbor connections\n" |
9803 | "Neighbor to display information about\n" | |
9804 | "Neighbor to display information about\n" | |
9805 | "Display the routes advertised to a BGP neighbor\n") | |
9806 | { | |
bb46e94f | 9807 | struct peer *peer; |
9808 | ||
2a71e9ce TP |
9809 | if (argc == 2) |
9810 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9811 | else | |
9812 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9813 | ||
bb46e94f | 9814 | if (! peer) |
9815 | return CMD_WARNING; | |
9816 | ||
9817 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); | |
718e3744 | 9818 | } |
9819 | ||
2a71e9ce TP |
9820 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
9821 | show_ip_bgp_neighbor_advertised_route_cmd, | |
9822 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9823 | SHOW_STR | |
9824 | IP_STR | |
9825 | BGP_STR | |
9826 | "Detailed information on TCP and BGP neighbor connections\n" | |
9827 | "Neighbor to display information about\n" | |
9828 | "Neighbor to display information about\n" | |
9829 | "Display the routes advertised to a BGP neighbor\n") | |
9830 | ||
718e3744 | 9831 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
9832 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, | |
9833 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9834 | SHOW_STR | |
9835 | IP_STR | |
9836 | BGP_STR | |
9837 | "Address family\n" | |
9838 | "Address Family modifier\n" | |
9839 | "Address Family modifier\n" | |
9840 | "Detailed information on TCP and BGP neighbor connections\n" | |
9841 | "Neighbor to display information about\n" | |
9842 | "Neighbor to display information about\n" | |
9843 | "Display the routes advertised to a BGP neighbor\n") | |
9844 | { | |
bb46e94f | 9845 | struct peer *peer; |
9846 | ||
9847 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9848 | if (! peer) | |
9849 | return CMD_WARNING; | |
9850 | ||
718e3744 | 9851 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 9852 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
718e3744 | 9853 | |
bb46e94f | 9854 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
718e3744 | 9855 | } |
9856 | ||
9857 | #ifdef HAVE_IPV6 | |
bb46e94f | 9858 | DEFUN (show_bgp_view_neighbor_advertised_route, |
9859 | show_bgp_view_neighbor_advertised_route_cmd, | |
9860 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9861 | SHOW_STR |
9862 | BGP_STR | |
bb46e94f | 9863 | "BGP view\n" |
9864 | "View name\n" | |
718e3744 | 9865 | "Detailed information on TCP and BGP neighbor connections\n" |
9866 | "Neighbor to display information about\n" | |
9867 | "Neighbor to display information about\n" | |
9868 | "Display the routes advertised to a BGP neighbor\n") | |
9869 | { | |
bb46e94f | 9870 | struct peer *peer; |
9871 | ||
9872 | if (argc == 2) | |
9873 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9874 | else | |
9875 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9876 | ||
9877 | if (! peer) | |
9878 | return CMD_WARNING; | |
9879 | ||
9880 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); | |
9881 | } | |
9882 | ||
9883 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
9884 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, | |
9885 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9886 | SHOW_STR | |
9887 | BGP_STR | |
9888 | "BGP view\n" | |
9889 | "View name\n" | |
9890 | "Address family\n" | |
9891 | "Detailed information on TCP and BGP neighbor connections\n" | |
9892 | "Neighbor to display information about\n" | |
9893 | "Neighbor to display information about\n" | |
9894 | "Display the routes advertised to a BGP neighbor\n") | |
9895 | ||
9896 | DEFUN (show_bgp_view_neighbor_received_routes, | |
9897 | show_bgp_view_neighbor_received_routes_cmd, | |
9898 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9899 | SHOW_STR | |
9900 | BGP_STR | |
9901 | "BGP view\n" | |
9902 | "View name\n" | |
9903 | "Detailed information on TCP and BGP neighbor connections\n" | |
9904 | "Neighbor to display information about\n" | |
9905 | "Neighbor to display information about\n" | |
9906 | "Display the received routes from neighbor\n") | |
9907 | { | |
9908 | struct peer *peer; | |
9909 | ||
9910 | if (argc == 2) | |
9911 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9912 | else | |
9913 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9914 | ||
9915 | if (! peer) | |
9916 | return CMD_WARNING; | |
9917 | ||
9918 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); | |
718e3744 | 9919 | } |
9920 | ||
bb46e94f | 9921 | ALIAS (show_bgp_view_neighbor_received_routes, |
9922 | show_bgp_view_ipv6_neighbor_received_routes_cmd, | |
9923 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9924 | SHOW_STR | |
9925 | BGP_STR | |
9926 | "BGP view\n" | |
9927 | "View name\n" | |
9928 | "Address family\n" | |
9929 | "Detailed information on TCP and BGP neighbor connections\n" | |
9930 | "Neighbor to display information about\n" | |
9931 | "Neighbor to display information about\n" | |
9932 | "Display the received routes from neighbor\n") | |
9933 | ||
9934 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
9935 | show_bgp_neighbor_advertised_route_cmd, | |
9936 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9937 | SHOW_STR | |
9938 | BGP_STR | |
9939 | "Detailed information on TCP and BGP neighbor connections\n" | |
9940 | "Neighbor to display information about\n" | |
9941 | "Neighbor to display information about\n" | |
9942 | "Display the routes advertised to a BGP neighbor\n") | |
9943 | ||
9944 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
718e3744 | 9945 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
9946 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9947 | SHOW_STR | |
9948 | BGP_STR | |
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 | /* old command */ | |
bb46e94f | 9956 | ALIAS (show_bgp_view_neighbor_advertised_route, |
718e3744 | 9957 | ipv6_bgp_neighbor_advertised_route_cmd, |
9958 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9959 | SHOW_STR | |
9960 | IPV6_STR | |
9961 | BGP_STR | |
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 routes advertised to a BGP neighbor\n") | |
bb46e94f | 9966 | |
718e3744 | 9967 | /* old command */ |
9968 | DEFUN (ipv6_mbgp_neighbor_advertised_route, | |
9969 | ipv6_mbgp_neighbor_advertised_route_cmd, | |
9970 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9971 | SHOW_STR | |
9972 | IPV6_STR | |
9973 | MBGP_STR | |
9974 | "Detailed information on TCP and BGP neighbor connections\n" | |
9975 | "Neighbor to display information about\n" | |
9976 | "Neighbor to display information about\n" | |
9977 | "Display the routes advertised to a BGP neighbor\n") | |
9978 | { | |
bb46e94f | 9979 | struct peer *peer; |
9980 | ||
9981 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9982 | if (! peer) | |
9983 | return CMD_WARNING; | |
9984 | ||
9985 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); | |
718e3744 | 9986 | } |
9987 | #endif /* HAVE_IPV6 */ | |
9988 | \f | |
2a71e9ce TP |
9989 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
9990 | show_ip_bgp_view_neighbor_received_routes_cmd, | |
9991 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
718e3744 | 9992 | SHOW_STR |
9993 | IP_STR | |
9994 | BGP_STR | |
2a71e9ce TP |
9995 | "BGP view\n" |
9996 | "View name\n" | |
718e3744 | 9997 | "Detailed information on TCP and BGP neighbor connections\n" |
9998 | "Neighbor to display information about\n" | |
9999 | "Neighbor to display information about\n" | |
10000 | "Display the received routes from neighbor\n") | |
10001 | { | |
bb46e94f | 10002 | struct peer *peer; |
10003 | ||
2a71e9ce TP |
10004 | if (argc == 2) |
10005 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10006 | else | |
10007 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10008 | ||
bb46e94f | 10009 | if (! peer) |
10010 | return CMD_WARNING; | |
10011 | ||
10012 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); | |
718e3744 | 10013 | } |
10014 | ||
2a71e9ce TP |
10015 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
10016 | show_ip_bgp_neighbor_received_routes_cmd, | |
10017 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10018 | SHOW_STR | |
10019 | IP_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 received routes from neighbor\n") | |
10025 | ||
718e3744 | 10026 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
10027 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, | |
10028 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10029 | SHOW_STR | |
10030 | IP_STR | |
10031 | BGP_STR | |
10032 | "Address family\n" | |
10033 | "Address Family modifier\n" | |
10034 | "Address Family modifier\n" | |
10035 | "Detailed information on TCP and BGP neighbor connections\n" | |
10036 | "Neighbor to display information about\n" | |
10037 | "Neighbor to display information about\n" | |
10038 | "Display the received routes from neighbor\n") | |
10039 | { | |
bb46e94f | 10040 | struct peer *peer; |
10041 | ||
10042 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10043 | if (! peer) | |
10044 | return CMD_WARNING; | |
10045 | ||
718e3744 | 10046 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 10047 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
718e3744 | 10048 | |
bb46e94f | 10049 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
718e3744 | 10050 | } |
10051 | ||
95cbbd2a ML |
10052 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
10053 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, | |
10054 | #ifdef HAVE_IPV6 | |
10055 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", | |
10056 | #else | |
10057 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", | |
10058 | #endif | |
10059 | SHOW_STR | |
10060 | BGP_STR | |
10061 | "BGP view\n" | |
10062 | "BGP view name\n" | |
10063 | "Address family\n" | |
10064 | #ifdef HAVE_IPV6 | |
10065 | "Address family\n" | |
10066 | #endif | |
10067 | "Address family modifier\n" | |
10068 | "Address family modifier\n" | |
10069 | "Detailed information on TCP and BGP neighbor connections\n" | |
10070 | "Neighbor to display information about\n" | |
10071 | "Neighbor to display information about\n" | |
10072 | "Display the advertised routes to neighbor\n" | |
10073 | "Display the received routes from neighbor\n") | |
10074 | { | |
10075 | int afi; | |
10076 | int safi; | |
10077 | int in; | |
10078 | struct peer *peer; | |
10079 | ||
10080 | #ifdef HAVE_IPV6 | |
10081 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); | |
10082 | #else | |
10083 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10084 | #endif | |
10085 | ||
10086 | if (! peer) | |
10087 | return CMD_WARNING; | |
10088 | ||
10089 | #ifdef HAVE_IPV6 | |
10090 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; | |
10091 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10092 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; | |
10093 | #else | |
10094 | afi = AFI_IP; | |
10095 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10096 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; | |
10097 | #endif | |
10098 | ||
10099 | return peer_adj_routes (vty, peer, afi, safi, in); | |
10100 | } | |
10101 | ||
718e3744 | 10102 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
10103 | show_ip_bgp_neighbor_received_prefix_filter_cmd, | |
10104 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10105 | SHOW_STR | |
10106 | IP_STR | |
10107 | BGP_STR | |
10108 | "Detailed information on TCP and BGP neighbor connections\n" | |
10109 | "Neighbor to display information about\n" | |
10110 | "Neighbor to display information about\n" | |
10111 | "Display information received from a BGP neighbor\n" | |
10112 | "Display the prefixlist filter\n") | |
10113 | { | |
10114 | char name[BUFSIZ]; | |
10115 | union sockunion *su; | |
10116 | struct peer *peer; | |
10117 | int count; | |
10118 | ||
10119 | su = sockunion_str2su (argv[0]); | |
10120 | if (su == NULL) | |
10121 | return CMD_WARNING; | |
10122 | ||
10123 | peer = peer_lookup (NULL, su); | |
10124 | if (! peer) | |
10125 | return CMD_WARNING; | |
10126 | ||
10127 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
10128 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10129 | if (count) | |
10130 | { | |
10131 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
10132 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10133 | } | |
10134 | ||
10135 | return CMD_SUCCESS; | |
10136 | } | |
10137 | ||
10138 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, | |
10139 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, | |
10140 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10141 | SHOW_STR | |
10142 | IP_STR | |
10143 | BGP_STR | |
10144 | "Address family\n" | |
10145 | "Address Family modifier\n" | |
10146 | "Address Family modifier\n" | |
10147 | "Detailed information on TCP and BGP neighbor connections\n" | |
10148 | "Neighbor to display information about\n" | |
10149 | "Neighbor to display information about\n" | |
10150 | "Display information received from a BGP neighbor\n" | |
10151 | "Display the prefixlist filter\n") | |
10152 | { | |
10153 | char name[BUFSIZ]; | |
10154 | union sockunion *su; | |
10155 | struct peer *peer; | |
10156 | int count; | |
10157 | ||
10158 | su = sockunion_str2su (argv[1]); | |
10159 | if (su == NULL) | |
10160 | return CMD_WARNING; | |
10161 | ||
10162 | peer = peer_lookup (NULL, su); | |
10163 | if (! peer) | |
10164 | return CMD_WARNING; | |
10165 | ||
10166 | if (strncmp (argv[0], "m", 1) == 0) | |
10167 | { | |
10168 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); | |
10169 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10170 | if (count) | |
10171 | { | |
10172 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); | |
10173 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10174 | } | |
10175 | } | |
10176 | else | |
10177 | { | |
10178 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
10179 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10180 | if (count) | |
10181 | { | |
10182 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
10183 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10184 | } | |
10185 | } | |
10186 | ||
10187 | return CMD_SUCCESS; | |
10188 | } | |
10189 | ||
10190 | ||
10191 | #ifdef HAVE_IPV6 | |
bb46e94f | 10192 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10193 | show_bgp_neighbor_received_routes_cmd, |
10194 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10195 | SHOW_STR | |
10196 | BGP_STR | |
10197 | "Detailed information on TCP and BGP neighbor connections\n" | |
10198 | "Neighbor to display information about\n" | |
10199 | "Neighbor to display information about\n" | |
10200 | "Display the received routes from neighbor\n") | |
718e3744 | 10201 | |
bb46e94f | 10202 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10203 | show_bgp_ipv6_neighbor_received_routes_cmd, |
10204 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10205 | SHOW_STR | |
10206 | BGP_STR | |
10207 | "Address family\n" | |
10208 | "Detailed information on TCP and BGP neighbor connections\n" | |
10209 | "Neighbor to display information about\n" | |
10210 | "Neighbor to display information about\n" | |
10211 | "Display the received routes from neighbor\n") | |
10212 | ||
10213 | DEFUN (show_bgp_neighbor_received_prefix_filter, | |
10214 | show_bgp_neighbor_received_prefix_filter_cmd, | |
10215 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10216 | SHOW_STR | |
10217 | BGP_STR | |
10218 | "Detailed information on TCP and BGP neighbor connections\n" | |
10219 | "Neighbor to display information about\n" | |
10220 | "Neighbor to display information about\n" | |
10221 | "Display information received from a BGP neighbor\n" | |
10222 | "Display the prefixlist filter\n") | |
10223 | { | |
10224 | char name[BUFSIZ]; | |
10225 | union sockunion *su; | |
10226 | struct peer *peer; | |
10227 | int count; | |
10228 | ||
10229 | su = sockunion_str2su (argv[0]); | |
10230 | if (su == NULL) | |
10231 | return CMD_WARNING; | |
10232 | ||
10233 | peer = peer_lookup (NULL, su); | |
10234 | if (! peer) | |
10235 | return CMD_WARNING; | |
10236 | ||
10237 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10238 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10239 | if (count) | |
10240 | { | |
10241 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10242 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10243 | } | |
10244 | ||
10245 | return CMD_SUCCESS; | |
10246 | } | |
10247 | ||
10248 | ALIAS (show_bgp_neighbor_received_prefix_filter, | |
10249 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, | |
10250 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10251 | SHOW_STR | |
10252 | BGP_STR | |
10253 | "Address family\n" | |
10254 | "Detailed information on TCP and BGP neighbor connections\n" | |
10255 | "Neighbor to display information about\n" | |
10256 | "Neighbor to display information about\n" | |
10257 | "Display information received from a BGP neighbor\n" | |
10258 | "Display the prefixlist filter\n") | |
10259 | ||
10260 | /* old command */ | |
bb46e94f | 10261 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10262 | ipv6_bgp_neighbor_received_routes_cmd, |
10263 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10264 | SHOW_STR | |
10265 | IPV6_STR | |
10266 | BGP_STR | |
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") | |
718e3744 | 10271 | |
10272 | /* old command */ | |
10273 | DEFUN (ipv6_mbgp_neighbor_received_routes, | |
10274 | ipv6_mbgp_neighbor_received_routes_cmd, | |
10275 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10276 | SHOW_STR | |
10277 | IPV6_STR | |
10278 | MBGP_STR | |
10279 | "Detailed information on TCP and BGP neighbor connections\n" | |
10280 | "Neighbor to display information about\n" | |
10281 | "Neighbor to display information about\n" | |
10282 | "Display the received routes from neighbor\n") | |
10283 | { | |
bb46e94f | 10284 | struct peer *peer; |
10285 | ||
10286 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10287 | if (! peer) | |
10288 | return CMD_WARNING; | |
10289 | ||
10290 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); | |
10291 | } | |
10292 | ||
10293 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, | |
10294 | show_bgp_view_neighbor_received_prefix_filter_cmd, | |
10295 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10296 | SHOW_STR | |
10297 | BGP_STR | |
10298 | "BGP view\n" | |
10299 | "View name\n" | |
10300 | "Detailed information on TCP and BGP neighbor connections\n" | |
10301 | "Neighbor to display information about\n" | |
10302 | "Neighbor to display information about\n" | |
10303 | "Display information received from a BGP neighbor\n" | |
10304 | "Display the prefixlist filter\n") | |
10305 | { | |
10306 | char name[BUFSIZ]; | |
10307 | union sockunion *su; | |
10308 | struct peer *peer; | |
10309 | struct bgp *bgp; | |
10310 | int count; | |
10311 | ||
10312 | /* BGP structure lookup. */ | |
10313 | bgp = bgp_lookup_by_name (argv[0]); | |
10314 | if (bgp == NULL) | |
10315 | { | |
10316 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10317 | return CMD_WARNING; | |
10318 | } | |
10319 | ||
10320 | su = sockunion_str2su (argv[1]); | |
10321 | if (su == NULL) | |
10322 | return CMD_WARNING; | |
10323 | ||
10324 | peer = peer_lookup (bgp, su); | |
10325 | if (! peer) | |
10326 | return CMD_WARNING; | |
10327 | ||
10328 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10329 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10330 | if (count) | |
10331 | { | |
10332 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10333 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10334 | } | |
10335 | ||
10336 | return CMD_SUCCESS; | |
718e3744 | 10337 | } |
bb46e94f | 10338 | |
10339 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, | |
10340 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, | |
10341 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10342 | SHOW_STR | |
10343 | BGP_STR | |
10344 | "BGP view\n" | |
10345 | "View name\n" | |
10346 | "Address family\n" | |
10347 | "Detailed information on TCP and BGP neighbor connections\n" | |
10348 | "Neighbor to display information about\n" | |
10349 | "Neighbor to display information about\n" | |
10350 | "Display information received from a BGP neighbor\n" | |
10351 | "Display the prefixlist filter\n") | |
718e3744 | 10352 | #endif /* HAVE_IPV6 */ |
10353 | \f | |
94f2b392 | 10354 | static int |
bb46e94f | 10355 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
718e3744 | 10356 | safi_t safi, enum bgp_show_type type) |
10357 | { | |
718e3744 | 10358 | if (! peer || ! peer->afc[afi][safi]) |
10359 | { | |
10360 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
718e3744 | 10361 | return CMD_WARNING; |
10362 | } | |
10363 | ||
5a646650 | 10364 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
718e3744 | 10365 | } |
10366 | ||
10367 | DEFUN (show_ip_bgp_neighbor_routes, | |
10368 | show_ip_bgp_neighbor_routes_cmd, | |
10369 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10370 | SHOW_STR | |
10371 | IP_STR | |
10372 | BGP_STR | |
10373 | "Detailed information on TCP and BGP neighbor connections\n" | |
10374 | "Neighbor to display information about\n" | |
10375 | "Neighbor to display information about\n" | |
10376 | "Display routes learned from neighbor\n") | |
10377 | { | |
bb46e94f | 10378 | struct peer *peer; |
10379 | ||
10380 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10381 | if (! peer) | |
10382 | return CMD_WARNING; | |
10383 | ||
10384 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10385 | bgp_show_type_neighbor); |
10386 | } | |
10387 | ||
10388 | DEFUN (show_ip_bgp_neighbor_flap, | |
10389 | show_ip_bgp_neighbor_flap_cmd, | |
10390 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10391 | SHOW_STR | |
10392 | IP_STR | |
10393 | BGP_STR | |
10394 | "Detailed information on TCP and BGP neighbor connections\n" | |
10395 | "Neighbor to display information about\n" | |
10396 | "Neighbor to display information about\n" | |
10397 | "Display flap statistics of the routes learned from neighbor\n") | |
10398 | { | |
bb46e94f | 10399 | struct peer *peer; |
10400 | ||
10401 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10402 | if (! peer) | |
10403 | return CMD_WARNING; | |
10404 | ||
10405 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10406 | bgp_show_type_flap_neighbor); |
10407 | } | |
10408 | ||
10409 | DEFUN (show_ip_bgp_neighbor_damp, | |
10410 | show_ip_bgp_neighbor_damp_cmd, | |
10411 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10412 | SHOW_STR | |
10413 | IP_STR | |
10414 | BGP_STR | |
10415 | "Detailed information on TCP and BGP neighbor connections\n" | |
10416 | "Neighbor to display information about\n" | |
10417 | "Neighbor to display information about\n" | |
10418 | "Display the dampened routes received from neighbor\n") | |
10419 | { | |
bb46e94f | 10420 | struct peer *peer; |
10421 | ||
10422 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10423 | if (! peer) | |
10424 | return CMD_WARNING; | |
10425 | ||
10426 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10427 | bgp_show_type_damp_neighbor); |
10428 | } | |
10429 | ||
10430 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, | |
10431 | show_ip_bgp_ipv4_neighbor_routes_cmd, | |
10432 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", | |
10433 | SHOW_STR | |
10434 | IP_STR | |
10435 | BGP_STR | |
10436 | "Address family\n" | |
10437 | "Address Family modifier\n" | |
10438 | "Address Family modifier\n" | |
10439 | "Detailed information on TCP and BGP neighbor connections\n" | |
10440 | "Neighbor to display information about\n" | |
10441 | "Neighbor to display information about\n" | |
10442 | "Display routes learned from neighbor\n") | |
10443 | { | |
bb46e94f | 10444 | struct peer *peer; |
10445 | ||
10446 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10447 | if (! peer) | |
10448 | return CMD_WARNING; | |
10449 | ||
718e3744 | 10450 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 10451 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
718e3744 | 10452 | bgp_show_type_neighbor); |
10453 | ||
bb46e94f | 10454 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
718e3744 | 10455 | bgp_show_type_neighbor); |
10456 | } | |
bb46e94f | 10457 | |
fee0f4c6 | 10458 | DEFUN (show_ip_bgp_view_rsclient, |
10459 | show_ip_bgp_view_rsclient_cmd, | |
10460 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
10461 | SHOW_STR | |
10462 | IP_STR | |
10463 | BGP_STR | |
10464 | "BGP view\n" | |
10465 | "BGP view name\n" | |
10466 | "Information about Route Server Client\n" | |
10467 | NEIGHBOR_ADDR_STR) | |
10468 | { | |
10469 | struct bgp_table *table; | |
10470 | struct peer *peer; | |
10471 | ||
10472 | if (argc == 2) | |
10473 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10474 | else | |
10475 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10476 | ||
10477 | if (! peer) | |
10478 | return CMD_WARNING; | |
10479 | ||
10480 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10481 | { | |
10482 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10483 | VTY_NEWLINE); | |
10484 | return CMD_WARNING; | |
10485 | } | |
10486 | ||
10487 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10488 | PEER_FLAG_RSERVER_CLIENT)) | |
10489 | { | |
10490 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10491 | VTY_NEWLINE); | |
10492 | return CMD_WARNING; | |
10493 | } | |
10494 | ||
10495 | table = peer->rib[AFI_IP][SAFI_UNICAST]; | |
10496 | ||
5a646650 | 10497 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 10498 | } |
10499 | ||
10500 | ALIAS (show_ip_bgp_view_rsclient, | |
10501 | show_ip_bgp_rsclient_cmd, | |
10502 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", | |
10503 | SHOW_STR | |
10504 | IP_STR | |
10505 | BGP_STR | |
10506 | "Information about Route Server Client\n" | |
10507 | NEIGHBOR_ADDR_STR) | |
10508 | ||
95cbbd2a ML |
10509 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
10510 | show_bgp_view_ipv4_safi_rsclient_cmd, | |
10511 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
fee0f4c6 | 10512 | SHOW_STR |
fee0f4c6 | 10513 | BGP_STR |
10514 | "BGP view\n" | |
10515 | "BGP view name\n" | |
95cbbd2a ML |
10516 | "Address family\n" |
10517 | "Address Family modifier\n" | |
10518 | "Address Family modifier\n" | |
fee0f4c6 | 10519 | "Information about Route Server Client\n" |
95cbbd2a | 10520 | NEIGHBOR_ADDR_STR) |
fee0f4c6 | 10521 | { |
95cbbd2a | 10522 | struct bgp_table *table; |
fee0f4c6 | 10523 | struct peer *peer; |
95cbbd2a | 10524 | safi_t safi; |
fee0f4c6 | 10525 | |
95cbbd2a ML |
10526 | if (argc == 3) { |
10527 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10528 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10529 | } else { | |
10530 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10531 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10532 | } | |
10533 | ||
10534 | if (! peer) | |
10535 | return CMD_WARNING; | |
10536 | ||
10537 | if (! peer->afc[AFI_IP][safi]) | |
fee0f4c6 | 10538 | { |
95cbbd2a ML |
10539 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
10540 | VTY_NEWLINE); | |
10541 | return CMD_WARNING; | |
10542 | } | |
10543 | ||
10544 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], | |
10545 | PEER_FLAG_RSERVER_CLIENT)) | |
10546 | { | |
10547 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10548 | VTY_NEWLINE); | |
10549 | return CMD_WARNING; | |
10550 | } | |
10551 | ||
10552 | table = peer->rib[AFI_IP][safi]; | |
10553 | ||
10554 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); | |
10555 | } | |
10556 | ||
10557 | ALIAS (show_bgp_view_ipv4_safi_rsclient, | |
10558 | show_bgp_ipv4_safi_rsclient_cmd, | |
10559 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
10560 | SHOW_STR | |
10561 | BGP_STR | |
10562 | "Address family\n" | |
10563 | "Address Family modifier\n" | |
10564 | "Address Family modifier\n" | |
10565 | "Information about Route Server Client\n" | |
10566 | NEIGHBOR_ADDR_STR) | |
10567 | ||
10568 | DEFUN (show_ip_bgp_view_rsclient_route, | |
10569 | show_ip_bgp_view_rsclient_route_cmd, | |
10570 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10571 | SHOW_STR | |
10572 | IP_STR | |
10573 | BGP_STR | |
10574 | "BGP view\n" | |
10575 | "BGP view name\n" | |
10576 | "Information about Route Server Client\n" | |
10577 | NEIGHBOR_ADDR_STR | |
10578 | "Network in the BGP routing table to display\n") | |
10579 | { | |
10580 | struct bgp *bgp; | |
10581 | struct peer *peer; | |
10582 | ||
10583 | /* BGP structure lookup. */ | |
10584 | if (argc == 3) | |
10585 | { | |
10586 | bgp = bgp_lookup_by_name (argv[0]); | |
10587 | if (bgp == NULL) | |
10588 | { | |
10589 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10590 | return CMD_WARNING; | |
fee0f4c6 | 10591 | } |
10592 | } | |
10593 | else | |
10594 | { | |
10595 | bgp = bgp_get_default (); | |
10596 | if (bgp == NULL) | |
10597 | { | |
10598 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10599 | return CMD_WARNING; | |
10600 | } | |
10601 | } | |
10602 | ||
10603 | if (argc == 3) | |
10604 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10605 | else | |
10606 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10607 | ||
10608 | if (! peer) | |
10609 | return CMD_WARNING; | |
10610 | ||
10611 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10612 | { | |
10613 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10614 | VTY_NEWLINE); | |
10615 | return CMD_WARNING; | |
10616 | } | |
10617 | ||
10618 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10619 | PEER_FLAG_RSERVER_CLIENT)) | |
10620 | { | |
10621 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10622 | VTY_NEWLINE); | |
10623 | return CMD_WARNING; | |
10624 | } | |
10625 | ||
10626 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10627 | (argc == 3) ? argv[2] : argv[1], | |
10628 | AFI_IP, SAFI_UNICAST, NULL, 0); | |
10629 | } | |
10630 | ||
10631 | ALIAS (show_ip_bgp_view_rsclient_route, | |
10632 | show_ip_bgp_rsclient_route_cmd, | |
10633 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10634 | SHOW_STR | |
10635 | IP_STR | |
10636 | BGP_STR | |
10637 | "Information about Route Server Client\n" | |
10638 | NEIGHBOR_ADDR_STR | |
10639 | "Network in the BGP routing table to display\n") | |
10640 | ||
95cbbd2a ML |
10641 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
10642 | show_bgp_view_ipv4_safi_rsclient_route_cmd, | |
10643 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10644 | SHOW_STR | |
10645 | BGP_STR | |
10646 | "BGP view\n" | |
10647 | "BGP view name\n" | |
10648 | "Address family\n" | |
10649 | "Address Family modifier\n" | |
10650 | "Address Family modifier\n" | |
10651 | "Information about Route Server Client\n" | |
10652 | NEIGHBOR_ADDR_STR | |
10653 | "Network in the BGP routing table to display\n") | |
10654 | { | |
10655 | struct bgp *bgp; | |
10656 | struct peer *peer; | |
10657 | safi_t safi; | |
10658 | ||
10659 | /* BGP structure lookup. */ | |
10660 | if (argc == 4) | |
10661 | { | |
10662 | bgp = bgp_lookup_by_name (argv[0]); | |
10663 | if (bgp == NULL) | |
10664 | { | |
10665 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10666 | return CMD_WARNING; | |
10667 | } | |
10668 | } | |
10669 | else | |
10670 | { | |
10671 | bgp = bgp_get_default (); | |
10672 | if (bgp == NULL) | |
10673 | { | |
10674 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10675 | return CMD_WARNING; | |
10676 | } | |
10677 | } | |
10678 | ||
10679 | if (argc == 4) { | |
10680 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10681 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10682 | } else { | |
10683 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10684 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10685 | } | |
10686 | ||
10687 | if (! peer) | |
10688 | return CMD_WARNING; | |
10689 | ||
10690 | if (! peer->afc[AFI_IP][safi]) | |
10691 | { | |
10692 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10693 | VTY_NEWLINE); | |
10694 | return CMD_WARNING; | |
10695 | } | |
10696 | ||
10697 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], | |
10698 | PEER_FLAG_RSERVER_CLIENT)) | |
10699 | { | |
10700 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10701 | VTY_NEWLINE); | |
10702 | return CMD_WARNING; | |
10703 | } | |
10704 | ||
10705 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], | |
10706 | (argc == 4) ? argv[3] : argv[2], | |
10707 | AFI_IP, safi, NULL, 0); | |
10708 | } | |
10709 | ||
10710 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, | |
10711 | show_bgp_ipv4_safi_rsclient_route_cmd, | |
10712 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10713 | SHOW_STR | |
10714 | BGP_STR | |
10715 | "Address family\n" | |
10716 | "Address Family modifier\n" | |
10717 | "Address Family modifier\n" | |
10718 | "Information about Route Server Client\n" | |
10719 | NEIGHBOR_ADDR_STR | |
10720 | "Network in the BGP routing table to display\n") | |
10721 | ||
fee0f4c6 | 10722 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
10723 | show_ip_bgp_view_rsclient_prefix_cmd, | |
10724 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10725 | SHOW_STR | |
10726 | IP_STR | |
10727 | BGP_STR | |
10728 | "BGP view\n" | |
10729 | "BGP view name\n" | |
10730 | "Information about Route Server Client\n" | |
10731 | NEIGHBOR_ADDR_STR | |
10732 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10733 | { | |
10734 | struct bgp *bgp; | |
10735 | struct peer *peer; | |
10736 | ||
10737 | /* BGP structure lookup. */ | |
10738 | if (argc == 3) | |
10739 | { | |
10740 | bgp = bgp_lookup_by_name (argv[0]); | |
10741 | if (bgp == NULL) | |
10742 | { | |
10743 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10744 | return CMD_WARNING; | |
10745 | } | |
10746 | } | |
10747 | else | |
10748 | { | |
10749 | bgp = bgp_get_default (); | |
10750 | if (bgp == NULL) | |
10751 | { | |
10752 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10753 | return CMD_WARNING; | |
10754 | } | |
10755 | } | |
10756 | ||
10757 | if (argc == 3) | |
10758 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10759 | else | |
10760 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10761 | ||
10762 | if (! peer) | |
10763 | return CMD_WARNING; | |
10764 | ||
10765 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10766 | { | |
10767 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10768 | VTY_NEWLINE); | |
10769 | return CMD_WARNING; | |
10770 | } | |
10771 | ||
10772 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10773 | PEER_FLAG_RSERVER_CLIENT)) | |
10774 | { | |
10775 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10776 | VTY_NEWLINE); | |
10777 | return CMD_WARNING; | |
10778 | } | |
10779 | ||
10780 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10781 | (argc == 3) ? argv[2] : argv[1], | |
10782 | AFI_IP, SAFI_UNICAST, NULL, 1); | |
10783 | } | |
10784 | ||
10785 | ALIAS (show_ip_bgp_view_rsclient_prefix, | |
10786 | show_ip_bgp_rsclient_prefix_cmd, | |
10787 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10788 | SHOW_STR | |
10789 | IP_STR | |
10790 | BGP_STR | |
10791 | "Information about Route Server Client\n" | |
10792 | NEIGHBOR_ADDR_STR | |
10793 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10794 | ||
95cbbd2a ML |
10795 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
10796 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, | |
10797 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10798 | SHOW_STR | |
10799 | BGP_STR | |
10800 | "BGP view\n" | |
10801 | "BGP view name\n" | |
10802 | "Address family\n" | |
10803 | "Address Family modifier\n" | |
10804 | "Address Family modifier\n" | |
10805 | "Information about Route Server Client\n" | |
10806 | NEIGHBOR_ADDR_STR | |
10807 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10808 | { | |
10809 | struct bgp *bgp; | |
10810 | struct peer *peer; | |
10811 | safi_t safi; | |
10812 | ||
10813 | /* BGP structure lookup. */ | |
10814 | if (argc == 4) | |
10815 | { | |
10816 | bgp = bgp_lookup_by_name (argv[0]); | |
10817 | if (bgp == NULL) | |
10818 | { | |
10819 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10820 | return CMD_WARNING; | |
10821 | } | |
10822 | } | |
10823 | else | |
10824 | { | |
10825 | bgp = bgp_get_default (); | |
10826 | if (bgp == NULL) | |
10827 | { | |
10828 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10829 | return CMD_WARNING; | |
10830 | } | |
10831 | } | |
10832 | ||
10833 | if (argc == 4) { | |
10834 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
10835 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10836 | } else { | |
10837 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10838 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
10839 | } | |
10840 | ||
10841 | if (! peer) | |
10842 | return CMD_WARNING; | |
10843 | ||
10844 | if (! peer->afc[AFI_IP][safi]) | |
10845 | { | |
10846 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10847 | VTY_NEWLINE); | |
10848 | return CMD_WARNING; | |
10849 | } | |
10850 | ||
10851 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], | |
10852 | PEER_FLAG_RSERVER_CLIENT)) | |
10853 | { | |
10854 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10855 | VTY_NEWLINE); | |
10856 | return CMD_WARNING; | |
10857 | } | |
10858 | ||
10859 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], | |
10860 | (argc == 4) ? argv[3] : argv[2], | |
10861 | AFI_IP, safi, NULL, 1); | |
10862 | } | |
10863 | ||
10864 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, | |
10865 | show_bgp_ipv4_safi_rsclient_prefix_cmd, | |
10866 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10867 | SHOW_STR | |
10868 | BGP_STR | |
10869 | "Address family\n" | |
10870 | "Address Family modifier\n" | |
10871 | "Address Family modifier\n" | |
10872 | "Information about Route Server Client\n" | |
10873 | NEIGHBOR_ADDR_STR | |
10874 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
fee0f4c6 | 10875 | |
718e3744 | 10876 | #ifdef HAVE_IPV6 |
bb46e94f | 10877 | DEFUN (show_bgp_view_neighbor_routes, |
10878 | show_bgp_view_neighbor_routes_cmd, | |
10879 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", | |
718e3744 | 10880 | SHOW_STR |
10881 | BGP_STR | |
bb46e94f | 10882 | "BGP view\n" |
10883 | "BGP view name\n" | |
718e3744 | 10884 | "Detailed information on TCP and BGP neighbor connections\n" |
10885 | "Neighbor to display information about\n" | |
10886 | "Neighbor to display information about\n" | |
10887 | "Display routes learned from neighbor\n") | |
10888 | { | |
bb46e94f | 10889 | struct peer *peer; |
10890 | ||
10891 | if (argc == 2) | |
10892 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10893 | else | |
10894 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10895 | ||
10896 | if (! peer) | |
10897 | return CMD_WARNING; | |
10898 | ||
10899 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
718e3744 | 10900 | bgp_show_type_neighbor); |
10901 | } | |
10902 | ||
bb46e94f | 10903 | ALIAS (show_bgp_view_neighbor_routes, |
10904 | show_bgp_view_ipv6_neighbor_routes_cmd, | |
10905 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
10906 | SHOW_STR | |
10907 | BGP_STR | |
10908 | "BGP view\n" | |
10909 | "BGP view name\n" | |
10910 | "Address family\n" | |
10911 | "Detailed information on TCP and BGP neighbor connections\n" | |
10912 | "Neighbor to display information about\n" | |
10913 | "Neighbor to display information about\n" | |
10914 | "Display routes learned from neighbor\n") | |
10915 | ||
10916 | DEFUN (show_bgp_view_neighbor_damp, | |
10917 | show_bgp_view_neighbor_damp_cmd, | |
10918 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10919 | SHOW_STR | |
10920 | BGP_STR | |
10921 | "BGP view\n" | |
10922 | "BGP view name\n" | |
10923 | "Detailed information on TCP and BGP neighbor connections\n" | |
10924 | "Neighbor to display information about\n" | |
10925 | "Neighbor to display information about\n" | |
10926 | "Display the dampened routes received from neighbor\n") | |
10927 | { | |
10928 | struct peer *peer; | |
10929 | ||
10930 | if (argc == 2) | |
10931 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10932 | else | |
10933 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10934 | ||
10935 | if (! peer) | |
10936 | return CMD_WARNING; | |
10937 | ||
10938 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
10939 | bgp_show_type_damp_neighbor); | |
10940 | } | |
10941 | ||
10942 | ALIAS (show_bgp_view_neighbor_damp, | |
10943 | show_bgp_view_ipv6_neighbor_damp_cmd, | |
10944 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10945 | SHOW_STR | |
10946 | BGP_STR | |
10947 | "BGP view\n" | |
10948 | "BGP view name\n" | |
10949 | "Address family\n" | |
10950 | "Detailed information on TCP and BGP neighbor connections\n" | |
10951 | "Neighbor to display information about\n" | |
10952 | "Neighbor to display information about\n" | |
10953 | "Display the dampened routes received from neighbor\n") | |
10954 | ||
10955 | DEFUN (show_bgp_view_neighbor_flap, | |
10956 | show_bgp_view_neighbor_flap_cmd, | |
10957 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10958 | SHOW_STR | |
10959 | BGP_STR | |
10960 | "BGP view\n" | |
10961 | "BGP view name\n" | |
10962 | "Detailed information on TCP and BGP neighbor connections\n" | |
10963 | "Neighbor to display information about\n" | |
10964 | "Neighbor to display information about\n" | |
10965 | "Display flap statistics of the routes learned from neighbor\n") | |
10966 | { | |
10967 | struct peer *peer; | |
10968 | ||
10969 | if (argc == 2) | |
10970 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10971 | else | |
10972 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10973 | ||
10974 | if (! peer) | |
10975 | return CMD_WARNING; | |
10976 | ||
10977 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
10978 | bgp_show_type_flap_neighbor); | |
10979 | } | |
10980 | ||
10981 | ALIAS (show_bgp_view_neighbor_flap, | |
10982 | show_bgp_view_ipv6_neighbor_flap_cmd, | |
10983 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10984 | SHOW_STR | |
10985 | BGP_STR | |
10986 | "BGP view\n" | |
10987 | "BGP view name\n" | |
10988 | "Address family\n" | |
10989 | "Detailed information on TCP and BGP neighbor connections\n" | |
10990 | "Neighbor to display information about\n" | |
10991 | "Neighbor to display information about\n" | |
10992 | "Display flap statistics of the routes learned from neighbor\n") | |
10993 | ||
10994 | ALIAS (show_bgp_view_neighbor_routes, | |
10995 | show_bgp_neighbor_routes_cmd, | |
10996 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10997 | SHOW_STR | |
10998 | BGP_STR | |
10999 | "Detailed information on TCP and BGP neighbor connections\n" | |
11000 | "Neighbor to display information about\n" | |
11001 | "Neighbor to display information about\n" | |
11002 | "Display routes learned from neighbor\n") | |
11003 | ||
11004 | ||
11005 | ALIAS (show_bgp_view_neighbor_routes, | |
718e3744 | 11006 | show_bgp_ipv6_neighbor_routes_cmd, |
11007 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
11008 | SHOW_STR | |
11009 | BGP_STR | |
11010 | "Address family\n" | |
11011 | "Detailed information on TCP and BGP neighbor connections\n" | |
11012 | "Neighbor to display information about\n" | |
11013 | "Neighbor to display information about\n" | |
11014 | "Display routes learned from neighbor\n") | |
11015 | ||
11016 | /* old command */ | |
bb46e94f | 11017 | ALIAS (show_bgp_view_neighbor_routes, |
718e3744 | 11018 | ipv6_bgp_neighbor_routes_cmd, |
11019 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
11020 | SHOW_STR | |
11021 | IPV6_STR | |
11022 | BGP_STR | |
11023 | "Detailed information on TCP and BGP neighbor connections\n" | |
11024 | "Neighbor to display information about\n" | |
11025 | "Neighbor to display information about\n" | |
11026 | "Display routes learned from neighbor\n") | |
718e3744 | 11027 | |
11028 | /* old command */ | |
11029 | DEFUN (ipv6_mbgp_neighbor_routes, | |
11030 | ipv6_mbgp_neighbor_routes_cmd, | |
11031 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", | |
11032 | SHOW_STR | |
11033 | IPV6_STR | |
11034 | MBGP_STR | |
11035 | "Detailed information on TCP and BGP neighbor connections\n" | |
11036 | "Neighbor to display information about\n" | |
11037 | "Neighbor to display information about\n" | |
11038 | "Display routes learned from neighbor\n") | |
11039 | { | |
bb46e94f | 11040 | struct peer *peer; |
11041 | ||
11042 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11043 | if (! peer) | |
11044 | return CMD_WARNING; | |
11045 | ||
11046 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, | |
718e3744 | 11047 | bgp_show_type_neighbor); |
11048 | } | |
bb46e94f | 11049 | |
11050 | ALIAS (show_bgp_view_neighbor_flap, | |
11051 | show_bgp_neighbor_flap_cmd, | |
11052 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11053 | SHOW_STR | |
11054 | BGP_STR | |
11055 | "Detailed information on TCP and BGP neighbor connections\n" | |
11056 | "Neighbor to display information about\n" | |
11057 | "Neighbor to display information about\n" | |
11058 | "Display flap statistics of the routes learned from neighbor\n") | |
11059 | ||
11060 | ALIAS (show_bgp_view_neighbor_flap, | |
11061 | show_bgp_ipv6_neighbor_flap_cmd, | |
11062 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
11063 | SHOW_STR | |
11064 | BGP_STR | |
11065 | "Address family\n" | |
11066 | "Detailed information on TCP and BGP neighbor connections\n" | |
11067 | "Neighbor to display information about\n" | |
11068 | "Neighbor to display information about\n" | |
11069 | "Display flap statistics of the routes learned from neighbor\n") | |
11070 | ||
11071 | ALIAS (show_bgp_view_neighbor_damp, | |
11072 | show_bgp_neighbor_damp_cmd, | |
11073 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
11074 | SHOW_STR | |
11075 | BGP_STR | |
11076 | "Detailed information on TCP and BGP neighbor connections\n" | |
11077 | "Neighbor to display information about\n" | |
11078 | "Neighbor to display information about\n" | |
11079 | "Display the dampened routes received from neighbor\n") | |
11080 | ||
11081 | ALIAS (show_bgp_view_neighbor_damp, | |
11082 | show_bgp_ipv6_neighbor_damp_cmd, | |
11083 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
11084 | SHOW_STR | |
11085 | BGP_STR | |
11086 | "Address family\n" | |
11087 | "Detailed information on TCP and BGP neighbor connections\n" | |
11088 | "Neighbor to display information about\n" | |
11089 | "Neighbor to display information about\n" | |
c001ae62 | 11090 | "Display the dampened routes received from neighbor\n") |
fee0f4c6 | 11091 | |
11092 | DEFUN (show_bgp_view_rsclient, | |
11093 | show_bgp_view_rsclient_cmd, | |
11094 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
11095 | SHOW_STR | |
11096 | BGP_STR | |
11097 | "BGP view\n" | |
11098 | "BGP view name\n" | |
11099 | "Information about Route Server Client\n" | |
11100 | NEIGHBOR_ADDR_STR) | |
11101 | { | |
11102 | struct bgp_table *table; | |
11103 | struct peer *peer; | |
11104 | ||
11105 | if (argc == 2) | |
11106 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11107 | else | |
11108 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11109 | ||
11110 | if (! peer) | |
11111 | return CMD_WARNING; | |
11112 | ||
11113 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
11114 | { | |
11115 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11116 | VTY_NEWLINE); | |
11117 | return CMD_WARNING; | |
11118 | } | |
11119 | ||
11120 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
11121 | PEER_FLAG_RSERVER_CLIENT)) | |
11122 | { | |
11123 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11124 | VTY_NEWLINE); | |
11125 | return CMD_WARNING; | |
11126 | } | |
11127 | ||
11128 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; | |
11129 | ||
5a646650 | 11130 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 11131 | } |
11132 | ||
11133 | ALIAS (show_bgp_view_rsclient, | |
11134 | show_bgp_rsclient_cmd, | |
11135 | "show bgp rsclient (A.B.C.D|X:X::X:X)", | |
11136 | SHOW_STR | |
11137 | BGP_STR | |
11138 | "Information about Route Server Client\n" | |
11139 | NEIGHBOR_ADDR_STR) | |
11140 | ||
95cbbd2a ML |
11141 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
11142 | show_bgp_view_ipv6_safi_rsclient_cmd, | |
11143 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
11144 | SHOW_STR | |
11145 | BGP_STR | |
11146 | "BGP view\n" | |
11147 | "BGP view name\n" | |
11148 | "Address family\n" | |
11149 | "Address Family modifier\n" | |
11150 | "Address Family modifier\n" | |
11151 | "Information about Route Server Client\n" | |
11152 | NEIGHBOR_ADDR_STR) | |
11153 | { | |
11154 | struct bgp_table *table; | |
11155 | struct peer *peer; | |
11156 | safi_t safi; | |
11157 | ||
11158 | if (argc == 3) { | |
11159 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
11160 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11161 | } else { | |
11162 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
11163 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11164 | } | |
11165 | ||
11166 | if (! peer) | |
11167 | return CMD_WARNING; | |
11168 | ||
11169 | if (! peer->afc[AFI_IP6][safi]) | |
11170 | { | |
11171 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11172 | VTY_NEWLINE); | |
11173 | return CMD_WARNING; | |
11174 | } | |
11175 | ||
11176 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], | |
11177 | PEER_FLAG_RSERVER_CLIENT)) | |
11178 | { | |
11179 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11180 | VTY_NEWLINE); | |
11181 | return CMD_WARNING; | |
11182 | } | |
11183 | ||
11184 | table = peer->rib[AFI_IP6][safi]; | |
11185 | ||
11186 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); | |
11187 | } | |
11188 | ||
11189 | ALIAS (show_bgp_view_ipv6_safi_rsclient, | |
11190 | show_bgp_ipv6_safi_rsclient_cmd, | |
11191 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", | |
11192 | SHOW_STR | |
11193 | BGP_STR | |
11194 | "Address family\n" | |
11195 | "Address Family modifier\n" | |
11196 | "Address Family modifier\n" | |
11197 | "Information about Route Server Client\n" | |
11198 | NEIGHBOR_ADDR_STR) | |
11199 | ||
fee0f4c6 | 11200 | DEFUN (show_bgp_view_rsclient_route, |
11201 | show_bgp_view_rsclient_route_cmd, | |
11202 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11203 | SHOW_STR | |
11204 | BGP_STR | |
11205 | "BGP view\n" | |
11206 | "BGP view name\n" | |
11207 | "Information about Route Server Client\n" | |
11208 | NEIGHBOR_ADDR_STR | |
11209 | "Network in the BGP routing table to display\n") | |
11210 | { | |
11211 | struct bgp *bgp; | |
11212 | struct peer *peer; | |
11213 | ||
11214 | /* BGP structure lookup. */ | |
11215 | if (argc == 3) | |
11216 | { | |
11217 | bgp = bgp_lookup_by_name (argv[0]); | |
11218 | if (bgp == NULL) | |
11219 | { | |
11220 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11221 | return CMD_WARNING; | |
11222 | } | |
11223 | } | |
11224 | else | |
11225 | { | |
11226 | bgp = bgp_get_default (); | |
11227 | if (bgp == NULL) | |
11228 | { | |
11229 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11230 | return CMD_WARNING; | |
11231 | } | |
11232 | } | |
11233 | ||
11234 | if (argc == 3) | |
11235 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11236 | else | |
11237 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11238 | ||
11239 | if (! peer) | |
11240 | return CMD_WARNING; | |
11241 | ||
11242 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
11243 | { | |
11244 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11245 | VTY_NEWLINE); | |
11246 | return CMD_WARNING; | |
11247 | } | |
11248 | ||
11249 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
11250 | PEER_FLAG_RSERVER_CLIENT)) | |
11251 | { | |
11252 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11253 | VTY_NEWLINE); | |
11254 | return CMD_WARNING; | |
11255 | } | |
11256 | ||
11257 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
11258 | (argc == 3) ? argv[2] : argv[1], | |
11259 | AFI_IP6, SAFI_UNICAST, NULL, 0); | |
11260 | } | |
11261 | ||
11262 | ALIAS (show_bgp_view_rsclient_route, | |
11263 | show_bgp_rsclient_route_cmd, | |
11264 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11265 | SHOW_STR | |
11266 | BGP_STR | |
11267 | "Information about Route Server Client\n" | |
11268 | NEIGHBOR_ADDR_STR | |
11269 | "Network in the BGP routing table to display\n") | |
11270 | ||
95cbbd2a ML |
11271 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
11272 | show_bgp_view_ipv6_safi_rsclient_route_cmd, | |
11273 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11274 | SHOW_STR | |
11275 | BGP_STR | |
11276 | "BGP view\n" | |
11277 | "BGP view name\n" | |
11278 | "Address family\n" | |
11279 | "Address Family modifier\n" | |
11280 | "Address Family modifier\n" | |
11281 | "Information about Route Server Client\n" | |
11282 | NEIGHBOR_ADDR_STR | |
11283 | "Network in the BGP routing table to display\n") | |
11284 | { | |
11285 | struct bgp *bgp; | |
11286 | struct peer *peer; | |
11287 | safi_t safi; | |
11288 | ||
11289 | /* BGP structure lookup. */ | |
11290 | if (argc == 4) | |
11291 | { | |
11292 | bgp = bgp_lookup_by_name (argv[0]); | |
11293 | if (bgp == NULL) | |
11294 | { | |
11295 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11296 | return CMD_WARNING; | |
11297 | } | |
11298 | } | |
11299 | else | |
11300 | { | |
11301 | bgp = bgp_get_default (); | |
11302 | if (bgp == NULL) | |
11303 | { | |
11304 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11305 | return CMD_WARNING; | |
11306 | } | |
11307 | } | |
11308 | ||
11309 | if (argc == 4) { | |
11310 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
11311 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11312 | } else { | |
11313 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
11314 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11315 | } | |
11316 | ||
11317 | if (! peer) | |
11318 | return CMD_WARNING; | |
11319 | ||
11320 | if (! peer->afc[AFI_IP6][safi]) | |
11321 | { | |
11322 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11323 | VTY_NEWLINE); | |
11324 | return CMD_WARNING; | |
11325 | } | |
11326 | ||
11327 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], | |
11328 | PEER_FLAG_RSERVER_CLIENT)) | |
11329 | { | |
11330 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11331 | VTY_NEWLINE); | |
11332 | return CMD_WARNING; | |
11333 | } | |
11334 | ||
11335 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], | |
11336 | (argc == 4) ? argv[3] : argv[2], | |
11337 | AFI_IP6, safi, NULL, 0); | |
11338 | } | |
11339 | ||
11340 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, | |
11341 | show_bgp_ipv6_safi_rsclient_route_cmd, | |
11342 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
11343 | SHOW_STR | |
11344 | BGP_STR | |
11345 | "Address family\n" | |
11346 | "Address Family modifier\n" | |
11347 | "Address Family modifier\n" | |
11348 | "Information about Route Server Client\n" | |
11349 | NEIGHBOR_ADDR_STR | |
11350 | "Network in the BGP routing table to display\n") | |
11351 | ||
fee0f4c6 | 11352 | DEFUN (show_bgp_view_rsclient_prefix, |
11353 | show_bgp_view_rsclient_prefix_cmd, | |
11354 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11355 | SHOW_STR | |
11356 | BGP_STR | |
11357 | "BGP view\n" | |
11358 | "BGP view name\n" | |
11359 | "Information about Route Server Client\n" | |
11360 | NEIGHBOR_ADDR_STR | |
11361 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11362 | { | |
11363 | struct bgp *bgp; | |
11364 | struct peer *peer; | |
11365 | ||
11366 | /* BGP structure lookup. */ | |
11367 | if (argc == 3) | |
11368 | { | |
11369 | bgp = bgp_lookup_by_name (argv[0]); | |
11370 | if (bgp == NULL) | |
11371 | { | |
11372 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11373 | return CMD_WARNING; | |
11374 | } | |
11375 | } | |
11376 | else | |
11377 | { | |
11378 | bgp = bgp_get_default (); | |
11379 | if (bgp == NULL) | |
11380 | { | |
11381 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11382 | return CMD_WARNING; | |
11383 | } | |
11384 | } | |
11385 | ||
11386 | if (argc == 3) | |
11387 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
11388 | else | |
11389 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
11390 | ||
11391 | if (! peer) | |
11392 | return CMD_WARNING; | |
11393 | ||
11394 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
11395 | { | |
11396 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11397 | VTY_NEWLINE); | |
11398 | return CMD_WARNING; | |
11399 | } | |
11400 | ||
11401 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
11402 | PEER_FLAG_RSERVER_CLIENT)) | |
11403 | { | |
11404 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11405 | VTY_NEWLINE); | |
11406 | return CMD_WARNING; | |
11407 | } | |
11408 | ||
11409 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
11410 | (argc == 3) ? argv[2] : argv[1], | |
11411 | AFI_IP6, SAFI_UNICAST, NULL, 1); | |
11412 | } | |
11413 | ||
11414 | ALIAS (show_bgp_view_rsclient_prefix, | |
11415 | show_bgp_rsclient_prefix_cmd, | |
11416 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11417 | SHOW_STR | |
11418 | BGP_STR | |
11419 | "Information about Route Server Client\n" | |
11420 | NEIGHBOR_ADDR_STR | |
11421 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11422 | ||
95cbbd2a ML |
11423 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
11424 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, | |
11425 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11426 | SHOW_STR | |
11427 | BGP_STR | |
11428 | "BGP view\n" | |
11429 | "BGP view name\n" | |
11430 | "Address family\n" | |
11431 | "Address Family modifier\n" | |
11432 | "Address Family modifier\n" | |
11433 | "Information about Route Server Client\n" | |
11434 | NEIGHBOR_ADDR_STR | |
11435 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11436 | { | |
11437 | struct bgp *bgp; | |
11438 | struct peer *peer; | |
11439 | safi_t safi; | |
11440 | ||
11441 | /* BGP structure lookup. */ | |
11442 | if (argc == 4) | |
11443 | { | |
11444 | bgp = bgp_lookup_by_name (argv[0]); | |
11445 | if (bgp == NULL) | |
11446 | { | |
11447 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
11448 | return CMD_WARNING; | |
11449 | } | |
11450 | } | |
11451 | else | |
11452 | { | |
11453 | bgp = bgp_get_default (); | |
11454 | if (bgp == NULL) | |
11455 | { | |
11456 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
11457 | return CMD_WARNING; | |
11458 | } | |
11459 | } | |
11460 | ||
11461 | if (argc == 4) { | |
11462 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); | |
11463 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11464 | } else { | |
11465 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
11466 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
11467 | } | |
11468 | ||
11469 | if (! peer) | |
11470 | return CMD_WARNING; | |
11471 | ||
11472 | if (! peer->afc[AFI_IP6][safi]) | |
11473 | { | |
11474 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
11475 | VTY_NEWLINE); | |
11476 | return CMD_WARNING; | |
11477 | } | |
11478 | ||
11479 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], | |
11480 | PEER_FLAG_RSERVER_CLIENT)) | |
11481 | { | |
11482 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
11483 | VTY_NEWLINE); | |
11484 | return CMD_WARNING; | |
11485 | } | |
11486 | ||
11487 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], | |
11488 | (argc == 4) ? argv[3] : argv[2], | |
11489 | AFI_IP6, safi, NULL, 1); | |
11490 | } | |
11491 | ||
11492 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, | |
11493 | show_bgp_ipv6_safi_rsclient_prefix_cmd, | |
11494 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
11495 | SHOW_STR | |
11496 | BGP_STR | |
11497 | "Address family\n" | |
11498 | "Address Family modifier\n" | |
11499 | "Address Family modifier\n" | |
11500 | "Information about Route Server Client\n" | |
11501 | NEIGHBOR_ADDR_STR | |
11502 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") | |
11503 | ||
718e3744 | 11504 | #endif /* HAVE_IPV6 */ |
11505 | \f | |
11506 | struct bgp_table *bgp_distance_table; | |
11507 | ||
11508 | struct bgp_distance | |
11509 | { | |
11510 | /* Distance value for the IP source prefix. */ | |
11511 | u_char distance; | |
11512 | ||
11513 | /* Name of the access-list to be matched. */ | |
11514 | char *access_list; | |
11515 | }; | |
11516 | ||
94f2b392 | 11517 | static struct bgp_distance * |
66e5cd87 | 11518 | bgp_distance_new (void) |
718e3744 | 11519 | { |
393deb9b | 11520 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
718e3744 | 11521 | } |
11522 | ||
94f2b392 | 11523 | static void |
718e3744 | 11524 | bgp_distance_free (struct bgp_distance *bdistance) |
11525 | { | |
11526 | XFREE (MTYPE_BGP_DISTANCE, bdistance); | |
11527 | } | |
11528 | ||
94f2b392 | 11529 | static int |
fd79ac91 | 11530 | bgp_distance_set (struct vty *vty, const char *distance_str, |
11531 | const char *ip_str, const char *access_list_str) | |
718e3744 | 11532 | { |
11533 | int ret; | |
11534 | struct prefix_ipv4 p; | |
11535 | u_char distance; | |
11536 | struct bgp_node *rn; | |
11537 | struct bgp_distance *bdistance; | |
11538 | ||
11539 | ret = str2prefix_ipv4 (ip_str, &p); | |
11540 | if (ret == 0) | |
11541 | { | |
11542 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
11543 | return CMD_WARNING; | |
11544 | } | |
11545 | ||
11546 | distance = atoi (distance_str); | |
11547 | ||
11548 | /* Get BGP distance node. */ | |
11549 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); | |
11550 | if (rn->info) | |
11551 | { | |
11552 | bdistance = rn->info; | |
11553 | bgp_unlock_node (rn); | |
11554 | } | |
11555 | else | |
11556 | { | |
11557 | bdistance = bgp_distance_new (); | |
11558 | rn->info = bdistance; | |
11559 | } | |
11560 | ||
11561 | /* Set distance value. */ | |
11562 | bdistance->distance = distance; | |
11563 | ||
11564 | /* Reset access-list configuration. */ | |
11565 | if (bdistance->access_list) | |
11566 | { | |
11567 | free (bdistance->access_list); | |
11568 | bdistance->access_list = NULL; | |
11569 | } | |
11570 | if (access_list_str) | |
11571 | bdistance->access_list = strdup (access_list_str); | |
11572 | ||
11573 | return CMD_SUCCESS; | |
11574 | } | |
11575 | ||
94f2b392 | 11576 | static int |
fd79ac91 | 11577 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
11578 | const char *ip_str, const char *access_list_str) | |
718e3744 | 11579 | { |
11580 | int ret; | |
11581 | struct prefix_ipv4 p; | |
11582 | u_char distance; | |
11583 | struct bgp_node *rn; | |
11584 | struct bgp_distance *bdistance; | |
11585 | ||
11586 | ret = str2prefix_ipv4 (ip_str, &p); | |
11587 | if (ret == 0) | |
11588 | { | |
11589 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
11590 | return CMD_WARNING; | |
11591 | } | |
11592 | ||
11593 | distance = atoi (distance_str); | |
11594 | ||
11595 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); | |
11596 | if (! rn) | |
11597 | { | |
11598 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); | |
11599 | return CMD_WARNING; | |
11600 | } | |
11601 | ||
11602 | bdistance = rn->info; | |
11603 | ||
11604 | if (bdistance->access_list) | |
11605 | free (bdistance->access_list); | |
11606 | bgp_distance_free (bdistance); | |
11607 | ||
11608 | rn->info = NULL; | |
11609 | bgp_unlock_node (rn); | |
11610 | bgp_unlock_node (rn); | |
11611 | ||
11612 | return CMD_SUCCESS; | |
11613 | } | |
11614 | ||
718e3744 | 11615 | /* Apply BGP information to distance method. */ |
11616 | u_char | |
11617 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) | |
11618 | { | |
11619 | struct bgp_node *rn; | |
11620 | struct prefix_ipv4 q; | |
11621 | struct peer *peer; | |
11622 | struct bgp_distance *bdistance; | |
11623 | struct access_list *alist; | |
11624 | struct bgp_static *bgp_static; | |
11625 | ||
11626 | if (! bgp) | |
11627 | return 0; | |
11628 | ||
11629 | if (p->family != AF_INET) | |
11630 | return 0; | |
11631 | ||
11632 | peer = rinfo->peer; | |
11633 | ||
11634 | if (peer->su.sa.sa_family != AF_INET) | |
11635 | return 0; | |
11636 | ||
11637 | memset (&q, 0, sizeof (struct prefix_ipv4)); | |
11638 | q.family = AF_INET; | |
11639 | q.prefix = peer->su.sin.sin_addr; | |
11640 | q.prefixlen = IPV4_MAX_BITLEN; | |
11641 | ||
11642 | /* Check source address. */ | |
11643 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); | |
11644 | if (rn) | |
11645 | { | |
11646 | bdistance = rn->info; | |
11647 | bgp_unlock_node (rn); | |
11648 | ||
11649 | if (bdistance->access_list) | |
11650 | { | |
11651 | alist = access_list_lookup (AFI_IP, bdistance->access_list); | |
11652 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) | |
11653 | return bdistance->distance; | |
11654 | } | |
11655 | else | |
11656 | return bdistance->distance; | |
11657 | } | |
11658 | ||
11659 | /* Backdoor check. */ | |
11660 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); | |
11661 | if (rn) | |
11662 | { | |
11663 | bgp_static = rn->info; | |
11664 | bgp_unlock_node (rn); | |
11665 | ||
11666 | if (bgp_static->backdoor) | |
11667 | { | |
11668 | if (bgp->distance_local) | |
11669 | return bgp->distance_local; | |
11670 | else | |
11671 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11672 | } | |
11673 | } | |
11674 | ||
11675 | if (peer_sort (peer) == BGP_PEER_EBGP) | |
11676 | { | |
11677 | if (bgp->distance_ebgp) | |
11678 | return bgp->distance_ebgp; | |
11679 | return ZEBRA_EBGP_DISTANCE_DEFAULT; | |
11680 | } | |
11681 | else | |
11682 | { | |
11683 | if (bgp->distance_ibgp) | |
11684 | return bgp->distance_ibgp; | |
11685 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11686 | } | |
11687 | } | |
11688 | ||
11689 | DEFUN (bgp_distance, | |
11690 | bgp_distance_cmd, | |
11691 | "distance bgp <1-255> <1-255> <1-255>", | |
11692 | "Define an administrative distance\n" | |
11693 | "BGP distance\n" | |
11694 | "Distance for routes external to the AS\n" | |
11695 | "Distance for routes internal to the AS\n" | |
11696 | "Distance for local routes\n") | |
11697 | { | |
11698 | struct bgp *bgp; | |
11699 | ||
11700 | bgp = vty->index; | |
11701 | ||
11702 | bgp->distance_ebgp = atoi (argv[0]); | |
11703 | bgp->distance_ibgp = atoi (argv[1]); | |
11704 | bgp->distance_local = atoi (argv[2]); | |
11705 | return CMD_SUCCESS; | |
11706 | } | |
11707 | ||
11708 | DEFUN (no_bgp_distance, | |
11709 | no_bgp_distance_cmd, | |
11710 | "no distance bgp <1-255> <1-255> <1-255>", | |
11711 | NO_STR | |
11712 | "Define an administrative distance\n" | |
11713 | "BGP distance\n" | |
11714 | "Distance for routes external to the AS\n" | |
11715 | "Distance for routes internal to the AS\n" | |
11716 | "Distance for local routes\n") | |
11717 | { | |
11718 | struct bgp *bgp; | |
11719 | ||
11720 | bgp = vty->index; | |
11721 | ||
11722 | bgp->distance_ebgp= 0; | |
11723 | bgp->distance_ibgp = 0; | |
11724 | bgp->distance_local = 0; | |
11725 | return CMD_SUCCESS; | |
11726 | } | |
11727 | ||
11728 | ALIAS (no_bgp_distance, | |
11729 | no_bgp_distance2_cmd, | |
11730 | "no distance bgp", | |
11731 | NO_STR | |
11732 | "Define an administrative distance\n" | |
11733 | "BGP distance\n") | |
11734 | ||
11735 | DEFUN (bgp_distance_source, | |
11736 | bgp_distance_source_cmd, | |
11737 | "distance <1-255> A.B.C.D/M", | |
11738 | "Define an administrative distance\n" | |
11739 | "Administrative distance\n" | |
11740 | "IP source prefix\n") | |
11741 | { | |
11742 | bgp_distance_set (vty, argv[0], argv[1], NULL); | |
11743 | return CMD_SUCCESS; | |
11744 | } | |
11745 | ||
11746 | DEFUN (no_bgp_distance_source, | |
11747 | no_bgp_distance_source_cmd, | |
11748 | "no distance <1-255> A.B.C.D/M", | |
11749 | NO_STR | |
11750 | "Define an administrative distance\n" | |
11751 | "Administrative distance\n" | |
11752 | "IP source prefix\n") | |
11753 | { | |
11754 | bgp_distance_unset (vty, argv[0], argv[1], NULL); | |
11755 | return CMD_SUCCESS; | |
11756 | } | |
11757 | ||
11758 | DEFUN (bgp_distance_source_access_list, | |
11759 | bgp_distance_source_access_list_cmd, | |
11760 | "distance <1-255> A.B.C.D/M WORD", | |
11761 | "Define an administrative distance\n" | |
11762 | "Administrative distance\n" | |
11763 | "IP source prefix\n" | |
11764 | "Access list name\n") | |
11765 | { | |
11766 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); | |
11767 | return CMD_SUCCESS; | |
11768 | } | |
11769 | ||
11770 | DEFUN (no_bgp_distance_source_access_list, | |
11771 | no_bgp_distance_source_access_list_cmd, | |
11772 | "no distance <1-255> A.B.C.D/M WORD", | |
11773 | NO_STR | |
11774 | "Define an administrative distance\n" | |
11775 | "Administrative distance\n" | |
11776 | "IP source prefix\n" | |
11777 | "Access list name\n") | |
11778 | { | |
11779 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); | |
11780 | return CMD_SUCCESS; | |
11781 | } | |
11782 | \f | |
11783 | DEFUN (bgp_damp_set, | |
11784 | bgp_damp_set_cmd, | |
11785 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11786 | "BGP Specific commands\n" | |
11787 | "Enable route-flap dampening\n" | |
11788 | "Half-life time for the penalty\n" | |
11789 | "Value to start reusing a route\n" | |
11790 | "Value to start suppressing a route\n" | |
11791 | "Maximum duration to suppress a stable route\n") | |
11792 | { | |
11793 | struct bgp *bgp; | |
11794 | int half = DEFAULT_HALF_LIFE * 60; | |
11795 | int reuse = DEFAULT_REUSE; | |
11796 | int suppress = DEFAULT_SUPPRESS; | |
11797 | int max = 4 * half; | |
11798 | ||
11799 | if (argc == 4) | |
11800 | { | |
11801 | half = atoi (argv[0]) * 60; | |
11802 | reuse = atoi (argv[1]); | |
11803 | suppress = atoi (argv[2]); | |
11804 | max = atoi (argv[3]) * 60; | |
11805 | } | |
11806 | else if (argc == 1) | |
11807 | { | |
11808 | half = atoi (argv[0]) * 60; | |
11809 | max = 4 * half; | |
11810 | } | |
11811 | ||
11812 | bgp = vty->index; | |
11813 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), | |
11814 | half, reuse, suppress, max); | |
11815 | } | |
11816 | ||
11817 | ALIAS (bgp_damp_set, | |
11818 | bgp_damp_set2_cmd, | |
11819 | "bgp dampening <1-45>", | |
11820 | "BGP Specific commands\n" | |
11821 | "Enable route-flap dampening\n" | |
11822 | "Half-life time for the penalty\n") | |
11823 | ||
11824 | ALIAS (bgp_damp_set, | |
11825 | bgp_damp_set3_cmd, | |
11826 | "bgp dampening", | |
11827 | "BGP Specific commands\n" | |
11828 | "Enable route-flap dampening\n") | |
11829 | ||
11830 | DEFUN (bgp_damp_unset, | |
11831 | bgp_damp_unset_cmd, | |
11832 | "no bgp dampening", | |
11833 | NO_STR | |
11834 | "BGP Specific commands\n" | |
11835 | "Enable route-flap dampening\n") | |
11836 | { | |
11837 | struct bgp *bgp; | |
11838 | ||
11839 | bgp = vty->index; | |
11840 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); | |
11841 | } | |
11842 | ||
11843 | ALIAS (bgp_damp_unset, | |
11844 | bgp_damp_unset2_cmd, | |
11845 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11846 | NO_STR | |
11847 | "BGP Specific commands\n" | |
11848 | "Enable route-flap dampening\n" | |
11849 | "Half-life time for the penalty\n" | |
11850 | "Value to start reusing a route\n" | |
11851 | "Value to start suppressing a route\n" | |
11852 | "Maximum duration to suppress a stable route\n") | |
11853 | ||
11854 | DEFUN (show_ip_bgp_dampened_paths, | |
11855 | show_ip_bgp_dampened_paths_cmd, | |
11856 | "show ip bgp dampened-paths", | |
11857 | SHOW_STR | |
11858 | IP_STR | |
11859 | BGP_STR | |
11860 | "Display paths suppressed due to dampening\n") | |
11861 | { | |
5a646650 | 11862 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
11863 | NULL); | |
718e3744 | 11864 | } |
11865 | ||
11866 | DEFUN (show_ip_bgp_flap_statistics, | |
11867 | show_ip_bgp_flap_statistics_cmd, | |
11868 | "show ip bgp flap-statistics", | |
11869 | SHOW_STR | |
11870 | IP_STR | |
11871 | BGP_STR | |
11872 | "Display flap statistics of routes\n") | |
11873 | { | |
5a646650 | 11874 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
11875 | bgp_show_type_flap_statistics, NULL); | |
718e3744 | 11876 | } |
11877 | \f | |
11878 | /* Display specified route of BGP table. */ | |
94f2b392 | 11879 | static int |
fd79ac91 | 11880 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
11881 | const char *ip_str, afi_t afi, safi_t safi, | |
11882 | struct prefix_rd *prd, int prefix_check) | |
718e3744 | 11883 | { |
11884 | int ret; | |
11885 | struct prefix match; | |
11886 | struct bgp_node *rn; | |
11887 | struct bgp_node *rm; | |
11888 | struct bgp_info *ri; | |
11889 | struct bgp_info *ri_temp; | |
11890 | struct bgp *bgp; | |
11891 | struct bgp_table *table; | |
11892 | ||
11893 | /* BGP structure lookup. */ | |
11894 | if (view_name) | |
11895 | { | |
11896 | bgp = bgp_lookup_by_name (view_name); | |
11897 | if (bgp == NULL) | |
11898 | { | |
11899 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
11900 | return CMD_WARNING; | |
11901 | } | |
11902 | } | |
11903 | else | |
11904 | { | |
11905 | bgp = bgp_get_default (); | |
11906 | if (bgp == NULL) | |
11907 | { | |
11908 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
11909 | return CMD_WARNING; | |
11910 | } | |
11911 | } | |
11912 | ||
11913 | /* Check IP address argument. */ | |
11914 | ret = str2prefix (ip_str, &match); | |
11915 | if (! ret) | |
11916 | { | |
11917 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
11918 | return CMD_WARNING; | |
11919 | } | |
11920 | ||
11921 | match.family = afi2family (afi); | |
11922 | ||
11923 | if (safi == SAFI_MPLS_VPN) | |
11924 | { | |
11925 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) | |
11926 | { | |
11927 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
11928 | continue; | |
11929 | ||
11930 | if ((table = rn->info) != NULL) | |
11931 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6c88b44d CC |
11932 | { |
11933 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) | |
11934 | { | |
11935 | ri = rm->info; | |
11936 | while (ri) | |
11937 | { | |
11938 | if (ri->extra && ri->extra->damp_info) | |
11939 | { | |
11940 | ri_temp = ri->next; | |
11941 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
11942 | ri = ri_temp; | |
11943 | } | |
11944 | else | |
11945 | ri = ri->next; | |
11946 | } | |
11947 | } | |
11948 | ||
11949 | bgp_unlock_node (rm); | |
11950 | } | |
718e3744 | 11951 | } |
11952 | } | |
11953 | else | |
11954 | { | |
11955 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) | |
6c88b44d CC |
11956 | { |
11957 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
11958 | { | |
11959 | ri = rn->info; | |
11960 | while (ri) | |
11961 | { | |
11962 | if (ri->extra && ri->extra->damp_info) | |
11963 | { | |
11964 | ri_temp = ri->next; | |
11965 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
11966 | ri = ri_temp; | |
11967 | } | |
11968 | else | |
11969 | ri = ri->next; | |
11970 | } | |
11971 | } | |
11972 | ||
11973 | bgp_unlock_node (rn); | |
11974 | } | |
718e3744 | 11975 | } |
11976 | ||
11977 | return CMD_SUCCESS; | |
11978 | } | |
11979 | ||
11980 | DEFUN (clear_ip_bgp_dampening, | |
11981 | clear_ip_bgp_dampening_cmd, | |
11982 | "clear ip bgp dampening", | |
11983 | CLEAR_STR | |
11984 | IP_STR | |
11985 | BGP_STR | |
11986 | "Clear route flap dampening information\n") | |
11987 | { | |
11988 | bgp_damp_info_clean (); | |
11989 | return CMD_SUCCESS; | |
11990 | } | |
11991 | ||
11992 | DEFUN (clear_ip_bgp_dampening_prefix, | |
11993 | clear_ip_bgp_dampening_prefix_cmd, | |
11994 | "clear ip bgp dampening A.B.C.D/M", | |
11995 | CLEAR_STR | |
11996 | IP_STR | |
11997 | BGP_STR | |
11998 | "Clear route flap dampening information\n" | |
11999 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
12000 | { | |
12001 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
12002 | SAFI_UNICAST, NULL, 1); | |
12003 | } | |
12004 | ||
12005 | DEFUN (clear_ip_bgp_dampening_address, | |
12006 | clear_ip_bgp_dampening_address_cmd, | |
12007 | "clear ip bgp dampening A.B.C.D", | |
12008 | CLEAR_STR | |
12009 | IP_STR | |
12010 | BGP_STR | |
12011 | "Clear route flap dampening information\n" | |
12012 | "Network to clear damping information\n") | |
12013 | { | |
12014 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
12015 | SAFI_UNICAST, NULL, 0); | |
12016 | } | |
12017 | ||
12018 | DEFUN (clear_ip_bgp_dampening_address_mask, | |
12019 | clear_ip_bgp_dampening_address_mask_cmd, | |
12020 | "clear ip bgp dampening A.B.C.D A.B.C.D", | |
12021 | CLEAR_STR | |
12022 | IP_STR | |
12023 | BGP_STR | |
12024 | "Clear route flap dampening information\n" | |
12025 | "Network to clear damping information\n" | |
12026 | "Network mask\n") | |
12027 | { | |
12028 | int ret; | |
12029 | char prefix_str[BUFSIZ]; | |
12030 | ||
12031 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
12032 | if (! ret) | |
12033 | { | |
12034 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
12035 | return CMD_WARNING; | |
12036 | } | |
12037 | ||
12038 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, | |
12039 | SAFI_UNICAST, NULL, 0); | |
12040 | } | |
12041 | \f | |
94f2b392 | 12042 | static int |
718e3744 | 12043 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
12044 | afi_t afi, safi_t safi, int *write) | |
12045 | { | |
12046 | struct bgp_node *prn; | |
12047 | struct bgp_node *rn; | |
12048 | struct bgp_table *table; | |
12049 | struct prefix *p; | |
12050 | struct prefix_rd *prd; | |
12051 | struct bgp_static *bgp_static; | |
12052 | u_int32_t label; | |
12053 | char buf[SU_ADDRSTRLEN]; | |
12054 | char rdbuf[RD_ADDRSTRLEN]; | |
12055 | ||
12056 | /* Network configuration. */ | |
12057 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) | |
12058 | if ((table = prn->info) != NULL) | |
12059 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
12060 | if ((bgp_static = rn->info) != NULL) | |
12061 | { | |
12062 | p = &rn->p; | |
12063 | prd = (struct prefix_rd *) &prn->p; | |
12064 | ||
12065 | /* "address-family" display. */ | |
12066 | bgp_config_write_family_header (vty, afi, safi, write); | |
12067 | ||
12068 | /* "network" configuration display. */ | |
12069 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); | |
12070 | label = decode_label (bgp_static->tag); | |
12071 | ||
12072 | vty_out (vty, " network %s/%d rd %s tag %d", | |
12073 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12074 | p->prefixlen, | |
12075 | rdbuf, label); | |
12076 | vty_out (vty, "%s", VTY_NEWLINE); | |
12077 | } | |
12078 | return 0; | |
12079 | } | |
12080 | ||
12081 | /* Configuration of static route announcement and aggregate | |
12082 | information. */ | |
12083 | int | |
12084 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, | |
12085 | afi_t afi, safi_t safi, int *write) | |
12086 | { | |
12087 | struct bgp_node *rn; | |
12088 | struct prefix *p; | |
12089 | struct bgp_static *bgp_static; | |
12090 | struct bgp_aggregate *bgp_aggregate; | |
12091 | char buf[SU_ADDRSTRLEN]; | |
12092 | ||
12093 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
12094 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); | |
12095 | ||
12096 | /* Network configuration. */ | |
12097 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
12098 | if ((bgp_static = rn->info) != NULL) | |
12099 | { | |
12100 | p = &rn->p; | |
12101 | ||
12102 | /* "address-family" display. */ | |
12103 | bgp_config_write_family_header (vty, afi, safi, write); | |
12104 | ||
12105 | /* "network" configuration display. */ | |
12106 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
12107 | { | |
12108 | u_int32_t destination; | |
12109 | struct in_addr netmask; | |
12110 | ||
12111 | destination = ntohl (p->u.prefix4.s_addr); | |
12112 | masklen2ip (p->prefixlen, &netmask); | |
12113 | vty_out (vty, " network %s", | |
12114 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); | |
12115 | ||
12116 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
12117 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
12118 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
12119 | || p->u.prefix4.s_addr == 0) | |
12120 | { | |
12121 | /* Natural mask is not display. */ | |
12122 | } | |
12123 | else | |
12124 | vty_out (vty, " mask %s", inet_ntoa (netmask)); | |
12125 | } | |
12126 | else | |
12127 | { | |
12128 | vty_out (vty, " network %s/%d", | |
12129 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12130 | p->prefixlen); | |
12131 | } | |
12132 | ||
12133 | if (bgp_static->rmap.name) | |
12134 | vty_out (vty, " route-map %s", bgp_static->rmap.name); | |
41367172 PJ |
12135 | else |
12136 | { | |
12137 | if (bgp_static->backdoor) | |
12138 | vty_out (vty, " backdoor"); | |
41367172 | 12139 | } |
718e3744 | 12140 | |
12141 | vty_out (vty, "%s", VTY_NEWLINE); | |
12142 | } | |
12143 | ||
12144 | /* Aggregate-address configuration. */ | |
12145 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) | |
12146 | if ((bgp_aggregate = rn->info) != NULL) | |
12147 | { | |
12148 | p = &rn->p; | |
12149 | ||
12150 | /* "address-family" display. */ | |
12151 | bgp_config_write_family_header (vty, afi, safi, write); | |
12152 | ||
12153 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
12154 | { | |
12155 | struct in_addr netmask; | |
12156 | ||
12157 | masklen2ip (p->prefixlen, &netmask); | |
12158 | vty_out (vty, " aggregate-address %s %s", | |
12159 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12160 | inet_ntoa (netmask)); | |
12161 | } | |
12162 | else | |
12163 | { | |
12164 | vty_out (vty, " aggregate-address %s/%d", | |
12165 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
12166 | p->prefixlen); | |
12167 | } | |
12168 | ||
12169 | if (bgp_aggregate->as_set) | |
12170 | vty_out (vty, " as-set"); | |
12171 | ||
12172 | if (bgp_aggregate->summary_only) | |
12173 | vty_out (vty, " summary-only"); | |
12174 | ||
12175 | vty_out (vty, "%s", VTY_NEWLINE); | |
12176 | } | |
12177 | ||
12178 | return 0; | |
12179 | } | |
12180 | ||
12181 | int | |
12182 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) | |
12183 | { | |
12184 | struct bgp_node *rn; | |
12185 | struct bgp_distance *bdistance; | |
12186 | ||
12187 | /* Distance configuration. */ | |
12188 | if (bgp->distance_ebgp | |
12189 | && bgp->distance_ibgp | |
12190 | && bgp->distance_local | |
12191 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT | |
12192 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT | |
12193 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) | |
12194 | vty_out (vty, " distance bgp %d %d %d%s", | |
12195 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, | |
12196 | VTY_NEWLINE); | |
12197 | ||
12198 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) | |
12199 | if ((bdistance = rn->info) != NULL) | |
12200 | { | |
12201 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, | |
12202 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
12203 | bdistance->access_list ? bdistance->access_list : "", | |
12204 | VTY_NEWLINE); | |
12205 | } | |
12206 | ||
12207 | return 0; | |
12208 | } | |
12209 | ||
12210 | /* Allocate routing table structure and install commands. */ | |
12211 | void | |
66e5cd87 | 12212 | bgp_route_init (void) |
718e3744 | 12213 | { |
12214 | /* Init BGP distance table. */ | |
64e580a7 | 12215 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
718e3744 | 12216 | |
12217 | /* IPv4 BGP commands. */ | |
12218 | install_element (BGP_NODE, &bgp_network_cmd); | |
12219 | install_element (BGP_NODE, &bgp_network_mask_cmd); | |
12220 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); | |
12221 | install_element (BGP_NODE, &bgp_network_route_map_cmd); | |
12222 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); | |
12223 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); | |
12224 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); | |
12225 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); | |
12226 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); | |
12227 | install_element (BGP_NODE, &no_bgp_network_cmd); | |
12228 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); | |
12229 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); | |
12230 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); | |
12231 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); | |
12232 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
12233 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); | |
12234 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); | |
12235 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); | |
12236 | ||
12237 | install_element (BGP_NODE, &aggregate_address_cmd); | |
12238 | install_element (BGP_NODE, &aggregate_address_mask_cmd); | |
12239 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); | |
12240 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); | |
12241 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); | |
12242 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); | |
12243 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); | |
12244 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
12245 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); | |
12246 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
12247 | install_element (BGP_NODE, &no_aggregate_address_cmd); | |
12248 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); | |
12249 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); | |
12250 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); | |
12251 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); | |
12252 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); | |
12253 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
12254 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); | |
12255 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
12256 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
12257 | ||
12258 | /* IPv4 unicast configuration. */ | |
12259 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); | |
12260 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); | |
12261 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); | |
12262 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); | |
12263 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); | |
12264 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); | |
c8f3fe30 | 12265 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
718e3744 | 12266 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
12267 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); | |
12268 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); | |
12269 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); | |
12270 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
c8f3fe30 | 12271 | |
718e3744 | 12272 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
12273 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); | |
12274 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); | |
12275 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); | |
12276 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); | |
12277 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); | |
12278 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); | |
12279 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
12280 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); | |
12281 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
12282 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); | |
12283 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); | |
12284 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); | |
12285 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); | |
12286 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); | |
12287 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); | |
12288 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
12289 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); | |
12290 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
12291 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
12292 | ||
12293 | /* IPv4 multicast configuration. */ | |
12294 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); | |
12295 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); | |
12296 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); | |
12297 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); | |
12298 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); | |
12299 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); | |
12300 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); | |
12301 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); | |
12302 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); | |
12303 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); | |
12304 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); | |
12305 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
12306 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); | |
12307 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); | |
12308 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); | |
12309 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); | |
12310 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); | |
12311 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); | |
12312 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); | |
12313 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
12314 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); | |
12315 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
12316 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); | |
12317 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); | |
12318 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); | |
12319 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); | |
12320 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); | |
12321 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); | |
12322 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
12323 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); | |
12324 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
12325 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
12326 | ||
12327 | install_element (VIEW_NODE, &show_ip_bgp_cmd); | |
12328 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); | |
95cbbd2a | 12329 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 12330 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
12331 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); | |
95cbbd2a | 12332 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 12333 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
12334 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
12335 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); | |
12336 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
95cbbd2a | 12337 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
718e3744 | 12338 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
12339 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
12340 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); | |
12341 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); | |
12342 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); | |
12343 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); | |
12344 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
12345 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); | |
12346 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
12347 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); | |
12348 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
12349 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); | |
12350 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
12351 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); | |
12352 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
12353 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); | |
12354 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
12355 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); | |
12356 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); | |
12357 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); | |
12358 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); | |
12359 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); | |
12360 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
12361 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
12362 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
95cbbd2a ML |
12363 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
12364 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); | |
12365 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); | |
12366 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); | |
12367 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); | |
718e3744 | 12368 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
12369 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); | |
12370 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); | |
12371 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); | |
12372 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
12373 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
12374 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
12375 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
12376 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); | |
12377 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
12378 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); | |
12379 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
12380 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); | |
12381 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
12382 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
12383 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
12384 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
12385 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
95cbbd2a | 12386 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 12387 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
12388 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
12389 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
12390 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
12391 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); | |
12392 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); | |
12393 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); | |
12394 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); | |
12395 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
12396 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); | |
12397 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
12398 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
12399 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
12400 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); | |
12401 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
12402 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 12403 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
95cbbd2a | 12404 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12405 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
95cbbd2a | 12406 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12407 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12408 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
2a71e9ce TP |
12409 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
12410 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 12411 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
95cbbd2a | 12412 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12413 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12414 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12415 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12416 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
62687ff1 PJ |
12417 | |
12418 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ | |
12419 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); | |
12420 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); | |
95cbbd2a | 12421 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
62687ff1 PJ |
12422 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
12423 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); | |
12424 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
95cbbd2a | 12425 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
62687ff1 PJ |
12426 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
12427 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
12428 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); | |
12429 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); | |
12430 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); | |
12431 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); | |
12432 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); | |
12433 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); | |
12434 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); | |
12435 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
12436 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
12437 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
95cbbd2a ML |
12438 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
12439 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); | |
12440 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); | |
12441 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); | |
12442 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); | |
62687ff1 PJ |
12443 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
12444 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); | |
12445 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); | |
12446 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); | |
12447 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
12448 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
12449 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
12450 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
12451 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); | |
95cbbd2a | 12452 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
62687ff1 | 12453 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12454 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
62687ff1 | 12455 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12456 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
62687ff1 | 12457 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12458 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
718e3744 | 12459 | |
12460 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); | |
12461 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); | |
95cbbd2a | 12462 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
718e3744 | 12463 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
12464 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); | |
95cbbd2a | 12465 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
718e3744 | 12466 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
12467 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
12468 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); | |
12469 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
95cbbd2a | 12470 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
718e3744 | 12471 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
12472 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
12473 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); | |
12474 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); | |
12475 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); | |
12476 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); | |
12477 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
12478 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); | |
12479 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
12480 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); | |
12481 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
12482 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); | |
12483 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
12484 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); | |
12485 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
12486 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); | |
12487 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
12488 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); | |
12489 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); | |
12490 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); | |
12491 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); | |
12492 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); | |
12493 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
12494 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
12495 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
95cbbd2a ML |
12496 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
12497 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); | |
12498 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); | |
12499 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); | |
12500 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); | |
718e3744 | 12501 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
12502 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); | |
12503 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); | |
12504 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); | |
12505 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
12506 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
12507 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
12508 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
12509 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); | |
12510 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
12511 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); | |
12512 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
12513 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); | |
12514 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
12515 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
12516 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
12517 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
12518 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
95cbbd2a | 12519 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
718e3744 | 12520 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
12521 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
12522 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
12523 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
12524 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); | |
12525 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); | |
12526 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); | |
12527 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); | |
12528 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
12529 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); | |
12530 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
12531 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
12532 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
12533 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); | |
12534 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
12535 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 12536 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
95cbbd2a | 12537 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12538 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
95cbbd2a | 12539 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12540 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12541 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
2a71e9ce TP |
12542 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
12543 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 12544 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
95cbbd2a | 12545 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
fee0f4c6 | 12546 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12547 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
fee0f4c6 | 12548 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12549 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
718e3744 | 12550 | |
12551 | /* BGP dampening clear commands */ | |
12552 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); | |
12553 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); | |
12554 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); | |
12555 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); | |
12556 | ||
ff7924f6 PJ |
12557 | /* prefix count */ |
12558 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); | |
12559 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); | |
12560 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); | |
718e3744 | 12561 | #ifdef HAVE_IPV6 |
ff7924f6 PJ |
12562 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
12563 | ||
718e3744 | 12564 | /* New config IPv6 BGP commands. */ |
12565 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); | |
12566 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); | |
12567 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); | |
12568 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); | |
12569 | ||
12570 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); | |
12571 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); | |
12572 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); | |
12573 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); | |
12574 | ||
12575 | /* Old config IPv6 BGP commands. */ | |
12576 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); | |
12577 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); | |
12578 | ||
12579 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); | |
12580 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); | |
12581 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); | |
12582 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); | |
12583 | ||
12584 | install_element (VIEW_NODE, &show_bgp_cmd); | |
12585 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 12586 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 12587 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
12588 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 12589 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
718e3744 | 12590 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
12591 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 12592 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
718e3744 | 12593 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
12594 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); | |
12595 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); | |
12596 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12597 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); | |
12598 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12599 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); | |
12600 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); | |
12601 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); | |
12602 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); | |
12603 | install_element (VIEW_NODE, &show_bgp_community_cmd); | |
12604 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); | |
12605 | install_element (VIEW_NODE, &show_bgp_community2_cmd); | |
12606 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); | |
12607 | install_element (VIEW_NODE, &show_bgp_community3_cmd); | |
12608 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); | |
12609 | install_element (VIEW_NODE, &show_bgp_community4_cmd); | |
12610 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); | |
12611 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); | |
12612 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12613 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); | |
12614 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12615 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); | |
12616 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12617 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); | |
12618 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12619 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); | |
12620 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); | |
12621 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); | |
12622 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12623 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); | |
12624 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12625 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12626 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12627 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12628 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12629 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); | |
12630 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12631 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12632 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12633 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
12634 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12635 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); | |
12636 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12637 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
95cbbd2a | 12638 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12639 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
95cbbd2a | 12640 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12641 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12642 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
bb46e94f | 12643 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
12644 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); | |
12645 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); | |
12646 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); | |
12647 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); | |
12648 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12649 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12650 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12651 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12652 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12653 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12654 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12655 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12656 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12657 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12658 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12659 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12660 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12661 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
95cbbd2a | 12662 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12663 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12664 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12665 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12666 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
62687ff1 PJ |
12667 | |
12668 | /* Restricted: | |
12669 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) | |
12670 | */ | |
12671 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); | |
12672 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 12673 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
62687ff1 PJ |
12674 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
12675 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 12676 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
62687ff1 PJ |
12677 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
12678 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); | |
12679 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); | |
12680 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); | |
12681 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); | |
12682 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); | |
12683 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); | |
12684 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); | |
12685 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); | |
12686 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12687 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); | |
12688 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12689 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); | |
12690 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12691 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); | |
12692 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12693 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); | |
95cbbd2a | 12694 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
62687ff1 | 12695 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12696 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
62687ff1 PJ |
12697 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
12698 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); | |
12699 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); | |
12700 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12701 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12702 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12703 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); | |
95cbbd2a | 12704 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
62687ff1 | 12705 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12706 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
718e3744 | 12707 | |
12708 | install_element (ENABLE_NODE, &show_bgp_cmd); | |
12709 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); | |
95cbbd2a | 12710 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
718e3744 | 12711 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
12712 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); | |
95cbbd2a | 12713 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
718e3744 | 12714 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
12715 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); | |
95cbbd2a | 12716 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
718e3744 | 12717 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
12718 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); | |
12719 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); | |
12720 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12721 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); | |
12722 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12723 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); | |
12724 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); | |
12725 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); | |
12726 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); | |
12727 | install_element (ENABLE_NODE, &show_bgp_community_cmd); | |
12728 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); | |
12729 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); | |
12730 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); | |
12731 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); | |
12732 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); | |
12733 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); | |
12734 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); | |
12735 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); | |
12736 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12737 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); | |
12738 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12739 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); | |
12740 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12741 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); | |
12742 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12743 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); | |
12744 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); | |
12745 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); | |
12746 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12747 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); | |
12748 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12749 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12750 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12751 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12752 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12753 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); | |
12754 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12755 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12756 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12757 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
12758 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12759 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); | |
12760 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12761 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
95cbbd2a | 12762 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12763 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
95cbbd2a | 12764 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12765 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
95cbbd2a | 12766 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
bb46e94f | 12767 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
12768 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); | |
12769 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); | |
12770 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); | |
12771 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); | |
12772 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12773 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12774 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12775 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12776 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12777 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12778 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12779 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12780 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12781 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12782 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12783 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12784 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12785 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
95cbbd2a | 12786 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
fee0f4c6 | 12787 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
95cbbd2a | 12788 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
fee0f4c6 | 12789 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
95cbbd2a | 12790 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
2815e61f PJ |
12791 | |
12792 | /* Statistics */ | |
12793 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); | |
12794 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); | |
12795 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); | |
12796 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); | |
12797 | ||
718e3744 | 12798 | /* old command */ |
12799 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); | |
12800 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); | |
12801 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); | |
12802 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); | |
12803 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12804 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12805 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); | |
12806 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); | |
12807 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); | |
12808 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); | |
12809 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); | |
12810 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12811 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12812 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12813 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12814 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); | |
12815 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12816 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12817 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); | |
12818 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); | |
12819 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12820 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12821 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12822 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12823 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12824 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); | |
12825 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); | |
12826 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); | |
12827 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); | |
12828 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12829 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12830 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12831 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12832 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12833 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
12834 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
bb46e94f | 12835 | |
718e3744 | 12836 | /* old command */ |
12837 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); | |
12838 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); | |
12839 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); | |
12840 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); | |
12841 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12842 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12843 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); | |
12844 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); | |
12845 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); | |
12846 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); | |
12847 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); | |
12848 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12849 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12850 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12851 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12852 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); | |
12853 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12854 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12855 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); | |
12856 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); | |
12857 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12858 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12859 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12860 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12861 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12862 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); | |
12863 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); | |
12864 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); | |
12865 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); | |
12866 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12867 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12868 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12869 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12870 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12871 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
12872 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
12873 | ||
12874 | /* old command */ | |
12875 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
12876 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
12877 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
12878 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
12879 | ||
12880 | /* old command */ | |
12881 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
12882 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
12883 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
12884 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
12885 | ||
12886 | /* old command */ | |
12887 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
12888 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
12889 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
12890 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
12891 | #endif /* HAVE_IPV6 */ | |
12892 | ||
12893 | install_element (BGP_NODE, &bgp_distance_cmd); | |
12894 | install_element (BGP_NODE, &no_bgp_distance_cmd); | |
12895 | install_element (BGP_NODE, &no_bgp_distance2_cmd); | |
12896 | install_element (BGP_NODE, &bgp_distance_source_cmd); | |
12897 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); | |
12898 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); | |
12899 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); | |
12900 | ||
12901 | install_element (BGP_NODE, &bgp_damp_set_cmd); | |
12902 | install_element (BGP_NODE, &bgp_damp_set2_cmd); | |
12903 | install_element (BGP_NODE, &bgp_damp_set3_cmd); | |
12904 | install_element (BGP_NODE, &bgp_damp_unset_cmd); | |
12905 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); | |
12906 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); | |
12907 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); | |
12908 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); | |
12909 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); | |
12910 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); | |
c8f3fe30 PJ |
12911 | |
12912 | /* Deprecated AS-Pathlimit commands */ | |
12913 | install_element (BGP_NODE, &bgp_network_ttl_cmd); | |
12914 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); | |
12915 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); | |
12916 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); | |
12917 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
12918 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
12919 | ||
12920 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); | |
12921 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); | |
12922 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
12923 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
12924 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
12925 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
12926 | ||
12927 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); | |
12928 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); | |
12929 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); | |
12930 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); | |
12931 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
12932 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
12933 | ||
12934 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); | |
12935 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); | |
12936 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
12937 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
12938 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
12939 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
12940 | ||
12941 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); | |
12942 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); | |
12943 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); | |
12944 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); | |
12945 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
12946 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
12947 | ||
12948 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); | |
12949 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); | |
12950 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
12951 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
12952 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
12953 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
3bde17f1 PJ |
12954 | |
12955 | #ifdef HAVE_IPV6 | |
c8f3fe30 PJ |
12956 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
12957 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); | |
3bde17f1 | 12958 | #endif |
718e3744 | 12959 | } |
228da428 CC |
12960 | |
12961 | void | |
12962 | bgp_route_finish (void) | |
12963 | { | |
12964 | bgp_table_unlock (bgp_distance_table); | |
12965 | bgp_distance_table = NULL; | |
12966 | } |