]>
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) | |
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 PJ |
912 | |
913 | /* AS-Pathlimit check */ | |
914 | if (ri->attr->pathlimit.ttl && peer_sort (peer) == BGP_PEER_EBGP) | |
915 | /* Our ASN has not yet been pre-pended, that's done in packet_attribute | |
916 | * on output. Hence the test here is for >=. | |
917 | */ | |
918 | if (aspath_count_hops (ri->attr->aspath) >= ri->attr->pathlimit.ttl) | |
919 | { | |
920 | if (BGP_DEBUG (filter, FILTER)) | |
921 | zlog_info ("%s [Update:SEND] suppressed, AS-Pathlimit TTL %u exceeded", | |
922 | peer->host, ri->attr->pathlimit.ttl); | |
923 | return 0; | |
924 | } | |
925 | ||
718e3744 | 926 | /* For modify attribute, copy it to temporary structure. */ |
fb982c25 PJ |
927 | bgp_attr_dup (attr, ri->attr); |
928 | ||
718e3744 | 929 | /* If local-preference is not set. */ |
930 | if ((peer_sort (peer) == BGP_PEER_IBGP | |
931 | || peer_sort (peer) == BGP_PEER_CONFED) | |
932 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) | |
933 | { | |
934 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); | |
935 | attr->local_pref = bgp->default_local_pref; | |
936 | } | |
937 | ||
718e3744 | 938 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
939 | if (peer_sort (peer) == BGP_PEER_EBGP | |
940 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
941 | { | |
942 | if (ri->peer != bgp->peer_self && ! transparent | |
943 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
944 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); | |
945 | } | |
946 | ||
947 | /* next-hop-set */ | |
948 | if (transparent || reflect | |
949 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) | |
950 | && ((p->family == AF_INET && attr->nexthop.s_addr) | |
286e1e71 | 951 | #ifdef HAVE_IPV6 |
fee0f4c6 | 952 | || (p->family == AF_INET6 && |
fb982c25 | 953 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
286e1e71 | 954 | #endif /* HAVE_IPV6 */ |
955 | ))) | |
718e3744 | 956 | { |
957 | /* NEXT-HOP Unchanged. */ | |
958 | } | |
959 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
960 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) | |
961 | #ifdef HAVE_IPV6 | |
fee0f4c6 | 962 | || (p->family == AF_INET6 && |
fb982c25 | 963 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
718e3744 | 964 | #endif /* HAVE_IPV6 */ |
965 | || (peer_sort (peer) == BGP_PEER_EBGP | |
966 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) | |
967 | { | |
968 | /* Set IPv4 nexthop. */ | |
969 | if (p->family == AF_INET) | |
970 | { | |
971 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
972 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
973 | IPV4_MAX_BYTELEN); | |
718e3744 | 974 | else |
975 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); | |
976 | } | |
977 | #ifdef HAVE_IPV6 | |
978 | /* Set IPv6 nexthop. */ | |
979 | if (p->family == AF_INET6) | |
980 | { | |
981 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 982 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
718e3744 | 983 | IPV6_MAX_BYTELEN); |
fb982c25 | 984 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 985 | } |
986 | #endif /* HAVE_IPV6 */ | |
987 | } | |
988 | ||
989 | #ifdef HAVE_IPV6 | |
990 | if (p->family == AF_INET6) | |
991 | { | |
fee0f4c6 | 992 | /* Left nexthop_local unchanged if so configured. */ |
993 | if ( CHECK_FLAG (peer->af_flags[afi][safi], | |
994 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) | |
995 | { | |
fb982c25 PJ |
996 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
997 | attr->extra->mp_nexthop_len=32; | |
fee0f4c6 | 998 | else |
fb982c25 | 999 | attr->extra->mp_nexthop_len=16; |
fee0f4c6 | 1000 | } |
1001 | ||
1002 | /* Default nexthop_local treatment for non-RS-Clients */ | |
1003 | else | |
1004 | { | |
718e3744 | 1005 | /* Link-local address should not be transit to different peer. */ |
fb982c25 | 1006 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1007 | |
1008 | /* Set link-local address for shared network peer. */ | |
1009 | if (peer->shared_network | |
1010 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) | |
1011 | { | |
fb982c25 | 1012 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
718e3744 | 1013 | IPV6_MAX_BYTELEN); |
fb982c25 | 1014 | attr->extra->mp_nexthop_len = 32; |
718e3744 | 1015 | } |
1016 | ||
1017 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local | |
1018 | address.*/ | |
1019 | if (reflect) | |
fb982c25 | 1020 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1021 | |
1022 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ | |
1023 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) | |
fb982c25 | 1024 | attr->extra->mp_nexthop_len = 16; |
718e3744 | 1025 | } |
fee0f4c6 | 1026 | |
1027 | } | |
718e3744 | 1028 | #endif /* HAVE_IPV6 */ |
1029 | ||
41367172 PJ |
1030 | /* AS-Pathlimit: Check ASN for private/confed */ |
1031 | if (attr->pathlimit.ttl) | |
1032 | { | |
1033 | /* locally originated update */ | |
1034 | if (!attr->pathlimit.as) | |
1035 | attr->pathlimit.as = peer->local_as; | |
1036 | ||
1037 | /* if the AS_PATHLIMIT attribute is attached to a prefix by a | |
1038 | member of a confederation, then when the prefix is advertised outside | |
1039 | of the confederation boundary, then the AS number of the | |
1040 | confederation member inside of the AS_PATHLIMIT attribute should be | |
1041 | replaced by the confederation's AS number. */ | |
1042 | if (peer_sort (from) == BGP_PEER_CONFED | |
1043 | && peer_sort (peer) != BGP_PEER_CONFED) | |
1044 | attr->pathlimit.as = peer->local_as; | |
1045 | ||
1046 | /* Private ASN should be updated whenever announcement leaves | |
1047 | * private space. This is deliberately done after simple confed | |
1048 | * based update.. | |
1049 | */ | |
1050 | if (attr->pathlimit.as >= BGP_PRIVATE_AS_MIN | |
1051 | && attr->pathlimit.as <= BGP_PRIVATE_AS_MAX) | |
1052 | { | |
1053 | if (peer->local_as < BGP_PRIVATE_AS_MIN | |
1054 | || peer->local_as > BGP_PRIVATE_AS_MAX) | |
1055 | attr->pathlimit.as = peer->local_as; | |
1056 | /* Ours is private, try using theirs.. */ | |
1057 | else if (peer->as < BGP_PRIVATE_AS_MIN | |
1058 | || peer->local_as > BGP_PRIVATE_AS_MAX) | |
1059 | attr->pathlimit.as = peer->as; | |
1060 | } | |
1061 | } | |
1062 | ||
718e3744 | 1063 | /* If this is EBGP peer and remove-private-AS is set. */ |
1064 | if (peer_sort (peer) == BGP_PEER_EBGP | |
1065 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) | |
1066 | && aspath_private_as_check (attr->aspath)) | |
1067 | attr->aspath = aspath_empty_get (); | |
1068 | ||
1069 | /* Route map & unsuppress-map apply. */ | |
1070 | if (ROUTE_MAP_OUT_NAME (filter) | |
fb982c25 | 1071 | || (ri->extra && ri->extra->suppress) ) |
718e3744 | 1072 | { |
7c7fa1b4 | 1073 | struct bgp_info info; |
9eda90ce | 1074 | struct attr dummy_attr = { 0 }; |
7c7fa1b4 | 1075 | |
718e3744 | 1076 | info.peer = peer; |
1077 | info.attr = attr; | |
1078 | ||
1079 | /* The route reflector is not allowed to modify the attributes | |
1080 | of the reflected IBGP routes. */ | |
1081 | if (peer_sort (from) == BGP_PEER_IBGP | |
1082 | && peer_sort (peer) == BGP_PEER_IBGP) | |
1083 | { | |
fb982c25 | 1084 | bgp_attr_dup (&dummy_attr, attr); |
9eda90ce | 1085 | info.attr = &dummy_attr; |
718e3744 | 1086 | } |
ac41b2a2 | 1087 | |
1088 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); | |
1089 | ||
fb982c25 | 1090 | if (ri->extra && ri->extra->suppress) |
718e3744 | 1091 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
1092 | else | |
1093 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1094 | ||
ac41b2a2 | 1095 | peer->rmap_type = 0; |
fb982c25 | 1096 | |
9eda90ce PJ |
1097 | if (dummy_attr.extra) |
1098 | bgp_attr_extra_free (&dummy_attr); | |
fb982c25 | 1099 | |
718e3744 | 1100 | if (ret == RMAP_DENYMATCH) |
1101 | { | |
1102 | bgp_attr_flush (attr); | |
1103 | return 0; | |
1104 | } | |
1105 | } | |
1106 | return 1; | |
1107 | } | |
1108 | ||
94f2b392 | 1109 | static int |
fee0f4c6 | 1110 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
1111 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) | |
1112 | { | |
1113 | int ret; | |
1114 | char buf[SU_ADDRSTRLEN]; | |
1115 | struct bgp_filter *filter; | |
1116 | struct bgp_info info; | |
1117 | struct peer *from; | |
1118 | struct bgp *bgp; | |
1119 | ||
1120 | from = ri->peer; | |
1121 | filter = &rsclient->filter[afi][safi]; | |
1122 | bgp = rsclient->bgp; | |
1123 | ||
750e8146 PJ |
1124 | if (DISABLE_BGP_ANNOUNCE) |
1125 | return 0; | |
fee0f4c6 | 1126 | |
1127 | /* Do not send back route to sender. */ | |
1128 | if (from == rsclient) | |
1129 | return 0; | |
1130 | ||
1131 | /* Aggregate-address suppress check. */ | |
fb982c25 | 1132 | if (ri->extra && ri->extra->suppress) |
fee0f4c6 | 1133 | if (! UNSUPPRESS_MAP_NAME (filter)) |
1134 | return 0; | |
1135 | ||
1136 | /* Default route check. */ | |
1137 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], | |
1138 | PEER_STATUS_DEFAULT_ORIGINATE)) | |
1139 | { | |
1140 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) | |
1141 | return 0; | |
1142 | #ifdef HAVE_IPV6 | |
1143 | else if (p->family == AF_INET6 && p->prefixlen == 0) | |
1144 | return 0; | |
1145 | #endif /* HAVE_IPV6 */ | |
1146 | } | |
1147 | ||
1148 | /* If the attribute has originator-id and it is same as remote | |
1149 | peer's id. */ | |
1150 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) | |
1151 | { | |
fb982c25 PJ |
1152 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
1153 | &ri->attr->extra->originator_id)) | |
fee0f4c6 | 1154 | { |
1155 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1156 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 1157 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
1158 | rsclient->host, | |
1159 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1160 | p->prefixlen); | |
1161 | return 0; | |
1162 | } | |
1163 | } | |
1164 | ||
1165 | /* ORF prefix-list filter check */ | |
1166 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
1167 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
1168 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) | |
1169 | if (rsclient->orf_plist[afi][safi]) | |
1170 | { | |
1171 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) | |
1172 | return 0; | |
1173 | } | |
1174 | ||
1175 | /* Output filter check. */ | |
1176 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) | |
1177 | { | |
1178 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1179 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 1180 | "%s [Update:SEND] %s/%d is filtered", |
1181 | rsclient->host, | |
1182 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1183 | p->prefixlen); | |
1184 | return 0; | |
1185 | } | |
1186 | ||
1187 | #ifdef BGP_SEND_ASPATH_CHECK | |
1188 | /* AS path loop check. */ | |
1189 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) | |
1190 | { | |
1191 | if (BGP_DEBUG (filter, FILTER)) | |
d2c1f16b | 1192 | zlog (rsclient->log, LOG_DEBUG, |
aea339f7 | 1193 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
fee0f4c6 | 1194 | rsclient->host, rsclient->as); |
1195 | return 0; | |
1196 | } | |
1197 | #endif /* BGP_SEND_ASPATH_CHECK */ | |
1198 | ||
1199 | /* For modify attribute, copy it to temporary structure. */ | |
9eda90ce | 1200 | bgp_attr_dup (attr, ri->attr); |
fee0f4c6 | 1201 | |
1202 | /* next-hop-set */ | |
1203 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) | |
1204 | #ifdef HAVE_IPV6 | |
1205 | || (p->family == AF_INET6 && | |
fb982c25 | 1206 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
fee0f4c6 | 1207 | #endif /* HAVE_IPV6 */ |
1208 | ) | |
1209 | { | |
1210 | /* Set IPv4 nexthop. */ | |
1211 | if (p->family == AF_INET) | |
1212 | { | |
1213 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1214 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
fee0f4c6 | 1215 | IPV4_MAX_BYTELEN); |
1216 | else | |
1217 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); | |
1218 | } | |
1219 | #ifdef HAVE_IPV6 | |
1220 | /* Set IPv6 nexthop. */ | |
1221 | if (p->family == AF_INET6) | |
1222 | { | |
1223 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 1224 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
fee0f4c6 | 1225 | IPV6_MAX_BYTELEN); |
fb982c25 | 1226 | attr->extra->mp_nexthop_len = 16; |
fee0f4c6 | 1227 | } |
1228 | #endif /* HAVE_IPV6 */ | |
1229 | } | |
1230 | ||
1231 | #ifdef HAVE_IPV6 | |
1232 | if (p->family == AF_INET6) | |
1233 | { | |
fb982c25 PJ |
1234 | struct attr_extra *attre = attr->extra; |
1235 | ||
1236 | assert (attr->extra); | |
1237 | ||
fee0f4c6 | 1238 | /* Left nexthop_local unchanged if so configured. */ |
1239 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], | |
1240 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) | |
1241 | { | |
fb982c25 PJ |
1242 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
1243 | attre->mp_nexthop_len=32; | |
fee0f4c6 | 1244 | else |
fb982c25 | 1245 | attre->mp_nexthop_len=16; |
fee0f4c6 | 1246 | } |
1247 | ||
1248 | /* Default nexthop_local treatment for RS-Clients */ | |
1249 | else | |
1250 | { | |
1251 | /* Announcer and RS-Client are both in the same network */ | |
1252 | if (rsclient->shared_network && from->shared_network && | |
1253 | (rsclient->ifindex == from->ifindex)) | |
1254 | { | |
fb982c25 PJ |
1255 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
1256 | attre->mp_nexthop_len=32; | |
fee0f4c6 | 1257 | else |
fb982c25 | 1258 | attre->mp_nexthop_len=16; |
fee0f4c6 | 1259 | } |
1260 | ||
1261 | /* Set link-local address for shared network peer. */ | |
1262 | else if (rsclient->shared_network | |
1263 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) | |
1264 | { | |
fb982c25 | 1265 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
fee0f4c6 | 1266 | IPV6_MAX_BYTELEN); |
fb982c25 | 1267 | attre->mp_nexthop_len = 32; |
fee0f4c6 | 1268 | } |
1269 | ||
1270 | else | |
fb982c25 | 1271 | attre->mp_nexthop_len = 16; |
fee0f4c6 | 1272 | } |
1273 | ||
1274 | } | |
1275 | #endif /* HAVE_IPV6 */ | |
1276 | ||
1277 | ||
1278 | /* If this is EBGP peer and remove-private-AS is set. */ | |
1279 | if (peer_sort (rsclient) == BGP_PEER_EBGP | |
1280 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) | |
1281 | && aspath_private_as_check (attr->aspath)) | |
1282 | attr->aspath = aspath_empty_get (); | |
1283 | ||
1284 | /* Route map & unsuppress-map apply. */ | |
fb982c25 | 1285 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
fee0f4c6 | 1286 | { |
1287 | info.peer = rsclient; | |
1288 | info.attr = attr; | |
1289 | ||
1290 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); | |
1291 | ||
fb982c25 | 1292 | if (ri->extra && ri->extra->suppress) |
fee0f4c6 | 1293 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
1294 | else | |
1295 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); | |
1296 | ||
1297 | rsclient->rmap_type = 0; | |
1298 | ||
1299 | if (ret == RMAP_DENYMATCH) | |
1300 | { | |
1301 | bgp_attr_flush (attr); | |
1302 | return 0; | |
1303 | } | |
1304 | } | |
1305 | ||
1306 | return 1; | |
1307 | } | |
1308 | ||
1309 | struct bgp_info_pair | |
1310 | { | |
1311 | struct bgp_info *old; | |
1312 | struct bgp_info *new; | |
1313 | }; | |
1314 | ||
94f2b392 | 1315 | static void |
fee0f4c6 | 1316 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result) |
718e3744 | 1317 | { |
718e3744 | 1318 | struct bgp_info *new_select; |
1319 | struct bgp_info *old_select; | |
fee0f4c6 | 1320 | struct bgp_info *ri; |
718e3744 | 1321 | struct bgp_info *ri1; |
1322 | struct bgp_info *ri2; | |
b40d939b | 1323 | struct bgp_info *nextri = NULL; |
1324 | ||
718e3744 | 1325 | /* bgp deterministic-med */ |
1326 | new_select = NULL; | |
1327 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1328 | for (ri1 = rn->info; ri1; ri1 = ri1->next) | |
1329 | { | |
1330 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) | |
1331 | continue; | |
1332 | if (BGP_INFO_HOLDDOWN (ri1)) | |
1333 | continue; | |
1334 | ||
1335 | new_select = ri1; | |
1336 | if (ri1->next) | |
1337 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) | |
1338 | { | |
1339 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) | |
1340 | continue; | |
1341 | if (BGP_INFO_HOLDDOWN (ri2)) | |
1342 | continue; | |
1343 | ||
1344 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) | |
1345 | || aspath_cmp_left_confed (ri1->attr->aspath, | |
1346 | ri2->attr->aspath)) | |
1347 | { | |
1348 | if (bgp_info_cmp (bgp, ri2, new_select)) | |
1349 | { | |
1a392d46 | 1350 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
718e3744 | 1351 | new_select = ri2; |
1352 | } | |
1353 | ||
1a392d46 | 1354 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
718e3744 | 1355 | } |
1356 | } | |
1a392d46 PJ |
1357 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
1358 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1359 | } |
1360 | ||
1361 | /* Check old selected route and new selected route. */ | |
1362 | old_select = NULL; | |
1363 | new_select = NULL; | |
b40d939b | 1364 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
718e3744 | 1365 | { |
1366 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
1367 | old_select = ri; | |
1368 | ||
1369 | if (BGP_INFO_HOLDDOWN (ri)) | |
b40d939b | 1370 | { |
1371 | /* reap REMOVED routes, if needs be | |
1372 | * selected route must stay for a while longer though | |
1373 | */ | |
1374 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) | |
1375 | && (ri != old_select)) | |
1376 | bgp_info_reap (rn, ri); | |
1377 | ||
1378 | continue; | |
1379 | } | |
718e3744 | 1380 | |
1381 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) | |
1382 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) | |
1383 | { | |
1a392d46 | 1384 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
718e3744 | 1385 | continue; |
1386 | } | |
1a392d46 PJ |
1387 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
1388 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); | |
718e3744 | 1389 | |
1390 | if (bgp_info_cmp (bgp, ri, new_select)) | |
1391 | new_select = ri; | |
1392 | } | |
b40d939b | 1393 | |
fee0f4c6 | 1394 | result->old = old_select; |
1395 | result->new = new_select; | |
1396 | ||
1397 | return; | |
1398 | } | |
1399 | ||
94f2b392 | 1400 | static int |
fee0f4c6 | 1401 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
9eda90ce PJ |
1402 | struct bgp_node *rn, afi_t afi, safi_t safi) |
1403 | { | |
fee0f4c6 | 1404 | struct prefix *p; |
9eda90ce | 1405 | struct attr attr = { 0 }; |
fee0f4c6 | 1406 | |
1407 | p = &rn->p; | |
1408 | ||
9eda90ce PJ |
1409 | /* Announce route to Established peer. */ |
1410 | if (peer->status != Established) | |
fee0f4c6 | 1411 | return 0; |
718e3744 | 1412 | |
9eda90ce PJ |
1413 | /* Address family configuration check. */ |
1414 | if (! peer->afc_nego[afi][safi]) | |
fee0f4c6 | 1415 | return 0; |
718e3744 | 1416 | |
9eda90ce | 1417 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
fee0f4c6 | 1418 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
1419 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
1420 | return 0; | |
718e3744 | 1421 | |
fee0f4c6 | 1422 | switch (rn->table->type) |
1423 | { | |
1424 | case BGP_TABLE_MAIN: | |
718e3744 | 1425 | /* Announcement to peer->conf. If the route is filtered, |
1426 | withdraw it. */ | |
9eda90ce PJ |
1427 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
1428 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); | |
fee0f4c6 | 1429 | else |
1430 | bgp_adj_out_unset (rn, peer, p, afi, safi); | |
1431 | break; | |
1432 | case BGP_TABLE_RSCLIENT: | |
1433 | /* Announcement to peer->conf. If the route is filtered, | |
1434 | withdraw it. */ | |
9eda90ce PJ |
1435 | if (selected && |
1436 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) | |
1437 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); | |
1438 | else | |
1439 | bgp_adj_out_unset (rn, peer, p, afi, safi); | |
fee0f4c6 | 1440 | break; |
1441 | } | |
9eda90ce PJ |
1442 | |
1443 | bgp_attr_extra_free (&attr); | |
1444 | ||
fee0f4c6 | 1445 | return 0; |
200df115 | 1446 | } |
fee0f4c6 | 1447 | |
200df115 | 1448 | struct bgp_process_queue |
fee0f4c6 | 1449 | { |
200df115 | 1450 | struct bgp *bgp; |
1451 | struct bgp_node *rn; | |
1452 | afi_t afi; | |
1453 | safi_t safi; | |
1454 | }; | |
1455 | ||
1456 | static wq_item_status | |
0fb58d5d | 1457 | bgp_process_rsclient (struct work_queue *wq, void *data) |
200df115 | 1458 | { |
0fb58d5d | 1459 | struct bgp_process_queue *pq = data; |
200df115 | 1460 | struct bgp *bgp = pq->bgp; |
1461 | struct bgp_node *rn = pq->rn; | |
1462 | afi_t afi = pq->afi; | |
1463 | safi_t safi = pq->safi; | |
fee0f4c6 | 1464 | struct bgp_info *new_select; |
1465 | struct bgp_info *old_select; | |
1466 | struct bgp_info_pair old_and_new; | |
1eb8ef25 | 1467 | struct listnode *node, *nnode; |
200df115 | 1468 | struct peer *rsclient = rn->table->owner; |
1469 | ||
fee0f4c6 | 1470 | /* Best path selection. */ |
1471 | bgp_best_selection (bgp, rn, &old_and_new); | |
1472 | new_select = old_and_new.new; | |
1473 | old_select = old_and_new.old; | |
1474 | ||
200df115 | 1475 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
1476 | { | |
228da428 CC |
1477 | if (rsclient->group) |
1478 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) | |
1479 | { | |
1480 | /* Nothing to do. */ | |
1481 | if (old_select && old_select == new_select) | |
1482 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) | |
1483 | continue; | |
1484 | ||
1485 | if (old_select) | |
1486 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); | |
1487 | if (new_select) | |
1488 | { | |
1489 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); | |
1490 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
1491 | } | |
1492 | ||
1493 | bgp_process_announce_selected (rsclient, new_select, rn, | |
1494 | afi, safi); | |
1495 | } | |
200df115 | 1496 | } |
1497 | else | |
1498 | { | |
b7395791 | 1499 | if (old_select) |
1a392d46 | 1500 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
b7395791 | 1501 | if (new_select) |
1502 | { | |
1a392d46 PJ |
1503 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1504 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
b7395791 | 1505 | } |
9eda90ce | 1506 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
200df115 | 1507 | } |
1508 | ||
b40d939b | 1509 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
1510 | bgp_info_reap (rn, old_select); | |
1511 | ||
200df115 | 1512 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1513 | return WQ_SUCCESS; | |
fee0f4c6 | 1514 | } |
1515 | ||
200df115 | 1516 | static wq_item_status |
0fb58d5d | 1517 | bgp_process_main (struct work_queue *wq, void *data) |
200df115 | 1518 | { |
0fb58d5d | 1519 | struct bgp_process_queue *pq = data; |
200df115 | 1520 | struct bgp *bgp = pq->bgp; |
1521 | struct bgp_node *rn = pq->rn; | |
1522 | afi_t afi = pq->afi; | |
1523 | safi_t safi = pq->safi; | |
1524 | struct prefix *p = &rn->p; | |
fee0f4c6 | 1525 | struct bgp_info *new_select; |
1526 | struct bgp_info *old_select; | |
1527 | struct bgp_info_pair old_and_new; | |
1eb8ef25 | 1528 | struct listnode *node, *nnode; |
fee0f4c6 | 1529 | struct peer *peer; |
fb982c25 | 1530 | |
fee0f4c6 | 1531 | /* Best path selection. */ |
1532 | bgp_best_selection (bgp, rn, &old_and_new); | |
1533 | old_select = old_and_new.old; | |
1534 | new_select = old_and_new.new; | |
1535 | ||
1536 | /* Nothing to do. */ | |
1537 | if (old_select && old_select == new_select) | |
1538 | { | |
1539 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) | |
200df115 | 1540 | { |
1541 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) | |
1542 | bgp_zebra_announce (p, old_select, bgp); | |
1543 | ||
1544 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); | |
1545 | return WQ_SUCCESS; | |
1546 | } | |
fee0f4c6 | 1547 | } |
1548 | ||
338b3424 | 1549 | if (old_select) |
1a392d46 | 1550 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
338b3424 | 1551 | if (new_select) |
1552 | { | |
1a392d46 PJ |
1553 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
1554 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); | |
338b3424 | 1555 | } |
1556 | ||
1557 | ||
fee0f4c6 | 1558 | /* Check each BGP peer. */ |
1eb8ef25 | 1559 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
fee0f4c6 | 1560 | { |
9eda90ce | 1561 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
718e3744 | 1562 | } |
1563 | ||
1564 | /* FIB update. */ | |
1565 | if (safi == SAFI_UNICAST && ! bgp->name && | |
1566 | ! bgp_option_check (BGP_OPT_NO_FIB)) | |
1567 | { | |
1568 | if (new_select | |
1569 | && new_select->type == ZEBRA_ROUTE_BGP | |
1570 | && new_select->sub_type == BGP_ROUTE_NORMAL) | |
1571 | bgp_zebra_announce (p, new_select, bgp); | |
1572 | else | |
1573 | { | |
1574 | /* Withdraw the route from the kernel. */ | |
1575 | if (old_select | |
1576 | && old_select->type == ZEBRA_ROUTE_BGP | |
1577 | && old_select->sub_type == BGP_ROUTE_NORMAL) | |
1578 | bgp_zebra_withdraw (p, old_select); | |
1579 | } | |
1580 | } | |
b40d939b | 1581 | |
1582 | /* Reap old select bgp_info, it it has been removed */ | |
1583 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) | |
1584 | bgp_info_reap (rn, old_select); | |
1585 | ||
200df115 | 1586 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
1587 | return WQ_SUCCESS; | |
718e3744 | 1588 | } |
1589 | ||
200df115 | 1590 | static void |
0fb58d5d | 1591 | bgp_processq_del (struct work_queue *wq, void *data) |
200df115 | 1592 | { |
0fb58d5d | 1593 | struct bgp_process_queue *pq = data; |
228da428 | 1594 | struct bgp_table *table = pq->rn->table; |
0fb58d5d | 1595 | |
228da428 | 1596 | bgp_unlock (pq->bgp); |
200df115 | 1597 | bgp_unlock_node (pq->rn); |
228da428 | 1598 | bgp_table_unlock (table); |
200df115 | 1599 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
1600 | } | |
1601 | ||
1602 | static void | |
1603 | bgp_process_queue_init (void) | |
1604 | { | |
1605 | bm->process_main_queue | |
1606 | = work_queue_new (bm->master, "process_main_queue"); | |
1607 | bm->process_rsclient_queue | |
1608 | = work_queue_new (bm->master, "process_rsclient_queue"); | |
1609 | ||
1610 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) | |
1611 | { | |
1612 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
1613 | exit (1); | |
1614 | } | |
1615 | ||
1616 | bm->process_main_queue->spec.workfunc = &bgp_process_main; | |
200df115 | 1617 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
838bbde0 PJ |
1618 | bm->process_main_queue->spec.max_retries = 0; |
1619 | bm->process_main_queue->spec.hold = 50; | |
1620 | ||
1621 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, | |
1622 | sizeof (struct work_queue *)); | |
1623 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; | |
200df115 | 1624 | } |
1625 | ||
1626 | void | |
fee0f4c6 | 1627 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
1628 | { | |
200df115 | 1629 | struct bgp_process_queue *pqnode; |
1630 | ||
1631 | /* already scheduled for processing? */ | |
1632 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) | |
1633 | return; | |
1634 | ||
1635 | if ( (bm->process_main_queue == NULL) || | |
1636 | (bm->process_rsclient_queue == NULL) ) | |
1637 | bgp_process_queue_init (); | |
1638 | ||
1639 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, | |
1640 | sizeof (struct bgp_process_queue)); | |
1641 | if (!pqnode) | |
1642 | return; | |
228da428 CC |
1643 | |
1644 | /* all unlocked in bgp_processq_del */ | |
1645 | bgp_table_lock (rn->table); | |
1646 | pqnode->rn = bgp_lock_node (rn); | |
200df115 | 1647 | pqnode->bgp = bgp; |
228da428 | 1648 | bgp_lock (bgp); |
200df115 | 1649 | pqnode->afi = afi; |
1650 | pqnode->safi = safi; | |
1651 | ||
fee0f4c6 | 1652 | switch (rn->table->type) |
1653 | { | |
200df115 | 1654 | case BGP_TABLE_MAIN: |
1655 | work_queue_add (bm->process_main_queue, pqnode); | |
1656 | break; | |
1657 | case BGP_TABLE_RSCLIENT: | |
1658 | work_queue_add (bm->process_rsclient_queue, pqnode); | |
1659 | break; | |
fee0f4c6 | 1660 | } |
200df115 | 1661 | |
1662 | return; | |
fee0f4c6 | 1663 | } |
0a486e5f | 1664 | |
94f2b392 | 1665 | static int |
0a486e5f | 1666 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
1667 | { | |
1668 | struct peer *peer; | |
1669 | ||
1670 | peer = THREAD_ARG (thread); | |
1671 | peer->t_pmax_restart = NULL; | |
1672 | ||
1673 | if (BGP_DEBUG (events, EVENTS)) | |
1674 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", | |
1675 | peer->host); | |
1676 | ||
1677 | peer_clear (peer); | |
1678 | ||
1679 | return 0; | |
1680 | } | |
1681 | ||
718e3744 | 1682 | int |
5228ad27 | 1683 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
1684 | safi_t safi, int always) | |
718e3744 | 1685 | { |
e0701b79 | 1686 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
1687 | return 0; | |
1688 | ||
1689 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) | |
718e3744 | 1690 | { |
e0701b79 | 1691 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
1692 | && ! always) | |
1693 | return 0; | |
1694 | ||
1695 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1696 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
1697 | "limit %ld", afi_safi_print (afi, safi), peer->host, | |
1698 | peer->pcount[afi][safi], peer->pmax[afi][safi]); | |
e0701b79 | 1699 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
1700 | ||
1701 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
1702 | return 0; | |
1703 | ||
1704 | { | |
5228ad27 | 1705 | u_int8_t ndata[7]; |
e0701b79 | 1706 | |
1707 | if (safi == SAFI_MPLS_VPN) | |
1708 | safi = BGP_SAFI_VPNV4; | |
5228ad27 | 1709 | |
1710 | ndata[0] = (afi >> 8); | |
1711 | ndata[1] = afi; | |
1712 | ndata[2] = safi; | |
1713 | ndata[3] = (peer->pmax[afi][safi] >> 24); | |
1714 | ndata[4] = (peer->pmax[afi][safi] >> 16); | |
1715 | ndata[5] = (peer->pmax[afi][safi] >> 8); | |
1716 | ndata[6] = (peer->pmax[afi][safi]); | |
e0701b79 | 1717 | |
1718 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); | |
1719 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, | |
1720 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); | |
1721 | } | |
0a486e5f | 1722 | |
1723 | /* restart timer start */ | |
1724 | if (peer->pmax_restart[afi][safi]) | |
1725 | { | |
1726 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; | |
1727 | ||
1728 | if (BGP_DEBUG (events, EVENTS)) | |
1729 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", | |
1730 | peer->host, peer->v_pmax_restart); | |
1731 | ||
1732 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, | |
1733 | peer->v_pmax_restart); | |
1734 | } | |
1735 | ||
e0701b79 | 1736 | return 1; |
1737 | } | |
1738 | else | |
1739 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); | |
1740 | ||
1741 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) | |
1742 | { | |
1743 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) | |
1744 | && ! always) | |
1745 | return 0; | |
1746 | ||
1747 | zlog (peer->log, LOG_INFO, | |
0a486e5f | 1748 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
1749 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], | |
1750 | peer->pmax[afi][safi]); | |
e0701b79 | 1751 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
718e3744 | 1752 | } |
e0701b79 | 1753 | else |
1754 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); | |
718e3744 | 1755 | return 0; |
1756 | } | |
1757 | ||
b40d939b | 1758 | /* Unconditionally remove the route from the RIB, without taking |
1759 | * damping into consideration (eg, because the session went down) | |
1760 | */ | |
94f2b392 | 1761 | static void |
718e3744 | 1762 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
1763 | afi_t afi, safi_t safi) | |
1764 | { | |
902212c3 | 1765 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1766 | ||
1767 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
1768 | bgp_info_delete (rn, ri); /* keep historical info */ | |
1769 | ||
b40d939b | 1770 | bgp_process (peer->bgp, rn, afi, safi); |
718e3744 | 1771 | } |
1772 | ||
94f2b392 | 1773 | static void |
718e3744 | 1774 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
b40d939b | 1775 | afi_t afi, safi_t safi) |
718e3744 | 1776 | { |
718e3744 | 1777 | int status = BGP_DAMP_NONE; |
1778 | ||
b40d939b | 1779 | /* apply dampening, if result is suppressed, we'll be retaining |
1780 | * the bgp_info in the RIB for historical reference. | |
1781 | */ | |
1782 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
1783 | && peer_sort (peer) == BGP_PEER_EBGP) | |
1784 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) | |
1785 | == BGP_DAMP_SUPPRESSED) | |
902212c3 | 1786 | { |
902212c3 | 1787 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
1788 | return; | |
1789 | } | |
1790 | ||
1791 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
718e3744 | 1792 | } |
1793 | ||
94f2b392 | 1794 | static void |
fee0f4c6 | 1795 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
1796 | struct attr *attr, struct peer *peer, struct prefix *p, int type, | |
1797 | int sub_type, struct prefix_rd *prd, u_char *tag) | |
1798 | { | |
1799 | struct bgp_node *rn; | |
1800 | struct bgp *bgp; | |
fb982c25 | 1801 | struct attr new_attr = { 0 }; |
fee0f4c6 | 1802 | struct attr *attr_new; |
1803 | struct attr *attr_new2; | |
1804 | struct bgp_info *ri; | |
1805 | struct bgp_info *new; | |
fd79ac91 | 1806 | const char *reason; |
fee0f4c6 | 1807 | char buf[SU_ADDRSTRLEN]; |
1808 | ||
1809 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ | |
1810 | if (peer == rsclient) | |
1811 | return; | |
1812 | ||
1813 | bgp = peer->bgp; | |
1814 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
1815 | ||
1816 | /* Check previously received route. */ | |
1817 | for (ri = rn->info; ri; ri = ri->next) | |
1818 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
1819 | break; | |
1820 | ||
1821 | /* AS path loop check. */ | |
1822 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) | |
1823 | { | |
1824 | reason = "as-path contains our own AS;"; | |
1825 | goto filtered; | |
1826 | } | |
1827 | ||
1828 | /* Route reflector originator ID check. */ | |
1829 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 1830 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
fee0f4c6 | 1831 | { |
1832 | reason = "originator is us;"; | |
1833 | goto filtered; | |
1834 | } | |
fb982c25 PJ |
1835 | |
1836 | bgp_attr_dup (&new_attr, attr); | |
fee0f4c6 | 1837 | |
1838 | /* Apply export policy. */ | |
1839 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && | |
1840 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1841 | { | |
1842 | reason = "export-policy;"; | |
1843 | goto filtered; | |
1844 | } | |
1845 | ||
1846 | attr_new2 = bgp_attr_intern (&new_attr); | |
fb982c25 | 1847 | |
fee0f4c6 | 1848 | /* Apply import policy. */ |
1849 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
1850 | { | |
1851 | bgp_attr_unintern (attr_new2); | |
1852 | ||
1853 | reason = "import-policy;"; | |
1854 | goto filtered; | |
1855 | } | |
1856 | ||
1857 | attr_new = bgp_attr_intern (&new_attr); | |
1858 | bgp_attr_unintern (attr_new2); | |
1859 | ||
1860 | /* IPv4 unicast next hop check. */ | |
1861 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
1862 | { | |
1863 | /* Next hop must not be 0.0.0.0 nor Class E address. */ | |
1864 | if (new_attr.nexthop.s_addr == 0 | |
1865 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) | |
1866 | { | |
1867 | bgp_attr_unintern (attr_new); | |
1868 | ||
1869 | reason = "martian next-hop;"; | |
1870 | goto filtered; | |
1871 | } | |
1872 | } | |
fb982c25 PJ |
1873 | |
1874 | /* new_attr isn't passed to any functions after here */ | |
1875 | bgp_attr_extra_free (&new_attr); | |
1876 | ||
fee0f4c6 | 1877 | /* If the update is implicit withdraw. */ |
1878 | if (ri) | |
1879 | { | |
65957886 | 1880 | ri->uptime = bgp_clock (); |
fee0f4c6 | 1881 | |
1882 | /* Same attribute comes in. */ | |
16d2e241 PJ |
1883 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
1884 | && attrhash_cmp (ri->attr, attr_new)) | |
fee0f4c6 | 1885 | { |
1886 | ||
1a392d46 | 1887 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1888 | |
1889 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1890 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1891 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
1892 | peer->host, | |
1893 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1894 | p->prefixlen, rsclient->host); | |
1895 | ||
228da428 CC |
1896 | bgp_unlock_node (rn); |
1897 | bgp_attr_unintern (attr_new); | |
fee0f4c6 | 1898 | |
228da428 | 1899 | return; |
fee0f4c6 | 1900 | } |
1901 | ||
16d2e241 PJ |
1902 | /* Withdraw/Announce before we fully processed the withdraw */ |
1903 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
1904 | bgp_info_restore (rn, ri); | |
1905 | ||
fee0f4c6 | 1906 | /* Received Logging. */ |
1907 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1908 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1909 | peer->host, |
1910 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1911 | p->prefixlen, rsclient->host); | |
1912 | ||
1913 | /* The attribute is changed. */ | |
1a392d46 | 1914 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 1915 | |
1916 | /* Update to new attribute. */ | |
1917 | bgp_attr_unintern (ri->attr); | |
1918 | ri->attr = attr_new; | |
1919 | ||
1920 | /* Update MPLS tag. */ | |
1921 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1922 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
fee0f4c6 | 1923 | |
1a392d46 | 1924 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
fee0f4c6 | 1925 | |
1926 | /* Process change. */ | |
1927 | bgp_process (bgp, rn, afi, safi); | |
1928 | bgp_unlock_node (rn); | |
1929 | ||
1930 | return; | |
1931 | } | |
1932 | ||
1933 | /* Received Logging. */ | |
1934 | if (BGP_DEBUG (update, UPDATE_IN)) | |
1935 | { | |
d2c1f16b | 1936 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
fee0f4c6 | 1937 | peer->host, |
1938 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1939 | p->prefixlen, rsclient->host); | |
1940 | } | |
1941 | ||
1942 | /* Make new BGP info. */ | |
1943 | new = bgp_info_new (); | |
1944 | new->type = type; | |
1945 | new->sub_type = sub_type; | |
1946 | new->peer = peer; | |
1947 | new->attr = attr_new; | |
65957886 | 1948 | new->uptime = bgp_clock (); |
fee0f4c6 | 1949 | |
1950 | /* Update MPLS tag. */ | |
1951 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 1952 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
fee0f4c6 | 1953 | |
1a392d46 | 1954 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
fee0f4c6 | 1955 | |
1956 | /* Register new BGP information. */ | |
1957 | bgp_info_add (rn, new); | |
200df115 | 1958 | |
1959 | /* route_node_get lock */ | |
1960 | bgp_unlock_node (rn); | |
1961 | ||
fee0f4c6 | 1962 | /* Process change. */ |
1963 | bgp_process (bgp, rn, afi, safi); | |
fb982c25 PJ |
1964 | |
1965 | bgp_attr_extra_free (&new_attr); | |
1966 | ||
fee0f4c6 | 1967 | return; |
1968 | ||
1969 | filtered: | |
1970 | ||
1971 | /* This BGP update is filtered. Log the reason then update BGP entry. */ | |
1972 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 1973 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 1974 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
1975 | peer->host, | |
1976 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
1977 | p->prefixlen, rsclient->host, reason); | |
1978 | ||
1979 | if (ri) | |
b40d939b | 1980 | bgp_rib_remove (rn, ri, peer, afi, safi); |
fee0f4c6 | 1981 | |
1982 | bgp_unlock_node (rn); | |
fb982c25 PJ |
1983 | |
1984 | if (new_attr.extra) | |
1985 | bgp_attr_extra_free (&new_attr); | |
1986 | ||
fee0f4c6 | 1987 | return; |
1988 | } | |
1989 | ||
94f2b392 | 1990 | static void |
fee0f4c6 | 1991 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
1992 | struct peer *peer, struct prefix *p, int type, int sub_type, | |
1993 | struct prefix_rd *prd, u_char *tag) | |
228da428 | 1994 | { |
fee0f4c6 | 1995 | struct bgp_node *rn; |
1996 | struct bgp_info *ri; | |
1997 | char buf[SU_ADDRSTRLEN]; | |
1998 | ||
1999 | if (rsclient == peer) | |
228da428 | 2000 | return; |
fee0f4c6 | 2001 | |
2002 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); | |
2003 | ||
2004 | /* Lookup withdrawn route. */ | |
2005 | for (ri = rn->info; ri; ri = ri->next) | |
2006 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2007 | break; | |
2008 | ||
2009 | /* Withdraw specified route from routing table. */ | |
2010 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2011 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
fee0f4c6 | 2012 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 2013 | zlog (peer->log, LOG_DEBUG, |
fee0f4c6 | 2014 | "%s Can't find the route %s/%d", peer->host, |
2015 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2016 | p->prefixlen); | |
2017 | ||
2018 | /* Unlock bgp_node_get() lock. */ | |
228da428 CC |
2019 | bgp_unlock_node (rn); |
2020 | } | |
fee0f4c6 | 2021 | |
94f2b392 | 2022 | static int |
fee0f4c6 | 2023 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
718e3744 | 2024 | afi_t afi, safi_t safi, int type, int sub_type, |
2025 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
2026 | { | |
2027 | int ret; | |
2028 | int aspath_loop_count = 0; | |
2029 | struct bgp_node *rn; | |
2030 | struct bgp *bgp; | |
fb982c25 | 2031 | struct attr new_attr = { 0 }; |
718e3744 | 2032 | struct attr *attr_new; |
2033 | struct bgp_info *ri; | |
2034 | struct bgp_info *new; | |
fd79ac91 | 2035 | const char *reason; |
718e3744 | 2036 | char buf[SU_ADDRSTRLEN]; |
2037 | ||
2038 | bgp = peer->bgp; | |
fee0f4c6 | 2039 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
fb982c25 | 2040 | |
718e3744 | 2041 | /* When peer's soft reconfiguration enabled. Record input packet in |
2042 | Adj-RIBs-In. */ | |
2043 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2044 | && peer != bgp->peer_self && ! soft_reconfig) | |
2045 | bgp_adj_in_set (rn, peer, attr); | |
2046 | ||
2047 | /* Check previously received route. */ | |
2048 | for (ri = rn->info; ri; ri = ri->next) | |
2049 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2050 | break; | |
2051 | ||
2052 | /* AS path local-as loop check. */ | |
2053 | if (peer->change_local_as) | |
2054 | { | |
2055 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
2056 | aspath_loop_count = 1; | |
2057 | ||
2058 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) | |
2059 | { | |
2060 | reason = "as-path contains our own AS;"; | |
2061 | goto filtered; | |
2062 | } | |
2063 | } | |
2064 | ||
2065 | /* AS path loop check. */ | |
2066 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] | |
2067 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
2068 | && aspath_loop_check(attr->aspath, bgp->confed_id) | |
2069 | > peer->allowas_in[afi][safi])) | |
2070 | { | |
2071 | reason = "as-path contains our own AS;"; | |
2072 | goto filtered; | |
2073 | } | |
2074 | ||
2075 | /* Route reflector originator ID check. */ | |
2076 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) | |
fb982c25 | 2077 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
718e3744 | 2078 | { |
2079 | reason = "originator is us;"; | |
2080 | goto filtered; | |
2081 | } | |
2082 | ||
2083 | /* Route reflector cluster ID check. */ | |
2084 | if (bgp_cluster_filter (peer, attr)) | |
2085 | { | |
2086 | reason = "reflected from the same cluster;"; | |
2087 | goto filtered; | |
2088 | } | |
2089 | ||
2090 | /* Apply incoming filter. */ | |
2091 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) | |
2092 | { | |
2093 | reason = "filter;"; | |
2094 | goto filtered; | |
2095 | } | |
2096 | ||
2097 | /* Apply incoming route-map. */ | |
fb982c25 | 2098 | bgp_attr_dup (&new_attr, attr); |
718e3744 | 2099 | |
2100 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) | |
2101 | { | |
2102 | reason = "route-map;"; | |
2103 | goto filtered; | |
2104 | } | |
2105 | ||
2106 | /* IPv4 unicast next hop check. */ | |
2107 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
2108 | { | |
2109 | /* If the peer is EBGP and nexthop is not on connected route, | |
2110 | discard it. */ | |
2111 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 | |
2112 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) | |
6ffd2079 | 2113 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
718e3744 | 2114 | { |
2115 | reason = "non-connected next-hop;"; | |
2116 | goto filtered; | |
2117 | } | |
2118 | ||
2119 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop | |
2120 | must not be my own address. */ | |
2121 | if (bgp_nexthop_self (afi, &new_attr) | |
2122 | || new_attr.nexthop.s_addr == 0 | |
2123 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) | |
2124 | { | |
2125 | reason = "martian next-hop;"; | |
2126 | goto filtered; | |
2127 | } | |
2128 | } | |
2129 | ||
2130 | attr_new = bgp_attr_intern (&new_attr); | |
2131 | ||
2132 | /* If the update is implicit withdraw. */ | |
2133 | if (ri) | |
2134 | { | |
65957886 | 2135 | ri->uptime = bgp_clock (); |
718e3744 | 2136 | |
2137 | /* Same attribute comes in. */ | |
16d2e241 PJ |
2138 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
2139 | && attrhash_cmp (ri->attr, attr_new)) | |
718e3744 | 2140 | { |
1a392d46 | 2141 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 2142 | |
2143 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2144 | && peer_sort (peer) == BGP_PEER_EBGP | |
2145 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2146 | { | |
2147 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2148 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2149 | peer->host, |
2150 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2151 | p->prefixlen); | |
2152 | ||
902212c3 | 2153 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
2154 | { | |
2155 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2156 | bgp_process (bgp, rn, afi, safi); | |
2157 | } | |
718e3744 | 2158 | } |
16d2e241 | 2159 | else /* Duplicate - odd */ |
718e3744 | 2160 | { |
2161 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2162 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2163 | "%s rcvd %s/%d...duplicate ignored", |
2164 | peer->host, | |
2165 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2166 | p->prefixlen); | |
93406d87 | 2167 | |
2168 | /* graceful restart STALE flag unset. */ | |
2169 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2170 | { | |
1a392d46 | 2171 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
902212c3 | 2172 | bgp_process (bgp, rn, afi, safi); |
93406d87 | 2173 | } |
718e3744 | 2174 | } |
2175 | ||
2176 | bgp_unlock_node (rn); | |
2177 | bgp_attr_unintern (attr_new); | |
fb982c25 PJ |
2178 | bgp_attr_extra_free (&new_attr); |
2179 | ||
718e3744 | 2180 | return 0; |
2181 | } | |
2182 | ||
16d2e241 PJ |
2183 | /* Withdraw/Announce before we fully processed the withdraw */ |
2184 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
2185 | { | |
2186 | if (BGP_DEBUG (update, UPDATE_IN)) | |
2187 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", | |
2188 | peer->host, | |
2189 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2190 | p->prefixlen); | |
2191 | bgp_info_restore (rn, ri); | |
2192 | } | |
2193 | ||
718e3744 | 2194 | /* Received Logging. */ |
2195 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2196 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2197 | peer->host, |
2198 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2199 | p->prefixlen); | |
2200 | ||
93406d87 | 2201 | /* graceful restart STALE flag unset. */ |
2202 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
1a392d46 | 2203 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
93406d87 | 2204 | |
718e3744 | 2205 | /* The attribute is changed. */ |
1a392d46 | 2206 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
902212c3 | 2207 | |
2208 | /* implicit withdraw, decrement aggregate and pcount here. | |
2209 | * only if update is accepted, they'll increment below. | |
2210 | */ | |
902212c3 | 2211 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
2212 | ||
718e3744 | 2213 | /* Update bgp route dampening information. */ |
2214 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2215 | && peer_sort (peer) == BGP_PEER_EBGP) | |
2216 | { | |
2217 | /* This is implicit withdraw so we should update dampening | |
2218 | information. */ | |
2219 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
2220 | bgp_damp_withdraw (ri, rn, afi, safi, 1); | |
718e3744 | 2221 | } |
2222 | ||
718e3744 | 2223 | /* Update to new attribute. */ |
2224 | bgp_attr_unintern (ri->attr); | |
2225 | ri->attr = attr_new; | |
2226 | ||
2227 | /* Update MPLS tag. */ | |
2228 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2229 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
718e3744 | 2230 | |
2231 | /* Update bgp route dampening information. */ | |
2232 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) | |
2233 | && peer_sort (peer) == BGP_PEER_EBGP) | |
2234 | { | |
2235 | /* Now we do normal update dampening. */ | |
2236 | ret = bgp_damp_update (ri, rn, afi, safi); | |
2237 | if (ret == BGP_DAMP_SUPPRESSED) | |
2238 | { | |
2239 | bgp_unlock_node (rn); | |
fb982c25 | 2240 | bgp_attr_extra_free (&new_attr); |
718e3744 | 2241 | return 0; |
2242 | } | |
2243 | } | |
2244 | ||
2245 | /* Nexthop reachability check. */ | |
2246 | if ((afi == AFI_IP || afi == AFI_IP6) | |
2247 | && safi == SAFI_UNICAST | |
2248 | && (peer_sort (peer) == BGP_PEER_IBGP | |
638b70ba | 2249 | || peer_sort (peer) == BGP_PEER_CONFED |
718e3744 | 2250 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
6ffd2079 | 2251 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
718e3744 | 2252 | { |
2253 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) | |
1a392d46 | 2254 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2255 | else |
1a392d46 | 2256 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2257 | } |
2258 | else | |
1a392d46 | 2259 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
718e3744 | 2260 | |
2261 | /* Process change. */ | |
2262 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
2263 | ||
2264 | bgp_process (bgp, rn, afi, safi); | |
2265 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2266 | bgp_attr_extra_free (&new_attr); |
2267 | ||
718e3744 | 2268 | return 0; |
2269 | } | |
2270 | ||
2271 | /* Received Logging. */ | |
2272 | if (BGP_DEBUG (update, UPDATE_IN)) | |
2273 | { | |
d2c1f16b | 2274 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
718e3744 | 2275 | peer->host, |
2276 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2277 | p->prefixlen); | |
2278 | } | |
2279 | ||
718e3744 | 2280 | /* Make new BGP info. */ |
2281 | new = bgp_info_new (); | |
2282 | new->type = type; | |
2283 | new->sub_type = sub_type; | |
2284 | new->peer = peer; | |
2285 | new->attr = attr_new; | |
65957886 | 2286 | new->uptime = bgp_clock (); |
718e3744 | 2287 | |
2288 | /* Update MPLS tag. */ | |
2289 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 | 2290 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
718e3744 | 2291 | |
2292 | /* Nexthop reachability check. */ | |
2293 | if ((afi == AFI_IP || afi == AFI_IP6) | |
2294 | && safi == SAFI_UNICAST | |
2295 | && (peer_sort (peer) == BGP_PEER_IBGP | |
638b70ba | 2296 | || peer_sort (peer) == BGP_PEER_CONFED |
718e3744 | 2297 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
6ffd2079 | 2298 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
718e3744 | 2299 | { |
2300 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) | |
1a392d46 | 2301 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2302 | else |
1a392d46 | 2303 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2304 | } |
2305 | else | |
1a392d46 | 2306 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
718e3744 | 2307 | |
902212c3 | 2308 | /* Increment prefix */ |
718e3744 | 2309 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
2310 | ||
2311 | /* Register new BGP information. */ | |
2312 | bgp_info_add (rn, new); | |
200df115 | 2313 | |
2314 | /* route_node_get lock */ | |
2315 | bgp_unlock_node (rn); | |
2316 | ||
fb982c25 PJ |
2317 | bgp_attr_extra_free (&new_attr); |
2318 | ||
718e3744 | 2319 | /* If maximum prefix count is configured and current prefix |
2320 | count exeed it. */ | |
e0701b79 | 2321 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
2322 | return -1; | |
718e3744 | 2323 | |
2324 | /* Process change. */ | |
2325 | bgp_process (bgp, rn, afi, safi); | |
2326 | ||
2327 | return 0; | |
2328 | ||
2329 | /* This BGP update is filtered. Log the reason then update BGP | |
2330 | entry. */ | |
2331 | filtered: | |
2332 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2333 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2334 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
2335 | peer->host, | |
2336 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2337 | p->prefixlen, reason); | |
2338 | ||
2339 | if (ri) | |
b40d939b | 2340 | bgp_rib_remove (rn, ri, peer, afi, safi); |
718e3744 | 2341 | |
2342 | bgp_unlock_node (rn); | |
fb982c25 PJ |
2343 | |
2344 | bgp_attr_extra_free (&new_attr); | |
2345 | ||
718e3744 | 2346 | return 0; |
2347 | } | |
2348 | ||
fee0f4c6 | 2349 | int |
2350 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, | |
2351 | afi_t afi, safi_t safi, int type, int sub_type, | |
2352 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) | |
2353 | { | |
2354 | struct peer *rsclient; | |
1eb8ef25 | 2355 | struct listnode *node, *nnode; |
fee0f4c6 | 2356 | struct bgp *bgp; |
2357 | int ret; | |
2358 | ||
2359 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, | |
2360 | soft_reconfig); | |
2361 | ||
2362 | bgp = peer->bgp; | |
2363 | ||
2364 | /* Process the update for each RS-client. */ | |
1eb8ef25 | 2365 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2366 | { |
2367 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2368 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, | |
2369 | sub_type, prd, tag); | |
2370 | } | |
2371 | ||
2372 | return ret; | |
2373 | } | |
2374 | ||
718e3744 | 2375 | int |
2376 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, | |
94f2b392 | 2377 | afi_t afi, safi_t safi, int type, int sub_type, |
2378 | struct prefix_rd *prd, u_char *tag) | |
718e3744 | 2379 | { |
2380 | struct bgp *bgp; | |
2381 | char buf[SU_ADDRSTRLEN]; | |
2382 | struct bgp_node *rn; | |
2383 | struct bgp_info *ri; | |
fee0f4c6 | 2384 | struct peer *rsclient; |
1eb8ef25 | 2385 | struct listnode *node, *nnode; |
718e3744 | 2386 | |
2387 | bgp = peer->bgp; | |
2388 | ||
fee0f4c6 | 2389 | /* Process the withdraw for each RS-client. */ |
1eb8ef25 | 2390 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 2391 | { |
2392 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2393 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); | |
2394 | } | |
2395 | ||
718e3744 | 2396 | /* Logging. */ |
2397 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 2398 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
718e3744 | 2399 | peer->host, |
2400 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2401 | p->prefixlen); | |
2402 | ||
2403 | /* Lookup node. */ | |
fee0f4c6 | 2404 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 2405 | |
2406 | /* If peer is soft reconfiguration enabled. Record input packet for | |
2407 | further calculation. */ | |
2408 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) | |
2409 | && peer != bgp->peer_self) | |
2410 | bgp_adj_in_unset (rn, peer); | |
2411 | ||
2412 | /* Lookup withdrawn route. */ | |
2413 | for (ri = rn->info; ri; ri = ri->next) | |
2414 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) | |
2415 | break; | |
2416 | ||
2417 | /* Withdraw specified route from routing table. */ | |
2418 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
b40d939b | 2419 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
718e3744 | 2420 | else if (BGP_DEBUG (update, UPDATE_IN)) |
d2c1f16b | 2421 | zlog (peer->log, LOG_DEBUG, |
718e3744 | 2422 | "%s Can't find the route %s/%d", peer->host, |
2423 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
2424 | p->prefixlen); | |
2425 | ||
2426 | /* Unlock bgp_node_get() lock. */ | |
2427 | bgp_unlock_node (rn); | |
2428 | ||
2429 | return 0; | |
2430 | } | |
2431 | \f | |
2432 | void | |
2433 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) | |
2434 | { | |
2435 | struct bgp *bgp; | |
228da428 | 2436 | struct attr attr = { 0 }; |
fb982c25 | 2437 | struct aspath *aspath = { 0 }; |
718e3744 | 2438 | struct prefix p; |
2439 | struct bgp_info binfo; | |
2440 | struct peer *from; | |
2441 | int ret = RMAP_DENYMATCH; | |
fb982c25 | 2442 | |
b2497024 | 2443 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
fb982c25 PJ |
2444 | return; |
2445 | ||
718e3744 | 2446 | bgp = peer->bgp; |
2447 | from = bgp->peer_self; | |
fb982c25 | 2448 | |
718e3744 | 2449 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
2450 | aspath = attr.aspath; | |
2451 | attr.local_pref = bgp->default_local_pref; | |
2452 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); | |
2453 | ||
2454 | if (afi == AFI_IP) | |
2455 | str2prefix ("0.0.0.0/0", &p); | |
2456 | #ifdef HAVE_IPV6 | |
2457 | else if (afi == AFI_IP6) | |
2458 | { | |
fb982c25 PJ |
2459 | struct attr_extra *ae; |
2460 | attr.extra = NULL; | |
2461 | ||
2462 | ae = bgp_attr_extra_get (&attr); | |
2463 | attr.extra = ae; | |
2464 | ||
718e3744 | 2465 | str2prefix ("::/0", &p); |
2466 | ||
2467 | /* IPv6 global nexthop must be included. */ | |
fb982c25 | 2468 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
718e3744 | 2469 | IPV6_MAX_BYTELEN); |
fb982c25 | 2470 | ae->mp_nexthop_len = 16; |
718e3744 | 2471 | |
2472 | /* If the peer is on shared nextwork and we have link-local | |
2473 | nexthop set it. */ | |
2474 | if (peer->shared_network | |
2475 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) | |
2476 | { | |
fb982c25 | 2477 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
718e3744 | 2478 | IPV6_MAX_BYTELEN); |
fb982c25 | 2479 | ae->mp_nexthop_len = 32; |
718e3744 | 2480 | } |
2481 | } | |
2482 | #endif /* HAVE_IPV6 */ | |
718e3744 | 2483 | |
2484 | if (peer->default_rmap[afi][safi].name) | |
2485 | { | |
2486 | binfo.peer = bgp->peer_self; | |
2487 | binfo.attr = &attr; | |
2488 | ||
fee0f4c6 | 2489 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
2490 | ||
718e3744 | 2491 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
2492 | RMAP_BGP, &binfo); | |
2493 | ||
fee0f4c6 | 2494 | bgp->peer_self->rmap_type = 0; |
2495 | ||
718e3744 | 2496 | if (ret == RMAP_DENYMATCH) |
2497 | { | |
2498 | bgp_attr_flush (&attr); | |
2499 | withdraw = 1; | |
2500 | } | |
2501 | } | |
2502 | ||
2503 | if (withdraw) | |
2504 | { | |
2505 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) | |
2506 | bgp_default_withdraw_send (peer, afi, safi); | |
2507 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2508 | } | |
2509 | else | |
2510 | { | |
2511 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); | |
2512 | bgp_default_update_send (peer, &attr, afi, safi, from); | |
2513 | } | |
fb982c25 PJ |
2514 | |
2515 | bgp_attr_extra_free (&attr); | |
718e3744 | 2516 | aspath_unintern (aspath); |
2517 | } | |
2518 | \f | |
2519 | static void | |
2520 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, | |
fee0f4c6 | 2521 | struct bgp_table *table, int rsclient) |
718e3744 | 2522 | { |
2523 | struct bgp_node *rn; | |
2524 | struct bgp_info *ri; | |
228da428 | 2525 | struct attr attr = { 0 }; |
fb982c25 | 2526 | |
718e3744 | 2527 | if (! table) |
fee0f4c6 | 2528 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
718e3744 | 2529 | |
2530 | if (safi != SAFI_MPLS_VPN | |
2531 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
2532 | bgp_default_originate (peer, afi, safi, 0); | |
2533 | ||
2534 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) | |
2535 | for (ri = rn->info; ri; ri = ri->next) | |
2536 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) | |
2537 | { | |
fee0f4c6 | 2538 | if ( (rsclient) ? |
2539 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) | |
2540 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) | |
718e3744 | 2541 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
2542 | else | |
2543 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); | |
fb982c25 PJ |
2544 | |
2545 | bgp_attr_extra_free (&attr); | |
718e3744 | 2546 | } |
2547 | } | |
2548 | ||
2549 | void | |
2550 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) | |
2551 | { | |
2552 | struct bgp_node *rn; | |
2553 | struct bgp_table *table; | |
2554 | ||
2555 | if (peer->status != Established) | |
2556 | return; | |
2557 | ||
2558 | if (! peer->afc_nego[afi][safi]) | |
2559 | return; | |
2560 | ||
2561 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ | |
2562 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
2563 | return; | |
2564 | ||
2565 | if (safi != SAFI_MPLS_VPN) | |
fee0f4c6 | 2566 | bgp_announce_table (peer, afi, safi, NULL, 0); |
718e3744 | 2567 | else |
2568 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2569 | rn = bgp_route_next(rn)) | |
2570 | if ((table = (rn->info)) != NULL) | |
fee0f4c6 | 2571 | bgp_announce_table (peer, afi, safi, table, 0); |
2572 | ||
2573 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
2574 | bgp_announce_table (peer, afi, safi, NULL, 1); | |
718e3744 | 2575 | } |
2576 | ||
2577 | void | |
2578 | bgp_announce_route_all (struct peer *peer) | |
2579 | { | |
2580 | afi_t afi; | |
2581 | safi_t safi; | |
2582 | ||
2583 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2584 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
2585 | bgp_announce_route (peer, afi, safi); | |
2586 | } | |
2587 | \f | |
2588 | static void | |
fee0f4c6 | 2589 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
2590 | safi_t safi, struct bgp_table *table) | |
2591 | { | |
2592 | struct bgp_node *rn; | |
2593 | struct bgp_adj_in *ain; | |
2594 | ||
2595 | if (! table) | |
2596 | table = rsclient->bgp->rib[afi][safi]; | |
2597 | ||
2598 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2599 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2600 | { | |
2601 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, | |
2602 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); | |
2603 | } | |
2604 | } | |
2605 | ||
2606 | void | |
2607 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) | |
2608 | { | |
2609 | struct bgp_table *table; | |
2610 | struct bgp_node *rn; | |
2611 | ||
2612 | if (safi != SAFI_MPLS_VPN) | |
2613 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); | |
2614 | ||
2615 | else | |
2616 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; | |
2617 | rn = bgp_route_next (rn)) | |
2618 | if ((table = rn->info) != NULL) | |
2619 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); | |
2620 | } | |
2621 | \f | |
2622 | static void | |
718e3744 | 2623 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
2624 | struct bgp_table *table) | |
2625 | { | |
2626 | int ret; | |
2627 | struct bgp_node *rn; | |
2628 | struct bgp_adj_in *ain; | |
2629 | ||
2630 | if (! table) | |
2631 | table = peer->bgp->rib[afi][safi]; | |
2632 | ||
2633 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2634 | for (ain = rn->adj_in; ain; ain = ain->next) | |
2635 | { | |
2636 | if (ain->peer == peer) | |
2637 | { | |
2638 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, | |
2639 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, | |
2640 | NULL, NULL, 1); | |
2641 | if (ret < 0) | |
2642 | { | |
2643 | bgp_unlock_node (rn); | |
2644 | return; | |
2645 | } | |
2646 | continue; | |
2647 | } | |
2648 | } | |
2649 | } | |
2650 | ||
2651 | void | |
2652 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) | |
2653 | { | |
2654 | struct bgp_node *rn; | |
2655 | struct bgp_table *table; | |
2656 | ||
2657 | if (peer->status != Established) | |
2658 | return; | |
2659 | ||
2660 | if (safi != SAFI_MPLS_VPN) | |
2661 | bgp_soft_reconfig_table (peer, afi, safi, NULL); | |
2662 | else | |
2663 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2664 | rn = bgp_route_next (rn)) | |
2665 | if ((table = rn->info) != NULL) | |
2666 | bgp_soft_reconfig_table (peer, afi, safi, table); | |
2667 | } | |
2668 | \f | |
228da428 CC |
2669 | |
2670 | struct bgp_clear_node_queue | |
2671 | { | |
2672 | struct bgp_node *rn; | |
2673 | enum bgp_clear_route_type purpose; | |
2674 | }; | |
2675 | ||
200df115 | 2676 | static wq_item_status |
0fb58d5d | 2677 | bgp_clear_route_node (struct work_queue *wq, void *data) |
200df115 | 2678 | { |
228da428 CC |
2679 | struct bgp_clear_node_queue *cnq = data; |
2680 | struct bgp_node *rn = cnq->rn; | |
64e580a7 | 2681 | struct peer *peer = wq->spec.data; |
718e3744 | 2682 | struct bgp_info *ri; |
64e580a7 PJ |
2683 | afi_t afi = rn->table->afi; |
2684 | safi_t safi = rn->table->safi; | |
200df115 | 2685 | |
64e580a7 | 2686 | assert (rn && peer); |
200df115 | 2687 | |
64e580a7 | 2688 | for (ri = rn->info; ri; ri = ri->next) |
228da428 | 2689 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
200df115 | 2690 | { |
2691 | /* graceful restart STALE flag set. */ | |
64e580a7 PJ |
2692 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
2693 | && peer->nsf[afi][safi] | |
200df115 | 2694 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
1a392d46 PJ |
2695 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2696 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); | |
200df115 | 2697 | else |
64e580a7 | 2698 | bgp_rib_remove (rn, ri, peer, afi, safi); |
200df115 | 2699 | break; |
2700 | } | |
200df115 | 2701 | return WQ_SUCCESS; |
2702 | } | |
2703 | ||
2704 | static void | |
0fb58d5d | 2705 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
200df115 | 2706 | { |
228da428 CC |
2707 | struct bgp_clear_node_queue *cnq = data; |
2708 | struct bgp_node *rn = cnq->rn; | |
2709 | struct bgp_table *table = rn->table; | |
64e580a7 PJ |
2710 | |
2711 | bgp_unlock_node (rn); | |
228da428 CC |
2712 | bgp_table_unlock (table); |
2713 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); | |
200df115 | 2714 | } |
2715 | ||
2716 | static void | |
94f2b392 | 2717 | bgp_clear_node_complete (struct work_queue *wq) |
200df115 | 2718 | { |
64e580a7 PJ |
2719 | struct peer *peer = wq->spec.data; |
2720 | ||
3e0c78ef | 2721 | /* Tickle FSM to start moving again */ |
ca058a30 | 2722 | BGP_EVENT_ADD (peer, Clearing_Completed); |
228da428 CC |
2723 | |
2724 | peer_unlock (peer); /* bgp_clear_route */ | |
200df115 | 2725 | } |
2726 | ||
2727 | static void | |
64e580a7 | 2728 | bgp_clear_node_queue_init (struct peer *peer) |
200df115 | 2729 | { |
a2943657 | 2730 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
64e580a7 | 2731 | |
a2943657 | 2732 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
64e580a7 PJ |
2733 | #undef CLEAR_QUEUE_NAME_LEN |
2734 | ||
2735 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) | |
200df115 | 2736 | { |
2737 | zlog_err ("%s: Failed to allocate work queue", __func__); | |
2738 | exit (1); | |
2739 | } | |
64e580a7 PJ |
2740 | peer->clear_node_queue->spec.hold = 10; |
2741 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; | |
2742 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; | |
2743 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; | |
2744 | peer->clear_node_queue->spec.max_retries = 0; | |
2745 | ||
2746 | /* we only 'lock' this peer reference when the queue is actually active */ | |
2747 | peer->clear_node_queue->spec.data = peer; | |
200df115 | 2748 | } |
718e3744 | 2749 | |
200df115 | 2750 | static void |
2751 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, | |
228da428 CC |
2752 | struct bgp_table *table, struct peer *rsclient, |
2753 | enum bgp_clear_route_type purpose) | |
200df115 | 2754 | { |
200df115 | 2755 | struct bgp_node *rn; |
2756 | ||
f2c31acb | 2757 | |
718e3744 | 2758 | if (! table) |
fee0f4c6 | 2759 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
64e580a7 | 2760 | |
6cf159b9 | 2761 | /* If still no table => afi/safi isn't configured at all or smth. */ |
2762 | if (! table) | |
2763 | return; | |
65ca75e0 PJ |
2764 | |
2765 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2766 | { | |
f2c31acb PJ |
2767 | struct bgp_info *ri; |
2768 | struct bgp_adj_in *ain; | |
2769 | struct bgp_adj_out *aout; | |
2770 | ||
65ca75e0 PJ |
2771 | if (rn->info == NULL) |
2772 | continue; | |
f2c31acb PJ |
2773 | |
2774 | /* XXX:TODO: This is suboptimal, every non-empty route_node is | |
2775 | * queued for every clearing peer, regardless of whether it is | |
2776 | * relevant to the peer at hand. | |
2777 | * | |
2778 | * Overview: There are 3 different indices which need to be | |
2779 | * scrubbed, potentially, when a peer is removed: | |
2780 | * | |
2781 | * 1 peer's routes visible via the RIB (ie accepted routes) | |
2782 | * 2 peer's routes visible by the (optional) peer's adj-in index | |
2783 | * 3 other routes visible by the peer's adj-out index | |
2784 | * | |
2785 | * 3 there is no hurry in scrubbing, once the struct peer is | |
2786 | * removed from bgp->peer, we could just GC such deleted peer's | |
2787 | * adj-outs at our leisure. | |
2788 | * | |
2789 | * 1 and 2 must be 'scrubbed' in some way, at least made | |
2790 | * invisible via RIB index before peer session is allowed to be | |
2791 | * brought back up. So one needs to know when such a 'search' is | |
2792 | * complete. | |
2793 | * | |
2794 | * Ideally: | |
2795 | * | |
2796 | * - there'd be a single global queue or a single RIB walker | |
2797 | * - rather than tracking which route_nodes still need to be | |
2798 | * examined on a peer basis, we'd track which peers still | |
2799 | * aren't cleared | |
2800 | * | |
2801 | * Given that our per-peer prefix-counts now should be reliable, | |
2802 | * this may actually be achievable. It doesn't seem to be a huge | |
2803 | * problem at this time, | |
2804 | */ | |
2805 | for (ri = rn->info; ri; ri = ri->next) | |
228da428 | 2806 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb | 2807 | { |
228da428 CC |
2808 | struct bgp_clear_node_queue *cnq; |
2809 | ||
2810 | /* both unlocked in bgp_clear_node_queue_del */ | |
2811 | bgp_table_lock (rn->table); | |
2812 | bgp_lock_node (rn); | |
2813 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, | |
2814 | sizeof (struct bgp_clear_node_queue)); | |
2815 | cnq->rn = rn; | |
2816 | cnq->purpose = purpose; | |
2817 | work_queue_add (peer->clear_node_queue, cnq); | |
2818 | break; | |
f2c31acb PJ |
2819 | } |
2820 | ||
2821 | for (ain = rn->adj_in; ain; ain = ain->next) | |
228da428 | 2822 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb PJ |
2823 | { |
2824 | bgp_adj_in_remove (rn, ain); | |
2825 | bgp_unlock_node (rn); | |
2826 | break; | |
2827 | } | |
2828 | for (aout = rn->adj_out; aout; aout = aout->next) | |
228da428 | 2829 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
f2c31acb PJ |
2830 | { |
2831 | bgp_adj_out_remove (rn, aout, peer, afi, safi); | |
2832 | bgp_unlock_node (rn); | |
2833 | break; | |
2834 | } | |
65ca75e0 PJ |
2835 | } |
2836 | return; | |
2837 | } | |
2838 | ||
2839 | void | |
228da428 CC |
2840 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
2841 | enum bgp_clear_route_type purpose) | |
65ca75e0 PJ |
2842 | { |
2843 | struct bgp_node *rn; | |
2844 | struct bgp_table *table; | |
2845 | struct peer *rsclient; | |
2846 | struct listnode *node, *nnode; | |
6cf159b9 | 2847 | |
64e580a7 PJ |
2848 | if (peer->clear_node_queue == NULL) |
2849 | bgp_clear_node_queue_init (peer); | |
200df115 | 2850 | |
ca058a30 PJ |
2851 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
2852 | * Idle until it receives a Clearing_Completed event. This protects | |
2853 | * against peers which flap faster than we can we clear, which could | |
2854 | * lead to: | |
64e580a7 PJ |
2855 | * |
2856 | * a) race with routes from the new session being installed before | |
2857 | * clear_route_node visits the node (to delete the route of that | |
2858 | * peer) | |
2859 | * b) resource exhaustion, clear_route_node likely leads to an entry | |
2860 | * on the process_main queue. Fast-flapping could cause that queue | |
2861 | * to grow and grow. | |
200df115 | 2862 | */ |
ca058a30 PJ |
2863 | if (!peer->clear_node_queue->thread) |
2864 | peer_lock (peer); /* bgp_clear_node_complete */ | |
fee0f4c6 | 2865 | |
228da428 | 2866 | switch (purpose) |
fee0f4c6 | 2867 | { |
228da428 CC |
2868 | case BGP_CLEAR_ROUTE_NORMAL: |
2869 | if (safi != SAFI_MPLS_VPN) | |
2870 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); | |
2871 | else | |
2872 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; | |
2873 | rn = bgp_route_next (rn)) | |
2874 | if ((table = rn->info) != NULL) | |
2875 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); | |
2876 | ||
2877 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) | |
2878 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], | |
2879 | PEER_FLAG_RSERVER_CLIENT)) | |
2880 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); | |
2881 | break; | |
2882 | ||
2883 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: | |
2884 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); | |
2885 | break; | |
2886 | ||
2887 | default: | |
2888 | assert (0); | |
2889 | break; | |
fee0f4c6 | 2890 | } |
65ca75e0 | 2891 | |
ca058a30 | 2892 | /* If no routes were cleared, nothing was added to workqueue, the |
f2c31acb PJ |
2893 | * completion function won't be run by workqueue code - call it here. |
2894 | * XXX: Actually, this assumption doesn't hold, see | |
2895 | * bgp_clear_route_table(), we queue all non-empty nodes. | |
ca058a30 PJ |
2896 | * |
2897 | * Additionally, there is a presumption in FSM that clearing is only | |
f2c31acb PJ |
2898 | * really needed if peer state is Established - peers in |
2899 | * pre-Established states shouldn't have any route-update state | |
2900 | * associated with them (in or out). | |
ca058a30 | 2901 | * |
f2c31acb PJ |
2902 | * We still can get here in pre-Established though, through |
2903 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity | |
2904 | * check to ensure the assumption above holds. | |
ca058a30 PJ |
2905 | * |
2906 | * At some future point, this check could be move to the top of the | |
2907 | * function, and do a quick early-return when state is | |
2908 | * pre-Established, avoiding above list and table scans. Once we're | |
2909 | * sure it is safe.. | |
65ca75e0 PJ |
2910 | */ |
2911 | if (!peer->clear_node_queue->thread) | |
2912 | bgp_clear_node_complete (peer->clear_node_queue); | |
718e3744 | 2913 | } |
2914 | ||
2915 | void | |
2916 | bgp_clear_route_all (struct peer *peer) | |
2917 | { | |
2918 | afi_t afi; | |
2919 | safi_t safi; | |
2920 | ||
2921 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2922 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
228da428 | 2923 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
718e3744 | 2924 | } |
2925 | ||
2926 | void | |
2927 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) | |
2928 | { | |
2929 | struct bgp_table *table; | |
2930 | struct bgp_node *rn; | |
2931 | struct bgp_adj_in *ain; | |
2932 | ||
2933 | table = peer->bgp->rib[afi][safi]; | |
2934 | ||
2935 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2936 | for (ain = rn->adj_in; ain ; ain = ain->next) | |
2937 | if (ain->peer == peer) | |
2938 | { | |
2939 | bgp_adj_in_remove (rn, ain); | |
2940 | bgp_unlock_node (rn); | |
2941 | break; | |
2942 | } | |
2943 | } | |
93406d87 | 2944 | |
2945 | void | |
2946 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) | |
2947 | { | |
2948 | struct bgp_node *rn; | |
2949 | struct bgp_info *ri; | |
2950 | struct bgp_table *table; | |
2951 | ||
2952 | table = peer->bgp->rib[afi][safi]; | |
2953 | ||
2954 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2955 | { | |
2956 | for (ri = rn->info; ri; ri = ri->next) | |
2957 | if (ri->peer == peer) | |
2958 | { | |
2959 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) | |
2960 | bgp_rib_remove (rn, ri, peer, afi, safi); | |
2961 | break; | |
2962 | } | |
2963 | } | |
2964 | } | |
718e3744 | 2965 | \f |
2966 | /* Delete all kernel routes. */ | |
2967 | void | |
66e5cd87 | 2968 | bgp_cleanup_routes (void) |
718e3744 | 2969 | { |
2970 | struct bgp *bgp; | |
1eb8ef25 | 2971 | struct listnode *node, *nnode; |
718e3744 | 2972 | struct bgp_node *rn; |
2973 | struct bgp_table *table; | |
2974 | struct bgp_info *ri; | |
2975 | ||
1eb8ef25 | 2976 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 2977 | { |
2978 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; | |
2979 | ||
2980 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2981 | for (ri = rn->info; ri; ri = ri->next) | |
2982 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
2983 | && ri->type == ZEBRA_ROUTE_BGP | |
2984 | && ri->sub_type == BGP_ROUTE_NORMAL) | |
2985 | bgp_zebra_withdraw (&rn->p, ri); | |
2986 | ||
2987 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; | |
2988 | ||
2989 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
2990 | for (ri = rn->info; ri; ri = ri->next) | |
2991 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) | |
2992 | && ri->type == ZEBRA_ROUTE_BGP | |
2993 | && ri->sub_type == BGP_ROUTE_NORMAL) | |
2994 | bgp_zebra_withdraw (&rn->p, ri); | |
2995 | } | |
2996 | } | |
2997 | ||
2998 | void | |
66e5cd87 | 2999 | bgp_reset (void) |
718e3744 | 3000 | { |
3001 | vty_reset (); | |
3002 | bgp_zclient_reset (); | |
3003 | access_list_reset (); | |
3004 | prefix_list_reset (); | |
3005 | } | |
3006 | \f | |
3007 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr | |
3008 | value. */ | |
3009 | int | |
3010 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) | |
3011 | { | |
3012 | u_char *pnt; | |
3013 | u_char *lim; | |
3014 | struct prefix p; | |
3015 | int psize; | |
3016 | int ret; | |
3017 | ||
3018 | /* Check peer status. */ | |
3019 | if (peer->status != Established) | |
3020 | return 0; | |
3021 | ||
3022 | pnt = packet->nlri; | |
3023 | lim = pnt + packet->length; | |
3024 | ||
3025 | for (; pnt < lim; pnt += psize) | |
3026 | { | |
3027 | /* Clear prefix structure. */ | |
3028 | memset (&p, 0, sizeof (struct prefix)); | |
3029 | ||
3030 | /* Fetch prefix length. */ | |
3031 | p.prefixlen = *pnt++; | |
3032 | p.family = afi2family (packet->afi); | |
3033 | ||
3034 | /* Already checked in nlri_sanity_check(). We do double check | |
3035 | here. */ | |
3036 | if ((packet->afi == AFI_IP && p.prefixlen > 32) | |
3037 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) | |
3038 | return -1; | |
3039 | ||
3040 | /* Packet size overflow check. */ | |
3041 | psize = PSIZE (p.prefixlen); | |
3042 | ||
3043 | /* When packet overflow occur return immediately. */ | |
3044 | if (pnt + psize > lim) | |
3045 | return -1; | |
3046 | ||
3047 | /* Fetch prefix from NLRI packet. */ | |
3048 | memcpy (&p.u.prefix, pnt, psize); | |
3049 | ||
3050 | /* Check address. */ | |
3051 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) | |
3052 | { | |
3053 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) | |
3054 | { | |
f5ba3874 | 3055 | /* |
3056 | * From draft-ietf-idr-bgp4-22, Section 6.3: | |
3057 | * If a BGP router receives an UPDATE message with a | |
3058 | * semantically incorrect NLRI field, in which a prefix is | |
3059 | * semantically incorrect (eg. an unexpected multicast IP | |
3060 | * address), it should ignore the prefix. | |
3061 | */ | |
718e3744 | 3062 | zlog (peer->log, LOG_ERR, |
3063 | "IPv4 unicast NLRI is multicast address %s", | |
3064 | inet_ntoa (p.u.prefix4)); | |
f5ba3874 | 3065 | |
718e3744 | 3066 | return -1; |
3067 | } | |
3068 | } | |
3069 | ||
3070 | #ifdef HAVE_IPV6 | |
3071 | /* Check address. */ | |
3072 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) | |
3073 | { | |
3074 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3075 | { | |
3076 | char buf[BUFSIZ]; | |
3077 | ||
3078 | zlog (peer->log, LOG_WARNING, | |
3079 | "IPv6 link-local NLRI received %s ignore this NLRI", | |
3080 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); | |
3081 | ||
3082 | continue; | |
3083 | } | |
3084 | } | |
3085 | #endif /* HAVE_IPV6 */ | |
3086 | ||
3087 | /* Normal process. */ | |
3088 | if (attr) | |
3089 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, | |
3090 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); | |
3091 | else | |
3092 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, | |
3093 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); | |
3094 | ||
3095 | /* Address family configuration mismatch or maximum-prefix count | |
3096 | overflow. */ | |
3097 | if (ret < 0) | |
3098 | return -1; | |
3099 | } | |
3100 | ||
3101 | /* Packet length consistency check. */ | |
3102 | if (pnt != lim) | |
3103 | return -1; | |
3104 | ||
3105 | return 0; | |
3106 | } | |
3107 | ||
3108 | /* NLRI encode syntax check routine. */ | |
3109 | int | |
3110 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, | |
3111 | bgp_size_t length) | |
3112 | { | |
3113 | u_char *end; | |
3114 | u_char prefixlen; | |
3115 | int psize; | |
3116 | ||
3117 | end = pnt + length; | |
3118 | ||
3119 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for | |
3120 | syntactic validity. If the field is syntactically incorrect, | |
3121 | then the Error Subcode is set to Invalid Network Field. */ | |
3122 | ||
3123 | while (pnt < end) | |
3124 | { | |
3125 | prefixlen = *pnt++; | |
3126 | ||
3127 | /* Prefix length check. */ | |
3128 | if ((afi == AFI_IP && prefixlen > 32) | |
3129 | || (afi == AFI_IP6 && prefixlen > 128)) | |
3130 | { | |
3131 | plog_err (peer->log, | |
3132 | "%s [Error] Update packet error (wrong prefix length %d)", | |
3133 | peer->host, prefixlen); | |
3134 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3135 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3136 | return -1; | |
3137 | } | |
3138 | ||
3139 | /* Packet size overflow check. */ | |
3140 | psize = PSIZE (prefixlen); | |
3141 | ||
3142 | if (pnt + psize > end) | |
3143 | { | |
3144 | plog_err (peer->log, | |
3145 | "%s [Error] Update packet error" | |
3146 | " (prefix data overflow prefix size is %d)", | |
3147 | peer->host, psize); | |
3148 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3149 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3150 | return -1; | |
3151 | } | |
3152 | ||
3153 | pnt += psize; | |
3154 | } | |
3155 | ||
3156 | /* Packet length consistency check. */ | |
3157 | if (pnt != end) | |
3158 | { | |
3159 | plog_err (peer->log, | |
3160 | "%s [Error] Update packet error" | |
3161 | " (prefix length mismatch with total length)", | |
3162 | peer->host); | |
3163 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, | |
3164 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); | |
3165 | return -1; | |
3166 | } | |
3167 | return 0; | |
3168 | } | |
3169 | \f | |
94f2b392 | 3170 | static struct bgp_static * |
66e5cd87 | 3171 | bgp_static_new (void) |
718e3744 | 3172 | { |
393deb9b | 3173 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
718e3744 | 3174 | } |
3175 | ||
94f2b392 | 3176 | static void |
718e3744 | 3177 | bgp_static_free (struct bgp_static *bgp_static) |
3178 | { | |
3179 | if (bgp_static->rmap.name) | |
3180 | free (bgp_static->rmap.name); | |
3181 | XFREE (MTYPE_BGP_STATIC, bgp_static); | |
3182 | } | |
3183 | ||
94f2b392 | 3184 | static void |
fee0f4c6 | 3185 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
3186 | struct prefix *p, afi_t afi, safi_t safi) | |
3187 | { | |
3188 | struct bgp_node *rn; | |
3189 | struct bgp_info *ri; | |
3190 | ||
3191 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); | |
3192 | ||
3193 | /* Check selected route and self inserted route. */ | |
3194 | for (ri = rn->info; ri; ri = ri->next) | |
3195 | if (ri->peer == bgp->peer_self | |
3196 | && ri->type == ZEBRA_ROUTE_BGP | |
3197 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3198 | break; | |
3199 | ||
3200 | /* Withdraw static BGP route from routing table. */ | |
3201 | if (ri) | |
3202 | { | |
fee0f4c6 | 3203 | bgp_info_delete (rn, ri); |
1a392d46 | 3204 | bgp_process (bgp, rn, afi, safi); |
fee0f4c6 | 3205 | } |
3206 | ||
3207 | /* Unlock bgp_node_lookup. */ | |
3208 | bgp_unlock_node (rn); | |
3209 | } | |
3210 | ||
94f2b392 | 3211 | static void |
fee0f4c6 | 3212 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
fb982c25 PJ |
3213 | struct bgp_static *bgp_static, |
3214 | afi_t afi, safi_t safi) | |
fee0f4c6 | 3215 | { |
3216 | struct bgp_node *rn; | |
3217 | struct bgp_info *ri; | |
3218 | struct bgp_info *new; | |
3219 | struct bgp_info info; | |
fee0f4c6 | 3220 | struct attr *attr_new; |
fb982c25 PJ |
3221 | struct attr attr = {0 }; |
3222 | struct attr new_attr = { .extra = 0 }; | |
fee0f4c6 | 3223 | struct bgp *bgp; |
3224 | int ret; | |
3225 | char buf[SU_ADDRSTRLEN]; | |
3226 | ||
3227 | bgp = rsclient->bgp; | |
3228 | ||
06e110f9 PJ |
3229 | assert (bgp_static); |
3230 | if (!bgp_static) | |
3231 | return; | |
3232 | ||
fee0f4c6 | 3233 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
3234 | ||
3235 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
06e110f9 PJ |
3236 | |
3237 | attr.nexthop = bgp_static->igpnexthop; | |
3238 | attr.med = bgp_static->igpmetric; | |
3239 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
41367172 PJ |
3240 | |
3241 | if (bgp_static->ttl) | |
3242 | { | |
3243 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT); | |
3244 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3245 | attr.pathlimit.as = 0; | |
3246 | attr.pathlimit.ttl = bgp_static->ttl; | |
3247 | } | |
3248 | ||
3249 | if (bgp_static->atomic) | |
3250 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3251 | ||
fee0f4c6 | 3252 | /* Apply network route-map for export to this rsclient. */ |
3253 | if (bgp_static->rmap.name) | |
3254 | { | |
fb982c25 | 3255 | struct attr attr_tmp = attr; |
fee0f4c6 | 3256 | info.peer = rsclient; |
fb982c25 PJ |
3257 | info.attr = &attr_tmp; |
3258 | ||
fee0f4c6 | 3259 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
3260 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); | |
3261 | ||
3262 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); | |
3263 | ||
3264 | rsclient->rmap_type = 0; | |
3265 | ||
3266 | if (ret == RMAP_DENYMATCH) | |
3267 | { | |
3268 | /* Free uninterned attribute. */ | |
fb982c25 | 3269 | bgp_attr_flush (&attr_tmp); |
fee0f4c6 | 3270 | |
3271 | /* Unintern original. */ | |
3272 | aspath_unintern (attr.aspath); | |
3273 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); | |
fb982c25 PJ |
3274 | bgp_attr_extra_free (&attr); |
3275 | ||
fee0f4c6 | 3276 | return; |
3277 | } | |
fb982c25 | 3278 | attr_new = bgp_attr_intern (&attr_tmp); |
fee0f4c6 | 3279 | } |
3280 | else | |
3281 | attr_new = bgp_attr_intern (&attr); | |
fb982c25 | 3282 | |
fee0f4c6 | 3283 | new_attr = *attr_new; |
fb982c25 | 3284 | |
fee0f4c6 | 3285 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3286 | ||
fb982c25 PJ |
3287 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
3288 | == RMAP_DENY) | |
3289 | { | |
fee0f4c6 | 3290 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
3291 | if (BGP_DEBUG (update, UPDATE_IN)) | |
d2c1f16b | 3292 | zlog (rsclient->log, LOG_DEBUG, |
fee0f4c6 | 3293 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
3294 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
3295 | p->prefixlen, rsclient->host); | |
3296 | ||
3297 | bgp->peer_self->rmap_type = 0; | |
3298 | ||
3299 | bgp_attr_unintern (attr_new); | |
3300 | aspath_unintern (attr.aspath); | |
fb982c25 | 3301 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3302 | |
3303 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); | |
3304 | ||
3305 | return; | |
fb982c25 | 3306 | } |
fee0f4c6 | 3307 | |
3308 | bgp->peer_self->rmap_type = 0; | |
3309 | ||
3310 | bgp_attr_unintern (attr_new); | |
3311 | attr_new = bgp_attr_intern (&new_attr); | |
3312 | ||
3313 | for (ri = rn->info; ri; ri = ri->next) | |
3314 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3315 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3316 | break; | |
3317 | ||
3318 | if (ri) | |
3319 | { | |
8d45210e AS |
3320 | if (attrhash_cmp (ri->attr, attr_new) && |
3321 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
fee0f4c6 | 3322 | { |
3323 | bgp_unlock_node (rn); | |
3324 | bgp_attr_unintern (attr_new); | |
3325 | aspath_unintern (attr.aspath); | |
fb982c25 | 3326 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3327 | return; |
3328 | } | |
3329 | else | |
3330 | { | |
3331 | /* The attribute is changed. */ | |
1a392d46 | 3332 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
fee0f4c6 | 3333 | |
3334 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3335 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3336 | bgp_info_restore(rn, ri); | |
fee0f4c6 | 3337 | bgp_attr_unintern (ri->attr); |
3338 | ri->attr = attr_new; | |
65957886 | 3339 | ri->uptime = bgp_clock (); |
fee0f4c6 | 3340 | |
3341 | /* Process change. */ | |
3342 | bgp_process (bgp, rn, afi, safi); | |
3343 | bgp_unlock_node (rn); | |
3344 | aspath_unintern (attr.aspath); | |
fb982c25 | 3345 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3346 | return; |
fb982c25 | 3347 | } |
fee0f4c6 | 3348 | } |
fb982c25 | 3349 | |
fee0f4c6 | 3350 | /* Make new BGP info. */ |
3351 | new = bgp_info_new (); | |
3352 | new->type = ZEBRA_ROUTE_BGP; | |
3353 | new->sub_type = BGP_ROUTE_STATIC; | |
3354 | new->peer = bgp->peer_self; | |
3355 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3356 | new->attr = attr_new; | |
65957886 | 3357 | new->uptime = bgp_clock (); |
fee0f4c6 | 3358 | |
3359 | /* Register new BGP information. */ | |
3360 | bgp_info_add (rn, new); | |
200df115 | 3361 | |
3362 | /* route_node_get lock */ | |
3363 | bgp_unlock_node (rn); | |
3364 | ||
fee0f4c6 | 3365 | /* Process change. */ |
3366 | bgp_process (bgp, rn, afi, safi); | |
3367 | ||
3368 | /* Unintern original. */ | |
3369 | aspath_unintern (attr.aspath); | |
fb982c25 | 3370 | bgp_attr_extra_free (&attr); |
fee0f4c6 | 3371 | } |
3372 | ||
94f2b392 | 3373 | static void |
fee0f4c6 | 3374 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
718e3744 | 3375 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
3376 | { | |
3377 | struct bgp_node *rn; | |
3378 | struct bgp_info *ri; | |
3379 | struct bgp_info *new; | |
3380 | struct bgp_info info; | |
fb982c25 | 3381 | struct attr attr = { 0 }; |
718e3744 | 3382 | struct attr *attr_new; |
3383 | int ret; | |
3384 | ||
dd8103a9 PJ |
3385 | assert (bgp_static); |
3386 | if (!bgp_static) | |
3387 | return; | |
3388 | ||
fee0f4c6 | 3389 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3390 | |
3391 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); | |
dd8103a9 PJ |
3392 | |
3393 | attr.nexthop = bgp_static->igpnexthop; | |
3394 | attr.med = bgp_static->igpmetric; | |
3395 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
718e3744 | 3396 | |
41367172 PJ |
3397 | if (bgp_static->ttl) |
3398 | { | |
3399 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT); | |
3400 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3401 | attr.pathlimit.as = 0; | |
3402 | attr.pathlimit.ttl = bgp_static->ttl; | |
3403 | } | |
3404 | ||
3405 | if (bgp_static->atomic) | |
3406 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); | |
3407 | ||
718e3744 | 3408 | /* Apply route-map. */ |
3409 | if (bgp_static->rmap.name) | |
3410 | { | |
fb982c25 | 3411 | struct attr attr_tmp = attr; |
718e3744 | 3412 | info.peer = bgp->peer_self; |
286e1e71 | 3413 | info.attr = &attr_tmp; |
718e3744 | 3414 | |
fee0f4c6 | 3415 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
3416 | ||
718e3744 | 3417 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
286e1e71 | 3418 | |
fee0f4c6 | 3419 | bgp->peer_self->rmap_type = 0; |
3420 | ||
718e3744 | 3421 | if (ret == RMAP_DENYMATCH) |
3422 | { | |
3423 | /* Free uninterned attribute. */ | |
286e1e71 | 3424 | bgp_attr_flush (&attr_tmp); |
718e3744 | 3425 | |
3426 | /* Unintern original. */ | |
3427 | aspath_unintern (attr.aspath); | |
fb982c25 | 3428 | bgp_attr_extra_free (&attr); |
718e3744 | 3429 | bgp_static_withdraw (bgp, p, afi, safi); |
3430 | return; | |
3431 | } | |
286e1e71 | 3432 | attr_new = bgp_attr_intern (&attr_tmp); |
718e3744 | 3433 | } |
286e1e71 | 3434 | else |
3435 | attr_new = bgp_attr_intern (&attr); | |
718e3744 | 3436 | |
3437 | for (ri = rn->info; ri; ri = ri->next) | |
3438 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP | |
3439 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3440 | break; | |
3441 | ||
3442 | if (ri) | |
3443 | { | |
8d45210e AS |
3444 | if (attrhash_cmp (ri->attr, attr_new) && |
3445 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) | |
718e3744 | 3446 | { |
3447 | bgp_unlock_node (rn); | |
3448 | bgp_attr_unintern (attr_new); | |
3449 | aspath_unintern (attr.aspath); | |
fb982c25 | 3450 | bgp_attr_extra_free (&attr); |
718e3744 | 3451 | return; |
3452 | } | |
3453 | else | |
3454 | { | |
3455 | /* The attribute is changed. */ | |
1a392d46 | 3456 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 3457 | |
3458 | /* Rewrite BGP route information. */ | |
8d45210e AS |
3459 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
3460 | bgp_info_restore(rn, ri); | |
3461 | else | |
3462 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3463 | bgp_attr_unintern (ri->attr); |
3464 | ri->attr = attr_new; | |
65957886 | 3465 | ri->uptime = bgp_clock (); |
718e3744 | 3466 | |
3467 | /* Process change. */ | |
3468 | bgp_aggregate_increment (bgp, p, ri, afi, safi); | |
3469 | bgp_process (bgp, rn, afi, safi); | |
3470 | bgp_unlock_node (rn); | |
3471 | aspath_unintern (attr.aspath); | |
fb982c25 | 3472 | bgp_attr_extra_free (&attr); |
718e3744 | 3473 | return; |
3474 | } | |
3475 | } | |
3476 | ||
3477 | /* Make new BGP info. */ | |
3478 | new = bgp_info_new (); | |
3479 | new->type = ZEBRA_ROUTE_BGP; | |
3480 | new->sub_type = BGP_ROUTE_STATIC; | |
3481 | new->peer = bgp->peer_self; | |
3482 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
3483 | new->attr = attr_new; | |
65957886 | 3484 | new->uptime = bgp_clock (); |
718e3744 | 3485 | |
3486 | /* Aggregate address increment. */ | |
3487 | bgp_aggregate_increment (bgp, p, new, afi, safi); | |
3488 | ||
3489 | /* Register new BGP information. */ | |
3490 | bgp_info_add (rn, new); | |
200df115 | 3491 | |
3492 | /* route_node_get lock */ | |
3493 | bgp_unlock_node (rn); | |
3494 | ||
718e3744 | 3495 | /* Process change. */ |
3496 | bgp_process (bgp, rn, afi, safi); | |
3497 | ||
3498 | /* Unintern original. */ | |
3499 | aspath_unintern (attr.aspath); | |
fb982c25 | 3500 | bgp_attr_extra_free (&attr); |
718e3744 | 3501 | } |
3502 | ||
fee0f4c6 | 3503 | void |
3504 | bgp_static_update (struct bgp *bgp, struct prefix *p, | |
3505 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) | |
3506 | { | |
3507 | struct peer *rsclient; | |
1eb8ef25 | 3508 | struct listnode *node, *nnode; |
fee0f4c6 | 3509 | |
3510 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); | |
3511 | ||
1eb8ef25 | 3512 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
fee0f4c6 | 3513 | { |
da5b30f6 PJ |
3514 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
3515 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); | |
fee0f4c6 | 3516 | } |
3517 | } | |
3518 | ||
94f2b392 | 3519 | static void |
4c9641ba ML |
3520 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3521 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3522 | { |
3523 | struct bgp_node *rn; | |
3524 | struct bgp_info *new; | |
fb982c25 | 3525 | |
fee0f4c6 | 3526 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3527 | |
3528 | /* Make new BGP info. */ | |
3529 | new = bgp_info_new (); | |
3530 | new->type = ZEBRA_ROUTE_BGP; | |
3531 | new->sub_type = BGP_ROUTE_STATIC; | |
3532 | new->peer = bgp->peer_self; | |
3533 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); | |
3534 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
65957886 | 3535 | new->uptime = bgp_clock (); |
fb982c25 PJ |
3536 | new->extra = bgp_info_extra_new(); |
3537 | memcpy (new->extra->tag, tag, 3); | |
718e3744 | 3538 | |
3539 | /* Aggregate address increment. */ | |
200df115 | 3540 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
718e3744 | 3541 | |
3542 | /* Register new BGP information. */ | |
200df115 | 3543 | bgp_info_add (rn, new); |
718e3744 | 3544 | |
200df115 | 3545 | /* route_node_get lock */ |
3546 | bgp_unlock_node (rn); | |
3547 | ||
718e3744 | 3548 | /* Process change. */ |
3549 | bgp_process (bgp, rn, afi, safi); | |
3550 | } | |
3551 | ||
3552 | void | |
3553 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, | |
3554 | safi_t safi) | |
3555 | { | |
3556 | struct bgp_node *rn; | |
3557 | struct bgp_info *ri; | |
3558 | ||
fee0f4c6 | 3559 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
718e3744 | 3560 | |
3561 | /* Check selected route and self inserted route. */ | |
3562 | for (ri = rn->info; ri; ri = ri->next) | |
3563 | if (ri->peer == bgp->peer_self | |
3564 | && ri->type == ZEBRA_ROUTE_BGP | |
3565 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3566 | break; | |
3567 | ||
3568 | /* Withdraw static BGP route from routing table. */ | |
3569 | if (ri) | |
3570 | { | |
3571 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3572 | bgp_info_delete (rn, ri); |
1a392d46 | 3573 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3574 | } |
3575 | ||
3576 | /* Unlock bgp_node_lookup. */ | |
3577 | bgp_unlock_node (rn); | |
3578 | } | |
3579 | ||
fee0f4c6 | 3580 | void |
3581 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) | |
3582 | { | |
3583 | struct bgp_static *bgp_static; | |
3584 | struct bgp *bgp; | |
3585 | struct bgp_node *rn; | |
3586 | struct prefix *p; | |
3587 | ||
3588 | bgp = rsclient->bgp; | |
3589 | ||
3590 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3591 | if ((bgp_static = rn->info) != NULL) | |
3592 | { | |
3593 | p = &rn->p; | |
3594 | ||
3595 | bgp_static_update_rsclient (rsclient, p, bgp_static, | |
3596 | afi, safi); | |
3597 | } | |
3598 | } | |
3599 | ||
94f2b392 | 3600 | static void |
4c9641ba ML |
3601 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
3602 | safi_t safi, struct prefix_rd *prd, u_char *tag) | |
718e3744 | 3603 | { |
3604 | struct bgp_node *rn; | |
3605 | struct bgp_info *ri; | |
3606 | ||
fee0f4c6 | 3607 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
718e3744 | 3608 | |
3609 | /* Check selected route and self inserted route. */ | |
3610 | for (ri = rn->info; ri; ri = ri->next) | |
3611 | if (ri->peer == bgp->peer_self | |
3612 | && ri->type == ZEBRA_ROUTE_BGP | |
3613 | && ri->sub_type == BGP_ROUTE_STATIC) | |
3614 | break; | |
3615 | ||
3616 | /* Withdraw static BGP route from routing table. */ | |
3617 | if (ri) | |
3618 | { | |
3619 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); | |
718e3744 | 3620 | bgp_info_delete (rn, ri); |
1a392d46 | 3621 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 3622 | } |
3623 | ||
3624 | /* Unlock bgp_node_lookup. */ | |
3625 | bgp_unlock_node (rn); | |
3626 | } | |
3627 | ||
41367172 PJ |
3628 | static void |
3629 | bgp_pathlimit_update_parents (struct bgp *bgp, struct bgp_node *rn, | |
3630 | int ttl_edge) | |
3631 | { | |
3632 | struct bgp_node *parent = rn; | |
3633 | struct bgp_static *sp; | |
3634 | ||
3635 | /* Existing static changed TTL, search parents and adjust their atomic */ | |
3636 | while ((parent = parent->parent)) | |
3637 | if ((sp = parent->info)) | |
3638 | { | |
3639 | int sp_level = (sp->atomic ? 1 : 0); | |
3640 | ttl_edge ? sp->atomic++ : sp->atomic--; | |
3641 | ||
3642 | /* did we change state of parent whether atomic is set or not? */ | |
3643 | if (sp_level != (sp->atomic ? 1 : 0)) | |
3644 | { | |
3645 | bgp_static_update (bgp, &parent->p, sp, | |
3646 | rn->table->afi, rn->table->safi); | |
3647 | } | |
3648 | } | |
3649 | } | |
3650 | ||
718e3744 | 3651 | /* Configure static BGP network. When user don't run zebra, static |
3652 | route should be installed as valid. */ | |
94f2b392 | 3653 | static int |
fd79ac91 | 3654 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
4c9641ba | 3655 | afi_t afi, safi_t safi, const char *rmap, int backdoor, |
41367172 | 3656 | u_char ttl) |
718e3744 | 3657 | { |
3658 | int ret; | |
3659 | struct prefix p; | |
3660 | struct bgp_static *bgp_static; | |
3661 | struct bgp_node *rn; | |
41367172 PJ |
3662 | u_char need_update = 0; |
3663 | u_char ttl_change = 0; | |
3664 | u_char ttl_edge = (ttl ? 1 : 0); | |
3665 | u_char new = 0; | |
718e3744 | 3666 | |
3667 | /* Convert IP prefix string to struct prefix. */ | |
3668 | ret = str2prefix (ip_str, &p); | |
3669 | if (! ret) | |
3670 | { | |
3671 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3672 | return CMD_WARNING; | |
3673 | } | |
3674 | #ifdef HAVE_IPV6 | |
3675 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3676 | { | |
3677 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3678 | VTY_NEWLINE); | |
3679 | return CMD_WARNING; | |
3680 | } | |
3681 | #endif /* HAVE_IPV6 */ | |
3682 | ||
3683 | apply_mask (&p); | |
3684 | ||
3685 | /* Set BGP static route configuration. */ | |
3686 | rn = bgp_node_get (bgp->route[afi][safi], &p); | |
3687 | ||
3688 | if (rn->info) | |
3689 | { | |
3690 | /* Configuration change. */ | |
3691 | bgp_static = rn->info; | |
3692 | ||
3693 | /* Check previous routes are installed into BGP. */ | |
41367172 PJ |
3694 | if (bgp_static->valid) |
3695 | { | |
3696 | if (bgp_static->backdoor != backdoor | |
3697 | || bgp_static->ttl != ttl) | |
3698 | need_update = 1; | |
3699 | } | |
3700 | ||
3701 | /* need to catch TTL set/unset transitions for handling of | |
3702 | * ATOMIC_AGGREGATE | |
3703 | */ | |
3704 | if ((bgp_static->ttl ? 1 : 0) != ttl_edge) | |
3705 | ttl_change = 1; | |
3706 | ||
718e3744 | 3707 | bgp_static->backdoor = backdoor; |
41367172 PJ |
3708 | bgp_static->ttl = ttl; |
3709 | ||
718e3744 | 3710 | if (rmap) |
3711 | { | |
3712 | if (bgp_static->rmap.name) | |
3713 | free (bgp_static->rmap.name); | |
3714 | bgp_static->rmap.name = strdup (rmap); | |
3715 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); | |
3716 | } | |
3717 | else | |
3718 | { | |
3719 | if (bgp_static->rmap.name) | |
3720 | free (bgp_static->rmap.name); | |
3721 | bgp_static->rmap.name = NULL; | |
3722 | bgp_static->rmap.map = NULL; | |
3723 | bgp_static->valid = 0; | |
3724 | } | |
3725 | bgp_unlock_node (rn); | |
3726 | } | |
3727 | else | |
3728 | { | |
3729 | /* New configuration. */ | |
3730 | bgp_static = bgp_static_new (); | |
3731 | bgp_static->backdoor = backdoor; | |
3732 | bgp_static->valid = 0; | |
3733 | bgp_static->igpmetric = 0; | |
3734 | bgp_static->igpnexthop.s_addr = 0; | |
41367172 PJ |
3735 | bgp_static->ttl = ttl; |
3736 | ttl_change = ttl_edge; | |
3737 | new = 1; | |
3738 | ||
718e3744 | 3739 | if (rmap) |
3740 | { | |
3741 | if (bgp_static->rmap.name) | |
3742 | free (bgp_static->rmap.name); | |
3743 | bgp_static->rmap.name = strdup (rmap); | |
3744 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); | |
3745 | } | |
3746 | rn->info = bgp_static; | |
3747 | } | |
3748 | ||
41367172 PJ |
3749 | /* ".. sites that choose to advertise the |
3750 | * AS_PATHLIMIT path attribute SHOULD advertise the ATOMIC_AGGREGATE on | |
3751 | * all less specific covering prefixes as well as the more specific | |
3752 | * prefixes." | |
3753 | * | |
3754 | * So: | |
3755 | * Prefix that has just had pathlimit set/unset: | |
3756 | * - Must bump ATOMIC refcount on all parents. | |
3757 | * | |
3758 | * To catch less specific prefixes: | |
3759 | * - Must search children for ones with TTL, bump atomic refcount | |
3760 | * (we dont care if we're deleting a less specific prefix..) | |
3761 | */ | |
3762 | if (ttl_change) | |
3763 | { | |
3764 | /* Existing static changed TTL, search parents and adjust their atomic */ | |
3765 | bgp_pathlimit_update_parents (bgp, rn, ttl_edge); | |
3766 | } | |
3767 | ||
3768 | if (new) | |
3769 | { | |
3770 | struct bgp_node *child; | |
3771 | struct bgp_static *sc; | |
3772 | ||
3773 | /* New static, search children and bump this statics atomic.. */ | |
3774 | child = bgp_lock_node (rn); /* route_next_until unlocks it.. */ | |
3775 | while ((child = bgp_route_next_until (child, rn))) | |
3776 | { | |
3777 | if ((sc = child->info) && sc->ttl) | |
3778 | bgp_static->atomic++; | |
3779 | } | |
3780 | } | |
3781 | ||
718e3744 | 3782 | /* If BGP scan is not enabled, we should install this route here. */ |
3783 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) | |
3784 | { | |
3785 | bgp_static->valid = 1; | |
3786 | ||
3787 | if (need_update) | |
3788 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3789 | ||
3790 | if (! bgp_static->backdoor) | |
3791 | bgp_static_update (bgp, &p, bgp_static, afi, safi); | |
3792 | } | |
3793 | ||
3794 | return CMD_SUCCESS; | |
3795 | } | |
3796 | ||
3797 | /* Configure static BGP network. */ | |
94f2b392 | 3798 | static int |
fd79ac91 | 3799 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
4c9641ba | 3800 | afi_t afi, safi_t safi) |
718e3744 | 3801 | { |
3802 | int ret; | |
3803 | struct prefix p; | |
3804 | struct bgp_static *bgp_static; | |
3805 | struct bgp_node *rn; | |
3806 | ||
3807 | /* Convert IP prefix string to struct prefix. */ | |
3808 | ret = str2prefix (ip_str, &p); | |
3809 | if (! ret) | |
3810 | { | |
3811 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3812 | return CMD_WARNING; | |
3813 | } | |
3814 | #ifdef HAVE_IPV6 | |
3815 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
3816 | { | |
3817 | vty_out (vty, "%% Malformed prefix (link-local address)%s", | |
3818 | VTY_NEWLINE); | |
3819 | return CMD_WARNING; | |
3820 | } | |
3821 | #endif /* HAVE_IPV6 */ | |
3822 | ||
3823 | apply_mask (&p); | |
3824 | ||
3825 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); | |
3826 | if (! rn) | |
3827 | { | |
3828 | vty_out (vty, "%% Can't find specified static route configuration.%s", | |
3829 | VTY_NEWLINE); | |
3830 | return CMD_WARNING; | |
3831 | } | |
3832 | ||
3833 | bgp_static = rn->info; | |
41367172 PJ |
3834 | |
3835 | /* decrement atomic in parents, see bgp_static_set */ | |
3836 | bgp_pathlimit_update_parents (bgp, rn, 0); | |
3837 | ||
718e3744 | 3838 | /* Update BGP RIB. */ |
3839 | if (! bgp_static->backdoor) | |
3840 | bgp_static_withdraw (bgp, &p, afi, safi); | |
3841 | ||
3842 | /* Clear configuration. */ | |
3843 | bgp_static_free (bgp_static); | |
3844 | rn->info = NULL; | |
3845 | bgp_unlock_node (rn); | |
3846 | bgp_unlock_node (rn); | |
3847 | ||
3848 | return CMD_SUCCESS; | |
3849 | } | |
3850 | ||
3851 | /* Called from bgp_delete(). Delete all static routes from the BGP | |
3852 | instance. */ | |
3853 | void | |
3854 | bgp_static_delete (struct bgp *bgp) | |
3855 | { | |
3856 | afi_t afi; | |
3857 | safi_t safi; | |
3858 | struct bgp_node *rn; | |
3859 | struct bgp_node *rm; | |
3860 | struct bgp_table *table; | |
3861 | struct bgp_static *bgp_static; | |
3862 | ||
3863 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
3864 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
3865 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
3866 | if (rn->info != NULL) | |
3867 | { | |
3868 | if (safi == SAFI_MPLS_VPN) | |
3869 | { | |
3870 | table = rn->info; | |
3871 | ||
3872 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) | |
3873 | { | |
3874 | bgp_static = rn->info; | |
3875 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, | |
3876 | AFI_IP, SAFI_MPLS_VPN, | |
3877 | (struct prefix_rd *)&rn->p, | |
3878 | bgp_static->tag); | |
3879 | bgp_static_free (bgp_static); | |
3880 | rn->info = NULL; | |
3881 | bgp_unlock_node (rn); | |
3882 | } | |
3883 | } | |
3884 | else | |
3885 | { | |
3886 | bgp_static = rn->info; | |
3887 | bgp_static_withdraw (bgp, &rn->p, afi, safi); | |
3888 | bgp_static_free (bgp_static); | |
3889 | rn->info = NULL; | |
3890 | bgp_unlock_node (rn); | |
3891 | } | |
3892 | } | |
3893 | } | |
3894 | ||
3895 | int | |
fd79ac91 | 3896 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
3897 | const char *tag_str) | |
718e3744 | 3898 | { |
3899 | int ret; | |
3900 | struct prefix p; | |
3901 | struct prefix_rd prd; | |
3902 | struct bgp *bgp; | |
3903 | struct bgp_node *prn; | |
3904 | struct bgp_node *rn; | |
3905 | struct bgp_table *table; | |
3906 | struct bgp_static *bgp_static; | |
3907 | u_char tag[3]; | |
3908 | ||
3909 | bgp = vty->index; | |
3910 | ||
3911 | ret = str2prefix (ip_str, &p); | |
3912 | if (! ret) | |
3913 | { | |
3914 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3915 | return CMD_WARNING; | |
3916 | } | |
3917 | apply_mask (&p); | |
3918 | ||
3919 | ret = str2prefix_rd (rd_str, &prd); | |
3920 | if (! ret) | |
3921 | { | |
3922 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3923 | return CMD_WARNING; | |
3924 | } | |
3925 | ||
3926 | ret = str2tag (tag_str, tag); | |
3927 | if (! ret) | |
3928 | { | |
3929 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3930 | return CMD_WARNING; | |
3931 | } | |
3932 | ||
3933 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
3934 | (struct prefix *)&prd); | |
3935 | if (prn->info == NULL) | |
64e580a7 | 3936 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 3937 | else |
3938 | bgp_unlock_node (prn); | |
3939 | table = prn->info; | |
3940 | ||
3941 | rn = bgp_node_get (table, &p); | |
3942 | ||
3943 | if (rn->info) | |
3944 | { | |
3945 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); | |
3946 | bgp_unlock_node (rn); | |
3947 | } | |
3948 | else | |
3949 | { | |
3950 | /* New configuration. */ | |
3951 | bgp_static = bgp_static_new (); | |
3952 | bgp_static->valid = 1; | |
3953 | memcpy (bgp_static->tag, tag, 3); | |
3954 | rn->info = bgp_static; | |
3955 | ||
3956 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
3957 | } | |
3958 | ||
3959 | return CMD_SUCCESS; | |
3960 | } | |
3961 | ||
3962 | /* Configure static BGP network. */ | |
3963 | int | |
fd79ac91 | 3964 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
3965 | const char *rd_str, const char *tag_str) | |
718e3744 | 3966 | { |
3967 | int ret; | |
3968 | struct bgp *bgp; | |
3969 | struct prefix p; | |
3970 | struct prefix_rd prd; | |
3971 | struct bgp_node *prn; | |
3972 | struct bgp_node *rn; | |
3973 | struct bgp_table *table; | |
3974 | struct bgp_static *bgp_static; | |
3975 | u_char tag[3]; | |
3976 | ||
3977 | bgp = vty->index; | |
3978 | ||
3979 | /* Convert IP prefix string to struct prefix. */ | |
3980 | ret = str2prefix (ip_str, &p); | |
3981 | if (! ret) | |
3982 | { | |
3983 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); | |
3984 | return CMD_WARNING; | |
3985 | } | |
3986 | apply_mask (&p); | |
3987 | ||
3988 | ret = str2prefix_rd (rd_str, &prd); | |
3989 | if (! ret) | |
3990 | { | |
3991 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); | |
3992 | return CMD_WARNING; | |
3993 | } | |
3994 | ||
3995 | ret = str2tag (tag_str, tag); | |
3996 | if (! ret) | |
3997 | { | |
3998 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); | |
3999 | return CMD_WARNING; | |
4000 | } | |
4001 | ||
4002 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], | |
4003 | (struct prefix *)&prd); | |
4004 | if (prn->info == NULL) | |
64e580a7 | 4005 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
718e3744 | 4006 | else |
4007 | bgp_unlock_node (prn); | |
4008 | table = prn->info; | |
4009 | ||
4010 | rn = bgp_node_lookup (table, &p); | |
4011 | ||
4012 | if (rn) | |
4013 | { | |
4014 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); | |
4015 | ||
4016 | bgp_static = rn->info; | |
4017 | bgp_static_free (bgp_static); | |
4018 | rn->info = NULL; | |
4019 | bgp_unlock_node (rn); | |
4020 | bgp_unlock_node (rn); | |
4021 | } | |
4022 | else | |
4023 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); | |
4024 | ||
4025 | return CMD_SUCCESS; | |
4026 | } | |
4027 | \f | |
4028 | DEFUN (bgp_network, | |
4029 | bgp_network_cmd, | |
4030 | "network A.B.C.D/M", | |
4031 | "Specify a network to announce via BGP\n" | |
4032 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4033 | { | |
41367172 PJ |
4034 | u_char ttl = 0; |
4035 | ||
4036 | if (argc == 2) | |
4037 | VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); | |
4038 | ||
718e3744 | 4039 | return bgp_static_set (vty, vty->index, argv[0], |
41367172 | 4040 | AFI_IP, bgp_node_safi (vty), NULL, 0, ttl); |
718e3744 | 4041 | } |
4042 | ||
41367172 PJ |
4043 | ALIAS (bgp_network, |
4044 | bgp_network_ttl_cmd, | |
4045 | "network A.B.C.D/M pathlimit <0-255>", | |
4046 | "Specify a network to announce via BGP\n" | |
4047 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4048 | "AS-Path hopcount limit attribute\n" | |
4049 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4050 | ||
718e3744 | 4051 | DEFUN (bgp_network_route_map, |
4052 | bgp_network_route_map_cmd, | |
4053 | "network A.B.C.D/M route-map WORD", | |
4054 | "Specify a network to announce via BGP\n" | |
4055 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4056 | "Route-map to modify the attributes\n" | |
4057 | "Name of the route map\n") | |
4058 | { | |
4059 | return bgp_static_set (vty, vty->index, argv[0], | |
41367172 | 4060 | AFI_IP, bgp_node_safi (vty), argv[1], 0, 0); |
718e3744 | 4061 | } |
4062 | ||
4063 | DEFUN (bgp_network_backdoor, | |
4064 | bgp_network_backdoor_cmd, | |
4065 | "network A.B.C.D/M backdoor", | |
4066 | "Specify a network to announce via BGP\n" | |
4067 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4068 | "Specify a BGP backdoor route\n") | |
4069 | { | |
41367172 PJ |
4070 | u_char ttl = 0; |
4071 | ||
4072 | if (argc == 2) | |
4073 | VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); | |
4074 | ||
4075 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, | |
4076 | NULL, 1, ttl); | |
718e3744 | 4077 | } |
4078 | ||
41367172 PJ |
4079 | ALIAS (bgp_network_backdoor, |
4080 | bgp_network_backdoor_ttl_cmd, | |
4081 | "network A.B.C.D/M backdoor pathlimit <0-255>", | |
4082 | "Specify a network to announce via BGP\n" | |
4083 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4084 | "Specify a BGP backdoor route\n" | |
4085 | "AS-Path hopcount limit attribute\n" | |
4086 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4087 | ||
718e3744 | 4088 | DEFUN (bgp_network_mask, |
4089 | bgp_network_mask_cmd, | |
4090 | "network A.B.C.D mask A.B.C.D", | |
4091 | "Specify a network to announce via BGP\n" | |
4092 | "Network number\n" | |
4093 | "Network mask\n" | |
4094 | "Network mask\n") | |
4095 | { | |
4096 | int ret; | |
4097 | char prefix_str[BUFSIZ]; | |
41367172 PJ |
4098 | u_char ttl = 0; |
4099 | ||
4100 | if (argc == 3) | |
4101 | VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[2], 1, 255); | |
4102 | ||
718e3744 | 4103 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
4104 | if (! ret) | |
4105 | { | |
4106 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4107 | return CMD_WARNING; | |
4108 | } | |
4109 | ||
4110 | return bgp_static_set (vty, vty->index, prefix_str, | |
41367172 | 4111 | AFI_IP, bgp_node_safi (vty), NULL, 0, ttl); |
718e3744 | 4112 | } |
4113 | ||
41367172 PJ |
4114 | ALIAS (bgp_network_mask, |
4115 | bgp_network_mask_ttl_cmd, | |
4116 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", | |
4117 | "Specify a network to announce via BGP\n" | |
4118 | "Network number\n" | |
4119 | "Network mask\n" | |
4120 | "Network mask\n" | |
4121 | "AS-Path hopcount limit attribute\n" | |
4122 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4123 | ||
718e3744 | 4124 | DEFUN (bgp_network_mask_route_map, |
4125 | bgp_network_mask_route_map_cmd, | |
4126 | "network A.B.C.D mask A.B.C.D route-map WORD", | |
4127 | "Specify a network to announce via BGP\n" | |
4128 | "Network number\n" | |
4129 | "Network mask\n" | |
4130 | "Network mask\n" | |
4131 | "Route-map to modify the attributes\n" | |
4132 | "Name of the route map\n") | |
4133 | { | |
4134 | int ret; | |
4135 | char prefix_str[BUFSIZ]; | |
41367172 | 4136 | |
718e3744 | 4137 | ret = netmask_str2prefix_str (argv[0], argv[1], 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_set (vty, vty->index, prefix_str, | |
41367172 | 4145 | AFI_IP, bgp_node_safi (vty), argv[2], 0, 0); |
718e3744 | 4146 | } |
4147 | ||
4148 | DEFUN (bgp_network_mask_backdoor, | |
4149 | bgp_network_mask_backdoor_cmd, | |
4150 | "network A.B.C.D mask A.B.C.D backdoor", | |
4151 | "Specify a network to announce via BGP\n" | |
4152 | "Network number\n" | |
4153 | "Network mask\n" | |
4154 | "Network mask\n" | |
4155 | "Specify a BGP backdoor route\n") | |
4156 | { | |
4157 | int ret; | |
4158 | char prefix_str[BUFSIZ]; | |
41367172 PJ |
4159 | u_char ttl = 0; |
4160 | ||
4161 | if (argc == 3) | |
4162 | VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[2], 1, 255); | |
718e3744 | 4163 | |
4164 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4165 | if (! ret) | |
4166 | { | |
4167 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4168 | return CMD_WARNING; | |
4169 | } | |
4170 | ||
41367172 PJ |
4171 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
4172 | NULL, 1, ttl); | |
718e3744 | 4173 | } |
4174 | ||
41367172 PJ |
4175 | ALIAS (bgp_network_mask_backdoor, |
4176 | bgp_network_mask_backdoor_ttl_cmd, | |
4177 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", | |
4178 | "Specify a network to announce via BGP\n" | |
4179 | "Network number\n" | |
4180 | "Network mask\n" | |
4181 | "Network mask\n" | |
4182 | "Specify a BGP backdoor route\n" | |
4183 | "AS-Path hopcount limit attribute\n" | |
4184 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4185 | ||
718e3744 | 4186 | DEFUN (bgp_network_mask_natural, |
4187 | bgp_network_mask_natural_cmd, | |
4188 | "network A.B.C.D", | |
4189 | "Specify a network to announce via BGP\n" | |
4190 | "Network number\n") | |
4191 | { | |
4192 | int ret; | |
4193 | char prefix_str[BUFSIZ]; | |
41367172 PJ |
4194 | u_char ttl = 0; |
4195 | ||
4196 | if (argc == 2) | |
4197 | VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); | |
718e3744 | 4198 | |
4199 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4200 | if (! ret) | |
4201 | { | |
4202 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4203 | return CMD_WARNING; | |
4204 | } | |
4205 | ||
4206 | return bgp_static_set (vty, vty->index, prefix_str, | |
41367172 | 4207 | AFI_IP, bgp_node_safi (vty), NULL, 0, ttl); |
718e3744 | 4208 | } |
4209 | ||
41367172 PJ |
4210 | ALIAS (bgp_network_mask_natural, |
4211 | bgp_network_mask_natural_ttl_cmd, | |
4212 | "network A.B.C.D pathlimit <0-255>", | |
4213 | "Specify a network to announce via BGP\n" | |
4214 | "Network number\n" | |
4215 | "AS-Path hopcount limit attribute\n" | |
4216 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4217 | ||
718e3744 | 4218 | DEFUN (bgp_network_mask_natural_route_map, |
4219 | bgp_network_mask_natural_route_map_cmd, | |
4220 | "network A.B.C.D route-map WORD", | |
4221 | "Specify a network to announce via BGP\n" | |
4222 | "Network number\n" | |
4223 | "Route-map to modify the attributes\n" | |
4224 | "Name of the route map\n") | |
4225 | { | |
4226 | int ret; | |
4227 | char prefix_str[BUFSIZ]; | |
4228 | ||
4229 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4230 | if (! ret) | |
4231 | { | |
4232 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4233 | return CMD_WARNING; | |
4234 | } | |
4235 | ||
4236 | return bgp_static_set (vty, vty->index, prefix_str, | |
41367172 | 4237 | AFI_IP, bgp_node_safi (vty), argv[1], 0, 0); |
718e3744 | 4238 | } |
4239 | ||
4240 | DEFUN (bgp_network_mask_natural_backdoor, | |
4241 | bgp_network_mask_natural_backdoor_cmd, | |
4242 | "network A.B.C.D backdoor", | |
4243 | "Specify a network to announce via BGP\n" | |
4244 | "Network number\n" | |
4245 | "Specify a BGP backdoor route\n") | |
4246 | { | |
4247 | int ret; | |
4248 | char prefix_str[BUFSIZ]; | |
41367172 PJ |
4249 | u_char ttl = 0; |
4250 | ||
4251 | if (argc == 2) | |
4252 | VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); | |
718e3744 | 4253 | |
4254 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4255 | if (! ret) | |
4256 | { | |
4257 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4258 | return CMD_WARNING; | |
4259 | } | |
4260 | ||
41367172 PJ |
4261 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
4262 | NULL, 1, ttl); | |
718e3744 | 4263 | } |
4264 | ||
41367172 PJ |
4265 | ALIAS (bgp_network_mask_natural_backdoor, |
4266 | bgp_network_mask_natural_backdoor_ttl_cmd, | |
4267 | "network A.B.C.D backdoor pathlimit (1-255>", | |
4268 | "Specify a network to announce via BGP\n" | |
4269 | "Network number\n" | |
4270 | "Specify a BGP backdoor route\n" | |
4271 | "AS-Path hopcount limit attribute\n" | |
4272 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4273 | ||
718e3744 | 4274 | DEFUN (no_bgp_network, |
4275 | no_bgp_network_cmd, | |
4276 | "no network A.B.C.D/M", | |
4277 | NO_STR | |
4278 | "Specify a network to announce via BGP\n" | |
4279 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
4280 | { | |
4281 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, | |
4282 | bgp_node_safi (vty)); | |
4283 | } | |
4284 | ||
41367172 PJ |
4285 | ALIAS (no_bgp_network, |
4286 | no_bgp_network_ttl_cmd, | |
4287 | "no network A.B.C.D/M pathlimit <0-255>", | |
4288 | NO_STR | |
4289 | "Specify a network to announce via BGP\n" | |
4290 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4291 | "AS-Path hopcount limit attribute\n" | |
4292 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4293 | ||
718e3744 | 4294 | ALIAS (no_bgp_network, |
4295 | no_bgp_network_route_map_cmd, | |
4296 | "no network A.B.C.D/M route-map WORD", | |
4297 | NO_STR | |
4298 | "Specify a network to announce via BGP\n" | |
4299 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4300 | "Route-map to modify the attributes\n" | |
4301 | "Name of the route map\n") | |
4302 | ||
4303 | ALIAS (no_bgp_network, | |
4304 | no_bgp_network_backdoor_cmd, | |
4305 | "no network A.B.C.D/M backdoor", | |
4306 | NO_STR | |
4307 | "Specify a network to announce via BGP\n" | |
4308 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4309 | "Specify a BGP backdoor route\n") | |
4310 | ||
41367172 PJ |
4311 | ALIAS (no_bgp_network, |
4312 | no_bgp_network_backdoor_ttl_cmd, | |
4313 | "no network A.B.C.D/M backdoor pathlimit <0-255>", | |
4314 | NO_STR | |
4315 | "Specify a network to announce via BGP\n" | |
4316 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
4317 | "Specify a BGP backdoor route\n" | |
4318 | "AS-Path hopcount limit attribute\n" | |
4319 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4320 | ||
718e3744 | 4321 | DEFUN (no_bgp_network_mask, |
4322 | no_bgp_network_mask_cmd, | |
4323 | "no network A.B.C.D mask A.B.C.D", | |
4324 | NO_STR | |
4325 | "Specify a network to announce via BGP\n" | |
4326 | "Network number\n" | |
4327 | "Network mask\n" | |
4328 | "Network mask\n") | |
4329 | { | |
4330 | int ret; | |
4331 | char prefix_str[BUFSIZ]; | |
4332 | ||
4333 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
4334 | if (! ret) | |
4335 | { | |
4336 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4337 | return CMD_WARNING; | |
4338 | } | |
4339 | ||
4340 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4341 | bgp_node_safi (vty)); | |
4342 | } | |
4343 | ||
41367172 PJ |
4344 | ALIAS (no_bgp_network, |
4345 | no_bgp_network_mask_ttl_cmd, | |
4346 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", | |
4347 | NO_STR | |
4348 | "Specify a network to announce via BGP\n" | |
4349 | "Network number\n" | |
4350 | "Network mask\n" | |
4351 | "Network mask\n" | |
4352 | "AS-Path hopcount limit attribute\n" | |
4353 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4354 | ||
718e3744 | 4355 | ALIAS (no_bgp_network_mask, |
4356 | no_bgp_network_mask_route_map_cmd, | |
4357 | "no network A.B.C.D mask A.B.C.D route-map WORD", | |
4358 | NO_STR | |
4359 | "Specify a network to announce via BGP\n" | |
4360 | "Network number\n" | |
4361 | "Network mask\n" | |
4362 | "Network mask\n" | |
4363 | "Route-map to modify the attributes\n" | |
4364 | "Name of the route map\n") | |
4365 | ||
4366 | ALIAS (no_bgp_network_mask, | |
4367 | no_bgp_network_mask_backdoor_cmd, | |
4368 | "no network A.B.C.D mask A.B.C.D backdoor", | |
4369 | NO_STR | |
4370 | "Specify a network to announce via BGP\n" | |
4371 | "Network number\n" | |
4372 | "Network mask\n" | |
4373 | "Network mask\n" | |
4374 | "Specify a BGP backdoor route\n") | |
4375 | ||
41367172 PJ |
4376 | ALIAS (no_bgp_network_mask, |
4377 | no_bgp_network_mask_backdoor_ttl_cmd, | |
4378 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", | |
4379 | NO_STR | |
4380 | "Specify a network to announce via BGP\n" | |
4381 | "Network number\n" | |
4382 | "Network mask\n" | |
4383 | "Network mask\n" | |
4384 | "Specify a BGP backdoor route\n" | |
4385 | "AS-Path hopcount limit attribute\n" | |
4386 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4387 | ||
718e3744 | 4388 | DEFUN (no_bgp_network_mask_natural, |
4389 | no_bgp_network_mask_natural_cmd, | |
4390 | "no network A.B.C.D", | |
4391 | NO_STR | |
4392 | "Specify a network to announce via BGP\n" | |
4393 | "Network number\n") | |
4394 | { | |
4395 | int ret; | |
4396 | char prefix_str[BUFSIZ]; | |
4397 | ||
4398 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); | |
4399 | if (! ret) | |
4400 | { | |
4401 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
4402 | return CMD_WARNING; | |
4403 | } | |
4404 | ||
4405 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, | |
4406 | bgp_node_safi (vty)); | |
4407 | } | |
4408 | ||
4409 | ALIAS (no_bgp_network_mask_natural, | |
4410 | no_bgp_network_mask_natural_route_map_cmd, | |
4411 | "no network A.B.C.D route-map WORD", | |
4412 | NO_STR | |
4413 | "Specify a network to announce via BGP\n" | |
4414 | "Network number\n" | |
4415 | "Route-map to modify the attributes\n" | |
4416 | "Name of the route map\n") | |
4417 | ||
4418 | ALIAS (no_bgp_network_mask_natural, | |
4419 | no_bgp_network_mask_natural_backdoor_cmd, | |
4420 | "no network A.B.C.D backdoor", | |
4421 | NO_STR | |
4422 | "Specify a network to announce via BGP\n" | |
4423 | "Network number\n" | |
4424 | "Specify a BGP backdoor route\n") | |
4425 | ||
41367172 PJ |
4426 | ALIAS (no_bgp_network_mask_natural, |
4427 | no_bgp_network_mask_natural_ttl_cmd, | |
4428 | "no network A.B.C.D pathlimit <0-255>", | |
4429 | NO_STR | |
4430 | "Specify a network to announce via BGP\n" | |
4431 | "Network number\n" | |
4432 | "AS-Path hopcount limit attribute\n" | |
4433 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4434 | ||
4435 | ALIAS (no_bgp_network_mask_natural, | |
4436 | no_bgp_network_mask_natural_backdoor_ttl_cmd, | |
4437 | "no network A.B.C.D backdoor pathlimit <0-255>", | |
4438 | NO_STR | |
4439 | "Specify a network to announce via BGP\n" | |
4440 | "Network number\n" | |
4441 | "Specify a BGP backdoor route\n" | |
4442 | "AS-Path hopcount limit attribute\n" | |
4443 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4444 | ||
718e3744 | 4445 | #ifdef HAVE_IPV6 |
4446 | DEFUN (ipv6_bgp_network, | |
4447 | ipv6_bgp_network_cmd, | |
4448 | "network X:X::X:X/M", | |
4449 | "Specify a network to announce via BGP\n" | |
4450 | "IPv6 prefix <network>/<length>\n") | |
4451 | { | |
41367172 PJ |
4452 | u_char ttl = 0; |
4453 | ||
4454 | if (argc == 2) | |
4455 | VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); | |
4456 | ||
4457 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, | |
4458 | NULL, 0, ttl); | |
718e3744 | 4459 | } |
4460 | ||
41367172 PJ |
4461 | ALIAS (ipv6_bgp_network, |
4462 | ipv6_bgp_network_ttl_cmd, | |
4463 | "network X:X::X:X/M pathlimit <0-255>", | |
4464 | "Specify a network to announce via BGP\n" | |
4465 | "IPv6 prefix <network>/<length>\n" | |
4466 | "AS-Path hopcount limit attribute\n" | |
4467 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4468 | ||
718e3744 | 4469 | DEFUN (ipv6_bgp_network_route_map, |
4470 | ipv6_bgp_network_route_map_cmd, | |
4471 | "network X:X::X:X/M route-map WORD", | |
4472 | "Specify a network to announce via BGP\n" | |
4473 | "IPv6 prefix <network>/<length>\n" | |
4474 | "Route-map to modify the attributes\n" | |
4475 | "Name of the route map\n") | |
4476 | { | |
4477 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, | |
41367172 | 4478 | bgp_node_safi (vty), argv[1], 0, 0); |
718e3744 | 4479 | } |
4480 | ||
4481 | DEFUN (no_ipv6_bgp_network, | |
4482 | no_ipv6_bgp_network_cmd, | |
4483 | "no network X:X::X:X/M", | |
4484 | NO_STR | |
4485 | "Specify a network to announce via BGP\n" | |
4486 | "IPv6 prefix <network>/<length>\n") | |
4487 | { | |
4488 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); | |
4489 | } | |
4490 | ||
4491 | ALIAS (no_ipv6_bgp_network, | |
4492 | no_ipv6_bgp_network_route_map_cmd, | |
4493 | "no network X:X::X:X/M route-map WORD", | |
4494 | NO_STR | |
4495 | "Specify a network to announce via BGP\n" | |
4496 | "IPv6 prefix <network>/<length>\n" | |
4497 | "Route-map to modify the attributes\n" | |
4498 | "Name of the route map\n") | |
4499 | ||
41367172 PJ |
4500 | ALIAS (no_ipv6_bgp_network, |
4501 | no_ipv6_bgp_network_ttl_cmd, | |
4502 | "no network X:X::X:X/M pathlimit <0-255>", | |
4503 | NO_STR | |
4504 | "Specify a network to announce via BGP\n" | |
4505 | "IPv6 prefix <network>/<length>\n" | |
4506 | "AS-Path hopcount limit attribute\n" | |
4507 | "AS-Pathlimit TTL, in number of AS-Path hops\n") | |
4508 | ||
718e3744 | 4509 | ALIAS (ipv6_bgp_network, |
4510 | old_ipv6_bgp_network_cmd, | |
4511 | "ipv6 bgp network X:X::X:X/M", | |
4512 | IPV6_STR | |
4513 | BGP_STR | |
4514 | "Specify a network to announce via BGP\n" | |
4515 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4516 | ||
4517 | ALIAS (no_ipv6_bgp_network, | |
4518 | old_no_ipv6_bgp_network_cmd, | |
4519 | "no ipv6 bgp network X:X::X:X/M", | |
4520 | NO_STR | |
4521 | IPV6_STR | |
4522 | BGP_STR | |
4523 | "Specify a network to announce via BGP\n" | |
4524 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
4525 | #endif /* HAVE_IPV6 */ | |
4526 | \f | |
4527 | /* Aggreagete address: | |
4528 | ||
4529 | advertise-map Set condition to advertise attribute | |
4530 | as-set Generate AS set path information | |
4531 | attribute-map Set attributes of aggregate | |
4532 | route-map Set parameters of aggregate | |
4533 | summary-only Filter more specific routes from updates | |
4534 | suppress-map Conditionally filter more specific routes from updates | |
4535 | <cr> | |
4536 | */ | |
4537 | struct bgp_aggregate | |
4538 | { | |
4539 | /* Summary-only flag. */ | |
4540 | u_char summary_only; | |
4541 | ||
4542 | /* AS set generation. */ | |
4543 | u_char as_set; | |
4544 | ||
4545 | /* Route-map for aggregated route. */ | |
4546 | struct route_map *map; | |
4547 | ||
4548 | /* Suppress-count. */ | |
4549 | unsigned long count; | |
4550 | ||
4551 | /* SAFI configuration. */ | |
4552 | safi_t safi; | |
4553 | }; | |
4554 | ||
94f2b392 | 4555 | static struct bgp_aggregate * |
66e5cd87 | 4556 | bgp_aggregate_new (void) |
718e3744 | 4557 | { |
393deb9b | 4558 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
718e3744 | 4559 | } |
4560 | ||
94f2b392 | 4561 | static void |
718e3744 | 4562 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
4563 | { | |
4564 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); | |
4565 | } | |
4566 | ||
94f2b392 | 4567 | static void |
718e3744 | 4568 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
4569 | afi_t afi, safi_t safi, struct bgp_info *del, | |
4570 | struct bgp_aggregate *aggregate) | |
4571 | { | |
4572 | struct bgp_table *table; | |
4573 | struct bgp_node *top; | |
4574 | struct bgp_node *rn; | |
4575 | u_char origin; | |
4576 | struct aspath *aspath = NULL; | |
4577 | struct aspath *asmerge = NULL; | |
4578 | struct community *community = NULL; | |
4579 | struct community *commerge = NULL; | |
4580 | struct in_addr nexthop; | |
4581 | u_int32_t med = 0; | |
4582 | struct bgp_info *ri; | |
4583 | struct bgp_info *new; | |
4584 | int first = 1; | |
4585 | unsigned long match = 0; | |
4586 | ||
4587 | /* Record adding route's nexthop and med. */ | |
4588 | if (rinew) | |
4589 | { | |
4590 | nexthop = rinew->attr->nexthop; | |
4591 | med = rinew->attr->med; | |
4592 | } | |
4593 | ||
4594 | /* ORIGIN attribute: If at least one route among routes that are | |
4595 | aggregated has ORIGIN with the value INCOMPLETE, then the | |
4596 | aggregated route must have the ORIGIN attribute with the value | |
4597 | INCOMPLETE. Otherwise, if at least one route among routes that | |
4598 | are aggregated has ORIGIN with the value EGP, then the aggregated | |
4599 | route must have the origin attribute with the value EGP. In all | |
4600 | other case the value of the ORIGIN attribute of the aggregated | |
4601 | route is INTERNAL. */ | |
4602 | origin = BGP_ORIGIN_IGP; | |
4603 | ||
4604 | table = bgp->rib[afi][safi]; | |
4605 | ||
4606 | top = bgp_node_get (table, p); | |
4607 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4608 | if (rn->p.prefixlen > p->prefixlen) | |
4609 | { | |
4610 | match = 0; | |
4611 | ||
4612 | for (ri = rn->info; ri; ri = ri->next) | |
4613 | { | |
4614 | if (BGP_INFO_HOLDDOWN (ri)) | |
4615 | continue; | |
4616 | ||
4617 | if (del && ri == del) | |
4618 | continue; | |
4619 | ||
4620 | if (! rinew && first) | |
4621 | { | |
4622 | nexthop = ri->attr->nexthop; | |
4623 | med = ri->attr->med; | |
4624 | first = 0; | |
4625 | } | |
4626 | ||
4627 | #ifdef AGGREGATE_NEXTHOP_CHECK | |
4628 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) | |
4629 | || ri->attr->med != med) | |
4630 | { | |
4631 | if (aspath) | |
4632 | aspath_free (aspath); | |
4633 | if (community) | |
4634 | community_free (community); | |
4635 | bgp_unlock_node (rn); | |
4636 | bgp_unlock_node (top); | |
4637 | return; | |
4638 | } | |
4639 | #endif /* AGGREGATE_NEXTHOP_CHECK */ | |
4640 | ||
4641 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4642 | { | |
4643 | if (aggregate->summary_only) | |
4644 | { | |
fb982c25 | 4645 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4646 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4647 | match++; |
4648 | } | |
4649 | ||
4650 | aggregate->count++; | |
4651 | ||
4652 | if (aggregate->as_set) | |
4653 | { | |
4654 | if (origin < ri->attr->origin) | |
4655 | origin = ri->attr->origin; | |
4656 | ||
4657 | if (aspath) | |
4658 | { | |
4659 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4660 | aspath_free (aspath); | |
4661 | aspath = asmerge; | |
4662 | } | |
4663 | else | |
4664 | aspath = aspath_dup (ri->attr->aspath); | |
4665 | ||
4666 | if (ri->attr->community) | |
4667 | { | |
4668 | if (community) | |
4669 | { | |
4670 | commerge = community_merge (community, | |
4671 | ri->attr->community); | |
4672 | community = community_uniq_sort (commerge); | |
4673 | community_free (commerge); | |
4674 | } | |
4675 | else | |
4676 | community = community_dup (ri->attr->community); | |
4677 | } | |
4678 | } | |
4679 | } | |
4680 | } | |
4681 | if (match) | |
4682 | bgp_process (bgp, rn, afi, safi); | |
4683 | } | |
4684 | bgp_unlock_node (top); | |
4685 | ||
4686 | if (rinew) | |
4687 | { | |
4688 | aggregate->count++; | |
4689 | ||
4690 | if (aggregate->summary_only) | |
fb982c25 | 4691 | (bgp_info_extra_get (rinew))->suppress++; |
718e3744 | 4692 | |
4693 | if (aggregate->as_set) | |
4694 | { | |
4695 | if (origin < rinew->attr->origin) | |
4696 | origin = rinew->attr->origin; | |
4697 | ||
4698 | if (aspath) | |
4699 | { | |
4700 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); | |
4701 | aspath_free (aspath); | |
4702 | aspath = asmerge; | |
4703 | } | |
4704 | else | |
4705 | aspath = aspath_dup (rinew->attr->aspath); | |
4706 | ||
4707 | if (rinew->attr->community) | |
4708 | { | |
4709 | if (community) | |
4710 | { | |
4711 | commerge = community_merge (community, | |
4712 | rinew->attr->community); | |
4713 | community = community_uniq_sort (commerge); | |
4714 | community_free (commerge); | |
4715 | } | |
4716 | else | |
4717 | community = community_dup (rinew->attr->community); | |
4718 | } | |
4719 | } | |
4720 | } | |
4721 | ||
4722 | if (aggregate->count > 0) | |
4723 | { | |
4724 | rn = bgp_node_get (table, p); | |
4725 | new = bgp_info_new (); | |
4726 | new->type = ZEBRA_ROUTE_BGP; | |
4727 | new->sub_type = BGP_ROUTE_AGGREGATE; | |
4728 | new->peer = bgp->peer_self; | |
4729 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
4730 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); | |
65957886 | 4731 | new->uptime = bgp_clock (); |
718e3744 | 4732 | |
4733 | bgp_info_add (rn, new); | |
200df115 | 4734 | bgp_unlock_node (rn); |
718e3744 | 4735 | bgp_process (bgp, rn, afi, safi); |
4736 | } | |
4737 | else | |
4738 | { | |
4739 | if (aspath) | |
4740 | aspath_free (aspath); | |
4741 | if (community) | |
4742 | community_free (community); | |
4743 | } | |
4744 | } | |
4745 | ||
4746 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, | |
4747 | struct bgp_aggregate *); | |
4748 | ||
4749 | void | |
4750 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, | |
4751 | struct bgp_info *ri, afi_t afi, safi_t safi) | |
4752 | { | |
4753 | struct bgp_node *child; | |
4754 | struct bgp_node *rn; | |
4755 | struct bgp_aggregate *aggregate; | |
4756 | ||
4757 | /* MPLS-VPN aggregation is not yet supported. */ | |
4758 | if (safi == SAFI_MPLS_VPN) | |
4759 | return; | |
4760 | ||
4761 | if (p->prefixlen == 0) | |
4762 | return; | |
4763 | ||
4764 | if (BGP_INFO_HOLDDOWN (ri)) | |
4765 | return; | |
4766 | ||
4767 | child = bgp_node_get (bgp->aggregate[afi][safi], p); | |
4768 | ||
4769 | /* Aggregate address configuration check. */ | |
4770 | for (rn = child; rn; rn = rn->parent) | |
4771 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) | |
4772 | { | |
4773 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4774 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
718e3744 | 4775 | } |
4776 | bgp_unlock_node (child); | |
4777 | } | |
4778 | ||
4779 | void | |
4780 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, | |
4781 | struct bgp_info *del, afi_t afi, safi_t safi) | |
4782 | { | |
4783 | struct bgp_node *child; | |
4784 | struct bgp_node *rn; | |
4785 | struct bgp_aggregate *aggregate; | |
4786 | ||
4787 | /* MPLS-VPN aggregation is not yet supported. */ | |
4788 | if (safi == SAFI_MPLS_VPN) | |
4789 | return; | |
4790 | ||
4791 | if (p->prefixlen == 0) | |
4792 | return; | |
4793 | ||
4794 | child = bgp_node_get (bgp->aggregate[afi][safi], p); | |
4795 | ||
4796 | /* Aggregate address configuration check. */ | |
4797 | for (rn = child; rn; rn = rn->parent) | |
4798 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) | |
4799 | { | |
4800 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); | |
286e1e71 | 4801 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
718e3744 | 4802 | } |
4803 | bgp_unlock_node (child); | |
4804 | } | |
4805 | ||
94f2b392 | 4806 | static void |
718e3744 | 4807 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
4808 | struct bgp_aggregate *aggregate) | |
4809 | { | |
4810 | struct bgp_table *table; | |
4811 | struct bgp_node *top; | |
4812 | struct bgp_node *rn; | |
4813 | struct bgp_info *new; | |
4814 | struct bgp_info *ri; | |
4815 | unsigned long match; | |
4816 | u_char origin = BGP_ORIGIN_IGP; | |
4817 | struct aspath *aspath = NULL; | |
4818 | struct aspath *asmerge = NULL; | |
4819 | struct community *community = NULL; | |
4820 | struct community *commerge = NULL; | |
4821 | ||
4822 | table = bgp->rib[afi][safi]; | |
4823 | ||
4824 | /* Sanity check. */ | |
4825 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4826 | return; | |
4827 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4828 | return; | |
4829 | ||
4830 | /* If routes exists below this node, generate aggregate routes. */ | |
4831 | top = bgp_node_get (table, p); | |
4832 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4833 | if (rn->p.prefixlen > p->prefixlen) | |
4834 | { | |
4835 | match = 0; | |
4836 | ||
4837 | for (ri = rn->info; ri; ri = ri->next) | |
4838 | { | |
4839 | if (BGP_INFO_HOLDDOWN (ri)) | |
4840 | continue; | |
4841 | ||
4842 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4843 | { | |
4844 | /* summary-only aggregate route suppress aggregated | |
4845 | route announcement. */ | |
4846 | if (aggregate->summary_only) | |
4847 | { | |
fb982c25 | 4848 | (bgp_info_extra_get (ri))->suppress++; |
1a392d46 | 4849 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4850 | match++; |
4851 | } | |
4852 | /* as-set aggregate route generate origin, as path, | |
4853 | community aggregation. */ | |
4854 | if (aggregate->as_set) | |
4855 | { | |
4856 | if (origin < ri->attr->origin) | |
4857 | origin = ri->attr->origin; | |
4858 | ||
4859 | if (aspath) | |
4860 | { | |
4861 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); | |
4862 | aspath_free (aspath); | |
4863 | aspath = asmerge; | |
4864 | } | |
4865 | else | |
4866 | aspath = aspath_dup (ri->attr->aspath); | |
4867 | ||
4868 | if (ri->attr->community) | |
4869 | { | |
4870 | if (community) | |
4871 | { | |
4872 | commerge = community_merge (community, | |
4873 | ri->attr->community); | |
4874 | community = community_uniq_sort (commerge); | |
4875 | community_free (commerge); | |
4876 | } | |
4877 | else | |
4878 | community = community_dup (ri->attr->community); | |
4879 | } | |
4880 | } | |
4881 | aggregate->count++; | |
4882 | } | |
4883 | } | |
4884 | ||
4885 | /* If this node is suppressed, process the change. */ | |
4886 | if (match) | |
4887 | bgp_process (bgp, rn, afi, safi); | |
4888 | } | |
4889 | bgp_unlock_node (top); | |
4890 | ||
4891 | /* Add aggregate route to BGP table. */ | |
4892 | if (aggregate->count) | |
4893 | { | |
4894 | rn = bgp_node_get (table, p); | |
4895 | ||
4896 | new = bgp_info_new (); | |
4897 | new->type = ZEBRA_ROUTE_BGP; | |
4898 | new->sub_type = BGP_ROUTE_AGGREGATE; | |
4899 | new->peer = bgp->peer_self; | |
4900 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
4901 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); | |
65957886 | 4902 | new->uptime = bgp_clock (); |
718e3744 | 4903 | |
4904 | bgp_info_add (rn, new); | |
200df115 | 4905 | bgp_unlock_node (rn); |
4906 | ||
718e3744 | 4907 | /* Process change. */ |
4908 | bgp_process (bgp, rn, afi, safi); | |
4909 | } | |
4910 | } | |
4911 | ||
4912 | void | |
4913 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, | |
4914 | safi_t safi, struct bgp_aggregate *aggregate) | |
4915 | { | |
4916 | struct bgp_table *table; | |
4917 | struct bgp_node *top; | |
4918 | struct bgp_node *rn; | |
4919 | struct bgp_info *ri; | |
4920 | unsigned long match; | |
4921 | ||
4922 | table = bgp->rib[afi][safi]; | |
4923 | ||
4924 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) | |
4925 | return; | |
4926 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) | |
4927 | return; | |
4928 | ||
4929 | /* If routes exists below this node, generate aggregate routes. */ | |
4930 | top = bgp_node_get (table, p); | |
4931 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) | |
4932 | if (rn->p.prefixlen > p->prefixlen) | |
4933 | { | |
4934 | match = 0; | |
4935 | ||
4936 | for (ri = rn->info; ri; ri = ri->next) | |
4937 | { | |
4938 | if (BGP_INFO_HOLDDOWN (ri)) | |
4939 | continue; | |
4940 | ||
4941 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) | |
4942 | { | |
fb982c25 | 4943 | if (aggregate->summary_only && ri->extra) |
718e3744 | 4944 | { |
fb982c25 | 4945 | ri->extra->suppress--; |
718e3744 | 4946 | |
fb982c25 | 4947 | if (ri->extra->suppress == 0) |
718e3744 | 4948 | { |
1a392d46 | 4949 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
718e3744 | 4950 | match++; |
4951 | } | |
4952 | } | |
4953 | aggregate->count--; | |
4954 | } | |
4955 | } | |
4956 | ||
fb982c25 | 4957 | /* If this node was suppressed, process the change. */ |
718e3744 | 4958 | if (match) |
4959 | bgp_process (bgp, rn, afi, safi); | |
4960 | } | |
4961 | bgp_unlock_node (top); | |
4962 | ||
4963 | /* Delete aggregate route from BGP table. */ | |
4964 | rn = bgp_node_get (table, p); | |
4965 | ||
4966 | for (ri = rn->info; ri; ri = ri->next) | |
4967 | if (ri->peer == bgp->peer_self | |
4968 | && ri->type == ZEBRA_ROUTE_BGP | |
4969 | && ri->sub_type == BGP_ROUTE_AGGREGATE) | |
4970 | break; | |
4971 | ||
4972 | /* Withdraw static BGP route from routing table. */ | |
4973 | if (ri) | |
4974 | { | |
718e3744 | 4975 | bgp_info_delete (rn, ri); |
1a392d46 | 4976 | bgp_process (bgp, rn, afi, safi); |
718e3744 | 4977 | } |
4978 | ||
4979 | /* Unlock bgp_node_lookup. */ | |
4980 | bgp_unlock_node (rn); | |
4981 | } | |
4982 | ||
4983 | /* Aggregate route attribute. */ | |
4984 | #define AGGREGATE_SUMMARY_ONLY 1 | |
4985 | #define AGGREGATE_AS_SET 1 | |
4986 | ||
94f2b392 | 4987 | static int |
fd79ac91 | 4988 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
4989 | afi_t afi, safi_t safi, | |
718e3744 | 4990 | u_char summary_only, u_char as_set) |
4991 | { | |
4992 | int ret; | |
4993 | struct prefix p; | |
4994 | struct bgp_node *rn; | |
4995 | struct bgp *bgp; | |
4996 | struct bgp_aggregate *aggregate; | |
4997 | ||
4998 | /* Convert string to prefix structure. */ | |
4999 | ret = str2prefix (prefix_str, &p); | |
5000 | if (!ret) | |
5001 | { | |
5002 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
5003 | return CMD_WARNING; | |
5004 | } | |
5005 | apply_mask (&p); | |
5006 | ||
5007 | /* Get BGP structure. */ | |
5008 | bgp = vty->index; | |
5009 | ||
5010 | /* Old configuration check. */ | |
5011 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); | |
5012 | ||
5013 | if (rn->info) | |
5014 | { | |
5015 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); | |
5016 | bgp_unlock_node (rn); | |
5017 | return CMD_WARNING; | |
5018 | } | |
5019 | ||
5020 | /* Make aggregate address structure. */ | |
5021 | aggregate = bgp_aggregate_new (); | |
5022 | aggregate->summary_only = summary_only; | |
5023 | aggregate->as_set = as_set; | |
5024 | aggregate->safi = safi; | |
5025 | rn->info = aggregate; | |
5026 | ||
5027 | /* Aggregate address insert into BGP routing table. */ | |
5028 | if (safi & SAFI_UNICAST) | |
5029 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
5030 | if (safi & SAFI_MULTICAST) | |
5031 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
5032 | ||
5033 | return CMD_SUCCESS; | |
5034 | } | |
5035 | ||
94f2b392 | 5036 | static int |
fd79ac91 | 5037 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
5038 | afi_t afi, safi_t safi) | |
718e3744 | 5039 | { |
5040 | int ret; | |
5041 | struct prefix p; | |
5042 | struct bgp_node *rn; | |
5043 | struct bgp *bgp; | |
5044 | struct bgp_aggregate *aggregate; | |
5045 | ||
5046 | /* Convert string to prefix structure. */ | |
5047 | ret = str2prefix (prefix_str, &p); | |
5048 | if (!ret) | |
5049 | { | |
5050 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
5051 | return CMD_WARNING; | |
5052 | } | |
5053 | apply_mask (&p); | |
5054 | ||
5055 | /* Get BGP structure. */ | |
5056 | bgp = vty->index; | |
5057 | ||
5058 | /* Old configuration check. */ | |
5059 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); | |
5060 | if (! rn) | |
5061 | { | |
5062 | vty_out (vty, "%% There is no aggregate-address configuration.%s", | |
5063 | VTY_NEWLINE); | |
5064 | return CMD_WARNING; | |
5065 | } | |
5066 | ||
5067 | aggregate = rn->info; | |
5068 | if (aggregate->safi & SAFI_UNICAST) | |
5069 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); | |
5070 | if (aggregate->safi & SAFI_MULTICAST) | |
5071 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); | |
5072 | ||
5073 | /* Unlock aggregate address configuration. */ | |
5074 | rn->info = NULL; | |
5075 | bgp_aggregate_free (aggregate); | |
5076 | bgp_unlock_node (rn); | |
5077 | bgp_unlock_node (rn); | |
5078 | ||
5079 | return CMD_SUCCESS; | |
5080 | } | |
5081 | ||
5082 | DEFUN (aggregate_address, | |
5083 | aggregate_address_cmd, | |
5084 | "aggregate-address A.B.C.D/M", | |
5085 | "Configure BGP aggregate entries\n" | |
5086 | "Aggregate prefix\n") | |
5087 | { | |
5088 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); | |
5089 | } | |
5090 | ||
5091 | DEFUN (aggregate_address_mask, | |
5092 | aggregate_address_mask_cmd, | |
5093 | "aggregate-address A.B.C.D A.B.C.D", | |
5094 | "Configure BGP aggregate entries\n" | |
5095 | "Aggregate address\n" | |
5096 | "Aggregate mask\n") | |
5097 | { | |
5098 | int ret; | |
5099 | char prefix_str[BUFSIZ]; | |
5100 | ||
5101 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5102 | ||
5103 | if (! ret) | |
5104 | { | |
5105 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5106 | return CMD_WARNING; | |
5107 | } | |
5108 | ||
5109 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5110 | 0, 0); | |
5111 | } | |
5112 | ||
5113 | DEFUN (aggregate_address_summary_only, | |
5114 | aggregate_address_summary_only_cmd, | |
5115 | "aggregate-address A.B.C.D/M summary-only", | |
5116 | "Configure BGP aggregate entries\n" | |
5117 | "Aggregate prefix\n" | |
5118 | "Filter more specific routes from updates\n") | |
5119 | { | |
5120 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5121 | AGGREGATE_SUMMARY_ONLY, 0); | |
5122 | } | |
5123 | ||
5124 | DEFUN (aggregate_address_mask_summary_only, | |
5125 | aggregate_address_mask_summary_only_cmd, | |
5126 | "aggregate-address A.B.C.D A.B.C.D summary-only", | |
5127 | "Configure BGP aggregate entries\n" | |
5128 | "Aggregate address\n" | |
5129 | "Aggregate mask\n" | |
5130 | "Filter more specific routes from updates\n") | |
5131 | { | |
5132 | int ret; | |
5133 | char prefix_str[BUFSIZ]; | |
5134 | ||
5135 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5136 | ||
5137 | if (! ret) | |
5138 | { | |
5139 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5140 | return CMD_WARNING; | |
5141 | } | |
5142 | ||
5143 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5144 | AGGREGATE_SUMMARY_ONLY, 0); | |
5145 | } | |
5146 | ||
5147 | DEFUN (aggregate_address_as_set, | |
5148 | aggregate_address_as_set_cmd, | |
5149 | "aggregate-address A.B.C.D/M as-set", | |
5150 | "Configure BGP aggregate entries\n" | |
5151 | "Aggregate prefix\n" | |
5152 | "Generate AS set path information\n") | |
5153 | { | |
5154 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5155 | 0, AGGREGATE_AS_SET); | |
5156 | } | |
5157 | ||
5158 | DEFUN (aggregate_address_mask_as_set, | |
5159 | aggregate_address_mask_as_set_cmd, | |
5160 | "aggregate-address A.B.C.D A.B.C.D as-set", | |
5161 | "Configure BGP aggregate entries\n" | |
5162 | "Aggregate address\n" | |
5163 | "Aggregate mask\n" | |
5164 | "Generate AS set path information\n") | |
5165 | { | |
5166 | int ret; | |
5167 | char prefix_str[BUFSIZ]; | |
5168 | ||
5169 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5170 | ||
5171 | if (! ret) | |
5172 | { | |
5173 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5174 | return CMD_WARNING; | |
5175 | } | |
5176 | ||
5177 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5178 | 0, AGGREGATE_AS_SET); | |
5179 | } | |
5180 | ||
5181 | ||
5182 | DEFUN (aggregate_address_as_set_summary, | |
5183 | aggregate_address_as_set_summary_cmd, | |
5184 | "aggregate-address A.B.C.D/M as-set summary-only", | |
5185 | "Configure BGP aggregate entries\n" | |
5186 | "Aggregate prefix\n" | |
5187 | "Generate AS set path information\n" | |
5188 | "Filter more specific routes from updates\n") | |
5189 | { | |
5190 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), | |
5191 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5192 | } | |
5193 | ||
5194 | ALIAS (aggregate_address_as_set_summary, | |
5195 | aggregate_address_summary_as_set_cmd, | |
5196 | "aggregate-address A.B.C.D/M summary-only as-set", | |
5197 | "Configure BGP aggregate entries\n" | |
5198 | "Aggregate prefix\n" | |
5199 | "Filter more specific routes from updates\n" | |
5200 | "Generate AS set path information\n") | |
5201 | ||
5202 | DEFUN (aggregate_address_mask_as_set_summary, | |
5203 | aggregate_address_mask_as_set_summary_cmd, | |
5204 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5205 | "Configure BGP aggregate entries\n" | |
5206 | "Aggregate address\n" | |
5207 | "Aggregate mask\n" | |
5208 | "Generate AS set path information\n" | |
5209 | "Filter more specific routes from updates\n") | |
5210 | { | |
5211 | int ret; | |
5212 | char prefix_str[BUFSIZ]; | |
5213 | ||
5214 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5215 | ||
5216 | if (! ret) | |
5217 | { | |
5218 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5219 | return CMD_WARNING; | |
5220 | } | |
5221 | ||
5222 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), | |
5223 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); | |
5224 | } | |
5225 | ||
5226 | ALIAS (aggregate_address_mask_as_set_summary, | |
5227 | aggregate_address_mask_summary_as_set_cmd, | |
5228 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5229 | "Configure BGP aggregate entries\n" | |
5230 | "Aggregate address\n" | |
5231 | "Aggregate mask\n" | |
5232 | "Filter more specific routes from updates\n" | |
5233 | "Generate AS set path information\n") | |
5234 | ||
5235 | DEFUN (no_aggregate_address, | |
5236 | no_aggregate_address_cmd, | |
5237 | "no aggregate-address A.B.C.D/M", | |
5238 | NO_STR | |
5239 | "Configure BGP aggregate entries\n" | |
5240 | "Aggregate prefix\n") | |
5241 | { | |
5242 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); | |
5243 | } | |
5244 | ||
5245 | ALIAS (no_aggregate_address, | |
5246 | no_aggregate_address_summary_only_cmd, | |
5247 | "no aggregate-address A.B.C.D/M summary-only", | |
5248 | NO_STR | |
5249 | "Configure BGP aggregate entries\n" | |
5250 | "Aggregate prefix\n" | |
5251 | "Filter more specific routes from updates\n") | |
5252 | ||
5253 | ALIAS (no_aggregate_address, | |
5254 | no_aggregate_address_as_set_cmd, | |
5255 | "no aggregate-address A.B.C.D/M as-set", | |
5256 | NO_STR | |
5257 | "Configure BGP aggregate entries\n" | |
5258 | "Aggregate prefix\n" | |
5259 | "Generate AS set path information\n") | |
5260 | ||
5261 | ALIAS (no_aggregate_address, | |
5262 | no_aggregate_address_as_set_summary_cmd, | |
5263 | "no aggregate-address A.B.C.D/M as-set summary-only", | |
5264 | NO_STR | |
5265 | "Configure BGP aggregate entries\n" | |
5266 | "Aggregate prefix\n" | |
5267 | "Generate AS set path information\n" | |
5268 | "Filter more specific routes from updates\n") | |
5269 | ||
5270 | ALIAS (no_aggregate_address, | |
5271 | no_aggregate_address_summary_as_set_cmd, | |
5272 | "no aggregate-address A.B.C.D/M summary-only as-set", | |
5273 | NO_STR | |
5274 | "Configure BGP aggregate entries\n" | |
5275 | "Aggregate prefix\n" | |
5276 | "Filter more specific routes from updates\n" | |
5277 | "Generate AS set path information\n") | |
5278 | ||
5279 | DEFUN (no_aggregate_address_mask, | |
5280 | no_aggregate_address_mask_cmd, | |
5281 | "no aggregate-address A.B.C.D A.B.C.D", | |
5282 | NO_STR | |
5283 | "Configure BGP aggregate entries\n" | |
5284 | "Aggregate address\n" | |
5285 | "Aggregate mask\n") | |
5286 | { | |
5287 | int ret; | |
5288 | char prefix_str[BUFSIZ]; | |
5289 | ||
5290 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
5291 | ||
5292 | if (! ret) | |
5293 | { | |
5294 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
5295 | return CMD_WARNING; | |
5296 | } | |
5297 | ||
5298 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); | |
5299 | } | |
5300 | ||
5301 | ALIAS (no_aggregate_address_mask, | |
5302 | no_aggregate_address_mask_summary_only_cmd, | |
5303 | "no aggregate-address A.B.C.D A.B.C.D summary-only", | |
5304 | NO_STR | |
5305 | "Configure BGP aggregate entries\n" | |
5306 | "Aggregate address\n" | |
5307 | "Aggregate mask\n" | |
5308 | "Filter more specific routes from updates\n") | |
5309 | ||
5310 | ALIAS (no_aggregate_address_mask, | |
5311 | no_aggregate_address_mask_as_set_cmd, | |
5312 | "no aggregate-address A.B.C.D A.B.C.D as-set", | |
5313 | NO_STR | |
5314 | "Configure BGP aggregate entries\n" | |
5315 | "Aggregate address\n" | |
5316 | "Aggregate mask\n" | |
5317 | "Generate AS set path information\n") | |
5318 | ||
5319 | ALIAS (no_aggregate_address_mask, | |
5320 | no_aggregate_address_mask_as_set_summary_cmd, | |
5321 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", | |
5322 | NO_STR | |
5323 | "Configure BGP aggregate entries\n" | |
5324 | "Aggregate address\n" | |
5325 | "Aggregate mask\n" | |
5326 | "Generate AS set path information\n" | |
5327 | "Filter more specific routes from updates\n") | |
5328 | ||
5329 | ALIAS (no_aggregate_address_mask, | |
5330 | no_aggregate_address_mask_summary_as_set_cmd, | |
5331 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", | |
5332 | NO_STR | |
5333 | "Configure BGP aggregate entries\n" | |
5334 | "Aggregate address\n" | |
5335 | "Aggregate mask\n" | |
5336 | "Filter more specific routes from updates\n" | |
5337 | "Generate AS set path information\n") | |
5338 | ||
5339 | #ifdef HAVE_IPV6 | |
5340 | DEFUN (ipv6_aggregate_address, | |
5341 | ipv6_aggregate_address_cmd, | |
5342 | "aggregate-address X:X::X:X/M", | |
5343 | "Configure BGP aggregate entries\n" | |
5344 | "Aggregate prefix\n") | |
5345 | { | |
5346 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); | |
5347 | } | |
5348 | ||
5349 | DEFUN (ipv6_aggregate_address_summary_only, | |
5350 | ipv6_aggregate_address_summary_only_cmd, | |
5351 | "aggregate-address X:X::X:X/M summary-only", | |
5352 | "Configure BGP aggregate entries\n" | |
5353 | "Aggregate prefix\n" | |
5354 | "Filter more specific routes from updates\n") | |
5355 | { | |
5356 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
5357 | AGGREGATE_SUMMARY_ONLY, 0); | |
5358 | } | |
5359 | ||
5360 | DEFUN (no_ipv6_aggregate_address, | |
5361 | no_ipv6_aggregate_address_cmd, | |
5362 | "no aggregate-address X:X::X:X/M", | |
5363 | NO_STR | |
5364 | "Configure BGP aggregate entries\n" | |
5365 | "Aggregate prefix\n") | |
5366 | { | |
5367 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5368 | } | |
5369 | ||
5370 | DEFUN (no_ipv6_aggregate_address_summary_only, | |
5371 | no_ipv6_aggregate_address_summary_only_cmd, | |
5372 | "no aggregate-address X:X::X:X/M summary-only", | |
5373 | NO_STR | |
5374 | "Configure BGP aggregate entries\n" | |
5375 | "Aggregate prefix\n" | |
5376 | "Filter more specific routes from updates\n") | |
5377 | { | |
5378 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); | |
5379 | } | |
5380 | ||
5381 | ALIAS (ipv6_aggregate_address, | |
5382 | old_ipv6_aggregate_address_cmd, | |
5383 | "ipv6 bgp aggregate-address X:X::X:X/M", | |
5384 | IPV6_STR | |
5385 | BGP_STR | |
5386 | "Configure BGP aggregate entries\n" | |
5387 | "Aggregate prefix\n") | |
5388 | ||
5389 | ALIAS (ipv6_aggregate_address_summary_only, | |
5390 | old_ipv6_aggregate_address_summary_only_cmd, | |
5391 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5392 | IPV6_STR | |
5393 | BGP_STR | |
5394 | "Configure BGP aggregate entries\n" | |
5395 | "Aggregate prefix\n" | |
5396 | "Filter more specific routes from updates\n") | |
5397 | ||
5398 | ALIAS (no_ipv6_aggregate_address, | |
5399 | old_no_ipv6_aggregate_address_cmd, | |
5400 | "no ipv6 bgp aggregate-address X:X::X:X/M", | |
5401 | NO_STR | |
5402 | IPV6_STR | |
5403 | BGP_STR | |
5404 | "Configure BGP aggregate entries\n" | |
5405 | "Aggregate prefix\n") | |
5406 | ||
5407 | ALIAS (no_ipv6_aggregate_address_summary_only, | |
5408 | old_no_ipv6_aggregate_address_summary_only_cmd, | |
5409 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", | |
5410 | NO_STR | |
5411 | IPV6_STR | |
5412 | BGP_STR | |
5413 | "Configure BGP aggregate entries\n" | |
5414 | "Aggregate prefix\n" | |
5415 | "Filter more specific routes from updates\n") | |
5416 | #endif /* HAVE_IPV6 */ | |
5417 | \f | |
5418 | /* Redistribute route treatment. */ | |
5419 | void | |
5420 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, | |
5421 | u_int32_t metric, u_char type) | |
5422 | { | |
5423 | struct bgp *bgp; | |
1eb8ef25 | 5424 | struct listnode *node, *nnode; |
718e3744 | 5425 | struct bgp_info *new; |
5426 | struct bgp_info *bi; | |
5427 | struct bgp_info info; | |
5428 | struct bgp_node *bn; | |
fb982c25 PJ |
5429 | struct attr attr = { 0 }; |
5430 | struct attr attr_new = { 0 }; | |
718e3744 | 5431 | struct attr *new_attr; |
5432 | afi_t afi; | |
5433 | int ret; | |
5434 | ||
5435 | /* Make default attribute. */ | |
5436 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); | |
5437 | if (nexthop) | |
5438 | attr.nexthop = *nexthop; | |
5439 | ||
5440 | attr.med = metric; | |
5441 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); | |
5442 | ||
1eb8ef25 | 5443 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 5444 | { |
5445 | afi = family2afi (p->family); | |
5446 | ||
5447 | if (bgp->redist[afi][type]) | |
5448 | { | |
5449 | /* Copy attribute for modification. */ | |
fb982c25 | 5450 | bgp_attr_dup (&attr_new, &attr); |
718e3744 | 5451 | |
5452 | if (bgp->redist_metric_flag[afi][type]) | |
5453 | attr_new.med = bgp->redist_metric[afi][type]; | |
5454 | ||
5455 | /* Apply route-map. */ | |
5456 | if (bgp->rmap[afi][type].map) | |
5457 | { | |
5458 | info.peer = bgp->peer_self; | |
5459 | info.attr = &attr_new; | |
5460 | ||
fee0f4c6 | 5461 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
5462 | ||
718e3744 | 5463 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
5464 | &info); | |
fee0f4c6 | 5465 | |
5466 | bgp->peer_self->rmap_type = 0; | |
5467 | ||
718e3744 | 5468 | if (ret == RMAP_DENYMATCH) |
5469 | { | |
5470 | /* Free uninterned attribute. */ | |
5471 | bgp_attr_flush (&attr_new); | |
fb982c25 PJ |
5472 | bgp_attr_extra_free (&attr_new); |
5473 | ||
718e3744 | 5474 | /* Unintern original. */ |
5475 | aspath_unintern (attr.aspath); | |
fb982c25 | 5476 | bgp_attr_extra_free (&attr); |
718e3744 | 5477 | bgp_redistribute_delete (p, type); |
5478 | return; | |
5479 | } | |
5480 | } | |
5481 | ||
fb982c25 PJ |
5482 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
5483 | afi, SAFI_UNICAST, p, NULL); | |
5484 | ||
718e3744 | 5485 | new_attr = bgp_attr_intern (&attr_new); |
fb982c25 PJ |
5486 | bgp_attr_extra_free (&attr_new); |
5487 | ||
718e3744 | 5488 | for (bi = bn->info; bi; bi = bi->next) |
5489 | if (bi->peer == bgp->peer_self | |
5490 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) | |
5491 | break; | |
5492 | ||
5493 | if (bi) | |
5494 | { | |
8d45210e AS |
5495 | if (attrhash_cmp (bi->attr, new_attr) && |
5496 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) | |
718e3744 | 5497 | { |
5498 | bgp_attr_unintern (new_attr); | |
5499 | aspath_unintern (attr.aspath); | |
fb982c25 | 5500 | bgp_attr_extra_free (&attr); |
718e3744 | 5501 | bgp_unlock_node (bn); |
5502 | return; | |
5503 | } | |
5504 | else | |
5505 | { | |
5506 | /* The attribute is changed. */ | |
1a392d46 | 5507 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
718e3744 | 5508 | |
5509 | /* Rewrite BGP route information. */ | |
8d45210e AS |
5510 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
5511 | bgp_info_restore(bn, bi); | |
5512 | else | |
5513 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); | |
718e3744 | 5514 | bgp_attr_unintern (bi->attr); |
5515 | bi->attr = new_attr; | |
65957886 | 5516 | bi->uptime = bgp_clock (); |
718e3744 | 5517 | |
5518 | /* Process change. */ | |
5519 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); | |
5520 | bgp_process (bgp, bn, afi, SAFI_UNICAST); | |
5521 | bgp_unlock_node (bn); | |
5522 | aspath_unintern (attr.aspath); | |
fb982c25 | 5523 | bgp_attr_extra_free (&attr); |
718e3744 | 5524 | return; |
5525 | } | |
5526 | } | |
5527 | ||
5528 | new = bgp_info_new (); | |
5529 | new->type = type; | |
5530 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; | |
5531 | new->peer = bgp->peer_self; | |
5532 | SET_FLAG (new->flags, BGP_INFO_VALID); | |
5533 | new->attr = new_attr; | |
65957886 | 5534 | new->uptime = bgp_clock (); |
718e3744 | 5535 | |
5536 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); | |
5537 | bgp_info_add (bn, new); | |
200df115 | 5538 | bgp_unlock_node (bn); |
718e3744 | 5539 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
5540 | } | |
5541 | } | |
5542 | ||
5543 | /* Unintern original. */ | |
5544 | aspath_unintern (attr.aspath); | |
fb982c25 | 5545 | bgp_attr_extra_free (&attr); |
718e3744 | 5546 | } |
5547 | ||
5548 | void | |
5549 | bgp_redistribute_delete (struct prefix *p, u_char type) | |
5550 | { | |
5551 | struct bgp *bgp; | |
1eb8ef25 | 5552 | struct listnode *node, *nnode; |
718e3744 | 5553 | afi_t afi; |
5554 | struct bgp_node *rn; | |
5555 | struct bgp_info *ri; | |
5556 | ||
1eb8ef25 | 5557 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
718e3744 | 5558 | { |
5559 | afi = family2afi (p->family); | |
5560 | ||
5561 | if (bgp->redist[afi][type]) | |
5562 | { | |
fee0f4c6 | 5563 | rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); |
718e3744 | 5564 | |
5565 | for (ri = rn->info; ri; ri = ri->next) | |
5566 | if (ri->peer == bgp->peer_self | |
5567 | && ri->type == type) | |
5568 | break; | |
5569 | ||
5570 | if (ri) | |
5571 | { | |
5572 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5573 | bgp_info_delete (rn, ri); |
1a392d46 | 5574 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5575 | } |
5576 | bgp_unlock_node (rn); | |
5577 | } | |
5578 | } | |
5579 | } | |
5580 | ||
5581 | /* Withdraw specified route type's route. */ | |
5582 | void | |
5583 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) | |
5584 | { | |
5585 | struct bgp_node *rn; | |
5586 | struct bgp_info *ri; | |
5587 | struct bgp_table *table; | |
5588 | ||
5589 | table = bgp->rib[afi][SAFI_UNICAST]; | |
5590 | ||
5591 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
5592 | { | |
5593 | for (ri = rn->info; ri; ri = ri->next) | |
5594 | if (ri->peer == bgp->peer_self | |
5595 | && ri->type == type) | |
5596 | break; | |
5597 | ||
5598 | if (ri) | |
5599 | { | |
5600 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); | |
718e3744 | 5601 | bgp_info_delete (rn, ri); |
1a392d46 | 5602 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
718e3744 | 5603 | } |
5604 | } | |
5605 | } | |
5606 | \f | |
5607 | /* Static function to display route. */ | |
94f2b392 | 5608 | static void |
718e3744 | 5609 | route_vty_out_route (struct prefix *p, struct vty *vty) |
5610 | { | |
5611 | int len; | |
5612 | u_int32_t destination; | |
5613 | char buf[BUFSIZ]; | |
5614 | ||
5615 | if (p->family == AF_INET) | |
5616 | { | |
5617 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); | |
5618 | destination = ntohl (p->u.prefix4.s_addr); | |
5619 | ||
5620 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
5621 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
5622 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
5623 | || p->u.prefix4.s_addr == 0) | |
5624 | { | |
5625 | /* When mask is natural, mask is not displayed. */ | |
5626 | } | |
5627 | else | |
5628 | len += vty_out (vty, "/%d", p->prefixlen); | |
5629 | } | |
5630 | else | |
5631 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), | |
5632 | p->prefixlen); | |
5633 | ||
5634 | len = 17 - len; | |
5635 | if (len < 1) | |
5636 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); | |
5637 | else | |
5638 | vty_out (vty, "%*s", len, " "); | |
5639 | } | |
5640 | ||
718e3744 | 5641 | enum bgp_display_type |
5642 | { | |
5643 | normal_list, | |
5644 | }; | |
5645 | ||
b40d939b | 5646 | /* Print the short form route status for a bgp_info */ |
5647 | static void | |
5648 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) | |
718e3744 | 5649 | { |
b40d939b | 5650 | /* Route status display. */ |
5651 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) | |
5652 | vty_out (vty, "R"); | |
5653 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) | |
93406d87 | 5654 | vty_out (vty, "S"); |
fb982c25 | 5655 | else if (binfo->extra && binfo->extra->suppress) |
718e3744 | 5656 | vty_out (vty, "s"); |
5657 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5658 | vty_out (vty, "*"); | |
5659 | else | |
5660 | vty_out (vty, " "); | |
5661 | ||
5662 | /* Selected */ | |
5663 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
5664 | vty_out (vty, "h"); | |
5665 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
5666 | vty_out (vty, "d"); | |
5667 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
5668 | vty_out (vty, ">"); | |
5669 | else | |
5670 | vty_out (vty, " "); | |
5671 | ||
5672 | /* Internal route. */ | |
5673 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) | |
5674 | vty_out (vty, "i"); | |
5675 | else | |
b40d939b | 5676 | vty_out (vty, " "); |
5677 | } | |
5678 | ||
5679 | /* called from terminal list command */ | |
5680 | void | |
5681 | route_vty_out (struct vty *vty, struct prefix *p, | |
5682 | struct bgp_info *binfo, int display, safi_t safi) | |
5683 | { | |
5684 | struct attr *attr; | |
5685 | ||
5686 | /* short status lead text */ | |
5687 | route_vty_short_status_out (vty, binfo); | |
718e3744 | 5688 | |
5689 | /* print prefix and mask */ | |
5690 | if (! display) | |
5691 | route_vty_out_route (p, vty); | |
5692 | else | |
5693 | vty_out (vty, "%*s", 17, " "); | |
5694 | ||
5695 | /* Print attribute */ | |
5696 | attr = binfo->attr; | |
5697 | if (attr) | |
5698 | { | |
5699 | if (p->family == AF_INET) | |
5700 | { | |
5701 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5702 | vty_out (vty, "%-16s", |
5703 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5704 | else |
5705 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5706 | } | |
5707 | #ifdef HAVE_IPV6 | |
5708 | else if (p->family == AF_INET6) | |
5709 | { | |
5710 | int len; | |
5711 | char buf[BUFSIZ]; | |
5712 | ||
5713 | len = vty_out (vty, "%s", | |
fb982c25 PJ |
5714 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5715 | buf, BUFSIZ)); | |
718e3744 | 5716 | len = 16 - len; |
5717 | if (len < 1) | |
5718 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5719 | else | |
5720 | vty_out (vty, "%*s", len, " "); | |
5721 | } | |
5722 | #endif /* HAVE_IPV6 */ | |
5723 | ||
5724 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
5725 | vty_out (vty, "%10d", attr->med); | |
5726 | else | |
5727 | vty_out (vty, " "); | |
5728 | ||
5729 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
5730 | vty_out (vty, "%7d", attr->local_pref); | |
5731 | else | |
5732 | vty_out (vty, " "); | |
5733 | ||
fb982c25 | 5734 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
718e3744 | 5735 | |
b2518c1e PJ |
5736 | /* Print aspath */ |
5737 | if (attr->aspath) | |
841f7a57 | 5738 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5739 | |
b2518c1e | 5740 | /* Print origin */ |
718e3744 | 5741 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
b2518c1e | 5742 | } |
718e3744 | 5743 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5744 | } |
5745 | ||
5746 | /* called from terminal list command */ | |
5747 | void | |
5748 | route_vty_out_tmp (struct vty *vty, struct prefix *p, | |
5749 | struct attr *attr, safi_t safi) | |
5750 | { | |
5751 | /* Route status display. */ | |
5752 | vty_out (vty, "*"); | |
5753 | vty_out (vty, ">"); | |
5754 | vty_out (vty, " "); | |
5755 | ||
5756 | /* print prefix and mask */ | |
5757 | route_vty_out_route (p, vty); | |
5758 | ||
5759 | /* Print attribute */ | |
5760 | if (attr) | |
5761 | { | |
5762 | if (p->family == AF_INET) | |
5763 | { | |
5764 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5765 | vty_out (vty, "%-16s", |
5766 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5767 | else |
5768 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5769 | } | |
5770 | #ifdef HAVE_IPV6 | |
5771 | else if (p->family == AF_INET6) | |
5772 | { | |
5773 | int len; | |
5774 | char buf[BUFSIZ]; | |
fb982c25 PJ |
5775 | |
5776 | assert (attr->extra); | |
718e3744 | 5777 | |
5778 | len = vty_out (vty, "%s", | |
fb982c25 PJ |
5779 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5780 | buf, BUFSIZ)); | |
718e3744 | 5781 | len = 16 - len; |
5782 | if (len < 1) | |
5783 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); | |
5784 | else | |
5785 | vty_out (vty, "%*s", len, " "); | |
5786 | } | |
5787 | #endif /* HAVE_IPV6 */ | |
5788 | ||
5789 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) | |
5790 | vty_out (vty, "%10d", attr->med); | |
5791 | else | |
5792 | vty_out (vty, " "); | |
5793 | ||
5794 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) | |
5795 | vty_out (vty, "%7d", attr->local_pref); | |
5796 | else | |
5797 | vty_out (vty, " "); | |
fb982c25 PJ |
5798 | |
5799 | vty_out (vty, "%7d ", (attr->extra ? attr->extra->weight : 0)); | |
5800 | ||
b2518c1e PJ |
5801 | /* Print aspath */ |
5802 | if (attr->aspath) | |
841f7a57 | 5803 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5804 | |
b2518c1e | 5805 | /* Print origin */ |
718e3744 | 5806 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
b2518c1e | 5807 | } |
718e3744 | 5808 | |
5809 | vty_out (vty, "%s", VTY_NEWLINE); | |
5810 | } | |
5811 | ||
5a646650 | 5812 | void |
718e3744 | 5813 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
5814 | struct bgp_info *binfo, int display, safi_t safi) | |
5815 | { | |
5816 | struct attr *attr; | |
718e3744 | 5817 | u_int32_t label = 0; |
fb982c25 PJ |
5818 | |
5819 | if (!binfo->extra) | |
5820 | return; | |
5821 | ||
b40d939b | 5822 | /* short status lead text */ |
5823 | route_vty_short_status_out (vty, binfo); | |
5824 | ||
718e3744 | 5825 | /* print prefix and mask */ |
5826 | if (! display) | |
5827 | route_vty_out_route (p, vty); | |
5828 | else | |
5829 | vty_out (vty, "%*s", 17, " "); | |
5830 | ||
5831 | /* Print attribute */ | |
5832 | attr = binfo->attr; | |
5833 | if (attr) | |
5834 | { | |
5835 | if (p->family == AF_INET) | |
5836 | { | |
5837 | if (safi == SAFI_MPLS_VPN) | |
fb982c25 PJ |
5838 | vty_out (vty, "%-16s", |
5839 | inet_ntoa (attr->extra->mp_nexthop_global_in)); | |
718e3744 | 5840 | else |
5841 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); | |
5842 | } | |
5843 | #ifdef HAVE_IPV6 | |
5844 | else if (p->family == AF_INET6) | |
5845 | { | |
fb982c25 | 5846 | assert (attr->extra); |
718e3744 | 5847 | char buf[BUFSIZ]; |
5848 | char buf1[BUFSIZ]; | |
fb982c25 | 5849 | if (attr->extra->mp_nexthop_len == 16) |
718e3744 | 5850 | vty_out (vty, "%s", |
fb982c25 PJ |
5851 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5852 | buf, BUFSIZ)); | |
5853 | else if (attr->extra->mp_nexthop_len == 32) | |
718e3744 | 5854 | vty_out (vty, "%s(%s)", |
fb982c25 PJ |
5855 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
5856 | buf, BUFSIZ), | |
5857 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, | |
5858 | buf1, BUFSIZ)); | |
718e3744 | 5859 | |
5860 | } | |
5861 | #endif /* HAVE_IPV6 */ | |
5862 | } | |
5863 | ||
fb982c25 | 5864 | label = decode_label (binfo->extra->tag); |
718e3744 | 5865 | |
5866 | vty_out (vty, "notag/%d", label); | |
5867 | ||
5868 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5869 | } |
5870 | ||
5871 | /* dampening route */ | |
5a646650 | 5872 | static void |
718e3744 | 5873 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
5874 | struct bgp_info *binfo, int display, safi_t safi) | |
5875 | { | |
5876 | struct attr *attr; | |
718e3744 | 5877 | int len; |
50aef6f3 | 5878 | char timebuf[BGP_UPTIME_LEN]; |
718e3744 | 5879 | |
b40d939b | 5880 | /* short status lead text */ |
5881 | route_vty_short_status_out (vty, binfo); | |
5882 | ||
718e3744 | 5883 | /* print prefix and mask */ |
5884 | if (! display) | |
5885 | route_vty_out_route (p, vty); | |
5886 | else | |
5887 | vty_out (vty, "%*s", 17, " "); | |
5888 | ||
5889 | len = vty_out (vty, "%s", binfo->peer->host); | |
5890 | len = 17 - len; | |
5891 | if (len < 1) | |
5892 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); | |
5893 | else | |
5894 | vty_out (vty, "%*s", len, " "); | |
5895 | ||
50aef6f3 | 5896 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
718e3744 | 5897 | |
5898 | /* Print attribute */ | |
5899 | attr = binfo->attr; | |
5900 | if (attr) | |
5901 | { | |
5902 | /* Print aspath */ | |
5903 | if (attr->aspath) | |
841f7a57 | 5904 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5905 | |
5906 | /* Print origin */ | |
b2518c1e | 5907 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
718e3744 | 5908 | } |
5909 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5910 | } |
5911 | ||
718e3744 | 5912 | /* flap route */ |
5a646650 | 5913 | static void |
718e3744 | 5914 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
5915 | struct bgp_info *binfo, int display, safi_t safi) | |
5916 | { | |
5917 | struct attr *attr; | |
5918 | struct bgp_damp_info *bdi; | |
718e3744 | 5919 | char timebuf[BGP_UPTIME_LEN]; |
5920 | int len; | |
fb982c25 PJ |
5921 | |
5922 | if (!binfo->extra) | |
5923 | return; | |
5924 | ||
5925 | bdi = binfo->extra->damp_info; | |
718e3744 | 5926 | |
b40d939b | 5927 | /* short status lead text */ |
5928 | route_vty_short_status_out (vty, binfo); | |
5929 | ||
718e3744 | 5930 | /* print prefix and mask */ |
5931 | if (! display) | |
5932 | route_vty_out_route (p, vty); | |
5933 | else | |
5934 | vty_out (vty, "%*s", 17, " "); | |
5935 | ||
5936 | len = vty_out (vty, "%s", binfo->peer->host); | |
5937 | len = 16 - len; | |
5938 | if (len < 1) | |
5939 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); | |
5940 | else | |
5941 | vty_out (vty, "%*s", len, " "); | |
5942 | ||
5943 | len = vty_out (vty, "%d", bdi->flap); | |
5944 | len = 5 - len; | |
5945 | if (len < 1) | |
5946 | vty_out (vty, " "); | |
5947 | else | |
5948 | vty_out (vty, "%*s ", len, " "); | |
5949 | ||
5950 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, | |
5951 | timebuf, BGP_UPTIME_LEN)); | |
5952 | ||
5953 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) | |
5954 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
50aef6f3 | 5955 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
718e3744 | 5956 | else |
5957 | vty_out (vty, "%*s ", 8, " "); | |
5958 | ||
5959 | /* Print attribute */ | |
5960 | attr = binfo->attr; | |
5961 | if (attr) | |
5962 | { | |
5963 | /* Print aspath */ | |
5964 | if (attr->aspath) | |
841f7a57 | 5965 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
718e3744 | 5966 | |
5967 | /* Print origin */ | |
b2518c1e | 5968 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
718e3744 | 5969 | } |
5970 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5971 | } |
5972 | ||
94f2b392 | 5973 | static void |
718e3744 | 5974 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
5975 | struct bgp_info *binfo, afi_t afi, safi_t safi) | |
5976 | { | |
5977 | char buf[INET6_ADDRSTRLEN]; | |
5978 | char buf1[BUFSIZ]; | |
5979 | struct attr *attr; | |
5980 | int sockunion_vty_out (struct vty *, union sockunion *); | |
30b00176 JK |
5981 | #ifdef HAVE_CLOCK_MONOTONIC |
5982 | time_t tbuf; | |
5983 | #endif | |
718e3744 | 5984 | |
5985 | attr = binfo->attr; | |
5986 | ||
5987 | if (attr) | |
5988 | { | |
5989 | /* Line1 display AS-path, Aggregator */ | |
5990 | if (attr->aspath) | |
5991 | { | |
5992 | vty_out (vty, " "); | |
fe69a505 | 5993 | if (aspath_count_hops (attr->aspath) == 0) |
718e3744 | 5994 | vty_out (vty, "Local"); |
5995 | else | |
841f7a57 | 5996 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
718e3744 | 5997 | } |
5998 | ||
b40d939b | 5999 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
6000 | vty_out (vty, ", (removed)"); | |
93406d87 | 6001 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
6002 | vty_out (vty, ", (stale)"); | |
6003 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) | |
aea339f7 | 6004 | vty_out (vty, ", (aggregated by %u %s)", |
fb982c25 PJ |
6005 | attr->extra->aggregator_as, |
6006 | inet_ntoa (attr->extra->aggregator_addr)); | |
93406d87 | 6007 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
6008 | vty_out (vty, ", (Received from a RR-client)"); | |
6009 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
6010 | vty_out (vty, ", (Received from a RS-client)"); | |
6011 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
6012 | vty_out (vty, ", (history entry)"); | |
6013 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) | |
6014 | vty_out (vty, ", (suppressed due to dampening)"); | |
718e3744 | 6015 | vty_out (vty, "%s", VTY_NEWLINE); |
6016 | ||
6017 | /* Line2 display Next-hop, Neighbor, Router-id */ | |
6018 | if (p->family == AF_INET) | |
6019 | { | |
6020 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? | |
fb982c25 | 6021 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
718e3744 | 6022 | inet_ntoa (attr->nexthop)); |
6023 | } | |
6024 | #ifdef HAVE_IPV6 | |
6025 | else | |
6026 | { | |
fb982c25 | 6027 | assert (attr->extra); |
718e3744 | 6028 | vty_out (vty, " %s", |
fb982c25 | 6029 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
718e3744 | 6030 | buf, INET6_ADDRSTRLEN)); |
6031 | } | |
6032 | #endif /* HAVE_IPV6 */ | |
6033 | ||
6034 | if (binfo->peer == bgp->peer_self) | |
6035 | { | |
6036 | vty_out (vty, " from %s ", | |
6037 | p->family == AF_INET ? "0.0.0.0" : "::"); | |
6038 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); | |
6039 | } | |
6040 | else | |
6041 | { | |
6042 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) | |
6043 | vty_out (vty, " (inaccessible)"); | |
fb982c25 PJ |
6044 | else if (binfo->extra && binfo->extra->igpmetric) |
6045 | vty_out (vty, " (metric %d)", binfo->extra->igpmetric); | |
eb821189 | 6046 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
718e3744 | 6047 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 | 6048 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
718e3744 | 6049 | else |
6050 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); | |
6051 | } | |
6052 | vty_out (vty, "%s", VTY_NEWLINE); | |
6053 | ||
6054 | #ifdef HAVE_IPV6 | |
6055 | /* display nexthop local */ | |
fb982c25 | 6056 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
718e3744 | 6057 | { |
6058 | vty_out (vty, " (%s)%s", | |
fb982c25 | 6059 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
718e3744 | 6060 | buf, INET6_ADDRSTRLEN), |
6061 | VTY_NEWLINE); | |
6062 | } | |
6063 | #endif /* HAVE_IPV6 */ | |
6064 | ||
6065 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ | |
6066 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); | |
6067 | ||
6068 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) | |
6069 | vty_out (vty, ", metric %d", attr->med); | |
6070 | ||
6071 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) | |
6072 | vty_out (vty, ", localpref %d", attr->local_pref); | |
6073 | else | |
6074 | vty_out (vty, ", localpref %d", bgp->default_local_pref); | |
6075 | ||
fb982c25 PJ |
6076 | if (attr->extra && attr->extra->weight != 0) |
6077 | vty_out (vty, ", weight %d", attr->extra->weight); | |
718e3744 | 6078 | |
6079 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) | |
6080 | vty_out (vty, ", valid"); | |
6081 | ||
6082 | if (binfo->peer != bgp->peer_self) | |
6083 | { | |
6084 | if (binfo->peer->as == binfo->peer->local_as) | |
6085 | vty_out (vty, ", internal"); | |
6086 | else | |
6087 | vty_out (vty, ", %s", | |
6088 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); | |
6089 | } | |
6090 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) | |
6091 | vty_out (vty, ", aggregated, local"); | |
6092 | else if (binfo->type != ZEBRA_ROUTE_BGP) | |
6093 | vty_out (vty, ", sourced"); | |
6094 | else | |
6095 | vty_out (vty, ", sourced, local"); | |
6096 | ||
6097 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) | |
6098 | vty_out (vty, ", atomic-aggregate"); | |
6099 | ||
6100 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) | |
6101 | vty_out (vty, ", best"); | |
6102 | ||
6103 | vty_out (vty, "%s", VTY_NEWLINE); | |
6104 | ||
6105 | /* Line 4 display Community */ | |
6106 | if (attr->community) | |
6107 | vty_out (vty, " Community: %s%s", attr->community->str, | |
6108 | VTY_NEWLINE); | |
6109 | ||
6110 | /* Line 5 display Extended-community */ | |
6111 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) | |
fb982c25 PJ |
6112 | vty_out (vty, " Extended Community: %s%s", |
6113 | attr->extra->ecommunity->str, VTY_NEWLINE); | |
718e3744 | 6114 | |
6115 | /* Line 6 display Originator, Cluster-id */ | |
6116 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || | |
6117 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) | |
6118 | { | |
fb982c25 | 6119 | assert (attr->extra); |
718e3744 | 6120 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
fb982c25 PJ |
6121 | vty_out (vty, " Originator: %s", |
6122 | inet_ntoa (attr->extra->originator_id)); | |
718e3744 | 6123 | |
6124 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) | |
6125 | { | |
6126 | int i; | |
6127 | vty_out (vty, ", Cluster list: "); | |
fb982c25 PJ |
6128 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
6129 | vty_out (vty, "%s ", | |
6130 | inet_ntoa (attr->extra->cluster->list[i])); | |
718e3744 | 6131 | } |
6132 | vty_out (vty, "%s", VTY_NEWLINE); | |
6133 | } | |
41367172 PJ |
6134 | |
6135 | /* 7: AS Pathlimit */ | |
6136 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AS_PATHLIMIT)) | |
6137 | { | |
6138 | ||
6139 | vty_out (vty, " AS-Pathlimit: %u", | |
6140 | attr->pathlimit.ttl); | |
6141 | if (attr->pathlimit.as) | |
6142 | vty_out (vty, " (%u)", attr->pathlimit.as); | |
6143 | vty_out (vty, "%s", VTY_NEWLINE); | |
6144 | } | |
6145 | ||
fb982c25 | 6146 | if (binfo->extra && binfo->extra->damp_info) |
718e3744 | 6147 | bgp_damp_info_vty (vty, binfo); |
6148 | ||
6149 | /* Line 7 display Uptime */ | |
30b00176 JK |
6150 | #ifdef HAVE_CLOCK_MONOTONIC |
6151 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); | |
213b6cd9 | 6152 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
30b00176 JK |
6153 | #else |
6154 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); | |
6155 | #endif /* HAVE_CLOCK_MONOTONIC */ | |
718e3744 | 6156 | } |
6157 | vty_out (vty, "%s", VTY_NEWLINE); | |
6158 | } | |
6159 | \f | |
b40d939b | 6160 | #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 | 6161 | #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s" |
718e3744 | 6162 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
6163 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" | |
6164 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" | |
6165 | ||
6166 | enum bgp_show_type | |
6167 | { | |
6168 | bgp_show_type_normal, | |
6169 | bgp_show_type_regexp, | |
6170 | bgp_show_type_prefix_list, | |
6171 | bgp_show_type_filter_list, | |
6172 | bgp_show_type_route_map, | |
6173 | bgp_show_type_neighbor, | |
6174 | bgp_show_type_cidr_only, | |
6175 | bgp_show_type_prefix_longer, | |
6176 | bgp_show_type_community_all, | |
6177 | bgp_show_type_community, | |
6178 | bgp_show_type_community_exact, | |
6179 | bgp_show_type_community_list, | |
6180 | bgp_show_type_community_list_exact, | |
6181 | bgp_show_type_flap_statistics, | |
6182 | bgp_show_type_flap_address, | |
6183 | bgp_show_type_flap_prefix, | |
6184 | bgp_show_type_flap_cidr_only, | |
6185 | bgp_show_type_flap_regexp, | |
6186 | bgp_show_type_flap_filter_list, | |
6187 | bgp_show_type_flap_prefix_list, | |
6188 | bgp_show_type_flap_prefix_longer, | |
6189 | bgp_show_type_flap_route_map, | |
6190 | bgp_show_type_flap_neighbor, | |
6191 | bgp_show_type_dampend_paths, | |
6192 | bgp_show_type_damp_neighbor | |
6193 | }; | |
6194 | ||
5a646650 | 6195 | static int |
fee0f4c6 | 6196 | bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id, |
5a646650 | 6197 | enum bgp_show_type type, void *output_arg) |
718e3744 | 6198 | { |
718e3744 | 6199 | struct bgp_info *ri; |
6200 | struct bgp_node *rn; | |
718e3744 | 6201 | int header = 1; |
718e3744 | 6202 | int display; |
5a646650 | 6203 | unsigned long output_count; |
718e3744 | 6204 | |
6205 | /* This is first entry point, so reset total line. */ | |
5a646650 | 6206 | output_count = 0; |
718e3744 | 6207 | |
718e3744 | 6208 | /* Start processing of routes. */ |
6209 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
6210 | if (rn->info != NULL) | |
6211 | { | |
6212 | display = 0; | |
6213 | ||
6214 | for (ri = rn->info; ri; ri = ri->next) | |
6215 | { | |
5a646650 | 6216 | if (type == bgp_show_type_flap_statistics |
718e3744 | 6217 | || type == bgp_show_type_flap_address |
6218 | || type == bgp_show_type_flap_prefix | |
6219 | || type == bgp_show_type_flap_cidr_only | |
6220 | || type == bgp_show_type_flap_regexp | |
6221 | || type == bgp_show_type_flap_filter_list | |
6222 | || type == bgp_show_type_flap_prefix_list | |
6223 | || type == bgp_show_type_flap_prefix_longer | |
6224 | || type == bgp_show_type_flap_route_map | |
6225 | || type == bgp_show_type_flap_neighbor | |
6226 | || type == bgp_show_type_dampend_paths | |
6227 | || type == bgp_show_type_damp_neighbor) | |
6228 | { | |
fb982c25 | 6229 | if (!(ri->extra && ri->extra->damp_info)) |
718e3744 | 6230 | continue; |
6231 | } | |
6232 | if (type == bgp_show_type_regexp | |
6233 | || type == bgp_show_type_flap_regexp) | |
6234 | { | |
5a646650 | 6235 | regex_t *regex = output_arg; |
718e3744 | 6236 | |
6237 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) | |
6238 | continue; | |
6239 | } | |
6240 | if (type == bgp_show_type_prefix_list | |
6241 | || type == bgp_show_type_flap_prefix_list) | |
6242 | { | |
5a646650 | 6243 | struct prefix_list *plist = output_arg; |
718e3744 | 6244 | |
6245 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) | |
6246 | continue; | |
6247 | } | |
6248 | if (type == bgp_show_type_filter_list | |
6249 | || type == bgp_show_type_flap_filter_list) | |
6250 | { | |
5a646650 | 6251 | struct as_list *as_list = output_arg; |
718e3744 | 6252 | |
6253 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) | |
6254 | continue; | |
6255 | } | |
6256 | if (type == bgp_show_type_route_map | |
6257 | || type == bgp_show_type_flap_route_map) | |
6258 | { | |
5a646650 | 6259 | struct route_map *rmap = output_arg; |
718e3744 | 6260 | struct bgp_info binfo; |
9eda90ce | 6261 | struct attr dummy_attr = { 0 }; |
718e3744 | 6262 | int ret; |
6263 | ||
fb982c25 | 6264 | bgp_attr_dup (&dummy_attr, ri->attr); |
718e3744 | 6265 | binfo.peer = ri->peer; |
6266 | binfo.attr = &dummy_attr; | |
6267 | ||
6268 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); | |
fb982c25 PJ |
6269 | |
6270 | bgp_attr_extra_free (&dummy_attr); | |
6271 | ||
718e3744 | 6272 | if (ret == RMAP_DENYMATCH) |
6273 | continue; | |
6274 | } | |
6275 | if (type == bgp_show_type_neighbor | |
6276 | || type == bgp_show_type_flap_neighbor | |
6277 | || type == bgp_show_type_damp_neighbor) | |
6278 | { | |
5a646650 | 6279 | union sockunion *su = output_arg; |
718e3744 | 6280 | |
6281 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) | |
6282 | continue; | |
6283 | } | |
6284 | if (type == bgp_show_type_cidr_only | |
6285 | || type == bgp_show_type_flap_cidr_only) | |
6286 | { | |
6287 | u_int32_t destination; | |
6288 | ||
6289 | destination = ntohl (rn->p.u.prefix4.s_addr); | |
6290 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) | |
6291 | continue; | |
6292 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) | |
6293 | continue; | |
6294 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) | |
6295 | continue; | |
6296 | } | |
6297 | if (type == bgp_show_type_prefix_longer | |
6298 | || type == bgp_show_type_flap_prefix_longer) | |
6299 | { | |
5a646650 | 6300 | struct prefix *p = output_arg; |
718e3744 | 6301 | |
6302 | if (! prefix_match (p, &rn->p)) | |
6303 | continue; | |
6304 | } | |
6305 | if (type == bgp_show_type_community_all) | |
6306 | { | |
6307 | if (! ri->attr->community) | |
6308 | continue; | |
6309 | } | |
6310 | if (type == bgp_show_type_community) | |
6311 | { | |
5a646650 | 6312 | struct community *com = output_arg; |
718e3744 | 6313 | |
6314 | if (! ri->attr->community || | |
6315 | ! community_match (ri->attr->community, com)) | |
6316 | continue; | |
6317 | } | |
6318 | if (type == bgp_show_type_community_exact) | |
6319 | { | |
5a646650 | 6320 | struct community *com = output_arg; |
718e3744 | 6321 | |
6322 | if (! ri->attr->community || | |
6323 | ! community_cmp (ri->attr->community, com)) | |
6324 | continue; | |
6325 | } | |
6326 | if (type == bgp_show_type_community_list) | |
6327 | { | |
5a646650 | 6328 | struct community_list *list = output_arg; |
718e3744 | 6329 | |
6330 | if (! community_list_match (ri->attr->community, list)) | |
6331 | continue; | |
6332 | } | |
6333 | if (type == bgp_show_type_community_list_exact) | |
6334 | { | |
5a646650 | 6335 | struct community_list *list = output_arg; |
718e3744 | 6336 | |
6337 | if (! community_list_exact_match (ri->attr->community, list)) | |
6338 | continue; | |
6339 | } | |
6340 | if (type == bgp_show_type_flap_address | |
6341 | || type == bgp_show_type_flap_prefix) | |
6342 | { | |
5a646650 | 6343 | struct prefix *p = output_arg; |
718e3744 | 6344 | |
6345 | if (! prefix_match (&rn->p, p)) | |
6346 | continue; | |
6347 | ||
6348 | if (type == bgp_show_type_flap_prefix) | |
6349 | if (p->prefixlen != rn->p.prefixlen) | |
6350 | continue; | |
6351 | } | |
6352 | if (type == bgp_show_type_dampend_paths | |
6353 | || type == bgp_show_type_damp_neighbor) | |
6354 | { | |
6355 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) | |
6356 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) | |
6357 | continue; | |
6358 | } | |
6359 | ||
6360 | if (header) | |
6361 | { | |
93406d87 | 6362 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
6363 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
6364 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 6365 | if (type == bgp_show_type_dampend_paths |
6366 | || type == bgp_show_type_damp_neighbor) | |
6367 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); | |
6368 | else if (type == bgp_show_type_flap_statistics | |
6369 | || type == bgp_show_type_flap_address | |
6370 | || type == bgp_show_type_flap_prefix | |
6371 | || type == bgp_show_type_flap_cidr_only | |
6372 | || type == bgp_show_type_flap_regexp | |
6373 | || type == bgp_show_type_flap_filter_list | |
6374 | || type == bgp_show_type_flap_prefix_list | |
6375 | || type == bgp_show_type_flap_prefix_longer | |
6376 | || type == bgp_show_type_flap_route_map | |
6377 | || type == bgp_show_type_flap_neighbor) | |
6378 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); | |
6379 | else | |
6380 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
718e3744 | 6381 | header = 0; |
6382 | } | |
6383 | ||
6384 | if (type == bgp_show_type_dampend_paths | |
6385 | || type == bgp_show_type_damp_neighbor) | |
5a646650 | 6386 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6387 | else if (type == bgp_show_type_flap_statistics |
6388 | || type == bgp_show_type_flap_address | |
6389 | || type == bgp_show_type_flap_prefix | |
6390 | || type == bgp_show_type_flap_cidr_only | |
6391 | || type == bgp_show_type_flap_regexp | |
6392 | || type == bgp_show_type_flap_filter_list | |
6393 | || type == bgp_show_type_flap_prefix_list | |
6394 | || type == bgp_show_type_flap_prefix_longer | |
6395 | || type == bgp_show_type_flap_route_map | |
6396 | || type == bgp_show_type_flap_neighbor) | |
5a646650 | 6397 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6398 | else |
5a646650 | 6399 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
718e3744 | 6400 | display++; |
6401 | } | |
6402 | if (display) | |
5a646650 | 6403 | output_count++; |
718e3744 | 6404 | } |
6405 | ||
6406 | /* No route is displayed */ | |
5a646650 | 6407 | if (output_count == 0) |
718e3744 | 6408 | { |
6409 | if (type == bgp_show_type_normal) | |
6410 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); | |
6411 | } | |
6412 | else | |
6413 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
5a646650 | 6414 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
718e3744 | 6415 | |
6416 | return CMD_SUCCESS; | |
6417 | } | |
6418 | ||
5a646650 | 6419 | static int |
fee0f4c6 | 6420 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
5a646650 | 6421 | enum bgp_show_type type, void *output_arg) |
fee0f4c6 | 6422 | { |
6423 | struct bgp_table *table; | |
6424 | ||
6425 | if (bgp == NULL) { | |
6426 | bgp = bgp_get_default (); | |
6427 | } | |
6428 | ||
6429 | if (bgp == NULL) | |
6430 | { | |
6431 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6432 | return CMD_WARNING; | |
6433 | } | |
6434 | ||
6435 | ||
6436 | table = bgp->rib[afi][safi]; | |
6437 | ||
5a646650 | 6438 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
fee0f4c6 | 6439 | } |
6440 | ||
718e3744 | 6441 | /* Header of detailed BGP route information */ |
94f2b392 | 6442 | static void |
718e3744 | 6443 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
6444 | struct bgp_node *rn, | |
6445 | struct prefix_rd *prd, afi_t afi, safi_t safi) | |
6446 | { | |
6447 | struct bgp_info *ri; | |
6448 | struct prefix *p; | |
6449 | struct peer *peer; | |
1eb8ef25 | 6450 | struct listnode *node, *nnode; |
718e3744 | 6451 | char buf1[INET6_ADDRSTRLEN]; |
6452 | char buf2[INET6_ADDRSTRLEN]; | |
6453 | int count = 0; | |
6454 | int best = 0; | |
6455 | int suppress = 0; | |
6456 | int no_export = 0; | |
6457 | int no_advertise = 0; | |
6458 | int local_as = 0; | |
6459 | int first = 0; | |
6460 | ||
6461 | p = &rn->p; | |
6462 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", | |
6463 | (safi == SAFI_MPLS_VPN ? | |
6464 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), | |
6465 | safi == SAFI_MPLS_VPN ? ":" : "", | |
6466 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), | |
6467 | p->prefixlen, VTY_NEWLINE); | |
6468 | ||
6469 | for (ri = rn->info; ri; ri = ri->next) | |
6470 | { | |
6471 | count++; | |
6472 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) | |
6473 | { | |
6474 | best = count; | |
fb982c25 | 6475 | if (ri->extra && ri->extra->suppress) |
718e3744 | 6476 | suppress = 1; |
6477 | if (ri->attr->community != NULL) | |
6478 | { | |
6479 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) | |
6480 | no_advertise = 1; | |
6481 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) | |
6482 | no_export = 1; | |
6483 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) | |
6484 | local_as = 1; | |
6485 | } | |
6486 | } | |
6487 | } | |
6488 | ||
6489 | vty_out (vty, "Paths: (%d available", count); | |
6490 | if (best) | |
6491 | { | |
6492 | vty_out (vty, ", best #%d", best); | |
6493 | if (safi == SAFI_UNICAST) | |
6494 | vty_out (vty, ", table Default-IP-Routing-Table"); | |
6495 | } | |
6496 | else | |
6497 | vty_out (vty, ", no best path"); | |
6498 | if (no_advertise) | |
6499 | vty_out (vty, ", not advertised to any peer"); | |
6500 | else if (no_export) | |
6501 | vty_out (vty, ", not advertised to EBGP peer"); | |
6502 | else if (local_as) | |
6503 | vty_out (vty, ", not advertised outside local AS"); | |
6504 | if (suppress) | |
6505 | vty_out (vty, ", Advertisements suppressed by an aggregate."); | |
6506 | vty_out (vty, ")%s", VTY_NEWLINE); | |
6507 | ||
6508 | /* advertised peer */ | |
1eb8ef25 | 6509 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6510 | { |
6511 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) | |
6512 | { | |
6513 | if (! first) | |
6514 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); | |
6515 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); | |
6516 | first = 1; | |
6517 | } | |
6518 | } | |
6519 | if (! first) | |
6520 | vty_out (vty, " Not advertised to any peer"); | |
6521 | vty_out (vty, "%s", VTY_NEWLINE); | |
6522 | } | |
6523 | ||
6524 | /* Display specified route of BGP table. */ | |
94f2b392 | 6525 | static int |
fee0f4c6 | 6526 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
fd79ac91 | 6527 | struct bgp_table *rib, const char *ip_str, |
6528 | afi_t afi, safi_t safi, struct prefix_rd *prd, | |
6529 | int prefix_check) | |
718e3744 | 6530 | { |
6531 | int ret; | |
6532 | int header; | |
6533 | int display = 0; | |
6534 | struct prefix match; | |
6535 | struct bgp_node *rn; | |
6536 | struct bgp_node *rm; | |
6537 | struct bgp_info *ri; | |
718e3744 | 6538 | struct bgp_table *table; |
6539 | ||
718e3744 | 6540 | /* Check IP address argument. */ |
6541 | ret = str2prefix (ip_str, &match); | |
6542 | if (! ret) | |
6543 | { | |
6544 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); | |
6545 | return CMD_WARNING; | |
6546 | } | |
6547 | ||
6548 | match.family = afi2family (afi); | |
6549 | ||
6550 | if (safi == SAFI_MPLS_VPN) | |
6551 | { | |
fee0f4c6 | 6552 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
718e3744 | 6553 | { |
6554 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
6555 | continue; | |
6556 | ||
6557 | if ((table = rn->info) != NULL) | |
6558 | { | |
6559 | header = 1; | |
6560 | ||
6561 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6562 | { | |
6563 | if (prefix_check && rm->p.prefixlen != match.prefixlen) | |
6c88b44d CC |
6564 | { |
6565 | bgp_unlock_node (rm); | |
6566 | continue; | |
6567 | } | |
718e3744 | 6568 | |
6569 | for (ri = rm->info; ri; ri = ri->next) | |
6570 | { | |
6571 | if (header) | |
6572 | { | |
6573 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, | |
6574 | AFI_IP, SAFI_MPLS_VPN); | |
6575 | ||
6576 | header = 0; | |
6577 | } | |
6578 | display++; | |
6579 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); | |
6580 | } | |
6c88b44d CC |
6581 | |
6582 | bgp_unlock_node (rm); | |
718e3744 | 6583 | } |
6584 | } | |
6585 | } | |
6586 | } | |
6587 | else | |
6588 | { | |
6589 | header = 1; | |
6590 | ||
fee0f4c6 | 6591 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
718e3744 | 6592 | { |
6593 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
6594 | { | |
6595 | for (ri = rn->info; ri; ri = ri->next) | |
6596 | { | |
6597 | if (header) | |
6598 | { | |
6599 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); | |
6600 | header = 0; | |
6601 | } | |
6602 | display++; | |
6603 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); | |
6604 | } | |
6605 | } | |
6c88b44d CC |
6606 | |
6607 | bgp_unlock_node (rn); | |
718e3744 | 6608 | } |
6609 | } | |
6610 | ||
6611 | if (! display) | |
6612 | { | |
6613 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); | |
6614 | return CMD_WARNING; | |
6615 | } | |
6616 | ||
6617 | return CMD_SUCCESS; | |
6618 | } | |
6619 | ||
fee0f4c6 | 6620 | /* Display specified route of Main RIB */ |
94f2b392 | 6621 | static int |
fd79ac91 | 6622 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
fee0f4c6 | 6623 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
6624 | int prefix_check) | |
6625 | { | |
6626 | struct bgp *bgp; | |
6627 | ||
6628 | /* BGP structure lookup. */ | |
6629 | if (view_name) | |
6630 | { | |
6631 | bgp = bgp_lookup_by_name (view_name); | |
6632 | if (bgp == NULL) | |
6633 | { | |
6634 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
6635 | return CMD_WARNING; | |
6636 | } | |
6637 | } | |
6638 | else | |
6639 | { | |
6640 | bgp = bgp_get_default (); | |
6641 | if (bgp == NULL) | |
6642 | { | |
6643 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
6644 | return CMD_WARNING; | |
6645 | } | |
6646 | } | |
6647 | ||
6648 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, | |
6649 | afi, safi, prd, prefix_check); | |
6650 | } | |
6651 | ||
718e3744 | 6652 | /* BGP route print out function. */ |
6653 | DEFUN (show_ip_bgp, | |
6654 | show_ip_bgp_cmd, | |
6655 | "show ip bgp", | |
6656 | SHOW_STR | |
6657 | IP_STR | |
6658 | BGP_STR) | |
6659 | { | |
5a646650 | 6660 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6661 | } |
6662 | ||
6663 | DEFUN (show_ip_bgp_ipv4, | |
6664 | show_ip_bgp_ipv4_cmd, | |
6665 | "show ip bgp ipv4 (unicast|multicast)", | |
6666 | SHOW_STR | |
6667 | IP_STR | |
6668 | BGP_STR | |
6669 | "Address family\n" | |
6670 | "Address Family modifier\n" | |
6671 | "Address Family modifier\n") | |
6672 | { | |
6673 | if (strncmp (argv[0], "m", 1) == 0) | |
5a646650 | 6674 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
6675 | NULL); | |
718e3744 | 6676 | |
5a646650 | 6677 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6678 | } |
6679 | ||
6680 | DEFUN (show_ip_bgp_route, | |
6681 | show_ip_bgp_route_cmd, | |
6682 | "show ip bgp A.B.C.D", | |
6683 | SHOW_STR | |
6684 | IP_STR | |
6685 | BGP_STR | |
6686 | "Network in the BGP routing table to display\n") | |
6687 | { | |
6688 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6689 | } | |
6690 | ||
6691 | DEFUN (show_ip_bgp_ipv4_route, | |
6692 | show_ip_bgp_ipv4_route_cmd, | |
6693 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", | |
6694 | SHOW_STR | |
6695 | IP_STR | |
6696 | BGP_STR | |
6697 | "Address family\n" | |
6698 | "Address Family modifier\n" | |
6699 | "Address Family modifier\n" | |
6700 | "Network in the BGP routing table to display\n") | |
6701 | { | |
6702 | if (strncmp (argv[0], "m", 1) == 0) | |
6703 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); | |
6704 | ||
6705 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6706 | } | |
6707 | ||
6708 | DEFUN (show_ip_bgp_vpnv4_all_route, | |
6709 | show_ip_bgp_vpnv4_all_route_cmd, | |
6710 | "show ip bgp vpnv4 all A.B.C.D", | |
6711 | SHOW_STR | |
6712 | IP_STR | |
6713 | BGP_STR | |
6714 | "Display VPNv4 NLRI specific information\n" | |
6715 | "Display information about all VPNv4 NLRIs\n" | |
6716 | "Network in the BGP routing table to display\n") | |
6717 | { | |
6718 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); | |
6719 | } | |
6720 | ||
6721 | DEFUN (show_ip_bgp_vpnv4_rd_route, | |
6722 | show_ip_bgp_vpnv4_rd_route_cmd, | |
6723 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", | |
6724 | SHOW_STR | |
6725 | IP_STR | |
6726 | BGP_STR | |
6727 | "Display VPNv4 NLRI specific information\n" | |
6728 | "Display information for a route distinguisher\n" | |
6729 | "VPN Route Distinguisher\n" | |
6730 | "Network in the BGP routing table to display\n") | |
6731 | { | |
6732 | int ret; | |
6733 | struct prefix_rd prd; | |
6734 | ||
6735 | ret = str2prefix_rd (argv[0], &prd); | |
6736 | if (! ret) | |
6737 | { | |
6738 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6739 | return CMD_WARNING; | |
6740 | } | |
6741 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); | |
6742 | } | |
6743 | ||
6744 | DEFUN (show_ip_bgp_prefix, | |
6745 | show_ip_bgp_prefix_cmd, | |
6746 | "show ip bgp A.B.C.D/M", | |
6747 | SHOW_STR | |
6748 | IP_STR | |
6749 | BGP_STR | |
6750 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6751 | { | |
6752 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6753 | } | |
6754 | ||
6755 | DEFUN (show_ip_bgp_ipv4_prefix, | |
6756 | show_ip_bgp_ipv4_prefix_cmd, | |
6757 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", | |
6758 | SHOW_STR | |
6759 | IP_STR | |
6760 | BGP_STR | |
6761 | "Address family\n" | |
6762 | "Address Family modifier\n" | |
6763 | "Address Family modifier\n" | |
6764 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6765 | { | |
6766 | if (strncmp (argv[0], "m", 1) == 0) | |
6767 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); | |
6768 | ||
6769 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6770 | } | |
6771 | ||
6772 | DEFUN (show_ip_bgp_vpnv4_all_prefix, | |
6773 | show_ip_bgp_vpnv4_all_prefix_cmd, | |
6774 | "show ip bgp vpnv4 all A.B.C.D/M", | |
6775 | SHOW_STR | |
6776 | IP_STR | |
6777 | BGP_STR | |
6778 | "Display VPNv4 NLRI specific information\n" | |
6779 | "Display information about all VPNv4 NLRIs\n" | |
6780 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6781 | { | |
6782 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); | |
6783 | } | |
6784 | ||
6785 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, | |
6786 | show_ip_bgp_vpnv4_rd_prefix_cmd, | |
6787 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", | |
6788 | SHOW_STR | |
6789 | IP_STR | |
6790 | BGP_STR | |
6791 | "Display VPNv4 NLRI specific information\n" | |
6792 | "Display information for a route distinguisher\n" | |
6793 | "VPN Route Distinguisher\n" | |
6794 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6795 | { | |
6796 | int ret; | |
6797 | struct prefix_rd prd; | |
6798 | ||
6799 | ret = str2prefix_rd (argv[0], &prd); | |
6800 | if (! ret) | |
6801 | { | |
6802 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); | |
6803 | return CMD_WARNING; | |
6804 | } | |
6805 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); | |
6806 | } | |
6807 | ||
6808 | DEFUN (show_ip_bgp_view, | |
6809 | show_ip_bgp_view_cmd, | |
6810 | "show ip bgp view WORD", | |
6811 | SHOW_STR | |
6812 | IP_STR | |
6813 | BGP_STR | |
6814 | "BGP view\n" | |
6815 | "BGP view name\n") | |
6816 | { | |
bb46e94f | 6817 | struct bgp *bgp; |
6818 | ||
6819 | /* BGP structure lookup. */ | |
6820 | bgp = bgp_lookup_by_name (argv[0]); | |
6821 | if (bgp == NULL) | |
6822 | { | |
6823 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6824 | return CMD_WARNING; | |
6825 | } | |
6826 | ||
5a646650 | 6827 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
718e3744 | 6828 | } |
6829 | ||
6830 | DEFUN (show_ip_bgp_view_route, | |
6831 | show_ip_bgp_view_route_cmd, | |
6832 | "show ip bgp view WORD A.B.C.D", | |
6833 | SHOW_STR | |
6834 | IP_STR | |
6835 | BGP_STR | |
6836 | "BGP view\n" | |
6837 | "BGP view name\n" | |
6838 | "Network in the BGP routing table to display\n") | |
6839 | { | |
6840 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); | |
6841 | } | |
6842 | ||
6843 | DEFUN (show_ip_bgp_view_prefix, | |
6844 | show_ip_bgp_view_prefix_cmd, | |
6845 | "show ip bgp view WORD A.B.C.D/M", | |
6846 | SHOW_STR | |
6847 | IP_STR | |
6848 | BGP_STR | |
6849 | "BGP view\n" | |
6850 | "BGP view name\n" | |
6851 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
6852 | { | |
6853 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); | |
6854 | } | |
6855 | ||
6856 | #ifdef HAVE_IPV6 | |
6857 | DEFUN (show_bgp, | |
6858 | show_bgp_cmd, | |
6859 | "show bgp", | |
6860 | SHOW_STR | |
6861 | BGP_STR) | |
6862 | { | |
5a646650 | 6863 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6864 | NULL); | |
718e3744 | 6865 | } |
6866 | ||
6867 | ALIAS (show_bgp, | |
6868 | show_bgp_ipv6_cmd, | |
6869 | "show bgp ipv6", | |
6870 | SHOW_STR | |
6871 | BGP_STR | |
6872 | "Address family\n") | |
6873 | ||
6874 | /* old command */ | |
6875 | DEFUN (show_ipv6_bgp, | |
6876 | show_ipv6_bgp_cmd, | |
6877 | "show ipv6 bgp", | |
6878 | SHOW_STR | |
6879 | IP_STR | |
6880 | BGP_STR) | |
6881 | { | |
5a646650 | 6882 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
6883 | NULL); | |
718e3744 | 6884 | } |
6885 | ||
6886 | DEFUN (show_bgp_route, | |
6887 | show_bgp_route_cmd, | |
6888 | "show bgp X:X::X:X", | |
6889 | SHOW_STR | |
6890 | BGP_STR | |
6891 | "Network in the BGP routing table to display\n") | |
6892 | { | |
6893 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6894 | } | |
6895 | ||
6896 | ALIAS (show_bgp_route, | |
6897 | show_bgp_ipv6_route_cmd, | |
6898 | "show bgp ipv6 X:X::X:X", | |
6899 | SHOW_STR | |
6900 | BGP_STR | |
6901 | "Address family\n" | |
6902 | "Network in the BGP routing table to display\n") | |
6903 | ||
6904 | /* old command */ | |
6905 | DEFUN (show_ipv6_bgp_route, | |
6906 | show_ipv6_bgp_route_cmd, | |
6907 | "show ipv6 bgp X:X::X:X", | |
6908 | SHOW_STR | |
6909 | IP_STR | |
6910 | BGP_STR | |
6911 | "Network in the BGP routing table to display\n") | |
6912 | { | |
6913 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6914 | } | |
6915 | ||
6916 | DEFUN (show_bgp_prefix, | |
6917 | show_bgp_prefix_cmd, | |
6918 | "show bgp X:X::X:X/M", | |
6919 | SHOW_STR | |
6920 | BGP_STR | |
6921 | "IPv6 prefix <network>/<length>\n") | |
6922 | { | |
6923 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6924 | } | |
6925 | ||
6926 | ALIAS (show_bgp_prefix, | |
6927 | show_bgp_ipv6_prefix_cmd, | |
6928 | "show bgp ipv6 X:X::X:X/M", | |
6929 | SHOW_STR | |
6930 | BGP_STR | |
6931 | "Address family\n" | |
6932 | "IPv6 prefix <network>/<length>\n") | |
6933 | ||
6934 | /* old command */ | |
6935 | DEFUN (show_ipv6_bgp_prefix, | |
6936 | show_ipv6_bgp_prefix_cmd, | |
6937 | "show ipv6 bgp X:X::X:X/M", | |
6938 | SHOW_STR | |
6939 | IP_STR | |
6940 | BGP_STR | |
6941 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
6942 | { | |
6943 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
6944 | } | |
6945 | ||
bb46e94f | 6946 | DEFUN (show_bgp_view, |
6947 | show_bgp_view_cmd, | |
6948 | "show bgp view WORD", | |
6949 | SHOW_STR | |
6950 | BGP_STR | |
6951 | "BGP view\n" | |
6952 | "View name\n") | |
6953 | { | |
6954 | struct bgp *bgp; | |
6955 | ||
6956 | /* BGP structure lookup. */ | |
6957 | bgp = bgp_lookup_by_name (argv[0]); | |
6958 | if (bgp == NULL) | |
6959 | { | |
6960 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
6961 | return CMD_WARNING; | |
6962 | } | |
6963 | ||
5a646650 | 6964 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
bb46e94f | 6965 | } |
6966 | ||
6967 | ALIAS (show_bgp_view, | |
6968 | show_bgp_view_ipv6_cmd, | |
6969 | "show bgp view WORD ipv6", | |
6970 | SHOW_STR | |
6971 | BGP_STR | |
6972 | "BGP view\n" | |
6973 | "View name\n" | |
6974 | "Address family\n") | |
6975 | ||
6976 | DEFUN (show_bgp_view_route, | |
6977 | show_bgp_view_route_cmd, | |
6978 | "show bgp view WORD X:X::X:X", | |
6979 | SHOW_STR | |
6980 | BGP_STR | |
6981 | "BGP view\n" | |
6982 | "View name\n" | |
6983 | "Network in the BGP routing table to display\n") | |
6984 | { | |
6985 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); | |
6986 | } | |
6987 | ||
6988 | ALIAS (show_bgp_view_route, | |
6989 | show_bgp_view_ipv6_route_cmd, | |
6990 | "show bgp view WORD ipv6 X:X::X:X", | |
6991 | SHOW_STR | |
6992 | BGP_STR | |
6993 | "BGP view\n" | |
6994 | "View name\n" | |
6995 | "Address family\n" | |
6996 | "Network in the BGP routing table to display\n") | |
6997 | ||
6998 | DEFUN (show_bgp_view_prefix, | |
6999 | show_bgp_view_prefix_cmd, | |
7000 | "show bgp view WORD X:X::X:X/M", | |
7001 | SHOW_STR | |
7002 | BGP_STR | |
7003 | "BGP view\n" | |
7004 | "View name\n" | |
7005 | "IPv6 prefix <network>/<length>\n") | |
7006 | { | |
7007 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); | |
7008 | } | |
7009 | ||
7010 | ALIAS (show_bgp_view_prefix, | |
7011 | show_bgp_view_ipv6_prefix_cmd, | |
7012 | "show bgp view WORD ipv6 X:X::X:X/M", | |
7013 | SHOW_STR | |
7014 | BGP_STR | |
7015 | "BGP view\n" | |
7016 | "View name\n" | |
7017 | "Address family\n" | |
7018 | "IPv6 prefix <network>/<length>\n") | |
7019 | ||
718e3744 | 7020 | /* old command */ |
7021 | DEFUN (show_ipv6_mbgp, | |
7022 | show_ipv6_mbgp_cmd, | |
7023 | "show ipv6 mbgp", | |
7024 | SHOW_STR | |
7025 | IP_STR | |
7026 | MBGP_STR) | |
7027 | { | |
5a646650 | 7028 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
7029 | NULL); | |
718e3744 | 7030 | } |
7031 | ||
7032 | /* old command */ | |
7033 | DEFUN (show_ipv6_mbgp_route, | |
7034 | show_ipv6_mbgp_route_cmd, | |
7035 | "show ipv6 mbgp X:X::X:X", | |
7036 | SHOW_STR | |
7037 | IP_STR | |
7038 | MBGP_STR | |
7039 | "Network in the MBGP routing table to display\n") | |
7040 | { | |
7041 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); | |
7042 | } | |
7043 | ||
7044 | /* old command */ | |
7045 | DEFUN (show_ipv6_mbgp_prefix, | |
7046 | show_ipv6_mbgp_prefix_cmd, | |
7047 | "show ipv6 mbgp X:X::X:X/M", | |
7048 | SHOW_STR | |
7049 | IP_STR | |
7050 | MBGP_STR | |
7051 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
7052 | { | |
7053 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); | |
7054 | } | |
7055 | #endif | |
7056 | \f | |
718e3744 | 7057 | |
94f2b392 | 7058 | static int |
fd79ac91 | 7059 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
718e3744 | 7060 | safi_t safi, enum bgp_show_type type) |
7061 | { | |
7062 | int i; | |
7063 | struct buffer *b; | |
7064 | char *regstr; | |
7065 | int first; | |
7066 | regex_t *regex; | |
5a646650 | 7067 | int rc; |
718e3744 | 7068 | |
7069 | first = 0; | |
7070 | b = buffer_new (1024); | |
7071 | for (i = 0; i < argc; i++) | |
7072 | { | |
7073 | if (first) | |
7074 | buffer_putc (b, ' '); | |
7075 | else | |
7076 | { | |
7077 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
7078 | continue; | |
7079 | first = 1; | |
7080 | } | |
7081 | ||
7082 | buffer_putstr (b, argv[i]); | |
7083 | } | |
7084 | buffer_putc (b, '\0'); | |
7085 | ||
7086 | regstr = buffer_getstr (b); | |
7087 | buffer_free (b); | |
7088 | ||
7089 | regex = bgp_regcomp (regstr); | |
3b8b1855 | 7090 | XFREE(MTYPE_TMP, regstr); |
718e3744 | 7091 | if (! regex) |
7092 | { | |
7093 | vty_out (vty, "Can't compile regexp %s%s", argv[0], | |
7094 | VTY_NEWLINE); | |
7095 | return CMD_WARNING; | |
7096 | } | |
7097 | ||
5a646650 | 7098 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
7099 | bgp_regex_free (regex); | |
7100 | return rc; | |
718e3744 | 7101 | } |
7102 | ||
7103 | DEFUN (show_ip_bgp_regexp, | |
7104 | show_ip_bgp_regexp_cmd, | |
7105 | "show ip bgp regexp .LINE", | |
7106 | SHOW_STR | |
7107 | IP_STR | |
7108 | BGP_STR | |
7109 | "Display routes matching the AS path regular expression\n" | |
7110 | "A regular-expression to match the BGP AS paths\n") | |
7111 | { | |
7112 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7113 | bgp_show_type_regexp); | |
7114 | } | |
7115 | ||
7116 | DEFUN (show_ip_bgp_flap_regexp, | |
7117 | show_ip_bgp_flap_regexp_cmd, | |
7118 | "show ip bgp flap-statistics regexp .LINE", | |
7119 | SHOW_STR | |
7120 | IP_STR | |
7121 | BGP_STR | |
7122 | "Display flap statistics of routes\n" | |
7123 | "Display routes matching the AS path regular expression\n" | |
7124 | "A regular-expression to match the BGP AS paths\n") | |
7125 | { | |
7126 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7127 | bgp_show_type_flap_regexp); | |
7128 | } | |
7129 | ||
7130 | DEFUN (show_ip_bgp_ipv4_regexp, | |
7131 | show_ip_bgp_ipv4_regexp_cmd, | |
7132 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", | |
7133 | SHOW_STR | |
7134 | IP_STR | |
7135 | BGP_STR | |
7136 | "Address family\n" | |
7137 | "Address Family modifier\n" | |
7138 | "Address Family modifier\n" | |
7139 | "Display routes matching the AS path regular expression\n" | |
7140 | "A regular-expression to match the BGP AS paths\n") | |
7141 | { | |
7142 | if (strncmp (argv[0], "m", 1) == 0) | |
7143 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, | |
7144 | bgp_show_type_regexp); | |
7145 | ||
7146 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, | |
7147 | bgp_show_type_regexp); | |
7148 | } | |
7149 | ||
7150 | #ifdef HAVE_IPV6 | |
7151 | DEFUN (show_bgp_regexp, | |
7152 | show_bgp_regexp_cmd, | |
7153 | "show bgp regexp .LINE", | |
7154 | SHOW_STR | |
7155 | BGP_STR | |
7156 | "Display routes matching the AS path regular expression\n" | |
7157 | "A regular-expression to match the BGP AS paths\n") | |
7158 | { | |
7159 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7160 | bgp_show_type_regexp); | |
7161 | } | |
7162 | ||
7163 | ALIAS (show_bgp_regexp, | |
7164 | show_bgp_ipv6_regexp_cmd, | |
7165 | "show bgp ipv6 regexp .LINE", | |
7166 | SHOW_STR | |
7167 | BGP_STR | |
7168 | "Address family\n" | |
7169 | "Display routes matching the AS path regular expression\n" | |
7170 | "A regular-expression to match the BGP AS paths\n") | |
7171 | ||
7172 | /* old command */ | |
7173 | DEFUN (show_ipv6_bgp_regexp, | |
7174 | show_ipv6_bgp_regexp_cmd, | |
7175 | "show ipv6 bgp regexp .LINE", | |
7176 | SHOW_STR | |
7177 | IP_STR | |
7178 | BGP_STR | |
7179 | "Display routes matching the AS path regular expression\n" | |
7180 | "A regular-expression to match the BGP AS paths\n") | |
7181 | { | |
7182 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, | |
7183 | bgp_show_type_regexp); | |
7184 | } | |
7185 | ||
7186 | /* old command */ | |
7187 | DEFUN (show_ipv6_mbgp_regexp, | |
7188 | show_ipv6_mbgp_regexp_cmd, | |
7189 | "show ipv6 mbgp regexp .LINE", | |
7190 | SHOW_STR | |
7191 | IP_STR | |
7192 | BGP_STR | |
7193 | "Display routes matching the AS path regular expression\n" | |
7194 | "A regular-expression to match the MBGP AS paths\n") | |
7195 | { | |
7196 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, | |
7197 | bgp_show_type_regexp); | |
7198 | } | |
7199 | #endif /* HAVE_IPV6 */ | |
7200 | \f | |
94f2b392 | 7201 | static int |
fd79ac91 | 7202 | bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi, |
718e3744 | 7203 | safi_t safi, enum bgp_show_type type) |
7204 | { | |
7205 | struct prefix_list *plist; | |
7206 | ||
7207 | plist = prefix_list_lookup (afi, prefix_list_str); | |
7208 | if (plist == NULL) | |
7209 | { | |
7210 | vty_out (vty, "%% %s is not a valid prefix-list name%s", | |
7211 | prefix_list_str, VTY_NEWLINE); | |
7212 | return CMD_WARNING; | |
7213 | } | |
7214 | ||
5a646650 | 7215 | return bgp_show (vty, NULL, afi, safi, type, plist); |
718e3744 | 7216 | } |
7217 | ||
7218 | DEFUN (show_ip_bgp_prefix_list, | |
7219 | show_ip_bgp_prefix_list_cmd, | |
7220 | "show ip bgp prefix-list WORD", | |
7221 | SHOW_STR | |
7222 | IP_STR | |
7223 | BGP_STR | |
7224 | "Display routes conforming to the prefix-list\n" | |
7225 | "IP prefix-list name\n") | |
7226 | { | |
7227 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7228 | bgp_show_type_prefix_list); | |
7229 | } | |
7230 | ||
7231 | DEFUN (show_ip_bgp_flap_prefix_list, | |
7232 | show_ip_bgp_flap_prefix_list_cmd, | |
7233 | "show ip bgp flap-statistics prefix-list WORD", | |
7234 | SHOW_STR | |
7235 | IP_STR | |
7236 | BGP_STR | |
7237 | "Display flap statistics of routes\n" | |
7238 | "Display routes conforming to the prefix-list\n" | |
7239 | "IP prefix-list name\n") | |
7240 | { | |
7241 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7242 | bgp_show_type_flap_prefix_list); | |
7243 | } | |
7244 | ||
7245 | DEFUN (show_ip_bgp_ipv4_prefix_list, | |
7246 | show_ip_bgp_ipv4_prefix_list_cmd, | |
7247 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", | |
7248 | SHOW_STR | |
7249 | IP_STR | |
7250 | BGP_STR | |
7251 | "Address family\n" | |
7252 | "Address Family modifier\n" | |
7253 | "Address Family modifier\n" | |
7254 | "Display routes conforming to the prefix-list\n" | |
7255 | "IP prefix-list name\n") | |
7256 | { | |
7257 | if (strncmp (argv[0], "m", 1) == 0) | |
7258 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7259 | bgp_show_type_prefix_list); | |
7260 | ||
7261 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7262 | bgp_show_type_prefix_list); | |
7263 | } | |
7264 | ||
7265 | #ifdef HAVE_IPV6 | |
7266 | DEFUN (show_bgp_prefix_list, | |
7267 | show_bgp_prefix_list_cmd, | |
7268 | "show bgp prefix-list WORD", | |
7269 | SHOW_STR | |
7270 | BGP_STR | |
7271 | "Display routes conforming to the prefix-list\n" | |
7272 | "IPv6 prefix-list name\n") | |
7273 | { | |
7274 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7275 | bgp_show_type_prefix_list); | |
7276 | } | |
7277 | ||
7278 | ALIAS (show_bgp_prefix_list, | |
7279 | show_bgp_ipv6_prefix_list_cmd, | |
7280 | "show bgp ipv6 prefix-list WORD", | |
7281 | SHOW_STR | |
7282 | BGP_STR | |
7283 | "Address family\n" | |
7284 | "Display routes conforming to the prefix-list\n" | |
7285 | "IPv6 prefix-list name\n") | |
7286 | ||
7287 | /* old command */ | |
7288 | DEFUN (show_ipv6_bgp_prefix_list, | |
7289 | show_ipv6_bgp_prefix_list_cmd, | |
7290 | "show ipv6 bgp prefix-list WORD", | |
7291 | SHOW_STR | |
7292 | IPV6_STR | |
7293 | BGP_STR | |
7294 | "Display routes matching the prefix-list\n" | |
7295 | "IPv6 prefix-list name\n") | |
7296 | { | |
7297 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7298 | bgp_show_type_prefix_list); | |
7299 | } | |
7300 | ||
7301 | /* old command */ | |
7302 | DEFUN (show_ipv6_mbgp_prefix_list, | |
7303 | show_ipv6_mbgp_prefix_list_cmd, | |
7304 | "show ipv6 mbgp prefix-list WORD", | |
7305 | SHOW_STR | |
7306 | IPV6_STR | |
7307 | MBGP_STR | |
7308 | "Display routes matching the prefix-list\n" | |
7309 | "IPv6 prefix-list name\n") | |
7310 | { | |
7311 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7312 | bgp_show_type_prefix_list); | |
7313 | } | |
7314 | #endif /* HAVE_IPV6 */ | |
7315 | \f | |
94f2b392 | 7316 | static int |
fd79ac91 | 7317 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
718e3744 | 7318 | safi_t safi, enum bgp_show_type type) |
7319 | { | |
7320 | struct as_list *as_list; | |
7321 | ||
7322 | as_list = as_list_lookup (filter); | |
7323 | if (as_list == NULL) | |
7324 | { | |
7325 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); | |
7326 | return CMD_WARNING; | |
7327 | } | |
7328 | ||
5a646650 | 7329 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
718e3744 | 7330 | } |
7331 | ||
7332 | DEFUN (show_ip_bgp_filter_list, | |
7333 | show_ip_bgp_filter_list_cmd, | |
7334 | "show ip bgp filter-list WORD", | |
7335 | SHOW_STR | |
7336 | IP_STR | |
7337 | BGP_STR | |
7338 | "Display routes conforming to the filter-list\n" | |
7339 | "Regular expression access list name\n") | |
7340 | { | |
7341 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7342 | bgp_show_type_filter_list); | |
7343 | } | |
7344 | ||
7345 | DEFUN (show_ip_bgp_flap_filter_list, | |
7346 | show_ip_bgp_flap_filter_list_cmd, | |
7347 | "show ip bgp flap-statistics filter-list WORD", | |
7348 | SHOW_STR | |
7349 | IP_STR | |
7350 | BGP_STR | |
7351 | "Display flap statistics of routes\n" | |
7352 | "Display routes conforming to the filter-list\n" | |
7353 | "Regular expression access list name\n") | |
7354 | { | |
7355 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7356 | bgp_show_type_flap_filter_list); | |
7357 | } | |
7358 | ||
7359 | DEFUN (show_ip_bgp_ipv4_filter_list, | |
7360 | show_ip_bgp_ipv4_filter_list_cmd, | |
7361 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", | |
7362 | SHOW_STR | |
7363 | IP_STR | |
7364 | BGP_STR | |
7365 | "Address family\n" | |
7366 | "Address Family modifier\n" | |
7367 | "Address Family modifier\n" | |
7368 | "Display routes conforming to the filter-list\n" | |
7369 | "Regular expression access list name\n") | |
7370 | { | |
7371 | if (strncmp (argv[0], "m", 1) == 0) | |
7372 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7373 | bgp_show_type_filter_list); | |
7374 | ||
7375 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7376 | bgp_show_type_filter_list); | |
7377 | } | |
7378 | ||
7379 | #ifdef HAVE_IPV6 | |
7380 | DEFUN (show_bgp_filter_list, | |
7381 | show_bgp_filter_list_cmd, | |
7382 | "show bgp filter-list WORD", | |
7383 | SHOW_STR | |
7384 | BGP_STR | |
7385 | "Display routes conforming to the filter-list\n" | |
7386 | "Regular expression access list name\n") | |
7387 | { | |
7388 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7389 | bgp_show_type_filter_list); | |
7390 | } | |
7391 | ||
7392 | ALIAS (show_bgp_filter_list, | |
7393 | show_bgp_ipv6_filter_list_cmd, | |
7394 | "show bgp ipv6 filter-list WORD", | |
7395 | SHOW_STR | |
7396 | BGP_STR | |
7397 | "Address family\n" | |
7398 | "Display routes conforming to the filter-list\n" | |
7399 | "Regular expression access list name\n") | |
7400 | ||
7401 | /* old command */ | |
7402 | DEFUN (show_ipv6_bgp_filter_list, | |
7403 | show_ipv6_bgp_filter_list_cmd, | |
7404 | "show ipv6 bgp filter-list WORD", | |
7405 | SHOW_STR | |
7406 | IPV6_STR | |
7407 | BGP_STR | |
7408 | "Display routes conforming to the filter-list\n" | |
7409 | "Regular expression access list name\n") | |
7410 | { | |
7411 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7412 | bgp_show_type_filter_list); | |
7413 | } | |
7414 | ||
7415 | /* old command */ | |
7416 | DEFUN (show_ipv6_mbgp_filter_list, | |
7417 | show_ipv6_mbgp_filter_list_cmd, | |
7418 | "show ipv6 mbgp filter-list WORD", | |
7419 | SHOW_STR | |
7420 | IPV6_STR | |
7421 | MBGP_STR | |
7422 | "Display routes conforming to the filter-list\n" | |
7423 | "Regular expression access list name\n") | |
7424 | { | |
7425 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
7426 | bgp_show_type_filter_list); | |
7427 | } | |
7428 | #endif /* HAVE_IPV6 */ | |
7429 | \f | |
94f2b392 | 7430 | static int |
fd79ac91 | 7431 | bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi, |
718e3744 | 7432 | safi_t safi, enum bgp_show_type type) |
7433 | { | |
7434 | struct route_map *rmap; | |
7435 | ||
7436 | rmap = route_map_lookup_by_name (rmap_str); | |
7437 | if (! rmap) | |
7438 | { | |
7439 | vty_out (vty, "%% %s is not a valid route-map name%s", | |
7440 | rmap_str, VTY_NEWLINE); | |
7441 | return CMD_WARNING; | |
7442 | } | |
7443 | ||
5a646650 | 7444 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
718e3744 | 7445 | } |
7446 | ||
7447 | DEFUN (show_ip_bgp_route_map, | |
7448 | show_ip_bgp_route_map_cmd, | |
7449 | "show ip bgp route-map WORD", | |
7450 | SHOW_STR | |
7451 | IP_STR | |
7452 | BGP_STR | |
7453 | "Display routes matching the route-map\n" | |
7454 | "A route-map to match on\n") | |
7455 | { | |
7456 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7457 | bgp_show_type_route_map); | |
7458 | } | |
7459 | ||
7460 | DEFUN (show_ip_bgp_flap_route_map, | |
7461 | show_ip_bgp_flap_route_map_cmd, | |
7462 | "show ip bgp flap-statistics route-map WORD", | |
7463 | SHOW_STR | |
7464 | IP_STR | |
7465 | BGP_STR | |
7466 | "Display flap statistics of routes\n" | |
7467 | "Display routes matching the route-map\n" | |
7468 | "A route-map to match on\n") | |
7469 | { | |
7470 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
7471 | bgp_show_type_flap_route_map); | |
7472 | } | |
7473 | ||
7474 | DEFUN (show_ip_bgp_ipv4_route_map, | |
7475 | show_ip_bgp_ipv4_route_map_cmd, | |
7476 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", | |
7477 | SHOW_STR | |
7478 | IP_STR | |
7479 | BGP_STR | |
7480 | "Address family\n" | |
7481 | "Address Family modifier\n" | |
7482 | "Address Family modifier\n" | |
7483 | "Display routes matching the route-map\n" | |
7484 | "A route-map to match on\n") | |
7485 | { | |
7486 | if (strncmp (argv[0], "m", 1) == 0) | |
7487 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
7488 | bgp_show_type_route_map); | |
7489 | ||
7490 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
7491 | bgp_show_type_route_map); | |
7492 | } | |
7493 | ||
7494 | DEFUN (show_bgp_route_map, | |
7495 | show_bgp_route_map_cmd, | |
7496 | "show bgp route-map WORD", | |
7497 | SHOW_STR | |
7498 | BGP_STR | |
7499 | "Display routes matching the route-map\n" | |
7500 | "A route-map to match on\n") | |
7501 | { | |
7502 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
7503 | bgp_show_type_route_map); | |
7504 | } | |
7505 | ||
7506 | ALIAS (show_bgp_route_map, | |
7507 | show_bgp_ipv6_route_map_cmd, | |
7508 | "show bgp ipv6 route-map WORD", | |
7509 | SHOW_STR | |
7510 | BGP_STR | |
7511 | "Address family\n" | |
7512 | "Display routes matching the route-map\n" | |
7513 | "A route-map to match on\n") | |
7514 | \f | |
7515 | DEFUN (show_ip_bgp_cidr_only, | |
7516 | show_ip_bgp_cidr_only_cmd, | |
7517 | "show ip bgp cidr-only", | |
7518 | SHOW_STR | |
7519 | IP_STR | |
7520 | BGP_STR | |
7521 | "Display only routes with non-natural netmasks\n") | |
7522 | { | |
7523 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7524 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7525 | } |
7526 | ||
7527 | DEFUN (show_ip_bgp_flap_cidr_only, | |
7528 | show_ip_bgp_flap_cidr_only_cmd, | |
7529 | "show ip bgp flap-statistics cidr-only", | |
7530 | SHOW_STR | |
7531 | IP_STR | |
7532 | BGP_STR | |
7533 | "Display flap statistics of routes\n" | |
7534 | "Display only routes with non-natural netmasks\n") | |
7535 | { | |
7536 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7537 | bgp_show_type_flap_cidr_only, NULL); |
718e3744 | 7538 | } |
7539 | ||
7540 | DEFUN (show_ip_bgp_ipv4_cidr_only, | |
7541 | show_ip_bgp_ipv4_cidr_only_cmd, | |
7542 | "show ip bgp ipv4 (unicast|multicast) cidr-only", | |
7543 | SHOW_STR | |
7544 | IP_STR | |
7545 | BGP_STR | |
7546 | "Address family\n" | |
7547 | "Address Family modifier\n" | |
7548 | "Address Family modifier\n" | |
7549 | "Display only routes with non-natural netmasks\n") | |
7550 | { | |
7551 | if (strncmp (argv[0], "m", 1) == 0) | |
7552 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7553 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7554 | |
7555 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7556 | bgp_show_type_cidr_only, NULL); |
718e3744 | 7557 | } |
7558 | \f | |
7559 | DEFUN (show_ip_bgp_community_all, | |
7560 | show_ip_bgp_community_all_cmd, | |
7561 | "show ip bgp community", | |
7562 | SHOW_STR | |
7563 | IP_STR | |
7564 | BGP_STR | |
7565 | "Display routes matching the communities\n") | |
7566 | { | |
7567 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7568 | bgp_show_type_community_all, NULL); |
718e3744 | 7569 | } |
7570 | ||
7571 | DEFUN (show_ip_bgp_ipv4_community_all, | |
7572 | show_ip_bgp_ipv4_community_all_cmd, | |
7573 | "show ip bgp ipv4 (unicast|multicast) community", | |
7574 | SHOW_STR | |
7575 | IP_STR | |
7576 | BGP_STR | |
7577 | "Address family\n" | |
7578 | "Address Family modifier\n" | |
7579 | "Address Family modifier\n" | |
7580 | "Display routes matching the communities\n") | |
7581 | { | |
7582 | if (strncmp (argv[0], "m", 1) == 0) | |
7583 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, | |
5a646650 | 7584 | bgp_show_type_community_all, NULL); |
718e3744 | 7585 | |
7586 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, | |
5a646650 | 7587 | bgp_show_type_community_all, NULL); |
718e3744 | 7588 | } |
7589 | ||
7590 | #ifdef HAVE_IPV6 | |
7591 | DEFUN (show_bgp_community_all, | |
7592 | show_bgp_community_all_cmd, | |
7593 | "show bgp community", | |
7594 | SHOW_STR | |
7595 | BGP_STR | |
7596 | "Display routes matching the communities\n") | |
7597 | { | |
7598 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
5a646650 | 7599 | bgp_show_type_community_all, NULL); |
718e3744 | 7600 | } |
7601 | ||
7602 | ALIAS (show_bgp_community_all, | |
7603 | show_bgp_ipv6_community_all_cmd, | |
7604 | "show bgp ipv6 community", | |
7605 | SHOW_STR | |
7606 | BGP_STR | |
7607 | "Address family\n" | |
7608 | "Display routes matching the communities\n") | |
7609 | ||
7610 | /* old command */ | |
7611 | DEFUN (show_ipv6_bgp_community_all, | |
7612 | show_ipv6_bgp_community_all_cmd, | |
7613 | "show ipv6 bgp community", | |
7614 | SHOW_STR | |
7615 | IPV6_STR | |
7616 | BGP_STR | |
7617 | "Display routes matching the communities\n") | |
7618 | { | |
7619 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, | |
5a646650 | 7620 | bgp_show_type_community_all, NULL); |
718e3744 | 7621 | } |
7622 | ||
7623 | /* old command */ | |
7624 | DEFUN (show_ipv6_mbgp_community_all, | |
7625 | show_ipv6_mbgp_community_all_cmd, | |
7626 | "show ipv6 mbgp community", | |
7627 | SHOW_STR | |
7628 | IPV6_STR | |
7629 | MBGP_STR | |
7630 | "Display routes matching the communities\n") | |
7631 | { | |
7632 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, | |
5a646650 | 7633 | bgp_show_type_community_all, NULL); |
718e3744 | 7634 | } |
7635 | #endif /* HAVE_IPV6 */ | |
7636 | \f | |
94f2b392 | 7637 | static int |
fd79ac91 | 7638 | bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, |
4c9641ba | 7639 | afi_t afi, safi_t safi) |
718e3744 | 7640 | { |
7641 | struct community *com; | |
7642 | struct buffer *b; | |
7643 | int i; | |
7644 | char *str; | |
7645 | int first = 0; | |
7646 | ||
7647 | b = buffer_new (1024); | |
7648 | for (i = 0; i < argc; i++) | |
7649 | { | |
7650 | if (first) | |
7651 | buffer_putc (b, ' '); | |
7652 | else | |
7653 | { | |
7654 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) | |
7655 | continue; | |
7656 | first = 1; | |
7657 | } | |
7658 | ||
7659 | buffer_putstr (b, argv[i]); | |
7660 | } | |
7661 | buffer_putc (b, '\0'); | |
7662 | ||
7663 | str = buffer_getstr (b); | |
7664 | buffer_free (b); | |
7665 | ||
7666 | com = community_str2com (str); | |
3b8b1855 | 7667 | XFREE (MTYPE_TMP, str); |
718e3744 | 7668 | if (! com) |
7669 | { | |
7670 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); | |
7671 | return CMD_WARNING; | |
7672 | } | |
7673 | ||
5a646650 | 7674 | return bgp_show (vty, NULL, afi, safi, |
7675 | (exact ? bgp_show_type_community_exact : | |
7676 | bgp_show_type_community), com); | |
718e3744 | 7677 | } |
7678 | ||
7679 | DEFUN (show_ip_bgp_community, | |
7680 | show_ip_bgp_community_cmd, | |
7681 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
7682 | SHOW_STR | |
7683 | IP_STR | |
7684 | BGP_STR | |
7685 | "Display routes matching the communities\n" | |
7686 | "community number\n" | |
7687 | "Do not send outside local AS (well-known community)\n" | |
7688 | "Do not advertise to any peer (well-known community)\n" | |
7689 | "Do not export to next AS (well-known community)\n") | |
7690 | { | |
7691 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); | |
7692 | } | |
7693 | ||
7694 | ALIAS (show_ip_bgp_community, | |
7695 | show_ip_bgp_community2_cmd, | |
7696 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7697 | SHOW_STR | |
7698 | IP_STR | |
7699 | BGP_STR | |
7700 | "Display routes matching the communities\n" | |
7701 | "community number\n" | |
7702 | "Do not send outside local AS (well-known community)\n" | |
7703 | "Do not advertise to any peer (well-known community)\n" | |
7704 | "Do not export to next AS (well-known community)\n" | |
7705 | "community number\n" | |
7706 | "Do not send outside local AS (well-known community)\n" | |
7707 | "Do not advertise to any peer (well-known community)\n" | |
7708 | "Do not export to next AS (well-known community)\n") | |
7709 | ||
7710 | ALIAS (show_ip_bgp_community, | |
7711 | show_ip_bgp_community3_cmd, | |
7712 | "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)", | |
7713 | SHOW_STR | |
7714 | IP_STR | |
7715 | BGP_STR | |
7716 | "Display routes matching the communities\n" | |
7717 | "community number\n" | |
7718 | "Do not send outside local AS (well-known community)\n" | |
7719 | "Do not advertise to any peer (well-known community)\n" | |
7720 | "Do not export to next AS (well-known community)\n" | |
7721 | "community number\n" | |
7722 | "Do not send outside local AS (well-known community)\n" | |
7723 | "Do not advertise to any peer (well-known community)\n" | |
7724 | "Do not export to next AS (well-known community)\n" | |
7725 | "community number\n" | |
7726 | "Do not send outside local AS (well-known community)\n" | |
7727 | "Do not advertise to any peer (well-known community)\n" | |
7728 | "Do not export to next AS (well-known community)\n") | |
7729 | ||
7730 | ALIAS (show_ip_bgp_community, | |
7731 | show_ip_bgp_community4_cmd, | |
7732 | "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)", | |
7733 | SHOW_STR | |
7734 | IP_STR | |
7735 | BGP_STR | |
7736 | "Display routes matching the communities\n" | |
7737 | "community number\n" | |
7738 | "Do not send outside local AS (well-known community)\n" | |
7739 | "Do not advertise to any peer (well-known community)\n" | |
7740 | "Do not export to next AS (well-known community)\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 | ||
7754 | DEFUN (show_ip_bgp_ipv4_community, | |
7755 | show_ip_bgp_ipv4_community_cmd, | |
7756 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", | |
7757 | SHOW_STR | |
7758 | IP_STR | |
7759 | BGP_STR | |
7760 | "Address family\n" | |
7761 | "Address Family modifier\n" | |
7762 | "Address Family modifier\n" | |
7763 | "Display routes matching the communities\n" | |
7764 | "community number\n" | |
7765 | "Do not send outside local AS (well-known community)\n" | |
7766 | "Do not advertise to any peer (well-known community)\n" | |
7767 | "Do not export to next AS (well-known community)\n") | |
7768 | { | |
7769 | if (strncmp (argv[0], "m", 1) == 0) | |
7770 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); | |
7771 | ||
7772 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); | |
7773 | } | |
7774 | ||
7775 | ALIAS (show_ip_bgp_ipv4_community, | |
7776 | show_ip_bgp_ipv4_community2_cmd, | |
7777 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
7778 | SHOW_STR | |
7779 | IP_STR | |
7780 | BGP_STR | |
7781 | "Address family\n" | |
7782 | "Address Family modifier\n" | |
7783 | "Address Family modifier\n" | |
7784 | "Display routes matching the communities\n" | |
7785 | "community number\n" | |
7786 | "Do not send outside local AS (well-known community)\n" | |
7787 | "Do not advertise to any peer (well-known community)\n" | |
7788 | "Do not export to next AS (well-known community)\n" | |
7789 | "community number\n" | |
7790 | "Do not send outside local AS (well-known community)\n" | |
7791 | "Do not advertise to any peer (well-known community)\n" | |
7792 | "Do not export to next AS (well-known community)\n") | |
7793 | ||
7794 | ALIAS (show_ip_bgp_ipv4_community, | |
7795 | show_ip_bgp_ipv4_community3_cmd, | |
7796 | "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)", | |
7797 | SHOW_STR | |
7798 | IP_STR | |
7799 | BGP_STR | |
7800 | "Address family\n" | |
7801 | "Address Family modifier\n" | |
7802 | "Address Family modifier\n" | |
7803 | "Display routes matching the communities\n" | |
7804 | "community number\n" | |
7805 | "Do not send outside local AS (well-known community)\n" | |
7806 | "Do not advertise to any peer (well-known community)\n" | |
7807 | "Do not export to next AS (well-known community)\n" | |
7808 | "community number\n" | |
7809 | "Do not send outside local AS (well-known community)\n" | |
7810 | "Do not advertise to any peer (well-known community)\n" | |
7811 | "Do not export to next AS (well-known community)\n" | |
7812 | "community number\n" | |
7813 | "Do not send outside local AS (well-known community)\n" | |
7814 | "Do not advertise to any peer (well-known community)\n" | |
7815 | "Do not export to next AS (well-known community)\n") | |
7816 | ||
7817 | ALIAS (show_ip_bgp_ipv4_community, | |
7818 | show_ip_bgp_ipv4_community4_cmd, | |
7819 | "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)", | |
7820 | SHOW_STR | |
7821 | IP_STR | |
7822 | BGP_STR | |
7823 | "Address family\n" | |
7824 | "Address Family modifier\n" | |
7825 | "Address Family modifier\n" | |
7826 | "Display routes matching the communities\n" | |
7827 | "community number\n" | |
7828 | "Do not send outside local AS (well-known community)\n" | |
7829 | "Do not advertise to any peer (well-known community)\n" | |
7830 | "Do not export to next AS (well-known community)\n" | |
7831 | "community number\n" | |
7832 | "Do not send outside local AS (well-known community)\n" | |
7833 | "Do not advertise to any peer (well-known community)\n" | |
7834 | "Do not export to next AS (well-known community)\n" | |
7835 | "community number\n" | |
7836 | "Do not send outside local AS (well-known community)\n" | |
7837 | "Do not advertise to any peer (well-known community)\n" | |
7838 | "Do not export to next AS (well-known community)\n" | |
7839 | "community number\n" | |
7840 | "Do not send outside local AS (well-known community)\n" | |
7841 | "Do not advertise to any peer (well-known community)\n" | |
7842 | "Do not export to next AS (well-known community)\n") | |
7843 | ||
7844 | DEFUN (show_ip_bgp_community_exact, | |
7845 | show_ip_bgp_community_exact_cmd, | |
7846 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7847 | SHOW_STR | |
7848 | IP_STR | |
7849 | BGP_STR | |
7850 | "Display routes matching the communities\n" | |
7851 | "community number\n" | |
7852 | "Do not send outside local AS (well-known community)\n" | |
7853 | "Do not advertise to any peer (well-known community)\n" | |
7854 | "Do not export to next AS (well-known community)\n" | |
7855 | "Exact match of the communities") | |
7856 | { | |
7857 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); | |
7858 | } | |
7859 | ||
7860 | ALIAS (show_ip_bgp_community_exact, | |
7861 | show_ip_bgp_community2_exact_cmd, | |
7862 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7863 | SHOW_STR | |
7864 | IP_STR | |
7865 | BGP_STR | |
7866 | "Display routes matching the communities\n" | |
7867 | "community number\n" | |
7868 | "Do not send outside local AS (well-known community)\n" | |
7869 | "Do not advertise to any peer (well-known community)\n" | |
7870 | "Do not export to next AS (well-known community)\n" | |
7871 | "community number\n" | |
7872 | "Do not send outside local AS (well-known community)\n" | |
7873 | "Do not advertise to any peer (well-known community)\n" | |
7874 | "Do not export to next AS (well-known community)\n" | |
7875 | "Exact match of the communities") | |
7876 | ||
7877 | ALIAS (show_ip_bgp_community_exact, | |
7878 | show_ip_bgp_community3_exact_cmd, | |
7879 | "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", | |
7880 | SHOW_STR | |
7881 | IP_STR | |
7882 | BGP_STR | |
7883 | "Display routes matching the communities\n" | |
7884 | "community number\n" | |
7885 | "Do not send outside local AS (well-known community)\n" | |
7886 | "Do not advertise to any peer (well-known community)\n" | |
7887 | "Do not export to next AS (well-known community)\n" | |
7888 | "community number\n" | |
7889 | "Do not send outside local AS (well-known community)\n" | |
7890 | "Do not advertise to any peer (well-known community)\n" | |
7891 | "Do not export to next AS (well-known community)\n" | |
7892 | "community number\n" | |
7893 | "Do not send outside local AS (well-known community)\n" | |
7894 | "Do not advertise to any peer (well-known community)\n" | |
7895 | "Do not export to next AS (well-known community)\n" | |
7896 | "Exact match of the communities") | |
7897 | ||
7898 | ALIAS (show_ip_bgp_community_exact, | |
7899 | show_ip_bgp_community4_exact_cmd, | |
7900 | "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", | |
7901 | SHOW_STR | |
7902 | IP_STR | |
7903 | BGP_STR | |
7904 | "Display routes matching the communities\n" | |
7905 | "community number\n" | |
7906 | "Do not send outside local AS (well-known community)\n" | |
7907 | "Do not advertise to any peer (well-known community)\n" | |
7908 | "Do not export to next AS (well-known community)\n" | |
7909 | "community number\n" | |
7910 | "Do not send outside local AS (well-known community)\n" | |
7911 | "Do not advertise to any peer (well-known community)\n" | |
7912 | "Do not export to next AS (well-known community)\n" | |
7913 | "community number\n" | |
7914 | "Do not send outside local AS (well-known community)\n" | |
7915 | "Do not advertise to any peer (well-known community)\n" | |
7916 | "Do not export to next AS (well-known community)\n" | |
7917 | "community number\n" | |
7918 | "Do not send outside local AS (well-known community)\n" | |
7919 | "Do not advertise to any peer (well-known community)\n" | |
7920 | "Do not export to next AS (well-known community)\n" | |
7921 | "Exact match of the communities") | |
7922 | ||
7923 | DEFUN (show_ip_bgp_ipv4_community_exact, | |
7924 | show_ip_bgp_ipv4_community_exact_cmd, | |
7925 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
7926 | SHOW_STR | |
7927 | IP_STR | |
7928 | BGP_STR | |
7929 | "Address family\n" | |
7930 | "Address Family modifier\n" | |
7931 | "Address Family modifier\n" | |
7932 | "Display routes matching the communities\n" | |
7933 | "community number\n" | |
7934 | "Do not send outside local AS (well-known community)\n" | |
7935 | "Do not advertise to any peer (well-known community)\n" | |
7936 | "Do not export to next AS (well-known community)\n" | |
7937 | "Exact match of the communities") | |
7938 | { | |
7939 | if (strncmp (argv[0], "m", 1) == 0) | |
7940 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); | |
7941 | ||
7942 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); | |
7943 | } | |
7944 | ||
7945 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
7946 | show_ip_bgp_ipv4_community2_exact_cmd, | |
7947 | "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", | |
7948 | SHOW_STR | |
7949 | IP_STR | |
7950 | BGP_STR | |
7951 | "Address family\n" | |
7952 | "Address Family modifier\n" | |
7953 | "Address Family modifier\n" | |
7954 | "Display routes matching the communities\n" | |
7955 | "community number\n" | |
7956 | "Do not send outside local AS (well-known community)\n" | |
7957 | "Do not advertise to any peer (well-known community)\n" | |
7958 | "Do not export to next AS (well-known community)\n" | |
7959 | "community number\n" | |
7960 | "Do not send outside local AS (well-known community)\n" | |
7961 | "Do not advertise to any peer (well-known community)\n" | |
7962 | "Do not export to next AS (well-known community)\n" | |
7963 | "Exact match of the communities") | |
7964 | ||
7965 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
7966 | show_ip_bgp_ipv4_community3_exact_cmd, | |
7967 | "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", | |
7968 | SHOW_STR | |
7969 | IP_STR | |
7970 | BGP_STR | |
7971 | "Address family\n" | |
7972 | "Address Family modifier\n" | |
7973 | "Address Family modifier\n" | |
7974 | "Display routes matching the communities\n" | |
7975 | "community number\n" | |
7976 | "Do not send outside local AS (well-known community)\n" | |
7977 | "Do not advertise to any peer (well-known community)\n" | |
7978 | "Do not export to next AS (well-known community)\n" | |
7979 | "community number\n" | |
7980 | "Do not send outside local AS (well-known community)\n" | |
7981 | "Do not advertise to any peer (well-known community)\n" | |
7982 | "Do not export to next AS (well-known community)\n" | |
7983 | "community number\n" | |
7984 | "Do not send outside local AS (well-known community)\n" | |
7985 | "Do not advertise to any peer (well-known community)\n" | |
7986 | "Do not export to next AS (well-known community)\n" | |
7987 | "Exact match of the communities") | |
7988 | ||
7989 | ALIAS (show_ip_bgp_ipv4_community_exact, | |
7990 | show_ip_bgp_ipv4_community4_exact_cmd, | |
7991 | "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", | |
7992 | SHOW_STR | |
7993 | IP_STR | |
7994 | BGP_STR | |
7995 | "Address family\n" | |
7996 | "Address Family modifier\n" | |
7997 | "Address Family modifier\n" | |
7998 | "Display routes matching the communities\n" | |
7999 | "community number\n" | |
8000 | "Do not send outside local AS (well-known community)\n" | |
8001 | "Do not advertise to any peer (well-known community)\n" | |
8002 | "Do not export to next AS (well-known community)\n" | |
8003 | "community number\n" | |
8004 | "Do not send outside local AS (well-known community)\n" | |
8005 | "Do not advertise to any peer (well-known community)\n" | |
8006 | "Do not export to next AS (well-known community)\n" | |
8007 | "community number\n" | |
8008 | "Do not send outside local AS (well-known community)\n" | |
8009 | "Do not advertise to any peer (well-known community)\n" | |
8010 | "Do not export to next AS (well-known community)\n" | |
8011 | "community number\n" | |
8012 | "Do not send outside local AS (well-known community)\n" | |
8013 | "Do not advertise to any peer (well-known community)\n" | |
8014 | "Do not export to next AS (well-known community)\n" | |
8015 | "Exact match of the communities") | |
8016 | ||
8017 | #ifdef HAVE_IPV6 | |
8018 | DEFUN (show_bgp_community, | |
8019 | show_bgp_community_cmd, | |
8020 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8021 | SHOW_STR | |
8022 | BGP_STR | |
8023 | "Display routes matching the communities\n" | |
8024 | "community number\n" | |
8025 | "Do not send outside local AS (well-known community)\n" | |
8026 | "Do not advertise to any peer (well-known community)\n" | |
8027 | "Do not export to next AS (well-known community)\n") | |
8028 | { | |
8029 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); | |
8030 | } | |
8031 | ||
8032 | ALIAS (show_bgp_community, | |
8033 | show_bgp_ipv6_community_cmd, | |
8034 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", | |
8035 | SHOW_STR | |
8036 | BGP_STR | |
8037 | "Address family\n" | |
8038 | "Display routes matching the communities\n" | |
8039 | "community number\n" | |
8040 | "Do not send outside local AS (well-known community)\n" | |
8041 | "Do not advertise to any peer (well-known community)\n" | |
8042 | "Do not export to next AS (well-known community)\n") | |
8043 | ||
8044 | ALIAS (show_bgp_community, | |
8045 | show_bgp_community2_cmd, | |
8046 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8047 | SHOW_STR | |
8048 | BGP_STR | |
8049 | "Display routes matching the communities\n" | |
8050 | "community number\n" | |
8051 | "Do not send outside local AS (well-known community)\n" | |
8052 | "Do not advertise to any peer (well-known community)\n" | |
8053 | "Do not export to next AS (well-known community)\n" | |
8054 | "community number\n" | |
8055 | "Do not send outside local AS (well-known community)\n" | |
8056 | "Do not advertise to any peer (well-known community)\n" | |
8057 | "Do not export to next AS (well-known community)\n") | |
8058 | ||
8059 | ALIAS (show_bgp_community, | |
8060 | show_bgp_ipv6_community2_cmd, | |
8061 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8062 | SHOW_STR | |
8063 | BGP_STR | |
8064 | "Address family\n" | |
8065 | "Display routes matching the communities\n" | |
8066 | "community number\n" | |
8067 | "Do not send outside local AS (well-known community)\n" | |
8068 | "Do not advertise to any peer (well-known community)\n" | |
8069 | "Do not export to next AS (well-known community)\n" | |
8070 | "community number\n" | |
8071 | "Do not send outside local AS (well-known community)\n" | |
8072 | "Do not advertise to any peer (well-known community)\n" | |
8073 | "Do not export to next AS (well-known community)\n") | |
8074 | ||
8075 | ALIAS (show_bgp_community, | |
8076 | show_bgp_community3_cmd, | |
8077 | "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)", | |
8078 | SHOW_STR | |
8079 | BGP_STR | |
8080 | "Display routes matching the communities\n" | |
8081 | "community number\n" | |
8082 | "Do not send outside local AS (well-known community)\n" | |
8083 | "Do not advertise to any peer (well-known community)\n" | |
8084 | "Do not export to next AS (well-known community)\n" | |
8085 | "community number\n" | |
8086 | "Do not send outside local AS (well-known community)\n" | |
8087 | "Do not advertise to any peer (well-known community)\n" | |
8088 | "Do not export to next AS (well-known community)\n" | |
8089 | "community number\n" | |
8090 | "Do not send outside local AS (well-known community)\n" | |
8091 | "Do not advertise to any peer (well-known community)\n" | |
8092 | "Do not export to next AS (well-known community)\n") | |
8093 | ||
8094 | ALIAS (show_bgp_community, | |
8095 | show_bgp_ipv6_community3_cmd, | |
8096 | "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)", | |
8097 | SHOW_STR | |
8098 | BGP_STR | |
8099 | "Address family\n" | |
8100 | "Display routes matching the communities\n" | |
8101 | "community number\n" | |
8102 | "Do not send outside local AS (well-known community)\n" | |
8103 | "Do not advertise to any peer (well-known community)\n" | |
8104 | "Do not export to next AS (well-known community)\n" | |
8105 | "community number\n" | |
8106 | "Do not send outside local AS (well-known community)\n" | |
8107 | "Do not advertise to any peer (well-known community)\n" | |
8108 | "Do not export to next AS (well-known community)\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 | ||
8114 | ALIAS (show_bgp_community, | |
8115 | show_bgp_community4_cmd, | |
8116 | "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)", | |
8117 | SHOW_STR | |
8118 | BGP_STR | |
8119 | "Display routes matching the communities\n" | |
8120 | "community number\n" | |
8121 | "Do not send outside local AS (well-known community)\n" | |
8122 | "Do not advertise to any peer (well-known community)\n" | |
8123 | "Do not export to next AS (well-known community)\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 | "community number\n" | |
8129 | "Do not send outside local AS (well-known community)\n" | |
8130 | "Do not advertise to any peer (well-known community)\n" | |
8131 | "Do not export to next AS (well-known community)\n" | |
8132 | "community number\n" | |
8133 | "Do not send outside local AS (well-known community)\n" | |
8134 | "Do not advertise to any peer (well-known community)\n" | |
8135 | "Do not export to next AS (well-known community)\n") | |
8136 | ||
8137 | ALIAS (show_bgp_community, | |
8138 | show_bgp_ipv6_community4_cmd, | |
8139 | "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)", | |
8140 | SHOW_STR | |
8141 | BGP_STR | |
8142 | "Address family\n" | |
8143 | "Display routes matching the communities\n" | |
8144 | "community number\n" | |
8145 | "Do not send outside local AS (well-known community)\n" | |
8146 | "Do not advertise to any peer (well-known community)\n" | |
8147 | "Do not export to next AS (well-known community)\n" | |
8148 | "community number\n" | |
8149 | "Do not send outside local AS (well-known community)\n" | |
8150 | "Do not advertise to any peer (well-known community)\n" | |
8151 | "Do not export to next AS (well-known community)\n" | |
8152 | "community number\n" | |
8153 | "Do not send outside local AS (well-known community)\n" | |
8154 | "Do not advertise to any peer (well-known community)\n" | |
8155 | "Do not export to next AS (well-known community)\n" | |
8156 | "community number\n" | |
8157 | "Do not send outside local AS (well-known community)\n" | |
8158 | "Do not advertise to any peer (well-known community)\n" | |
8159 | "Do not export to next AS (well-known community)\n") | |
8160 | ||
8161 | /* old command */ | |
8162 | DEFUN (show_ipv6_bgp_community, | |
8163 | show_ipv6_bgp_community_cmd, | |
8164 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8165 | SHOW_STR | |
8166 | IPV6_STR | |
8167 | BGP_STR | |
8168 | "Display routes matching the communities\n" | |
8169 | "community number\n" | |
8170 | "Do not send outside local AS (well-known community)\n" | |
8171 | "Do not advertise to any peer (well-known community)\n" | |
8172 | "Do not export to next AS (well-known community)\n") | |
8173 | { | |
8174 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); | |
8175 | } | |
8176 | ||
8177 | /* old command */ | |
8178 | ALIAS (show_ipv6_bgp_community, | |
8179 | show_ipv6_bgp_community2_cmd, | |
8180 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8181 | SHOW_STR | |
8182 | IPV6_STR | |
8183 | BGP_STR | |
8184 | "Display routes matching the communities\n" | |
8185 | "community number\n" | |
8186 | "Do not send outside local AS (well-known community)\n" | |
8187 | "Do not advertise to any peer (well-known community)\n" | |
8188 | "Do not export to next AS (well-known community)\n" | |
8189 | "community number\n" | |
8190 | "Do not send outside local AS (well-known community)\n" | |
8191 | "Do not advertise to any peer (well-known community)\n" | |
8192 | "Do not export to next AS (well-known community)\n") | |
8193 | ||
8194 | /* old command */ | |
8195 | ALIAS (show_ipv6_bgp_community, | |
8196 | show_ipv6_bgp_community3_cmd, | |
8197 | "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)", | |
8198 | SHOW_STR | |
8199 | IPV6_STR | |
8200 | BGP_STR | |
8201 | "Display routes matching the communities\n" | |
8202 | "community number\n" | |
8203 | "Do not send outside local AS (well-known community)\n" | |
8204 | "Do not advertise to any peer (well-known community)\n" | |
8205 | "Do not export to next AS (well-known community)\n" | |
8206 | "community number\n" | |
8207 | "Do not send outside local AS (well-known community)\n" | |
8208 | "Do not advertise to any peer (well-known community)\n" | |
8209 | "Do not export to next AS (well-known community)\n" | |
8210 | "community number\n" | |
8211 | "Do not send outside local AS (well-known community)\n" | |
8212 | "Do not advertise to any peer (well-known community)\n" | |
8213 | "Do not export to next AS (well-known community)\n") | |
8214 | ||
8215 | /* old command */ | |
8216 | ALIAS (show_ipv6_bgp_community, | |
8217 | show_ipv6_bgp_community4_cmd, | |
8218 | "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)", | |
8219 | SHOW_STR | |
8220 | IPV6_STR | |
8221 | BGP_STR | |
8222 | "Display routes matching the communities\n" | |
8223 | "community number\n" | |
8224 | "Do not send outside local AS (well-known community)\n" | |
8225 | "Do not advertise to any peer (well-known community)\n" | |
8226 | "Do not export to next AS (well-known community)\n" | |
8227 | "community number\n" | |
8228 | "Do not send outside local AS (well-known community)\n" | |
8229 | "Do not advertise to any peer (well-known community)\n" | |
8230 | "Do not export to next AS (well-known community)\n" | |
8231 | "community number\n" | |
8232 | "Do not send outside local AS (well-known community)\n" | |
8233 | "Do not advertise to any peer (well-known community)\n" | |
8234 | "Do not export to next AS (well-known community)\n" | |
8235 | "community number\n" | |
8236 | "Do not send outside local AS (well-known community)\n" | |
8237 | "Do not advertise to any peer (well-known community)\n" | |
8238 | "Do not export to next AS (well-known community)\n") | |
8239 | ||
8240 | DEFUN (show_bgp_community_exact, | |
8241 | show_bgp_community_exact_cmd, | |
8242 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8243 | SHOW_STR | |
8244 | BGP_STR | |
8245 | "Display routes matching the communities\n" | |
8246 | "community number\n" | |
8247 | "Do not send outside local AS (well-known community)\n" | |
8248 | "Do not advertise to any peer (well-known community)\n" | |
8249 | "Do not export to next AS (well-known community)\n" | |
8250 | "Exact match of the communities") | |
8251 | { | |
8252 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); | |
8253 | } | |
8254 | ||
8255 | ALIAS (show_bgp_community_exact, | |
8256 | show_bgp_ipv6_community_exact_cmd, | |
8257 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8258 | SHOW_STR | |
8259 | BGP_STR | |
8260 | "Address family\n" | |
8261 | "Display routes matching the communities\n" | |
8262 | "community number\n" | |
8263 | "Do not send outside local AS (well-known community)\n" | |
8264 | "Do not advertise to any peer (well-known community)\n" | |
8265 | "Do not export to next AS (well-known community)\n" | |
8266 | "Exact match of the communities") | |
8267 | ||
8268 | ALIAS (show_bgp_community_exact, | |
8269 | show_bgp_community2_exact_cmd, | |
8270 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8271 | SHOW_STR | |
8272 | BGP_STR | |
8273 | "Display routes matching the communities\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 | "community number\n" | |
8279 | "Do not send outside local AS (well-known community)\n" | |
8280 | "Do not advertise to any peer (well-known community)\n" | |
8281 | "Do not export to next AS (well-known community)\n" | |
8282 | "Exact match of the communities") | |
8283 | ||
8284 | ALIAS (show_bgp_community_exact, | |
8285 | show_bgp_ipv6_community2_exact_cmd, | |
8286 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8287 | SHOW_STR | |
8288 | BGP_STR | |
8289 | "Address family\n" | |
8290 | "Display routes matching the communities\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 | "Exact match of the communities") | |
8300 | ||
8301 | ALIAS (show_bgp_community_exact, | |
8302 | show_bgp_community3_exact_cmd, | |
8303 | "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", | |
8304 | SHOW_STR | |
8305 | BGP_STR | |
8306 | "Display routes matching the communities\n" | |
8307 | "community number\n" | |
8308 | "Do not send outside local AS (well-known community)\n" | |
8309 | "Do not advertise to any peer (well-known community)\n" | |
8310 | "Do not export to next AS (well-known community)\n" | |
8311 | "community number\n" | |
8312 | "Do not send outside local AS (well-known community)\n" | |
8313 | "Do not advertise to any peer (well-known community)\n" | |
8314 | "Do not export to next AS (well-known community)\n" | |
8315 | "community number\n" | |
8316 | "Do not send outside local AS (well-known community)\n" | |
8317 | "Do not advertise to any peer (well-known community)\n" | |
8318 | "Do not export to next AS (well-known community)\n" | |
8319 | "Exact match of the communities") | |
8320 | ||
8321 | ALIAS (show_bgp_community_exact, | |
8322 | show_bgp_ipv6_community3_exact_cmd, | |
8323 | "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", | |
8324 | SHOW_STR | |
8325 | BGP_STR | |
8326 | "Address family\n" | |
8327 | "Display routes matching the communities\n" | |
8328 | "community number\n" | |
8329 | "Do not send outside local AS (well-known community)\n" | |
8330 | "Do not advertise to any peer (well-known community)\n" | |
8331 | "Do not export to next AS (well-known community)\n" | |
8332 | "community number\n" | |
8333 | "Do not send outside local AS (well-known community)\n" | |
8334 | "Do not advertise to any peer (well-known community)\n" | |
8335 | "Do not export to next AS (well-known community)\n" | |
8336 | "community number\n" | |
8337 | "Do not send outside local AS (well-known community)\n" | |
8338 | "Do not advertise to any peer (well-known community)\n" | |
8339 | "Do not export to next AS (well-known community)\n" | |
8340 | "Exact match of the communities") | |
8341 | ||
8342 | ALIAS (show_bgp_community_exact, | |
8343 | show_bgp_community4_exact_cmd, | |
8344 | "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", | |
8345 | SHOW_STR | |
8346 | BGP_STR | |
8347 | "Display routes matching the communities\n" | |
8348 | "community number\n" | |
8349 | "Do not send outside local AS (well-known community)\n" | |
8350 | "Do not advertise to any peer (well-known community)\n" | |
8351 | "Do not export to next AS (well-known community)\n" | |
8352 | "community number\n" | |
8353 | "Do not send outside local AS (well-known community)\n" | |
8354 | "Do not advertise to any peer (well-known community)\n" | |
8355 | "Do not export to next AS (well-known community)\n" | |
8356 | "community number\n" | |
8357 | "Do not send outside local AS (well-known community)\n" | |
8358 | "Do not advertise to any peer (well-known community)\n" | |
8359 | "Do not export to next AS (well-known community)\n" | |
8360 | "community number\n" | |
8361 | "Do not send outside local AS (well-known community)\n" | |
8362 | "Do not advertise to any peer (well-known community)\n" | |
8363 | "Do not export to next AS (well-known community)\n" | |
8364 | "Exact match of the communities") | |
8365 | ||
8366 | ALIAS (show_bgp_community_exact, | |
8367 | show_bgp_ipv6_community4_exact_cmd, | |
8368 | "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", | |
8369 | SHOW_STR | |
8370 | BGP_STR | |
8371 | "Address family\n" | |
8372 | "Display routes matching the communities\n" | |
8373 | "community number\n" | |
8374 | "Do not send outside local AS (well-known community)\n" | |
8375 | "Do not advertise to any peer (well-known community)\n" | |
8376 | "Do not export to next AS (well-known community)\n" | |
8377 | "community number\n" | |
8378 | "Do not send outside local AS (well-known community)\n" | |
8379 | "Do not advertise to any peer (well-known community)\n" | |
8380 | "Do not export to next AS (well-known community)\n" | |
8381 | "community number\n" | |
8382 | "Do not send outside local AS (well-known community)\n" | |
8383 | "Do not advertise to any peer (well-known community)\n" | |
8384 | "Do not export to next AS (well-known community)\n" | |
8385 | "community number\n" | |
8386 | "Do not send outside local AS (well-known community)\n" | |
8387 | "Do not advertise to any peer (well-known community)\n" | |
8388 | "Do not export to next AS (well-known community)\n" | |
8389 | "Exact match of the communities") | |
8390 | ||
8391 | /* old command */ | |
8392 | DEFUN (show_ipv6_bgp_community_exact, | |
8393 | show_ipv6_bgp_community_exact_cmd, | |
8394 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8395 | SHOW_STR | |
8396 | IPV6_STR | |
8397 | BGP_STR | |
8398 | "Display routes matching the communities\n" | |
8399 | "community number\n" | |
8400 | "Do not send outside local AS (well-known community)\n" | |
8401 | "Do not advertise to any peer (well-known community)\n" | |
8402 | "Do not export to next AS (well-known community)\n" | |
8403 | "Exact match of the communities") | |
8404 | { | |
8405 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); | |
8406 | } | |
8407 | ||
8408 | /* old command */ | |
8409 | ALIAS (show_ipv6_bgp_community_exact, | |
8410 | show_ipv6_bgp_community2_exact_cmd, | |
8411 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8412 | SHOW_STR | |
8413 | IPV6_STR | |
8414 | BGP_STR | |
8415 | "Display routes matching the communities\n" | |
8416 | "community number\n" | |
8417 | "Do not send outside local AS (well-known community)\n" | |
8418 | "Do not advertise to any peer (well-known community)\n" | |
8419 | "Do not export to next AS (well-known community)\n" | |
8420 | "community number\n" | |
8421 | "Do not send outside local AS (well-known community)\n" | |
8422 | "Do not advertise to any peer (well-known community)\n" | |
8423 | "Do not export to next AS (well-known community)\n" | |
8424 | "Exact match of the communities") | |
8425 | ||
8426 | /* old command */ | |
8427 | ALIAS (show_ipv6_bgp_community_exact, | |
8428 | show_ipv6_bgp_community3_exact_cmd, | |
8429 | "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", | |
8430 | SHOW_STR | |
8431 | IPV6_STR | |
8432 | BGP_STR | |
8433 | "Display routes matching the communities\n" | |
8434 | "community number\n" | |
8435 | "Do not send outside local AS (well-known community)\n" | |
8436 | "Do not advertise to any peer (well-known community)\n" | |
8437 | "Do not export to next AS (well-known community)\n" | |
8438 | "community number\n" | |
8439 | "Do not send outside local AS (well-known community)\n" | |
8440 | "Do not advertise to any peer (well-known community)\n" | |
8441 | "Do not export to next AS (well-known community)\n" | |
8442 | "community number\n" | |
8443 | "Do not send outside local AS (well-known community)\n" | |
8444 | "Do not advertise to any peer (well-known community)\n" | |
8445 | "Do not export to next AS (well-known community)\n" | |
8446 | "Exact match of the communities") | |
8447 | ||
8448 | /* old command */ | |
8449 | ALIAS (show_ipv6_bgp_community_exact, | |
8450 | show_ipv6_bgp_community4_exact_cmd, | |
8451 | "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", | |
8452 | SHOW_STR | |
8453 | IPV6_STR | |
8454 | BGP_STR | |
8455 | "Display routes matching the communities\n" | |
8456 | "community number\n" | |
8457 | "Do not send outside local AS (well-known community)\n" | |
8458 | "Do not advertise to any peer (well-known community)\n" | |
8459 | "Do not export to next AS (well-known community)\n" | |
8460 | "community number\n" | |
8461 | "Do not send outside local AS (well-known community)\n" | |
8462 | "Do not advertise to any peer (well-known community)\n" | |
8463 | "Do not export to next AS (well-known community)\n" | |
8464 | "community number\n" | |
8465 | "Do not send outside local AS (well-known community)\n" | |
8466 | "Do not advertise to any peer (well-known community)\n" | |
8467 | "Do not export to next AS (well-known community)\n" | |
8468 | "community number\n" | |
8469 | "Do not send outside local AS (well-known community)\n" | |
8470 | "Do not advertise to any peer (well-known community)\n" | |
8471 | "Do not export to next AS (well-known community)\n" | |
8472 | "Exact match of the communities") | |
8473 | ||
8474 | /* old command */ | |
8475 | DEFUN (show_ipv6_mbgp_community, | |
8476 | show_ipv6_mbgp_community_cmd, | |
8477 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", | |
8478 | SHOW_STR | |
8479 | IPV6_STR | |
8480 | MBGP_STR | |
8481 | "Display routes matching the communities\n" | |
8482 | "community number\n" | |
8483 | "Do not send outside local AS (well-known community)\n" | |
8484 | "Do not advertise to any peer (well-known community)\n" | |
8485 | "Do not export to next AS (well-known community)\n") | |
8486 | { | |
8487 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); | |
8488 | } | |
8489 | ||
8490 | /* old command */ | |
8491 | ALIAS (show_ipv6_mbgp_community, | |
8492 | show_ipv6_mbgp_community2_cmd, | |
8493 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", | |
8494 | SHOW_STR | |
8495 | IPV6_STR | |
8496 | MBGP_STR | |
8497 | "Display routes matching the communities\n" | |
8498 | "community number\n" | |
8499 | "Do not send outside local AS (well-known community)\n" | |
8500 | "Do not advertise to any peer (well-known community)\n" | |
8501 | "Do not export to next AS (well-known community)\n" | |
8502 | "community number\n" | |
8503 | "Do not send outside local AS (well-known community)\n" | |
8504 | "Do not advertise to any peer (well-known community)\n" | |
8505 | "Do not export to next AS (well-known community)\n") | |
8506 | ||
8507 | /* old command */ | |
8508 | ALIAS (show_ipv6_mbgp_community, | |
8509 | show_ipv6_mbgp_community3_cmd, | |
8510 | "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)", | |
8511 | SHOW_STR | |
8512 | IPV6_STR | |
8513 | MBGP_STR | |
8514 | "Display routes matching the communities\n" | |
8515 | "community number\n" | |
8516 | "Do not send outside local AS (well-known community)\n" | |
8517 | "Do not advertise to any peer (well-known community)\n" | |
8518 | "Do not export to next AS (well-known community)\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 | ||
8528 | /* old command */ | |
8529 | ALIAS (show_ipv6_mbgp_community, | |
8530 | show_ipv6_mbgp_community4_cmd, | |
8531 | "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)", | |
8532 | SHOW_STR | |
8533 | IPV6_STR | |
8534 | MBGP_STR | |
8535 | "Display routes matching the communities\n" | |
8536 | "community number\n" | |
8537 | "Do not send outside local AS (well-known community)\n" | |
8538 | "Do not advertise to any peer (well-known community)\n" | |
8539 | "Do not export to next AS (well-known community)\n" | |
8540 | "community number\n" | |
8541 | "Do not send outside local AS (well-known community)\n" | |
8542 | "Do not advertise to any peer (well-known community)\n" | |
8543 | "Do not export to next AS (well-known community)\n" | |
8544 | "community number\n" | |
8545 | "Do not send outside local AS (well-known community)\n" | |
8546 | "Do not advertise to any peer (well-known community)\n" | |
8547 | "Do not export to next AS (well-known community)\n" | |
8548 | "community number\n" | |
8549 | "Do not send outside local AS (well-known community)\n" | |
8550 | "Do not advertise to any peer (well-known community)\n" | |
8551 | "Do not export to next AS (well-known community)\n") | |
8552 | ||
8553 | /* old command */ | |
8554 | DEFUN (show_ipv6_mbgp_community_exact, | |
8555 | show_ipv6_mbgp_community_exact_cmd, | |
8556 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8557 | SHOW_STR | |
8558 | IPV6_STR | |
8559 | MBGP_STR | |
8560 | "Display routes matching the communities\n" | |
8561 | "community number\n" | |
8562 | "Do not send outside local AS (well-known community)\n" | |
8563 | "Do not advertise to any peer (well-known community)\n" | |
8564 | "Do not export to next AS (well-known community)\n" | |
8565 | "Exact match of the communities") | |
8566 | { | |
8567 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); | |
8568 | } | |
8569 | ||
8570 | /* old command */ | |
8571 | ALIAS (show_ipv6_mbgp_community_exact, | |
8572 | show_ipv6_mbgp_community2_exact_cmd, | |
8573 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", | |
8574 | SHOW_STR | |
8575 | IPV6_STR | |
8576 | MBGP_STR | |
8577 | "Display routes matching the communities\n" | |
8578 | "community number\n" | |
8579 | "Do not send outside local AS (well-known community)\n" | |
8580 | "Do not advertise to any peer (well-known community)\n" | |
8581 | "Do not export to next AS (well-known community)\n" | |
8582 | "community number\n" | |
8583 | "Do not send outside local AS (well-known community)\n" | |
8584 | "Do not advertise to any peer (well-known community)\n" | |
8585 | "Do not export to next AS (well-known community)\n" | |
8586 | "Exact match of the communities") | |
8587 | ||
8588 | /* old command */ | |
8589 | ALIAS (show_ipv6_mbgp_community_exact, | |
8590 | show_ipv6_mbgp_community3_exact_cmd, | |
8591 | "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", | |
8592 | SHOW_STR | |
8593 | IPV6_STR | |
8594 | MBGP_STR | |
8595 | "Display routes matching the communities\n" | |
8596 | "community number\n" | |
8597 | "Do not send outside local AS (well-known community)\n" | |
8598 | "Do not advertise to any peer (well-known community)\n" | |
8599 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") | |
8609 | ||
8610 | /* old command */ | |
8611 | ALIAS (show_ipv6_mbgp_community_exact, | |
8612 | show_ipv6_mbgp_community4_exact_cmd, | |
8613 | "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", | |
8614 | SHOW_STR | |
8615 | IPV6_STR | |
8616 | MBGP_STR | |
8617 | "Display routes matching the communities\n" | |
8618 | "community number\n" | |
8619 | "Do not send outside local AS (well-known community)\n" | |
8620 | "Do not advertise to any peer (well-known community)\n" | |
8621 | "Do not export to next AS (well-known community)\n" | |
8622 | "community number\n" | |
8623 | "Do not send outside local AS (well-known community)\n" | |
8624 | "Do not advertise to any peer (well-known community)\n" | |
8625 | "Do not export to next AS (well-known community)\n" | |
8626 | "community number\n" | |
8627 | "Do not send outside local AS (well-known community)\n" | |
8628 | "Do not advertise to any peer (well-known community)\n" | |
8629 | "Do not export to next AS (well-known community)\n" | |
8630 | "community number\n" | |
8631 | "Do not send outside local AS (well-known community)\n" | |
8632 | "Do not advertise to any peer (well-known community)\n" | |
8633 | "Do not export to next AS (well-known community)\n" | |
8634 | "Exact match of the communities") | |
8635 | #endif /* HAVE_IPV6 */ | |
8636 | \f | |
94f2b392 | 8637 | static int |
fd79ac91 | 8638 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
4c9641ba | 8639 | afi_t afi, safi_t safi) |
718e3744 | 8640 | { |
8641 | struct community_list *list; | |
8642 | ||
fee6e4e4 | 8643 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
718e3744 | 8644 | if (list == NULL) |
8645 | { | |
8646 | vty_out (vty, "%% %s is not a valid community-list name%s", com, | |
8647 | VTY_NEWLINE); | |
8648 | return CMD_WARNING; | |
8649 | } | |
8650 | ||
5a646650 | 8651 | return bgp_show (vty, NULL, afi, safi, |
8652 | (exact ? bgp_show_type_community_list_exact : | |
8653 | bgp_show_type_community_list), list); | |
718e3744 | 8654 | } |
8655 | ||
8656 | DEFUN (show_ip_bgp_community_list, | |
8657 | show_ip_bgp_community_list_cmd, | |
fee6e4e4 | 8658 | "show ip bgp community-list (<1-500>|WORD)", |
718e3744 | 8659 | SHOW_STR |
8660 | IP_STR | |
8661 | BGP_STR | |
8662 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8663 | "community-list number\n" |
718e3744 | 8664 | "community-list name\n") |
8665 | { | |
8666 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); | |
8667 | } | |
8668 | ||
8669 | DEFUN (show_ip_bgp_ipv4_community_list, | |
8670 | show_ip_bgp_ipv4_community_list_cmd, | |
fee6e4e4 | 8671 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
718e3744 | 8672 | SHOW_STR |
8673 | IP_STR | |
8674 | BGP_STR | |
8675 | "Address family\n" | |
8676 | "Address Family modifier\n" | |
8677 | "Address Family modifier\n" | |
8678 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8679 | "community-list number\n" |
718e3744 | 8680 | "community-list name\n") |
8681 | { | |
8682 | if (strncmp (argv[0], "m", 1) == 0) | |
8683 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); | |
8684 | ||
8685 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); | |
8686 | } | |
8687 | ||
8688 | DEFUN (show_ip_bgp_community_list_exact, | |
8689 | show_ip_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8690 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8691 | SHOW_STR |
8692 | IP_STR | |
8693 | BGP_STR | |
8694 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8695 | "community-list number\n" |
718e3744 | 8696 | "community-list name\n" |
8697 | "Exact match of the communities\n") | |
8698 | { | |
8699 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); | |
8700 | } | |
8701 | ||
8702 | DEFUN (show_ip_bgp_ipv4_community_list_exact, | |
8703 | show_ip_bgp_ipv4_community_list_exact_cmd, | |
fee6e4e4 | 8704 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
718e3744 | 8705 | SHOW_STR |
8706 | IP_STR | |
8707 | BGP_STR | |
8708 | "Address family\n" | |
8709 | "Address Family modifier\n" | |
8710 | "Address Family modifier\n" | |
8711 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8712 | "community-list number\n" |
718e3744 | 8713 | "community-list name\n" |
8714 | "Exact match of the communities\n") | |
8715 | { | |
8716 | if (strncmp (argv[0], "m", 1) == 0) | |
8717 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); | |
8718 | ||
8719 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); | |
8720 | } | |
8721 | ||
8722 | #ifdef HAVE_IPV6 | |
8723 | DEFUN (show_bgp_community_list, | |
8724 | show_bgp_community_list_cmd, | |
fee6e4e4 | 8725 | "show bgp community-list (<1-500>|WORD)", |
718e3744 | 8726 | SHOW_STR |
8727 | BGP_STR | |
8728 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8729 | "community-list number\n" |
718e3744 | 8730 | "community-list name\n") |
8731 | { | |
8732 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8733 | } | |
8734 | ||
8735 | ALIAS (show_bgp_community_list, | |
8736 | show_bgp_ipv6_community_list_cmd, | |
fee6e4e4 | 8737 | "show bgp ipv6 community-list (<1-500>|WORD)", |
718e3744 | 8738 | SHOW_STR |
8739 | BGP_STR | |
8740 | "Address family\n" | |
8741 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8742 | "community-list number\n" |
e8e1946e | 8743 | "community-list name\n") |
718e3744 | 8744 | |
8745 | /* old command */ | |
8746 | DEFUN (show_ipv6_bgp_community_list, | |
8747 | show_ipv6_bgp_community_list_cmd, | |
8748 | "show ipv6 bgp community-list WORD", | |
8749 | SHOW_STR | |
8750 | IPV6_STR | |
8751 | BGP_STR | |
8752 | "Display routes matching the community-list\n" | |
8753 | "community-list name\n") | |
8754 | { | |
8755 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); | |
8756 | } | |
8757 | ||
8758 | /* old command */ | |
8759 | DEFUN (show_ipv6_mbgp_community_list, | |
8760 | show_ipv6_mbgp_community_list_cmd, | |
8761 | "show ipv6 mbgp community-list WORD", | |
8762 | SHOW_STR | |
8763 | IPV6_STR | |
8764 | MBGP_STR | |
8765 | "Display routes matching the community-list\n" | |
8766 | "community-list name\n") | |
8767 | { | |
8768 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); | |
8769 | } | |
8770 | ||
8771 | DEFUN (show_bgp_community_list_exact, | |
8772 | show_bgp_community_list_exact_cmd, | |
fee6e4e4 | 8773 | "show bgp community-list (<1-500>|WORD) exact-match", |
718e3744 | 8774 | SHOW_STR |
8775 | BGP_STR | |
8776 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8777 | "community-list number\n" |
718e3744 | 8778 | "community-list name\n" |
8779 | "Exact match of the communities\n") | |
8780 | { | |
8781 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
8782 | } | |
8783 | ||
8784 | ALIAS (show_bgp_community_list_exact, | |
8785 | show_bgp_ipv6_community_list_exact_cmd, | |
fee6e4e4 | 8786 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
718e3744 | 8787 | SHOW_STR |
8788 | BGP_STR | |
8789 | "Address family\n" | |
8790 | "Display routes matching the community-list\n" | |
fee6e4e4 | 8791 | "community-list number\n" |
718e3744 | 8792 | "community-list name\n" |
8793 | "Exact match of the communities\n") | |
8794 | ||
8795 | /* old command */ | |
8796 | DEFUN (show_ipv6_bgp_community_list_exact, | |
8797 | show_ipv6_bgp_community_list_exact_cmd, | |
8798 | "show ipv6 bgp community-list WORD exact-match", | |
8799 | SHOW_STR | |
8800 | IPV6_STR | |
8801 | BGP_STR | |
8802 | "Display routes matching the community-list\n" | |
8803 | "community-list name\n" | |
8804 | "Exact match of the communities\n") | |
8805 | { | |
8806 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); | |
8807 | } | |
8808 | ||
8809 | /* old command */ | |
8810 | DEFUN (show_ipv6_mbgp_community_list_exact, | |
8811 | show_ipv6_mbgp_community_list_exact_cmd, | |
8812 | "show ipv6 mbgp community-list WORD exact-match", | |
8813 | SHOW_STR | |
8814 | IPV6_STR | |
8815 | MBGP_STR | |
8816 | "Display routes matching the community-list\n" | |
8817 | "community-list name\n" | |
8818 | "Exact match of the communities\n") | |
8819 | { | |
8820 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); | |
8821 | } | |
8822 | #endif /* HAVE_IPV6 */ | |
8823 | \f | |
94f2b392 | 8824 | static int |
fd79ac91 | 8825 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
718e3744 | 8826 | safi_t safi, enum bgp_show_type type) |
8827 | { | |
8828 | int ret; | |
8829 | struct prefix *p; | |
8830 | ||
8831 | p = prefix_new(); | |
8832 | ||
8833 | ret = str2prefix (prefix, p); | |
8834 | if (! ret) | |
8835 | { | |
8836 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); | |
8837 | return CMD_WARNING; | |
8838 | } | |
8839 | ||
5a646650 | 8840 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
8841 | prefix_free(p); | |
8842 | return ret; | |
718e3744 | 8843 | } |
8844 | ||
8845 | DEFUN (show_ip_bgp_prefix_longer, | |
8846 | show_ip_bgp_prefix_longer_cmd, | |
8847 | "show ip bgp A.B.C.D/M longer-prefixes", | |
8848 | SHOW_STR | |
8849 | IP_STR | |
8850 | BGP_STR | |
8851 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8852 | "Display route and more specific routes\n") | |
8853 | { | |
8854 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8855 | bgp_show_type_prefix_longer); | |
8856 | } | |
8857 | ||
8858 | DEFUN (show_ip_bgp_flap_prefix_longer, | |
8859 | show_ip_bgp_flap_prefix_longer_cmd, | |
8860 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", | |
8861 | SHOW_STR | |
8862 | IP_STR | |
8863 | BGP_STR | |
8864 | "Display flap statistics of routes\n" | |
8865 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8866 | "Display route and more specific routes\n") | |
8867 | { | |
8868 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8869 | bgp_show_type_flap_prefix_longer); | |
8870 | } | |
8871 | ||
8872 | DEFUN (show_ip_bgp_ipv4_prefix_longer, | |
8873 | show_ip_bgp_ipv4_prefix_longer_cmd, | |
8874 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", | |
8875 | SHOW_STR | |
8876 | IP_STR | |
8877 | BGP_STR | |
8878 | "Address family\n" | |
8879 | "Address Family modifier\n" | |
8880 | "Address Family modifier\n" | |
8881 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
8882 | "Display route and more specific routes\n") | |
8883 | { | |
8884 | if (strncmp (argv[0], "m", 1) == 0) | |
8885 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, | |
8886 | bgp_show_type_prefix_longer); | |
8887 | ||
8888 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, | |
8889 | bgp_show_type_prefix_longer); | |
8890 | } | |
8891 | ||
8892 | DEFUN (show_ip_bgp_flap_address, | |
8893 | show_ip_bgp_flap_address_cmd, | |
8894 | "show ip bgp flap-statistics A.B.C.D", | |
8895 | SHOW_STR | |
8896 | IP_STR | |
8897 | BGP_STR | |
8898 | "Display flap statistics of routes\n" | |
8899 | "Network in the BGP routing table to display\n") | |
8900 | { | |
8901 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8902 | bgp_show_type_flap_address); | |
8903 | } | |
8904 | ||
8905 | DEFUN (show_ip_bgp_flap_prefix, | |
8906 | show_ip_bgp_flap_prefix_cmd, | |
8907 | "show ip bgp flap-statistics A.B.C.D/M", | |
8908 | SHOW_STR | |
8909 | IP_STR | |
8910 | BGP_STR | |
8911 | "Display flap statistics of routes\n" | |
8912 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
8913 | { | |
8914 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, | |
8915 | bgp_show_type_flap_prefix); | |
8916 | } | |
8917 | #ifdef HAVE_IPV6 | |
8918 | DEFUN (show_bgp_prefix_longer, | |
8919 | show_bgp_prefix_longer_cmd, | |
8920 | "show bgp X:X::X:X/M longer-prefixes", | |
8921 | SHOW_STR | |
8922 | BGP_STR | |
8923 | "IPv6 prefix <network>/<length>\n" | |
8924 | "Display route and more specific routes\n") | |
8925 | { | |
8926 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
8927 | bgp_show_type_prefix_longer); | |
8928 | } | |
8929 | ||
8930 | ALIAS (show_bgp_prefix_longer, | |
8931 | show_bgp_ipv6_prefix_longer_cmd, | |
8932 | "show bgp ipv6 X:X::X:X/M longer-prefixes", | |
8933 | SHOW_STR | |
8934 | BGP_STR | |
8935 | "Address family\n" | |
8936 | "IPv6 prefix <network>/<length>\n" | |
8937 | "Display route and more specific routes\n") | |
8938 | ||
8939 | /* old command */ | |
8940 | DEFUN (show_ipv6_bgp_prefix_longer, | |
8941 | show_ipv6_bgp_prefix_longer_cmd, | |
8942 | "show ipv6 bgp X:X::X:X/M longer-prefixes", | |
8943 | SHOW_STR | |
8944 | IPV6_STR | |
8945 | BGP_STR | |
8946 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
8947 | "Display route and more specific routes\n") | |
8948 | { | |
8949 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, | |
8950 | bgp_show_type_prefix_longer); | |
8951 | } | |
8952 | ||
8953 | /* old command */ | |
8954 | DEFUN (show_ipv6_mbgp_prefix_longer, | |
8955 | show_ipv6_mbgp_prefix_longer_cmd, | |
8956 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", | |
8957 | SHOW_STR | |
8958 | IPV6_STR | |
8959 | MBGP_STR | |
8960 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" | |
8961 | "Display route and more specific routes\n") | |
8962 | { | |
8963 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, | |
8964 | bgp_show_type_prefix_longer); | |
8965 | } | |
8966 | #endif /* HAVE_IPV6 */ | |
bb46e94f | 8967 | |
94f2b392 | 8968 | static struct peer * |
fd79ac91 | 8969 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
8970 | const char *ip_str) | |
bb46e94f | 8971 | { |
8972 | int ret; | |
8973 | struct bgp *bgp; | |
8974 | struct peer *peer; | |
8975 | union sockunion su; | |
8976 | ||
8977 | /* BGP structure lookup. */ | |
8978 | if (view_name) | |
8979 | { | |
8980 | bgp = bgp_lookup_by_name (view_name); | |
8981 | if (! bgp) | |
8982 | { | |
8983 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
8984 | return NULL; | |
8985 | } | |
8986 | } | |
5228ad27 | 8987 | else |
bb46e94f | 8988 | { |
8989 | bgp = bgp_get_default (); | |
8990 | if (! bgp) | |
8991 | { | |
8992 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
8993 | return NULL; | |
8994 | } | |
8995 | } | |
8996 | ||
8997 | /* Get peer sockunion. */ | |
8998 | ret = str2sockunion (ip_str, &su); | |
8999 | if (ret < 0) | |
9000 | { | |
9001 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); | |
9002 | return NULL; | |
9003 | } | |
9004 | ||
9005 | /* Peer structure lookup. */ | |
9006 | peer = peer_lookup (bgp, &su); | |
9007 | if (! peer) | |
9008 | { | |
9009 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); | |
9010 | return NULL; | |
9011 | } | |
9012 | ||
9013 | return peer; | |
9014 | } | |
2815e61f PJ |
9015 | \f |
9016 | enum bgp_stats | |
9017 | { | |
9018 | BGP_STATS_MAXBITLEN = 0, | |
9019 | BGP_STATS_RIB, | |
9020 | BGP_STATS_PREFIXES, | |
9021 | BGP_STATS_TOTPLEN, | |
9022 | BGP_STATS_UNAGGREGATEABLE, | |
9023 | BGP_STATS_MAX_AGGREGATEABLE, | |
9024 | BGP_STATS_AGGREGATES, | |
9025 | BGP_STATS_SPACE, | |
9026 | BGP_STATS_ASPATH_COUNT, | |
9027 | BGP_STATS_ASPATH_MAXHOPS, | |
9028 | BGP_STATS_ASPATH_TOTHOPS, | |
9029 | BGP_STATS_ASPATH_MAXSIZE, | |
9030 | BGP_STATS_ASPATH_TOTSIZE, | |
9031 | BGP_STATS_ASN_HIGHEST, | |
9032 | BGP_STATS_MAX, | |
9033 | }; | |
9034 | ||
9035 | static const char *table_stats_strs[] = | |
9036 | { | |
9037 | [BGP_STATS_PREFIXES] = "Total Prefixes", | |
9038 | [BGP_STATS_TOTPLEN] = "Average prefix length", | |
9039 | [BGP_STATS_RIB] = "Total Advertisements", | |
9040 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", | |
9041 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", | |
9042 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", | |
9043 | [BGP_STATS_SPACE] = "Address space advertised", | |
9044 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", | |
9045 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", | |
9046 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", | |
9047 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", | |
9048 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", | |
9049 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", | |
9050 | [BGP_STATS_MAX] = NULL, | |
9051 | }; | |
9052 | ||
9053 | struct bgp_table_stats | |
9054 | { | |
9055 | struct bgp_table *table; | |
9056 | unsigned long long counts[BGP_STATS_MAX]; | |
9057 | }; | |
9058 | ||
9059 | #if 0 | |
9060 | #define TALLY_SIGFIG 100000 | |
9061 | static unsigned long | |
9062 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) | |
9063 | { | |
9064 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); | |
9065 | unsigned long res = (newtot * TALLY_SIGFIG) / count; | |
9066 | unsigned long ret = newtot / count; | |
9067 | ||
9068 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) | |
9069 | return ret + 1; | |
9070 | else | |
9071 | return ret; | |
9072 | } | |
9073 | #endif | |
9074 | ||
9075 | static int | |
9076 | bgp_table_stats_walker (struct thread *t) | |
9077 | { | |
9078 | struct bgp_node *rn; | |
9079 | struct bgp_node *top; | |
9080 | struct bgp_table_stats *ts = THREAD_ARG (t); | |
9081 | unsigned int space = 0; | |
9082 | ||
53d9f67a PJ |
9083 | if (!(top = bgp_table_top (ts->table))) |
9084 | return 0; | |
2815e61f PJ |
9085 | |
9086 | switch (top->p.family) | |
9087 | { | |
9088 | case AF_INET: | |
9089 | space = IPV4_MAX_BITLEN; | |
9090 | break; | |
9091 | case AF_INET6: | |
9092 | space = IPV6_MAX_BITLEN; | |
9093 | break; | |
9094 | } | |
9095 | ||
9096 | ts->counts[BGP_STATS_MAXBITLEN] = space; | |
9097 | ||
9098 | for (rn = top; rn; rn = bgp_route_next (rn)) | |
9099 | { | |
9100 | struct bgp_info *ri; | |
9101 | struct bgp_node *prn = rn->parent; | |
9102 | unsigned int rinum = 0; | |
9103 | ||
9104 | if (rn == top) | |
9105 | continue; | |
9106 | ||
9107 | if (!rn->info) | |
9108 | continue; | |
9109 | ||
9110 | ts->counts[BGP_STATS_PREFIXES]++; | |
9111 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; | |
9112 | ||
9113 | #if 0 | |
9114 | ts->counts[BGP_STATS_AVGPLEN] | |
9115 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], | |
9116 | ts->counts[BGP_STATS_AVGPLEN], | |
9117 | rn->p.prefixlen); | |
9118 | #endif | |
9119 | ||
9120 | /* check if the prefix is included by any other announcements */ | |
9121 | while (prn && !prn->info) | |
9122 | prn = prn->parent; | |
9123 | ||
9124 | if (prn == NULL || prn == top) | |
8383a9bd PJ |
9125 | { |
9126 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; | |
9127 | /* announced address space */ | |
9128 | if (space) | |
9129 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); | |
9130 | } | |
2815e61f PJ |
9131 | else if (prn->info) |
9132 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; | |
9133 | ||
2815e61f PJ |
9134 | for (ri = rn->info; ri; ri = ri->next) |
9135 | { | |
9136 | rinum++; | |
9137 | ts->counts[BGP_STATS_RIB]++; | |
9138 | ||
9139 | if (ri->attr && | |
9140 | (CHECK_FLAG (ri->attr->flag, | |
9141 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) | |
9142 | ts->counts[BGP_STATS_AGGREGATES]++; | |
9143 | ||
9144 | /* as-path stats */ | |
9145 | if (ri->attr && ri->attr->aspath) | |
9146 | { | |
9147 | unsigned int hops = aspath_count_hops (ri->attr->aspath); | |
9148 | unsigned int size = aspath_size (ri->attr->aspath); | |
9149 | as_t highest = aspath_highest (ri->attr->aspath); | |
9150 | ||
9151 | ts->counts[BGP_STATS_ASPATH_COUNT]++; | |
9152 | ||
9153 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) | |
9154 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; | |
9155 | ||
9156 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) | |
9157 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; | |
9158 | ||
9159 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; | |
9160 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; | |
9161 | #if 0 | |
9162 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] | |
9163 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9164 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], | |
9165 | hops); | |
9166 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] | |
9167 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], | |
9168 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], | |
9169 | size); | |
9170 | #endif | |
9171 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) | |
9172 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; | |
9173 | } | |
9174 | } | |
9175 | } | |
9176 | return 0; | |
9177 | } | |
9178 | ||
9179 | static int | |
9180 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) | |
9181 | { | |
9182 | struct bgp_table_stats ts; | |
9183 | unsigned int i; | |
9184 | ||
9185 | if (!bgp->rib[afi][safi]) | |
9186 | { | |
9187 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); | |
9188 | return CMD_WARNING; | |
9189 | } | |
9190 | ||
9191 | memset (&ts, 0, sizeof (ts)); | |
9192 | ts.table = bgp->rib[afi][safi]; | |
9193 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); | |
bb46e94f | 9194 | |
2815e61f PJ |
9195 | vty_out (vty, "BGP %s RIB statistics%s%s", |
9196 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); | |
9197 | ||
9198 | for (i = 0; i < BGP_STATS_MAX; i++) | |
9199 | { | |
9200 | if (!table_stats_strs[i]) | |
9201 | continue; | |
9202 | ||
9203 | switch (i) | |
9204 | { | |
9205 | #if 0 | |
9206 | case BGP_STATS_ASPATH_AVGHOPS: | |
9207 | case BGP_STATS_ASPATH_AVGSIZE: | |
9208 | case BGP_STATS_AVGPLEN: | |
9209 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9210 | vty_out (vty, "%12.2f", | |
9211 | (float)ts.counts[i] / (float)TALLY_SIGFIG); | |
9212 | break; | |
9213 | #endif | |
9214 | case BGP_STATS_ASPATH_TOTHOPS: | |
9215 | case BGP_STATS_ASPATH_TOTSIZE: | |
9216 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9217 | vty_out (vty, "%12.2f", | |
9218 | ts.counts[i] ? | |
9219 | (float)ts.counts[i] / | |
9220 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] | |
9221 | : 0); | |
9222 | break; | |
9223 | case BGP_STATS_TOTPLEN: | |
9224 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9225 | vty_out (vty, "%12.2f", | |
9226 | ts.counts[i] ? | |
9227 | (float)ts.counts[i] / | |
9228 | (float)ts.counts[BGP_STATS_PREFIXES] | |
9229 | : 0); | |
9230 | break; | |
9231 | case BGP_STATS_SPACE: | |
9232 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9233 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); | |
9234 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) | |
9235 | break; | |
30a2231a | 9236 | vty_out (vty, "%30s: ", "%% announced "); |
2815e61f PJ |
9237 | vty_out (vty, "%12.2f%s", |
9238 | 100 * (float)ts.counts[BGP_STATS_SPACE] / | |
56395af7 | 9239 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
2815e61f PJ |
9240 | VTY_NEWLINE); |
9241 | vty_out (vty, "%30s: ", "/8 equivalent "); | |
9242 | vty_out (vty, "%12.2f%s", | |
9243 | (float)ts.counts[BGP_STATS_SPACE] / | |
9244 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), | |
9245 | VTY_NEWLINE); | |
9246 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) | |
9247 | break; | |
9248 | vty_out (vty, "%30s: ", "/24 equivalent "); | |
9249 | vty_out (vty, "%12.2f", | |
9250 | (float)ts.counts[BGP_STATS_SPACE] / | |
9251 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); | |
9252 | break; | |
9253 | default: | |
9254 | vty_out (vty, "%-30s: ", table_stats_strs[i]); | |
9255 | vty_out (vty, "%12llu", ts.counts[i]); | |
9256 | } | |
9257 | ||
9258 | vty_out (vty, "%s", VTY_NEWLINE); | |
9259 | } | |
9260 | return CMD_SUCCESS; | |
9261 | } | |
9262 | ||
9263 | static int | |
9264 | bgp_table_stats_vty (struct vty *vty, const char *name, | |
9265 | const char *afi_str, const char *safi_str) | |
9266 | { | |
9267 | struct bgp *bgp; | |
9268 | afi_t afi; | |
9269 | safi_t safi; | |
9270 | ||
9271 | if (name) | |
9272 | bgp = bgp_lookup_by_name (name); | |
9273 | else | |
9274 | bgp = bgp_get_default (); | |
9275 | ||
9276 | if (!bgp) | |
9277 | { | |
9278 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9279 | return CMD_WARNING; | |
9280 | } | |
9281 | if (strncmp (afi_str, "ipv", 3) == 0) | |
9282 | { | |
9283 | if (strncmp (afi_str, "ipv4", 4) == 0) | |
9284 | afi = AFI_IP; | |
9285 | else if (strncmp (afi_str, "ipv6", 4) == 0) | |
9286 | afi = AFI_IP6; | |
9287 | else | |
9288 | { | |
9289 | vty_out (vty, "%% Invalid address family %s%s", | |
9290 | afi_str, VTY_NEWLINE); | |
9291 | return CMD_WARNING; | |
9292 | } | |
9293 | if (strncmp (safi_str, "m", 1) == 0) | |
9294 | safi = SAFI_MULTICAST; | |
9295 | else if (strncmp (safi_str, "u", 1) == 0) | |
9296 | safi = SAFI_UNICAST; | |
9297 | else if (strncmp (safi_str, "vpnv4", 5) == 0) | |
9298 | safi = BGP_SAFI_VPNV4; | |
9299 | else if (strncmp (safi_str, "vpnv6", 6) == 0) | |
9300 | safi = BGP_SAFI_VPNV6; | |
9301 | else | |
9302 | { | |
9303 | vty_out (vty, "%% Invalid subsequent address family %s%s", | |
9304 | safi_str, VTY_NEWLINE); | |
9305 | return CMD_WARNING; | |
9306 | } | |
9307 | } | |
9308 | else | |
9309 | { | |
9310 | vty_out (vty, "%% Invalid address family %s%s", | |
9311 | afi_str, VTY_NEWLINE); | |
9312 | return CMD_WARNING; | |
9313 | } | |
9314 | ||
9315 | if ((afi == AFI_IP && safi == BGP_SAFI_VPNV6) | |
9316 | || (afi == AFI_IP6 && safi == BGP_SAFI_VPNV4)) | |
9317 | { | |
9318 | vty_out (vty, "%% Invalid subsequent address family %s for %s%s", | |
9319 | afi_str, safi_str, VTY_NEWLINE); | |
9320 | return CMD_WARNING; | |
9321 | } | |
9322 | return bgp_table_stats (vty, bgp, afi, safi); | |
9323 | } | |
9324 | ||
9325 | DEFUN (show_bgp_statistics, | |
9326 | show_bgp_statistics_cmd, | |
9327 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", | |
9328 | SHOW_STR | |
9329 | BGP_STR | |
9330 | "Address family\n" | |
9331 | "Address family\n" | |
9332 | "Address Family modifier\n" | |
9333 | "Address Family modifier\n" | |
9334 | "BGP RIB advertisement statistics\n") | |
9335 | { | |
9336 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9337 | } | |
9338 | ||
9339 | ALIAS (show_bgp_statistics, | |
9340 | show_bgp_statistics_vpnv4_cmd, | |
9341 | "show bgp (ipv4) (vpnv4) statistics", | |
9342 | SHOW_STR | |
9343 | BGP_STR | |
9344 | "Address family\n" | |
9345 | "Address Family modifier\n" | |
9346 | "BGP RIB advertisement statistics\n") | |
9347 | ||
9348 | DEFUN (show_bgp_statistics_view, | |
9349 | show_bgp_statistics_view_cmd, | |
9350 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", | |
9351 | SHOW_STR | |
9352 | BGP_STR | |
9353 | "BGP view\n" | |
9354 | "Address family\n" | |
9355 | "Address family\n" | |
9356 | "Address Family modifier\n" | |
9357 | "Address Family modifier\n" | |
9358 | "BGP RIB advertisement statistics\n") | |
9359 | { | |
9360 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); | |
9361 | } | |
9362 | ||
9363 | ALIAS (show_bgp_statistics_view, | |
9364 | show_bgp_statistics_view_vpnv4_cmd, | |
9365 | "show bgp view WORD (ipv4) (vpnv4) statistics", | |
9366 | SHOW_STR | |
9367 | BGP_STR | |
9368 | "BGP view\n" | |
9369 | "Address family\n" | |
9370 | "Address Family modifier\n" | |
9371 | "BGP RIB advertisement statistics\n") | |
9372 | \f | |
ff7924f6 PJ |
9373 | enum bgp_pcounts |
9374 | { | |
9375 | PCOUNT_ADJ_IN = 0, | |
9376 | PCOUNT_DAMPED, | |
9377 | PCOUNT_REMOVED, | |
9378 | PCOUNT_HISTORY, | |
9379 | PCOUNT_STALE, | |
9380 | PCOUNT_VALID, | |
9381 | PCOUNT_ALL, | |
9382 | PCOUNT_COUNTED, | |
9383 | PCOUNT_PFCNT, /* the figure we display to users */ | |
9384 | PCOUNT_MAX, | |
9385 | }; | |
9386 | ||
9387 | static const char *pcount_strs[] = | |
9388 | { | |
9389 | [PCOUNT_ADJ_IN] = "Adj-in", | |
9390 | [PCOUNT_DAMPED] = "Damped", | |
9391 | [PCOUNT_REMOVED] = "Removed", | |
9392 | [PCOUNT_HISTORY] = "History", | |
9393 | [PCOUNT_STALE] = "Stale", | |
9394 | [PCOUNT_VALID] = "Valid", | |
9395 | [PCOUNT_ALL] = "All RIB", | |
9396 | [PCOUNT_COUNTED] = "PfxCt counted", | |
9397 | [PCOUNT_PFCNT] = "Useable", | |
9398 | [PCOUNT_MAX] = NULL, | |
9399 | }; | |
9400 | ||
2815e61f PJ |
9401 | struct peer_pcounts |
9402 | { | |
9403 | unsigned int count[PCOUNT_MAX]; | |
9404 | const struct peer *peer; | |
9405 | const struct bgp_table *table; | |
9406 | }; | |
9407 | ||
ff7924f6 | 9408 | static int |
2815e61f | 9409 | bgp_peer_count_walker (struct thread *t) |
ff7924f6 PJ |
9410 | { |
9411 | struct bgp_node *rn; | |
2815e61f PJ |
9412 | struct peer_pcounts *pc = THREAD_ARG (t); |
9413 | const struct peer *peer = pc->peer; | |
ff7924f6 | 9414 | |
2815e61f | 9415 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
ff7924f6 PJ |
9416 | { |
9417 | struct bgp_adj_in *ain; | |
2815e61f | 9418 | struct bgp_info *ri; |
ff7924f6 PJ |
9419 | |
9420 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9421 | if (ain->peer == peer) | |
2815e61f | 9422 | pc->count[PCOUNT_ADJ_IN]++; |
ff7924f6 | 9423 | |
ff7924f6 PJ |
9424 | for (ri = rn->info; ri; ri = ri->next) |
9425 | { | |
9426 | char buf[SU_ADDRSTRLEN]; | |
9427 | ||
9428 | if (ri->peer != peer) | |
9429 | continue; | |
9430 | ||
2815e61f | 9431 | pc->count[PCOUNT_ALL]++; |
ff7924f6 PJ |
9432 | |
9433 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) | |
2815e61f | 9434 | pc->count[PCOUNT_DAMPED]++; |
ff7924f6 | 9435 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
2815e61f | 9436 | pc->count[PCOUNT_HISTORY]++; |
ff7924f6 | 9437 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
2815e61f | 9438 | pc->count[PCOUNT_REMOVED]++; |
ff7924f6 | 9439 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
2815e61f | 9440 | pc->count[PCOUNT_STALE]++; |
ff7924f6 | 9441 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
2815e61f | 9442 | pc->count[PCOUNT_VALID]++; |
1a392d46 | 9443 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
2815e61f | 9444 | pc->count[PCOUNT_PFCNT]++; |
ff7924f6 PJ |
9445 | |
9446 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) | |
9447 | { | |
2815e61f | 9448 | pc->count[PCOUNT_COUNTED]++; |
1a392d46 | 9449 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9450 | plog_warn (peer->log, |
9451 | "%s [pcount] %s/%d is counted but flags 0x%x", | |
9452 | peer->host, | |
9453 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9454 | buf, SU_ADDRSTRLEN), | |
9455 | rn->p.prefixlen, | |
9456 | ri->flags); | |
9457 | } | |
9458 | else | |
9459 | { | |
1a392d46 | 9460 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
ff7924f6 PJ |
9461 | plog_warn (peer->log, |
9462 | "%s [pcount] %s/%d not counted but flags 0x%x", | |
9463 | peer->host, | |
9464 | inet_ntop(rn->p.family, &rn->p.u.prefix, | |
9465 | buf, SU_ADDRSTRLEN), | |
9466 | rn->p.prefixlen, | |
9467 | ri->flags); | |
9468 | } | |
9469 | } | |
9470 | } | |
2815e61f PJ |
9471 | return 0; |
9472 | } | |
ff7924f6 | 9473 | |
2815e61f PJ |
9474 | static int |
9475 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) | |
9476 | { | |
9477 | struct peer_pcounts pcounts = { .peer = peer }; | |
9478 | unsigned int i; | |
9479 | ||
9480 | if (!peer || !peer->bgp || !peer->afc[afi][safi] | |
9481 | || !peer->bgp->rib[afi][safi]) | |
9482 | { | |
9483 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9484 | return CMD_WARNING; | |
9485 | } | |
9486 | ||
9487 | memset (&pcounts, 0, sizeof(pcounts)); | |
9488 | pcounts.peer = peer; | |
9489 | pcounts.table = peer->bgp->rib[afi][safi]; | |
9490 | ||
9491 | /* in-place call via thread subsystem so as to record execution time | |
9492 | * stats for the thread-walk (i.e. ensure this can't be blamed on | |
9493 | * on just vty_read()). | |
9494 | */ | |
9495 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); | |
9496 | ||
ff7924f6 PJ |
9497 | vty_out (vty, "Prefix counts for %s, %s%s", |
9498 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); | |
9499 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); | |
9500 | vty_out (vty, "%sCounts from RIB table walk:%s%s", | |
9501 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
9502 | ||
9503 | for (i = 0; i < PCOUNT_MAX; i++) | |
2815e61f PJ |
9504 | vty_out (vty, "%20s: %-10d%s", |
9505 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); | |
ff7924f6 | 9506 | |
2815e61f | 9507 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
ff7924f6 PJ |
9508 | { |
9509 | vty_out (vty, "%s [pcount] PfxCt drift!%s", | |
9510 | peer->host, VTY_NEWLINE); | |
9511 | vty_out (vty, "Please report this bug, with the above command output%s", | |
9512 | VTY_NEWLINE); | |
9513 | } | |
9514 | ||
9515 | return CMD_SUCCESS; | |
9516 | } | |
9517 | ||
9518 | DEFUN (show_ip_bgp_neighbor_prefix_counts, | |
9519 | show_ip_bgp_neighbor_prefix_counts_cmd, | |
9520 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9521 | SHOW_STR | |
9522 | IP_STR | |
9523 | BGP_STR | |
9524 | "Detailed information on TCP and BGP neighbor connections\n" | |
9525 | "Neighbor to display information about\n" | |
9526 | "Neighbor to display information about\n" | |
9527 | "Display detailed prefix count information\n") | |
9528 | { | |
9529 | struct peer *peer; | |
9530 | ||
9531 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9532 | if (! peer) | |
9533 | return CMD_WARNING; | |
9534 | ||
9535 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9536 | } | |
9537 | ||
9538 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, | |
9539 | show_bgp_ipv6_neighbor_prefix_counts_cmd, | |
9540 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9541 | SHOW_STR | |
9542 | BGP_STR | |
9543 | "Address family\n" | |
9544 | "Detailed information on TCP and BGP neighbor connections\n" | |
9545 | "Neighbor to display information about\n" | |
9546 | "Neighbor to display information about\n" | |
9547 | "Display detailed prefix count information\n") | |
9548 | { | |
9549 | struct peer *peer; | |
9550 | ||
9551 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9552 | if (! peer) | |
9553 | return CMD_WARNING; | |
9554 | ||
9555 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); | |
9556 | } | |
9557 | ||
9558 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, | |
9559 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, | |
9560 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9561 | SHOW_STR | |
9562 | IP_STR | |
9563 | BGP_STR | |
9564 | "Address family\n" | |
9565 | "Address Family modifier\n" | |
9566 | "Address Family modifier\n" | |
9567 | "Detailed information on TCP and BGP neighbor connections\n" | |
9568 | "Neighbor to display information about\n" | |
9569 | "Neighbor to display information about\n" | |
9570 | "Display detailed prefix count information\n") | |
9571 | { | |
9572 | struct peer *peer; | |
9573 | ||
9574 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9575 | if (! peer) | |
9576 | return CMD_WARNING; | |
9577 | ||
9578 | if (strncmp (argv[0], "m", 1) == 0) | |
9579 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); | |
9580 | ||
9581 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); | |
9582 | } | |
9583 | ||
9584 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, | |
9585 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, | |
9586 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", | |
9587 | SHOW_STR | |
9588 | IP_STR | |
9589 | BGP_STR | |
9590 | "Address family\n" | |
9591 | "Address Family modifier\n" | |
9592 | "Address Family modifier\n" | |
9593 | "Detailed information on TCP and BGP neighbor connections\n" | |
9594 | "Neighbor to display information about\n" | |
9595 | "Neighbor to display information about\n" | |
9596 | "Display detailed prefix count information\n") | |
9597 | { | |
9598 | struct peer *peer; | |
9599 | ||
9600 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9601 | if (! peer) | |
9602 | return CMD_WARNING; | |
9603 | ||
9604 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); | |
9605 | } | |
9606 | ||
9607 | ||
94f2b392 | 9608 | static void |
718e3744 | 9609 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
9610 | int in) | |
9611 | { | |
9612 | struct bgp_table *table; | |
9613 | struct bgp_adj_in *ain; | |
9614 | struct bgp_adj_out *adj; | |
9615 | unsigned long output_count; | |
9616 | struct bgp_node *rn; | |
9617 | int header1 = 1; | |
9618 | struct bgp *bgp; | |
9619 | int header2 = 1; | |
9620 | ||
bb46e94f | 9621 | bgp = peer->bgp; |
718e3744 | 9622 | |
9623 | if (! bgp) | |
9624 | return; | |
9625 | ||
9626 | table = bgp->rib[afi][safi]; | |
9627 | ||
9628 | output_count = 0; | |
9629 | ||
9630 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], | |
9631 | PEER_STATUS_DEFAULT_ORIGINATE)) | |
9632 | { | |
9633 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9634 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9635 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9636 | |
9637 | vty_out (vty, "Originating default network 0.0.0.0%s%s", | |
9638 | VTY_NEWLINE, VTY_NEWLINE); | |
9639 | header1 = 0; | |
9640 | } | |
9641 | ||
9642 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
9643 | if (in) | |
9644 | { | |
9645 | for (ain = rn->adj_in; ain; ain = ain->next) | |
9646 | if (ain->peer == peer) | |
9647 | { | |
9648 | if (header1) | |
9649 | { | |
9650 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9651 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9652 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9653 | header1 = 0; |
9654 | } | |
9655 | if (header2) | |
9656 | { | |
9657 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9658 | header2 = 0; | |
9659 | } | |
9660 | if (ain->attr) | |
9661 | { | |
9662 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); | |
9663 | output_count++; | |
9664 | } | |
9665 | } | |
9666 | } | |
9667 | else | |
9668 | { | |
9669 | for (adj = rn->adj_out; adj; adj = adj->next) | |
9670 | if (adj->peer == peer) | |
9671 | { | |
9672 | if (header1) | |
9673 | { | |
9674 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); | |
93406d87 | 9675 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
9676 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9677 | header1 = 0; |
9678 | } | |
9679 | if (header2) | |
9680 | { | |
9681 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); | |
9682 | header2 = 0; | |
9683 | } | |
9684 | if (adj->attr) | |
9685 | { | |
9686 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); | |
9687 | output_count++; | |
9688 | } | |
9689 | } | |
9690 | } | |
9691 | ||
9692 | if (output_count != 0) | |
9693 | vty_out (vty, "%sTotal number of prefixes %ld%s", | |
9694 | VTY_NEWLINE, output_count, VTY_NEWLINE); | |
9695 | } | |
9696 | ||
94f2b392 | 9697 | static int |
bb46e94f | 9698 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
9699 | { | |
718e3744 | 9700 | if (! peer || ! peer->afc[afi][safi]) |
9701 | { | |
9702 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
9703 | return CMD_WARNING; | |
9704 | } | |
9705 | ||
9706 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9707 | { | |
9708 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", | |
9709 | VTY_NEWLINE); | |
9710 | return CMD_WARNING; | |
9711 | } | |
9712 | ||
9713 | show_adj_route (vty, peer, afi, safi, in); | |
9714 | ||
9715 | return CMD_SUCCESS; | |
9716 | } | |
9717 | ||
2a71e9ce TP |
9718 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
9719 | show_ip_bgp_view_neighbor_advertised_route_cmd, | |
9720 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9721 | SHOW_STR |
9722 | IP_STR | |
9723 | BGP_STR | |
2a71e9ce TP |
9724 | "BGP view\n" |
9725 | "View name\n" | |
718e3744 | 9726 | "Detailed information on TCP and BGP neighbor connections\n" |
9727 | "Neighbor to display information about\n" | |
9728 | "Neighbor to display information about\n" | |
9729 | "Display the routes advertised to a BGP neighbor\n") | |
9730 | { | |
bb46e94f | 9731 | struct peer *peer; |
9732 | ||
2a71e9ce TP |
9733 | if (argc == 2) |
9734 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9735 | else | |
9736 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9737 | ||
bb46e94f | 9738 | if (! peer) |
9739 | return CMD_WARNING; | |
9740 | ||
9741 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); | |
718e3744 | 9742 | } |
9743 | ||
2a71e9ce TP |
9744 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
9745 | show_ip_bgp_neighbor_advertised_route_cmd, | |
9746 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9747 | SHOW_STR | |
9748 | IP_STR | |
9749 | BGP_STR | |
9750 | "Detailed information on TCP and BGP neighbor connections\n" | |
9751 | "Neighbor to display information about\n" | |
9752 | "Neighbor to display information about\n" | |
9753 | "Display the routes advertised to a BGP neighbor\n") | |
9754 | ||
718e3744 | 9755 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
9756 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, | |
9757 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9758 | SHOW_STR | |
9759 | IP_STR | |
9760 | BGP_STR | |
9761 | "Address family\n" | |
9762 | "Address Family modifier\n" | |
9763 | "Address Family modifier\n" | |
9764 | "Detailed information on TCP and BGP neighbor connections\n" | |
9765 | "Neighbor to display information about\n" | |
9766 | "Neighbor to display information about\n" | |
9767 | "Display the routes advertised to a BGP neighbor\n") | |
9768 | { | |
bb46e94f | 9769 | struct peer *peer; |
9770 | ||
9771 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9772 | if (! peer) | |
9773 | return CMD_WARNING; | |
9774 | ||
718e3744 | 9775 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 9776 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
718e3744 | 9777 | |
bb46e94f | 9778 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
718e3744 | 9779 | } |
9780 | ||
9781 | #ifdef HAVE_IPV6 | |
bb46e94f | 9782 | DEFUN (show_bgp_view_neighbor_advertised_route, |
9783 | show_bgp_view_neighbor_advertised_route_cmd, | |
9784 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
718e3744 | 9785 | SHOW_STR |
9786 | BGP_STR | |
bb46e94f | 9787 | "BGP view\n" |
9788 | "View name\n" | |
718e3744 | 9789 | "Detailed information on TCP and BGP neighbor connections\n" |
9790 | "Neighbor to display information about\n" | |
9791 | "Neighbor to display information about\n" | |
9792 | "Display the routes advertised to a BGP neighbor\n") | |
9793 | { | |
bb46e94f | 9794 | struct peer *peer; |
9795 | ||
9796 | if (argc == 2) | |
9797 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9798 | else | |
9799 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9800 | ||
9801 | if (! peer) | |
9802 | return CMD_WARNING; | |
9803 | ||
9804 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); | |
9805 | } | |
9806 | ||
9807 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
9808 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, | |
9809 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9810 | SHOW_STR | |
9811 | BGP_STR | |
9812 | "BGP view\n" | |
9813 | "View name\n" | |
9814 | "Address family\n" | |
9815 | "Detailed information on TCP and BGP neighbor connections\n" | |
9816 | "Neighbor to display information about\n" | |
9817 | "Neighbor to display information about\n" | |
9818 | "Display the routes advertised to a BGP neighbor\n") | |
9819 | ||
9820 | DEFUN (show_bgp_view_neighbor_received_routes, | |
9821 | show_bgp_view_neighbor_received_routes_cmd, | |
9822 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9823 | SHOW_STR | |
9824 | BGP_STR | |
9825 | "BGP view\n" | |
9826 | "View name\n" | |
9827 | "Detailed information on TCP and BGP neighbor connections\n" | |
9828 | "Neighbor to display information about\n" | |
9829 | "Neighbor to display information about\n" | |
9830 | "Display the received routes from neighbor\n") | |
9831 | { | |
9832 | struct peer *peer; | |
9833 | ||
9834 | if (argc == 2) | |
9835 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9836 | else | |
9837 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9838 | ||
9839 | if (! peer) | |
9840 | return CMD_WARNING; | |
9841 | ||
9842 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); | |
718e3744 | 9843 | } |
9844 | ||
bb46e94f | 9845 | ALIAS (show_bgp_view_neighbor_received_routes, |
9846 | show_bgp_view_ipv6_neighbor_received_routes_cmd, | |
9847 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9848 | SHOW_STR | |
9849 | BGP_STR | |
9850 | "BGP view\n" | |
9851 | "View name\n" | |
9852 | "Address family\n" | |
9853 | "Detailed information on TCP and BGP neighbor connections\n" | |
9854 | "Neighbor to display information about\n" | |
9855 | "Neighbor to display information about\n" | |
9856 | "Display the received routes from neighbor\n") | |
9857 | ||
9858 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
9859 | show_bgp_neighbor_advertised_route_cmd, | |
9860 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9861 | SHOW_STR | |
9862 | BGP_STR | |
9863 | "Detailed information on TCP and BGP neighbor connections\n" | |
9864 | "Neighbor to display information about\n" | |
9865 | "Neighbor to display information about\n" | |
9866 | "Display the routes advertised to a BGP neighbor\n") | |
9867 | ||
9868 | ALIAS (show_bgp_view_neighbor_advertised_route, | |
718e3744 | 9869 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
9870 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9871 | SHOW_STR | |
9872 | BGP_STR | |
9873 | "Address family\n" | |
9874 | "Detailed information on TCP and BGP neighbor connections\n" | |
9875 | "Neighbor to display information about\n" | |
9876 | "Neighbor to display information about\n" | |
9877 | "Display the routes advertised to a BGP neighbor\n") | |
9878 | ||
9879 | /* old command */ | |
bb46e94f | 9880 | ALIAS (show_bgp_view_neighbor_advertised_route, |
718e3744 | 9881 | ipv6_bgp_neighbor_advertised_route_cmd, |
9882 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9883 | SHOW_STR | |
9884 | IPV6_STR | |
9885 | BGP_STR | |
9886 | "Detailed information on TCP and BGP neighbor connections\n" | |
9887 | "Neighbor to display information about\n" | |
9888 | "Neighbor to display information about\n" | |
9889 | "Display the routes advertised to a BGP neighbor\n") | |
bb46e94f | 9890 | |
718e3744 | 9891 | /* old command */ |
9892 | DEFUN (ipv6_mbgp_neighbor_advertised_route, | |
9893 | ipv6_mbgp_neighbor_advertised_route_cmd, | |
9894 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", | |
9895 | SHOW_STR | |
9896 | IPV6_STR | |
9897 | MBGP_STR | |
9898 | "Detailed information on TCP and BGP neighbor connections\n" | |
9899 | "Neighbor to display information about\n" | |
9900 | "Neighbor to display information about\n" | |
9901 | "Display the routes advertised to a BGP neighbor\n") | |
9902 | { | |
bb46e94f | 9903 | struct peer *peer; |
9904 | ||
9905 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9906 | if (! peer) | |
9907 | return CMD_WARNING; | |
9908 | ||
9909 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); | |
718e3744 | 9910 | } |
9911 | #endif /* HAVE_IPV6 */ | |
9912 | \f | |
2a71e9ce TP |
9913 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
9914 | show_ip_bgp_view_neighbor_received_routes_cmd, | |
9915 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", | |
718e3744 | 9916 | SHOW_STR |
9917 | IP_STR | |
9918 | BGP_STR | |
2a71e9ce TP |
9919 | "BGP view\n" |
9920 | "View name\n" | |
718e3744 | 9921 | "Detailed information on TCP and BGP neighbor connections\n" |
9922 | "Neighbor to display information about\n" | |
9923 | "Neighbor to display information about\n" | |
9924 | "Display the received routes from neighbor\n") | |
9925 | { | |
bb46e94f | 9926 | struct peer *peer; |
9927 | ||
2a71e9ce TP |
9928 | if (argc == 2) |
9929 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
9930 | else | |
9931 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
9932 | ||
bb46e94f | 9933 | if (! peer) |
9934 | return CMD_WARNING; | |
9935 | ||
9936 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); | |
718e3744 | 9937 | } |
9938 | ||
2a71e9ce TP |
9939 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
9940 | show_ip_bgp_neighbor_received_routes_cmd, | |
9941 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9942 | SHOW_STR | |
9943 | IP_STR | |
9944 | BGP_STR | |
9945 | "Detailed information on TCP and BGP neighbor connections\n" | |
9946 | "Neighbor to display information about\n" | |
9947 | "Neighbor to display information about\n" | |
9948 | "Display the received routes from neighbor\n") | |
9949 | ||
718e3744 | 9950 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
9951 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, | |
9952 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", | |
9953 | SHOW_STR | |
9954 | IP_STR | |
9955 | BGP_STR | |
9956 | "Address family\n" | |
9957 | "Address Family modifier\n" | |
9958 | "Address Family modifier\n" | |
9959 | "Detailed information on TCP and BGP neighbor connections\n" | |
9960 | "Neighbor to display information about\n" | |
9961 | "Neighbor to display information about\n" | |
9962 | "Display the received routes from neighbor\n") | |
9963 | { | |
bb46e94f | 9964 | struct peer *peer; |
9965 | ||
9966 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
9967 | if (! peer) | |
9968 | return CMD_WARNING; | |
9969 | ||
718e3744 | 9970 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 9971 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
718e3744 | 9972 | |
bb46e94f | 9973 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
718e3744 | 9974 | } |
9975 | ||
9976 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, | |
9977 | show_ip_bgp_neighbor_received_prefix_filter_cmd, | |
9978 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
9979 | SHOW_STR | |
9980 | IP_STR | |
9981 | BGP_STR | |
9982 | "Detailed information on TCP and BGP neighbor connections\n" | |
9983 | "Neighbor to display information about\n" | |
9984 | "Neighbor to display information about\n" | |
9985 | "Display information received from a BGP neighbor\n" | |
9986 | "Display the prefixlist filter\n") | |
9987 | { | |
9988 | char name[BUFSIZ]; | |
9989 | union sockunion *su; | |
9990 | struct peer *peer; | |
9991 | int count; | |
9992 | ||
9993 | su = sockunion_str2su (argv[0]); | |
9994 | if (su == NULL) | |
9995 | return CMD_WARNING; | |
9996 | ||
9997 | peer = peer_lookup (NULL, su); | |
9998 | if (! peer) | |
9999 | return CMD_WARNING; | |
10000 | ||
10001 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
10002 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10003 | if (count) | |
10004 | { | |
10005 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
10006 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10007 | } | |
10008 | ||
10009 | return CMD_SUCCESS; | |
10010 | } | |
10011 | ||
10012 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, | |
10013 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, | |
10014 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10015 | SHOW_STR | |
10016 | IP_STR | |
10017 | BGP_STR | |
10018 | "Address family\n" | |
10019 | "Address Family modifier\n" | |
10020 | "Address Family modifier\n" | |
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 information received from a BGP neighbor\n" | |
10025 | "Display the prefixlist filter\n") | |
10026 | { | |
10027 | char name[BUFSIZ]; | |
10028 | union sockunion *su; | |
10029 | struct peer *peer; | |
10030 | int count; | |
10031 | ||
10032 | su = sockunion_str2su (argv[1]); | |
10033 | if (su == NULL) | |
10034 | return CMD_WARNING; | |
10035 | ||
10036 | peer = peer_lookup (NULL, su); | |
10037 | if (! peer) | |
10038 | return CMD_WARNING; | |
10039 | ||
10040 | if (strncmp (argv[0], "m", 1) == 0) | |
10041 | { | |
10042 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); | |
10043 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10044 | if (count) | |
10045 | { | |
10046 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); | |
10047 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10048 | } | |
10049 | } | |
10050 | else | |
10051 | { | |
10052 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); | |
10053 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); | |
10054 | if (count) | |
10055 | { | |
10056 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); | |
10057 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); | |
10058 | } | |
10059 | } | |
10060 | ||
10061 | return CMD_SUCCESS; | |
10062 | } | |
10063 | ||
10064 | ||
10065 | #ifdef HAVE_IPV6 | |
bb46e94f | 10066 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10067 | show_bgp_neighbor_received_routes_cmd, |
10068 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10069 | SHOW_STR | |
10070 | BGP_STR | |
10071 | "Detailed information on TCP and BGP neighbor connections\n" | |
10072 | "Neighbor to display information about\n" | |
10073 | "Neighbor to display information about\n" | |
10074 | "Display the received routes from neighbor\n") | |
718e3744 | 10075 | |
bb46e94f | 10076 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10077 | show_bgp_ipv6_neighbor_received_routes_cmd, |
10078 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10079 | SHOW_STR | |
10080 | BGP_STR | |
10081 | "Address family\n" | |
10082 | "Detailed information on TCP and BGP neighbor connections\n" | |
10083 | "Neighbor to display information about\n" | |
10084 | "Neighbor to display information about\n" | |
10085 | "Display the received routes from neighbor\n") | |
10086 | ||
10087 | DEFUN (show_bgp_neighbor_received_prefix_filter, | |
10088 | show_bgp_neighbor_received_prefix_filter_cmd, | |
10089 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10090 | SHOW_STR | |
10091 | BGP_STR | |
10092 | "Detailed information on TCP and BGP neighbor connections\n" | |
10093 | "Neighbor to display information about\n" | |
10094 | "Neighbor to display information about\n" | |
10095 | "Display information received from a BGP neighbor\n" | |
10096 | "Display the prefixlist filter\n") | |
10097 | { | |
10098 | char name[BUFSIZ]; | |
10099 | union sockunion *su; | |
10100 | struct peer *peer; | |
10101 | int count; | |
10102 | ||
10103 | su = sockunion_str2su (argv[0]); | |
10104 | if (su == NULL) | |
10105 | return CMD_WARNING; | |
10106 | ||
10107 | peer = peer_lookup (NULL, su); | |
10108 | if (! peer) | |
10109 | return CMD_WARNING; | |
10110 | ||
10111 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10112 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10113 | if (count) | |
10114 | { | |
10115 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10116 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10117 | } | |
10118 | ||
10119 | return CMD_SUCCESS; | |
10120 | } | |
10121 | ||
10122 | ALIAS (show_bgp_neighbor_received_prefix_filter, | |
10123 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, | |
10124 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10125 | SHOW_STR | |
10126 | BGP_STR | |
10127 | "Address family\n" | |
10128 | "Detailed information on TCP and BGP neighbor connections\n" | |
10129 | "Neighbor to display information about\n" | |
10130 | "Neighbor to display information about\n" | |
10131 | "Display information received from a BGP neighbor\n" | |
10132 | "Display the prefixlist filter\n") | |
10133 | ||
10134 | /* old command */ | |
bb46e94f | 10135 | ALIAS (show_bgp_view_neighbor_received_routes, |
718e3744 | 10136 | ipv6_bgp_neighbor_received_routes_cmd, |
10137 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10138 | SHOW_STR | |
10139 | IPV6_STR | |
10140 | BGP_STR | |
10141 | "Detailed information on TCP and BGP neighbor connections\n" | |
10142 | "Neighbor to display information about\n" | |
10143 | "Neighbor to display information about\n" | |
10144 | "Display the received routes from neighbor\n") | |
718e3744 | 10145 | |
10146 | /* old command */ | |
10147 | DEFUN (ipv6_mbgp_neighbor_received_routes, | |
10148 | ipv6_mbgp_neighbor_received_routes_cmd, | |
10149 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", | |
10150 | SHOW_STR | |
10151 | IPV6_STR | |
10152 | MBGP_STR | |
10153 | "Detailed information on TCP and BGP neighbor connections\n" | |
10154 | "Neighbor to display information about\n" | |
10155 | "Neighbor to display information about\n" | |
10156 | "Display the received routes from neighbor\n") | |
10157 | { | |
bb46e94f | 10158 | struct peer *peer; |
10159 | ||
10160 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10161 | if (! peer) | |
10162 | return CMD_WARNING; | |
10163 | ||
10164 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); | |
10165 | } | |
10166 | ||
10167 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, | |
10168 | show_bgp_view_neighbor_received_prefix_filter_cmd, | |
10169 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10170 | SHOW_STR | |
10171 | BGP_STR | |
10172 | "BGP view\n" | |
10173 | "View name\n" | |
10174 | "Detailed information on TCP and BGP neighbor connections\n" | |
10175 | "Neighbor to display information about\n" | |
10176 | "Neighbor to display information about\n" | |
10177 | "Display information received from a BGP neighbor\n" | |
10178 | "Display the prefixlist filter\n") | |
10179 | { | |
10180 | char name[BUFSIZ]; | |
10181 | union sockunion *su; | |
10182 | struct peer *peer; | |
10183 | struct bgp *bgp; | |
10184 | int count; | |
10185 | ||
10186 | /* BGP structure lookup. */ | |
10187 | bgp = bgp_lookup_by_name (argv[0]); | |
10188 | if (bgp == NULL) | |
10189 | { | |
10190 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10191 | return CMD_WARNING; | |
10192 | } | |
10193 | ||
10194 | su = sockunion_str2su (argv[1]); | |
10195 | if (su == NULL) | |
10196 | return CMD_WARNING; | |
10197 | ||
10198 | peer = peer_lookup (bgp, su); | |
10199 | if (! peer) | |
10200 | return CMD_WARNING; | |
10201 | ||
10202 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); | |
10203 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); | |
10204 | if (count) | |
10205 | { | |
10206 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); | |
10207 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); | |
10208 | } | |
10209 | ||
10210 | return CMD_SUCCESS; | |
718e3744 | 10211 | } |
bb46e94f | 10212 | |
10213 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, | |
10214 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, | |
10215 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", | |
10216 | SHOW_STR | |
10217 | BGP_STR | |
10218 | "BGP view\n" | |
10219 | "View name\n" | |
10220 | "Address family\n" | |
10221 | "Detailed information on TCP and BGP neighbor connections\n" | |
10222 | "Neighbor to display information about\n" | |
10223 | "Neighbor to display information about\n" | |
10224 | "Display information received from a BGP neighbor\n" | |
10225 | "Display the prefixlist filter\n") | |
718e3744 | 10226 | #endif /* HAVE_IPV6 */ |
10227 | \f | |
94f2b392 | 10228 | static int |
bb46e94f | 10229 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
718e3744 | 10230 | safi_t safi, enum bgp_show_type type) |
10231 | { | |
718e3744 | 10232 | if (! peer || ! peer->afc[afi][safi]) |
10233 | { | |
10234 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); | |
718e3744 | 10235 | return CMD_WARNING; |
10236 | } | |
10237 | ||
5a646650 | 10238 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
718e3744 | 10239 | } |
10240 | ||
10241 | DEFUN (show_ip_bgp_neighbor_routes, | |
10242 | show_ip_bgp_neighbor_routes_cmd, | |
10243 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10244 | SHOW_STR | |
10245 | IP_STR | |
10246 | BGP_STR | |
10247 | "Detailed information on TCP and BGP neighbor connections\n" | |
10248 | "Neighbor to display information about\n" | |
10249 | "Neighbor to display information about\n" | |
10250 | "Display routes learned from neighbor\n") | |
10251 | { | |
bb46e94f | 10252 | struct peer *peer; |
10253 | ||
10254 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10255 | if (! peer) | |
10256 | return CMD_WARNING; | |
10257 | ||
10258 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10259 | bgp_show_type_neighbor); |
10260 | } | |
10261 | ||
10262 | DEFUN (show_ip_bgp_neighbor_flap, | |
10263 | show_ip_bgp_neighbor_flap_cmd, | |
10264 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10265 | SHOW_STR | |
10266 | IP_STR | |
10267 | BGP_STR | |
10268 | "Detailed information on TCP and BGP neighbor connections\n" | |
10269 | "Neighbor to display information about\n" | |
10270 | "Neighbor to display information about\n" | |
10271 | "Display flap statistics of the routes learned from neighbor\n") | |
10272 | { | |
bb46e94f | 10273 | struct peer *peer; |
10274 | ||
10275 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10276 | if (! peer) | |
10277 | return CMD_WARNING; | |
10278 | ||
10279 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10280 | bgp_show_type_flap_neighbor); |
10281 | } | |
10282 | ||
10283 | DEFUN (show_ip_bgp_neighbor_damp, | |
10284 | show_ip_bgp_neighbor_damp_cmd, | |
10285 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10286 | SHOW_STR | |
10287 | IP_STR | |
10288 | BGP_STR | |
10289 | "Detailed information on TCP and BGP neighbor connections\n" | |
10290 | "Neighbor to display information about\n" | |
10291 | "Neighbor to display information about\n" | |
10292 | "Display the dampened routes received from neighbor\n") | |
10293 | { | |
bb46e94f | 10294 | struct peer *peer; |
10295 | ||
10296 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10297 | if (! peer) | |
10298 | return CMD_WARNING; | |
10299 | ||
10300 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, | |
718e3744 | 10301 | bgp_show_type_damp_neighbor); |
10302 | } | |
10303 | ||
10304 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, | |
10305 | show_ip_bgp_ipv4_neighbor_routes_cmd, | |
10306 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", | |
10307 | SHOW_STR | |
10308 | IP_STR | |
10309 | BGP_STR | |
10310 | "Address family\n" | |
10311 | "Address Family modifier\n" | |
10312 | "Address Family modifier\n" | |
10313 | "Detailed information on TCP and BGP neighbor connections\n" | |
10314 | "Neighbor to display information about\n" | |
10315 | "Neighbor to display information about\n" | |
10316 | "Display routes learned from neighbor\n") | |
10317 | { | |
bb46e94f | 10318 | struct peer *peer; |
10319 | ||
10320 | peer = peer_lookup_in_view (vty, NULL, argv[1]); | |
10321 | if (! peer) | |
10322 | return CMD_WARNING; | |
10323 | ||
718e3744 | 10324 | if (strncmp (argv[0], "m", 1) == 0) |
bb46e94f | 10325 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
718e3744 | 10326 | bgp_show_type_neighbor); |
10327 | ||
bb46e94f | 10328 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
718e3744 | 10329 | bgp_show_type_neighbor); |
10330 | } | |
bb46e94f | 10331 | |
fee0f4c6 | 10332 | DEFUN (show_ip_bgp_view_rsclient, |
10333 | show_ip_bgp_view_rsclient_cmd, | |
10334 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
10335 | SHOW_STR | |
10336 | IP_STR | |
10337 | BGP_STR | |
10338 | "BGP view\n" | |
10339 | "BGP view name\n" | |
10340 | "Information about Route Server Client\n" | |
10341 | NEIGHBOR_ADDR_STR) | |
10342 | { | |
10343 | struct bgp_table *table; | |
10344 | struct peer *peer; | |
10345 | ||
10346 | if (argc == 2) | |
10347 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10348 | else | |
10349 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10350 | ||
10351 | if (! peer) | |
10352 | return CMD_WARNING; | |
10353 | ||
10354 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10355 | { | |
10356 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10357 | VTY_NEWLINE); | |
10358 | return CMD_WARNING; | |
10359 | } | |
10360 | ||
10361 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10362 | PEER_FLAG_RSERVER_CLIENT)) | |
10363 | { | |
10364 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10365 | VTY_NEWLINE); | |
10366 | return CMD_WARNING; | |
10367 | } | |
10368 | ||
10369 | table = peer->rib[AFI_IP][SAFI_UNICAST]; | |
10370 | ||
5a646650 | 10371 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 10372 | } |
10373 | ||
10374 | ALIAS (show_ip_bgp_view_rsclient, | |
10375 | show_ip_bgp_rsclient_cmd, | |
10376 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", | |
10377 | SHOW_STR | |
10378 | IP_STR | |
10379 | BGP_STR | |
10380 | "Information about Route Server Client\n" | |
10381 | NEIGHBOR_ADDR_STR) | |
10382 | ||
10383 | DEFUN (show_ip_bgp_view_rsclient_route, | |
10384 | show_ip_bgp_view_rsclient_route_cmd, | |
a8bf6f52 | 10385 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
fee0f4c6 | 10386 | SHOW_STR |
10387 | IP_STR | |
10388 | BGP_STR | |
10389 | "BGP view\n" | |
10390 | "BGP view name\n" | |
10391 | "Information about Route Server Client\n" | |
10392 | NEIGHBOR_ADDR_STR | |
10393 | "Network in the BGP routing table to display\n") | |
10394 | { | |
10395 | struct bgp *bgp; | |
10396 | struct peer *peer; | |
10397 | ||
10398 | /* BGP structure lookup. */ | |
10399 | if (argc == 3) | |
10400 | { | |
10401 | bgp = bgp_lookup_by_name (argv[0]); | |
10402 | if (bgp == NULL) | |
10403 | { | |
10404 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10405 | return CMD_WARNING; | |
10406 | } | |
10407 | } | |
10408 | else | |
10409 | { | |
10410 | bgp = bgp_get_default (); | |
10411 | if (bgp == NULL) | |
10412 | { | |
10413 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10414 | return CMD_WARNING; | |
10415 | } | |
10416 | } | |
10417 | ||
10418 | if (argc == 3) | |
10419 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10420 | else | |
10421 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10422 | ||
10423 | if (! peer) | |
10424 | return CMD_WARNING; | |
10425 | ||
10426 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10427 | { | |
10428 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10429 | VTY_NEWLINE); | |
10430 | return CMD_WARNING; | |
10431 | } | |
10432 | ||
10433 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10434 | PEER_FLAG_RSERVER_CLIENT)) | |
10435 | { | |
10436 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10437 | VTY_NEWLINE); | |
10438 | return CMD_WARNING; | |
10439 | } | |
10440 | ||
10441 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10442 | (argc == 3) ? argv[2] : argv[1], | |
10443 | AFI_IP, SAFI_UNICAST, NULL, 0); | |
10444 | } | |
10445 | ||
10446 | ALIAS (show_ip_bgp_view_rsclient_route, | |
10447 | show_ip_bgp_rsclient_route_cmd, | |
10448 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", | |
10449 | SHOW_STR | |
10450 | IP_STR | |
10451 | BGP_STR | |
10452 | "Information about Route Server Client\n" | |
10453 | NEIGHBOR_ADDR_STR | |
10454 | "Network in the BGP routing table to display\n") | |
10455 | ||
10456 | DEFUN (show_ip_bgp_view_rsclient_prefix, | |
10457 | show_ip_bgp_view_rsclient_prefix_cmd, | |
10458 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10459 | SHOW_STR | |
10460 | IP_STR | |
10461 | BGP_STR | |
10462 | "BGP view\n" | |
10463 | "BGP view name\n" | |
10464 | "Information about Route Server Client\n" | |
10465 | NEIGHBOR_ADDR_STR | |
10466 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10467 | { | |
10468 | struct bgp *bgp; | |
10469 | struct peer *peer; | |
10470 | ||
10471 | /* BGP structure lookup. */ | |
10472 | if (argc == 3) | |
10473 | { | |
10474 | bgp = bgp_lookup_by_name (argv[0]); | |
10475 | if (bgp == NULL) | |
10476 | { | |
10477 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10478 | return CMD_WARNING; | |
10479 | } | |
10480 | } | |
10481 | else | |
10482 | { | |
10483 | bgp = bgp_get_default (); | |
10484 | if (bgp == NULL) | |
10485 | { | |
10486 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10487 | return CMD_WARNING; | |
10488 | } | |
10489 | } | |
10490 | ||
10491 | if (argc == 3) | |
10492 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10493 | else | |
10494 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10495 | ||
10496 | if (! peer) | |
10497 | return CMD_WARNING; | |
10498 | ||
10499 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) | |
10500 | { | |
10501 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10502 | VTY_NEWLINE); | |
10503 | return CMD_WARNING; | |
10504 | } | |
10505 | ||
10506 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], | |
10507 | PEER_FLAG_RSERVER_CLIENT)) | |
10508 | { | |
10509 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10510 | VTY_NEWLINE); | |
10511 | return CMD_WARNING; | |
10512 | } | |
10513 | ||
10514 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], | |
10515 | (argc == 3) ? argv[2] : argv[1], | |
10516 | AFI_IP, SAFI_UNICAST, NULL, 1); | |
10517 | } | |
10518 | ||
10519 | ALIAS (show_ip_bgp_view_rsclient_prefix, | |
10520 | show_ip_bgp_rsclient_prefix_cmd, | |
10521 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", | |
10522 | SHOW_STR | |
10523 | IP_STR | |
10524 | BGP_STR | |
10525 | "Information about Route Server Client\n" | |
10526 | NEIGHBOR_ADDR_STR | |
10527 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
10528 | ||
10529 | ||
718e3744 | 10530 | #ifdef HAVE_IPV6 |
bb46e94f | 10531 | DEFUN (show_bgp_view_neighbor_routes, |
10532 | show_bgp_view_neighbor_routes_cmd, | |
10533 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", | |
718e3744 | 10534 | SHOW_STR |
10535 | BGP_STR | |
bb46e94f | 10536 | "BGP view\n" |
10537 | "BGP view name\n" | |
718e3744 | 10538 | "Detailed information on TCP and BGP neighbor connections\n" |
10539 | "Neighbor to display information about\n" | |
10540 | "Neighbor to display information about\n" | |
10541 | "Display routes learned from neighbor\n") | |
10542 | { | |
bb46e94f | 10543 | struct peer *peer; |
10544 | ||
10545 | if (argc == 2) | |
10546 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10547 | else | |
10548 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10549 | ||
10550 | if (! peer) | |
10551 | return CMD_WARNING; | |
10552 | ||
10553 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
718e3744 | 10554 | bgp_show_type_neighbor); |
10555 | } | |
10556 | ||
bb46e94f | 10557 | ALIAS (show_bgp_view_neighbor_routes, |
10558 | show_bgp_view_ipv6_neighbor_routes_cmd, | |
10559 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
10560 | SHOW_STR | |
10561 | BGP_STR | |
10562 | "BGP view\n" | |
10563 | "BGP view name\n" | |
10564 | "Address family\n" | |
10565 | "Detailed information on TCP and BGP neighbor connections\n" | |
10566 | "Neighbor to display information about\n" | |
10567 | "Neighbor to display information about\n" | |
10568 | "Display routes learned from neighbor\n") | |
10569 | ||
10570 | DEFUN (show_bgp_view_neighbor_damp, | |
10571 | show_bgp_view_neighbor_damp_cmd, | |
10572 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10573 | SHOW_STR | |
10574 | BGP_STR | |
10575 | "BGP view\n" | |
10576 | "BGP view name\n" | |
10577 | "Detailed information on TCP and BGP neighbor connections\n" | |
10578 | "Neighbor to display information about\n" | |
10579 | "Neighbor to display information about\n" | |
10580 | "Display the dampened routes received from neighbor\n") | |
10581 | { | |
10582 | struct peer *peer; | |
10583 | ||
10584 | if (argc == 2) | |
10585 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10586 | else | |
10587 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10588 | ||
10589 | if (! peer) | |
10590 | return CMD_WARNING; | |
10591 | ||
10592 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
10593 | bgp_show_type_damp_neighbor); | |
10594 | } | |
10595 | ||
10596 | ALIAS (show_bgp_view_neighbor_damp, | |
10597 | show_bgp_view_ipv6_neighbor_damp_cmd, | |
10598 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10599 | SHOW_STR | |
10600 | BGP_STR | |
10601 | "BGP view\n" | |
10602 | "BGP view name\n" | |
10603 | "Address family\n" | |
10604 | "Detailed information on TCP and BGP neighbor connections\n" | |
10605 | "Neighbor to display information about\n" | |
10606 | "Neighbor to display information about\n" | |
10607 | "Display the dampened routes received from neighbor\n") | |
10608 | ||
10609 | DEFUN (show_bgp_view_neighbor_flap, | |
10610 | show_bgp_view_neighbor_flap_cmd, | |
10611 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10612 | SHOW_STR | |
10613 | BGP_STR | |
10614 | "BGP view\n" | |
10615 | "BGP view name\n" | |
10616 | "Detailed information on TCP and BGP neighbor connections\n" | |
10617 | "Neighbor to display information about\n" | |
10618 | "Neighbor to display information about\n" | |
10619 | "Display flap statistics of the routes learned from neighbor\n") | |
10620 | { | |
10621 | struct peer *peer; | |
10622 | ||
10623 | if (argc == 2) | |
10624 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10625 | else | |
10626 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10627 | ||
10628 | if (! peer) | |
10629 | return CMD_WARNING; | |
10630 | ||
10631 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, | |
10632 | bgp_show_type_flap_neighbor); | |
10633 | } | |
10634 | ||
10635 | ALIAS (show_bgp_view_neighbor_flap, | |
10636 | show_bgp_view_ipv6_neighbor_flap_cmd, | |
10637 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10638 | SHOW_STR | |
10639 | BGP_STR | |
10640 | "BGP view\n" | |
10641 | "BGP view name\n" | |
10642 | "Address family\n" | |
10643 | "Detailed information on TCP and BGP neighbor connections\n" | |
10644 | "Neighbor to display information about\n" | |
10645 | "Neighbor to display information about\n" | |
10646 | "Display flap statistics of the routes learned from neighbor\n") | |
10647 | ||
10648 | ALIAS (show_bgp_view_neighbor_routes, | |
10649 | show_bgp_neighbor_routes_cmd, | |
10650 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10651 | SHOW_STR | |
10652 | BGP_STR | |
10653 | "Detailed information on TCP and BGP neighbor connections\n" | |
10654 | "Neighbor to display information about\n" | |
10655 | "Neighbor to display information about\n" | |
10656 | "Display routes learned from neighbor\n") | |
10657 | ||
10658 | ||
10659 | ALIAS (show_bgp_view_neighbor_routes, | |
718e3744 | 10660 | show_bgp_ipv6_neighbor_routes_cmd, |
10661 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", | |
10662 | SHOW_STR | |
10663 | BGP_STR | |
10664 | "Address family\n" | |
10665 | "Detailed information on TCP and BGP neighbor connections\n" | |
10666 | "Neighbor to display information about\n" | |
10667 | "Neighbor to display information about\n" | |
10668 | "Display routes learned from neighbor\n") | |
10669 | ||
10670 | /* old command */ | |
bb46e94f | 10671 | ALIAS (show_bgp_view_neighbor_routes, |
718e3744 | 10672 | ipv6_bgp_neighbor_routes_cmd, |
10673 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10674 | SHOW_STR | |
10675 | IPV6_STR | |
10676 | BGP_STR | |
10677 | "Detailed information on TCP and BGP neighbor connections\n" | |
10678 | "Neighbor to display information about\n" | |
10679 | "Neighbor to display information about\n" | |
10680 | "Display routes learned from neighbor\n") | |
718e3744 | 10681 | |
10682 | /* old command */ | |
10683 | DEFUN (ipv6_mbgp_neighbor_routes, | |
10684 | ipv6_mbgp_neighbor_routes_cmd, | |
10685 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", | |
10686 | SHOW_STR | |
10687 | IPV6_STR | |
10688 | MBGP_STR | |
10689 | "Detailed information on TCP and BGP neighbor connections\n" | |
10690 | "Neighbor to display information about\n" | |
10691 | "Neighbor to display information about\n" | |
10692 | "Display routes learned from neighbor\n") | |
10693 | { | |
bb46e94f | 10694 | struct peer *peer; |
10695 | ||
10696 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10697 | if (! peer) | |
10698 | return CMD_WARNING; | |
10699 | ||
10700 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, | |
718e3744 | 10701 | bgp_show_type_neighbor); |
10702 | } | |
bb46e94f | 10703 | |
10704 | ALIAS (show_bgp_view_neighbor_flap, | |
10705 | show_bgp_neighbor_flap_cmd, | |
10706 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10707 | SHOW_STR | |
10708 | BGP_STR | |
10709 | "Detailed information on TCP and BGP neighbor connections\n" | |
10710 | "Neighbor to display information about\n" | |
10711 | "Neighbor to display information about\n" | |
10712 | "Display flap statistics of the routes learned from neighbor\n") | |
10713 | ||
10714 | ALIAS (show_bgp_view_neighbor_flap, | |
10715 | show_bgp_ipv6_neighbor_flap_cmd, | |
10716 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", | |
10717 | SHOW_STR | |
10718 | BGP_STR | |
10719 | "Address family\n" | |
10720 | "Detailed information on TCP and BGP neighbor connections\n" | |
10721 | "Neighbor to display information about\n" | |
10722 | "Neighbor to display information about\n" | |
10723 | "Display flap statistics of the routes learned from neighbor\n") | |
10724 | ||
10725 | ALIAS (show_bgp_view_neighbor_damp, | |
10726 | show_bgp_neighbor_damp_cmd, | |
10727 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10728 | SHOW_STR | |
10729 | BGP_STR | |
10730 | "Detailed information on TCP and BGP neighbor connections\n" | |
10731 | "Neighbor to display information about\n" | |
10732 | "Neighbor to display information about\n" | |
10733 | "Display the dampened routes received from neighbor\n") | |
10734 | ||
10735 | ALIAS (show_bgp_view_neighbor_damp, | |
10736 | show_bgp_ipv6_neighbor_damp_cmd, | |
10737 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", | |
10738 | SHOW_STR | |
10739 | BGP_STR | |
10740 | "Address family\n" | |
10741 | "Detailed information on TCP and BGP neighbor connections\n" | |
10742 | "Neighbor to display information about\n" | |
10743 | "Neighbor to display information about\n" | |
c001ae62 | 10744 | "Display the dampened routes received from neighbor\n") |
fee0f4c6 | 10745 | |
10746 | DEFUN (show_bgp_view_rsclient, | |
10747 | show_bgp_view_rsclient_cmd, | |
10748 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", | |
10749 | SHOW_STR | |
10750 | BGP_STR | |
10751 | "BGP view\n" | |
10752 | "BGP view name\n" | |
10753 | "Information about Route Server Client\n" | |
10754 | NEIGHBOR_ADDR_STR) | |
10755 | { | |
10756 | struct bgp_table *table; | |
10757 | struct peer *peer; | |
10758 | ||
10759 | if (argc == 2) | |
10760 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10761 | else | |
10762 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10763 | ||
10764 | if (! peer) | |
10765 | return CMD_WARNING; | |
10766 | ||
10767 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
10768 | { | |
10769 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10770 | VTY_NEWLINE); | |
10771 | return CMD_WARNING; | |
10772 | } | |
10773 | ||
10774 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
10775 | PEER_FLAG_RSERVER_CLIENT)) | |
10776 | { | |
10777 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10778 | VTY_NEWLINE); | |
10779 | return CMD_WARNING; | |
10780 | } | |
10781 | ||
10782 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; | |
10783 | ||
5a646650 | 10784 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
fee0f4c6 | 10785 | } |
10786 | ||
10787 | ALIAS (show_bgp_view_rsclient, | |
10788 | show_bgp_rsclient_cmd, | |
10789 | "show bgp rsclient (A.B.C.D|X:X::X:X)", | |
10790 | SHOW_STR | |
10791 | BGP_STR | |
10792 | "Information about Route Server Client\n" | |
10793 | NEIGHBOR_ADDR_STR) | |
10794 | ||
10795 | DEFUN (show_bgp_view_rsclient_route, | |
10796 | show_bgp_view_rsclient_route_cmd, | |
10797 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
10798 | SHOW_STR | |
10799 | BGP_STR | |
10800 | "BGP view\n" | |
10801 | "BGP view name\n" | |
10802 | "Information about Route Server Client\n" | |
10803 | NEIGHBOR_ADDR_STR | |
10804 | "Network in the BGP routing table to display\n") | |
10805 | { | |
10806 | struct bgp *bgp; | |
10807 | struct peer *peer; | |
10808 | ||
10809 | /* BGP structure lookup. */ | |
10810 | if (argc == 3) | |
10811 | { | |
10812 | bgp = bgp_lookup_by_name (argv[0]); | |
10813 | if (bgp == NULL) | |
10814 | { | |
10815 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10816 | return CMD_WARNING; | |
10817 | } | |
10818 | } | |
10819 | else | |
10820 | { | |
10821 | bgp = bgp_get_default (); | |
10822 | if (bgp == NULL) | |
10823 | { | |
10824 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10825 | return CMD_WARNING; | |
10826 | } | |
10827 | } | |
10828 | ||
10829 | if (argc == 3) | |
10830 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10831 | else | |
10832 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10833 | ||
10834 | if (! peer) | |
10835 | return CMD_WARNING; | |
10836 | ||
10837 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
10838 | { | |
10839 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10840 | VTY_NEWLINE); | |
10841 | return CMD_WARNING; | |
10842 | } | |
10843 | ||
10844 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
10845 | PEER_FLAG_RSERVER_CLIENT)) | |
10846 | { | |
10847 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10848 | VTY_NEWLINE); | |
10849 | return CMD_WARNING; | |
10850 | } | |
10851 | ||
10852 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
10853 | (argc == 3) ? argv[2] : argv[1], | |
10854 | AFI_IP6, SAFI_UNICAST, NULL, 0); | |
10855 | } | |
10856 | ||
10857 | ALIAS (show_bgp_view_rsclient_route, | |
10858 | show_bgp_rsclient_route_cmd, | |
10859 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", | |
10860 | SHOW_STR | |
10861 | BGP_STR | |
10862 | "Information about Route Server Client\n" | |
10863 | NEIGHBOR_ADDR_STR | |
10864 | "Network in the BGP routing table to display\n") | |
10865 | ||
10866 | DEFUN (show_bgp_view_rsclient_prefix, | |
10867 | show_bgp_view_rsclient_prefix_cmd, | |
10868 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
10869 | SHOW_STR | |
10870 | BGP_STR | |
10871 | "BGP view\n" | |
10872 | "BGP view name\n" | |
10873 | "Information about Route Server Client\n" | |
10874 | NEIGHBOR_ADDR_STR | |
10875 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
10876 | { | |
10877 | struct bgp *bgp; | |
10878 | struct peer *peer; | |
10879 | ||
10880 | /* BGP structure lookup. */ | |
10881 | if (argc == 3) | |
10882 | { | |
10883 | bgp = bgp_lookup_by_name (argv[0]); | |
10884 | if (bgp == NULL) | |
10885 | { | |
10886 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); | |
10887 | return CMD_WARNING; | |
10888 | } | |
10889 | } | |
10890 | else | |
10891 | { | |
10892 | bgp = bgp_get_default (); | |
10893 | if (bgp == NULL) | |
10894 | { | |
10895 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
10896 | return CMD_WARNING; | |
10897 | } | |
10898 | } | |
10899 | ||
10900 | if (argc == 3) | |
10901 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); | |
10902 | else | |
10903 | peer = peer_lookup_in_view (vty, NULL, argv[0]); | |
10904 | ||
10905 | if (! peer) | |
10906 | return CMD_WARNING; | |
10907 | ||
10908 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) | |
10909 | { | |
10910 | vty_out (vty, "%% Activate the neighbor for the address family first%s", | |
10911 | VTY_NEWLINE); | |
10912 | return CMD_WARNING; | |
10913 | } | |
10914 | ||
10915 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], | |
10916 | PEER_FLAG_RSERVER_CLIENT)) | |
10917 | { | |
10918 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", | |
10919 | VTY_NEWLINE); | |
10920 | return CMD_WARNING; | |
10921 | } | |
10922 | ||
10923 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], | |
10924 | (argc == 3) ? argv[2] : argv[1], | |
10925 | AFI_IP6, SAFI_UNICAST, NULL, 1); | |
10926 | } | |
10927 | ||
10928 | ALIAS (show_bgp_view_rsclient_prefix, | |
10929 | show_bgp_rsclient_prefix_cmd, | |
10930 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", | |
10931 | SHOW_STR | |
10932 | BGP_STR | |
10933 | "Information about Route Server Client\n" | |
10934 | NEIGHBOR_ADDR_STR | |
10935 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") | |
10936 | ||
718e3744 | 10937 | #endif /* HAVE_IPV6 */ |
10938 | \f | |
10939 | struct bgp_table *bgp_distance_table; | |
10940 | ||
10941 | struct bgp_distance | |
10942 | { | |
10943 | /* Distance value for the IP source prefix. */ | |
10944 | u_char distance; | |
10945 | ||
10946 | /* Name of the access-list to be matched. */ | |
10947 | char *access_list; | |
10948 | }; | |
10949 | ||
94f2b392 | 10950 | static struct bgp_distance * |
66e5cd87 | 10951 | bgp_distance_new (void) |
718e3744 | 10952 | { |
393deb9b | 10953 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
718e3744 | 10954 | } |
10955 | ||
94f2b392 | 10956 | static void |
718e3744 | 10957 | bgp_distance_free (struct bgp_distance *bdistance) |
10958 | { | |
10959 | XFREE (MTYPE_BGP_DISTANCE, bdistance); | |
10960 | } | |
10961 | ||
94f2b392 | 10962 | static int |
fd79ac91 | 10963 | bgp_distance_set (struct vty *vty, const char *distance_str, |
10964 | const char *ip_str, const char *access_list_str) | |
718e3744 | 10965 | { |
10966 | int ret; | |
10967 | struct prefix_ipv4 p; | |
10968 | u_char distance; | |
10969 | struct bgp_node *rn; | |
10970 | struct bgp_distance *bdistance; | |
10971 | ||
10972 | ret = str2prefix_ipv4 (ip_str, &p); | |
10973 | if (ret == 0) | |
10974 | { | |
10975 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
10976 | return CMD_WARNING; | |
10977 | } | |
10978 | ||
10979 | distance = atoi (distance_str); | |
10980 | ||
10981 | /* Get BGP distance node. */ | |
10982 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); | |
10983 | if (rn->info) | |
10984 | { | |
10985 | bdistance = rn->info; | |
10986 | bgp_unlock_node (rn); | |
10987 | } | |
10988 | else | |
10989 | { | |
10990 | bdistance = bgp_distance_new (); | |
10991 | rn->info = bdistance; | |
10992 | } | |
10993 | ||
10994 | /* Set distance value. */ | |
10995 | bdistance->distance = distance; | |
10996 | ||
10997 | /* Reset access-list configuration. */ | |
10998 | if (bdistance->access_list) | |
10999 | { | |
11000 | free (bdistance->access_list); | |
11001 | bdistance->access_list = NULL; | |
11002 | } | |
11003 | if (access_list_str) | |
11004 | bdistance->access_list = strdup (access_list_str); | |
11005 | ||
11006 | return CMD_SUCCESS; | |
11007 | } | |
11008 | ||
94f2b392 | 11009 | static int |
fd79ac91 | 11010 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
11011 | const char *ip_str, const char *access_list_str) | |
718e3744 | 11012 | { |
11013 | int ret; | |
11014 | struct prefix_ipv4 p; | |
11015 | u_char distance; | |
11016 | struct bgp_node *rn; | |
11017 | struct bgp_distance *bdistance; | |
11018 | ||
11019 | ret = str2prefix_ipv4 (ip_str, &p); | |
11020 | if (ret == 0) | |
11021 | { | |
11022 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); | |
11023 | return CMD_WARNING; | |
11024 | } | |
11025 | ||
11026 | distance = atoi (distance_str); | |
11027 | ||
11028 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); | |
11029 | if (! rn) | |
11030 | { | |
11031 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); | |
11032 | return CMD_WARNING; | |
11033 | } | |
11034 | ||
11035 | bdistance = rn->info; | |
11036 | ||
11037 | if (bdistance->access_list) | |
11038 | free (bdistance->access_list); | |
11039 | bgp_distance_free (bdistance); | |
11040 | ||
11041 | rn->info = NULL; | |
11042 | bgp_unlock_node (rn); | |
11043 | bgp_unlock_node (rn); | |
11044 | ||
11045 | return CMD_SUCCESS; | |
11046 | } | |
11047 | ||
718e3744 | 11048 | /* Apply BGP information to distance method. */ |
11049 | u_char | |
11050 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) | |
11051 | { | |
11052 | struct bgp_node *rn; | |
11053 | struct prefix_ipv4 q; | |
11054 | struct peer *peer; | |
11055 | struct bgp_distance *bdistance; | |
11056 | struct access_list *alist; | |
11057 | struct bgp_static *bgp_static; | |
11058 | ||
11059 | if (! bgp) | |
11060 | return 0; | |
11061 | ||
11062 | if (p->family != AF_INET) | |
11063 | return 0; | |
11064 | ||
11065 | peer = rinfo->peer; | |
11066 | ||
11067 | if (peer->su.sa.sa_family != AF_INET) | |
11068 | return 0; | |
11069 | ||
11070 | memset (&q, 0, sizeof (struct prefix_ipv4)); | |
11071 | q.family = AF_INET; | |
11072 | q.prefix = peer->su.sin.sin_addr; | |
11073 | q.prefixlen = IPV4_MAX_BITLEN; | |
11074 | ||
11075 | /* Check source address. */ | |
11076 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); | |
11077 | if (rn) | |
11078 | { | |
11079 | bdistance = rn->info; | |
11080 | bgp_unlock_node (rn); | |
11081 | ||
11082 | if (bdistance->access_list) | |
11083 | { | |
11084 | alist = access_list_lookup (AFI_IP, bdistance->access_list); | |
11085 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) | |
11086 | return bdistance->distance; | |
11087 | } | |
11088 | else | |
11089 | return bdistance->distance; | |
11090 | } | |
11091 | ||
11092 | /* Backdoor check. */ | |
11093 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); | |
11094 | if (rn) | |
11095 | { | |
11096 | bgp_static = rn->info; | |
11097 | bgp_unlock_node (rn); | |
11098 | ||
11099 | if (bgp_static->backdoor) | |
11100 | { | |
11101 | if (bgp->distance_local) | |
11102 | return bgp->distance_local; | |
11103 | else | |
11104 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11105 | } | |
11106 | } | |
11107 | ||
11108 | if (peer_sort (peer) == BGP_PEER_EBGP) | |
11109 | { | |
11110 | if (bgp->distance_ebgp) | |
11111 | return bgp->distance_ebgp; | |
11112 | return ZEBRA_EBGP_DISTANCE_DEFAULT; | |
11113 | } | |
11114 | else | |
11115 | { | |
11116 | if (bgp->distance_ibgp) | |
11117 | return bgp->distance_ibgp; | |
11118 | return ZEBRA_IBGP_DISTANCE_DEFAULT; | |
11119 | } | |
11120 | } | |
11121 | ||
11122 | DEFUN (bgp_distance, | |
11123 | bgp_distance_cmd, | |
11124 | "distance bgp <1-255> <1-255> <1-255>", | |
11125 | "Define an administrative distance\n" | |
11126 | "BGP distance\n" | |
11127 | "Distance for routes external to the AS\n" | |
11128 | "Distance for routes internal to the AS\n" | |
11129 | "Distance for local routes\n") | |
11130 | { | |
11131 | struct bgp *bgp; | |
11132 | ||
11133 | bgp = vty->index; | |
11134 | ||
11135 | bgp->distance_ebgp = atoi (argv[0]); | |
11136 | bgp->distance_ibgp = atoi (argv[1]); | |
11137 | bgp->distance_local = atoi (argv[2]); | |
11138 | return CMD_SUCCESS; | |
11139 | } | |
11140 | ||
11141 | DEFUN (no_bgp_distance, | |
11142 | no_bgp_distance_cmd, | |
11143 | "no distance bgp <1-255> <1-255> <1-255>", | |
11144 | NO_STR | |
11145 | "Define an administrative distance\n" | |
11146 | "BGP distance\n" | |
11147 | "Distance for routes external to the AS\n" | |
11148 | "Distance for routes internal to the AS\n" | |
11149 | "Distance for local routes\n") | |
11150 | { | |
11151 | struct bgp *bgp; | |
11152 | ||
11153 | bgp = vty->index; | |
11154 | ||
11155 | bgp->distance_ebgp= 0; | |
11156 | bgp->distance_ibgp = 0; | |
11157 | bgp->distance_local = 0; | |
11158 | return CMD_SUCCESS; | |
11159 | } | |
11160 | ||
11161 | ALIAS (no_bgp_distance, | |
11162 | no_bgp_distance2_cmd, | |
11163 | "no distance bgp", | |
11164 | NO_STR | |
11165 | "Define an administrative distance\n" | |
11166 | "BGP distance\n") | |
11167 | ||
11168 | DEFUN (bgp_distance_source, | |
11169 | bgp_distance_source_cmd, | |
11170 | "distance <1-255> A.B.C.D/M", | |
11171 | "Define an administrative distance\n" | |
11172 | "Administrative distance\n" | |
11173 | "IP source prefix\n") | |
11174 | { | |
11175 | bgp_distance_set (vty, argv[0], argv[1], NULL); | |
11176 | return CMD_SUCCESS; | |
11177 | } | |
11178 | ||
11179 | DEFUN (no_bgp_distance_source, | |
11180 | no_bgp_distance_source_cmd, | |
11181 | "no distance <1-255> A.B.C.D/M", | |
11182 | NO_STR | |
11183 | "Define an administrative distance\n" | |
11184 | "Administrative distance\n" | |
11185 | "IP source prefix\n") | |
11186 | { | |
11187 | bgp_distance_unset (vty, argv[0], argv[1], NULL); | |
11188 | return CMD_SUCCESS; | |
11189 | } | |
11190 | ||
11191 | DEFUN (bgp_distance_source_access_list, | |
11192 | bgp_distance_source_access_list_cmd, | |
11193 | "distance <1-255> A.B.C.D/M WORD", | |
11194 | "Define an administrative distance\n" | |
11195 | "Administrative distance\n" | |
11196 | "IP source prefix\n" | |
11197 | "Access list name\n") | |
11198 | { | |
11199 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); | |
11200 | return CMD_SUCCESS; | |
11201 | } | |
11202 | ||
11203 | DEFUN (no_bgp_distance_source_access_list, | |
11204 | no_bgp_distance_source_access_list_cmd, | |
11205 | "no distance <1-255> A.B.C.D/M WORD", | |
11206 | NO_STR | |
11207 | "Define an administrative distance\n" | |
11208 | "Administrative distance\n" | |
11209 | "IP source prefix\n" | |
11210 | "Access list name\n") | |
11211 | { | |
11212 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); | |
11213 | return CMD_SUCCESS; | |
11214 | } | |
11215 | \f | |
11216 | DEFUN (bgp_damp_set, | |
11217 | bgp_damp_set_cmd, | |
11218 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11219 | "BGP Specific commands\n" | |
11220 | "Enable route-flap dampening\n" | |
11221 | "Half-life time for the penalty\n" | |
11222 | "Value to start reusing a route\n" | |
11223 | "Value to start suppressing a route\n" | |
11224 | "Maximum duration to suppress a stable route\n") | |
11225 | { | |
11226 | struct bgp *bgp; | |
11227 | int half = DEFAULT_HALF_LIFE * 60; | |
11228 | int reuse = DEFAULT_REUSE; | |
11229 | int suppress = DEFAULT_SUPPRESS; | |
11230 | int max = 4 * half; | |
11231 | ||
11232 | if (argc == 4) | |
11233 | { | |
11234 | half = atoi (argv[0]) * 60; | |
11235 | reuse = atoi (argv[1]); | |
11236 | suppress = atoi (argv[2]); | |
11237 | max = atoi (argv[3]) * 60; | |
11238 | } | |
11239 | else if (argc == 1) | |
11240 | { | |
11241 | half = atoi (argv[0]) * 60; | |
11242 | max = 4 * half; | |
11243 | } | |
11244 | ||
11245 | bgp = vty->index; | |
11246 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), | |
11247 | half, reuse, suppress, max); | |
11248 | } | |
11249 | ||
11250 | ALIAS (bgp_damp_set, | |
11251 | bgp_damp_set2_cmd, | |
11252 | "bgp dampening <1-45>", | |
11253 | "BGP Specific commands\n" | |
11254 | "Enable route-flap dampening\n" | |
11255 | "Half-life time for the penalty\n") | |
11256 | ||
11257 | ALIAS (bgp_damp_set, | |
11258 | bgp_damp_set3_cmd, | |
11259 | "bgp dampening", | |
11260 | "BGP Specific commands\n" | |
11261 | "Enable route-flap dampening\n") | |
11262 | ||
11263 | DEFUN (bgp_damp_unset, | |
11264 | bgp_damp_unset_cmd, | |
11265 | "no bgp dampening", | |
11266 | NO_STR | |
11267 | "BGP Specific commands\n" | |
11268 | "Enable route-flap dampening\n") | |
11269 | { | |
11270 | struct bgp *bgp; | |
11271 | ||
11272 | bgp = vty->index; | |
11273 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); | |
11274 | } | |
11275 | ||
11276 | ALIAS (bgp_damp_unset, | |
11277 | bgp_damp_unset2_cmd, | |
11278 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", | |
11279 | NO_STR | |
11280 | "BGP Specific commands\n" | |
11281 | "Enable route-flap dampening\n" | |
11282 | "Half-life time for the penalty\n" | |
11283 | "Value to start reusing a route\n" | |
11284 | "Value to start suppressing a route\n" | |
11285 | "Maximum duration to suppress a stable route\n") | |
11286 | ||
11287 | DEFUN (show_ip_bgp_dampened_paths, | |
11288 | show_ip_bgp_dampened_paths_cmd, | |
11289 | "show ip bgp dampened-paths", | |
11290 | SHOW_STR | |
11291 | IP_STR | |
11292 | BGP_STR | |
11293 | "Display paths suppressed due to dampening\n") | |
11294 | { | |
5a646650 | 11295 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
11296 | NULL); | |
718e3744 | 11297 | } |
11298 | ||
11299 | DEFUN (show_ip_bgp_flap_statistics, | |
11300 | show_ip_bgp_flap_statistics_cmd, | |
11301 | "show ip bgp flap-statistics", | |
11302 | SHOW_STR | |
11303 | IP_STR | |
11304 | BGP_STR | |
11305 | "Display flap statistics of routes\n") | |
11306 | { | |
5a646650 | 11307 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
11308 | bgp_show_type_flap_statistics, NULL); | |
718e3744 | 11309 | } |
11310 | \f | |
11311 | /* Display specified route of BGP table. */ | |
94f2b392 | 11312 | static int |
fd79ac91 | 11313 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
11314 | const char *ip_str, afi_t afi, safi_t safi, | |
11315 | struct prefix_rd *prd, int prefix_check) | |
718e3744 | 11316 | { |
11317 | int ret; | |
11318 | struct prefix match; | |
11319 | struct bgp_node *rn; | |
11320 | struct bgp_node *rm; | |
11321 | struct bgp_info *ri; | |
11322 | struct bgp_info *ri_temp; | |
11323 | struct bgp *bgp; | |
11324 | struct bgp_table *table; | |
11325 | ||
11326 | /* BGP structure lookup. */ | |
11327 | if (view_name) | |
11328 | { | |
11329 | bgp = bgp_lookup_by_name (view_name); | |
11330 | if (bgp == NULL) | |
11331 | { | |
11332 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); | |
11333 | return CMD_WARNING; | |
11334 | } | |
11335 | } | |
11336 | else | |
11337 | { | |
11338 | bgp = bgp_get_default (); | |
11339 | if (bgp == NULL) | |
11340 | { | |
11341 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
11342 | return CMD_WARNING; | |
11343 | } | |
11344 | } | |
11345 | ||
11346 | /* Check IP address argument. */ | |
11347 | ret = str2prefix (ip_str, &match); | |
11348 | if (! ret) | |
11349 | { | |
11350 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
11351 | return CMD_WARNING; | |
11352 | } | |
11353 | ||
11354 | match.family = afi2family (afi); | |
11355 | ||
11356 | if (safi == SAFI_MPLS_VPN) | |
11357 | { | |
11358 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) | |
11359 | { | |
11360 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
11361 | continue; | |
11362 | ||
11363 | if ((table = rn->info) != NULL) | |
11364 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
6c88b44d CC |
11365 | { |
11366 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) | |
11367 | { | |
11368 | ri = rm->info; | |
11369 | while (ri) | |
11370 | { | |
11371 | if (ri->extra && ri->extra->damp_info) | |
11372 | { | |
11373 | ri_temp = ri->next; | |
11374 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
11375 | ri = ri_temp; | |
11376 | } | |
11377 | else | |
11378 | ri = ri->next; | |
11379 | } | |
11380 | } | |
11381 | ||
11382 | bgp_unlock_node (rm); | |
11383 | } | |
718e3744 | 11384 | } |
11385 | } | |
11386 | else | |
11387 | { | |
11388 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) | |
6c88b44d CC |
11389 | { |
11390 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) | |
11391 | { | |
11392 | ri = rn->info; | |
11393 | while (ri) | |
11394 | { | |
11395 | if (ri->extra && ri->extra->damp_info) | |
11396 | { | |
11397 | ri_temp = ri->next; | |
11398 | bgp_damp_info_free (ri->extra->damp_info, 1); | |
11399 | ri = ri_temp; | |
11400 | } | |
11401 | else | |
11402 | ri = ri->next; | |
11403 | } | |
11404 | } | |
11405 | ||
11406 | bgp_unlock_node (rn); | |
11407 | } | |
718e3744 | 11408 | } |
11409 | ||
11410 | return CMD_SUCCESS; | |
11411 | } | |
11412 | ||
11413 | DEFUN (clear_ip_bgp_dampening, | |
11414 | clear_ip_bgp_dampening_cmd, | |
11415 | "clear ip bgp dampening", | |
11416 | CLEAR_STR | |
11417 | IP_STR | |
11418 | BGP_STR | |
11419 | "Clear route flap dampening information\n") | |
11420 | { | |
11421 | bgp_damp_info_clean (); | |
11422 | return CMD_SUCCESS; | |
11423 | } | |
11424 | ||
11425 | DEFUN (clear_ip_bgp_dampening_prefix, | |
11426 | clear_ip_bgp_dampening_prefix_cmd, | |
11427 | "clear ip bgp dampening A.B.C.D/M", | |
11428 | CLEAR_STR | |
11429 | IP_STR | |
11430 | BGP_STR | |
11431 | "Clear route flap dampening information\n" | |
11432 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") | |
11433 | { | |
11434 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
11435 | SAFI_UNICAST, NULL, 1); | |
11436 | } | |
11437 | ||
11438 | DEFUN (clear_ip_bgp_dampening_address, | |
11439 | clear_ip_bgp_dampening_address_cmd, | |
11440 | "clear ip bgp dampening A.B.C.D", | |
11441 | CLEAR_STR | |
11442 | IP_STR | |
11443 | BGP_STR | |
11444 | "Clear route flap dampening information\n" | |
11445 | "Network to clear damping information\n") | |
11446 | { | |
11447 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, | |
11448 | SAFI_UNICAST, NULL, 0); | |
11449 | } | |
11450 | ||
11451 | DEFUN (clear_ip_bgp_dampening_address_mask, | |
11452 | clear_ip_bgp_dampening_address_mask_cmd, | |
11453 | "clear ip bgp dampening A.B.C.D A.B.C.D", | |
11454 | CLEAR_STR | |
11455 | IP_STR | |
11456 | BGP_STR | |
11457 | "Clear route flap dampening information\n" | |
11458 | "Network to clear damping information\n" | |
11459 | "Network mask\n") | |
11460 | { | |
11461 | int ret; | |
11462 | char prefix_str[BUFSIZ]; | |
11463 | ||
11464 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); | |
11465 | if (! ret) | |
11466 | { | |
11467 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); | |
11468 | return CMD_WARNING; | |
11469 | } | |
11470 | ||
11471 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, | |
11472 | SAFI_UNICAST, NULL, 0); | |
11473 | } | |
11474 | \f | |
94f2b392 | 11475 | static int |
718e3744 | 11476 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
11477 | afi_t afi, safi_t safi, int *write) | |
11478 | { | |
11479 | struct bgp_node *prn; | |
11480 | struct bgp_node *rn; | |
11481 | struct bgp_table *table; | |
11482 | struct prefix *p; | |
11483 | struct prefix_rd *prd; | |
11484 | struct bgp_static *bgp_static; | |
11485 | u_int32_t label; | |
11486 | char buf[SU_ADDRSTRLEN]; | |
11487 | char rdbuf[RD_ADDRSTRLEN]; | |
11488 | ||
11489 | /* Network configuration. */ | |
11490 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) | |
11491 | if ((table = prn->info) != NULL) | |
11492 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
11493 | if ((bgp_static = rn->info) != NULL) | |
11494 | { | |
11495 | p = &rn->p; | |
11496 | prd = (struct prefix_rd *) &prn->p; | |
11497 | ||
11498 | /* "address-family" display. */ | |
11499 | bgp_config_write_family_header (vty, afi, safi, write); | |
11500 | ||
11501 | /* "network" configuration display. */ | |
11502 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); | |
11503 | label = decode_label (bgp_static->tag); | |
11504 | ||
11505 | vty_out (vty, " network %s/%d rd %s tag %d", | |
11506 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
11507 | p->prefixlen, | |
11508 | rdbuf, label); | |
11509 | vty_out (vty, "%s", VTY_NEWLINE); | |
11510 | } | |
11511 | return 0; | |
11512 | } | |
11513 | ||
11514 | /* Configuration of static route announcement and aggregate | |
11515 | information. */ | |
11516 | int | |
11517 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, | |
11518 | afi_t afi, safi_t safi, int *write) | |
11519 | { | |
11520 | struct bgp_node *rn; | |
11521 | struct prefix *p; | |
11522 | struct bgp_static *bgp_static; | |
11523 | struct bgp_aggregate *bgp_aggregate; | |
11524 | char buf[SU_ADDRSTRLEN]; | |
11525 | ||
11526 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
11527 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); | |
11528 | ||
11529 | /* Network configuration. */ | |
11530 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) | |
11531 | if ((bgp_static = rn->info) != NULL) | |
11532 | { | |
11533 | p = &rn->p; | |
11534 | ||
11535 | /* "address-family" display. */ | |
11536 | bgp_config_write_family_header (vty, afi, safi, write); | |
11537 | ||
11538 | /* "network" configuration display. */ | |
11539 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
11540 | { | |
11541 | u_int32_t destination; | |
11542 | struct in_addr netmask; | |
11543 | ||
11544 | destination = ntohl (p->u.prefix4.s_addr); | |
11545 | masklen2ip (p->prefixlen, &netmask); | |
11546 | vty_out (vty, " network %s", | |
11547 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); | |
11548 | ||
11549 | if ((IN_CLASSC (destination) && p->prefixlen == 24) | |
11550 | || (IN_CLASSB (destination) && p->prefixlen == 16) | |
11551 | || (IN_CLASSA (destination) && p->prefixlen == 8) | |
11552 | || p->u.prefix4.s_addr == 0) | |
11553 | { | |
11554 | /* Natural mask is not display. */ | |
11555 | } | |
11556 | else | |
11557 | vty_out (vty, " mask %s", inet_ntoa (netmask)); | |
11558 | } | |
11559 | else | |
11560 | { | |
11561 | vty_out (vty, " network %s/%d", | |
11562 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
11563 | p->prefixlen); | |
11564 | } | |
11565 | ||
11566 | if (bgp_static->rmap.name) | |
11567 | vty_out (vty, " route-map %s", bgp_static->rmap.name); | |
41367172 PJ |
11568 | else |
11569 | { | |
11570 | if (bgp_static->backdoor) | |
11571 | vty_out (vty, " backdoor"); | |
11572 | if (bgp_static->ttl) | |
11573 | vty_out (vty, " pathlimit %u", bgp_static->ttl); | |
11574 | } | |
718e3744 | 11575 | |
11576 | vty_out (vty, "%s", VTY_NEWLINE); | |
11577 | } | |
11578 | ||
11579 | /* Aggregate-address configuration. */ | |
11580 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) | |
11581 | if ((bgp_aggregate = rn->info) != NULL) | |
11582 | { | |
11583 | p = &rn->p; | |
11584 | ||
11585 | /* "address-family" display. */ | |
11586 | bgp_config_write_family_header (vty, afi, safi, write); | |
11587 | ||
11588 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) | |
11589 | { | |
11590 | struct in_addr netmask; | |
11591 | ||
11592 | masklen2ip (p->prefixlen, &netmask); | |
11593 | vty_out (vty, " aggregate-address %s %s", | |
11594 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
11595 | inet_ntoa (netmask)); | |
11596 | } | |
11597 | else | |
11598 | { | |
11599 | vty_out (vty, " aggregate-address %s/%d", | |
11600 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), | |
11601 | p->prefixlen); | |
11602 | } | |
11603 | ||
11604 | if (bgp_aggregate->as_set) | |
11605 | vty_out (vty, " as-set"); | |
11606 | ||
11607 | if (bgp_aggregate->summary_only) | |
11608 | vty_out (vty, " summary-only"); | |
11609 | ||
11610 | vty_out (vty, "%s", VTY_NEWLINE); | |
11611 | } | |
11612 | ||
11613 | return 0; | |
11614 | } | |
11615 | ||
11616 | int | |
11617 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) | |
11618 | { | |
11619 | struct bgp_node *rn; | |
11620 | struct bgp_distance *bdistance; | |
11621 | ||
11622 | /* Distance configuration. */ | |
11623 | if (bgp->distance_ebgp | |
11624 | && bgp->distance_ibgp | |
11625 | && bgp->distance_local | |
11626 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT | |
11627 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT | |
11628 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) | |
11629 | vty_out (vty, " distance bgp %d %d %d%s", | |
11630 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, | |
11631 | VTY_NEWLINE); | |
11632 | ||
11633 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) | |
11634 | if ((bdistance = rn->info) != NULL) | |
11635 | { | |
11636 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, | |
11637 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
11638 | bdistance->access_list ? bdistance->access_list : "", | |
11639 | VTY_NEWLINE); | |
11640 | } | |
11641 | ||
11642 | return 0; | |
11643 | } | |
11644 | ||
11645 | /* Allocate routing table structure and install commands. */ | |
11646 | void | |
66e5cd87 | 11647 | bgp_route_init (void) |
718e3744 | 11648 | { |
11649 | /* Init BGP distance table. */ | |
64e580a7 | 11650 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
718e3744 | 11651 | |
11652 | /* IPv4 BGP commands. */ | |
11653 | install_element (BGP_NODE, &bgp_network_cmd); | |
11654 | install_element (BGP_NODE, &bgp_network_mask_cmd); | |
11655 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); | |
11656 | install_element (BGP_NODE, &bgp_network_route_map_cmd); | |
11657 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); | |
11658 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); | |
11659 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); | |
11660 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); | |
11661 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); | |
41367172 PJ |
11662 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
11663 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); | |
11664 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); | |
11665 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); | |
11666 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
11667 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); | |
718e3744 | 11668 | install_element (BGP_NODE, &no_bgp_network_cmd); |
11669 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); | |
11670 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); | |
11671 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); | |
11672 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); | |
11673 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
11674 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); | |
11675 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); | |
11676 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); | |
41367172 PJ |
11677 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
11678 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); | |
11679 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
11680 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
11681 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
11682 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); | |
718e3744 | 11683 | |
11684 | install_element (BGP_NODE, &aggregate_address_cmd); | |
11685 | install_element (BGP_NODE, &aggregate_address_mask_cmd); | |
11686 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); | |
11687 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); | |
11688 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); | |
11689 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); | |
11690 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); | |
11691 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
11692 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); | |
11693 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
11694 | install_element (BGP_NODE, &no_aggregate_address_cmd); | |
11695 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); | |
11696 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); | |
11697 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); | |
11698 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); | |
11699 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); | |
11700 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
11701 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); | |
11702 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
11703 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
11704 | ||
11705 | /* IPv4 unicast configuration. */ | |
11706 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); | |
11707 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); | |
11708 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); | |
11709 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); | |
11710 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); | |
11711 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); | |
41367172 PJ |
11712 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
11713 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); | |
11714 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); | |
11715 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); | |
11716 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
11717 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); | |
718e3744 | 11718 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
11719 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); | |
11720 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); | |
11721 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); | |
11722 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
41367172 PJ |
11723 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
11724 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); | |
11725 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
11726 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
11727 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
11728 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); | |
718e3744 | 11729 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
11730 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); | |
11731 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); | |
11732 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); | |
11733 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); | |
11734 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); | |
11735 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); | |
11736 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
11737 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); | |
11738 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
11739 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); | |
11740 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); | |
11741 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); | |
11742 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); | |
11743 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); | |
11744 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); | |
11745 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
11746 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); | |
11747 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
11748 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
11749 | ||
11750 | /* IPv4 multicast configuration. */ | |
11751 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); | |
11752 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); | |
11753 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); | |
11754 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); | |
11755 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); | |
11756 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); | |
41367172 PJ |
11757 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
11758 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); | |
11759 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); | |
11760 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); | |
11761 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); | |
11762 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); | |
718e3744 | 11763 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
11764 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); | |
11765 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); | |
11766 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); | |
11767 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); | |
11768 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); | |
41367172 PJ |
11769 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
11770 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); | |
11771 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); | |
11772 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); | |
11773 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); | |
11774 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); | |
718e3744 | 11775 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
11776 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); | |
11777 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); | |
11778 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); | |
11779 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); | |
11780 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); | |
11781 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); | |
11782 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); | |
11783 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); | |
11784 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); | |
11785 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); | |
11786 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); | |
11787 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); | |
11788 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); | |
11789 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); | |
11790 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); | |
11791 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); | |
11792 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); | |
11793 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); | |
11794 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); | |
11795 | ||
11796 | install_element (VIEW_NODE, &show_ip_bgp_cmd); | |
11797 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); | |
11798 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); | |
11799 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); | |
11800 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); | |
11801 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
11802 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); | |
11803 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
11804 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); | |
11805 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
11806 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); | |
11807 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); | |
11808 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); | |
11809 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); | |
11810 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
11811 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); | |
11812 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
11813 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); | |
11814 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
11815 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); | |
11816 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
11817 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); | |
11818 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
11819 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); | |
11820 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
11821 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); | |
11822 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); | |
11823 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); | |
11824 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); | |
11825 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); | |
11826 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
11827 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
11828 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
11829 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); | |
11830 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); | |
11831 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); | |
11832 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); | |
11833 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
11834 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
11835 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
11836 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
11837 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); | |
11838 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
11839 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); | |
11840 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
11841 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); | |
11842 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
11843 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
11844 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
11845 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
11846 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
11847 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); | |
11848 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
11849 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
11850 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
11851 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); | |
11852 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); | |
11853 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); | |
11854 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); | |
11855 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
11856 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); | |
11857 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
11858 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
11859 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
11860 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); | |
11861 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
11862 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 11863 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
11864 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); | |
11865 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); | |
2a71e9ce TP |
11866 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
11867 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 11868 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
11869 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); | |
11870 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); | |
62687ff1 PJ |
11871 | |
11872 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ | |
11873 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); | |
11874 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); | |
11875 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
11876 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); | |
11877 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
11878 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); | |
11879 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
11880 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); | |
11881 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); | |
11882 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); | |
11883 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); | |
11884 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); | |
11885 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); | |
11886 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); | |
11887 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
11888 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
11889 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
11890 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); | |
11891 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); | |
11892 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); | |
11893 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); | |
11894 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
11895 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
11896 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
11897 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
11898 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); | |
11899 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); | |
11900 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); | |
11901 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); | |
718e3744 | 11902 | |
11903 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); | |
11904 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); | |
11905 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); | |
11906 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); | |
11907 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); | |
11908 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); | |
11909 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); | |
11910 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); | |
11911 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); | |
11912 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); | |
11913 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); | |
11914 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); | |
11915 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); | |
11916 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); | |
11917 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); | |
11918 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); | |
11919 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); | |
11920 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); | |
11921 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); | |
11922 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); | |
11923 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); | |
11924 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); | |
11925 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); | |
11926 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); | |
11927 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); | |
11928 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); | |
11929 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); | |
11930 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); | |
11931 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); | |
11932 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); | |
11933 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); | |
11934 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); | |
11935 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); | |
11936 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); | |
11937 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); | |
11938 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); | |
11939 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); | |
11940 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); | |
11941 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); | |
11942 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); | |
11943 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); | |
11944 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); | |
11945 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); | |
11946 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); | |
11947 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); | |
11948 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); | |
11949 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); | |
11950 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); | |
11951 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); | |
11952 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); | |
11953 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); | |
11954 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); | |
11955 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); | |
11956 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); | |
11957 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); | |
11958 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); | |
11959 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); | |
11960 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); | |
11961 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); | |
11962 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); | |
11963 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); | |
11964 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); | |
11965 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); | |
11966 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); | |
11967 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); | |
11968 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); | |
11969 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); | |
fee0f4c6 | 11970 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
11971 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); | |
11972 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); | |
2a71e9ce TP |
11973 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
11974 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); | |
fee0f4c6 | 11975 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
11976 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); | |
11977 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); | |
718e3744 | 11978 | |
11979 | /* BGP dampening clear commands */ | |
11980 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); | |
11981 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); | |
11982 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); | |
11983 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); | |
11984 | ||
ff7924f6 PJ |
11985 | /* prefix count */ |
11986 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); | |
11987 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); | |
11988 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); | |
718e3744 | 11989 | #ifdef HAVE_IPV6 |
ff7924f6 PJ |
11990 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
11991 | ||
718e3744 | 11992 | /* New config IPv6 BGP commands. */ |
11993 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); | |
11994 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); | |
41367172 | 11995 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
718e3744 | 11996 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
11997 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); | |
41367172 | 11998 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
718e3744 | 11999 | |
12000 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); | |
12001 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); | |
12002 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); | |
12003 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); | |
12004 | ||
12005 | /* Old config IPv6 BGP commands. */ | |
12006 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); | |
12007 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); | |
12008 | ||
12009 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); | |
12010 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); | |
12011 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); | |
12012 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); | |
12013 | ||
12014 | install_element (VIEW_NODE, &show_bgp_cmd); | |
12015 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); | |
12016 | install_element (VIEW_NODE, &show_bgp_route_cmd); | |
12017 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); | |
12018 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); | |
12019 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); | |
12020 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); | |
12021 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); | |
12022 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); | |
12023 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12024 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); | |
12025 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12026 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); | |
12027 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); | |
12028 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); | |
12029 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); | |
12030 | install_element (VIEW_NODE, &show_bgp_community_cmd); | |
12031 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); | |
12032 | install_element (VIEW_NODE, &show_bgp_community2_cmd); | |
12033 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); | |
12034 | install_element (VIEW_NODE, &show_bgp_community3_cmd); | |
12035 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); | |
12036 | install_element (VIEW_NODE, &show_bgp_community4_cmd); | |
12037 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); | |
12038 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); | |
12039 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12040 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); | |
12041 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12042 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); | |
12043 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12044 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); | |
12045 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12046 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); | |
12047 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); | |
12048 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); | |
12049 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12050 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); | |
12051 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12052 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12053 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12054 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12055 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12056 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); | |
12057 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12058 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12059 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12060 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
12061 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12062 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); | |
12063 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12064 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
12065 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); | |
12066 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); | |
bb46e94f | 12067 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
12068 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); | |
12069 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); | |
12070 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); | |
12071 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); | |
12072 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12073 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12074 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12075 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12076 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12077 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12078 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12079 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12080 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12081 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12082 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12083 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12084 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12085 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
12086 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); | |
12087 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); | |
62687ff1 PJ |
12088 | |
12089 | /* Restricted: | |
12090 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) | |
12091 | */ | |
12092 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); | |
12093 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); | |
12094 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); | |
12095 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); | |
12096 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); | |
12097 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); | |
12098 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); | |
12099 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); | |
12100 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); | |
12101 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); | |
12102 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); | |
12103 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); | |
12104 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); | |
12105 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12106 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); | |
12107 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12108 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); | |
12109 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12110 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); | |
12111 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12112 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); | |
12113 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); | |
12114 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); | |
12115 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); | |
12116 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); | |
12117 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12118 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12119 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12120 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); | |
12121 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); | |
718e3744 | 12122 | |
12123 | install_element (ENABLE_NODE, &show_bgp_cmd); | |
12124 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); | |
12125 | install_element (ENABLE_NODE, &show_bgp_route_cmd); | |
12126 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); | |
12127 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); | |
12128 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); | |
12129 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); | |
12130 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); | |
12131 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); | |
12132 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); | |
12133 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); | |
12134 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); | |
12135 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); | |
12136 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); | |
12137 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); | |
12138 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); | |
12139 | install_element (ENABLE_NODE, &show_bgp_community_cmd); | |
12140 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); | |
12141 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); | |
12142 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); | |
12143 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); | |
12144 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); | |
12145 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); | |
12146 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); | |
12147 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); | |
12148 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); | |
12149 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); | |
12150 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); | |
12151 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); | |
12152 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); | |
12153 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); | |
12154 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); | |
12155 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); | |
12156 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); | |
12157 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); | |
12158 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); | |
12159 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); | |
12160 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); | |
12161 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); | |
12162 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); | |
12163 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); | |
12164 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); | |
12165 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); | |
12166 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); | |
12167 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); | |
12168 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); | |
bb46e94f | 12169 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
12170 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); | |
12171 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); | |
12172 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12173 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
12174 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); | |
12175 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); | |
bb46e94f | 12176 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
12177 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); | |
12178 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); | |
12179 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); | |
12180 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); | |
12181 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); | |
12182 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); | |
12183 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); | |
12184 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); | |
12185 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); | |
12186 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); | |
12187 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); | |
12188 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); | |
12189 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); | |
12190 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); | |
12191 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); | |
12192 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); | |
12193 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); | |
fee0f4c6 | 12194 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
12195 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); | |
12196 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); | |
2815e61f PJ |
12197 | |
12198 | /* Statistics */ | |
12199 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); | |
12200 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); | |
12201 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); | |
12202 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); | |
12203 | ||
718e3744 | 12204 | /* old command */ |
12205 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); | |
12206 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); | |
12207 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); | |
12208 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); | |
12209 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12210 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12211 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); | |
12212 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); | |
12213 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); | |
12214 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); | |
12215 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); | |
12216 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12217 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12218 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12219 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12220 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); | |
12221 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12222 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12223 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); | |
12224 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); | |
12225 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12226 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12227 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12228 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12229 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12230 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); | |
12231 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); | |
12232 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); | |
12233 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); | |
12234 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12235 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12236 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12237 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12238 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12239 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
12240 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
bb46e94f | 12241 | |
718e3744 | 12242 | /* old command */ |
12243 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); | |
12244 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); | |
12245 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); | |
12246 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); | |
12247 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); | |
12248 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); | |
12249 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); | |
12250 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); | |
12251 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); | |
12252 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); | |
12253 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); | |
12254 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); | |
12255 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); | |
12256 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); | |
12257 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); | |
12258 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); | |
12259 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); | |
12260 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); | |
12261 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); | |
12262 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); | |
12263 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); | |
12264 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); | |
12265 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); | |
12266 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); | |
12267 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); | |
12268 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); | |
12269 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); | |
12270 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); | |
12271 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); | |
12272 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); | |
12273 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); | |
12274 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); | |
12275 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); | |
12276 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); | |
12277 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); | |
12278 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); | |
12279 | ||
12280 | /* old command */ | |
12281 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
12282 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); | |
12283 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
12284 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); | |
12285 | ||
12286 | /* old command */ | |
12287 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
12288 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); | |
12289 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
12290 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); | |
12291 | ||
12292 | /* old command */ | |
12293 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
12294 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); | |
12295 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
12296 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); | |
12297 | #endif /* HAVE_IPV6 */ | |
12298 | ||
12299 | install_element (BGP_NODE, &bgp_distance_cmd); | |
12300 | install_element (BGP_NODE, &no_bgp_distance_cmd); | |
12301 | install_element (BGP_NODE, &no_bgp_distance2_cmd); | |
12302 | install_element (BGP_NODE, &bgp_distance_source_cmd); | |
12303 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); | |
12304 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); | |
12305 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); | |
12306 | ||
12307 | install_element (BGP_NODE, &bgp_damp_set_cmd); | |
12308 | install_element (BGP_NODE, &bgp_damp_set2_cmd); | |
12309 | install_element (BGP_NODE, &bgp_damp_set3_cmd); | |
12310 | install_element (BGP_NODE, &bgp_damp_unset_cmd); | |
12311 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); | |
12312 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); | |
12313 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); | |
12314 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); | |
12315 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); | |
12316 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); | |
12317 | } | |
228da428 CC |
12318 | |
12319 | void | |
12320 | bgp_route_finish (void) | |
12321 | { | |
12322 | bgp_table_unlock (bgp_distance_table); | |
12323 | bgp_distance_table = NULL; | |
12324 | } |